Skip to content

Commit

Permalink
autogenerated python code
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jun 12, 2023
1 parent e96c10f commit 16fb932
Show file tree
Hide file tree
Showing 14 changed files with 810 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rerun_py/rerun2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

from rerun2.archetypes import Points2D # noqa: F401
8 changes: 8 additions & 0 deletions rerun_py/rerun2/archetypes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

# NOTE:
# - we use fully qualified paths to prevent lazy circular imports
# - `noqa F401` (unused import) everywhere because, while not strictly necessary,
# these imports are very nice for end users.

from rerun2.archetypes.points2d import Points2D # noqa: F401
112 changes: 112 additions & 0 deletions rerun_py/rerun2/archetypes/points2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

from rerun2 import components


@dataclass
class Points2D:
"""A 2D point cloud with positions and optional colors, radii, labels, etc."""

points: components.Point2DArray
"""
All the actual 2D points that make up the point cloud.
"""

radii: Optional[components.RadiusArray] = None
"""
Optional radii for the points, effectively turning them into circles.
"""

colors: Optional[components.ColorArray] = None
"""
Optional colors for the points.
The colors are interpreted as RGB or RGBA in sRGB gamma-space,
As either 0-1 floats or 0-255 integers, with separate alpha.
"""

labels: Optional[components.LabelArray] = None
"""
Optional text labels for the points.
"""

draw_order: Optional[components.DrawOrderArray] = None
"""
An optional floating point value that specifies the 2D drawing order.
Objects with higher values are drawn on top of those with lower values.
The default for 2D points is 30.0.
"""

class_ids: Optional[components.ClassIdArray] = None
"""
Optional class Ids for the points.
The class ID provides colors and labels if not specified explicitly.
"""

keypoint_ids: Optional[components.KeypointIdArray] = None
"""
Optional keypoint IDs for the points, identifying them within a class.
If keypoint IDs are passed in but no class IDs were specified, the class ID will
default to 0.
This is useful to identify points within a single classification (which is identified
with `class_id`).
E.g. the classification might be 'Person' and the keypoints refer to joints on a
detected skeleton.
"""

instance_keys: Optional[components.InstanceKeyArray] = None
"""
Unique identifiers for each individual point in the batch.
"""

def __str__(self):
s = f"rr.{type(self).__name__}(\n"

from dataclasses import fields

for field in fields(self):
data = getattr(self, field.name)
datatype = getattr(data, "type", None)
if datatype:
name = datatype.extension_name
typ = datatype.storage_type
s += f" {name}<{typ}>(\n {data.to_pylist()}\n )\n"

s += ")"

return s

def __repr__(self):
return str(self)

def __init__(
self,
points: components.Point2DArrayLike,
*,
radii: Optional[components.RadiusArrayLike] = None,
colors: Optional[components.ColorArrayLike] = None,
labels: Optional[components.LabelArrayLike] = None,
draw_order: Optional[components.DrawOrderLike] = None,
class_ids: Optional[components.ClassIdArrayLike] = None,
keypoint_ids: Optional[components.KeypointIdArrayLike] = None,
instance_keys: Optional[components.InstanceKeyArrayLike] = None,
) -> None:
# Required components
self.points = components.Point2DArray.from_similar(points)

# Optional components
self.radii = components.RadiusArray.from_similar(radii)
self.colors = components.ColorArray.from_similar(colors)
self.labels = components.LabelArray.from_similar(labels)
self.draw_order = components.DrawOrderArray.from_similar(draw_order)
self.class_ids = components.ClassIdArray.from_similar(class_ids)
self.keypoint_ids = components.KeypointIdArray.from_similar(keypoint_ids)
self.instance_keys = components.InstanceKeyArray.from_similar(instance_keys)
33 changes: 33 additions & 0 deletions rerun_py/rerun2/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

# NOTE:
# - we use fully qualified paths to prevent lazy circular imports
# - `noqa F401` (unused import) everywhere because, while not strictly necessary,
# these imports are very nice for end users.

from rerun2.components.class_id import ClassId, ClassIdArray, ClassIdArrayLike, ClassIdLike, ClassIdType # noqa: F401
from rerun2.components.color import Color, ColorArray, ColorArrayLike, ColorLike, ColorType # noqa: F401
from rerun2.components.draw_order import ( # noqa: F401
DrawOrder,
DrawOrderArray,
DrawOrderArrayLike,
DrawOrderLike,
DrawOrderType,
)
from rerun2.components.instance_key import ( # noqa: F401
InstanceKey,
InstanceKeyArray,
InstanceKeyArrayLike,
InstanceKeyLike,
InstanceKeyType,
)
from rerun2.components.keypoint_id import ( # noqa: F401
KeypointId,
KeypointIdArray,
KeypointIdArrayLike,
KeypointIdLike,
KeypointIdType,
)
from rerun2.components.label import Label, LabelArray, LabelArrayLike, LabelLike, LabelType # noqa: F401
from rerun2.components.point2d import Point2D, Point2DArray, Point2DArrayLike, Point2DLike, Point2DType # noqa: F401
from rerun2.components.radius import Radius, RadiusArray, RadiusArrayLike, RadiusLike, RadiusType # noqa: F401
70 changes: 70 additions & 0 deletions rerun_py/rerun2/components/class_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional, Sequence, Union

import numpy as np
import numpy.typing as npt
import pyarrow as pa


@dataclass
class ClassId:
"""A 16-bit ID representing a type of semantic class."""

id: int

def __array__(self):
return np.asarray(self.id)


ClassIdLike = Union[ClassId, float]

ClassIdArrayLike = Union[
ClassIdLike, Sequence[ClassIdLike], npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]
]


