scipy

jit – "Failed in nopython mode pipeline" error, despite not using nopython in numba

jit – "Failed in nopython mode pipeline" error, despite not using nopython in numba Question: I am using value function iteration to solve a complex dynamic programming problem with many states. I want to use numba/jit to speed up my code (and eventually parallelize the for loops). When I use the @jit decorator in my …

Total answers: 1

Masking nan values from an xarray dataset for scikit.learn mulltiple linear regression following scipy

Masking nan values from an xarray dataset for scikit.learn mulltiple linear regression following scipy Question: I’m attempting to use scikit-learn.linear_model’s LinearRegression find the multiple linear regression coefficients for different variables at each latitude and longitude point along the time dimension like so: for i in range(len(data.lat)): for j in range(len(data.lon)): storage_dframe[i, j, :] = LinearRegression().fit(np.array((data.ivar1.values[:, …

Total answers: 2

Small value artifacts from applying scipy.signal.convolve

Small value artifacts from applying scipy.signal.convolve Question: This Python 3.11.5 script: import numpy as np from skimage.io import imread from scipy.signal import convolve image = np.flipud(imread(‘conv-test.bmp’).astype(np.float32)) con = convolve(image, np.ones((3, 3))/9, mode=’valid’) print(image.min()) print(np.logical_and(image > 0, image < 1).any()) print(np.logical_and(con > 0, con < 0.00001).any()) produces: 0.0 False True How is it possible to get …

Total answers: 1

Why is the integration not progressing with scipy.integrate.ode?

Why is the integration not progressing with scipy.integrate.ode? Question: I am integrating a function func in the complex domain using scipy.integrate.ode. I have assembled the following code structure: import numpy as np from scipy.integrate import ode def func(x, u, k): #f, g = u dfdx = k*x**2 dgdx = -x rhs_FD = [0]*2 rhs_FD[0] = …

Total answers: 1

scipy.signal not defined, but works after importing skimage

scipy.signal not defined, but works after importing skimage Question: I would like to use scipy.signal.convolve2d() function from SciPy, but signal is undefined: >>> import scipy … >>> conv = scipy.signal.convolve2d(data, kernel, mode="same") Error: Traceback (most recent call last): File "test.py", line n, in <module> conv = scipy.signal.convolve2d(data, kernel, mode="same") AttributeError: module ‘scipy’ has no attribute …

Total answers: 1

Degenerate root finding problem: get the first value for which f(x)>0

Degenerate root finding problem: get the first value for which f(x)>0 Question: Given a function f(x) that is zero for all values x less than a critical value c, and non-zero for values x>c. I want to approximate the critical value c using an optimization method. Because the function f(x) is expensive, I want to …

Total answers: 2

Explanation of signal.find_peaks() approach

Explanation of signal.find_peaks() approach Question: I have looked through the scipy.signal docs for an explanation of the peak finding approach used in find_peaks() and have been unable to find an explanation similar to the excellent explanation given but the cwt peak finding approach. Is anyone here able to explain the peak finding approach used by …

Total answers: 1

Can i use the Newton-Raphson method of scipy.optimize with a multiple variable system?

Can i use the Newton-Raphson method of scipy.optimize with a multiple variable system? Question: I wanted to do the Newton-Raphson method with scipy with a multivariable system. So, i followed this documentation. And here is an example code where i tried to solved my problem: import numpy as np from scipy.optimize import newton def f(x): …

Total answers: 1

Vectorizing multivariate normal distribution calculation

Vectorizing multivariate normal distribution calculation Question: I have n points in 3D space, each with a corresponding guess and certainty attached to it. I want to calculate the multivariate normal distribution for each point given its guess and certainty. Currently, I’m using an iterative approach and the Scipy.stats multivariate_normal function, as shown in the code …

Total answers: 1

How to run sicpy.signal freqz in C# / ASP.NET Core?

How to run sicpy.signal freqz in C# / ASP.NET Core? Question: I need to run Python source code (.py) with dependencies on numpy and scipy.signal in the ASP.NET Core context. I’ve found IronPython to be a suitable solution, but it doesn’t support these two dependencies (GitHub issue #355). So, I decided to automatically generate C# …

Total answers: 1