115,286 questions
Advice
0
votes
8
replies
40
views
How to apply numpy vectorization to a function with optional arguments?
Suppose I have a function with the following signature:
def f(x,**kwargs)
Here, **kwargs are some optional arguments that may be passed to other functions called in the body of f. I want to apply ...
1
vote
1
answer
48
views
How can I save an image after altering its color?
I have a small Python code to read and save an image:
import numpy as np
# from scipy.misc import imread, imsave # Not working
from imread import imread, imsave
img = imread('tst-image.jpg')
# print(...
1
vote
1
answer
46
views
PyTorch and NVIdia Flare is taking all computing resource on machine learning experiments
I am utilizing PyTorch for federated experiments. As my experiments involves 50 datasets with models, so, I have to run multiple ML models experiments parallelly.
The code for training ML model is ...
4
votes
1
answer
130
views
Silencing NumPy Divide-by-Zero Warning while maintaining bit-for-bit parity with F77 Double Precision
I am porting a vertical interpolation routine from Fortran 77 to NumPy. I am aiming for bit-for-bit parity (Mean Absolute Error (\approx 10^{-16})) with the gfortran output, which uses DOUBLE ...
4
votes
3
answers
149
views
Return the list of indices where an array is increasing for at least a particular number of values
For example, indices where arr is increasing for at least 4 values:
arr = [4, 5, 6, 7, 2, 3, 4, 7, 8, 11, 2]
func(arr, 4) # -> [0, 4]
Is there some numpy-ish method for dealing with intervals of ...
0
votes
1
answer
45
views
How to resolve abydos version issue involving numpy.float and numpy.cfloat
I am using the name matcher hmni for the first time. I am getting the error ImportError: cannot import name 'float' from 'numpy' (C:\Program Files\Python312\Lib\site-packages\numpy\__init__.py). Did ...
1
vote
1
answer
83
views
Integrating rate gyroscope data efficiently with Python
I am working with a 3 axis gyroscope and I would like to integrate the rate data to find the orientation of my gyroscope as a function of time. The rate gyro measures the instantaneous rotation vector ...
0
votes
0
answers
109
views
TBB interaction in python binding [closed]
I have a C++ library exposed as a python module which internally uses oneTBB.
When compiling the library, I install the dependencies with it, including the oneTBB shared
library.
When I try to use the ...
Advice
0
votes
5
replies
70
views
Numpy axis rules
I am a Python developer, but I don't understand one thing: what are the numpy axis? Sometimes, when I use Sklearn, I have errors about axis. And I need explanations about values and reshape functions.
3
votes
1
answer
147
views
Unbalanced diagonal matrix from a symmetric matrix
I want to find the eigenvalues of a symmetric matrix.
When I do this in Python, I get an unbalanced diagonal matrix. The value of [0, 0] is much larger than the other eigenvalues.
Is it wrong?
How ...
2
votes
3
answers
108
views
Finding unique 1D arrays and corresponding 2D index pairs in 3D array (with numpy)
I have a 3D numerical array X, of shape=(N,N,6); and a 2D logical array mask, of shape=(N,N). I would like to find all unique 1D subarrays (length=6, along axis=2) of X, searching over the first two ...
-1
votes
1
answer
167
views
Python Multiplication of Two Arrays that May or May Not Have Same Shape [closed]
I have a problem where I have two arrays that can possibly have different shapes that I want to multiply together. Let's say I have two cases (I'm just using zeros right now cause all I care about is ...
3
votes
1
answer
469
views
Optimize, or correct, a code for interpolation and parameter estimation
This is a simple question, but will be a little long so I can give all the context to what is happening. Essentially, this is a code question/issue and the physical context behind is just to ...
0
votes
1
answer
65
views
Disabling Numpy Array Helper in Spyder
I would like to disable the AltGr + M shortcut in Spyder. Currently, it opens a "Numpy array helper" but I would rather be able to insert the µ character as I'm often dealing with units ...
5
votes
4
answers
211
views
Vectorise coincidences lookup between numpy arrays
I am trying to check how many elements in one numpy array can be found, with a certain tolerance, inside another numpy array. For now I have been using a for loop to apply my comparison logic, however,...