@@ -19,8 +19,11 @@ def test_read():
1919 )
2020 ds = cmlds .to_xarray ()
2121 I = np .where (ds ["predictor" ] == "air_temperature_2m" )[0 ][0 ]
22- value0 = ds ["predictors" ][0 , 0 , 0 , 0 , I ].values
23- np .testing .assert_almost_equal (value0 , 0.33352637 )
22+ value = ds ["predictors" ][0 , 0 , 0 , 0 , I ].values
23+ np .testing .assert_almost_equal (value , 0.33352637 )
24+
25+ value = ds ["targets" ][0 , 0 , 0 , 0 , 0 ].values
26+ np .testing .assert_almost_equal (value , 0.3591344 )
2427
2528def test_normalize_dataset ():
2629 cmlds = cml .load_dataset (
@@ -29,12 +32,17 @@ def test_normalize_dataset():
2932 dates = ["2020-03-01" , "2020-03-02" ],
3033 # location=f"{dir}/",
3134 probabilistic_target = False ,
35+ predict_diff = True ,
3236 normalize = True ,
3337 )
3438 ds = cmlds .to_xarray ()
3539 I = np .where (ds ["predictor" ] == "air_temperature_2m" )[0 ][0 ]
36- value0 = ds ["predictors" ][0 , 0 , 0 , 0 , I ].values
37- np .testing .assert_almost_equal (value0 , (0.33352637 - 5.388952960570653 )/ 7.4335476655246735 )
40+ value = ds ["predictors" ][0 , 0 , 0 , 0 , I ].values
41+ np .testing .assert_almost_equal (value , (0.33352637 - 5.388952960570653 )/ 7.4335476655246735 )
42+
43+ # Check that the target has been normalized by air_temperature_2m
44+ value = ds ["targets" ][0 , 0 , 0 , 0 , 0 ].values
45+ np .testing .assert_almost_equal (value , 0.3591344 - 0.33352637 )
3846
3947def test_normalize_functions ():
4048 ar = np .array ([0 , 1 , 2 ], np .float32 )
@@ -43,7 +51,6 @@ def test_normalize_functions():
4351 np .testing .assert_array_almost_equal (ar , [0 , 1 , 2 ])
4452
4553
46-
4754if __name__ == "__main__" :
4855 from climetlab .testing import main
4956
0 commit comments