Skip to content

Commit

Permalink
revert Dataset.pl; it needs pyarrow after all
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidcarbon authored Nov 12, 2024
1 parent 6e95a80 commit ae2aadc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion affinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ dependencies = [

[dependency-groups]
dev = [
"pytest>=8",
]
polars = [
"polars>=1",
]
pyarrow = [
"pyarrow>=17",
"pytest>=8",
]

[tool.hatch.build]
Expand Down
2 changes: 2 additions & 0 deletions test_affinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ 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("")
v2 = af.VectorF32("")
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]"

Expand Down

0 comments on commit ae2aadc

Please sign in to comment.