def __eq__(self, bst2): """ ------------------------------------------------------- Description: Check if given bst is equal to current bst All data should be equal and at the same node location Assert: bst2 is a BST Use: bst1 == bst2 ------------------------------------------------------- Parameters: bst2 - a binary search tree to compare with (BST) Returns: True/False ------------------------------------------------------- """ if self._root == None and bst2._root == None: return True if (self._root != None and bst2._root == None): return False if self._root == None and bst2._root != None: return False # else: # if(self._leaf_count() != bst2._leaf_count()): # return False if ((self._root._data == bst2._root._data) and __eq__(self._root._left, bst2._root._left) and __eq__(self._root._right, bst2._root._right)): return True else: return False
def type_checker(): text_bucket = list() if operator.__eq__(args.data_type, 'list'): """ Example ------- >>> text_bucket = list([ '구급대는 아이 얼굴과 온몸에서 타박상과 멍 자국을 발견하고 경찰에 신고했습니다', '아동 학대를 의심한 경찰은 부모를 조사한 끝에 의붓아버지 26살 A 씨를 긴급체포했습니다', '혐의를 부인했던 A 씨는 계속된 추궁에 아이를 20시간 넘게 때린 사실을 인정했습니다', '특히 끔찍한 폭행은 가족들이 모두 있는 자리에서 이뤄졌습니다', """ text_bucket = list() elif operator.__eq__(args.data_type, 'file'): FILE_DIR = os.path.join(os.getcwd(), 'samples/news_2.txt') if not os.path.exists(FILE_DIR): raise FileNotFoundError('File not found exception') with codecs.open(FILE_DIR, mode='r', encoding='utf-8', errors='strict', buffering=1) as f: for (_, sentence) in enumerate(f): text_bucket.append(sentence) else: PrettyPrinter(indent=4) raise ValueError('ArgumentParser Error') return text_bucket
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))
def __sum_recursive(self, clusters_investigator, ends): # Todo modify function interface self.summaries = [] for _ in range(self.num_clusters): # Todo Exception self.summaries.append(self.clusters[_][0]) clusters_investigator[_] += 1 if operator.__eq__(len(self.summaries), self.k): return self.__summary_splitter() while True: # Todo Exception try: cluster_branch = np.array([clusters_investigator + 1, ends], dtype=np.float64).min(axis=0) / ends branch_arg_min = int(cluster_branch.argmin()) cluster_investigator = int( clusters_investigator[branch_arg_min]) self.summaries.append( self.clusters[branch_arg_min][cluster_investigator]) clusters_investigator[branch_arg_min] += 1 if len(self.summaries) == self.k: return self.__summary_splitter() except: pass
def get_newweibo(id, laststring): i = 1 url = 'https://m.weibo.cn/api/container/getIndex?type=uid&value=' + id weibo_url = 'https://m.weibo.cn/api/container/getIndex?type=uid&value=' + id + '&containerid=' + get_containerid( url) + '&page=' + str(i) #print(weibo_url) try: data = use_proxy(weibo_url, proxy_addr) while data == -1: data = use_proxy(weibo_url, proxy_addr) content = json.loads(data).get('data') cards = content.get('cards') #print('get msg suc len(cards):'+str(len(cards))) if (len(cards) > 0): card_type = cards[0].get('card_type') if card_type == 9: mblog = cards[0].get('mblog') text = mblog.get('text') text = text.replace('<br /><br />', '。') #print('消息返回 text:'+text) if operator.__eq__(laststring, '') == True: print('first get suc') print(text) return False, text rtime = mblog.get('created_at') tmin = check_time(rtime) if tmin > 0 and tmin < 4: if operator.__eq__(laststring, text) == True: return False, laststring #pic = mblog.get('original_pic') #if pic is not None: # now_time = time.strftime('%Y/%m/%d-%H%M') # url_download(pic, now_time + '-' + picid) # picid = picid + 1 #else: # print('pic none') print('get suc:' + text) return True, text else: print('get False and tmin:' + str(tmin)) return False, laststring except Exception as e: print(e) return False, laststring
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)
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)
def call_const_eq(self: jit.Judge, *args: jit.AbsVal): if len(args) != 2: return NotImplemented a, b = args if a.is_literal() and b.is_literal(): const = jit.S(operator.__eq__(a.base, b.base)) ret_types = (jit.S(type(const.base)), ) return jit.CallSpec(const, const, ret_types) return self.spec(jit.S(operator.__eq__), "__call__", list(args))
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)
def summary_works(self): self.summaries = list() self.__cluster_observation() if operator.eq(self.k, 0): return [] else: ends = np.array([len(cluster) for cluster in self.clusters], dtype=np.int64) clusters_investigator = np.zeros(ends.shape, dtype=np.float64) for _ in range(self.num_clusters): # Todo Exception self.summaries.append(self.clusters[_][0]) clusters_investigator[_] += 1 if operator.__eq__(len(self.summaries), self.k): return self.__summary_splitter() while True: # Todo Exception try: cluster_branch = np.array( [clusters_investigator + 1, ends], dtype=np.float64).min(axis=0) / ends branch_arg_min = int(cluster_branch.argmin()) cluster_investigator = int( clusters_investigator[branch_arg_min]) self.summaries.append( self.clusters[branch_arg_min][cluster_investigator]) clusters_investigator[branch_arg_min] += 1 if len(self.summaries) == self.k: return self.__summary_splitter() except: # Todo Exception with raise value say.info( 'Cluster branch tries the sequence if it is not clustered or empty' )
def __eq__(self, other): """self == other""" return __eq__(get_wrapped_object(self), get_wrapped_object(other))
def __eq__(self, value): return operator.__eq__(self._tensor, value)
@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)
def __ne__(self,b): return not operator.__eq__(self,b)
import operator operator.eq('hello', 'hello') operator.__eq__('hello', 'hello')
name='__contains__', doc=operator.contains.__doc__) contains = spice(lambda x, y: operator.contains(x, y), name='contains', doc=operator.contains.__doc__) concat = spice(lambda x, y: operator.concat(x, y), name='concat', doc=operator.concat.__doc__) countOf = spice(lambda x, y: operator.countOf(x, y), name='countOf', doc=operator.countOf.__doc__) 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),
def __gt__(self, other): if __eq__(self, other): return False return self.__test_gt__(other)
def update_event(self, inp=-1): self.set_output_val(0, operator.__eq__(self.input(0), self.input(1)))
def __neq__(self,other): return not operator.__eq__(self,other)
def __ge__(self, other): if __eq__(self, other): return True return self.__test_gt__(other)