-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REVERT: no longer directly subclass astropy to avoid units issues (#21)
* REVERT: no longer directly subclass astropy to avoid units issues * TEST: make astropy jit test more sensible
- Loading branch information
1 parent
4ee193c
commit b423d82
Showing
2 changed files
with
187 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
import pytest | ||
|
||
|
||
def test_astropy_cosmology_not_clobbered(): | ||
"""See https://github.com/ColmTalbot/wcosmo/issues/15""" | ||
import astropy.cosmology | ||
|
||
import wcosmo.astropy | ||
|
||
assert "wcosmo" not in astropy.cosmology.Planck15.__module__ | ||
|
||
|
||
def test_jits(): | ||
pytest.importorskip("jax") | ||
import gwpopulation | ||
from astropy.cosmology import FlatLambdaCDM | ||
from jax import jit | ||
|
||
import wcosmo | ||
from wcosmo.astropy import FlatwCDM | ||
from wcosmo.utils import disable_units | ||
|
||
@jit | ||
def test_func(h0): | ||
cosmo = FlatwCDM(h0, 0.1, -1) | ||
return cosmo.luminosity_distance(0.1) | ||
|
||
gwpopulation.set_backend("jax") | ||
disable_units() | ||
|
||
assert ( | ||
abs( | ||
float(test_func(67.0)) | ||
- FlatLambdaCDM(67.0, 0.1).luminosity_distance(0.1).value | ||
) | ||
< 1 | ||
) |