Spectral-World-Models-Reproducibility / tests /test_v14_external_control.py
kiruluta's picture
Upload folder using huggingface_hub
4fd79a1 verified
Raw History Blame Contribute Delete
717 Bytes
import numpy as np
from spectral_world_models.v14_external_control import rgb_to_gray32, build_vocab, obs_to_tokens, ExternalConfig, SUPPORTED_ENVS
def test_external_suite_declared():
assert set(SUPPORTED_ENVS)=={"CartPole-v1","MountainCar-v0","Acrobot-v1"}
def test_render_preprocess_shape_range():
rgb=np.zeros((40,60,3),dtype=np.uint8); rgb[10:20,20:30]=255
x=rgb_to_gray32(rgb,32); assert x.shape==(1,32,32); assert 0<=x.min()<=x.max()<=1
def test_external_tokens_bounded():
obs=np.array([0.,1.,-2.],dtype=np.float32); low=np.array([-1.,-np.inf,-3.]); high=np.array([1.,np.inf,3.])
v=build_vocab('X',3); t=obs_to_tokens(obs,low,high,'X',8); assert t.shape==(8,); assert int(t.max())<len(v)