Skip to main content

All Questions

Tagged with
1 vote
0 answers
70 views

Numpy ints convert into python ints within numpy array

I'm writing code to group points around each point in a curve into concentric regions. Then I find the geometric median of each region as way of determining its "shape". The point indices ...
lilbumblingbee's user avatar
3 votes
1 answer
103 views

How to extract sub arrays from a larger array with two start and two stop 1-D arrays in Python?

I am looking for a way to vectorize the following code, # Let cube have shape (N, M, M) sub_arrays = np.empty(len(cube), 3, 3) row_start = ... # Shape (N,) and are integers in range [0, M-2] row_end ...
Austin's user avatar
  • 33
0 votes
2 answers
84 views

Demystify numpy indexing/slicing

could you please help demystify the following numpy indexing/slicing behaviours? Thanks! arr = np.arange(60).reshape(3,4,5) print(arr[2, :, 4]) #1 print(arr[[2], :, 4]) #2 print(arr[2, :, [4]])...
ThxAlot's user avatar
  • 99
1 vote
1 answer
78 views

Taking values from numpy array using array of indices

I am trying to find a simple numpy command to take the values of an 3D matrix according to an index array for the second coordinate. This can be done as: import numpy as np entry = np.array([[1, 2],[3,...
Thomas Koller's user avatar
1 vote
2 answers
80 views

Converting an array of floats into RGBA values in an efficient way

I am trying to create a system to take an array of floats which range from 0.0 to 1.0 and convert them into RGBA values based on a lookup table. The output should be an array that is one dimension ...
Liam's user avatar
  • 51
0 votes
1 answer
73 views

Dynamic input to populate Numpy array without for loop for Monte Carlo

I've got some elegant code from other contributors for a Monte Carlo (random walk) using numpy. However, currently the 'vol,' aka standard deviation, is a supplied constant. Ideally, it should vary ...
rdsencap's user avatar
0 votes
3 answers
84 views

Indexing overlapping areas of a numpy array

I have a 2D array of zeros (called labels) and a list of its coordinates (called centers). For each of the centers I would like to put a progressive number in a 5x5 cluster around it inside the label ...
toto's user avatar
  • 357
0 votes
2 answers
53 views

How to index an ndarray of unknown dimensions

I have a python code that uses a numpy array to store multi-dimensional data. The dimensionality of the array is determined at runtime so I cannot know in advance the exact number of dimensions, which ...
Arthur's user avatar
  • 117
2 votes
4 answers
138 views

Why the result is different? Numpy Slicing and indexing

Basically I want to obtain a part of the variable "cubote". I tried two methods that should work in the same way, but it didn't. My code: import numpy as np # Create a 3x3x3 cube ...
Hamilton Espitia's user avatar
0 votes
1 answer
48 views

Numpy/PyTorch indexing, assigning values over repeats

I am trying to combine assignment and advanced indexing. I have an array of size (batch, x, y, width) and I am trying to assign it to an array of (batch, width) such that the values are repeated over ...
Luke Bhan's user avatar
2 votes
1 answer
55 views

Numpy memory error when masking along only certain axis, despite having sufficient RAM

I have a large array and I want to mask out certain values (set them to nodata). But I'm experiencing an out-of-memory error despite having sufficient RAM. I have shown below an example that ...
Placibo's user avatar
  • 33
0 votes
0 answers
23 views

python (Apply inflation table to sales table) [duplicate]

I have the below tables: Sales Table: enter image description here Inflation Table: enter image description here I want python to update table one values by multiply each value in table one with ...
Mohamamd Khalil's user avatar
2 votes
3 answers
282 views

Numpy index argsorted with integer array while retaining sorting order

I have an array x and the result of argsorting it i. I need to sort x (and y, irrelevant here) according to i hundreds of times. It is therefore not doable to sort the data twice, everything needs to ...
NotProbable's user avatar
0 votes
0 answers
215 views

How to save a numpy array in .fvecs

I'm using faiss to create an index out of vector embeddings, which can then be used for performing similarity search. Since my dataset runs into billions, I'm looking for extremely fast (near-optimal) ...
helloworld's user avatar
0 votes
1 answer
55 views

Array coordinate treated as sequence

I am inputting a numpy array, which was generated from an image into a function. That function makes an autostereogram by horizontally repeating the image and shifting certain pixels. This is done ...
T. J. Foster's user avatar

15 30 50 per page
1
2 3 4 5
93