Skip to content

Instantly share code, notes, and snippets.

View nirum's full-sized avatar

Niru Maheswaranathan nirum

View GitHub Profile
@nirum
nirum / test_numpy.py
Last active August 29, 2015 14:26 — forked from osdf/test_numpy.py
Testing numpy and scipy setups
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
@nirum
nirum / unfold.py
Last active February 3, 2018 23:58
Unfold a muli-dimensional numpy array along an arbitrary axis
import numpy as np
def unfold(arr, ax):
"""
Unfolds a given array along the given axis
"""
return np.rollaxis(arr, ax, 0).reshape(arr.shape[ax], -1)
def test_unfold():
"""
@nirum
nirum / classes.py
Last active October 28, 2015 04:54
classes in python
class Foo(object):
def __init__(self, data):
self.data = data
self.shape = self.data.shape
def __getitem__(self, index):
return self.data[index] ** 2
def __dir__(self):