From 452f9aab72a8c9341e1f85f2df940e001dc08cbd Mon Sep 17 00:00:00 2001 From: stephanbreimann Date: Mon, 25 Sep 2023 17:37:21 +0200 Subject: [PATCH] Change ut.check_non_negative_number to ut.check_number_range --- aaanalysis/__init__.py | 6 +- .../__pycache__/__init__.cpython-39.pyc | Bin 713 -> 713 bytes aaanalysis/__pycache__/utils.cpython-39.pyc | Bin 14981 -> 14975 bytes .../__pycache__/_utils_check.cpython-39.pyc | Bin 4218 -> 4212 bytes .../__pycache__/utils_cpp.cpython-39.pyc | Bin 10659 -> 10634 bytes aaanalysis/_utils/_utils_check.py | 32 +- aaanalysis/_utils/utils_cpp.py | 18 +- .../cpp/__pycache__/_cpp.cpython-39.pyc | Bin 26744 -> 26737 bytes .../__pycache__/_feature_pos.cpython-39.pyc | Bin 3725 -> 3718 bytes aaanalysis/cpp/__pycache__/cpp.cpython-39.pyc | Bin 12623 -> 12616 bytes .../cpp/__pycache__/cpp_plot.cpython-39.pyc | Bin 25949 -> 25887 bytes .../cpp/__pycache__/feature.cpython-39.pyc | Bin 25070 -> 25063 bytes aaanalysis/cpp/_cpp.py | 8 +- aaanalysis/cpp/_feature_pos.py | 2 +- aaanalysis/cpp/cpp.py | 10 +- aaanalysis/cpp/cpp_plot.py | 39 +- aaanalysis/cpp/feature.py | 8 +- .../__pycache__/load_dataset_.cpython-39.pyc | Bin 9129 -> 9122 bytes .../__pycache__/load_scales_.cpython-39.pyc | Bin 6016 -> 6009 bytes aaanalysis/data_loader/load_dataset_.py | 8 +- aaanalysis/data_loader/load_scales_.py | 2 +- .../__pycache__/dpulearn.cpython-39.pyc | Bin 12057 -> 12050 bytes aaanalysis/dpulearn/dpulearn.py | 2 +- aaanalysis/plotting/__init__.py | 16 +- .../__pycache__/__init__.cpython-39.pyc | Bin 411 -> 598 bytes .../__pycache__/plot_gcfs_.cpython-39.pyc | Bin 0 -> 548 bytes .../plot_get_cdict_.cpython-39.pyc | Bin 0 -> 1132 bytes .../__pycache__/plot_get_cmap_.cpython-39.pyc | Bin 0 -> 4913 bytes .../plot_set_legend_.cpython-39.pyc | Bin 0 -> 4997 bytes .../__pycache__/plot_settings_.cpython-39.pyc | Bin 0 -> 6862 bytes .../plotting_functions.cpython-39.pyc | Bin 16895 -> 0 bytes aaanalysis/plotting/plot_gcfs_.py | 12 + aaanalysis/plotting/plot_get_cdict_.py | 34 ++ aaanalysis/plotting/plot_get_cmap_.py | 141 +++++ aaanalysis/plotting/plot_set_legend_.py | 158 +++++ aaanalysis/plotting/plot_settings_.py | 217 +++++++ aaanalysis/plotting/plotting_functions.py | 542 ------------------ aaanalysis/utils.py | 7 +- .../aaanalysis-plot_settings-2.py | 2 + .../aaanalysis-plot_get_cmap-1.py | 2 + .../generated/aaanalysis-plot_get_cmap-1.py | 2 + .../generated/aaanalysis-plot_settings-2.py | 2 + .../08f18bcc6e95a855/08a8943010657a68 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/0f8c06e51312863b | Bin 0 -> 26 bytes .../08f18bcc6e95a855/1c250cdc9b08f1d7 | Bin 0 -> 24 bytes .../08f18bcc6e95a855/2328c0eb29579fb9 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/48823cffadcf5186 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/5dc6257654107074 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/6593a69b4839cb20 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/88c8de4e225144f7 | Bin 0 -> 24 bytes .../08f18bcc6e95a855/892e20e928f1e99f | Bin 0 -> 26 bytes .../08f18bcc6e95a855/9d54e309a9b7e2d0 | Bin 0 -> 24 bytes .../08f18bcc6e95a855/9f56f6bb6cd962f7 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/af8b5b8a3bd85066 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/bc2c53100ac18631 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/cabcde271069ed73 | Bin 0 -> 29 bytes .../08f18bcc6e95a855/cac54aaab9476b06 | Bin 0 -> 26 bytes .../e7ef3b694c2376e5 | Bin .../08f18bcc6e95a855/ec6b451ee15ebb30 | Bin 0 -> 26 bytes .../08f18bcc6e95a855/f68995865845a314 | Bin 0 -> 24 bytes .../08f18bcc6e95a855/ff510f536a8ab63a | Bin 0 -> 24 bytes .../08f18bcc6e95a855/ffc6bbdfc14bbbde | Bin 0 -> 24 bytes .../294991fa193c7e4b/38b060a751ac9638 | 0 .../34a18a217fcd3d50/ff9999a1befa9f7c | Bin 0 -> 24 bytes .../79dc6ff64864796e/bec021b4f368e306 | Bin 0 -> 1 bytes .../bd70ae7e97dc433b/364d5aa9cae93350 | Bin 0 -> 12 bytes .../bd70ae7e97dc433b/394341b7182cd227 | Bin 0 -> 4 bytes .../bd70ae7e97dc433b/442eca218c0f2ae4 | Bin 0 -> 4 bytes .../bd70ae7e97dc433b/8fb29073d75ebc7d | Bin 0 -> 2 bytes .../bd70ae7e97dc433b/b871280c1cf29d7a | Bin 0 -> 7 bytes .../bd70ae7e97dc433b/e3cd28f00d196b82 | Bin 0 -> 12 bytes .../f39290ea0f49a551/e7ef3b694c2376e5 | Bin 31 -> 0 bytes .../f39290ea0f49a551/ff9999a1befa9f7c | Bin 0 -> 24 bytes .../unicode_data/13.0.0/codec-utf-8.json.gz | Bin 60 -> 60 bytes ...plot_get_cdict.cpython-39-pytest-7.4.2.pyc | Bin 3024 -> 3124 bytes ..._plot_get_cmap.cpython-39-pytest-7.4.2.pyc | Bin 7464 -> 7510 bytes .../test_plot_get_cdict.py | 10 +- .../test_plot_get_cmap.py | 1 + 78 files changed, 661 insertions(+), 620 deletions(-) create mode 100644 aaanalysis/plotting/__pycache__/plot_gcfs_.cpython-39.pyc create mode 100644 aaanalysis/plotting/__pycache__/plot_get_cdict_.cpython-39.pyc create mode 100644 aaanalysis/plotting/__pycache__/plot_get_cmap_.cpython-39.pyc create mode 100644 aaanalysis/plotting/__pycache__/plot_set_legend_.cpython-39.pyc create mode 100644 aaanalysis/plotting/__pycache__/plot_settings_.cpython-39.pyc delete mode 100644 aaanalysis/plotting/__pycache__/plotting_functions.cpython-39.pyc create mode 100644 aaanalysis/plotting/plot_gcfs_.py create mode 100644 aaanalysis/plotting/plot_get_cdict_.py create mode 100644 aaanalysis/plotting/plot_get_cmap_.py create mode 100644 aaanalysis/plotting/plot_set_legend_.py create mode 100644 aaanalysis/plotting/plot_settings_.py delete mode 100644 aaanalysis/plotting/plotting_functions.py create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/08a8943010657a68 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/0f8c06e51312863b create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/1c250cdc9b08f1d7 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/2328c0eb29579fb9 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/48823cffadcf5186 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/5dc6257654107074 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/6593a69b4839cb20 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/88c8de4e225144f7 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/892e20e928f1e99f create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/9d54e309a9b7e2d0 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/9f56f6bb6cd962f7 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/af8b5b8a3bd85066 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/bc2c53100ac18631 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/cabcde271069ed73 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/cac54aaab9476b06 rename tests/unit/.hypothesis/examples/{34a18a217fcd3d50 => 08f18bcc6e95a855}/e7ef3b694c2376e5 (100%) create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/ec6b451ee15ebb30 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/f68995865845a314 create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/ff510f536a8ab63a create mode 100644 tests/unit/.hypothesis/examples/08f18bcc6e95a855/ffc6bbdfc14bbbde create mode 100644 tests/unit/.hypothesis/examples/294991fa193c7e4b/38b060a751ac9638 create mode 100644 tests/unit/.hypothesis/examples/34a18a217fcd3d50/ff9999a1befa9f7c create mode 100644 tests/unit/.hypothesis/examples/79dc6ff64864796e/bec021b4f368e306 create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/364d5aa9cae93350 create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/394341b7182cd227 create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/442eca218c0f2ae4 create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/8fb29073d75ebc7d create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/b871280c1cf29d7a create mode 100644 tests/unit/.hypothesis/examples/bd70ae7e97dc433b/e3cd28f00d196b82 delete mode 100644 tests/unit/.hypothesis/examples/f39290ea0f49a551/e7ef3b694c2376e5 create mode 100644 tests/unit/.hypothesis/examples/f39290ea0f49a551/ff9999a1befa9f7c diff --git a/aaanalysis/__init__.py b/aaanalysis/__init__.py index b31e9569..bf55eff8 100644 --- a/aaanalysis/__init__.py +++ b/aaanalysis/__init__.py @@ -2,9 +2,11 @@ from aaanalysis.aaclust import AAclust from aaanalysis.cpp import CPP, CPPPlot, SequenceFeature, SplitRange from aaanalysis.dpulearn import dPULearn -from aaanalysis.plotting import plot_settings, plot_set_legend, plot_gcfs, plot_get_cmap, plot_get_cdict +from aaanalysis.plotting import (plot_settings, plot_set_legend, plot_gcfs, + plot_get_cmap, plot_get_cdict) __all__ = ["load_dataset", "load_scales", "AAclust", "CPP", "CPPPlot", "SequenceFeature", "SplitRange", "dPULearn", - "plot_settings", "plot_set_legend", "plot_gcfs", "plot_get_cmap", "plot_get_cdict"] + "plot_get_cmap", "plot_get_cdict", + "plot_settings", "plot_set_legend", "plot_gcfs"] diff --git a/aaanalysis/__pycache__/__init__.cpython-39.pyc b/aaanalysis/__pycache__/__init__.cpython-39.pyc index 22e71d846c419d25c08723d9f21dd4d63a62054a..d261c1f87fc9ec2b218d74ad33d8268cacbf258d 100644 GIT binary patch delta 51 xcmX@fdXkklk(ZZ?0SI=?6-*7@$eY0^$_wNb@qq}CL=iWL;Mv^8XvfIN3;+sI2@U`N delta 33 ncmX@fdXkklk(ZZ?0SM}53Z|-Vx(2+P3~ZA^|jw7f~YDH&W2 z^+@5^7~hLdEw2|3-i+`HJl5Nuzbed?xmr>$Wc``O=AbC|p8Wtu9Yk<0gA1*IfO#}J z1;kxo%`JwByi73XZDt)%pXbo2UNGmD3dd1)7=FsL>VqQsE21SVMlj{OY)A0zFv2ke zT4s5L6oo>6{;jf&lDJ193Cm`>9Hvw@B7R52 zgk=ll8f`9&5@pUjF(@i4MdYD%iGNSg0^(k{QCN{WZ|q^L34SfKu{Ovmim*d4UR0Xb zB_e_}$q-EVx+o^dqz(97Q;ZU_yw%DRT)MfGKlb#TX7y zht8r!tLLb46{|->d?dC256v~~;!R_z#)?HsGG4pPTJCEa6ZB4~FPmcr;Xzp;C6`5m z2}_fWdVmUFSJiBa5aaP$xNdR4v}K>^Y5N#JY8(7vsnXF#B4Du=>1bmUu*ST!=VxW28Pmh*GjWO-NHo0!qPscF>-B? zQwM`+`^FC0+LKg zk3}N`BO9Jkzq;WCXP;1q$F+sj(WwshyFBertHN68Dp}sPR%x%#6X@*l@ljlwN^%LU zy#gFMWs{I>uPi!z75;W@EBOpvq-evkqS5UIPqmB9rv|HswJ+f&9%+%ErXCion_Blz z(IVlJ1lH;xswQu8->;=Q&~=l17GsPU7?H%A@|?5E?a*){3y&Cm7CBC2^?uvE;mvtQ zP3oT-sHQ7#j`X6J>Wa6MqVvmqK%5DpQBFd~o=7VoyDsgA+V^_}c4)NKzMD7SR+;f|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E#L8r&ZW2Z6aErhp`Rf2Wley53il`Yx0oDe6h>l&%)Lqb2oBm(}Opnz~5VG-d5 N%y)GXE&Sef?q9uN2q6Ff diff --git a/aaanalysis/_utils/__pycache__/_utils_check.cpython-39.pyc b/aaanalysis/_utils/__pycache__/_utils_check.cpython-39.pyc index c93a4165b28dc63c38fbf48ba32422513d68d06d..bf44610c465ee45d05b7f082f970bca09f4354cc 100644 GIT binary patch delta 1113 zcmY*X&u<$=6y7)cYj(YBJ8qMhwy4ucfSg06K$Sob6xxC~HBu`T$*q(+e!KA!cQ=_G zr>eD9payY7)kwWmz4cIW0?LUaH~s{C;$J|(g%fW!AYi3=@0)q=?R@Wh^QZV-#Dh2v zE&3k4SV}HDj^90AMi;%$q3_`e`p60SxQYRWggADwff1nqU%?ogghD)nEo>8N;8|S4 z4xtFo;VC>#C`S91)q8ci5ndgX*-%VWHqO*TF&rhseUVP`p~{N96lo!adU%isUPrQg z@9_`sA9EshjaKVAcfphj69opbaEN(oS`%G zm0dyQ&6&JMp6y%Zy~?Iqkl)bW-gn5Gy(J~O6?JGD191X^kL=>sm%Z`#<w zn50>rppb)nFVQV_-e1^RuBMURW?g;ARdfcgJ zu#->j?85w02C6suqknow=1=-lUh{lH_jA33&$5bX~pa zyylq;rKbnZ>syA4G%sl3n2x1Su;)qh+GWF-rZFut{l-bdwLbcgFRw@cRp2b8lpQh_ zqn@eTHudg6NJ_{R{hMc)QtcIQ9X9kQ-lvU!YrFan@6D*b!NF{(DD5r(5^U*_|NMVx zt9&!A(_A$<7*pH2&)nUa!|q+=gv7C2d?G2wNZ`5CN6CRV04gsF1ppYN@o^>~j*6#jeJ) zLA7SJKxidSC>n_aC=#F^5GSOHJL;hle*wq`B)D-z<$!X5H%5s%{>F&|IiBiJMspmoV;pDq@>H$^f^#Pw*n9S?V+&2c&uNtWi`Z+iE(SvIPL z{{FA4(;9hRrjg$zkT$~D;Gr^!Di$8{Y>u*lh%&CT3M;+PDeUu|^n9mqwew<@#)q(c zXe~!i7JfU*x3lpGqm4K!>QVZ1^j;#iqc$tO%Y)H4ewFi#mljnj?W%6cn7DpTePNzk zIueDfIPcYS!TXh?R~sPq$yBCQOc#!VsK5S$!}QbfyBjgDYY`&?!*aoe5;8S&!-=bcsllhxZi;D@6>gh=4U=Zki;^8)#N~l2D{1JFq8A zTKT$UXp`D3CGFACjHG00l|An0?YOP3vL~L^opM)$etg^^Xxm)>8N8ukhM?!YGtNc7 zx+0aii&4c+(@Gu^7^Xf`NT+1rnJ)0A`jfp4Om*!ubETK$Nt%m6I*dz;ZjL+Z1A7IY zQs3HFS5HtjKk9~9aqPc}ZDiSKmJE8b-0AehD5^Uj=J$L;VM7vt!8BbaoxO>igNZ eps8BnD~ozlW`*D~1B}1CrWbgw=Mc_#OMe5+VI{i& diff --git a/aaanalysis/_utils/__pycache__/utils_cpp.cpython-39.pyc b/aaanalysis/_utils/__pycache__/utils_cpp.cpython-39.pyc index adc6af7b8716b19c6cdaad9dfae948e7e316f8a5..b0d9b6afe754847eb329b24a0c5ef4d2551faecf 100644 GIT binary patch delta 269 zcmZ1++!f55$ji&c00eAH1yd()3M6iEWR(_|#AoJB-pkd<%afdu znw%YcLxz3Ai@(!XtE#- zEfNEXT1;Lfpd9Q5l4CCN28qCRXtEYr0R?UeA=?*Ul$e*ETI2#!=>?KyNy$tu(d0tY zTjaS}UNE1J(RFgayckoF`R2{?vl$t!Hv233vNPIGo~vQSXf^qUh7-3V$RLPmlT|hA E0BXBJD*ylh delta 311 zcmeAQUL4Gu$ji&c00axS3Zx#}$UBouT$8y-1Sn7>3M6iEWtA3}#HZ!tCr;kY)yTu0 zoRONG4d$0j_T*l}=&<=4cOfIA^X3fRbBv6ho6Y&{7C|8gibCDNF1g=Aqwa5}Ea7z+mXI_3@d|qmLVo7FMYJ6U4Zc=Jd zkuykxCrA-XN@jA2CKs9!MIM`l1oQb+U4Tk{0o}!t8DEldi#;#CxF9F9Bm~)~MLwHn m$={min_val}" if max_val is None else f"{min_val}<=n<={max_val}" - if accept_none: - add_str += " or None" - error = f"'{name}' ({val}) should be {str_check} n, with " + add_str if accept_none and val is None: return None - if type(val) not in check_types: - raise ValueError(error) - if val < min_val: - raise ValueError(error) - if max_val is not None and val > max_val: + valid_types = (int,) if just_int else (float, int) + type_description = "int" if just_int else "float or int" + + # Verify the value's type and range + if not isinstance(val, valid_types) or val < min_val or (max_val is not None and val > max_val): + range_desc = f"n>={min_val}" if max_val is None else f"{min_val}<=n<={max_val}" + error = f"'{name}' ({val}) should be {type_description} in the range: {range_desc}" + if accept_none: + error += " or None" raise ValueError(error) -def check_float(name=None, val=None, accept_none=False, just_float=True): +def check_number_val(name=None, val=None, accept_none=False, just_int=False): """Check if value is float""" + check_types = [int] if just_int else [float, int] if accept_none and val is None: return None if type(val) not in [float, int]: error = f"'{name}' ({val}) should be float" - if not just_float: + if not just_int: error += " or int." else: error += "." diff --git a/aaanalysis/_utils/utils_cpp.py b/aaanalysis/_utils/utils_cpp.py index 0e55e96f..af35d564 100644 --- a/aaanalysis/_utils/utils_cpp.py +++ b/aaanalysis/_utils/utils_cpp.py @@ -72,8 +72,8 @@ def check_ylim(df=None, ylim=None, val_col=None, retrieve_plot=False, scaling_fa """""" if ylim is not None: ut_check.check_tuple(name="ylim", val=ylim, n=2) - ut_check.check_float(name="ylim:min", val=ylim[0], just_float=False) - ut_check.check_float(name="ylim:max", val=ylim[1], just_float=False) + ut_check.check_number_val(name="ylim:min", val=ylim[0], just_int=False) + ut_check.check_number_val(name="ylim:max", val=ylim[1], just_int=False) max_val = round(max(df[val_col]), 3) max_y = ylim[1] if max_val >= max_y: @@ -117,10 +117,10 @@ def check_args_len(tmd_len=None, jmd_n_len=None, jmd_c_len=None, ext_len=None, """Check length parameters and if they are matching with sequences if provided""" # Check lengths tmd_seq_given = tmd_seq is not None or accept_tmd_none # If tmd_seq is given, tmd_len can be None - ut_check.check_non_negative_number(name="tmd_len", val=tmd_len, accept_none=tmd_seq_given, min_val=1, just_int=True) - ut_check.check_non_negative_number(name="jmd_n_len", val=jmd_n_len, accept_none=True, min_val=1, just_int=True) - ut_check.check_non_negative_number(name="jmd_c_len", val=jmd_c_len, accept_none=True, min_val=1, just_int=True) - ut_check.check_non_negative_number(name="ext_len", val=ext_len, accept_none=True, just_int=True) + ut_check.check_number_range(name="tmd_len", val=tmd_len, accept_none=tmd_seq_given, min_val=1, just_int=True) + ut_check.check_number_range(name="jmd_n_len", val=jmd_n_len, accept_none=True, min_val=1, just_int=True) + ut_check.check_number_range(name="jmd_c_len", val=jmd_c_len, accept_none=True, min_val=1, just_int=True) + ut_check.check_number_range(name="ext_len", val=ext_len, accept_none=True, just_int=True) # Check if lengths and sequences match (any sequence is excepted, strings, lists, arrays) tmd_len = _check_seq(tmd_seq, tmd_len, "tmd_seq", "tmd_len") jmd_n_len = _check_seq(jmd_n_seq, jmd_n_len, "jmd_n_seq", "jmd_n_len") @@ -220,7 +220,7 @@ def check_split(split=None): i_th, n_split = [int(x) for x in split.split("(")[1].replace(")", "").split(",")] # Check if values non-negative integers for name, val in zip(["i_th", "n_split"], [i_th, n_split]): - ut_check.check_non_negative_number(name=name, val=val, just_int=True) + ut_check.check_number_range(name=name, val=val, just_int=True) # Check if i-th and n_split are valid if i_th > n_split: raise ValueError @@ -233,7 +233,7 @@ def check_split(split=None): start = int(start[0]) # Check if values non-negative integers for name, val in zip(["start", "step1", "step2"], [start, step1, step2]): - ut_check.check_non_negative_number(name=name, val=val, just_int=True) + ut_check.check_number_range(name=name, val=val, just_int=True) # Check if terminus valid terminus = split.split("i+")[0].split("(")[1].replace(",", "") if terminus not in ["N", "C"]: @@ -248,7 +248,7 @@ def check_split(split=None): list_pos = [int(x) for x in list_pos] for val in list_pos: name = "pos" + str(val) - ut_check.check_non_negative_number(name=name, val=val, just_int=True) + ut_check.check_number_range(name=name, val=val, just_int=True) # Check if terminus valid if terminus not in ["N", "C"]: raise ValueError diff --git a/aaanalysis/cpp/__pycache__/_cpp.cpython-39.pyc b/aaanalysis/cpp/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JxMCNq>e7lz49$1I44y36E?Om~|{7$uMC zSY%5|RWh8WREHW=cK;RFy!U_JUSrUQcf!5c4iEU+ve0Nz5hcJk;dyZ3*~mV>EGqVE z%mxh~MMi^tR5I=ZiQEMN*kyf->;WiZP`eM$v87$5Ivl+WE7tAk2_mewy+NDbj?KXu zX5$}W!y4;rO7IEaB|1>D=KH^>TnKCoEt72T@Bz4lXNI?^bN|5_K-pS7l&}YE9$qD; zmTbUx%RSOgz!X}k<50kz)GMt>TMa6rWiPs5!)Y6e*gbcTu9Q0e%{olDQR7rtKff SxUFCDhZvCm@B}@o$Nv)s>ahg? delta 711 zcmZ9JO=uHA6vyXnb~nveF-hwt{W2Dc#2&n~#CYkUJ?KFZL=QD(n`Ad>KDw*ZX~nWd zZLo^kR+x)WYc)uribA>wVo${?SPy~+k)jtxv>k{vgy0MgAi6d6$8utbq8lWE5^Zy?93M@mFEx z93z%s5zRF%Ot|ty6RR*GGO$Pmn7~{)VT{ldOe{({QXrP=E@+Y_Yi_OXCh8dgVjN|% zMVPxH(90IF#4(_Yn#U66h~~8j(r1ZtWL}<-Se+$RU=obBfBXc|{Qoy-aE!zQv?OV7;(_d4|Xl!kM_@?+n1bz@Ak{&QVa@ww7(DX{7L_cQo@|LOsh`Z6$i&1l=!uiv-r9#sasni zd$9Xs>IW>_?*^WO?`G=<;kErUa|h(2Gs@sq?Np$F0PbJjpf}_V{06)A%5nez diff --git a/aaanalysis/cpp/__pycache__/feature.cpython-39.pyc b/aaanalysis/cpp/__pycache__/feature.cpython-39.pyc index 98141833cb6d8206a922c9c2755e2bf0c919c0b2..a50164c779b2e894a6f645b9b8c6fc562e1da4c8 100644 GIT binary patch delta 49 zcmaENnDO~xM&3kTUM>b8U|TAfnzoU5F1xT$az<)$c6?rGZc=Jdd{JUvdg|sQ>{?L( Df*BA} delta 56 zcmaEUnDO0VM&3kTUM>b8$e$sY+O&~(F1wUuaz<)$c6?rbUVL6^dSXdtS!#SL+# K(dNDET2TNL`4hna diff --git a/aaanalysis/cpp/_cpp.py b/aaanalysis/cpp/_cpp.py index 5b082849..e12f9811 100644 --- a/aaanalysis/cpp/_cpp.py +++ b/aaanalysis/cpp/_cpp.py @@ -381,10 +381,10 @@ def draw_shap_legend(x=None, y=10, offset_text=1, fontsize=13): class CPPPlots: """Class for plotting functions for CPP analysis""" def __init__(self, tmd_len=20, jmd_n_len=10, jmd_c_len=10, start=1): - ut.check_non_negative_number(name="tmd_len", val=tmd_len, min_val=1, just_int=True) - ut.check_non_negative_number(name="jmd_n_len", val=jmd_n_len, min_val=0, just_int=True) - ut.check_non_negative_number(name="jmd_c_len", val=jmd_c_len, min_val=0, just_int=True) - ut.check_non_negative_number(name="start", val=start, just_int=True) + ut.check_number_range(name="tmd_len", val=tmd_len, min_val=1, just_int=True) + ut.check_number_range(name="jmd_n_len", val=jmd_n_len, min_val=0, just_int=True) + ut.check_number_range(name="jmd_c_len", val=jmd_c_len, min_val=0, just_int=True) + ut.check_number_range(name="start", val=start, just_int=True) self.jmd_n_len = jmd_n_len self.tmd_len = tmd_len self.jmd_c_len = jmd_c_len diff --git a/aaanalysis/cpp/_feature_pos.py b/aaanalysis/cpp/_feature_pos.py index 44faea55..12c29fc5 100644 --- a/aaanalysis/cpp/_feature_pos.py +++ b/aaanalysis/cpp/_feature_pos.py @@ -39,7 +39,7 @@ def get_dict_part_pos(tmd_len=20, jmd_n_len=10, jmd_c_len=10, ext_len=0, start=1 ------- dict_part_pos: dictionary with parts to positions of parts """ - ut.check_non_negative_number(name="start", val=start, min_val=1, just_int=True) + ut.check_number_range(name="start", val=start, min_val=1, just_int=True) ut.check_args_len(tmd_len=tmd_len, jmd_n_len=jmd_n_len, jmd_c_len=jmd_c_len, ext_len=ext_len) pa = Parts() jmd_n = list(range(0, jmd_n_len)) diff --git a/aaanalysis/cpp/cpp.py b/aaanalysis/cpp/cpp.py index 9b734501..84c27f69 100644 --- a/aaanalysis/cpp/cpp.py +++ b/aaanalysis/cpp/cpp.py @@ -272,11 +272,11 @@ def run(self, labels=None, parametric=False, n_filter=100, # Check input ut.check_labels(labels=labels, df=self.df_parts, name_df="df_parts") ut.check_args_len(tmd_len=tmd_len, jmd_n_len=jmd_n_len, jmd_c_len=jmd_c_len, ext_len=ext_len) - ut.check_non_negative_number(name="n_filter", val=n_filter, min_val=1, just_int=True) - ut.check_non_negative_number(name="n_pre_filter", val=n_pre_filter, min_val=1, accept_none=True, just_int=True) - ut.check_non_negative_number(name="pct_pre_filter", val=pct_pre_filter, min_val=5, max_val=100, just_int=True) - ut.check_non_negative_number(name="max_std_test", val=max_std_test, min_val=0.0, max_val=1.0, just_int=False) - ut.check_non_negative_number(name="max_overlap", val=max_overlap, min_val=0.0, max_val=1.0, just_int=False) + ut.check_number_range(name="n_filter", val=n_filter, min_val=1, just_int=True) + ut.check_number_range(name="n_pre_filter", val=n_pre_filter, min_val=1, accept_none=True, just_int=True) + ut.check_number_range(name="pct_pre_filter", val=pct_pre_filter, min_val=5, max_val=100, just_int=True) + ut.check_number_range(name="max_std_test", val=max_std_test, min_val=0.0, max_val=1.0, just_int=False) + ut.check_number_range(name="max_overlap", val=max_overlap, min_val=0.0, max_val=1.0, just_int=False) ut.check_bool(name="verbose", val=self._verbose) # Settings and creation of objects args = dict(split_kws=self.split_kws, df_scales=self.df_scales) diff --git a/aaanalysis/cpp/cpp_plot.py b/aaanalysis/cpp/cpp_plot.py index c4fc30ac..b1f5d6ad 100644 --- a/aaanalysis/cpp/cpp_plot.py +++ b/aaanalysis/cpp/cpp_plot.py @@ -41,8 +41,8 @@ def check_normalize(normalize=True): # Check for plotting methods def check_args_size(seq_size=None, tmd_jmd_fontsize=None): """Check if sequence size parameters match""" - ut.check_non_negative_number(name="seq_size", val=seq_size, min_val=0, accept_none=True, just_int=False) - ut.check_non_negative_number(name="tmd_jmd_fontsize", val=tmd_jmd_fontsize, min_val=0, accept_none=True, just_int=False) + ut.check_number_range(name="seq_size", val=seq_size, min_val=0, accept_none=True, just_int=False) + ut.check_number_range(name="tmd_jmd_fontsize", val=tmd_jmd_fontsize, min_val=0, accept_none=True, just_int=False) args_size = dict(seq_size=seq_size, tmd_jmd_fontsize=tmd_jmd_fontsize) return args_size @@ -50,9 +50,9 @@ def check_args_size(seq_size=None, tmd_jmd_fontsize=None): def check_args_xtick(xtick_size=None, xtick_width=None, xtick_length=None): """Check if x tick parameters non-negative float""" args = dict(accept_none=True, just_int=False, min_val=0) - ut.check_non_negative_number(name="xtick_size", val=xtick_size, **args) - ut.check_non_negative_number(name="xtick_width", val=xtick_width, **args) - ut.check_non_negative_number(name="xtick_length", val=xtick_length, **args) + ut.check_number_range(name="xtick_size", val=xtick_size, **args) + ut.check_number_range(name="xtick_width", val=xtick_width, **args) + ut.check_number_range(name="xtick_length", val=xtick_length, **args) args_xtick = dict(xtick_size=xtick_size, xtick_width=xtick_width, xtick_length=xtick_length) return args_xtick @@ -60,9 +60,9 @@ def check_args_xtick(xtick_size=None, xtick_width=None, xtick_length=None): def check_args_ytick(ytick_size=None, ytick_width=None, ytick_length=None): """Check if y tick parameters non-negative float""" args = dict(accept_none=True, just_int=False, min_val=1) - ut.check_non_negative_number(name="ytick_size", val=ytick_size, **args) - ut.check_non_negative_number(name="ytick_width", val=ytick_width, **args) - ut.check_non_negative_number(name="ytick_length", val=ytick_length, **args) + ut.check_number_range(name="ytick_size", val=ytick_size, **args) + ut.check_number_range(name="ytick_width", val=ytick_width, **args) + ut.check_number_range(name="ytick_length", val=ytick_length, **args) args_ytick = dict(ytick_size=ytick_size, ytick_width=ytick_width, ytick_length=ytick_length) return args_ytick @@ -86,8 +86,8 @@ def check_seq_color(tmd_seq_color=None, jmd_seq_color=None): def check_figsize(figsize=None): """""" ut.check_tuple(name="figsize", val=figsize, n=2) - ut.check_non_negative_number(name="figsize:width", val=figsize[0], min_val=1, just_int=False) - ut.check_non_negative_number(name="figsize:height", val=figsize[1], min_val=1, just_int=False) + ut.check_number_range(name="figsize:width", val=figsize[0], min_val=1, just_int=False) + ut.check_number_range(name="figsize:height", val=figsize[1], min_val=1, just_int=False) def check_dict_color(dict_color=None, df_cat=None): @@ -124,8 +124,8 @@ def check_parameters(func=None, name_called_func=None, e=None): # Check heatmap plotting def check_vmin_vmax(vmin=None, vmax=None): """Check if number of cmap colors is valid with given value range""" - ut.check_float(name="vmin", val=vmin, accept_none=True, just_float=False) - ut.check_float(name="vmax", val=vmax, accept_none=True, just_float=False) + ut.check_number_val(name="vmin", val=vmin, accept_none=True, just_int=False) + ut.check_number_val(name="vmax", val=vmax, accept_none=True, just_int=False) if vmin is not None and vmax is not None and vmin >= vmax: raise ValueError(f"'vmin' ({vmin}) < 'vmax' ({vmax}) not fulfilled.") @@ -144,10 +144,9 @@ def check_ylabel_fontweight(ylabel_fontweight=None, accept_none=True): if accept_none and ylabel_fontweight is None: return name = "ylabel_fontweight" - args = dict(name=name, val=ylabel_fontweight) list_weights = ['light', 'medium', 'bold'] if type(ylabel_fontweight) in [float, int]: - ut.check_non_negative_number(**args, min_val=0, max_val=1000, just_int=False) + ut.check_number_range(name=name, val=ylabel_fontweight, min_val=0, max_val=1000, just_int=False) elif isinstance(ylabel_fontweight, str): if ylabel_fontweight not in list_weights: error = f"'{name}' ({ylabel_fontweight}) should be one of following: {list_weights}" @@ -360,9 +359,9 @@ def profile(self, df_feat=None, y="category", val_col="mean_dif", val_type="coun # Checking input # Args checked by Matplotlib: title, legend_kws # Args checked by internal plotting functions: ylim - ut.check_non_negative_number(name="bar_width", val=bar_width, min_val=0, just_int=False) - ut.check_non_negative_number(name="start", val=start, min_val=0, just_int=True) - ut.check_non_negative_number(name="tmd_area_alpha", val=highlight_alpha, min_val=0, max_val=1, just_int=False) + ut.check_number_range(name="bar_width", val=bar_width, min_val=0, just_int=False) + ut.check_number_range(name="start", val=start, min_val=0, just_int=True) + ut.check_number_range(name="tmd_area_alpha", val=highlight_alpha, min_val=0, max_val=1, just_int=False) ut.check_bool(name="add_jmd_tmd", val=add_jmd_tmd) ut.check_bool(name="highlight_tmd_area", val=highlight_tmd_area) ut.check_bool(name="grid", val=grid) @@ -578,9 +577,9 @@ def heatmap(self, df_feat=None, y="subcategory", val_col="mean_dif", val_type="m # Checking input # Args checked by Matplotlib: title, cmap, cbar_kws, legend_kws - ut.check_non_negative_number(name="start", val=start, min_val=0, just_int=True) - ut.check_non_negative_number(name="ytick_size", val=ytick_size, accept_none=True, just_int=False, min_val=1) - ut.check_non_negative_number(name="cmap_n_colors", val=cmap_n_colors, min_val=1, accept_none=True, just_int=True) + ut.check_number_range(name="start", val=start, min_val=0, just_int=True) + ut.check_number_range(name="ytick_size", val=ytick_size, accept_none=True, just_int=False, min_val=1) + ut.check_number_range(name="cmap_n_colors", val=cmap_n_colors, min_val=1, accept_none=True, just_int=True) ut.check_bool(name="add_jmd_tmd", val=add_jmd_tmd) ut.check_bool(name="add_legend_cat", val=add_legend_cat) ut.check_dict(name="legend_kws", val=legend_kws, accept_none=True) diff --git a/aaanalysis/cpp/feature.py b/aaanalysis/cpp/feature.py index 8ab70c8b..4d217b7a 100644 --- a/aaanalysis/cpp/feature.py +++ b/aaanalysis/cpp/feature.py @@ -62,7 +62,7 @@ def check_split_int_args(kwargs_int=None): """Check type of given arguments""" for arg in kwargs_int: arg_val = kwargs_int[arg] - ut.check_non_negative_number(name=arg, val=arg_val, just_int=False) + ut.check_number_range(name=arg, val=arg_val, just_int=False) def check_split_list_args(kwargs_list=None, accept_none=True): @@ -385,7 +385,7 @@ def feat_matrix(features=None, df_parts=None, df_scales=None, accept_gaps=False, feat_matrix: array-like or sparse matrix, shape (n_samples, n_features) Feature values of samples. """ - ut.check_non_negative_number(name="j_jobs", val=n_jobs, accept_none=True, min_val=1, just_int=True) + ut.check_number_range(name="j_jobs", val=n_jobs, accept_none=True, min_val=1, just_int=True) if df_scales is None: df_scales = aaanalysis.data_loader.load_scales_.load_scales() ut.check_df_scales(df_scales=df_scales) @@ -607,10 +607,10 @@ def add_position(df_feat=None, features=None, start=1, tmd_len=20, jmd_n_len=10, """ # TODO add sequence, generalize check functions for tmd_len ... features = ut.check_features(features=features) - ut.check_non_negative_number(name="tmd_len", val=tmd_len, just_int=True, min_val=1) + ut.check_number_range(name="tmd_len", val=tmd_len, just_int=True, min_val=1) args = dict(jmd_n_len=jmd_n_len, jmd_c_len=jmd_c_len, ext_len=ext_len, start=start) for name in args: - ut.check_non_negative_number(name=name, val=args[name], just_int=True, min_val=0) + ut.check_number_range(name=name, val=args[name], just_int=True, min_val=0) sfp = SequenceFeaturePositions() dict_part_pos = sfp.get_dict_part_pos(tmd_len=tmd_len, **args) feat_positions = sfp.get_positions(dict_part_pos=dict_part_pos, features=features) diff --git a/aaanalysis/data_loader/__pycache__/load_dataset_.cpython-39.pyc b/aaanalysis/data_loader/__pycache__/load_dataset_.cpython-39.pyc index 2c13b1abd1674290949fa82c009970a9258555f4..4b730ab51c0e749df9a6f13adca895703cb063d8 100644 GIT binary patch delta 47 zcmZ4KzQ~<7k(ZZ?0SMTa3Z@?0$UBE!SSUFoH90#zuQWF)wJ5$QF)uxJ^I`U9(f~xr B52^qF delta 54 zcmZ4FzS5mHk(ZZ?0SNME2&O*T$UBE!N-{YkH90#zFF!9nFEu@}B(p3vKCd)4DYaP0o(b%g>9?OHEHK$t+8a&nwMMN-f&V I&ypn!0KVrDjsO4v diff --git a/aaanalysis/data_loader/load_dataset_.py b/aaanalysis/data_loader/load_dataset_.py index 483d060b..a76aafe7 100644 --- a/aaanalysis/data_loader/load_dataset_.py +++ b/aaanalysis/data_loader/load_dataset_.py @@ -36,8 +36,8 @@ def check_name_of_dataset(name="INFO", folder_in=None): def check_min_max_val(min_len=None, max_len=None): """Check if min_val and max_val are valid and match""" - ut.check_non_negative_number(name="min_len", val=min_len, min_val=1, accept_none=True, just_int=True) - ut.check_non_negative_number(name="max_len", val=max_len, min_val=1, accept_none=True, just_int=True) + ut.check_number_range(name="min_len", val=min_len, min_val=1, accept_none=True, just_int=True) + ut.check_number_range(name="max_len", val=max_len, min_val=1, accept_none=True, just_int=True) if min_len is None or max_len is None: return if isinstance(min_len, int) and isinstance(max_len, int) and min_len > max_len: @@ -55,7 +55,7 @@ def check_aa_window_size(aa_window_size=None): """Check if aa_window size is a positive odd integer""" if aa_window_size is None: return - ut.check_non_negative_number(name="aa_window_size", val=aa_window_size, min_val=1, just_int=True) + ut.check_number_range(name="aa_window_size", val=aa_window_size, min_val=1, just_int=True) if aa_window_size % 2 == 0: raise ValueError(f"'aa_window_size' ({aa_window_size}) must be an odd number.") @@ -183,7 +183,7 @@ def load_dataset(name: str = "INFO", """ check_name_of_dataset(name=name, folder_in=FOLDER_BENCHMARKS) - ut.check_non_negative_number(name="n", val=n, min_val=1, accept_none=True, just_int=True) + ut.check_number_range(name="n", val=n, min_val=1, accept_none=True, just_int=True) check_non_canonical_aa(non_canonical_aa=non_canonical_aa) check_min_max_val(min_len=min_len, max_len=max_len) check_aa_window_size(aa_window_size=aa_window_size) diff --git a/aaanalysis/data_loader/load_scales_.py b/aaanalysis/data_loader/load_scales_.py index 57f3783a..1bd5c6eb 100644 --- a/aaanalysis/data_loader/load_scales_.py +++ b/aaanalysis/data_loader/load_scales_.py @@ -18,7 +18,7 @@ def check_top60_n(name=None, top60_n=None): """Check if name is valid and top60_n is between 1 and 60""" if top60_n is None: return - ut.check_non_negative_number(name="top60_n", val=top60_n, min_val=1, max_val=60, just_int=True) + ut.check_number_range(name="top60_n", val=top60_n, min_val=1, max_val=60, just_int=True) matching_scale_sets = [ut.STR_SCALES, ut.STR_SCALE_CAT, ut.STR_SCALES_RAW] if name not in matching_scale_sets: raise ValueError(f"'name' ('{name}') is not valid for 'top60_n' ({top60_n})." diff --git a/aaanalysis/dpulearn/__pycache__/dpulearn.cpython-39.pyc b/aaanalysis/dpulearn/__pycache__/dpulearn.cpython-39.pyc index 31cc1b49c86c67a8dacd5fee187757e879ae0e67..bf1070eda433f83bf87fd18587a0a422a664a426 100644 GIT binary patch delta 47 zcmbOkHz|%ck(ZZ?0SMTZ3Z_ 0: raise ValueError(f"'labels' should not contain labels for negatives ({label_neg})") n_pos = sum([x == label_pos for x in labels]) diff --git a/aaanalysis/plotting/__init__.py b/aaanalysis/plotting/__init__.py index dfa4cf8d..ea0a437b 100644 --- a/aaanalysis/plotting/__init__.py +++ b/aaanalysis/plotting/__init__.py @@ -1,4 +1,14 @@ -from aaanalysis.plotting.plotting_functions import plot_get_cmap, plot_get_cdict, plot_gcfs, \ - plot_settings, plot_set_legend +from aaanalysis.plotting.plot_get_cmap_ import plot_get_cmap +from aaanalysis.plotting.plot_get_cdict_ import plot_get_cdict +from aaanalysis.plotting.plot_settings_ import plot_settings +from aaanalysis.plotting.plot_gcfs_ import plot_gcfs +from aaanalysis.plotting.plot_set_legend_ import plot_set_legend -__all__ = ["plot_get_cmap", "plot_get_cdict", "plot_settings", "plot_set_legend", "plot_gcfs"] + + +__all__ = ["plot_get_cmap", + "plot_get_cdict", + "plot_settings", + "plot_set_legend", + "plot_gcfs", + ] diff --git a/aaanalysis/plotting/__pycache__/__init__.cpython-39.pyc b/aaanalysis/plotting/__pycache__/__init__.cpython-39.pyc index 2f1cbe98f45883d876b7ea33894aa9dd09a741eb..a89b3b69b851c02d91a64bd407d91fe7a4be7f79 100644 GIT binary patch literal 598 zcmaJ<(a&%UIZX6g@&(E3aTB zph;{J7~Z`9`F!4EV3Wxhh4KD!B0exepE3A91|hf!%iRXxh+~B`rWi*)Py?OOEb&a` zx}Zhkxf<${mWdat(jz*;NFqLb#dOTedsJ6np&P34YSOFDgA^Vb&H9iy+9r70_)Uou z-nT}&kQn`zG>3BZ&Bctf^|9wU59GVin?&WnD| z%!3uJX2y`2?WAQ|2fJjpZ05{r2)QS*@Pb^)1Eh)*&OD~>yKu(wyXhabkh+qK{ewyr2Y7;+7D1qeT(@OJ_OEUBGii?;)3YcN4 Ria?qsZ)2Rq1`?NH1^}0RHMal& diff --git a/aaanalysis/plotting/__pycache__/plot_gcfs_.cpython-39.pyc b/aaanalysis/plotting/__pycache__/plot_gcfs_.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..59b3b720076b16c9088c047649579e70007c2559 GIT binary patch literal 548 zcmZWn%}N6?5YFzlc3UVac+gv}1?l3o6cGfyNkLD&q-i$08{17vlAC%r`&z62jZ<76E&IK9u8tkPi%YErj3#+#Lg?WJuB=4X42{Orx~+ zM21ls-jYsz*>Bwy%28OHI$_n!)67_!OYfD=shC?UHF5w>EhRM>%~U?O(sf&(Fq_;6 z#I51E=$GK`2*8t<;FYY&3KX1>b+8KH+;DkyE&c!Lr}UvvqChzg^5X^VWpgchquJDW z1{8{NBZ{O~Mt7G@RMtghov@0WcGUsaVjUBZl8?R<4)=fVv8Ad_8^g9YV(TFDOC^OV zW#YV?6ZOMSUmlH3OvjG7Z`iVs`+WtGHj9bUu~m N@Dqru0o0;6`UXIEn(+Vt literal 0 HcmV?d00001 diff --git a/aaanalysis/plotting/__pycache__/plot_get_cdict_.cpython-39.pyc b/aaanalysis/plotting/__pycache__/plot_get_cdict_.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..962f472f84f06a4e481a02cd58a00d7142c16b80 GIT binary patch literal 1132 zcma)5&2AGh5Vkj)w5-xdoH!ww9w>WgS8%M_h$!s=3AIrZap+~^uAOAt-Sx`$Qc{%* zaOMU0x$`Kzg0GwqZ@`JMn|2c}Fp_^}Y|ni2&6sX%1PJ8&*Zcfq1EC*QSr#9Z=P=Y` zm>4=m3^Omoxp&&Yh^=#$I4XL}Z|` zG|@l76$-IwRyxg;2@YQLM{)o76H0H%CRBlTcWz_FH{G-k z_8psT3|$r{_T-5rd4IF!Y%{#6)zzadd$dLJN@;Qig(zGxCL+tkC3NU6ISO0GtF-A1 zM<;RZ!L)0=H!{I1npONzN+G4~N7JdV#{J$X^rZbYCdg8yV;fU_L$VE~-$gVNIgga) z<%||*lBYQ>ifACk6dEZ95Yb?s%&5#`u$}V@&7-FSnq1H+S5eK#^46wrKUlQNL%dVY zO=s2C1PsaoK@Zw^9d~emTb}HIeiUMtOSop%;+Tmfj!jUd1t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*S#Q069MLZ9AkPEtPdUcQ`$NeU|yp8*XjPMva~vwzy8a{n>4@Dc+G1F&Kj#8 zHm_oH8^Yzr(W=(X^+wWYYW3XZ+`AEGiDENyS*kIiY@GnLv`tW*=y5jS-c!Z`okMwy z=WqZSI*dWGr_|Vhu&3drBgY8FJVvKAa;GELHNk1}SWhsTSRD_D1w8--y2Jb+1$P41 zUdMpt;d_@F3I!9~n;Lp;u?Qhi(-Gf+kN7SYD$4v3)~-PT36a2vNnj)?t2^NPyI}jp z_mFl4icOe&JfH$eLl-h9@nh_t#^Q%iG|l5N;&mYS7+;Pa6Dn1B&%>K}Q1l^cfmn;= z2E=3JBD{~RN9H4P-}$xqzI|6`FHIfHHce@^UX>QuvS+rAP%%W-+rVIOB0{cRL(l3b zQM&#i^!x{2m2zRS)fF`E^HGwuoj_P_t0d9YSe55SxfqBf9c9&;FNv!tj1m}=n&bF>0u$=A zzmL7BfaB0!9j-XJ8?^TFOU8L~6p!<2CbUh{Jo(#2)62(1~rPF5_N%mHNuGM*W8k+`4RFb3bM<-&OJ z9?Wi9?RLAl1O-0gGLYJ$1*JN__J&x)`m0zV#@p>p)!T-IsM77S#P4>c3wI5|IDzOD zm{AEE3rtxB=Bg5Mzmb6!-#{va(S|MGX{liy$oBfle%4-tJV$jKmPt*BQB`320s^mrg}%E MsoF?I%F4g~3rd=1<^TWy literal 0 HcmV?d00001 diff --git a/aaanalysis/plotting/__pycache__/plot_settings_.cpython-39.pyc b/aaanalysis/plotting/__pycache__/plot_settings_.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..18ff5951a548d2a8c2bd471a3e99b4ef4fdcd5f6 GIT binary patch literal 6862 zcmeHLPj4H?73VG~iXthAk{#!NGI5hoOk^st(*_VMH;x>+1`=0*gd7;S)Q~eIS6c3} zvr9?bt}jiFP2p33HYtz>DUf`Fe1Lw4Vz24NKu4=d=35#}Kg$@rg}?VZG$PZ;2t$~*(J=Kp+sNtnOh4b4HR8EK zf38tX`lUvxn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oF-}$Q9)mPEyu@2oNmW>QK8Xp`w?nQ$uAJb(xw=)Vxm38Z}p_p~6FOa~vo2si71U{wZXxB70`lsbE)ytWjRl z`SUoBN-FgG3t72UOY zOWN^g2}JwK1W|Q@gA&~%OZdI+AOAql{htR*$CQKA`+VP3^?2@ze!iW|Sx9!`xnOB@ zdifYMS=9waJmt57$~1Pm$lRx@=@_g(A#hNc#(M%XUZbmV>H@w;Jq_iupiG&5%K!UR zD-0@WR$FiLfkv|sC%5$uDU|C(`95xO!+x-s!XYWWu!Ktm(sD(WprDw{+HO0wg>&k8 zBE1~fo17u8imHhkaaZcPq^_muYExRpY`Lx-Wl{5v3b+|MxXqwqM7?NcpkQREDcXKi zNXxfT?m&)EUqsds<%a_}0U0f(lQ-hK6iSW`RhTAsyU0}S+H!2!q%7KC&$LrA;n+I0 z#cJ!+W~+@=+b$VvV~(q?hf)}A9y@Bx6NkrT+SBE?c^wu~4^Ixk3(;hLwQLmiFK6V8 zJbvcC@-qeFe3sya_@B)g&{Hab~#i7)n4)puB}fq z#dT71rR%$et0;90ZF!A6x<`l3<*4LY#;;%&=8A>lTyZvIJmmLX&M<%Qm;3HNr?lMA literal 0 HcmV?d00001 diff --git a/aaanalysis/plotting/__pycache__/plotting_functions.cpython-39.pyc b/aaanalysis/plotting/__pycache__/plotting_functions.cpython-39.pyc deleted file mode 100644 index 7207b383861eb82ce5ae428d5b1fadda7dffc803..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16895 zcmeHOTaX;rS?=3hc6N4mB+I(kiqn=IkH%SzY{}P+BzrAcvO!)i-X$iRnAzSrJ+rf# zTTb_^c81;rVh4)?fvJ#Gkto4724WK~MHN&YfTt8yKovYf^%GTrqEyKP6<#P8V7~u9 z-90nAD_@|B;(^)P)2IJ)&VO$I`ETcMXKE^^;rAC`+2{VslBRv1UPgaM@$w}8y+6@4 zO=v5c(1p>|R}6ldD;7Uft@KJpS7q7O#7d6yW^=NYU&*(oR;F6hE7Pr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0Z5$n3Qko_=sUu4*a_Xcf|1@MpZtP61?31IJtV4~ z{A~c_JCyt`C1iZdw-98TC4BpHl!CSayJOa?4u3?Y0;wj|H$Amx$MKaR&X%`D z90Ol#@m*Co8Lc%e+pRFgoWFF3e3N?Rk@32mrq^+kNR95dsDNfVLVtWL#)r*gmA^;z z=)A~3po9n{OkaWFU-wpWY+b9New|AHl#;)ugf<04IozckG{*Zivtw(%h1KOKEA2D% zB_VwzoV~5aQ*F z%NH5-MfEG)PVMnyD|SKt22~`IS-2=)r~Dg~%oAW?nM)T+_l22CMRcl_N|=dmQ dict: + """ + Returns color dictionaries specified for AAanalysis. + + Parameters + ---------- + name + The name of the AAanalysis color dictionary. + + - ``DICT_COLOR``: Dictionary with default colors for plots. + - ``DICT_CAT``: Dictionary with default colors for scale categories. + + Returns + ------- + dict + AAanalysis color dictionary. + + Examples + -------- + >>> import aaanalysis as aa + >>> dict_color = aa.plot_get_cdict(name="DICT_COLOR") + + """ + list_names = [ut.STR_DICT_COLOR, ut.STR_DICT_CAT] + if name not in list_names: + raise ValueError(f"'name' must be one of following: {list_names}") + if name == ut.STR_DICT_COLOR: + return ut.DICT_COLOR + else: + return ut.DICT_COLOR_CAT diff --git a/aaanalysis/plotting/plot_get_cmap_.py b/aaanalysis/plotting/plot_get_cmap_.py new file mode 100644 index 00000000..6acd4b7d --- /dev/null +++ b/aaanalysis/plotting/plot_get_cmap_.py @@ -0,0 +1,141 @@ +""" +Plotting utility function to obtain AAanalysis color maps. +""" +from typing import Union, List, Tuple +import seaborn as sns +from aaanalysis import utils as ut + + +# Helper functions +# Get color maps +def _get_cpp_cmap(n_colors=100, facecolor_dark=False): + """Generate a diverging color map for CPP feature values.""" + ut.check_number_range(name="n_colors", val=n_colors, min_val=2, just_int=True) + n = 5 + cmap = sns.color_palette(palette="RdBu_r", n_colors=n_colors + n * 2) + cmap_low, cmap_high = cmap[0:int((n_colors + n * 2) / 2)], cmap[int((n_colors + n * 2) / 2):] + c_middle = [(0, 0, 0)] if facecolor_dark else [cmap_low[-1]] + add_to_end = 1 # Must be added to keep list size consistent + cmap = cmap_low[0:-n] + c_middle + cmap_high[n+add_to_end:] + return cmap + + +def _get_shap_cmap(n_colors=100, facecolor_dark=True): + """Generate a diverging color map for feature values.""" + n = 20 # TODO check if 5 is better for CPP-SHAP heatmap + cmap_low = sns.light_palette(ut.COLOR_SHAP_NEG, input="hex", reverse=True, n_colors=int(n_colors/2)+n) + cmap_high = sns.light_palette(ut.COLOR_SHAP_POS, input="hex", n_colors=int(n_colors/2)+n) + c_middle = [(0, 0, 0)] if facecolor_dark else [cmap_low[-1]] + add_to_end = (n_colors+1)%2 # Must be added to keep list size consistent + cmap = cmap_low[0:-n] + c_middle + cmap_high[n+add_to_end:] + return cmap + +def _get_tab_color(n_colors=None): + """Get default color lists for up to 9 categories """ + # Base lists + list_colors_3_to_4 = ["tab:gray", "tab:blue", "tab:red", "tab:orange"] + list_colors_5_to_6 = ["tab:blue", "tab:cyan", "tab:gray","tab:red", + "tab:orange", "tab:brown"] + list_colors_8_to_9 = ["tab:blue", "tab:orange", "tab:green", "tab:red", + "tab:gray", "gold", "tab:cyan", "tab:brown", + "tab:purple"] + # Two classes + if n_colors == 2: + return ["tab:blue", "tab:red"] + # Control/base + 2-3 classes + elif n_colors in [3, 4]: + return list_colors_3_to_4[0:n_colors] + # 5-7 classes (gray in middle as visual "breather") + elif n_colors in [5, 6]: + return list_colors_5_to_6[0:n_colors] + elif n_colors == 7: + return ["tab:blue", "tab:cyan", "tab:purple", "tab:gray", + "tab:red", "tab:orange", "tab:brown"] + # 8-9 classes (colors from scale categories) + elif n_colors in [8, 9]: + return list_colors_8_to_9[0:n_colors] + +# TODO check if needed later +def _get_cmap_with_gap(n_colors=100, pct_gap=10, pct_center=None, + color_pos=None, color_neg=None, color_center=None, input="hex"): + """Generate a custom color map with a gap. + + """ + n_gap = int(n_colors*pct_gap/2) + cmap_pos = sns.light_palette(color_pos, input=input, n_colors=int(n_colors/2)+n_gap) + cmap_neg = sns.light_palette(color_neg, input=input, reverse=True, n_colors=int(n_colors/2)+n_gap) + color_center = [cmap_neg[-1]] if color_center is None else color_center + color_center = [color_center] if type(color_center) is str else color_center + if pct_center is None: + cmap = cmap_neg[0:-n_gap] + color_center + cmap_pos[n_gap:] + else: + n_center = int(n_colors * pct_center) + n_gap += int(n_center/2) + cmap = cmap_neg[0:-n_gap] + color_center * n_center + cmap_pos[n_gap:] + return cmap + + +# II Main function +def plot_get_cmap(name: str = "CPP", + n_colors: int = 101, + facecolor_dark: bool = False + ) -> Union[List[Tuple[float, float, float]], List[str]]: + """ + Returns color maps specified for AAanalysis. + + Parameters + ---------- + name + The name of the AAanalysis color palettes. + + - ``CPP``: Continuous color map for CPP plots. + - ``SHAP``: Continuous color map for CPP-SHP plots. + - ``CAT``: Color list for appealing visualization of categories. + + n_colors + Number of colors in the color map. Must be >=2 for 'CPP' and 'SHAP' and 2-9 for 'CAT'. + facecolor_dark + Whether central color in 'CPP' and 'SHAP' is black (if ``True``) or white. + + Returns + ------- + list + List with colors given as RGB tuples (for 'CPP' and 'SHAP') or matplotlib color names (for 'CAT'). + + Examples + -------- + .. plot:: + :include-source: + + >>> import matplotlib.pyplot as plt + >>> import seaborn as sns + >>> import aaanalysis as aa + >>> colors = aa.plot_get_cmap(name="CAT", n_colors=4) + >>> data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]} + >>> aa.plot_settings(no_ticks_x=True, font_scale=1.2) + >>> sns.barplot(x='Classes', y='Values', data=data, palette=colors) + >>> plt.show() + + See Also + -------- + * Example notebooks in `Plotting Prelude `_. + * :func:`seaborn.color_palette` function to generate a color palette in seaborn. + * :func:`seaborn.light_palette function` to generate a lighter color palettes. + * `Matplotlib color names `_ + """ + # Check input + list_names = [ut.STR_CMAP_CPP, ut.STR_CMAP_SHAP, ut.STR_CMAP_CAT] + if name not in list_names: + raise ValueError(f"'name' must be one of following: {list_names}") + ut.check_bool(name="facecolor_dark", val=facecolor_dark) + + # Get color maps + if name == ut.STR_CMAP_SHAP: + ut.check_number_range(name="n_colors", val=n_colors, min_val=3, just_int=True) + return _get_shap_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark) + elif name == ut.STR_CMAP_CPP: + ut.check_number_range(name="n_colors", val=n_colors, min_val=3, just_int=True) + return _get_cpp_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark) + elif name == ut.STR_CMAP_CAT: + ut.check_number_range(name="n_colors", val=n_colors, min_val=2, max_val=9, just_int=True) + return _get_tab_color(n_colors=n_colors) diff --git a/aaanalysis/plotting/plot_set_legend_.py b/aaanalysis/plotting/plot_set_legend_.py new file mode 100644 index 00000000..beda4d8d --- /dev/null +++ b/aaanalysis/plotting/plot_set_legend_.py @@ -0,0 +1,158 @@ +""" +This is a script for setting plot legend. +""" +from typing import Optional, List, Dict, Union, Tuple +import matplotlib as mpl +from matplotlib import pyplot as plt +from aaanalysis import utils as ut + +# I Helper functions +# Checking functions +def check_cats(list_cat=None, dict_color=None, labels=None): + """""" + ut.check_dict(name="dict_color", val=dict_color, accept_none=False) + if labels is not None: + if list_cat is not None: + if len(list_cat) != len(labels): + raise ValueError(f"Length of 'list_cat' ({len(list_cat)}) and 'labels' ({len(labels)}) must match") + elif len(dict_color) != len(labels): + raise ValueError(f"Length of 'dict_color' ({len(dict_color)}) and 'labels' ({len(labels)}) must match") + if list_cat is None: + list_cat = list(dict_color.keys()) + else: + raise ValueError("'list_cat' and 'dict_color' should not be None") + return list_cat + +# Helper functions +def _create_marker(color, category, shape, lw, edgecolor): + if shape is None: + args = {'facecolor': color, 'label': category, 'lw': lw} + if edgecolor: + args['edgecolor'] = edgecolor + return mpl.patches.Patch(**args) + return plt.Line2D([0], [0], marker=shape, color='w', markerfacecolor=color, markersize=10, label=category) + + + +# II Main function +# TODO check, interface, doc, test +def plot_set_legend(ax: Optional[plt.Axes] = None, + handles: Optional[List] = None, + dict_color: Optional[Dict[str, str]] = None, + list_cat: Optional[List[str]] = None, + labels: Optional[List[str]] = None, + y: Optional[int] = None, + x: Optional[int] = None, + ncol: int = 3, + fontsize: Optional[int] = None, + weight: str = "normal", + lw: float = 0, + edgecolor: Optional[str] = None, + return_handles: bool = False, + loc: str = "upper left", + labelspacing: float = 0.2, + columnspacing: int = 1, + title: Optional[str] = None, + fontsize_legend: Optional[int] = None, + title_align_left: bool = True, + fontsize_weight: str = "normal", + shape: Optional[str] = None, + **kwargs) -> Union[plt.Axes, Tuple[List, List[str]]]: + """ + Set a customizable legend for a plot. + + Parameters + ---------- + ax + The axes to attach the legend to. If not provided, the current axes will be used. + handles + Handles for legend items. If not provided, they will be generated based on `dict_color` and `list_cat`. + dict_color + A dictionary mapping categories to colors. + list_cat + List of categories to include in the legend. + labels + Labels for legend items. + y + The y-coordinate for the legend's anchor point. + x + The x-coordinate for the legend's anchor point. + ncol + Number of columns in the legend. + fontsize + Font size for the legend text. + weight + Weight of the font. + lw + Line width for legend items. + edgecolor + Edge color for legend items. + return_handles + Whether to return handles and labels. If `True`, function returns `handles, labels` instead of the axes. + loc + Location for the legend. + labelspacing + Vertical spacing between legend items. + columnspacing + Horizontal spacing between legend columns. + title + Title for the legend. + fontsize_legend + Font size for the legend title. + title_align_left + Whether to align the title to the left. + fontsize_weight + Font weight for the legend title. + shape + Marker shape for legend items. Refer to `matplotlib.lines.Line2D` for available shapes. + + Returns + ------- + ax + The axes with the legend applied. If `return_handles=True`, it returns handles and labels instead. + + Examples + -------- + >>> import aaanalysis as aa + >>> aa.plot_set_legend(ax=ax, dict_color={'Cat1': 'red', 'Cat2': 'blue'}, shape='o') + + See Also + -------- + matplotlib.pyplot.legend + For additional details on how the 'loc' parameter can be customized. + matplotlib.lines.Line2D + For details on the different types of marker shapes ('shape' parameter). + """ + + # Check input + if ax is None: + ax = plt.gca() + list_cat = check_cats(list_cat=list_cat, dict_color=dict_color, labels=labels) + args_float = {"y": y, "x": x, "lw": lw, "labelspacing": labelspacing, + "columnspacing": columnspacing} + for key in args_float: + ut.check_number_val(name=key, val=args_float[key], just_int=False) + ut.check_number_range(name="ncol", val=ncol, min_val=1, just_int=True, accept_none=True) + ut.check_bool(name="return_handles", val=return_handles) + ut.check_bool(name="title_align_left", val=title_align_left) + + # TODO check other args + # Generate legend items if not provided + if not handles and dict_color and list_cat: + handles = [_create_marker(dict_color[cat], cat, shape, lw, edgecolor) for cat in list_cat] + + # Return handles and labels if required + if return_handles: + return handles, labels if labels else list_cat + # Set up legend properties + labels = labels or list_cat + args = dict(prop={"weight": weight, "size": fontsize}, **kwargs) + if fontsize_legend: + args["title_fontproperties"] = {"weight": fontsize_weight, "size": fontsize_legend} + # Create the legend + legend = ax.legend(handles=handles, labels=labels, bbox_to_anchor=(x, y), ncol=ncol, loc=loc, + labelspacing=labelspacing, columnspacing=columnspacing, borderpad=0, **args, title=title) + # Align title if needed + if title_align_left: + legend._legend_box.align = "left" + return ax diff --git a/aaanalysis/plotting/plot_settings_.py b/aaanalysis/plotting/plot_settings_.py new file mode 100644 index 00000000..53d61f6a --- /dev/null +++ b/aaanalysis/plotting/plot_settings_.py @@ -0,0 +1,217 @@ +""" +Plotting utility functions for AAanalysis to create publication ready figures. Can +be used for any Python project independently of AAanalysis. +""" +import seaborn as sns +import matplotlib as mpl +import matplotlib.pyplot as plt +import aaanalysis.utils as ut +import warnings + +LIST_FONTS = ['Arial', 'Avant Garde', + 'Bitstream Vera Sans', 'Computer Modern Sans Serif', + 'DejaVu Sans', 'Geneva', + 'Helvetica', 'Lucid', + 'Lucida Grande', 'Verdana'] + + +# I Helper functions +# Check plot_settings +def check_font(font="Arial"): + """""" + if font not in LIST_FONTS: + error_message = f"'font' ({font}) not in recommended fonts: {LIST_FONTS}. Set font manually by:" \ + f"\n\tplt.rcParams['font.sans-serif'] = '{font}'" + raise ValueError(error_message) + + +def check_fig_format(fig_format="pdf"): + """""" + list_fig_formats = ['eps', 'jpg', 'jpeg', 'pdf', 'pgf', 'png', 'ps', + 'raw', 'rgba', 'svg', 'svgz', 'tif', 'tiff', 'webp'] + ut.check_str(name="fig_format", val=fig_format) + if fig_format not in list_fig_formats: + raise ValueError(f"'fig_format' should be one of following: {list_fig_formats}") + + +def check_grid_axis(grid_axis="y"): + list_grid_axis = ["y", "x", "both"] + if grid_axis not in list_grid_axis: + raise ValueError(f"'grid_axis' ({grid_axis}) should be one of following: {list_grid_axis}") + + +# II Main functions +def plot_settings(font_scale: float = 1, + font: str = "Arial", + fig_format: str = "pdf", + weight_bold: bool = True, + adjust_only_font: bool = False, + adjust_further_elements: bool = True, + grid: bool = False, + grid_axis: str = "y", + no_ticks: bool = False, + short_ticks: bool = False, + no_ticks_x: bool = False, + short_ticks_x: bool = False, + no_ticks_y: bool = False, + short_ticks_y: bool = False, + show_options: bool = False) -> None: + """ + Configure general settings for plot visualization with various customization options. + + This function modifies the global settings of :mod:`matplotlib` and :mod:`seaborn` libraries. + PDFs are embedded such that they can be edited using image editing software. + + Parameters + ---------- + font_scale + Scaling factor to scale the size of font elements. Consistent with :func:`seaborn.set_context`. + font + Name of text font. Common options are 'Arial', 'Verdana', 'Helvetica', or 'DejaVu Sans' (Matplotlib default). + fig_format + Specifies the file format for saving plots. Most backends support png, pdf, ps, eps and svg. + weight_bold + If ``True``, font and line elements are bold. + adjust_only_font + If ``True``, only the font style will be adjusted, leaving other elements unchanged. + adjust_further_elements + If ``True``, makes additional visual and layout adjustments to the plot (errorbars, legend). + grid + If ``True``, display the grid in plots. + grid_axis + Choose the axis ('y', 'x', 'both') to apply the grid to. + no_ticks + If ``True``, remove all tick marks on both x and y axes. + short_ticks + If ``True``, display short tick marks on both x and y axes. Is ignored if ``no_ticks=True``. + no_ticks_x + If ``True``, remove tick marks on the x-axis. + short_ticks_x + If ``True``, display short tick marks on the x-axis. Is ignored if ``no_ticks=True``. + no_ticks_y + If ``True``, remove tick marks on the y-axis. + short_ticks_y + If ``True``, display short tick marks on the y-axis. Is ignored if ``no_ticks=True``. + show_options + If ``True``, show all plot runtime configurations of matplotlib. + + Examples + -------- + Create default seaborn plot: + + .. plot:: + :include-source: + + >>> import matplotlib.pyplot as plt + >>> import seaborn as sns + >>> import aaanalysis as aa + >>> data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} + >>> sns.barplot(x='Classes', y='Values', data=data) + >>> sns.despine() + >>> plt.title("Seaborn default") + >>> plt.tight_layout() + >>> plt.show() + + Adjust polts with AAanalysis: + + .. plot:: + :include-source: + + >>> import matplotlib.pyplot as plt + >>> import seaborn as sns + >>> import aaanalysis as aa + >>> data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} + >>> colors = aa.plot_get_cmap(name="CAT", n_colors=3) + >>> aa.plot_settings() + >>> sns.barplot(x='Classes', y='Values', data=data, palette=colors) + >>> sns.despine() + >>> plt.title("Adjusted") + >>> plt.tight_layout() + >>> plt.show() + + See Also + -------- + * :func:`seaborn.set_context`, where ``font_scale`` is utilized. + * :data:`matplotlib.rcParams`, which manages the global settings in :mod:`matplotlib`. + """ + # Check input + ut.check_number_range(name="font_scale", val=font_scale, min_val=0, just_int=False) + check_font(font=font) + check_fig_format(fig_format=fig_format) + check_grid_axis(grid_axis=grid_axis) + args_bool = {"weight_bold": weight_bold, "adjust_only_font": adjust_only_font, + "adjust_further_elements": adjust_further_elements, "grid": grid, + "short_ticks": short_ticks, "short_ticks_x": short_ticks_x, "short_ticks_y": short_ticks_y, + "no_ticks": no_ticks, "no_ticks_y": no_ticks_y, "no_ticks_x": no_ticks_x, + "show_options": show_options,} + for key in args_bool: + ut.check_bool(name=key, val=args_bool[key]) + + # Warning + if no_ticks and any([short_ticks, short_ticks_x, short_ticks_y]): + warnings.warn("`no_ticks` is set to True, so 'short_ticks' parameters will be ignored.") + if no_ticks_x and short_ticks_x: + warnings.warn("`no_ticks_x` is set to True, so 'short_ticks_x' will be ignored.") + if no_ticks_y and short_ticks_y: + warnings.warn("`no_ticks_y` is set to True, so 'short_ticks_y' will be ignored.") + + # Print all plot settings/runtime configurations of matplotlib + if show_options: + print(plt.rcParams.keys) + + # Set embedded fonts in PDF + mpl.rcParams.update(mpl.rcParamsDefault) + mpl.rcParams["pdf.fonttype"] = 42 + + # Change only font style + if adjust_only_font: + plt.rcParams["font.family"] = "sans-serif" + plt.rcParams["font.sans-serif"] = font + return + + # Apply all changes + sns.set_context("talk", font_scale=font_scale) + # Font settings + plt.rcParams["font.family"] = "sans-serif" + plt.rcParams["font.sans-serif"] = font + font_settings = {'family': 'sans-serif', "weight": "bold"} if weight_bold else {'family': 'sans-serif'} + mpl.rc('font', **font_settings) + # Grid + plt.rcParams["axes.grid.axis"] = grid_axis + plt.rcParams["axes.grid"] = grid + # Adjust weight of text and lines + if weight_bold: + plt.rcParams["axes.labelweight"] = "bold" + plt.rcParams["axes.titleweight"] = "bold" + else: + plt.rcParams["axes.linewidth"] = 1 + plt.rcParams["xtick.major.width"] = 0.8 + plt.rcParams["xtick.minor.width"] = 0.6 + plt.rcParams["ytick.major.width"] = 0.8 + plt.rcParams["ytick.minor.width"] = 0.6 + # Handle tick options (short are default matplotlib options, otherwise from seaborn) + if short_ticks or short_ticks_x: + plt.rcParams["xtick.major.size"] = 3.5 + plt.rcParams["xtick.minor.size"] = 2 + if short_ticks or short_ticks_y: + plt.rcParams["ytick.major.size"] = 3.5 + plt.rcParams["ytick.minor.size"] = 2 + if no_ticks or no_ticks_x: + plt.rcParams["xtick.major.size"] = 0 + plt.rcParams["xtick.minor.size"] = 0 + if no_ticks or no_ticks_y: + plt.rcParams["ytick.major.size"] = 0 + plt.rcParams["ytick.minor.size"] = 0 + # Handle figure format + if fig_format == "pdf": + mpl.rcParams['pdf.fonttype'] = 42 + elif "svg" in fig_format: + mpl.rcParams['svg.fonttype'] = 'none' + # Additional adjustments + if adjust_further_elements: + # Error bars + plt.rcParams["errorbar.capsize"] = 10 + # Legend + plt.rcParams["legend.frameon"] = False + plt.rcParams["legend.fontsize"] = "medium" + plt.rcParams["legend.loc"] = 'upper right' diff --git a/aaanalysis/plotting/plotting_functions.py b/aaanalysis/plotting/plotting_functions.py deleted file mode 100644 index 1cb1c2de..00000000 --- a/aaanalysis/plotting/plotting_functions.py +++ /dev/null @@ -1,542 +0,0 @@ -""" -Plotting utility functions for AAanalysis to create publication ready figures. Can -be used for any Python project independently of AAanalysis. -""" -import seaborn as sns -import matplotlib as mpl -import matplotlib.pyplot as plt -import aaanalysis.utils as ut -from typing import List, Union, Tuple, Dict, Optional -import warnings - -LIST_FONTS = ['Arial', 'Avant Garde', - 'Bitstream Vera Sans', 'Computer Modern Sans Serif', - 'DejaVu Sans', 'Geneva', - 'Helvetica', 'Lucid', - 'Lucida Grande', 'Verdana'] - - -# I Helper functions -# Check plot_settings -def check_font(font="Arial"): - """""" - if font not in LIST_FONTS: - error_message = f"'font' ({font}) not in recommended fonts: {LIST_FONTS}. Set font manually by:" \ - f"\n\tplt.rcParams['font.sans-serif'] = '{font}'" - raise ValueError(error_message) - - -def check_fig_format(fig_format="pdf"): - """""" - list_fig_formats = ['eps', 'jpg', 'jpeg', 'pdf', 'pgf', 'png', 'ps', - 'raw', 'rgba', 'svg', 'svgz', 'tif', 'tiff', 'webp'] - ut.check_str(name="fig_format", val=fig_format) - if fig_format not in list_fig_formats: - raise ValueError(f"'fig_format' should be one of following: {list_fig_formats}") - - -def check_grid_axis(grid_axis="y"): - list_grid_axis = ["y", "x", "both"] - if grid_axis not in list_grid_axis: - raise ValueError(f"'grid_axis' ({grid_axis}) should be one of following: {list_grid_axis}") - - -# Check plot_set_legend -def check_cats(list_cat=None, dict_color=None, labels=None): - """""" - ut.check_dict(name="dict_color", val=dict_color, accept_none=False) - if labels is not None: - if list_cat is not None: - if len(list_cat) != len(labels): - raise ValueError(f"Length of 'list_cat' ({len(list_cat)}) and 'labels' ({len(labels)}) must match") - elif len(dict_color) != len(labels): - raise ValueError(f"Length of 'dict_color' ({len(dict_color)}) and 'labels' ({len(labels)}) must match") - if list_cat is None: - list_cat = list(dict_color.keys()) - else: - raise ValueError("'list_cat' and 'dict_color' should not be None") - return list_cat - - -# Get color maps -def _get_cpp_cmap(n_colors=100, facecolor_dark=False): - """Generate a diverging color map for CPP feature values.""" - ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=2, just_int=True) - n = 5 - cmap = sns.color_palette(palette="RdBu_r", n_colors=n_colors + n * 2) - cmap_low, cmap_high = cmap[0:int((n_colors + n * 2) / 2)], cmap[int((n_colors + n * 2) / 2):] - c_middle = [(0, 0, 0)] if facecolor_dark else [cmap_low[-1]] - add_to_end = 1 # Must be added to keep list size consistent - cmap = cmap_low[0:-n] + c_middle + cmap_high[n+add_to_end:] - return cmap - - -def _get_shap_cmap(n_colors=100, facecolor_dark=True): - """Generate a diverging color map for feature values.""" - n = 20 # TODO check if 5 is better for CPP-SHAP heatmap - cmap_low = sns.light_palette(ut.COLOR_SHAP_NEG, input="hex", reverse=True, n_colors=int(n_colors/2)+n) - cmap_high = sns.light_palette(ut.COLOR_SHAP_POS, input="hex", n_colors=int(n_colors/2)+n) - c_middle = [(0, 0, 0)] if facecolor_dark else [cmap_low[-1]] - add_to_end = (n_colors+1)%2 # Must be added to keep list size consistent - cmap = cmap_low[0:-n] + c_middle + cmap_high[n+add_to_end:] - return cmap - -def _get_tab_color(n_colors=None): - """Get default color lists for up to 9 categories """ - # Base lists - list_colors_3_to_4 = ["tab:gray", "tab:blue", "tab:red", "tab:orange"] - list_colors_5_to_6 = ["tab:blue", "tab:cyan", "tab:gray","tab:red", - "tab:orange", "tab:brown"] - list_colors_8_to_9 = ["tab:blue", "tab:orange", "tab:green", "tab:red", - "tab:gray", "gold", "tab:cyan", "tab:brown", - "tab:purple"] - # Two classes - if n_colors == 2: - return ["tab:blue", "tab:red"] - # Control/base + 2-3 classes - elif n_colors in [3, 4]: - return list_colors_3_to_4[0:n_colors] - # 5-7 classes (gray in middle as visual "breather") - elif n_colors in [5, 6]: - return list_colors_5_to_6[0:n_colors] - elif n_colors == 7: - return ["tab:blue", "tab:cyan", "tab:purple", "tab:gray", - "tab:red", "tab:orange", "tab:brown"] - # 8-9 classes (colors from scale categories) - elif n_colors in [8, 9]: - return list_colors_8_to_9[0:n_colors] - -# TODO check if needed later -def _get_cmap_with_gap(n_colors=100, pct_gap=10, pct_center=None, - color_pos=None, color_neg=None, color_center=None, input="hex"): - """Generate a custom color map with a gap. - - """ - n_gap = int(n_colors*pct_gap/2) - cmap_pos = sns.light_palette(color_pos, input=input, n_colors=int(n_colors/2)+n_gap) - cmap_neg = sns.light_palette(color_neg, input=input, reverse=True, n_colors=int(n_colors/2)+n_gap) - color_center = [cmap_neg[-1]] if color_center is None else color_center - color_center = [color_center] if type(color_center) is str else color_center - if pct_center is None: - cmap = cmap_neg[0:-n_gap] + color_center + cmap_pos[n_gap:] - else: - n_center = int(n_colors * pct_center) - n_gap += int(n_center/2) - cmap = cmap_neg[0:-n_gap] + color_center * n_center + cmap_pos[n_gap:] - return cmap - - -# II Main functions -# Plotting colors -def plot_get_cmap(name: str = "CPP", - n_colors: int = 101, - facecolor_dark: bool = False - ) -> Union[List[Tuple[float, float, float]], List[str]]: - """ - Returns color maps specified for AAanalysis. - - Parameters - ---------- - name - The name of the AAanalysis color palettes. - - - ``CPP``: Continuous color map for CPP plots. - - ``SHAP``: Continuous color map for CPP-SHP plots. - - ``CAT``: Color list for appealing visualization of categories. - - n_colors - Number of colors in the color map. Must be >=2 for 'CPP' and 'SHAP' and 2-9 for 'CAT'. - facecolor_dark - Whether central color in 'CPP' and 'SHAP' is black (if ``True``) or white. - - Returns - ------- - list - List with colors given as RGB tuples (for 'CPP' and 'SHAP') or matplotlib color names (for 'CAT'). - - Examples - -------- - .. plot:: - :include-source: - - >>> import matplotlib.pyplot as plt - >>> import seaborn as sns - >>> import aaanalysis as aa - >>> colors = aa.plot_get_cmap(name="CAT", n_colors=4) - >>> data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]} - >>> aa.plot_settings(no_ticks_x=True, font_scale=1.2) - >>> sns.barplot(x='Classes', y='Values', data=data, palette=colors) - >>> plt.show() - - See Also - -------- - * Example notebooks in `Plotting Prelude `_. - * :func:`seaborn.color_palette` function to generate a color palette in seaborn. - * :func:`seaborn.light_palette function` to generate a lighter color palettes. - * `Matplotlib color names `_ - """ - # Check input - list_names = [ut.STR_CMAP_CPP, ut.STR_CMAP_SHAP, ut.STR_CMAP_CAT] - if name not in list_names: - raise ValueError(f"'name' must be one of following: {list_names}") - ut.check_bool(name="facecolor_dark", val=facecolor_dark) - - # Get color maps - if name == ut.STR_CMAP_SHAP: - ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=3, just_int=True) - return _get_shap_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark) - elif name == ut.STR_CMAP_CPP: - ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=3, just_int=True) - return _get_cpp_cmap(n_colors=n_colors, facecolor_dark=facecolor_dark) - elif name == ut.STR_CMAP_CAT: - ut.check_non_negative_number(name="n_colors", val=n_colors, min_val=2, max_val=9, just_int=True) - return _get_tab_color(n_colors=n_colors) - - -def plot_get_cdict(name: str = "DICT_COLOR") -> dict: - """ - Returns color dictionaries specified for AAanalysis. - - Parameters - ---------- - name - The name of the AAanalysis color dictionary. - - - ``DICT_COLOR``: Dictionary with default colors for plots. - - ``DICT_CAT``: Dictionary with default colors for scale categories. - - Returns - ------- - dict - AAanalysis color dictionary. - - Examples - -------- - >>> import aaanalysis as aa - >>> dict_color = aa.plot_get_cdict(name="DICT_COLOR") - - """ - list_names = [ut.STR_DICT_COLOR, ut.STR_DICT_CAT] - if name not in list_names: - raise ValueError(f"'name' must be one of following: {list_names}") - if name == ut.STR_DICT_COLOR: - return ut.DICT_COLOR - else: - return ut.DICT_COLOR_CAT - - -# Plotting adjuster -def plot_settings(font_scale: float = 1, - font: str = "Arial", - fig_format: str = "pdf", - weight_bold: bool = True, - adjust_only_font: bool = False, - adjust_further_elements: bool = True, - grid: bool = False, - grid_axis: str = "y", - no_ticks: bool = False, - short_ticks: bool = False, - no_ticks_x: bool = False, - short_ticks_x: bool = False, - no_ticks_y: bool = False, - short_ticks_y: bool = False, - show_options: bool = False) -> None: - """ - Configure general settings for plot visualization with various customization options. - - This function modifies the global settings of :mod:`matplotlib` and :mod:`seaborn` libraries. - PDFs are embedded such that they can be edited using image editing software. - - Parameters - ---------- - font_scale - Scaling factor to scale the size of font elements. Consistent with :func:`seaborn.set_context`. - font - Name of text font. Common options are 'Arial', 'Verdana', 'Helvetica', or 'DejaVu Sans' (Matplotlib default). - fig_format - Specifies the file format for saving plots. Most backends support png, pdf, ps, eps and svg. - weight_bold - If ``True``, font and line elements are bold. - adjust_only_font - If ``True``, only the font style will be adjusted, leaving other elements unchanged. - adjust_further_elements - If ``True``, makes additional visual and layout adjustments to the plot (errorbars, legend). - grid - If ``True``, display the grid in plots. - grid_axis - Choose the axis ('y', 'x', 'both') to apply the grid to. - no_ticks - If ``True``, remove all tick marks on both x and y axes. - short_ticks - If ``True``, display short tick marks on both x and y axes. Is ignored if ``no_ticks=True``. - no_ticks_x - If ``True``, remove tick marks on the x-axis. - short_ticks_x - If ``True``, display short tick marks on the x-axis. Is ignored if ``no_ticks=True``. - no_ticks_y - If ``True``, remove tick marks on the y-axis. - short_ticks_y - If ``True``, display short tick marks on the y-axis. Is ignored if ``no_ticks=True``. - show_options - If ``True``, show all plot runtime configurations of matplotlib. - - Examples - -------- - Create default seaborn plot: - - .. plot:: - :include-source: - - >>> import matplotlib.pyplot as plt - >>> import seaborn as sns - >>> import aaanalysis as aa - >>> data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} - >>> sns.barplot(x='Classes', y='Values', data=data) - >>> sns.despine() - >>> plt.title("Seaborn default") - >>> plt.tight_layout() - >>> plt.show() - - Adjust polts with AAanalysis: - - .. plot:: - :include-source: - - >>> import matplotlib.pyplot as plt - >>> import seaborn as sns - >>> import aaanalysis as aa - >>> data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} - >>> colors = aa.plot_get_cmap(name="CAT", n_colors=3) - >>> aa.plot_settings() - >>> sns.barplot(x='Classes', y='Values', data=data, palette=colors) - >>> sns.despine() - >>> plt.title("Adjusted") - >>> plt.tight_layout() - >>> plt.show() - - See Also - -------- - * :func:`seaborn.set_context`, where ``font_scale`` is utilized. - * :data:`matplotlib.rcParams`, which manages the global settings in :mod:`matplotlib`. - """ - # Check input - ut.check_non_negative_number(name="font_scale", val=font_scale, min_val=0, just_int=False) - check_font(font=font) - check_fig_format(fig_format=fig_format) - check_grid_axis(grid_axis=grid_axis) - args_bool = {"weight_bold": weight_bold, "adjust_only_font": adjust_only_font, - "adjust_further_elements": adjust_further_elements, "grid": grid, - "short_ticks": short_ticks, "short_ticks_x": short_ticks_x, "short_ticks_y": short_ticks_y, - "no_ticks": no_ticks, "no_ticks_y": no_ticks_y, "no_ticks_x": no_ticks_x, - "show_options": show_options,} - for key in args_bool: - ut.check_bool(name=key, val=args_bool[key]) - - # Warning - if no_ticks and any([short_ticks, short_ticks_x, short_ticks_y]): - warnings.warn("`no_ticks` is set to True, so 'short_ticks' parameters will be ignored.") - if no_ticks_x and short_ticks_x: - warnings.warn("`no_ticks_x` is set to True, so 'short_ticks_x' will be ignored.") - if no_ticks_y and short_ticks_y: - warnings.warn("`no_ticks_y` is set to True, so 'short_ticks_y' will be ignored.") - - # Print all plot settings/runtime configurations of matplotlib - if show_options: - print(plt.rcParams.keys) - - # Set embedded fonts in PDF - mpl.rcParams.update(mpl.rcParamsDefault) - mpl.rcParams["pdf.fonttype"] = 42 - - # Change only font style - if adjust_only_font: - plt.rcParams["font.family"] = "sans-serif" - plt.rcParams["font.sans-serif"] = font - return - - # Apply all changes - sns.set_context("talk", font_scale=font_scale) - # Font settings - plt.rcParams["font.family"] = "sans-serif" - plt.rcParams["font.sans-serif"] = font - font_settings = {'family': 'sans-serif', "weight": "bold"} if weight_bold else {'family': 'sans-serif'} - mpl.rc('font', **font_settings) - # Grid - plt.rcParams["axes.grid.axis"] = grid_axis - plt.rcParams["axes.grid"] = grid - # Adjust weight of text and lines - if weight_bold: - plt.rcParams["axes.labelweight"] = "bold" - plt.rcParams["axes.titleweight"] = "bold" - else: - plt.rcParams["axes.linewidth"] = 1 - plt.rcParams["xtick.major.width"] = 0.8 - plt.rcParams["xtick.minor.width"] = 0.6 - plt.rcParams["ytick.major.width"] = 0.8 - plt.rcParams["ytick.minor.width"] = 0.6 - # Handle tick options (short are default matplotlib options, otherwise from seaborn) - if short_ticks or short_ticks_x: - plt.rcParams["xtick.major.size"] = 3.5 - plt.rcParams["xtick.minor.size"] = 2 - if short_ticks or short_ticks_y: - plt.rcParams["ytick.major.size"] = 3.5 - plt.rcParams["ytick.minor.size"] = 2 - if no_ticks or no_ticks_x: - plt.rcParams["xtick.major.size"] = 0 - plt.rcParams["xtick.minor.size"] = 0 - if no_ticks or no_ticks_y: - plt.rcParams["ytick.major.size"] = 0 - plt.rcParams["ytick.minor.size"] = 0 - # Handle figure format - if fig_format == "pdf": - mpl.rcParams['pdf.fonttype'] = 42 - elif "svg" in fig_format: - mpl.rcParams['svg.fonttype'] = 'none' - # Additional adjustments - if adjust_further_elements: - # Error bars - plt.rcParams["errorbar.capsize"] = 10 - # Legend - plt.rcParams["legend.frameon"] = False - plt.rcParams["legend.fontsize"] = "medium" - plt.rcParams["legend.loc"] = 'upper right' - - -def plot_gcfs(): - """Get current font size, which is set by :func:`plot_settings` function.""" - # Get the current plotting context - current_context = sns.plotting_context() - font_size = current_context['font.size'] - return font_size - -# TODO check, interface, doc, test - -def plot_set_legend(ax: Optional[plt.Axes] = None, - handles: Optional[List] = None, - dict_color: Optional[Dict[str, str]] = None, - list_cat: Optional[List[str]] = None, - labels: Optional[List[str]] = None, - y: Optional[int] = None, - x: Optional[int] = None, - ncol: int = 3, - fontsize: Optional[int] = None, - weight: str = "normal", - lw: float = 0, - edgecolor: Optional[str] = None, - return_handles: bool = False, - loc: str = "upper left", - labelspacing: float = 0.2, - columnspacing: int = 1, - title: Optional[str] = None, - fontsize_legend: Optional[int] = None, - title_align_left: bool = True, - fontsize_weight: str = "normal", - shape: Optional[str] = None, - **kwargs) -> Union[plt.Axes, Tuple[List, List[str]]]: - """ - Set a customizable legend for a plot. - - Parameters - ---------- - ax - The axes to attach the legend to. If not provided, the current axes will be used. - handles - Handles for legend items. If not provided, they will be generated based on `dict_color` and `list_cat`. - dict_color - A dictionary mapping categories to colors. - list_cat - List of categories to include in the legend. - labels - Labels for legend items. - y - The y-coordinate for the legend's anchor point. - x - The x-coordinate for the legend's anchor point. - ncol - Number of columns in the legend. - fontsize - Font size for the legend text. - weight - Weight of the font. - lw - Line width for legend items. - edgecolor - Edge color for legend items. - return_handles - Whether to return handles and labels. If `True`, function returns `handles, labels` instead of the axes. - loc - Location for the legend. - labelspacing - Vertical spacing between legend items. - columnspacing - Horizontal spacing between legend columns. - title - Title for the legend. - fontsize_legend - Font size for the legend title. - title_align_left - Whether to align the title to the left. - fontsize_weight - Font weight for the legend title. - shape - Marker shape for legend items. Refer to `matplotlib.lines.Line2D` for available shapes. - - Returns - ------- - ax - The axes with the legend applied. If `return_handles=True`, it returns handles and labels instead. - - Examples - -------- - >>> import aaanalysis as aa - >>> aa.plot_set_legend(ax=ax, dict_color={'Cat1': 'red', 'Cat2': 'blue'}, shape='o') - - See Also - -------- - matplotlib.pyplot.legend - For additional details on how the 'loc' parameter can be customized. - matplotlib.lines.Line2D - For details on the different types of marker shapes ('shape' parameter). - """ - - # Check input - if ax is None: - ax = plt.gca() - list_cat = check_cats(list_cat=list_cat, dict_color=dict_color, labels=labels) - args_float = {"y": y, "x": x, "lw": lw, "labelspacing": labelspacing, - "columnspacing": columnspacing} - for key in args_float: - ut.check_float(name=key, val=args_float[key]) - ut.check_non_negative_number(name="ncol", val=ncol, min_val=1, just_int=True, accept_none=True) - ut.check_bool(name="return_handles", val=return_handles) - ut.check_bool(name="title_align_left", val=title_align_left) - - # TODO check other args - # Function to create legend markers - def create_marker(color, category): - if shape is None: - args = {'facecolor': color, 'label': category, 'lw': lw} - if edgecolor: - args['edgecolor'] = edgecolor - return mpl.patches.Patch(**args) - return plt.Line2D([0], [0], marker=shape, color='w', markerfacecolor=color, markersize=10, label=category) - - # Generate legend items if not provided - if not handles and dict_color and list_cat: - handles = [create_marker(dict_color[cat], cat) for cat in list_cat] - - # Return handles and labels if required - if return_handles: - return handles, labels if labels else list_cat - # Set up legend properties - labels = labels or list_cat - args = dict(prop={"weight": weight, "size": fontsize}, **kwargs) - if fontsize_legend: - args["title_fontproperties"] = {"weight": fontsize_weight, "size": fontsize_legend} - # Create the legend - legend = ax.legend(handles=handles, labels=labels, bbox_to_anchor=(x, y), ncol=ncol, loc=loc, - labelspacing=labelspacing, columnspacing=columnspacing, borderpad=0, **args, title=title) - # Align title if needed - if title_align_left: - legend._legend_box.align = "left" - return ax diff --git a/aaanalysis/utils.py b/aaanalysis/utils.py index 0dc60b15..05a6b9bd 100644 --- a/aaanalysis/utils.py +++ b/aaanalysis/utils.py @@ -8,7 +8,8 @@ import numpy as np # Import utility functions explicitly -from aaanalysis._utils._utils_check import (check_non_negative_number, check_float, check_str, check_bool, +from aaanalysis._utils._utils_check import (check_number_range, check_number_val, + check_str, check_bool, check_dict, check_tuple, check_feat_matrix, check_col_in_df) from aaanalysis._utils._utils_output import (print_red, print_start_progress, print_progress, print_finished_progress) @@ -183,8 +184,8 @@ def check_df_seq(df_seq=None, jmd_n_len=None, jmd_c_len=None): if seq_in_df and not parts_in_df: if seq_info_in_df: for entry, start, stop in zip(df_seq[COL_ENTRY], df_seq[COL_TMD_START], df_seq[COL_TMD_STOP]): - check_non_negative_number(name=f"tmd_start [{entry}]", val=start, just_int=True) - check_non_negative_number(name=f"tmd_start [{entry}]", val=stop, just_int=True) + check_number_range(name=f"tmd_start [{entry}]", val=start, just_int=True) + check_number_range(name=f"tmd_start [{entry}]", val=stop, just_int=True) tmd_start = [int(x) for x in df_seq[COL_TMD_START]] tmd_stop = [int(x) for x in df_seq[COL_TMD_STOP]] else: diff --git a/docs/build/html/_downloads/2a58656d4cb61bad4f791aca80114c58/aaanalysis-plot_settings-2.py b/docs/build/html/_downloads/2a58656d4cb61bad4f791aca80114c58/aaanalysis-plot_settings-2.py index 3d0cf45c..913cb0b4 100644 --- a/docs/build/html/_downloads/2a58656d4cb61bad4f791aca80114c58/aaanalysis-plot_settings-2.py +++ b/docs/build/html/_downloads/2a58656d4cb61bad4f791aca80114c58/aaanalysis-plot_settings-2.py @@ -1,6 +1,8 @@ import matplotlib.pyplot as plt import seaborn as sns import aaanalysis as aa +import aaanalysis.plotting.plot_get_cmap_ + data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} colors = aa.plot_get_cmap(name="CAT", n_colors=3) aa.plot_settings() diff --git a/docs/build/html/_downloads/b89a5a5e2e370853db1a08a17e57d011/aaanalysis-plot_get_cmap-1.py b/docs/build/html/_downloads/b89a5a5e2e370853db1a08a17e57d011/aaanalysis-plot_get_cmap-1.py index a7a0a0ad..c3454347 100644 --- a/docs/build/html/_downloads/b89a5a5e2e370853db1a08a17e57d011/aaanalysis-plot_get_cmap-1.py +++ b/docs/build/html/_downloads/b89a5a5e2e370853db1a08a17e57d011/aaanalysis-plot_get_cmap-1.py @@ -1,6 +1,8 @@ import matplotlib.pyplot as plt import seaborn as sns import aaanalysis as aa +import aaanalysis.plotting.plot_get_cmap_ + colors = aa.plot_get_cmap(name="CAT", n_colors=4) data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]} aa.plot_settings(no_ticks_x=True, font_scale=1.2) diff --git a/docs/build/plot_directive/generated/aaanalysis-plot_get_cmap-1.py b/docs/build/plot_directive/generated/aaanalysis-plot_get_cmap-1.py index a7a0a0ad..c3454347 100644 --- a/docs/build/plot_directive/generated/aaanalysis-plot_get_cmap-1.py +++ b/docs/build/plot_directive/generated/aaanalysis-plot_get_cmap-1.py @@ -1,6 +1,8 @@ import matplotlib.pyplot as plt import seaborn as sns import aaanalysis as aa +import aaanalysis.plotting.plot_get_cmap_ + colors = aa.plot_get_cmap(name="CAT", n_colors=4) data = {'Classes': ['Class A', 'Class B', 'Class C', "Class D"], 'Values': [23, 27, 43, 38]} aa.plot_settings(no_ticks_x=True, font_scale=1.2) diff --git a/docs/build/plot_directive/generated/aaanalysis-plot_settings-2.py b/docs/build/plot_directive/generated/aaanalysis-plot_settings-2.py index 3d0cf45c..913cb0b4 100644 --- a/docs/build/plot_directive/generated/aaanalysis-plot_settings-2.py +++ b/docs/build/plot_directive/generated/aaanalysis-plot_settings-2.py @@ -1,6 +1,8 @@ import matplotlib.pyplot as plt import seaborn as sns import aaanalysis as aa +import aaanalysis.plotting.plot_get_cmap_ + data = {'Classes': ['Class A', 'Class B', 'Class C'], 'Values': [23, 27, 43]} colors = aa.plot_get_cmap(name="CAT", n_colors=3) aa.plot_settings() diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/08a8943010657a68 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/08a8943010657a68 new file mode 100644 index 0000000000000000000000000000000000000000..f910cf4d36720657b9c7e48a6794857317536874 GIT binary patch literal 26 gcmZQ%WSGYwzm|a^?k^)FBS+9G1_lF$b_O5-07F9rh5!Hn literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/0f8c06e51312863b b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/0f8c06e51312863b new file mode 100644 index 0000000000000000000000000000000000000000..c08760b4160fc13f29a6866f61825cdd44a31912 GIT binary patch literal 26 ecmZQ%WSGYwzm|a^?k^)FBS+9G1_lELFaQ8RpacH^ literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/1c250cdc9b08f1d7 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/1c250cdc9b08f1d7 new file mode 100644 index 0000000000000000000000000000000000000000..2636331aa4f10df0d102051a7610e14d5db55156 GIT binary patch literal 24 VcmZQ%WSGYw&j139j9>~v000l80KxzO literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/2328c0eb29579fb9 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/2328c0eb29579fb9 new file mode 100644 index 0000000000000000000000000000000000000000..e8a4d51898452c9a56af4e077716f8b728b60b07 GIT binary patch literal 26 hcmZQ%WSGYwzm|a^?k^)FBS+9G1_lF$_Rv)fEC5EC1&IIv literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/48823cffadcf5186 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/48823cffadcf5186 new file mode 100644 index 0000000000000000000000000000000000000000..679a8eec00c2fec6b9f92ca31b4d0bfb6c96d4e9 GIT binary patch literal 26 hcmZQ%WaJ21#SpqmxLw$Qk&$5@gZx?#kGQ`KEC5MS20s7* literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/5dc6257654107074 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/5dc6257654107074 new file mode 100644 index 0000000000000000000000000000000000000000..f4c2801b86c5abd6b0da2a0a857b69f02773c376 GIT binary patch literal 26 hcmZQ%WSGYwzm|a^?k^)FBS+9G1_lF$_D}`}1^`5t1ls@r literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/6593a69b4839cb20 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/6593a69b4839cb20 new file mode 100644 index 0000000000000000000000000000000000000000..b4ac4d02bf1255f034e116f176893c3f6013f5b5 GIT binary patch literal 26 hcmZQ%WSGYwzt+Pe?k^)FBS+9G24Mr?_Rv)fEC5mq20s7* literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/88c8de4e225144f7 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/88c8de4e225144f7 new file mode 100644 index 0000000000000000000000000000000000000000..10459e052cfe98b0dcf035088ae97962fc23fca0 GIT binary patch literal 24 TcmZQ%WSGYQ0gQ}L28aRx4ORf7 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/892e20e928f1e99f b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/892e20e928f1e99f new file mode 100644 index 0000000000000000000000000000000000000000..33908f166732b7c7648b1b31eba30b415e8ddef2 GIT binary patch literal 26 gcmZQ%WSGYwzm|a^?k^)FBS+9G1_lF$_D~=N07jJsg#Z8m literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/9d54e309a9b7e2d0 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/9d54e309a9b7e2d0 new file mode 100644 index 0000000000000000000000000000000000000000..e05fad7188fe1cb3af9bf3ae977daabc699711b4 GIT binary patch literal 24 WcmZQ%WSGYwzm|a^j)9Sp0RaFZPXWyU literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/9f56f6bb6cd962f7 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/9f56f6bb6cd962f7 new file mode 100644 index 0000000000000000000000000000000000000000..a568635e8826aafaaee776d22025d4ad4dce185d GIT binary patch literal 26 hcmZQ%WaJ21#UN}T+#b4$k&$5@gZx?#kGQ`KEC5Df20s7* literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/af8b5b8a3bd85066 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/af8b5b8a3bd85066 new file mode 100644 index 0000000000000000000000000000000000000000..ead19871ca4604537fbe13e6c3ab6acd758068ab GIT binary patch literal 26 bcmZQ%WSGYwzm|a^?k^)FBS+9G1{eSUKTreD literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/bc2c53100ac18631 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/bc2c53100ac18631 new file mode 100644 index 0000000000000000000000000000000000000000..0a91ff0de4e76296c6d10e37803ce0a0f7e14556 GIT binary patch literal 26 hcmZQ%WaJ21#SpqmxLw$Qk&$5@gNH}lU-`8REC5OO20s7* literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/cabcde271069ed73 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/cabcde271069ed73 new file mode 100644 index 0000000000000000000000000000000000000000..9d4825bd12d7e2f45249150e93339838a170851b GIT binary patch literal 29 kcmZQ%WaJ21#SpqmxLw$Qk&$5@BSQm&hezCB`Lzrz09lU)zyJUM literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/cac54aaab9476b06 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/cac54aaab9476b06 new file mode 100644 index 0000000000000000000000000000000000000000..964cb0597fec82c5c94e8997412bcb8eee2eaa6c GIT binary patch literal 26 hcmZQ%WSGYwzm|a^?k^)FBS+9G24Mr?_Rv)fEC5HN1+M@A literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/34a18a217fcd3d50/e7ef3b694c2376e5 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/e7ef3b694c2376e5 similarity index 100% rename from tests/unit/.hypothesis/examples/34a18a217fcd3d50/e7ef3b694c2376e5 rename to tests/unit/.hypothesis/examples/08f18bcc6e95a855/e7ef3b694c2376e5 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ec6b451ee15ebb30 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ec6b451ee15ebb30 new file mode 100644 index 0000000000000000000000000000000000000000..ca805f78e711c692631c42e0f44ef208b4a04971 GIT binary patch literal 26 YcmZQ%WSGYwzm|a^?k^)FBLflu05rw|%K!iX literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/f68995865845a314 b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/f68995865845a314 new file mode 100644 index 0000000000000000000000000000000000000000..47ba616d7ceaa8636565327014cbe3015adab0c9 GIT binary patch literal 24 WcmZQ%WSGYwzm@?A7#Tq%6aWAl%>i!! literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ff510f536a8ab63a b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ff510f536a8ab63a new file mode 100644 index 0000000000000000000000000000000000000000..64eac0b21eaebc66e69751c46a0b52de345b250a GIT binary patch literal 24 ScmZQ%WME`~07e)C#03BVbpQqc literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ffc6bbdfc14bbbde b/tests/unit/.hypothesis/examples/08f18bcc6e95a855/ffc6bbdfc14bbbde new file mode 100644 index 0000000000000000000000000000000000000000..3955bfd00dfcc238c80917dbf47f19e3285a73f0 GIT binary patch literal 24 XcmZQ%WSGYwzm|a^?k^)F0|Ed5FC_xX literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/294991fa193c7e4b/38b060a751ac9638 b/tests/unit/.hypothesis/examples/294991fa193c7e4b/38b060a751ac9638 new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/.hypothesis/examples/34a18a217fcd3d50/ff9999a1befa9f7c b/tests/unit/.hypothesis/examples/34a18a217fcd3d50/ff9999a1befa9f7c new file mode 100644 index 0000000000000000000000000000000000000000..56eec31d984bf984c73fd338ced0edd4edd0724d GIT binary patch literal 24 QcmZQ%WPkxiMg{~2003$L1^@s6 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/79dc6ff64864796e/bec021b4f368e306 b/tests/unit/.hypothesis/examples/79dc6ff64864796e/bec021b4f368e306 new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/364d5aa9cae93350 b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/364d5aa9cae93350 new file mode 100644 index 0000000000000000000000000000000000000000..dd2855181b9b682d926ba56d0b25db49b3364d04 GIT binary patch literal 12 LcmZQ%WPk$z03!ec literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/394341b7182cd227 b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/394341b7182cd227 new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/442eca218c0f2ae4 b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/442eca218c0f2ae4 new file mode 100644 index 0000000000000000000000000000000000000000..9a4eb4e5a975c47461b9c0a283262527533aa7cd GIT binary patch literal 4 LcmZQ#WMBXQ01p5J literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/8fb29073d75ebc7d b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/8fb29073d75ebc7d new file mode 100644 index 0000000000000000000000000000000000000000..5407bf3ddf8b5ca61b411342fe54921a2bbb0ec2 GIT binary patch literal 2 JcmZQ#0000600RI3 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/b871280c1cf29d7a b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/b871280c1cf29d7a new file mode 100644 index 0000000000000000000000000000000000000000..a3758593054468dd8db08f15fa3295cf2667a626 GIT binary patch literal 7 McmZQ#WMlvW001BW1poj5 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/e3cd28f00d196b82 b/tests/unit/.hypothesis/examples/bd70ae7e97dc433b/e3cd28f00d196b82 new file mode 100644 index 0000000000000000000000000000000000000000..32354e902f066d3296273d77500be8ea6e7d086f GIT binary patch literal 12 KcmZQ%KmY&$7ytqQ literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/examples/f39290ea0f49a551/e7ef3b694c2376e5 b/tests/unit/.hypothesis/examples/f39290ea0f49a551/e7ef3b694c2376e5 deleted file mode 100644 index c108e4f27f2be9dc7b788c60c1cfc0ee799628ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31 lcmZQ%WaJ21#SpqmxLw$Qk&%sI9uPM$czDG9m0!!i0svs52Fw5e diff --git a/tests/unit/.hypothesis/examples/f39290ea0f49a551/ff9999a1befa9f7c b/tests/unit/.hypothesis/examples/f39290ea0f49a551/ff9999a1befa9f7c new file mode 100644 index 0000000000000000000000000000000000000000..56eec31d984bf984c73fd338ced0edd4edd0724d GIT binary patch literal 24 QcmZQ%WPkxiMg{~2003$L1^@s6 literal 0 HcmV?d00001 diff --git a/tests/unit/.hypothesis/unicode_data/13.0.0/codec-utf-8.json.gz b/tests/unit/.hypothesis/unicode_data/13.0.0/codec-utf-8.json.gz index eb41807a23f16070edda775dc757234457de28b0..b97f962a00e9a4e9d244132382fa119b7eb6048b 100644 GIT binary patch delta 26 hcmcDq5s~la;9z86U|{-Rl3QRJpI=atm_1QM0{~DV2O0nX delta 26 hcmcDq5s~la;9z86U|{-Rl3P$bYt=NDB^A=ew8dur>*j#3TnC z;>ZC|*n}p*k<1hC15=ztQw~TV&y%JSDE?cf?rKyHlv$vPSf3>=6lD5tvL!7`{v+%g z0cnBv7*R@~2B8V69x|2%gDJ>(CKxP*5Gksd@QPemOC!nzY6~`C9jKv5O{FO}UZa(4 z+{zaC_mO#E2Ddt5<_Gro&HNJTN6nx{uiywfTi^`{R$5Hrh7yq>J}LhkY6}h1G#jS7 z>f3&(FS-ki*^RldO`zJG#cDIuo?$gUp?rrTznj?U$YDUfE@F~%pu-M%GRVIqyLp#7 zRx09Z8A4d`1llhpM4^7uHS5#Vtn~7y>O@Zk*O;^m3{UgLX^@!gU@nfzPw54?$Te*o zG=5JTEP8pN(}AT-ygq@4M2V^MP3B<+GaIST{`(bPw zq@EP9b#5Y(c+raoi+_cup7RfQ6;INO&ZMTqBE?;pd1l^+-}|sH`z60Op7zpd8_DOx z+^FyDq)$U-Xa2_d`iOf15Cw{B88_44N8Ri)qJ-+t5Y@M^d-C&}Hf-JpggB}~1QcFE zjOC8kFx%z0s>ND_BW(@GBqHHQPC7c(B2orQ)O{IuC5#&#vy0YIct_T)2zPZ{aS%8O6NgWRILWq-{3u? z9Mrhan5NwGV%MH7UhG$^&5*Ope={6)RG*Czx!A9hg=~(Mr0iL%P00xwABr zZ9dJ%&B&;+`8vNfBby%3q9V7+7x>gB+X?nE>TEtED8R^QIQg#73r6$F$AsTA+D_ge zYBBkp$U#OYAnOdH`{Y`&C;UD@eZ?#wXEO0HRvAn#;p zelmtl4wXE~7&BR3>M&!%=EqW6jEvlq`DA<;g(pYLR4FSZCMM=3=2RAE7V8z{9W j=B0xf@#(20@yWS~1@V)w$hZmc0IgwR)?(xULmp-TQ72MZ delta 244 zcmca+wZe)ok(ZZ?0SFdo3#LBcpU5Y}7&B4ZT_l%3N`R5UogsxKg|&qtg|(R}N^oP} zR#ry7$#Xf4HkYxLGBOHpe#5?jkx^pvT+Snm{IWnpidjHLG4U~0$xkkn5S@I0lYMg! z_Z>z?rOlbVnT%|jK-td>lNAKjCjaAmz^K0YKEE|1qwZvB!5xg+o3988FftlUek$~W z(QNWL;rEO-llO`IWOM|Q7Lz}SPGNML+$#2j(R*^1_z%W_$;lEw8AB(>N}gnlo~$l) om@$6yYbh;8My|sQ>@~ diff --git a/tests/unit/plotting_functions_tests/test_plot_get_cdict.py b/tests/unit/plotting_functions_tests/test_plot_get_cdict.py index 87e5d959..daae090c 100644 --- a/tests/unit/plotting_functions_tests/test_plot_get_cdict.py +++ b/tests/unit/plotting_functions_tests/test_plot_get_cdict.py @@ -3,6 +3,8 @@ """ from hypothesis import given, example import hypothesis.strategies as some + +import aaanalysis.plotting.plot_get_cdict_ import aaanalysis.utils as ut import pytest import aaanalysis as aa @@ -14,7 +16,7 @@ class TestPlotGetCDict: @given(name=some.sampled_from(["DICT_COLOR", "DICT_CAT"])) def test_valid_dict_names(self, name): """Test function with valid dictionary names.""" - color_dict = aa.plot_get_cdict(name=name) + color_dict = aaanalysis.plotting.plot_get_cdict_.plot_get_cdict(name=name) if name == "DICT_COLOR": assert color_dict == ut.DICT_COLOR else: @@ -26,16 +28,16 @@ def test_valid_dict_names(self, name): def test_invalid_dict_names(self, invalid_name): """Test function with invalid dictionary names.""" with pytest.raises(ValueError): - aa.plot_get_cdict(name=invalid_name) + aaanalysis.plotting.plot_get_cdict_.plot_get_cdict(name=invalid_name) @given(invalid_type=some.one_of(some.integers(), some.floats(), some.lists(some.text()))) def test_invalid_types(self, invalid_type): """Test function with unexpected types as dictionary name.""" with pytest.raises(ValueError): - aa.plot_get_cdict(name=invalid_type) + aaanalysis.plotting.plot_get_cdict_.plot_get_cdict(name=invalid_type) @given(empty_str=some.just("")) def test_empty_string_as_name(self, empty_str): """Test function with an empty string as dictionary name.""" with pytest.raises(ValueError): - aa.plot_get_cdict(name=empty_str) + aaanalysis.plotting.plot_get_cdict_.plot_get_cdict(name=empty_str) diff --git a/tests/unit/plotting_functions_tests/test_plot_get_cmap.py b/tests/unit/plotting_functions_tests/test_plot_get_cmap.py index 2d6197da..1d4986bf 100644 --- a/tests/unit/plotting_functions_tests/test_plot_get_cmap.py +++ b/tests/unit/plotting_functions_tests/test_plot_get_cmap.py @@ -4,6 +4,7 @@ from hypothesis import given, strategies as st import pytest import aaanalysis as aa +import aaanalysis.plotting.plot_get_cmap_ import aaanalysis.utils as ut