This file contains hidden or 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 weirdimport(*paths): | |
import os, sys | |
fullpath = os.path.abspath(os.path.join(*paths)) | |
global project | |
sys.path.append(os.path.dirname(fullpath)) | |
try: | |
project = __import__(os.path.basename(fullpath)) | |
sys.modules['project'] = project | |
finally: | |
del sys.path[-1] |
This file contains hidden or 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
import time | |
class Measurement(object): | |
def __init__(self, name): | |
self.name = name | |
return | |
def __enter__(self): | |
self.t_start = time.time() | |
return |
This file contains hidden or 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
import theano | |
import theano.tensor as T | |
import numpy | |
import h5py | |
import os | |
import time | |
def rungekuttastep(h, y, fprime, *theta): | |
k1 = h*fprime(y,*theta) |
This file contains hidden or 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
# saving a DataFrame to an Excel spreadsheet | |
writer = pandas.ExcelWriter(fp_xlsx) | |
df.to_excel(writer, 'Sheetname') | |
writer.save() |
This file contains hidden or 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
import base64 | |
import hashlib | |
import theano | |
import theano.tensor as tt | |
def make_hashable(obj): | |
"""Makes tuples, lists, dicts, sets and frozensets hashable.""" | |
if isinstance(obj, (tuple, list)): | |
return tuple((make_hashable(e) for e in obj)) |
This file contains hidden or 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
conda create -n pm3 python=3.7 pandas jupyter matplotlib mkl-service libpython m2w64-toolchain coverage xlrd openpyxl scipy -y | |
activate pm3 | |
# install last release from PyPI | |
pip install pymc3 | |
# or latest version directly from master: | |
pip install git+https://github.com/pymc-devs/pymc3 | |
# or from master in editable mode: | |
git clone https//github.com/pymc-devs/pymc3 pymc3 | |
cd pymc3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
import numpy | |
from matplotlib import pyplot | |
def interpolate(x_fix, y_fix, x_var): | |
x_repeat = numpy.tile(x_var[:,None], (len(x_fix),)) | |
distances = numpy.abs(x_repeat - x_fix) | |
x_indices = numpy.searchsorted(x_fix, x_var) |
This file contains hidden or 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
public class BroadcastReceiver : IDisposable | |
{ | |
//OnMessageReceived | |
public delegate void AddOnMessageReceivedDelegate(string message, IPEndPoint remoteEndpoint); | |
public event AddOnMessageReceivedDelegate MessageReceived; | |
private void OnMessageReceivedEvent(string message, IPEndPoint remoteEndpoint) | |
{ | |
if (MessageReceived != null) | |
MessageReceived(message, remoteEndpoint); | |
} |
This file contains hidden or 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
""" | |
Reformats piped mypy output to group by the error code. | |
Author: Michael Osthege | |
License: MIT | |
Usage | |
----- | |
mypy -p mypackage --show-error-codes | python mypy_groupby.py | |
""" |
OlderNewer