From d04a4cc8be73c6f4c49a02284bca9139677429de Mon Sep 17 00:00:00 2001 From: nstarman Date: Thu, 11 Jul 2024 12:07:42 -0400 Subject: [PATCH] test: add explanatory comments Signed-off-by: nstarman --- astropy/cosmology/flrw/base.py | 2 +- astropy/cosmology/flrw/tests/test_base.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/astropy/cosmology/flrw/base.py b/astropy/cosmology/flrw/base.py index c066e9ca7630..aa801e84de26 100644 --- a/astropy/cosmology/flrw/base.py +++ b/astropy/cosmology/flrw/base.py @@ -1646,7 +1646,7 @@ def __post_init__(self): super().__post_init__() # Do some twiddling after the fact to get flatness self.__dict__["Ok0"] = 0.0 - object.__setattr__( # managed by a Property + object.__setattr__( # managed by a Parameter self, "_Ode0", 1.0 - (self.Om0 + self.Ogamma0 + self.Onu0 + self.Ok0) ) diff --git a/astropy/cosmology/flrw/tests/test_base.py b/astropy/cosmology/flrw/tests/test_base.py index d61d8b311efe..c6baba99189e 100644 --- a/astropy/cosmology/flrw/tests/test_base.py +++ b/astropy/cosmology/flrw/tests/test_base.py @@ -1100,13 +1100,15 @@ def test_is_equivalent(self, cosmo, nonflatcosmo): assert not nonflat.is_equivalent(cosmo) assert not cosmo.is_equivalent(nonflat) - # flat, but not FlatFLRWMixin + # Flat, but not FlatFLRWMixin + # Shis will require forching flatness by overriding attribute values. + # Since Cosmology is frozen, the easiest way is via __dict__. flat = nonflat_cosmo_cls( *self.cls_args, Ode0=1.0 - cosmo.Om0 - cosmo.Ogamma0 - cosmo.Onu0, **self.cls_kwargs, ) - flat.__dict__["Ok0"] = 0.0 + flat.__dict__["Ok0"] = 0.0 # manually forcing flatness by setting `Ok0`. assert flat.is_equivalent(cosmo) assert cosmo.is_equivalent(flat)