Python numpy.geterr() Examples
The following are 30
code examples of numpy.geterr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: test_core.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #2
Source File: test_core.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def setUp(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #3
Source File: test_core.py From coffeegrindsize with MIT License | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #4
Source File: test_core.py From ImageFusion with MIT License | 6 votes |
def setUp(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #5
Source File: test_core.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def setUp(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #6
Source File: test_core.py From lambda-packs with MIT License | 6 votes |
def setUp(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #7
Source File: test_core.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def setUp(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #8
Source File: test_core.py From pySINDy with MIT License | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #9
Source File: test_core.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #10
Source File: decorators.py From ngraph-python with Apache License 2.0 | 6 votes |
def with_error_settings(**new_settings): """ TODO. Arguments: **new_settings: TODO Returns: """ @decorator.decorator def dec(f, *args, **kwargs): old_settings = np.geterr() np.seterr(**new_settings) ret = f(*args, **kwargs) np.seterr(**old_settings) return ret return dec
Example #11
Source File: basic_stats_generator_test.py From data-validation with Apache License 2.0 | 6 votes |
def test_basic_stats_generator_no_runtime_warnings_close_to_max_int(self): # input has batches with values that are slightly smaller than the maximum # integer value. less_than_max_int_value = np.iinfo(np.int64).max - 1 batches = ([ pa.RecordBatch.from_arrays([pa.array([[less_than_max_int_value]])], ['a']) ] * 2) generator = basic_stats_generator.BasicStatsGenerator() old_nperr = np.geterr() np.seterr(over='raise') accumulators = [ generator.add_input(generator.create_accumulator(), batch) for batch in batches ] generator.merge_accumulators(accumulators) np.seterr(**old_nperr)
Example #12
Source File: util.py From Computable with MIT License | 6 votes |
def handleError(errorStatus, sourcemsg): """Take error status and use error mode to handle it.""" modes = np.geterr() if errorStatus & np.FPE_INVALID: if modes['invalid'] == "warn": print("Warning: Encountered invalid numeric result(s)", sourcemsg) if modes['invalid'] == "raise": raise MathDomainError(sourcemsg) if errorStatus & np.FPE_DIVIDEBYZERO: if modes['dividebyzero'] == "warn": print("Warning: Encountered divide by zero(s)", sourcemsg) if modes['dividebyzero'] == "raise": raise ZeroDivisionError(sourcemsg) if errorStatus & np.FPE_OVERFLOW: if modes['overflow'] == "warn": print("Warning: Encountered overflow(s)", sourcemsg) if modes['overflow'] == "raise": raise NumOverflowError(sourcemsg) if errorStatus & np.FPE_UNDERFLOW: if modes['underflow'] == "warn": print("Warning: Encountered underflow(s)", sourcemsg) if modes['underflow'] == "raise": raise UnderflowError(sourcemsg)
Example #13
Source File: test_core.py From vnpy_crypto with MIT License | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #14
Source File: test_core.py From Computable with MIT License | 6 votes |
def setUp (self): "Base data definition." x = np.array([1., 1., 1., -2., pi / 2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #15
Source File: test_core.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #16
Source File: test_core.py From recruit with Apache License 2.0 | 6 votes |
def setup(self): # Base data definition. x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.]) y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1] xm = masked_array(x, mask=m1) ym = masked_array(y, mask=m2) z = np.array([-.5, 0., .5, .8]) zm = masked_array(z, mask=[0, 1, 0, 0]) xf = np.where(m1, 1e+20, x) xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #17
Source File: test_core.py From pySINDy with MIT License | 5 votes |
def setup(self): # Base data definition. self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #18
Source File: hmm.py From deepbgc with MIT License | 5 votes |
def predict(self, X): sample_vector = self.get_sample_vector(X) prev_level = np.geterr()['divide'] np.seterr(divide='ignore') logprob, posteriors = self.model_.score_samples(sample_vector.reshape(-1, 1)) np.seterr(divide=prev_level) # final prediction is maximum of the probability of the last two states prediction = posteriors[:,2:] return pd.Series(np.max(prediction, axis=1), X.index)
Example #19
Source File: test_numeric.py From pySINDy with MIT License | 5 votes |
def test_default(self): err = np.geterr() assert_equal(err, dict(divide='warn', invalid='warn', over='warn', under='ignore') )
Example #20
Source File: sampling.py From pynoddy with GNU General Public License v2.0 | 5 votes |
def VMLookupTable(): try: # try loading ordered dict from collections import OrderedDict except ImportError: # not installed, try on pythonpath try: from OrderedDict import OrderedDict except ImportError: "PyNoddy requires OrderedDict to run. Please download it and make it available on the pythonpath." kappa_lookup = OrderedDict() #disable numpy warnings err = np.geterr() np.seterr(all='ignore') # build lookup table for k in range(1000, 100, -20): ci = sc.stats.vonmises.interval(0.95, k) kappa_lookup[ci[1]] = k for k in range(100, 10, -1): ci = sc.stats.vonmises.interval(0.95, k) kappa_lookup[ci[1]] = k for k in np.arange(10, 0, -0.1): ci = sc.stats.vonmises.interval(0.95, k) kappa_lookup[ci[1]] = k #re-enable numpy warnings np.seterr(**err) # return lookup table return kappa_lookup # build (static) lookup table
Example #21
Source File: test_core.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def setUp(self): # Base data definition. self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #22
Source File: test_numeric.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_default(self): err = np.geterr() assert_equal(err, dict(divide='warn', invalid='warn', over='warn', under='ignore') )
Example #23
Source File: test_numeric.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_default(self): err = np.geterr() self.assertEqual(err, dict( divide='warn', invalid='warn', over='warn', under='ignore', ))
Example #24
Source File: test_util.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_numpy_errstate_is_default(): # The defaults since numpy 1.6.0 expected = {'over': 'warn', 'divide': 'warn', 'invalid': 'warn', 'under': 'ignore'} import numpy as np from pandas.compat import numpy # noqa # The errstate should be unchanged after that import. assert np.geterr() == expected
Example #25
Source File: test_core.py From coffeegrindsize with MIT License | 5 votes |
def setup(self): # Base data definition. self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #26
Source File: electrode_placement.py From simnibs with GNU General Public License v3.0 | 5 votes |
def _calc_triangle_angles(p, eps=1e-5): p1 = p[:, 0] p2 = p[:, 1] p3 = p[:, 2] e1 = np.linalg.norm(p2 - p1, axis=1) e2 = np.linalg.norm(p3 - p1, axis=1) e3 = np.linalg.norm(p3 - p2, axis=1) # Law Of Cossines state = np.geterr()['invalid'] np.seterr(invalid='ignore') a = np.zeros((p.shape[0], 3)) v = (e1 > eps) * (e2 > eps) a[v, 0] = np.arccos((e2[v] ** 2 + e1[v] ** 2 - e3[v] ** 2) / (2 * e1[v] * e2[v])) a[~v, 0] = 0 v = (e1 > eps) * (e3 > eps) a[v, 1] = np.arccos((e1[v] ** 2 + e3[v] ** 2 - e2[v] ** 2) / (2 * e1[v] * e3[v])) a[~v, 1] = 0 v = (e2 > eps) * (e3 > eps) a[v, 2] = np.arccos((e2[v] ** 2 + e3[v] ** 2 - e1[v] ** 2) / (2 * e2[v] * e3[v])) a[~v, 2] = 0 np.seterr(invalid=state) a[np.isnan(a)] = np.pi return a
Example #27
Source File: test_numeric.py From coffeegrindsize with MIT License | 5 votes |
def test_default(self): err = np.geterr() assert_equal(err, dict(divide='warn', invalid='warn', over='warn', under='ignore') )
Example #28
Source File: test_core.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def setup(self): # Base data definition. self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) self.err_status = np.geterr() np.seterr(divide='ignore', invalid='ignore')
Example #29
Source File: test_numeric.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_default(self): err = np.geterr() assert_equal(err, dict(divide='warn', invalid='warn', over='warn', under='ignore') )
Example #30
Source File: test_numeric.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_default(self): err = np.geterr() assert_equal(err, dict(divide='warn', invalid='warn', over='warn', under='ignore') )