-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
89 lines (81 loc) · 1.85 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from re import A
import torch
import numpy as np
from collections import Counter
from channel import Channel
# def myfun(data):
# tempdata = data
# tempdata[1] = 0
# return tempdata
# a = torch.tensor([1,1,0,0,0,1,1,0,0,1])
# index = torch.nonzero(a).squeeze()
# n = len(index)
# print(index,n)
# a[index[-1]] = 0
# print(a)
# b = myfun(a.clone())
# print(b,a)
# c = b.tolist()
# print(c)
# print(c == set(c), c)
# a = {1:0, 5:0, 6:1, 9:2}
# min_set = min(a.values())
# xxx = a.keys()
# a = list(range(11))
# a.remove(9)
# print(a)
# alive = torch.tensor([1,0,0,1,1])
# alive = alive.view(1,1,5)
# alive = alive.expand(1, 5, 5).unsqueeze(-1)
# print(alive, alive.transpose(1,2))
# # check for np.nonzero function
# x = np.array([[1,0,1,1,1,0,0,1,0,1]])
# print(x[np.nonzero(x)])
# print(np.nonzero(x.squeeze()))
# # check for non-alive, return an empty array
# a = np.array([0,0,0])
# print(type(np.nonzero(a.squeeze())[0]))
# print(type(np.nonzero(a.squeeze())[0].tolist()))
# # check channel
# alive = np.array([0,0,0,0,0,0])
# mychannel = Channel()
# a,b,c = mychannel.send(alive)
# print(a)
# # check empty list iter
# a = []
# for x in a:
# print('efeef')
# # check loop return
# def loopfunction():
# x = 100
# while x >0:
# x -= 1
# return 100
# print(loopfunction())
# a = []
# for x in range(10):
# b = []
# for y in range(5):
# b.append(y)
# a.extend(b)
# print(a)
class myclass():
def __init__(self,qq) -> None:
self.data = 9.9
self.qq = qq
def myfun(self):
tempdata = self.data
for x in [1,2,3,4]:
print(tempdata,self.data)
tempdata -= 1
self.qq -= 1
print(self.qq)
print(id(tempdata) == id(self.data))
y = 100
mymine = myclass(y)
for x in [1,2,3]:
mymine.myfun()
print(y)
a = 100.0
b = a
print(id(a) == id(b))