alinarus's picture
Upload folder using huggingface_hub (part 18)
9ff4bea verified
Raw History Blame Contribute Delete
3.94 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/annotation_info.def.rs".
# You can extend this class by creating a "AnnotationInfoExt" class in "annotation_info_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 .annotation_info_ext import AnnotationInfoExt
__all__ = ["AnnotationInfo", "AnnotationInfoArrayLike", "AnnotationInfoBatch", "AnnotationInfoLike"]
def _annotation_info__label__special_field_converter_override(x: encodings.Utf8Like | None) -> encodings.Utf8 | None:
if x is None:
return None
elif isinstance(x, encodings.Utf8):
return x
else:
return encodings.Utf8(x)
def _annotation_info__color__special_field_converter_override(
x: encodings.Rgba32Like | None,
) -> encodings.Rgba32 | None:
if x is None:
return None
elif isinstance(x, encodings.Rgba32):
return x
else:
return encodings.Rgba32(x)
@define(init=False)
class AnnotationInfo(AnnotationInfoExt):
"""
**Encoding**: Annotation info annotating a class id or key-point id.
Color and label will be used to annotate entities/keypoints which reference the id.
The id refers either to a class or key-point id
"""
def __init__(
self: Any, id: int, label: encodings.Utf8Like | None = None, color: encodings.Rgba32Like | None = None
) -> None:
"""
Create a new instance of the AnnotationInfo encoding.
Parameters
----------
id:
[`encodings.ClassId`][rerun.encodings.ClassId] or [`encodings.KeypointId`][rerun.encodings.KeypointId] to which this annotation info belongs.
label:
The label that will be shown in the UI.
color:
The color that will be applied to the annotated entity.
"""
# You can define your own __init__ function as a member of AnnotationInfoExt in annotation_info_ext.py
self.__attrs_init__(id=id, label=label, color=color)
id: int = field(converter=int)
# [`encodings.ClassId`][rerun.encodings.ClassId] or [`encodings.KeypointId`][rerun.encodings.KeypointId] to which this annotation info belongs.
#
# (Docstring intentionally commented out to hide this field from the docs)
label: encodings.Utf8 | None = field(
default=None, converter=_annotation_info__label__special_field_converter_override
)
# The label that will be shown in the UI.
#
# (Docstring intentionally commented out to hide this field from the docs)
color: encodings.Rgba32 | None = field(
default=None, converter=_annotation_info__color__special_field_converter_override
)
# The color that will be applied to the annotated entity.
#
# (Docstring intentionally commented out to hide this field from the docs)
if TYPE_CHECKING:
AnnotationInfoLike = AnnotationInfo | int | tuple[int, str] | tuple[int, str, encodings.Rgba32Like]
"""A type alias for any AnnotationInfo-like object."""
else:
AnnotationInfoLike = Any
AnnotationInfoArrayLike = AnnotationInfo | Sequence[AnnotationInfoLike]
"""A type alias for any AnnotationInfo-like array object."""
class AnnotationInfoBatch(BaseBatch[AnnotationInfoArrayLike]):
_ARROW_DATATYPE = pa.struct([
pa.field("id", pa.uint16(), nullable=False, metadata={}),
pa.field("label", pa.utf8(), nullable=True, metadata={}),
pa.field("color", pa.uint32(), nullable=True, metadata={}),
])
@staticmethod
def _native_to_pa_array(data: AnnotationInfoArrayLike, data_type: pa.DataType) -> pa.Array:
return AnnotationInfoExt.native_to_pa_array_override(data, data_type)