115,290 questions
-1
votes
1
answer
61
views
How to randomly select a pixel within a kernel and attribute its value to the center pixel? [closed]
In order to investigate whether the decisions of a CNN for image classification are predominantly driven by image regions related to relatively fine object features, I am looking for an image ...
4
votes
1
answer
78
views
Efficiently coercing a Python list to a Numpy array with a custom datatype
I am using python to build an OpenGL rendering engine and am using numpy arrays with a custom datatype to store my vertex data.
import numpy as np
data_type_vertex = np.dtype({
"names": ...
0
votes
0
answers
55
views
Why am I getting a blank nullcline plot? [closed]
I'm trying to plot nullclines for a nonlinear system and determine fixed points from the same. However, until now, my code has not been good enough to generate the plots. Presently, I'm only able to ...
1
vote
1
answer
53
views
What is the correct NumPy representation of a row vector for gradients
I am doing an assignment on matrices and gradients, where the final answer must be expressed as a row vector.
vr = np.array([1, 2, 3])
vrr = np.array([[1, 2, 3]])
Mathematically, a row vector should ...
Advice
2
votes
5
replies
94
views
Numpy handling small imaginary parts differently
There is a difference in behaviour on macOS with arm64 CPU vs other Linux with amd64.
For numpy v1 on arm64, it seems there is an internal logic guaranteeing the imaginary part to be exactly 0:
>&...
2
votes
1
answer
65
views
How do I make a custom field output different datatypes depending on file asking for data?
I'm building a molecule properties displaying website using django and sqlite. The database takes a numpy array and stores it as a BLOB. Currently, it just outputs the numpy array back out when asked ...
0
votes
0
answers
92
views
Noiseless Gaussian Process Regression not crossing the training points
I'm trying to perform a Gaussian Process Regression on series of data points Y and ln(X+(10^-4)) (The X values are used in log scale to create the model)
X ln(X+(10^-4)) Y
0.00001 -9.11503019 ...
2
votes
1
answer
32
views
How do I fix a "TypeError: bad number of pixels" in a healpy.fitsfunc.write_map call?
I have downloaded the HEALPix5 DECaPS 3D dust extinction map (from arXiv:2503.02657) and imported it as a numpy array meanmap. The array gives an expected result (51415400, 1, 120) to the meanmap....
2
votes
1
answer
108
views
numpy 2.2.6 tries to build on Windows 11 x64 instead of using wheel
originally I was trying to install opencv-python which fails on trying to install numpy:2.2.6
So I am trying to just install this numpy and for some obscure reason it tries to build it! instead of ...
3
votes
3
answers
107
views
Numerically finding the minimum value of a variable where a function equals a value
I have a black box function baseball that determines the magnitude of the distance that a baseball travels when launched. It takes the initial speed, the angle of launch and the initial spin. Assuming ...
1
vote
1
answer
92
views
Scipy Hessian with Numpy cross product
I need to compute the Hessian of a function involving cross products in Python. As an experiment, I consider the simple function
def func(x):
return np.sum(np.cross(x[0:3], x[3:6]))
and compute the ...
1
vote
0
answers
66
views
PSTH with numpy.histogram shows periodic “gaps” at bin boundaries even after integer time conversion—how to bin robustly?
I’m computing peristimulus time histograms (PSTHs) in Python. Each trial aligns spikes to a reach-start timestamp and bins them into fixed-width bins. I see vertical “gaps” (low counts) at exact bin ...
0
votes
1
answer
47
views
Creating 3d Mesh from Z stack of ROIs
I have a set of 3D ROI label stacks stored as TIFF files, where each ROI represents a single cell. I want to generate surface meshes(I use trimesh) suitable for downstream shape analysis.
I tried ...
-4
votes
0
answers
60
views
Getting "ERROR: No matching distribution found for numpy" while installing NumPy on Mac
I am trying to install and import numpy on my Mac but in the terminal of Pycharm, it comes up with a error message as shown below.
I am a relatively new coder in python so I am extremely confused.
...
Best practices
1
vote
1
replies
90
views
Applying Cosine Similarity to multiple vectors at once
I am implementing cosine similarity to my vector database using python and numpy. I would like to know if I should loop through every database entry and find the cosine similarity or is there a way of ...