Skip to content

Fixes and dispatch improvements - #940

Merged
gertjanvanzwieten merged 13 commits into
mainfrom
dispatch
Sep 30, 2026
Merged

gertjanvanzwieten merged 13 commits into
mainfrom
dispatch

Conversation

@gertjanvanzwieten

Copy link
Copy Markdown
Contributor

No description provided.

When the _util.cli function was rewritten on top of ags in commit 1d8b7db, it
was incorrectly assumed that stringly_doc.presets and stringly_doc.defaults
contained the already destringlified object values. This patch fixes that
assumption, and adds arguments that are yet to be converted in a `string_args`
dictionary first, before converting it to the `kwargs` dictionary of objects in
the final loop.
This patch restores test.docs which got disabled as a side effect of moving
nutils into the src directory.
This patch avoids the stack operation of the choose arguments which adds
work that is entirely unnecessary.
This patch adds the equivalent to Choose._multiply, which was missing for no
apparent reason. It also adds the test.evaluable.Choose unit test to make sure
that the simplifications are operational.
This patch adds the nutils_dispatch decorator to the following functions in the
nutils.function module:

- piecewise
- partition
- heaviside
- chain
- vectorize
- add_T
- trignormal
- trigtangent
- rotmat
- dotarg
This patch adds the _util.flatten utility function that will be used in
subsequent commits to deal with arbitrarily nested function arguments.
This patch limits the kinds of arguments that are accepted by the
@single_or_multiple decorator, no longer accepting maps or generators.

The reason for this change is that in the scenario that a function is later
decorated with @nutils_dispatch, it is preferable to replace the existing
@single_or_multiple decorator and instead handle nested arguments internal to
the function, as otherwise (using single_or_multiple) the function that is
passed on by @nutils_dispatch (undecorated) does not match the function object
in the module namespace (decorated). Since this means that every dispatch
handler needs to be able to handle the complex argument, it at least eases the
burden by not allowing iterators.
This patch generalizes the implementation of _util.nutils_dispatch by
recursively entering arguments of type tuple of list in the search for argument
types that have a __nutils_dispatch__ method.
This patch adds _util.nested_map, which will be used in situations that the
@single_or_multiple decorator is not applicable.
@gertjanvanzwieten
gertjanvanzwieten merged commit 7ed71a0 into main Sep 30, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants