115,291 questions
0
votes
0
answers
16
views
Noiseless Gausian Proces regression not crossing the training points
I'm trying to perform a Gaussian Process Regression on the following series of data points (X and Y):
X Y
0.00001 -6.8200000000000003
0.00014 -6.8073846153846160
0.00042 -6.6818333333333326
...
2
votes
1
answer
27
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....
3
votes
3
answers
104
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
0
answers
59
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 ...
-4
votes
0
answers
54
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
88
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 ...
Advice
0
votes
4
replies
61
views
Regex-logic in a numpy/torch array
Evening,
Is there any way to find a specific sequence of numerical values, matching certain logic (in the same way as in a regex), within a numpy/torch array or matrix row?
I know i could just convert ...
3
votes
2
answers
128
views
Calculate cumulative value based on another column [duplicate]
Having this kind of pandas dataframe
df = pd.DataFrame({
'ts_diff':[0, 0, 738, 20, 29, 61, 42, 18, 62, 41, 42, 0, 0, 729, 43, 59, 42, 61, 44, 36, 61, 61, 42, 18, 62, 41, 42, 0, 0]
})
ts_diff - is ...
2
votes
2
answers
120
views
Deserializing msgpack_numpy array in browser
I make a web app, the server side is running Python and processes data with numpy. I want to display charts from the numpy data on the browser.
On the server I encode a list of numpy arrays with ...
1
vote
0
answers
156
views
Plotting linear regression for geometric intuition
I am regressing Y~(X1, X2) such that this fit is perfect (R squared is 1), where the R squared for Y~X1 and Y~X2 are chosen somewhere in the interval $(0,1)$. I am trying to create the numerical ...
-5
votes
0
answers
57
views
Upgrade to 3.14 causes np.float64 to print in output--how do I fix? [duplicate]
I recently upgraded to Python 3.14. This caused the below weird output in my dataframe:
Stock Price ATM Theta Return Roll Avg
0 SOFI np.float64(29.68) np....
4
votes
3
answers
116
views
numpy vectorise approach to creating array results computed from indices
What is an efficient numpy way of achieving an array of results based on a pair of index datasets?
So, lets say there are 2 arrays these are the row and column headers in the table underneath:
a = [1,...
1
vote
1
answer
65
views
EDL generation with python 3.10 (imagehash & numpy) produces complete nonsense on a greater amount of files
I have a directory of ca. 1600 PNGs (1000x400 res. previews of frames) and want to generate an EDL so I do not have to render the same frame several times.
So far, I have successfully run the ...
3
votes
1
answer
139
views
Build numpy 2.3+ without accelerated libraries
Related post: Compile numpy WITHOUT Intel MKL/BLAS/ATLAS/LAPACK
Recent versions of numpy use meson for build configuration, I can build numpy from source but failed to exclude BLAS/LAPACK/... deps.
...
2
votes
1
answer
90
views
Does `jax` compilation save runtime memory by recognizing array elements that are duplicated by indexing
Consider the example code:
from functools import partial
from jax import jit
import jax.numpy as jnp
@partial(jit, static_argnums=(0,))
def my_function(n):
idx = jnp.tile(jnp.arange(n, dtype=int)...
1
vote
2
answers
104
views
Why does NumPy load() take longer in a larger script than in another?
I scan for a trigger and when I get it, load a .npy file and process it. It started to take almost 2 seconds to load the NumPy file from within the process but when I tried to load the same file from ...
1
vote
1
answer
91
views
How to read a chunk of big tiff file in Python? [closed]
I have a TIFF file with a size of (48000, 432000) and I would like to upload only a piece of the image, for example, pass a parameter like (X, Y, wid, hei), where X, Y are the coordinates of the upper-...
-4
votes
1
answer
116
views
NumPy high-dimensional array automatically rearranges after subsetting
Today I wanted to use the following command to subset a numpy high-dimensional array, but was surprised to find that the two methods were completely different. I'm very curious why numpy reorders the ...
1
vote
1
answer
95
views
Calculating MultiIndex intersection to a given tolerance in an efficient way
I have two DataFrames, data1 and data2, with 3-level multiindices. The first two levels are floats, and correspond to spatial coordinates (say longitude and latitude). The third level, time, is based ...
5
votes
1
answer
194
views
Divide by zero encountered in matmul on MacOS M4 with numpy v2.0.0
I'm encountering a strange RuntimeWarning: divide by zero encountered in matmul when performing a simple matrix multiplication on my new Apple M4 machine.
The most peculiar part is that this warning ...
4
votes
2
answers
198
views
Python multiprocessing shared memory seems to hang or crash when interacting with small numpy arrays
I've been trying to parallelize some code that I wrote in python. The actual work is embarrassingly parallel, but I don't have much experience with multiprocessing in Python.
The actual code I'm ...
2
votes
1
answer
106
views
Shape of sliced array from shape of array and slice
If I know the shape of a numpy array like (1000, 50), and I have an arbitrary selection expressed as an IndexExpression, let's say np.s_[:200, :], how can I evaluate the shape of the sliced array (in ...
2
votes
2
answers
119
views
Numpy random normal test shows unexpected results with low p-value
I am performing some tests on the normality of the numpy random generator. Running the following code, the stats.normaltest shows some seeds with low pvalue (which highlights non-normal distribution).
...
1
vote
2
answers
240
views
How to make index into exponential notation?
I've tried to put in the NumPy scientific notation function in different places but that didn't work, other than that I haven't been able to find anything that works
def optimal_resistor(name="&...
0
votes
1
answer
116
views
How to save violin plot object as npy or npz files
I am plotting multiple violin plots for a large dataset and it takes so long to generate one figure. I would like to save the violin plotting objects as npy or npz, and plot them separately. Is this ...