7
7
import importlib .util
8
8
import urllib .error
9
9
10
- from gym .core import ObsType
11
-
12
10
_has_isaac = importlib .util .find_spec ("isaacgym" ) is not None
13
11
14
12
if _has_isaac :
25
23
from contextlib import nullcontext
26
24
from pathlib import Path
27
25
from sys import platform
28
- from typing import Optional , Tuple , Union
26
+ from typing import Optional , Union
29
27
from unittest import mock
30
28
31
29
import numpy as np
@@ -638,7 +636,8 @@ def test_torchrl_to_gym(self, backend, numpy):
638
636
639
637
@implement_for ("gym" , None , "0.26" )
640
638
def test_gym_dict_action_space (self ):
641
- pytest .skip ("tested for gym > 0.26 - no backward issue" )
639
+ torchrl_logger .info ("tested for gym > 0.26 - no backward issue" )
640
+ return
642
641
643
642
@implement_for ("gym" , "0.26" , None )
644
643
def test_gym_dict_action_space (self ): # noqa: F811
@@ -653,14 +652,17 @@ def __init__(self):
653
652
self .observation_space = gym .spaces .Box (- 1 , 1 )
654
653
655
654
def step (self , action ):
655
+ assert isinstance (action , dict )
656
+ assert isinstance (action ["a0" ], np .ndarray )
657
+ assert isinstance (action ["a1" ], np .ndarray )
656
658
return (0.5 , 0.0 , False , False , {})
657
659
658
660
def reset (
659
661
self ,
660
662
* ,
661
663
seed : Optional [int ] = None ,
662
664
options : Optional [dict ] = None ,
663
- ) -> Tuple [ ObsType , dict ] :
665
+ ):
664
666
return (0.0 , {})
665
667
666
668
env = CompositeActionEnv ()
@@ -686,14 +688,17 @@ def __init__(self):
686
688
self .observation_space = gym .spaces .Box (- 1 , 1 )
687
689
688
690
def step (self , action ):
691
+ assert isinstance (action , dict )
692
+ assert isinstance (action ["a0" ], np .ndarray )
693
+ assert isinstance (action ["a1" ], np .ndarray )
689
694
return (0.5 , 0.0 , False , False , {})
690
695
691
696
def reset (
692
697
self ,
693
698
* ,
694
699
seed : Optional [int ] = None ,
695
700
options : Optional [dict ] = None ,
696
- ) -> Tuple [ ObsType , dict ] :
701
+ ):
697
702
return (0.0 , {})
698
703
699
704
env = CompositeActionEnv ()
0 commit comments