Skip to content

Commit bc871fd

Browse files
committed
fix: new mypy errors due to numpy typing
1 parent 8064696 commit bc871fd

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

modepy/modal_decay.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@ def make_mode_number_vector(
103103
return mode_number_vector
104104

105105

106-
def create_decay_baseline(mode_number_vector: np.ndarray, n: int) -> np.ndarray:
106+
def create_decay_baseline(
107+
mode_number_vector: np.ndarray[tuple[int, ...], np.dtype[np.floating]],
108+
n: int) -> np.ndarray[tuple[int, ...], np.dtype[np.floating]]:
107109
"""Create a vector of modal coefficients that exhibit 'optimal'
108110
(:math:`k^{-N}`) decay.
109111
"""
110112

111113
zeros = mode_number_vector == 0
112114

113115
modal_coefficients = mode_number_vector**(-n)
114-
modal_coefficients[zeros] = 1 # irrelevant, just keeps log from NaNing
115-
116-
# NOTE: mypy seems to be confused by the __itruediv__ argument types
117-
modal_coefficients /= la.norm(modal_coefficients) # type: ignore[arg-type,misc]
116+
modal_coefficients[zeros] = 1.0 # irrelevant, just keeps log from NaNing
117+
modal_coefficients /= la.norm(modal_coefficients)
118118

119119
return modal_coefficients
120120

modepy/quadrature/clenshaw_curtis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _make_clenshaw_curtis_nodes_and_weights(n: int) -> tuple[np.ndarray, np.ndar
4949
# Clenshaw-Curtis weights
5050
w = np.concatenate([2 / N / (N - 2), 1 / N[-1:], np.zeros(m)])
5151
w = 0 - w[:-1] - w[-1:0:-1]
52-
g0 = -np.ones(n)
52+
g0: np.ndarray[tuple[int, ...], np.dtype[np.floating]] = -np.ones(n)
5353
g0[r] = g0[r] + n
5454
g0[m] = g0[m] + n
5555
g0 = g0 / (n**2 - 1 + (n % 2))

modepy/quadrature/jacobi_gauss.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
THE SOFTWARE.
5151
"""
5252

53-
5453
import numpy as np
5554
import numpy.linalg as la
5655

@@ -267,7 +266,7 @@ def jacobi_gauss_lobatto_nodes(
267266
Exact to degree :math:`2N - 3`.
268267
"""
269268

270-
x = np.zeros((N + 1,))
269+
x: np.ndarray[tuple[int, ...], np.dtype[np.floating]] = np.zeros((N + 1,))
271270
if N == 0:
272271
x[0] = 0
273272
return x

0 commit comments

Comments
 (0)