refactor(typing): add comprehensive types and their aliases#171
Merged
Conversation
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Contributor
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces comprehensive type validation and type aliases to the T4 dataset toolkit. It replaces the existing monolithic typing.py module with a structured typing package containing specialized classes for vectors, matrices, quaternions, and camera parameters with built-in validation.
Key changes include:
- Addition of validated type classes (Vector2, Vector3, Vector6, Matrix3x3, Matrix4x4, Quaternion, Roi, Trajectory, CameraIntrinsic, CameraDistortion)
- Comprehensive type aliases in
typing.aliasesfor flexible input handling - Removal of old validation system in favor of type constructors
- Extensive test coverage for all new typing components
Reviewed Changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
t4_devkit/typing/__init__.py |
Main typing module exports with numpy array type definitions |
t4_devkit/typing/vector.py |
BaseVector class and Vector2/3/6 implementations with validation |
t4_devkit/typing/matrix.py |
Matrix3x3 and Matrix4x4 classes with shape validation |
t4_devkit/typing/quaternion.py |
Quaternion wrapper around PyQuaternion |
t4_devkit/typing/roi.py |
ROI class with geometric property methods |
t4_devkit/typing/trajectory.py |
Trajectory class with 3D shape validation |
t4_devkit/typing/camera.py |
Camera intrinsic and distortion parameter classes |
t4_devkit/typing/aliases.py |
Comprehensive type aliases for flexible input handling |
tests/typing/ |
Extensive test suite covering all typing components |
| Various schema/dataclass files | Updated to use new typing system |
Comments suppressed due to low confidence (1)
tests/typing/test_vector.py:108
- The test case
test_invalid_2d_arrayon line 108 is checking for ValueError with a specific message, but the actual error would likely occur during numpy array conversion before reaching the Trajectory validation. This test might not be testing the intended validation path.
assert mean == 3.5
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR adds comprehensive types, which validates the input when it is constructed.
Type with Validation
For example,
t4_devkit.typing.Vector3validates the input array whether the shape of the array is 3:Type Aliases
In
typing.aliases, comprehensive type aliases are defined, and they allow developer to add type hints easily: