Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default DisconnectedSpaces boolean to true in Python #3760

Merged
merged 8 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ struct DisconnectedSpace (
"attr.python.array_aliases": "bool, npt.NDArray[np.bool_]",
"attr.rust.derive": "Copy, PartialEq, Eq"
) {
/// Whether the entity path at which this is logged is disconnected from its parent.
is_disconnected: bool (order: 100);
}
5 changes: 4 additions & 1 deletion crates/re_types/src/components/disconnected_space.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/code-examples/disconnected_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
rr.log("world/room2/point", rr.Points3D([[1, 1, 1]]))

# ..but this one lives in a completely separate space!
rr.log("world/wormhole", rr.DisconnectedSpace(True))
rr.log("world/wormhole", rr.DisconnectedSpace())
rr.log("world/wormhole/point", rr.Points3D([[2, 2, 2]]))
1 change: 1 addition & 0 deletions rerun_cpp/src/rerun/components/disconnected_space.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 4 additions & 13 deletions rerun_py/rerun_sdk/rerun/archetypes/disconnected_space.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions rerun_py/rerun_sdk/rerun/archetypes/disconnected_space_ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from ..components import DisconnectedSpaceLike


class DisconnectedSpaceExt:
"""Extension for [DisconnectedSpace][rerun.archetypes.DisconnectedSpace]."""

def __init__(
self: Any,
is_disconnected: DisconnectedSpaceLike = True,
):
"""
Disconnect an entity from its parent.

Parameters
----------
is_disconnected:
Whether or not the entity should be disconnected from the rest of the scene.
Set to `True` to disconnect the entity from its parent.
Set to `False` to disable the effects of this archetype, (re-)connecting the entity to its parent again.
"""

self.__attrs_init__(is_disconnected=is_disconnected)
9 changes: 4 additions & 5 deletions rerun_py/rerun_sdk/rerun/components/disconnected_space.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion rerun_py/rerun_sdk/rerun/components/disconnected_space_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import numpy as np
import pyarrow as pa
Expand All @@ -12,6 +12,22 @@
class DisconnectedSpaceExt:
"""Extension for [DisconnectedSpace][rerun.components.DisconnectedSpace]."""

def __init__(
self: Any,
is_disconnected: bool = True,
):
"""
Disconnect an entity from its parent.

Parameters
----------
is_disconnected:
Whether or not the entity should be disconnected from the rest of the scene.
Set to `True` to disconnect the entity from its parent.
Set to `False` to disable the effects of this component, (re-)connecting the entity to its parent again.
"""
self.__attrs_init__(is_disconnected=is_disconnected)

@staticmethod
def native_to_pa_array_override(data: DisconnectedSpaceArrayLike, data_type: pa.DataType) -> pa.Array:
array = np.asarray(data, dtype=np.bool_).flatten()
Expand Down
2 changes: 1 addition & 1 deletion rerun_py/rerun_sdk/rerun/log_deprecated/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def log_disconnected_space(

recording = RecordingStream.to_native(recording)

log(entity_path, DisconnectedSpace(True), timeless=timeless, recording=recording)
log(entity_path, DisconnectedSpace(), timeless=timeless, recording=recording)


@deprecated(
Expand Down
2 changes: 1 addition & 1 deletion rerun_py/tests/unit/test_disconnected_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_disconnected_space() -> None:
# DisconnectedSpaceLike: bool
True,
# DisconnectedSpaceLike: DisconnectedSpace
DisconnectedSpace(True),
DisconnectedSpace(),
]

for disconnected_space in disconnected_spaces:
Expand Down
2 changes: 1 addition & 1 deletion tests/python/roundtrips/disconnected_space/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main() -> None:

rr.script_setup(args, "rerun_example_roundtrip_disconnected_space")

rr.log("disconnected_space", rr.DisconnectedSpace(True))
rr.log("disconnected_space", rr.DisconnectedSpace())

rr.script_teardown(args)

Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def transforms(experimental_api: bool) -> None:
rr.log("transforms", rr.ViewCoordinates.RIGHT_HAND_Y_UP, timeless=True)

# Log a disconnected space (this doesn't do anything here, but can be used to force a new space)
rr.log("transforms/disconnected", rr.DisconnectedSpace(True))
rr.log("transforms/disconnected", rr.DisconnectedSpace())

# Log scale along the x axis only.
rr.log("transforms/x_scaled", rr.Transform3D(scale=(3, 1, 1)))
Expand Down
Loading