diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi index 946c82b25824..9bfe9750b061 100644 --- a/python/pyarrow/array.pxi +++ b/python/pyarrow/array.pxi @@ -1531,7 +1531,7 @@ cdef class Array(_PandasConvertible): return np.array(values, dtype=dtype, copy=False) values = self.to_numpy(zero_copy_only=False) - if copy is True and is_numeric(self.type.id) and self.null_count == 0: + if copy is True and is_numeric(self.type) and self.null_count == 0: # to_numpy did not yet make a copy (is_numeric = integer/floats, no decimal) return np.array(values, dtype=dtype, copy=True) diff --git a/python/pyarrow/compute.py b/python/pyarrow/compute.py index 83612f66d21e..af35718e1a3c 100644 --- a/python/pyarrow/compute.py +++ b/python/pyarrow/compute.py @@ -397,7 +397,7 @@ def cast(arr, target_type=None, safe=None, options=None, memory_pool=None): " or pass a value for 'options'") if options is None: - target_type = pa.types.lib.ensure_type(target_type) + target_type = pa.lib.ensure_type(target_type) if safe is False: options = CastOptions.unsafe(target_type) else: diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index f461513e8b3c..4cf0b5735050 100644 --- a/python/pyarrow/includes/libarrow.pxd +++ b/python/pyarrow/includes/libarrow.pxd @@ -172,9 +172,6 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: CDataTypeLayout layout() c_string ToString() - c_bool is_primitive(Type type) - c_bool is_numeric(Type type) - cdef cppclass CArrayData" arrow::ArrayData": shared_ptr[CDataType] type int64_t length @@ -3026,3 +3023,34 @@ cdef extern from "arrow/python/udf.h" namespace "arrow::py" nogil: cdef extern from "arrow/compute/cast.h" namespace "arrow::compute": CResult[CDatum] Cast(const CDatum& value, const CCastOptions& options) + +cdef extern from "arrow/type_traits.h" namespace "arrow": + c_bool c_is_integer "is_integer"(Type type_id) + c_bool c_is_signed_integer "is_signed_integer"(Type type_id) + c_bool c_is_unsigned_integer "is_unsigned_integer"(Type type_id) + c_bool c_is_floating "is_floating"(Type type_id) + c_bool c_is_numeric "is_numeric"(Type type_id) + c_bool c_is_decimal "is_decimal"(Type type_id) + c_bool c_is_run_end "is_run_end_type"(Type type_id) + c_bool c_is_primitive "is_primitive"(Type type_id) + c_bool c_is_base_binary_like "is_base_binary_like"(Type type_id) + c_bool c_is_binary_like "is_binary_like"(Type type_id) + c_bool c_is_large_binary_like "is_large_binary_like"(Type type_id) + c_bool c_is_binary "is_binary"(Type type_id) + c_bool c_is_string "is_string"(Type type_id) + c_bool c_is_temporal "is_temporal"(Type type_id) + c_bool c_is_time "is_time"(Type type_id) + c_bool c_is_date "is_date"(Type type_id) + c_bool c_is_interval "is_interval"(Type type_id) + c_bool c_is_dictionary "is_dictionary"(Type type_id) + c_bool c_is_fixed_size_binary "is_fixed_size_binary"(Type type_id) + c_bool c_is_fixed_width "is_fixed_width"(Type type_id) + c_bool c_is_var_length_list "is_var_length_list"(Type type_id) + c_bool c_is_list "is_list"(Type type_id) + c_bool c_is_list_like "is_list_like"(Type type_id) + c_bool c_is_var_length_list_like "is_var_length_list_like"(Type type_id) + c_bool c_is_list_view "is_list_view"(Type type_id) + c_bool c_is_nested "is_nested"(Type type_id) + c_bool c_is_union "is_union"(Type type_id) + int c_bit_width "bit_width"(Type type_id) + int c_offset_bit_width "offset_bit_width"(Type type_id) diff --git a/python/pyarrow/tests/test_types.py b/python/pyarrow/tests/test_types.py index 4f66a6f41672..9ad78e819374 100644 --- a/python/pyarrow/tests/test_types.py +++ b/python/pyarrow/tests/test_types.py @@ -32,8 +32,8 @@ import numpy as np import pyarrow as pa -import pyarrow.types as types import pyarrow.tests.strategies as past +from pyarrow import types def get_many_types(): @@ -1260,24 +1260,24 @@ def test_field_modified_copies(): def test_is_integer_value(): - assert pa.types.is_integer_value(1) - assert pa.types.is_integer_value(np.int64(1)) - assert not pa.types.is_integer_value('1') + assert types.is_integer_value(1) + assert types.is_integer_value(np.int64(1)) + assert not types.is_integer_value('1') def test_is_float_value(): - assert not pa.types.is_float_value(1) - assert pa.types.is_float_value(1.) - assert pa.types.is_float_value(np.float64(1)) - assert not pa.types.is_float_value('1.0') + assert not types.is_float_value(1) + assert types.is_float_value(1.) + assert types.is_float_value(np.float64(1)) + assert not types.is_float_value('1.0') def test_is_boolean_value(): - assert not pa.types.is_boolean_value(1) - assert pa.types.is_boolean_value(True) - assert pa.types.is_boolean_value(False) - assert pa.types.is_boolean_value(np.bool_(True)) - assert pa.types.is_boolean_value(np.bool_(False)) + assert not types.is_boolean_value(1) + assert types.is_boolean_value(True) + assert types.is_boolean_value(False) + assert types.is_boolean_value(np.bool_(True)) + assert types.is_boolean_value(np.bool_(False)) @h.settings(suppress_health_check=(h.HealthCheck.too_slow,)) diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi index 018099ae7e65..1aa3759b168c 100644 --- a/python/pyarrow/types.pxi +++ b/python/pyarrow/types.pxi @@ -142,11 +142,6 @@ cdef void* _as_c_pointer(v, allow_null=False) except *: return c_ptr -def _is_primitive(Type type): - # This is simply a redirect, the official API is in pyarrow.types. - return is_primitive(type) - - def _get_pandas_type(arrow_type, coerce_to_ns=False): cdef Type type_id = arrow_type.id if type_id not in _pandas_type_map: @@ -5417,6 +5412,729 @@ def is_float_value(object obj): return IsPyFloat(obj) +def is_integer(data_type): + """ + Returns whether the `data_type` is an integer type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_integer(data_type.id) + + +def is_signed_integer(data_type): + """ + Returns whether the `data_type` is a signed integer type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_signed_integer(data_type.id) + + +def is_unsigned_integer(data_type): + """ + Returns whether the `data_type` is an unsigned integer type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_unsigned_integer(data_type.id) + + +def is_floating(data_type): + """ + Returns whether the `data_type` is a floating type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_floating(data_type.id) + + +def is_numeric(data_type): + """ + Returns whether the `data_type` is a numeric type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_numeric(data_type.id) + + +def is_decimal(data_type): + """ + Returns whether the `data_type` is a decimal type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_decimal(data_type.id) + + +def is_run_end_encoded(data_type): + """ + Returns whether the `data_type` is a run end type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_run_end(data_type.id) + + +def is_primitive(data_type): + """ + Returns whether the `data_type` is a primitive type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_primitive(data_type.id) + + +def is_base_binary_like(data_type): + """ + Returns whether the `data_type` is a base binary-like type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_base_binary_like(data_type.id) + + +def is_binary_like(data_type): + """ + Returns whether the `data_type` is a binary-like type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_binary_like(data_type.id) + + +def is_large_binary_like(data_type): + """ + Returns whether the `data_type` is a large binary-like type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_large_binary_like(data_type.id) + + +def is_binary(data_type): + """ + Returns whether the `data_type` is a binary type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_binary(data_type.id) and c_offset_bit_width(data_type.id) == 32 + + +def is_string(data_type): + """ + Returns whether the `data_type` is a string type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_string(data_type.id) and c_offset_bit_width(data_type.id) == 32 + + +def is_temporal(data_type): + """ + Returns whether the `data_type` is a temporal type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_primitive(data_type.id) and not c_is_integer(data_type.id) and \ + not c_is_floating(data_type.id) + + +def is_time(data_type): + """ + Returns whether the `data_type` is a time type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_time(data_type.id) + + +def is_date(data_type): + """ + Returns whether the `data_type` is a date type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_date(data_type.id) + + +def is_interval(data_type): + """ + Returns whether the `data_type` is an interval type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_interval(data_type.id) + + +def is_dictionary(data_type): + """ + Returns whether the `data_type` is a dictionary type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_dictionary(data_type.id) + + +def is_fixed_size_binary(data_type): + """ + Returns whether the `data_type` is a fixed size binary type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_fixed_size_binary(data_type.id) + + +def is_fixed_width(data_type): + """ + Returns whether the `data_type` is a fixed width type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_fixed_width(data_type.id) + + +def is_var_length_list(data_type): + """ + Returns whether the `data_type` is a variable length list type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_var_length_list(data_type.id) + + +def is_list(data_type): + """ + Returns whether the `data_type` is a list type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_list(data_type.id) and c_offset_bit_width(data_type.id) == 32 + + +def is_list_like(data_type): + """ + Returns whether the `data_type` is a list like type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_list_like(data_type.id) + + +def is_var_length_list_like(data_type): + """ + Returns whether the `data_type` is a variable length list like type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_var_length_list_like(data_type.id) + + +def bit_width_length(data_type): + """ + Determine the bit width of the data type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_bit_width(data_type.id) + + +def offset_bit_width_length(data_type): + """ + Determine the offset bit width of the data type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_offset_bit_width(data_type.id) + + +def is_null(data_type): + """ + Returns whether the `data_type` is a null type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_NA + + +def is_boolean(data_type): + """ + Returns whether the `data_type` is a boolean type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_BOOL + + +def is_int8(data_type): + """ + Returns whether the `data_type` is an 8-bit integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_integer(data_type.id) and c_bit_width(data_type.id) == 8 + + +def is_int16(data_type): + """ + Returns whether the `data_type` is an 16-bit integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_integer(data_type.id) and c_bit_width(data_type.id) == 16 + + +def is_int32(data_type): + """ + Returns whether the `data_type` is an 32-bit integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_integer(data_type.id) and c_bit_width(data_type.id) == 32 + + +def is_int64(data_type): + """ + Returns whether the `data_type` is an 64-bit integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_integer(data_type.id) and c_bit_width(data_type.id) == 64 + + +def is_uint8(data_type): + """ + Returns whether the `data_type` is an 8-bit unsigned integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_unsigned_integer(data_type.id) and c_bit_width(data_type.id) == 8 + + +def is_uint16(data_type): + """ + Returns whether the `data_type` is an 16-bit unsigned integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_unsigned_integer(data_type.id) and c_bit_width(data_type.id) == 16 + + +def is_uint32(data_type): + """ + Returns whether the `data_type` is an 32-bit unsigned integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_unsigned_integer(data_type.id) and c_bit_width(data_type.id) == 32 + + +def is_uint64(data_type): + """ + Returns whether the `data_type` is an 64-bit unsigned integer. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_unsigned_integer(data_type.id) and c_bit_width(data_type.id) == 64 + + +def is_float16(data_type): + """ + Returns whether the `data_type` is a 16-bit floating point number. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_floating(data_type.id) and c_bit_width(data_type.id) == 16 + + +def is_float32(data_type): + """ + Returns whether the `data_type` is a 32-bit floating point number. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_floating(data_type.id) and c_bit_width(data_type.id) == 32 + + +def is_float64(data_type): + """ + Returns whether the `data_type` is a 64-bit floating point number. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_floating(data_type.id) and c_bit_width(data_type.id) == 64 + + +def is_large_list(data_type): + """ + Returns whether the `data_type` is a large list type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_list(data_type.id) and c_offset_bit_width(data_type.id) == 64 + + +def is_fixed_size_list(data_type): + """ + Returns whether the `data_type` is a fixed size list type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_FIXED_SIZE_LIST + + +def is_list_view(data_type): + """ + Returns whether the `data_type` is a list view type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_list_view(data_type.id) and c_offset_bit_width(data_type.id) == 32 + + +def is_large_list_view(data_type): + """ + Returns whether the `data_type` is a large list view type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_list_view(data_type.id) and c_offset_bit_width(data_type.id) == 64 + + +def is_struct(data_type): + """ + Returns whether the `data_type` is a struct type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_STRUCT + + +def is_union(data_type): + """ + Returns whether the `data_type` is a union type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_union(data_type.id) + + +def is_nested(data_type): + """ + Returns whether the `data_type` is a nested type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_nested(data_type.id) + + +def is_timestamp(data_type): + """ + Returns whether the `data_type` is a timestamp type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_temporal(data_type.id) and not c_is_time(data_type.id) and not c_is_date(data_type.id) + + +def is_duration(data_type): + """ + Returns whether the `data_type` is a duration type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_primitive(data_type.id) and not c_is_integer(data_type.id) and \ + not c_is_floating(data_type.id) and not c_is_temporal(data_type.id) and \ + not c_is_interval(data_type.id) + + +def is_time32(data_type): + """ + Returns whether the `data_type` is a time32 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_time(data_type.id) and c_bit_width(data_type.id) == 32 + + +def is_time64(data_type): + """ + Returns whether the `data_type` is a time64 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_time(data_type.id) and c_bit_width(data_type.id) == 64 + + +def is_large_binary(data_type): + """ + Returns whether the `data_type` is a large binary type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_binary(data_type.id) and c_offset_bit_width(data_type.id) == 64 + + +def is_large_string(data_type): + """ + Returns whether the `data_type` is a large string type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_string(data_type.id) and c_offset_bit_width(data_type.id) == 64 + + +def is_binary_view(data_type): + """ + Returns whether the `data_type` is a binary view type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_BINARY_VIEW + + +def is_string_view(data_type): + """ + Returns whether the `data_type` is a string view type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_STRING_VIEW + + +def is_date32(data_type): + """ + Returns whether the `data_type` is a date32 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_date(data_type.id) and c_bit_width(data_type.id) == 32 + + +def is_date64(data_type): + """ + Returns whether the `data_type` is a date64 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_date(data_type.id) and c_bit_width(data_type.id) == 64 + + +def is_run_end_encoded(data_type): + """ + Returns whether the `data_type` is a run end encoded type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return data_type.id == Type_RUN_END_ENCODED + + +def is_map(data_type): + """ + Returns whether the `data_type` is a map type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_var_length_list(data_type.id) and not c_is_list(data_type.id) + + +def is_decimal128(data_type): + """ + Returns whether the `data_type` is a decimal128 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_decimal(data_type.id) and c_bit_width(data_type.id) == 128 + + +def is_decimal256(data_type): + """ + Returns whether the `data_type` is a decimal256 type. + + Parameters + ---------- + data_type : DataType + The data type to check. + """ + return c_is_decimal(data_type.id) and c_bit_width(data_type.id) == 256 + + cdef class _ExtensionRegistryNanny(_Weakrefable): # Keep the registry alive until we have unregistered PyExtensionType cdef: diff --git a/python/pyarrow/types.py b/python/pyarrow/types.py index 66b1ec33953a..759e88ac0fac 100644 --- a/python/pyarrow/types.py +++ b/python/pyarrow/types.py @@ -20,295 +20,53 @@ from pyarrow.lib import (is_boolean_value, # noqa is_integer_value, - is_float_value) - -import pyarrow.lib as lib -from pyarrow.util import doc - - -_SIGNED_INTEGER_TYPES = {lib.Type_INT8, lib.Type_INT16, lib.Type_INT32, - lib.Type_INT64} -_UNSIGNED_INTEGER_TYPES = {lib.Type_UINT8, lib.Type_UINT16, lib.Type_UINT32, - lib.Type_UINT64} -_INTEGER_TYPES = _SIGNED_INTEGER_TYPES | _UNSIGNED_INTEGER_TYPES -_FLOATING_TYPES = {lib.Type_HALF_FLOAT, lib.Type_FLOAT, lib.Type_DOUBLE} -_DECIMAL_TYPES = {lib.Type_DECIMAL128, lib.Type_DECIMAL256} -_DATE_TYPES = {lib.Type_DATE32, lib.Type_DATE64} -_TIME_TYPES = {lib.Type_TIME32, lib.Type_TIME64} -_INTERVAL_TYPES = {lib.Type_INTERVAL_MONTH_DAY_NANO} -_TEMPORAL_TYPES = ({lib.Type_TIMESTAMP, - lib.Type_DURATION} | _TIME_TYPES | _DATE_TYPES | - _INTERVAL_TYPES) -_UNION_TYPES = {lib.Type_SPARSE_UNION, lib.Type_DENSE_UNION} -_NESTED_TYPES = {lib.Type_LIST, lib.Type_FIXED_SIZE_LIST, lib.Type_LARGE_LIST, - lib.Type_LIST_VIEW, lib.Type_LARGE_LIST_VIEW, - lib.Type_STRUCT, lib.Type_MAP} | _UNION_TYPES - - -@doc(datatype="null") -def is_null(t): - """ - Return True if value is an instance of type: {datatype}. - - Parameters - ---------- - t : DataType - """ - return t.id == lib.Type_NA - - -@doc(is_null, datatype="boolean") -def is_boolean(t): - return t.id == lib.Type_BOOL - - -@doc(is_null, datatype="any integer") -def is_integer(t): - return t.id in _INTEGER_TYPES - - -@doc(is_null, datatype="signed integer") -def is_signed_integer(t): - return t.id in _SIGNED_INTEGER_TYPES - - -@doc(is_null, datatype="unsigned integer") -def is_unsigned_integer(t): - return t.id in _UNSIGNED_INTEGER_TYPES - - -@doc(is_null, datatype="int8") -def is_int8(t): - return t.id == lib.Type_INT8 - - -@doc(is_null, datatype="int16") -def is_int16(t): - return t.id == lib.Type_INT16 - - -@doc(is_null, datatype="int32") -def is_int32(t): - return t.id == lib.Type_INT32 - - -@doc(is_null, datatype="int64") -def is_int64(t): - return t.id == lib.Type_INT64 - - -@doc(is_null, datatype="uint8") -def is_uint8(t): - return t.id == lib.Type_UINT8 - - -@doc(is_null, datatype="uint16") -def is_uint16(t): - return t.id == lib.Type_UINT16 - - -@doc(is_null, datatype="uint32") -def is_uint32(t): - return t.id == lib.Type_UINT32 - - -@doc(is_null, datatype="uint64") -def is_uint64(t): - return t.id == lib.Type_UINT64 - - -@doc(is_null, datatype="floating point numeric") -def is_floating(t): - return t.id in _FLOATING_TYPES - - -@doc(is_null, datatype="float16 (half-precision)") -def is_float16(t): - return t.id == lib.Type_HALF_FLOAT - - -@doc(is_null, datatype="float32 (single precision)") -def is_float32(t): - return t.id == lib.Type_FLOAT - - -@doc(is_null, datatype="float64 (double precision)") -def is_float64(t): - return t.id == lib.Type_DOUBLE - - -@doc(is_null, datatype="list") -def is_list(t): - return t.id == lib.Type_LIST - - -@doc(is_null, datatype="large list") -def is_large_list(t): - return t.id == lib.Type_LARGE_LIST - - -@doc(is_null, datatype="fixed size list") -def is_fixed_size_list(t): - return t.id == lib.Type_FIXED_SIZE_LIST - - -@doc(is_null, datatype="list view") -def is_list_view(t): - return t.id == lib.Type_LIST_VIEW - - -@doc(is_null, datatype="large list view") -def is_large_list_view(t): - return t.id == lib.Type_LARGE_LIST_VIEW - - -@doc(is_null, datatype="struct") -def is_struct(t): - return t.id == lib.Type_STRUCT - - -@doc(is_null, datatype="union") -def is_union(t): - return t.id in _UNION_TYPES - - -@doc(is_null, datatype="nested type") -def is_nested(t): - return t.id in _NESTED_TYPES - - -@doc(is_null, datatype="run-end encoded") -def is_run_end_encoded(t): - return t.id == lib.Type_RUN_END_ENCODED - - -@doc(is_null, datatype="date, time, timestamp or duration") -def is_temporal(t): - return t.id in _TEMPORAL_TYPES - - -@doc(is_null, datatype="timestamp") -def is_timestamp(t): - return t.id == lib.Type_TIMESTAMP - - -@doc(is_null, datatype="duration") -def is_duration(t): - return t.id == lib.Type_DURATION - - -@doc(is_null, datatype="time") -def is_time(t): - return t.id in _TIME_TYPES - - -@doc(is_null, datatype="time32") -def is_time32(t): - return t.id == lib.Type_TIME32 - - -@doc(is_null, datatype="time64") -def is_time64(t): - return t.id == lib.Type_TIME64 - - -@doc(is_null, datatype="variable-length binary") -def is_binary(t): - return t.id == lib.Type_BINARY - - -@doc(is_null, datatype="large variable-length binary") -def is_large_binary(t): - return t.id == lib.Type_LARGE_BINARY - - -@doc(method="is_string") -def is_unicode(t): - """ - Alias for {method}. - - Parameters - ---------- - t : DataType - """ - return is_string(t) - - -@doc(is_null, datatype="string (utf8 unicode)") -def is_string(t): - return t.id == lib.Type_STRING - - -@doc(is_unicode, method="is_large_string") -def is_large_unicode(t): - return is_large_string(t) - - -@doc(is_null, datatype="large string (utf8 unicode)") -def is_large_string(t): - return t.id == lib.Type_LARGE_STRING - - -@doc(is_null, datatype="fixed size binary") -def is_fixed_size_binary(t): - return t.id == lib.Type_FIXED_SIZE_BINARY - - -@doc(is_null, datatype="variable-length binary view") -def is_binary_view(t): - return t.id == lib.Type_BINARY_VIEW - - -@doc(is_null, datatype="variable-length string (utf-8) view") -def is_string_view(t): - return t.id == lib.Type_STRING_VIEW - - -@doc(is_null, datatype="date") -def is_date(t): - return t.id in _DATE_TYPES - - -@doc(is_null, datatype="date32 (days)") -def is_date32(t): - return t.id == lib.Type_DATE32 - - -@doc(is_null, datatype="date64 (milliseconds)") -def is_date64(t): - return t.id == lib.Type_DATE64 - - -@doc(is_null, datatype="map") -def is_map(t): - return t.id == lib.Type_MAP - - -@doc(is_null, datatype="decimal") -def is_decimal(t): - return t.id in _DECIMAL_TYPES - - -@doc(is_null, datatype="decimal128") -def is_decimal128(t): - return t.id == lib.Type_DECIMAL128 - - -@doc(is_null, datatype="decimal256") -def is_decimal256(t): - return t.id == lib.Type_DECIMAL256 - - -@doc(is_null, datatype="dictionary-encoded") -def is_dictionary(t): - return t.id == lib.Type_DICTIONARY - - -@doc(is_null, datatype="interval") -def is_interval(t): - return t.id == lib.Type_INTERVAL_MONTH_DAY_NANO - - -@doc(is_null, datatype="primitive type") -def is_primitive(t): - return lib._is_primitive(t.id) + is_float_value, + is_integer, + is_signed_integer, + is_unsigned_integer, + is_floating, + is_numeric, + is_decimal, + is_run_end_encoded, + is_primitive, + is_base_binary_like, + is_binary_like, + is_large_binary_like, + is_binary, + is_string, is_string as is_unicode, + is_temporal, + is_time, + is_date, + is_interval, + is_dictionary, + is_fixed_size_binary, + is_fixed_width, + is_var_length_list, + is_list, + is_list_like, + is_var_length_list_like, + is_list_view, + is_large_list_view, + is_nested, + is_union, + bit_width_length, + offset_bit_width_length, + is_run_end_encoded, + is_null, + is_boolean, + is_int8, is_int16, is_int32, is_int64, + is_uint8, is_uint16, is_uint32, is_uint64, + is_float16, is_float32, is_float64, + is_large_list, + is_fixed_size_list, + is_struct, + is_timestamp, + is_duration, + is_time32, is_time64, + is_large_binary, + is_large_string, is_large_string as is_large_unicode, + is_binary_view, + is_string_view, + is_date32, is_date64, + is_map, + is_decimal128, is_decimal256)