def cmp_fun():
    a, b = 5, 3
    print (operator.lt(a,b))
    #True Same as a<b.
    print (operator.le(a, b))
    # False
    print (operator.eq(a,b))
    # False
    print (operator.ne(a,b))    
    #TRUE
    print(operator.ge(a,b))
    #False Same as a>=b
    print (operator.gt(a, b))
    # True
    print (operator.__lt__(a, b))
    #TRUE
    print (operator.__le__(a, b))
    #TRUE
    print (operator.__ne__(a, b))
    #TRUE Same as a<b.
    print (operator.__ge__(a, b))    
    #FALSE
    print (operator.__gt__(a, b))
    #FALSE
    print (operator.__eq__(a, b))
Пример #2
0
def check_con(date_list):
    for k, g in groupby(enumerate(date_list), lambda x: x[1]-x[0]):
        lst = list(map(itemgetter(1), g))
        percentage = len(lst) / streak_len
        if operator.__ge__(percentage, 0.5):
            return "{0:.0%}".format(percentage)
        else:
            return ':)'
Пример #3
0
 def specialcases(x):
     operator.lt(x,3)
     operator.le(x,3)
     operator.eq(x,3)
     operator.ne(x,3)
     operator.gt(x,3)
     operator.ge(x,3)
     is_operator(x,3)
     operator.__lt__(x,3)
     operator.__le__(x,3)
     operator.__eq__(x,3)
     operator.__ne__(x,3)
     operator.__gt__(x,3)
     operator.__ge__(x,3)
     # the following ones are constant-folded
     operator.eq(2,3)
     operator.__gt__(2,3)
Пример #4
0
 def specialcases(x):
     operator.lt(x, 3)
     operator.le(x, 3)
     operator.eq(x, 3)
     operator.ne(x, 3)
     operator.gt(x, 3)
     operator.ge(x, 3)
     is_operator(x, 3)
     operator.__lt__(x, 3)
     operator.__le__(x, 3)
     operator.__eq__(x, 3)
     operator.__ne__(x, 3)
     operator.__gt__(x, 3)
     operator.__ge__(x, 3)
     operator.xor(x, 3)
     # the following ones are constant-folded
     operator.eq(2, 3)
     operator.__gt__(2, 3)
Пример #5
0
 def __clustered(self):
     # Todo refactor cluster class
     self.clusters = [
         cluster for cluster in self.clusters
         if operator.__ge__(len(cluster), self.min_cluster_size)
     ]
     self.num_clusters = len(self.clusters)
     self.clusters = sorted(self.clusters,
                            key=lambda cluster: len(cluster),
                            reverse=True)
Пример #6
0
def operations_to_functions(operation, a, b):
    if operation == ">=":
        return operator.__ge__(a, b)
    if operation == "<=":
        return operator.__le__(a, b)
    if operation == "=":
        return operator.__eq__(a, b)
    if operation == ">":
        return operator.__gt__(a, b)
    if operation == "<":
        return operator.__lt__(a, b)
Пример #7
0
def compatible_release_operator(x, y):
    return op.__ge__(x, y) and x.startswith(
        VersionOrder(".".join(text_type(y).split(".")[:-1])))
Пример #8
0
 def __ge__(self, value):
     return operator.__ge__(self._tensor, value)
Пример #9
0
@Time    : 2020/6/20 14:08
@Software: PyCharm
@File    : operator_learn.py
'''

import operator
a = 6
b = 7
operator.lt(a, b)  #less than小于

operator.le(a, b)  #lessthan or equal to小于等于

operator.eq(a, b)  #equal to等于

operator.ne(a, b)  #not equalto不等于

operator.ge(a, b)  #greaterand equal to大于等于

operator.gt(a, b)  #greater大于

operator.__le__(a, b)

operator.__lt__(a, b)

operator.__eq__(a, b)

operator.__ne__(a, b)

print(operator.__ge__(a, b))

operator.__gt__(a, b)
Пример #10
0
def compatible_release_operator(x, y):
    return op.__ge__(x, y) and x.startswith(VersionOrder(".".join(text_type(y).split(".")[:-1])))
Пример #11
0
 def __ge__(self, other):
     """self >= other"""
     return __ge__(get_wrapped_object(self), get_wrapped_object(other))
Пример #12
0
 def update_event(self, inp=-1):
     self.set_output_val(0, operator.__ge__(self.input(0), self.input(1)))
Пример #13
0
print(c)
c = operator.ne(a, b)
print(c)
c = operator.ge(a, b)
print(c)
c = operator.gt(a, b)
print(c)
c = operator.__lt__(a, b)
print(c)
c = operator.__le__(a, b)
print(c)
c = operator.__eq__(a, b)
print(c)
c = operator.__ne__(a, b)
print(c)
c = operator.__ge__(a, b)
print(c)
c = operator.__gt__(a, b)
print(c)

from itertools import *

for i in chain([x * 2 for x in range(0, 10)], ['a', 'b', 'c', 'd']):
    print(i)

#itertools combination
for i in combinations([x for x in range(0, 10)], 3):
    print(i)

#compress
Пример #14
0
eq = spice(lambda x, y: operator.eq(x, y), name='eq', doc=operator.eq.__doc__)
__eq__ = spice(lambda x, y: operator.__eq__(x, y),
               name='__eq__',
               doc=operator.eq.__doc__)

floordiv = spice(lambda x, y: operator.floordiv(x, y),
                 name='floordiv',
                 doc=operator.floordiv.__doc__)
__floordiv__ = spice(lambda x, y: operator.__floordiv__(x, y),
                     name='__floordiv__',
                     doc=operator.floordiv.__doc__)

# reversed
ge = spice(lambda x, y: operator.ge(y, x), name='ge')
__ge__ = spice(lambda x, y: operator.__ge__(y, x), name='__ge__')

getitem = spice(lambda x, y: operator.getitem(x, y),
                name='getitem',
                doc=operator.getitem.__doc__)
__getitem__ = spice(lambda x, y: operator.__getitem__(x, y),
                    name='__getitem__',
                    doc=operator.getitem.__doc__)

# reversed
gt = spice(lambda x, y: operator.gt(y, x), name='gt')
__gt__ = spice(lambda x, y: operator.__gt__(y, x))

indexOf = spice(lambda x, y: operator.indexOf(x, y),
                name='indexOf',
                doc=operator.indexOf.__doc__)