Repository navigation
Conversation
The name given to generated objects was read by a block copied in 20 places that walked the stack with traceback.walk_stack(None). Since Python 3.12 it starts four frames up instead of two, so in a plain script it walks past the end of the stack and pytta.generate.sweep() raises AttributeError at module level and UnboundLocalError inside a function. One helper, _instanceinfo.caller_name, replaces the copies: it walks from the caller explicitly and returns an empty name when the source line is not available (python -c). Tests run real scripts in a subprocess, since under pytest the stack is deep enough to hide the failure. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
scipy.signal.hann and scipy.signal.tukey were removed in SciPy 1.13. The five calls now use scipy.signal.windows, the same functions with the same defaults. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
_powerlaw_noise gave the DC bin the largest amplitude of the spectrum (frequency 1/nsamples in the power law), so the noise came out as mostly offset: 7 times its rms. With the silent margins of colored_noise the offset is a rectangular pulse whose 1/f**2 leakage tilts the spectrum: pink measured -3.96 dB per octave instead of -3.01. The DC bin is now 0. imag[-1] = 0 was meant for the Nyquist bin but zeroed the last channel, whose spectrum became real and its waveform its own mirror image in time; with one channel every noise did. It is now imag[:, -1]. Tests pin the power law of the five colors, the absence of offset and a random phase in every channel. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 31, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR builds on #52. Its first two commits are those of #52, which
colored_noiseneeds to run with SciPy 1.13 or later, and the change proposed here is the last commit._powerlaw_noise, which generates every color ofgenerate.colored_noise, had two bugs.colored_noise, the offset becomes a rectangular pulse whose leakage tilts the spectrum: pink noise measured -3.96 dB per octave, where -3.01 is expected. The DC bin is now set to zero.imag[-1] = 0was meant for the Nyquist bin. The array is channels by frequencies, so the line zeroed the imaginary part of the whole last channel, and that channel came out as its own mirror image in time. With a single channel, every noise was affected. The line is nowimag[:, -1] = 0.Measured with a fixed seed:
The tests in
tests/test_colored_noise.pycheck the slope of the five colors, from purple to red, within 0.2 dB per octave of the power law, the absence of DC offset, and a random phase in every channel.This also answers #12, since pink noise is available as
pytta.generate.colored_noise('pink').Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 3 failures left in
test_pyttasave.pyare those that remain after #52.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com