115,292 questions
0
votes
1
answer
76
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
108
views
+250
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 ...
Advice
1
vote
6
replies
102
views
How to find max value within a specific range
Basically I have a 2D numpy array, the first column being my x-axis values and the second being my y-axis values. I want to find the max value of y within a specified range of x values (there are ...
3
votes
3
answers
102
views
String print format specifier does not work for numpy string array
I am trying to use numpy sort for numpy string array. But, when I try to print them element-wise with string print format specifier '{:s}' it is giving me the following error.
print("{0:s} {1:...
2
votes
1
answer
76
views
NumPy generate a 2d linear array using multiple values
So I'm trying to generate a map for a personal project using opensimplex noise, multiple layers etc.
My problem is that I want to recreate the equator to combine with a temperature map to obviously ...
Best practices
2
votes
3
replies
81
views
Create mask from array based on threshold
I have an array and I want to create a mask for this array based on a threshold, sorry if the explanation is a bit convoluted.
The first step is to find the intervals of elements higher than half of ...
3
votes
0
answers
103
views
Numpy importing error in mod_wsgi app on Fedora 43
I'm getting an error when importing numpy from an Apache mod_wsgi application on Fedora 43 and 42. It does not happen in Rocky Linux 9, the production server.
app.wsgi:
import sys
sys.path.insert(0, '/...
4
votes
1
answer
95
views
Efficiently coercing a Python list to a Numpy array with a custom datatype
I am using python to build an OpenGL rendering engine and am using numpy arrays with a custom datatype to store my vertex data.
import numpy as np
data_type_vertex = np.dtype({
"names": ...
1
vote
1
answer
58
views
What is the correct NumPy representation of a row vector for gradients
I am doing an assignment on matrices and gradients, where the final answer must be expressed as a row vector.
vr = np.array([1, 2, 3])
vrr = np.array([[1, 2, 3]])
Mathematically, a row vector should ...
Advice
2
votes
5
replies
107
views
Numpy handling small imaginary parts differently
There is a difference in behaviour on macOS with arm64 CPU vs other Linux with amd64.
For numpy v1 on arm64, it seems there is an internal logic guaranteeing the imaginary part to be exactly 0:
>&...
2
votes
1
answer
74
views
How do I make a custom field output different datatypes depending on file asking for data?
I'm building a molecule properties displaying website using django and sqlite. The database takes a numpy array and stores it as a BLOB. Currently, it just outputs the numpy array back out when asked ...
0
votes
0
answers
99
views
Noiseless Gaussian Process Regression not crossing the training points
I'm trying to perform a Gaussian Process Regression on series of data points Y and ln(X+(10^-4)) (The X values are used in log scale to create the model)
X ln(X+(10^-4)) Y
0.00001 -9.11503019 ...
2
votes
1
answer
36
views
How do I fix a "TypeError: bad number of pixels" in a healpy.fitsfunc.write_map call?
I have downloaded the HEALPix5 DECaPS 3D dust extinction map (from arXiv:2503.02657) and imported it as a numpy array meanmap. The array gives an expected result (51415400, 1, 120) to the meanmap....
2
votes
1
answer
175
views
numpy 2.2.6 tries to build on Windows 11 x64 instead of using wheel
originally I was trying to install opencv-python which fails on trying to install numpy:2.2.6
So I am trying to just install this numpy and for some obscure reason it tries to build it! instead of ...
3
votes
3
answers
110
views
Numerically finding the minimum value of a variable where a function equals a value
I have a black box function baseball that determines the magnitude of the distance that a baseball travels when launched. It takes the initial speed, the angle of launch and the initial spin. Assuming ...