From ae2aadc6c9c0b98ab6540fc0bd0f1b915d5f5d2c Mon Sep 17 00:00:00 2001 From: Alexander Kislukhin <47034358+liquidcarbon@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:40:38 -0700 Subject: [PATCH] revert Dataset.pl; it needs pyarrow after all --- affinity.py | 2 +- pyproject.toml | 6 +----- test_affinity.py | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/affinity.py b/affinity.py index de49d19..8f9aa83 100644 --- a/affinity.py +++ b/affinity.py @@ -348,7 +348,7 @@ def arrow(self) -> "pa.Table": @property def pl(self) -> "pl.DataFrame": - return pl.DataFrame(self.dict) + return pl.DataFrame(dict(self)) def is_dataset(self, key): attr = getattr(self, key, None) diff --git a/pyproject.toml b/pyproject.toml index b5c37d6..764636e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,13 +19,9 @@ dependencies = [ [dependency-groups] dev = [ - "pytest>=8", -] -polars = [ "polars>=1", -] -pyarrow = [ "pyarrow>=17", + "pytest>=8", ] [tool.hatch.build] diff --git a/test_affinity.py b/test_affinity.py index c207795..415ab0a 100644 --- a/test_affinity.py +++ b/test_affinity.py @@ -259,6 +259,7 @@ class aDataset(af.Dataset): @pytest.mark.skipif(NO_POLARS, reason="polars is not installed") +@pytest.mark.skipif(NO_PYARROW, reason="pyarrow is not installed") def test_to_polars(): class aDataset(af.Dataset): v1 = af.VectorBool("") @@ -266,6 +267,7 @@ class aDataset(af.Dataset): v3 = af.VectorI16("") data = aDataset(v1=[True], v2=[1 / 2], v3=[999]) + # this requires polars AND pyarrow because conversion goes via pd.Series polars_df = data.pl assert str(polars_df.dtypes) == "[Boolean, Float32, Int16]"