Skip to content

Instantly share code, notes, and snippets.

View notmatthancock's full-sized avatar

Matt Hancock notmatthancock

View GitHub Profile
@notmatthancock
notmatthancock / compiled_file_python_version.py
Created February 8, 2022 01:10 — forked from delimitry/compiled_file_python_version.py
Get the version of Python by which the file was compiled
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A script to get the version of Python by which the file was compiled
"""
from __future__ import print_function
import binascii
import os
# Run flake8 only on new files according to git-diff
#
# If run with no arguments, i.e.,
# $ dflake8
# then the diff is taken against the master branch.
# If run with a single argument, then that argument is used for diff'ing, i.e.,
# $ dflake8 feature-branch
# or
# $ dflake8 HEAD
dflake8 () {
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets as ds
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_val_score
# Number of folds to use for CV
N_FOLDS = 5
@notmatthancock
notmatthancock / pylidc_volume_mask.py
Created October 1, 2017 12:10
pylidc volume mask
import pylidc as pl
import numpy as np
import matplotlib.pyplot as plt
from skimage.viewer import CollectionViewer
# Load scan, convert to volume.
scan = pl.query(pl.Scan).filter(pl.Scan.patient_id == "LIDC-IDRI-0001").first()
vol = scan.to_volume(verbose=False)
# mask_vol is a boolean, indicator volume for the first annotation of the scan.
sudo apt-get remove mayavi2
sudo apt-get autoremove
sudo apt-get install libvtk5.10-qt4 # I use leave off qt4. I use qt backend.
sudo apt-get install python-vtk
sudo apt-get install python-traits
sudo apt-get install libvtk5-dev
sudo pip install sphinx
cd ~/Downloads # or whatever temporary dir.
wget https://github.com/enthought/mayavi/archive/4.5.0.zip
# cython windowize.pyx
# gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o windowize.so windowize.c
import numpy as np
cimport numpy as np
cimport cython
DTYPE = np.float64
ctypedef np.float64_t dtype_t
import sys
import numpy as np
import matplotlib.pyplot as plt
import theano
import theano.tensor as T
rs = np.random.RandomState(1234)
def gen_spiral(label, dt, n_samples=100, noise=0.1):
"""
^CTraceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/backend_bases.py", line 56, in <module>
impor