patrick-kidger / torchtyping

Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.
Apache License 2.0
1.41k stars 34 forks source link

Add Any type support for shape #6

Closed AdilZouitine closed 3 years ago

AdilZouitine commented 3 years ago

We can specify the arbitrary shape of a dimension using the Any type. Example: any_tensor = TensorType[3, 3, Any, torch.float32]

I do not include the tests, to be honest, I am a bit lost on all the tests that you want. Could you clarify them for me @patrick-kidger ?

So that I can do them in the next commit.

Edit: I guess a test/test_any.py and a function test_any_dim in test/test_shape.py

patrick-kidger commented 3 years ago

Haha, it's definitely true I went a bit overboard on the tests.

I think duplicating every test with a -1 in test_shape.py, to also test for Any, should be sufficient.

AdilZouitine commented 3 years ago

My PR is ready for the code review @patrick-kidger :smile:

Edit: I forgot README.md and doc modification

AdilZouitine commented 3 years ago

English is not my mother tongue, so don't hesitate to correct me :smile:

AdilZouitine commented 3 years ago

I thank you for your reactivity, I will come back to you with new feature proposals when I will have spent more time using your library :smile:

patrick-kidger commented 3 years ago

LGTM. Thanks for contributing!