PK!q7jjmolib/__init__.py__version__ = '0.3.1' from .figures import * from .colors import * from .logging_formatter import * PK!ttmolib/colors.pydef rescale_colors(color_list): # Rescale to values between 0 and 1 for i in range(len(color_list)): r, g, b = color_list[i] color_list[i] = (r / 255., g / 255., b / 255.) return color_list def tableau10(index): # Tableau 10 Colors tableau10_list = [(31,119,180),(255,127,14),(44,160,44),(214,39,40),(148,103,189),(140,86,75),(227,119,194),(127,127,127),(188,189,34),(23,190,207)]; tableau10_list = rescale_colors(tableau10_list) return tableau10_list[index] def tableau20(index): # Tableau 20 Colors tableau20_list = [(31, 119, 180), (174, 199, 232), (255, 127, 14), (255, 187, 120), (44, 160, 44), (152, 223, 138), (214, 39, 40), (255, 152, 150), (148, 103, 189), (197, 176, 213), (140, 86, 75), (196, 156, 148), (227, 119, 194), (247, 182, 210), (127, 127, 127), (199, 199, 199), (188, 189, 34), (219, 219, 141), (23, 190, 207), (158, 218, 229)] tableau20_list = rescale_colors(tableau20_list) return tableau20_list[index] def tableau10blind(index): # Tableau Color Blind 10 tableau10blind_list = [(0, 107, 164), (255, 128, 14), (171, 171, 171), (89, 89, 89), (95, 158, 209), (200, 82, 0), (137, 137, 137), (163, 200, 236), (255, 188, 121), (207, 207, 207)] tableau10blind_list = rescale_colors(tableau10blind_list) return tableau10blind_list[index]PK!wvxxmolib/figures.pyfrom pathlib import Path import matplotlib.pyplot as plt def add_subfig_label(ax, label, size=14): ''' Adds a subplot label to an axis.''' ax.text(-0.1, 1, label, transform=ax.transAxes, fontsize=size, fontweight='bold', va='top', ha='right') return ax def gen_sub_label(lower=False, paren=False): '''Generates the next letter in the alphabet as a subfig label. Label can be uppercase or lowercase, with optional parentheses. ''' letters = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z' labels = letters.lower().split(' ') if lower else letters.split(' ') for letter in labels: yield '('+letter+')' if paren else letter def label_subplots(fig, size=14, paren=False, lower=False): '''Adds letter labels to all subplots in a figure. Adjusts figure padding and left margin to make labels fit. ''' allaxes = fig.get_axes() sub_labels = gen_sub_label(lower=lower, paren=paren) for ax in allaxes: add_subfig_label(ax, next(sub_labels), size=size) # plt.tight_layout(rect=[l_mar,0,1,1], w_pad=w_pad) def save_plot(output_filename, proj_dir=Path.cwd(), subdir=None, fig=None): ''' Function for saving plots and printing message.''' # make directory for plots, and save plot plots_dir = proj_dir/'plots' if subdir: plots_dir = plots_dir / str(subdir) plots_dir.mkdir(parents=True, exist_ok=True) output_file_path = plots_dir / (output_filename + '.png') if fig: fig.savefig(str(output_file_path), dpi=300) else: plt.savefig(str(output_file_path), dpi=300) print('Created plot: ' + str(output_file_path)) plt.close() PK!0R~~molib/logging_formatter.pyimport logging import sys # Custom formatter class LogFormatter(logging.Formatter): '''adapted from https://stackoverflow.com/a/14859558''' err_fmt = "\n***ERROR: %(msg)s" dbg_fmt = "\n***DEBUG: %(module)s: %(lineno)d: %(msg)s" info_fmt = "\n%(msg)s" def __init__(self): super().__init__(fmt="%(levelno)d: %(msg)s", datefmt=None, style='%') def format(self, record): # Save the original format configured by the user # when the logger formatter was instantiated format_orig = self._style._fmt # Replace the original format with one customized by logging level if record.levelno == logging.DEBUG: self._style._fmt = LogFormatter.dbg_fmt elif record.levelno == logging.INFO: self._style._fmt = LogFormatter.info_fmt elif record.levelno == logging.ERROR: self._style._fmt = LogFormatter.err_fmt # Call the original formatter class to do the grunt work result = logging.Formatter.format(self, record) # Restore the original format configured by the user self._style._fmt = format_orig return result def console_logger(level): fmt = LogFormatter() hdlr = logging.StreamHandler(sys.stdout) hdlr.setFormatter(fmt) logging.root.addHandler(hdlr) logging.root.setLevel(level) PK!KUBBmolib-0.3.1.dist-info/LICENSEMIT License Copyright (c) 2018 Manuel Ochoa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HڽTUmolib-0.3.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Hڍ+molib-0.3.1.dist-info/METADATATMo6W C六b M|4i$N{t"YJ-;CɎ$3ͼ7C]Q #"5c/FkCmg8]ScBc?(mErb5 .~?<{]Livĕ˕l@5*=~4D-(OapTÃS׏0;Z(b֮p}wGyD|sM ۥǺVf h .m%y;#~yxBd1:m#r;Lb{)+y"k"8%̣yɲn|ӕ |%#PƔ 0<94h Tj pCYQ*4Zp\b*WV]l!\QkrznCHCP{"Ɨt"{V1$ ^ȩ-nd{{p *{pTU)FnKtBD"a !uiHYʞmrN`7W:}쵵?0&0Ef۪JD#5GLk|M   D 21K |$#9-mJ^TU<Ǘ~ x&!d`x6dMkP D)USRx%"jbZe\wS!QX9Aÿ֎&>< ff7u_2Zޑ8g&9mkl47,osxqUUKr43U}9XȊ,G@K0ٽ4~畉i j 8"ZBkpX9SY^񶅮V%\rؘJZmyնV_q.|RXm}H> cٺ' S5 SO}?+E3'J)l`4Tz66T QG%k%Up.wxKDuHs1 ˛yyw\q|PK!H^?{/Kmolib-0.3.1.dist-info/RECORDuKo@} XȢ u@1l&S`)os7Os;B}f-dc-ll/%X\Ļù+Qj`#n{ _.=$o4Prv.Oߢj ?уl)pg/WRˉ:6ɏ/[,H|S|VbxE^-KLJT} C?,Kߥrޯr8T\!XKըݼ*)KFۈ~st`1)w6UU$ 'yACS6HDz ;N^c=]h>A/=.irY:aB܁P7P_Qhrlڧ<(Mbwot~[KZ1&* &üPK!q7jjmolib/__init__.pyPK!ttmolib/colors.pyPK!wvxx:molib/figures.pyPK!0R~~ molib/logging_formatter.pyPK!KUBBmolib-0.3.1.dist-info/LICENSEPK!HڽTUmolib-0.3.1.dist-info/WHEELPK!Hڍ+molib-0.3.1.dist-info/METADATAPK!H^?{/Kmolib-0.3.1.dist-info/RECORDPK,[