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

Either support passing of all Quantified-like objects to all functions supporting them or create a new TypeVar #1726

Open
Zeitsperre opened this issue Apr 22, 2024 · 0 comments
Assignees
Labels
information For development/intsructional purposes invalid This doesn't seem right standards / conventions Suggestions on ways forward

Comments

@Zeitsperre
Copy link
Collaborator

  • xclim version: v0.48.3-dev
  • Python version: Any
  • Operating System: All

Description

We currently use the Quantified type alias in almost all the threshold-based indicators to specify that this variable should conform to something resembling a string with units (str | pint.Quantity), but this alias also includes xarray.DataArray. Does this mean that we can pass (or would like to enable passing) DataArrays of grids denoting thresholds? No, we currently don't support that behaviour, but maybe we would want to?

If not, we may need to create a new, more constrained custom variable (str2pint often takes variables of this type but does not support pint.Quantity or xarray.DataArray). Solving this issue alone will resolve at least 1/4 of all errors associated with mypy typing (~300+).

See also: #1719 and #1721

@Zeitsperre Zeitsperre added standards / conventions Suggestions on ways forward information For development/intsructional purposes invalid This doesn't seem right labels Apr 22, 2024
@Zeitsperre Zeitsperre added this to the Summer 2024 milestone May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
information For development/intsructional purposes invalid This doesn't seem right standards / conventions Suggestions on ways forward
Projects
None yet
Development

No branches or pull requests

2 participants