Skip to content

Instantly share code, notes, and snippets.

View jni's full-sized avatar

Juan Nunez-Iglesias jni

View GitHub Profile
@jni
jni / ZError
Created July 9, 2012 20:36
Attempt to use joblib mmap failed
In [8]: rf = RandomForestClassifier(100, max_depth=20, n_jobs=2, shared=True, compute_importances=True)
In [9]: rf = rf.fit(dat5[0], dat5[1][:, 0])
Exception AttributeError: AttributeError("'NoneType' object has no attribute 'tell'",) in <bound method memmap.__del__ of memmap([ 2.00000000e+00, 1.50000006e-02, 2.25000018e-04,
0.00000000e+00, 5.06250080e-08, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
9.54999954e-01, 1.22499975e-03, 1.11022302e-16,
1.50062439e-06, 3.00000003e-02, 4.00000019e-04,
-1.35525272e-20, 1.60000015e-07, 1.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
@jni
jni / Error.txt
Created July 9, 2012 20:43
Failure using @glouppe's cytomine scikit-learn RF shared memory implementation
In [7]: rf = RandomForestClassifier(100, max_depth=20, n_jobs=8, shared=True, compute_importances=True)
In [8]: rf = rf.fit(dat5[0], dat5[1][:, 0])
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/groups/chklovskii/home/nuneziglesiasj/data/cropped_5um3_larva_fib_10x10x10nm/cl2/<ipython-input-8-16d0d527a259> in <module>()
----> 1 rf = rf.fit(dat5[0], dat5[1][:, 0])
/groups/chklovskii/home/nuneziglesiasj/projects/scikit-learn-sharedmem/sklearn/ensemble/forest.pyc in fit(self, X, y)
273 # Pack inputs into shared-memory arrays
~/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."""
@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
@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 / 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-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()
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 / 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.
@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