# --- Arrow support ---

from rerun2.components.class_id_ext import ClassIdArrayExt # noqa: E402


class ClassIdType(pa.ExtensionType):
def __init__(self: type[pa.ExtensionType]) -> None:
pa.ExtensionType.__init__(self, pa.uint16(), "rerun.components.ClassId")

def __arrow_ext_serialize__(self: type[pa.ExtensionType]) -> bytes:
# since we don't have a parameterized type, we don't need extra metadata to be deserialized
return b""

@classmethod
def __arrow_ext_deserialize__(
cls: type[pa.ExtensionType], storage_type: Any, serialized: Any
) -> type[pa.ExtensionType]:
# return an instance of this subclass given the serialized metadata.
return ClassIdType()

def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray]:
return ClassIdArray


pa.register_extension_type(ClassIdType())


class ClassIdArray(pa.ExtensionArray, ClassIdArrayExt): # type: ignore[misc]
@staticmethod
def from_similar(data: Optional[ClassIdArrayLike]):
if data is None:
return ClassIdType().wrap_array(pa.array([], type=ClassIdType().storage_type))
else:
return ClassIdArrayExt.from_similar(
data,
mono=ClassId,
mono_aliases=ClassIdLike,
many=ClassIdArray,
many_aliases=ClassIdArrayLike,
arrow=ClassIdType,
)
78 changes: 78 additions & 0 deletions rerun_py/rerun2/components/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional, Sequence, Union

import numpy as np
import numpy.typing as npt
import pyarrow as pa


@dataclass
class Color:
"""An RGBA color tuple with unmultiplied/separate alpha, in sRGB gamma space with linear alpha."""

rgba: int

def __array__(self):
return np.asarray(self.rgba)


ColorLike = Union[
Color, Sequence[int], Sequence[float], npt.NDArray[np.uint8], npt.NDArray[np.float32], npt.NDArray[np.float64]
]

ColorArrayLike = Union[
ColorLike,
Sequence[ColorLike],
Sequence[int],
Sequence[float],
npt.NDArray[np.uint8],
npt.NDArray[np.float32],
npt.NDArray[np.float64],
]


# --- Arrow support ---

from rerun2.components.color_ext import ColorArrayExt # noqa: E402


class ColorType(pa.ExtensionType):
def __init__(self: type[pa.ExtensionType]) -> None:
pa.ExtensionType.__init__(self, pa.uint32(), "rerun.components.Color")

def __arrow_ext_serialize__(self: type[pa.ExtensionType]) -> bytes:
# since we don't have a parameterized type, we don't need extra metadata to be deserialized
return b""

@classmethod
def __arrow_ext_deserialize__(
cls: type[pa.ExtensionType], storage_type: Any, serialized: Any
) -> type[pa.ExtensionType]:
# return an instance of this subclass given the serialized metadata.
return ColorType()

def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray]:
return ColorArray


pa.register_extension_type(ColorType())


class ColorArray(pa.ExtensionArray, ColorArrayExt): # type: ignore[misc]
@staticmethod
def from_similar(data: Optional[ColorArrayLike]):
if data is None:
return ColorType().wrap_array(pa.array([], type=ColorType().storage_type))
else:
return ColorArrayExt.from_similar(
data,
mono=Color,
mono_aliases=ColorLike,
many=ColorArray,
many_aliases=ColorArrayLike,
arrow=ColorType,
)
76 changes: 76 additions & 0 deletions rerun_py/rerun2/components/draw_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional, Sequence, Union

import numpy as np
import numpy.typing as npt
import pyarrow as pa


@dataclass
class DrawOrder:
"""
Draw order used for the display order of 2D elements.
Higher values are drawn on top of lower values.
An entity can have only a single draw order component.
Within an entity draw order is governed by the order of the components.
Draw order for entities with the same draw order is generally undefined.
"""

value: float

def __array__(self):
return np.asarray(self.value)


DrawOrderLike = Union[DrawOrder, float]

DrawOrderArrayLike = Union[DrawOrderLike, Sequence[DrawOrderLike], npt.NDArray[np.float32]]


# --- Arrow support ---

from rerun2.components.draw_order_ext import DrawOrderArrayExt # noqa: E402


class DrawOrderType(pa.ExtensionType):
def __init__(self: type[pa.ExtensionType]) -> None:
pa.ExtensionType.__init__(self, pa.float32(), "rerun.components.DrawOrder")

def __arrow_ext_serialize__(self: type[pa.ExtensionType]) -> bytes:
# since we don't have a parameterized type, we don't need extra metadata to be deserialized
return b""

@classmethod
def __arrow_ext_deserialize__(
cls: type[pa.ExtensionType], storage_type: Any, serialized: Any
) -> type[pa.ExtensionType]:
# return an instance of this subclass given the serialized metadata.
return DrawOrderType()

def __arrow_ext_class__(self: type[pa.ExtensionType]) -> type[pa.ExtensionArray]:
return DrawOrderArray


pa.register_extension_type(DrawOrderType())


class DrawOrderArray(pa.ExtensionArray, DrawOrderArrayExt): # type: ignore[misc]
@staticmethod
def from_similar(data: Optional[DrawOrderArrayLike]):
if data is None:
return DrawOrderType().wrap_array(pa.array([], type=DrawOrderType().storage_type))
else:
return DrawOrderArrayExt.from_similar(
data,
mono=DrawOrder,
mono_aliases=DrawOrderLike,
many=DrawOrderArray,
many_aliases=DrawOrderArrayLike,
arrow=DrawOrderType,
)
Loading

0 comments on commit 16fb932

Please sign in to comment.