feat(normalization): add validation for empty features in NormalizerProcessorStep and UnnormalizerProcessorStep (#2087)

* feat(normalization): add validation for empty features in NormalizerProcessorStep and UnnormalizerProcessorStep

* refactor(normalization): streamline feature reconstruction logic in _NormalizationMixin

* refactor(tests): remove unused preprocessor initialization in test_act_backbone_lr

---------

Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com>
This commit is contained in:
Adil Zouitine
2025-09-29 16:02:15 +02:00
committed by GitHub
parent bbcf66bd82
commit f173265354
3 changed files with 23 additions and 10 deletions

View File

@@ -534,6 +534,18 @@ def test_empty_observation():
assert result == transition
def test_empty_features_raises_error():
"""Test that empty features dict raises ValueError."""
norm_map = {FeatureType.VISUAL: NormalizationMode.MEAN_STD}
stats = {OBS_IMAGE: {"mean": [0.5], "std": [0.2]}}
with pytest.raises(ValueError, match="Normalization features cannot be empty"):
NormalizerProcessorStep(features={}, norm_map=norm_map, stats=stats)
with pytest.raises(ValueError, match="Normalization features cannot be empty"):
UnnormalizerProcessorStep(features={}, norm_map=norm_map, stats=stats)
def test_empty_stats():
features = {OBS_IMAGE: PolicyFeature(FeatureType.VISUAL, (3, 96, 96))}
norm_map = {FeatureType.VISUAL: NormalizationMode.MEAN_STD}