Skip to content
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

Consistency of type deferral #4

Open
jthielen opened this issue Sep 24, 2021 · 0 comments
Open

Consistency of type deferral #4

jthielen opened this issue Sep 24, 2021 · 0 comments

Comments

@jthielen
Copy link

As hinted at by the varied language of "array interaction" in #3, there are several different interactions in practice in which handling/deferral needs to be considered. As far as I can recall, these are:

  • Construction/wrapping
  • Binary operations (addition, multiplication, etc.)
  • __array_ufunc__
  • __array_function__
  • Modules of array functions (e.g., dask.array, but also future __array_module__ of NEP 37)

Current State

The consistency of type handling between these different forms of interaction is varied. For example, Pint Quantities are designed with these consistent (where they exist, as Pint doesn't have an array function module/namespace), whereas with Dask arrays are deliberately different (e.g., deferring to other types in binops and __array_*__, but assuming user intent to override the standard deferral in construction/wrapping and array functions) and (at least as I see it) xarray is accidentally different (see pydata/xarray#3950). The main sticking point in the discussions involved in each of these respective implementations can be summarized as "How much should we trust user to not 'break' the DAG through inconsistencies in type deferral?" or "How much should consistency be enforced?"

Specific Goals

  • Resolve the question (both conceptually and in implementation): to what extent can we trust users to not "break" the type casting hierarchy when/if certain operations/interactions can partially introduce cyclicness to the otherwise acyclic directed graph?

Key Points Raised at Coordination Meeting

  • Consensus (or at least absence of any objections) that all these forms of interaction should be consistent
    • Emphasis on clarity of messaging (i.e., "here's how I defer to another library" rather than "here's how I defer to other libraries with respect to interaction a, and here's how with interaction b, etc.")
    • Hopefully should ease implementation/allow shared utils
    • There is a desire for ability to opt-out/override for third-party/custom/unknown array types
  • Big hurdle: how do we consistently support custom (unknown) libraries?

Suggested Paths Forward

Discussion

  • Should this between-interaction consistency be up to each library to carry out within its own interaction implementation, or should deferral utils be shared (i.e., with Defining Pairwise Interactions #3)?
  • As either a recommendation (if up to each library) or implementation (if shared util), how to best support custom/unknown array types?

Changes to Participating Libraries

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

No branches or pull requests

1 participant