-
Notifications
You must be signed in to change notification settings - Fork 89
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
chore: Factor out _polars from top-level Narwhals modules (i.e.: the mother of all refactors!) #561
chore: Factor out _polars from top-level Narwhals modules (i.e.: the mother of all refactors!) #561
Conversation
def func(plx: Any) -> Any: | ||
if ( | ||
(pl := get_polars()) is not None | ||
and plx is pl | ||
and parse_version(pl.__version__) <= (0, 20, 4) | ||
): # pragma: no cover | ||
return plx.count().alias("len") | ||
return plx.len() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally...that was really dirty, so glad we've finally got a better way
def validate_same_library(items: Iterable[Any]) -> None: | ||
if all(item._is_polars for item in items): | ||
return | ||
if all(hasattr(item._compliant_frame, "_implementation") for item in items) and ( | ||
len({item._compliant_frame._implementation for item in items}) == 1 | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function's good, it's just going to be intractable to enforce the "same-library-constraint" everywhere...rather than rewrite it, I'd prefer to just not bother
trying to compare different libraries raises an error anyway, it doesn't do something dangerous like silently give wrong results
what this achives:
but hopefully, it makes the project easier to understand, and most importantly, easy to contribute to |
What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below.