@@ -634,23 +634,47 @@ def test_less_equal(args):
634
634
635
635
@given (floating_scalars )
636
636
def test_log (x ):
637
- # a = _array_module.log(x)
638
- pass
637
+ a = _array_module .log (x )
638
+ INFINITY = infinity (x .shape , x .dtype )
639
+ ZERO = zero (x .shape , x .dtype )
640
+ domain = inrange (x , ZERO , INFINITY )
641
+ codomain = inrange (a , - INFINITY , INFINITY )
642
+ # log maps [0, inf] to [-inf, inf]. Values outside this domain are
643
+ # mapped to nan, which is already tested in the special cases.
644
+ assert_exactly_equal (domain , codomain )
639
645
640
646
@given (floating_scalars )
641
647
def test_log1p (x ):
642
- # a = _array_module.log1p(x)
643
- pass
648
+ a = _array_module .log1p (x )
649
+ INFINITY = infinity (x .shape , x .dtype )
650
+ NEGONE = - one (x .shape , x .dtype )
651
+ codomain = inrange (x , NEGONE , INFINITY )
652
+ domain = inrange (a , - INFINITY , INFINITY )
653
+ # log1p maps [1, inf] to [-inf, inf]. Values outside this domain are
654
+ # mapped to nan, which is already tested in the special cases.
655
+ assert_exactly_equal (domain , codomain )
644
656
645
657
@given (floating_scalars )
646
658
def test_log2 (x ):
647
- # a = _array_module.log2(x)
648
- pass
659
+ a = _array_module .log2 (x )
660
+ INFINITY = infinity (x .shape , x .dtype )
661
+ ZERO = zero (x .shape , x .dtype )
662
+ domain = inrange (x , ZERO , INFINITY )
663
+ codomain = inrange (a , - INFINITY , INFINITY )
664
+ # log2 maps [0, inf] to [-inf, inf]. Values outside this domain are
665
+ # mapped to nan, which is already tested in the special cases.
666
+ assert_exactly_equal (domain , codomain )
649
667
650
668
@given (floating_scalars )
651
669
def test_log10 (x ):
652
- # a = _array_module.log10(x)
653
- pass
670
+ a = _array_module .log10 (x )
671
+ INFINITY = infinity (x .shape , x .dtype )
672
+ ZERO = zero (x .shape , x .dtype )
673
+ domain = inrange (x , ZERO , INFINITY )
674
+ codomain = inrange (a , - INFINITY , INFINITY )
675
+ # log10 maps [0, inf] to [-inf, inf]. Values outside this domain are
676
+ # mapped to nan, which is already tested in the special cases.
677
+ assert_exactly_equal (domain , codomain )
654
678
655
679
@given (two_floating_dtypes .flatmap (lambda i : two_array_scalars (* i )))
656
680
def test_logaddexp (args ):
0 commit comments