alinarus's picture
Upload folder using huggingface_hub (part 18)
9ff4bea verified
Raw History Blame Contribute Delete
3.04 kB
# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/build/re_type_definitions/rerun/encodings/keypoint_pair.def.rs".
# You can extend this class by creating a "KeypointPairExt" class in "keypoint_pair_ext.py".
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import pyarrow as pa
from attrs import define, field
from .. import encodings
from .._baseclasses import (
BaseBatch,
)
from .keypoint_pair_ext import KeypointPairExt
__all__ = ["KeypointPair", "KeypointPairArrayLike", "KeypointPairBatch", "KeypointPairLike"]
def _keypoint_pair__keypoint0__special_field_converter_override(x: encodings.KeypointIdLike) -> encodings.KeypointId:
if isinstance(x, encodings.KeypointId):
return x
else:
return encodings.KeypointId(x)
def _keypoint_pair__keypoint1__special_field_converter_override(x: encodings.KeypointIdLike) -> encodings.KeypointId:
if isinstance(x, encodings.KeypointId):
return x
else:
return encodings.KeypointId(x)
@define(init=False)
class KeypointPair(KeypointPairExt):
"""**Encoding**: A connection between two [`encodings.KeypointId`][rerun.encodings.KeypointId]s."""
def __init__(self: Any, keypoint0: encodings.KeypointIdLike, keypoint1: encodings.KeypointIdLike) -> None:
"""
Create a new instance of the KeypointPair encoding.
Parameters
----------
keypoint0:
The first point of the pair.
keypoint1:
The second point of the pair.
"""
# You can define your own __init__ function as a member of KeypointPairExt in keypoint_pair_ext.py
self.__attrs_init__(keypoint0=keypoint0, keypoint1=keypoint1)
keypoint0: encodings.KeypointId = field(converter=_keypoint_pair__keypoint0__special_field_converter_override)
# The first point of the pair.
#
# (Docstring intentionally commented out to hide this field from the docs)
keypoint1: encodings.KeypointId = field(converter=_keypoint_pair__keypoint1__special_field_converter_override)
# The second point of the pair.
#
# (Docstring intentionally commented out to hide this field from the docs)
if TYPE_CHECKING:
KeypointPairLike = KeypointPair | Sequence[encodings.KeypointIdLike]
"""A type alias for any KeypointPair-like object."""
else:
KeypointPairLike = Any
KeypointPairArrayLike = KeypointPair | Sequence[KeypointPairLike]
"""A type alias for any KeypointPair-like array object."""
class KeypointPairBatch(BaseBatch[KeypointPairArrayLike]):
_ARROW_DATATYPE = pa.struct([
pa.field("keypoint0", pa.uint16(), nullable=False, metadata={}),
pa.field("keypoint1", pa.uint16(), nullable=False, metadata={}),
])
@staticmethod
def _native_to_pa_array(data: KeypointPairArrayLike, data_type: pa.DataType) -> pa.Array:
return KeypointPairExt.native_to_pa_array_override(data, data_type)