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 as np | |
import dask.array as da | |
# Benchmark: NumPy with array construction included | |
%timeit nparr0 = np.random.random(size=(10000, 1000)); \ | |
nparr1 = np.random.random(size=(10000, 1000)); \ | |
np.sqrt((nparr0 - nparr1) ** 2 + (nparr0 - nparr1) ** 2 + (nparr0 - nparr1) ** 2) | |
# Benchmark: Dask with dask.array construction included | |
%timeit x = da.random.random(size=(10000, 1000), chunks=(10000, 1000)); \ |
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 as np | |
cimport numpy as cnp | |
# Compiler directives | |
@cython.cdivision(True) | |
@cython.boundscheck(False) | |
@cython.nonecheck(False) | |
@cython.wraparound(False) | |
def flood_fill(unsigned char[:, ::1] data, tuple start_coords, |
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
# Pure Python, usable speed but over 10x greater runtime than Cython version | |
def fill(data, start_coords, fill_value): | |
""" | |
Flood fill algorithm | |
Parameters | |
---------- | |
data : (M, N) ndarray of uint8 type | |
Image with flood to be filled. Modified inplace. | |
start_coords : tuple |
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
""" | |
_jaccard.py : Jaccard metric for comparing set similarity. | |
""" | |
import numpy as np | |
def jaccard(im1, im2): | |
""" |
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
""" | |
_dice.py : Dice coefficient for comparing set similarity. | |
""" | |
import numpy as np | |
def dice(im1, im2): | |
""" |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import math | |
from PyQt4 import QtGui, QtCore | |
def binomial(i, n): |
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
#!/usr/bin/env python | |
"""In order to use the script you need to copy your SSH key to the target server | |
and also copy the server SSH public key (usually .ssh/id_rsa.pub) to .ssh/authorized_keys, | |
so that the computing node can ssh passwordless to the login node""" | |
from subprocess import Popen, PIPE, call | |
import sys | |
import webbrowser | |
from getopt import getopt | |
import time |
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 as np | |
def _pad_asymmetric_zeros(arr, pad_amt, axis=-1): | |
"""Pads `arr` by `pad_amt` along specified `axis`""" | |
if axis == -1: | |
axis = arr.ndim - 1 | |
zeroshape = tuple([x if i != axis else pad_amt | |
for (i, x) in enumerate(arr.shape)]) |