Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
robotics
embodied-ai
human-demonstration
egocentric-video
bimanual-manipulation
tactile-sensing
License:
File size: 3,492 Bytes
9ff4bea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | # 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/range2d.def.rs".
# You can extend this class by creating a "Range2DExt" class in "range2d_ext.py".
from __future__ import annotations
from collections.abc import Sequence
from typing import Any
import pyarrow as pa
from attrs import define, field
from .. import encodings
from .._baseclasses import (
BaseBatch,
)
__all__ = ["Range2D", "Range2DArrayLike", "Range2DBatch", "Range2DLike"]
def _range2d__x_range__special_field_converter_override(x: encodings.Range1DLike) -> encodings.Range1D:
if isinstance(x, encodings.Range1D):
return x
else:
return encodings.Range1D(x)
def _range2d__y_range__special_field_converter_override(x: encodings.Range1DLike) -> encodings.Range1D:
if isinstance(x, encodings.Range1D):
return x
else:
return encodings.Range1D(x)
@define(init=False)
class Range2D:
"""**Encoding**: An Axis-Aligned Bounding Box in 2D space, implemented as the minimum and maximum corners."""
def __init__(self: Any, x_range: encodings.Range1DLike, y_range: encodings.Range1DLike) -> None:
"""
Create a new instance of the Range2D encoding.
Parameters
----------
x_range:
The range of the X-axis (usually left and right bounds).
y_range:
The range of the Y-axis (usually top and bottom bounds).
"""
# You can define your own __init__ function as a member of Range2DExt in range2d_ext.py
self.__attrs_init__(x_range=x_range, y_range=y_range)
x_range: encodings.Range1D = field(converter=_range2d__x_range__special_field_converter_override)
# The range of the X-axis (usually left and right bounds).
#
# (Docstring intentionally commented out to hide this field from the docs)
y_range: encodings.Range1D = field(converter=_range2d__y_range__special_field_converter_override)
# The range of the Y-axis (usually top and bottom bounds).
#
# (Docstring intentionally commented out to hide this field from the docs)
Range2DLike = Range2D
"""A type alias for any Range2D-like object."""
Range2DArrayLike = Range2D | Sequence[Range2DLike]
"""A type alias for any Range2D-like array object."""
class Range2DBatch(BaseBatch[Range2DArrayLike]):
_ARROW_DATATYPE = pa.struct([
pa.field(
"x_range",
pa.list_(pa.field("item", pa.float64(), nullable=False, metadata={}), 2),
nullable=False,
metadata={},
),
pa.field(
"y_range",
pa.list_(pa.field("item", pa.float64(), nullable=False, metadata={}), 2),
nullable=False,
metadata={},
),
])
@staticmethod
def _native_to_pa_array(data: Range2DArrayLike, data_type: pa.DataType) -> pa.Array:
from rerun.encodings import Range1DBatch
typed_data: Sequence[Range2D]
if isinstance(data, Range2D):
typed_data = [data]
else:
typed_data = data
return pa.StructArray.from_arrays(
[
Range1DBatch([x.x_range for x in typed_data]).as_arrow_array(), # type: ignore[misc, arg-type]
Range1DBatch([x.y_range for x in typed_data]).as_arrow_array(), # type: ignore[misc, arg-type]
],
fields=list(data_type),
)
|