Skip to content

Accept NumPy integer smoothing widths#1336

Draft
sapunyangkut wants to merge 1 commit into
astropy:mainfrom
sapunyangkut:codex/accept-numpy-smoothing-widths
Draft

Accept NumPy integer smoothing widths#1336
sapunyangkut wants to merge 1 commit into
astropy:mainfrom
sapunyangkut:codex/accept-numpy-smoothing-widths

Conversation

@sapunyangkut

Copy link
Copy Markdown

Summary

  • accept NumPy integer values in the four smoothing width parameters
  • keep rejecting non-real and non-positive values
  • add a shared regression test and the required changelog entry

Root cause

The four smoothing entry points each limited valid widths to the built-in int and float types. Values produced by APIs such as np.arange, including np.int64, are real numbers accepted by the downstream Astropy and SciPy operations but failed those duplicated checks.

Using the standard-library numbers.Real protocol fixes the common type gate without accepting complex values.

Validation

  • regression test against the unmodified base: 4 failures, one for each smoothing function
  • tox -e codestyle: passed, 0 errors
  • Python 3.12 specutils/tests/test_smoothing.py: 28 passed
  • Python 3.13 full package and documentation suite: 598 passed, 137 skipped, 3 xfailed

The standard Python 3.13 tox command encountered a Windows permission error while finalizing pytest's cache. I reran the same installed environment and full test scope with the cache plugin disabled and MPLBACKEND=agg; all tests passed as reported above.

AI assistance

This fix was prepared with OpenAI Codex-assisted automation. I reviewed and understand the complete diff, reproduced the failure before the fix, ran the validation above, and take responsibility for the correctness and licensing of the contribution.

Fixes #1224.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

specutils.manipulation gaussian_smooth does not work on numpy.int64 input stddev

1 participant