Skip to content

Commit

Permalink
gh-441: import directly from glass in tests (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy authored Nov 21, 2024
1 parent 09b14bd commit d5f4fd8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 0 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

@pytest.fixture(scope="session")
def rng() -> np.random.Generator:
import numpy as np

return np.random.default_rng(seed=42)
2 changes: 1 addition & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from glass.fields import getcl
from glass import getcl


def test_getcl() -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy.typing as npt
import pytest

from glass import user
from glass import write_catalog

# check if fitsio is available for testing
HAVE_FITSIO = importlib.util.find_spec("fitsio") is not None
Expand Down Expand Up @@ -37,7 +37,7 @@ def _test_append(
hdu.write(data, names=names, firstrow=hdu.get_nrows())

with (
user.write_catalog(tmp_path / filename_gfits, ext="CATALOG") as out,
write_catalog(tmp_path / filename_gfits, ext="CATALOG") as out,
fitsio.FITS(tmp_path / filename_tfits, "rw", clobber=True) as my_fits,
):
for i in range(my_max):
Expand Down Expand Up @@ -80,7 +80,7 @@ def raise_error(msg: str) -> None:
raise TestWriteError(msg)

try:
with user.write_catalog(tmp_path / filename, ext="CATALOG") as out:
with write_catalog(tmp_path / filename, ext="CATALOG") as out:
for i in range(my_max):
if i == except_int:
msg = "Unhandled exception"
Expand Down
7 changes: 6 additions & 1 deletion tests/test_galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import pytest
import pytest_mock

from glass.galaxies import galaxy_shear, gaussian_phz, redshifts, redshifts_from_nz
from glass import (
galaxy_shear,
gaussian_phz,
redshifts,
redshifts_from_nz,
)


def test_redshifts(mocker: pytest_mock.MockerFixture) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import numpy.typing as npt
import pytest

from glass.lensing import (
from glass import (
MultiPlaneConvergence,
RadialWindow,
deflect,
multi_plane_matrix,
multi_plane_weights,
)
from glass.shells import RadialWindow

if typing.TYPE_CHECKING:
from cosmology import Cosmology
Expand Down
2 changes: 1 addition & 1 deletion tests/test_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy.typing as npt
import pytest

from glass.points import (
from glass import (
effective_bias,
linear_bias,
loglinear_bias,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_shapes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from glass.shapes import (
from glass import (
ellipticity_gaussian,
ellipticity_intnorm,
ellipticity_ryden04,
Expand Down
7 changes: 6 additions & 1 deletion tests/test_shells.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import numpy as np
import pytest

from glass.shells import RadialWindow, partition, restrict, tophat_windows
from glass import (
RadialWindow,
partition,
restrict,
tophat_windows,
)


def test_tophat_windows() -> None:
Expand Down

0 comments on commit d5f4fd8

Please sign in to comment.