Skip to content

Commit

Permalink
Misc data type fixes (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Aug 1, 2024
1 parent 30be5ca commit 8221181
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 2 deletions.
95 changes: 94 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyo3-arrow/src/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ impl PyDataType {
#[getter]
fn value_type(&self, py: Python) -> PyResult<Option<PyObject>> {
match &self.0 {
DataType::List(value_field)
DataType::FixedSizeList(value_field, _)
| DataType::List(value_field)
| DataType::LargeList(value_field)
| DataType::ListView(value_field)
| DataType::LargeListView(value_field)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pyarrow = "^17.0.0"
ipykernel = "^6.29.5"
maturin = "^1.7.0"
geoarrow-types = "^0.2.0"
pandas = "^2.2.2"

[tool.poetry.group.docs.dependencies]
# We use ruff format ourselves, but mkdocstrings requires black to be installed
Expand Down
13 changes: 13 additions & 0 deletions tests/core/test_data_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from arro3.core import DataType, Field


def test_value_type_fixed_size_list_type():
value_type = DataType.int8()
list_dt = DataType.list(Field("inner", value_type), 2)
assert list_dt.value_type == value_type


@pytest.mark.xfail
def test_list_data_type_construction_with_dt():
_ = DataType.list(DataType.int16())
11 changes: 11 additions & 0 deletions tests/core/test_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import geoarrow.types as gt
import numpy as np
import pandas as pd
import pyarrow as pa
import pytest
from arro3.core import ChunkedArray, Table


Expand Down Expand Up @@ -44,3 +46,12 @@ def test_table_append_array_extension_type():
meta = geo_table.schema["geometry"].metadata
assert b"ARROW:extension:name" in meta.keys()
assert meta[b"ARROW:extension:name"] == b"geoarrow.point"


@pytest.mark.xfail
# from_batches fails on empty column with positive length
def test_table_from_batches_empty_columns_with_len():
df = pd.DataFrame({"a": [1, 2, 3]})
no_columns = df[[]]
pa_table = pa.Table.from_pandas(no_columns)
_table = Table.from_batches(pa_table.to_batches())

0 comments on commit 8221181

Please sign in to comment.