Python operator.__gt__() Examples

The following are 30 code examples of operator.__gt__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module operator , or try the search function .
Example #1
Source File: NodeNumericalAttribute.py    From ndlib with BSD 2-Clause "Simplified" License 7 votes vote down vote up
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) 
Example #2
Source File: test_richcmp.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def __gt__(self, other):
        return self.x > other 
Example #3
Source File: IdaTools.py    From apiscout with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 
Example #4
Source File: models.py    From Weapon-Detection-And-Classification with MIT License 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #5
Source File: models.py    From CogAlg with MIT License 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #6
Source File: models.py    From android_universal with MIT License 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #7
Source File: models.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #8
Source File: models.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #9
Source File: test_richcmp.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self.x > other 
Example #10
Source File: test_richcmp.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return Vector([a > b for a, b in zip(self.data, self.__cast(other))]) 
Example #11
Source File: test_richcmp.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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): raise TestFailed, "This shouldn't happen"
            def __ge__(self, other): raise TestFailed, "This shouldn't happen"
            def __ne__(self, other): raise TestFailed, "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) 
Example #12
Source File: models.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #13
Source File: models.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #14
Source File: models.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #15
Source File: models.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self._compare(other, operator.__gt__) 
Example #16
Source File: test_richcmp.py    From android_universal with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: resourcedef.py    From guildai with Apache License 2.0 5 votes vote down vote up
def _select_reduce_max(matches):
    return _select_reduce_op(matches, operator.__gt__) 
Example #18
Source File: test_richcmp.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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): raise TestFailed, "This shouldn't happen"
            def __ge__(self, other): raise TestFailed, "This shouldn't happen"
            def __ne__(self, other): raise TestFailed, "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) 
Example #19
Source File: test_richcmp.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return Vector([a > b for a, b in zip(self.data, self.__cast(other))]) 
Example #20
Source File: test_richcmp.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self.x > other 
Example #21
Source File: test_arithmetic.py    From py-flags with MIT License 5 votes vote down vote up
def test_gt(self):
        self._test_incompatible_types_fail(operator.__gt__)

        self.assertFalse(no_flags > no_flags)
        self.assertFalse(no_flags > all_flags)
        self.assertFalse(no_flags > f0)
        self.assertFalse(no_flags > f1)
        self.assertFalse(no_flags > f2)
        self.assertFalse(no_flags > f01)
        self.assertFalse(no_flags > f02)
        self.assertFalse(no_flags > f12)

        self.assertTrue(f0 > no_flags)
        self.assertFalse(f0 > all_flags)
        self.assertFalse(f0 > f0)
        self.assertFalse(f0 > f1)
        self.assertFalse(f0 > f2)
        self.assertFalse(f0 > f01)
        self.assertFalse(f0 > f02)
        self.assertFalse(f0 > f12)

        self.assertTrue(f01 > no_flags)
        self.assertFalse(f01 > all_flags)
        self.assertTrue(f01 > f0)
        self.assertTrue(f01 > f1)
        self.assertFalse(f01 > f2)
        self.assertFalse(f01 > f01)
        self.assertFalse(f01 > f02)
        self.assertFalse(f01 > f12)

        self.assertFalse(no_flags > all_flags)
        self.assertFalse(all_flags > all_flags)
        self.assertFalse(f0 > all_flags)
        self.assertFalse(f1 > all_flags)
        self.assertFalse(f2 > all_flags)
        self.assertFalse(f01 > all_flags)
        self.assertFalse(f02 > all_flags)
        self.assertFalse(f12 > all_flags) 
Example #22
Source File: test_richcmp.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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): raise TestFailed, "This shouldn't happen"
            def __ge__(self, other): raise TestFailed, "This shouldn't happen"
            def __ne__(self, other): raise TestFailed, "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) 
Example #23
Source File: test_richcmp.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __gt__(self, other):
        return Vector([a > b for a, b in zip(self.data, self.__cast(other))]) 
Example #24
Source File: test_richcmp.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __gt__(self, other):
        return self.x > other 
Example #25
Source File: test_richcmp.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #26
Source File: test_richcmp.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return Vector([a > b for a, b in zip(self.data, self.__cast(other))]) 
Example #27
Source File: test_richcmp.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def __gt__(self, other):
        return self.x > other 
Example #28
Source File: test_richcmp.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #29
Source File: test_richcmp.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __gt__(self, other):
        return Vector([a > b for a, b in zip(self.data, self.__cast(other))]) 
Example #30
Source File: test_richcmp.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __gt__(self, other):
        return self.x > other