Closed
Description
CompositeSpec tests need improvements:
Test all CompositeSpec
features
Right now we only have a single function to test all of the CompositeSpec
methods. This should be chunked in several pieces:
class TestComposite:
@pytest.mark.parametrize("shape", [[], [3]])
@pytest.mark.parametrize("device", get_available_devices())
def test_composite_rand(device, shape):
do_stuff()
def test_composite_encode(...):
do_stuff()
These tests should cover all the available devices.
The methods to test are:
-
to
(device casting): test that an exception is raised if one inputs a dtype. Test that the device corresponds to the device used for casting. Test that random values drawn after casting to the device are on the device. -
__getitem__
and__setitem__
-
del_
-
encode
: inputting a dictionary should return the same dictionary modified in-place with the corresponding encodings. -
__repr__
should return a readable string -
type_check
should work with either a tensor and a key OR with a dict/TensorDict. -
is_in
-
project
-
rand
Test CompositeSpec
with incomplete spec fields
CompositeSpec
can have None
values when we know that a value is expected but we don't need to bother defining its space.
The current tests for CompositeSpec
only cover the case where all the fields are defined.
We should define a second round of tests where one of the values is None
.
This test should somewhat look like
@pytest.mark.parametrize("incomplete", [True, False])
def test_composite(incomplete, ...):
do_stuff()
Metadata
Metadata
Assignees
Labels
No labels