115,280 questions
5
votes
1
answer
95
views
If I build numpy with `-Dcpu-baseline="none"`, will it still generate optimised code paths for newer CPUs?
I have trouble understanding this section of the docs: https://numpy.org/devdocs//reference/simd/build-options.html#targeting-older-cpus
In the default build of numpy, cpu-baseline is set to min. In ...
0
votes
0
answers
101
views
Error while generating package metadata --> numpy
My Question: I am trying to run an acoustic program with Python. I have encountered an error in the file while executing "pip install arlpy". I am using the instructions from the following ...
0
votes
0
answers
92
views
Binary incompatibility with Numpy [duplicate]
I am running a Kaggle notebook with a T4 GPU with the following code:
%%capture
!pip uninstall -y transformers datasets accelerate peft huggingface_hub bitsandbytes sentence-transformers faiss-gpu
!...
14
votes
1
answer
694
views
Why is nonzero(arr != 0) faster than nonzero(arr) in python?
It doesn’t make sense to me. It looks like nonzero(arr != 0) just creates an intermediate array, allocating more memory. No way it is faster, otherwise why doesn’t NumPy optimize it? But here is my ...
0
votes
0
answers
96
views
Getting only top line of the object in pyvista
I am looking to get the precise top line of an object to later compare sensor data of an encoder that will travel over this object.
import pyvista as pv
import numpy as np
PATH = r"Foam.stl"...
0
votes
1
answer
112
views
Version mismatch between Numpy and Python?
I use Linux to learn reinforcement learning, but found that something went wrong with different versions of Numpy and Python...
My old project uses python=3.7, numpy=1.18.2 and that's OK. However, ...
Advice
1
vote
2
replies
55
views
Using numpy.isin for set operations where set members are Vectors or Matrices
In [251]: x.shape
Out[251]: (388240, 15, 8)
In [252]: y.shape
Out[252]: (66, 15, 8)
I'd like to treat x and y as ⊆ 𝓜(15, 8) and x[i], y[i] for the purposes of set operations such as isin. Or in ...
3
votes
1
answer
139
views
Generalized histogram in python: applying function bin by bin
To construct a histogram, we have an array of bins and a data array, find in which bins the data go, and count the number of elements in each bin. I would like something similar but more general, ...
4
votes
1
answer
123
views
Spherical Voronoi heatmap on a Mollweide projection
Using Python, I want to display a scalar distribution defined over a sphere, and visualize it with a Mollweide projection. The issue I'm dealing with is the discontinuity caused by the projection.
...
4
votes
1
answer
179
views
Memory leak happening with Python when creating numpy diagonal array and doing matrix math
P = y.T @ (np.diag(Wc) @ y) This line is creating increased memory usage for me in the below code on my Windows 11 machine. As soon as I run the code, I see the RAM usage increasing and skyrocketing. ...
1
vote
2
answers
112
views
Is there a numpy (or scipy, or whatever) vectorized function that can sample from an array of probabilities?
I need a function that behave like np.random.choice, but that takes the argument "p" to be a 2-dimension array, of which each row is a probability. The function should return a sample from ...
4
votes
2
answers
86
views
When or why should I use numpy.meshgrid (Ny,Nx) arrays instead of two (1,Nx) and (Ny,1) arrays?
I have been extensively using numpy arrays recently, and have discovered that what I used to do with meshgrids could be done with smaller 1D arrays:
import numpy as np
def myfun(x,y):
return np....
3
votes
0
answers
87
views
Conda shows numpy=1.24.3 as installed, but Python reports version 2.4.2 in the same environment
I am encountering a version mismatch issue with numpy in a specific Conda environment (speciesnet).
The Symptoms:
When I run conda install numpy=1.24.3, Conda tells me: # All requested packages ...
2
votes
1
answer
87
views
Python colour.difference.CIE_delta_E_2000 conversion from numpy to built-in math
I try to convert the colour.difference.delta_E_CIE2000 method from numpy in a built-in math function, since the colour-science package (while great) is just overkill for my purpose.
I checked the ...
5
votes
2
answers
159
views
Python type hints with optional dependencies
I am writing some Python type stubs for a package, and I have run into a function that can take either a list or, if numpy is available, a numpy.ndarray. If numpy is present and the function is given ...