115,129 questions
0votes
1answer
30views
Wierd memory allocation and freeing with Numpy
So I have been tracking this weird memory leak in my Python repo for a while now. Finally I was able to isolate the problem using the code below. The numpy arrays are generating data with a similar ...
2votes
1answer
37views
How to compute elementwise dot product of two 2D NumPy arrays [duplicate]
This script: import numpy as np a = np.array([[0, 1], [1, 1], [1, 0]]) b = np.array([[1, 0], [1, 1], [1, -1]]) dot = a[:, 0]*b[:, 0] + a[:, 1]*b[:, 1] print(dot) produces elementwise dot product of ...
1vote
0answers
47views
Create all possible outcomes from numpy matrix that represents mutually in/exclusivity of outcomes
Let's assume there is an event and within this event there are multiple outcomes that can co-exist. An example would be a tennis game where A plays against B and B serves. A couple of possible ...
-2votes
0answers
20views
Why does the build_model-function in mpi-sppy not work? [closed]
Could someone please help me understand the error in my code? I based it on the farmer example from the link provided, but I’m unable to figure out why the model isn’t being created. I have noted the ...
2votes
0answers
56views
numpy.load() seems to use double the memory of the array at peak
I thought numpy.load() writes directly into the array data memory. However, the results of the profiling functions (I profiled with memray and mprof) seems a bit strange to me... My array is 2GB big. ...
0votes
1answer
74views
Why does np.fromfile fail when reading from a pipe?
In a Python script, I've written: # etc. etc. input_file = args.input_file_path or sys.stdin arr = numpy.fromfile(input_file, dtype=numpy.dtype('f32')) when I run the script, I get: $ cat nums.fp32....
1vote
0answers
24views
gdal_array can't be imported in Python-GDAL
Ok, so, I'm trying to process some .bil files in Debian 12 I installed GDAL using: sudo apt install gdal-bin sudo apt-get install libgdal-dev And ogrinfo --version outputs: GDAL 3.6.2, released 2023/...
-1votes
0answers
72views
How do I do Eigen decomposition of a generalized Fibonacci matrix to arbitrary precision?
This is a follow up to my previous question. I want to efficiently compute Nth term of higher order generalized Fibonacci numbers, N is sufficiently large such that the Nth term is guaranteed to be ...
0votes
0answers
32views
Unable to limit memory(RAM) consumption in a FastAPI based service using Sqlite / AioSqlite
I have stored strings & their vector embeddings in a Sqlite DB file with the table name "query_metadata". Embeddings are stored as numpy bytes. The embeddings would be used for ...
0votes
0answers
57views
Why doesn’t the barycenter method detect subpixel displacements where correlation does?
I’m working with X-ray imaging data. I have a reference image containing a structured pattern, and a sample image where this pattern is slightly distorted due to the presence of a physical sample. My ...
1vote
1answer
45views
import gensim binary incompatibility
import gensim import numpy import scipy print("gensim version:", gensim.__version__) print("numpy version:", numpy.__version__) print("scipy version:", scipy.__version__) ...
2votes
2answers
66views
Pandas: Fill in missing values with an empty numpy array
I have a Pandas Dataframe that I derive from a process like this: df1 = pd.DataFrame({'c1':['A','B','C','D','E'],'c2':[1,2,3,4,5]}) df2 = pd.DataFrame({'c1':['A','B','C'],'c2':[1,2,3],'c3': [np.array((...
-1votes
1answer
83views
python interpreter getting killed when writing into large-ish numpy array (but much smaller than the RAM)
The following python code allocates an 8GB numpy array, and writes into it. It kills the python interpreter, regardless of the size of the RAM of the machine (it happens on a server with 384GB of RAM)....
2votes
1answer
56views
Alternative to looping over one numpy axis
I have two numpy arrays a and b such that a.shape[:-1] and b.shape are broadcastable. With this constraint only, I want to calculate an array c according to the following: c = numpy.empty(numpy....
0votes
2answers
68views
Unexpected behavior with array slicing and mask
It was unexpected that x=np.empty((2,10,5)) x.shape >>> (2, 10, 5) x[0].shape, x[0,:,:].shape >>> ((10, 5), (10, 5)) mask = [True,True,True,False,False] x[0,:,mask].shape >>&...