Skip to content

Commit

Permalink
Add python types
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed May 28, 2024
1 parent f98d685 commit 8428903
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
54 changes: 54 additions & 0 deletions arro3-core/python/arro3/core/_rust.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from typing import Self
from numpy.typing import NDArray

from .types import ArrowArrayExportable, ArrowSchemaExportable, ArrowStreamExportable

class Array:
def __array__(self) -> NDArray: ...
def __arrow_c_array__(self, requested_schema) -> object: ...
def __eq__(self) -> bool: ...
def __len__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowArrayExportable) -> Self: ...
def to_numpy(self) -> NDArray: ...

class ChunkedArray:
def __array__(self) -> NDArray: ...
def __arrow_c_stream__(self, requested_schema) -> object: ...
def __eq__(self) -> bool: ...
def __len__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowStreamExportable) -> Self: ...
def to_numpy(self) -> NDArray: ...

class Field:
def __arrow_c_schema__(self) -> object: ...
def __eq__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowSchemaExportable) -> Self: ...

class RecordBatch:
def __arrow_c_array__(self, requested_schema) -> object: ...
def __eq__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowArrayExportable) -> Self: ...

class RecordBatchReader:
def __arrow_c_stream__(self, requested_schema) -> object: ...
@classmethod
def from_arrow(cls, input: ArrowStreamExportable) -> Self: ...
def schema(self) -> Schema: ...

class Schema:
def __arrow_c_schema__(self) -> object: ...
def __eq__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowSchemaExportable) -> Self: ...

class Table:
def __arrow_c_stream__(self, requested_schema) -> object: ...
def __eq__(self) -> bool: ...
def __len__(self) -> bool: ...
@classmethod
def from_arrow(cls, input: ArrowStreamExportable) -> Self: ...
def schema(self) -> Schema: ...
Empty file.
23 changes: 23 additions & 0 deletions arro3-core/python/arro3/core/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import annotations

from typing import Protocol, Tuple


class ArrowSchemaExportable(Protocol):
"""An Arrow or GeoArrow schema or field."""

def __arrow_c_schema__(self) -> object: ...


class ArrowArrayExportable(Protocol):
"""An Arrow or GeoArrow array or RecordBatch."""

def __arrow_c_array__(
self, requested_schema: object | None = None
) -> Tuple[object, object]: ...


class ArrowStreamExportable(Protocol):
"""An Arrow or GeoArrow ChunkedArray or Table."""

def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...

0 comments on commit 8428903

Please sign in to comment.