Python numpy.sometrue() Examples

The following are 30 code examples of numpy.sometrue(). 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: phaseplane.py    From compneuro with 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
Source File: phaseplane.py    From compneuro with 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
Source File: test_type_check.py    From coffeegrindsize with 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 #4
Source File: test_function_base.py    From predictive-maintenance-using-machine-learning with 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 #5
Source File: test_type_check.py    From predictive-maintenance-using-machine-learning with 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 #6
Source File: test_function_base.py    From pySINDy with 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 #7
Source File: test_type_check.py    From pySINDy with 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 #8
Source File: test_function_base.py    From mxnet-lambda with 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 #9
Source File: test_type_check.py    From mxnet-lambda with 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 #10
Source File: test_function_base.py    From ImageFusion with 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 #11
Source File: test_type_check.py    From ImageFusion with 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 #12
Source File: test_function_base.py    From elasticintel with 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 #13
Source File: test_type_check.py    From elasticintel with 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)) 
Example #14
Source File: test_function_base.py    From coffeegrindsize with 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 #15
Source File: test_type_check.py    From recruit with 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 #16
Source File: functions.py    From biskit with GNU General Public License v3.0 5 votes vote down vote up
def sometrue(x, axis=0):
    return np.sometrue(x, axis) 
Example #17
Source File: TemplateFilter.py    From biskit with GNU General Public License v3.0 5 votes vote down vote up
def get_filtered( self ):
        """
        @return: the identifiers of the templates that survived the filtering
        @rtype: [ str ]
        """
        if not N.sometrue(self.filter_mask):
            self.filter_mask[ N.argmax( self.identities ) ] = 1

        r = N.compress( self.filter_mask, self.templates ).tolist()

        if self.verbose:
            self.log.add( '%i templates were filtered out' % \
                          ( len(self.templates) - len(r)) )
        return r 
Example #18
Source File: test_quantity_non_ufuncs.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_sometrue(self):
        with pytest.raises(TypeError):
            np.sometrue(self.q) 
Example #19
Source File: test_function_base.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with 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 #20
Source File: test_type_check.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with 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 #21
Source File: test_function_base.py    From twitter-stock-recommendation with 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 #22
Source File: test_type_check.py    From twitter-stock-recommendation with 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 #23
Source File: test_function_base.py    From keras-lambda with 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
Source File: test_type_check.py    From keras-lambda with 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
Source File: test_function_base.py    From Mastering-Elasticsearch-7.0 with 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 #26
Source File: test_function_base.py    From vnpy_crypto with 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 #27
Source File: test_type_check.py    From vnpy_crypto with 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 #28
Source File: test_type_check.py    From auto-alt-text-lambda-api with 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
Source File: functions.py    From Computable with 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 #30
Source File: test_function_base.py    From Computable with 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])