This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process(val): | |
try: | |
do_something(val) | |
except Exception as ex: | |
msg = '{}: {}'.format(val, ex.args[0]) if ex.args else str(val) | |
ex.args = (msg,) + ex.args[1:] | |
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
"""See main.__doc__""" | |
import os | |
import logging | |
import glob | |
import unittest | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@title %~n0 | |
@python.exe -O %~d0\%~p0\%~n0.py %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filter_log(msg_re=''): | |
"""Decorator to temporarily disable logging so as to prevent noise. | |
:param msg_re: regular expression to be filtered out. | |
:type msg_re: string. | |
Note that the default argument '' causes all warnings to be filtered out. | |
""" | |
def decorator(func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rem remove any PYTHONHOME setting. | |
@set PYTHONHOME= | |
@rem first sets python path so we can run uniquepath. | |
@set PYTHON=C:\Python%1 | |
@set PYTHONSTARTUP=%HOME%\scripts\startup.py | |
@dir %PYTHON% > NUL | |
@if ERRORLEVEL 1 GOTO FAILED | |
@set PATH=%PATH%;%PYTHON% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set PYTHON=python.exe | |
for %%a in (%*) do ( | |
if "%%a" == "-h" goto nocall | |
if "%%a" == "--help" goto nocall | |
if "%%a" == "-d" goto nocall | |
if "%%a" == "--debug" goto nocall | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Removes duplicates in a PATH-like environment variable.""" | |
# Copyright (c) 2012-14 Jerome Lecomte | |
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: set encoding=utf-8 | |
""" | |
My convenience test runners for unittest. | |
Place it in your tests folder and use it with python -m <test folder>. | |
(Requires click, and colorama (if you want colors)). | |
Allows one to run your tests in your tests folder in a spartain way: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sns.set(style='whitegrid', context='notebook', font_scale=1.5) | |
cm = np.corrcoef(df[cols].values.T) | |
hm = sns.heatmap(cm, cbar=True, annot=True, square=True, fmt='.2f', | |
annot_kws={'size': 15}, yticklabels=cols, xticklabels=cols) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sns.set(style='whitegrid', context='notebook', font_scale=1.5) | |
sns.pairplot(df[cols]) | |
plt.show() |
OlderNewer