3,933 questions
4
votes
1
answer
122
views
Numpy vectorising n-variable function by index
Given a closed-form function f(x,y,z), what is the most efficient way to fill up a 3D ndarray arr[z][y][x] with the values of f(x,y,z)?
For example, if I wanted a 3D ndarray arr[z][y][x] with each ...
4
votes
2
answers
228
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 ...
4
votes
1
answer
177
views
Weird behavior in large complex128 NumPy arrays, imaginary part only [closed]
I'm working on numerical simulations. I ran into an issue with large NumPy arrays (~ 26 GB) on Linux with 128 GB of RAM. The arrays are of type complex128.
Arrays are instantiated without errors (if ...
2
votes
2
answers
70
views
List of points [ (x,y), …] to np.array()
I have a list of points such as [(x, y), …]
I want to convert it in a numpy.array() such as [[0,0,1,…], …], 1 representing a point of the list.
According that np.array().shape is : ( max(x)-min(x)+1, ...
2
votes
2
answers
142
views
Making a random grid that doesn't vary 'too much'
I'm making a meshgrid to represent background radiation levels, but I'd like it to be less noisy. My implementation is trivial, I've plotted
import numpy as np
x = np.linspace(-2, 2, 100)
y = np....
1
vote
1
answer
86
views
Arbitrary Stencil Slicing in Numpy
Is there a simple syntax for creating references to an arbitrary number of neighbouring array elements in numpy?
The syntax is relatively straightforward when the number of neighbours is hard-coded. A ...
1
vote
1
answer
102
views
Numpy __array__ not working when return array with single item
Because plain dict is not adequate for inheritance, I design the following MyDict with UserDict in python standard libraries:
import numpy as np
from collections import UserDict
class MyUserDict(...
1
vote
0
answers
16
views
How do I expand an "named" n-dimensional matrix in n dimensions at once?
I start with a 0 by 0 matrix that I want to expand to a (1,1) matrix, then (2,2) etc. I also want to have the columns named, so the (0,0) matrix would increase to:
First
First 0
then
...
1
vote
1
answer
60
views
numpy.ndarray of seconds of a day to datetime format
I have a Python numpy.ndarray of seconds of the day with a bunch of decimal seconds:
import numpy as np
sec = [40389.66574375, 40390.12063928, 40391.32714992, 40392.64457077, 40393.48519607, 40394....
0
votes
0
answers
45
views
How to convert holoscan Tensor to ndarray
I have a holoscan Application, a MiddleOperator where I take a Tensor, i want to convert this Tensor to ndarray, do something with it, and emit to "out".
import os
from holoscan.core import ...
2
votes
2
answers
149
views
issue with sympy lambdify
I just want numerically integrate the Lorenz' famous 3 equations
I create this code that seems perfectly work:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import ...
0
votes
0
answers
60
views
subclass numpy arrays: when using resize, how to re-attach the view to sliced children arrays
I am trying to create a buffer array that creates extra indexes of the numpy so I can assign rather than using functions like np.append and where "children" sliced array can still be a view ...
3
votes
0
answers
218
views
Numpy IO seems to have an 2GB overhead in StorNex (cvfs) File System
TL;DR:
Initally I thought the numpy load functions doubles memory usage at peak
after some additional tests it seems like the underlying file system (StorNex [cfvs]) leads to a size-independent 2GB ...
0
votes
1
answer
86
views
Apparently weird condition on inclusion of endpoint in np.arange() [duplicate]
The numpy.arange function takes the three parameters: start, stop, step (positional args.)
The default step is 1.
Throughout my entire Numpy experience, the last element of the resultant array is not ...
1
vote
0
answers
120
views
PySide6 QImage conversion to PyQtGraph ndarray
I cannot generate a QImage with some text on it, keep it in memory, and then successfully display it on a pyqtgraph.ImageItem which needs it as an np.ndarray
import sys
import numpy as np
import ...