Skip to main content
Filter by
Sorted by
Tagged with
4 votes
1 answer
118 views

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 ...
Towelmonkey's user avatar
4 votes
1 answer
172 views

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 ...
laserpropsims's user avatar
2 votes
2 answers
142 views

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....
Space cat 321's user avatar
1 vote
1 answer
100 views

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(...
DrizzleatDusk's user avatar
1 vote
1 answer
59 views

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....
Swawa's user avatar
  • 273
2 votes
2 answers
147 views

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 ...
Ged's user avatar
  • 37
3 votes
0 answers
217 views

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 ...
Helmut's user avatar
  • 496
1 vote
0 answers
111 views

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 ...
Andrei M.'s user avatar
  • 413
0 votes
2 answers
61 views

I am wanting to identify identical vectors after a dot product calc. The below works for a single dimension but not multi-dimensionally. Single Dimension a = np.array([0.8,0.5]) b = np.array([0.8,0.5])...
Zac's user avatar
  • 1,637
5 votes
1 answer
143 views

Say I have an array as follows: arr = np.asarray([1, 2, 3, 4294967296, 100], dtype=np.uint64) I now want two arrays, one array with the lower 32 bits of every element, and one with the upper 32 bits ...
lrdewaal's user avatar
  • 360
10 votes
1 answer
660 views

I need to work with arrays that can have zeros in their shapes. However, I am encountering an issue. Here's an example: import numpy as np arr = np.array([[]]) assert arr.shape == (1,0) arr.reshape((...
Ziofil's user avatar
  • 2,105
1 vote
0 answers
80 views

Numpy library crash without console error or warning constantly In Python Console see notifications either Process finished with exit code -1073741819 (0xC0000005) or Process finished with exit code -...
Антон Орлов's user avatar
0 votes
1 answer
122 views

I'm currently trying to implement my own version of 2D Pooling (with channels included) in Python using only NumPy, but I've run into a bit of a roadblock with vectorizing the backpropagation process. ...
user29391104's user avatar
-1 votes
1 answer
49 views

Take a unitary matrix U. I want to swap the columns such that the largest element of each column (in absolute value) is on the diagonal (modulo ties). What is the best way to do this in numpy?
Ben's user avatar
  • 539
0 votes
1 answer
75 views

What I'm trying to do is essentially removing all rows h,s in a 3D numpy array a if a[h,s,v] = some value for all v More specifically, I have a loaded image from cv2 which contains some transparent ...
Omaro_IB's user avatar
  • 435
3 votes
2 answers
68 views

I have an array a of size (M, N, K). And I have an array b of size (M, N) with integer values of [0, K-1]. How do I get the array... c of size (M, N), where c[i, j] == a[i, j, b[i, j]] in the simplest ...
Kuraga's user avatar
  • 403
1 vote
3 answers
68 views

Suppose I have a Numpy array n indices, where the first n-2 represents some counting indices and the last 2 indices represent a square MxM matrix. I want to initialize this structure so it will ...
Triceratops's user avatar
0 votes
0 answers
38 views

%timeit -n 1000 -r 7 np.zeros(100000000, dtype=bool) gives 4.22 ms %timeit -n 1000 -r 7 np.zeros(1000000000, dtype=bool) # 1 more zero = 10 times longer array gives 3.13 μs (not even milliseconds, ...
ruul's user avatar
  • 41
1 vote
3 answers
81 views

The following snippet: import numpy as np x = np.arange(25).reshape(5, 5) print(x.base) y = x[:2, [0, 2]] print(y.base) outputs [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
Antonios Sarikas's user avatar
2 votes
1 answer
151 views

I have a numpy array I converted from awkward array by to_numpy() function, and the resulting array has the datatype: dtype=[('phi', '<f8'), ('eta', '<f8')]). I want to make it a regular tuple ...
Yusuf Çil's user avatar
4 votes
2 answers
168 views

Problem I have a NumPy array and need to identify repeated elements, marking the second occurrence and beyond as True, while keeping the first occurrence as False. For example, given the following ...
Dos_Santos's user avatar
0 votes
1 answer
103 views

Here is my code. I import Wisconsin breast cancer database from kaggle to vscode. All dataset variables all numeric and float 64. There is this type error: (Exception has occurred: TypeError can't ...
bahar homayoun's user avatar
0 votes
1 answer
40 views

If I have a vector vec, I can index it with a matrix as follows: import numpy as np vec = np.asarray([1,2,3,4]) # Shape (4,) mat = np.asarray([[0,2], [3,1]]) # Shape (2,2) result =...
Ben's user avatar
  • 539
1 vote
2 answers
52 views

The function has this mathematical form f(x) = 1, if x<1 = g(x), for 1<=x<10 = 0, for x >=10 where g(x) is a simple function. It is straightforward to write such a function if ...
nos's user avatar
  • 21.1k
3 votes
1 answer
63 views

I have a numpy array of numpy arrays and I need to add a leading zero to each of the inner arrays: a = [[1 2] [3 4] [5 6]] --> b = [[0 1 2] [0 3 4] [0 5 6]] Looping through like this: for item in a:...
apnoorex's user avatar

1
2 3 4 5
79