Skip to content

Commit

Permalink
test: add explanatory comments
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman committed Jul 11, 2024
1 parent 963440c commit d04a4cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion astropy/cosmology/flrw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down
6 changes: 4 additions & 2 deletions astropy/cosmology/flrw/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d04a4cc

Please sign in to comment.