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


Python operator.__gt__方法代碼示例

本文整理匯總了Python中operator.__gt__方法的典型用法代碼示例。如果您正苦於以下問題:Python operator.__gt__方法的具體用法?Python operator.__gt__怎麽用?Python operator.__gt__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在operator的用法示例。


在下文中一共展示了operator.__gt__方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __init__(self, attribute, value=None, op=None, probability=1, **kwargs):
        super(self.__class__, self).__init__(kwargs)
        self.__available_operators = {"==": operator.__eq__, "<": operator.__lt__,
                                      ">": operator.__gt__, "<=": operator.__le__,
                                      ">=": operator.__ge__, "!=": operator.__ne__,
                                      "IN": (operator.__ge__, operator.__le__)}

        self.attribute = attribute
        self.attribute_range = value
        self.probability = probability
        self.operator = op

        if self.attribute_range is None:
            raise ValueError("A valid attribute value must be provided")

        if self.operator is not None and self.operator in self.__available_operators:
            if self.operator == "IN":
                if not isinstance(self.attribute_range, list) or self.attribute_range[1] < self.attribute_range[0]:
                    raise ValueError("A range list is required to test IN condition")
            else:
                if not isinstance(self.attribute_range, int):
                    if not isinstance(self.attribute_range, float):
                        raise ValueError("A numeric value is required to test the selected condition")
        else:
            raise ValueError("The operator provided '%s' is not valid" % operator) 
開發者ID:GiulioRossetti,項目名稱:ndlib,代碼行數:27,代碼來源:NodeNumericalAttribute.py

示例2: lrange

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def lrange(num1, num2=None, step=1):
    """
    Allows iteration over arbitrary numbers instead of dword long numbers.
    Credits go to:
    http://stackoverflow.com/questions/2187135/range-and-xrange-for-13-digit-numbers-in-python
    http://stackoverflow.com/users/263162/ricardo-cardenes
    """
    op = operator.__lt__

    if num2 is None:
        num1, num2 = 0, num1
    if num2 < num1:
        if step > 0:
            num1 = num2
        op = operator.__gt__
    elif step < 0:
        num1 = num2

    while op(num1, num2):
        yield num1
        num1 += step 
開發者ID:danielplohmann,項目名稱:apiscout,代碼行數:23,代碼來源:IdaTools.py

示例3: __gt__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __gt__(self, _):
        return False 
開發者ID:google,項目名稱:rekall,代碼行數:4,代碼來源:obj.py

示例4: __gt__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __gt__(self, other):
        return self.x > other 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:test_richcmp.py

示例5: test_misbehavin

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def test_misbehavin(self):
        class Misb:
            def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
            def __cmp__(self_, other): raise RuntimeError, "expected"
        a = Misb()
        b = Misb()
        self.assertEqual(a<b, 0)
        self.assertEqual(a==b, 0)
        self.assertEqual(a>b, 0)
        self.assertRaises(RuntimeError, cmp, a, b) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:test_richcmp.py

示例6: __gt__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:4,代碼來源:models.py

示例7: assert_array_greater

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def assert_array_greater(x, y, err_msg='', verbose=True):
    assert_array_compare(operator.__gt__, x, y, err_msg=err_msg,
                         verbose=verbose,
                         header='Arrays are not greater-ordered') 
開發者ID:fgnt,項目名稱:pb_bss,代碼行數:6,代碼來源:module_asserts.py

示例8: __init__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __init__(self, attribute, value=None, op=None, triggering_status=None, probability=1, **kwargs):
        super(self.__class__, self).__init__(kwargs)
        self.__available_operators = {"==": operator.__eq__, "<": operator.__lt__,
                                      ">": operator.__gt__, "<=": operator.__le__,
                                      ">=": operator.__ge__, "!=": operator.__ne__,
                                      "IN": (operator.__ge__, operator.__le__)}

        self.attribute = attribute
        self.trigger = triggering_status
        self.attribute_range = value
        self.probability = probability
        self.operator = op

        if self.attribute_range is None:
            raise ValueError("A valid attribute value must be provided")

        if self.operator is not None and self.operator in self.__available_operators:
            if self.operator == "IN":
                if not isinstance(self.attribute_range, list) or self.attribute_range[1] < self.attribute_range[0]:
                    raise ValueError("A range list is required to test IN condition")
            else:
                if not isinstance(self.attribute_range, int):
                    if not isinstance(self.attribute_range, float):
                        raise ValueError("A numeric value is required to test the selected condition")
        else:
            raise ValueError("The operator provided '%s' is not valid" % operator) 
開發者ID:GiulioRossetti,項目名稱:ndlib,代碼行數:28,代碼來源:EdgeNumericalAttribute.py

示例9: test_misbehavin

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def test_misbehavin(self):
        class Misb:
            def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()
        b = Misb()
        self.assertEqual(a<b, 0)
        self.assertEqual(a==b, 0)
        self.assertEqual(a>b, 0) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:15,代碼來源:test_richcmp.py

示例10: __gt__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __gt__ [as 別名]
def __gt__(self, other):
        return self._operation(other, operator.__gt__) 
開發者ID:mementum,項目名稱:backtrader,代碼行數:4,代碼來源:lineroot.py


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