numba

Error installing Numba on OS X

天涯浪子 提交于 2019-11-30 08:56:36
I'm unable to install Numba (via pip) on my OS X system. I'm using Python: 2.7.11 (Homebrew) pip: 8.1.1 setuptools: 20.6.7 OS X: 10.11.4 (x86_64) Xcode: 7.3 Xcode CLT: 7.3.0.0.1.1457485338 Clang: 7.3 build 703 and have installed the prerequisites (I think) with brew install llvm git clone https://github.com/numba/llvmlite cd llvmlite LLVM_CONFIG=/usr/local/opt/llvm/bin/llvm-config python setup.py install cd .. rm -rf llvmlite and also tried brew install llvm brew link --force llvm # later: brew unlink llvm cd /usr/local/Cellar/llvm/X.X.X/include/llvm/Config/ # X.X.X = 3.6.2 ln -s llvm-config.h

Fastest way to numerically process 2d-array: dataframe vs series vs array vs numba

≡放荡痞女 提交于 2019-11-30 07:42:28
问题 Edit to add : I don't think the numba benchmarks are fair, notes below I'm trying to benchmark different approaches to numerically processing data for the following use case: Fairly big dataset (100,000+ records) 100+ lines of fairly simple code (z = x + y) Don't need to sort or index In other words, the full generality of series and dataframes is not needed, although they are included here b/c they are still convenient ways to encapsulate the data and there is often pre- or post-processing

How to make numba @jit use all cpu cores (parallelize numba @jit)

萝らか妹 提交于 2019-11-30 06:52:32
I am using numbas @jit decorator for adding two numpy arrays in python. The performance is so high if I use @jit compared with python . However it is not utilizing all CPU cores even if I pass in @numba.jit(nopython = True, parallel = True, nogil = True) . Is there any way to to make use of all CPU cores with numba @jit . Here is my code: import time import numpy as np import numba SIZE = 2147483648 * 6 a = np.full(SIZE, 1, dtype = np.int32) b = np.full(SIZE, 1, dtype = np.int32) c = np.ndarray(SIZE, dtype = np.int32) @numba.jit(nopython = True, parallel = True, nogil = True) def add(a, b, c):

Vectorized 2-D moving window in numpy including edges

丶灬走出姿态 提交于 2019-11-30 05:40:45
问题 I realize my question is fairly similar to Vectorized moving window on 2D array in numpy , but the answers there don't quite satisfy my needs. Is it possible to do a vectorized 2D moving window (rolling window) which includes so-called edge effects? What would be the most efficient way to do this? That is, I would like to slide the center of a moving window across my grid, such that the center can move over each cell in the grid. When moving along the margins of the grid, this operation would

Speed up Metropolis--Hastings in Python

时光怂恿深爱的人放手 提交于 2019-11-29 22:15:53
问题 I have some code that samples a posterior distribution using MCMC, specifically Metropolis Hastings. I use scipy to generate random samples: import numpy as np from scipy import stats def get_samples(n): """ Generate and return a randomly sampled posterior. For simplicity, Prior is fixed as Beta(a=2,b=5), Likelihood is fixed as Normal(0,2) :type n: int :param n: number of iterations :rtype: numpy.ndarray """ x_t = stats.uniform(0,1).rvs() # initial value posterior = np.zeros((n,)) for t in

Achieving Numba's performance with Cython

≯℡__Kan透↙ 提交于 2019-11-29 14:40:58
Usually I'm able to match Numba's performance when using Cython. However, in this example I have failed to do so - Numba is about 4 times faster than my Cython's version. Here the Cython-version: %%cython -c=-march=native -c=-O3 cimport numpy as np import numpy as np cimport cython @cython.boundscheck(False) @cython.wraparound(False) def cy_where(double[::1] df): cdef int i cdef int n = len(df) cdef np.ndarray[dtype=double] output = np.empty(n, dtype=np.float64) for i in range(n): if df[i]>0.5: output[i] = 2.0*df[i] else: output[i] = df[i] return output And here is the Numba-version: import

Error installing Numba on OS X

自作多情 提交于 2019-11-29 12:56:23
问题 I'm unable to install Numba (via pip) on my OS X system. I'm using Python: 2.7.11 (Homebrew) pip: 8.1.1 setuptools: 20.6.7 OS X: 10.11.4 (x86_64) Xcode: 7.3 Xcode CLT: 7.3.0.0.1.1457485338 Clang: 7.3 build 703 and have installed the prerequisites (I think) with brew install llvm git clone https://github.com/numba/llvmlite cd llvmlite LLVM_CONFIG=/usr/local/opt/llvm/bin/llvm-config python setup.py install cd .. rm -rf llvmlite and also tried brew install llvm brew link --force llvm # later:

Python/Numba: Unknown attribute error with scipy.special.gammainc()

扶醉桌前 提交于 2019-11-29 11:06:41
I am having an error when running code using the @jit decorator. It appears that some information for the function scipy.special.gammainc() can't be located: Failed at nopython (nopython frontend) Unknown attribute 'gammainc' for Module(<module 'scipy.special' from 'C:\home\Miniconda\lib\site-packages\scipy\special\__init__.pyc'>) $164.2 $164.3 = getattr(attr=gammainc, value=$164.2) Without the @jit decorator the code will run fine. Maybe there is something required to make the attributes of the scipy.special module visible to Numba? Thanks in advance for any suggestions, comments, etc. The

Comparing Python, Numpy, Numba and C++ for matrix multiplication

≡放荡痞女 提交于 2019-11-29 05:41:21
In a program I am working on, I need to multiply two matrices repeatedly. Because of the size of one of the matrices, this operation takes some time and I wanted to see which method would be the most efficient. The matrices have dimensions (m x n)*(n x p) where m = n = 3 and 10^5 < p < 10^6 . With the exception of Numpy, which I assume works with an optimized algorithm, every test consists of a simple implementation of the matrix multiplication : Below are my various implementations: Python def dot_py(A,B): m, n = A.shape p = B.shape[1] C = np.zeros((m,p)) for i in range(0,m): for j in range(0

Fastest way to numerically process 2d-array: dataframe vs series vs array vs numba

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 05:21:37
Edit to add : I don't think the numba benchmarks are fair, notes below I'm trying to benchmark different approaches to numerically processing data for the following use case: Fairly big dataset (100,000+ records) 100+ lines of fairly simple code (z = x + y) Don't need to sort or index In other words, the full generality of series and dataframes is not needed, although they are included here b/c they are still convenient ways to encapsulate the data and there is often pre- or post-processing that does require the generality of pandas over numpy arrays. Question : Based on this use case, are the