1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
# tag: numpy
# tag: no-cpp
# Numpy <= 1.7.1 doesn't have a C++ guard in the header file.
cimport numpy.math as npmath
def test_fp_classif():
"""
>>> test_fp_classif()
"""
cdef double d_zero
cdef float f_zero
d_zero = -1 * 0.
f_zero = -1 * 0.
assert d_zero == npmath.NZERO
assert f_zero == npmath.NZERO
assert npmath.signbit(d_zero)
assert npmath.signbit(f_zero)
d_zero = 1 * 0.
f_zero = 1 * 0.
assert d_zero == npmath.PZERO
assert f_zero == npmath.PZERO
assert not npmath.signbit(d_zero)
assert not npmath.signbit(f_zero)
assert not npmath.isinf(d_zero)
assert not npmath.isinf(f_zero)
assert not npmath.isnan(d_zero)
assert not npmath.isnan(f_zero)
assert npmath.isinf(-npmath.INFINITY)
assert npmath.isinf(npmath.INFINITY)
assert npmath.isnan(npmath.NAN)
assert npmath.signbit(npmath.copysign(1., -1.))
def test_nextafter():
"""
>>> test_nextafter()
"""
x = npmath.nextafter(npmath.EULER, 1)
assert npmath.isfinite(x)
assert x > npmath.EULER
x = npmath.nextafter(npmath.PI_4, -1)
assert npmath.isfinite(x)
assert x < npmath.PI_4
|