Python numpy.NZERO Examples
The following are 30
code examples of numpy.NZERO().
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_constants.py From chainer with MIT License | 6 votes |
def test_constants(): assert chainerx.Inf is numpy.Inf assert chainerx.Infinity is numpy.Infinity assert chainerx.NAN is numpy.NAN assert chainerx.NINF is numpy.NINF assert chainerx.NZERO is numpy.NZERO assert chainerx.NaN is numpy.NaN assert chainerx.PINF is numpy.PINF assert chainerx.PZERO is numpy.PZERO assert chainerx.e is numpy.e assert chainerx.euler_gamma is numpy.euler_gamma assert chainerx.inf is numpy.inf assert chainerx.infty is numpy.infty assert chainerx.nan is numpy.nan assert chainerx.newaxis is numpy.newaxis assert chainerx.pi is numpy.pi
Example #2
Source File: test_umath.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_positive_zero(self): # atan2(y, +-0) returns +pi/2 for y > 0. assert_almost_equal(ncu.arctan2(1, np.PZERO), 0.5 * np.pi) assert_almost_equal(ncu.arctan2(1, np.NZERO), 0.5 * np.pi)
Example #3
Source File: test_umath.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_zero_negative(self): # atan2(+-0, x) returns +-pi for x < 0. assert_almost_equal(ncu.arctan2(np.PZERO, -1), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, -1), -np.pi)
Example #4
Source File: test_umath.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_zero_nzero(self): # atan2(+-0, -0) returns +-pi. assert_almost_equal(ncu.arctan2(np.PZERO, np.NZERO), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, np.NZERO), -np.pi)
Example #5
Source File: test_umath_complex.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_zero(self): # carg(-0 +- 0i) returns +- pi check_real_value(ncu._arg, np.NZERO, np.PZERO, np.pi, False) check_real_value(ncu._arg, np.NZERO, np.NZERO, -np.pi, False) # carg(+0 +- 0i) returns +- 0 check_real_value(ncu._arg, np.PZERO, np.PZERO, np.PZERO) check_real_value(ncu._arg, np.PZERO, np.NZERO, np.NZERO) # carg(x +- 0i) returns +- 0 for x > 0 check_real_value(ncu._arg, 1, np.PZERO, np.PZERO, False) check_real_value(ncu._arg, 1, np.NZERO, np.NZERO, False) # carg(x +- 0i) returns +- pi for x < 0 check_real_value(ncu._arg, -1, np.PZERO, np.pi, False) check_real_value(ncu._arg, -1, np.NZERO, -np.pi, False) # carg(+- 0 + yi) returns pi/2 for y > 0 check_real_value(ncu._arg, np.PZERO, 1, 0.5 * np.pi, False) check_real_value(ncu._arg, np.NZERO, 1, 0.5 * np.pi, False) # carg(+- 0 + yi) returns -pi/2 for y < 0 check_real_value(ncu._arg, np.PZERO, -1, 0.5 * np.pi, False) check_real_value(ncu._arg, np.NZERO, -1, -0.5 * np.pi, False) #def test_branch_cuts(self): # _check_branch_cut(ncu._arg, -1, 1j, -1, 1)
Example #6
Source File: test_umath.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_zero_nzero(self): # atan2(+-0, -0) returns +-pi. assert_almost_equal(ncu.arctan2(np.PZERO, np.NZERO), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, np.NZERO), -np.pi)
Example #7
Source File: test_umath.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_zero_pzero(self): # atan2(+-0, +0) returns +-0. assert_arctan2_ispzero(np.PZERO, np.PZERO) assert_arctan2_isnzero(np.NZERO, np.PZERO)
Example #8
Source File: test_umath.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_zero_negative(self): # atan2(+-0, x) returns +-pi for x < 0. assert_almost_equal(ncu.arctan2(np.PZERO, -1), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, -1), -np.pi)
Example #9
Source File: test_umath.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_zero_positive(self): # atan2(+-0, x) returns +-0 for x > 0. assert_arctan2_ispzero(np.PZERO, 1) assert_arctan2_isnzero(np.NZERO, 1)
Example #10
Source File: test_umath.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_positive_zero(self): # atan2(y, +-0) returns +pi/2 for y > 0. assert_almost_equal(ncu.arctan2(1, np.PZERO), 0.5 * np.pi) assert_almost_equal(ncu.arctan2(1, np.NZERO), 0.5 * np.pi)
Example #11
Source File: test_utils.py From pySINDy with MIT License | 5 votes |
def test_negative_zero(self): self._test_not_equal(np.PZERO, np.NZERO)
Example #12
Source File: test_utils.py From pySINDy with MIT License | 5 votes |
def test_nan(self): # Test that nan is 'far' from small, tiny, inf, max and min for dt in [np.float32, np.float64]: if dt == np.float32: maxulp = 1e6 else: maxulp = 1e12 inf = np.array([np.inf]).astype(dt) nan = np.array([np.nan]).astype(dt) big = np.array([np.finfo(dt).max]) tiny = np.array([np.finfo(dt).tiny]) zero = np.array([np.PZERO]).astype(dt) nzero = np.array([np.NZERO]).astype(dt) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, inf, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, big, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, tiny, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, zero, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, nzero, maxulp=maxulp))
Example #13
Source File: test_umath_complex.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_fabs(self): # Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs) x = np.array([1+0j], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(1, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.inf, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.nan, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x))
Example #14
Source File: test_utils.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_nan(self): # Test that nan is 'far' from small, tiny, inf, max and min for dt in [np.float32, np.float64]: if dt == np.float32: maxulp = 1e6 else: maxulp = 1e12 inf = np.array([np.inf]).astype(dt) nan = np.array([np.nan]).astype(dt) big = np.array([np.finfo(dt).max]) tiny = np.array([np.finfo(dt).tiny]) zero = np.array([np.PZERO]).astype(dt) nzero = np.array([np.NZERO]).astype(dt) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, inf, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, big, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, tiny, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, zero, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, nzero, maxulp=maxulp))
Example #15
Source File: test_utils.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_negative_zero(self): self._test_not_equal(np.PZERO, np.NZERO)
Example #16
Source File: test_umath_complex.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_fabs(self): # Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs) x = np.array([1+0j], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(1, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.inf, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.nan, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x))
Example #17
Source File: test_umath.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_zero_positive(self): # atan2(+-0, x) returns +-0 for x > 0. assert_arctan2_ispzero(np.PZERO, 1) assert_arctan2_isnzero(np.NZERO, 1)
Example #18
Source File: test_umath.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_zero_negative(self): # atan2(+-0, x) returns +-pi for x < 0. assert_almost_equal(ncu.arctan2(np.PZERO, -1), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, -1), -np.pi)
Example #19
Source File: test_umath.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_zero_pzero(self): # atan2(+-0, +0) returns +-0. assert_arctan2_ispzero(np.PZERO, np.PZERO) assert_arctan2_isnzero(np.NZERO, np.PZERO)
Example #20
Source File: test_umath.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_zero_nzero(self): # atan2(+-0, -0) returns +-pi. assert_almost_equal(ncu.arctan2(np.PZERO, np.NZERO), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, np.NZERO), -np.pi)
Example #21
Source File: test_umath_complex.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_zero(self): # carg(-0 +- 0i) returns +- pi check_real_value(ncu._arg, np.NZERO, np.PZERO, np.pi, False) check_real_value(ncu._arg, np.NZERO, np.NZERO, -np.pi, False) # carg(+0 +- 0i) returns +- 0 check_real_value(ncu._arg, np.PZERO, np.PZERO, np.PZERO) check_real_value(ncu._arg, np.PZERO, np.NZERO, np.NZERO) # carg(x +- 0i) returns +- 0 for x > 0 check_real_value(ncu._arg, 1, np.PZERO, np.PZERO, False) check_real_value(ncu._arg, 1, np.NZERO, np.NZERO, False) # carg(x +- 0i) returns +- pi for x < 0 check_real_value(ncu._arg, -1, np.PZERO, np.pi, False) check_real_value(ncu._arg, -1, np.NZERO, -np.pi, False) # carg(+- 0 + yi) returns pi/2 for y > 0 check_real_value(ncu._arg, np.PZERO, 1, 0.5 * np.pi, False) check_real_value(ncu._arg, np.NZERO, 1, 0.5 * np.pi, False) # carg(+- 0 + yi) returns -pi/2 for y < 0 check_real_value(ncu._arg, np.PZERO, -1, 0.5 * np.pi, False) check_real_value(ncu._arg, np.NZERO, -1, -0.5 * np.pi, False) #def test_branch_cuts(self): # _check_branch_cut(ncu._arg, -1, 1j, -1, 1)
Example #22
Source File: test_umath_complex.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_fabs(self): # Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs) x = np.array([1+0j], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(1, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.inf, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x)) x = np.array([complex(np.nan, np.NZERO)], dtype=complex) assert_array_equal(np.abs(x), np.real(x))
Example #23
Source File: test_utils.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_nan(self): # Test that nan is 'far' from small, tiny, inf, max and min for dt in [np.float32, np.float64]: if dt == np.float32: maxulp = 1e6 else: maxulp = 1e12 inf = np.array([np.inf]).astype(dt) nan = np.array([np.nan]).astype(dt) big = np.array([np.finfo(dt).max]) tiny = np.array([np.finfo(dt).tiny]) zero = np.array([np.PZERO]).astype(dt) nzero = np.array([np.NZERO]).astype(dt) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, inf, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, big, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, tiny, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, zero, maxulp=maxulp)) assert_raises(AssertionError, lambda: assert_array_max_ulp(nan, nzero, maxulp=maxulp))
Example #24
Source File: test_utils.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_negative_zero(self): self._test_not_equal(np.PZERO, np.NZERO)
Example #25
Source File: test_umath.py From Computable with MIT License | 5 votes |
def test_positive_zero(self): # atan2(y, +-0) returns +pi/2 for y > 0. assert_almost_equal(ncu.arctan2(1, np.PZERO), 0.5 * np.pi) assert_almost_equal(ncu.arctan2(1, np.NZERO), 0.5 * np.pi)
Example #26
Source File: test_umath.py From Computable with MIT License | 5 votes |
def test_zero_positive(self): # atan2(+-0, x) returns +-0 for x > 0. assert_arctan2_ispzero(np.PZERO, 1) assert_arctan2_isnzero(np.NZERO, 1)
Example #27
Source File: test_umath.py From Computable with MIT License | 5 votes |
def test_zero_negative(self): # atan2(+-0, x) returns +-pi for x < 0. assert_almost_equal(ncu.arctan2(np.PZERO, -1), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, -1), -np.pi)
Example #28
Source File: test_umath.py From Computable with MIT License | 5 votes |
def test_zero_pzero(self): # atan2(+-0, +0) returns +-0. assert_arctan2_ispzero(np.PZERO, np.PZERO) assert_arctan2_isnzero(np.NZERO, np.PZERO)
Example #29
Source File: test_umath.py From Computable with MIT License | 5 votes |
def test_zero_nzero(self): # atan2(+-0, -0) returns +-pi. assert_almost_equal(ncu.arctan2(np.PZERO, np.NZERO), np.pi) assert_almost_equal(ncu.arctan2(np.NZERO, np.NZERO), -np.pi)
Example #30
Source File: test_umath_complex.py From Computable with MIT License | 5 votes |
def test_zero(self): # carg(-0 +- 0i) returns +- pi yield check_real_value, ncu._arg, np.NZERO, np.PZERO, np.pi, False yield check_real_value, ncu._arg, np.NZERO, np.NZERO, -np.pi, False # carg(+0 +- 0i) returns +- 0 yield check_real_value, ncu._arg, np.PZERO, np.PZERO, np.PZERO yield check_real_value, ncu._arg, np.PZERO, np.NZERO, np.NZERO # carg(x +- 0i) returns +- 0 for x > 0 yield check_real_value, ncu._arg, 1, np.PZERO, np.PZERO, False yield check_real_value, ncu._arg, 1, np.NZERO, np.NZERO, False # carg(x +- 0i) returns +- pi for x < 0 yield check_real_value, ncu._arg, -1, np.PZERO, np.pi, False yield check_real_value, ncu._arg, -1, np.NZERO, -np.pi, False # carg(+- 0 + yi) returns pi/2 for y > 0 yield check_real_value, ncu._arg, np.PZERO, 1, 0.5 * np.pi, False yield check_real_value, ncu._arg, np.NZERO, 1, 0.5 * np.pi, False # carg(+- 0 + yi) returns -pi/2 for y < 0 yield check_real_value, ncu._arg, np.PZERO, -1, 0.5 * np.pi, False yield check_real_value, ncu._arg, np.NZERO, -1, -0.5 * np.pi, False #def test_branch_cuts(self): # _check_branch_cut(ncu._arg, -1, 1j, -1, 1)