Skip to content

Write Ufunc_Nin0_Nout1 directly in the ufunc stub template - #353

Merged
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:hardcode-ufunc-nin0-nout1-generic-type
Oct 9, 2026
Merged

avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:hardcode-ufunc-nin0-nout1-generic-type

Conversation

@eerovaher

Copy link
Copy Markdown
Collaborator

A good way to annotate ufuncs is to generate typing-only generic types for each (nin,nout) combination and to declare individual ufuncs as instances of those generic types with appropriate values for the type parameters. The ufuncs with nout==1 have a usable at() method and their __call__() method signature is also somewhat different from ufuncs with nout!=1, so it will be useful to have erfa_generator create the generic ufunc subtypes from two separate templates. However, if a ufunc has (nin,nout)==(0,1) then its __call__() method is analogous to the other ufuncs with nout==1, but it nonetheless does not have a usable at() method. That means the corresponding generic ufunc subtype is the simplest to implement by writing it directly in the type stub template instead of having erfa_generator create it from a separate template.

A good way to annotate ufuncs is to generate typing-only generic types
for each `(nin,nout)` combination and to declare individual ufuncs as
instances of those generic types with appropriate values for the type
parameters. The ufuncs with `nout==1` have a usable `at()` method and
their `__call__()` method signature is also somewhat different from
ufuncs with `nout!=1`, so it will be useful to have `erfa_generator`
create the generic ufunc subtypes from two separate templates. However,
if a ufunc has `(nin,nout)==(0,1)` then its `__call__()` method is
analogous to the other ufuncs with `nout==1`, but it nonetheless does
not have a usable `at()` method. That means the corresponding generic
ufunc subtype is the simplest to implement by writing it directly in the
type stub template instead of having `erfa_generator` create it from a
separate template.
@avalentino
avalentino merged commit f675b57 into liberfa:main Oct 9, 2026
23 checks passed
@eerovaher
eerovaher deleted the hardcode-ufunc-nin0-nout1-generic-type branch October 9, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants