本文整理汇总了Python中operator.eq方法的典型用法代码示例。如果您正苦于以下问题:Python operator.eq方法的具体用法?Python operator.eq怎么用?Python operator.eq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类operator
的用法示例。
在下文中一共展示了operator.eq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dedup_with_blocking_vs_sortedneighbourhood
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def test_dedup_with_blocking_vs_sortedneighbourhood(self, window):
indexers = [
NeighbourhoodBlock(
['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
NeighbourhoodBlock(
left_on=['var_arange', 'var_block10'],
right_on=['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
SortedNeighbourhood(
'var_arange', block_on='var_block10', window=window),
]
self.assert_index_comparisons(eq, indexers, self.a)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a)
示例2: test_link_with_blocking_vs_sortedneighbourhood
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def test_link_with_blocking_vs_sortedneighbourhood(self, window):
indexers = [
NeighbourhoodBlock(
['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
NeighbourhoodBlock(
left_on=['var_arange', 'var_block10'],
right_on=['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
SortedNeighbourhood(
'var_arange', block_on='var_block10', window=window),
]
self.assert_index_comparisons(eq, indexers, self.a, self.b)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a,
self.incomplete_b)
示例3: test_richcompare_crash
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def test_richcompare_crash(self):
# gh-4613
import operator as op
# dummy class where __array__ throws exception
class Foo(object):
__array_priority__ = 1002
def __array__(self, *args, **kwargs):
raise Exception()
rhs = Foo()
lhs = np.array(1)
for f in [op.lt, op.le, op.gt, op.ge]:
if sys.version_info[0] >= 3:
assert_raises(TypeError, f, lhs, rhs)
elif not sys.py3kwarning:
# With -3 switch in python 2, DeprecationWarning is raised
# which we are not interested in
f(lhs, rhs)
assert_(not op.eq(lhs, rhs))
assert_(op.ne(lhs, rhs))
示例4: test_compare_frame
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def test_compare_frame(self):
# GH#24282 check that Categorical.__cmp__(DataFrame) defers to frame
data = ["a", "b", 2, "a"]
cat = Categorical(data)
df = DataFrame(cat)
for op in [operator.eq, operator.ne, operator.ge,
operator.gt, operator.le, operator.lt]:
with pytest.raises(ValueError):
# alignment raises unless we transpose
op(cat, df)
result = cat == df.T
expected = DataFrame([[True, True, True, True]])
tm.assert_frame_equal(result, expected)
result = cat[::-1] != df.T
expected = DataFrame([[False, True, True, False]])
tm.assert_frame_equal(result, expected)
示例5: visit_binary
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def visit_binary(self, binary, **kwargs):
"""Move bind parameters to the right-hand side of an operator, where
possible.
"""
if (
isinstance(binary.left, expression.BindParameter)
and binary.operator == operator.eq
and not isinstance(binary.right, expression.BindParameter)
):
return self.process(
expression.BinaryExpression(binary.right,
binary.left,
binary.operator),
**kwargs)
return super(MSSQLCompiler, self).visit_binary(binary, **kwargs)
示例6: _validate_query_state
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def _validate_query_state(self):
for attr, methname, notset, op in (
('_limit', 'limit()', None, operator.is_),
('_offset', 'offset()', None, operator.is_),
('_order_by', 'order_by()', False, operator.is_),
('_group_by', 'group_by()', False, operator.is_),
('_distinct', 'distinct()', False, operator.is_),
(
'_from_obj',
'join(), outerjoin(), select_from(), or from_self()',
(), operator.eq)
):
if not op(getattr(self.query, attr), notset):
raise sa_exc.InvalidRequestError(
"Can't call Query.update() or Query.delete() "
"when %s has been called" %
(methname, )
)
示例7: get_op
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
'<': operator.lt,
'>': operator.gt,
'<=': operator.le,
'>=': operator.ge,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
示例8: make_multi_lable
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def make_multi_lable(self,dic):
for key in dic:
pre=None
#print("before:",dic[key])
temp=[]
for info in dic[key]:
if pre==None:
pre=info
temp.append(info)
elif operator.eq(info.bbox.tolist(),pre.bbox.tolist()):
temp[-1].img_class.append(info.img_class[0])
#这是个陷坑
#dic[key].remove(info)
else:
pre=info
temp.append(info)
dic[key]=temp
#print("dic:",dic)
示例9: make_multi_lable
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def make_multi_lable(self,dic):
for key in dic:
pre=None
#print("before:",dic[key])
temp=[]
for info in dic[key]:
if pre==None:
pre=info
temp.append(info)
elif operator.eq(info.bbox.tolist(),pre.bbox.tolist()):
temp[-1].img_class.append(info.img_class[0])
#这是个陷坑
#dic[key].remove(info)
else:
pre=info
temp.append(info)
dic[key]=temp
#print("dic:",dic)
#把dic的信息转换成一一对应的list信息(bboxes,labels,detector_bboxes_list,width,height,ratio,image_position)
示例10: make_multi_lable
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def make_multi_lable(self,dic):
for key in dic:
pre=None
#print("before:",dic[key])
temp=[]
for info in dic[key]:
if pre==None:
pre=info
temp.append(info)
elif operator.eq(info.bbox.tolist(),pre.bbox.tolist()):
temp[-1].img_class.append(info.img_class[0])
temp[-1].prob.append(info.prob[0])
#这是个陷坑
#dic[key].remove(info)
else:
pre=info
temp.append(info)
dic[key]=temp
示例11: test_values
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def test_values(self):
# check all operators and all comparison results
self.checkvalue("lt", 0, 0, False)
self.checkvalue("le", 0, 0, True )
self.checkvalue("eq", 0, 0, True )
self.checkvalue("ne", 0, 0, False)
self.checkvalue("gt", 0, 0, False)
self.checkvalue("ge", 0, 0, True )
self.checkvalue("lt", 0, 1, True )
self.checkvalue("le", 0, 1, True )
self.checkvalue("eq", 0, 1, False)
self.checkvalue("ne", 0, 1, True )
self.checkvalue("gt", 0, 1, False)
self.checkvalue("ge", 0, 1, False)
self.checkvalue("lt", 1, 0, False)
self.checkvalue("le", 1, 0, False)
self.checkvalue("eq", 1, 0, False)
self.checkvalue("ne", 1, 0, True )
self.checkvalue("gt", 1, 0, True )
self.checkvalue("ge", 1, 0, True )
示例12: _filter_checks
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def _filter_checks(checks, type=None, context=None, inverse=False):
result = []
comparator = operator.eq if inverse else operator.ne
for check in checks:
if type and comparator(check['type'], type):
continue
if context and comparator(check['context'], context):
continue
result.append(check)
return result
示例13: testEq
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def testEq(self):
self.comparisonCheck(operator.eq)
示例14: __eq__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def __eq__(self, other: Union['Quantity', float, int]) -> bool:
return Quantity._bool_operation(self, other, operator.eq)
示例15: _compare
# 需要导入模块: import operator [as 别名]
# 或者: from operator import eq [as 别名]
def _compare(self, op, other):
if isinstance(other, SplitKey):
if self.sampling != other.sampling:
if op == operator.eq:
return False
if op == operator.ne:
return True
raise TypeError(
"Cannot compare %s with different sampling" %
self.__class__.__name__)
return op(self.key, other.key)
if isinstance(other, numpy.datetime64):
return op(self.key, other)
raise TypeError("Cannot compare %r with %r" % (self, other))