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

chore: Factor out _polars from top-level Narwhals modules (i.e.: the mother of all refactors!) #561

Merged
merged 41 commits into from
Jul 20, 2024

Conversation

MarcoGorelli
Copy link
Member

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #
  • Closes #

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below.

Comment on lines 3131 to 3132
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()
Copy link
Member Author

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

Comment on lines -88 to -93
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
):
Copy link
Member Author

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

@MarcoGorelli MarcoGorelli marked this pull request as ready for review July 20, 2024 16:59
@MarcoGorelli
Copy link
Member Author

what this achives:

  • bug fixed: 0
  • features added: 0

but hopefully, it makes the project easier to understand, and most importantly, easy to contribute to

@MarcoGorelli MarcoGorelli merged commit fb80986 into narwhals-dev:main Jul 20, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant