-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-480: fix mypy failures #490
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -410,8 +410,8 @@ def __init__(self, cosmo: Cosmology) -> None: | |
self.cosmo = cosmo | ||
|
||
# set up initial values of variables | ||
self.z2: float = 0.0 | ||
self.z3: float = 0.0 | ||
self.z2: float | npt.NDArray[np.float64] = 0.0 | ||
self.z3: float | npt.NDArray[np.float64] = 0.0 | ||
Comment on lines
+413
to
+414
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of |
||
self.x3: float = 0.0 | ||
self.w3: float = 0.0 | ||
self.r23: float = 1.0 | ||
|
@@ -442,7 +442,7 @@ def add_window(self, delta: npt.NDArray[np.float64], w: RadialWindow) -> None: | |
def add_plane( | ||
self, | ||
delta: npt.NDArray[np.float64], | ||
zsrc: float, | ||
zsrc: float | npt.NDArray[np.float64], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
wlens: float = 1.0, | ||
) -> None: | ||
""" | ||
|
@@ -505,7 +505,7 @@ def add_plane( | |
self.kappa3 += f * delta2 | ||
|
||
@property | ||
def zsrc(self) -> float: | ||
def zsrc(self) -> float | npt.NDArray[np.float64]: | ||
"""The redshift of the current convergence plane.""" | ||
return self.z3 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ def effective_bias( | |
z: npt.NDArray[np.float64], | ||
bz: npt.NDArray[np.float64], | ||
w: RadialWindow, | ||
) -> npt.NDArray[np.float64]: | ||
) -> float | npt.NDArray[np.double]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
r""" | ||
Effective bias parameter from a redshift-dependent bias function. | ||
|
||
|
@@ -85,7 +85,7 @@ def effective_bias( | |
|
||
""" | ||
norm = np.trapezoid(w.wa, w.za) | ||
return trapezoid_product((z, bz), (w.za, w.wa)) / norm # type: ignore[return-value] | ||
return trapezoid_product((z, bz), (w.za, w.wa)) / norm | ||
|
||
|
||
def linear_bias( | ||
|
@@ -107,7 +107,7 @@ def linear_bias( | |
The density contrast after biasing. | ||
|
||
""" | ||
return b * delta # type: ignore[return-value] | ||
return b * delta | ||
|
||
|
||
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 # type: ignore[assignment] | ||
densities = densities * bias | ||
# densities now contains the relative contribution with bias applied | ||
return densities |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,7 @@ class RadialWindow(typing.NamedTuple): | |
|
||
za: npt.NDArray[np.float64] | ||
wa: npt.NDArray[np.float64] | ||
zeff: float = 0 | ||
zeff: float | npt.NDArray[np.float64] = 0 | ||
|
||
|
||
def tophat_windows( | ||
|
@@ -235,10 +235,10 @@ def tophat_windows( | |
ws = [] | ||
for zmin, zmax in itertools.pairwise(zbins): | ||
n = max(round((zmax - zmin) / dz), 2) | ||
z = np.linspace(zmin, zmax, n) | ||
w = wht(z) # type: ignore[arg-type] | ||
z = np.linspace(zmin, zmax, n, dtype=np.float64) | ||
w = wht(z) | ||
zeff = np.trapezoid(w * z, z) / np.trapezoid(w, z) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ws.append(RadialWindow(z, w, zeff)) # type: ignore[arg-type] | ||
ws.append(RadialWindow(z, w, zeff)) | ||
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 # type: ignore[return-value] | ||
return zr, fr | ||
|
||
|
||
def partition( | ||
|
@@ -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) # type: ignore[return-value] | ||
return np.linspace(start, stop, num + 1, dtype=np.float64) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returns "float-any" so be explicit about the type |
||
msg = "exactly one of grid step size or number of steps must be given" | ||
raise ValueError(msg) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failing
ignore[return-value]
checks were on numpy 2.2.0, and should be resolved now.