Skip to content

Commit

Permalink
ci: add python 3.13 to CI GHA (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi authored Nov 2, 2024
1 parent e11b284 commit 96e0d79
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
#, macos-latest
#, windows-latest
]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ docstring-code-format = true

[tool.ruff.lint.isort]
force-single-line = true
required-imports = ["from __future__ import annotations"]

[tool.interrogate]
ignore-nested-functions = true
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any
from typing import Dict
from typing import List
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sklearn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from contextlib import nullcontext as does_not_raise

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions tests/test_splitstate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import date
from datetime import datetime
from datetime import timedelta
Expand Down
2 changes: 2 additions & 0 deletions tests/test_timebasedsplit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from contextlib import nullcontext as does_not_raise
from datetime import date
from datetime import datetime
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from contextlib import nullcontext as does_not_raise

import narwhals.stable.v1 as nw
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/test_funcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import operator
from typing import Callable
from typing import List
Expand Down
2 changes: 2 additions & 0 deletions timebasedcv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from importlib import metadata

from timebasedcv.core import ExpandingTimeSplit
Expand Down
6 changes: 4 additions & 2 deletions timebasedcv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def _splits_from_period(
msg = "`time_start` must be before `time_end`."
raise ValueError(msg)

is_rolling_window = self.window_ == "rolling"

if self.mode_ == "forward":
train_delta = self.train_delta
forecast_delta = self.forecast_delta
Expand All @@ -232,13 +234,13 @@ def _splits_from_period(
forecast_end = time_end
forecast_start = forecast_end + forecast_delta
train_end = forecast_start + gap_delta
train_start = train_end + train_delta if self.window_ == "rolling" else time_start
train_start = train_end + train_delta if is_rolling_window else time_start

while (forecast_start <= time_end) and (train_start >= time_start) and (train_start <= train_end + train_delta):
yield SplitState(train_start, train_end, forecast_start, forecast_end)

# Update state values
train_start = train_start + stride_delta if self.window_ == "rolling" else train_start
train_start = train_start + stride_delta if is_rolling_window else train_start
train_end = train_end + stride_delta
forecast_start = forecast_start + stride_delta
forecast_end = forecast_end + stride_delta
Expand Down
8 changes: 6 additions & 2 deletions timebasedcv/utils/_backends.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Callable
from typing import Dict
from typing import TypeVar

import narwhals.stable.v1 as nw
import numpy as np

from timebasedcv.utils._types import SeriesLike
from timebasedcv.utils._types import TensorLike
if TYPE_CHECKING:
from timebasedcv.utils._types import SeriesLike
from timebasedcv.utils._types import TensorLike


def default_indexing_method(arr: TensorLike, mask: SeriesLike) -> TensorLike:
Expand Down
2 changes: 2 additions & 0 deletions timebasedcv/utils/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from itertools import tee
from typing import Callable
from typing import Iterable
Expand Down

0 comments on commit 96e0d79

Please sign in to comment.