Skip to content

cosmo: Hubble parameter trait - #18271

Merged
nstarman merged 21 commits into
astropy:mainfrom
preshanth:cosmo-Hubbleparameter
Jun 26, 2025
Merged

nstarman merged 21 commits into
astropy:mainfrom
preshanth:cosmo-Hubbleparameter

Conversation

@preshanth

Copy link
Copy Markdown
Contributor

Description

This pull request is to address the introduction of hubble parameter as a trait in the FLRW cosmology class.

Fixes a portion of #17150

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@preshanth
preshanth requested a review from a team as a code owner June 13, 2025 21:42
@preshanth
preshanth requested a review from nstarman June 13, 2025 21:42
@github-actions

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.

@preshanth

Copy link
Copy Markdown
Contributor Author

@nstarman Have a look at this when you get a chance.

@preshanth
preshanth marked this pull request as draft June 13, 2025 21:59
@preshanth

Copy link
Copy Markdown
Contributor Author

I will fix the tests first tonight

@nstarman nstarman 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.

Thanks @preshanth!
I think starting with _HubbleParameter as a private class is the right way to start.

Comment thread astropy/cosmology/_src/flrw/base.py Resolved
Comment thread astropy/cosmology/_src/traits/hubble.py Resolved
Comment thread astropy/cosmology/_src/traits/hubble.py Resolved
@preshanth

Copy link
Copy Markdown
Contributor Author

@nstarman I think this covers yours suggestions. If you are fine with it I will push some edits for the docs and then this can be converted from draft to PR.

@pllim pllim added this to the v7.2.0 milestone Jun 17, 2025
@nstarman nstarman changed the title Initial commit for hubble parameter trait cosmo: Hubble parameter trait Jun 17, 2025
Comment thread astropy/cosmology/_src/flrw/base.py Resolved
Comment thread astropy/cosmology/_src/traits/hubble.py Resolved
@nstarman nstarman moved this from Triage to In Progress in Cosmology, the Expansion Jun 17, 2025
Comment thread docs/cosmology/traits.rst Resolved
@preshanth
preshanth marked this pull request as ready for review June 17, 2025 16:36
@preshanth

Copy link
Copy Markdown
Contributor Author

@nstarman I can pick up the next one now that I am warmed up and if you are happy with this.

@nstarman nstarman 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.

@preshanth I think this PR is close. The H method needs to be removed from FLRW so that it uses the HubbleParameter.H method that it inherits.

@github-project-automation github-project-automation Bot moved this from In Progress to Review in progress in Cosmology, the Expansion Jun 19, 2025
@preshanth
preshanth requested a review from nstarman June 19, 2025 23:25
@preshanth

Copy link
Copy Markdown
Contributor Author

I wonder if we have to add tests directly using traits to ensure that the code coverage does not drop.

Comment thread docs/cosmology/traits.rst Resolved
Comment thread docs/cosmology/traits.rst Resolved
Comment thread docs/cosmology/traits.rst Resolved
Comment thread docs/whatsnew/7.2.rst Resolved
Comment thread docs/cosmology/traits.rst Resolved
Comment thread docs/cosmology/traits.rst Resolved
@preshanth

Copy link
Copy Markdown
Contributor Author

Sorry this is taking forever. Its a good template for me. Thanks for your efforts @nstarman

@nstarman

Copy link
Copy Markdown
Member

@preshanth the CI is picking up an issue in the docs.

_____________________________ [doctest] traits.rst _____________________________
[gw3] linux -- Python 3.11.13 /home/runner/work/astropy/astropy/.tox/py311-test-double/bin/python3
037 ...
038 ...     is_flat = False
039 ...     # Additional custom methods and properties can be added here
040 
041 >>> cosmo = CustomCosmology(H0=70, Om0=0.3, Ode0=0.7)
042 >>> cosmo.H0
043 <Quantity 70. km / (Mpc s)>
044 >>> cosmo.scale_factor(0)
045 <Quantity 1.>
046 >>> cosmo.Tcmb(1)
Expected:
    <Quantity 5.45>
