Python numpy 模块,sometrue() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用numpy.sometrue()

项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def UpdatePointLabel(self, mDataDict):
        """Updates the pointLabel point on screen with data contained in
            mDataDict.
            mDataDict will be passed to your function set by
            SetPointLabelFunc.  It can contain anything you
            want to display on the screen at the scaledXY point
            you specify.
            This function can be called from parent window with onClick,
            onMotion events etc.
        """
        if self.last_PointLabel != None:
            # compare pointXY
            if np.sometrue(mDataDict["pointXY"] != self.last_PointLabel["pointXY"]):
                # closest changed
                self._drawPointLabel(self.last_PointLabel)  # erase old
                self._drawPointLabel(mDataDict)  # plot new
        else:
            # just plot new with no erase
            self._drawPointLabel(mDataDict)  # plot new
        # save for next erase
        self.last_PointLabel = mDataDict
    # event handlers **********************************
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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])
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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])
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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])
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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])
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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])
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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])
项目:sequitur-g2p    作者:Holzhaus    | 项目源码 | 文件源码
def adjustHigherOrder(self, evidence, order, maximumDiscount):
    def criterion(discount):
        disc = tuple(num.maximum(0.0, discount))
        sm = self.modelFactory.sequenceModel(evidence, disc)
        ll = self.develSample.logLik(sm, self.shallUseMaximumApproximation)
        crit = - ll \
           - sum(num.minimum(discount, 0)) \
           + sum(num.maximum(discount - maximumDiscount, 0))
        print discount, ll, crit # TESTING
        return crit

    initialGuess = self.discounts[-1]
    firstDirection = None
    if initialGuess is None:
        initialGuess = 0.1 * num.arange(1, order+2, dtype=num.float64)
    elif len(initialGuess) < order+1:
            oldGuess = initialGuess
        oldSize = len(initialGuess)
            initialGuess = num.zeros(order+1, dtype=num.float64)
            initialGuess[:oldSize] = oldGuess
        initialGuess[oldSize:] = oldGuess[-1]
    elif len(initialGuess) > order+1:
        initialGuess = initialGuess[:order+1]
    else:
        previous = self.discounts[-2]
        if previous is not None and len(previous) == order+1:
        firstDirection = initialGuess - previous
        if not num.sometrue(num.abs(firstDirection) > 1e-4):
            firstDirection = None

    directions = num.identity(order+1, dtype=num.float64)
    directions = directions[::-1]
    if firstDirection is not None:
        directions = num.concatenate((firstDirection[num.newaxis,:], directions))
    directions *= 0.1
    print directions # TESTING

    discount, ll = Minimization.directionSetMinimization(
        criterion, initialGuess, directions, tolerance=1e-4)

    discount = num.maximum(0.0, discount)
    return discount, -ll