-
-
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
Type chunkmanagers #9227
base: main
Are you sure you want to change the base?
Type chunkmanagers #9227
Conversation
for more information, see https://pre-commit.ci
…n/xarray into namedarray_chunkmanager
xarray/coding/times.py
Outdated
def encode_cf_datetime( | ||
dates: T_DuckArray, # type: ignore | ||
dates: duckarray | chunkedduckarray, |
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.
You should still use TypeVars and not the protocol directly.
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 don't think that works (yet, waiting on Higher-Kinded TypeVars). Using T_DuckArray
will indeed retain the np.ndarray
typing (good) but also the dtype
and shape
typing (bad/wrong).
We don't really care (in theory) if it is ndarray or cupy array, just that they pass the minimal requirements for a duckarray
. But we do care that dtype
and shape
is correct after calculation.
duckarray
is actually duckarray[_ShapeType, _DType]
where the dtype and shape are TypeVars, in same fashion as numpy see #8294. I am intentionally lazy with this in non-namedarray files though to avoid the PRs touching every file.
for more information, see https://pre-commit.ci
…n/xarray into namedarray_chunkmanager
pd.index is apparently not a "duckarray": def test_pd_index_duckarray(self) -> None:
import pandas as pd
a: duckarray[Any, Any] = pd.Index([])
check_duck_array_typevar(a)
|
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…n/xarray into namedarray_chunkmanager
for more information, see https://pre-commit.ci
…n/xarray into namedarray_chunkmanager
for more information, see https://pre-commit.ci
…n/xarray into namedarray_chunkmanager
Use
chunkedduckarray
andduckarray
in chunkmanagers now that it is used in namedarray.Split from #8933
Requires #9226, #9225