@@ -46,7 +46,7 @@ def test_refine_morph(self, setup):
4646
4747 assert (x_morph == x_target ).all ()
4848 assert numpy .allclose (y_morph , y_target )
49- pytest .approx (config ["scale" ], 3.0 )
49+ assert pytest .approx (config ["scale" ]) == 3.0
5050 return
5151
5252 def test_refine_chain (self , setup ):
@@ -74,8 +74,44 @@ def test_refine_chain(self, setup):
7474 err = 15.0 * 2
7575 res = sum (numpy .fabs (y_target - y_morph ))
7676 assert res < err
77- pytest .approx (chain .scale , 3 , 2 )
78- pytest .approx (chain .stretch , 0.1 , 2 )
77+ assert pytest .approx (chain .scale , 0.01 , 0.01 ) == 3.0
78+ assert pytest .approx (chain .stretch , 0.01 , 0.01 ) == 0.1
79+ return
80+
81+ def test_refine_tolerance (self , setup ):
82+ # Check that small tolerance gives good result
83+ stol = 1e-16
84+ config = {
85+ "scale" : 1.0 ,
86+ }
87+ mscale = MorphScale (config )
88+ refiner = Refiner (
89+ mscale ,
90+ self .x_morph ,
91+ self .y_morph ,
92+ self .x_target ,
93+ self .y_target ,
94+ tolerance = stol ,
95+ )
96+ refiner .refine ()
97+ assert pytest .approx (config ["scale" ], stol , stol ) == 3.0
98+
99+ # Check that larger tolerance does not give as good of result
100+ ltol = 100
101+ config = {
102+ "scale" : 1.0 ,
103+ }
104+ mscale = MorphScale (config )
105+ refiner = Refiner (
106+ mscale ,
107+ self .x_morph ,
108+ self .y_morph ,
109+ self .x_target ,
110+ self .y_target ,
111+ tolerance = ltol ,
112+ )
113+ refiner .refine ()
114+ assert not pytest .approx (config ["scale" ], stol , stol ) == 3.0
79115 return
80116
81117
0 commit comments