@@ -101,16 +101,16 @@ def test_morphshift_extrapolate(user_filesystem, stretch, wmsg_gen):
101101 y_morph = numpy .sin (x_morph )
102102 x_target = x_morph .copy ()
103103 y_target = y_morph .copy ()
104- with pytest .warns () as w :
104+ with pytest .warns () as warning :
105105 morphpy .morph_arrays (
106106 numpy .array ([x_morph , y_morph ]).T ,
107107 numpy .array ([x_target , y_target ]).T ,
108108 stretch = stretch ,
109109 apply = True ,
110110 )
111- assert len (w ) == 1
112- assert w [0 ].category is UserWarning
113- actual_wmsg = str (w [0 ].message )
111+ assert len (warning ) == 1
112+ assert warning [0 ].category is UserWarning
113+ actual_wmsg = str (warning [0 ].message )
114114 expected_wmsg = wmsg_gen ([min (x_morph ), max (x_morph )])
115115 assert actual_wmsg == expected_wmsg
116116
@@ -131,3 +131,36 @@ def test_morphshift_extrapolate(user_filesystem, stretch, wmsg_gen):
131131 )
132132 with pytest .warns (UserWarning , match = expected_wmsg ):
133133 single_morph (parser , opts , pargs , stdout_flag = False )
134+
135+
136+ def test_morphshift_no_warning (user_filesystem ):
137+ # Apply a stretch with no extrapolation
138+ # There should be no warning or errors produced
139+ x_morph = numpy .linspace (1 , 10 , 101 )
140+ y_morph = numpy .sin (x_morph )
141+ x_target = x_morph .copy ()
142+ y_target = y_morph .copy ()
143+ morphpy .morph_arrays (
144+ numpy .array ([x_morph , y_morph ]).T ,
145+ numpy .array ([x_target , y_target ]).T ,
146+ stretch = 0 ,
147+ apply = True ,
148+ )
149+
150+ # CLI test
151+ morph_file , target_file = create_morph_data_file (
152+ user_filesystem / "cwd_dir" , x_morph , y_morph , x_target , y_target
153+ )
154+
155+ parser = create_option_parser ()
156+ (opts , pargs ) = parser .parse_args (
157+ [
158+ "--scale=1" ,
159+ "--stretch=0" ,
160+ f"{ morph_file .as_posix ()} " ,
161+ f"{ target_file .as_posix ()} " ,
162+ "--apply" ,
163+ "-n" ,
164+ ]
165+ )
166+ single_morph (parser , opts , pargs , stdout_flag = False )
0 commit comments