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


Python operator.eq方法代碼示例

本文整理匯總了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) 
開發者ID:J535D165,項目名稱:recordlinkage,代碼行數:18,代碼來源:neighbourhoodblock_test.py

示例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) 
開發者ID:J535D165,項目名稱:recordlinkage,代碼行數:19,代碼來源:neighbourhoodblock_test.py

示例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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:test_regression.py

示例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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:22,代碼來源:test_operators.py

示例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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:18,代碼來源:base.py

示例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, )
                ) 
開發者ID:jpush,項目名稱:jbox,代碼行數:20,代碼來源:persistence.py

示例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] 
開發者ID:jpush,項目名稱:jbox,代碼行數:20,代碼來源:__init__.py

示例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) 
開發者ID:MagicChuyi,項目名稱:SlowFast-Network-pytorch,代碼行數:20,代碼來源:AVA_video_v1.py

示例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) 
開發者ID:MagicChuyi,項目名稱:SlowFast-Network-pytorch,代碼行數:24,代碼來源:AVA_video_v2.py

示例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 
開發者ID:MagicChuyi,項目名稱:SlowFast-Network-pytorch,代碼行數:20,代碼來源:imshow_result.py

示例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 ) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:test_richcmp.py

示例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 
開發者ID:frictionlessdata,項目名稱:goodtables-py,代碼行數:12,代碼來源:inspector.py

示例13: testEq

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

示例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) 
開發者ID:tensortrade-org,項目名稱:tensortrade,代碼行數:4,代碼來源:quantity.py

示例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)) 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:16,代碼來源:carbonara.py


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