当前位置: 首页>>代码示例>>Python>>正文


Python operator.invert方法代码示例

本文整理汇总了Python中operator.invert方法的典型用法代码示例。如果您正苦于以下问题:Python operator.invert方法的具体用法?Python operator.invert怎么用?Python operator.invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operator的用法示例。


在下文中一共展示了operator.invert方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unary_operators

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_unary_operators(self, values, op, fill_value):
        # https://github.com/pandas-dev/pandas/issues/22835
        values = np.asarray(values)
        if op is operator.invert:
            new_fill_value = not fill_value
        else:
            new_fill_value = op(fill_value)
        s = SparseSeries(values,
                         fill_value=fill_value,
                         index=['a', 'b', 'c', 'd'],
                         name='name')
        result = op(s)
        expected = SparseSeries(op(values),
                                fill_value=new_fill_value,
                                index=['a', 'b', 'c', 'd'],
                                name='name')
        tm.assert_sp_series_equal(result, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:test_series.py

示例2: _build_logical_expression

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def _build_logical_expression(self, grammar, terminal_component_names):
        terminal_component_symbols = eval("symbols('%s')"%(' '.join(terminal_component_names)))
        if isinstance(terminal_component_symbols, Symbol):
            terminal_component_symbols = [terminal_component_symbols]
        name_to_symbol = {terminal_component_names[i]:symbol for i, symbol in enumerate(terminal_component_symbols)}
        terminal_component_names = set(terminal_component_names)

        op_to_symbolic_operation = {'not':operator.invert, 'concat':operator.and_, 'gap':operator.and_, 'union':operator.or_, 'intersect':operator.and_}

        def logical_expression_builder(component):
            if component['id'] in terminal_component_names:
                return name_to_symbol[component['id']]
            else:
                children = component['components']
                return reduce(op_to_symbolic_operation[component['operation']],[logical_expression_builder(child) for child in children])

        return simplify(logical_expression_builder(grammar)) 
开发者ID:texta-tk,项目名称:texta,代码行数:19,代码来源:elastic_grammar_query.py

示例3: test_unary_methods

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_unary_methods(self):
        array = np.array([-1, 0, 1, 2])
        array_like = ArrayLike(array)
        for op in [operator.neg,
                   operator.pos,
                   abs,
                   operator.invert]:
            _assert_equal_type_and_value(op(array_like), ArrayLike(op(array))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_mixins.py

示例4: _add_unary_ops

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def _add_unary_ops(cls):
        cls.__pos__ = cls._create_unary_method(operator.pos)
        cls.__neg__ = cls._create_unary_method(operator.neg)
        cls.__invert__ = cls._create_unary_method(operator.invert) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:sparse.py

示例5: __invert__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
    return NonStandardInteger(operator.invert(self.val)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:4,代码来源:test_util.py

示例6: test_invert

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [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: setUp

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def setUp(self):
    super(LogicalNotTest, self).setUp()
    self.ops = [('logical_not', operator.invert, math_ops.logical_not,
                 core.logical_not),]
    self.test_lt = self.original_lt < 10 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:7,代码来源:core_test.py

示例8: __invert__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
        return self._un_op(operator.invert) 
开发者ID:angr,项目名称:angr,代码行数:4,代码来源:dataset.py

示例9: test_invert_array

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_invert_array(self):
        self.check_array_op(operator.invert) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_unary_op.py

示例10: test_invert_zerodim

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_invert_zerodim(self):
        self.check_zerodim_op(operator.invert) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_unary_op.py

示例11: __invert__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
        return self.apply_op1(operator.invert) 
开发者ID:xesscorp,项目名称:myhdlpeek,代码行数:4,代码来源:myhdlpeek.py


注:本文中的operator.invert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。