time-split 1.2.0__tar.gz → 1.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {time_split-1.2.0 → time_split-1.2.1}/LICENSE.md +1 -1
  2. {time_split-1.2.0 → time_split-1.2.1}/PKG-INFO +1 -2
  3. {time_split-1.2.0 → time_split-1.2.1}/README.md +0 -1
  4. {time_split-1.2.0 → time_split-1.2.1}/pyproject.toml +15 -14
  5. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/__init__.py +1 -1
  6. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_limits.py +9 -7
  7. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_schedule.py +2 -1
  8. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_span.py +2 -1
  9. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_splitter.py +2 -2
  10. time_split-1.2.1/src/time_split/_compat.py +14 -0
  11. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/_plot.py +6 -7
  12. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/_weight.py +2 -1
  13. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/__main__.py +0 -0
  14. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/__init__.py +0 -0
  15. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_datetime_index_like.py +0 -0
  16. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_backend/_process_available.py +0 -0
  17. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_docstrings.py +0 -0
  18. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/__init__.py +0 -0
  19. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/_progress.py +0 -0
  20. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/_split.py +0 -0
  21. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_frontend/_to_string.py +0 -0
  22. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/_support.py +0 -0
  23. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/app/__init__.py +0 -0
  24. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/app/_create_explorer_link.py +0 -0
  25. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/app/reexport/__init__.py +0 -0
  26. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/cli.py +0 -0
  27. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/__init__.py +0 -0
  28. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/_log_progress.py +0 -0
  29. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/base.py +0 -0
  30. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/pandas/__init__.py +0 -0
  31. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/pandas/_impl.py +0 -0
  32. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/polars/__init__.py +0 -0
  33. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/polars/_impl.py +0 -0
  34. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/sklearn/__init__.py +0 -0
  35. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/integration/sklearn/_impl.py +0 -0
  36. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/py.typed +0 -0
  37. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/settings.py +0 -0
  38. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/support/__init__.py +0 -0
  39. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/support/types.py +0 -0
  40. {time_split-1.2.0 → time_split-1.2.1}/src/time_split/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2024, Richard Sundqvist
3
+ Copyright © 2026, Richard Sundqvist
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: time-split
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: Time-based k-fold validation splits for heterogeneous data.
5
5
  License: MIT
6
6
  License-File: LICENSE.md
@@ -116,7 +116,6 @@ most recent stable release.
116
116
  Hosted on Read the Docs: https://time-split.readthedocs.io
117
117
 
118
118
  ## Contributing
119
-
120
119
  All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. To get
121
120
  started, see the [Contributing Guide](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md).
122
121
 
@@ -76,7 +76,6 @@ most recent stable release.
76
76
  Hosted on Read the Docs: https://time-split.readthedocs.io
77
77
 
78
78
  ## Contributing
79
-
80
79
  All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. To get
81
80
  started, see the [Contributing Guide](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md).
82
81
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "time-split"
3
- version = "1.2.0"
3
+ version = "1.2.1"
4
4
  description = "Time-based k-fold validation splits for heterogeneous data."
