Skip to content

Commit

Permalink
better expression handling and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erichutchins committed Aug 16, 2024
1 parent 50fc6b8 commit d5f358c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 100 deletions.
9 changes: 8 additions & 1 deletion polars_iptools/iptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ def numeric_to_ipv4(expr: IntoExpr) -> pl.Expr:
"""
Returns IPv4 address string from its numeric representation
"""
# Convert to a polars expression if not already one
if isinstance(expr, str):
expr = pl.col(expr)
elif isinstance(expr, pl.Series):
expr = pl.lit(expr)

# cast to UInt32 and leave any errors as nulls
expr = pl.select(expr).to_series().cast(pl.UInt32, strict=False)
expr = expr.cast(pl.UInt32, strict=False)

return register_plugin_function(
args=[expr],
plugin_path=LIB,
Expand Down
98 changes: 0 additions & 98 deletions polars_iptools/utils.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=1.0,<2.0", "polars>=0.20.6"]
requires = ["maturin>=1.0,<2.0", "polars>=1.3.0"]
build-backend = "maturin"

[project]
Expand Down

0 comments on commit d5f358c

Please sign in to comment.