2017-10-07 15:49:10 -04:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
|
# distributed with this work for additional information
|
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
|
|
# Tools for dealing with Arrow type metadata in Python
|
|
|
|
|
|
2019-05-27 18:01:27 +02:00
|
|
|
|
2025-07-25 15:14:26 +02:00
|
|
|
from enum import IntEnum
|
|
|
|
|
|
2018-09-30 13:48:47 +02:00
|
|
|
from pyarrow.lib import (is_boolean_value, # noqa
|
|
|
|
|
is_integer_value,
|
2018-12-09 22:22:08 +01:00
|
|
|
is_float_value)
|
2018-09-30 13:48:47 +02:00
|
|
|
|
2017-10-07 15:49:10 -04:00
|
|
|
import pyarrow.lib as lib
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
from pyarrow.util import doc
|
2017-10-07 15:49:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
_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}
|
2024-12-16 21:12:07 -06:00
|
|
|
_DECIMAL_TYPES = {lib.Type_DECIMAL32, lib.Type_DECIMAL64, lib.Type_DECIMAL128,
|
|
|
|
|
lib.Type_DECIMAL256}
|
2017-10-07 15:49:10 -04:00
|
|
|
_DATE_TYPES = {lib.Type_DATE32, lib.Type_DATE64}
|
|
|
|
|
_TIME_TYPES = {lib.Type_TIME32, lib.Type_TIME64}
|
2021-10-07 12:36:46 +02:00
|
|
|
_INTERVAL_TYPES = {lib.Type_INTERVAL_MONTH_DAY_NANO}
|
|
|
|
|
_TEMPORAL_TYPES = ({lib.Type_TIMESTAMP,
|
|
|
|
|
lib.Type_DURATION} | _TIME_TYPES | _DATE_TYPES |
|
|
|
|
|
_INTERVAL_TYPES)
|
2020-06-12 13:03:12 -05:00
|
|
|
_UNION_TYPES = {lib.Type_SPARSE_UNION, lib.Type_DENSE_UNION}
|
2024-02-27 14:28:55 +01:00
|
|
|
_NESTED_TYPES = {lib.Type_LIST, lib.Type_FIXED_SIZE_LIST, lib.Type_LARGE_LIST,
|
2024-02-28 04:37:34 -05:00
|
|
|
lib.Type_LIST_VIEW, lib.Type_LARGE_LIST_VIEW,
|
2024-02-27 14:28:55 +01:00
|
|
|
lib.Type_STRUCT, lib.Type_MAP} | _UNION_TYPES
|
2017-10-07 15:49:10 -04:00
|
|
|
|
|
|
|
|
|
2025-07-25 15:14:26 +02:00
|
|
|
class TypesEnum(IntEnum):
|
|
|
|
|
"""
|
|
|
|
|
An Enum that maps constant values to data types.
|
|
|
|
|
Exposes the underlying data types representation for type checking purposes.
|
|
|
|
|
Note that some of the types listed here are not supported by PyArrow yet:
|
|
|
|
|
INTERVAL_MONTHS and INTERVAL_DAY_TIME.
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
--------
|
|
|
|
|
>>> import pyarrow as pa
|
|
|
|
|
>>> from pyarrow.types import TypesEnum
|
|
|
|
|
>>> int8_field = pa.field('int8_field', pa.int8())
|
|
|
|
|
>>> int8_field.type.id == TypesEnum.INT8
|
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
>>> fixed_size_list = pa.list_(pa.uint16(), 3)
|
|
|
|
|
>>> fixed_size_list.id == TypesEnum.LIST
|
|
|
|
|
False
|
|
|
|
|
|
|
|
|
|
>>> fixed_size_list.id == TypesEnum.FIXED_SIZE_LIST
|
|
|
|
|
True
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
NA = lib.Type_NA
|
|
|
|
|
BOOL = lib.Type_BOOL
|
|
|
|
|
|
|
|
|
|
INT8 = lib.Type_INT8
|
|
|
|
|
INT16 = lib.Type_INT16
|
|
|
|
|
INT32 = lib.Type_INT32
|
|
|
|
|
INT64 = lib.Type_INT64
|
|
|
|
|
|
|
|
|
|
UINT8 = lib.Type_UINT8
|
|
|
|
|
UINT16 = lib.Type_UINT16
|
|
|
|
|
UINT32 = lib.Type_UINT32
|
|
|
|
|
UINT64 = lib.Type_UINT64
|
|
|
|
|
|
|
|
|
|
HALF_FLOAT = lib.Type_HALF_FLOAT
|
|
|
|
|
FLOAT = lib.Type_FLOAT
|
|
|
|
|
DOUBLE = lib.Type_DOUBLE
|
|
|
|
|
|
|
|
|
|
BINARY = lib.Type_BINARY
|
|
|
|
|
BINARY_VIEW = lib.Type_BINARY_VIEW
|
|
|
|
|
LARGE_BINARY = lib.Type_LARGE_BINARY
|
|
|
|
|
STRING = lib.Type_STRING
|
|
|
|
|
STRING_VIEW = lib.Type_STRING_VIEW
|
|
|
|
|
LARGE_STRING = lib.Type_LARGE_STRING
|
|
|
|
|
FIXED_SIZE_BINARY = lib.Type_FIXED_SIZE_BINARY
|
|
|
|
|
|
|
|
|
|
DECIMAL32 = lib.Type_DECIMAL32
|
|
|
|
|
DECIMAL64 = lib.Type_DECIMAL64
|
|
|
|
|
DECIMAL128 = lib.Type_DECIMAL128
|
|
|
|
|
DECIMAL256 = lib.Type_DECIMAL256
|
|
|
|
|
|
|
|
|
|
LIST = lib.Type_LIST
|
|
|
|
|
LARGE_LIST = lib.Type_LARGE_LIST
|
|
|
|
|
LIST_VIEW = lib.Type_LIST_VIEW
|
|
|
|
|
LARGE_LIST_VIEW = lib.Type_LARGE_LIST_VIEW
|
|
|
|
|
MAP = lib.Type_MAP
|
|
|
|
|
FIXED_SIZE_LIST = lib.Type_FIXED_SIZE_LIST
|
|
|
|
|
|
|
|
|
|
STRUCT = lib.Type_STRUCT
|
|
|
|
|
SPARSE_UNION = lib.Type_SPARSE_UNION
|
|
|
|
|
DENSE_UNION = lib.Type_DENSE_UNION
|
|
|
|
|
RUN_END_ENCODED = lib.Type_RUN_END_ENCODED
|
|
|
|
|
|
|
|
|
|
DATE32 = lib.Type_DATE32
|
|
|
|
|
DATE64 = lib.Type_DATE64
|
|
|
|
|
TIME32 = lib.Type_TIME32
|
|
|
|
|
TIME64 = lib.Type_TIME64
|
|
|
|
|
TIMESTAMP = lib.Type_TIMESTAMP
|
|
|
|
|
|
|
|
|
|
INTERVAL_MONTHS = lib.Type_INTERVAL_MONTHS
|
|
|
|
|
INTERVAL_DAY_TIME = lib.Type_INTERVAL_DAY_TIME
|
|
|
|
|
INTERVAL_MONTH_DAY_NANO = lib.Type_INTERVAL_MONTH_DAY_NANO
|
|
|
|
|
|
|
|
|
|
DURATION = lib.Type_DURATION
|
|
|
|
|
DICTIONARY = lib.Type_DICTIONARY
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(datatype="null")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_null(t):
|
|
|
|
|
"""
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
Return True if value is an instance of type: {datatype}.
|
2021-10-04 11:44:40 +02:00
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
t : DataType
|
2017-12-11 10:09:16 -05:00
|
|
|
"""
|
|
|
|
|
return t.id == lib.Type_NA
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="boolean")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_boolean(t):
|
|
|
|
|
return t.id == lib.Type_BOOL
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="any integer")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_integer(t):
|
|
|
|
|
return t.id in _INTEGER_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="signed integer")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_signed_integer(t):
|
|
|
|
|
return t.id in _SIGNED_INTEGER_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="unsigned integer")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_unsigned_integer(t):
|
|
|
|
|
return t.id in _UNSIGNED_INTEGER_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="int8")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_int8(t):
|
|
|
|
|
return t.id == lib.Type_INT8
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="int16")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_int16(t):
|
|
|
|
|
return t.id == lib.Type_INT16
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="int32")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_int32(t):
|
|
|
|
|
return t.id == lib.Type_INT32
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="int64")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_int64(t):
|
|
|
|
|
return t.id == lib.Type_INT64
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="uint8")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_uint8(t):
|
|
|
|
|
return t.id == lib.Type_UINT8
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="uint16")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_uint16(t):
|
|
|
|
|
return t.id == lib.Type_UINT16
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="uint32")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_uint32(t):
|
|
|
|
|
return t.id == lib.Type_UINT32
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="uint64")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_uint64(t):
|
|
|
|
|
return t.id == lib.Type_UINT64
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="floating point numeric")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_floating(t):
|
|
|
|
|
return t.id in _FLOATING_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="float16 (half-precision)")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_float16(t):
|
|
|
|
|
return t.id == lib.Type_HALF_FLOAT
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="float32 (single precision)")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_float32(t):
|
|
|
|
|
return t.id == lib.Type_FLOAT
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="float64 (double precision)")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_float64(t):
|
|
|
|
|
return t.id == lib.Type_DOUBLE
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="list")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_list(t):
|
|
|
|
|
return t.id == lib.Type_LIST
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="large list")
|
2019-08-06 13:41:41 -05:00
|
|
|
def is_large_list(t):
|
|
|
|
|
return t.id == lib.Type_LARGE_LIST
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="fixed size list")
|
2019-12-10 14:58:29 +01:00
|
|
|
def is_fixed_size_list(t):
|
|
|
|
|
return t.id == lib.Type_FIXED_SIZE_LIST
|
|
|
|
|
|
|
|
|
|
|
2024-02-08 09:44:19 -05:00
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="struct")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_struct(t):
|
|
|
|
|
return t.id == lib.Type_STRUCT
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="union")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_union(t):
|
2020-06-12 13:03:12 -05:00
|
|
|
return t.id in _UNION_TYPES
|
2017-10-07 15:49:10 -04:00
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="nested type")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_nested(t):
|
|
|
|
|
return t.id in _NESTED_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="run-end encoded")
|
2023-03-23 05:20:06 -03:00
|
|
|
def is_run_end_encoded(t):
|
|
|
|
|
return t.id == lib.Type_RUN_END_ENCODED
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="date, time, timestamp or duration")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_temporal(t):
|
|
|
|
|
return t.id in _TEMPORAL_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="timestamp")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_timestamp(t):
|
|
|
|
|
return t.id == lib.Type_TIMESTAMP
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="duration")
|
2019-10-08 13:12:38 +02:00
|
|
|
def is_duration(t):
|
|
|
|
|
return t.id == lib.Type_DURATION
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="time")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_time(t):
|
|
|
|
|
return t.id in _TIME_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="time32")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_time32(t):
|
|
|
|
|
return t.id == lib.Type_TIME32
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="time64")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_time64(t):
|
|
|
|
|
return t.id == lib.Type_TIME64
|
2017-10-07 15:49:10 -04:00
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="variable-length binary")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_binary(t):
|
|
|
|
|
return t.id == lib.Type_BINARY
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="large variable-length binary")
|
2019-08-01 12:50:21 +02:00
|
|
|
def is_large_binary(t):
|
|
|
|
|
return t.id == lib.Type_LARGE_BINARY
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(method="is_string")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_unicode(t):
|
|
|
|
|
"""
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
Alias for {method}.
|
2021-10-04 11:44:40 +02:00
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
t : DataType
|
2017-10-07 15:49:10 -04:00
|
|
|
"""
|
|
|
|
|
return is_string(t)
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="string (utf8 unicode)")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_string(t):
|
|
|
|
|
return t.id == lib.Type_STRING
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_unicode, method="is_large_string")
|
2019-08-01 12:50:21 +02:00
|
|
|
def is_large_unicode(t):
|
|
|
|
|
return is_large_string(t)
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="large string (utf8 unicode)")
|
2019-08-01 12:50:21 +02:00
|
|
|
def is_large_string(t):
|
|
|
|
|
return t.id == lib.Type_LARGE_STRING
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="fixed size binary")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_fixed_size_binary(t):
|
|
|
|
|
return t.id == lib.Type_FIXED_SIZE_BINARY
|
|
|
|
|
|
|
|
|
|
|
2024-01-30 12:54:19 +01:00
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="date")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_date(t):
|
|
|
|
|
return t.id in _DATE_TYPES
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="date32 (days)")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_date32(t):
|
|
|
|
|
return t.id == lib.Type_DATE32
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="date64 (milliseconds)")
|
2017-12-11 10:09:16 -05:00
|
|
|
def is_date64(t):
|
|
|
|
|
return t.id == lib.Type_DATE64
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="map")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_map(t):
|
|
|
|
|
return t.id == lib.Type_MAP
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="decimal")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_decimal(t):
|
2020-10-22 21:39:53 -07:00
|
|
|
return t.id in _DECIMAL_TYPES
|
|
|
|
|
|
|
|
|
|
|
2024-12-16 21:12:07 -06:00
|
|
|
@doc(is_null, datatype="decimal32")
|
|
|
|
|
def is_decimal32(t):
|
|
|
|
|
return t.id == lib.Type_DECIMAL32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@doc(is_null, datatype="decimal64")
|
|
|
|
|
def is_decimal64(t):
|
|
|
|
|
return t.id == lib.Type_DECIMAL64
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="decimal128")
|
2020-10-22 21:39:53 -07:00
|
|
|
def is_decimal128(t):
|
|
|
|
|
return t.id == lib.Type_DECIMAL128
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="decimal256")
|
2020-10-22 21:39:53 -07:00
|
|
|
def is_decimal256(t):
|
|
|
|
|
return t.id == lib.Type_DECIMAL256
|
2017-10-07 15:49:10 -04:00
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="dictionary-encoded")
|
2017-10-07 15:49:10 -04:00
|
|
|
def is_dictionary(t):
|
|
|
|
|
return t.id == lib.Type_DICTIONARY
|
2018-05-08 19:15:40 +02:00
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="interval")
|
2021-10-07 12:36:46 +02:00
|
|
|
def is_interval(t):
|
|
|
|
|
return t.id == lib.Type_INTERVAL_MONTH_DAY_NANO
|
|
|
|
|
|
|
|
|
|
|
GH-34868: [Python] Share docstrings between classes (#34894)
### Rationale for this change
Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue https://github.com/python/cpython/issues/91309.
### What changes are included in this PR?
Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes.
### Are these changes tested?
Tests added.
```
>>> import pyarrow
>>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper
>>> from pyarrow.hdfs import HadoopFileSystem
>>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]:
... print(fs.__name__)
... print(fs.isdir.__doc__)
...
FileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
LocalFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
DaskFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
S3FSWrapper
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
HadoopFileSystem
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
```
Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator.
### Are there any user-facing changes?
No
* Closes: #34868
Authored-by: Dane Pitkin <dane@voltrondata.com>
Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
2023-04-24 02:18:52 -04:00
|
|
|
@doc(is_null, datatype="primitive type")
|
2018-05-08 19:15:40 +02:00
|
|
|
def is_primitive(t):
|
|
|
|
|
return lib._is_primitive(t.id)
|