Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
robotics
embodied-ai
human-demonstration
egocentric-video
bimanual-manipulation
tactile-sensing
License:
MultimodalData / player /runtime /python /Lib /site-packages /rerun /components /aggregation_policy.py
Download player/runtime/python/Lib/site-packages/rerun/components/aggregation_policy.py from alinarus/MultimodalData: direct link, hf CLI and curl.
- Browser
- Download file 4 kB
-
https://huggingface.co/datasets/alinarus/MultimodalData/resolve/main/player/runtime/python/Lib/site-packages/rerun/components/aggregation_policy.py
- Command line
-
hf download hf://datasets/alinarus/MultimodalData/player/runtime/python/Lib/site-packages/rerun/components/aggregation_policy.py
-
curl -L -o aggregation_policy.py https://huggingface.co/datasets/alinarus/MultimodalData/resolve/main/player/runtime/python/Lib/site-packages/rerun/components/aggregation_policy.py
4 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/components/aggregation_policy.def.rs". | |
| # You can extend this class by creating a "AggregationPolicyExt" class in "aggregation_policy_ext.py". | |
| from __future__ import annotations | |
| from collections.abc import Sequence | |
| from typing import Literal | |
| import pyarrow as pa | |
| from .._baseclasses import ( | |
| BaseBatch, | |
| ComponentBatchMixin, | |
| ) | |
| __all__ = ["AggregationPolicy", "AggregationPolicyArrayLike", "AggregationPolicyBatch", "AggregationPolicyLike"] | |
| from enum import Enum | |
| class AggregationPolicy(Enum): | |
| """ | |
| **Component**: Policy for aggregation of multiple scalar plot values. | |
| This is used for lines in plots when the X axis distance of individual points goes below a single pixel, | |
| i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance | |
| (and readability) in such situations as it prevents overdraw. | |
| """ | |
| Off = 1 | |
| """No aggregation.""" | |
| Average = 2 | |
| """ | |
| Average all points in the range together. | |
| This can wash out outliers (spikes). | |
| """ | |
| Max = 3 | |
| """Keep only the maximum values in the range.""" | |
| Min = 4 | |
| """Keep only the minimum values in the range.""" | |
| MinMax = 5 | |
| """ | |
| Keep both the minimum and maximum values in the range. | |
| This will yield two aggregated points instead of one, effectively creating a vertical line. | |
| In practice this often leads to a rather ugly zig-zag look. | |
| """ | |
| MinMaxAverage = 6 | |
| """ | |
| Find both the minimum and maximum values in the range, then use the average of those. | |
| This yields a single point per range, so it does not draw a vertical line per pixel, | |
| while still letting a lone outlier move the plotted value, which averaging all the | |
| points in the range would wash out. | |
| """ | |
| def auto(cls, val: str | int | AggregationPolicy) -> AggregationPolicy: | |
| """Best-effort converter, including a case-insensitive string matcher.""" | |
| if isinstance(val, AggregationPolicy): | |
| return val | |
| if isinstance(val, int): | |
| return cls(val) | |
| try: | |
| return cls[val] | |
| except KeyError: | |
| val_lower = val.lower() | |
| for variant in cls: | |
| if variant.name.lower() == val_lower: | |
| return variant | |
| raise ValueError(f"Cannot convert {val} to {cls.__name__}") | |
| def __str__(self) -> str: | |
| """Returns the variant name.""" | |
| return self.name | |
| AggregationPolicyLike = ( | |
| AggregationPolicy | |
| | Literal[ | |
| "Average", | |
| "Max", | |
| "Min", | |
| "MinMax", | |
| "MinMaxAverage", | |
| "Off", | |
| "average", | |
| "max", | |
| "min", | |
| "minmax", | |
| "minmaxaverage", | |
| "off", | |
| ] | |
| | int | |
| ) | |
| """A type alias for any AggregationPolicy-like object.""" | |
| AggregationPolicyArrayLike = ( | |
| AggregationPolicy | |
| | Literal[ | |
| "Average", | |
| "Max", | |
| "Min", | |
| "MinMax", | |
| "MinMaxAverage", | |
| "Off", | |
| "average", | |
| "max", | |
| "min", | |
| "minmax", | |
| "minmaxaverage", | |
| "off", | |
| ] | |
| | int | |
| | Sequence[AggregationPolicyLike] | |
| ) | |
| """A type alias for any AggregationPolicy-like array object.""" | |
| class AggregationPolicyBatch(BaseBatch[AggregationPolicyArrayLike], ComponentBatchMixin): | |
| _ARROW_DATATYPE = pa.uint8() | |
| _COMPONENT_TYPE: str = "rerun.components.AggregationPolicy" | |
| def _native_to_pa_array(data: AggregationPolicyArrayLike, data_type: pa.DataType) -> pa.Array: | |
| items: Sequence[AggregationPolicyLike | str] = ( | |
| [data] if isinstance(data, (AggregationPolicy, int, str)) else data | |
| ) | |
| pa_data = [AggregationPolicy.auto(v).value if v is not None else None for v in items] # type: ignore[redundant-expr] | |
| return pa.array(pa_data, type=data_type) | |