Skip to content

Commit 050562e

Browse files
authored
Merge branch 'main' into padd/issue-998
2 parents acb8ba7 + aa0e3ef commit 050562e

31 files changed

+210
-155
lines changed

.github/ISSUE_TEMPLATE/documentation.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ body:
1616
attributes:
1717
label: What Can be Improved About This Section
1818
description: Is it incomplete, incorrect or difficult to understand?
19-
validations:
20-
required: true
2119
- id: suggestions
2220
type: textarea
2321
attributes:

.pre-commit-config.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ci:
44
autofix_prs: false
55
autoupdate_commit_msg: "pre-commit.ci: update pre-commit hooks"
66
autoupdate_schedule: monthly
7+
skip:
8+
- ty
79

810
exclude: ^uv.lock$
911
repos:
@@ -74,14 +76,15 @@ repos:
7476
rev: v1.7.10
7577
hooks:
7678
- id: actionlint
77-
- repo: https://github.com/pre-commit/mirrors-mypy
78-
rev: v1.19.1
79+
- repo: local
7980
hooks:
80-
- id: mypy
81-
additional_dependencies:
82-
- array-api-strict~=2.4.1
83-
- jaxtyping~=0.3.4
84-
- numpy~=2.2.6
81+
- id: ty
82+
entry: uv run ty check
83+
language: python
84+
name: ty-check
85+
pass_filenames: true
86+
types:
87+
- python
8588
- repo: https://github.com/kynan/nbstripout
8689
rev: 0.8.2
8790
hooks:

docs/modules/healpix.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.. module:: glass.healpix
2+
3+
:mod:`glass.healpix` --- Array API compatible HEALPix functions
4+
===============================================================
5+
6+
.. currentmodule:: glass.healpix
7+
8+
This module contains functions for working with HEALPix maps in an Array API
9+
compliant manner used with GLASS.
10+
11+
This module should be imported manually if used outside of GLASS::
12+
13+
import glass.healpix as hp
14+
15+
``healpix`` Functions
16+
---------------------
17+
18+
.. autofunction:: ang2pix
19+
.. autofunction:: ang2vec
20+
.. autofunction:: npix2nside
21+
.. autofunction:: nside2npix
22+
.. autofunction:: randang
23+
24+
``healpy`` Functions
25+
--------------------
26+
27+
.. autofunction:: alm2map
28+
.. autofunction:: alm2map_spin
29+
.. autofunction:: almxfl
30+
.. autofunction:: get_nside
31+
.. autofunction:: map2alm
32+
.. autofunction:: pixwin
33+
.. autofunction:: query_strip
34+
.. automethod:: Rotator.rotate_map_pixel

docs/modules/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Modules
99
arraytools
1010
grf
1111
harmonics
12+
healpix

glass/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"glass_to_healpix_spectra",
4242
"grf",
4343
"harmonics",
44+
"healpix",
4445
"healpix_to_glass_spectra",
4546
"iternorm",
4647
"linear_bias",
@@ -79,7 +80,7 @@
7980
from ._version import __version__
8081

