python类sometrue()的实例源码

plot.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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 **********************************
test_type_check.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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])
test_type_check.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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])
test_type_check.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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])
test_type_check.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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])
test_type_check.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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])
test_type_check.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def test_fail(self):
        z = np.array([-1, 0, 1])
        res = iscomplex(z)
        assert_(not np.sometrue(res, axis=0))
test_function_base.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:sequitur-g2p 作者: Holzhaus 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号