Skip to content

Commit

Permalink
Merge branch 'main' into narwhals
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart authored Sep 13, 2024
2 parents 42ef8ac + e288b47 commit 34c4789
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_categorical_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,13 @@ def test_cat_property(input_type):
np.testing.assert_array_equal(
cat_out["categories"], cat_vec.categories.to_numpy()
)


def test_polars_non_contiguous_codes():
str_series = ["labrador", "boxer", "beagle"]
with pl.StringCache():
_ = pl.Series(["beagle", "poodle", "labrador"], dtype=pl.Categorical)
cat_series = pl.Series(str_series, dtype=pl.Categorical)

indices, categories = _extract_codes_and_categories(cat_series)
np.testing.assert_array_equal(str_series, categories[indices].tolist())

0 comments on commit 34c4789

Please sign in to comment.