Skip to content

Instantly share code, notes, and snippets.

View FedericoV's full-sized avatar

Federico Vaggi FedericoV

View GitHub Profile
@numba.jit(target='cpu', nopython=True)
def _compute_overlaps(u, v):
a = 0
b = 0
c = 0
m = u.shape[0]
for idx in range(m):
a += u[idx] & v[idx]
b += u[idx] & ~v[idx]
c += ~u[idx] & v[idx]
@FedericoV
FedericoV / gist:0e7d6d8c8794a99a7a42
Created May 28, 2015 08:06
Cosine Similarity that handles NaN with Numba
import numba
@numba.jit(target='cpu', nopython=True)
def fast_cosine(u, v):
m = u.shape[0]
udotv = 0
u_norm = 0
v_norm = 0
for i in range(m):
if (np.isnan(u[i])) or (np.isnan(v[i])):
Ab Ratio_12h 448
Ratio_18h 431
Ratio_24h 1088
Ratio_6h 141
FUS Ratio_12h 272
Ratio_18h 1656
Ratio_24h 1867
Ratio_6h 489
GFP Ratio_12h 40
Ratio_18h 1042
self.rotation = rotation_matrix(np.array([0, 0, 1]),
self.model.stem_rotation)
self.axis = self.__get_axis()
self.rotation = np.dot(self.rotation,
rotation_matrix(self.axis,
self.model.tree_rotation))
self.rotation = rotation_matrix(np.array([0,0,1]), self.model.stem_rotation)
self.axis = self.__get_axis()
self.rotation = np.dot(rotation_matrix(self.axis, self.model.tree_rotation), self.rotation)
Jaccard
Unclustered Communities: 2984
Total Clustered Genes: 4555
Number of Communities: 205
---------------------------
Simpson
Unclustered Communities: 162
Total Clustered Genes: 6328
@numba.jit(target='cpu', nopython=True)
def fast_simpson(i, j):
a = 0
b = 0
c = 0
M = i.shape[0]
for idx in range(M):
a += (i[idx] == 1) and (j[idx] == 1)
@FedericoV
FedericoV / Numba_ODEINT_benchmark.ipynb
Created September 9, 2014 09:47
Showing numba at speeding up a complicated ODE
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
total 16G
drwx------ 4 keu_vaggi kore 60K 12 giu 11:19 .
drwxrwxr-x 49 root kore 4,0K 6 giu 09:33 ..
-rw------- 1 keu_vaggi kore 17K 11 giu 10:36 .bash_history
-rw-r--r-- 1 keu_vaggi kore 18 10 mag 2012 .bash_logout
-rw-r--r-- 1 keu_vaggi kore 176 10 mag 2012 .bash_profile
-rw-r--r-- 1 keu_vaggi kore 155 30 ago 2013 .bashrc
-rw-r--r-- 1 keu_vaggi kore 179 28 mar 17:28 batch.sh
-rw------- 1 keu_vaggi kore 150M 12 giu 11:06 core.12240
-rw------- 1 keu_vaggi kore 1,3G 12 giu 11:07 core.12241
bash: module: line 1: syntax error: unexpected end of file
bash: error importing function definition for `module'
bash: module: line 1: syntax error: unexpected end of file
bash: error importing function definition for `module'
bash: module: line 1: syntax error: unexpected end of file
bash: error importing function definition for `module'
bash: module: line 1: syntax error: unexpected end of file
bash: error importing function definition for `module'
/fem0/keu_albanese/local/lib/python2.7/site-packages/scipy/integrate/quadpack.py:315: RuntimeWarning: overflow encountered in square
return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)