Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contrib/weights-from-festa-sommariva.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ def generate_festa_sommariva_quadrature_rules(outfile):
#
# DEGREE: <degree>

_re_degree = re.compile(r"DEGREE:\s+(\d+)")
_re_xw = re.compile(r"xw\s?=\s?\[(.+?)\];", re.DOTALL)
re_degree = re.compile(r"DEGREE:\s+(\d+)")
re_xw = re.compile(r"xw\s?=\s?\[(.+?)\];", re.DOTALL)

# NOTE: some degrees have multiple quadrature rules with a repeated
# header, so we just take the unique ones here
degrees = np.unique(
np.fromiter(_re_degree.findall(mfile), dtype=np.int64)
np.fromiter(re_degree.findall(mfile), dtype=np.int64)
)

rules = {}
for imatch, match in enumerate(_re_xw.findall(mfile)):
for imatch, match in enumerate(re_xw.findall(mfile)):
d = degrees[imatch]
assert d == imatch + 1, (d, imatch + 1)

Expand Down
10 changes: 5 additions & 5 deletions modepy/modal_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ def make_mode_number_vector(
return mode_number_vector


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

zeros = mode_number_vector == 0

modal_coefficients = mode_number_vector**(-n)
modal_coefficients[zeros] = 1 # irrelevant, just keeps log from NaNing

# NOTE: mypy seems to be confused by the __itruediv__ argument types
modal_coefficients /= la.norm(modal_coefficients) # type: ignore[arg-type,misc]
modal_coefficients[zeros] = 1.0 # irrelevant, just keeps log from NaNing
modal_coefficients /= la.norm(modal_coefficients)

return modal_coefficients

Expand Down
2 changes: 1 addition & 1 deletion modepy/quadrature/clenshaw_curtis.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _make_clenshaw_curtis_nodes_and_weights(n: int) -> tuple[np.ndarray, np.ndar
# Clenshaw-Curtis weights
w = np.concatenate([2 / N / (N - 2), 1 / N[-1:], np.zeros(m)])
w = 0 - w[:-1] - w[-1:0:-1]
g0 = -np.ones(n)
g0: np.ndarray[tuple[int, ...], np.dtype[np.floating]] = -np.ones(n)
g0[r] = g0[r] + n
g0[m] = g0[m] + n
g0 = g0 / (n**2 - 1 + (n % 2))
Expand Down
3 changes: 1 addition & 2 deletions modepy/quadrature/jacobi_gauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
THE SOFTWARE.
"""


import numpy as np
import numpy.linalg as la

Expand Down Expand Up @@ -267,7 +266,7 @@ def jacobi_gauss_lobatto_nodes(
Exact to degree :math:`2N - 3`.
"""

x = np.zeros((N + 1,))
x: np.ndarray[tuple[int, ...], np.dtype[np.floating]] = np.zeros((N + 1,))
if N == 0:
x[0] = 0
return x
Expand Down
Loading