Skip to content

Instantly share code, notes, and snippets.

View jni's full-sized avatar

Juan Nunez-Iglesias jni

View GitHub Profile
@jni
jni / output.txt
Created March 16, 2015 22:40
Python generators and piping demo
times2 start
range start
yielding 0
multiplying 0 by 2
yielding 1
multiplying 1 by 2
yielding 2
multiplying 2 by 2
yielding 3
multiplying 3 by 2
@jni
jni / error
Created January 10, 2015 01:28
sudo py.test fails on Travis
travis@debug-hs-11922-jni-python-1420819368:~/jni/cellom2tif$ py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4
plugins: cov
collected 10 items
verify.py .
cellom2tif/cellom2tif.py ..
tests/test_cellom2tif.py .
tests/test_package.py ..
@jni
jni / gist:5083fa78229ab0278a2e
Created October 29, 2014 03:15
Fiji Crash Yosemite
Process: ImageJ-macosx [1330]
Path: /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx
Identifier: org.fiji
Version: 1.0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: ImageJ-macosx [1330]
User ID: 501
Date/Time: 2014-10-29 14:12:22.191 +1100
@jni
jni / islic.py
Last active August 29, 2015 14:03
IPython interact ~~fail~~ success!
%matplotlib inline
from skimage import img_as_float
import numpy as np
from matplotlib import pyplot as plt
def imshow_all(*images, **kwargs):
""" Plot a series of images side-by-side.
Convert all images to float so that images have a common intensity range.
nuneziglesiasj@jni-lscc-mbp Mon Apr 07 10:08
~/projects/scikit-image/skimage/viewer/tests (master)$ python test_viewer.py
Recommended matplotlib backend is `Agg` for full skimage.viewer functionality.
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/ or in the resources directory of your application bundle.
Abort trap: 6
@jni
jni / example-run.py
Created October 29, 2013 13:54
Example gala run
# run this from $GALADIR/tests
# This script was used to generate the matched random forest and training data for regression testing.
# However, the training data do not get reproduced between this run and a test run, presumably because
# of some problem setting the random state.
import numpy as np
from gala import imio, classify, features, agglo, evaluate as ev
gt_train, pr_train, p4_train, ws_train = map(imio.read_h5_stack, ['example-data/train-gt.lzf.h5', 'example-data/train-p1.lzf.h5', 'example-data/train-p4.lzf.h5', 'example-data/train-ws.lzf.h5'])
gt_test, pr_test, p4_test, ws_test = map(imio.read_h5_stack, ['example-data/test-gt.lzf.h5', 'example-data/test-p1.lzf.h5', 'example-data/test-p4.lzf.h5', 'example-data/test-ws.lzf.h5'])
fm = features.moments.Manager()
@jni
jni / tosi.py
Last active December 24, 2015 23:19
print numbers in engineering notation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# copied with modifications from http://stackoverflow.com/a/15734251/224254 by @scls
import math
def to_si(d):
incPrefixes = ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
decPrefixes = ['m', 'µ', 'n', 'p', 'f', 'a', 'z', 'y']
@jni
jni / example.py
Created July 31, 2013 10:17
Failure case for sparse max() function
In [28]: x = np.zeros((3, 3), float)
In [29]: x[0, 0] = -3.2
In [30]: x[2, 1] = -2.7
In [31]: s = sparse.csr_matrix(x)
In [32]: s.data
Out[32]: array([-3.2, -2.7])
@jni
jni / error log
Created May 29, 2013 16:04
Heisenbug: segfault when debugging problem with pdb, but only erroneous output when running in python or iPython.
nuneziglesiasj@jni-lscc-mbp Thu May 30 01:38
~ $ ipython --pylab
Activating auto-logging. Current session state plus future input saved.
Filename : /Users/nuneziglesiasj/ipython-logs/automatic-log--2013.5.30--1.38.py
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
~/projects/skimage (3d-slic)$ python setup.py install
non-existing path in 'skimage/_shared': 'tests'
cython -o /Volumes/Projects/skimage/skimage/segmentation/_slic.c /Volumes/Projects/skimage/skimage/segmentation/_slic.pyx
Error compiling Cython file:
------------------------------------------------------------
...
float ratio, int max_iter, int n_segments):
"""Helper function for SLIC segmentation."""