Here are the examples of the python api numpy.seterr taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_continuous_basic.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def _silence_fp_errors(func):
# warning: don't apply to test_ functions as is, then those will be skipped
def wrap(*a, **kw):
olderr = np.seterr(all='ignore')
try:
return func(*a, **kw)
finally:
np.seterr(**olderr)
wrap.__name__ = func.__name__
return wrap
3
View Complete Implementation : test_orthogonal_eval.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_warnings():
# ticket 1334
olderr = np.seterr(all='raise')
try:
# these should raise no fp warnings
orth.eval_legendre(1, 0)
orth.eval_laguerre(1, 1)
orth.eval_gegenbauer(1, 1, 0)
finally:
np.seterr(**olderr)
3
View Complete Implementation : test_minpack.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_array_basic1(self):
"""f(x) = c * x**2; fixed point should be x=1/c"""
def func(x, c):
return c * x**2
c = array([0.75, 1.0, 1.25])
x0 = [1.1, 1.15, 0.9]
olderr = np.seterr(all='ignore')
try:
x = fixed_point(func, x0, args=(c,))
finally:
np.seterr(**olderr)
astert_almost_equal(x, 1.0/c)
3
View Complete Implementation : test_orthogonal.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_chebyc(self):
C0 = orth.chebyc(0)
C1 = orth.chebyc(1)
olderr = np.seterr(all='ignore')
try:
C2 = orth.chebyc(2)
C3 = orth.chebyc(3)
C4 = orth.chebyc(4)
C5 = orth.chebyc(5)
finally:
np.seterr(**olderr)
astert_array_almost_equal(C0.c,[2],13)
astert_array_almost_equal(C1.c,[1,0],13)
astert_array_almost_equal(C2.c,[1,0,-2],13)
astert_array_almost_equal(C3.c,[1,0,-3,0],13)
astert_array_almost_equal(C4.c,[1,0,-4,0,2],13)
astert_array_almost_equal(C5.c,[1,0,-5,0,5,0],13)
3
View Complete Implementation : test_rbf.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def check_rbf1d_interpolation(function):
"""Check that the Rbf function interpolates throught the nodes (1D)"""
olderr = np.seterr(all="ignore")
try:
x = linspace(0,10,9)
y = sin(x)
rbf = Rbf(x, y, function=function)
yi = rbf(x)
astert_array_almost_equal(y, yi)
astert_almost_equal(rbf(float(x[0])), y[0])
finally:
np.seterr(**olderr)
3
View Complete Implementation : test_measurements.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_standard_deviation06():
"standard deviation 6"
labels = [2, 2, 3, 3, 4]
olderr = np.seterr(all='ignore')
try:
for type in types:
input = np.array([1, 3, 8, 10, 8], type)
output = ndimage.standard_deviation(input, labels, [2, 3, 4])
astert_array_almost_equal(output, [1.0, 1.0, 0.0])
finally:
np.seterr(**olderr)
3
View Complete Implementation : test_rbf.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def check_rbf3d_interpolation(function):
"""Check that the Rbf function interpolates throught the nodes (3D)"""
olderr = np.seterr(all="ignore")
try:
x = random.rand(50,1)*4-2
y = random.rand(50,1)*4-2
z = random.rand(50,1)*4-2
d = x*exp(-x**2-y**2)
rbf = Rbf(x, y, z, d, epsilon=2, function=function)
di = rbf(x, y, z)
di.shape = x.shape
astert_array_almost_equal(di, d)
finally:
np.seterr(**olderr)
3
View Complete Implementation : test_minpack.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_array_basic1(self):
"""f(x) = c * x**2; fixed point should be x=1/c"""
def func(x, c):
return c * x**2
c = array([0.75, 1.0, 1.25])
x0 = [1.1, 1.15, 0.9]
olderr = np.seterr(all='ignore')
try:
x = fixed_point(func, x0, args=(c,))
finally:
np.seterr(**olderr)
astert_almost_equal(x, 1.0/c)
3
View Complete Implementation : test_measurements.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_variance01():
"variance 1"
olderr = np.seterr(all='ignore')
try:
for type in types:
input = np.array([], type)
output = ndimage.variance(input)
astert_(np.isnan(output))
finally:
np.seterr(**olderr)
3
View Complete Implementation : test_orthogonal.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_chebyc(self):
C0 = orth.chebyc(0)
C1 = orth.chebyc(1)
olderr = np.seterr(all='ignore')
try:
C2 = orth.chebyc(2)
C3 = orth.chebyc(3)
C4 = orth.chebyc(4)
C5 = orth.chebyc(5)
finally:
np.seterr(**olderr)
astert_array_almost_equal(C0.c,[2],13)
astert_array_almost_equal(C1.c,[1,0],13)
astert_array_almost_equal(C2.c,[1,0,-2],13)
astert_array_almost_equal(C3.c,[1,0,-3,0],13)
astert_array_almost_equal(C4.c,[1,0,-4,0,2],13)
astert_array_almost_equal(C5.c,[1,0,-5,0,5,0],13)