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

fix: replace np.asarray by np.array in dataclass constructors #73

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

ktro2828
Copy link
Collaborator

@ktro2828 ktro2828 commented Dec 25, 2024

What

This PR replaces np.asarray in converters in each dataclass into np.array.
Because np.asarray doesn't create a copy of the input if it is already ndarray, the original values are changed unexpectedly if a destructive method is called, such as Box3D.translate(...).

Experiment

Test code is as follows:

from t4_devkit import Tier4

t4 = Tier4("annotation", <DATA_ROOT>, verbose=False)

print(t4.sample_annotation[0].translation)

# Destructive methods, which are Box3D.translate(...) and Box3D.rotate(...), are invoked under the hood.
t4.get_sample_data(t4.sample_data[0].token)  

print(t4.sample_annotation[0].translation)

Before

Then the output shows the original has been changed.

[8.9548508e+04 4.2286165e+04 7.9690000e+00]
[-6.61751375 -4.48131001  1.01779332]

After

As of this PR, there is no change between before and after calling destructive methods.

[8.9548508e+04 4.2286165e+04 7.9690000e+00]
[8.9548508e+04 4.2286165e+04 7.9690000e+00]

@github-actions github-actions bot added the bug Something isn't working label Dec 25, 2024
Copy link

github-actions bot commented Dec 25, 2024

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
2106 1428 68% 50% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
t4_devkit/common/converter.py 89% 🟢
t4_devkit/dataclass/box.py 76% 🔴
t4_devkit/dataclass/pointcloud.py 40% 🔴
t4_devkit/dataclass/roi.py 94% 🟢
t4_devkit/dataclass/shape.py 94% 🟢
t4_devkit/dataclass/trajectory.py 93% 🟢
t4_devkit/dataclass/transform.py 76% 🔴
t4_devkit/schema/tables/calibrated_sensor.py 95% 🟢
t4_devkit/schema/tables/ego_pose.py 95% 🟢
t4_devkit/schema/tables/keypoint.py 94% 🟢
t4_devkit/schema/tables/sample_annotation.py 97% 🟢
t4_devkit/schema/tables/vehicle_state.py 100% 🟢
TOTAL 87% 🔴

updated for commit: 251c10d by action🐍

@github-actions github-actions bot added the ci Continuous Integration (CI) processes and testing label Dec 25, 2024
@ktro2828 ktro2828 changed the title fix: replace np.array instead of np.asarray in dataclass constructors fix: replace np.asarray by np.array in dataclass constructors Dec 25, 2024
@ktro2828 ktro2828 merged commit 88e158c into main Dec 25, 2024
4 of 5 checks passed
@ktro2828 ktro2828 deleted the fix/dataclass/conversion branch December 25, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci Continuous Integration (CI) processes and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant