115,282 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
5
votes
1
answer
69
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
102
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
223
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
80
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
129
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
157
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(...
11
votes
3
answers
427
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
69
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
171
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
94
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
174
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
139
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]: ...
1
vote
1
answer
105
views
Why does my rotation (up / down) break when I rotate 90 degrees left or right, and how do I fix it?
I'm trying to make a simple 3d renderer in CMU Graphics using rotation matrices. When I rotate the camera 90 degrees (left or right), and I try rotating (up / down), it does a "barrel roll" ...
1
vote
3
answers
196
views
Error while deploying python code to linux based azure function
I am trying to deploy python code to azure function (linux based, python 3.12). The app works if I exclude pandas (and other package dependency). However, I am getting the following error on azure if ...