當前位置: 首頁>>代碼示例>>Python>>正文


Python umath.minimum方法代碼示例

本文整理匯總了Python中numpy.core.umath.minimum方法的典型用法代碼示例。如果您正苦於以下問題:Python umath.minimum方法的具體用法?Python umath.minimum怎麽用?Python umath.minimum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.core.umath的用法示例。


在下文中一共展示了umath.minimum方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_reduce

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_reduce(self):
        dflt = np.typecodes['AllFloat']
        dint = np.typecodes['AllInteger']
        seq1 = np.arange(11)
        seq2 = seq1[::-1]
        func = np.minimum.reduce
        for dt in dint:
            tmp1 = seq1.astype(dt)
            tmp2 = seq2.astype(dt)
            assert_equal(func(tmp1), 0)
            assert_equal(func(tmp2), 0)
        for dt in dflt:
            tmp1 = seq1.astype(dt)
            tmp2 = seq2.astype(dt)
            assert_equal(func(tmp1), 0)
            assert_equal(func(tmp2), 0)
            tmp1[::2] = np.nan
            tmp2[::2] = np.nan
            assert_equal(func(tmp1), np.nan)
            assert_equal(func(tmp2), np.nan) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:22,代碼來源:test_umath.py

示例2: test_truth_table_logical

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_truth_table_logical(self):
        # 2, 3 and 4 serves as true values
        input1 = [0, 0, 3, 2]
        input2 = [0, 4, 0, 2]

        typecodes = (np.typecodes['AllFloat']
                     + np.typecodes['AllInteger']
                     + '?')     # boolean
        for dtype in map(np.dtype, typecodes):
            arg1 = np.asarray(input1, dtype=dtype)
            arg2 = np.asarray(input2, dtype=dtype)

            # OR
            out = [False, True, True, True]
            for func in (np.logical_or, np.maximum):
                assert_equal(func(arg1, arg2).astype(bool), out)
            # AND
            out = [False, False, False, True]
            for func in (np.logical_and, np.minimum):
                assert_equal(func(arg1, arg2).astype(bool), out)
            # XOR
            out = [False, True, True, False]
            for func in (np.logical_xor, np.not_equal):
                assert_equal(func(arg1, arg2).astype(bool), out) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:26,代碼來源:test_umath.py

示例3: test_wrap

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_wrap(self):

        class with_wrap(object):
            def __array__(self):
                return np.zeros(1)

            def __array_wrap__(self, arr, context):
                r = with_wrap()
                r.arr = arr
                r.context = context
                return r

        a = with_wrap()
        x = ncu.minimum(a, a)
        assert_equal(x.arr, np.zeros(1))
        func, args, i = x.context
        assert_(func is ncu.minimum)
        assert_equal(len(args), 2)
        assert_equal(args[0], a)
        assert_equal(args[1], a)
        assert_equal(i, 0) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:23,代碼來源:test_umath.py

示例4: test_wrap

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_wrap(self):

        class with_wrap(object):
            def __array__(self):
                return np.zeros(1)

            def __array_wrap__(self, arr, context):
                r = with_wrap()
                r.arr = arr
                r.context = context
                return r

        a = with_wrap()
        x = ncu.minimum(a, a)
        assert_equal(x.arr, np.zeros(1))
        func, args, i = x.context
        self.assertTrue(func is ncu.minimum)
        self.assertEqual(len(args), 2)
        assert_equal(args[0], a)
        assert_equal(args[1], a)
        self.assertEqual(i, 0) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:23,代碼來源:test_umath.py

示例5: test_reduce_complex

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_reduce_complex(self):
        assert_equal(np.minimum.reduce([1, 2j]), 2j)
        assert_equal(np.minimum.reduce([1+3j, 2j]), 2j) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_umath.py

示例6: test_float_nans

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_float_nans(self):
        nan = np.nan
        arg1 = np.array([0,   nan, nan])
        arg2 = np.array([nan, 0,   nan])
        out = np.array([nan, nan, nan])
        assert_equal(np.minimum(arg1, arg2), out) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:8,代碼來源:test_umath.py

示例7: test_object_nans

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_object_nans(self):
        # Multiple checks to give this a chance to
        # fail if cmp is used instead of rich compare.
        # Failure cannot be guaranteed.
        for i in range(1):
            x = np.array(float('nan'), object)
            y = 1.0
            z = np.array(float('nan'), object)
            assert_(np.minimum(x, y) == 1.0)
            assert_(np.minimum(z, y) == 1.0) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_umath.py

示例8: test_complex_nans

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_complex_nans(self):
        nan = np.nan
        for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)]:
            arg1 = np.array([0, cnan, cnan], dtype=complex)
            arg2 = np.array([cnan, 0, cnan], dtype=complex)
            out = np.array([nan, nan, nan], dtype=complex)
            assert_equal(np.minimum(arg1, arg2), out) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_umath.py

示例9: test_minimize_no_warns

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_minimize_no_warns(self):
        a = np.minimum(np.nan, 1)
        assert_equal(a, np.nan) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_umath.py

示例10: test_old_wrap

# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import minimum [as 別名]
def test_old_wrap(self):

        class with_wrap(object):
            def __array__(self):
                return np.zeros(1)

            def __array_wrap__(self, arr):
                r = with_wrap()
                r.arr = arr
                return r

        a = with_wrap()
        x = ncu.minimum(a, a)
        assert_equal(x.arr, np.zeros(1)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:16,代碼來源:test_umath.py


注:本文中的numpy.core.umath.minimum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。