@@ -519,26 +519,6 @@ def test_infinity_sign_errors(func):
519519
520520
521521class TestIsClose :
522- @pytest .mark .parametrize ("val" , [1.0 , numpy .inf , - numpy .inf , numpy .nan ])
523- def test_input_0d (self , val ):
524- dp_arr = dpnp .array (val )
525- np_arr = numpy .array (val )
526-
527- # array & scalar
528- dp_res = dpnp .isclose (dp_arr , val )
529- np_res = numpy .isclose (np_arr , val )
530- assert_allclose (dp_res , np_res )
531-
532- # scalar & array
533- dp_res = dpnp .isclose (val , dp_arr )
534- np_res = numpy .isclose (val , np_arr )
535- assert_allclose (dp_res , np_res )
536-
537- # array & array
538- dp_res = dpnp .isclose (dp_arr , dp_arr )
539- np_res = numpy .isclose (np_arr , np_arr )
540- assert_allclose (dp_res , np_res )
541-
542522 @pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
543523 @pytest .mark .parametrize (
544524 "rtol" , [1e-5 , dpnp .array (1e-5 ), dpnp .full ((10 ,), 1e-5 )]
@@ -572,6 +552,51 @@ def test_isclose_complex(self, dtype, shape):
572552 dpnp_res = dpnp .isclose (dpnp_a , dpnp_b )
573553 assert_allclose (dpnp_res , np_res )
574554
555+ @pytest .mark .parametrize (
556+ "rtol, atol" ,
557+ [
558+ (1e-5 , 1e-8 ),
559+ (dpnp .array (1e-5 ), dpnp .array (1e-8 )),
560+ ],
561+ )
562+ def test_empty_input (self , rtol , atol ):
563+ a = numpy .array ([])
564+ b = numpy .array ([])
565+
566+ dpnp_a = dpnp .array (a )
567+ dpnp_b = dpnp .array (b )
568+
569+ np_res = numpy .isclose (a , b , rtol = 1e-5 , atol = 1e-8 )
570+ dpnp_res = dpnp .isclose (dpnp_a , dpnp_b , rtol = rtol , atol = atol )
571+ assert_allclose (dpnp_res , np_res )
572+
573+ @pytest .mark .parametrize (
574+ "rtol, atol" ,
575+ [
576+ (1e-5 , 1e-8 ),
577+ (dpnp .array (1e-5 ), dpnp .array (1e-8 )),
578+ ],
579+ )
580+ @pytest .mark .parametrize ("val" , [1.0 , numpy .inf , - numpy .inf , numpy .nan ])
581+ def test_input_0d (self , val , rtol , atol ):
582+ dp_arr = dpnp .array (val )
583+ np_arr = numpy .array (val )
584+
585+ # array & scalar
586+ dp_res = dpnp .isclose (dp_arr , val , rtol = rtol , atol = atol )
587+ np_res = numpy .isclose (np_arr , val , rtol = 1e-5 , atol = 1e-8 )
588+ assert_allclose (dp_res , np_res )
589+
590+ # scalar & array
591+ dp_res = dpnp .isclose (val , dp_arr , rtol = rtol , atol = atol )
592+ np_res = numpy .isclose (val , np_arr , rtol = 1e-5 , atol = 1e-8 )
593+ assert_allclose (dp_res , np_res )
594+
595+ # array & array
596+ dp_res = dpnp .isclose (dp_arr , dp_arr , rtol = rtol , atol = atol )
597+ np_res = numpy .isclose (np_arr , np_arr , rtol = 1e-5 , atol = 1e-8 )
598+ assert_allclose (dp_res , np_res )
599+
575600 @pytest .mark .parametrize (
576601 "sh_a, sh_b" ,
577602 [
@@ -592,15 +617,22 @@ def test_broadcast_shapes(self, sh_a, sh_b):
592617 dp_res = dpnp .isclose (a_dp , b_dp )
593618 assert_allclose (dp_res , np_res )
594619
595- def test_equal_nan (self ):
620+ @pytest .mark .parametrize (
621+ "rtol, atol" ,
622+ [
623+ (1e-5 , 1e-8 ),
624+ (dpnp .array (1e-5 ), dpnp .array (1e-8 )),
625+ ],
626+ )
627+ def test_equal_nan (self , rtol , atol ):
596628 a = numpy .array ([numpy .nan , 1.0 ])
597629 b = numpy .array ([numpy .nan , 1.0 ])
598630
599631 dp_a = dpnp .array (a )
600632 dp_b = dpnp .array (b )
601633
602- np_res = numpy .isclose (a , b , equal_nan = True )
603- dp_res = dpnp .isclose (dp_a , dp_b , equal_nan = True )
634+ np_res = numpy .isclose (a , b , rtol = 1e-5 , atol = 1e-8 , equal_nan = True )
635+ dp_res = dpnp .isclose (dp_a , dp_b , rtol = rtol , atol = atol , equal_nan = True )
604636 assert_allclose (dp_res , np_res )
605637
606638 # array-like rtol/atol support requires NumPy >= 2.0
0 commit comments