8182
# modules
82-
from glass import algorithm, arraytools, grf, harmonics
83+
from glass import algorithm, arraytools, grf, harmonics, healpix
8384
from glass.fields import (
8485
check_posdef_spectra,
8586
cls2cov,

glass/_array_api_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def linalg_lstsq(
315315
xp = array_api_compat.array_namespace(a, b, use_compat=False)
316316

317317
if xp.__name__ in {"numpy", "jax.numpy"}:
318-
return xp.linalg.lstsq(a, b, rcond=rcond) # type: ignore[no-any-return]
318+
return xp.linalg.lstsq(a, b, rcond=rcond)
319319

320320
if xp.__name__ == "array_api_strict":
321321
np = import_numpy(xp.__name__)
@@ -471,13 +471,13 @@ def vectorize(
471471
472472
"""
473473
if xp.__name__ == "numpy":
474-
return xp.vectorize(pyfunc, otypes=otypes) # type: ignore[no-any-return]
474+
return xp.vectorize(pyfunc, otypes=otypes)
475475

476476
if xp.__name__ in {"array_api_strict", "jax.numpy"}:
477477
# Import here to prevent users relying on numpy unless in this instance
478478
np = import_numpy(xp.__name__)
479479

480-
return np.vectorize(pyfunc, otypes=otypes) # type: ignore[no-any-return]
480+
return np.vectorize(pyfunc, otypes=otypes)
481481

482482
msg = "the array backend in not supported"
483483
raise NotImplementedError(msg)
@@ -568,11 +568,11 @@ def ndindex(shape: tuple[int, ...], *, xp: ModuleType) -> np.ndindex:
568568
569569
"""
570570
if xp.__name__ == "numpy":
571-
return xp.ndindex(shape) # type: ignore[no-any-return]
571+
return xp.ndindex(shape)
572572

573573
if xp.__name__ in {"array_api_strict", "jax.numpy"}:
574574
np = import_numpy(xp.__name__)
575-
return np.ndindex(shape) # type: ignore[no-any-return]
575+
return np.ndindex(shape)
576576

577577
msg = "the array backend in not supported"
578578
raise NotImplementedError(msg)
@@ -607,7 +607,7 @@ def tril_indices(
607607
608608
"""
609609
if xp.__name__ in {"numpy", "jax.numpy"}:
610-
return xp.tril_indices(n, k=k, m=m) # type: ignore[no-any-return]
610+
return xp.tril_indices(n, k=k, m=m)
611611

612612
if xp.__name__ == "array_api_strict":
613613
np = import_numpy(xp.__name__)

glass/_rng.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def rng_dispatcher(*, xp: ModuleType) -> UnifiedGenerator:
4646
return glass.jax.Generator(seed=SEED)
4747

4848
if xp.__name__ == "numpy":
49-
return xp.random.default_rng(seed=SEED) # type: ignore[no-any-return]
49+
return xp.random.default_rng(seed=SEED)
5050

5151
if xp.__name__ == "array_api_strict":
5252
return Generator(seed=SEED)
@@ -111,7 +111,7 @@ def random(
111111
112112
"""
113113
dtype = dtype if dtype is not None else self.np.float64
114-
return self.ap.asarray(self.rng.random(size, dtype, out)) # type: ignore[arg-type]
114+
return self.ap.asarray(self.rng.random(size, dtype, out)) # ty: ignore[no-matching-overload]
115115

116116
def normal(
117117
self,
@@ -184,7 +184,7 @@ def standard_normal(
184184
185185
"""
186186
dtype = dtype if dtype is not None else self.np.float64
187-
return self.ap.asarray(self.rng.standard_normal(size, dtype, out)) # type: ignore[arg-type]
187+
return self.ap.asarray(self.rng.standard_normal(size, dtype, out)) # ty: ignore[no-matching-overload]
188188

189189
def uniform(
190190
self,

glass/algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def nnls(
9999
q = xpx.at(q)[x <= 0].set(False)
100100
x = xpx.at(x)[q].set(sq)
101101
x = xpx.at(x)[~q].set(0)
102-
return x
102+
return x # ty: ignore[invalid-return-type]
103103

104104

105105
def cov_clip(

glass/arraytools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def trapezoid_product(
177177
x: FloatArray
178178
x, _ = f
179179
for x_, _ in ff:
180-
x = xpx.union1d(
181-
x[(x >= x_[0]) & (x <= x_[-1])], # type: ignore[index]
182-
x_[(x_ >= x[0]) & (x_ <= x[-1])], # type: ignore[index]
180+
x = xpx.union1d( # ty: ignore[invalid-assignment]
181+
x[(x >= x_[0]) & (x <= x_[-1])],
182+
x_[(x_ >= x[0]) & (x_ <= x[-1])],
183183
)
184184
y = uxpx.interp(x, *f)
185185
for f_ in ff:

glass/cosmology.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99

1010
class Cosmology(
11-
cosmology.api.HasComovingDistance[AnyArray, AnyArray], # type: ignore[misc]
12-
cosmology.api.HasCriticalDensity0[AnyArray], # type: ignore[misc]
13-
cosmology.api.HasGrowthFactor[AnyArray, AnyArray], # type: ignore[misc]
14-
cosmology.api.HasHoverH0[AnyArray, AnyArray], # type: ignore[misc]
15-
cosmology.api.HasHubbleDistance[AnyArray], # type: ignore[misc]
16-
cosmology.api.HasInverseComovingDistance[AnyArray, AnyArray], # type: ignore[misc]
17-
cosmology.api.HasLittleH[AnyArray], # type: ignore[misc]
18-
cosmology.api.HasOmegaM0[AnyArray], # type: ignore[misc]
19-
cosmology.api.HasOmegaM[AnyArray, AnyArray], # type: ignore[misc]
20-
cosmology.api.HasTransverseComovingDistance[AnyArray, AnyArray], # type: ignore[misc]
11+
cosmology.api.HasComovingDistance[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
12+
cosmology.api.HasCriticalDensity0[AnyArray], # ty: ignore[invalid-type-arguments]
13+
cosmology.api.HasGrowthFactor[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
14+
cosmology.api.HasHoverH0[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
15+
cosmology.api.HasHubbleDistance[AnyArray], # ty: ignore[invalid-type-arguments]
16+
cosmology.api.HasInverseComovingDistance[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
17+
cosmology.api.HasLittleH[AnyArray], # ty: ignore[invalid-type-arguments]
18+
cosmology.api.HasOmegaM0[AnyArray], # ty: ignore[invalid-type-arguments]
19+
cosmology.api.HasOmegaM[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
20+
cosmology.api.HasTransverseComovingDistance[AnyArray, AnyArray], # ty: ignore[invalid-type-arguments]
2121
Protocol,
2222
):
2323
"""Cosmology protocol for GLASS."""

0 commit comments

Comments
 (0)