Repository navigation
Conditions, frequency axes and plot axes are written by name, so a positional mix-up fails instead of answering - #980
Conversation
|
Important Review skippedToo many files! This PR contains 540 files, which is 440 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configuration
📒 Files selected for processing: 540
You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…sitional mix-up fails instead of answering A parameter that ends in its unit and carries a default was already keyword-only, because a number typed at the call site is where a unit gets lost. Three kinds of argument slipped past that rule. The speed of sound, the density of air or of water, a calibration factor and the three ground factors of ISO 9613-2 carry no unit of their own, so `ground_attenuation(200, 2, 2, bands, 1, 1, 1)` and `sound_exposure(x, fs, 8.0, cal)` still read as a row of bare numbers in an order nobody remembers. A frequency axis sat beside the values it labels as just another array: two arrays of one length bind either way round without a complaint, and the API reference itself showed `weighted_rating_extended(freqs, r)` and `weighted_impact_rating_extended(freqs, ln)` with the frequencies where the levels go. And the 23 public `plot_*` geometry helpers took the axes in two different places: seventeen after their data (`plot_plate_geometry(0.8, 0.6, ax)`), six first (`plot_barrier_geometry(ax, ...)`).
a36d06d to
2620ab2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/errors-and-warnings-by-kind #980 +/- ##
===================================================================
- Coverage 92.02% 92.02% -0.01%
===================================================================
Files 446 446
Lines 91130 91133 +3
===================================================================
+ Hits 83864 83866 +2
- Misses 7266 7267 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Numerical conformance1893/1893 checks pass across 111 domains and 523 standards (227 normative designations, 125 further published sources). Used in the tables below is how much of that clause's published tolerance the deviation consumes: 100 % sits exactly on the limit, 5 % uses a twentieth of the allowance, and a dash means the clause states no two-sided tolerance for the quantity, so there is no budget to spend. It is reported and never used to decide a verdict, which is settled at full precision before any rounding. Renamed (4)
Closest to their published limit (top 5) The rows with the least room left, so the ones a change is most likely to push over.
|
|


