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

Nicer transform archetype interface in python #3560

Merged
merged 10 commits into from
Oct 2, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Sep 29, 2023

What

Checklist

@Wumpf Wumpf added 🐍 Python API Python logging API exclude from changelog PRs with this won't show up in CHANGELOG.md labels Sep 29, 2023
@Wumpf
Copy link
Member Author

Wumpf commented Sep 29, 2023

@jleibs is the exception throwing there in line and will be caught automatically? I'm a bit out of the loop with what we ended up with

Edit: Oh that's still all on #3531. I'll review it on Monday

Copy link
Contributor

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

This makes for such a nice API!!

Two things:

  1. Maybe add a test to ensure exceptions are raised with incompatible args (with @pytest.raises(ValueError): ....
  2. Maybe should shouldn't completely hide (or make non-obvious) that the "concrete" types (TranslationAndMat3x3, etc.) can be used as well. That could be added to the __init__ docstring, maybe, in a transform3d_explicit.py example?

"""
Create a new instance of the Transform3D archetype.

Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

May be an example section here would be good, as a way to list all supported combinations. This is going to be useful for the user, to avoid solving for constraints listed in the Parameter section

Copy link
Member Author

Choose a reason for hiding this comment

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

we generally have examples on the type documentation. I'm hesitant to add examples now and here and only for python.
"all supported combintations" may also be way too much

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this is not the place for a full on example, but something akin to this would still provide value IMO. It's much more explicit as to what the 3 general forms are.

# use one of the concrete transform data type, e.g.
rr.Transform3D(rr.datatypes.TranslationAndMat3x3)

# using translation and/or and 3x3 matrix
rr.Transform3D(translation=[...], mat3x3=[...])

# using any or all of the elementary transform components
rr.Transform3D(translation=[...], rotation=..., scale=...)

Copy link
Contributor

Choose a reason for hiding this comment

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

It could even be a bullet list without actual code.

@Wumpf
Copy link
Member Author

Wumpf commented Oct 2, 2023

Maybe should shouldn't completely hide (or make non-obvious) that the "concrete" types (TranslationAndMat3x3, etc.) can be used as well. That could be added to the init docstring, maybe, in a transform3d_explicit.py example?

I mean they're not really all that hidden, are they? It's the first parameter the method takes. But that said I could manually expand the type annotation to

        Transform3D |
        datatypes.TranslationAndMat3x3 |
        datatypes.TranslationRotationScale3D

but we also never do that in any other place, so I'm a bit hesitant

@abey79
Copy link
Contributor

abey79 commented Oct 2, 2023

Maybe should shouldn't completely hide (or make non-obvious) that the "concrete" types (TranslationAndMat3x3, etc.) can be used as well. That could be added to the init docstring, maybe, in a transform3d_explicit.py example?

I mean they're not really all that hidden, are they? It's the first parameter the method takes. But that said I could manually expand the type annotation to

        Transform3D |
        datatypes.TranslationAndMat3x3 |
        datatypes.TranslationRotationScale3D

but we also never do that in any other place, so I'm a bit hesitant

Yeah, I don't have a very strong feeling about this. Also, I think my comment would largely address the visibility of these datatypes.

@Wumpf Wumpf force-pushed the andreas/python-better-transform branch from 938bfb3 to a26c974 Compare October 2, 2023 13:17
@jleibs jleibs mentioned this pull request Oct 2, 2023
55 tasks
@Wumpf Wumpf merged commit 69a1549 into main Oct 2, 2023
30 of 31 checks passed
@Wumpf Wumpf deleted the andreas/python-better-transform branch October 2, 2023 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md 🐍 Python API Python logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's hard to discover how to use Transform3D archetype
3 participants