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

avoid private _utils import #23

Merged
merged 1 commit into from
Mar 14, 2024
Merged
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
13 changes: 1 addition & 12 deletions polars_hash/polars_hash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
from typing import Iterable, Protocol, cast

import polars as pl
from packaging.version import Version
from polars.type_aliases import IntoExpr, PolarsDataType
from polars.utils.udfs import _get_shared_lib_location

from polars_hash._internal import __version__ as __version__

if Version(pl.__version__) >= Version("0.20.14"):
from polars._utils.parse_expr_input import parse_as_expression
from polars._utils.wrap import wrap_expr
else:
# old locations prior to https://github.com/pola-rs/polars/commit/b8d7a0f5492b662787d790c35712f0daabd01429
from polars.utils._parse_expr_input import parse_as_expression # type: ignore
from polars.utils._wrap import wrap_expr # type: ignore


lib = _get_shared_lib_location(__file__)


Expand Down Expand Up @@ -158,10 +148,9 @@ def to_coords(self) -> pl.Expr:

def from_coords(self, len: int | str | pl.Expr = 12) -> pl.Expr:
"""Takes Struct with latitude, longitude as input and returns utf8 hash using geohash."""
len_expr = wrap_expr(parse_as_expression(len))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I believe still needs to used because input can also be int or str,

Copy link
Contributor Author

@MarcoGorelli MarcoGorelli Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't Polars take care of this here

https://github.com/pola-rs/polars/blob/b957d53aa6d835e5c456bc98943cde960658633d/py-polars/polars/expr/expr.py#L9680-L9683

?

so long as self is an expression, I think it should be fine

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I did not know that :) that's nice!

return self._expr.register_plugin(
lib=lib,
args=[len_expr],
args=[len],
symbol="ghash_encode",
is_elementwise=True,
)
Expand Down
Loading