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
84 changes: 6 additions & 78 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4248,98 +4248,26 @@
}
},
{
"code": "reportUnknownArgumentType",
"code": "reportArgumentType",
"range": {
"startColumn": 33,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportUnknownLambdaType",
"range": {
"startColumn": 40,
"endColumn": 41,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 43,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 50,
"endColumn": 51,
"endColumn": 39,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"code": "reportArgumentType",
"range": {
"startColumn": 33,
"endColumn": 49,
"lineCount": 1
}
},
{
"code": "reportUnknownLambdaType",
"range": {
"startColumn": 40,
"endColumn": 41,
"lineCount": 1
}
},
{
"code": "reportUnknownLambdaType",
"range": {
"startColumn": 43,
"endColumn": 49,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 47,
"endColumn": 48,
"endColumn": 36,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"code": "reportArgumentType",
"range": {
"startColumn": 33,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportUnknownLambdaType",
"range": {
"startColumn": 40,
"endColumn": 41,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 43,
"endColumn": 52,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 50,
"endColumn": 51,
"endColumn": 39,
"lineCount": 1
}
}
Expand Down
6 changes: 3 additions & 3 deletions modepy/quadrature/jacobi_gauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ def jacobi_gauss_lobatto_nodes(
alpha: float, beta: float, N: int, # ruff:ignore[invalid-argument-name]
backend: str | None = None,
force_dim_axis: bool = False) -> ArrayF:
"""Compute Gauss-Lobatto quadrature nodes associated with
r"""Compute Gauss-Lobatto quadrature nodes associated with
:class:`~modepy.JacobiGaussQuadrature` with the same parameters.

This helper returns only the *N+1* nodes; the corresponding
Gauss-Lobatto quadrature rule (using these nodes with appropriate
weights) is exact for polynomials up to degree :math:`2N - 1`
when :math:`N \\ge 1`.
when :math:`N \ge 1`.

For :math:`N = 0`, this function returns a single node at ``0``.
This degenerate case does not correspond to a Gauss-Lobatto node
set with endpoints :math:`\\pm 1`, but is provided for convenience.
set with endpoints :math:`\pm 1`, but is provided for convenience.
"""

x: np.ndarray[tuple[int, ...], np.dtype[np.floating]] = np.zeros((N + 1,))
Expand Down
6 changes: 3 additions & 3 deletions modepy/quadrature/kronrod.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,21 +608,21 @@ def test_semi_pos_inf():

def test_semi_pos_neg():
# Semi-infinite negative: e^x from -inf to 0
approx_int, err_est = quadgk(lambda x: np.exp(x), -np.inf, 0)
approx_int, err_est = quadgk(np.exp, -np.inf, 0)
assert err_est < 1e-10
check("integral e^x from -inf to 0", approx_int, 1.0)


def test_multi_break():
# Multiple breakpoints
approx_int, err_est = quadgk(lambda x: abs(x), -1, 0, 1)
approx_int, err_est = quadgk(abs, -1, 0, 1)
assert err_est < 1e-10
check("integral |x| from -1 to 1 (with breakpoint)", approx_int, 1.0)


def test_oscillatory():
# Oscillatory
approx_int, err_est = quadgk(lambda x: np.sin(x), 0, np.pi)
approx_int, err_est = quadgk(np.sin, 0, np.pi)
assert err_est < 1e-10
check("integral sin(x) from 0 to pi", approx_int, 2.0)
Comment on lines 623 to 627

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these tests here on purpose? Shouldn't they be in modepy/test?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are! I noticed this pattern in Rust code, where tests live alongside the code being tested, and rather liked it. At least for the packages where the tests live under the main package import, they're also guaranteed to be discovered. Do you not like this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. I don't know, can't say I have too much of a preference. The main worry is just consistency, I guess? i.e. I wouldn't have looked here for tests.

Although I'm not a big fan of these being exported by default. Does pytest not find them if they're not in __all__?


Expand Down
2 changes: 2 additions & 0 deletions modepy/test/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,9 @@ def agree(x: bool, y: bool) -> bool:

for a in [5, _Inf(), np.inf, -np.inf, "z"]:
for b in [5, _Inf(), np.inf, -np.inf, "z"]:
# ruff: ignore[unnecessary-dunder-call]
assert agree(a.__lt__(b), b.__gt__(a)) # pyright: ignore[reportArgumentType]
# ruff: ignore[unnecessary-dunder-call]
assert agree(a.__le__(b), b.__ge__(a)) # pyright: ignore[reportArgumentType]


Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ extend-select = [
"TC",
]
extend-ignore = [
"C90", # McCabe complexity
"multiple-spaces-before-operator",
"complex-structure",
"error-suffix-on-exception-name",
"missing-whitespace-around-arithmetic-operator",
"multiple-spaces-after-comma",
"tab-after-comma",
"module-import-not-at-top-of-file",
"error-suffix-on-exception-name",
"multiple-spaces-after-comma",
"multiple-spaces-before-operator",
"non-empty-init-module",
"pytest-parameter-with-default-argument",
"tab-after-comma",
"type-check-without-type-error",
]
allowed-confusables = ["‐", "–"]
Expand Down
Loading