A parameter that ends in its unit and carries a default was already keyword-only, because a number typed at the call site is where a unit gets lost. Three kinds of argument slipped past that rule. The speed of sound, the density of air or of water, a calibration factor and the three ground factors of ISO 9613-2 carry no unit of their own, so
ground_attenuation(200, 2, 2, bands, 1, 1, 1)andsound_exposure(x, fs, 8.0, cal)still read as a row of bare numbers in an order nobody remembers. A frequency axis sat beside the values it labels as just another array: two arrays of one length bind either way round without a complaint, and the API reference itself showedweighted_rating_extended(freqs, r)andweighted_impact_rating_extended(freqs, ln)with the frequencies where the levels go. And the 23 publicplot_*geometry helpers took the axes in two different places: seventeen after their data (plot_plate_geometry(0.8, 0.6, ax)), six first (plot_barrier_geometry(ax, ...)).What changes
A condition of the medium or of the measuring chain that carries a default is keyword-only whatever its suffix.
signals.sound_exposureandlex_8hread(x, fs=None, *, duration_hours=None, calibration_factor=None),psychoacoustics.sharpness_dintakes its calibration factor by name,environment.ground_attenuationtakes everything after the receiver height by name, and the speed of sound is keyword-only onIntensityInstrumentComplianceResult.phase_mismatch_deg,phase_mismatch_from_residual_index,residual_index_from_phase_mismatch,fresnel_number,spherical_reflection_coefficient,reflection_density,reflected_path_delay,spot_tube_upper_frequencyandspot_microphone_spacing_bounds.noise_control.LiquidPipe,underwater.FluidSeabedandio.Signalput aKW_ONLYmarker before their conditions, asDownstreamPipealready did, so the pipe wall and the outside air of the first, the density of the water above the second and the calibration factor, channel labels, provenance and source of the third are written by name. A condition the call cannot do without, such as the speed of sound oftube_wavenumber(frequency, speed_of_sound), has no default to slip in behind and keeps its place. Options (mode,method,fraction,n,seed) and the subject of a call are not conditions and stay where they were.In every public function and method that takes a frequency axis beside another array of numbers, the axis (
frequencies,frequencies_hzon the two underwater functions whose formulas are printed in kHz,frequencywhere a function is vectorised over it) is keyword-only, and the values stay positional in their order:noise_criterion(levels, *, frequencies=None),fractional_octave_smoothing(values, *, frequencies, fraction=3.0, domain="power"),program_signal_level(band_levels, *, frequencies, ...),kb_weighted_levels(levels, *, frequencies),third_octaves_from_narrowband(psd, *, frequencies),sequential_comparison(..., *, frequencies, ...), 139 signatures in all. An array whose name ends in one of those words is held to the same rule, because the hazard is the same two arrays of one length in a row: thetone_frequenciesofpsychoacoustics.assess_tonesandcombined_tone_level, thereversal_frequenciesofhearing.sweep_audiometry_threshold, thecritical_frequenciesofbuilding.perimeter_absorption_coefficientand thedamped_natural_frequency_hzofvibration.exponential_window_correction. Given the tone frequencies and the mean narrow-band levels the other way round,combined_tone_levelanswered 49.4 dB for the three tones of ISO/PAS 20065 Annex E, whose combined level is 72.15 dB, andperimeter_absorption_coefficientanswered 8.8e-11 instead of 0.139 for two edges at 92.6 Hz with a K of 6.4 dB. A positional value that came after the axis moves up one place (convert_frf(value, "mobility", "impedance", frequency=f),assess_tones(LT, LS, 2.7, tone_frequencies=fT)). Records are left as they are: a result's fields are read by name off it, and the guides buildaircraft.RotorcraftHemisphere, the input record they construct, with every field named.The 23
plot_*helpers now readplot_x(<data>, *, ax=None, ..., language="en", **kwargs), the@overloadstubs ofplot_aperture_geometryandplot_piston_geometryincluded, andplot_silencer_geometry, the one helper that took no style keywords, forwards them to the outline of the bore as the others do. A result's.plot(ax=None, *, ...)keeps the axes first, as before.What breaks
Every changed signature refuses the old positional call with a
TypeErrorthat names it (noise_criterion() takes 1 positional argument but 2 were given). The migration guide, in its three copies, says what the rule covers (an ambient or medium condition or a calibration factor that carries a default, and every flag) instead of every condition or option with a default, lists the condition signatures in a table (FluidSeabed(rho, c, water_density=rho_water)among them) and the frequency-axis functions that shipped in 3.3.0 or 4.0.0rc1 by package,assess_tonesandperimeter_absorption_coefficientincluded, with a worked example, and adds a row for the plot helpers to the section on.plot(), its left column in the 4.0.0rc1 spelling. The functions newer than rc1 are in the CHANGELOG only. CONTRIBUTING states the two rules and the helper shape in the parameter row of the naming table. Every call insrc, the tests, the conformance domains, the figure and report scripts and the guides (EN, ES and thedocs/mirror) is written in the new form, the guide examples with the values positional and the axis by name; the two swapped examples of the curated table read right now, and the prose call ofdiffusion_spectrumin the diffusers guide isdiffusion_spectrum(d, frequencies=freqs, ...).How it was verified
No number moves. The conformance report comes out byte for byte the same (1893 of 1893 checks, and the badges, claims, artifact and vocabulary steps leave no diff). The figures whose generators changed come out with the committed bytes, the two tone audibility figures included; the only four that differ,
plant_measurement_contourandplant_sound_powerin English and Spanish, come out with the same bytes on the base, so that drift is not this change's. The full suite passes on Python 3.13 (29032 passed, 69 skipped). Every documentation code block runs (7570 blocks over 732 pages), the site builds and validates (the type check reports 0 errors, 987 pages build and html-validate reports 0 errors), the API reference covers all 3082 public names, the 77 report fiches match what the scripts print,make llmsleaves no diff on a second run, andmypy src scripts, ruff, bandit and the em dash, markdown, Spanish accent, digit grouping, frozen constant, raises block, language forwarding, plot style, published source, errata evidence and identifier spelling checks are green.The guards
scripts/check_parameter_units.pygains two rules:CONDITIONS(speed_of_sound,air_density,air_sound_speed,water_density,calibration_factor,ground_source,ground_middle,ground_receiver) that carry a default and are not the first parameter must be keyword-only whatever their suffix;POSITIONALstays the escape hatch, with its reason;frequencies,frequency,frequencies_hzorfrequency_hz, or whose name ends in one of them, and an array of numbers is read off the annotation (ArrayLike,NDArray, a sequence of floats, but not a sequence of layers or a(low, high)pair).FREQUENCY_AXIS_EXEMPT, keyed by location, is its escape hatch, and it is empty.tests/test_result_plots.pygainstest_every_plot_helper_takes_its_axes_and_language_by_name, beside the test that holds every.plot()to the axes first: everyplot_*function a public module publishes takesaxandlanguagekeyword-only, declares**kwargs, and reads it in its body.tests/test_device_geometry_plots.pychecks that a style keyword given toplot_silencer_geometryreaches the outline of the bore, and only it, for the four kinds of silencer.tests/test_check_parameter_units.pypins both new rules on stub modules (a water density with a default, a tone frequency and a natural frequency per mode beside their values), the reading of an annotation as an array, the stale exemption, the tree, and a positional call of seven changed signatures raisingTypeError. The special room suitability test passes the frequencies by name, so itsTypeErrorcan only come from the temperature and the pressure.Red on the base (7200d27f5),
scripts/check_parameter_units.py:Red on the base,
test_every_plot_helper_takes_its_axes_and_language_by_name:Red with the two
**kwargs,lines ofplot_silencer_geometryremoved, the helper test and the new silencer test:Green on the branch: