本文整理汇总了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)
示例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))
示例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)))
示例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)
示例5: __invert__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
return NonStandardInteger(operator.invert(self.val))
示例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)
示例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
示例8: __invert__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
return self._un_op(operator.invert)
示例9: test_invert_array
# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_invert_array(self):
self.check_array_op(operator.invert)
示例10: test_invert_zerodim
# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def test_invert_zerodim(self):
self.check_zerodim_op(operator.invert)
示例11: __invert__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import invert [as 别名]
def __invert__(self):
return self.apply_op1(operator.invert)