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
Cosmology property is_flat
#12606
Cosmology property is_flat
#12606
Conversation
👋 Thank you for your draft pull request! Do you know that you can use |
91eea98
to
817fed8
Compare
I still need to add a what's-new and update some doc, but the code is ready to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except I would perhaps suggest not to make it an abstract property; it just seems to add quite a bit of boilerplate, especially calling super
just to get NotImplementedError
back again. It also makes for a real API break - user-defined classes now have to change. (I've more generally found the concept of these abstract methods a bit less useful than I thought initially; I've not see a clear win with it.)
But really only a suggestion - if you think this is not a real problem, that's fine too.
@@ -77,6 +77,10 @@ def __init__(self, H0, Tcmb0=0*u.K, m_nu=0*u.eV, name=None, meta=None): | |||
self.Tcmb0 = Tcmb0 | |||
self.m_nu = m_nu | |||
|
|||
@property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me wonder a little whether the abstractproperty
really is all that useful.
It does add a bit of boilerplate, but crucially all that boilerplate is in the test code. I cannot find on GH any example of someone directly subclassing
I think I'll keep it as is. Thanks again for the detailed and quick review! |
Done. Added a what's-new. |
817fed8
to
7bd9e5c
Compare
7bd9e5c
to
635e928
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) nstarkman@protonmail.com
Description
Add property
is_flat
to cosmologies to verify the curvature of the Universe.It's abstract on
Cosmology
, making it abstract (finally).On
FLRW
it checksOk0
andOtot0
.On subclassess of
FlatCosmologyMixin
it's justTrue
.Flatness is a subtle thing. On FLRW cosmologies it's simple, but not in general. So it's abstract on
Cosmology
.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label. If this is a manual backport, use theskip-changelog-checks
label unless special changelog handling is necessary.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.