示例#1
0
文件: Enum_PyUnit.py 项目: m-w-a/pywg
    def test(self) -> None:
        class Color(metaclass=Enum):
            R = 1
            G = ...

        self.assertEqual(builtins.hash(Color.R), hash(1))
        self.assertEqual(builtins.hash(Color.G), hash(2))
示例#2
0
 def _populate_thread_info_for_metaevent(
     self, event, node_id="", phase_tid_default=None, phase_name=""
 ):
     # The `E` event in horovod and SMDataParallel does not have a `name` entity. Add an empty `name` in an event dictionary if it is absent.
     if self.type in ["SMDataParallelMetrics", "HorovodMetrics"]:
         if "name" not in event and "ph" in event and event["ph"] == "E":
             event["name"] = ""
     if event["name"] == "thread_name":
         name = node_id + "_" + event["args"]["name"]
         t_id = event["tid"]
     elif event["name"] == "thread_sort_index":
         name = "Unknown"
         t_id = event["tid"]
     elif phase_tid_default is not None:
         # there is no thread mentioned and this is unique thread for phase and node
         # We will be generating a unique tid here and return this tid to be populated in event
         name = node_id + "_" + str(phase_tid_default)
         t_id = hash(name + str(phase_name))
     else:
         self.logger.debug(
             f"Event:{event} doesn't have thread_name nor phase_tid_default. Returning"
         )
         return
     pid = event["pid"]
     if pid not in self._processes:
         self.logger.warn(
             f"Did not find matching process for pid {pid}. Creating a process with name 'Unknown'"
         )
         self._processes[pid] = ProcessInfo(pid, "Unknown")
     self._processes[pid].add_thread(t_id, name)
     return t_id
示例#3
0
 def __init__(self,
              hash,
              paths,
              format,
              width,
              height,
              added,
              modified,
              invalid_paths=None,
              views=0,
              **props):
     super().__init__()
     self.hash = hash
     self.int_hash = builtins.hash(int(hash, 16))  # truncated int
     self.paths = paths
     self.format = format
     self._width = width
     self._height = height
     self.added = added
     self.modified = modified
     self.invalid_paths = invalid_paths or []
     self._views = views
     for attr, value in props.items():
         setattr(self, attr, value)
     self.subscribe(self)
示例#4
0
 def __hash__(self):
     keys = [
         'shape', 'typestr', 'descr', 'data', 'strides', 'mask', 'offset',
         'version'
     ]
     array_intf = self._mat.__array_interface__
     array_intf_tup = tuple(array_intf.get(i, None) for i in keys)
     return builtins.hash((repr(array_intf_tup), self._mode))
def creating_tuple_hash():
    ele = []
    n = int(input())
    x = input()
    temp = x.split(" ")
    for i in range(n):
        ele.append(int(temp[i]))
    t = tuple(ele)
    print(hash(t))
示例#6
0
def hash(array):
    """Hashes an array that represents a streamline"""

    # Use just a few data points as hash key. I could use all the data of
    # the streamlines, but then the complexity grows with the number of
    # points.
    if len(array) < MIN_NB_POINTS:
        key = array
    else:
        key = array[KEY_INDEX]

    return builtins.hash(tuple(key.ravel()))
示例#7
0
 def __hash__(self):
     """Filename is hash"""
     return builtins.hash(self.args["filename"])
示例#8
0
import builtins
if __name__ == '__main__':
    n = int(input())
    integer_list = tuple(map(int, input().split()))
    print(builtins.hash(integer_list))
示例#9
0
 def __hash__(self) -> int:
     return builtins.hash(self.id)
示例#10
0
from builtins import hash
if __name__ == '__main__':
    numbers = tuple()
    n = int(input())
    integer_list = map(int, input().split())
    numbers = tuple(integer_list)
    print(hash(numbers))
import builtins
    n = int(input())
    integer_list = map(int, input().split())
    print(builtins.hash(tuple(integer_list)))
示例#12
0
文件: bpipe.py 项目: mavnt/bpipe
def hash(x=None):
    if x is None:
        return bpipe(hash)
    else:
        return builtins.hash(x)
示例#13
0
from builtins import hash
if __name__ == '__main__':
    n = int(input())
    t = tuple(map(int, input().split()))
    print(hash(t))
示例#14
0
__author__ = "trunghieu11"
from builtins import hash

n = int(input())
A = tuple(map(int, input().split()))
print(hash(A))
示例#15
0
def get_vector_hash(vector):
    return hash(str(vector))
示例#16
0
import builtins as built

if __name__ == '__main__':
    n = int(input())
    integer_list = map(int, input().split())

    t = tuple(integer_list)
    print(built.hash(t))
示例#17
0
"""
Link: https://www.hackerrank.com/challenges/python-tuples/problem

Given an integer, n, and n space-separated integers as input, create a tuple, t, of those n integers.
Then compute and print the result of hash(t).

Note: hash() is one of the functions in the __builtins__ module, so it need not be imported.

Input Format
The first line contains an integer, n, denoting the number of elements in the tuple.
The second line contains n space-separated integers describing the elements in tuple t.

Output Format
Print the result of hash(t).

Sample Input 0

2
1 2
Sample Output 0

3713081631934410656
"""

from builtins import hash

if __name__ == '__main__':
    n = int(input())
    print(hash(tuple(map(int, input().split()))))
示例#18
0
    lambda *args, **kwargs: wrap(builtins.getattr)(*args, **kwargs),
    builtins.getattr)
globals = functools.update_wrapper(
    lambda *args, **kwargs: builtins.globals(*args, **kwargs),
    builtins.globals)
globals._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.globals)(*args, **kwargs),
    builtins.globals)
hasattr = functools.update_wrapper(
    lambda *args, **kwargs: builtins.hasattr(*args, **kwargs),
    builtins.hasattr)
hasattr._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.hasattr)(*args, **kwargs),
    builtins.hasattr)
hash = functools.update_wrapper(
    lambda *args, **kwargs: builtins.hash(*args, **kwargs), builtins.hash)
hash._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.hash)(*args, **kwargs),
    builtins.hash)
hex = functools.update_wrapper(
    lambda *args, **kwargs: builtins.hex(*args, **kwargs), builtins.hex)
hex._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.hex)(*args, **kwargs), builtins.hex)
id = functools.update_wrapper(
    lambda *args, **kwargs: builtins.id(*args, **kwargs), builtins.id)
id._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.id)(*args, **kwargs), builtins.id)
input = functools.update_wrapper(
    lambda *args, **kwargs: builtins.input(*args, **kwargs), builtins.input)
input._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.input)(*args, **kwargs),
示例#19
0
###############   LISTS   ################
if __name__ == '__main__':
    N = int(input())
    lis = []
    for i in range(N):
        str_input = input().split()
        if str_input[0] == "insert":
            lis.insert(int(str_input[1]), int(str_input[2]))
        elif str_input[0] == "remove":
            lis.remove(int(str_input[1]))
        elif str_input[0] == "append":
            lis.append(int(str_input[1]))
        elif str_input[0] == "sort":
            lis.sort()
        elif str_input[0] == "pop":
            lis.pop()
        elif str_input[0] == "reverse":
            lis.reverse()
        elif str_input[0] == "print":
            print(lis)
        else:
            print("wrong input")

###############   TUPLES   ################

if __name__ == '__main__':
    from builtins import hash
    n = int(input())
    integer_list = tuple(map(int, input().split()))
    print(hash(integer_list))
示例#20
0
def printHash(input_tuple):
    print(builtins.hash(input_tuple))
示例#21
0
def printHash(input_tuple):
    print(builtins.hash(input_tuple))
import builtins
T = tuple()
new = []
input1=[]
input2=[]
looper=input("")
input1=input()
#print(input1)
input2 = str.split(input1)
for i in range(len(input2)):
    input2[i]=int(input2[i])
#print(type(input2[1]))
#print(input2)
Tuple=tuple(input2)
#print(Tuple)
print(builtins.hash(Tuple))
""" ACCEPTED CODE:
import __builtin__
T = tuple()
new = []
input1=[]
input2=[]
looper=raw_input("")
input1=raw_input()
#print(input1)
input2 = str.split(input1)
for i in range(len(input2)):
    input2[i]=int(input2[i])
#print(type(input2[1]))
#print(input2)
示例#23
0
 def __hash__(self):
     return builtins.hash(self.Value)