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

ci: add py 3.13 to GHA #61

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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