Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

no implicit type casting #841

Merged
merged 12 commits into from
Dec 18, 2023
Merged

no implicit type casting #841

merged 12 commits into from
Dec 18, 2023

Conversation

joostvanzwieten
Copy link
Member

Many of the evaluable array ops (the functions, not the classes) support automatic type casting. For example you can do evaluable.add(1, 1.5) without problems. However, you can also do evaluable.add(True, 1) (evaluates to 2, int), and here implicit casting makes less sense. To prevent unforeseen casts, this PR disallows all implicit casting in evaluable array ops.

A large portion of the `evaluable.Pointwise` subclasses are holomorphic. This
patch adds a subclass `evaluable.Holomorphic` derived from `Pointwise`, with a
default implementation for `return_type` and support for complex derivatives,
and lets the holomorphic pointwise array functions derive from `Holomorphic`.
This patch also removes support for complex derivatives of subclasses of
`Pointwise` (unless overriden).
The variable `evaluable._type_order` is an ordered tuple of dtypes: casting is
safe to types to the right of a type. The function `evaluable.astype` is the
only user of the orderedness of `evaluable._type_order`. This patch inlines the
casting logic in `evaluable.astype`, leaving the orderedness of
`evaluable._type_order` unused.
This patch formally removes the orderedness from the list of valid array dtypes
by renaming `evaluable._type_order` to `evaluable._array_dtypes`.
@joostvanzwieten joostvanzwieten force-pushed the no-implicit-type-casting branch from b425c2a to 9195274 Compare December 18, 2023 12:23
@joostvanzwieten joostvanzwieten merged commit 7d5a645 into master Dec 18, 2023
19 of 21 checks passed
@joostvanzwieten joostvanzwieten deleted the no-implicit-type-casting branch December 18, 2023 12:49
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants