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

make compatible with polars 1.0 #77

Merged
merged 1 commit into from
Jun 12, 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
4 changes: 3 additions & 1 deletion polars_xdt/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@


if parse_version(pl.__version__) < parse_version("0.20.16"):
from polars.utils.udfs import _get_shared_lib_location
from polars.utils.udfs import ( # type: ignore[import-not-found]
_get_shared_lib_location,
)

lib: str | Path = _get_shared_lib_location(__file__)
else:
Expand Down
22 changes: 3 additions & 19 deletions polars_xdt/ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if TYPE_CHECKING:
from datetime import date, datetime, timedelta

from polars.type_aliases import ClosedInterval, IntoExprColumn, TimeUnit
from polars.type_aliases import ClosedInterval, IntoExprColumn


@overload
Expand All @@ -20,8 +20,6 @@ def date_range(
interval: str | timedelta = "1d",
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[False] = ...,
weekend: Sequence[str] = ...,
holidays: Sequence[date] | None = ...,
Expand All @@ -35,8 +33,6 @@ def date_range(
interval: str | timedelta = "1d",
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: Literal[True],
weekend: Sequence[str] = ...,
holidays: Sequence[date] | None = ...,
Expand All @@ -50,22 +46,18 @@ def date_range(
interval: str | timedelta = "1d",
*,
closed: ClosedInterval = ...,
time_unit: TimeUnit | None = ...,
time_zone: str | None = ...,
eager: bool = ...,
weekend: Sequence[str] = ...,
holidays: Sequence[date] | None = ...,
) -> pl.Series | pl.Expr: ...


def date_range( # noqa: PLR0913
start: date | datetime | IntoExprColumn,
end: date | datetime | IntoExprColumn,
start: date | IntoExprColumn,
end: date | IntoExprColumn,
interval: str | timedelta = "1bd",
*,
closed: ClosedInterval = "both",
time_unit: TimeUnit | None = None,
time_zone: str | None = None,
eager: bool = False,
weekend: Sequence[str] = ("Sat", "Sun"),
holidays: Sequence[date] | None = None,
Expand All @@ -87,12 +79,6 @@ def date_range( # noqa: PLR0913
"Examples" section below).
closed : {'both', 'left', 'right', 'none'}
Define which sides of the range are closed (inclusive).
time_unit : {None, 'ns', 'us', 'ms'}
Time unit of the resulting ``Datetime`` data type.
Only takes effect if the output column is of type ``Datetime``.
time_zone
Time zone of the resulting ``Datetime`` data type.
Only takes effect if the output column is of type ``Datetime``.
eager
Evaluate immediately and return a ``Series``.
If set to ``False`` (default), return an expression instead.
Expand Down Expand Up @@ -152,8 +138,6 @@ def date_range( # noqa: PLR0913
end,
interval,
closed=closed,
time_unit=time_unit,
time_zone=time_zone,
eager=False,
)
expr = expr.filter(~expr.dt.date().is_in(holidays))
Expand Down
Loading