Skip to content

Commit

Permalink
More DataType methods (#78)
Browse files Browse the repository at this point in the history
* Export DataType constructors

* Added DataType methods
  • Loading branch information
kylebarron authored Jul 30, 2024
1 parent 6e93771 commit 7a9eeaa
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 9 deletions.
7 changes: 3 additions & 4 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
rm -rf .venv
poetry install
# Note: need to install core first because others depend on core
poetry run maturin build -m arro3-core/Cargo.toml -o dist
poetry run maturin build -m arro3-compute/Cargo.toml -o dist
poetry run maturin build -m arro3-io/Cargo.toml -o dist
poetry run pip install dist/*
poetry run maturin develop -m arro3-core/Cargo.toml
poetry run maturin develop -m arro3-compute/Cargo.toml
poetry run maturin develop -m arro3-io/Cargo.toml
poetry run mkdocs serve
```
145 changes: 145 additions & 0 deletions arro3-core/python/arro3/core/_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,43 @@ class DataType:
@classmethod
def from_arrow_pycapsule(cls, capsule) -> DataType:
"""Construct this object from a bare Arrow PyCapsule"""
@property
def bit_width(self) -> int | None: ...
def equals(
self, other: ArrowSchemaExportable, *, check_metadata: bool = False
) -> bool:
"""Return true if type is equivalent to passed value.
Args:
other: _description_
check_metadata: Whether nested Field metadata equality should be checked as well. Defaults to False.
Returns:
_description_
"""
@property
def list_size(self) -> int | None:
"""The size of the list in the case of fixed size lists.
This will return `None` if the data type is not a fixed size list.
Examples:
```py
from arro3.core import DataType
DataType.list(DataType.int32(), 2).list_size
# 2
```
Returns:
_description_
"""
@property
def num_fields(self) -> int:
"""The number of child fields."""
#################
#### Constructors
#################
@classmethod
def null(cls) -> DataType:
"""Create instance of null type."""
Expand Down Expand Up @@ -383,6 +418,116 @@ class DataType:
_description_
"""

##################
#### Type Checking
##################
@staticmethod
def is_boolean(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_integer(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_signed_integer(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_unsigned_integer(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_int8(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_int16(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_int32(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_int64(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_uint8(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_uint16(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_uint32(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_uint64(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_floating(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_float16(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_float32(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_float64(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_decimal(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_decimal128(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_decimal256(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_list(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_large_list(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_fixed_size_list(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_list_view(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_large_list_view(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_struct(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_union(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_nested(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_run_end_encoded(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_temporal(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_timestamp(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_date(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_date32(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_date64(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_time(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_time32(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_time64(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_duration(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_interval(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_null(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_binary(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_unicode(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_string(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_large_binary(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_large_unicode(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_large_string(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_binary_view(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_string_view(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_fixed_size_binary(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_map(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_dictionary(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_primitive(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_numeric(t: ArrowSchemaExportable) -> bool: ...
@staticmethod
def is_dictionary_key_type(t: ArrowSchemaExportable) -> bool: ...

class Field:
def __init__(
self,
Expand Down
8 changes: 8 additions & 0 deletions docs/api/core/datatype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# arro3.core.DataType

::: arro3.core.DataType
options:
filters:
- "!^_"
- "^__arrow"
show_if_no_docstring: true
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ nav:
- api/core/record-batch.md
- api/core/schema.md
- api/core/table.md
- api/core/datatype.md
- api/core/types.md
- api/compute.md
- api/io.md
Expand Down
Loading

0 comments on commit 7a9eeaa

Please sign in to comment.