Skip to content

Fix the string representation of archetypes #9297

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

Merged
merged 6 commits into from
Mar 20, 2025
Merged

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Mar 17, 2025

Archetype.__str__ was broken at some point. This PR fixes it. It also adds a (small) test.

Before:

rr.Points3D(
)

After:

rr.Points3D(
    positions=[[11.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 2.0],
 [3.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 2.0],
 [3.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 3.0]],
    radii=[1.0, 2.0, 3.0]
)

@abey79 abey79 added 🐍 Python API Python logging API 🦟 regression A thing that used to work in an earlier release include in changelog labels Mar 17, 2025
else:
comp_contents = pformat(as_arrow_array().to_pylist(), compact=True)

yield f" {fld.name}={comp_contents}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 4 spaces here combined with the 1 space indentation from pformat feels odd to me.

I'd personally find something like this more legible:

rr.Points3D(
  positions=[[11.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 2.0],
    [3.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 2.0],
    [3.0, 2.0, 3.0], [2.0, 3.0, 2.0], [3.0, 2.0, 3.0], [2.0, 3.0, 3.0]],
  radii=[1.0, 2.0, 3.0]
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I've been lazy because pformat is annoying. Threw in some regex to address that 🙄

@abey79 abey79 merged commit 422ebc5 into main Mar 20, 2025
36 checks passed
@abey79 abey79 deleted the antoine/fix-archetype-print branch March 20, 2025 09:41
@emilk emilk mentioned this pull request Apr 11, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🐍 Python API Python logging API 🦟 regression A thing that used to work in an earlier release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants