Skip to content

Commit

Permalink
Merge branch 'paddy/issue-358' into saransh/test_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy authored Nov 6, 2024
2 parents 1c1b541 + 0afdd0e commit f7a7090
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 24 deletions.
1 change: 0 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ b42067f6776dcd763827000d585a88e071b78af3
f9bac62f497a7288aa71fd4dbd948945c37f854e
# applied ruff-linting - https://github.com/glass-dev/glass/pull/232
e58d8616c03b8447aba90996905a98b42f18ba0a
# added static typing - https://github.com/glass-dev/glass/pull/368
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ jobs:
- name: Install nox and coverage.py
run: python -m pip install coverage[toml] nox

- name: Install ubuntu dependencies for fitsio
run: |-
sudo apt-get update
sudo apt-get install -y libbz2-dev
- name: Run doctests
run: nox -s doctests-${{ matrix.python-version }} --verbose
env:
Expand Down
2 changes: 1 addition & 1 deletion glass/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def trapz_product(
y = np.interp(x, *f)
for f_ in ff:
y *= np.interp(x, *f_)
return np.trapz( # type: ignore[attr-defined]
return np.trapz( # type: ignore[attr-defined, no-any-return]
y,
x,
axis=axis,
Expand Down
2 changes: 1 addition & 1 deletion glass/galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,4 @@ def kappa_ia_nla( # noqa: PLR0913
prefactor * inverse_linear_growth * redshift_dependence * luminosity_dependence
)

return delta * f_nla
return delta * f_nla # type: ignore[no-any-return]
4 changes: 2 additions & 2 deletions glass/lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def shear_from_convergence(
hp.almxfl(alm, fl, inplace=True)

# transform to shear maps
return hp.alm2map_spin([alm, blm], nside, 2, lmax)
return hp.alm2map_spin([alm, blm], nside, 2, lmax) # type: ignore[no-any-return]


class MultiPlaneConvergence:
Expand Down Expand Up @@ -423,7 +423,7 @@ def multi_plane_weights(
weights = weights / np.sum(weights, axis=0)
# combine weights and the matrix of lensing contributions
mat = multi_plane_matrix(shells, cosmo)
return np.matmul(mat.T, weights)
return np.matmul(mat.T, weights) # type: ignore[no-any-return]


def deflect(
Expand Down
8 changes: 4 additions & 4 deletions glass/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def vmap_galactic_ecliptic(
m[hp.query_strip(nside, *galactic)] = 0
m = hp.Rotator(coord="GC").rotate_map_pixel(m)
m[hp.query_strip(nside, *ecliptic)] = 0
return hp.Rotator(coord="CE").rotate_map_pixel(m)
return hp.Rotator(coord="CE").rotate_map_pixel(m) # type: ignore[no-any-return]


def gaussian_nz(
Expand Down Expand Up @@ -123,7 +123,7 @@ def gaussian_nz(
if norm is not None:
nz *= norm

return nz
return nz # type: ignore[no-any-return]


def smail_nz(
Expand Down Expand Up @@ -186,7 +186,7 @@ def smail_nz(
if norm is not None:
pz *= norm

return pz
return pz # type: ignore[no-any-return]


def fixed_zbins(
Expand Down Expand Up @@ -323,4 +323,4 @@ def tomo_nz_gausserr(
binned_nz /= 1 + erf(z / sz)
binned_nz *= nz

return binned_nz
return binned_nz # type: ignore[no-any-return]
2 changes: 1 addition & 1 deletion glass/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def effective_bias(
w.wa,
w.za,
)
return trapz_product((z, bz), (w.za, w.wa)) / norm
return trapz_product((z, bz), (w.za, w.wa)) / norm # type: ignore[no-any-return]


def linear_bias(
Expand Down
4 changes: 2 additions & 2 deletions glass/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def triaxial_axis_ratio(
C = 1 + z2m1 * cos2_phi # noqa: N806

# eq. (12)
return np.sqrt(
return np.sqrt( # type: ignore[no-any-return]
(A + C - np.sqrt((A - C) ** 2 + B2)) / (A + C + np.sqrt((A - C) ** 2 + B2)),
)

Expand Down Expand Up @@ -174,7 +174,7 @@ def ellipticity_ryden04( # noqa: PLR0913
e *= (1 - q) / (1 + q)

# return the ellipticity
return e
return e # type: ignore[no-any-return]


def ellipticity_gaussian(
Expand Down
12 changes: 6 additions & 6 deletions glass/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ def distance_weight(
cosmo: Cosmology,
) -> npt.NDArray[np.float64]:
"""Uniform weight in comoving distance."""
return 1 / cosmo.ef(z)
return 1 / cosmo.ef(z) # type: ignore[no-any-return]


def volume_weight(
z: npt.NDArray[np.float64],
cosmo: Cosmology,
) -> npt.NDArray[np.float64]:
"""Uniform weight in comoving volume."""
return cosmo.xm(z) ** 2 / cosmo.ef(z)
return cosmo.xm(z) ** 2 / cosmo.ef(z) # type: ignore[no-any-return]


def density_weight(
z: npt.NDArray[np.float64],
cosmo: Cosmology,
) -> npt.NDArray[np.float64]:
"""Uniform weight in matter density."""
return cosmo.rho_m_z(z) * cosmo.xm(z) ** 2 / cosmo.ef(z)
return cosmo.rho_m_z(z) * cosmo.xm(z) ** 2 / cosmo.ef(z) # type: ignore[no-any-return]


class RadialWindow(typing.NamedTuple):
Expand Down Expand Up @@ -474,7 +474,7 @@ def partition(
except KeyError:
msg = f"invalid method: {method}"
raise ValueError(msg) from None
return partition_method(z, fz, shells)
return partition_method(z, fz, shells) # type: ignore[no-any-return]


def partition_lstsq(
Expand Down Expand Up @@ -681,7 +681,7 @@ def distance_grid(
else:
msg = 'exactly one of "dx" or "num" must be given'
raise ValueError(msg)
return cosmo.dc_inv(x)
return cosmo.dc_inv(x) # type: ignore[no-any-return]


def combine(
Expand Down Expand Up @@ -718,7 +718,7 @@ def combine(
Find weights for a given function.
"""
return np.sum(
return np.sum( # type: ignore[no-any-return]
[
np.expand_dims(weight, -1)
* np.interp(
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ plugins = [
"numpy.typing.mypy_plugin",
]
strict = true
warn_return_any = false
warn_unreachable = true

[tool.pytest.ini_options]
Expand Down

0 comments on commit f7a7090

Please sign in to comment.