Skip to content

Commit

Permalink
Revert "pre-commit.ci: update pre-commit hooks (#467)"
Browse files Browse the repository at this point in the history
This reverts commit b8fc91a.
  • Loading branch information
paddyroddy committed Jan 16, 2025
1 parent 3db11ff commit 6132f5e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:
hooks:
- id: toml-sort-fix
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
rev: v3.4.1
hooks:
- id: prettier
- repo: https://github.com/igorshubovych/markdownlint-cli
Expand All @@ -62,11 +62,11 @@ repos:
hooks:
- id: forbid-tabs
- repo: https://github.com/rhysd/actionlint
rev: v1.7.6
rev: v1.7.4
hooks:
- id: actionlint
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v1.13.0
hooks:
- id: mypy
files: ^glass/
Expand Down
2 changes: 1 addition & 1 deletion glass/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def trapezoid_product(
y = np.interp(x, *f)
for f_ in ff:
y *= np.interp(x, *f_)
return np.atleast_1d(np.trapezoid(y, x, axis=axis))
return np.trapezoid(y, x, axis=axis) # type: ignore[no-any-return]


def cumulative_trapezoid(
Expand Down
6 changes: 3 additions & 3 deletions glass/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def effective_bias(
"""
norm = np.trapezoid(w.wa, w.za)
return (trapezoid_product((z, bz), (w.za, w.wa)) / norm).astype(np.float64)
return trapezoid_product((z, bz), (w.za, w.wa)) / norm


def linear_bias(
Expand All @@ -107,7 +107,7 @@ def linear_bias(
The density contrast after biasing.
"""
return (b * delta).astype(np.float64)
return b * delta


def loglinear_bias(
Expand Down Expand Up @@ -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).astype(np.float64)
densities = densities * bias
# densities now contains the relative contribution with bias applied
return densities
17 changes: 8 additions & 9 deletions glass/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def tophat_windows(
ws = []
for zmin, zmax in itertools.pairwise(zbins):
n = max(round((zmax - zmin) / dz), 2)
z = np.linspace(zmin, zmax, n, dtype=np.float64)
w = np.asarray(wht(z), dtype=np.float64)
z = np.linspace(zmin, zmax, n)
w = wht(z)
zeff = np.trapezoid(w * z, z) / np.trapezoid(w, z)
ws.append(RadialWindow(z, w, zeff))
return ws
Expand Down Expand Up @@ -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.astype(np.float64), fr.astype(np.float64)
return zr, fr


def partition(
Expand Down Expand Up @@ -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).astype(np.float64)
zp = np.union1d(zp, w.za)

# get extra leading axes of fz
*dims, _ = np.shape(fz)
Expand Down Expand Up @@ -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).astype(np.float64)
zp = np.union1d(zp, w.za)

# get extra leading axes of fz
*dims, _ = np.shape(fz)
Expand Down Expand Up @@ -673,8 +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):
index = (slice(None),) + i # noqa: RUF005
x[index] = nnls(r, y[i])
x[(..., *i)] = nnls(r, y[i])

# all done
return x
Expand Down Expand Up @@ -741,9 +740,9 @@ def _uniform_grid(
"""
if step is not None and num is None:
return np.arange(start, np.nextafter(stop + step, stop), step, dtype=np.float64)
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, dtype=np.float64)
return np.linspace(start, stop, num + 1)
msg = "exactly one of grid step size or number of steps must be given"
raise ValueError(msg)

Expand Down

0 comments on commit 6132f5e

Please sign in to comment.