Got:
    <Quantity 5.45 K>

/home/runner/work/astropy/astropy/docs/cosmology/traits.rst:46: DocTestFailure
______________________________ [doctest] 7.2.rst _______________________________
[gw3] linux -- Python 3.11.13 /home/runner/work/astropy/astropy/.tox/py311-test-double/bin/python3
058 ...
059 ...     is_flat = False
060 ...     # Additional custom methods and properties can be added here
061 
062 >>> cosmo = CustomCosmology(H0=70, Om0=0.3, Ode0=0.7)
063 >>> cosmo.H0
064 <Quantity 70. km / (Mpc s)>
065 >>> cosmo.scale_factor(0)
066 <Quantity 1.>
067 >>> cosmo.Tcmb(1)
Expected:
    <Quantity 5.45>
Got:
    <Quantity 5.45 K>

/home/runner/work/astropy/astropy/docs/whatsnew/7.2.rst:67: DocTestFailure
_____________________________ [doctest] traits.rst _____________________________
[gw0] linux -- Python 3.11.13 /home/runner/work/astropy/astropy/.tox/py311-test-double/bin/python3
037 ...
038 ...     is_flat = False
039 ...     # Additional custom methods and properties can be added here
040 
041 >>> cosmo = CustomCosmology(H0=70, Om0=0.3, Ode0=0.7)
042 >>> cosmo.H0
043 <Quantity 70. km / (Mpc s)>
044 >>> cosmo.scale_factor(0)
045 <Quantity 1.>
046 >>> cosmo.Tcmb(1)
Expected:
    <Quantity 5.45>
Got:
    <Quantity 5.45 K>

/home/runner/work/astropy/astropy/docs/cosmology/traits.rst:46: DocTestFailure
______________________________ [doctest] 7.2.rst _______________________________
[gw3] linux -- Python 3.11.13 /home/runner/work/astropy/astropy/.tox/py311-test-double/bin/python3
058 ...
059 ...     is_flat = False
060 ...     # Additional custom methods and properties can be added here
061 
062 >>> cosmo = CustomCosmology(H0=70, Om0=0.3, Ode0=0.7)
063 >>> cosmo.H0
064 <Quantity 70. km / (Mpc s)>
065 >>> cosmo.scale_factor(0)
066 <Quantity 1.>
067 >>> cosmo.Tcmb(1)
Expected:
    <Quantity 5.45>
Got:
    <Quantity 5.45 K>

@preshanth

Copy link
Copy Markdown
Contributor Author

On it.

@nstarman

Copy link
Copy Markdown
Member

@preshanth because of squash-merging it's not a big deal, but in general we prefer to do rebasing rather than merging to update a PR, e.g. c426c39. Just a PSA :).

@preshanth

preshanth commented Jun 26, 2025 •

Copy link
Copy Markdown
Contributor Author

@preshanth because of squash-merging it's not a big deal, but in general we prefer to do rebasing rather than merging to update a PR, e.g. c426c39. Just a PSA :).

This makes my master diverge from the main right. That throws me off. I can give it a shot next time.

@nstarman

Copy link
Copy Markdown
Member

One more docs failure. Same thing in 7.2.rst

@preshanth

Copy link
Copy Markdown
Contributor Author

@nstarman I finally got all the docs right. The rest should pass.

@nstarman nstarman 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.

Thanks @preshanth for the PR! Looks great. Let's get this in.

@github-project-automation github-project-automation Bot moved this from Review in progress to Reviewer approved in Cosmology, the Expansion Jun 26, 2025
@nstarman
nstarman merged commit 9d15746 into astropy:main Jun 26, 2025
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in Cosmology, the Expansion Jun 26, 2025
@preshanth
preshanth deleted the cosmo-Hubbleparameter branch June 26, 2025 04:09
@nstarman nstarman mentioned this pull request Oct 23, 2025
12 of 22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants