-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
core.missing typing #9584
base: main
Are you sure you want to change the base?
core.missing typing #9584
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR.
This topic is a complicated endeavor, trying to type such deeply internal stuff.
Unfortunately I think some more work had to be put into it. The pandas stubs are just one part.
Lots of type hints are np.ndarray
, have you checked if this is indeed the only allowed argument and no Duckarrays or dask Arrays etc. are allowed?
xarray/core/missing.py
Outdated
nu=0, | ||
ext=None, | ||
xi: Variable, | ||
yi: np.ndarray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that xi and yi have different types?
Im on mobile only, so cannot really check this.
@@ -696,7 +706,7 @@ def interp_func(var, x, new_x, method: InterpOptions, kwargs): | |||
scipy.interpolate.interp1d | |||
""" | |||
if not x: | |||
return var.copy() | |||
return var.data.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to go beyond type hints. Are you sure that this is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes though I'm not sure what level of certainty is appropriate. The output is passed as data to the Variable constructor which just wants to treat it as a numpy-like array.
Thanks for the detailed feedback! I think I have a big-picture question about how typing is intended to develop. I was viewing this PR as a delta towards there being more documentation of this module, subject to maybe the behaviors in the documentation and testing modules. However if type hints are going to be viewed as a contract to which future users/developers will ascribe a high degree of credence, or if adding them can break things in some way that I'm not aware of, I'm not in a position to provide that. |
I didn't want to discourage you, we are able to help and guide you in this PR. I'm currently on mobile only, so it might take some weeks from my side. Unfortunately many developers are not super familiar with static typing and the past has shown that there are rarely any changes on existing type hints on internal stuff. If any other developer disagrees with that statement, please say so. So again, we appreciate this PR and are willing to support you to get this in shape. |
Thanks, that makes sense. Appreciate the support and feedback! |
a57c591
to
c5c9db6
Compare
@headtr1ck Thanks again for your help with this. I had two additional questions.
|
I have not finished the following yet. I am posting this as a draft PR to solicit feedback about typing philosophy/style, in particular about the balance between permissive typing (Union[...]) versus overloading versus substantive code changes.