Python numpy.sometrue() Examples

The following are 30 code examples for showing how to use numpy.sometrue(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module numpy , or try the search function .

Example 1
Project: compneuro   Author: robclewley   File: phaseplane.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _classify(self):
        if self.dimension == 2:
            print "Use fixedpoint_2D class"

        real_evals = (isreal(self.evals[0]), isreal(self.evals[1]))
        equal_evals = abs(self.evals[0] - self.evals[1]) < self.eps
        zero_evals = (abs(self.evals[0]) < self.eps,
                      abs(self.evals[1]) < self.eps)
##        if alltrue(real_evals):
##            sign_evals = (sign(self.evals[0]), sign(self.evals[1]))
##            if sign_evals[0] == sign_evals[1]:
##                self.classification = 'node-like'
##            else:
##                self.classification = 'saddle-like'
##        else:
##            self.classification = 'spiral-like'
        real_parts = real(self.evals)
        if alltrue(real_parts<0):
            self.stability = 's'
        elif alltrue(real_parts==0):
            self.stability = 'c'
        else:
            self.stability = 'u'
        self.degenerate = sometrue(zero_evals) or equal_evals 
Example 2
Project: compneuro   Author: robclewley   File: phaseplane.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _classify(self):
        real_evals = (isreal(self.evals[0]), isreal(self.evals[1]))
        equal_evals = abs(self.evals[0] - self.evals[1]) < self.eps
        zero_evals = (abs(self.evals[0]) < self.eps,
                      abs(self.evals[1]) < self.eps)
        if alltrue(real_evals):
            sign_evals = (sign(self.evals[0]), sign(self.evals[1]))
            if sign_evals[0] == sign_evals[1]:
                self.classification = 'node'
            else:
                self.classification = 'saddle'
        else:
            self.classification = 'spiral'
        real_parts = real(self.evals)
        if alltrue(real_parts<0):
            self.stability = 's'
        elif alltrue(real_parts==0):
            self.stability = 'c'
        else:
            self.stability = 'u'
        self.degenerate = sometrue(zero_evals) or equal_evals 
Example 3
Project: recruit   Author: Frank-qlu   File: test_function_base.py    License: Apache License 2.0 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 4
Project: recruit   Author: Frank-qlu   File: test_type_check.py    License: Apache License 2.0 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 5
Project: lambda-packs   Author: ryfeus   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 6
Project: lambda-packs   Author: ryfeus   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 7
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 8
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 9
Project: vnpy_crypto   Author: birforce   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 10
Project: vnpy_crypto   Author: birforce   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 11
Project: Computable   Author: ktraunmueller   File: functions.py    License: MIT License 5 votes vote down vote up
def sometrue(array, axis=0):
    return np.sometrue(array, axis)

#clipmode is ignored if axis is not an integer 
Example 12
Project: Computable   Author: ktraunmueller   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 13
Project: Computable   Author: ktraunmueller   File: functions.py    License: MIT License 5 votes vote down vote up
def sometrue(x, axis=0):
    return np.sometrue(x, axis) 
Example 14
Project: Computable   Author: ktraunmueller   File: proj3d.py    License: MIT License 5 votes vote down vote up
def proj_transform_vec_clip(vec, M):
    vecw = np.dot(M, vec)
    w = vecw[3]
    # clip here..
    txs, tys, tzs = vecw[0]/w, vecw[1]/w, vecw[2]/w
    tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
    if np.sometrue(tis):
        tis =  vecw[1] < 1
    return txs, tys, tzs, tis 
Example 15
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 16
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 17
Project: matplotlib-4-abaqus   Author: Solid-Mechanics   File: proj3d.py    License: MIT License 5 votes vote down vote up
def proj_transform_vec_clip(vec, M):
    vecw = np.dot(M, vec)
    w = vecw[3]
    # clip here..
    txs, tys, tzs = vecw[0]/w, vecw[1]/w, vecw[2]/w
    tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
    if np.sometrue(tis):
        tis =  vecw[1] < 1
    return txs, tys, tzs, tis 
Example 18
Project: GraphicDesignPatternByPython   Author: Relph1119   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 19
Project: GraphicDesignPatternByPython   Author: Relph1119   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 20
Project: opticspy   Author: Sterncat   File: proj3d.py    License: MIT License 5 votes vote down vote up
def proj_transform_vec_clip(vec, M):
    vecw = np.dot(M, vec)
    w = vecw[3]
    # clip here..
    txs, tys, tzs = vecw[0]/w, vecw[1]/w, vecw[2]/w
    tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
    if np.sometrue(tis):
        tis =  vecw[1] < 1
    return txs, tys, tzs, tis 
Example 21
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 22
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 23
Project: pySINDy   Author: luckystarufo   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 24
Project: pySINDy   Author: luckystarufo   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 25
Project: mxnet-lambda   Author: awslabs   File: test_function_base.py    License: Apache License 2.0 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 26
Project: mxnet-lambda   Author: awslabs   File: test_type_check.py    License: Apache License 2.0 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 27
Project: ImageFusion   Author: pfchai   File: test_function_base.py    License: MIT License 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 28
Project: ImageFusion   Author: pfchai   File: test_type_check.py    License: MIT License 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0)) 
Example 29
Project: elasticintel   Author: securityclippy   File: test_function_base.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_nd(self):
        y1 = [[0, 0, 0], [0, 1, 0], [1, 1, 0]]
        assert_(np.any(y1))
        assert_array_equal(np.sometrue(y1, axis=0), [1, 1, 0])
        assert_array_equal(np.sometrue(y1, axis=1), [0, 1, 1]) 
Example 30
Project: elasticintel   Author: securityclippy   File: test_type_check.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))