From 9c84c4a4cec555fc3096a7edb44f811cc34582d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:40:18 +0000 Subject: [PATCH 1/2] pre-commit.ci: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.1 → v0.9.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.1...v0.9.2) - [github.com/rhysd/actionlint: v1.7.6 → v1.7.7](https://github.com/rhysd/actionlint/compare/v1.7.6...v1.7.7) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2590888d..365ded25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: args: - --strict - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.1 + rev: v0.9.2 hooks: - id: ruff - id: ruff-format @@ -62,7 +62,7 @@ repos: hooks: - id: forbid-tabs - repo: https://github.com/rhysd/actionlint - rev: v1.7.6 + rev: v1.7.7 hooks: - id: actionlint - repo: https://github.com/pre-commit/mirrors-mypy From 1d1bc2410a7eb64bcec394e83fc50fbaf251d03c Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Tue, 21 Jan 2025 16:02:04 +0000 Subject: [PATCH 2/2] Silence mypy --- glass/core/array.py | 2 +- glass/points.py | 6 +++--- glass/shells.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/glass/core/array.py b/glass/core/array.py index 9814e1e4..00a4e34f 100644 --- a/glass/core/array.py +++ b/glass/core/array.py @@ -166,7 +166,7 @@ def trapezoid_product( y = np.interp(x, *f) for f_ in ff: y *= np.interp(x, *f_) - return np.trapezoid(y, x, axis=axis) # type: ignore[no-any-return] + return np.trapezoid(y, x, axis=axis) # type: ignore[return-value] def cumulative_trapezoid( diff --git a/glass/points.py b/glass/points.py index 39f1cf23..1ecf1f34 100644 --- a/glass/points.py +++ b/glass/points.py @@ -85,7 +85,7 @@ def effective_bias( """ norm = np.trapezoid(w.wa, w.za) - return trapezoid_product((z, bz), (w.za, w.wa)) / norm + return trapezoid_product((z, bz), (w.za, w.wa)) / norm # type: ignore[return-value] def linear_bias( @@ -107,7 +107,7 @@ def linear_bias( The density contrast after biasing. """ - return b * delta + return b * delta # type: ignore[return-value] def loglinear_bias( @@ -413,6 +413,6 @@ def position_weights( densities = densities / np.sum(densities, axis=0) # apply bias after normalisation if bias is not None: - densities = densities * bias + densities = densities * bias # type: ignore[assignment] # densities now contains the relative contribution with bias applied return densities diff --git a/glass/shells.py b/glass/shells.py index a28a1295..4ee414d5 100644 --- a/glass/shells.py +++ b/glass/shells.py @@ -236,9 +236,9 @@ def tophat_windows( for zmin, zmax in itertools.pairwise(zbins): n = max(round((zmax - zmin) / dz), 2) z = np.linspace(zmin, zmax, n) - w = wht(z) + w = wht(z) # type: ignore[arg-type] zeff = np.trapezoid(w * z, z) / np.trapezoid(w, z) - ws.append(RadialWindow(z, w, zeff)) + ws.append(RadialWindow(z, w, zeff)) # type: ignore[arg-type] return ws @@ -410,7 +410,7 @@ def restrict( z_ = np.compress(np.greater(z, w.za[0]) & np.less(z, w.za[-1]), z) zr = np.union1d(w.za, z_) fr = ndinterp(zr, z, f, left=0.0, right=0.0) * ndinterp(zr, w.za, w.wa) - return zr, fr + return zr, fr # type: ignore[return-value] def partition( @@ -565,7 +565,7 @@ def partition_lstsq( # compute the union of all given redshift grids zp = z for w in shells: - zp = np.union1d(zp, w.za) + zp = np.union1d(zp, w.za) # type: ignore[assignment] # get extra leading axes of fz *dims, _ = np.shape(fz) @@ -629,7 +629,7 @@ def partition_nnls( # compute the union of all given redshift grids zp = z for w in shells: - zp = np.union1d(zp, w.za) + zp = np.union1d(zp, w.za) # type: ignore[assignment] # get extra leading axes of fz *dims, _ = np.shape(fz) @@ -673,7 +673,7 @@ def partition_nnls( # for each dim, find non-negative weights x such that y == r @ x x = np.empty([len(shells), *dims]) for i in np.ndindex(*dims): - x[(..., *i)] = nnls(r, y[i]) + x[(..., *i)] = nnls(r, y[i]) # type: ignore[index] # all done return x @@ -742,7 +742,7 @@ def _uniform_grid( if step is not None and num is None: return np.arange(start, np.nextafter(stop + step, stop), step) if step is None and num is not None: - return np.linspace(start, stop, num + 1) + return np.linspace(start, stop, num + 1) # type: ignore[return-value] msg = "exactly one of grid step size or number of steps must be given" raise ValueError(msg)