Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
22 views

Why does `blake2b` on a `numpy` array give different results in different machines?

I ran the following code in two different machines: import numpy as np from hashlib import blake2b print(blake2b(np.array([1, 2, 3])).hexdigest()) The two machines print a different result. Why ...
Ray Bern's user avatar
  • 125
-7 votes
1 answer
57 views

WiggleSort: giving wrong output? [closed]

I am trying to solve LeetCode problem 324. Wiggle Sort II: Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... You may assume the input array always ...
ttait1's user avatar
  • 1
0 votes
0 answers
18 views

Plotting Eigen-energies using QuTip

I am trying to plot the eigen-energies of the following Hamiltonian $$ H = 2\tau \cos(\frac{eA}{hc} \sin(\omega t) + k) $$ Here \tau value is set to 1. A is the amplitude. e,h,c are electron charge, ...
strings's user avatar
0 votes
0 answers
15 views

pLotting the correlation between temperature and wildfire in iran

The idea is to find the correlation between wildfires and temperature in iran. I used the coordinate for each wildfire against the temperature in iran, i mean the geometry but the p-value was very low ...
user26506504's user avatar
0 votes
3 answers
69 views

numpy 2d arrays, remove duplicate rows

I have 2 2d numpy arrays, Array A and Array B. I want to remove rows who occurs in both arrays for Array A and B. But, if it occurs 1 time in Array A and 2 times in Array B, I want to only remove it 1 ...
BGR's user avatar
  • 157
1 vote
1 answer
36 views

Iteration of a graph approximation

The code below runs a model based on a graph generated by the solution to a system of differential equations and shows one with random 5% error added to the points. How would I iterate this process (...
user1134699's user avatar
4 votes
2 answers
57 views

Numpy: apply mask to values, then take mean, but in parallel

I have an 1d numpy array of values: v = np.array([0, 1, 4, 0, 5]) Furthermore, I have a 2d numpy array of boolean masks (in production, there are millions of masks): m = np.array([ [True, True, ...
Franc Weser's user avatar
0 votes
3 answers
62 views

python and problems with passing array to a function

I need to solve some ordinary differential equation dy/dx = f(x) = x^2 ln(x) and to proceed I create the array xpt between the limits 0. <= xpt <= 2. Because I have to be careful at xpt = 0, I ...
jim's user avatar
  • 155
-1 votes
0 answers
46 views

Dividing number into minimum number of teams

I am trying to solve a problem. There are 2 possible team sizes teamSize1 and teamSize2, and p total players. How can we divide the players such that each player is in exactly one team, and the number ...
Mirajur Rahman's user avatar
0 votes
0 answers
56 views

How do I build a specific Python structure of a 2D array of 1D arrays?

How do I build a specific structure of a 2D array of 1D arrays (i. row vectors) to meet the specific structure of a legacy programme I am maintaining? I can generate the right content, in this ...
Donovan Roisin's user avatar
4 votes
0 answers
104 views

Why is np.sort() with order slow on multi dtype arrays? (sorting by unsigned integer ID)

Working with embedded software, I'm using numpy arrays with specified datatypes to save memory and other reasons. I'm using version '1.23.4' and Python 3.10.0, but this seems to be an issue with ...
me9hanics's user avatar
  • 351
1 vote
1 answer
74 views

How do I effectively compute pairwise quantities in numpy?

I want to compute pairwise quantities, e.g. distances between two points. A simple example would be import numpy as np N = 9 x = np.linspace(0,1,N) y = np.abs(x - x[:,None]) # pairwise 1d eucdlidian ...
knods's user avatar
  • 23
0 votes
2 answers
70 views

How to transform nested arrays by extending the dimension of the array

Suppose I have an array X with N elements. I would like then to input this array into a 2D array A as follows X=np.array([0,1,2,3],dtype=np.float64) A=np.array([[0,0,X], [0,X,0]],dtype=np....
J.Agusti's user avatar
  • 173
5 votes
2 answers
84 views

Apply permutation array on multiple axes in numpy

Let's say I have an array of permutations perm which could look like: perm = np.array([[0, 1, 2], [1, 2, 0], [0, 2, 1], [2, 1, 0]]) If I want to apply it to one axis, I can write something like: v = ...
sams-studio's user avatar
-2 votes
0 answers
76 views

How can Flat sequences occupy more memory than container sequences in Python? [duplicate]

Fluent python book describes two types of sequences: Container and Flat, with container sequences being able to hold items of different types but as reference to python objects, while flat sequences ...
DarKing's user avatar
  • 21

15 30 50 per page
1
2 3 4 5
2296