Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Dec 27, 2024
1 parent 9ca433c commit 2eb7ae2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions py-polars/polars/expr/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -2940,8 +2940,8 @@ def normalize(self, form: UnicodeForm = "NFC") -> Expr:
--------
>>> df = pl.DataFrame({"text": ["01²", "KADOKAWA"]})
>>> new = df.with_columns(
... nfc = pl.col("text").str.normalize("NFC"),
... nfkc = pl.col("text").str.normalize("NFKC")
... nfc=pl.col("text").str.normalize("NFC"),
... nfkc=pl.col("text").str.normalize("NFKC"),
... )
>>> new
shape: (2, 3)
Expand All @@ -2963,7 +2963,7 @@ def normalize(self, form: UnicodeForm = "NFC") -> Expr:
│ 4 ┆ 4 ┆ 3 │
│ 24 ┆ 24 ┆ 8 │
└──────┴─────┴──────┘
""" # noqa: RUF002
""" # noqa: RUF002
return wrap_expr(self._pyexpr.str_normalize(form))


Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/series/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,4 +2259,4 @@ def normalize(self, form: UnicodeForm = "NFC") -> Series:
"012"
"KADOKAWA"
]
""" # noqa: RUF002
""" # noqa: RUF002
12 changes: 6 additions & 6 deletions py-polars/tests/unit/operations/namespaces/string/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -1848,23 +1848,23 @@ def test_escape_regex() -> None:
assert_frame_equal(result_df, expected_df)
assert_series_equal(result_df["escaped"], expected_df["escaped"])


@pytest.mark.parametrize(
("form", "expected_data"),
[
("NFC", ["01²", "KADOKAWA"]), # noqa: RUF001
("NFD", ["01²", "KADOKAWA"]), # noqa: RUF001
("NFC", ["01²", "KADOKAWA"]), # noqa: RUF001
("NFD", ["01²", "KADOKAWA"]), # noqa: RUF001
("NFKC", ["012", "KADOKAWA"]),
("NFKD", ["012", "KADOKAWA"]),
],
)
def test_string_normalize(
form: str, expected_data: list[str | None]
) -> None:
s = pl.Series(["01²", "KADOKAWA"], dtype=pl.String) # noqa: RUF001
def test_string_normalize(form: str, expected_data: list[str | None]) -> None:
s = pl.Series(["01²", "KADOKAWA"], dtype=pl.String) # noqa: RUF001
res = s.str.normalize(form)
expected_s = pl.Series(expected_data, dtype=pl.String)
assert_series_equal(res, expected_s)


def test_string_normalize_wrong_input() -> None:
with pytest.raises(ValueError, match="`form` must be one of"):
pl.Series(["01²"], dtype=pl.String).str.normalize("foobar")

0 comments on commit 2eb7ae2

Please sign in to comment.