44
55import numpy as np
66
7- from src .defences .local_spatial_smoothing import LocalSpatialSmoothing
7+ from src .defences .spatial_smoothing import SpatialSmoothing
88
99
1010class TestLocalSpatialSmoothing (unittest .TestCase ):
@@ -15,29 +15,30 @@ def test_ones(self):
1515 # Start to test
1616 for window_size in range (1 , 20 ):
1717 with self .subTest ("Sliding window size = {}" .format (window_size )):
18- preprocess = LocalSpatialSmoothing ()
18+ preprocess = SpatialSmoothing ()
1919 smoothed_x = preprocess (x , window_size )
2020 self .assertTrue ((smoothed_x == 1 ).all ())
2121
2222 def test_fix (self ):
23- x = np .array ([[[[1 ],[2 ],[3 ]],[[7 ],[8 ],[9 ]],[[4 ],[5 ],[6 ]]]])
23+ x = np .array ([[[[1 ], [2 ], [3 ]], [[7 ], [8 ], [9 ]], [[4 ], [5 ], [6 ]]]])
2424
2525 # Start to test
26- preprocess = LocalSpatialSmoothing ()
26+ preprocess = SpatialSmoothing ()
2727 smoothed_x = preprocess (x , 3 )
2828 self .assertTrue ((smoothed_x == np .array (
29- [[[[2 ],[3 ],[3 ]],[[4 ],[5 ],[6 ]],[[5 ],[6 ],[6 ]]]])).all ())
29+ [[[[2 ], [3 ], [3 ]], [[4 ], [5 ], [6 ]], [[5 ], [6 ], [6 ]]]])).all ())
3030
3131 smoothed_x = preprocess (x , 1 )
3232 self .assertTrue ((smoothed_x == x ).all ())
3333
3434 smoothed_x = preprocess (x , 2 )
3535 self .assertTrue ((smoothed_x == np .array (
36- [[[[1 ],[2 ],[3 ]],[[7 ],[7 ],[8 ]],[[7 ],[7 ],[8 ]]]])).all ())
36+ [[[[1 ], [2 ], [3 ]], [[7 ], [7 ], [8 ]], [[7 ], [7 ], [8 ]]]])).all ())
3737
3838
3939if __name__ == '__main__' :
4040 unittest .main ()
4141
4242
4343
44+
0 commit comments