5
5
  authors = [
6
6
  { name = "Richard Sundqvist", email = "richard.sundqvist@live.se" },
@@ -60,38 +60,39 @@ polars = { version = "~1.35.2", extras = ["pandas"] }
60
60
  # duplicate object warnings for sphinx>=4
61
61
  # description: https://github.com/astropy/astropy/issues/11723
62
62
  # https://github.com/astropy/astropy/pull/12270
63
- sphinx = "~8.1.3" # 8.2 breaks xdoc refs in README.md; maybe https://github.com/sphinx-doc/sphinx/issues/13932?
64
- sphinx-gallery = "~0.20.0"
65
- pydata-sphinx-theme = "~0.16.1"
66
- myst-parser = "~4.0.1"
67
- ipython = "~9.8.0"
68
- sphinx-llm = "~0.2.1"
63
+ sphinx = { version = "~9.1.0", python = ">=3.12" }
64
+ sphinx-gallery = { version = "~0.20.0", python = ">=3.12" }
65
+ pydata-sphinx-theme = { version = "~0.16.1", python = ">=3.12" }
66
+ myst-parser = { version = "~5.0.0", python = ">=3.12" } # https://github.com/executablebooks/MyST-Parser/issues/749
67
+ nbsphinx = { version = "~0.9.8", python = ">=3.12" }
68
+ ipython = { version = "~9.10.0", python = ">=3.12" }
69
+ sphinx-llm = { version = "~0.3.0", python = ">=3.12" }
69
70
 
70
71
  [tool.poetry.group.notebooks]
71
72
  optional = true
72
73
  [tool.poetry.group.notebooks.dependencies]
73
- jupyterlab = "~4.4.10"
74
+ jupyterlab = "~4.5.2"
74
75
  ipywidgets = "*"
75
76
  jupyterlab-execute-time = "*"
76
77
  tqdm = "*"
77
78
 
78
79
  [tool.poetry.group.test.dependencies]
79
- pytest = "~9.0.1"
80
+ pytest = "~9.0.2"
80
81
  xdoctest = "~1.3.0"
81
- coverage = "~7.12.0"
82
+ coverage = "~7.13.1"
82
83
  pytest-cov = "~7.0.0"
83
84
 
84
- scikit-learn = "~1.7.2"
85
- dask = { version = "~2025.10.0", extras = ["dataframe"] }
85
+ scikit-learn = "~1.8.0"
86
+ dask = { version = "~2026.1.1", extras = ["dataframe"] }
86
87
 
87
88
  [tool.poetry.group.devops.dependencies]
88
89
  invoke = "~2.2.1"
89
90
  mypy = "~1.19.0"
90
- ruff = "~0.14.8"
91
+ ruff = "~0.14.13"
91
92
 
92
93
  safety = "~3.7.0"
93
94
  codespell = "~2.4.1"
94
- bump2version = "~1.0.1"
95
+ bump2version = "==1.0.1"
95
96
 
96
97
  [tool.ruff]
97
98
  line-length = 120
@@ -9,4 +9,4 @@ __all__ = [
9
9
  "split",
10
10
  ]
11
11
 
12
- __version__ = "1.2.0"
12
+ __version__ = "1.2.1"
@@ -4,6 +4,7 @@ from typing import Any, NamedTuple, TypeGuard
4
4
 
5
5
  from pandas import Timedelta, Timestamp
6
6
 
7
+ from .._compat import fix_pandas4_warning, make_timedelta
7
8
  from ..settings import auto_expand_limits, misc
8
9
  from ..types import ExpandLimits, TimedeltaTypes
9
10
 
@@ -159,19 +160,20 @@ def _levels_from_settings() -> list[_TimedeltaTuple]:
159
160
 
160
161
  def _make_level(
161
162
  start_at: TimedeltaTypes | None,
162
- round_to: TimedeltaTypes,
163
+ round_to: str | Timedelta,
163
164
  tolerance: TimedeltaTypes,
164
165
  ) -> _TimedeltaTuple:
165
- start_at = Timedelta(start_at) # Will be NaT if None, making all ifs False.
166
+ start_at = make_timedelta(start_at) # Will be NaT if None, making all ifs False.
166
167
  if start_at <= Timedelta(0):
167
168
  raise ValueError(f"Bad {start_at=}; must be non-negative.")
168
169
 
169
- try:
170
- round_to = Timedelta(1, unit=round_to)
171
- except ValueError as e:
172
- raise ValueError(f"Got {round_to=}, which is not a valid frequency.") from e
170
+ if isinstance(round_to, str):
171
+ try:
172
+ round_to = Timedelta(1, unit=fix_pandas4_warning(round_to))
173
+ except ValueError as e:
174
+ raise ValueError(f"Got {round_to=}, which is not a valid frequency.") from e
173
175
 
174
- tolerance = Timedelta(tolerance)
176
+ tolerance = make_timedelta(tolerance)
175
177
  if tolerance <= Timedelta(0):
176
178
  raise ValueError(f"Bad {tolerance=}; must be non-negative.")
177
179
 
@@ -2,6 +2,7 @@ from typing import Literal, NamedTuple, get_args
2
2
 
3
3
  from pandas import DatetimeIndex, NaT, Timedelta, Timestamp, date_range
4
4
 
5
+ from .._compat import make_timedelta
5
6
  from ..settings import misc as settings
6
7
  from ..types import DatetimeIterable, ExpandLimits, Schedule, TimedeltaTypes
7
8
  from ._limits import LimitsTuple
@@ -60,7 +61,7 @@ def _cron_like(schedule: str) -> bool:
60
61
 
61
62
 
62
63
  def _from_timedelta(schedule: TimedeltaTypes, limits: LimitsTuple) -> DatetimeIndex:
63
- timedelta = Timedelta(schedule)
64
+ timedelta = make_timedelta(schedule)
64
65
  if timedelta <= Timedelta(0):
65
66
  raise ValueError(f"unbounded {schedule=} must be greater than zero.")
66
67
 
@@ -4,6 +4,7 @@ from typing import Literal, TypeAlias
4
4
 
5
5
  from pandas import DatetimeIndex, Timedelta, Timestamp
6
6
 
7
+ from .._compat import make_timedelta
7
8
  from ..types import Span
8
9
  from ._limits import LimitsTuple
9
10
  from ._schedule import NO_LIMITS
@@ -27,7 +28,7 @@ class InvalidSpanError(ValueError):
27
28
 
28
29
 
29
30
  def _to_timedelta(span: str | timedelta | Timedelta, *, name: SpanArgumentName) -> Timedelta:
30
- retval = Timedelta(span)
31
+ retval = make_timedelta(span)
31
32
  if retval <= Timedelta(0):
32
33
  raise InvalidSpanError(span, name=name)
33
34
  return retval
@@ -1,9 +1,9 @@
1
1
  from dataclasses import asdict, dataclass
2
2
  from typing import cast, get_args
3
3
 
4
- from pandas import Timedelta
5
4
  from rics.misc import format_kwargs, get_by_full_name
6
5
 
6
+ from .._compat import make_timedelta
7
7
  from ..settings import misc as settings
8
8
  from ..types import (
9
9
  DatetimeIndexSplitterKwargs,
@@ -66,7 +66,7 @@ class DatetimeIndexSplitter:
66
66
 
67
67
  from_end = data_end - schedule_end
68
68
  if not isinstance(self.after, int):
69
- after = Timedelta(self.after)
69
+ after = make_timedelta(self.after)
70
70
  from_end -= after
71
71
 
72
72
  return ms._replace(schedule=ms.schedule + from_end)
@@ -0,0 +1,14 @@
1
+ from pandas import Timedelta
2
+
3
+ from time_split.types import TimedeltaTypes
4
+
5
+
6
+ def fix_pandas4_warning(arg: str) -> str:
7
+ return arg[:-1] + "D" if arg.endswith("d") else arg
8
+
9
+
10
+ def make_timedelta(arg: TimedeltaTypes) -> Timedelta:
11
+ if isinstance(arg, str):
12
+ arg = fix_pandas4_warning(arg)
13
+
14
+ return Timedelta(arg)
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from collections.abc import Sized
2
3
  from contextlib import suppress
3
4
  from dataclasses import asdict, dataclass, replace
@@ -11,6 +12,7 @@ from rics.strings import format_seconds as fmt_sec
11
12
  from .._backend import DatetimeIndexSplitter
12
13
  from .._backend._datetime_index_like import DatetimeIndexLike
13
14
  from .._backend._limits import LimitsTuple
15
+ from .._compat import fix_pandas4_warning, make_timedelta
14
16
  from .._docstrings import docs
15
17
  from .._support import handle_dask
16
18
  from ..settings import plot as settings
@@ -27,11 +29,8 @@ from ._split import split
27
29
  from ._to_string import _PrettyTimestamp
28
30
  from ._weight import fold_weight
29
31
 
30
- if TYPE_CHECKING:
31
- try:
32
- from matplotlib.pyplot import Axes # type: ignore[attr-defined]
33
- except ModuleNotFoundError:
34
- Axes = Any # type: ignore[misc, assignment]
32
+ if TYPE_CHECKING or os.environ.get("SPHINX_BUILD") is True:
33
+ from matplotlib.axes import Axes # noqa: TC002
35
34
 
36
35
  Rows = Literal["rows"]
37
36
  COUNT_ROWS: Literal["rows"] = "rows"
@@ -233,7 +232,7 @@ def _plot_row_counts(ax: "Axes", row_count_bin: str | pd.Series, row_counts: pd.
233
232
  pretty = fmt_sec(diff(row_counts.index).min() / timedelta64(1, "s"))
234
233
  else:
235
234
  row_counts = row_counts.sort_index()
236
- pretty = fmt_sec(pd.Timedelta(row_count_bin).total_seconds())
235
+ pretty = fmt_sec(make_timedelta(row_count_bin).total_seconds())
237
236
 
238
237
  row_counts = row_counts * (max(ax.get_yticks()) / row_counts.max()) # Normalize to fold number yaxis
239
238
  ax.fill_between(
@@ -356,7 +355,7 @@ def _compute_row_counts(
356
355
  a_type = get_public_module(type(available), resolve_reexport=True, include_name=True)
357
356
  raise TypeError(f"type(available)={a_type} must have one of `floor` and `dt` to use {row_count_bin=}")
358
357
 
359
- return handle_dask(index_like.floor(row_count_bin).value_counts())
358
+ return handle_dask(index_like.floor(fix_pandas4_warning(row_count_bin)).value_counts())
360
359
 
361
360
 
362
361
  def _make_title(available: Any | None, split_kwargs: dict[str, Any]) -> str:
@@ -2,6 +2,7 @@ from typing import Literal
2
2
 
3
3
  from pandas import DatetimeIndex, Timedelta
4
4
 
5
+ from .._compat import fix_pandas4_warning
5
6
  from .._support import handle_dask
6
7
  from ..types import DatetimeIterable, DatetimeSplitCounts, DatetimeSplits
7
8
 
@@ -35,7 +36,7 @@ def fold_weight(
35
36
 
36
37
 
37
38
  def _from_unit(unit: str, splits: DatetimeSplits) -> list[DatetimeSplitCounts]:
38
- resolution = Timedelta(1, unit=unit)
39
+ resolution = Timedelta(1, unit=fix_pandas4_warning(unit))
39
40
  return [
40
41
  DatetimeSplitCounts(
41
42
  round((fold.mid - fold.start) / resolution),