@@ -680,30 +680,59 @@ def test_log10(x):
680
680
def test_logaddexp (args ):
681
681
x1 , x2 = args
682
682
sanity_check (x1 , x2 )
683
- # a = _array_module.logaddexp(x1, x2)
683
+ _array_module .logaddexp (x1 , x2 )
684
+ # The spec doesn't require any behavior for this function. We could test
685
+ # that this is indeed an approximation of log(exp(x1) + exp(x2)), but we
686
+ # don't have tests for this sort of thing for any functions yet.
684
687
685
688
@given (two_boolean_dtypes .flatmap (lambda i : two_array_scalars (* i )))
686
689
def test_logical_and (args ):
687
690
x1 , x2 = args
688
691
sanity_check (x1 , x2 )
689
- # a = _array_module.logical_and(x1, x2)
692
+ a = _array_module .logical_and (x1 , x2 )
693
+
694
+ # See the comments in test_equal
695
+ shape = broadcast_shapes (x1 .shape , x2 .shape )
696
+ _x1 = _array_module .broadcast_to (x1 , shape )
697
+ _x2 = _array_module .broadcast_to (x2 , shape )
698
+
699
+ for idx in ndindex (shape ):
700
+ assert a [idx ] == (bool (_x1 [idx ]) and bool (_x2 [idx ]))
690
701
691
702
@given (boolean_scalars )
692
703
def test_logical_not (x ):
693
- # a = _array_module.logical_not(x)
694
- pass
704
+ a = _array_module .logical_not (x )
705
+
706
+ for idx in ndindex (x .shape ):
707
+ assert a [idx ] == (not bool (x [idx ]))
695
708
696
709
@given (two_boolean_dtypes .flatmap (lambda i : two_array_scalars (* i )))
697
710
def test_logical_or (args ):
698
711
x1 , x2 = args
699
712
sanity_check (x1 , x2 )
700
- # a = _array_module.logical_or(x1, x2)
713
+ a = _array_module .logical_or (x1 , x2 )
714
+
715
+ # See the comments in test_equal
716
+ shape = broadcast_shapes (x1 .shape , x2 .shape )
717
+ _x1 = _array_module .broadcast_to (x1 , shape )
718
+ _x2 = _array_module .broadcast_to (x2 , shape )
719
+
720
+ for idx in ndindex (shape ):
721
+ assert a [idx ] == (bool (_x1 [idx ]) or bool (_x2 [idx ]))
701
722
702
723
@given (two_boolean_dtypes .flatmap (lambda i : two_array_scalars (* i )))
703
724
def test_logical_xor (args ):
704
725
x1 , x2 = args
705
726
sanity_check (x1 , x2 )
706
- # a = _array_module.logical_xor(x1, x2)
727
+ a = _array_module .logical_xor (x1 , x2 )
728
+
729
+ # See the comments in test_equal
730
+ shape = broadcast_shapes (x1 .shape , x2 .shape )
731
+ _x1 = _array_module .broadcast_to (x1 , shape )
732
+ _x2 = _array_module .broadcast_to (x2 , shape )
733
+
734
+ for idx in ndindex (shape ):
735
+ assert a [idx ] == (bool (_x1 [idx ]) ^ bool (_x2 [idx ]))
707
736
708
737
@given (two_numeric_dtypes .flatmap (lambda i : two_array_scalars (* i )))
709
738
def test_multiply (args ):
0 commit comments