-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom types (RFC) #4
Comments
Naturally, the above is syntax sugar and dispatching on types can still look like this:
|
For numba usecases, we will need to construct types dynamically. I suppose we can invoke |
Yes, all that matters is that the typedef exists in the typedef table before |
A dual number type would be very interesting for forward mode AD! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There have been various questions about custom types. This is the current state and an opportunity for concrete feedback.
Custom types are created as follows, an example is the graph custom type:
https://github.com/plures/gumath/blob/daa7bb94730efe163e6129de5998a28d016e538d/libgumath/extending/graph.c#L346
To validate graph invariants, the constraint function
graph_constraint
is automatically called upon initialization.Functions that operate on the graph obviously still need to be written in C.
We define a Python class that inherits from
xnd
, with type checked initialization of values:https://github.com/plures/gumath/blob/daa7bb94730efe163e6129de5998a28d016e538d/python/extending.py#L11
xnd
subclass just like any other Python type:https://github.com/plures/gumath/blob/daa7bb94730efe163e6129de5998a28d016e538d/python/test_gumath.py#L241
The text was updated successfully, but these errors were encountered: