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


Python operator.inv方法代碼示例

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


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

示例1: p_unary_operator

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def p_unary_operator(p):
    '''unary_operator : '&'
                      | '*'
                      | '+'
                      | '-'
                      | '~'
                      | '!'
    '''
    # reduces to (op, op_str)
    p[0] = ({
        '+': operator.pos,
        '-': operator.neg,
        '~': operator.inv,
        '!': operator.not_,
        '&': 'AddressOfUnaryOperator',
        '*': 'DereferenceUnaryOperator'}[p[1]], p[1]) 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:18,代碼來源:cparser.py

示例2: test_normalInv

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def test_normalInv(self, g3):
        layout, blades = g3, g3.blades
        e1 = layout.blades['e1']
        e2 = layout.blades['e2']
        e3 = layout.blades['e3']
        assert (2*e1).normalInv() == (0.5*e1)

        with pytest.raises(ValueError):
            (0*e1).normalInv()  # divide by 0

        with pytest.raises(ValueError):
            (1 + e1 + e2).normalInv()  # mixed even and odd grades

        # produces garbage, but doesn't crash
        (1 + e1 + e2).normalInv(check=False)

        # check that not requiring normalInv works fine
        assert (1 + e1 + e2).inv() == -1 + e1 + e2 
開發者ID:pygae,項目名稱:clifford,代碼行數:20,代碼來源:test_clifford.py

示例3: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self):
        """Implement the ``~`` operator.

        When used with SQL expressions, results in a
        NOT operation, equivalent to
        :func:`_expression.not_`, that is::

            ~a

        is equivalent to::

            from sqlalchemy import not_
            not_(a)

        """
        return self.operate(inv) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:18,代碼來源:operators.py

示例4: testInvert

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def testInvert(self):
        self.unaryCheck(operator.inv) 
開發者ID:myhdl,項目名稱:myhdl,代碼行數:4,代碼來源:test_Signal.py

示例5: test_logical_operators

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def test_logical_operators(self):

        def _check_bin_op(op):
            result = op(df1, df2)
            expected = DataFrame(op(df1.values, df2.values), index=df1.index,
                                 columns=df1.columns)
            assert result.values.dtype == np.bool_
            assert_frame_equal(result, expected)

        def _check_unary_op(op):
            result = op(df1)
            expected = DataFrame(op(df1.values), index=df1.index,
                                 columns=df1.columns)
            assert result.values.dtype == np.bool_
            assert_frame_equal(result, expected)

        df1 = {'a': {'a': True, 'b': False, 'c': False, 'd': True, 'e': True},
               'b': {'a': False, 'b': True, 'c': False,
                     'd': False, 'e': False},
               'c': {'a': False, 'b': False, 'c': True,
                     'd': False, 'e': False},
               'd': {'a': True, 'b': False, 'c': False, 'd': True, 'e': True},
               'e': {'a': True, 'b': False, 'c': False, 'd': True, 'e': True}}

        df2 = {'a': {'a': True, 'b': False, 'c': True, 'd': False, 'e': False},
               'b': {'a': False, 'b': True, 'c': False,
                     'd': False, 'e': False},
               'c': {'a': True, 'b': False, 'c': True, 'd': False, 'e': False},
               'd': {'a': False, 'b': False, 'c': False,
                     'd': True, 'e': False},
               'e': {'a': False, 'b': False, 'c': False,
                     'd': False, 'e': True}}

        df1 = DataFrame(df1)
        df2 = DataFrame(df2)

        _check_bin_op(operator.and_)
        _check_bin_op(operator.or_)
        _check_bin_op(operator.xor)

        _check_unary_op(operator.inv)  # TODO: belongs elsewhere 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:43,代碼來源:test_operators.py

示例6: test_invert

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def test_invert(self):
        self.assertRaises(TypeError, operator.invert)
        self.assertRaises(TypeError, operator.invert, None)
        self.assertTrue(operator.inv(4) == -5) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_operator.py

示例7: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self):
        arr = operator.inv(_values_from_object(self))
        return self._wrap_array(arr, self.axes, copy=False) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:generic.py

示例8: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self):
        arr = operator.inv(self.values)
        return self._constructor(arr, self.index).__finalize__(self)

    #----------------------------------------------------------------------
    # unbox reductions 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:series.py

示例9: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self):
        return self._uop(operator.inv) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:UserFloat.py

示例10: __inv__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __inv__(self):
        return self.apply_op1(operator.inv) 
開發者ID:xesscorp,項目名稱:myhdlpeek,代碼行數:4,代碼來源:myhdlpeek.py

示例11: p_unary_operator

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def p_unary_operator(self, p):
        '''unary_operator : '+'
                          | '-'
                          | '~'
                          | '!'
        '''
        # reduces to (op, op_str)
        p[0] = ({
            '+': operator.pos,
            '-': operator.neg,
            '~': operator.inv,
            '!': operator.not_}[p[1]], p[1]) 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:14,代碼來源:preprocessor.py

示例12: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self):
        return inv(self, graph=self.graph) 
開發者ID:spotify,項目名稱:pythonflow,代碼行數:4,代碼來源:core.py

示例13: __invert__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def __invert__(self): return type(self)(self, operator.inv) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:3,代碼來源:transform.py

示例14: test_invert

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def test_invert(self):
        self.failUnlessRaises(TypeError, operator.invert)
        self.failUnlessRaises(TypeError, operator.invert, None)
        self.failUnless(operator.inv(4) == -5) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:6,代碼來源:test_operator.py

示例15: test_inv_g4

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import inv [as 別名]
def test_inv_g4(self, g4):
        '''
        a numerical test for the inverse of a MV. truth was
        generated by results of clifford v0.82
        '''
        layout, blades = g4, g4.blades
        valA = np.array([
            -0.3184271488037198 , -0.8751064635010213 ,  # noqa
            -1.5011710376191947 ,  1.7946332649746224 ,  # noqa
            -0.8899576254164621 , -0.3297631748225678 ,  # noqa
             0.04310366054166925,  1.3970365638677635 ,  # noqa
            -1.545423393858595  ,  1.7790215501876614 ,  # noqa
             0.4785341530609175 , -1.32279679741638   ,  # noqa
             0.5874769077573831 , -1.0227287710873676 ,  # noqa
             1.779673249468527  , -1.5415648119743852    # noqa
        ])

        valAinv = np.array([
             0.06673424072253006 , -0.005709960252678998,  # noqa
            -0.10758540037163118 ,  0.1805895938775471  ,  # noqa
             0.13919236400967427 ,  0.04123255613093294 ,  # noqa
            -0.015395162562329407, -0.1388977308136247  ,  # noqa
            -0.1462160646855434  , -0.1183453106997158  ,  # noqa
            -0.06961956152268277 ,  0.1396713851886765  ,  # noqa
            -0.02572904638749348 ,  0.02079613649197489 ,  # noqa
            -0.06933660606043765 , -0.05436077710009021    # noqa
        ])

        A = MultiVector(layout=layout, value=valA)
        Ainv = MultiVector(layout=layout, value=valAinv)

        np.testing.assert_almost_equal(A.inv().value, Ainv.value) 
開發者ID:pygae,項目名稱:clifford,代碼行數:34,代碼來源:test_clifford.py


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