@@ -408,6 +408,25 @@ def test_unsized_integer_casts(dtype, typename, signed):
408408 np .testing .assert_array_equal (ainp , ainp .astype (dtype ).astype (idtype ))
409409
410410
411+ @pytest .mark .parametrize ("typename" , ["float64" , "float32" , "float16" ])
412+ def test_float_casts (dtype , typename ):
413+ inp = [1.1 , 2.8 , - 3.2 , 2.7e4 ]
414+ ainp = np .array (inp , dtype = typename )
415+ np .testing .assert_array_equal (ainp , ainp .astype (dtype ).astype (typename ))
416+
417+ fi = np .finfo (typename )
418+
419+ inp = [1e-324 , fi .smallest_subnormal , - 1e-324 , - fi .smallest_subnormal ]
420+ eres = [0 , fi .smallest_subnormal , - 0 , - fi .smallest_subnormal ]
421+ res = np .array (inp , dtype = typename ).astype (dtype ).astype (typename )
422+ np .testing .assert_array_equal (eres , res )
423+
424+ inp = [2e308 , fi .max , - 2e308 , fi .min ]
425+ eres = [np .inf , fi .max , - np .inf , fi .min ]
426+ res = np .array (inp , dtype = typename ).astype (dtype ).astype (typename )
427+ np .testing .assert_array_equal (eres , res )
428+
429+
411430def test_take (dtype , string_list ):
412431 sarr = np .array (string_list , dtype = dtype )
413432 out = np .empty (len (string_list ), dtype = dtype )
0 commit comments