当前位置: 首页>>代码示例>>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;未经允许,请勿转载。