Repository navigation
Conversation
…1672-1 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
pytta.weighting, which is exported at the top level of the package, fails on every call, and when its curves are evaluated by hand at the nominal frequencies they differ from IEC 61672-1:2013, Table 3, by up to 0.13 dB. This pull request makes it work and evaluates it at the exact frequencies that Table 3 uses.What was found
Each way of calling the function raised an error:
pytta.weighting('A', nth=1)and the call withfreqsended innp.asarray(out, ndmin=2), andnumpy.asarrayhas nondminargument (numpy.arrayhas).pytta.weighting('A', nth=3)evaluatedA(...)througheval, a name that does not exist (the curves are__A,__C, ...).freqshad to be given as strings, since each value was pasted into the string passed toeval.The curves themselves,
__A,__B,__Cand__D, are right: they are the analytical expressions of Annex E with the constants that the 2013 text gives (20.60 Hz, 107.7 Hz, 737.9 Hz and 12 194 Hz). The function evaluated them at the nominal frequencies (31.5 Hz, 16 kHz). Table 3 gives them at the exact frequencies f = 1000 × 10^(0.1(n − 30)), as its note says. Evaluated at the nominal frequencies, A is −39.53 dB at 31.5 Hz where Table 3 gives −39.4 dB, and −6.71 dB at 16 kHz where it gives −6.6 dB.The change
weighting(kind, nth, freqs)now computes the chosen curve directly. Withnth=3it gives the one-third octave bands from 20 Hz to 20 kHz and withnth=1the octave bands from 31.5 Hz to 16 kHz, both at the exact frequencies of Table 3.freqstakes numbers and uses them as they are. The result keeps its former shape, one row per frequency, and an unknown kind or a call withoutnthorfreqsraisesValueError. The constants and the curves are unchanged.Tests
The tests in
tests/test_weighting.pycompare with Table 3:ValueError.Both fail without this change. Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of
development(3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com