115,284 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
2
answers
45
views
plotly express trandline cannot import name '_lazywhere' from 'scipy._lib._util'
I used to be able to run ols trendline in plotly express without issue, but now it returns this error:
ImportError: cannot import name '_lazywhere' from 'scipy._lib._util'`
This code works:
# Works
...
0
votes
0
answers
35
views
Keras to_categorical results in different memory allocation error every re-run
I'm working on a semantic segmentation model through U-net for classifying 11 categories. After splitting my image and label data into training and testing arrays, I turn the arrays into Unsigned ...
5
votes
1
answer
77
views
Is my noise function differentially private? Is flattening then reshaping correct? Or it breaks the image?
The main function is apply_noise which applies the noise using the laplacian distribution, the scale of the distribution is b which is calculated with an epsilon value and the sensitivity value that ...
2
votes
3
answers
128
views
Python packages installation - pandas & nympy
I have read close to all posts about this topic now but I can get it working, so sorry if you find this similar to other questions, but I can't just solve it based on existing posts.
I find it very ...
3
votes
1
answer
253
views
Solving a cubic polynomial using numpy
I intend to design the foundation of an elevated water tank, consisting of a raft with the shape shown in the image below. To do so, I need to determine the raft diameter Dr by solving the following ...
0
votes
1
answer
83
views
Why doesn't the np.dot() method work with my arrays?
I am using jupyter notebook and numpy with the intention of making a program that orthonormalizes any given base following the Gram-Schmidt method for linear algebra.
Why doesn't the np.dot() method ...
1
vote
1
answer
130
views
Broadcasting DataFrames across NumPy array dimensions
I'm working with a large Pandas DataFrame and a multi-dimensional NumPy array. My goal is to efficiently "broadcast" a specific column of the DataFrame across one or more dimensions of the ...
3
votes
4
answers
166
views
Count Common Values between Different 2D Arrays
I have 2 arrays 2d and I would like to compare both and count the common values between them, for instance here is my code:
import numpy as np
def f_m_common(V_R, V_A):
r = len(V_A)
c = len(...
12
votes
3
answers
448
views
Multithreading becomes much slower than multiprocessing in free-threaded Python
Consider the following executable Python script mtmp.py:
import numpy as np
import os
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
# `x` is referenced `n_loop` times.
def ...
Advice
0
votes
11
replies
70
views
python/numpy : generate sound from an inverse fft of a synthetic spectrum
I continue to tinker with some code I found for analysing/categorising sound in .wav files, among others with the amplitude-weighted average and std. deviation of the rfft spectrum (I know, the ...
0
votes
1
answer
172
views
How to eliminate extra dimensions in this 3D Numpy array pattern matching?
This Python script:
import numpy as np
img = np.zeros((5, 5, 3), dtype='u1')
a = (1, 2, 3)
b = (3, 2, 1)
img[1:4, 1:4] = a
img[1, 1] = b
pat = img[1:4, 1:4]
win = np.lib.stride_tricks....
Advice
0
votes
4
replies
95
views
convert a numpy array[N] of 'S{n}' to an array[2*N] of 'S{n/2}'?
I have some code where I read N strings of a given size n into an ndarray, which I would then like to cut in half to obtain a twice longer array of strings size n/2. Is there a numpy operation which ...
Advice
1
vote
7
replies
98
views
python: numpy array interface to struct.unpack?
I'm tinkering with some code I found that reads in sound data from (stereo) .wav files, and wonder if there is no way to optimise the reading step.
Currently, it has the form (assuming a basic 16bit ....
3
votes
3
answers
175
views
Calls to Numpy routines from within multiprocessing tasks are very slow
I am calling numpy.linalg.inv from within a multiprocessing task forked from the Python multiprocessing module. I compare the Numpy routine to my own inverse routine my_inv.
What I see is that the ...
2
votes
2
answers
142
views
How to calculate the gradient of a scatter graph?
I have an arguably common problem, but I don't seem to find any instruction on the web. I have a 3D Numpy array containing the coordinates of N points:
In[1]: import numpy as np
In[2]: N = 50
In[3]: ...