alinarus's picture
Upload folder using huggingface_hub (part 18)
9ff4bea verified
Raw History Blame Contribute Delete
2.39 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_id.def.rs".
# You can extend this class by creating a "KeypointIdExt" class in "keypoint_id_ext.py".
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import numpy as np
import numpy.typing as npt
import pyarrow as pa
from attrs import define, field
from .._baseclasses import (
BaseBatch,
)
from .._numpy_compatibility import asarray
__all__ = ["KeypointId", "KeypointIdArrayLike", "KeypointIdBatch", "KeypointIdLike"]
@define(init=False)
class KeypointId:
"""
**Encoding**: A 16-bit ID representing a type of semantic keypoint within a class.
`KeypointId`s are only meaningful within the context of a [`encodings.ClassDescription`][rerun.encodings.ClassDescription].
Used to look up an [`encodings.AnnotationInfo`][rerun.encodings.AnnotationInfo] for a Keypoint within the
[`components.AnnotationContext`][rerun.components.AnnotationContext].
"""
def __init__(self: Any, id: KeypointIdLike) -> None:
"""Create a new instance of the KeypointId encoding."""
# You can define your own __init__ function as a member of KeypointIdExt in keypoint_id_ext.py
self.__attrs_init__(id=id)
id: int = field(converter=int)
def __array__(self, dtype: npt.DTypeLike = None, copy: bool | None = None) -> npt.NDArray[Any]:
# You can define your own __array__ function as a member of KeypointIdExt in keypoint_id_ext.py
return asarray(self.id, dtype=dtype, copy=copy)
def __int__(self) -> int:
return int(self.id)
def __hash__(self) -> int:
return hash(self.id)
if TYPE_CHECKING:
KeypointIdLike = KeypointId | int
"""A type alias for any KeypointId-like object."""
else:
KeypointIdLike = Any
KeypointIdArrayLike = KeypointId | Sequence[KeypointIdLike] | int | npt.ArrayLike
"""A type alias for any KeypointId-like array object."""
class KeypointIdBatch(BaseBatch[KeypointIdArrayLike]):
_ARROW_DATATYPE = pa.uint16()
@staticmethod
def _native_to_pa_array(data: KeypointIdArrayLike, data_type: pa.DataType) -> pa.Array:
array = np.asarray(data, dtype=np.uint16).flatten()
return pa.array(array, type=data_type)