Skip to content

Commit

Permalink
Merge pull request #77 from pola-rs/compat-1.0
Browse files Browse the repository at this point in the history
make compatible with polars 1.0
  • Loading branch information
MarcoGorelli authored Jun 12, 2024
2 parents df47882 + d374f76 commit 9c26aa6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
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

0 comments on commit 9c26aa6

Please sign in to comment.