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 type error in DropPointsByClass #113

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Fix type error in DropPointsByClass #113

merged 1 commit into from
Mar 7, 2024

Conversation

leavauchier
Copy link
Collaborator

A TypeError: object of type 'numpy.int64' has no len() was raised in some specific use case when using DropPointsByClass with batches containing a single point (the numpy array was transformed to an integer)

def test_model_get_batch_tensor_by_enumeration():
with hydra.initialize(config_path="./../../../trained_model_assets/", job_name="config"):
config = hydra.compose(
config_name="proto151_V2.0_epoch_100_Myria3DV3.1.0_predict_config_V3.7.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This config_name is hardcoded. Can it be defined imported (I think it is defined in run.py or train.py).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, looks a good idea, but I'm not sure it is easy to get DEFAULT_CONFIG_FILE from run.py as it is not in the myria3d python module (hence I suppose it is not intended to be imported)

Copy link
Collaborator

@CharlesGaydon CharlesGaydon Mar 6, 2024

Choose a reason for hiding this comment

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

Inded, but consequently I do not think it is supposed to be used for testing.
In test I usually used function make_default_hydra_cfg from conftest.py, to always test for the default configuration (not the one used for inference).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I finally managed to find how to use it (the issue was that datamodule was using hydra:runtime.cwd, so I had to override the parameter that required it

data = torch_geometric.data.Data(x=None, y=y, idx_in_original_cloud=idx)
out_data = tt(data)
assert np.array_equal(out_data.y, np.array([0, 0, 0, 0, 1, 1]))
assert np.array_equal(out_data.idx_in_original_cloud, idx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you testing that the idx in original cloud are not modified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, after all I'm not sure it is useful, but I did it to be consistent with the test I added for DropPointsByClass

Copy link
Collaborator

@CharlesGaydon CharlesGaydon left a comment

Choose a reason for hiding this comment

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

Small improvement could be made by referencing config file via a variable. Apart from that looks good to me :)

@CharlesGaydon
Copy link
Collaborator

LGTM !

@leavauchier leavauchier merged commit 83b6b21 into main Mar 7, 2024
1 check passed
@leavauchier leavauchier deleted the fix-drop-points branch March 7, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants