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

Type chunkmanagers #9227

Draft
wants to merge 61 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
3fdb52f
Type parallelcompat
Illviljan Jul 10, 2024
c24b7ae
Type daskmanager
Illviljan Jul 10, 2024
a932c71
Add chunks typing
Illviljan Jul 10, 2024
676f045
Update times.py
Illviljan Jul 10, 2024
6f79bdc
Update times.py
Illviljan Jul 10, 2024
3d48d44
Update _typing.py
Illviljan Jul 10, 2024
e7041e0
Update test_parallelcompat.py
Illviljan Jul 10, 2024
6f56dd8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2024
19b2674
Update indexing.py
Illviljan Jul 10, 2024
11aa840
Update core.py
Illviljan Jul 10, 2024
62635eb
Update variable.py
Illviljan Jul 10, 2024
9c996a8
Update computation.py
Illviljan Jul 10, 2024
6625874
Merge branch 'namedarray_chunkmanager' of https://github.com/Illvilja…
Illviljan Jul 10, 2024
81fcf85
Update variables.py
Illviljan Jul 10, 2024
c894c7b
Update dataset.py
Illviljan Jul 10, 2024
fe35554
Update _typing.py
Illviljan Jul 10, 2024
bc05489
Update parallelcompat.py
Illviljan Jul 10, 2024
cedff32
Update parallelcompat.py
Illviljan Jul 10, 2024
d43c0c1
Update test_coding_times.py
Illviljan Jul 10, 2024
6530440
Merge branch 'main' into namedarray_chunkmanager
Illviljan Jul 11, 2024
2f1a6ca
Merge branch 'main' into namedarray_chunkmanager
Illviljan Jul 11, 2024
d5d3e35
Merge branch 'main' into namedarray_chunkmanager
max-sixty Jul 13, 2024
116c920
Merge branch 'main' into namedarray_chunkmanager
Illviljan Aug 3, 2024
6399dab
Update _typing.py
Illviljan Aug 3, 2024
156a953
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2024
6a08740
Update times.py
Illviljan Aug 3, 2024
daba54e
Merge branch 'namedarray_chunkmanager' of https://github.com/Illvilja…
Illviljan Aug 3, 2024
eef8fc8
Update core.py
Illviljan Aug 4, 2024
db98984
Update daskmanager.py
Illviljan Aug 4, 2024
96e1a1d
Update test_coding_times.py
Illviljan Aug 4, 2024
bf83275
Update test_coding_times.py
Illviljan Aug 4, 2024
31e1895
test pd.index
Illviljan Aug 5, 2024
30f8cdd
Update test_namedarray.py
Illviljan Aug 5, 2024
6ed1ae6
Update test_namedarray.py
Illviljan Aug 5, 2024
cd05c67
Add more helpful error
Illviljan Aug 5, 2024
459378f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2024
7bc2c31
Merge branch 'main' into namedarray_chunkmanager
Illviljan Aug 6, 2024
389aca7
Merge branch 'main' into namedarray_chunkmanager
Illviljan Aug 13, 2024
254a6b3
Merge branch 'main' into namedarray_chunkmanager
Illviljan Aug 14, 2024
85f49eb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 14, 2024
7ab9fda
Merge branch 'main' into namedarray_chunkmanager
Illviljan Nov 17, 2024
1b791b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2024
7632f3f
Update core.py
Illviljan Nov 17, 2024
ac3102e
Merge branch 'namedarray_chunkmanager' of https://github.com/Illvilja…
Illviljan Nov 17, 2024
340b70f
Update daskmanager.py
Illviljan Nov 17, 2024
52aacfe
Update parallelcompat.py
Illviljan Nov 17, 2024
ebf415d
chunkedduckarray
Illviljan Nov 17, 2024
02e7b28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2024
e71a36a
Update datatree.py
Illviljan Nov 17, 2024
aa214e4
Merge branch 'namedarray_chunkmanager' of https://github.com/Illvilja…
Illviljan Nov 17, 2024
d7da450
Update times.py
Illviljan Nov 17, 2024
df29319
Update times.py
Illviljan Nov 17, 2024
6735cf0
Update times.py
Illviljan Nov 17, 2024
feaed2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2024
9d0c480
Update times.py
Illviljan Nov 17, 2024
3e6b5dd
add __array___ test
Illviljan Nov 17, 2024
fd891e9
Update test_namedarray.py
Illviljan Nov 17, 2024
76d9de6
Merge branch 'namedarray_chunkmanager' of https://github.com/Illvilja…
Illviljan Nov 17, 2024
fa148fa
Merge branch 'main' into namedarray_chunkmanager
Illviljan Nov 26, 2024
82e5f58
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2024
a4b4e7e
Merge branch 'main' into namedarray_chunkmanager
Illviljan Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update times.py
Illviljan committed Nov 17, 2024
commit df29319ddd151835119dbb622fc161acff0b7bc2
18 changes: 10 additions & 8 deletions xarray/coding/times.py
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@
from xarray.core.types import CFCalendar, NPDatetimeUnitOptions

T_Name = Union[Hashable, None]
PandasTypes = Union[pd.Index, pd.DatetimeIndex, pd.timedelta64]


# standard calendars recognized by cftime
_STANDARD_CALENDARS = {"standard", "gregorian", "proleptic_gregorian"}
@@ -725,17 +727,17 @@ def encode_cf_datetime(
) -> tuple[chunkedduckarray, str, str]: ...
@overload
def encode_cf_datetime(
dates: duckarray | pd.Index | pd.DatetimeIndex,
dates: duckarray | PandasTypes,
units: str | None = None,
calendar: str | None = None,
dtype: np.dtype | None = None,
) -> tuple[duckarray, str, str]: ...
def encode_cf_datetime(
dates: duckarray | pd.Index | pd.DatetimeIndex | chunkedduckarray,
dates: duckarray | PandasTypes | chunkedduckarray,
units: str | None = None,
calendar: str | None = None,
dtype: np.dtype | None = None,
) -> tuple[duckarray | pd.Index | pd.DatetimeIndex | chunkedduckarray, str, str]:
) -> tuple[duckarray | PandasTypes | chunkedduckarray, str, str]:
"""Given an array of datetime objects, returns the tuple `(num, units,
calendar)` suitable for a CF compliant time variable.

@@ -753,12 +755,12 @@ def encode_cf_datetime(


def _eagerly_encode_cf_datetime(
dates: duckarray | pd.Index | pd.DatetimeIndex,
dates: duckarray | PandasTypes,
units: str | None = None,
calendar: str | None = None,
dtype: np.dtype | None = None,
allow_units_modification: bool = True,
) -> tuple[duckarray | pd.Index | pd.DatetimeIndex, str, str]:
) -> tuple[duckarray | PandasTypes, str, str]:
dates = asarray(dates)

data_units = infer_datetime_units(dates)
@@ -840,7 +842,7 @@ def _encode_cf_datetime_within_map_blocks(
units: str,
calendar: str,
dtype: np.dtype,
) -> duckarray | pd.Index | pd.DatetimeIndex:
) -> duckarray | PandasTypes:
num, *_ = _eagerly_encode_cf_datetime(
dates, units, calendar, dtype, allow_units_modification=False
)
@@ -893,12 +895,12 @@ def encode_cf_timedelta(
) -> tuple[chunkedduckarray, str]: ...
@overload
def encode_cf_timedelta(
timedeltas: duckarray,
timedeltas: duckarray | PandasTypes,
units: str | None = None,
dtype: np.dtype | None = None,
) -> tuple[duckarray, str]: ...
def encode_cf_timedelta(
timedeltas: chunkedduckarray | duckarray,
timedeltas: chunkedduckarray | duckarray | PandasTypes,
units: str | None = None,
dtype: np.dtype | None = None,
) -> tuple[chunkedduckarray | duckarray, str]: