Conversation
Not up to standards ⛔
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add type hints to the public functions and methods in
core.pyandutils.py, and fixoption_to_listso the per-dimension*_listoptions actually work as documented. Also modernize the CI workflow,
which is required because the new typing syntax needs Python >= 3.10.
Typing conventions used:
numpy.typing.NDArrayfor real arrays,numpy.typing.ArrayLikeforthe knot inputs that get normalized via
np.array/np.asarray(the
XSpline/NDXSplineconstructors).float | NDArray(simple unions, no@overload) for thescalar-or-array math functions, matching how the code branches on
np.isscalar.What changed
src/xspline/utils.py— annotated all functions (args + returns).Notable:
order_to_index(shape)istuple[int, ...] | NDArray(tuple in tests, ndarray in
core.py);funcsislist[Callable[..., float | NDArray]];outer_flatten(*args: NDArray).src/xspline/utils.py(option_to_list) — behavior fix.Previously any non-empty list was truthy and collapsed to all-
True,so per-dimension lists were silently ignored. It now accepts a single
bool,None, or a reallist[bool](length-checked), returning thelist as-is. Signature:
bool | list[bool] | None.src/xspline/core.py— annotated the fourbspline_*functions,the
XSpline/NDXSplinemethods, constructors (-> None), and thenested integration piece helpers in
ifun. The*_list/*_extra_listparams are typedbool | list[bool] | Noneto keep thescalar/None convenience while enabling real lists.
tests/test_utils.py— replaced the previously vacuoustest_utils_option_to_list(its~(a ^ b)assertion was alwaystruthy) with assertions that actually check the values, plus new tests
for the real-list path and the length-mismatch guard.
.github/workflows/python-build.yml— bumped the test Python to3.11 (the new
X | Y/list[bool]syntax needs >= 3.10, which wasthe CI failure), and updated action versions:
actions/checkout@v2 -> v4,actions/setup-python@v2 -> v5,pypa/gh-action-pypi-publish@master -> @release/v1.