Skip to content

Document the parameters multiband periodic_fit actually takes - #20212

Open
darkdi wants to merge 7 commits into
astropy:mainfrom
darkdi:fix/multiband-periodic-fit-docstring
Open

darkdi wants to merge 7 commits into
astropy:mainfrom
darkdi:fix/multiband-periodic-fit-docstring

Conversation

@darkdi

@darkdi darkdi commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #20207.

The multiband periodic_fit carried the single-band docstring: it documented nterms, which this function does not take, and left six real parameters undescribed — bands_fit, nterms_base, nterms_band, reg_base, reg_band, regularize_by_trace.

Following @dougbrn's suggestion in the issue, the wording comes from LombScargleMultiband in lombscargle_multiband/core.py, and bands_fit uses the phrasing already used elsewhere in the submodule:

bands_fit : array-like, or str
Bands to use in fitting, must be subset of bands in input data.

The entries are ordered to match the signature.

Docstring only — no signature, call site, or behaviour is touched.

AI assistance

Per the astropy AI policy: the mismatch was surfaced by a sweep comparing numpydoc parameter names against the actual signature, run with Claude in Claude Code. I read the signature and the source docstring in core.py by hand before writing the entries, and the descriptions are copied from the project's own wording rather than invented.

The docstring still described the single-band signature: it listed nterms,
which does not exist here, and omitted bands_fit, nterms_base, nterms_band,
reg_base, reg_band and regularize_by_trace.

Wording taken from LombScargleMultiband, as suggested in the issue.
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@pllim pllim added this to the v7.2.3 milestone Aug 5, 2026
@pllim pllim added Docs Bug no-changelog-entry-needed backport-v7.2.x on-merge: backport to v7.2.x backport-v8.0.x on-merge: backport to v8.0.x labels Aug 5, 2026
Comment thread docs/changes/timeseries/20212.other.rst Resolved
@darkdi

darkdi commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Both done — formatting aligned with the rest of the section, and the change log fragment removed.

On the fragment: I added it because the towncrier check was failing, before I noticed you had already applied no-changelog-entry-needed. Removing it is what actually satisfies the check. My mistake.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also fix the grammar in new text, e.g., capitalization and so on. Thanks.

@darkdi

darkdi commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Done, and the comma in the type line went with it. I had missed that suggestion when I pushed the capitalization fix.

@dhomeier dhomeier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bands_fit must be array-like, and in fact I believe bands needs to be passed as list of strings when not an array.
The rests corresponds directly to LombScargleMultiband parameters and thus should be fine.

Comment on lines +88 to +89
bands_fit : array-like or str
Bands to use in the fit, must be a subset of the bands in the input data

@dhomeier dhomeier Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bands_fit : array-like or str
Bands to use in the fit, must be a subset of the bands in the input data
bands_fit : array-like
The unique bands to use in the fit, must be a subset of the bands in the input data

This cannot work with str (see e.g. bands_fit[:, np.newaxis] operation below).
The call from LombScargleMultiband.model() uses "list or array-like", but I don't see how it could work with a plain list either.
BTW it looks like the same should hold for bands above, which is called with LombScargleMultiband.bands (but then processed as np.asarray()).

@dhomeier dhomeier Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougbrn if I read the tests right, they are passing np.array(['a', 'aa', 'aaa', ...]) as bands, so that should probably indeed not be a single string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, and the str was mine from the first draft. Line 99 does bands_fit[:, np.newaxis], which a plain string will not survive, so the type was wrong no matter what the caller docs say. Applied your wording.

@darkdi

darkdi commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Took bands too. Same story a bit further down, design_matrix does mask = bands == band and then indexes with it, so a lone string collapses the mask to a scalar and never survives. The np.asarray() on the way in does not rescue it either, a 0-d array indexes just as badly.

Left the description as it was, that part reads fine.

@dhomeier

Copy link
Copy Markdown
Contributor

Thanks for checking! Even if np.asarray(str) had slipped through some of the way, it would have been quite misleading in my feeling. At least I would have expected something like "UBVRI" passed to bands to be interpreted as the 5 Johnson filters rather than a single band named "UBVRI".

@darkdi

darkdi commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Agreed. The docstring says arrays for both now, so there is not much room left to read it the other way.

Everything from your review is in as of yesterday, so this one is only waiting on a re-review.

@darkdi

darkdi commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@dhomeier gentle ping on this one, I think everything from your review is in

@astrofrog astrofrog modified the milestones: v7.2.3, v7.2.4 Oct 16, 2026

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiband periodic_fit documents nterms, but takes nterms_base and nterms_band

4 participants