Skip to content

Commit 3fc348f

Browse files
authored
gh-880: Fix inconsistencies in the documentation rendering (#889)
1 parent d0ff6e6 commit 3fc348f

File tree

10 files changed

+19
-29
lines changed

10 files changed

+19
-29
lines changed

glass/_array_api_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Array API Utilities for glass.
3-
============================
3+
==============================
44
55
This module provides utility functions and classes for working with multiple array
66
backends in the glass project, including NumPy, JAX, and array-api-strict. It includes

glass/algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ def cov_nearest(
234234
235235
Divides *cov* along rows and columns by the square root of the
236236
diagonal, then computes the nearest valid correlation matrix using
237-
:func:`nearcorr`, before scaling rows and columns back. The
237+
:func:`glass.nearcorr`, before scaling rows and columns back. The
238238
diagonal of the input is hence unchanged.
239239
240240
Parameters
241241
----------
242242
cov
243243
A square matrix (or a stack of matrices).
244244
tol
245-
Tolerance for convergence, see :func:`nearcorr`.
245+
Tolerance for convergence, see :func:`glass.nearcorr`.
246246
niter
247247
Maximum number of iterations.
248248

glass/fields.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def generate_gaussian(
424424
425425
.. deprecated:: 2025.1
426426
427-
Use :func:`glass.generate()` instead.
427+
Use :func:`glass.generate` instead.
428428
429429
A generator that iteratively samples HEALPix maps of Gaussian random fields
430430
with the given angular power spectra ``gls`` and resolution parameter
@@ -478,7 +478,7 @@ def generate_lognormal(
478478
479479
.. deprecated:: 2025.1
480480
481-
Use :func:`glass.generate()` instead.
481+
Use :func:`glass.generate` instead.
482482
483483
Parameters
484484
----------

glass/grf/_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def compute(
164164
165165
See Also
166166
--------
167-
glass.grf.solve: Iterative solver for non-band-limited spectra.
167+
:func:`glass.grf.solve`: Iterative solver for non-band-limited spectra.
168168
169169
"""
170170
if t2 is None:

glass/grf/_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def solve( # noqa: PLR0912, PLR0913
7777
7878
See Also
7979
--------
80-
glass.grf.compute : Direct computation for band-limited spectra.
80+
:func:`glass.grf.compute`: Direct computation for band-limited spectra.
8181
8282
"""
8383
if t2 is None:

glass/lensing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def deflect(
618618
Apply deflections to positions.
619619
620620
.. deprecated:: >2025.2
621-
Use :func:`displace` instead.
621+
Use :func:`glass.displace` instead.
622622
623623
Takes an array of :term:`deflection` values and applies them
624624
to the given positions.

glass/points.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
162162
bias: float | FloatArray | None = None,
163163
vis: FloatArray | None = None,
164164
*,
165-
bias_model: str | Callable[..., Any] = "linear",
165+
bias_model: Callable[..., Any] = linear_bias,
166166
remove_monopole: bool = False,
167167
batch: int = 1_000_000,
168168
rng: np.random.Generator | None = None,
@@ -207,10 +207,8 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
207207
Visibility map for the observed points. This is multiplied with
208208
the full sky number count map, and must hence be of compatible shape.
209209
bias_model
210-
The bias model to apply. If a string, refers to a function in
211-
the :mod:`~glass.points` module, e.g. ``'linear'`` for
212-
:func:`glass.linear_bias()` or ``'glass.loglinear'`` for
213-
:func:`glass.loglinear_bias`.
210+
The bias model to apply. For examples, :func:`glass.linear_bias`
211+
or :func:`glass.loglinear_bias`.
214212
remove_monopole
215213
If true, the monopole of the density contrast
216214
after biasing is fixed to zero.
@@ -239,13 +237,9 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
239237
if rng is None:
240238
rng = np.random.default_rng(42)
241239

242-
# get the bias model
243-
if isinstance(bias_model, str):
244-
bias_model_callable = globals()[f"{bias_model}_bias"]
245-
elif not callable(bias_model):
246-
raise TypeError("bias_model must be string or callable")
247-
else:
248-
bias_model_callable = bias_model
240+
# ensure bias_model is a function
241+
if not callable(bias_model):
242+
raise TypeError("bias_model must be callable")
249243

250244
# broadcast inputs to common shape of extra dimensions
251245
inputs: list[tuple[float | FloatArray, int]] = [(ngal, 0), (delta, 1)]
@@ -263,11 +257,7 @@ def positions_from_delta( # noqa: PLR0912, PLR0913, PLR0915
263257
# iterate the leading dimensions
264258
for k in np.ndindex(dims):
265259
# compute density contrast from bias model, or copy
266-
n = (
267-
np.copy(delta[k])
268-
if bias is None
269-
else bias_model_callable(delta[k], bias[k])
270-
)
260+
n = np.copy(delta[k]) if bias is None else bias_model(delta[k], bias[k])
271261

272262
# remove monopole if asked to
273263
if remove_monopole:

glass/shells.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def partition(
609609
where :math:`\lambda` is a multiplier to enforce the integral
610610
constraints.
611611
612-
The :func:`glass.partition()` function implements a number of methods to
612+
The :func:`glass.partition` function implements a number of methods to
613613
obtain a solution:
614614
615615
If ``method="nnls"`` (the default), obtain a partition from a

tests/benchmarks/test_points.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
("bias", "bias_model"),
2929
[
3030
(None, lambda x: x),
31-
(0.8, "linear"),
31+
(0.8, glass.linear_bias),
3232
],
3333
)
3434
@pytest.mark.parametrize("remove_monopole", [True, False])
@@ -38,7 +38,7 @@ def test_positions_from_delta( # noqa: PLR0913
3838
generator_consumer: GeneratorConsumer,
3939
xpb: ModuleType,
4040
bias: float,
41-
bias_model: str | Callable[[int], int],
41+
bias_model: Callable[[int], int],
4242
remove_monopole: bool, # noqa: FBT001
4343
) -> None:
4444
"""Benchmarks for glass.positions_from_delta."""

tests/core/test_points.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_positions_from_delta( # noqa: PLR0915
249249

250250
# test TypeError
251251

252-
with pytest.raises(TypeError, match="bias_model must be string or callable"):
252+
with pytest.raises(TypeError, match="bias_model must be callable"):
253253
next(glass.positions_from_delta(ngal, delta, bias, vis, bias_model=0))
254254

255255

0 commit comments

Comments
 (0)