Relative Content

Tag Archive for pythonnumpyscipy

Scipy fft on winsize-long data array computes 2 windows

I’m trying to write an algorithm for lazily plotting spectrograms on long, high-sampled audio files.
I want to break my audio array into chunks of size equal to the width of my fft sliding window for computing [nfft//2+1:1] sub-spectrogram arrays.

Why is trapz returning negative values, even when x is sorted ascending and y is all positive?

y = np.array([59817478.73563218, 56195352.29885057, 59679547.70114943, 61071789.08045977, 56678110.91954023, 56900812.06896552, 61942478.73563218, 57360582.18390805, 57423800.57471264, 61169490.22988506, 58930984.48275862, 56777248.85057471, 60586156.89655172, 59669490.22988506, 55715467.24137931, 60485582.18390805, 61771501.72413793, 56966904.02298851, 60666616.66666666, 56887881.03448276, 60699662.64367816, 61545927.01149426, 56418053.44827586, 58850524.71264368, 61071789.08045977, 57018628.16091954, 57936731.60919541, 62103398.27586207, 58135007.47126437, 56629260.34482759, 61922363.79310345, 59757133.90804598, 56195352.29885057, 60400812.06896552, 61711156.89655172, 56942478.73563218, 60438168.3908046 , 61416616.66666666, 57703972.98850574, 59380697.12643679, 62241329.31034483, 59031559.1954023 , 58037306.32183908, 61216904.02298851, 61757133.90804598, 56735582.18390805, 58390754.59770115, 62216904.02298851, 58216904.02298851, 57432421.26436782, 61956846.55172414, […]

Why is trapz returning negative values, even when x is sorted ascending and y is all positive?

y = np.array([59817478.73563218, 56195352.29885057, 59679547.70114943, 61071789.08045977, 56678110.91954023, 56900812.06896552, 61942478.73563218, 57360582.18390805, 57423800.57471264, 61169490.22988506, 58930984.48275862, 56777248.85057471, 60586156.89655172, 59669490.22988506, 55715467.24137931, 60485582.18390805, 61771501.72413793, 56966904.02298851, 60666616.66666666, 56887881.03448276, 60699662.64367816, 61545927.01149426, 56418053.44827586, 58850524.71264368, 61071789.08045977, 57018628.16091954, 57936731.60919541, 62103398.27586207, 58135007.47126437, 56629260.34482759, 61922363.79310345, 59757133.90804598, 56195352.29885057, 60400812.06896552, 61711156.89655172, 56942478.73563218, 60438168.3908046 , 61416616.66666666, 57703972.98850574, 59380697.12643679, 62241329.31034483, 59031559.1954023 , 58037306.32183908, 61216904.02298851, 61757133.90804598, 56735582.18390805, 58390754.59770115, 62216904.02298851, 58216904.02298851, 57432421.26436782, 61956846.55172414, […]

DeprecationWarning when using scipy.minimize

import scipy import math def LR(x): return -(1+x*math.exp(-x))/2 max_LR= scipy.optimize.minimize(LR, [1],bounds =[(0, 1/2)]) I get the following error: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.) return -(1+x*math.exp(-x))/2 […]

scipy.linalg.eigh terminates without raising an error

My code involves diagonalizing a matrix of size 128×128. The matrix is very nearly hermitian and depends on some initial conditions. When I call scipy.linalg.eigh, it sometimes works normally. Other times, it churns for a while and then terminates the whole Python code without raising any errors.