Skip to content

Commit

Permalink
Fix more typing
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Oct 17, 2024
1 parent 42cb3b8 commit 8f4f79f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions glass/galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def gaussian_phz(


def kappa_ia_nla( # noqa: PLR0913
delta: npt.NDArray[typing.Any],
delta: npt.NDArray[np.float64],
zeff: float,
a_ia: float,
cosmo: Cosmology,
Expand All @@ -306,7 +306,7 @@ def kappa_ia_nla( # noqa: PLR0913
lbar: float = 0.0,
l0: float = 1e-9,
beta: float = 0.0,
) -> npt.NDArray[typing.Any]:
) -> npt.NDArray[np.float64]:
r"""
Effective convergence from intrinsic alignments using the NLA model.
Expand Down
3 changes: 2 additions & 1 deletion glass/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

if typing.TYPE_CHECKING:
import collections.abc
import pathlib


def save_cls(filename: str, cls: list[npt.NDArray[np.float64] | None]) -> None:
Expand Down Expand Up @@ -106,7 +107,7 @@ def write(

@contextmanager
def write_catalog(
filename: str,
filename: pathlib.Path,
*,
ext: str | None = None,
) -> collections.abc.Generator[_FitsWriter]:
Expand Down
13 changes: 6 additions & 7 deletions tests/test_fits.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import importlib.util
import os
import pathlib

import numpy as np
Expand Down Expand Up @@ -28,15 +27,15 @@ def _test_append(fits, data, names) -> None: # type: ignore[no-untyped-def]


@pytest.mark.skipif(not HAVE_FITSIO, reason="test requires fitsio")
def test_basic_write(tmp_path: os.PathLike[str]) -> None:
def test_basic_write(tmp_path: pathlib.Path) -> None:
import fitsio

filename_gfits = "gfits.fits" # what GLASS creates
filename_tfits = "tfits.fits" # file created on the fly to test against

with (
user.write_catalog(tmp_path / filename_gfits, ext="CATALOG") as out, # type: ignore[operator]
fitsio.FITS(tmp_path / filename_tfits, "rw", clobber=True) as my_fits, # type: ignore[operator]
user.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):
array = np.arange(i, i + 1, delta) # array of size 1/delta
Expand All @@ -47,8 +46,8 @@ def test_basic_write(tmp_path: os.PathLike[str]) -> None:
_test_append(my_fits, arrays, names)

with (
fitsio.FITS(tmp_path / filename_gfits) as g_fits, # type: ignore[operator]
fitsio.FITS(tmp_path / filename_tfits) as t_fits, # type: ignore[operator]
fitsio.FITS(tmp_path / filename_gfits) as g_fits,
fitsio.FITS(tmp_path / filename_tfits) as t_fits,
):
glass_data = g_fits[1].read()
test_data = t_fits[1].read()
Expand All @@ -59,7 +58,7 @@ def test_basic_write(tmp_path: os.PathLike[str]) -> None:
@pytest.mark.skipif(not HAVE_FITSIO, reason="test requires fitsio")
def test_write_exception(tmp_path: pathlib.Path) -> None:
try:
with user.write_catalog(tmp_path / filename, ext="CATALOG") as out: # type: ignore[arg-type]
with user.write_catalog(tmp_path / filename, ext="CATALOG") as out:
for i in range(my_max):
if i == except_int:
msg = "Unhandled exception"
Expand Down

0 comments on commit 8f4f79f

Please sign in to comment.