Repository navigation
Improve ndarray return types - #2052
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.0.0dev #2052 +/- ##
=========================================
Coverage 98.89% 98.89%
=========================================
Files 34 34
Lines 5236 5238 +2
=========================================
+ Hits 5178 5180 +2
Misses 58 58
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR continues the typing work from #2050 by tightening return type annotations for functions that return numpy.ndarray, focusing on cases where the returned array’s dtype and/or shape are deterministic.
Changes:
- Add shape-typed aliases (
_Array1D,_Array2D) and apply them to selected APIs. - Refine many return annotations from generic
np.ndarrayto dtype- (and sometimes shape-) specificNDArray[...]/_Array*D[...]. - Simplify/trim overload sets where unions can express the return types directly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_display.py | Updates a test assertion to accommodate tightened typing in display multiplot helpers. |
| librosa/util/utils.py | Adds shape/dtype-specific return types for utility helpers (sorting, extrema, peak picking, interpolation, masking, uniqueness). |
| librosa/util/matching.py | Tightens match index return type to a 1D uint32 array. |
| librosa/sequence.py | Refines return types for DTW/RQA/Viterbi helpers and related internal utilities. |
| librosa/segment.py | Refines return types for segmentation helpers and introduces a generic-typed decorator signature. |
| librosa/filters.py | Refines return typing for wavelet helper output arrays. |
| librosa/effects.py | Refines return typing for silence detection and trimming helpers; trims redundant overloads. |
| librosa/display.py | Refines return typing for coordinate and multiplot setup helpers (notably object-typed arrays). |
| librosa/core/spectrum.py | Tightens scalar/array return types for dB/power/amplitude conversion utilities and removes redundant overloads. |
| librosa/core/notation.py | Refines degree-array return types and overloads for internal note parsing helpers. |
| librosa/core/intervals.py | Refines return types for interval construction helpers and overload simplification. |
| librosa/core/convert.py | Refines scalar vs array return types across conversion helpers (frames/samples/time/notes/frequencies). |
| librosa/core/audio.py | Refines return types for zero-crossing detection, click generation, tones/chirps, and μ-law expansion. |
| librosa/beat.py | Refines return typing for internal beat tracking mask output. |
| librosa/_typing.py | Adds shape-typed ndarray aliases for 1D/2D arrays to support tighter annotations elsewhere. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bmcfee
left a comment
There was a problem hiding this comment.
LGTM - your typing efforts are so very appreciated!
If there's nothing left for this one, I'm happy to merge.
Yea this is good to merge as far as I'm concerned |
* Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * Test overhaul (#1925) * removed dependency on test1.wav in onset tests * removed dependency on test1.wav in beat tests * properly scoping chirp fixtures * simplifying test_icqt * simplifying onset strength tests * adding some comments on new onset tests * simplifying beat tests * simplifying griffinlim tests * cleaning up gl-cqt tests * further test optimizations * fixing a test naming issue * Reduced nnls_multiblock test * Reduced recurrence matrix test * Reduced hybrid cqt tests * reducing hpss tests * removed test1_22050 from features tests * removing unnecessary example file reference * seeing if skipping ifgram regression drops coverage * Replacing regression fixtures on stft tests * putting in skips for old regression tests * self-contained lpc correctness tests * removing old fixtures from core tests * whoops still need the fixture loader for now * removed fixture files from effects tests * removed fixture files from segment tests * removed fixture files from decompose tests * suppressing known warning in glcqt test * using a fixture for find_files tests * in-place fixture generation for multichannel tests * working on purging srand for proper fixture * purging np.random continues * more rng purging * purging randomness * purging np.random continues * srand purging * random seeding * removed all unseeded randomness in tests * transitioning core tests to internal fixtures * blacking * moving core tests to a new audio clip * migrating display tests to new test track * adding build artifacts for failed image comparison tests * revising image tests once more * progress on purging old tests * simplified tonnetz test * simplified cens tests * rewrite hz/mel tests * rewrote hz_to_octs tests * rewrote melfbnorm tests * marking more tests for removal/rewriting * rewrote centroid tests * finished with met features tests * rewrote chromafb tests * rewrote melfb tests * removing unneded code and documentation * removing unneded code and documentation * rewrote semitone filterbank tests * removed all regression tests * removed the test submodule * keeping regression tests for yin/pyin * copilot suggestions * removing another unused test * added explicit buf_to_float test * fixing coverage * blacked the tests * Peak picking by dynamic programming (#1927) * Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * DP peak picking * Added tests for dp peak picker * loop optimization * linting * skipping blank lines * linting * added multichannel test for dp peak picker * a couple more extensions to peak picking * upper pinning cmake until the rest of the world gets its act together * updating documentation on peak picker to describe greedy method * spelling * mypy cleanups * removing cmake pin * squashing an unhelpful type check in multichannel * expanding docstring per copilot CR recommendations * Trying a new environment cache setup in CI (#1936) * Trying a new environment cache setup in CI * purging old ci instructions * updated cache setup for docs-ci workflow * fixing a version pin in doc CI * sphinx 8.2 doesn't like something in our multiversion builds. pin it for now * dropping sphinx pin in favor of removing historical builds on 0.9.2 * regexen lol * Variable-rate and non-iterative phase vocoding (#1931) * rewrote phase vocoder * whatever velin... * removed unnecessary unwrap * fixing missing type annotation * Finishing up rough edges on phase vocoder * coverage up on phase vocoder * coverage up on phase vocoder * final copilot recommendations * dropped python 3.8 support for the 1.0 release * bumping numba version requirement * trying to fix the min env * Include scipy-stubs in the test dependencies - v1.0.0 rebase (#1946) * Include `scipy-stubs` in the type-check dependencies https://github.com/scipy/scipy-stubs * remove unused `# type: ignore`s * restrict `scipy-stubs` to `python>=3.10` * mypy no longer ignores missing `scipy` imports * add `scipy-stubs` to the CI linting coda-forge deps * get rid of some squiggly lines * fix remaining ~mypy errors~ squiggly lines * fix `recurrence_matrix` overload for `sparse=True` * workaround a mypy type narrowing bug with `TypeIs` guards * workaround for limitations in mypy's local inference algorithm * workarounds for non-gradual `scipy.io.loadmat` return types * apply review suggestions Co-authored-by: Brian McFee <[email protected]> * post-merge fix of missing Literal annotation --------- Co-authored-by: Brian McFee <[email protected]> * bumping for scipy stubs 1.16.0.1+ * arguing with stubs * arguing with stubs * arguing with stubs * vscale option to specshow (#1938) * some very broken code in here right now * yargh * rewrote scaling code in specshow * correcting docstrings * Reverting a change in power db * fixing type annotation import * blacking and docstring fixes * updated examples to use vscale * updated examples and docstrings * linting * docstyle is strict * Fixed a typo * type hacking * specshow vscale tests * keying mpl image failure artifacts on runner metadata * trying high-precision audio for image tests * bumping error tolerance on the phase plots * adding more information to vscale image test * mpl image tests are hard * expanded docstring for specshow * expanded specshow advanced example * Switched to twilight_shifted as default phase colormap * reworking phase differential plots, updated rainbowgram example * revised plot_display * phase_unwrap_diff -> dphase * added dphase_t mode to specshow * splitting phase from db vscale tests * adding fixture * improving stability of phase display tests * bumping tolerance back up due to font layout quirks * last docstring update to specshow * more docstring fiddling * Remove default quantization for note_to_hz (#1947) * fixes #1945, leave cent deviation in place for note_to_hz * type linting * minor docstring updates * fixed docstring typo * expanded docstring added default behavior test * Freq convert nan (#1948) * fixing #1944 * added tests for nan conversion of notes * Blacking and linting * linting * suppressing bad type checks in nan converters * i don't understand type annotations at all * i can't program either * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * Colorbar helpers (#1952) * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * whoops missed a commit * Apply suggestions from copilot code review Mostly cosmetic changes Co-authored-by: Copilot <[email protected]> * fixing a type testing error * Two-slope norm for inferred diverging colormap (#1954) * twoslopenorm diverging colormaps * updating image comparison tests for new diverging cmap style * fixing some buglets * fixing some numerical precision issues in image tests * working on ic test for diverging colormaps * working on ic test for diverging colormaps * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * relaxing rms on divergence color tests * updating advanced example for display * updating viterbi example with new diverging cmap plot * expanded cmap to support preconstructed colormap objects * fixing type import business * Update librosa/display.py Co-authored-by: Copilot <[email protected]> * bug fixing * fixing coverage * fixing coverage * deprecation rename of cmap * deprecation rename of cmap * Update librosa/display.py More direct dtype check for boolean data in cmap inference Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Warn on perceptual weighting underflow (#1955) * added warnings for perceptual weighting curves on underflow * fixes #1941 * Warping path to step grid (#1958) * Added path-to-steps fixes #1937 * revising warping example for time synchronization * making the stretched examples more obvious in display * added inverse warping path sampling * linting * linting * quivers * using colors more smartly in stretching example * using colors more smartly in stretching example * quivering * fixing up docs * revising some plots in the advanced gallery * added some unit tests for pathtosteps * Docstring formatting * fudging test data for path conversion to avoid rounding errors * nudging scipy dependency to unstick test failures * final polish on music sync example figures * Fix subsegment example (#1959) * fixed #1950 * improved styling * SPEC07 compliant rng parameters (#1960) * transitioning random_state to rng= for spec07 * suppressing type failures * Update librosa/_typing.py Co-authored-by: Copilot <[email protected]> * fixing old type annotation code * simplified testing, consistentized errors * improved docstring styling * Update tests/test_core.py Co-authored-by: Copilot <[email protected]> * preserve support for old randomstate objects in griffinlim --------- Co-authored-by: Copilot <[email protected]> * nudging min python in setup.cfg * Upload doc build preview artifacts (#1962) * adding an artifact build for pr docs * Trying a different naming * Expire deprecations for 1.0 release (#1963) * removed audioread dependency * removed res_type=None support for vqt and friends * removed get/set_fftlib * removed old filterbanks for cqt * fixing flakes * removed x_axis param from waveshow * removed winlength from yin and pyin * removed audioread from version lister * clarified comment in cqt * blacking * fixing docstring formatting * fixing type annotations now that we are narrowly on scipy fft * removing dead tests * optionalizing dct norms * added generated/ to docs clean target * allow link failure on htk site * Signal mixing helpers (#1964) * progress on mixing * extended to_mono for multiple inputs * added to_multi * fixed a typo * fixed docstring formatting * fixed docstring formatting * examples and docs updates * types are silly * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Added upmixing in to_stereo * fixes from copilot cr * added norm parameter to mixers * types are silly * types are silly * CR feedback * Apply suggestions from code review require at least one input for to_mono and to_stereo Co-authored-by: Copilot <[email protected]> * expanded tests for to_mono * Added pad testing for to_mono * test coverage for to_stereo * test coverage for to_multi * adding mixer helpers into more advanced examples --------- Co-authored-by: Copilot <[email protected]> * oct3 display modes (#1967) * first hack at oct3 * added oct3 display modes * added tests for oct3 modes * trying again without constrained layout * improving docstring and expanding vqt axis compatibility support * fixing image comparison test to support matplotlib 3.10.5 * Inverted waveshow (#1971) * added a proxy patch for waveshow label containment * First cut at inverted waveform display * tests for inverted waveshow * more fancy footwork with matplotlib artists * [CR] Wavebars (#1973) * first cut at wavebars * linting * linting * added basic wavebar tests * added basic wavebar tests * removing dependency on compressed layout for wavebar test * removing dependency on compressed layout for wavebar test * nudging mpl dependency * nudging mpl dependency * nudging mpl dependency entirely * docstring improvements * chore: Refine .gitignore for improved accuracy and coverage (#1969) This commit refines the `.gitignore` file by: - Removing redundant entries. - Improving comments for better readability. - Reorganizing and categorizing ignored files for better maintainability. - Consolidating testing and checkpoint related entries. * Adding plt.show() at the end of code blocks (#1979) * Fix types in beat tracking code (#1977) The development version of Numba 0.62.0 is unhappy about `range` being applied to floating point values here. * Fix #1970: Prevent AdaptiveWaveplot adaptor from being garbage collected (#1992) - Add _WAVESHOW_ADAPTORS WeakKeyDictionary to retain adaptors per-Axes - Store artists (steps, envelope) and axes as weakrefs in AdaptiveWaveplot - Add properties to preserve existing attribute API - Add GC guard in update() for safety - Add 3 regression tests * Add Metrogram Transform (#1986) * feat: add metrogram transform * allow passing no aggregate, improve documentation * feat: add interp_broadcast Reference: #1909 * show metrogram in html docs * show interp_broadcast in html docs * fix: linting issues * use keywording,reorder x1/x1_pos, check axis range * generalize axis for metrogram transform also fix a logic bug with checking index bounds * overload interp_broadcast when func = None * fix interp_broadcast not accepting negative axis * formatting * set np.expand_dims to -3 instead of using a param * add metrogram example * add interp_broadcast example * add tests for metrogram * rename func -> op in interp_broadcast * simplify interp_broadcast example choosing to keep the example minimal like the other examples in utils an exhaustive use of all parameters is better suited for the tests * add tests for interp_broadcast * metrogram example: keep the zero in funt_freqs * remove duplicate imports added unintentionally * remove blank line after doc strings * add tests for interp_broadcast axis * update metrogram docs * Fix typo Co-authored-by: Copilot <[email protected]> * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * fix: input shape validation based on broadcasting rules Co-authored-by: Brian McFee <[email protected]> * docs: type change kind: str -> kind: _InterpKind --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Brian McFee <[email protected]> * Update type annotations (#1980) * nudging matplotlib min version for spec0 * needs mpl in lint environment now * type hacking * type hacking * type annotations are the worst * type hacking continues * type hacking continues * types types types * bumping numpy for env compatibility * fixing scipy sparse indexing type annotations * type hacking * mypy is stupid * mypy is stupid * mypy is stupid * strengthening tests stupidly for mypy * Fixing type annotations in display and tests * upper pinning sphinx dependency until sphinx-multiversion is fixed * trying to address copilot reviews * more type annotation nonsense * Trying to fix numba/numpy compatibility for test environments * type annotations * Migrate from SciPy spmatrix to sparray (#1994) * [ENH] Migrate from scipy.sparse matrix to array interface (#1902) * spell check * spell check * Remove redundant empty-index check in sparsify_rows; add test for 1D sparse shear rejection * Fix 1D sparse shear test for scipy < 1.14 compatibility * Address review: accept sparse matrices in shear, vectorize sparsify_rows * Suppress scipy-stubs attr-defined errors in sparse matrix shear test * Python 3.14 test support (#1999) * adding 3.14 to test matrix * is it a name mismatch problem? * forcing python versions back into place * Trying to force a source build on the samplerate package * reverting source build for samplerate, it doesn't work * nudging python for docs build to 3.11 * nudging python for docs build to 3.11 * bypassing zenodo linkchecks * updated libsndfile link in docs * feat: implement hybrid_tempogram (#1991) (#2004) * feat: implement hybrid_tempogram per Peeters 2005 * refactor: address CR feedback, explicit kwargs, finite interpolation * Merge branch '1.0.0dev' into feature/hybrid-tempogram and resolve conflicts * Merge upstream 1.0.0dev and resolve conflicts * Merge upstream 1.0.0dev and fix typo in metrogram * Resolve rhythm imports and add to __all__ * style: fix linting and restore metrogram * test: add unit tests for hybrid_tempogram coverage * fix: use fourier_tempo_frequencies for hybrid_tempogram freq grid * fix: import fourier_tempo_frequencies * fix: remove non-english text from docstring to pass codespell * refactor: simplify hybrid_tempogram array handling and fix kwargs * style: remove trailing whitespace in docstring to pass velin linter * fix: resolve mypy type hints for interp1d and remove duplicate decorator * refactor: add type hints, docstring examples, and optimize interp kwargs per review * refactor: apply robust type hinting, clean docstrings, and array return per strict mypy checks * fix: finalize hybrid_tempogram with strict typing, optimized interpolation, and test coverage * fix: remove assume_sorted=True to fix interpolation on descending lag domain * refactor: apply reviewer feedback for optimizations and test fixtures * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Brian McFee <[email protected]> Co-authored-by: Copilot <[email protected]> * Document specshow frequency axis scaling (#2006) Co-authored-by: Terry Chen <[email protected]> * Surface contributing guide in docs site, link build instructions (#2009) * Surface contributing guide in docs site, link build instructions Adds myst-parser to render CONTRIBUTING.md inside the docs sidebar, so first-time contributors can find the contributor guide without leaving the docs site. Also updates CONTRIBUTING.md to reference docs/BUILD.md for documentation build instructions, replacing a stale reference to a doc/README that no longer exists. Fixes #1800. * Add myst-parser to docs env * fixed broken link in contributing guidelines --------- Co-authored-by: Brian McFee <[email protected]> * Multiplot (#2012) * first cut at multiplot * multiplot cleanups * type annotating * example fixups * added legend aggregator, fixing sphinx configs * fixing type hints * support variadic multiplot inputs * polishing multiplot * velinizing * fixing singleton multiplots * Added legend_for_axes tests * multiplot helper tests * updated multilegend plots to be more informative * coverage up * coverage up * fixing type checks in display tests * test blacking * tying up loose ends * covering legend loc inference * multiplot coverage * adding fixtures for multiplot * Added titles= support to multiplot * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * improving on copilot suggested test * improved docstrings * velinizing * added example for legend_for_axes * simplified docstring * fixing #2013 * renaming function aliases in multiplot * expanded unit tests to cover multiplot titles * expanded legend_for_axes docstring to clarify loc quirkiness * fixing type annotations for optional labels and titles * working on stefanv's comments * Accept user-supplied property cycles in multiplot * fixing positional argument in display tests * simplified docstring examples * updated docstring on multiplot orient * finished docstring fixups --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Spec0 2026.06 (#2018) * attempting spec0 compliance * attempting spec0 compliance * revised min doc build version in build.md * added dead batteries to doc build matrix * bumped numba version * trying with strict in conda env * bumping packaging to 23.2 for python 3.12 support * bumped soxr to 1.0.0 * fixing environment naming while i'm at it * Bumping msgpack-python for environment consistency * bumping lazy and typing_extensions * bumping min versions again for py3.12 environment compatibility * bumping versions to ensure python 3.12 compatibility * removed version constraint on scipy stubs * removed resource management shim dead branch * cleanups around python version handling * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * display.wavef0 (was: melodyplot) (#1976) * added mask to waveshow * fixing stuff * melody plot first cut * added missing docstring update * Added test coverage * nudging to mpl 3.8 * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.8.4 to see if that works * should fix wavef0 inverted mode * i can't program in python apparently * nudging back to mpl 3.8 for datalim hacking * trying mpl 3.9 * trying mpl 3.9 * trying mpl 3.9 * working on making mypy happy * more mypy business * fixed typing in wavef0 * added round trip test for transformf0 * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * revised docstring * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * velinizing * protect transformf0 from nonpositive f0 values * streamlined wavef0 norm calculation * copilot cr comments * copilot comments on docstrings * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * rearranging error checks * fixing type checking * fixed display.__all__ * fixing thinko in f0 bounds checking * Added docstrings to transformf0 methods * minor docstring updates * linting * contorting around edge cases in wavef0 * fixing numerical problems in wavef0 edge cases * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * added cqt overlay example in wavef0 docstring --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Yet another Viterbi acceleration PR (#2007) * removed over alloation in viterbi core * temporary hack faster viterbi * pyin speedups * added safety barrier on transition thresholding * added tests for viterbi acceleration * one more test case coverage * Streamlining changes * polishing viterbi optimization * Updates for mypy 2.1 (#2025) * making mypy happy in 2.1 * making mypy happy in 2.1 * mypy making us jump through hoops again * mypy making us jump through hoops again * making mypy happy in 2.1 * mypy is happy for now * maybe removing numpy typing plugins was premature * making mypy happy on minimal numpy * fidgeting some type annotations to work across multiple numpy versions * fixing some import silliness in tests * undoing some bad optimizations * fixes #2014 (#2026) * Modern linting (#2027) * migrating to ruff * migrating to ruff * down into line length constraints * removed unused imports * whitespace fixing * import ordering via ruff * pyi linting * setting output format * fixing quote styles * working on bugbear * bugbear tests * simplify linting * ruffing * ruff lint rules * Dynamic vectorize (#2028) * dynamic vectorization in beat * dynamic vectorization in core * dynamic vectorization in core * dynamic vectorization in utils * removed all static vectorized signatures * fixing some type business * rewrote abs2 for more direct dtype handling * cleaning up some typing code * more mypy tweaking * Even faster import (#2029) * being better about enforcing type checking blocks * localizing heavy imports to accelerate package import * more typechecking blocks * fixed missing import * purging typing extensions * stricter typecheck blocks * lingering type block * Negative offset load (#2030) * first cut at negative offset loading * added flac example and fixture for negative load offset test * marking ogg seek tests as optional pass * added negative offset load in stream * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Loadx (#2031) * added loadx * updated examples to use loadx where appropriate * updated examples to use loadx where appropriate * Clarified docstring for loadx * Docstring formatting * typing and docstring improvements from copilot * more helpful failure mode in loadx (#2032) * Modernize types in `librosa._typing` (#2035) * Modernize types in `librosa._typing` * remove sudden unused `# type: ignore[misc]` * forcing upgrade to codecov action * modernizing type annotations for the future (#2036) * mdoernizing type annotations for the future * loosened util.tiny type annotation just a wee bit * more type annotation modernization (#2038) * Fill in missing type annotations (#2037) * Fill in missing type annotations in `display.py` * Fill in missing type annotations in `core/intervals.py` * Fill in missing type annotations in `beat.py` * remove expired `librosa.beat.tempo` deprecation * Display Highlighter (#2034) * first cut at display.highlight * updated examples to use highlighter * more example updates * added tests for highlighter * highlighter tests * highlighter test images * spelling * velinizing * path coverage * copilot review comments * copilot review comments * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * one more copilot suggestion * modernized annotations * type modernizing --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fixed #2040 (#2041) * avoid turning scalars into 0-d arrays in `core.{convert,spectrum}` and `util.utils` (#2039) * `core.convert`: avoid turning scalars into 0-d arrays * `core.spectrum`: avoid turning scalars into 0-d arrays * `util.utils`: avoid turning scalars into 0-d arrays * fix irreproducible mypy error * Waveplot styling (#2044) * style waveplot proxy after steps, not fill * fixed #2042 * updated tests * cleanups in the new waveplot legend code * styling and ruffing * Final polishing on waveplot legend code * improved `dtype_r2c` and `dtype_c2r` typing in `util.utils` (#2043) * Doc check modernizing (#2047) * switched velin to numpydoc lint * configuring numpydoc lint * revising numpydoc configs to avoid hobgoblins * starting to get somewhere with numpydoc linting * fixing exceptions to numpydoc linting * [WIP] Fix failing GitHub Actions job for lint and code analysis (#2048) * Initial plan * Apply remaining changes --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> * working through numpydoc corrections * working through numpydoc corrections * working through numpydoc corrections * fixing numpydoc lint * fixing exceptions to numpydoc linting * numpydoc is all passing --------- Co-authored-by: Copilot <[email protected]> * Contributing and agents update (#2017) * updating contributing guidelines with ai policy * Added agents.md * Fix CONTRIBUTING.md markdown formatting * revising contributing guidelines * integrating comments * formatting * updated contributing guidelines for numpydoc linting * reformat `**/__init__.pyi` re-exports (#2049) * Include str dtype in `ndarray` return type annotations (#2050) * Multichannel db (#2051) * implemented axis targeting for db conversion * db calculation now works properly with target axes * fixed scalar processing for db * added 'auto' mode to db conversion axes inference * fixed regression in amplitude_to_db * fixed regression in amplitude_to_db * copilot reviews * fixing some type annotations * copilot comments * cleaning up tests * pytest nonsense * Fix decorator callable types in `librosa.util.decorators` (#2053) * Improve `ndarray` return types (#2052) * Generic shaped `ndarray` type aliases * Improve `ndarray` return types in `librosa.core` * Improve `ndarray` return types in `librosa.util` * Improve `ndarray` return types in `librosa.beat` * Improve `ndarray` return types in `librosa.display` * Improve `ndarray` return types in `librosa.effect` * Improve `ndarray` return types in `librosa.filters` * Improve `ndarray` return types in `librosa.segment` * Improve `ndarray` return types in `librosa.sequence` * Fix mypy errors with `numpy<2.4` * Ignore false positive mypy error in tests related to `np.object_` array iteration * Address review comments for the typing changes in `util.utils` * Work around a mypy bug where it fails to expand `bool` into `Literal[True] | Literal[False]`. * Support matplotlib 3.11 in tests (#2054) * redoing tests for matplotlib 3.11, tightening tolerance where possible * updated failure artifact upload recipe * loosening tests more on mpl 3.10 * bypassing image comparison tests on 3.10 completely * fixed types for legend in matplotlib 3.11 * Stream resampling (#2055) * initial cut of resampling stream passes previous tests * progress on stream resampling * clarified docstring, reverted changes * updated tests * feature complete stream resampling * refactored tests * better coverage for edge cases * working in some copilot review comments * more copilot suggestions * copilot and gemini comments * cleaning up stream tests * tightening memory allocations in stream * added a future default change decorator and bundled onto stream * forgot to kw-only a parameter name * ratcheting down default stream parameter setting deprecation to 1.1 * last round of copilot reviews * massive simplification of legend_for_axes, fixes #2057 (#2059) * Refactor frequency formatters (#2060) * fixed minor ticking for oct3 modes * numpydoc linting * copilot review comments * copilot review comments * Updating actions (#2065) * updating actions * fixing an out= allocation issue * more warnings cleanup * libsamplerate comes via conda now * upload-artifact update * disable auto-activate * Standardize n_fft parameter docstrings (#2068) * Standardize n_fft parameter docstrings Rebuilt against 1.0.0dev after retargeting. Standardizes the analysis n_fft descriptions on 'length of the FFT window', fixes the bins/window conflations (piptrack, estimate_tuning, filters.mel, filters.chroma, feature.inverse), clarifies istft's frame-length inference, corrects mel_to_stft's documented return shape, and fixes frequency-axis references that assumed 2D input (istft win_length, phase_vocoder hop_length). Incorporates review feedback: 'frame' terminology in get_duration; audio-output functions reference the intermediate STFT without a bins clause. * Use 'frame' terminology for n_fft descriptions Per review: n_fft refers to frame length, not window length, since a window can be shorter than the frame. Swept all standardized n_fft descriptions accordingly. --------- Co-authored-by: Cameron Brooks <[email protected]> * precise dtype annotations in `librosa.beat` (#2069) Co-authored-by: Brian McFee <[email protected]> * Infer n_bins automatically in cqt/vqt (#2066) * added n_bins=None to cqt/vqt * added n_bins=None to cqt/vqt tests * linting * revisions * revisions * one more test * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Added nbins inference to hybrid and pseudo cqt * linting * copypasta * fixed #2071, tightened icqt tests * revised downsampling logic in vqt * copilot review comments --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Add out= parameter to to_mono for in-place downmixing (#2058) * Add out= buffer parameter to to_mono, to_stereo, to_multi Lets callers pass a pre-allocated output buffer to the mixing functions, avoiding a fresh allocation per call (e.g. per-block downmix in stream()). A shared _init_output helper validates the buffer's shape and dtype against the computed output, zero-fills it, and returns it; out=None preserves the previous allocate-fresh behavior. Implements #2056 against the redesigned 1.0 mixing API. * Remove joblib caching from to_mono/to_stereo/to_multi Per review (#2058): the @cache decorator is incompatible with out=, since a cache hit returns the memoized array and skips writing into the caller's buffer, and hashing an uninitialized out= buffer is costly/non-deterministic. Dropping caching keeps the out= contract simple and correct. * Reuse output buffers in to_stereo/to_multi and stream mono downmix Addresses review feedback on #2058: - to_stereo: downmix directly into the output rows via out=, removing a second allocation. Cast left/right to the shared dtype first so the pass-through buffer always matches to_mono's computed dtype. - to_multi: pass the output row into to_mono when no length adjustment is needed; fall back to allocate-and-fix_length only when lengths differ. - stream: reuse a single mono downmix buffer across blocks, writing the final short block into a truncated view. - Add a mixed-dtype regression test for the downmix pass-through. * Relax out= dtype check to accept higher-precision buffers Per review (#2058): rather than requiring an exact dtype match, accept any out= buffer whose dtype can hold the result without loss of precision (promote_types(out.dtype, dtype) == out.dtype). A caller who explicitly allocates a higher-precision buffer keeps that precision; too-narrow buffers are still rejected. Updated docstrings and added a wider-dtype test. --------- Co-authored-by: Brian McFee <[email protected]> * Fix RQA single-axis inputs (#2063) * Fix RQA single-axis inputs * Update tests/test_sequence.py Work around mypy for test type checks --------- Co-authored-by: Brian McFee <[email protected]> * BoundedNorm for specshow on boolean data (#2072) * added boundednorm for boolean data in specshow * Added tests for boundarynorm boolean specshow --------- Co-authored-by: Joren Hammudoglu <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Ale Lloveras <[email protected]> Co-authored-by: Haydn Lam <[email protected]> Co-authored-by: Emily <[email protected]> Co-authored-by: dhaasb <[email protected]> Co-authored-by: Daniel Fernandes <[email protected]> Co-authored-by: Gopesh Pandey <[email protected]> Co-authored-by: T <[email protected]> Co-authored-by: Terry Chen <[email protected]> Co-authored-by: Petra Kühnle <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: ejwong24 <[email protected]> Co-authored-by: Suhas Holla Karkada Chandrashekar <[email protected]>
* Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * Test overhaul (#1925) * removed dependency on test1.wav in onset tests * removed dependency on test1.wav in beat tests * properly scoping chirp fixtures * simplifying test_icqt * simplifying onset strength tests * adding some comments on new onset tests * simplifying beat tests * simplifying griffinlim tests * cleaning up gl-cqt tests * further test optimizations * fixing a test naming issue * Reduced nnls_multiblock test * Reduced recurrence matrix test * Reduced hybrid cqt tests * reducing hpss tests * removed test1_22050 from features tests * removing unnecessary example file reference * seeing if skipping ifgram regression drops coverage * Replacing regression fixtures on stft tests * putting in skips for old regression tests * self-contained lpc correctness tests * removing old fixtures from core tests * whoops still need the fixture loader for now * removed fixture files from effects tests * removed fixture files from segment tests * removed fixture files from decompose tests * suppressing known warning in glcqt test * using a fixture for find_files tests * in-place fixture generation for multichannel tests * working on purging srand for proper fixture * purging np.random continues * more rng purging * purging randomness * purging np.random continues * srand purging * random seeding * removed all unseeded randomness in tests * transitioning core tests to internal fixtures * blacking * moving core tests to a new audio clip * migrating display tests to new test track * adding build artifacts for failed image comparison tests * revising image tests once more * progress on purging old tests * simplified tonnetz test * simplified cens tests * rewrite hz/mel tests * rewrote hz_to_octs tests * rewrote melfbnorm tests * marking more tests for removal/rewriting * rewrote centroid tests * finished with met features tests * rewrote chromafb tests * rewrote melfb tests * removing unneded code and documentation * removing unneded code and documentation * rewrote semitone filterbank tests * removed all regression tests * removed the test submodule * keeping regression tests for yin/pyin * copilot suggestions * removing another unused test * added explicit buf_to_float test * fixing coverage * blacked the tests * Peak picking by dynamic programming (#1927) * Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * DP peak picking * Added tests for dp peak picker * loop optimization * linting * skipping blank lines * linting * added multichannel test for dp peak picker * a couple more extensions to peak picking * upper pinning cmake until the rest of the world gets its act together * updating documentation on peak picker to describe greedy method * spelling * mypy cleanups * removing cmake pin * squashing an unhelpful type check in multichannel * expanding docstring per copilot CR recommendations * Trying a new environment cache setup in CI (#1936) * Trying a new environment cache setup in CI * purging old ci instructions * updated cache setup for docs-ci workflow * fixing a version pin in doc CI * sphinx 8.2 doesn't like something in our multiversion builds. pin it for now * dropping sphinx pin in favor of removing historical builds on 0.9.2 * regexen lol * Variable-rate and non-iterative phase vocoding (#1931) * rewrote phase vocoder * whatever velin... * removed unnecessary unwrap * fixing missing type annotation * Finishing up rough edges on phase vocoder * coverage up on phase vocoder * coverage up on phase vocoder * final copilot recommendations * dropped python 3.8 support for the 1.0 release * bumping numba version requirement * trying to fix the min env * Include scipy-stubs in the test dependencies - v1.0.0 rebase (#1946) * Include `scipy-stubs` in the type-check dependencies https://github.com/scipy/scipy-stubs * remove unused `# type: ignore`s * restrict `scipy-stubs` to `python>=3.10` * mypy no longer ignores missing `scipy` imports * add `scipy-stubs` to the CI linting coda-forge deps * get rid of some squiggly lines * fix remaining ~mypy errors~ squiggly lines * fix `recurrence_matrix` overload for `sparse=True` * workaround a mypy type narrowing bug with `TypeIs` guards * workaround for limitations in mypy's local inference algorithm * workarounds for non-gradual `scipy.io.loadmat` return types * apply review suggestions Co-authored-by: Brian McFee <[email protected]> * post-merge fix of missing Literal annotation --------- Co-authored-by: Brian McFee <[email protected]> * bumping for scipy stubs 1.16.0.1+ * arguing with stubs * arguing with stubs * arguing with stubs * vscale option to specshow (#1938) * some very broken code in here right now * yargh * rewrote scaling code in specshow * correcting docstrings * Reverting a change in power db * fixing type annotation import * blacking and docstring fixes * updated examples to use vscale * updated examples and docstrings * linting * docstyle is strict * Fixed a typo * type hacking * specshow vscale tests * keying mpl image failure artifacts on runner metadata * trying high-precision audio for image tests * bumping error tolerance on the phase plots * adding more information to vscale image test * mpl image tests are hard * expanded docstring for specshow * expanded specshow advanced example * Switched to twilight_shifted as default phase colormap * reworking phase differential plots, updated rainbowgram example * revised plot_display * phase_unwrap_diff -> dphase * added dphase_t mode to specshow * splitting phase from db vscale tests * adding fixture * improving stability of phase display tests * bumping tolerance back up due to font layout quirks * last docstring update to specshow * more docstring fiddling * Remove default quantization for note_to_hz (#1947) * fixes #1945, leave cent deviation in place for note_to_hz * type linting * minor docstring updates * fixed docstring typo * expanded docstring added default behavior test * Freq convert nan (#1948) * fixing #1944 * added tests for nan conversion of notes * Blacking and linting * linting * suppressing bad type checks in nan converters * i don't understand type annotations at all * i can't program either * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * Colorbar helpers (#1952) * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * whoops missed a commit * Apply suggestions from copilot code review Mostly cosmetic changes Co-authored-by: Copilot <[email protected]> * fixing a type testing error * Two-slope norm for inferred diverging colormap (#1954) * twoslopenorm diverging colormaps * updating image comparison tests for new diverging cmap style * fixing some buglets * fixing some numerical precision issues in image tests * working on ic test for diverging colormaps * working on ic test for diverging colormaps * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * relaxing rms on divergence color tests * updating advanced example for display * updating viterbi example with new diverging cmap plot * expanded cmap to support preconstructed colormap objects * fixing type import business * Update librosa/display.py Co-authored-by: Copilot <[email protected]> * bug fixing * fixing coverage * fixing coverage * deprecation rename of cmap * deprecation rename of cmap * Update librosa/display.py More direct dtype check for boolean data in cmap inference Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Warn on perceptual weighting underflow (#1955) * added warnings for perceptual weighting curves on underflow * fixes #1941 * Warping path to step grid (#1958) * Added path-to-steps fixes #1937 * revising warping example for time synchronization * making the stretched examples more obvious in display * added inverse warping path sampling * linting * linting * quivers * using colors more smartly in stretching example * using colors more smartly in stretching example * quivering * fixing up docs * revising some plots in the advanced gallery * added some unit tests for pathtosteps * Docstring formatting * fudging test data for path conversion to avoid rounding errors * nudging scipy dependency to unstick test failures * final polish on music sync example figures * Fix subsegment example (#1959) * fixed #1950 * improved styling * SPEC07 compliant rng parameters (#1960) * transitioning random_state to rng= for spec07 * suppressing type failures * Update librosa/_typing.py Co-authored-by: Copilot <[email protected]> * fixing old type annotation code * simplified testing, consistentized errors * improved docstring styling * Update tests/test_core.py Co-authored-by: Copilot <[email protected]> * preserve support for old randomstate objects in griffinlim --------- Co-authored-by: Copilot <[email protected]> * nudging min python in setup.cfg * Upload doc build preview artifacts (#1962) * adding an artifact build for pr docs * Trying a different naming * Expire deprecations for 1.0 release (#1963) * removed audioread dependency * removed res_type=None support for vqt and friends * removed get/set_fftlib * removed old filterbanks for cqt * fixing flakes * removed x_axis param from waveshow * removed winlength from yin and pyin * removed audioread from version lister * clarified comment in cqt * blacking * fixing docstring formatting * fixing type annotations now that we are narrowly on scipy fft * removing dead tests * optionalizing dct norms * added generated/ to docs clean target * allow link failure on htk site * Signal mixing helpers (#1964) * progress on mixing * extended to_mono for multiple inputs * added to_multi * fixed a typo * fixed docstring formatting * fixed docstring formatting * examples and docs updates * types are silly * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Added upmixing in to_stereo * fixes from copilot cr * added norm parameter to mixers * types are silly * types are silly * CR feedback * Apply suggestions from code review require at least one input for to_mono and to_stereo Co-authored-by: Copilot <[email protected]> * expanded tests for to_mono * Added pad testing for to_mono * test coverage for to_stereo * test coverage for to_multi * adding mixer helpers into more advanced examples --------- Co-authored-by: Copilot <[email protected]> * oct3 display modes (#1967) * first hack at oct3 * added oct3 display modes * added tests for oct3 modes * trying again without constrained layout * improving docstring and expanding vqt axis compatibility support * fixing image comparison test to support matplotlib 3.10.5 * Inverted waveshow (#1971) * added a proxy patch for waveshow label containment * First cut at inverted waveform display * tests for inverted waveshow * more fancy footwork with matplotlib artists * [CR] Wavebars (#1973) * first cut at wavebars * linting * linting * added basic wavebar tests * added basic wavebar tests * removing dependency on compressed layout for wavebar test * removing dependency on compressed layout for wavebar test * nudging mpl dependency * nudging mpl dependency * nudging mpl dependency entirely * docstring improvements * chore: Refine .gitignore for improved accuracy and coverage (#1969) This commit refines the `.gitignore` file by: - Removing redundant entries. - Improving comments for better readability. - Reorganizing and categorizing ignored files for better maintainability. - Consolidating testing and checkpoint related entries. * Adding plt.show() at the end of code blocks (#1979) * Fix types in beat tracking code (#1977) The development version of Numba 0.62.0 is unhappy about `range` being applied to floating point values here. * Fix #1970: Prevent AdaptiveWaveplot adaptor from being garbage collected (#1992) - Add _WAVESHOW_ADAPTORS WeakKeyDictionary to retain adaptors per-Axes - Store artists (steps, envelope) and axes as weakrefs in AdaptiveWaveplot - Add properties to preserve existing attribute API - Add GC guard in update() for safety - Add 3 regression tests * Add Metrogram Transform (#1986) * feat: add metrogram transform * allow passing no aggregate, improve documentation * feat: add interp_broadcast Reference: #1909 * show metrogram in html docs * show interp_broadcast in html docs * fix: linting issues * use keywording,reorder x1/x1_pos, check axis range * generalize axis for metrogram transform also fix a logic bug with checking index bounds * overload interp_broadcast when func = None * fix interp_broadcast not accepting negative axis * formatting * set np.expand_dims to -3 instead of using a param * add metrogram example * add interp_broadcast example * add tests for metrogram * rename func -> op in interp_broadcast * simplify interp_broadcast example choosing to keep the example minimal like the other examples in utils an exhaustive use of all parameters is better suited for the tests * add tests for interp_broadcast * metrogram example: keep the zero in funt_freqs * remove duplicate imports added unintentionally * remove blank line after doc strings * add tests for interp_broadcast axis * update metrogram docs * Fix typo Co-authored-by: Copilot <[email protected]> * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * fix: input shape validation based on broadcasting rules Co-authored-by: Brian McFee <[email protected]> * docs: type change kind: str -> kind: _InterpKind --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Brian McFee <[email protected]> * Update type annotations (#1980) * nudging matplotlib min version for spec0 * needs mpl in lint environment now * type hacking * type hacking * type annotations are the worst * type hacking continues * type hacking continues * types types types * bumping numpy for env compatibility * fixing scipy sparse indexing type annotations * type hacking * mypy is stupid * mypy is stupid * mypy is stupid * strengthening tests stupidly for mypy * Fixing type annotations in display and tests * upper pinning sphinx dependency until sphinx-multiversion is fixed * trying to address copilot reviews * more type annotation nonsense * Trying to fix numba/numpy compatibility for test environments * type annotations * Migrate from SciPy spmatrix to sparray (#1994) * [ENH] Migrate from scipy.sparse matrix to array interface (#1902) * spell check * spell check * Remove redundant empty-index check in sparsify_rows; add test for 1D sparse shear rejection * Fix 1D sparse shear test for scipy < 1.14 compatibility * Address review: accept sparse matrices in shear, vectorize sparsify_rows * Suppress scipy-stubs attr-defined errors in sparse matrix shear test * Python 3.14 test support (#1999) * adding 3.14 to test matrix * is it a name mismatch problem? * forcing python versions back into place * Trying to force a source build on the samplerate package * reverting source build for samplerate, it doesn't work * nudging python for docs build to 3.11 * nudging python for docs build to 3.11 * bypassing zenodo linkchecks * updated libsndfile link in docs * feat: implement hybrid_tempogram (#1991) (#2004) * feat: implement hybrid_tempogram per Peeters 2005 * refactor: address CR feedback, explicit kwargs, finite interpolation * Merge branch '1.0.0dev' into feature/hybrid-tempogram and resolve conflicts * Merge upstream 1.0.0dev and resolve conflicts * Merge upstream 1.0.0dev and fix typo in metrogram * Resolve rhythm imports and add to __all__ * style: fix linting and restore metrogram * test: add unit tests for hybrid_tempogram coverage * fix: use fourier_tempo_frequencies for hybrid_tempogram freq grid * fix: import fourier_tempo_frequencies * fix: remove non-english text from docstring to pass codespell * refactor: simplify hybrid_tempogram array handling and fix kwargs * style: remove trailing whitespace in docstring to pass velin linter * fix: resolve mypy type hints for interp1d and remove duplicate decorator * refactor: add type hints, docstring examples, and optimize interp kwargs per review * refactor: apply robust type hinting, clean docstrings, and array return per strict mypy checks * fix: finalize hybrid_tempogram with strict typing, optimized interpolation, and test coverage * fix: remove assume_sorted=True to fix interpolation on descending lag domain * refactor: apply reviewer feedback for optimizations and test fixtures * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Brian McFee <[email protected]> Co-authored-by: Copilot <[email protected]> * Document specshow frequency axis scaling (#2006) Co-authored-by: Terry Chen <[email protected]> * Surface contributing guide in docs site, link build instructions (#2009) * Surface contributing guide in docs site, link build instructions Adds myst-parser to render CONTRIBUTING.md inside the docs sidebar, so first-time contributors can find the contributor guide without leaving the docs site. Also updates CONTRIBUTING.md to reference docs/BUILD.md for documentation build instructions, replacing a stale reference to a doc/README that no longer exists. Fixes #1800. * Add myst-parser to docs env * fixed broken link in contributing guidelines --------- Co-authored-by: Brian McFee <[email protected]> * Multiplot (#2012) * first cut at multiplot * multiplot cleanups * type annotating * example fixups * added legend aggregator, fixing sphinx configs * fixing type hints * support variadic multiplot inputs * polishing multiplot * velinizing * fixing singleton multiplots * Added legend_for_axes tests * multiplot helper tests * updated multilegend plots to be more informative * coverage up * coverage up * fixing type checks in display tests * test blacking * tying up loose ends * covering legend loc inference * multiplot coverage * adding fixtures for multiplot * Added titles= support to multiplot * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * improving on copilot suggested test * improved docstrings * velinizing * added example for legend_for_axes * simplified docstring * fixing #2013 * renaming function aliases in multiplot * expanded unit tests to cover multiplot titles * expanded legend_for_axes docstring to clarify loc quirkiness * fixing type annotations for optional labels and titles * working on stefanv's comments * Accept user-supplied property cycles in multiplot * fixing positional argument in display tests * simplified docstring examples * updated docstring on multiplot orient * finished docstring fixups --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Spec0 2026.06 (#2018) * attempting spec0 compliance * attempting spec0 compliance * revised min doc build version in build.md * added dead batteries to doc build matrix * bumped numba version * trying with strict in conda env * bumping packaging to 23.2 for python 3.12 support * bumped soxr to 1.0.0 * fixing environment naming while i'm at it * Bumping msgpack-python for environment consistency * bumping lazy and typing_extensions * bumping min versions again for py3.12 environment compatibility * bumping versions to ensure python 3.12 compatibility * removed version constraint on scipy stubs * removed resource management shim dead branch * cleanups around python version handling * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * display.wavef0 (was: melodyplot) (#1976) * added mask to waveshow * fixing stuff * melody plot first cut * added missing docstring update * Added test coverage * nudging to mpl 3.8 * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.8.4 to see if that works * should fix wavef0 inverted mode * i can't program in python apparently * nudging back to mpl 3.8 for datalim hacking * trying mpl 3.9 * trying mpl 3.9 * trying mpl 3.9 * working on making mypy happy * more mypy business * fixed typing in wavef0 * added round trip test for transformf0 * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * revised docstring * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * velinizing * protect transformf0 from nonpositive f0 values * streamlined wavef0 norm calculation * copilot cr comments * copilot comments on docstrings * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * rearranging error checks * fixing type checking * fixed display.__all__ * fixing thinko in f0 bounds checking * Added docstrings to transformf0 methods * minor docstring updates * linting * contorting around edge cases in wavef0 * fixing numerical problems in wavef0 edge cases * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * added cqt overlay example in wavef0 docstring --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Yet another Viterbi acceleration PR (#2007) * removed over alloation in viterbi core * temporary hack faster viterbi * pyin speedups * added safety barrier on transition thresholding * added tests for viterbi acceleration * one more test case coverage * Streamlining changes * polishing viterbi optimization * Updates for mypy 2.1 (#2025) * making mypy happy in 2.1 * making mypy happy in 2.1 * mypy making us jump through hoops again * mypy making us jump through hoops again * making mypy happy in 2.1 * mypy is happy for now * maybe removing numpy typing plugins was premature * making mypy happy on minimal numpy * fidgeting some type annotations to work across multiple numpy versions * fixing some import silliness in tests * undoing some bad optimizations * fixes #2014 (#2026) * Modern linting (#2027) * migrating to ruff * migrating to ruff * down into line length constraints * removed unused imports * whitespace fixing * import ordering via ruff * pyi linting * setting output format * fixing quote styles * working on bugbear * bugbear tests * simplify linting * ruffing * ruff lint rules * Dynamic vectorize (#2028) * dynamic vectorization in beat * dynamic vectorization in core * dynamic vectorization in core * dynamic vectorization in utils * removed all static vectorized signatures * fixing some type business * rewrote abs2 for more direct dtype handling * cleaning up some typing code * more mypy tweaking * Even faster import (#2029) * being better about enforcing type checking blocks * localizing heavy imports to accelerate package import * more typechecking blocks * fixed missing import * purging typing extensions * stricter typecheck blocks * lingering type block * Negative offset load (#2030) * first cut at negative offset loading * added flac example and fixture for negative load offset test * marking ogg seek tests as optional pass * added negative offset load in stream * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Loadx (#2031) * added loadx * updated examples to use loadx where appropriate * updated examples to use loadx where appropriate * Clarified docstring for loadx * Docstring formatting * typing and docstring improvements from copilot * more helpful failure mode in loadx (#2032) * Modernize types in `librosa._typing` (#2035) * Modernize types in `librosa._typing` * remove sudden unused `# type: ignore[misc]` * forcing upgrade to codecov action * modernizing type annotations for the future (#2036) * mdoernizing type annotations for the future * loosened util.tiny type annotation just a wee bit * more type annotation modernization (#2038) * Fill in missing type annotations (#2037) * Fill in missing type annotations in `display.py` * Fill in missing type annotations in `core/intervals.py` * Fill in missing type annotations in `beat.py` * remove expired `librosa.beat.tempo` deprecation * Display Highlighter (#2034) * first cut at display.highlight * updated examples to use highlighter * more example updates * added tests for highlighter * highlighter tests * highlighter test images * spelling * velinizing * path coverage * copilot review comments * copilot review comments * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * one more copilot suggestion * modernized annotations * type modernizing --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fixed #2040 (#2041) * avoid turning scalars into 0-d arrays in `core.{convert,spectrum}` and `util.utils` (#2039) * `core.convert`: avoid turning scalars into 0-d arrays * `core.spectrum`: avoid turning scalars into 0-d arrays * `util.utils`: avoid turning scalars into 0-d arrays * fix irreproducible mypy error * Waveplot styling (#2044) * style waveplot proxy after steps, not fill * fixed #2042 * updated tests * cleanups in the new waveplot legend code * styling and ruffing * Final polishing on waveplot legend code * improved `dtype_r2c` and `dtype_c2r` typing in `util.utils` (#2043) * Doc check modernizing (#2047) * switched velin to numpydoc lint * configuring numpydoc lint * revising numpydoc configs to avoid hobgoblins * starting to get somewhere with numpydoc linting * fixing exceptions to numpydoc linting * [WIP] Fix failing GitHub Actions job for lint and code analysis (#2048) * Initial plan * Apply remaining changes --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> * working through numpydoc corrections * working through numpydoc corrections * working through numpydoc corrections * fixing numpydoc lint * fixing exceptions to numpydoc linting * numpydoc is all passing --------- Co-authored-by: Copilot <[email protected]> * Contributing and agents update (#2017) * updating contributing guidelines with ai policy * Added agents.md * Fix CONTRIBUTING.md markdown formatting * revising contributing guidelines * integrating comments * formatting * updated contributing guidelines for numpydoc linting * reformat `**/__init__.pyi` re-exports (#2049) * Include str dtype in `ndarray` return type annotations (#2050) * Multichannel db (#2051) * implemented axis targeting for db conversion * db calculation now works properly with target axes * fixed scalar processing for db * added 'auto' mode to db conversion axes inference * fixed regression in amplitude_to_db * fixed regression in amplitude_to_db * copilot reviews * fixing some type annotations * copilot comments * cleaning up tests * pytest nonsense * Fix decorator callable types in `librosa.util.decorators` (#2053) * Improve `ndarray` return types (#2052) * Generic shaped `ndarray` type aliases * Improve `ndarray` return types in `librosa.core` * Improve `ndarray` return types in `librosa.util` * Improve `ndarray` return types in `librosa.beat` * Improve `ndarray` return types in `librosa.display` * Improve `ndarray` return types in `librosa.effect` * Improve `ndarray` return types in `librosa.filters` * Improve `ndarray` return types in `librosa.segment` * Improve `ndarray` return types in `librosa.sequence` * Fix mypy errors with `numpy<2.4` * Ignore false positive mypy error in tests related to `np.object_` array iteration * Address review comments for the typing changes in `util.utils` * Work around a mypy bug where it fails to expand `bool` into `Literal[True] | Literal[False]`. * Support matplotlib 3.11 in tests (#2054) * redoing tests for matplotlib 3.11, tightening tolerance where possible * updated failure artifact upload recipe * loosening tests more on mpl 3.10 * bypassing image comparison tests on 3.10 completely * fixed types for legend in matplotlib 3.11 * Stream resampling (#2055) * initial cut of resampling stream passes previous tests * progress on stream resampling * clarified docstring, reverted changes * updated tests * feature complete stream resampling * refactored tests * better coverage for edge cases * working in some copilot review comments * more copilot suggestions * copilot and gemini comments * cleaning up stream tests * tightening memory allocations in stream * added a future default change decorator and bundled onto stream * forgot to kw-only a parameter name * ratcheting down default stream parameter setting deprecation to 1.1 * last round of copilot reviews * massive simplification of legend_for_axes, fixes #2057 (#2059) * Refactor frequency formatters (#2060) * fixed minor ticking for oct3 modes * numpydoc linting * copilot review comments * copilot review comments * Updating actions (#2065) * updating actions * fixing an out= allocation issue * more warnings cleanup * libsamplerate comes via conda now * upload-artifact update * disable auto-activate * Standardize n_fft parameter docstrings (#2068) * Standardize n_fft parameter docstrings Rebuilt against 1.0.0dev after retargeting. Standardizes the analysis n_fft descriptions on 'length of the FFT window', fixes the bins/window conflations (piptrack, estimate_tuning, filters.mel, filters.chroma, feature.inverse), clarifies istft's frame-length inference, corrects mel_to_stft's documented return shape, and fixes frequency-axis references that assumed 2D input (istft win_length, phase_vocoder hop_length). Incorporates review feedback: 'frame' terminology in get_duration; audio-output functions reference the intermediate STFT without a bins clause. * Use 'frame' terminology for n_fft descriptions Per review: n_fft refers to frame length, not window length, since a window can be shorter than the frame. Swept all standardized n_fft descriptions accordingly. --------- Co-authored-by: Cameron Brooks <[email protected]> * precise dtype annotations in `librosa.beat` (#2069) Co-authored-by: Brian McFee <[email protected]> * Infer n_bins automatically in cqt/vqt (#2066) * added n_bins=None to cqt/vqt * added n_bins=None to cqt/vqt tests * linting * revisions * revisions * one more test * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Added nbins inference to hybrid and pseudo cqt * linting * copypasta * fixed #2071, tightened icqt tests * revised downsampling logic in vqt * copilot review comments --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Add out= parameter to to_mono for in-place downmixing (#2058) * Add out= buffer parameter to to_mono, to_stereo, to_multi Lets callers pass a pre-allocated output buffer to the mixing functions, avoiding a fresh allocation per call (e.g. per-block downmix in stream()). A shared _init_output helper validates the buffer's shape and dtype against the computed output, zero-fills it, and returns it; out=None preserves the previous allocate-fresh behavior. Implements #2056 against the redesigned 1.0 mixing API. * Remove joblib caching from to_mono/to_stereo/to_multi Per review (#2058): the @cache decorator is incompatible with out=, since a cache hit returns the memoized array and skips writing into the caller's buffer, and hashing an uninitialized out= buffer is costly/non-deterministic. Dropping caching keeps the out= contract simple and correct. * Reuse output buffers in to_stereo/to_multi and stream mono downmix Addresses review feedback on #2058: - to_stereo: downmix directly into the output rows via out=, removing a second allocation. Cast left/right to the shared dtype first so the pass-through buffer always matches to_mono's computed dtype. - to_multi: pass the output row into to_mono when no length adjustment is needed; fall back to allocate-and-fix_length only when lengths differ. - stream: reuse a single mono downmix buffer across blocks, writing the final short block into a truncated view. - Add a mixed-dtype regression test for the downmix pass-through. * Relax out= dtype check to accept higher-precision buffers Per review (#2058): rather than requiring an exact dtype match, accept any out= buffer whose dtype can hold the result without loss of precision (promote_types(out.dtype, dtype) == out.dtype). A caller who explicitly allocates a higher-precision buffer keeps that precision; too-narrow buffers are still rejected. Updated docstrings and added a wider-dtype test. --------- Co-authored-by: Brian McFee <[email protected]> * Fix RQA single-axis inputs (#2063) * Fix RQA single-axis inputs * Update tests/test_sequence.py Work around mypy for test type checks --------- Co-authored-by: Brian McFee <[email protected]> * BoundedNorm for specshow on boolean data (#2072) * added boundednorm for boolean data in specshow * Added tests for boundarynorm boolean specshow --------- Co-authored-by: Joren Hammudoglu <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Ale Lloveras <[email protected]> Co-authored-by: Haydn Lam <[email protected]> Co-authored-by: Emily <[email protected]> Co-authored-by: dhaasb <[email protected]> Co-authored-by: Daniel Fernandes <[email protected]> Co-authored-by: Gopesh Pandey <[email protected]> Co-authored-by: T <[email protected]> Co-authored-by: Terry Chen <[email protected]> Co-authored-by: Petra Kühnle <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: ejwong24 <[email protected]> Co-authored-by: Suhas Holla Karkada Chandrashekar <[email protected]>
* Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * Test overhaul (#1925) * removed dependency on test1.wav in onset tests * removed dependency on test1.wav in beat tests * properly scoping chirp fixtures * simplifying test_icqt * simplifying onset strength tests * adding some comments on new onset tests * simplifying beat tests * simplifying griffinlim tests * cleaning up gl-cqt tests * further test optimizations * fixing a test naming issue * Reduced nnls_multiblock test * Reduced recurrence matrix test * Reduced hybrid cqt tests * reducing hpss tests * removed test1_22050 from features tests * removing unnecessary example file reference * seeing if skipping ifgram regression drops coverage * Replacing regression fixtures on stft tests * putting in skips for old regression tests * self-contained lpc correctness tests * removing old fixtures from core tests * whoops still need the fixture loader for now * removed fixture files from effects tests * removed fixture files from segment tests * removed fixture files from decompose tests * suppressing known warning in glcqt test * using a fixture for find_files tests * in-place fixture generation for multichannel tests * working on purging srand for proper fixture * purging np.random continues * more rng purging * purging randomness * purging np.random continues * srand purging * random seeding * removed all unseeded randomness in tests * transitioning core tests to internal fixtures * blacking * moving core tests to a new audio clip * migrating display tests to new test track * adding build artifacts for failed image comparison tests * revising image tests once more * progress on purging old tests * simplified tonnetz test * simplified cens tests * rewrite hz/mel tests * rewrote hz_to_octs tests * rewrote melfbnorm tests * marking more tests for removal/rewriting * rewrote centroid tests * finished with met features tests * rewrote chromafb tests * rewrote melfb tests * removing unneded code and documentation * removing unneded code and documentation * rewrote semitone filterbank tests * removed all regression tests * removed the test submodule * keeping regression tests for yin/pyin * copilot suggestions * removing another unused test * added explicit buf_to_float test * fixing coverage * blacked the tests * Peak picking by dynamic programming (#1927) * Update version.py * Update ci.yml also CI on PR to 1.0 dev branch * Update docs-ci.yml also doc CI on pr to 1.0.0dev * DP peak picking * Added tests for dp peak picker * loop optimization * linting * skipping blank lines * linting * added multichannel test for dp peak picker * a couple more extensions to peak picking * upper pinning cmake until the rest of the world gets its act together * updating documentation on peak picker to describe greedy method * spelling * mypy cleanups * removing cmake pin * squashing an unhelpful type check in multichannel * expanding docstring per copilot CR recommendations * Trying a new environment cache setup in CI (#1936) * Trying a new environment cache setup in CI * purging old ci instructions * updated cache setup for docs-ci workflow * fixing a version pin in doc CI * sphinx 8.2 doesn't like something in our multiversion builds. pin it for now * dropping sphinx pin in favor of removing historical builds on 0.9.2 * regexen lol * Variable-rate and non-iterative phase vocoding (#1931) * rewrote phase vocoder * whatever velin... * removed unnecessary unwrap * fixing missing type annotation * Finishing up rough edges on phase vocoder * coverage up on phase vocoder * coverage up on phase vocoder * final copilot recommendations * dropped python 3.8 support for the 1.0 release * bumping numba version requirement * trying to fix the min env * Include scipy-stubs in the test dependencies - v1.0.0 rebase (#1946) * Include `scipy-stubs` in the type-check dependencies https://github.com/scipy/scipy-stubs * remove unused `# type: ignore`s * restrict `scipy-stubs` to `python>=3.10` * mypy no longer ignores missing `scipy` imports * add `scipy-stubs` to the CI linting coda-forge deps * get rid of some squiggly lines * fix remaining ~mypy errors~ squiggly lines * fix `recurrence_matrix` overload for `sparse=True` * workaround a mypy type narrowing bug with `TypeIs` guards * workaround for limitations in mypy's local inference algorithm * workarounds for non-gradual `scipy.io.loadmat` return types * apply review suggestions Co-authored-by: Brian McFee <[email protected]> * post-merge fix of missing Literal annotation --------- Co-authored-by: Brian McFee <[email protected]> * bumping for scipy stubs 1.16.0.1+ * arguing with stubs * arguing with stubs * arguing with stubs * vscale option to specshow (#1938) * some very broken code in here right now * yargh * rewrote scaling code in specshow * correcting docstrings * Reverting a change in power db * fixing type annotation import * blacking and docstring fixes * updated examples to use vscale * updated examples and docstrings * linting * docstyle is strict * Fixed a typo * type hacking * specshow vscale tests * keying mpl image failure artifacts on runner metadata * trying high-precision audio for image tests * bumping error tolerance on the phase plots * adding more information to vscale image test * mpl image tests are hard * expanded docstring for specshow * expanded specshow advanced example * Switched to twilight_shifted as default phase colormap * reworking phase differential plots, updated rainbowgram example * revised plot_display * phase_unwrap_diff -> dphase * added dphase_t mode to specshow * splitting phase from db vscale tests * adding fixture * improving stability of phase display tests * bumping tolerance back up due to font layout quirks * last docstring update to specshow * more docstring fiddling * Remove default quantization for note_to_hz (#1947) * fixes #1945, leave cent deviation in place for note_to_hz * type linting * minor docstring updates * fixed docstring typo * expanded docstring added default behavior test * Freq convert nan (#1948) * fixing #1944 * added tests for nan conversion of notes * Blacking and linting * linting * suppressing bad type checks in nan converters * i don't understand type annotations at all * i can't program either * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * Colorbar helpers (#1952) * implemented colorbar helpers * added tests for colorbar helpers * updating docstring examples for new colorbar helpers * updated advanced examples for new colorbar helpers * minor tweaks to colorbar helpers * force a default color gamut on phase plots * type hinting fixes * bumping matplotlib to 3.6 (2022) * reverting to old-style formatter strings * redid image comparison test results * rearranged some code to allow more user overrides * tweaking format strings for aesthetics * fixing docstrings * whoops missed a commit * Apply suggestions from copilot code review Mostly cosmetic changes Co-authored-by: Copilot <[email protected]> * fixing a type testing error * Two-slope norm for inferred diverging colormap (#1954) * twoslopenorm diverging colormaps * updating image comparison tests for new diverging cmap style * fixing some buglets * fixing some numerical precision issues in image tests * working on ic test for diverging colormaps * working on ic test for diverging colormaps * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * relaxing rms on divergence color tests * updating advanced example for display * updating viterbi example with new diverging cmap plot * expanded cmap to support preconstructed colormap objects * fixing type import business * Update librosa/display.py Co-authored-by: Copilot <[email protected]> * bug fixing * fixing coverage * fixing coverage * deprecation rename of cmap * deprecation rename of cmap * Update librosa/display.py More direct dtype check for boolean data in cmap inference Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Warn on perceptual weighting underflow (#1955) * added warnings for perceptual weighting curves on underflow * fixes #1941 * Warping path to step grid (#1958) * Added path-to-steps fixes #1937 * revising warping example for time synchronization * making the stretched examples more obvious in display * added inverse warping path sampling * linting * linting * quivers * using colors more smartly in stretching example * using colors more smartly in stretching example * quivering * fixing up docs * revising some plots in the advanced gallery * added some unit tests for pathtosteps * Docstring formatting * fudging test data for path conversion to avoid rounding errors * nudging scipy dependency to unstick test failures * final polish on music sync example figures * Fix subsegment example (#1959) * fixed #1950 * improved styling * SPEC07 compliant rng parameters (#1960) * transitioning random_state to rng= for spec07 * suppressing type failures * Update librosa/_typing.py Co-authored-by: Copilot <[email protected]> * fixing old type annotation code * simplified testing, consistentized errors * improved docstring styling * Update tests/test_core.py Co-authored-by: Copilot <[email protected]> * preserve support for old randomstate objects in griffinlim --------- Co-authored-by: Copilot <[email protected]> * nudging min python in setup.cfg * Upload doc build preview artifacts (#1962) * adding an artifact build for pr docs * Trying a different naming * Expire deprecations for 1.0 release (#1963) * removed audioread dependency * removed res_type=None support for vqt and friends * removed get/set_fftlib * removed old filterbanks for cqt * fixing flakes * removed x_axis param from waveshow * removed winlength from yin and pyin * removed audioread from version lister * clarified comment in cqt * blacking * fixing docstring formatting * fixing type annotations now that we are narrowly on scipy fft * removing dead tests * optionalizing dct norms * added generated/ to docs clean target * allow link failure on htk site * Signal mixing helpers (#1964) * progress on mixing * extended to_mono for multiple inputs * added to_multi * fixed a typo * fixed docstring formatting * fixed docstring formatting * examples and docs updates * types are silly * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Update librosa/core/audio.py Co-authored-by: Copilot <[email protected]> * Added upmixing in to_stereo * fixes from copilot cr * added norm parameter to mixers * types are silly * types are silly * CR feedback * Apply suggestions from code review require at least one input for to_mono and to_stereo Co-authored-by: Copilot <[email protected]> * expanded tests for to_mono * Added pad testing for to_mono * test coverage for to_stereo * test coverage for to_multi * adding mixer helpers into more advanced examples --------- Co-authored-by: Copilot <[email protected]> * oct3 display modes (#1967) * first hack at oct3 * added oct3 display modes * added tests for oct3 modes * trying again without constrained layout * improving docstring and expanding vqt axis compatibility support * fixing image comparison test to support matplotlib 3.10.5 * Inverted waveshow (#1971) * added a proxy patch for waveshow label containment * First cut at inverted waveform display * tests for inverted waveshow * more fancy footwork with matplotlib artists * [CR] Wavebars (#1973) * first cut at wavebars * linting * linting * added basic wavebar tests * added basic wavebar tests * removing dependency on compressed layout for wavebar test * removing dependency on compressed layout for wavebar test * nudging mpl dependency * nudging mpl dependency * nudging mpl dependency entirely * docstring improvements * chore: Refine .gitignore for improved accuracy and coverage (#1969) This commit refines the `.gitignore` file by: - Removing redundant entries. - Improving comments for better readability. - Reorganizing and categorizing ignored files for better maintainability. - Consolidating testing and checkpoint related entries. * Adding plt.show() at the end of code blocks (#1979) * Fix types in beat tracking code (#1977) The development version of Numba 0.62.0 is unhappy about `range` being applied to floating point values here. * Fix #1970: Prevent AdaptiveWaveplot adaptor from being garbage collected (#1992) - Add _WAVESHOW_ADAPTORS WeakKeyDictionary to retain adaptors per-Axes - Store artists (steps, envelope) and axes as weakrefs in AdaptiveWaveplot - Add properties to preserve existing attribute API - Add GC guard in update() for safety - Add 3 regression tests * Add Metrogram Transform (#1986) * feat: add metrogram transform * allow passing no aggregate, improve documentation * feat: add interp_broadcast Reference: #1909 * show metrogram in html docs * show interp_broadcast in html docs * fix: linting issues * use keywording,reorder x1/x1_pos, check axis range * generalize axis for metrogram transform also fix a logic bug with checking index bounds * overload interp_broadcast when func = None * fix interp_broadcast not accepting negative axis * formatting * set np.expand_dims to -3 instead of using a param * add metrogram example * add interp_broadcast example * add tests for metrogram * rename func -> op in interp_broadcast * simplify interp_broadcast example choosing to keep the example minimal like the other examples in utils an exhaustive use of all parameters is better suited for the tests * add tests for interp_broadcast * metrogram example: keep the zero in funt_freqs * remove duplicate imports added unintentionally * remove blank line after doc strings * add tests for interp_broadcast axis * update metrogram docs * Fix typo Co-authored-by: Copilot <[email protected]> * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * Update librosa/util/utils.py Co-authored-by: Copilot <[email protected]> * fix: input shape validation based on broadcasting rules Co-authored-by: Brian McFee <[email protected]> * docs: type change kind: str -> kind: _InterpKind --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Brian McFee <[email protected]> * Update type annotations (#1980) * nudging matplotlib min version for spec0 * needs mpl in lint environment now * type hacking * type hacking * type annotations are the worst * type hacking continues * type hacking continues * types types types * bumping numpy for env compatibility * fixing scipy sparse indexing type annotations * type hacking * mypy is stupid * mypy is stupid * mypy is stupid * strengthening tests stupidly for mypy * Fixing type annotations in display and tests * upper pinning sphinx dependency until sphinx-multiversion is fixed * trying to address copilot reviews * more type annotation nonsense * Trying to fix numba/numpy compatibility for test environments * type annotations * Migrate from SciPy spmatrix to sparray (#1994) * [ENH] Migrate from scipy.sparse matrix to array interface (#1902) * spell check * spell check * Remove redundant empty-index check in sparsify_rows; add test for 1D sparse shear rejection * Fix 1D sparse shear test for scipy < 1.14 compatibility * Address review: accept sparse matrices in shear, vectorize sparsify_rows * Suppress scipy-stubs attr-defined errors in sparse matrix shear test * Python 3.14 test support (#1999) * adding 3.14 to test matrix * is it a name mismatch problem? * forcing python versions back into place * Trying to force a source build on the samplerate package * reverting source build for samplerate, it doesn't work * nudging python for docs build to 3.11 * nudging python for docs build to 3.11 * bypassing zenodo linkchecks * updated libsndfile link in docs * feat: implement hybrid_tempogram (#1991) (#2004) * feat: implement hybrid_tempogram per Peeters 2005 * refactor: address CR feedback, explicit kwargs, finite interpolation * Merge branch '1.0.0dev' into feature/hybrid-tempogram and resolve conflicts * Merge upstream 1.0.0dev and resolve conflicts * Merge upstream 1.0.0dev and fix typo in metrogram * Resolve rhythm imports and add to __all__ * style: fix linting and restore metrogram * test: add unit tests for hybrid_tempogram coverage * fix: use fourier_tempo_frequencies for hybrid_tempogram freq grid * fix: import fourier_tempo_frequencies * fix: remove non-english text from docstring to pass codespell * refactor: simplify hybrid_tempogram array handling and fix kwargs * style: remove trailing whitespace in docstring to pass velin linter * fix: resolve mypy type hints for interp1d and remove duplicate decorator * refactor: add type hints, docstring examples, and optimize interp kwargs per review * refactor: apply robust type hinting, clean docstrings, and array return per strict mypy checks * fix: finalize hybrid_tempogram with strict typing, optimized interpolation, and test coverage * fix: remove assume_sorted=True to fix interpolation on descending lag domain * refactor: apply reviewer feedback for optimizations and test fixtures * Update librosa/feature/rhythm.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Brian McFee <[email protected]> Co-authored-by: Copilot <[email protected]> * Document specshow frequency axis scaling (#2006) Co-authored-by: Terry Chen <[email protected]> * Surface contributing guide in docs site, link build instructions (#2009) * Surface contributing guide in docs site, link build instructions Adds myst-parser to render CONTRIBUTING.md inside the docs sidebar, so first-time contributors can find the contributor guide without leaving the docs site. Also updates CONTRIBUTING.md to reference docs/BUILD.md for documentation build instructions, replacing a stale reference to a doc/README that no longer exists. Fixes #1800. * Add myst-parser to docs env * fixed broken link in contributing guidelines --------- Co-authored-by: Brian McFee <[email protected]> * Multiplot (#2012) * first cut at multiplot * multiplot cleanups * type annotating * example fixups * added legend aggregator, fixing sphinx configs * fixing type hints * support variadic multiplot inputs * polishing multiplot * velinizing * fixing singleton multiplots * Added legend_for_axes tests * multiplot helper tests * updated multilegend plots to be more informative * coverage up * coverage up * fixing type checks in display tests * test blacking * tying up loose ends * covering legend loc inference * multiplot coverage * adding fixtures for multiplot * Added titles= support to multiplot * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * improving on copilot suggested test * improved docstrings * velinizing * added example for legend_for_axes * simplified docstring * fixing #2013 * renaming function aliases in multiplot * expanded unit tests to cover multiplot titles * expanded legend_for_axes docstring to clarify loc quirkiness * fixing type annotations for optional labels and titles * working on stefanv's comments * Accept user-supplied property cycles in multiplot * fixing positional argument in display tests * simplified docstring examples * updated docstring on multiplot orient * finished docstring fixups --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Spec0 2026.06 (#2018) * attempting spec0 compliance * attempting spec0 compliance * revised min doc build version in build.md * added dead batteries to doc build matrix * bumped numba version * trying with strict in conda env * bumping packaging to 23.2 for python 3.12 support * bumped soxr to 1.0.0 * fixing environment naming while i'm at it * Bumping msgpack-python for environment consistency * bumping lazy and typing_extensions * bumping min versions again for py3.12 environment compatibility * bumping versions to ensure python 3.12 compatibility * removed version constraint on scipy stubs * removed resource management shim dead branch * cleanups around python version handling * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * display.wavef0 (was: melodyplot) (#1976) * added mask to waveshow * fixing stuff * melody plot first cut * added missing docstring update * Added test coverage * nudging to mpl 3.8 * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.10 to see if that works * Temporarily nudging ci minimal to mpl 3.8.4 to see if that works * should fix wavef0 inverted mode * i can't program in python apparently * nudging back to mpl 3.8 for datalim hacking * trying mpl 3.9 * trying mpl 3.9 * trying mpl 3.9 * working on making mypy happy * more mypy business * fixed typing in wavef0 * added round trip test for transformf0 * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * revised docstring * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * velinizing * protect transformf0 from nonpositive f0 values * streamlined wavef0 norm calculation * copilot cr comments * copilot comments on docstrings * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * rearranging error checks * fixing type checking * fixed display.__all__ * fixing thinko in f0 bounds checking * Added docstrings to transformf0 methods * minor docstring updates * linting * contorting around edge cases in wavef0 * fixing numerical problems in wavef0 edge cases * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * added cqt overlay example in wavef0 docstring --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Yet another Viterbi acceleration PR (#2007) * removed over alloation in viterbi core * temporary hack faster viterbi * pyin speedups * added safety barrier on transition thresholding * added tests for viterbi acceleration * one more test case coverage * Streamlining changes * polishing viterbi optimization * Updates for mypy 2.1 (#2025) * making mypy happy in 2.1 * making mypy happy in 2.1 * mypy making us jump through hoops again * mypy making us jump through hoops again * making mypy happy in 2.1 * mypy is happy for now * maybe removing numpy typing plugins was premature * making mypy happy on minimal numpy * fidgeting some type annotations to work across multiple numpy versions * fixing some import silliness in tests * undoing some bad optimizations * fixes #2014 (#2026) * Modern linting (#2027) * migrating to ruff * migrating to ruff * down into line length constraints * removed unused imports * whitespace fixing * import ordering via ruff * pyi linting * setting output format * fixing quote styles * working on bugbear * bugbear tests * simplify linting * ruffing * ruff lint rules * Dynamic vectorize (#2028) * dynamic vectorization in beat * dynamic vectorization in core * dynamic vectorization in core * dynamic vectorization in utils * removed all static vectorized signatures * fixing some type business * rewrote abs2 for more direct dtype handling * cleaning up some typing code * more mypy tweaking * Even faster import (#2029) * being better about enforcing type checking blocks * localizing heavy imports to accelerate package import * more typechecking blocks * fixed missing import * purging typing extensions * stricter typecheck blocks * lingering type block * Negative offset load (#2030) * first cut at negative offset loading * added flac example and fixture for negative load offset test * marking ogg seek tests as optional pass * added negative offset load in stream * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Loadx (#2031) * added loadx * updated examples to use loadx where appropriate * updated examples to use loadx where appropriate * Clarified docstring for loadx * Docstring formatting * typing and docstring improvements from copilot * more helpful failure mode in loadx (#2032) * Modernize types in `librosa._typing` (#2035) * Modernize types in `librosa._typing` * remove sudden unused `# type: ignore[misc]` * forcing upgrade to codecov action * modernizing type annotations for the future (#2036) * mdoernizing type annotations for the future * loosened util.tiny type annotation just a wee bit * more type annotation modernization (#2038) * Fill in missing type annotations (#2037) * Fill in missing type annotations in `display.py` * Fill in missing type annotations in `core/intervals.py` * Fill in missing type annotations in `beat.py` * remove expired `librosa.beat.tempo` deprecation * Display Highlighter (#2034) * first cut at display.highlight * updated examples to use highlighter * more example updates * added tests for highlighter * highlighter tests * highlighter test images * spelling * velinizing * path coverage * copilot review comments * copilot review comments * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> * one more copilot suggestion * modernized annotations * type modernizing --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fixed #2040 (#2041) * avoid turning scalars into 0-d arrays in `core.{convert,spectrum}` and `util.utils` (#2039) * `core.convert`: avoid turning scalars into 0-d arrays * `core.spectrum`: avoid turning scalars into 0-d arrays * `util.utils`: avoid turning scalars into 0-d arrays * fix irreproducible mypy error * Waveplot styling (#2044) * style waveplot proxy after steps, not fill * fixed #2042 * updated tests * cleanups in the new waveplot legend code * styling and ruffing * Final polishing on waveplot legend code * improved `dtype_r2c` and `dtype_c2r` typing in `util.utils` (#2043) * Doc check modernizing (#2047) * switched velin to numpydoc lint * configuring numpydoc lint * revising numpydoc configs to avoid hobgoblins * starting to get somewhere with numpydoc linting * fixing exceptions to numpydoc linting * [WIP] Fix failing GitHub Actions job for lint and code analysis (#2048) * Initial plan * Apply remaining changes --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> * working through numpydoc corrections * working through numpydoc corrections * working through numpydoc corrections * fixing numpydoc lint * fixing exceptions to numpydoc linting * numpydoc is all passing --------- Co-authored-by: Copilot <[email protected]> * Contributing and agents update (#2017) * updating contributing guidelines with ai policy * Added agents.md * Fix CONTRIBUTING.md markdown formatting * revising contributing guidelines * integrating comments * formatting * updated contributing guidelines for numpydoc linting * reformat `**/__init__.pyi` re-exports (#2049) * Include str dtype in `ndarray` return type annotations (#2050) * Multichannel db (#2051) * implemented axis targeting for db conversion * db calculation now works properly with target axes * fixed scalar processing for db * added 'auto' mode to db conversion axes inference * fixed regression in amplitude_to_db * fixed regression in amplitude_to_db * copilot reviews * fixing some type annotations * copilot comments * cleaning up tests * pytest nonsense * Fix decorator callable types in `librosa.util.decorators` (#2053) * Improve `ndarray` return types (#2052) * Generic shaped `ndarray` type aliases * Improve `ndarray` return types in `librosa.core` * Improve `ndarray` return types in `librosa.util` * Improve `ndarray` return types in `librosa.beat` * Improve `ndarray` return types in `librosa.display` * Improve `ndarray` return types in `librosa.effect` * Improve `ndarray` return types in `librosa.filters` * Improve `ndarray` return types in `librosa.segment` * Improve `ndarray` return types in `librosa.sequence` * Fix mypy errors with `numpy<2.4` * Ignore false positive mypy error in tests related to `np.object_` array iteration * Address review comments for the typing changes in `util.utils` * Work around a mypy bug where it fails to expand `bool` into `Literal[True] | Literal[False]`. * Support matplotlib 3.11 in tests (#2054) * redoing tests for matplotlib 3.11, tightening tolerance where possible * updated failure artifact upload recipe * loosening tests more on mpl 3.10 * bypassing image comparison tests on 3.10 completely * fixed types for legend in matplotlib 3.11 * Stream resampling (#2055) * initial cut of resampling stream passes previous tests * progress on stream resampling * clarified docstring, reverted changes * updated tests * feature complete stream resampling * refactored tests * better coverage for edge cases * working in some copilot review comments * more copilot suggestions * copilot and gemini comments * cleaning up stream tests * tightening memory allocations in stream * added a future default change decorator and bundled onto stream * forgot to kw-only a parameter name * ratcheting down default stream parameter setting deprecation to 1.1 * last round of copilot reviews * massive simplification of legend_for_axes, fixes #2057 (#2059) * Refactor frequency formatters (#2060) * fixed minor ticking for oct3 modes * numpydoc linting * copilot review comments * copilot review comments * Updating actions (#2065) * updating actions * fixing an out= allocation issue * more warnings cleanup * libsamplerate comes via conda now * upload-artifact update * disable auto-activate * Standardize n_fft parameter docstrings (#2068) * Standardize n_fft parameter docstrings Rebuilt against 1.0.0dev after retargeting. Standardizes the analysis n_fft descriptions on 'length of the FFT window', fixes the bins/window conflations (piptrack, estimate_tuning, filters.mel, filters.chroma, feature.inverse), clarifies istft's frame-length inference, corrects mel_to_stft's documented return shape, and fixes frequency-axis references that assumed 2D input (istft win_length, phase_vocoder hop_length). Incorporates review feedback: 'frame' terminology in get_duration; audio-output functions reference the intermediate STFT without a bins clause. * Use 'frame' terminology for n_fft descriptions Per review: n_fft refers to frame length, not window length, since a window can be shorter than the frame. Swept all standardized n_fft descriptions accordingly. --------- Co-authored-by: Cameron Brooks <[email protected]> * precise dtype annotations in `librosa.beat` (#2069) Co-authored-by: Brian McFee <[email protected]> * Infer n_bins automatically in cqt/vqt (#2066) * added n_bins=None to cqt/vqt * added n_bins=None to cqt/vqt tests * linting * revisions * revisions * one more test * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Added nbins inference to hybrid and pseudo cqt * linting * copypasta * fixed #2071, tightened icqt tests * revised downsampling logic in vqt * copilot review comments --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * Add out= parameter to to_mono for in-place downmixing (#2058) * Add out= buffer parameter to to_mono, to_stereo, to_multi Lets callers pass a pre-allocated output buffer to the mixing functions, avoiding a fresh allocation per call (e.g. per-block downmix in stream()). A shared _init_output helper validates the buffer's shape and dtype against the computed output, zero-fills it, and returns it; out=None preserves the previous allocate-fresh behavior. Implements #2056 against the redesigned 1.0 mixing API. * Remove joblib caching from to_mono/to_stereo/to_multi Per review (#2058): the @cache decorator is incompatible with out=, since a cache hit returns the memoized array and skips writing into the caller's buffer, and hashing an uninitialized out= buffer is costly/non-deterministic. Dropping caching keeps the out= contract simple and correct. * Reuse output buffers in to_stereo/to_multi and stream mono downmix Addresses review feedback on #2058: - to_stereo: downmix directly into the output rows via out=, removing a second allocation. Cast left/right to the shared dtype first so the pass-through buffer always matches to_mono's computed dtype. - to_multi: pass the output row into to_mono when no length adjustment is needed; fall back to allocate-and-fix_length only when lengths differ. - stream: reuse a single mono downmix buffer across blocks, writing the final short block into a truncated view. - Add a mixed-dtype regression test for the downmix pass-through. * Relax out= dtype check to accept higher-precision buffers Per review (#2058): rather than requiring an exact dtype match, accept any out= buffer whose dtype can hold the result without loss of precision (promote_types(out.dtype, dtype) == out.dtype). A caller who explicitly allocates a higher-precision buffer keeps that precision; too-narrow buffers are still rejected. Updated docstrings and added a wider-dtype test. --------- Co-authored-by: Brian McFee <[email protected]> * Fix RQA single-axis inputs (#2063) * Fix RQA single-axis inputs * Update tests/test_sequence.py Work around mypy for test type checks --------- Co-authored-by: Brian McFee <[email protected]> * BoundedNorm for specshow on boolean data (#2072) * added boundednorm for boolean data in specshow * Added tests for boundarynorm boolean specshow --------- Co-authored-by: Joren Hammudoglu <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Ale Lloveras <[email protected]> Co-authored-by: Haydn Lam <[email protected]> Co-authored-by: Emily <[email protected]> Co-authored-by: dhaasb <[email protected]> Co-authored-by: Daniel Fernandes <[email protected]> Co-authored-by: Gopesh Pandey <[email protected]> Co-authored-by: T <[email protected]> Co-authored-by: Terry Chen <[email protected]> Co-authored-by: Petra Kühnle <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: Cameron Brooks <[email protected]> Co-authored-by: ejwong24 <[email protected]> Co-authored-by: Suhas Holla Karkada Chandrashekar <[email protected]>
As promised in #2050, here are a bunch of other typing improvements related to
ndarrayreturn types.There are still (many) other
ndarrayreturn types that could still be improved, but those are all input-dependent in either their shape-type or dtype. So this PR only covers the "absolute" cases where the dtype and/or shape-type of the returnedndarrayis always the same (with a couple of exceptions). I'll leave those input-dependent return types (not to be confused with the type-theoretical"dependent types", which are types that depend on values, and here we're talking about output types depending on input types), as they'll require a bit more effort (generic functions, a.k.a. parametric polymorphism) to tackle, and this PR is already larger than I'm usualy comfortable with haha.
Oh and in case you were wondering why I removed those
[Any]type arguments fornp.floatingand other abstract generic numpy scalar types; those are no longer needed in recent numpy versions (deprecated, even). Without thoseAnys it's also a biteasierless difficult too read IMO.