Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-509: inv_triangle_number -> nfields_from_nspectra (plus make it public) #527

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

Saransh-cpp
Copy link
Member

@Saransh-cpp Saransh-cpp commented Feb 19, 2025

Description

Renamed inv_triangle_number -> nfields_from_nspectra
Made the function public and added it to __all__.

Closes: #509

Changelog entry

Checks

  • Is your code passing linting?
  • Is your code passing tests?
  • Have you added additional tests (if required)?
  • Have you modified/extended the documentation (if required)?
  • Have you added a one-liner changelog entry above (if required)?

@Saransh-cpp Saransh-cpp added maintenance Maintenance: refactoring, typos, etc. api An (incompatible) API change labels Feb 19, 2025
@Saransh-cpp Saransh-cpp self-assigned this Feb 19, 2025
@Saransh-cpp Saransh-cpp marked this pull request as ready for review February 19, 2025 16:53
@paddyroddy
Copy link
Member

Lol I was literally just about to raise a PR

@Saransh-cpp Saransh-cpp added this to the v2025.1 milestone Feb 19, 2025
glass/fields.py Outdated
Comment on lines 30 to 32
r"""
The :math:`n`-th triangle number is :math:`T_n = n \, (n+1)/2`. If
the argument is :math:`T_n`, then :math:`n` is returned. Otherwise,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would update the argument and docstring here to reflect the new function name. Something along the lines of

Returns the number of fields for a number of spectra.

Given the number of spectra nspectra, returns the number of fields n such that n * (n + 1) // 2 == nspectra.

In addition, I would also update the error message:

invalid number of spectra: {nspectra}

That means there's no need to catch and rethrow the error elsewhere in fields.py

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

@Saransh-cpp Saransh-cpp requested a review from ntessore February 20, 2025 11:29
Co-authored-by: Nicolas Tessore <n.tessore@ucl.ac.uk>
@Saransh-cpp
Copy link
Member Author

Thanks for the fixes, @ntessore!

@Saransh-cpp Saransh-cpp requested a review from ntessore February 21, 2025 12:54
@Saransh-cpp Saransh-cpp merged commit 1b407ea into main Feb 21, 2025
16 checks passed
@Saransh-cpp Saransh-cpp deleted the saransh/nfields_from_nspectra branch February 21, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An (incompatible) API change maintenance Maintenance: refactoring, typos, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is inv_triangle_number intended to be public?
3 participants