-
Notifications
You must be signed in to change notification settings - Fork 168
refactor: Add CompliantColumn
#2967
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fe84162
refactor: Add `CompliantColumn`
dangotbanned c24d449
refactor: Add as base for `CompliantSeries`
dangotbanned af0392f
refactor: Add as base for `CompliantExpr`
dangotbanned d594b38
refactor: Reduce some bin op repetition
dangotbanned bf4c781
oops
dangotbanned 4d2c4cc
lol
dangotbanned a132309
no cov pending feedback
dangotbanned 8c6099b
revert: Restore `CompliantSeries`-only rhs operators
dangotbanned 334d7c2
Merge branch 'main' into compliant-column
dangotbanned ef63995
refactor: Move `is_between` impl to `CompliantColumn`
dangotbanned 3695b08
refactor: Move `is_duplicated` impl to `CompliantColumn`
dangotbanned 893e366
refactor: Move `is_empty` impl to `CompliantSeries`
dangotbanned 53923f7
revert: no cov
dangotbanned f522e8f
Merge branch 'main' into compliant-column
dangotbanned 4505d59
Merge branch 'main' into compliant-column
dangotbanned 0719af4
Merge remote-tracking branch 'upstream/main' into compliant-column
dangotbanned d00b12c
refactor: Move `is_close` to `CompliantColumn`
dangotbanned b7abac8
Merge branch 'main' into compliant-column
dangotbanned File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING, Any, Protocol | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Mapping, Sequence | ||
|
|
||
| from typing_extensions import Self | ||
|
|
||
| from narwhals._compliant.any_namespace import ( | ||
| CatNamespace, | ||
| DateTimeNamespace, | ||
| ListNamespace, | ||
| StringNamespace, | ||
| StructNamespace, | ||
| ) | ||
| from narwhals._compliant.namespace import CompliantNamespace | ||
| from narwhals._utils import Version | ||
| from narwhals.typing import ( | ||
| ClosedInterval, | ||
| FillNullStrategy, | ||
| IntoDType, | ||
| NonNestedLiteral, | ||
| NumericLiteral, | ||
| RankMethod, | ||
| TemporalLiteral, | ||
| ) | ||
|
|
||
| __all__ = ["CompliantColumn"] | ||
|
|
||
|
|
||
| class CompliantColumn(Protocol): | ||
| """Common parts of `Expr`, `Series`.""" | ||
|
|
||
| _version: Version | ||
|
|
||
| def __add__(self, other: Any) -> Self: ... | ||
| def __and__(self, other: Any) -> Self: ... | ||
| def __eq__(self, other: object) -> Self: ... # type: ignore[override] | ||
| def __floordiv__(self, other: Any) -> Self: ... | ||
| def __ge__(self, other: Any) -> Self: ... | ||
| def __gt__(self, other: Any) -> Self: ... | ||
| def __invert__(self) -> Self: ... | ||
| def __le__(self, other: Any) -> Self: ... | ||
| def __lt__(self, other: Any) -> Self: ... | ||
| def __mod__(self, other: Any) -> Self: ... | ||
| def __mul__(self, other: Any) -> Self: ... | ||
| def __ne__(self, other: object) -> Self: ... # type: ignore[override] | ||
| def __or__(self, other: Any) -> Self: ... | ||
| def __pow__(self, other: Any) -> Self: ... | ||
| def __radd__(self, other: Any) -> Self: ... | ||
| def __rand__(self, other: Any) -> Self: ... | ||
| def __rfloordiv__(self, other: Any) -> Self: ... | ||
| def __rmod__(self, other: Any) -> Self: ... | ||
| def __rmul__(self, other: Any) -> Self: ... | ||
| def __ror__(self, other: Any) -> Self: ... | ||
| def __rpow__(self, other: Any) -> Self: ... | ||
| def __rsub__(self, other: Any) -> Self: ... | ||
| def __rtruediv__(self, other: Any) -> Self: ... | ||
| def __sub__(self, other: Any) -> Self: ... | ||
| def __truediv__(self, other: Any) -> Self: ... | ||
|
|
||
| def __narwhals_namespace__(self) -> CompliantNamespace[Any, Any]: ... | ||
|
|
||
| def abs(self) -> Self: ... | ||
| def alias(self, name: str) -> Self: ... | ||
| def cast(self, dtype: IntoDType) -> Self: ... | ||
| def clip( | ||
| self, | ||
| lower_bound: Self | NumericLiteral | TemporalLiteral | None, | ||
| upper_bound: Self | NumericLiteral | TemporalLiteral | None, | ||
| ) -> Self: ... | ||
| def cum_count(self, *, reverse: bool) -> Self: ... | ||
| def cum_max(self, *, reverse: bool) -> Self: ... | ||
| def cum_min(self, *, reverse: bool) -> Self: ... | ||
| def cum_prod(self, *, reverse: bool) -> Self: ... | ||
| def cum_sum(self, *, reverse: bool) -> Self: ... | ||
| def diff(self) -> Self: ... | ||
| def drop_nulls(self) -> Self: ... | ||
| def ewm_mean( | ||
| self, | ||
| *, | ||
| com: float | None, | ||
| span: float | None, | ||
| half_life: float | None, | ||
| alpha: float | None, | ||
| adjust: bool, | ||
| min_samples: int, | ||
| ignore_nulls: bool, | ||
| ) -> Self: ... | ||
| def exp(self) -> Self: ... | ||
| def sqrt(self) -> Self: ... | ||
| def fill_null( | ||
| self, | ||
| value: Self | NonNestedLiteral, | ||
| strategy: FillNullStrategy | None, | ||
| limit: int | None, | ||
| ) -> Self: ... | ||
| def is_between( | ||
| self, lower_bound: Any, upper_bound: Any, closed: ClosedInterval | ||
| ) -> Self: ... | ||
| def is_finite(self) -> Self: ... | ||
| def is_first_distinct(self) -> Self: ... | ||
| def is_in(self, other: Any) -> Self: ... | ||
| def is_last_distinct(self) -> Self: ... | ||
| def is_nan(self) -> Self: ... | ||
| def is_null(self) -> Self: ... | ||
| def is_unique(self) -> Self: ... | ||
| def log(self, base: float) -> Self: ... | ||
| def mode(self) -> Self: ... | ||
| def rank(self, method: RankMethod, *, descending: bool) -> Self: ... | ||
| def replace_strict( | ||
| self, | ||
| old: Sequence[Any] | Mapping[Any, Any], | ||
| new: Sequence[Any], | ||
| *, | ||
| return_dtype: IntoDType | None, | ||
| ) -> Self: ... | ||
| def rolling_mean( | ||
| self, window_size: int, *, min_samples: int, center: bool | ||
| ) -> Self: ... | ||
| def rolling_std( | ||
| self, window_size: int, *, min_samples: int, center: bool, ddof: int | ||
| ) -> Self: ... | ||
| def rolling_sum( | ||
| self, window_size: int, *, min_samples: int, center: bool | ||
| ) -> Self: ... | ||
| def rolling_var( | ||
| self, window_size: int, *, min_samples: int, center: bool, ddof: int | ||
| ) -> Self: ... | ||
| def round(self, decimals: int) -> Self: ... | ||
| def shift(self, n: int) -> Self: ... | ||
| def unique(self) -> Self: ... | ||
|
|
||
| @property | ||
| def str(self) -> StringNamespace[Self]: ... | ||
| @property | ||
| def dt(self) -> DateTimeNamespace[Self]: ... | ||
| @property | ||
| def cat(self) -> CatNamespace[Self]: ... | ||
| @property | ||
| def list(self) -> ListNamespace[Self]: ... | ||
| @property | ||
| def struct(self) -> StructNamespace[Self]: ... | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.