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
mmaction/core/evaluation/__init__.py
jin-s13/mmaction2
47
137381
<filename>mmaction/core/evaluation/__init__.py from .accuracy import (average_precision_at_temporal_iou, average_recall_at_avg_proposals, confusion_matrix, get_weighted_score, interpolated_precision_recall, mean_average_precision, mean_class_accuracy, mmit_mean_average_precision, pairwise_temporal_iou, softmax, top_k_accuracy) from .eval_detection import ActivityNetDetection from .eval_hooks import DistEpochEvalHook, EpochEvalHook __all__ = [ 'DistEpochEvalHook', 'EpochEvalHook', 'top_k_accuracy', 'mean_class_accuracy', 'confusion_matrix', 'mean_average_precision', 'get_weighted_score', 'average_recall_at_avg_proposals', 'pairwise_temporal_iou', 'average_precision_at_temporal_iou', 'ActivityNetDetection', 'softmax', 'interpolated_precision_recall', 'mmit_mean_average_precision' ]
[ 1, 529, 9507, 29958, 29885, 655, 428, 29914, 3221, 29914, 24219, 362, 29914, 1649, 2344, 26914, 2272, 13, 3166, 869, 562, 2764, 4135, 1053, 313, 12483, 482, 29918, 17990, 2459, 29918, 271, 29918, 1356, 1971, 284, 29918, 29875, 283, 29892, 13, 462, 539, 6588, 29918, 3757, 497, 29918, 271, 29918, 485, 29887, 29918, 771, 1066, 1338, 29892, 14679, 29918, 5344, 29892, 13, 462, 539, 679, 29918, 7915, 287, 29918, 13628, 29892, 20064, 630, 29918, 17990, 2459, 29918, 3757, 497, 29892, 13, 462, 539, 2099, 29918, 12483, 482, 29918, 17990, 2459, 29892, 2099, 29918, 1990, 29918, 562, 2764, 4135, 29892, 13, 462, 539, 286, 2415, 29918, 12676, 29918, 12483, 482, 29918, 17990, 2459, 29892, 5101, 3538, 29918, 1356, 1971, 284, 29918, 29875, 283, 29892, 13, 462, 539, 4964, 3317, 29892, 2246, 29918, 29895, 29918, 562, 2764, 4135, 29897, 13, 3166, 869, 14513, 29918, 29881, 2650, 428, 1053, 13414, 6779, 29928, 2650, 428, 13, 3166, 869, 14513, 29918, 1251, 12117, 1053, 6652, 29923, 1129, 305, 29923, 791, 29950, 2550, 29892, 382, 1129, 305, 29923, 791, 29950, 2550, 13, 13, 1649, 497, 1649, 353, 518, 13, 1678, 525, 13398, 29923, 1129, 305, 29923, 791, 29950, 2550, 742, 525, 29923, 1129, 305, 29923, 791, 29950, 2550, 742, 525, 3332, 29918, 29895, 29918, 562, 2764, 4135, 742, 13, 1678, 525, 12676, 29918, 1990, 29918, 562, 2764, 4135, 742, 525, 5527, 3958, 29918, 5344, 742, 525, 12676, 29918, 12483, 482, 29918, 17990, 2459, 742, 13, 1678, 525, 657, 29918, 7915, 287, 29918, 13628, 742, 525, 12483, 482, 29918, 3757, 497, 29918, 271, 29918, 485, 29887, 29918, 771, 1066, 1338, 742, 13, 1678, 525, 18784, 3538, 29918, 1356, 1971, 284, 29918, 29875, 283, 742, 525, 12483, 482, 29918, 17990, 2459, 29918, 271, 29918, 1356, 1971, 284, 29918, 29875, 283, 742, 13, 1678, 525, 3886, 6779, 29928, 2650, 428, 742, 525, 2695, 3317, 742, 525, 1639, 3733, 630, 29918, 17990, 2459, 29918, 3757, 497, 742, 13, 1678, 525, 29885, 2415, 29918, 12676, 29918, 12483, 482, 29918, 17990, 2459, 29915, 13, 29962, 13, 2 ]
Darlington/phase-3/python challenge/day 90 solution/qtn2.py
darlcruz/python-challenge-solutions
0
52955
# program to find whether it contains an additive sequence or not. class Solution(object): # DFS: iterative implement. def is_additive_number(self, num): length = len(num) for i in range(1, int(length/2+1)): for j in range(1, int((length-i)/2 + 1)): first, second, others = num[:i], num[i:i+j], num[i+j:] if self.isValid(first, second, others): return True return False def isValid(self, first, second, others): if ((len(first) > 1 and first[0] == "0") or (len(second) > 1 and second[0] == "0")): return False sum_str = str(int(first) + int(second)) if sum_str == others: return True elif others.startswith(sum_str): return self.isValid(second, sum_str, others[len(sum_str):]) else: return False if __name__ == "__main__": print(Solution().is_additive_number('66121830')) print(Solution().is_additive_number('51123')) print(Solution().is_additive_number('235813'))
[ 1, 396, 1824, 304, 1284, 3692, 372, 3743, 385, 788, 3321, 5665, 470, 451, 29889, 13, 1990, 24380, 29898, 3318, 1125, 13, 29937, 360, 9998, 29901, 4256, 1230, 2334, 29889, 13, 1678, 822, 338, 29918, 1202, 3321, 29918, 4537, 29898, 1311, 29892, 954, 1125, 13, 4706, 3309, 353, 7431, 29898, 1949, 29897, 13, 4706, 363, 474, 297, 3464, 29898, 29896, 29892, 938, 29898, 2848, 29914, 29906, 29974, 29896, 22164, 13, 9651, 363, 432, 297, 3464, 29898, 29896, 29892, 938, 3552, 2848, 29899, 29875, 6802, 29906, 718, 29871, 29896, 22164, 13, 18884, 937, 29892, 1473, 29892, 4045, 353, 954, 7503, 29875, 1402, 954, 29961, 29875, 29901, 29875, 29974, 29926, 1402, 954, 29961, 29875, 29974, 29926, 17531, 13, 18884, 565, 1583, 29889, 275, 7211, 29898, 4102, 29892, 1473, 29892, 4045, 1125, 13, 462, 1678, 736, 5852, 13, 4706, 736, 7700, 13, 13, 1678, 822, 338, 7211, 29898, 1311, 29892, 937, 29892, 1473, 29892, 4045, 1125, 13, 4706, 565, 5135, 2435, 29898, 4102, 29897, 1405, 29871, 29896, 322, 937, 29961, 29900, 29962, 1275, 376, 29900, 1159, 470, 13, 18884, 313, 2435, 29898, 7496, 29897, 1405, 29871, 29896, 322, 1473, 29961, 29900, 29962, 1275, 376, 29900, 5783, 29901, 13, 9651, 736, 7700, 13, 4706, 2533, 29918, 710, 353, 851, 29898, 524, 29898, 4102, 29897, 718, 938, 29898, 7496, 876, 13, 4706, 565, 2533, 29918, 710, 1275, 4045, 29901, 13, 9651, 736, 5852, 13, 4706, 25342, 4045, 29889, 27382, 2541, 29898, 2083, 29918, 710, 1125, 13, 9651, 736, 1583, 29889, 275, 7211, 29898, 7496, 29892, 2533, 29918, 710, 29892, 4045, 29961, 2435, 29898, 2083, 29918, 710, 1125, 2314, 13, 4706, 1683, 29901, 13, 9651, 736, 7700, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 1596, 29898, 13296, 918, 2141, 275, 29918, 1202, 3321, 29918, 4537, 877, 29953, 29953, 29896, 29906, 29896, 29947, 29941, 29900, 8785, 13, 1678, 1596, 29898, 13296, 918, 2141, 275, 29918, 1202, 3321, 29918, 4537, 877, 29945, 29896, 29896, 29906, 29941, 8785, 13, 1678, 1596, 29898, 13296, 918, 2141, 275, 29918, 1202, 3321, 29918, 4537, 877, 29906, 29941, 29945, 29947, 29896, 29941, 8785, 13, 12, 2 ]
jmeter_api/configs/__init__.py
dashawn888/jmeter_api
11
45265
<gh_stars>10-100 from jmeter_api.configs.counter.elements import Counter from jmeter_api.configs.csv_data_set_config.elements import CsvDataSetConfig from jmeter_api.configs.http_auth_manager.elements import HTTPAuthManager from jmeter_api.configs.http_cache_manager.elements import HTTPCacheManager from jmeter_api.configs.http_cookie_manager.elements import HTTPCookieManager from jmeter_api.configs.http_header_manager.elements import HTTPHeaderManager from jmeter_api.configs.http_request_defaults.elements import HTTPRequestDefaults from jmeter_api.configs.random_csv_data_set_config.elements import RandomCsvDataSetConfig from jmeter_api.configs.random_variable.elements import RandomVariable
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 11808, 29889, 17664, 1053, 315, 5336, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 7638, 29918, 1272, 29918, 842, 29918, 2917, 29889, 17664, 1053, 315, 4501, 28449, 3991, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 1124, 29918, 5150, 29918, 12847, 29889, 17664, 1053, 7331, 6444, 3260, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 1124, 29918, 8173, 29918, 12847, 29889, 17664, 1053, 7331, 10408, 3260, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 1124, 29918, 21509, 29918, 12847, 29889, 17664, 1053, 7331, 24914, 3260, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 1124, 29918, 6672, 29918, 12847, 29889, 17664, 1053, 7331, 7850, 3260, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 1124, 29918, 3827, 29918, 4381, 29879, 29889, 17664, 1053, 7331, 3089, 24863, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 8172, 29918, 7638, 29918, 1272, 29918, 842, 29918, 2917, 29889, 17664, 1053, 16968, 29907, 4501, 28449, 3991, 13, 3166, 432, 29391, 29918, 2754, 29889, 2917, 29879, 29889, 8172, 29918, 11918, 29889, 17664, 1053, 16968, 16174, 13, 2 ]
.hypothesis/eval_source/hypothesis_temporary_module_0529b12987b897d7290f83bcbcc804e28602383d.py
keybar/keybar
4
130236
<filename>.hypothesis/eval_source/hypothesis_temporary_module_0529b12987b897d7290f83bcbcc804e28602383d.py from hypothesis.utils.conventions import not_set def accept(f): def decimals(): return f() return decimals
[ 1, 529, 9507, 15513, 29882, 1478, 720, 6656, 29914, 14513, 29918, 4993, 29914, 29882, 1478, 720, 6656, 29918, 1356, 1971, 653, 29918, 5453, 29918, 29900, 29945, 29906, 29929, 29890, 29896, 29906, 29929, 29947, 29955, 29890, 29947, 29929, 29955, 29881, 29955, 29906, 29929, 29900, 29888, 29947, 29941, 29890, 10702, 617, 29947, 29900, 29946, 29872, 29906, 29947, 29953, 29900, 29906, 29941, 29947, 29941, 29881, 29889, 2272, 13, 3166, 20051, 29889, 13239, 29889, 535, 794, 1080, 1053, 451, 29918, 842, 13, 13, 1753, 3544, 29898, 29888, 1125, 13, 1678, 822, 1602, 326, 1338, 7295, 13, 4706, 736, 285, 580, 13, 1678, 736, 1602, 326, 1338, 13, 2 ]
bb-master/sandbox/lib/python3.5/site-packages/buildbot_worker/util/_hangcheck.py
Alecto3-D/testable-greeter
2
53514
""" Protocol wrapper that will detect hung connections. In particular, since PB expects the server to talk first and HTTP expects the client to talk first, when a PB client talks to an HTTP server, neither side will talk, leading to a hung connection. This wrapper will disconnect in that case, and inform the caller. """ from __future__ import absolute_import from __future__ import print_function from twisted.internet.interfaces import IProtocol from twisted.internet.interfaces import IProtocolFactory from twisted.python.components import proxyForInterface def _noop(): pass class HangCheckProtocol( proxyForInterface(IProtocol, '_wrapped_protocol'), object, ): """ Wrap a protocol, so the underlying connection will disconnect if the other end doesn't send data within a given timeout. """ transport = None _hungConnectionTimer = None # hung connections wait for a relatively long time, since a busy master may # take a while to get back to us. _HUNG_CONNECTION_TIMEOUT = 120 def __init__(self, wrapped_protocol, hung_callback=_noop, reactor=None): """ :param IProtocol wrapped_protocol: The protocol to wrap. :param hung_callback: Called when the connection has hung. :type hung_callback: callable taking no arguments. :param IReactorTime reactor: The reactor to use to schedule the hang check. """ if reactor is None: from twisted.internet import reactor self._wrapped_protocol = wrapped_protocol self._reactor = reactor self._hung_callback = hung_callback def makeConnection(self, transport): # Note that we don't wrap the transport for the protocol, # because we only care about noticing data received, not # sent. self.transport = transport super(HangCheckProtocol, self).makeConnection(transport) self._startHungConnectionTimer() def dataReceived(self, data): self._stopHungConnectionTimer() super(HangCheckProtocol, self).dataReceived(data) def connectionLost(self, reason): self._stopHungConnectionTimer() super(HangCheckProtocol, self).connectionLost(reason) def _startHungConnectionTimer(self): """ Start a timer to detect if the connection is hung. """ def hungConnection(): self._hung_callback() self._hungConnectionTimer = None self.transport.loseConnection() self._hungConnectionTimer = self._reactor.callLater( self._HUNG_CONNECTION_TIMEOUT, hungConnection) def _stopHungConnectionTimer(self): """ Cancel the hang check timer, since we have received data or been closed. """ if self._hungConnectionTimer: self._hungConnectionTimer.cancel() self._hungConnectionTimer = None class HangCheckFactory( proxyForInterface(IProtocolFactory, '_wrapped_factory'), object, ): """ Wrap a protocol factory, so the underlying connection will disconnect if the other end doesn't send data within a given timeout. """ def __init__(self, wrapped_factory, hung_callback): """ :param IProtocolFactory wrapped_factory: The factory to wrap. :param hung_callback: Called when the connection has hung. :type hung_callback: callable taking no arguments. """ self._wrapped_factory = wrapped_factory self._hung_callback = hung_callback def buildProtocol(self, addr): protocol = self._wrapped_factory.buildProtocol(addr) return HangCheckProtocol(protocol, hung_callback=self._hung_callback) # This is used as a ClientFactory, which doesn't have a specific interface, so forward the additional methods. def startedConnecting(self, connector): self._wrapped_factory.startedConnecting(connector) def clientConnectionFailed(self, connector, reason): self._wrapped_factory.clientConnectionFailed(connector, reason) def clientConnectionLost(self, connector, reason): self._wrapped_factory.clientConnectionLost(connector, reason)
[ 1, 9995, 13, 17830, 14476, 393, 674, 6459, 18757, 12368, 29889, 13, 13, 797, 3153, 29892, 1951, 349, 29933, 23347, 278, 1923, 304, 5193, 937, 322, 7331, 13, 17854, 29879, 278, 3132, 304, 5193, 937, 29892, 746, 263, 349, 29933, 3132, 5969, 2039, 304, 385, 7331, 13, 2974, 29892, 9561, 2625, 674, 5193, 29892, 8236, 304, 263, 18757, 3957, 29889, 910, 13, 17699, 674, 766, 6915, 297, 393, 1206, 29892, 322, 1871, 278, 24959, 29889, 13, 15945, 29908, 13, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 13, 3166, 4770, 29888, 9130, 1649, 1053, 1596, 29918, 2220, 13, 13, 3166, 3252, 12652, 29889, 14168, 300, 29889, 1639, 8726, 1053, 306, 17830, 13, 3166, 3252, 12652, 29889, 14168, 300, 29889, 1639, 8726, 1053, 306, 17830, 5126, 13, 3166, 3252, 12652, 29889, 4691, 29889, 14036, 1053, 10166, 2831, 10448, 13, 13, 13, 1753, 903, 1217, 459, 7295, 13, 1678, 1209, 13, 13, 13, 1990, 379, 574, 5596, 17830, 29898, 13, 1678, 10166, 2831, 10448, 29898, 29902, 17830, 29892, 22868, 29893, 336, 2986, 29918, 20464, 5477, 1203, 29892, 13, 1125, 13, 1678, 9995, 13, 1678, 399, 2390, 263, 9608, 29892, 577, 278, 14407, 3957, 674, 766, 6915, 565, 13, 1678, 278, 916, 1095, 1838, 29915, 29873, 3638, 848, 2629, 263, 2183, 11815, 29889, 13, 1678, 9995, 13, 1678, 8608, 353, 6213, 13, 1678, 903, 18808, 5350, 14745, 353, 6213, 13, 13, 1678, 396, 18757, 12368, 4480, 363, 263, 13774, 1472, 931, 29892, 1951, 263, 19587, 5835, 1122, 13, 1678, 396, 2125, 263, 1550, 304, 679, 1250, 304, 502, 29889, 13, 1678, 903, 29950, 3904, 29954, 29918, 6007, 8186, 9838, 29918, 15307, 12015, 353, 29871, 29896, 29906, 29900, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 21021, 29918, 20464, 29892, 18757, 29918, 14035, 29922, 29918, 1217, 459, 29892, 337, 7168, 29922, 8516, 1125, 13, 4706, 9995, 13, 4706, 584, 3207, 306, 17830, 21021, 29918, 20464, 29901, 450, 9608, 304, 12244, 29889, 13, 4706, 584, 3207, 18757, 29918, 14035, 29901, 3037, 839, 746, 278, 3957, 756, 18757, 29889, 13, 4706, 584, 1853, 18757, 29918, 14035, 29901, 1246, 519, 5622, 694, 6273, 29889, 13, 4706, 584, 3207, 306, 1123, 7168, 2481, 337, 7168, 29901, 450, 337, 7168, 304, 671, 304, 20410, 13, 9651, 278, 13958, 1423, 29889, 13, 4706, 9995, 13, 4706, 565, 337, 7168, 338, 6213, 29901, 13, 9651, 515, 3252, 12652, 29889, 14168, 300, 1053, 337, 7168, 13, 4706, 1583, 3032, 29893, 336, 2986, 29918, 20464, 353, 21021, 29918, 20464, 13, 4706, 1583, 3032, 276, 7168, 353, 337, 7168, 13, 4706, 1583, 3032, 18808, 29918, 14035, 353, 18757, 29918, 14035, 13, 13, 1678, 822, 1207, 5350, 29898, 1311, 29892, 8608, 1125, 13, 4706, 396, 3940, 393, 591, 1016, 29915, 29873, 12244, 278, 8608, 363, 278, 9608, 29892, 13, 4706, 396, 1363, 591, 871, 2562, 1048, 451, 18499, 848, 4520, 29892, 451, 13, 4706, 396, 2665, 29889, 13, 4706, 1583, 29889, 27882, 353, 8608, 13, 4706, 2428, 29898, 29950, 574, 5596, 17830, 29892, 1583, 467, 5675, 5350, 29898, 27882, 29897, 13, 4706, 1583, 3032, 2962, 29950, 686, 5350, 14745, 580, 13, 13, 1678, 822, 848, 29816, 29898, 1311, 29892, 848, 1125, 13, 4706, 1583, 3032, 9847, 29950, 686, 5350, 14745, 580, 13, 4706, 2428, 29898, 29950, 574, 5596, 17830, 29892, 1583, 467, 1272, 29816, 29898, 1272, 29897, 13, 13, 1678, 822, 3957, 29931, 520, 29898, 1311, 29892, 2769, 1125, 13, 4706, 1583, 3032, 9847, 29950, 686, 5350, 14745, 580, 13, 4706, 2428, 29898, 29950, 574, 5596, 17830, 29892, 1583, 467, 9965, 29931, 520, 29898, 23147, 29897, 13, 13, 1678, 822, 903, 2962, 29950, 686, 5350, 14745, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 7370, 263, 12237, 304, 6459, 565, 278, 3957, 338, 18757, 29889, 13, 4706, 9995, 13, 4706, 822, 18757, 5350, 7295, 13, 9651, 1583, 3032, 18808, 29918, 14035, 580, 13, 9651, 1583, 3032, 18808, 5350, 14745, 353, 6213, 13, 9651, 1583, 29889, 27882, 29889, 2226, 5350, 580, 13, 4706, 1583, 3032, 18808, 5350, 14745, 353, 1583, 3032, 276, 7168, 29889, 4804, 29931, 1008, 29898, 13, 9651, 1583, 3032, 29950, 3904, 29954, 29918, 6007, 8186, 9838, 29918, 15307, 12015, 29892, 18757, 5350, 29897, 13, 13, 1678, 822, 903, 9847, 29950, 686, 5350, 14745, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 1815, 2242, 278, 13958, 1423, 12237, 29892, 1951, 591, 505, 4520, 848, 470, 13, 4706, 1063, 5764, 29889, 13, 4706, 9995, 13, 4706, 565, 1583, 3032, 18808, 5350, 14745, 29901, 13, 9651, 1583, 3032, 18808, 5350, 14745, 29889, 20713, 580, 13, 4706, 1583, 3032, 18808, 5350, 14745, 353, 6213, 13, 13, 13, 1990, 379, 574, 5596, 5126, 29898, 13, 1678, 10166, 2831, 10448, 29898, 29902, 17830, 5126, 29892, 22868, 29893, 336, 2986, 29918, 14399, 5477, 1203, 29892, 13, 1125, 13, 1678, 9995, 13, 1678, 399, 2390, 263, 9608, 12529, 29892, 577, 278, 14407, 3957, 674, 13, 1678, 766, 6915, 565, 278, 916, 1095, 1838, 29915, 29873, 3638, 848, 2629, 263, 2183, 13, 1678, 11815, 29889, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 21021, 29918, 14399, 29892, 18757, 29918, 14035, 1125, 13, 4706, 9995, 13, 4706, 584, 3207, 306, 17830, 5126, 21021, 29918, 14399, 29901, 450, 12529, 304, 12244, 29889, 13, 4706, 584, 3207, 18757, 29918, 14035, 29901, 3037, 839, 746, 278, 3957, 756, 18757, 29889, 13, 4706, 584, 1853, 18757, 29918, 14035, 29901, 1246, 519, 5622, 694, 6273, 29889, 13, 4706, 9995, 13, 4706, 1583, 3032, 29893, 336, 2986, 29918, 14399, 353, 21021, 29918, 14399, 13, 4706, 1583, 3032, 18808, 29918, 14035, 353, 18757, 29918, 14035, 13, 13, 1678, 822, 2048, 17830, 29898, 1311, 29892, 28915, 1125, 13, 4706, 9608, 353, 1583, 3032, 29893, 336, 2986, 29918, 14399, 29889, 4282, 17830, 29898, 10030, 29897, 13, 4706, 736, 379, 574, 5596, 17830, 29898, 20464, 29892, 18757, 29918, 14035, 29922, 1311, 3032, 18808, 29918, 14035, 29897, 13, 13, 1678, 396, 910, 338, 1304, 408, 263, 12477, 5126, 29892, 607, 1838, 29915, 29873, 505, 263, 2702, 5067, 29892, 577, 6375, 278, 5684, 3519, 29889, 13, 13, 1678, 822, 4687, 17918, 292, 29898, 1311, 29892, 1826, 2801, 1125, 13, 4706, 1583, 3032, 29893, 336, 2986, 29918, 14399, 29889, 2962, 287, 17918, 292, 29898, 11958, 2801, 29897, 13, 13, 1678, 822, 3132, 5350, 17776, 29898, 1311, 29892, 1826, 2801, 29892, 2769, 1125, 13, 4706, 1583, 3032, 29893, 336, 2986, 29918, 14399, 29889, 4645, 5350, 17776, 29898, 11958, 2801, 29892, 2769, 29897, 13, 13, 1678, 822, 3132, 5350, 29931, 520, 29898, 1311, 29892, 1826, 2801, 29892, 2769, 1125, 13, 4706, 1583, 3032, 29893, 336, 2986, 29918, 14399, 29889, 4645, 5350, 29931, 520, 29898, 11958, 2801, 29892, 2769, 29897, 13, 2 ]
tests/test_codebase/test_mmpose/test_pose_detection.py
grimoire/mmdeploy
746
1616176
<filename>tests/test_codebase/test_mmpose/test_pose_detection.py<gh_stars>100-1000 # Copyright (c) OpenMMLab. All rights reserved. import os from tempfile import NamedTemporaryFile, TemporaryDirectory import mmcv import numpy as np import pytest import torch import mmdeploy.backend.onnxruntime as ort_apis from mmdeploy.apis import build_task_processor from mmdeploy.codebase import import_codebase from mmdeploy.utils import Backend, Codebase, Task, load_config from mmdeploy.utils.test import DummyModel, SwitchBackendWrapper try: import_codebase(Codebase.MMPOSE) except ImportError: pytest.skip( f'{Codebase.MMPOSE.value} is not installed.', allow_module_level=True) model_cfg_path = 'tests/test_codebase/test_mmpose/data/model.py' model_cfg = load_config(model_cfg_path)[0] deploy_cfg = mmcv.Config( dict( backend_config=dict(type='onnxruntime'), codebase_config=dict(type='mmpose', task='PoseDetection'), onnx_config=dict( type='onnx', export_params=True, keep_initializers_as_inputs=False, opset_version=11, save_file='end2end.onnx', input_names=['input'], output_names=['output'], input_shape=None))) onnx_file = NamedTemporaryFile(suffix='.onnx').name task_processor = build_task_processor(model_cfg, deploy_cfg, 'cpu') img_shape = (192, 256) heatmap_shape = (48, 64) # mmpose.apis.inference.LoadImage uses opencv, needs float32 in # cv2.cvtColor. img = np.random.rand(*img_shape, 3).astype(np.float32) num_output_channels = model_cfg['data_cfg']['num_output_channels'] def test_create_input(): deploy_cfg = mmcv.Config( dict( backend_config=dict(type=Backend.ONNXRUNTIME.value), codebase_config=dict( type=Codebase.MMPOSE.value, task=Task.POSE_DETECTION.value), onnx_config=dict( type='onnx', export_params=True, keep_initializers_as_inputs=False, opset_version=11, save_file='end2end.onnx', input_names=['input'], output_names=['output'], input_shape=None))) task_processor = build_task_processor(model_cfg, deploy_cfg, 'cpu') inputs = task_processor.create_input(img, input_shape=img_shape) assert isinstance(inputs, tuple) and len(inputs) == 2 def test_init_pytorch_model(): from mmpose.models.detectors.base import BasePose model = task_processor.init_pytorch_model(None) assert isinstance(model, BasePose) @pytest.fixture def backend_model(): from mmdeploy.backend.onnxruntime import ORTWrapper ort_apis.__dict__.update({'ORTWrapper': ORTWrapper}) wrapper = SwitchBackendWrapper(ORTWrapper) wrapper.set(outputs={ 'output': torch.rand(1, num_output_channels, *heatmap_shape), }) yield task_processor.init_backend_model(['']) wrapper.recover() def test_init_backend_model(backend_model): assert isinstance(backend_model, torch.nn.Module) def test_run_inference(backend_model): input_dict, _ = task_processor.create_input(img, input_shape=img_shape) results = task_processor.run_inference(backend_model, input_dict) assert results is not None def test_visualize(backend_model): input_dict, _ = task_processor.create_input(img, input_shape=img_shape) results = task_processor.run_inference(backend_model, input_dict) with TemporaryDirectory() as dir: filename = dir + 'tmp.jpg' task_processor.visualize(backend_model, img, results[0], filename, '') assert os.path.exists(filename) def test_get_tensor_from_input(): input_data = {'img': torch.ones(3, 4, 5)} inputs = task_processor.get_tensor_from_input(input_data) assert torch.equal(inputs, torch.ones(3, 4, 5)) def test_get_partition_cfg(): try: _ = task_processor.get_partition_cfg(partition_type='') except NotImplementedError: pass def test_get_model_name(): model_name = task_processor.get_model_name() assert isinstance(model_name, str) and model_name is not None def test_build_dataset_and_dataloader(): from torch.utils.data import DataLoader, Dataset dataset = task_processor.build_dataset( dataset_cfg=model_cfg, dataset_type='test') assert isinstance(dataset, Dataset), 'Failed to build dataset' dataloader = task_processor.build_dataloader(dataset, 1, 1) assert isinstance(dataloader, DataLoader), 'Failed to build dataloader' def test_single_gpu_test_and_evaluate(): from mmcv.parallel import MMDataParallel dataset = task_processor.build_dataset( dataset_cfg=model_cfg, dataset_type='test') dataloader = task_processor.build_dataloader(dataset, 1, 1) # Prepare dummy model model = DummyModel(outputs=[torch.rand([1, 1000])]) model = MMDataParallel(model, device_ids=[0]) assert model is not None # Run test outputs = task_processor.single_gpu_test(model, dataloader) assert outputs is not None task_processor.evaluate_outputs(model_cfg, outputs, dataset)
[ 1, 529, 9507, 29958, 21150, 29914, 1688, 29918, 401, 3188, 29914, 1688, 29918, 29885, 1526, 852, 29914, 1688, 29918, 4220, 29918, 29881, 2650, 428, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29900, 29899, 29896, 29900, 29900, 29900, 13, 29937, 14187, 1266, 313, 29883, 29897, 4673, 29924, 1988, 370, 29889, 2178, 10462, 21676, 29889, 13, 5215, 2897, 13, 3166, 5694, 1445, 1053, 405, 2795, 5776, 1971, 653, 2283, 29892, 6789, 1971, 653, 9882, 13, 13, 5215, 5654, 11023, 13, 5215, 12655, 408, 7442, 13, 5215, 11451, 1688, 13, 5215, 4842, 305, 13, 13, 5215, 5654, 16519, 29889, 27852, 29889, 3409, 29916, 15634, 408, 20289, 29918, 11355, 13, 3166, 5654, 16519, 29889, 11355, 1053, 2048, 29918, 7662, 29918, 26482, 13, 3166, 5654, 16519, 29889, 401, 3188, 1053, 1053, 29918, 401, 3188, 13, 3166, 5654, 16519, 29889, 13239, 1053, 7437, 355, 29892, 5920, 3188, 29892, 9330, 29892, 2254, 29918, 2917, 13, 3166, 5654, 16519, 29889, 13239, 29889, 1688, 1053, 360, 11770, 3195, 29892, 28176, 5841, 355, 15646, 13, 13, 2202, 29901, 13, 1678, 1053, 29918, 401, 3188, 29898, 3399, 3188, 29889, 29924, 3580, 29949, 1660, 29897, 13, 19499, 16032, 2392, 29901, 13, 1678, 11451, 1688, 29889, 11014, 29898, 13, 4706, 285, 29915, 29912, 3399, 3188, 29889, 29924, 3580, 29949, 1660, 29889, 1767, 29913, 338, 451, 5130, 29889, 742, 2758, 29918, 5453, 29918, 5563, 29922, 5574, 29897, 13, 13, 4299, 29918, 16859, 29918, 2084, 353, 525, 21150, 29914, 1688, 29918, 401, 3188, 29914, 1688, 29918, 29885, 1526, 852, 29914, 1272, 29914, 4299, 29889, 2272, 29915, 13, 4299, 29918, 16859, 353, 2254, 29918, 2917, 29898, 4299, 29918, 16859, 29918, 2084, 9601, 29900, 29962, 13, 16519, 29918, 16859, 353, 5654, 11023, 29889, 3991, 29898, 13, 1678, 9657, 29898, 13, 4706, 14998, 29918, 2917, 29922, 8977, 29898, 1853, 2433, 3409, 29916, 15634, 5477, 13, 4706, 775, 3188, 29918, 2917, 29922, 8977, 29898, 1853, 2433, 29885, 1526, 852, 742, 3414, 2433, 29925, 852, 29928, 2650, 428, 5477, 13, 4706, 373, 23818, 29918, 2917, 29922, 8977, 29898, 13, 9651, 1134, 2433, 3409, 29916, 742, 13, 9651, 5609, 29918, 7529, 29922, 5574, 29892, 13, 9651, 3013, 29918, 11228, 19427, 29918, 294, 29918, 2080, 29879, 29922, 8824, 29892, 13, 9651, 288, 567, 300, 29918, 3259, 29922, 29896, 29896, 29892, 13, 9651, 4078, 29918, 1445, 2433, 355, 29906, 355, 29889, 3409, 29916, 742, 13, 9651, 1881, 29918, 7039, 29922, 1839, 2080, 7464, 13, 9651, 1962, 29918, 7039, 29922, 1839, 4905, 7464, 13, 9651, 1881, 29918, 12181, 29922, 8516, 4961, 13, 13, 3409, 29916, 29918, 1445, 353, 405, 2795, 5776, 1971, 653, 2283, 29898, 2146, 600, 861, 2433, 29889, 3409, 29916, 2824, 978, 13, 7662, 29918, 26482, 353, 2048, 29918, 7662, 29918, 26482, 29898, 4299, 29918, 16859, 29892, 7246, 29918, 16859, 29892, 525, 21970, 1495, 13, 2492, 29918, 12181, 353, 313, 29896, 29929, 29906, 29892, 29871, 29906, 29945, 29953, 29897, 13, 354, 271, 1958, 29918, 12181, 353, 313, 29946, 29947, 29892, 29871, 29953, 29946, 29897, 13, 29937, 286, 1526, 852, 29889, 11355, 29889, 262, 1659, 29889, 5896, 2940, 3913, 1722, 11023, 29892, 4225, 5785, 29941, 29906, 297, 13, 29937, 13850, 29906, 29889, 11023, 29873, 3306, 29889, 13, 2492, 353, 7442, 29889, 8172, 29889, 9502, 10456, 2492, 29918, 12181, 29892, 29871, 29941, 467, 579, 668, 29898, 9302, 29889, 7411, 29941, 29906, 29897, 13, 1949, 29918, 4905, 29918, 305, 12629, 353, 1904, 29918, 16859, 1839, 1272, 29918, 16859, 16215, 1949, 29918, 4905, 29918, 305, 12629, 2033, 13, 13, 13, 1753, 1243, 29918, 3258, 29918, 2080, 7295, 13, 1678, 7246, 29918, 16859, 353, 5654, 11023, 29889, 3991, 29898, 13, 4706, 9657, 29898, 13, 9651, 14998, 29918, 2917, 29922, 8977, 29898, 1853, 29922, 5841, 355, 29889, 1164, 29940, 29990, 29934, 10356, 8890, 29889, 1767, 511, 13, 9651, 775, 3188, 29918, 2917, 29922, 8977, 29898, 13, 18884, 1134, 29922, 3399, 3188, 29889, 29924, 3580, 29949, 1660, 29889, 1767, 29892, 3414, 29922, 5398, 29889, 13152, 1660, 29918, 2287, 4330, 9838, 29889, 1767, 511, 13, 9651, 373, 23818, 29918, 2917, 29922, 8977, 29898, 13, 18884, 1134, 2433, 3409, 29916, 742, 13, 18884, 5609, 29918, 7529, 29922, 5574, 29892, 13, 18884, 3013, 29918, 11228, 19427, 29918, 294, 29918, 2080, 29879, 29922, 8824, 29892, 13, 18884, 288, 567, 300, 29918, 3259, 29922, 29896, 29896, 29892, 13, 18884, 4078, 29918, 1445, 2433, 355, 29906, 355, 29889, 3409, 29916, 742, 13, 18884, 1881, 29918, 7039, 29922, 1839, 2080, 7464, 13, 18884, 1962, 29918, 7039, 29922, 1839, 4905, 7464, 13, 18884, 1881, 29918, 12181, 29922, 8516, 4961, 13, 1678, 3414, 29918, 26482, 353, 2048, 29918, 7662, 29918, 26482, 29898, 4299, 29918, 16859, 29892, 7246, 29918, 16859, 29892, 525, 21970, 1495, 13, 1678, 10970, 353, 3414, 29918, 26482, 29889, 3258, 29918, 2080, 29898, 2492, 29892, 1881, 29918, 12181, 29922, 2492, 29918, 12181, 29897, 13, 1678, 4974, 338, 8758, 29898, 2080, 29879, 29892, 18761, 29897, 322, 7431, 29898, 2080, 29879, 29897, 1275, 29871, 29906, 13, 13, 13, 1753, 1243, 29918, 2344, 29918, 2272, 7345, 305, 29918, 4299, 7295, 13, 1678, 515, 286, 1526, 852, 29889, 9794, 29889, 4801, 11142, 29889, 3188, 1053, 7399, 29925, 852, 13, 1678, 1904, 353, 3414, 29918, 26482, 29889, 2344, 29918, 2272, 7345, 305, 29918, 4299, 29898, 8516, 29897, 13, 1678, 4974, 338, 8758, 29898, 4299, 29892, 7399, 29925, 852, 29897, 13, 13, 13, 29992, 2272, 1688, 29889, 7241, 15546, 13, 1753, 14998, 29918, 4299, 7295, 13, 1678, 515, 5654, 16519, 29889, 27852, 29889, 3409, 29916, 15634, 1053, 6323, 29911, 15646, 13, 1678, 20289, 29918, 11355, 17255, 8977, 26914, 5504, 3319, 29915, 8476, 15646, 2396, 6323, 29911, 15646, 1800, 13, 1678, 14476, 353, 28176, 5841, 355, 15646, 29898, 8476, 15646, 29897, 13, 1678, 14476, 29889, 842, 29898, 4905, 29879, 3790, 13, 4706, 525, 4905, 2396, 4842, 305, 29889, 9502, 29898, 29896, 29892, 954, 29918, 4905, 29918, 305, 12629, 29892, 334, 354, 271, 1958, 29918, 12181, 511, 13, 1678, 5615, 13, 13, 1678, 7709, 3414, 29918, 26482, 29889, 2344, 29918, 27852, 29918, 4299, 18959, 11287, 13, 13, 1678, 14476, 29889, 3757, 957, 580, 13, 13, 13, 1753, 1243, 29918, 2344, 29918, 27852, 29918, 4299, 29898, 27852, 29918, 4299, 1125, 13, 1678, 4974, 338, 8758, 29898, 27852, 29918, 4299, 29892, 4842, 305, 29889, 15755, 29889, 7355, 29897, 13, 13, 13, 1753, 1243, 29918, 3389, 29918, 262, 1659, 29898, 27852, 29918, 4299, 1125, 13, 1678, 1881, 29918, 8977, 29892, 903, 353, 3414, 29918, 26482, 29889, 3258, 29918, 2080, 29898, 2492, 29892, 1881, 29918, 12181, 29922, 2492, 29918, 12181, 29897, 13, 1678, 2582, 353, 3414, 29918, 26482, 29889, 3389, 29918, 262, 1659, 29898, 27852, 29918, 4299, 29892, 1881, 29918, 8977, 29897, 13, 1678, 4974, 2582, 338, 451, 6213, 13, 13, 13, 1753, 1243, 29918, 20119, 675, 29898, 27852, 29918, 4299, 1125, 13, 1678, 1881, 29918, 8977, 29892, 903, 353, 3414, 29918, 26482, 29889, 3258, 29918, 2080, 29898, 2492, 29892, 1881, 29918, 12181, 29922, 2492, 29918, 12181, 29897, 13, 1678, 2582, 353, 3414, 29918, 26482, 29889, 3389, 29918, 262, 1659, 29898, 27852, 29918, 4299, 29892, 1881, 29918, 8977, 29897, 13, 1678, 411, 6789, 1971, 653, 9882, 580, 408, 4516, 29901, 13, 4706, 10422, 353, 4516, 718, 525, 7050, 29889, 6173, 29915, 13, 4706, 3414, 29918, 26482, 29889, 20119, 675, 29898, 27852, 29918, 4299, 29892, 10153, 29892, 2582, 29961, 29900, 1402, 10422, 29892, 27255, 13, 4706, 4974, 2897, 29889, 2084, 29889, 9933, 29898, 9507, 29897, 13, 13, 13, 1753, 1243, 29918, 657, 29918, 20158, 29918, 3166, 29918, 2080, 7295, 13, 1678, 1881, 29918, 1272, 353, 11117, 2492, 2396, 4842, 305, 29889, 2873, 29898, 29941, 29892, 29871, 29946, 29892, 29871, 29945, 2915, 13, 1678, 10970, 353, 3414, 29918, 26482, 29889, 657, 29918, 20158, 29918, 3166, 29918, 2080, 29898, 2080, 29918, 1272, 29897, 13, 1678, 4974, 4842, 305, 29889, 11745, 29898, 2080, 29879, 29892, 4842, 305, 29889, 2873, 29898, 29941, 29892, 29871, 29946, 29892, 29871, 29945, 876, 13, 13, 13, 1753, 1243, 29918, 657, 29918, 16707, 29918, 16859, 7295, 13, 1678, 1018, 29901, 13, 4706, 903, 353, 3414, 29918, 26482, 29889, 657, 29918, 16707, 29918, 16859, 29898, 16707, 29918, 1853, 2433, 1495, 13, 1678, 5174, 2216, 1888, 2037, 287, 2392, 29901, 13, 4706, 1209, 13, 13, 13, 1753, 1243, 29918, 657, 29918, 4299, 29918, 978, 7295, 13, 1678, 1904, 29918, 978, 353, 3414, 29918, 26482, 29889, 657, 29918, 4299, 29918, 978, 580, 13, 1678, 4974, 338, 8758, 29898, 4299, 29918, 978, 29892, 851, 29897, 322, 1904, 29918, 978, 338, 451, 6213, 13, 13, 13, 1753, 1243, 29918, 4282, 29918, 24713, 29918, 392, 29918, 29881, 2075, 29877, 1664, 7295, 13, 1678, 515, 4842, 305, 29889, 13239, 29889, 1272, 1053, 3630, 10036, 29892, 13373, 24541, 13, 1678, 8783, 353, 3414, 29918, 26482, 29889, 4282, 29918, 24713, 29898, 13, 4706, 8783, 29918, 16859, 29922, 4299, 29918, 16859, 29892, 8783, 29918, 1853, 2433, 1688, 1495, 13, 1678, 4974, 338, 8758, 29898, 24713, 29892, 13373, 24541, 511, 525, 17776, 304, 2048, 8783, 29915, 13, 1678, 1418, 7003, 1664, 353, 3414, 29918, 26482, 29889, 4282, 29918, 29881, 2075, 29877, 1664, 29898, 24713, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 1678, 4974, 338, 8758, 29898, 29881, 2075, 29877, 1664, 29892, 3630, 10036, 511, 525, 17776, 304, 2048, 1418, 7003, 1664, 29915, 13, 13, 13, 1753, 1243, 29918, 14369, 29918, 29887, 3746, 29918, 1688, 29918, 392, 29918, 24219, 403, 7295, 13, 1678, 515, 5654, 11023, 29889, 23482, 1053, 28880, 1469, 2177, 6553, 13, 1678, 8783, 353, 3414, 29918, 26482, 29889, 4282, 29918, 24713, 29898, 13, 4706, 8783, 29918, 16859, 29922, 4299, 29918, 16859, 29892, 8783, 29918, 1853, 2433, 1688, 1495, 13, 1678, 1418, 7003, 1664, 353, 3414, 29918, 26482, 29889, 4282, 29918, 29881, 2075, 29877, 1664, 29898, 24713, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 13, 1678, 396, 349, 3445, 598, 20254, 1904, 13, 1678, 1904, 353, 360, 11770, 3195, 29898, 4905, 29879, 11759, 7345, 305, 29889, 9502, 4197, 29896, 29892, 29871, 29896, 29900, 29900, 29900, 2314, 2314, 13, 1678, 1904, 353, 28880, 1469, 2177, 6553, 29898, 4299, 29892, 4742, 29918, 4841, 11759, 29900, 2314, 13, 1678, 4974, 1904, 338, 451, 6213, 13, 1678, 396, 7525, 1243, 13, 1678, 14391, 353, 3414, 29918, 26482, 29889, 14369, 29918, 29887, 3746, 29918, 1688, 29898, 4299, 29892, 1418, 7003, 1664, 29897, 13, 1678, 4974, 14391, 338, 451, 6213, 13, 1678, 3414, 29918, 26482, 29889, 24219, 403, 29918, 4905, 29879, 29898, 4299, 29918, 16859, 29892, 14391, 29892, 8783, 29897, 13, 2 ]
trade/admin.py
dc74089/oneshirt
0
48569
from django.contrib import admin from .models import * # Register your models here. admin.site.register(OneshirtUser) admin.site.register(Item) admin.site.register(Trade) admin.site.register(PasswordResetRequest)
[ 1, 515, 9557, 29889, 21570, 1053, 4113, 13, 13, 3166, 869, 9794, 1053, 334, 13, 13, 29937, 12577, 596, 4733, 1244, 29889, 13, 6406, 29889, 2746, 29889, 9573, 29898, 2951, 12094, 2728, 2659, 29897, 13, 6406, 29889, 2746, 29889, 9573, 29898, 2001, 29897, 13, 6406, 29889, 2746, 29889, 9573, 29898, 5323, 311, 29897, 13, 6406, 29889, 2746, 29889, 9573, 29898, 10048, 27175, 3089, 29897, 13, 2 ]
app/backend/knowledge_base_approach/python-client/swagger_client/api/default_api.py
e-lubrini/fake-news-detector
0
22282
<gh_stars>0 # coding: utf-8 """ FRED API FRED is a tool for automatically producing RDF/OWL ontologies and linked data from natural language sentences. The method is based on Combinatory Categorial Grammar, Discourse Representation Theory, Linguistic Frames, and Ontology Design Patterns. Results are enriched with NER and WSD. # noqa: E501 OpenAPI spec version: v1 Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import absolute_import import re # noqa: F401 # python 2 and python 3 compatibility library import six from swagger_client.api_client import ApiClient class DefaultApi(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. Ref: https://github.com/swagger-api/swagger-codegen """ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client def stlab_tools_fred_get(self, authorization, text, **kwargs): # noqa: E501 """stlab_tools_fred_get # noqa: E501 Generate RDF from natural language text. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.stlab_tools_fred_get(authorization, text, async_req=True) >>> result = thread.get() :param async_req bool :param str authorization: The authorization bearear. Type \"Bearer xxx-yyy-zzz\", where is your secret token. (required) :param str text: The input natural language text. (required) :param str prefix: The prefix used for the namespace of terms introduced by FRED in the output. If not specified fred: is used as default. :param str namespace: The namespace used for the terms introduced by FRED in the output. If not specified http://www.ontologydesignpatterns.org/ont/fred/domain.owl# is used as default. :param bool wsd: Perform Word Sense Disambiguation on input terms. By default it is set to false. :param bool wfd: Perform Word Frame Disambiguation on input terms in order to provide alignments to WordNet synsets, WordNet Super-senses and Dolce classes. By default it is set to false. :param str wfd_profile: The profile associated with the Word Frame Disambiguation :param bool tense: Include temporal relations between events according to their grammatical tense. By default it is set to false. :param bool roles: Use FrameNet roles into the resulting ontology. By default it is set to false. :param str textannotation: The vocabulary used for annotating the text in RDF. Two possible alternatives are available, i.e. EARMARK and NIF. :param bool semantic_subgraph: Generate a RDF which only expresses the semantics of a sentence without additional RDF triples, such as those containing text spans, part-of-speeches, etc. By default it is set to false. :return: None If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.stlab_tools_fred_get_with_http_info(authorization, text, **kwargs) # noqa: E501 else: (data) = self.stlab_tools_fred_get_with_http_info(authorization, text, **kwargs) # noqa: E501 return data def stlab_tools_fred_get_with_http_info(self, authorization, text, **kwargs): # noqa: E501 """stlab_tools_fred_get # noqa: E501 Generate RDF from natural language text. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.stlab_tools_fred_get_with_http_info(authorization, text, async_req=True) >>> result = thread.get() :param async_req bool :param str authorization: The authorization bearear. Type \"Bearer xxx-yyy-zzz\", where is your secret token. (required) :param str text: The input natural language text. (required) :param str prefix: The prefix used for the namespace of terms introduced by FRED in the output. If not specified fred: is used as default. :param str namespace: The namespace used for the terms introduced by FRED in the output. If not specified http://www.ontologydesignpatterns.org/ont/fred/domain.owl# is used as default. :param bool wsd: Perform Word Sense Disambiguation on input terms. By default it is set to false. :param bool wfd: Perform Word Frame Disambiguation on input terms in order to provide alignments to WordNet synsets, WordNet Super-senses and Dolce classes. By default it is set to false. :param str wfd_profile: The profile associated with the Word Frame Disambiguation :param bool tense: Include temporal relations between events according to their grammatical tense. By default it is set to false. :param bool roles: Use FrameNet roles into the resulting ontology. By default it is set to false. :param str textannotation: The vocabulary used for annotating the text in RDF. Two possible alternatives are available, i.e. EARMARK and NIF. :param bool semantic_subgraph: Generate a RDF which only expresses the semantics of a sentence without additional RDF triples, such as those containing text spans, part-of-speeches, etc. By default it is set to false. :return: None If the method is called asynchronously, returns the request thread. """ all_params = ['authorization', 'text', 'prefix', 'namespace', 'wsd', 'wfd', 'wfd_profile', 'tense', 'roles', 'textannotation', 'semantic_subgraph'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in six.iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method stlab_tools_fred_get" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'authorization' is set if self.api_client.client_side_validation and ('authorization' not in params or params['authorization'] is None): # noqa: E501 raise ValueError("Missing the required parameter `authorization` when calling `stlab_tools_fred_get`") # noqa: E501 # verify the required parameter 'text' is set if self.api_client.client_side_validation and ('text' not in params or params['text'] is None): # noqa: E501 raise ValueError("Missing the required parameter `text` when calling `stlab_tools_fred_get`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'text' in params: query_params.append(('text', params['text'])) # noqa: E501 if 'prefix' in params: query_params.append(('prefix', params['prefix'])) # noqa: E501 if 'namespace' in params: query_params.append(('namespace', params['namespace'])) # noqa: E501 if 'wsd' in params: query_params.append(('wsd', params['wsd'])) # noqa: E501 if 'wfd' in params: query_params.append(('wfd', params['wfd'])) # noqa: E501 if 'wfd_profile' in params: query_params.append(('wfd_profile', params['wfd_profile'])) # noqa: E501 if 'tense' in params: query_params.append(('tense', params['tense'])) # noqa: E501 if 'roles' in params: query_params.append(('roles', params['roles'])) # noqa: E501 if 'textannotation' in params: query_params.append(('textannotation', params['textannotation'])) # noqa: E501 if 'semantic_subgraph' in params: query_params.append(('semantic-subgraph', params['semantic_subgraph'])) # noqa: E501 header_params = {} if 'authorization' in params: header_params['Authorization'] = params['authorization'] # noqa: E501 form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/rdf+xml', 'text/turtle', 'application/rdf+json', 'text/rdf+n3', 'text/rdf+nt', 'image/png']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/stlab-tools/fred', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 14137, 29901, 23616, 29899, 29947, 13, 13, 15945, 29908, 13, 1678, 383, 19386, 3450, 13, 13, 1678, 383, 19386, 338, 263, 5780, 363, 6336, 20811, 390, 4037, 29914, 9806, 29931, 4625, 11763, 322, 9024, 848, 515, 5613, 4086, 25260, 29889, 450, 1158, 338, 2729, 373, 422, 2109, 7606, 315, 1845, 9020, 16878, 3034, 29892, 8565, 10242, 16314, 362, 24134, 29892, 365, 6202, 4695, 4693, 1280, 29892, 322, 18265, 3002, 12037, 25860, 29879, 29889, 17212, 526, 427, 4018, 287, 411, 405, 1001, 322, 399, 7230, 29889, 259, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 1678, 4673, 8787, 1580, 1873, 29901, 325, 29896, 13, 268, 13, 1678, 3251, 630, 491, 29901, 2045, 597, 3292, 29889, 510, 29914, 2774, 9921, 29899, 2754, 29914, 2774, 9921, 29899, 401, 1885, 29889, 5559, 13, 15945, 29908, 13, 13, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 13, 13, 5215, 337, 29871, 396, 694, 25621, 29901, 383, 29946, 29900, 29896, 13, 13, 29937, 3017, 29871, 29906, 322, 3017, 29871, 29941, 24521, 3489, 13, 5215, 4832, 13, 13, 3166, 2381, 9921, 29918, 4645, 29889, 2754, 29918, 4645, 1053, 29749, 4032, 13, 13, 13, 1990, 13109, 11713, 29898, 3318, 1125, 13, 1678, 9995, 12256, 29923, 29901, 910, 770, 338, 4469, 5759, 491, 278, 2381, 9921, 775, 15299, 1824, 29889, 13, 13, 1678, 1938, 451, 3863, 278, 770, 7522, 29889, 13, 1678, 9897, 29901, 2045, 597, 3292, 29889, 510, 29914, 2774, 9921, 29899, 2754, 29914, 2774, 9921, 29899, 401, 1885, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 7882, 29918, 4645, 29922, 8516, 1125, 13, 4706, 565, 7882, 29918, 4645, 338, 6213, 29901, 13, 9651, 7882, 29918, 4645, 353, 29749, 4032, 580, 13, 4706, 1583, 29889, 2754, 29918, 4645, 353, 7882, 29918, 4645, 13, 13, 1678, 822, 380, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29898, 1311, 29892, 28733, 29892, 1426, 29892, 3579, 19290, 1125, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 9995, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 3251, 403, 390, 4037, 515, 5613, 4086, 1426, 29889, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 910, 1158, 3732, 263, 12231, 681, 7331, 2009, 491, 2322, 29889, 1763, 1207, 385, 13, 4706, 20489, 7331, 2009, 29892, 3113, 1209, 7465, 29918, 7971, 29922, 5574, 13, 4706, 8653, 3244, 353, 7882, 29889, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29898, 8921, 2133, 29892, 1426, 29892, 7465, 29918, 7971, 29922, 5574, 29897, 13, 4706, 8653, 1121, 353, 3244, 29889, 657, 580, 13, 13, 4706, 584, 3207, 7465, 29918, 7971, 6120, 13, 4706, 584, 3207, 851, 28733, 29901, 450, 28733, 367, 598, 279, 29889, 5167, 13218, 29933, 799, 261, 921, 4419, 29899, 8071, 29891, 29899, 5617, 29920, 23370, 988, 338, 596, 7035, 5993, 29889, 313, 12403, 29897, 13, 4706, 584, 3207, 851, 1426, 29901, 450, 1881, 5613, 4086, 1426, 29889, 313, 12403, 29897, 13, 4706, 584, 3207, 851, 10944, 29901, 450, 10944, 1304, 363, 278, 7397, 310, 4958, 9129, 491, 383, 19386, 297, 278, 1962, 29889, 960, 451, 6790, 285, 1127, 29901, 338, 1304, 408, 2322, 29889, 13, 4706, 584, 3207, 851, 7397, 29901, 450, 7397, 1304, 363, 278, 4958, 9129, 491, 383, 19386, 297, 278, 1962, 29889, 960, 451, 6790, 1732, 597, 1636, 29889, 609, 3002, 13892, 11037, 29879, 29889, 990, 29914, 609, 29914, 18447, 29914, 7247, 29889, 340, 29880, 29937, 338, 1304, 408, 2322, 29889, 13, 4706, 584, 3207, 6120, 281, 4928, 29901, 27313, 10803, 317, 1947, 3295, 18065, 373, 1881, 4958, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 6120, 281, 11512, 29901, 27313, 10803, 12218, 3295, 18065, 373, 1881, 4958, 297, 1797, 304, 3867, 7595, 1860, 304, 10803, 6779, 5222, 7224, 29892, 10803, 6779, 5670, 29899, 29879, 11259, 322, 11201, 346, 4413, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 851, 281, 11512, 29918, 10185, 29901, 450, 8722, 6942, 411, 278, 10803, 12218, 3295, 18065, 13, 4706, 584, 3207, 6120, 260, 1947, 29901, 512, 2325, 25406, 5302, 1546, 4959, 5034, 304, 1009, 14961, 2922, 936, 260, 1947, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 6120, 16178, 29901, 4803, 12218, 6779, 16178, 964, 278, 9819, 4625, 3002, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 851, 1426, 18317, 29901, 450, 7931, 370, 352, 653, 1304, 363, 9732, 1218, 278, 1426, 297, 390, 4037, 29889, 7803, 1950, 27809, 526, 3625, 29892, 474, 29889, 29872, 29889, 382, 1718, 1529, 29934, 29968, 322, 405, 6545, 29889, 13, 4706, 584, 3207, 6120, 28837, 29918, 1491, 4262, 29901, 3251, 403, 263, 390, 4037, 607, 871, 4653, 267, 278, 29505, 310, 263, 10541, 1728, 5684, 390, 4037, 3367, 2701, 29892, 1316, 408, 1906, 6943, 1426, 805, 550, 29892, 760, 29899, 974, 29899, 5965, 5309, 267, 29892, 2992, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 2457, 29901, 6213, 13, 462, 960, 278, 1158, 338, 2000, 408, 9524, 5794, 29892, 13, 462, 3639, 278, 2009, 3244, 29889, 13, 4706, 9995, 13, 4706, 9049, 5085, 1839, 29918, 2457, 29918, 1124, 29918, 1272, 29918, 6194, 2033, 353, 5852, 13, 4706, 565, 9049, 5085, 29889, 657, 877, 12674, 29918, 7971, 29374, 13, 9651, 736, 1583, 29889, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29918, 2541, 29918, 1124, 29918, 3888, 29898, 8921, 2133, 29892, 1426, 29892, 3579, 19290, 29897, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 1683, 29901, 13, 9651, 313, 1272, 29897, 353, 1583, 29889, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29918, 2541, 29918, 1124, 29918, 3888, 29898, 8921, 2133, 29892, 1426, 29892, 3579, 19290, 29897, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 9651, 736, 848, 13, 13, 1678, 822, 380, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29918, 2541, 29918, 1124, 29918, 3888, 29898, 1311, 29892, 28733, 29892, 1426, 29892, 3579, 19290, 1125, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 9995, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 3251, 403, 390, 4037, 515, 5613, 4086, 1426, 29889, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 910, 1158, 3732, 263, 12231, 681, 7331, 2009, 491, 2322, 29889, 1763, 1207, 385, 13, 4706, 20489, 7331, 2009, 29892, 3113, 1209, 7465, 29918, 7971, 29922, 5574, 13, 4706, 8653, 3244, 353, 7882, 29889, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29918, 2541, 29918, 1124, 29918, 3888, 29898, 8921, 2133, 29892, 1426, 29892, 7465, 29918, 7971, 29922, 5574, 29897, 13, 4706, 8653, 1121, 353, 3244, 29889, 657, 580, 13, 13, 4706, 584, 3207, 7465, 29918, 7971, 6120, 13, 4706, 584, 3207, 851, 28733, 29901, 450, 28733, 367, 598, 279, 29889, 5167, 13218, 29933, 799, 261, 921, 4419, 29899, 8071, 29891, 29899, 5617, 29920, 23370, 988, 338, 596, 7035, 5993, 29889, 313, 12403, 29897, 13, 4706, 584, 3207, 851, 1426, 29901, 450, 1881, 5613, 4086, 1426, 29889, 313, 12403, 29897, 13, 4706, 584, 3207, 851, 10944, 29901, 450, 10944, 1304, 363, 278, 7397, 310, 4958, 9129, 491, 383, 19386, 297, 278, 1962, 29889, 960, 451, 6790, 285, 1127, 29901, 338, 1304, 408, 2322, 29889, 13, 4706, 584, 3207, 851, 7397, 29901, 450, 7397, 1304, 363, 278, 4958, 9129, 491, 383, 19386, 297, 278, 1962, 29889, 960, 451, 6790, 1732, 597, 1636, 29889, 609, 3002, 13892, 11037, 29879, 29889, 990, 29914, 609, 29914, 18447, 29914, 7247, 29889, 340, 29880, 29937, 338, 1304, 408, 2322, 29889, 13, 4706, 584, 3207, 6120, 281, 4928, 29901, 27313, 10803, 317, 1947, 3295, 18065, 373, 1881, 4958, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 6120, 281, 11512, 29901, 27313, 10803, 12218, 3295, 18065, 373, 1881, 4958, 297, 1797, 304, 3867, 7595, 1860, 304, 10803, 6779, 5222, 7224, 29892, 10803, 6779, 5670, 29899, 29879, 11259, 322, 11201, 346, 4413, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 851, 281, 11512, 29918, 10185, 29901, 450, 8722, 6942, 411, 278, 10803, 12218, 3295, 18065, 13, 4706, 584, 3207, 6120, 260, 1947, 29901, 512, 2325, 25406, 5302, 1546, 4959, 5034, 304, 1009, 14961, 2922, 936, 260, 1947, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 6120, 16178, 29901, 4803, 12218, 6779, 16178, 964, 278, 9819, 4625, 3002, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 3207, 851, 1426, 18317, 29901, 450, 7931, 370, 352, 653, 1304, 363, 9732, 1218, 278, 1426, 297, 390, 4037, 29889, 7803, 1950, 27809, 526, 3625, 29892, 474, 29889, 29872, 29889, 382, 1718, 1529, 29934, 29968, 322, 405, 6545, 29889, 13, 4706, 584, 3207, 6120, 28837, 29918, 1491, 4262, 29901, 3251, 403, 263, 390, 4037, 607, 871, 4653, 267, 278, 29505, 310, 263, 10541, 1728, 5684, 390, 4037, 3367, 2701, 29892, 1316, 408, 1906, 6943, 1426, 805, 550, 29892, 760, 29899, 974, 29899, 5965, 5309, 267, 29892, 2992, 29889, 2648, 2322, 372, 338, 731, 304, 2089, 29889, 13, 4706, 584, 2457, 29901, 6213, 13, 462, 960, 278, 1158, 338, 2000, 408, 9524, 5794, 29892, 13, 462, 3639, 278, 2009, 3244, 29889, 13, 4706, 9995, 13, 13, 4706, 599, 29918, 7529, 353, 6024, 8921, 2133, 742, 525, 726, 742, 525, 13506, 742, 525, 22377, 742, 525, 29893, 4928, 742, 525, 29893, 11512, 742, 525, 29893, 11512, 29918, 10185, 742, 525, 841, 344, 742, 525, 307, 793, 742, 525, 726, 18317, 742, 525, 12846, 7716, 29918, 1491, 4262, 2033, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 599, 29918, 7529, 29889, 4397, 877, 12674, 29918, 7971, 1495, 13, 4706, 599, 29918, 7529, 29889, 4397, 877, 29918, 2457, 29918, 1124, 29918, 1272, 29918, 6194, 1495, 13, 4706, 599, 29918, 7529, 29889, 4397, 877, 29918, 1457, 1359, 29918, 3051, 1495, 13, 4706, 599, 29918, 7529, 29889, 4397, 877, 29918, 3827, 29918, 15619, 1495, 13, 13, 4706, 8636, 353, 1180, 1338, 580, 13, 4706, 363, 1820, 29892, 659, 297, 4832, 29889, 1524, 7076, 29898, 7529, 1839, 19290, 2033, 1125, 13, 9651, 565, 1820, 451, 297, 599, 29918, 7529, 29901, 13, 18884, 12020, 20948, 29898, 13, 462, 1678, 376, 29954, 327, 385, 15668, 13553, 2980, 14210, 29879, 11838, 13, 462, 1678, 376, 304, 1158, 380, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29908, 1273, 1820, 13, 18884, 1723, 13, 9651, 8636, 29961, 1989, 29962, 353, 659, 13, 4706, 628, 8636, 1839, 19290, 2033, 13, 4706, 396, 11539, 278, 3734, 3443, 525, 8921, 2133, 29915, 338, 731, 13, 4706, 565, 1583, 29889, 2754, 29918, 4645, 29889, 4645, 29918, 2975, 29918, 18157, 322, 6702, 8921, 2133, 29915, 451, 297, 8636, 470, 13, 462, 462, 462, 539, 8636, 1839, 8921, 2133, 2033, 338, 6213, 1125, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 9651, 12020, 7865, 2392, 703, 18552, 292, 278, 3734, 3443, 421, 8921, 2133, 29952, 746, 5432, 421, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29952, 1159, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 396, 11539, 278, 3734, 3443, 525, 726, 29915, 338, 731, 13, 4706, 565, 1583, 29889, 2754, 29918, 4645, 29889, 4645, 29918, 2975, 29918, 18157, 322, 6702, 726, 29915, 451, 297, 8636, 470, 13, 462, 462, 462, 539, 8636, 1839, 726, 2033, 338, 6213, 1125, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 9651, 12020, 7865, 2392, 703, 18552, 292, 278, 3734, 3443, 421, 726, 29952, 746, 5432, 421, 303, 8205, 29918, 8504, 29918, 18447, 29918, 657, 29952, 1159, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 4333, 29918, 689, 1446, 353, 6571, 13, 13, 4706, 2224, 29918, 7529, 353, 6571, 13, 13, 4706, 2346, 29918, 7529, 353, 5159, 13, 4706, 565, 525, 726, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 726, 742, 8636, 1839, 726, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 13506, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 13506, 742, 8636, 1839, 13506, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 22377, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 22377, 742, 8636, 1839, 22377, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 29893, 4928, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 29893, 4928, 742, 8636, 1839, 29893, 4928, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 29893, 11512, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 29893, 11512, 742, 8636, 1839, 29893, 11512, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 29893, 11512, 29918, 10185, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 29893, 11512, 29918, 10185, 742, 8636, 1839, 29893, 11512, 29918, 10185, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 841, 344, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 841, 344, 742, 8636, 1839, 841, 344, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 307, 793, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 307, 793, 742, 8636, 1839, 307, 793, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 726, 18317, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 726, 18317, 742, 8636, 1839, 726, 18317, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 4706, 565, 525, 12846, 7716, 29918, 1491, 4262, 29915, 297, 8636, 29901, 13, 9651, 2346, 29918, 7529, 29889, 4397, 29898, 877, 12846, 7716, 29899, 1491, 4262, 742, 8636, 1839, 12846, 7716, 29918, 1491, 4262, 25901, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 4839, 29918, 7529, 353, 6571, 13, 4706, 565, 525, 8921, 2133, 29915, 297, 8636, 29901, 13, 9651, 4839, 29918, 7529, 1839, 25471, 2033, 353, 8636, 1839, 8921, 2133, 2033, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 883, 29918, 7529, 353, 5159, 13, 4706, 1887, 29918, 1707, 29918, 5325, 353, 6571, 13, 13, 4706, 3573, 29918, 7529, 353, 6213, 13, 4706, 396, 7331, 4839, 421, 23965, 29952, 13, 4706, 4839, 29918, 7529, 1839, 23965, 2033, 353, 1583, 29889, 2754, 29918, 4645, 29889, 2622, 29918, 6672, 29918, 16044, 29898, 13, 9651, 6024, 6214, 29914, 29878, 2176, 29974, 3134, 742, 525, 726, 29914, 29873, 4227, 280, 742, 525, 6214, 29914, 29878, 2176, 29974, 3126, 742, 525, 726, 29914, 29878, 2176, 29974, 29876, 29941, 742, 525, 726, 29914, 29878, 2176, 29974, 593, 742, 525, 3027, 29914, 2732, 11287, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 396, 27241, 4444, 13, 4706, 4817, 29918, 11027, 353, 5159, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 13, 4706, 736, 1583, 29889, 2754, 29918, 4645, 29889, 4804, 29918, 2754, 29898, 13, 9651, 8207, 303, 8205, 29899, 8504, 29914, 18447, 742, 525, 7194, 742, 13, 9651, 2224, 29918, 7529, 29892, 13, 9651, 2346, 29918, 7529, 29892, 13, 9651, 4839, 29918, 7529, 29892, 13, 9651, 3573, 29922, 2587, 29918, 7529, 29892, 13, 9651, 1400, 29918, 7529, 29922, 689, 29918, 7529, 29892, 13, 9651, 2066, 29922, 2997, 29918, 1707, 29918, 5325, 29892, 13, 9651, 2933, 29918, 1853, 29922, 8516, 29892, 29871, 396, 694, 25621, 29901, 382, 29945, 29900, 29896, 13, 9651, 4817, 29918, 11027, 29922, 5150, 29918, 11027, 29892, 13, 9651, 7465, 29918, 7971, 29922, 7529, 29889, 657, 877, 12674, 29918, 7971, 5477, 13, 9651, 903, 2457, 29918, 1124, 29918, 1272, 29918, 6194, 29922, 7529, 29889, 657, 877, 29918, 2457, 29918, 1124, 29918, 1272, 29918, 6194, 5477, 13, 9651, 903, 1457, 1359, 29918, 3051, 29922, 7529, 29889, 657, 877, 29918, 1457, 1359, 29918, 3051, 742, 5852, 511, 13, 9651, 903, 3827, 29918, 15619, 29922, 7529, 29889, 657, 877, 29918, 3827, 29918, 15619, 5477, 13, 9651, 4333, 29918, 689, 1446, 29922, 10855, 29918, 689, 1446, 29897, 13, 2 ]
Programs/slithering_snakes.py
ShineTop/PiGlow
5
174700
#!/usr/bin/env python3 """ Slithering Snakes I think the title is self explanatory. .................... Functions: - slithering_snake_12: Lights up then turns off the LEDs on arms 1 and 2 - slithering_snake_13: Lights up then turns off the LEDs on arms 1 and 3 - slithering_snake_21: Lights up then turns off the LEDs on arms 2 and 1 - slithering_snake_23: Lights up then turns off the LEDs on arms 2 and 3 - slithering_snake_31: Lights up then turns off the LEDs on arms 3 and 1 - slithering_snake_32: Lights up then turns off the LEDs on arms 3 and 2 .................... Requirements: PyGlow.py (many thanks to benleb for this program) bfp_piglow_modules.py You will have these files if you downloaded the entire repository. .................... Author: <NAME> This program was written on a Raspberry Pi using the Geany IDE. """ ######################################################################## # Import modules # ######################################################################## import logging from time import sleep from PyGlow import PyGlow from bfp_piglow_modules import print_header from bfp_piglow_modules import check_log_directory from bfp_piglow_modules import delete_empty_logs from bfp_piglow_modules import stop ######################################################################## # Initialize # ######################################################################## PYGLOW = PyGlow() PYGLOW.all(0) ######################################################################## # Functions # ######################################################################## def slithering_snake_12(): """ Lights up then turns off the LEDs on arms 1 and 2 """ LOGGER.debug("Slithering Snake 1-2") sleep_speed = 0.10 # Light up Snake 12 PYGLOW.led(1, 100) sleep(sleep_speed) PYGLOW.led(2, 100) sleep(sleep_speed) PYGLOW.led(3, 100) sleep(sleep_speed) PYGLOW.led(4, 100) sleep(sleep_speed) PYGLOW.led(5, 100) sleep(sleep_speed) PYGLOW.led(6, 100) sleep(sleep_speed) PYGLOW.led(18, 100) sleep(sleep_speed) PYGLOW.led(11, 100) sleep(sleep_speed) PYGLOW.led(10, 100) sleep(sleep_speed) PYGLOW.led(9, 100) sleep(sleep_speed) PYGLOW.led(8, 100) sleep(sleep_speed) PYGLOW.led(7, 100) sleep(sleep_speed) # Turn off Snake 12 PYGLOW.led(1, 0) sleep(sleep_speed) PYGLOW.led(2, 0) sleep(sleep_speed) PYGLOW.led(3, 0) sleep(sleep_speed) PYGLOW.led(4, 0) sleep(sleep_speed) PYGLOW.led(5, 0) sleep(sleep_speed) PYGLOW.led(6, 0) sleep(sleep_speed) PYGLOW.led(18, 0) sleep(sleep_speed) PYGLOW.led(11, 0) sleep(sleep_speed) PYGLOW.led(10, 0) sleep(sleep_speed) PYGLOW.led(9, 0) sleep(sleep_speed) PYGLOW.led(8, 0) sleep(sleep_speed) PYGLOW.led(7, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def slithering_snake_13(): """ Lights up then turns off the LEDs on arms 1 and 3 """ LOGGER.debug("Slithering Snake 1-3") sleep_speed = 0.10 # Light up Snake 13 PYGLOW.led(1, 100) sleep(sleep_speed) PYGLOW.led(2, 100) sleep(sleep_speed) PYGLOW.led(3, 100) sleep(sleep_speed) PYGLOW.led(4, 100) sleep(sleep_speed) PYGLOW.led(5, 100) sleep(sleep_speed) PYGLOW.led(12, 100) sleep(sleep_speed) PYGLOW.led(18, 100) sleep(sleep_speed) PYGLOW.led(17, 100) sleep(sleep_speed) PYGLOW.led(16, 100) sleep(sleep_speed) PYGLOW.led(15, 100) sleep(sleep_speed) PYGLOW.led(14, 100) sleep(sleep_speed) PYGLOW.led(13, 100) sleep(sleep_speed) # Turn off Snake 13 PYGLOW.led(1, 0) sleep(sleep_speed) PYGLOW.led(2, 0) sleep(sleep_speed) PYGLOW.led(3, 0) sleep(sleep_speed) PYGLOW.led(4, 0) sleep(sleep_speed) PYGLOW.led(5, 0) sleep(sleep_speed) PYGLOW.led(12, 0) sleep(sleep_speed) PYGLOW.led(18, 0) sleep(sleep_speed) PYGLOW.led(17, 0) sleep(sleep_speed) PYGLOW.led(16, 0) sleep(sleep_speed) PYGLOW.led(15, 0) sleep(sleep_speed) PYGLOW.led(14, 0) sleep(sleep_speed) PYGLOW.led(13, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def slithering_snake_21(): """ Lights up then turns off the LEDs on arms 2 and 1 """ LOGGER.debug("Slithering Snake 2-1") sleep_speed = 0.10 # Light up Snake 21 PYGLOW.led(7, 100) sleep(sleep_speed) PYGLOW.led(8, 100) sleep(sleep_speed) PYGLOW.led(9, 100) sleep(sleep_speed) PYGLOW.led(10, 100) sleep(sleep_speed) PYGLOW.led(11, 100) sleep(sleep_speed) PYGLOW.led(18, 100) sleep(sleep_speed) PYGLOW.led(6, 100) sleep(sleep_speed) PYGLOW.led(5, 100) sleep(sleep_speed) PYGLOW.led(4, 100) sleep(sleep_speed) PYGLOW.led(3, 100) sleep(sleep_speed) PYGLOW.led(2, 100) sleep(sleep_speed) PYGLOW.led(1, 100) sleep(sleep_speed) # Turn off Snake 21 PYGLOW.led(7, 0) sleep(sleep_speed) PYGLOW.led(8, 0) sleep(sleep_speed) PYGLOW.led(9, 0) sleep(sleep_speed) PYGLOW.led(10, 0) sleep(sleep_speed) PYGLOW.led(11, 0) sleep(sleep_speed) PYGLOW.led(18, 0) sleep(sleep_speed) PYGLOW.led(6, 0) sleep(sleep_speed) PYGLOW.led(5, 0) sleep(sleep_speed) PYGLOW.led(4, 0) sleep(sleep_speed) PYGLOW.led(3, 0) sleep(sleep_speed) PYGLOW.led(2, 0) sleep(sleep_speed) PYGLOW.led(1, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def slithering_snake_23(): """ Lights up then turns off the LEDs on arms 2 and 3 """ LOGGER.debug("Slithering Snake 2-3") sleep_speed = 0.10 # Light up Snake 23 PYGLOW.led(7, 100) sleep(sleep_speed) PYGLOW.led(8, 100) sleep(sleep_speed) PYGLOW.led(9, 100) sleep(sleep_speed) PYGLOW.led(10, 100) sleep(sleep_speed) PYGLOW.led(11, 100) sleep(sleep_speed) PYGLOW.led(12, 100) sleep(sleep_speed) PYGLOW.led(6, 100) sleep(sleep_speed) PYGLOW.led(17, 100) sleep(sleep_speed) PYGLOW.led(16, 100) sleep(sleep_speed) PYGLOW.led(15, 100) sleep(sleep_speed) PYGLOW.led(14, 100) sleep(sleep_speed) PYGLOW.led(13, 100) sleep(sleep_speed) # Turn off Snake 23 PYGLOW.led(7, 0) sleep(sleep_speed) PYGLOW.led(8, 0) sleep(sleep_speed) PYGLOW.led(9, 0) sleep(sleep_speed) PYGLOW.led(10, 0) sleep(sleep_speed) PYGLOW.led(11, 0) sleep(sleep_speed) PYGLOW.led(12, 0) sleep(sleep_speed) PYGLOW.led(6, 0) sleep(sleep_speed) PYGLOW.led(17, 0) sleep(sleep_speed) PYGLOW.led(16, 0) sleep(sleep_speed) PYGLOW.led(15, 0) sleep(sleep_speed) PYGLOW.led(14, 0) sleep(sleep_speed) PYGLOW.led(13, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def slithering_snake_31(): """ Lights up then turns off the LEDs on arms 3 and 1 """ LOGGER.debug("Slithering Snake 3-1") sleep_speed = 0.10 # Light up Snake 31 PYGLOW.led(13, 100) sleep(sleep_speed) PYGLOW.led(14, 100) sleep(sleep_speed) PYGLOW.led(15, 100) sleep(sleep_speed) PYGLOW.led(16, 100) sleep(sleep_speed) PYGLOW.led(17, 100) sleep(sleep_speed) PYGLOW.led(18, 100) sleep(sleep_speed) PYGLOW.led(12, 100) sleep(sleep_speed) PYGLOW.led(5, 100) sleep(sleep_speed) PYGLOW.led(4, 100) sleep(sleep_speed) PYGLOW.led(3, 100) sleep(sleep_speed) PYGLOW.led(2, 100) sleep(sleep_speed) PYGLOW.led(1, 100) sleep(sleep_speed) # Turn off Snake 31 PYGLOW.led(13, 0) sleep(sleep_speed) PYGLOW.led(14, 0) sleep(sleep_speed) PYGLOW.led(15, 0) sleep(sleep_speed) PYGLOW.led(16, 0) sleep(sleep_speed) PYGLOW.led(17, 0) sleep(sleep_speed) PYGLOW.led(18, 0) sleep(sleep_speed) PYGLOW.led(12, 0) sleep(sleep_speed) PYGLOW.led(5, 0) sleep(sleep_speed) PYGLOW.led(4, 0) sleep(sleep_speed) PYGLOW.led(3, 0) sleep(sleep_speed) PYGLOW.led(2, 0) sleep(sleep_speed) PYGLOW.led(1, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def slithering_snake_32(): """ Lights up then turns off the LEDs on arms 3 and 2 """ LOGGER.debug("Slithering Snake 3-2") sleep_speed = 0.10 # Light up Snake 32 PYGLOW.led(13, 100) sleep(sleep_speed) PYGLOW.led(14, 100) sleep(sleep_speed) PYGLOW.led(15, 100) sleep(sleep_speed) PYGLOW.led(16, 100) sleep(sleep_speed) PYGLOW.led(17, 100) sleep(sleep_speed) PYGLOW.led(6, 100) sleep(sleep_speed) PYGLOW.led(12, 100) sleep(sleep_speed) PYGLOW.led(11, 100) sleep(sleep_speed) PYGLOW.led(10, 100) sleep(sleep_speed) PYGLOW.led(9, 100) sleep(sleep_speed) PYGLOW.led(8, 100) sleep(sleep_speed) PYGLOW.led(7, 100) sleep(sleep_speed) # Turn off Snake 32 PYGLOW.led(13, 0) sleep(sleep_speed) PYGLOW.led(14, 0) sleep(sleep_speed) PYGLOW.led(15, 0) sleep(sleep_speed) PYGLOW.led(16, 0) sleep(sleep_speed) PYGLOW.led(17, 0) sleep(sleep_speed) PYGLOW.led(6, 0) sleep(sleep_speed) PYGLOW.led(12, 0) sleep(sleep_speed) PYGLOW.led(11, 0) sleep(sleep_speed) PYGLOW.led(10, 0) sleep(sleep_speed) PYGLOW.led(9, 0) sleep(sleep_speed) PYGLOW.led(8, 0) sleep(sleep_speed) PYGLOW.led(7, 0) sleep(sleep_speed) # Pause before next snake sleep(1) def main(): """ The main function """ LOGGER.debug("START") # Snakes 12, 13, 21, 23, 31, 32 slithering_snake_12() slithering_snake_13() slithering_snake_21() slithering_snake_23() slithering_snake_31() slithering_snake_32() # Snakes 12, 23, 31, 13, 32, 21 slithering_snake_12() slithering_snake_23() slithering_snake_31() slithering_snake_13() slithering_snake_32() slithering_snake_21() # Snakes 13, 12, 23, 21, 31, 32 slithering_snake_13() slithering_snake_12() slithering_snake_23() slithering_snake_21() slithering_snake_31() slithering_snake_32() # Snakes 13, 32, 21, 12, 23, 31 slithering_snake_13() slithering_snake_32() slithering_snake_21() slithering_snake_12() slithering_snake_23() slithering_snake_31() LOGGER.debug("END") delete_empty_logs(LOG) stop() if __name__ == '__main__': try: # STEP01: Check if Log directory exists. check_log_directory() # STEP02: Enable logging LOG = 'Logs/slithering_snakes.log' LOG_FORMAT = '%(asctime)s %(name)s: %(funcName)s: \ %(levelname)s: %(message)s' LOGGER = logging.getLogger(__name__) # Nothing will log unless logging level is changed to DEBUG LOGGER.setLevel(logging.ERROR) FORMATTER = logging.Formatter(fmt=LOG_FORMAT, datefmt='%m/%d/%y %I:%M:%S %p:') FILE_HANDLER = logging.FileHandler(LOG, 'w') FILE_HANDLER.setFormatter(FORMATTER) LOGGER.addHandler(FILE_HANDLER) # STEP03: Print header print_header() # STEP04: Print instructions in white text print("\033[1;37;40mPress Ctrl-C to stop the program.") # STEP05: Run the main function main() except KeyboardInterrupt: delete_empty_logs(LOG) stop()
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 29941, 13, 15945, 29908, 13, 16973, 2121, 292, 22639, 6926, 13, 13, 29902, 1348, 278, 3611, 338, 1583, 7309, 7606, 29889, 13, 13, 25285, 3045, 13, 13, 6678, 29879, 29901, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29896, 322, 29871, 29906, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29896, 322, 29871, 29941, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29906, 322, 29871, 29896, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29906, 322, 29871, 29941, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29941, 322, 29871, 29896, 13, 29899, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 29901, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29941, 322, 29871, 29906, 13, 13, 25285, 3045, 13, 13, 1123, 1548, 1860, 29901, 13, 1678, 10772, 29954, 677, 29889, 2272, 313, 13011, 3969, 304, 3856, 19982, 363, 445, 1824, 29897, 13, 1678, 289, 18091, 29918, 29886, 335, 677, 29918, 7576, 29889, 2272, 13, 13, 3492, 674, 505, 1438, 2066, 565, 366, 16532, 278, 4152, 9810, 29889, 13, 13, 25285, 3045, 13, 13, 13720, 29901, 529, 5813, 29958, 13, 13, 4013, 1824, 471, 3971, 373, 263, 390, 4692, 16344, 7362, 773, 278, 1879, 1384, 15004, 29889, 13, 15945, 29908, 13, 13383, 13383, 13383, 13383, 7346, 13, 29937, 462, 3986, 16032, 10585, 462, 795, 396, 13, 13383, 13383, 13383, 13383, 7346, 13, 13, 5215, 12183, 13, 3166, 931, 1053, 8709, 13, 3166, 10772, 29954, 677, 1053, 10772, 29954, 677, 13, 3166, 289, 18091, 29918, 29886, 335, 677, 29918, 7576, 1053, 1596, 29918, 6672, 13, 3166, 289, 18091, 29918, 29886, 335, 677, 29918, 7576, 1053, 1423, 29918, 1188, 29918, 12322, 13, 3166, 289, 18091, 29918, 29886, 335, 677, 29918, 7576, 1053, 5217, 29918, 6310, 29918, 20756, 13, 3166, 289, 18091, 29918, 29886, 335, 677, 29918, 7576, 1053, 5040, 13, 13, 13383, 13383, 13383, 13383, 7346, 13, 29937, 462, 965, 25455, 462, 462, 396, 13, 13383, 13383, 13383, 13383, 7346, 13, 13, 20055, 29954, 27998, 353, 10772, 29954, 677, 580, 13, 20055, 29954, 27998, 29889, 497, 29898, 29900, 29897, 13, 13, 13383, 13383, 13383, 13383, 7346, 13, 29937, 462, 9651, 6680, 29879, 462, 462, 396, 13, 13383, 13383, 13383, 13383, 7346, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29896, 322, 29871, 29906, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29896, 29899, 29906, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29896, 29906, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29896, 29906, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29896, 322, 29871, 29941, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29896, 29899, 29941, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29896, 29941, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29896, 29941, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29906, 322, 29871, 29896, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29906, 29899, 29896, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29906, 29896, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29906, 29896, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29906, 322, 29871, 29941, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29906, 29899, 29941, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29906, 29941, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29906, 29941, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29941, 322, 29871, 29896, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29941, 29899, 29896, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29941, 29896, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29941, 29896, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 7295, 13, 1678, 9995, 13, 1678, 365, 5861, 701, 769, 12169, 1283, 278, 25023, 29879, 373, 10188, 29871, 29941, 322, 29871, 29906, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 16973, 2121, 292, 317, 21040, 29871, 29941, 29899, 29906, 1159, 13, 13, 1678, 8709, 29918, 19322, 353, 29871, 29900, 29889, 29896, 29900, 13, 13, 1678, 396, 12790, 701, 317, 21040, 29871, 29941, 29906, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29896, 29900, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 9603, 1283, 317, 21040, 29871, 29941, 29906, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29941, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29946, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29945, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29953, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29906, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29896, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29896, 29900, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29929, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29947, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 349, 29979, 29954, 27998, 29889, 839, 29898, 29955, 29892, 29871, 29900, 29897, 13, 1678, 8709, 29898, 17059, 29918, 19322, 29897, 13, 1678, 396, 349, 1071, 1434, 2446, 269, 21040, 13, 1678, 8709, 29898, 29896, 29897, 13, 13, 13, 1753, 1667, 7295, 13, 1678, 9995, 13, 1678, 450, 1667, 740, 13, 1678, 9995, 13, 1678, 25401, 17070, 29889, 8382, 703, 25826, 1159, 13, 13, 1678, 396, 22639, 6926, 29871, 29896, 29906, 29892, 29871, 29896, 29941, 29892, 29871, 29906, 29896, 29892, 29871, 29906, 29941, 29892, 29871, 29941, 29896, 29892, 29871, 29941, 29906, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 580, 13, 1678, 396, 22639, 6926, 29871, 29896, 29906, 29892, 29871, 29906, 29941, 29892, 29871, 29941, 29896, 29892, 29871, 29896, 29941, 29892, 29871, 29941, 29906, 29892, 29871, 29906, 29896, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 580, 13, 1678, 396, 22639, 6926, 29871, 29896, 29941, 29892, 29871, 29896, 29906, 29892, 29871, 29906, 29941, 29892, 29871, 29906, 29896, 29892, 29871, 29941, 29896, 29892, 29871, 29941, 29906, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 580, 13, 1678, 396, 22639, 6926, 29871, 29896, 29941, 29892, 29871, 29941, 29906, 29892, 29871, 29906, 29896, 29892, 29871, 29896, 29906, 29892, 29871, 29906, 29941, 29892, 29871, 29941, 29896, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29896, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29896, 29906, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29906, 29941, 580, 13, 1678, 2243, 2121, 292, 29918, 29879, 21040, 29918, 29941, 29896, 580, 13, 13, 1678, 25401, 17070, 29889, 8382, 703, 11794, 1159, 13, 13, 1678, 5217, 29918, 6310, 29918, 20756, 29898, 14480, 29897, 13, 1678, 5040, 580, 13, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1018, 29901, 13, 4706, 396, 317, 4330, 29925, 29900, 29896, 29901, 5399, 565, 4522, 3884, 4864, 29889, 13, 4706, 1423, 29918, 1188, 29918, 12322, 580, 13, 4706, 396, 317, 4330, 29925, 29900, 29906, 29901, 1174, 519, 12183, 13, 4706, 25401, 353, 525, 3403, 29879, 29914, 2536, 2121, 292, 29918, 16586, 6926, 29889, 1188, 29915, 13, 4706, 25401, 29918, 19094, 1299, 353, 14210, 29898, 294, 312, 603, 29897, 29879, 1273, 29898, 978, 29897, 29879, 29901, 1273, 29898, 9891, 1170, 29897, 29879, 29901, 320, 13, 462, 418, 1273, 29898, 5563, 978, 29897, 29879, 29901, 1273, 29898, 4906, 29897, 29879, 29915, 13, 4706, 25401, 17070, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 4706, 396, 9531, 674, 1480, 6521, 12183, 3233, 338, 3939, 304, 21681, 13, 4706, 25401, 17070, 29889, 842, 10108, 29898, 21027, 29889, 11432, 29897, 13, 4706, 383, 12054, 1299, 4945, 353, 12183, 29889, 18522, 29898, 23479, 29922, 14480, 29918, 19094, 1299, 29892, 13, 462, 462, 418, 2635, 23479, 2433, 29995, 29885, 22584, 29881, 22584, 29891, 1273, 29902, 16664, 29924, 16664, 29903, 1273, 29886, 29901, 1495, 13, 4706, 24080, 29918, 29950, 9468, 29931, 1001, 353, 12183, 29889, 2283, 4598, 29898, 14480, 29892, 525, 29893, 1495, 13, 4706, 24080, 29918, 29950, 9468, 29931, 1001, 29889, 842, 18522, 29898, 19094, 1299, 4945, 29897, 13, 4706, 25401, 17070, 29889, 1202, 4598, 29898, 7724, 29918, 29950, 9468, 29931, 1001, 29897, 13, 4706, 396, 317, 4330, 29925, 29900, 29941, 29901, 13905, 4839, 13, 4706, 1596, 29918, 6672, 580, 13, 4706, 396, 317, 4330, 29925, 29900, 29946, 29901, 13905, 11994, 297, 4796, 1426, 13, 4706, 1596, 14182, 29900, 29941, 29941, 29961, 29896, 29936, 29941, 29955, 29936, 29946, 29900, 29885, 10923, 315, 11742, 29899, 29907, 304, 5040, 278, 1824, 23157, 13, 4706, 396, 317, 4330, 29925, 29900, 29945, 29901, 7525, 278, 1667, 740, 13, 4706, 1667, 580, 13, 1678, 5174, 7670, 3377, 4074, 6685, 29901, 13, 4706, 5217, 29918, 6310, 29918, 20756, 29898, 14480, 29897, 13, 4706, 5040, 580, 13, 13, 2 ]
application/model/widget/serialize/SerializeButtontwo.py
Kzulfazriawan/Stigma-game-demo
2
116690
<filename>application/model/widget/serialize/SerializeButtontwo.py<gh_stars>1-10 from core import Files from library.stigma.application import Button from library.stigma.helper import kivyBuilder kivyBuilder(Files.apppath, 'model', 'builder', 'Buttontwo.kv') class SerializeButtontwo(Button): def __init__(self): super(SerializeButtontwo, self).__init__() self.value = '1' self.text = 'SLOT 2' self.data = None self.params = int(self.value)
[ 1, 529, 9507, 29958, 6214, 29914, 4299, 29914, 8030, 29914, 643, 6646, 29914, 1748, 6646, 29819, 609, 827, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 3166, 7136, 1053, 12745, 13, 3166, 3489, 29889, 303, 2934, 29889, 6214, 1053, 11025, 13, 3166, 3489, 29889, 303, 2934, 29889, 20907, 1053, 413, 440, 29891, 5627, 13, 29895, 440, 29891, 5627, 29898, 10547, 29889, 932, 2084, 29892, 525, 4299, 742, 525, 16409, 742, 525, 29819, 609, 827, 29889, 27049, 1495, 13, 13, 13, 1990, 1816, 6646, 29819, 609, 827, 29898, 3125, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 2428, 29898, 1748, 6646, 29819, 609, 827, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 1767, 29871, 353, 525, 29896, 29915, 13, 4706, 1583, 29889, 726, 29871, 353, 525, 12750, 2891, 29871, 29906, 29915, 13, 4706, 1583, 29889, 1272, 259, 353, 6213, 13, 4706, 1583, 29889, 7529, 353, 938, 29898, 1311, 29889, 1767, 29897, 2 ]
output/models/nist_data/atomic/time/schema_instance/nistschema_sv_iv_atomic_time_max_inclusive_3_xsd/__init__.py
tefra/xsdata-w3c-tests
1
175065
<filename>output/models/nist_data/atomic/time/schema_instance/nistschema_sv_iv_atomic_time_max_inclusive_3_xsd/__init__.py from output.models.nist_data.atomic.time.schema_instance.nistschema_sv_iv_atomic_time_max_inclusive_3_xsd.nistschema_sv_iv_atomic_time_max_inclusive_3 import NistschemaSvIvAtomicTimeMaxInclusive3 __all__ = [ "NistschemaSvIvAtomicTimeMaxInclusive3", ]
[ 1, 529, 9507, 29958, 4905, 29914, 9794, 29914, 29876, 391, 29918, 1272, 29914, 21641, 29914, 2230, 29914, 11010, 29918, 8758, 29914, 29876, 391, 11010, 29918, 4501, 29918, 440, 29918, 21641, 29918, 2230, 29918, 3317, 29918, 262, 7009, 573, 29918, 29941, 29918, 19168, 29914, 1649, 2344, 26914, 2272, 13, 3166, 1962, 29889, 9794, 29889, 29876, 391, 29918, 1272, 29889, 21641, 29889, 2230, 29889, 11010, 29918, 8758, 29889, 29876, 391, 11010, 29918, 4501, 29918, 440, 29918, 21641, 29918, 2230, 29918, 3317, 29918, 262, 7009, 573, 29918, 29941, 29918, 19168, 29889, 29876, 391, 11010, 29918, 4501, 29918, 440, 29918, 21641, 29918, 2230, 29918, 3317, 29918, 262, 7009, 573, 29918, 29941, 1053, 405, 391, 11010, 29903, 29894, 29902, 29894, 4178, 25426, 2481, 7976, 797, 7009, 573, 29941, 13, 13, 1649, 497, 1649, 353, 518, 13, 1678, 376, 29940, 391, 11010, 29903, 29894, 29902, 29894, 4178, 25426, 2481, 7976, 797, 7009, 573, 29941, 613, 13, 29962, 13, 2 ]
exercises/04_While/exe_04.py
MariaTrindade/CursoPython
1
64692
""" Crie um programa que solicita vários números inteiros ao usuário, pergunte se ele quer continuar digitando e caso responda não, informe o total de números digitados, o menor, o maior e a média entre eles. """ total = soma = maior = 0 menor = 9999999999999999 resposta = 'S' while resposta in 'S': num = int(input('Digite um número: ')) total += 1 soma += num if num > maior: # 30 > 0 maior = num if num < menor: # 30 < 99999999999999 menor = num resposta = str(input('\033[32mQuer continuar? \033[m')).upper().strip() if resposta == 'N': print('Encerrando o sistema') print() # fora do while ------------------------ print(f'Total de número inseridos: {total}\nSoma dos números inseridos: {soma}\n' f'Média dos números inseridos: {soma / total:.1f}\nMaior número inserido: {maior}\n' f'Menor número inserido: {menor}') 0 2 0 1000.0 todos = [] while True: todos.append(int(input('Digite um número: '))) resposta = str(input('Quer continuar: ')).strip().upper() if resposta == 'N': break if 15 in todos: print('Achei') print(f'Total de número inseridos: {todos}\nSoma dos números inseridos: {sum(todos)}\n' f'Média dos números inseridos: {sum(todos) / len(todos)}\nMaior número inserido: {max(todos)}\n' f'Menor número inserido: {min(todos)}')
[ 1, 9995, 13, 29907, 2546, 1922, 16914, 712, 26978, 2028, 9366, 13095, 12158, 359, 2293, 17177, 5017, 502, 29884, 12288, 29892, 13, 546, 29887, 17316, 409, 4552, 22320, 3133, 279, 13615, 1743, 321, 11986, 10049, 29874, 8145, 29892, 13, 262, 689, 29872, 288, 3001, 316, 12158, 359, 13615, 2255, 29892, 288, 26764, 29892, 288, 17136, 321, 263, 13, 29885, 13292, 2637, 560, 267, 29889, 13, 15945, 29908, 13, 13, 7827, 353, 1047, 29874, 353, 17136, 353, 29871, 29900, 13, 1527, 272, 353, 29871, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 13, 690, 27363, 353, 525, 29903, 29915, 13, 13, 8000, 620, 27363, 297, 525, 29903, 2396, 13, 1678, 954, 353, 938, 29898, 2080, 877, 14991, 568, 1922, 13831, 29901, 525, 876, 13, 1678, 3001, 4619, 29871, 29896, 13, 1678, 1047, 29874, 4619, 954, 13, 13, 1678, 565, 954, 1405, 17136, 29901, 396, 29871, 29941, 29900, 1405, 29871, 29900, 13, 4706, 17136, 353, 954, 13, 13, 1678, 565, 954, 529, 26764, 29901, 396, 29871, 29941, 29900, 529, 29871, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 13, 4706, 26764, 353, 954, 13, 13, 1678, 620, 27363, 353, 851, 29898, 2080, 28909, 29900, 29941, 29941, 29961, 29941, 29906, 29885, 2182, 261, 3133, 279, 29973, 320, 29900, 29941, 29941, 29961, 29885, 1495, 467, 21064, 2141, 17010, 580, 13, 1678, 565, 620, 27363, 1275, 525, 29940, 2396, 13, 4706, 1596, 877, 2369, 2265, 29878, 1743, 288, 10502, 1495, 13, 1678, 1596, 580, 13, 13, 29937, 363, 29874, 437, 1550, 448, 2683, 26589, 13, 2158, 29898, 29888, 29915, 11536, 316, 13831, 13534, 4396, 29901, 426, 7827, 1012, 29876, 29903, 4125, 3248, 12158, 359, 13534, 4396, 29901, 426, 29879, 4125, 1012, 29876, 29915, 13, 418, 285, 29915, 29924, 13292, 3248, 12158, 359, 13534, 4396, 29901, 426, 29879, 4125, 847, 3001, 29901, 29889, 29896, 29888, 1012, 29876, 21870, 1611, 13831, 13534, 1941, 29901, 426, 655, 1611, 1012, 29876, 29915, 13, 418, 285, 29915, 28154, 272, 13831, 13534, 1941, 29901, 426, 1527, 272, 29913, 1495, 13, 13, 29900, 13, 29906, 13, 13, 29900, 13, 13, 13, 13, 29896, 29900, 29900, 29900, 29889, 29900, 13, 20034, 359, 353, 5159, 13, 13, 8000, 5852, 29901, 13, 1678, 10843, 29889, 4397, 29898, 524, 29898, 2080, 877, 14991, 568, 1922, 13831, 29901, 525, 4961, 13, 13, 1678, 620, 27363, 353, 851, 29898, 2080, 877, 2182, 261, 3133, 279, 29901, 525, 8106, 17010, 2141, 21064, 580, 13, 13, 1678, 565, 620, 27363, 1275, 525, 29940, 2396, 13, 4706, 2867, 13, 13, 1678, 565, 29871, 29896, 29945, 297, 10843, 29901, 13, 4706, 1596, 877, 29909, 1173, 29875, 1495, 13, 13, 2158, 29898, 29888, 29915, 11536, 316, 13831, 13534, 4396, 29901, 426, 20034, 359, 1012, 29876, 29903, 4125, 3248, 12158, 359, 13534, 4396, 29901, 426, 2083, 29898, 20034, 359, 11383, 29876, 29915, 13, 418, 285, 29915, 29924, 13292, 3248, 12158, 359, 13534, 4396, 29901, 426, 2083, 29898, 20034, 359, 29897, 847, 7431, 29898, 20034, 359, 11383, 29876, 21870, 1611, 13831, 13534, 1941, 29901, 426, 3317, 29898, 20034, 359, 11383, 29876, 29915, 13, 418, 285, 29915, 28154, 272, 13831, 13534, 1941, 29901, 426, 1195, 29898, 20034, 359, 2915, 1495, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 2 ]
rst2pdf/tests/input/test_extensions.py
shakna-israel/rst2pdf
1
1611075
<reponame>shakna-israel/rst2pdf import sys print """ This test should print the message from the sample extension, and then this message, and then generate an empty PDF. """
[ 1, 529, 276, 1112, 420, 29958, 845, 557, 1056, 29899, 275, 9058, 29914, 29878, 303, 29906, 5140, 13, 5215, 10876, 13, 13, 2158, 9995, 13, 13, 4013, 1243, 881, 1596, 278, 2643, 515, 278, 4559, 6081, 29892, 13, 392, 769, 445, 2643, 29892, 322, 769, 5706, 385, 4069, 11328, 29889, 13, 15945, 29908, 13, 2 ]
build/lib.linux-x86_64-2.7_ucs4/mx/Misc/PackageTools.py
mkubux/egenix-mx-base
0
1768
""" PackageTools - A set of tools to aid working with packages. Copyright (c) 1998-2000, <NAME>; mailto:<EMAIL> Copyright (c) 2000-2015, eGenix.com Software GmbH; mailto:<EMAIL> See the documentation for further information on copyrights, or contact the author. All Rights Reserved. """ __version__ = '0.4.0' import os,types,sys,re,imp,__builtin__ import mx.Tools.NewBuiltins # RE to identify Python modules suffixes = projection(imp.get_suffixes(),0) module_name = re.compile('(.*)(' + '|'.join(suffixes) + ')$') initmodule_name = re.compile('__init__(' + '|'.join(suffixes) + ')$') initmodule_names = [] for suffix in suffixes: initmodule_names.append('__init__' + suffix) def find_packages(dir=os.curdir, files_only=0, recursive=0, ignore_modules=0, pkgbasename='', pkgdict=None, isdir=os.path.isdir,exists=os.path.exists, isfile=os.path.isfile,join=os.path.join,listdir=os.listdir, module_name=module_name,initmodule_name=initmodule_name): """ Return a list of package names found in dir. Packages are Python modules and subdirectories that provide an __init__ module. The .py extension is removed from the files. The __init__ modules are not considered being seperate packages. If files_only is true, only Python files are included in the search (subdirectories are *not* taken into account). If ignore_modules is true (default is false), modules are ignored. If recursive is true the search recurses into package directories. pkgbasename and pkgdict are only used during recursion. """ l = listdir(dir) if pkgdict is None: pkgdict = {} if files_only: for filename in l: m = module_name.match(filename) if m is not None and \ m.group(1) != '__init__': pkgdict[pkgbasename + m.group(1)] = 1 else: for filename in l: path = join(dir, filename) if isdir(path): # Check for __init__ module(s) for name in initmodule_names: if isfile(join(path, name)): pkgname = pkgbasename + filename pkgdict[pkgname] = 1 if recursive: find_packages(path, recursive=1, pkgbasename=pkgname + '.', pkgdict=pkgdict) break elif not ignore_modules: m = module_name.match(filename) if m is not None and \ m.group(1) != '__init__': pkgdict[pkgbasename + m.group(1)] = 1 return pkgdict.keys() def find_subpackages(package, recursive=0, splitpath=os.path.split): """ Assuming that package points to a loaded package module, this function tries to identify all subpackages of that package. Subpackages are all Python files included in the same directory as the module plus all subdirectories having an __init__.py file. The modules name is prepended to all subpackage names. The module location is found by looking at the __file__ attribute that non-builtin modules define. The function uses the __all__ attribute from the package __init__ module if available. If recursive is true (default is false), then subpackages of subpackages are recursively also included in the search. """ if not recursive: # Try the __all__ attribute... try: subpackages = list(package.__all__) except (ImportError, AttributeError): # Did not work, then let's try to find the subpackages by looking # at the directory where package lives... subpackages = find_packages(package.__path__[0], recursive=recursive) else: # XXX Recursive search does not support the __all__ attribute subpackages = find_packages(package.__path__[0], recursive=recursive) basename = package.__name__ + '.' for i,name in irange(subpackages): subpackages[i] = basename + name return subpackages def _thismodule(upcount=1, exc_info=sys.exc_info,trange=trange): """ Returns the module object that the callee is calling from. upcount can be given to indicate how far up the execution stack the function is supposed to look (1 == direct callee, 2 == callee of callee, etc.). """ try: 1/0 except: frame = exc_info()[2].tb_frame for i in trange(upcount): frame = frame.f_back name = frame.f_globals['__name__'] del frame return sys.modules[name] def _module_loader(name, locals, globals, sysmods, errors='strict', importer=__import__, reloader=reload, from_list=['*']): """ Internal API for loading a module """ if not sysmods.has_key(name): is_new = 1 else: is_new = 0 try: mod = importer(name, locals, globals, from_list) if reload and not is_new: mod = reloader(mod) except KeyboardInterrupt: # Pass through; SystemExit will be handled by the error handler raise except Exception, why: if errors == 'ignore': pass elif errors == 'strict': raise elif callable(errors): errors(name, sys.exc_info()[0], sys.exc_info()[1]) else: raise ValueError,'unknown errors value' else: return mod return None def import_modules(modnames,module=None,errors='strict',reload=0, thismodule=_thismodule): """ Import all modules given in modnames into module. module defaults to the caller's module. modnames may contain dotted package names. If errors is 'strict' (default), then ImportErrors and SyntaxErrors are raised. If set to 'ignore', they are silently ignored. If errors is a callable object, then it is called with arguments (modname, errorclass, errorvalue). If the handler returns, processing continues. If reload is true (default is false), all already modules among the list will be forced to reload. """ if module is None: module = _thismodule(2) locals = module.__dict__ sysmods = sys.modules for name in modnames: mod = _module_loader(name, locals, locals, sysmods, errors=errors) if mod is not None: locals[name] = mod def load_modules(modnames,locals=None,globals=None,errors='strict',reload=0): """ Imports all modules in modnames using the given namespaces and returns list of corresponding module objects. If errors is 'strict' (default), then ImportErrors and SyntaxErrors are raised. If set to 'ignore', they are silently ignored. If errors is a callable object, then it is called with arguments (modname, errorclass, errorvalue). If the handler returns, processing continues. If reload is true (default is false), all already modules among the list will be forced to reload. """ modules = [] append = modules.append sysmods = sys.modules for name in modnames: mod = _module_loader(name, locals, globals, sysmods, errors=errors) if mod is not None: append(mod) return modules def import_subpackages(module, reload=0, recursive=0, import_modules=import_modules, find_subpackages=find_subpackages): """ Does a subpackages scan using find_subpackages(module) and then imports all submodules found into module. The module location is found by looking at the __file__ attribute that non-builtin modules define. The function uses the __all__ attribute from the package __init__ module if available. If reload is true (default is false), all already modules among the list will be forced to reload. """ import_modules(find_subpackages(module, recursive=recursive), module, reload=reload) def load_subpackages(module, locals=None, globals=None, errors='strict', reload=0, recursive=0, load_modules=load_modules, find_subpackages=find_subpackages): """ Same as import_subpackages but with load_modules functionality, i.e. imports the modules and also returns a list of module objects. If errors is 'strict' (default), then ImportErrors are raised. If set to 'ignore', they are silently ignored. If reload is true (default is false), all already modules among the list will be forced to reload. """ return load_modules(find_subpackages(module, recursive=recursive), locals, globals, errors=errors, reload=reload) def modules(names, extract=extract): """ Converts a list of module names into a list of module objects. The modules must already be loaded. """ return extract(sys.modules, names) def package_modules(pkgname): """ Returns a list of all modules belonging to the package with the given name. The package must already be loaded. Only the currently registered modules are included in the list. """ match = pkgname + '.' match_len = len(match) mods = [sys.modules[pkgname]] for k,v in sys.modules.items(): if k[:match_len] == match and v is not None: mods.append(v) return mods def find_classes(mods,baseclass=None,annotated=0, ClassType=types.ClassType,issubclass=issubclass): """ Find all subclasses of baseclass or simply all classes (if baseclass is None) defined by the module objects in list mods. If annotated is true the returned list will contain tuples (module_object,name,class_object) for each class found where module_object is the module where the class is defined. """ classes = [] for mod in mods: for name,obj in mod.__dict__.items(): if type(obj) is ClassType: if baseclass and not issubclass(obj,baseclass): continue if annotated: classes.append((mod, name, obj)) else: classes.append(obj) return classes def find_instances(mods,baseclass,annotated=0, InstanceType=types.InstanceType,issubclass=issubclass): """ Find all instances of baseclass defined by the module objects in list mods. If annotated is true the returned list will contain tuples (module_object,name,instances_object) for each instances found where module_object is the module where the instances is defined. """ instances = [] for mod in mods: for name,obj in mod.__dict__.items(): if isinstance(obj,baseclass): if annotated: instances.append((mod,name,obj)) else: instances.append(obj) return instances
[ 1, 9995, 22029, 24183, 448, 319, 731, 310, 8492, 304, 16226, 1985, 411, 9741, 29889, 13, 13, 1678, 14187, 1266, 313, 29883, 29897, 29871, 29896, 29929, 29929, 29947, 29899, 29906, 29900, 29900, 29900, 29892, 529, 5813, 25867, 10524, 517, 29901, 29966, 26862, 6227, 29958, 13, 1678, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29900, 29900, 29899, 29906, 29900, 29896, 29945, 29892, 321, 15462, 861, 29889, 510, 18540, 18156, 29936, 10524, 517, 29901, 29966, 26862, 6227, 29958, 13, 1678, 2823, 278, 5106, 363, 4340, 2472, 373, 3509, 1266, 29879, 29892, 13, 1678, 470, 6958, 278, 4148, 29889, 2178, 26863, 2538, 9841, 29889, 13, 15945, 29908, 13, 1649, 3259, 1649, 353, 525, 29900, 29889, 29946, 29889, 29900, 29915, 13, 13, 5215, 2897, 29892, 8768, 29892, 9675, 29892, 276, 29892, 6574, 29892, 1649, 16145, 262, 1649, 13, 5215, 286, 29916, 29889, 24183, 29889, 4373, 3727, 2782, 1144, 13, 13, 29937, 5195, 304, 12439, 5132, 10585, 13, 2146, 600, 861, 267, 353, 18246, 29898, 6574, 29889, 657, 29918, 2146, 600, 861, 267, 3285, 29900, 29897, 13, 5453, 29918, 978, 353, 337, 29889, 12198, 877, 28104, 29897, 877, 718, 525, 29989, 4286, 7122, 29898, 2146, 600, 861, 267, 29897, 718, 525, 1262, 1495, 13, 2344, 5453, 29918, 978, 353, 337, 29889, 12198, 877, 1649, 2344, 1649, 877, 718, 525, 29989, 4286, 7122, 29898, 2146, 600, 861, 267, 29897, 718, 525, 1262, 1495, 13, 2344, 5453, 29918, 7039, 353, 5159, 13, 1454, 25557, 297, 25557, 267, 29901, 13, 1678, 2069, 5453, 29918, 7039, 29889, 4397, 877, 1649, 2344, 1649, 29915, 718, 25557, 29897, 13, 13, 1753, 1284, 29918, 8318, 29898, 3972, 29922, 359, 29889, 2764, 3972, 29892, 2066, 29918, 6194, 29922, 29900, 29892, 16732, 29922, 29900, 29892, 11455, 29918, 7576, 29922, 29900, 29892, 13, 462, 29871, 282, 9415, 6500, 3871, 2433, 742, 282, 9415, 8977, 29922, 8516, 29892, 13, 462, 259, 13, 462, 29871, 338, 3972, 29922, 359, 29889, 2084, 29889, 275, 3972, 29892, 9933, 29922, 359, 29889, 2084, 29889, 9933, 29892, 13, 462, 29871, 338, 1445, 29922, 359, 29889, 2084, 29889, 275, 1445, 29892, 7122, 29922, 359, 29889, 2084, 29889, 7122, 29892, 1761, 3972, 29922, 359, 29889, 1761, 3972, 29892, 13, 462, 29871, 3883, 29918, 978, 29922, 5453, 29918, 978, 29892, 2344, 5453, 29918, 978, 29922, 2344, 5453, 29918, 978, 1125, 13, 13, 1678, 9995, 7106, 263, 1051, 310, 3577, 2983, 1476, 297, 4516, 29889, 13, 13, 4706, 18744, 1179, 526, 5132, 10585, 322, 1014, 11851, 3842, 393, 3867, 385, 13, 4706, 4770, 2344, 1649, 3883, 29889, 29871, 450, 869, 2272, 6081, 338, 6206, 515, 278, 13, 4706, 2066, 29889, 450, 4770, 2344, 1649, 10585, 526, 451, 5545, 1641, 409, 21194, 13, 4706, 9741, 29889, 13, 13, 4706, 960, 2066, 29918, 6194, 338, 1565, 29892, 871, 5132, 2066, 526, 5134, 297, 278, 13, 4706, 2740, 313, 1491, 11851, 3842, 526, 334, 1333, 29930, 4586, 964, 3633, 467, 960, 13, 4706, 11455, 29918, 7576, 338, 1565, 313, 4381, 338, 2089, 511, 10585, 526, 13, 4706, 17262, 29889, 960, 16732, 338, 1565, 278, 2740, 8304, 267, 964, 3577, 13, 4706, 17525, 29889, 13, 13, 4706, 282, 9415, 6500, 3871, 322, 282, 9415, 8977, 526, 871, 1304, 2645, 20437, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 301, 353, 1051, 3972, 29898, 3972, 29897, 13, 1678, 565, 282, 9415, 8977, 338, 6213, 29901, 13, 4706, 282, 9415, 8977, 353, 6571, 13, 1678, 565, 2066, 29918, 6194, 29901, 13, 4706, 363, 10422, 297, 301, 29901, 13, 9651, 286, 353, 3883, 29918, 978, 29889, 4352, 29898, 9507, 29897, 13, 9651, 565, 286, 338, 451, 6213, 322, 320, 13, 1669, 286, 29889, 2972, 29898, 29896, 29897, 2804, 525, 1649, 2344, 1649, 2396, 13, 18884, 282, 9415, 8977, 29961, 15865, 6500, 3871, 718, 286, 29889, 2972, 29898, 29896, 4638, 353, 29871, 29896, 13, 1678, 1683, 29901, 13, 4706, 363, 10422, 297, 301, 29901, 13, 9651, 2224, 353, 5988, 29898, 3972, 29892, 10422, 29897, 13, 9651, 565, 338, 3972, 29898, 2084, 1125, 13, 18884, 396, 5399, 363, 4770, 2344, 1649, 3883, 29898, 29879, 29897, 13, 18884, 363, 1024, 297, 2069, 5453, 29918, 7039, 29901, 13, 462, 1678, 565, 338, 1445, 29898, 7122, 29898, 2084, 29892, 1024, 22164, 13, 462, 4706, 282, 9415, 978, 353, 282, 9415, 6500, 3871, 718, 10422, 13, 462, 4706, 282, 9415, 8977, 29961, 15865, 978, 29962, 353, 29871, 29896, 13, 462, 4706, 565, 16732, 29901, 13, 462, 9651, 1284, 29918, 8318, 29898, 2084, 29892, 13, 462, 462, 3986, 16732, 29922, 29896, 29892, 13, 462, 462, 3986, 282, 9415, 6500, 3871, 29922, 15865, 978, 718, 15300, 742, 13, 462, 462, 3986, 282, 9415, 8977, 29922, 15865, 8977, 29897, 13, 462, 4706, 2867, 13, 9651, 25342, 451, 11455, 29918, 7576, 29901, 13, 18884, 286, 353, 3883, 29918, 978, 29889, 4352, 29898, 9507, 29897, 13, 18884, 565, 286, 338, 451, 6213, 322, 320, 13, 462, 259, 286, 29889, 2972, 29898, 29896, 29897, 2804, 525, 1649, 2344, 1649, 2396, 13, 462, 1678, 282, 9415, 8977, 29961, 15865, 6500, 3871, 718, 286, 29889, 2972, 29898, 29896, 4638, 353, 29871, 29896, 13, 1678, 736, 282, 9415, 8977, 29889, 8149, 580, 13, 13, 1753, 1284, 29918, 1491, 8318, 29898, 5113, 29892, 16732, 29922, 29900, 29892, 13, 13, 462, 268, 6219, 2084, 29922, 359, 29889, 2084, 29889, 5451, 1125, 13, 13, 1678, 9995, 17090, 393, 3577, 3291, 304, 263, 7500, 3577, 3883, 29892, 445, 13, 4706, 740, 14335, 304, 12439, 599, 1014, 8318, 310, 393, 3577, 29889, 13, 13, 4706, 3323, 8318, 526, 599, 5132, 2066, 5134, 297, 278, 1021, 13, 4706, 3884, 408, 278, 3883, 2298, 599, 1014, 11851, 3842, 2534, 385, 13, 4706, 4770, 2344, 26914, 2272, 934, 29889, 29871, 450, 10585, 1024, 338, 8273, 2760, 304, 599, 13, 4706, 1014, 5113, 2983, 29889, 13, 13, 4706, 450, 3883, 4423, 338, 1476, 491, 3063, 472, 278, 4770, 1445, 1649, 13, 4706, 5352, 393, 1661, 29899, 16145, 262, 10585, 4529, 29889, 450, 740, 3913, 13, 4706, 278, 4770, 497, 1649, 5352, 515, 278, 3577, 4770, 2344, 1649, 3883, 565, 13, 4706, 3625, 29889, 13, 13, 4706, 960, 16732, 338, 1565, 313, 4381, 338, 2089, 511, 769, 1014, 8318, 310, 13, 4706, 1014, 8318, 526, 8304, 3598, 884, 5134, 297, 278, 2740, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 565, 451, 16732, 29901, 13, 4706, 396, 3967, 278, 4770, 497, 1649, 5352, 856, 13, 4706, 1018, 29901, 13, 9651, 1014, 8318, 353, 1051, 29898, 5113, 17255, 497, 1649, 29897, 13, 4706, 5174, 313, 17518, 2392, 29892, 23833, 2392, 1125, 13, 9651, 396, 7440, 451, 664, 29892, 769, 1235, 29915, 29879, 1018, 304, 1284, 278, 1014, 8318, 491, 3063, 13, 9651, 396, 472, 278, 3884, 988, 3577, 12080, 856, 13, 9651, 1014, 8318, 353, 1284, 29918, 8318, 29898, 5113, 17255, 2084, 1649, 29961, 29900, 1402, 16732, 29922, 3757, 25397, 29897, 13, 1678, 1683, 29901, 13, 4706, 396, 22615, 3599, 25397, 2740, 947, 451, 2304, 278, 4770, 497, 1649, 5352, 13, 4706, 1014, 8318, 353, 1284, 29918, 8318, 29898, 5113, 17255, 2084, 1649, 29961, 29900, 1402, 16732, 29922, 3757, 25397, 29897, 13, 1678, 2362, 3871, 353, 3577, 17255, 978, 1649, 718, 525, 6169, 13, 1678, 363, 474, 29892, 978, 297, 3805, 927, 29898, 1491, 8318, 1125, 13, 4706, 1014, 8318, 29961, 29875, 29962, 353, 2362, 3871, 718, 1024, 13, 1678, 736, 1014, 8318, 13, 13, 1753, 903, 1366, 5453, 29898, 786, 2798, 29922, 29896, 29892, 13, 13, 18884, 5566, 29918, 3888, 29922, 9675, 29889, 735, 29883, 29918, 3888, 29892, 509, 927, 29922, 509, 927, 1125, 13, 13, 1678, 9995, 16969, 278, 3883, 1203, 393, 278, 1208, 17179, 338, 5432, 515, 29889, 13, 13, 4706, 701, 2798, 508, 367, 2183, 304, 12266, 920, 2215, 701, 278, 8225, 13, 4706, 5096, 278, 740, 338, 7424, 304, 1106, 313, 29896, 1275, 1513, 1208, 17179, 29892, 29871, 29906, 13, 4706, 1275, 1208, 17179, 310, 1208, 17179, 29892, 2992, 6250, 13, 13, 1678, 9995, 13, 1678, 1018, 29901, 13, 308, 29896, 29914, 29900, 13, 1678, 5174, 29901, 13, 4706, 3515, 353, 5566, 29918, 3888, 580, 29961, 29906, 1822, 22625, 29918, 2557, 13, 4706, 363, 474, 297, 534, 927, 29898, 786, 2798, 1125, 13, 9651, 3515, 353, 3515, 29889, 29888, 29918, 1627, 13, 1678, 1024, 353, 3515, 29889, 29888, 29918, 23705, 1338, 1839, 1649, 978, 1649, 2033, 13, 1678, 628, 3515, 13, 1678, 736, 10876, 29889, 7576, 29961, 978, 29962, 13, 13, 1753, 903, 5453, 29918, 12657, 29898, 978, 29892, 1180, 1338, 29892, 13149, 1338, 29892, 10876, 1545, 29879, 29892, 4436, 2433, 710, 919, 742, 13, 462, 259, 527, 18505, 29922, 1649, 5215, 1649, 29892, 337, 12657, 29922, 28120, 29892, 515, 29918, 1761, 29922, 1839, 29930, 2033, 1125, 13, 13, 1678, 9995, 512, 1890, 3450, 363, 8363, 263, 3883, 13, 1678, 9995, 13, 1678, 565, 451, 10876, 1545, 29879, 29889, 5349, 29918, 1989, 29898, 978, 1125, 13, 4706, 338, 29918, 1482, 353, 29871, 29896, 13, 1678, 1683, 29901, 13, 4706, 338, 29918, 1482, 353, 29871, 29900, 13, 1678, 1018, 29901, 13, 4706, 878, 353, 527, 18505, 29898, 978, 29892, 1180, 1338, 29892, 13149, 1338, 29892, 515, 29918, 1761, 29897, 13, 4706, 565, 19763, 322, 451, 338, 29918, 1482, 29901, 13, 9651, 878, 353, 337, 12657, 29898, 1545, 29897, 13, 1678, 5174, 7670, 3377, 4074, 6685, 29901, 13, 4706, 396, 6978, 1549, 29936, 2184, 24365, 674, 367, 16459, 491, 278, 1059, 7834, 13, 4706, 12020, 13, 1678, 5174, 8960, 29892, 2020, 29901, 13, 4706, 565, 4436, 1275, 525, 17281, 2396, 13, 9651, 1209, 13, 4706, 25342, 4436, 1275, 525, 710, 919, 2396, 13, 9651, 12020, 13, 4706, 25342, 1246, 519, 29898, 12523, 1125, 13, 9651, 4436, 29898, 978, 29892, 10876, 29889, 735, 29883, 29918, 3888, 580, 29961, 29900, 1402, 10876, 29889, 735, 29883, 29918, 3888, 580, 29961, 29896, 2314, 13, 4706, 1683, 29901, 13, 9651, 12020, 7865, 2392, 5501, 26690, 4436, 995, 29915, 13, 1678, 1683, 29901, 13, 4706, 736, 878, 13, 1678, 736, 6213, 13, 13, 1753, 1053, 29918, 7576, 29898, 1545, 7039, 29892, 5453, 29922, 8516, 29892, 12523, 2433, 710, 919, 742, 28120, 29922, 29900, 29892, 13, 13, 462, 259, 445, 5453, 29922, 29918, 1366, 5453, 1125, 13, 13, 1678, 9995, 16032, 599, 10585, 2183, 297, 878, 7039, 964, 3883, 29889, 13, 13, 4706, 3883, 21274, 304, 278, 24959, 29915, 29879, 3883, 29889, 878, 7039, 1122, 1712, 13, 4706, 270, 15048, 3577, 2983, 29889, 13, 13, 4706, 960, 4436, 338, 525, 710, 919, 29915, 313, 4381, 511, 769, 16032, 22463, 322, 13, 4706, 21306, 22463, 526, 10425, 29889, 960, 731, 304, 525, 17281, 742, 896, 526, 4047, 2705, 13, 4706, 17262, 29889, 960, 4436, 338, 263, 1246, 519, 1203, 29892, 769, 372, 338, 2000, 13, 4706, 411, 6273, 313, 1545, 978, 29892, 1059, 1990, 29892, 1059, 1767, 467, 960, 278, 13, 4706, 7834, 3639, 29892, 9068, 18172, 29889, 13, 13, 4706, 960, 19763, 338, 1565, 313, 4381, 338, 2089, 511, 599, 2307, 10585, 13, 4706, 4249, 278, 1051, 674, 367, 11826, 304, 19763, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 565, 3883, 338, 6213, 29901, 13, 4706, 3883, 353, 903, 1366, 5453, 29898, 29906, 29897, 13, 1678, 1180, 1338, 353, 3883, 17255, 8977, 1649, 13, 1678, 10876, 1545, 29879, 353, 10876, 29889, 7576, 13, 1678, 363, 1024, 297, 878, 7039, 29901, 13, 4706, 878, 353, 903, 5453, 29918, 12657, 29898, 978, 29892, 1180, 1338, 29892, 1180, 1338, 29892, 10876, 1545, 29879, 29892, 4436, 29922, 12523, 29897, 13, 4706, 565, 878, 338, 451, 6213, 29901, 13, 9651, 1180, 1338, 29961, 978, 29962, 353, 878, 13, 268, 13, 1753, 2254, 29918, 7576, 29898, 1545, 7039, 29892, 2997, 29879, 29922, 8516, 29892, 23705, 1338, 29922, 8516, 29892, 12523, 2433, 710, 919, 742, 28120, 29922, 29900, 1125, 13, 13, 1678, 9995, 1954, 4011, 599, 10585, 297, 878, 7039, 773, 278, 2183, 2983, 22459, 322, 3639, 13, 4706, 1051, 310, 6590, 3883, 3618, 29889, 13, 13, 4706, 960, 4436, 338, 525, 710, 919, 29915, 313, 4381, 511, 769, 16032, 22463, 322, 13, 4706, 21306, 22463, 526, 10425, 29889, 960, 731, 304, 525, 17281, 742, 896, 526, 4047, 2705, 13, 4706, 17262, 29889, 960, 4436, 338, 263, 1246, 519, 1203, 29892, 769, 372, 338, 2000, 13, 4706, 411, 6273, 313, 1545, 978, 29892, 1059, 1990, 29892, 1059, 1767, 467, 960, 278, 13, 4706, 7834, 3639, 29892, 9068, 18172, 29889, 13, 13, 4706, 960, 19763, 338, 1565, 313, 4381, 338, 2089, 511, 599, 2307, 10585, 13, 4706, 4249, 278, 1051, 674, 367, 11826, 304, 19763, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 10585, 353, 5159, 13, 1678, 9773, 353, 10585, 29889, 4397, 13, 1678, 10876, 1545, 29879, 353, 10876, 29889, 7576, 13, 1678, 363, 1024, 297, 878, 7039, 29901, 13, 4706, 878, 353, 903, 5453, 29918, 12657, 29898, 978, 29892, 1180, 1338, 29892, 13149, 1338, 29892, 10876, 1545, 29879, 29892, 4436, 29922, 12523, 29897, 13, 4706, 565, 878, 338, 451, 6213, 29901, 13, 9651, 9773, 29898, 1545, 29897, 13, 1678, 736, 10585, 13, 268, 13, 1753, 1053, 29918, 1491, 8318, 29898, 5453, 29892, 19763, 29922, 29900, 29892, 16732, 29922, 29900, 29892, 13, 13, 462, 539, 1053, 29918, 7576, 29922, 5215, 29918, 7576, 29892, 13, 462, 539, 1284, 29918, 1491, 8318, 29922, 2886, 29918, 1491, 8318, 1125, 13, 13, 1678, 9995, 5538, 263, 1014, 8318, 12812, 773, 1284, 29918, 1491, 8318, 29898, 5453, 29897, 322, 769, 13, 4706, 24802, 599, 1014, 7576, 1476, 964, 3883, 29889, 13, 13, 4706, 450, 3883, 4423, 338, 1476, 491, 3063, 472, 278, 4770, 1445, 1649, 13, 4706, 5352, 393, 1661, 29899, 16145, 262, 10585, 4529, 29889, 450, 740, 3913, 13, 4706, 278, 4770, 497, 1649, 5352, 515, 278, 3577, 4770, 2344, 1649, 3883, 565, 13, 4706, 3625, 29889, 13, 13, 4706, 960, 19763, 338, 1565, 313, 4381, 338, 2089, 511, 599, 2307, 10585, 13, 4706, 4249, 278, 1051, 674, 367, 11826, 304, 19763, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 1053, 29918, 7576, 29898, 2886, 29918, 1491, 8318, 29898, 5453, 29892, 16732, 29922, 3757, 25397, 511, 13, 462, 259, 3883, 29892, 19763, 29922, 28120, 29897, 13, 13, 1753, 2254, 29918, 1491, 8318, 29898, 5453, 29892, 1180, 1338, 29922, 8516, 29892, 13149, 1338, 29922, 8516, 29892, 4436, 2433, 710, 919, 742, 19763, 29922, 29900, 29892, 13, 462, 268, 16732, 29922, 29900, 29892, 13, 462, 418, 13, 462, 268, 2254, 29918, 7576, 29922, 1359, 29918, 7576, 29892, 13, 462, 268, 1284, 29918, 1491, 8318, 29922, 2886, 29918, 1491, 8318, 1125, 13, 13, 1678, 9995, 19491, 408, 1053, 29918, 1491, 8318, 541, 411, 2254, 29918, 7576, 13, 4706, 9863, 29892, 474, 29889, 29872, 29889, 24802, 278, 10585, 322, 884, 3639, 263, 1051, 310, 13, 4706, 3883, 3618, 29889, 13, 13, 4706, 960, 4436, 338, 525, 710, 919, 29915, 313, 4381, 511, 769, 16032, 22463, 526, 13, 4706, 10425, 29889, 960, 731, 304, 525, 17281, 742, 896, 526, 4047, 2705, 17262, 29889, 13, 13, 4706, 960, 19763, 338, 1565, 313, 4381, 338, 2089, 511, 599, 2307, 10585, 13, 4706, 4249, 278, 1051, 674, 367, 11826, 304, 19763, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 736, 2254, 29918, 7576, 29898, 2886, 29918, 1491, 8318, 29898, 5453, 29892, 16732, 29922, 3757, 25397, 511, 13, 462, 4706, 1180, 1338, 29892, 13149, 1338, 29892, 13, 462, 4706, 4436, 29922, 12523, 29892, 19763, 29922, 28120, 29897, 13, 13, 1753, 10585, 29898, 7039, 29892, 13, 13, 9651, 6597, 29922, 21111, 1125, 13, 13, 1678, 9995, 1281, 369, 1372, 263, 1051, 310, 3883, 2983, 964, 263, 1051, 310, 3883, 3618, 29889, 13, 268, 13, 4706, 450, 10585, 1818, 2307, 367, 7500, 29889, 13, 13, 1678, 9995, 13, 1678, 736, 6597, 29898, 9675, 29889, 7576, 29892, 2983, 29897, 13, 13, 1753, 3577, 29918, 7576, 29898, 15865, 978, 1125, 13, 13, 1678, 9995, 16969, 263, 1051, 310, 599, 10585, 23329, 304, 278, 3577, 411, 278, 13, 4706, 2183, 1024, 29889, 13, 13, 4706, 450, 3577, 1818, 2307, 367, 7500, 29889, 9333, 278, 5279, 13, 4706, 15443, 10585, 526, 5134, 297, 278, 1051, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 1993, 353, 282, 9415, 978, 718, 525, 6169, 13, 1678, 1993, 29918, 2435, 353, 7431, 29898, 4352, 29897, 13, 1678, 878, 29879, 353, 518, 9675, 29889, 7576, 29961, 15865, 978, 5262, 13, 1678, 363, 413, 29892, 29894, 297, 10876, 29889, 7576, 29889, 7076, 7295, 13, 4706, 565, 413, 7503, 4352, 29918, 2435, 29962, 1275, 1993, 322, 325, 338, 451, 6213, 29901, 13, 9651, 878, 29879, 29889, 4397, 29898, 29894, 29897, 13, 1678, 736, 878, 29879, 13, 13, 1753, 1284, 29918, 13203, 29898, 1545, 29879, 29892, 3188, 1990, 29922, 8516, 29892, 6735, 630, 29922, 29900, 29892, 13, 13, 462, 4134, 1542, 29922, 8768, 29889, 2385, 1542, 29892, 790, 431, 1990, 29922, 790, 431, 1990, 1125, 13, 13, 1678, 9995, 10987, 599, 1014, 13203, 310, 2967, 1990, 470, 3763, 599, 4413, 313, 361, 2967, 1990, 13, 4706, 338, 6213, 29897, 3342, 491, 278, 3883, 3618, 297, 1051, 878, 29879, 29889, 13, 13, 4706, 960, 9732, 630, 338, 1565, 278, 4133, 1051, 674, 1712, 5291, 2701, 13, 4706, 313, 5453, 29918, 3318, 29892, 978, 29892, 1990, 29918, 3318, 29897, 363, 1269, 770, 1476, 988, 13, 4706, 3883, 29918, 3318, 338, 278, 3883, 988, 278, 770, 338, 3342, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 4413, 353, 5159, 13, 1678, 363, 878, 297, 878, 29879, 29901, 13, 4706, 363, 1024, 29892, 5415, 297, 878, 17255, 8977, 26914, 7076, 7295, 13, 9651, 565, 1134, 29898, 5415, 29897, 338, 4134, 1542, 29901, 13, 18884, 565, 2967, 1990, 322, 451, 338, 1491, 1990, 29898, 5415, 29892, 3188, 1990, 1125, 13, 462, 1678, 6773, 13, 18884, 565, 9732, 630, 29901, 13, 462, 1678, 4413, 29889, 4397, 3552, 1545, 29892, 1024, 29892, 5446, 876, 13, 18884, 1683, 29901, 13, 462, 1678, 4413, 29889, 4397, 29898, 5415, 29897, 13, 1678, 736, 4413, 13, 13, 1753, 1284, 29918, 2611, 2925, 29898, 1545, 29879, 29892, 3188, 1990, 29892, 6735, 630, 29922, 29900, 29892, 13, 13, 462, 259, 2799, 749, 1542, 29922, 8768, 29889, 4998, 1542, 29892, 790, 431, 1990, 29922, 790, 431, 1990, 1125, 13, 13, 1678, 9995, 10987, 599, 8871, 310, 2967, 1990, 3342, 491, 278, 3883, 3618, 13, 4706, 297, 1051, 878, 29879, 29889, 13, 13, 4706, 960, 9732, 630, 338, 1565, 278, 4133, 1051, 674, 1712, 5291, 2701, 13, 4706, 313, 5453, 29918, 3318, 29892, 978, 29892, 2611, 2925, 29918, 3318, 29897, 363, 1269, 8871, 1476, 988, 13, 4706, 3883, 29918, 3318, 338, 278, 3883, 988, 278, 8871, 338, 3342, 29889, 13, 308, 13, 1678, 9995, 13, 1678, 8871, 353, 5159, 13, 1678, 363, 878, 297, 878, 29879, 29901, 13, 4706, 363, 1024, 29892, 5415, 297, 878, 17255, 8977, 26914, 7076, 7295, 13, 9651, 565, 338, 8758, 29898, 5415, 29892, 3188, 1990, 1125, 13, 18884, 565, 9732, 630, 29901, 13, 462, 1678, 8871, 29889, 4397, 3552, 1545, 29892, 978, 29892, 5415, 876, 13, 18884, 1683, 29901, 13, 462, 1678, 8871, 29889, 4397, 29898, 5415, 29897, 13, 1678, 736, 8871, 13, 2 ]
Service_Components/Sink/Sink_DataFlow.py
mydata-sdk/mydata-sdk-1.x
0
11081
<filename>Service_Components/Sink/Sink_DataFlow.py # -*- coding: utf-8 -*- from signed_requests.signed_request_auth import SignedRequest __author__ = 'alpaloma' from flask import Blueprint, current_app, request from helpers import Helpers import requests from json import dumps, loads from DetailedHTTPException import error_handler from flask_restful import Resource, Api import logging from jwcrypto import jwk from Templates import Sequences debug_log = logging.getLogger("debug") logger = logging.getLogger("sequence") api_Sink_blueprint = Blueprint("api_Sink_blueprint", __name__) api = Api() api.init_app(api_Sink_blueprint) sq = Sequences("Service_Components Mgmnt (Sink)", {}) # import xmltodict # @api.representation('application/xml') # def output_xml(data, code, headers=None): # if isinstance(data, dict): # xm = {"response": data} # resp = make_response(xmltodict.unparse(xm, pretty=True), code) # resp.headers.extend(headers) # return resp class Status(Resource): @error_handler def get(self): status = {"status": "running", "service_mode": "Sink"} return status class DataFlow(Resource): def __init__(self): super(DataFlow, self).__init__() self.service_url = current_app.config["SERVICE_URL"] self.operator_url = current_app.config["OPERATOR_URL"] self.helpers = Helpers(current_app.config) @error_handler def post(self): # TODO Make this a GET def renew_token(operator_url, record_id): sq.task("Renewing Auth Token.") token = requests.get( "{}/api/1.2/cr/auth_token/{}".format(operator_url, record_id)) # TODO Get api path from some config? debug_log.info("{}, {}, {}, {}".format(token.url, token.reason, token.status_code, token.text)) store_dict = {cr_id: dumps(loads(token.text.encode()))} self.helpers.storeToken(store_dict) def step_1(): params = request.json debug_log.info(params) debug_log.info(request.json) user_id = params["user_id"] cr_id = params["cr_id"] rs_id = params["rs_id"] sq.task("Get data_set_id from POST json") data_set_id = request.args.get("dataset_id", None) debug_log.info("data_set_id is ({}), cr_id is ({}), user_id ({}) and rs_id ({})" .format(data_set_id, cr_id, user_id, rs_id)) sq.task("Create request") req = {"we want": "data"} sq.task("Validate CR") cr = self.helpers.validate_cr(cr_id, surrogate_id=user_id) sq.task("Validate Request from UI") distribution_urls = self.helpers.validate_request_from_ui(cr, data_set_id, rs_id) # Fetch data request urls # Data request urls fetched. debug_log.info("Data request urls fetched.") return cr_id, cr, distribution_urls cr_id, cr, distribution_urls = step_1() sq.task("Validate Authorisation Token") surrogate_id = cr["cr"]["common_part"]["surrogate_id"] our_key = self.helpers.get_key() our_key_pub = our_key["pub"] tries = 3 # TODO: Get this from config while True: try: aud = self.helpers.validate_authorization_token(cr_id, surrogate_id, our_key_pub) break except ValueError as e: debug_log.exception(e) renew_token(self.operator_url, cr_id) if tries == 0: raise EnvironmentError("Auth token validation failed and retry counter exceeded.") tries -= 1 except TypeError as e: debug_log.exception(e) raise EnvironmentError("Token used too soon, halting.") # Most verifying and checking below is done in the validate_authorization_token function by jwcrypto # Fetch Authorisation Token related to CR from data storage by rs_id (cr_id?) # Check Integrity ( Signed by operator, Operator's public key can be found from SLR) # Check "Issued" timestamp # Check "Not Before" timestamp # Check "Not After" timestamp # Check that "sub" contains correct public key(Our key.) # OPT: Token expired # Get new Authorization token, start again from validation. # TODO: Make these steps work as functions that call the next step. # Check URL patterns in "aud" field # Check that fetched distribution urls can be found from "aud" field # Token validated debug_log.info("Auth Token Validated.") # With these two steps Sink has verified that it's allowed to make request. # Construct request sq.task("Construct request") # Select request URL from "aud" field # Add Authorisation Token to request # Request constructed. # Sign request # Fetch private key pair of public key specified in Authorisation Token's "sub" field. # Sign with fetched private key sq.task("Fetch key used to sign request") our_key_full = jwk.JWK() our_key_full.import_key(**our_key["key"]) # Add signature to request # Request signed. # Request created. sq.send_to("Service_Components Mgmnt (Source)", "Data Request (PoP stuff)") # Make Data Request for url in distribution_urls: req = requests.get(url, auth=SignedRequest(token=aud, sign_method=True, sign_path=True, key=our_key_full, protected=dumps(our_key["prot"]))) debug_log.info("Made data request and received following data from Source: \n{}" .format(dumps(loads(req.content), indent=2))) status = {"status": "ok", "service_mode": "Sink"} return status api.add_resource(Status, '/init') api.add_resource(DataFlow, '/dc') #api.add_resource(DataFlow, '/user/<string:user_id>/consentRecord/<string:cr_id>/resourceSet/<string:rs_id>') #"http://service_components:7000/api/1.2/sink_flow/user/95479a08-80cc-4359-ba28-b8ca23ff5572_53af88dc-33de-44be-bc30-e0826db9bd6c/consentRecord/cd431509-777a-4285-8211-95c5ac577537/resourceSet/http%3A%2F%2Fservice_components%3A7000%7C%7C9aebb487-0c83-4139-b12c-d7fcea93a3ad"
[ 1, 529, 9507, 29958, 3170, 29918, 25503, 29914, 29903, 682, 29914, 29903, 682, 29918, 1469, 17907, 29889, 2272, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 3166, 8794, 29918, 24830, 29889, 7433, 29918, 3827, 29918, 5150, 1053, 9954, 287, 3089, 13, 13, 1649, 8921, 1649, 353, 525, 284, 7830, 4125, 29915, 13, 3166, 29784, 1053, 10924, 2158, 29892, 1857, 29918, 932, 29892, 2009, 13, 3166, 1371, 414, 1053, 6162, 6774, 13, 5215, 7274, 13, 3166, 4390, 1053, 270, 17204, 29892, 15376, 13, 3166, 360, 11881, 10493, 2451, 1053, 1059, 29918, 13789, 13, 3166, 29784, 29918, 5060, 1319, 1053, 18981, 29892, 29749, 13, 5215, 12183, 13, 3166, 432, 29893, 29883, 17929, 1053, 432, 29893, 29895, 13, 3166, 6789, 9884, 1053, 922, 339, 2063, 13, 8382, 29918, 1188, 353, 12183, 29889, 657, 16363, 703, 8382, 1159, 13, 21707, 353, 12183, 29889, 657, 16363, 703, 16506, 1159, 13, 2754, 29918, 29903, 682, 29918, 9539, 2158, 353, 10924, 2158, 703, 2754, 29918, 29903, 682, 29918, 9539, 2158, 613, 4770, 978, 1649, 29897, 13, 2754, 353, 29749, 580, 13, 2754, 29889, 2344, 29918, 932, 29898, 2754, 29918, 29903, 682, 29918, 9539, 2158, 29897, 13, 13, 3044, 353, 922, 339, 2063, 703, 3170, 29918, 25503, 341, 29887, 29885, 593, 313, 29903, 682, 19123, 426, 1800, 13, 29937, 1053, 4903, 20034, 919, 13, 29937, 732, 2754, 29889, 276, 26081, 877, 6214, 29914, 3134, 1495, 13, 29937, 822, 1962, 29918, 3134, 29898, 1272, 29892, 775, 29892, 9066, 29922, 8516, 1125, 13, 29937, 268, 565, 338, 8758, 29898, 1272, 29892, 9657, 1125, 13, 29937, 308, 921, 29885, 353, 8853, 5327, 1115, 848, 29913, 13, 29937, 308, 4613, 353, 1207, 29918, 5327, 29898, 3134, 20034, 919, 29889, 348, 5510, 29898, 29916, 29885, 29892, 5051, 29922, 5574, 511, 775, 29897, 13, 29937, 308, 4613, 29889, 13662, 29889, 21843, 29898, 13662, 29897, 13, 29937, 308, 736, 4613, 13, 13, 1990, 16034, 29898, 6848, 1125, 13, 1678, 732, 2704, 29918, 13789, 13, 1678, 822, 679, 29898, 1311, 1125, 13, 4706, 4660, 353, 8853, 4882, 1115, 376, 21094, 613, 376, 5509, 29918, 8513, 1115, 376, 29903, 682, 9092, 13, 4706, 736, 4660, 13, 13, 1990, 3630, 17907, 29898, 6848, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 2428, 29898, 1469, 17907, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 5509, 29918, 2271, 353, 1857, 29918, 932, 29889, 2917, 3366, 6304, 19059, 29918, 4219, 3108, 13, 4706, 1583, 29889, 6891, 29918, 2271, 353, 1857, 29918, 932, 29889, 2917, 3366, 4590, 1001, 1299, 1955, 29918, 4219, 3108, 13, 4706, 1583, 29889, 3952, 6774, 353, 6162, 6774, 29898, 3784, 29918, 932, 29889, 2917, 29897, 13, 13, 1678, 732, 2704, 29918, 13789, 13, 1678, 822, 1400, 29898, 1311, 1125, 29871, 396, 14402, 8561, 445, 263, 12354, 13, 4706, 822, 23011, 29918, 6979, 29898, 6891, 29918, 2271, 29892, 2407, 29918, 333, 1125, 13, 9651, 18074, 29889, 7662, 703, 29934, 264, 809, 292, 13189, 25159, 23157, 13, 9651, 5993, 353, 7274, 29889, 657, 29898, 13, 18884, 29850, 6822, 2754, 29914, 29896, 29889, 29906, 29914, 7283, 29914, 5150, 29918, 6979, 29914, 8875, 1642, 4830, 29898, 6891, 29918, 2271, 29892, 2407, 29918, 333, 876, 29871, 396, 14402, 3617, 7882, 2224, 515, 777, 2295, 29973, 13, 9651, 4744, 29918, 1188, 29889, 3888, 703, 29912, 1118, 24335, 24335, 6571, 1642, 4830, 29898, 6979, 29889, 2271, 29892, 5993, 29889, 23147, 29892, 5993, 29889, 4882, 29918, 401, 29892, 5993, 29889, 726, 876, 13, 9651, 3787, 29918, 8977, 353, 426, 7283, 29918, 333, 29901, 270, 17204, 29898, 18132, 29898, 6979, 29889, 726, 29889, 12508, 22130, 29913, 13, 9651, 1583, 29889, 3952, 6774, 29889, 8899, 6066, 29898, 8899, 29918, 8977, 29897, 13, 13, 4706, 822, 4331, 29918, 29896, 7295, 13, 9651, 8636, 353, 2009, 29889, 3126, 13, 9651, 4744, 29918, 1188, 29889, 3888, 29898, 7529, 29897, 13, 9651, 4744, 29918, 1188, 29889, 3888, 29898, 3827, 29889, 3126, 29897, 13, 9651, 1404, 29918, 333, 353, 8636, 3366, 1792, 29918, 333, 3108, 13, 9651, 2181, 29918, 333, 353, 8636, 3366, 7283, 29918, 333, 3108, 13, 9651, 20371, 29918, 333, 353, 8636, 3366, 2288, 29918, 333, 3108, 13, 9651, 18074, 29889, 7662, 703, 2577, 848, 29918, 842, 29918, 333, 515, 11971, 4390, 1159, 13, 9651, 848, 29918, 842, 29918, 333, 353, 2009, 29889, 5085, 29889, 657, 703, 24713, 29918, 333, 613, 6213, 29897, 13, 9651, 4744, 29918, 1188, 29889, 3888, 703, 1272, 29918, 842, 29918, 333, 338, 313, 8875, 511, 2181, 29918, 333, 338, 313, 8875, 511, 1404, 29918, 333, 21313, 1800, 322, 20371, 29918, 333, 21313, 1800, 29908, 13, 462, 965, 869, 4830, 29898, 1272, 29918, 842, 29918, 333, 29892, 2181, 29918, 333, 29892, 1404, 29918, 333, 29892, 20371, 29918, 333, 876, 13, 9651, 18074, 29889, 7662, 703, 4391, 2009, 1159, 13, 9651, 12428, 353, 8853, 705, 864, 1115, 376, 1272, 9092, 13, 13, 9651, 18074, 29889, 7662, 703, 7211, 403, 15600, 1159, 13, 9651, 2181, 353, 1583, 29889, 3952, 6774, 29889, 15480, 29918, 7283, 29898, 7283, 29918, 333, 29892, 1190, 9102, 403, 29918, 333, 29922, 1792, 29918, 333, 29897, 13, 13, 9651, 18074, 29889, 7662, 703, 7211, 403, 10729, 515, 3740, 1159, 13, 9651, 4978, 29918, 26045, 353, 1583, 29889, 3952, 6774, 29889, 15480, 29918, 3827, 29918, 3166, 29918, 1481, 29898, 7283, 29892, 848, 29918, 842, 29918, 333, 29892, 20371, 29918, 333, 29897, 13, 13, 9651, 396, 383, 3486, 848, 2009, 23942, 13, 9651, 396, 3630, 2009, 23942, 6699, 287, 29889, 13, 9651, 4744, 29918, 1188, 29889, 3888, 703, 1469, 2009, 23942, 6699, 287, 23157, 13, 9651, 736, 2181, 29918, 333, 29892, 2181, 29892, 4978, 29918, 26045, 13, 4706, 2181, 29918, 333, 29892, 2181, 29892, 4978, 29918, 26045, 353, 4331, 29918, 29896, 580, 13, 13, 4706, 18074, 29889, 7662, 703, 7211, 403, 13361, 4371, 25159, 1159, 13, 4706, 1190, 9102, 403, 29918, 333, 353, 2181, 3366, 7283, 3108, 3366, 9435, 29918, 1595, 3108, 3366, 7610, 9102, 403, 29918, 333, 3108, 13, 4706, 1749, 29918, 1989, 353, 1583, 29889, 3952, 6774, 29889, 657, 29918, 1989, 580, 13, 4706, 1749, 29918, 1989, 29918, 5467, 353, 1749, 29918, 1989, 3366, 5467, 3108, 13, 4706, 14335, 353, 29871, 29941, 29871, 396, 14402, 29901, 3617, 445, 515, 2295, 13, 4706, 1550, 5852, 29901, 13, 9651, 1018, 29901, 13, 18884, 12990, 353, 1583, 29889, 3952, 6774, 29889, 15480, 29918, 8921, 2133, 29918, 6979, 29898, 7283, 29918, 333, 29892, 1190, 9102, 403, 29918, 333, 29892, 1749, 29918, 1989, 29918, 5467, 29897, 13, 18884, 2867, 13, 9651, 5174, 7865, 2392, 408, 321, 29901, 13, 18884, 4744, 29918, 1188, 29889, 11739, 29898, 29872, 29897, 13, 18884, 23011, 29918, 6979, 29898, 1311, 29889, 6891, 29918, 2271, 29892, 2181, 29918, 333, 29897, 13, 18884, 565, 14335, 1275, 29871, 29900, 29901, 13, 462, 1678, 12020, 16738, 2392, 703, 6444, 5993, 8845, 5229, 322, 337, 2202, 6795, 13461, 287, 23157, 13, 18884, 14335, 22361, 29871, 29896, 13, 9651, 5174, 20948, 408, 321, 29901, 13, 18884, 4744, 29918, 1188, 29889, 11739, 29898, 29872, 29897, 13, 18884, 12020, 16738, 2392, 703, 6066, 1304, 2086, 4720, 29892, 8870, 1259, 23157, 13, 13, 4706, 396, 7849, 1147, 9215, 322, 8454, 2400, 338, 2309, 297, 278, 12725, 29918, 8921, 2133, 29918, 6979, 740, 491, 432, 29893, 29883, 17929, 13, 4706, 396, 383, 3486, 13361, 4371, 25159, 4475, 304, 15600, 515, 848, 8635, 491, 20371, 29918, 333, 313, 7283, 29918, 333, 7897, 13, 4706, 396, 5399, 17100, 537, 313, 9954, 287, 491, 5455, 29892, 6607, 1061, 29915, 29879, 970, 1820, 508, 367, 1476, 515, 27146, 29934, 29897, 13, 4706, 396, 5399, 376, 29902, 893, 6742, 29908, 14334, 13, 4706, 396, 5399, 376, 3664, 10949, 29908, 14334, 13, 4706, 396, 5399, 376, 3664, 2860, 29908, 14334, 13, 13, 4706, 396, 5399, 393, 376, 1491, 29908, 3743, 1959, 970, 1820, 29898, 29949, 332, 1820, 1846, 13, 13, 4706, 396, 6418, 29911, 29901, 25159, 1518, 2859, 13, 4706, 396, 3617, 716, 13361, 2133, 5993, 29892, 1369, 1449, 515, 8845, 29889, 396, 14402, 29901, 8561, 1438, 6576, 664, 408, 3168, 393, 1246, 278, 2446, 4331, 29889, 13, 13, 4706, 396, 5399, 3988, 15038, 297, 376, 15052, 29908, 1746, 13, 4706, 396, 5399, 393, 6699, 287, 4978, 23942, 508, 367, 1476, 515, 376, 15052, 29908, 1746, 13, 13, 13, 4706, 396, 25159, 2854, 630, 13, 4706, 4744, 29918, 1188, 29889, 3888, 703, 6444, 25159, 15758, 630, 23157, 13, 4706, 396, 2973, 1438, 1023, 6576, 317, 682, 756, 26834, 393, 372, 29915, 29879, 6068, 304, 1207, 2009, 29889, 13, 13, 4706, 396, 1281, 4984, 2009, 13, 4706, 18074, 29889, 7662, 703, 1168, 4984, 2009, 1159, 13, 4706, 396, 7605, 2009, 3988, 515, 376, 15052, 29908, 1746, 13, 4706, 396, 3462, 13361, 4371, 25159, 304, 2009, 13, 4706, 396, 10729, 13319, 29889, 13, 4706, 396, 9954, 2009, 13, 4706, 396, 383, 3486, 2024, 1820, 5101, 310, 970, 1820, 6790, 297, 13361, 4371, 25159, 29915, 29879, 376, 1491, 29908, 1746, 29889, 13, 4706, 396, 9954, 411, 6699, 287, 2024, 1820, 13, 4706, 18074, 29889, 7662, 703, 20927, 1820, 1304, 304, 1804, 2009, 1159, 13, 4706, 1749, 29918, 1989, 29918, 8159, 353, 432, 29893, 29895, 29889, 29967, 29956, 29968, 580, 13, 4706, 1749, 29918, 1989, 29918, 8159, 29889, 5215, 29918, 1989, 29898, 1068, 473, 29918, 1989, 3366, 1989, 20068, 13, 4706, 396, 3462, 12608, 304, 2009, 13, 4706, 396, 10729, 8794, 29889, 13, 4706, 396, 10729, 2825, 29889, 13, 4706, 18074, 29889, 6717, 29918, 517, 703, 3170, 29918, 25503, 341, 29887, 29885, 593, 313, 4435, 19123, 376, 1469, 10729, 313, 9837, 29925, 6433, 25760, 13, 4706, 396, 8561, 3630, 10729, 13, 4706, 363, 3142, 297, 4978, 29918, 26045, 29901, 13, 9651, 12428, 353, 7274, 29889, 657, 29898, 2271, 29892, 13, 462, 965, 4817, 29922, 10140, 287, 3089, 29898, 6979, 29922, 15052, 29892, 1804, 29918, 5696, 29922, 5574, 29892, 1804, 29918, 2084, 29922, 5574, 29892, 1820, 29922, 473, 29918, 1989, 29918, 8159, 29892, 6364, 29922, 29881, 17204, 29898, 473, 29918, 1989, 3366, 771, 29873, 3108, 4961, 13, 4706, 4744, 29918, 1188, 29889, 3888, 703, 29924, 1943, 848, 2009, 322, 4520, 1494, 848, 515, 7562, 29901, 320, 29876, 29912, 5038, 13, 462, 539, 869, 4830, 29898, 29881, 17204, 29898, 18132, 29898, 7971, 29889, 3051, 511, 29536, 29922, 29906, 4961, 13, 4706, 4660, 353, 8853, 4882, 1115, 376, 554, 613, 376, 5509, 29918, 8513, 1115, 376, 29903, 682, 9092, 13, 4706, 736, 4660, 13, 13, 13, 13, 2754, 29889, 1202, 29918, 10314, 29898, 5709, 29892, 8207, 2344, 1495, 13, 2754, 29889, 1202, 29918, 10314, 29898, 1469, 17907, 29892, 8207, 13891, 1495, 13, 13, 29937, 2754, 29889, 1202, 29918, 10314, 29898, 1469, 17907, 29892, 8207, 1792, 29914, 29966, 1807, 29901, 1792, 29918, 333, 20690, 3200, 296, 9182, 29914, 29966, 1807, 29901, 7283, 29918, 333, 20690, 10314, 2697, 29914, 29966, 1807, 29901, 2288, 29918, 333, 29958, 1495, 13, 29937, 29908, 1124, 597, 5509, 29918, 14036, 29901, 29955, 29900, 29900, 29900, 29914, 2754, 29914, 29896, 29889, 29906, 29914, 29879, 682, 29918, 1731, 29914, 1792, 29914, 29929, 29945, 29946, 29955, 29929, 29874, 29900, 29947, 29899, 29947, 29900, 617, 29899, 29946, 29941, 29945, 29929, 29899, 2291, 29906, 29947, 29899, 29890, 29947, 1113, 29906, 29941, 600, 29945, 29945, 29955, 29906, 29918, 29945, 29941, 2142, 29947, 29947, 13891, 29899, 29941, 29941, 311, 29899, 29946, 29946, 915, 29899, 12328, 29941, 29900, 29899, 29872, 29900, 29947, 29906, 29953, 2585, 29929, 6448, 29953, 29883, 29914, 3200, 296, 9182, 29914, 2252, 29946, 29941, 29896, 29945, 29900, 29929, 29899, 29955, 29955, 29955, 29874, 29899, 29946, 29906, 29947, 29945, 29899, 29947, 29906, 29896, 29896, 29899, 29929, 29945, 29883, 29945, 562, 29945, 29955, 29955, 29945, 29941, 29955, 29914, 10314, 2697, 29914, 1124, 29995, 29941, 29909, 29995, 29906, 29943, 29995, 29906, 29943, 5509, 29918, 14036, 29995, 29941, 29909, 29955, 29900, 29900, 29900, 29995, 29955, 29907, 29995, 29955, 29907, 29929, 29874, 27885, 29946, 29947, 29955, 29899, 29900, 29883, 29947, 29941, 29899, 29946, 29896, 29941, 29929, 29899, 29890, 29896, 29906, 29883, 29899, 29881, 29955, 29888, 346, 29874, 29929, 29941, 29874, 29941, 328, 29908, 2 ]
examples/exersice2DimRed.py
s2812135/Data_Challenges_WiSe2122
0
17638
import numpy as np import pandas as pd import os from tqdm import tqdm import pacmap import matplotlib.pyplot as plt from sklearn.manifold import TSNE import umap def darius1(numberDirectory): path = "" if(numberDirectory == 1): directorys = [ ['training_setA/training/', 'p0'] ] if(numberDirectory == 2): directorys = [ ['training_setB/training/', 'p1'] ] if(numberDirectory == 3): directorys = [ ['training_setA/training/', 'p0'], ['training_setB/training/', 'p1'] ] dfs = [] for z, (directory, file_head) in enumerate(directorys): for i, filename in enumerate(tqdm(os.listdir(path + directory))): df_temp = pd.read_csv(path + directory + filename, skiprows=0, sep='|') dfs.append(df_temp) df = pd.concat(dfs) #df_no_nan = df.dropna() df_nan_zwero = df.replace(np.NaN, 0) df_nan_zwero.head(n=50) df_nan_none = df.replace(np.NaN, None) df_nan_none.head(n=50) df_nan_mean = df.fillna(df.mean()) df_nan_mean.head(n=50) df_nan_none_2= df.where(pd.notnull(df), None) df_nan_mean.head(n=50) #df.shape #df.head(n=80) ############################################################ # initializing the pacmap instance # Setting n_neighbors to "None" leads to a default choice shown below in "parameter" section embedding = pacmap.PaCMAP(n_dims=2, n_neighbors=None, MN_ratio=0.5, FP_ratio=2.0) # fit the data (The index of transformed data corresponds to the index of the original data) X_transformed = embedding.fit_transform(df_nan_none_2.values, init="pca") # visualize the embedding #fig, ax = plt.subplots(1, 1, figsize=(6, 6)) #ax.scatter(X_transformed[:, 0], X_transformed[:, 1], cmap="Spectral", s=0.6) plt.scatter(X_transformed[:, 0], X_transformed[:, 1], cmap="Spectral") plt.show() ############################################################# X_embedded = TSNE(n_components=2, learning_rate='auto',init='random').fit_transform(df.values) fig, ax = plt.subplots(1, 1, figsize=(6, 6)) ax.scatter(X_transformed[:, 0], X_embedded[:, 1], cmap="Spectral", c=list(df.columns), s=0.6) #############################################################
[ 1, 1053, 12655, 408, 7442, 13, 5215, 11701, 408, 10518, 13, 5215, 2897, 13, 3166, 260, 29939, 18933, 1053, 260, 29939, 18933, 13, 5215, 22906, 1958, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 3166, 2071, 19668, 29889, 1171, 361, 1025, 1053, 323, 29903, 8186, 13, 5215, 1922, 481, 13, 13, 13, 13, 1753, 270, 19563, 29896, 29898, 4537, 9882, 1125, 13, 1678, 2224, 353, 5124, 13, 13, 1678, 565, 29898, 4537, 9882, 1275, 29871, 29896, 1125, 13, 4706, 3884, 29879, 353, 518, 13, 4706, 6024, 26495, 29918, 842, 29909, 29914, 26495, 29914, 742, 525, 29886, 29900, 2033, 13, 4706, 4514, 13, 13, 1678, 565, 29898, 4537, 9882, 1275, 29871, 29906, 1125, 13, 4706, 3884, 29879, 353, 518, 13, 4706, 6024, 26495, 29918, 842, 29933, 29914, 26495, 29914, 742, 525, 29886, 29896, 2033, 13, 4706, 4514, 13, 1678, 565, 29898, 4537, 9882, 1275, 29871, 29941, 1125, 13, 4706, 3884, 29879, 353, 518, 13, 4706, 6024, 26495, 29918, 842, 29909, 29914, 26495, 29914, 742, 525, 29886, 29900, 7464, 13, 4706, 6024, 26495, 29918, 842, 29933, 29914, 26495, 29914, 742, 525, 29886, 29896, 2033, 13, 4706, 4514, 13, 13, 1678, 4489, 29879, 353, 5159, 13, 13, 1678, 363, 503, 29892, 313, 12322, 29892, 934, 29918, 2813, 29897, 297, 26985, 29898, 12322, 29879, 1125, 13, 4706, 363, 474, 29892, 10422, 297, 26985, 29898, 29873, 29939, 18933, 29898, 359, 29889, 1761, 3972, 29898, 2084, 718, 3884, 876, 1125, 13, 9651, 4489, 29918, 7382, 353, 10518, 29889, 949, 29918, 7638, 29898, 2084, 718, 3884, 718, 10422, 29892, 14383, 5727, 29922, 29900, 29892, 16345, 2433, 29989, 1495, 13, 9651, 4489, 29879, 29889, 4397, 29898, 2176, 29918, 7382, 29897, 13, 13, 1678, 4489, 353, 10518, 29889, 17685, 29898, 29069, 29897, 13, 13, 1678, 396, 2176, 29918, 1217, 29918, 13707, 353, 4489, 29889, 8865, 1056, 580, 13, 13, 1678, 4489, 29918, 13707, 29918, 29920, 556, 29877, 353, 4489, 29889, 6506, 29898, 9302, 29889, 19377, 29892, 29871, 29900, 29897, 13, 1678, 4489, 29918, 13707, 29918, 29920, 556, 29877, 29889, 2813, 29898, 29876, 29922, 29945, 29900, 29897, 13, 13, 1678, 4489, 29918, 13707, 29918, 9290, 353, 4489, 29889, 6506, 29898, 9302, 29889, 19377, 29892, 6213, 29897, 13, 1678, 4489, 29918, 13707, 29918, 9290, 29889, 2813, 29898, 29876, 29922, 29945, 29900, 29897, 13, 13, 1678, 4489, 29918, 13707, 29918, 12676, 353, 4489, 29889, 5589, 1056, 29898, 2176, 29889, 12676, 3101, 13, 1678, 4489, 29918, 13707, 29918, 12676, 29889, 2813, 29898, 29876, 29922, 29945, 29900, 29897, 13, 13, 1678, 4489, 29918, 13707, 29918, 9290, 29918, 29906, 29922, 4489, 29889, 3062, 29898, 15926, 29889, 1333, 4304, 29898, 2176, 511, 6213, 29897, 13, 1678, 4489, 29918, 13707, 29918, 12676, 29889, 2813, 29898, 29876, 29922, 29945, 29900, 29897, 13, 13, 1678, 396, 2176, 29889, 12181, 13, 1678, 396, 2176, 29889, 2813, 29898, 29876, 29922, 29947, 29900, 29897, 13, 13, 1678, 835, 13383, 13383, 13383, 7346, 29937, 13, 1678, 396, 2847, 5281, 278, 22906, 1958, 2777, 13, 1678, 396, 21605, 302, 29918, 484, 1141, 29890, 943, 304, 376, 8516, 29908, 11981, 304, 263, 2322, 7348, 4318, 2400, 297, 376, 15501, 29908, 4004, 13, 1678, 23655, 353, 22906, 1958, 29889, 11868, 29907, 23827, 29898, 29876, 29918, 6229, 29879, 29922, 29906, 29892, 302, 29918, 484, 1141, 29890, 943, 29922, 8516, 29892, 341, 29940, 29918, 3605, 601, 29922, 29900, 29889, 29945, 29892, 383, 29925, 29918, 3605, 601, 29922, 29906, 29889, 29900, 29897, 29871, 13, 13, 1678, 396, 6216, 278, 848, 313, 1576, 2380, 310, 27615, 848, 16161, 304, 278, 2380, 310, 278, 2441, 848, 29897, 13, 1678, 1060, 29918, 9067, 287, 353, 23655, 29889, 9202, 29918, 9067, 29898, 2176, 29918, 13707, 29918, 9290, 29918, 29906, 29889, 5975, 29892, 2069, 543, 29886, 1113, 1159, 13, 13, 1678, 396, 7604, 675, 278, 23655, 13, 1678, 396, 1003, 29892, 4853, 353, 14770, 29889, 1491, 26762, 29898, 29896, 29892, 29871, 29896, 29892, 2537, 2311, 7607, 29953, 29892, 29871, 29953, 876, 13, 1678, 396, 1165, 29889, 1557, 2620, 29898, 29990, 29918, 9067, 287, 7503, 29892, 29871, 29900, 1402, 1060, 29918, 9067, 287, 7503, 29892, 29871, 29896, 1402, 274, 1958, 543, 29903, 1103, 1705, 613, 269, 29922, 29900, 29889, 29953, 29897, 13, 13, 13, 1678, 14770, 29889, 1557, 2620, 29898, 29990, 29918, 9067, 287, 7503, 29892, 29871, 29900, 1402, 1060, 29918, 9067, 287, 7503, 29892, 29871, 29896, 1402, 274, 1958, 543, 29903, 1103, 1705, 1159, 13, 1678, 14770, 29889, 4294, 580, 13, 13, 1678, 835, 13383, 13383, 13383, 7346, 2277, 13, 1678, 1060, 29918, 17987, 7176, 353, 323, 29903, 8186, 29898, 29876, 29918, 14036, 29922, 29906, 29892, 6509, 29918, 10492, 2433, 6921, 742, 2344, 2433, 8172, 2824, 9202, 29918, 9067, 29898, 2176, 29889, 5975, 29897, 13, 13, 1678, 2537, 29892, 4853, 353, 14770, 29889, 1491, 26762, 29898, 29896, 29892, 29871, 29896, 29892, 2537, 2311, 7607, 29953, 29892, 29871, 29953, 876, 13, 1678, 4853, 29889, 1557, 2620, 29898, 29990, 29918, 9067, 287, 7503, 29892, 29871, 29900, 1402, 1060, 29918, 17987, 7176, 7503, 29892, 29871, 29896, 1402, 274, 1958, 543, 29903, 1103, 1705, 613, 274, 29922, 1761, 29898, 2176, 29889, 13099, 511, 269, 29922, 29900, 29889, 29953, 29897, 13, 13, 1678, 835, 13383, 13383, 13383, 7346, 2277, 2 ]
src/model/rpm_solver.py
tyler-hayes/Continual-Analogical-Reasoning
5
192277
<filename>src/model/rpm_solver.py # INFORMATION ------------------------------------------------------------------------------------------------------- # # Author: <NAME> # Date: 10/11/2019 # Purpose: Model for solving RPM problems # IMPORTS ----------------------------------------------------------------------------------------------------------- # import sys import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from basic_model import BasicModel # CONSTANTS --------------------------------------------------------------------------------------------------------- # DR_S, DR_F = .1, .5 # Dropout prob. for spatial and fully-connected layers. O_HC, O_OC = 64, 64 # Hidden and output channels for original enc. F_HC, F_OC = 64, 16 # Hidden and output channels for frame enc. S_HC, S_OC = 128, 64 # Hidden and output channels for sequence enc. F_PL, S_PL = 5 * 5, 16 # Pooled sizes for frame and sequence enc. outputs. F_Z = F_OC * F_PL # Frame embedding dimensions. K_D = 7 # Conv. kernel dimensions. BL_IN = 3 BLOUT = F_Z G_IN = BLOUT G_HID = G_IN G_OUT = G_IN R_OUT = 32 C_DIM = 2 P_DIM = 32 C = 1.0 # CLASSES ----------------------------------------------------------------------------------------------------------- # # Helper function for spatial dropout. class perm(nn.Module): def __init__(self): super(perm, self).__init__() def forward(self, x): return x.permute(0, 2, 1) class flat(nn.Module): def __init__(self): super(flat, self).__init__() def forward(self, x): return x.flatten(1) # Convolutional block class (conv, elu, bnorm, dropout). If 1D block, no downsampling. If 2D, stride==2. # Implements spatial dropout for both 1D and 2D convolutional layers. class ConvBlock(nn.Module): def __init__(self, in_ch, out_ch, dim): super(ConvBlock, self).__init__() self.conv = getattr(nn, 'Conv{}d'.format(dim))(in_ch, out_ch, K_D, stride=dim, padding=K_D // 2) self.bnrm = getattr(nn, 'BatchNorm{}d'.format(dim))(out_ch) self.drop = nn.Sequential(perm(), nn.Dropout2d(DR_S), perm()) if dim == 1 else nn.Dropout2d(DR_S) self.block = nn.Sequential(self.conv, nn.ELU(), self.bnrm, self.drop) def forward(self, x): return self.block(x) # Residual block class, made up of two convolutional blocks. class ResBlock(nn.Module): def __init__(self, in_ch, hd_ch, out_ch, dim): super(ResBlock, self).__init__() self.dim = dim self.conv = nn.Sequential(ConvBlock(in_ch, hd_ch, dim), ConvBlock(hd_ch, out_ch, dim)) self.down = nn.Sequential(nn.MaxPool2d(3, 2, 1), nn.MaxPool2d(3, 2, 1)) self.skip = getattr(nn, 'Conv{}d'.format(dim))(in_ch, out_ch, 1, bias=False) def forward(self, x): return self.conv(x) + self.skip(x if self.dim == 1 else self.down(x)) # Relational net class, defining three models with which to extract relations in RPM problems. class RelNet(nn.Module): def __init__(self, model, n_s): super(RelNet, self).__init__() self.stack = lambda x: torch.stack([torch.cat((x[:, :8], x[:, i].unsqueeze(1)), dim=1) for i in range(8, 16)], dim=1) self.model = model self.n_s = n_s if model in ["Rel-AIR", "Rel-Base"]: lin_in = S_OC * S_PL self.obj_enc = nn.Sequential(ResBlock(1, F_HC, F_HC, 2), ResBlock(F_HC, F_HC, F_OC, 2)) self.seq_enc = nn.Sequential(ResBlock(9, S_OC, S_HC, 1), nn.MaxPool1d(6, 4, 1), ResBlock(S_HC, S_HC, S_OC, 1), nn.AdaptiveAvgPool1d(S_PL)) if model in ["Rel-AIR"]: self.obj_rel = nn.Sequential(ResBlock(n_s, S_HC, S_HC, 1), ResBlock(S_HC, S_HC, 1, 1)) self.bilinear = nn.Bilinear(F_Z, BL_IN, BLOUT) self.ebd = nn.Sequential(nn.ELU(), nn.BatchNorm1d(BLOUT)) elif model in ["ResNet", "Context-blind"]: lin_in = O_OC * F_PL self.og_net = nn.Sequential(ResBlock(9 if model == "ResNet" else 8, O_HC, O_HC, 2), ResBlock(O_HC, O_HC, O_OC, 2)) else: print("Model \"{}\" unrecognised.".format(model)) sys.exit(1) if model in ["Rel-AIR", "Rel-Base", 'ResNet', 'Context-blind']: self.linear = nn.Sequential(nn.Linear(lin_in, 512), nn.ELU(), nn.BatchNorm1d(512), nn.Dropout(DR_F), nn.Linear(512, 8 if model == 'Context-blind' else 1)) def forward(self, x, n_s, t=None): if self.model in ['Rel-GNN', 'Rel-AIR']: obj, pos, n = x # 1. Encode each object, of each frame, of each RPM, separately. x = self.obj_enc(obj.view(-1, 1, 80, 80)).flatten(1) x = x.view(-1, 16, n_s, F_Z) # 2. Feed object embeddings and pos data through a bilinear layer. x = x.view(-1, F_Z) p = pos.view(-1, 3) x = self.ebd(self.bilinear(x, p)) # 3. Perform feature extraction for object relationships using residual blocks. x = x.view(-1, 16, n_s, G_IN) x = self.obj_rel(x.view(-1, n_s, G_IN)).view(-1, 16, G_IN) # 4. Assemble RPM into 8 sequences of 9 frames each (8 context + 1 answer). # Alternatively, assemble into 10 sequences of 3 frames each (2 problem rows + 8 candidate rows). x = self.stack(x) # 5. Perform feature extraction for frame relationships, and score sequences. x = self.seq_enc(x.view(-1, 9, G_OUT if self.model == 'Rel-GNN' else G_IN)).flatten(1) return self.linear(x).view(-1, 8) elif self.model == 'Rel-Base': # 1. Encode each frame independently. x = x.view(-1, 1, 80, 80) x = self.obj_enc(x).flatten(1) # 2. Assemble sequences. x = x.view(-1, 16, F_Z) x = self.stack(x) # 3. Extract frame relationships and score sequences. x = self.seq_enc(x.view(-1, 9, F_Z)).flatten(1) return self.linear(x).view(-1, 8) elif self.model == 'ResNet': # 1. Assemble sequences, extract frame relationships, score sequences. x = self.stack(x) x = self.og_net(x.view(-1, 9, 80, 80)).flatten(1) return self.linear(x).view(-1, 8) else: x = self.og_net(x[:, 8:]) return self.linear(x.flatten(1)) # Main model class. class RPM_Solver(BasicModel): def __init__(self, args): super(RPM_Solver, self).__init__(args) self.model = args.model self.rel_enc = nn.DataParallel(RelNet(args.model, args.trn_n), device_ids=[0, 1]) \ if args.multi_gpu else RelNet(args.model, args.trn_n) self.optimizer = optim.Adam(self.parameters(), lr=args.lr) def compute_loss(self, output, target, reduction='mean'): # target: bs # output: bs x 8 return F.cross_entropy(output, target, reduction=reduction) def forward(self, x, n_s, t=None): x = x if self.model == 'Rel-AIR' else 1 - x / 255.0 out = self.rel_enc(x, n_s, t) # batch_size x 8 return out # END SCRIPT -------------------------------------------------------------------------------------------------------- #
[ 1, 529, 9507, 29958, 4351, 29914, 4299, 29914, 29878, 3358, 29918, 2929, 369, 29889, 2272, 13, 29937, 2672, 19094, 8098, 448, 2683, 2683, 2683, 2683, 2683, 2683, 22158, 396, 13, 13, 29937, 13361, 29901, 29871, 529, 5813, 29958, 13, 29937, 4712, 29901, 268, 29896, 29900, 29914, 29896, 29896, 29914, 29906, 29900, 29896, 29929, 13, 29937, 15247, 4220, 29901, 8125, 363, 17069, 390, 13427, 4828, 13, 13, 29937, 306, 3580, 8476, 29903, 448, 2683, 2683, 2683, 2683, 2683, 2683, 28400, 396, 13, 13, 5215, 10876, 13, 5215, 4842, 305, 13, 5215, 4842, 305, 29889, 15755, 408, 302, 29876, 13, 5215, 4842, 305, 29889, 20640, 408, 5994, 13, 5215, 4842, 305, 29889, 15755, 29889, 2220, 284, 408, 383, 13, 3166, 6996, 29918, 4299, 1053, 19219, 3195, 13, 13, 29937, 8707, 1254, 2190, 9375, 448, 2683, 2683, 2683, 2683, 2683, 2683, 1378, 396, 13, 13, 8353, 29918, 29903, 29892, 26900, 29918, 29943, 353, 869, 29896, 29892, 869, 29945, 29871, 396, 20724, 449, 2070, 29889, 363, 18652, 322, 8072, 29899, 18045, 15359, 29889, 13, 29949, 29918, 19127, 29892, 438, 29918, 20166, 353, 29871, 29953, 29946, 29892, 29871, 29953, 29946, 29871, 396, 379, 4215, 322, 1962, 18196, 363, 2441, 2094, 29889, 13, 29943, 29918, 19127, 29892, 383, 29918, 20166, 353, 29871, 29953, 29946, 29892, 29871, 29896, 29953, 29871, 396, 379, 4215, 322, 1962, 18196, 363, 3515, 2094, 29889, 13, 29903, 29918, 19127, 29892, 317, 29918, 20166, 353, 29871, 29896, 29906, 29947, 29892, 29871, 29953, 29946, 29871, 396, 379, 4215, 322, 1962, 18196, 363, 5665, 2094, 29889, 13, 29943, 29918, 7390, 29892, 317, 29918, 7390, 353, 29871, 29945, 334, 29871, 29945, 29892, 29871, 29896, 29953, 29871, 396, 349, 3634, 839, 15786, 363, 3515, 322, 5665, 2094, 29889, 14391, 29889, 13, 29943, 29918, 29999, 353, 383, 29918, 20166, 334, 383, 29918, 7390, 29871, 396, 12218, 23655, 13391, 29889, 13, 29968, 29918, 29928, 353, 29871, 29955, 29871, 396, 1281, 29894, 29889, 8466, 13391, 29889, 13, 13, 13367, 29918, 1177, 353, 29871, 29941, 13, 29933, 3927, 2692, 353, 383, 29918, 29999, 13, 29954, 29918, 1177, 353, 350, 3927, 2692, 13, 29954, 29918, 29950, 1367, 353, 402, 29918, 1177, 13, 29954, 29918, 12015, 353, 402, 29918, 1177, 13, 29934, 29918, 12015, 353, 29871, 29941, 29906, 13, 29907, 29918, 4571, 29924, 353, 29871, 29906, 13, 29925, 29918, 4571, 29924, 353, 29871, 29941, 29906, 13, 29907, 353, 29871, 29896, 29889, 29900, 13, 13, 13, 29937, 17332, 3289, 1660, 29903, 448, 2683, 2683, 2683, 2683, 2683, 2683, 28400, 396, 13, 13, 29937, 6162, 546, 740, 363, 18652, 5768, 449, 29889, 13, 1990, 3635, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 2428, 29898, 17858, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 736, 921, 29889, 17858, 1082, 29898, 29900, 29892, 29871, 29906, 29892, 29871, 29896, 29897, 13, 13, 13, 1990, 12151, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 2428, 29898, 20620, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 736, 921, 29889, 1579, 8606, 29898, 29896, 29897, 13, 13, 13, 29937, 1281, 4068, 284, 2908, 770, 313, 20580, 29892, 560, 29884, 29892, 289, 12324, 29892, 5768, 449, 467, 960, 29871, 29896, 29928, 2908, 29892, 694, 1623, 13445, 10335, 29889, 960, 29871, 29906, 29928, 29892, 380, 2426, 1360, 29906, 29889, 13, 29937, 1954, 9711, 18652, 5768, 449, 363, 1716, 29871, 29896, 29928, 322, 29871, 29906, 29928, 26851, 284, 15359, 29889, 13, 1990, 1281, 29894, 7445, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 297, 29918, 305, 29892, 714, 29918, 305, 29892, 3964, 1125, 13, 4706, 2428, 29898, 1168, 29894, 7445, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 20580, 353, 679, 5552, 29898, 15755, 29892, 525, 1168, 29894, 8875, 29881, 4286, 4830, 29898, 6229, 876, 29898, 262, 29918, 305, 29892, 714, 29918, 305, 29892, 476, 29918, 29928, 29892, 380, 2426, 29922, 6229, 29892, 7164, 29922, 29968, 29918, 29928, 849, 29871, 29906, 29897, 13, 4706, 1583, 29889, 11197, 1758, 353, 679, 5552, 29898, 15755, 29892, 525, 23145, 29940, 555, 8875, 29881, 4286, 4830, 29898, 6229, 876, 29898, 449, 29918, 305, 29897, 13, 4706, 1583, 29889, 8865, 353, 302, 29876, 29889, 16941, 2556, 29898, 17858, 3285, 302, 29876, 29889, 15063, 449, 29906, 29881, 29898, 8353, 29918, 29903, 511, 3635, 3101, 565, 3964, 1275, 29871, 29896, 1683, 302, 29876, 29889, 15063, 449, 29906, 29881, 29898, 8353, 29918, 29903, 29897, 13, 4706, 1583, 29889, 1271, 353, 302, 29876, 29889, 16941, 2556, 29898, 1311, 29889, 20580, 29892, 302, 29876, 29889, 6670, 29965, 3285, 1583, 29889, 11197, 1758, 29892, 1583, 29889, 8865, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 736, 1583, 29889, 1271, 29898, 29916, 29897, 13, 13, 13, 29937, 2538, 333, 950, 2908, 770, 29892, 1754, 701, 310, 1023, 26851, 284, 10930, 29889, 13, 1990, 2538, 7445, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 297, 29918, 305, 29892, 298, 29881, 29918, 305, 29892, 714, 29918, 305, 29892, 3964, 1125, 13, 4706, 2428, 29898, 1666, 7445, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 6229, 353, 3964, 13, 4706, 1583, 29889, 20580, 353, 302, 29876, 29889, 16941, 2556, 29898, 1168, 29894, 7445, 29898, 262, 29918, 305, 29892, 298, 29881, 29918, 305, 29892, 3964, 511, 1281, 29894, 7445, 29898, 16440, 29918, 305, 29892, 714, 29918, 305, 29892, 3964, 876, 13, 4706, 1583, 29889, 3204, 353, 302, 29876, 29889, 16941, 2556, 29898, 15755, 29889, 7976, 11426, 29906, 29881, 29898, 29941, 29892, 29871, 29906, 29892, 29871, 29896, 511, 302, 29876, 29889, 7976, 11426, 29906, 29881, 29898, 29941, 29892, 29871, 29906, 29892, 29871, 29896, 876, 13, 4706, 1583, 29889, 11014, 353, 679, 5552, 29898, 15755, 29892, 525, 1168, 29894, 8875, 29881, 4286, 4830, 29898, 6229, 876, 29898, 262, 29918, 305, 29892, 714, 29918, 305, 29892, 29871, 29896, 29892, 24003, 29922, 8824, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 736, 1583, 29889, 20580, 29898, 29916, 29897, 718, 1583, 29889, 11014, 29898, 29916, 565, 1583, 29889, 6229, 1275, 29871, 29896, 1683, 1583, 29889, 3204, 29898, 29916, 876, 13, 13, 13, 29937, 6376, 1288, 7787, 770, 29892, 16184, 2211, 4733, 411, 607, 304, 6597, 5302, 297, 390, 13427, 4828, 29889, 13, 1990, 6376, 6779, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1904, 29892, 302, 29918, 29879, 1125, 13, 4706, 2428, 29898, 9662, 6779, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 1429, 353, 14013, 921, 29901, 4842, 305, 29889, 1429, 4197, 7345, 305, 29889, 4117, 3552, 29916, 7503, 29892, 584, 29947, 1402, 921, 7503, 29892, 474, 1822, 6948, 802, 29872, 911, 29898, 29896, 8243, 3964, 29922, 29896, 29897, 363, 474, 297, 3464, 29898, 29947, 29892, 29871, 29896, 29953, 29897, 1402, 13, 462, 462, 965, 3964, 29922, 29896, 29897, 13, 4706, 1583, 29889, 4299, 353, 1904, 13, 4706, 1583, 29889, 29876, 29918, 29879, 353, 302, 29918, 29879, 13, 13, 4706, 565, 1904, 297, 6796, 9662, 29899, 29909, 8193, 613, 376, 9662, 29899, 5160, 3108, 29901, 13, 9651, 6276, 29918, 262, 353, 317, 29918, 20166, 334, 317, 29918, 7390, 13, 9651, 1583, 29889, 5415, 29918, 3977, 353, 302, 29876, 29889, 16941, 2556, 29898, 1666, 7445, 29898, 29896, 29892, 383, 29918, 19127, 29892, 383, 29918, 19127, 29892, 29871, 29906, 511, 2538, 7445, 29898, 29943, 29918, 19127, 29892, 383, 29918, 19127, 29892, 383, 29918, 20166, 29892, 29871, 29906, 876, 13, 9651, 1583, 29889, 11762, 29918, 3977, 353, 302, 29876, 29889, 16941, 2556, 29898, 1666, 7445, 29898, 29929, 29892, 317, 29918, 20166, 29892, 317, 29918, 19127, 29892, 29871, 29896, 511, 302, 29876, 29889, 7976, 11426, 29896, 29881, 29898, 29953, 29892, 29871, 29946, 29892, 29871, 29896, 511, 13, 462, 462, 308, 2538, 7445, 29898, 29903, 29918, 19127, 29892, 317, 29918, 19127, 29892, 317, 29918, 20166, 29892, 29871, 29896, 511, 302, 29876, 29889, 29909, 1388, 415, 573, 12810, 29887, 11426, 29896, 29881, 29898, 29903, 29918, 7390, 876, 13, 9651, 565, 1904, 297, 6796, 9662, 29899, 29909, 8193, 3108, 29901, 13, 18884, 1583, 29889, 5415, 29918, 2674, 353, 302, 29876, 29889, 16941, 2556, 29898, 1666, 7445, 29898, 29876, 29918, 29879, 29892, 317, 29918, 19127, 29892, 317, 29918, 19127, 29892, 29871, 29896, 511, 2538, 7445, 29898, 29903, 29918, 19127, 29892, 317, 29918, 19127, 29892, 29871, 29896, 29892, 29871, 29896, 876, 13, 18884, 1583, 29889, 18152, 457, 279, 353, 302, 29876, 29889, 29933, 309, 457, 279, 29898, 29943, 29918, 29999, 29892, 350, 29931, 29918, 1177, 29892, 350, 3927, 2692, 29897, 13, 18884, 1583, 29889, 774, 29881, 353, 302, 29876, 29889, 16941, 2556, 29898, 15755, 29889, 6670, 29965, 3285, 302, 29876, 29889, 23145, 29940, 555, 29896, 29881, 29898, 29933, 3927, 2692, 876, 13, 13, 4706, 25342, 1904, 297, 6796, 1666, 6779, 613, 376, 2677, 29899, 2204, 513, 3108, 29901, 13, 9651, 6276, 29918, 262, 353, 438, 29918, 20166, 334, 383, 29918, 7390, 13, 9651, 1583, 29889, 468, 29918, 1212, 353, 302, 29876, 29889, 16941, 2556, 29898, 1666, 7445, 29898, 29929, 565, 1904, 1275, 376, 1666, 6779, 29908, 1683, 29871, 29947, 29892, 438, 29918, 19127, 29892, 438, 29918, 19127, 29892, 29871, 29906, 511, 13, 462, 462, 4706, 2538, 7445, 29898, 29949, 29918, 19127, 29892, 438, 29918, 19127, 29892, 438, 29918, 20166, 29892, 29871, 29906, 876, 13, 13, 4706, 1683, 29901, 13, 9651, 1596, 703, 3195, 13218, 29912, 1012, 29908, 443, 29423, 3368, 1213, 29889, 4830, 29898, 4299, 876, 13, 9651, 10876, 29889, 13322, 29898, 29896, 29897, 13, 13, 4706, 565, 1904, 297, 6796, 9662, 29899, 29909, 8193, 613, 376, 9662, 29899, 5160, 613, 525, 1666, 6779, 742, 525, 2677, 29899, 2204, 513, 2033, 29901, 13, 9651, 1583, 29889, 10660, 353, 302, 29876, 29889, 16941, 2556, 29898, 15755, 29889, 12697, 29898, 1915, 29918, 262, 29892, 29871, 29945, 29896, 29906, 511, 302, 29876, 29889, 6670, 29965, 3285, 302, 29876, 29889, 23145, 29940, 555, 29896, 29881, 29898, 29945, 29896, 29906, 511, 302, 29876, 29889, 15063, 449, 29898, 8353, 29918, 29943, 511, 13, 462, 462, 4706, 302, 29876, 29889, 12697, 29898, 29945, 29896, 29906, 29892, 29871, 29947, 565, 1904, 1275, 525, 2677, 29899, 2204, 513, 29915, 1683, 29871, 29896, 876, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 29892, 302, 29918, 29879, 29892, 260, 29922, 8516, 1125, 13, 4706, 565, 1583, 29889, 4299, 297, 6024, 9662, 29899, 29954, 10262, 742, 525, 9662, 29899, 29909, 8193, 2033, 29901, 13, 9651, 5446, 29892, 926, 29892, 302, 353, 921, 13, 13, 9651, 396, 29871, 29896, 29889, 1174, 401, 1269, 1203, 29892, 310, 1269, 3515, 29892, 310, 1269, 390, 13427, 29892, 16949, 29889, 13, 9651, 921, 353, 1583, 29889, 5415, 29918, 3977, 29898, 5415, 29889, 1493, 6278, 29896, 29892, 29871, 29896, 29892, 29871, 29947, 29900, 29892, 29871, 29947, 29900, 8106, 1579, 8606, 29898, 29896, 29897, 13, 9651, 921, 353, 921, 29889, 1493, 6278, 29896, 29892, 29871, 29896, 29953, 29892, 302, 29918, 29879, 29892, 383, 29918, 29999, 29897, 13, 13, 9651, 396, 29871, 29906, 29889, 5169, 287, 1203, 8297, 29881, 886, 322, 926, 848, 1549, 263, 13181, 457, 279, 7546, 29889, 13, 9651, 921, 353, 921, 29889, 1493, 6278, 29896, 29892, 383, 29918, 29999, 29897, 13, 9651, 282, 353, 926, 29889, 1493, 6278, 29896, 29892, 29871, 29941, 29897, 13, 9651, 921, 353, 1583, 29889, 774, 29881, 29898, 1311, 29889, 18152, 457, 279, 29898, 29916, 29892, 282, 876, 13, 13, 9651, 396, 29871, 29941, 29889, 27313, 4682, 4805, 428, 363, 1203, 21702, 773, 10995, 950, 10930, 29889, 13, 9651, 921, 353, 921, 29889, 1493, 6278, 29896, 29892, 29871, 29896, 29953, 29892, 302, 29918, 29879, 29892, 402, 29918, 1177, 29897, 13, 9651, 921, 353, 1583, 29889, 5415, 29918, 2674, 29898, 29916, 29889, 1493, 6278, 29896, 29892, 302, 29918, 29879, 29892, 402, 29918, 1177, 8106, 1493, 6278, 29896, 29892, 29871, 29896, 29953, 29892, 402, 29918, 1177, 29897, 13, 13, 9651, 396, 29871, 29946, 29889, 4007, 6967, 390, 13427, 964, 29871, 29947, 15602, 310, 29871, 29929, 16608, 1269, 313, 29947, 3030, 718, 29871, 29896, 1234, 467, 13, 9651, 396, 259, 20360, 29892, 24940, 964, 29871, 29896, 29900, 15602, 310, 29871, 29941, 16608, 1269, 313, 29906, 1108, 4206, 718, 29871, 29947, 14020, 4206, 467, 13, 9651, 921, 353, 1583, 29889, 1429, 29898, 29916, 29897, 13, 13, 9651, 396, 29871, 29945, 29889, 27313, 4682, 4805, 428, 363, 3515, 21702, 29892, 322, 8158, 15602, 29889, 13, 9651, 921, 353, 1583, 29889, 11762, 29918, 3977, 29898, 29916, 29889, 1493, 6278, 29896, 29892, 29871, 29929, 29892, 402, 29918, 12015, 565, 1583, 29889, 4299, 1275, 525, 9662, 29899, 29954, 10262, 29915, 1683, 402, 29918, 1177, 8106, 1579, 8606, 29898, 29896, 29897, 13, 9651, 736, 1583, 29889, 10660, 29898, 29916, 467, 1493, 6278, 29896, 29892, 29871, 29947, 29897, 13, 13, 4706, 25342, 1583, 29889, 4299, 1275, 525, 9662, 29899, 5160, 2396, 13, 9651, 396, 29871, 29896, 29889, 1174, 401, 1269, 3515, 25499, 29889, 13, 9651, 921, 353, 921, 29889, 1493, 6278, 29896, 29892, 29871, 29896, 29892, 29871, 29947, 29900, 29892, 29871, 29947, 29900, 29897, 13, 9651, 921, 353, 1583, 29889, 5415, 29918, 3977, 29898, 29916, 467, 1579, 8606, 29898, 29896, 29897, 13, 13, 9651, 396, 29871, 29906, 29889, 4007, 6967, 15602, 29889, 13, 9651, 921, 353, 921, 29889, 1493, 6278, 29896, 29892, 29871, 29896, 29953, 29892, 383, 29918, 29999, 29897, 13, 9651, 921, 353, 1583, 29889, 1429, 29898, 29916, 29897, 13, 13, 9651, 396, 29871, 29941, 29889, 7338, 1461, 3515, 21702, 322, 8158, 15602, 29889, 13, 9651, 921, 353, 1583, 29889, 11762, 29918, 3977, 29898, 29916, 29889, 1493, 6278, 29896, 29892, 29871, 29929, 29892, 383, 29918, 29999, 8106, 1579, 8606, 29898, 29896, 29897, 13, 9651, 736, 1583, 29889, 10660, 29898, 29916, 467, 1493, 6278, 29896, 29892, 29871, 29947, 29897, 13, 13, 4706, 25342, 1583, 29889, 4299, 1275, 525, 1666, 6779, 2396, 13, 9651, 396, 29871, 29896, 29889, 4007, 6967, 15602, 29892, 6597, 3515, 21702, 29892, 8158, 15602, 29889, 13, 9651, 921, 353, 1583, 29889, 1429, 29898, 29916, 29897, 13, 9651, 921, 353, 1583, 29889, 468, 29918, 1212, 29898, 29916, 29889, 1493, 6278, 29896, 29892, 29871, 29929, 29892, 29871, 29947, 29900, 29892, 29871, 29947, 29900, 8106, 1579, 8606, 29898, 29896, 29897, 13, 9651, 736, 1583, 29889, 10660, 29898, 29916, 467, 1493, 6278, 29896, 29892, 29871, 29947, 29897, 13, 13, 4706, 1683, 29901, 13, 9651, 921, 353, 1583, 29889, 468, 29918, 1212, 29898, 29916, 7503, 29892, 29871, 29947, 29901, 2314, 13, 9651, 736, 1583, 29889, 10660, 29898, 29916, 29889, 1579, 8606, 29898, 29896, 876, 13, 13, 13, 29937, 4241, 1904, 770, 29889, 13, 1990, 390, 13427, 29918, 13296, 369, 29898, 16616, 3195, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 6389, 1125, 13, 4706, 2428, 29898, 29934, 13427, 29918, 13296, 369, 29892, 1583, 467, 1649, 2344, 12035, 5085, 29897, 13, 4706, 1583, 29889, 4299, 353, 6389, 29889, 4299, 13, 4706, 1583, 29889, 2674, 29918, 3977, 353, 302, 29876, 29889, 1469, 2177, 6553, 29898, 9662, 6779, 29898, 5085, 29889, 4299, 29892, 6389, 29889, 509, 29876, 29918, 29876, 511, 4742, 29918, 4841, 11759, 29900, 29892, 29871, 29896, 2314, 320, 13, 9651, 565, 6389, 29889, 9910, 29918, 29887, 3746, 1683, 6376, 6779, 29898, 5085, 29889, 4299, 29892, 6389, 29889, 509, 29876, 29918, 29876, 29897, 13, 4706, 1583, 29889, 20640, 3950, 353, 5994, 29889, 3253, 314, 29898, 1311, 29889, 16744, 3285, 301, 29878, 29922, 5085, 29889, 29212, 29897, 13, 13, 1678, 822, 10272, 29918, 6758, 29898, 1311, 29892, 1962, 29892, 3646, 29892, 20376, 2433, 12676, 29374, 13, 4706, 396, 3646, 29901, 24512, 13, 4706, 396, 1962, 29901, 24512, 921, 29871, 29947, 13, 4706, 736, 383, 29889, 19128, 29918, 296, 14441, 29898, 4905, 29892, 3646, 29892, 20376, 29922, 9313, 428, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 29892, 302, 29918, 29879, 29892, 260, 29922, 8516, 1125, 13, 4706, 921, 353, 921, 565, 1583, 29889, 4299, 1275, 525, 9662, 29899, 29909, 8193, 29915, 1683, 29871, 29896, 448, 921, 847, 29871, 29906, 29945, 29945, 29889, 29900, 13, 4706, 714, 353, 1583, 29889, 2674, 29918, 3977, 29898, 29916, 29892, 302, 29918, 29879, 29892, 260, 29897, 29871, 396, 9853, 29918, 2311, 921, 29871, 29947, 13, 4706, 736, 714, 13, 13, 29937, 11056, 12314, 24290, 448, 2683, 2683, 2683, 2683, 2683, 2683, 26589, 396, 13, 2 ]
tests/rules/test_gcloud_cli.py
ronandoolan2/thefuck
0
44413
<reponame>ronandoolan2/thefuck<gh_stars>0 import pytest from thefuck.rules.gcloud_cli import match, get_new_command from thefuck.types import Command no_suggestions = '''\ ERROR: (gcloud) Command name argument expected. ''' misspelled_command = '''\ ERROR: (gcloud) Invalid choice: 'comute'. Usage: gcloud [optional flags] <group | command> group may be access-context-manager | ai-platform | alpha | app | asset | auth | beta | bigtable | builds | components | composer | compute | config | container | dataflow | dataproc | datastore | debug | deployment-manager | dns | domains | endpoints | filestore | firebase | functions | iam | iot | kms | logging | ml | ml-engine | organizations | projects | pubsub | redis | resource-manager | scheduler | services | source | spanner | sql | tasks | topic command may be docker | feedback | help | info | init | version For detailed information on this command and its flags, run: gcloud --help ''' misspelled_subcommand = '''\ ERROR: (gcloud.compute) Invalid choice: 'instance'. Maybe you meant: gcloud compute instance-groups gcloud compute instance-templates gcloud compute instances gcloud compute target-instances To search the help text of gcloud commands, run: gcloud help -- SEARCH_TERMS ''' @pytest.mark.parametrize('command', [ Command('gcloud comute instances list', misspelled_subcommand), Command('gcloud compute instance list', misspelled_subcommand)]) def test_match(command): assert match(command) def test_not_match(): assert not match(Command('aws dynamodb invalid', no_suggestions)) @pytest.mark.parametrize('command, result', [ (Command('gcloud comute instances list', misspelled_subcommand), ['gcloud compute instance-groups']), (Command('gcloud compute instance list', misspelled_subcommand), ['gcloud compute instance-groups'])]) def test_get_new_command(command, result): assert get_new_command(command) == result
[ 1, 529, 276, 1112, 420, 29958, 1617, 392, 1507, 273, 29906, 29914, 1552, 29888, 2707, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 5215, 11451, 1688, 13, 13, 3166, 278, 29888, 2707, 29889, 19238, 29889, 29887, 9274, 29918, 11303, 1053, 1993, 29892, 679, 29918, 1482, 29918, 6519, 13, 3166, 278, 29888, 2707, 29889, 8768, 1053, 10516, 13, 13, 1217, 29918, 29879, 12981, 2297, 353, 14550, 29905, 13, 11432, 29901, 313, 29887, 9274, 29897, 10516, 1024, 2980, 3806, 29889, 13, 12008, 13, 13, 9894, 13111, 839, 29918, 6519, 353, 14550, 29905, 13, 11432, 29901, 313, 29887, 9274, 29897, 21403, 7348, 29901, 525, 510, 1082, 4286, 13, 27573, 29901, 330, 9274, 518, 25253, 13449, 29962, 529, 2972, 891, 1899, 29958, 13, 29871, 2318, 1122, 367, 965, 2130, 29899, 4703, 29899, 12847, 891, 7468, 29899, 12120, 891, 15595, 891, 623, 891, 13, 462, 308, 24342, 891, 4817, 891, 21762, 891, 4802, 2371, 891, 23315, 891, 7117, 891, 13, 462, 308, 18422, 891, 10272, 891, 2295, 891, 5639, 891, 848, 1731, 891, 13, 462, 308, 1418, 481, 10198, 891, 1418, 579, 487, 891, 4744, 891, 18209, 29899, 12847, 891, 13, 462, 308, 270, 1983, 891, 21904, 891, 1095, 9748, 891, 977, 22818, 891, 16119, 891, 13, 462, 308, 3168, 891, 474, 314, 891, 474, 327, 891, 413, 1516, 891, 12183, 891, 286, 29880, 891, 13, 462, 308, 286, 29880, 29899, 10599, 891, 25700, 891, 9279, 891, 2529, 1491, 891, 29825, 891, 13, 462, 308, 6503, 29899, 12847, 891, 1364, 14952, 891, 5786, 891, 2752, 891, 13, 462, 308, 805, 7310, 891, 4576, 891, 9595, 891, 11261, 13, 29871, 1899, 1122, 367, 308, 10346, 891, 16705, 891, 1371, 891, 5235, 891, 2069, 891, 1873, 13, 13, 2831, 13173, 2472, 373, 445, 1899, 322, 967, 13449, 29892, 1065, 29901, 13, 29871, 330, 9274, 1192, 8477, 13, 12008, 13, 13, 9894, 13111, 839, 29918, 1491, 6519, 353, 14550, 29905, 13, 11432, 29901, 313, 29887, 9274, 29889, 26017, 29897, 21403, 7348, 29901, 525, 8758, 4286, 13, 22762, 366, 6839, 29901, 13, 29871, 330, 9274, 10272, 2777, 29899, 13155, 13, 29871, 330, 9274, 10272, 2777, 29899, 20943, 13, 29871, 330, 9274, 10272, 8871, 13, 29871, 330, 9274, 10272, 3646, 29899, 2611, 2925, 13, 13, 1762, 2740, 278, 1371, 1426, 310, 330, 9274, 8260, 29892, 1065, 29901, 13, 29871, 330, 9274, 1371, 1192, 3725, 1718, 3210, 29918, 4945, 4345, 13, 12008, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 877, 6519, 742, 518, 13, 1678, 10516, 877, 29887, 9274, 419, 1082, 8871, 1051, 742, 3052, 13111, 839, 29918, 1491, 6519, 511, 13, 1678, 10516, 877, 29887, 9274, 10272, 2777, 1051, 742, 3052, 13111, 839, 29918, 1491, 6519, 29897, 2314, 13, 1753, 1243, 29918, 4352, 29898, 6519, 1125, 13, 1678, 4974, 1993, 29898, 6519, 29897, 13, 13, 13, 1753, 1243, 29918, 1333, 29918, 4352, 7295, 13, 1678, 4974, 451, 1993, 29898, 6255, 877, 10467, 4292, 10396, 8340, 742, 694, 29918, 29879, 12981, 2297, 876, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 877, 6519, 29892, 1121, 742, 518, 13, 1678, 313, 6255, 877, 29887, 9274, 419, 1082, 8871, 1051, 742, 3052, 13111, 839, 29918, 1491, 6519, 511, 13, 268, 6024, 29887, 9274, 10272, 2777, 29899, 13155, 2033, 511, 13, 1678, 313, 6255, 877, 29887, 9274, 10272, 2777, 1051, 742, 3052, 13111, 839, 29918, 1491, 6519, 511, 13, 268, 6024, 29887, 9274, 10272, 2777, 29899, 13155, 11287, 2314, 13, 1753, 1243, 29918, 657, 29918, 1482, 29918, 6519, 29898, 6519, 29892, 1121, 1125, 13, 1678, 4974, 679, 29918, 1482, 29918, 6519, 29898, 6519, 29897, 1275, 1121, 13, 2 ]
vanilla_clean_acc.py
inspire-group/PatchCleanser
3
172145
import torch import torch.backends.cudnn as cudnn import numpy as np import os import argparse import time from tqdm import tqdm from utils.setup import get_model,get_data_loader parser = argparse.ArgumentParser() parser.add_argument("--model_dir",default='checkpoints',type=str,help="directory of checkpoints") parser.add_argument('--data_dir', default='data', type=str,help="directory of data") parser.add_argument('--dataset', default='imagenette',type=str,choices=('imagenette','imagenet','cifar','cifar100','svhn','flower102'),help="dataset") parser.add_argument("--model",default='vit_base_patch16_224',type=str,help="model name") parser.add_argument("--num_img",default=-1,type=int,help="number of randomly selected images for this experiment (-1: using the all images)") args = parser.parse_args() DATASET = args.dataset MODEL_DIR=os.path.join('.',args.model_dir) DATA_DIR=os.path.join(args.data_dir,DATASET) MODEL_NAME = args.model NUM_IMG = args.num_img #get model and data loader model = get_model(MODEL_NAME,DATASET,MODEL_DIR) val_loader,NUM_IMG,_ = get_data_loader(DATASET,DATA_DIR,model,batch_size=16,num_img=NUM_IMG,train=False) device = 'cuda' model = model.to(device) model.eval() cudnn.benchmark = True accuracy_list=[] time_list=[] for data,labels in tqdm(val_loader): data,labels=data.to(device),labels.to(device) start = time.time() output_clean = model(data) end=time.time() time_list.append(end-start) acc_clean=torch.sum(torch.argmax(output_clean, dim=1) == labels).item()#cpu().detach().numpy() accuracy_list.append(acc_clean) print("Test accuracy:",np.sum(accuracy_list)/NUM_IMG) print('Per-example inference time:',np.sum(time_list)/NUM_IMG)
[ 1, 1053, 4842, 305, 13, 5215, 4842, 305, 29889, 1627, 1975, 29889, 29883, 566, 15755, 408, 274, 566, 15755, 13, 13, 5215, 12655, 408, 7442, 29871, 13, 5215, 2897, 29871, 13, 5215, 1852, 5510, 13, 5215, 931, 13, 3166, 260, 29939, 18933, 1053, 260, 29939, 18933, 13, 13, 3166, 3667, 29879, 29889, 14669, 1053, 679, 29918, 4299, 29892, 657, 29918, 1272, 29918, 12657, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 13, 16680, 29889, 1202, 29918, 23516, 703, 489, 4299, 29918, 3972, 613, 4381, 2433, 3198, 9748, 742, 1853, 29922, 710, 29892, 8477, 543, 12322, 310, 1423, 9748, 1159, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 1272, 29918, 3972, 742, 2322, 2433, 1272, 742, 1134, 29922, 710, 29892, 8477, 543, 12322, 310, 848, 1159, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 24713, 742, 2322, 2433, 326, 5370, 2353, 742, 1853, 29922, 710, 29892, 1859, 1575, 29922, 877, 326, 5370, 2353, 3788, 326, 5370, 300, 3788, 29883, 361, 279, 3788, 29883, 361, 279, 29896, 29900, 29900, 3788, 4501, 3123, 3788, 1731, 261, 29896, 29900, 29906, 5477, 8477, 543, 24713, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 489, 4299, 613, 4381, 2433, 29894, 277, 29918, 3188, 29918, 5041, 29896, 29953, 29918, 29906, 29906, 29946, 742, 1853, 29922, 710, 29892, 8477, 543, 4299, 1024, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 489, 1949, 29918, 2492, 613, 4381, 10457, 29896, 29892, 1853, 29922, 524, 29892, 8477, 543, 4537, 310, 20459, 4629, 4558, 363, 445, 7639, 8521, 29896, 29901, 773, 278, 599, 4558, 25760, 13, 13, 5085, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 25832, 8127, 29911, 353, 6389, 29889, 24713, 13, 20387, 29931, 29918, 9464, 29922, 359, 29889, 2084, 29889, 7122, 12839, 742, 5085, 29889, 4299, 29918, 3972, 29897, 13, 14573, 29918, 9464, 29922, 359, 29889, 2084, 29889, 7122, 29898, 5085, 29889, 1272, 29918, 3972, 29892, 25832, 8127, 29911, 29897, 13, 20387, 29931, 29918, 5813, 353, 6389, 29889, 4299, 13, 13967, 29918, 7833, 29954, 353, 6389, 29889, 1949, 29918, 2492, 13, 13, 29937, 657, 1904, 322, 848, 23466, 13, 4299, 353, 679, 29918, 4299, 29898, 20387, 29931, 29918, 5813, 29892, 25832, 8127, 29911, 29892, 20387, 29931, 29918, 9464, 29897, 13, 791, 29918, 12657, 29892, 13967, 29918, 7833, 29954, 29892, 29918, 353, 679, 29918, 1272, 29918, 12657, 29898, 25832, 8127, 29911, 29892, 14573, 29918, 9464, 29892, 4299, 29892, 16175, 29918, 2311, 29922, 29896, 29953, 29892, 1949, 29918, 2492, 29922, 13967, 29918, 7833, 29954, 29892, 14968, 29922, 8824, 29897, 13, 13, 10141, 353, 525, 29883, 6191, 29915, 29871, 13, 4299, 353, 1904, 29889, 517, 29898, 10141, 29897, 13, 4299, 29889, 14513, 580, 13, 29883, 566, 15755, 29889, 1785, 16580, 353, 5852, 13, 13, 562, 2764, 4135, 29918, 1761, 29922, 2636, 13, 2230, 29918, 1761, 29922, 2636, 13, 1454, 848, 29892, 21134, 297, 260, 29939, 18933, 29898, 791, 29918, 12657, 1125, 13, 12, 1272, 29892, 21134, 29922, 1272, 29889, 517, 29898, 10141, 511, 21134, 29889, 517, 29898, 10141, 29897, 13, 12, 2962, 353, 931, 29889, 2230, 580, 13, 12, 4905, 29918, 14941, 353, 1904, 29898, 1272, 29897, 13, 12, 355, 29922, 2230, 29889, 2230, 580, 13, 12, 2230, 29918, 1761, 29889, 4397, 29898, 355, 29899, 2962, 29897, 13, 12, 5753, 29918, 14941, 29922, 7345, 305, 29889, 2083, 29898, 7345, 305, 29889, 1191, 3317, 29898, 4905, 29918, 14941, 29892, 3964, 29922, 29896, 29897, 1275, 11073, 467, 667, 580, 29937, 21970, 2141, 4801, 496, 2141, 23749, 580, 13, 12, 562, 2764, 4135, 29918, 1761, 29889, 4397, 29898, 5753, 29918, 14941, 29897, 13, 12, 13, 2158, 703, 3057, 13600, 29901, 613, 9302, 29889, 2083, 29898, 562, 2764, 4135, 29918, 1761, 6802, 13967, 29918, 7833, 29954, 29897, 13, 2158, 877, 5894, 29899, 4773, 27262, 931, 29901, 742, 9302, 29889, 2083, 29898, 2230, 29918, 1761, 6802, 13967, 29918, 7833, 29954, 29897, 13, 13, 2 ]
core/migrations/populate_andelacenter.py
raheemazeezabiodun/art-backend
4
1615168
<gh_stars>1-10 from django.db import migrations def add_user_location(apps, schema_editor): User = apps.get_model('core', 'User') location = apps.get_model('core', 'AndelaCentre') center = None for user in User.objects.all(): if location.objects.filter(country="Kenya").exists(): # A Kenyan center exists center = location.objects.filter(country="Kenya")[0] else: # Create an Andela center in Kenya location.objects.create(centre_name="Dojo", country="Kenya") center = location.objects.filter(country="Kenya")[0] user.location = center user.save() class Migration(migrations.Migration): dependencies = [ ('core', '0030_user_location'), ] operations = [ migrations.RunPython(add_user_location), ]
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 3166, 9557, 29889, 2585, 1053, 9725, 800, 13, 13, 13, 1753, 788, 29918, 1792, 29918, 5479, 29898, 13371, 29892, 10938, 29918, 15204, 1125, 13, 1678, 4911, 353, 11446, 29889, 657, 29918, 4299, 877, 3221, 742, 525, 2659, 1495, 13, 1678, 4423, 353, 11446, 29889, 657, 29918, 4299, 877, 3221, 742, 525, 2855, 3100, 29907, 14056, 1495, 13, 1678, 4818, 353, 6213, 13, 1678, 363, 1404, 297, 4911, 29889, 12650, 29889, 497, 7295, 13, 4706, 565, 4423, 29889, 12650, 29889, 4572, 29898, 13509, 543, 29968, 264, 3761, 2564, 9933, 7295, 13, 9651, 396, 319, 10015, 10094, 4818, 4864, 13, 9651, 4818, 353, 4423, 29889, 12650, 29889, 4572, 29898, 13509, 543, 29968, 264, 3761, 1159, 29961, 29900, 29962, 13, 4706, 1683, 29901, 13, 9651, 396, 6204, 385, 1126, 3100, 4818, 297, 10015, 3761, 13, 9651, 4423, 29889, 12650, 29889, 3258, 29898, 1760, 276, 29918, 978, 543, 6132, 2212, 613, 4234, 543, 29968, 264, 3761, 1159, 13, 9651, 4818, 353, 4423, 29889, 12650, 29889, 4572, 29898, 13509, 543, 29968, 264, 3761, 1159, 29961, 29900, 29962, 13, 4706, 1404, 29889, 5479, 353, 4818, 13, 4706, 1404, 29889, 7620, 580, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 13, 4706, 6702, 3221, 742, 525, 29900, 29900, 29941, 29900, 29918, 1792, 29918, 5479, 5477, 13, 1678, 4514, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 6558, 11980, 29898, 1202, 29918, 1792, 29918, 5479, 511, 13, 1678, 4514, 13, 2 ]
tests_python/tests_011/test_migration.py
bikallem/tezos
8
194143
<reponame>bikallem/tezos from typing import Dict, List import time import pytest from launchers.sandbox import Sandbox from tools import constants, utils from tools.constants import PROTO_GENESIS from . import protocol MIGRATION_LEVEL = 8 BAKER = 'bootstrap1' BAKER_PKH = constants.IDENTITIES[BAKER]['identity'] PREV_DEPOSIT = protocol.PREV_PARAMETERS["block_security_deposit"] DEPOSIT = protocol.PARAMETERS["block_security_deposit"] PREV_DEPOSIT_RECEIPTS = [ { "kind": "contract", "contract": BAKER_PKH, "change": "-" + PREV_DEPOSIT, "origin": "block", }, { "kind": "freezer", "category": "deposits", "delegate": BAKER_PKH, "cycle": 0, "change": PREV_DEPOSIT, "origin": "block", }, ] DEPOSIT_RECEIPTS = [ { "kind": "contract", "contract": BAKER_PKH, "change": "-" + DEPOSIT, "origin": "block", }, { "kind": "freezer", "category": "deposits", "delegate": BAKER_PKH, "cycle": 1, "change": DEPOSIT, "origin": "block", }, ] MIGRATION_RECEIPTS: List[Dict[str, str]] = [] # configure user-activate-upgrade at MIGRATION_LEVEL to test migration NODE_CONFIG = { 'network': { 'genesis': { 'timestamp': '2018-06-30T16:07:32Z', 'block': 'BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2', 'protocol': PROTO_GENESIS, }, 'genesis_parameters': { 'values': {'genesis_pubkey': constants.GENESIS_PK} }, 'chain_name': 'TEZOS', 'sandboxed_chain_name': 'SANDBOXED_TEZOS', 'user_activated_upgrades': [ {'level': MIGRATION_LEVEL, 'replacement_protocol': protocol.HASH} ], } } @pytest.fixture(scope="class") def client(sandbox): sandbox.add_node(0, node_config=NODE_CONFIG) protocol.activate( sandbox.client(0), proto=protocol.PREV_HASH, parameters=protocol.PREV_PARAMETERS, activate_in_the_past=True, ) yield sandbox.client(0) @pytest.mark.incremental class TestMigration: """Test migration from PROTO_A (the previous protocol) to PROTO_B (the current protocol). After migration, test snapshots: - node0: activate PROTO_A, migrate to PROTO_B, bake, export a snapshot in full and rolling modes, and terminate - node1: import full, bake - node2: import rolling, sync, bake - node3: reconstruct full, sync, bake - all 4 are synced """ def test_init(self, client): # 1: genesis block client.get_head() client.rpc('get', '/config/network/user_activated_upgrades') def test_activate(self, client, sandbox): # 2: activated PROTO_A utils.bake(client, BAKER) assert client.get_protocol() == protocol.PREV_HASH assert sandbox.client(0).get_head()['header']['proto'] == 1 metadata = client.get_metadata() assert metadata['balance_updates'] == PREV_DEPOSIT_RECEIPTS # PROTO_A is using env. V1+, metadata hashes should be present _ops_metadata_hash = client.get_operations_metadata_hash() _block_metadata_hash = client.get_block_metadata_hash() def test_migration(self, client, sandbox): # 3: last block of PROTO_A, runs migration code (MIGRATION_LEVEL) for _i in range(MIGRATION_LEVEL - 2): utils.bake(client, BAKER) metadata = client.get_metadata() assert metadata['next_protocol'] == protocol.HASH assert metadata['balance_updates'] == PREV_DEPOSIT_RECEIPTS # PROTO_B is using env. V1+, metadata hashes should be present _ops_metadata_hash = client.get_operations_metadata_hash() _block_metadata_hash = client.get_block_metadata_hash() assert sandbox.client(0).get_head()['header']['proto'] == 2 def test_new_proto(self, client, sandbox): # 4: first block of PROTO_B utils.bake(client, BAKER) assert client.get_protocol() == protocol.HASH assert sandbox.client(0).get_head()['header']['proto'] == 2 # check that migration balance update appears in receipts metadata = client.get_metadata() assert metadata['balance_updates'] == ( MIGRATION_RECEIPTS + DEPOSIT_RECEIPTS ) _ops_metadata_hash = client.get_operations_metadata_hash() _block_metadata_hash = client.get_block_metadata_hash() def test_new_proto_second(self, client): # 5: second block of PROTO_B utils.bake(client, BAKER) metadata = client.get_metadata() assert metadata['balance_updates'] == DEPOSIT_RECEIPTS def test_terminate_node0(self, client, sandbox: Sandbox, session: dict): # to export rolling snapshot, we need to be at level > 60 # (see `max_operations_ttl`) level = client.get_head()['header']['level'] for _ in range(60 - level + 1): utils.bake(client, BAKER) assert client.get_head()['header']['level'] == 61 # terminate node0 session['head_hash'] = sandbox.client(0).get_head()['hash'] sandbox.node(0).terminate() time.sleep(1) def test_export_snapshots(self, sandbox, tmpdir, session: dict): node_export = sandbox.node(0) file_full = f'{tmpdir}/FILE.full' file_rolling = f'{tmpdir}/FILE.rolling' head_hash = session['head_hash'] session['snapshot_full'] = file_full session['snapshot_rolling'] = file_rolling node_export.snapshot_export(file_full, params=['--block', head_hash]) node_export.snapshot_export( file_rolling, params=['--block', head_hash, '--rolling'] ) def test_import_full_snapshot_node1(self, sandbox, session): sandbox.add_node( 1, snapshot=session['snapshot_full'], node_config=NODE_CONFIG ) client = sandbox.client(1) utils.bake(client, BAKER) def test_import_rolling_snapshot_node2(self, sandbox, session): sandbox.add_node( 2, snapshot=session['snapshot_rolling'], node_config=NODE_CONFIG ) client = sandbox.client(2) utils.synchronize([sandbox.client(1), client], max_diff=0) utils.bake(client, BAKER) def test_reconstruct_full_node3(self, sandbox, session): sandbox.add_node( 3, snapshot=session['snapshot_full'], node_config=NODE_CONFIG ) sandbox.node(3).terminate() time.sleep(3) sandbox.node(3).reconstruct() sandbox.node(3).run() client = sandbox.client(3) assert client.check_node_listening() utils.synchronize( [sandbox.client(1), sandbox.client(2), client], max_diff=0 ) utils.bake(client, BAKER) def test_rerun_node0(self, sandbox): sandbox.node(0).run() sandbox.client(0).check_node_listening() utils.synchronize(sandbox.all_clients(), max_diff=0)
[ 1, 529, 276, 1112, 420, 29958, 29890, 23587, 2409, 29914, 371, 29834, 13, 3166, 19229, 1053, 360, 919, 29892, 2391, 13, 5215, 931, 13, 13, 5215, 11451, 1688, 13, 13, 3166, 6826, 414, 29889, 29879, 26738, 1053, 8564, 1884, 13, 3166, 8492, 1053, 17727, 29892, 3667, 29879, 13, 3166, 8492, 29889, 3075, 1934, 1053, 13756, 4986, 29918, 24647, 2890, 3235, 13, 3166, 869, 1053, 9608, 13, 13, 29924, 6259, 29934, 8098, 29918, 1307, 29963, 6670, 353, 29871, 29947, 13, 5688, 29968, 1001, 353, 525, 8704, 29896, 29915, 13, 5688, 29968, 1001, 29918, 21738, 29950, 353, 17727, 29889, 1367, 3919, 1806, 29059, 29961, 5688, 29968, 1001, 22322, 22350, 2033, 13, 15094, 29963, 29918, 2287, 24815, 1806, 353, 9608, 29889, 15094, 29963, 29918, 16320, 25797, 4945, 29903, 3366, 1271, 29918, 8926, 29918, 311, 1066, 277, 3108, 13, 2287, 24815, 1806, 353, 9608, 29889, 16320, 25797, 4945, 29903, 3366, 1271, 29918, 8926, 29918, 311, 1066, 277, 3108, 13, 13, 15094, 29963, 29918, 2287, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 353, 518, 13, 1678, 426, 13, 4706, 376, 14380, 1115, 376, 1285, 1461, 613, 13, 4706, 376, 1285, 1461, 1115, 350, 22311, 1001, 29918, 21738, 29950, 29892, 13, 4706, 376, 3167, 1115, 11663, 29908, 718, 349, 1525, 29963, 29918, 2287, 24815, 1806, 29892, 13, 4706, 376, 12574, 1115, 376, 1271, 613, 13, 1678, 2981, 13, 1678, 426, 13, 4706, 376, 14380, 1115, 376, 9021, 3298, 613, 13, 4706, 376, 7320, 1115, 376, 311, 1066, 1169, 613, 13, 4706, 376, 21234, 1115, 350, 22311, 1001, 29918, 21738, 29950, 29892, 13, 4706, 376, 23090, 1115, 29871, 29900, 29892, 13, 4706, 376, 3167, 1115, 349, 1525, 29963, 29918, 2287, 24815, 1806, 29892, 13, 4706, 376, 12574, 1115, 376, 1271, 613, 13, 1678, 2981, 13, 29962, 13, 2287, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 353, 518, 13, 1678, 426, 13, 4706, 376, 14380, 1115, 376, 1285, 1461, 613, 13, 4706, 376, 1285, 1461, 1115, 350, 22311, 1001, 29918, 21738, 29950, 29892, 13, 4706, 376, 3167, 1115, 11663, 29908, 718, 5012, 24815, 1806, 29892, 13, 4706, 376, 12574, 1115, 376, 1271, 613, 13, 1678, 2981, 13, 1678, 426, 13, 4706, 376, 14380, 1115, 376, 9021, 3298, 613, 13, 4706, 376, 7320, 1115, 376, 311, 1066, 1169, 613, 13, 4706, 376, 21234, 1115, 350, 22311, 1001, 29918, 21738, 29950, 29892, 13, 4706, 376, 23090, 1115, 29871, 29896, 29892, 13, 4706, 376, 3167, 1115, 5012, 24815, 1806, 29892, 13, 4706, 376, 12574, 1115, 376, 1271, 613, 13, 1678, 2981, 13, 29962, 13, 29924, 6259, 29934, 8098, 29918, 1525, 4741, 5690, 9375, 29901, 2391, 29961, 21533, 29961, 710, 29892, 851, 5262, 353, 5159, 13, 13, 13, 29937, 10822, 1404, 29899, 11236, 403, 29899, 786, 8228, 472, 341, 6259, 29934, 8098, 29918, 1307, 29963, 6670, 304, 1243, 20332, 13, 6632, 2287, 29918, 25903, 353, 426, 13, 1678, 525, 11618, 2396, 426, 13, 4706, 525, 1885, 6656, 2396, 426, 13, 9651, 525, 16394, 2396, 525, 29906, 29900, 29896, 29947, 29899, 29900, 29953, 29899, 29941, 29900, 29911, 29896, 29953, 29901, 29900, 29955, 29901, 29941, 29906, 29999, 742, 13, 9651, 525, 1271, 2396, 525, 13367, 1698, 15462, 6656, 15462, 6656, 15462, 6656, 15462, 6656, 15462, 267, 4492, 29955, 29929, 29890, 29945, 29881, 29896, 7967, 29956, 29906, 742, 13, 9651, 525, 20464, 2396, 13756, 4986, 29918, 24647, 2890, 3235, 29892, 13, 4706, 2981, 13, 4706, 525, 1885, 6656, 29918, 16744, 2396, 426, 13, 9651, 525, 5975, 2396, 11117, 1885, 6656, 29918, 5467, 1989, 2396, 17727, 29889, 24647, 2890, 3235, 29918, 21738, 29913, 13, 4706, 2981, 13, 4706, 525, 14153, 29918, 978, 2396, 525, 4330, 29999, 3267, 742, 13, 4706, 525, 29879, 26738, 287, 29918, 14153, 29918, 978, 2396, 525, 29903, 2190, 4051, 29949, 29990, 3352, 29918, 4330, 29999, 3267, 742, 13, 4706, 525, 1792, 29918, 11236, 630, 29918, 786, 629, 3076, 2396, 518, 13, 9651, 11117, 5563, 2396, 341, 6259, 29934, 8098, 29918, 1307, 29963, 6670, 29892, 525, 3445, 9552, 29918, 20464, 2396, 9608, 29889, 29950, 24943, 29913, 13, 4706, 21251, 13, 1678, 500, 13, 29913, 13, 13, 13, 29992, 2272, 1688, 29889, 7241, 15546, 29898, 6078, 543, 1990, 1159, 13, 1753, 3132, 29898, 29879, 26738, 1125, 13, 1678, 11982, 1884, 29889, 1202, 29918, 3177, 29898, 29900, 29892, 2943, 29918, 2917, 29922, 6632, 2287, 29918, 25903, 29897, 13, 1678, 9608, 29889, 11236, 403, 29898, 13, 4706, 11982, 1884, 29889, 4645, 29898, 29900, 511, 13, 4706, 17814, 29922, 20464, 29889, 15094, 29963, 29918, 29950, 24943, 29892, 13, 4706, 4128, 29922, 20464, 29889, 15094, 29963, 29918, 16320, 25797, 4945, 29903, 29892, 13, 4706, 5039, 403, 29918, 262, 29918, 1552, 29918, 29886, 579, 29922, 5574, 29892, 13, 1678, 1723, 13, 1678, 7709, 11982, 1884, 29889, 4645, 29898, 29900, 29897, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 25629, 284, 13, 1990, 4321, 29924, 16783, 29901, 13, 1678, 9995, 3057, 20332, 515, 13756, 4986, 29918, 29909, 313, 1552, 3517, 9608, 29897, 304, 13756, 4986, 29918, 29933, 313, 1552, 13, 1678, 1857, 9608, 467, 13, 13, 1678, 2860, 20332, 29892, 1243, 15101, 845, 1862, 29901, 13, 4706, 448, 2943, 29900, 29901, 5039, 403, 13756, 4986, 29918, 29909, 29892, 9725, 403, 304, 13756, 4986, 29918, 29933, 29892, 289, 1296, 29892, 5609, 13, 462, 263, 22395, 297, 2989, 322, 27777, 18893, 29892, 322, 29504, 13, 4706, 448, 2943, 29896, 29901, 1053, 2989, 29892, 289, 1296, 13, 4706, 448, 2943, 29906, 29901, 1053, 27777, 29892, 16523, 29892, 289, 1296, 13, 4706, 448, 2943, 29941, 29901, 337, 11433, 2989, 29892, 16523, 29892, 289, 1296, 13, 4706, 448, 599, 29871, 29946, 526, 5222, 1133, 13, 1678, 9995, 13, 13, 1678, 822, 1243, 29918, 2344, 29898, 1311, 29892, 3132, 1125, 13, 4706, 396, 29871, 29896, 29901, 2531, 6656, 2908, 13, 4706, 3132, 29889, 657, 29918, 2813, 580, 13, 4706, 3132, 29889, 29878, 6739, 877, 657, 742, 8207, 2917, 29914, 11618, 29914, 1792, 29918, 11236, 630, 29918, 786, 629, 3076, 1495, 13, 13, 1678, 822, 1243, 29918, 11236, 403, 29898, 1311, 29892, 3132, 29892, 11982, 1884, 1125, 13, 4706, 396, 29871, 29906, 29901, 5039, 630, 13756, 4986, 29918, 29909, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 4706, 4974, 3132, 29889, 657, 29918, 20464, 580, 1275, 9608, 29889, 15094, 29963, 29918, 29950, 24943, 13, 4706, 4974, 11982, 1884, 29889, 4645, 29898, 29900, 467, 657, 29918, 2813, 580, 1839, 6672, 16215, 17529, 2033, 1275, 29871, 29896, 13, 4706, 15562, 353, 3132, 29889, 657, 29918, 19635, 580, 13, 4706, 4974, 15562, 1839, 5521, 749, 29918, 786, 15190, 2033, 1275, 349, 1525, 29963, 29918, 2287, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 13, 4706, 396, 13756, 4986, 29918, 29909, 338, 773, 8829, 29889, 478, 29896, 29974, 29892, 15562, 6608, 267, 881, 367, 2198, 13, 4706, 903, 3554, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 3372, 800, 29918, 19635, 29918, 8568, 580, 13, 4706, 903, 1271, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 1271, 29918, 19635, 29918, 8568, 580, 13, 13, 1678, 822, 1243, 29918, 29885, 16783, 29898, 1311, 29892, 3132, 29892, 11982, 1884, 1125, 13, 4706, 396, 29871, 29941, 29901, 1833, 2908, 310, 13756, 4986, 29918, 29909, 29892, 6057, 20332, 775, 313, 29924, 6259, 29934, 8098, 29918, 1307, 29963, 6670, 29897, 13, 4706, 363, 903, 29875, 297, 3464, 29898, 29924, 6259, 29934, 8098, 29918, 1307, 29963, 6670, 448, 29871, 29906, 1125, 13, 9651, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 4706, 15562, 353, 3132, 29889, 657, 29918, 19635, 580, 13, 4706, 4974, 15562, 1839, 4622, 29918, 20464, 2033, 1275, 9608, 29889, 29950, 24943, 13, 4706, 4974, 15562, 1839, 5521, 749, 29918, 786, 15190, 2033, 1275, 349, 1525, 29963, 29918, 2287, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 13, 4706, 396, 13756, 4986, 29918, 29933, 338, 773, 8829, 29889, 478, 29896, 29974, 29892, 15562, 6608, 267, 881, 367, 2198, 13, 4706, 903, 3554, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 3372, 800, 29918, 19635, 29918, 8568, 580, 13, 4706, 903, 1271, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 1271, 29918, 19635, 29918, 8568, 580, 13, 4706, 4974, 11982, 1884, 29889, 4645, 29898, 29900, 467, 657, 29918, 2813, 580, 1839, 6672, 16215, 17529, 2033, 1275, 29871, 29906, 13, 13, 1678, 822, 1243, 29918, 1482, 29918, 17529, 29898, 1311, 29892, 3132, 29892, 11982, 1884, 1125, 13, 4706, 396, 29871, 29946, 29901, 937, 2908, 310, 13756, 4986, 29918, 29933, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 4706, 4974, 3132, 29889, 657, 29918, 20464, 580, 1275, 9608, 29889, 29950, 24943, 13, 4706, 4974, 11982, 1884, 29889, 4645, 29898, 29900, 467, 657, 29918, 2813, 580, 1839, 6672, 16215, 17529, 2033, 1275, 29871, 29906, 13, 13, 4706, 396, 1423, 393, 20332, 17346, 2767, 5692, 297, 2414, 29875, 16485, 13, 4706, 15562, 353, 3132, 29889, 657, 29918, 19635, 580, 13, 4706, 4974, 15562, 1839, 5521, 749, 29918, 786, 15190, 2033, 1275, 313, 13, 9651, 341, 6259, 29934, 8098, 29918, 1525, 4741, 5690, 9375, 718, 5012, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 13, 4706, 1723, 13, 4706, 903, 3554, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 3372, 800, 29918, 19635, 29918, 8568, 580, 13, 4706, 903, 1271, 29918, 19635, 29918, 8568, 353, 3132, 29889, 657, 29918, 1271, 29918, 19635, 29918, 8568, 580, 13, 13, 1678, 822, 1243, 29918, 1482, 29918, 17529, 29918, 7496, 29898, 1311, 29892, 3132, 1125, 13, 4706, 396, 29871, 29945, 29901, 1473, 2908, 310, 13756, 4986, 29918, 29933, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 4706, 15562, 353, 3132, 29889, 657, 29918, 19635, 580, 13, 4706, 4974, 15562, 1839, 5521, 749, 29918, 786, 15190, 2033, 1275, 5012, 24815, 1806, 29918, 1525, 4741, 5690, 9375, 13, 13, 1678, 822, 1243, 29918, 18821, 403, 29918, 3177, 29900, 29898, 1311, 29892, 3132, 29892, 11982, 1884, 29901, 8564, 1884, 29892, 4867, 29901, 9657, 1125, 13, 4706, 396, 304, 5609, 27777, 22395, 29892, 591, 817, 304, 367, 472, 3233, 1405, 29871, 29953, 29900, 13, 4706, 396, 313, 4149, 421, 3317, 29918, 3372, 800, 29918, 698, 29880, 6348, 13, 4706, 3233, 353, 3132, 29889, 657, 29918, 2813, 580, 1839, 6672, 16215, 5563, 2033, 13, 4706, 363, 903, 297, 3464, 29898, 29953, 29900, 448, 3233, 718, 29871, 29896, 1125, 13, 9651, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 4706, 4974, 3132, 29889, 657, 29918, 2813, 580, 1839, 6672, 16215, 5563, 2033, 1275, 29871, 29953, 29896, 13, 13, 4706, 396, 29504, 2943, 29900, 13, 4706, 4867, 1839, 2813, 29918, 8568, 2033, 353, 11982, 1884, 29889, 4645, 29898, 29900, 467, 657, 29918, 2813, 580, 1839, 8568, 2033, 13, 4706, 11982, 1884, 29889, 3177, 29898, 29900, 467, 18821, 403, 580, 13, 4706, 931, 29889, 17059, 29898, 29896, 29897, 13, 13, 1678, 822, 1243, 29918, 15843, 29918, 29879, 8971, 845, 1862, 29898, 1311, 29892, 11982, 1884, 29892, 13128, 3972, 29892, 4867, 29901, 9657, 1125, 13, 4706, 2943, 29918, 15843, 353, 11982, 1884, 29889, 3177, 29898, 29900, 29897, 13, 4706, 934, 29918, 8159, 353, 285, 29915, 29912, 7050, 3972, 6822, 7724, 29889, 8159, 29915, 13, 4706, 934, 29918, 22155, 353, 285, 29915, 29912, 7050, 3972, 6822, 7724, 29889, 22155, 29915, 13, 4706, 2343, 29918, 8568, 353, 4867, 1839, 2813, 29918, 8568, 2033, 13, 4706, 4867, 1839, 29879, 14551, 29918, 8159, 2033, 353, 934, 29918, 8159, 13, 4706, 4867, 1839, 29879, 14551, 29918, 22155, 2033, 353, 934, 29918, 22155, 13, 4706, 2943, 29918, 15843, 29889, 29879, 14551, 29918, 15843, 29898, 1445, 29918, 8159, 29892, 8636, 29922, 1839, 489, 1271, 742, 2343, 29918, 8568, 2314, 13, 4706, 2943, 29918, 15843, 29889, 29879, 14551, 29918, 15843, 29898, 13, 9651, 934, 29918, 22155, 29892, 8636, 29922, 1839, 489, 1271, 742, 2343, 29918, 8568, 29892, 525, 489, 22155, 2033, 13, 4706, 1723, 13, 13, 1678, 822, 1243, 29918, 5215, 29918, 8159, 29918, 29879, 14551, 29918, 3177, 29896, 29898, 1311, 29892, 11982, 1884, 29892, 4867, 1125, 13, 4706, 11982, 1884, 29889, 1202, 29918, 3177, 29898, 13, 632, 29896, 29892, 22395, 29922, 7924, 1839, 29879, 14551, 29918, 8159, 7464, 2943, 29918, 2917, 29922, 6632, 2287, 29918, 25903, 13, 4706, 1723, 13, 4706, 3132, 353, 11982, 1884, 29889, 4645, 29898, 29896, 29897, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 13, 1678, 822, 1243, 29918, 5215, 29918, 22155, 29918, 29879, 14551, 29918, 3177, 29906, 29898, 1311, 29892, 11982, 1884, 29892, 4867, 1125, 13, 4706, 11982, 1884, 29889, 1202, 29918, 3177, 29898, 13, 632, 29906, 29892, 22395, 29922, 7924, 1839, 29879, 14551, 29918, 22155, 7464, 2943, 29918, 2917, 29922, 6632, 2287, 29918, 25903, 13, 4706, 1723, 13, 4706, 3132, 353, 11982, 1884, 29889, 4645, 29898, 29906, 29897, 13, 4706, 3667, 29879, 29889, 29879, 9524, 675, 4197, 29879, 26738, 29889, 4645, 29898, 29896, 511, 3132, 1402, 4236, 29918, 12765, 29922, 29900, 29897, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 13, 1678, 822, 1243, 29918, 276, 11433, 29918, 8159, 29918, 3177, 29941, 29898, 1311, 29892, 11982, 1884, 29892, 4867, 1125, 13, 4706, 11982, 1884, 29889, 1202, 29918, 3177, 29898, 13, 632, 29941, 29892, 22395, 29922, 7924, 1839, 29879, 14551, 29918, 8159, 7464, 2943, 29918, 2917, 29922, 6632, 2287, 29918, 25903, 13, 4706, 1723, 13, 4706, 11982, 1884, 29889, 3177, 29898, 29941, 467, 18821, 403, 580, 13, 4706, 931, 29889, 17059, 29898, 29941, 29897, 13, 4706, 11982, 1884, 29889, 3177, 29898, 29941, 467, 276, 11433, 580, 13, 4706, 11982, 1884, 29889, 3177, 29898, 29941, 467, 3389, 580, 13, 4706, 3132, 353, 11982, 1884, 29889, 4645, 29898, 29941, 29897, 13, 4706, 4974, 3132, 29889, 3198, 29918, 3177, 29918, 1761, 8333, 580, 13, 4706, 3667, 29879, 29889, 29879, 9524, 675, 29898, 13, 9651, 518, 29879, 26738, 29889, 4645, 29898, 29896, 511, 11982, 1884, 29889, 4645, 29898, 29906, 511, 3132, 1402, 4236, 29918, 12765, 29922, 29900, 13, 4706, 1723, 13, 4706, 3667, 29879, 29889, 29890, 1296, 29898, 4645, 29892, 350, 22311, 1001, 29897, 13, 13, 1678, 822, 1243, 29918, 2872, 348, 29918, 3177, 29900, 29898, 1311, 29892, 11982, 1884, 1125, 13, 4706, 11982, 1884, 29889, 3177, 29898, 29900, 467, 3389, 580, 13, 4706, 11982, 1884, 29889, 4645, 29898, 29900, 467, 3198, 29918, 3177, 29918, 1761, 8333, 580, 13, 4706, 3667, 29879, 29889, 29879, 9524, 675, 29898, 29879, 26738, 29889, 497, 29918, 11303, 1237, 3285, 4236, 29918, 12765, 29922, 29900, 29897, 13, 2 ]
Python-3/basic_examples/strings/string_isidentifier.py
ghiloufibelgacem/jornaldev
1,139
118470
s = 'xyzABC' print(f'{s} is a valid identifier = {s.isidentifier()}') s = '0xyz' # identifier can't start with digits 0-9 print(f'{s} is a valid identifier = {s.isidentifier()}') s = '' # identifier can't be empty string print(f'{s} is a valid identifier = {s.isidentifier()}') s = '_xyz' print(f'{s} is a valid identifier = {s.isidentifier()}') s = 'ꝗꞨꫳ' # PEP-3131 introduced Non-ASCII characters to identifier list print(f'{s} is a valid identifier = {s.isidentifier()}') import unicodedata count = 0 for codepoint in range(2 ** 16): ch = chr(codepoint) if ch.isidentifier(): print(u'{:04x}: {} ({})'.format(codepoint, ch, unicodedata.name(ch, 'UNNAMED'))) count = count + 1 print(f'Total Number of Identifier Unicode Characters = {count}')
[ 1, 269, 353, 525, 20230, 19658, 29915, 13, 13, 2158, 29898, 29888, 29915, 29912, 29879, 29913, 338, 263, 2854, 15882, 353, 426, 29879, 29889, 275, 25378, 28296, 1495, 13, 13, 29879, 353, 525, 29900, 20230, 29915, 29871, 396, 15882, 508, 29915, 29873, 1369, 411, 13340, 29871, 29900, 29899, 29929, 13, 2158, 29898, 29888, 29915, 29912, 29879, 29913, 338, 263, 2854, 15882, 353, 426, 29879, 29889, 275, 25378, 28296, 1495, 13, 13, 29879, 353, 6629, 29871, 396, 15882, 508, 29915, 29873, 367, 4069, 1347, 13, 2158, 29898, 29888, 29915, 29912, 29879, 29913, 338, 263, 2854, 15882, 353, 426, 29879, 29889, 275, 25378, 28296, 1495, 13, 13, 29879, 353, 22868, 20230, 29915, 13, 2158, 29898, 29888, 29915, 29912, 29879, 29913, 338, 263, 2854, 15882, 353, 426, 29879, 29889, 275, 25378, 28296, 1495, 13, 13, 29879, 353, 525, 237, 160, 154, 237, 161, 171, 237, 174, 182, 29915, 29871, 396, 349, 15488, 29899, 29941, 29896, 29941, 29896, 9129, 10050, 29899, 28599, 2687, 4890, 304, 15882, 1051, 13, 2158, 29898, 29888, 29915, 29912, 29879, 29913, 338, 263, 2854, 15882, 353, 426, 29879, 29889, 275, 25378, 28296, 1495, 13, 13, 5215, 443, 293, 6797, 532, 13, 13, 2798, 353, 29871, 29900, 13, 1454, 775, 3149, 297, 3464, 29898, 29906, 3579, 29871, 29896, 29953, 1125, 13, 1678, 521, 353, 18460, 29898, 401, 3149, 29897, 13, 1678, 565, 521, 29889, 275, 25378, 7295, 13, 4706, 1596, 29898, 29884, 29915, 25641, 29900, 29946, 29916, 6177, 6571, 21313, 1800, 4286, 4830, 29898, 401, 3149, 29892, 521, 29892, 443, 293, 6797, 532, 29889, 978, 29898, 305, 29892, 525, 3904, 5813, 29928, 29915, 4961, 13, 4706, 2302, 353, 2302, 718, 29871, 29896, 13, 2158, 29898, 29888, 29915, 11536, 9681, 310, 20286, 23862, 2896, 21706, 353, 426, 2798, 29913, 1495, 13, 2 ]
cal/migrations/0004_auto_20200229_1141.py
PudgyPoppins/caps
0
90954
<reponame>PudgyPoppins/caps<filename>cal/migrations/0004_auto_20200229_1141.py<gh_stars>0 # Generated by Django 3.0.3 on 2020-02-29 18:41 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('cal', '0003_calendar_event'), ] operations = [ migrations.RemoveField( model_name='event', name='recurrence', ), migrations.AddField( model_name='event', name='repeat', field=models.CharField(blank=True, help_text='Will this event ever repeat?', max_length=200, null=True), ), ]
[ 1, 529, 276, 1112, 420, 29958, 29925, 566, 1927, 29925, 9354, 1144, 29914, 29883, 2547, 29966, 9507, 29958, 1052, 29914, 26983, 800, 29914, 29900, 29900, 29900, 29946, 29918, 6921, 29918, 29906, 29900, 29906, 29900, 29900, 29906, 29906, 29929, 29918, 29896, 29896, 29946, 29896, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 3251, 630, 491, 15337, 29871, 29941, 29889, 29900, 29889, 29941, 373, 29871, 29906, 29900, 29906, 29900, 29899, 29900, 29906, 29899, 29906, 29929, 29871, 29896, 29947, 29901, 29946, 29896, 13, 13, 3166, 9557, 29889, 2585, 1053, 9725, 800, 29892, 4733, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 13, 4706, 6702, 1052, 742, 525, 29900, 29900, 29900, 29941, 29918, 23392, 29918, 3696, 5477, 13, 1678, 4514, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 15941, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 3696, 742, 13, 9651, 1024, 2433, 3757, 26841, 742, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 3696, 742, 13, 9651, 1024, 2433, 14358, 742, 13, 9651, 1746, 29922, 9794, 29889, 27890, 29898, 19465, 29922, 5574, 29892, 1371, 29918, 726, 2433, 12984, 445, 1741, 3926, 12312, 29973, 742, 4236, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 1678, 4514, 13, 2 ]
scale.app/scripts/msvc2org.py
f4rsh/SCALe
239
56621
#!/usr/bin/env python # Scrubs the output of msvc and prints out the dianostics. # # The only argument indicates the file containing the input. # # This script can produce lots of messages per diagnostic # # Copyright (c) 2007-2018 Carnegie Mellon University. All Rights Reserved. # See COPYRIGHT file for details. import sys import re import os if len(sys.argv) != 2: raise TypeError("Usage: " + sys.argv[0] + " <raw-input> > <org-output>") input = sys.argv[1] uniqueErrors = {} regexes = [] regexes.append(re.compile("(.*?)\((\d*)\).*?error (.*?): (.*)")) regexes.append(re.compile("(.*?)\((\d*),\d*\).*?error (.*?): (.*)")) regexes.append(re.compile("(.*?)\((\d*)\).*?warning (.*?): (.*)")) regexes.append(re.compile("(.*?)\((\d*),\d*\).*?warning (.*?): (.*)")) for line in open(input): # match regular expressions for regex in regexes: parse = re.match(regex, line) if parse != None: break else: continue fileLocation = parse.group(1).strip() lineNumber = parse.group(2).strip() errorNumber = parse.group(3).strip() diagonostic = parse.group(4).strip().replace("|", " ") # print table tableEntry = " | ".join( ["", errorNumber, fileLocation, lineNumber, diagonostic, ""]) print tableEntry
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 13, 29937, 2522, 29878, 23954, 278, 1962, 310, 286, 4501, 29883, 322, 14677, 714, 278, 652, 273, 520, 1199, 29889, 13, 29937, 13, 29937, 450, 871, 2980, 14088, 278, 934, 6943, 278, 1881, 29889, 13, 29937, 13, 29937, 910, 2471, 508, 7738, 14568, 310, 7191, 639, 652, 21780, 13, 29937, 13, 29937, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29900, 29955, 29899, 29906, 29900, 29896, 29947, 1704, 10052, 347, 341, 514, 265, 3014, 29889, 2178, 26863, 2538, 9841, 29889, 13, 29937, 2823, 315, 4590, 29979, 22789, 3912, 934, 363, 4902, 29889, 13, 13, 13, 5215, 10876, 13, 5215, 337, 13, 5215, 2897, 13, 13, 361, 7431, 29898, 9675, 29889, 19218, 29897, 2804, 29871, 29906, 29901, 13, 1678, 12020, 20948, 703, 27573, 29901, 376, 718, 10876, 29889, 19218, 29961, 29900, 29962, 718, 376, 529, 1610, 29899, 2080, 29958, 1405, 529, 990, 29899, 4905, 29958, 1159, 13, 2080, 353, 10876, 29889, 19218, 29961, 29896, 29962, 13, 13, 13092, 22463, 353, 6571, 13, 13087, 267, 353, 5159, 13, 13087, 267, 29889, 4397, 29898, 276, 29889, 12198, 703, 28104, 29973, 2144, 29898, 1194, 29881, 29930, 2144, 467, 29930, 29973, 2704, 313, 5575, 29973, 1125, 313, 5575, 5513, 876, 13, 13087, 267, 29889, 4397, 29898, 276, 29889, 12198, 703, 28104, 29973, 2144, 29898, 1194, 29881, 29930, 20481, 29881, 17710, 467, 29930, 29973, 2704, 313, 5575, 29973, 1125, 313, 5575, 5513, 876, 13, 13087, 267, 29889, 4397, 29898, 276, 29889, 12198, 703, 28104, 29973, 2144, 29898, 1194, 29881, 29930, 2144, 467, 29930, 29973, 27392, 313, 5575, 29973, 1125, 313, 5575, 5513, 876, 13, 13087, 267, 29889, 4397, 29898, 276, 29889, 12198, 703, 28104, 29973, 2144, 29898, 1194, 29881, 29930, 20481, 29881, 17710, 467, 29930, 29973, 27392, 313, 5575, 29973, 1125, 313, 5575, 5513, 876, 13, 13, 1454, 1196, 297, 1722, 29898, 2080, 1125, 13, 1678, 396, 1993, 4943, 12241, 13, 1678, 363, 6528, 297, 6528, 267, 29901, 13, 4706, 6088, 353, 337, 29889, 4352, 29898, 13087, 29892, 1196, 29897, 13, 4706, 565, 6088, 2804, 6213, 29901, 13, 9651, 2867, 13, 1678, 1683, 29901, 13, 4706, 6773, 13, 1678, 934, 6508, 353, 6088, 29889, 2972, 29898, 29896, 467, 17010, 580, 13, 1678, 1196, 4557, 353, 6088, 29889, 2972, 29898, 29906, 467, 17010, 580, 13, 1678, 1059, 4557, 353, 6088, 29889, 2972, 29898, 29941, 467, 17010, 580, 13, 1678, 7936, 265, 520, 293, 353, 6088, 29889, 2972, 29898, 29946, 467, 17010, 2141, 6506, 703, 29989, 613, 376, 16521, 13, 13, 1678, 396, 1596, 1591, 13, 1678, 1591, 9634, 353, 376, 891, 11393, 7122, 29898, 13, 4706, 6796, 613, 1059, 4557, 29892, 934, 6508, 29892, 1196, 4557, 29892, 7936, 265, 520, 293, 29892, 5124, 2314, 13, 1678, 1596, 1591, 9634, 13, 2 ]
src/models/decoders.py
yizhe-ang/vi-lab
1
55312
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Bernoulli from src.models.nns import Decoder class ConvDecoder(nn.Module): def __init__(self, z_dim): super().__init__() self.z_dim = z_dim self.decoder = Decoder( 128, z_dim, 28, 28, 1 ) def decode(self, z: torch.tensor) -> torch.tensor: """Decode latent points into data points Parameters ---------- z : torch.tensor [B, Z] Returns ------- torch.tensor [B, D] """ # Output is Bernoulli loc_img = torch.sigmoid(self.decoder(z)) return loc_img def forward(self, x: torch.tensor, z: torch.tensor) -> torch.tensor: """log p(x|z), reconstruction term Parameters ---------- x : torch.tensor [B, C, H, W], Data points z : torch.tensor [B, Z], Latent points Returns ------- torch.tensor [B,], log p(x|z) """ x = x.reshape(-1, 784) loc_img = self.decode(z) # FIXME Use F.binary_cross_entropy instead? it's the same dist = Bernoulli(probs=loc_img) log_px_z = dist.log_prob(x).sum(-1) # log_px_z = -F.binary_cross_entropy(loc_img, x, reduction="none").sum(-1) return log_px_z class MNISTDecoder(nn.Module): def __init__(self, z_dim, hidden_dim=400): super().__init__() self.z_dim = z_dim self.fc1 = nn.Linear(z_dim, hidden_dim) self.fc2 = nn.Linear(hidden_dim, 784) def decode(self, z: torch.tensor) -> torch.tensor: """Decode latent points into data points Parameters ---------- z : torch.tensor [B, Z] Returns ------- torch.tensor [B, D] """ hidden = F.relu(self.fc1(z)) # Output is Bernoulli loc_img = torch.sigmoid(self.fc2(hidden)) return loc_img def forward(self, x: torch.tensor, z: torch.tensor) -> torch.tensor: """log p(x|z), reconstruction term Parameters ---------- x : torch.tensor [B, C, H, W], Data points z : torch.tensor [B, Z], Latent points Returns ------- torch.tensor [B,], log p(x|z) """ x = x.reshape(-1, 784) loc_img = self.decode(z) # FIXME Use F.binary_cross_entropy instead? it's the same dist = Bernoulli(probs=loc_img) log_px_z = dist.log_prob(x).sum(-1) # log_px_z = -F.binary_cross_entropy(loc_img, x, reduction="none").sum(-1) return log_px_z
[ 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, 4842, 305, 29889, 27691, 29879, 1053, 6209, 5059, 492, 13, 13, 3166, 4765, 29889, 9794, 29889, 29876, 1983, 1053, 3826, 6119, 13, 13, 1990, 1281, 29894, 6185, 6119, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 503, 29918, 6229, 1125, 13, 4706, 2428, 2141, 1649, 2344, 1649, 580, 13, 13, 4706, 1583, 29889, 29920, 29918, 6229, 353, 503, 29918, 6229, 13, 4706, 1583, 29889, 7099, 6119, 353, 3826, 6119, 29898, 13, 632, 29896, 29906, 29947, 29892, 13, 9651, 503, 29918, 6229, 29892, 13, 632, 29906, 29947, 29892, 13, 632, 29906, 29947, 29892, 13, 632, 29896, 13, 4706, 1723, 13, 13, 1678, 822, 21822, 29898, 1311, 29892, 503, 29901, 4842, 305, 29889, 20158, 29897, 1599, 4842, 305, 29889, 20158, 29901, 13, 4706, 9995, 2772, 401, 3405, 296, 3291, 964, 848, 3291, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 503, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 796, 29962, 13, 13, 4706, 16969, 13, 4706, 448, 22158, 13, 4706, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 360, 29962, 13, 4706, 9995, 13, 4706, 396, 10604, 338, 6209, 5059, 492, 13, 4706, 1180, 29918, 2492, 353, 4842, 305, 29889, 18816, 29885, 3398, 29898, 1311, 29889, 7099, 6119, 29898, 29920, 876, 13, 13, 4706, 736, 1180, 29918, 2492, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 29901, 4842, 305, 29889, 20158, 29892, 503, 29901, 4842, 305, 29889, 20158, 29897, 1599, 4842, 305, 29889, 20158, 29901, 13, 4706, 9995, 1188, 282, 29898, 29916, 29989, 29920, 511, 17789, 4080, 1840, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 921, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 315, 29892, 379, 29892, 399, 1402, 3630, 3291, 13, 4706, 503, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 796, 1402, 7053, 296, 3291, 13, 13, 4706, 16969, 13, 4706, 448, 22158, 13, 4706, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 1402, 1480, 282, 29898, 29916, 29989, 29920, 29897, 13, 4706, 9995, 13, 4706, 921, 353, 921, 29889, 690, 14443, 6278, 29896, 29892, 29871, 29955, 29947, 29946, 29897, 13, 13, 4706, 1180, 29918, 2492, 353, 1583, 29889, 13808, 29898, 29920, 29897, 13, 13, 4706, 396, 383, 6415, 2303, 4803, 383, 29889, 19541, 29918, 19128, 29918, 296, 14441, 2012, 29973, 372, 29915, 29879, 278, 1021, 13, 4706, 1320, 353, 6209, 5059, 492, 29898, 771, 5824, 29922, 2029, 29918, 2492, 29897, 13, 4706, 1480, 29918, 1756, 29918, 29920, 353, 1320, 29889, 1188, 29918, 22795, 29898, 29916, 467, 2083, 6278, 29896, 29897, 13, 13, 4706, 396, 1480, 29918, 1756, 29918, 29920, 353, 448, 29943, 29889, 19541, 29918, 19128, 29918, 296, 14441, 29898, 2029, 29918, 2492, 29892, 921, 29892, 20376, 543, 9290, 2564, 2083, 6278, 29896, 29897, 13, 13, 4706, 736, 1480, 29918, 1756, 29918, 29920, 13, 13, 13, 1990, 341, 29940, 9047, 6185, 6119, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 503, 29918, 6229, 29892, 7934, 29918, 6229, 29922, 29946, 29900, 29900, 1125, 13, 4706, 2428, 2141, 1649, 2344, 1649, 580, 13, 13, 4706, 1583, 29889, 29920, 29918, 6229, 353, 503, 29918, 6229, 13, 13, 4706, 1583, 29889, 13801, 29896, 353, 302, 29876, 29889, 12697, 29898, 29920, 29918, 6229, 29892, 7934, 29918, 6229, 29897, 13, 4706, 1583, 29889, 13801, 29906, 353, 302, 29876, 29889, 12697, 29898, 10892, 29918, 6229, 29892, 29871, 29955, 29947, 29946, 29897, 13, 13, 1678, 822, 21822, 29898, 1311, 29892, 503, 29901, 4842, 305, 29889, 20158, 29897, 1599, 4842, 305, 29889, 20158, 29901, 13, 4706, 9995, 2772, 401, 3405, 296, 3291, 964, 848, 3291, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 503, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 796, 29962, 13, 13, 4706, 16969, 13, 4706, 448, 22158, 13, 4706, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 360, 29962, 13, 4706, 9995, 13, 4706, 7934, 353, 383, 29889, 2674, 29884, 29898, 1311, 29889, 13801, 29896, 29898, 29920, 876, 13, 13, 4706, 396, 10604, 338, 6209, 5059, 492, 13, 4706, 1180, 29918, 2492, 353, 4842, 305, 29889, 18816, 29885, 3398, 29898, 1311, 29889, 13801, 29906, 29898, 10892, 876, 13, 13, 4706, 736, 1180, 29918, 2492, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 29901, 4842, 305, 29889, 20158, 29892, 503, 29901, 4842, 305, 29889, 20158, 29897, 1599, 4842, 305, 29889, 20158, 29901, 13, 4706, 9995, 1188, 282, 29898, 29916, 29989, 29920, 511, 17789, 4080, 1840, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 921, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 315, 29892, 379, 29892, 399, 1402, 3630, 3291, 13, 4706, 503, 584, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 796, 1402, 7053, 296, 3291, 13, 13, 4706, 16969, 13, 4706, 448, 22158, 13, 4706, 4842, 305, 29889, 20158, 13, 9651, 518, 29933, 29892, 1402, 1480, 282, 29898, 29916, 29989, 29920, 29897, 13, 4706, 9995, 13, 4706, 921, 353, 921, 29889, 690, 14443, 6278, 29896, 29892, 29871, 29955, 29947, 29946, 29897, 13, 13, 4706, 1180, 29918, 2492, 353, 1583, 29889, 13808, 29898, 29920, 29897, 13, 13, 4706, 396, 383, 6415, 2303, 4803, 383, 29889, 19541, 29918, 19128, 29918, 296, 14441, 2012, 29973, 372, 29915, 29879, 278, 1021, 13, 4706, 1320, 353, 6209, 5059, 492, 29898, 771, 5824, 29922, 2029, 29918, 2492, 29897, 13, 4706, 1480, 29918, 1756, 29918, 29920, 353, 1320, 29889, 1188, 29918, 22795, 29898, 29916, 467, 2083, 6278, 29896, 29897, 13, 13, 4706, 396, 1480, 29918, 1756, 29918, 29920, 353, 448, 29943, 29889, 19541, 29918, 19128, 29918, 296, 14441, 29898, 2029, 29918, 2492, 29892, 921, 29892, 20376, 543, 9290, 2564, 2083, 6278, 29896, 29897, 13, 13, 4706, 736, 1480, 29918, 1756, 29918, 29920, 13, 2 ]
HMQ/networks/blocks.py
UniSerj/ai-research
46
117971
import torch from torch import nn from torch.nn import functional as F from torch.distributions.uniform import Uniform from networks.layers.non_linear import NonLinear, NonLinearType from networks.layers.conv_bn import ConvBN class DropConnect(nn.Module): def __init__(self, survival_prob): """ A module that implements drop connection :param survival_prob: the probability if connection survival """ super(DropConnect, self).__init__() self.survival_prob = survival_prob self.u = Uniform(0, 1) def forward(self, x): """ The forward function of the DropConnect module :param x: Input tensor x :return: A tensor after drop connection """ if self.training: random_tensor = self.u.sample([x.shape[0], 1, 1, 1]).cuda() random_tensor += self.survival_prob binary_tensor = torch.floor(random_tensor) return x * binary_tensor / self.survival_prob else: return x class GlobalAvgPool2d(nn.Module): def __init__(self): """ Global Average pooling module """ super(GlobalAvgPool2d, self).__init__() def forward(self, x): """ The forward function of the GlobalAvgPool2d module :param x: Input tensor x :return: A tensor after average pooling """ return F.avg_pool2d(x, (x.shape[2], x.shape[3])) class SEBlock(nn.Module): def __init__(self, nc, in_channels, reduce_channels): """ An implantation of Squeeze Excite block :param nc: Input network controller :param in_channels: the number of input channels :param reduce_channels: the number of channels after reduction """ super(SEBlock, self).__init__() self.gap = GlobalAvgPool2d() self.conv_reduce = nn.Sequential( ConvBN(nc, in_channels, reduce_channels, 1, disable_bn=True), NonLinear(nc, reduce_channels, NonLinearType.SWISH)) self.conv_expand = nn.Sequential( ConvBN(nc, reduce_channels, in_channels, 1, disable_bn=True), NonLinear(nc, in_channels, NonLinearType.SIGMOID)) def forward(self, x): """ The forward function of the SEBlock module :param x: Input tensor x :return: A tensor after SE Block """ return x * self.conv_expand(self.conv_reduce(self.gap(x))) class ConvBNNonLinear(nn.Sequential): def __init__(self, nc, in_planes, out_planes, kernel_size=3, stride=1, groups=1, nl_type=NonLinearType.RELU6, batch_norm_epsilon=1e-5, batch_norm_momentum=0.1, tf_padding=False): """ A joint block of 2d convolution with batch normalization and non linear function modules with HMQ quantization of both the convolution weights and activation function :param nc: The network quantization controller :param in_planes: The number of input channels :param out_planes: The number of output channels :param kernel_size: The kernel size :param stride: The convolution stride :param groups: The convolution group size :param nl_type: enum that state the non-linear type. :param batch_norm_epsilon: The batch normalization epsilon :param batch_norm_momentum: The batch normalization momentum :param tf_padding: Use TensorFlow padding (for EfficientNet) """ padding = kernel_size - stride if tf_padding else (kernel_size - 1) // 2 super(ConvBNNonLinear, self).__init__( ConvBN(nc, in_planes, out_planes, kernel_size, stride, padding, group=groups, batch_norm_epsilon=batch_norm_epsilon, batch_norm_momentum=batch_norm_momentum, tf_padding=tf_padding), NonLinear(nc, out_planes, nl_type) ) class InvertedResidual(nn.Module): def __init__(self, nc, inp, oup, stride, expand_ratio, kernel_size=3, nl_type=NonLinearType.RELU6, se_ratio=0, survival_prob=0, batch_norm_epsilon=1e-5, batch_norm_momentum=0.1, tf_padding=False): """ A Inverted Residual block use in Efficient-Net :param nc: The network quantization controller :param inp: The number of input channels :param oup: The number of output channels :param stride: The depth wise convolution stride :param expand_ratio: The block expand ratio for depth-wise convolution :param kernel_size: The kernel size :param nl_type: enum that state the non-linear type. :param se_ratio: the ratio between the number of input channel and mid channels in SE Bloock :param survival_prob: the probability if connection survival :param batch_norm_epsilon: The batch normalization epsilon :param batch_norm_momentum: The batch normalization momentum :param tf_padding: Use TensorFlow padding (for EfficientNet) """ super(InvertedResidual, self).__init__() self.stride = stride assert stride in [1, 2] hidden_dim = int(round(inp * expand_ratio)) self.use_res_connect = self.stride == 1 and inp == oup self.kernel_size = kernel_size layers = [] if expand_ratio != 1: # pw layers.append(ConvBNNonLinear(nc, inp, hidden_dim, kernel_size=1, nl_type=nl_type, batch_norm_epsilon=batch_norm_epsilon, batch_norm_momentum=batch_norm_momentum)) layers.append( ConvBNNonLinear(nc, hidden_dim, hidden_dim, kernel_size=kernel_size, stride=stride, groups=hidden_dim, nl_type=nl_type, batch_norm_epsilon=batch_norm_epsilon, batch_norm_momentum=batch_norm_momentum, tf_padding=tf_padding)) if se_ratio != 0: layers.append(SEBlock(nc, hidden_dim, int(inp * se_ratio))) layers.append(ConvBNNonLinear(nc, hidden_dim, oup, kernel_size=1, stride=1, nl_type=NonLinearType.IDENTITY, batch_norm_epsilon=batch_norm_epsilon, batch_norm_momentum=batch_norm_momentum)) if survival_prob != 0 and self.use_res_connect: layers.append(DropConnect(survival_prob)) self.conv = nn.Sequential(*layers) self.output_q = NonLinear(nc, oup, nl_type=NonLinearType.IDENTITY) def forward(self, x): """ The forward function of the InvertedResidual module :param x: Input tensor x :return: A tensor after InvertedResidual """ if self.use_res_connect: y = self.conv(x) return self.output_q(x + y) else: x = self.conv(x) return self.output_q(x) class RepeatedInvertedResidual(nn.Module): def __init__(self, nc, n_repeat, in_channels, out_channels, stride_first, expand_ratio, kernel_size=3, nl_type=NonLinearType.RELU6, se_ratio=0, survival_prob_start=0, drop_rate=0, batch_norm_epsilon=1e-5, batch_norm_momentum=0.1, tf_padding=False): """ A block the repeatedly run the InvertedResidual block :param nc:The network quantization controller :param n_repeat: :param in_channels: The number of input channels :param out_channels: The number of output channels :param stride_first: The depth wise convolution stride in the first block :param expand_ratio: The block expand ratio for depth-wise convolution :param kernel_size: The kernel size :param nl_type: enum that state the non-linear type. :param se_ratio: the ratio between the number of input channel and mid channels in SE Bloock :param survival_prob_start: the probability if connection survival in the first block :param batch_norm_epsilon: The batch normalization epsilon :param batch_norm_momentum: The batch normalization momentum :param tf_padding: Use TensorFlow padding (for EfficientNet) """ super(RepeatedInvertedResidual, self).__init__() layers = [] for i in range(n_repeat): if survival_prob_start > 0 and drop_rate > 0: survival_prob = survival_prob_start - drop_rate * float(i) else: survival_prob = 0 block = InvertedResidual(nc, in_channels if i == 0 else out_channels, out_channels, stride_first if i == 0 else 1, expand_ratio, kernel_size=kernel_size, nl_type=nl_type, se_ratio=se_ratio, survival_prob=survival_prob, batch_norm_epsilon=batch_norm_epsilon, batch_norm_momentum=batch_norm_momentum, tf_padding=tf_padding) layers.append(block) self.blocks = nn.Sequential(*layers) def forward(self, x): """ The forward function of the RepeatedInvertedResidual module :param x: Input tensor x :return: A tensor after RepeatedInvertedResidual """ return self.blocks(x)
[ 1, 1053, 4842, 305, 13, 3166, 4842, 305, 1053, 302, 29876, 13, 3166, 4842, 305, 29889, 15755, 1053, 13303, 408, 383, 13, 3166, 4842, 305, 29889, 27691, 29879, 29889, 29590, 1053, 853, 5560, 13, 3166, 14379, 29889, 29277, 29889, 5464, 29918, 10660, 1053, 10050, 12697, 29892, 10050, 12697, 1542, 13, 3166, 14379, 29889, 29277, 29889, 20580, 29918, 11197, 1053, 1281, 29894, 29933, 29940, 13, 13, 13, 1990, 20724, 17918, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 10503, 2561, 29918, 22795, 1125, 13, 4706, 9995, 13, 4706, 319, 3883, 393, 10703, 5768, 3957, 13, 4706, 584, 3207, 10503, 2561, 29918, 22795, 29901, 278, 6976, 565, 3957, 10503, 2561, 13, 4706, 9995, 13, 4706, 2428, 29898, 15063, 17918, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 7610, 29894, 2561, 29918, 22795, 353, 10503, 2561, 29918, 22795, 13, 4706, 1583, 29889, 29884, 353, 853, 5560, 29898, 29900, 29892, 29871, 29896, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 9995, 13, 4706, 450, 6375, 740, 310, 278, 20724, 17918, 3883, 13, 13, 4706, 584, 3207, 921, 29901, 10567, 12489, 921, 13, 4706, 584, 2457, 29901, 319, 12489, 1156, 5768, 3957, 13, 4706, 9995, 13, 4706, 565, 1583, 29889, 26495, 29901, 13, 9651, 4036, 29918, 20158, 353, 1583, 29889, 29884, 29889, 11249, 4197, 29916, 29889, 12181, 29961, 29900, 1402, 29871, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 14664, 29883, 6191, 580, 13, 9651, 4036, 29918, 20158, 4619, 1583, 29889, 7610, 29894, 2561, 29918, 22795, 13, 9651, 7581, 29918, 20158, 353, 4842, 305, 29889, 14939, 29898, 8172, 29918, 20158, 29897, 13, 9651, 736, 921, 334, 7581, 29918, 20158, 847, 1583, 29889, 7610, 29894, 2561, 29918, 22795, 13, 4706, 1683, 29901, 13, 9651, 736, 921, 13, 13, 13, 1990, 12002, 12810, 29887, 11426, 29906, 29881, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 9995, 13, 4706, 12002, 319, 19698, 11565, 292, 3883, 13, 4706, 9995, 13, 4706, 2428, 29898, 12756, 12810, 29887, 11426, 29906, 29881, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 9995, 13, 4706, 450, 6375, 740, 310, 278, 12002, 12810, 29887, 11426, 29906, 29881, 3883, 13, 13, 4706, 584, 3207, 921, 29901, 10567, 12489, 921, 13, 4706, 584, 2457, 29901, 319, 12489, 1156, 6588, 11565, 292, 13, 4706, 9995, 13, 4706, 736, 383, 29889, 485, 29887, 29918, 10109, 29906, 29881, 29898, 29916, 29892, 313, 29916, 29889, 12181, 29961, 29906, 1402, 921, 29889, 12181, 29961, 29941, 12622, 13, 13, 13, 1990, 3725, 7445, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 29883, 29892, 297, 29918, 305, 12629, 29892, 10032, 29918, 305, 12629, 1125, 13, 4706, 9995, 13, 4706, 530, 13374, 424, 362, 310, 317, 802, 29872, 911, 1222, 2036, 2908, 13, 13, 4706, 584, 3207, 302, 29883, 29901, 10567, 3564, 4701, 13, 4706, 584, 3207, 297, 29918, 305, 12629, 29901, 278, 1353, 310, 1881, 18196, 13, 4706, 584, 3207, 10032, 29918, 305, 12629, 29901, 278, 1353, 310, 18196, 1156, 20376, 13, 4706, 9995, 13, 4706, 2428, 29898, 1660, 7445, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 29887, 481, 353, 12002, 12810, 29887, 11426, 29906, 29881, 580, 13, 4706, 1583, 29889, 20580, 29918, 17469, 353, 302, 29876, 29889, 16941, 2556, 29898, 13, 9651, 1281, 29894, 29933, 29940, 29898, 17608, 29892, 297, 29918, 305, 12629, 29892, 10032, 29918, 305, 12629, 29892, 29871, 29896, 29892, 11262, 29918, 11197, 29922, 5574, 511, 13, 9651, 10050, 12697, 29898, 17608, 29892, 10032, 29918, 305, 12629, 29892, 10050, 12697, 1542, 29889, 23066, 3235, 29950, 876, 13, 4706, 1583, 29889, 20580, 29918, 18837, 353, 302, 29876, 29889, 16941, 2556, 29898, 13, 9651, 1281, 29894, 29933, 29940, 29898, 17608, 29892, 10032, 29918, 305, 12629, 29892, 297, 29918, 305, 12629, 29892, 29871, 29896, 29892, 11262, 29918, 11197, 29922, 5574, 511, 13, 9651, 10050, 12697, 29898, 17608, 29892, 297, 29918, 305, 12629, 29892, 10050, 12697, 1542, 29889, 5425, 29954, 6720, 1367, 876, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 9995, 13, 4706, 450, 6375, 740, 310, 278, 3725, 7445, 3883, 13, 4706, 584, 3207, 921, 29901, 10567, 12489, 921, 13, 4706, 584, 2457, 29901, 319, 12489, 1156, 3725, 15658, 13, 4706, 9995, 13, 4706, 736, 921, 334, 1583, 29889, 20580, 29918, 18837, 29898, 1311, 29889, 20580, 29918, 17469, 29898, 1311, 29889, 29887, 481, 29898, 29916, 4961, 13, 13, 13, 1990, 1281, 29894, 29933, 10262, 265, 12697, 29898, 15755, 29889, 16941, 2556, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 29883, 29892, 297, 29918, 9018, 267, 29892, 714, 29918, 9018, 267, 29892, 8466, 29918, 2311, 29922, 29941, 29892, 380, 2426, 29922, 29896, 29892, 6471, 29922, 29896, 29892, 302, 29880, 29918, 1853, 29922, 12283, 12697, 1542, 29889, 1525, 29931, 29965, 29953, 29892, 13, 462, 9853, 29918, 12324, 29918, 5463, 29922, 29896, 29872, 29899, 29945, 29892, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 29900, 29889, 29896, 29892, 15886, 29918, 12791, 29922, 8824, 1125, 13, 4706, 9995, 13, 4706, 319, 14002, 2908, 310, 29871, 29906, 29881, 26851, 411, 9853, 4226, 2133, 322, 1661, 5608, 740, 10585, 13, 4706, 411, 379, 25566, 4323, 2133, 310, 1716, 278, 26851, 18177, 322, 26229, 740, 13, 4706, 584, 3207, 302, 29883, 29901, 450, 3564, 4323, 2133, 4701, 13, 4706, 584, 3207, 297, 29918, 9018, 267, 29901, 450, 1353, 310, 1881, 18196, 13, 4706, 584, 3207, 714, 29918, 9018, 267, 29901, 450, 1353, 310, 1962, 18196, 13, 4706, 584, 3207, 8466, 29918, 2311, 29901, 450, 8466, 2159, 13, 4706, 584, 3207, 380, 2426, 29901, 450, 26851, 380, 2426, 13, 4706, 584, 3207, 6471, 29901, 450, 26851, 2318, 2159, 13, 4706, 584, 3207, 302, 29880, 29918, 1853, 29901, 14115, 393, 2106, 278, 1661, 29899, 10660, 1134, 29889, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 5463, 29901, 450, 9853, 4226, 2133, 321, 3232, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29901, 450, 9853, 4226, 2133, 19399, 13, 4706, 584, 3207, 15886, 29918, 12791, 29901, 4803, 323, 6073, 17907, 7164, 313, 1454, 382, 4543, 6779, 29897, 13, 4706, 9995, 13, 4706, 7164, 353, 8466, 29918, 2311, 448, 380, 2426, 565, 15886, 29918, 12791, 1683, 313, 17460, 29918, 2311, 448, 29871, 29896, 29897, 849, 29871, 29906, 13, 4706, 2428, 29898, 1168, 29894, 29933, 10262, 265, 12697, 29892, 1583, 467, 1649, 2344, 12035, 13, 9651, 1281, 29894, 29933, 29940, 29898, 17608, 29892, 297, 29918, 9018, 267, 29892, 714, 29918, 9018, 267, 29892, 8466, 29918, 2311, 29892, 380, 2426, 29892, 7164, 29892, 2318, 29922, 13155, 29892, 13, 462, 259, 9853, 29918, 12324, 29918, 5463, 29922, 16175, 29918, 12324, 29918, 5463, 29892, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 16175, 29918, 12324, 29918, 29885, 2932, 398, 29892, 13, 462, 259, 15886, 29918, 12791, 29922, 13264, 29918, 12791, 511, 13, 9651, 10050, 12697, 29898, 17608, 29892, 714, 29918, 9018, 267, 29892, 302, 29880, 29918, 1853, 29897, 13, 4706, 1723, 13, 13, 13, 1990, 512, 1765, 287, 1666, 333, 950, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 29883, 29892, 297, 29886, 29892, 29871, 1132, 29892, 380, 2426, 29892, 7985, 29918, 3605, 601, 29892, 8466, 29918, 2311, 29922, 29941, 29892, 302, 29880, 29918, 1853, 29922, 12283, 12697, 1542, 29889, 1525, 29931, 29965, 29953, 29892, 409, 29918, 3605, 601, 29922, 29900, 29892, 13, 462, 10503, 2561, 29918, 22795, 29922, 29900, 29892, 9853, 29918, 12324, 29918, 5463, 29922, 29896, 29872, 29899, 29945, 29892, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 29900, 29889, 29896, 29892, 15886, 29918, 12791, 29922, 8824, 1125, 13, 4706, 9995, 13, 4706, 319, 512, 1765, 287, 2538, 333, 950, 2908, 671, 297, 382, 4543, 29899, 6779, 13, 13, 4706, 584, 3207, 302, 29883, 29901, 450, 3564, 4323, 2133, 4701, 13, 4706, 584, 3207, 297, 29886, 29901, 450, 1353, 310, 1881, 18196, 13, 4706, 584, 3207, 29871, 1132, 29901, 450, 1353, 310, 1962, 18196, 13, 4706, 584, 3207, 380, 2426, 29901, 450, 10809, 19396, 26851, 380, 2426, 13, 4706, 584, 3207, 7985, 29918, 3605, 601, 29901, 450, 2908, 7985, 11959, 363, 10809, 29899, 3538, 26851, 13, 4706, 584, 3207, 8466, 29918, 2311, 29901, 450, 8466, 2159, 13, 4706, 584, 3207, 302, 29880, 29918, 1853, 29901, 29871, 14115, 393, 2106, 278, 1661, 29899, 10660, 1134, 29889, 13, 4706, 584, 3207, 409, 29918, 3605, 601, 29901, 278, 11959, 1546, 278, 1353, 310, 1881, 8242, 322, 7145, 18196, 297, 3725, 11447, 1698, 13, 4706, 584, 3207, 10503, 2561, 29918, 22795, 29901, 278, 6976, 565, 3957, 10503, 2561, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 5463, 29901, 450, 9853, 4226, 2133, 321, 3232, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29901, 450, 9853, 4226, 2133, 19399, 13, 4706, 584, 3207, 15886, 29918, 12791, 29901, 4803, 323, 6073, 17907, 7164, 313, 1454, 382, 4543, 6779, 29897, 13, 4706, 9995, 13, 4706, 2428, 29898, 797, 1765, 287, 1666, 333, 950, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 29889, 303, 2426, 353, 380, 2426, 13, 4706, 4974, 380, 2426, 297, 518, 29896, 29892, 29871, 29906, 29962, 13, 13, 4706, 7934, 29918, 6229, 353, 938, 29898, 14486, 29898, 262, 29886, 334, 7985, 29918, 3605, 601, 876, 13, 4706, 1583, 29889, 1509, 29918, 690, 29918, 6915, 353, 1583, 29889, 303, 2426, 1275, 29871, 29896, 322, 297, 29886, 1275, 29871, 1132, 13, 4706, 1583, 29889, 17460, 29918, 2311, 353, 8466, 29918, 2311, 13, 13, 4706, 15359, 353, 5159, 13, 4706, 565, 7985, 29918, 3605, 601, 2804, 29871, 29896, 29901, 13, 9651, 396, 282, 29893, 13, 9651, 15359, 29889, 4397, 29898, 1168, 29894, 29933, 10262, 265, 12697, 29898, 17608, 29892, 297, 29886, 29892, 7934, 29918, 6229, 29892, 8466, 29918, 2311, 29922, 29896, 29892, 302, 29880, 29918, 1853, 29922, 12938, 29918, 1853, 29892, 13, 462, 462, 3986, 9853, 29918, 12324, 29918, 5463, 29922, 16175, 29918, 12324, 29918, 5463, 29892, 13, 462, 462, 3986, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 16175, 29918, 12324, 29918, 29885, 2932, 398, 876, 13, 4706, 15359, 29889, 4397, 29898, 13, 9651, 1281, 29894, 29933, 10262, 265, 12697, 29898, 17608, 29892, 7934, 29918, 6229, 29892, 7934, 29918, 6229, 29892, 8466, 29918, 2311, 29922, 17460, 29918, 2311, 29892, 380, 2426, 29922, 303, 2426, 29892, 6471, 29922, 10892, 29918, 6229, 29892, 13, 462, 9651, 302, 29880, 29918, 1853, 29922, 12938, 29918, 1853, 29892, 9853, 29918, 12324, 29918, 5463, 29922, 16175, 29918, 12324, 29918, 5463, 29892, 13, 462, 9651, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 16175, 29918, 12324, 29918, 29885, 2932, 398, 29892, 15886, 29918, 12791, 29922, 13264, 29918, 12791, 876, 13, 4706, 565, 409, 29918, 3605, 601, 2804, 29871, 29900, 29901, 13, 9651, 15359, 29889, 4397, 29898, 1660, 7445, 29898, 17608, 29892, 7934, 29918, 6229, 29892, 938, 29898, 262, 29886, 334, 409, 29918, 3605, 601, 4961, 13, 13, 4706, 15359, 29889, 4397, 29898, 1168, 29894, 29933, 10262, 265, 12697, 29898, 17608, 29892, 7934, 29918, 6229, 29892, 29871, 1132, 29892, 8466, 29918, 2311, 29922, 29896, 29892, 380, 2426, 29922, 29896, 29892, 302, 29880, 29918, 1853, 29922, 12283, 12697, 1542, 29889, 1367, 3919, 11937, 29892, 13, 462, 462, 418, 9853, 29918, 12324, 29918, 5463, 29922, 16175, 29918, 12324, 29918, 5463, 29892, 13, 462, 462, 418, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 16175, 29918, 12324, 29918, 29885, 2932, 398, 876, 13, 13, 4706, 565, 10503, 2561, 29918, 22795, 2804, 29871, 29900, 322, 1583, 29889, 1509, 29918, 690, 29918, 6915, 29901, 13, 9651, 15359, 29889, 4397, 29898, 15063, 17918, 29898, 7610, 29894, 2561, 29918, 22795, 876, 13, 4706, 1583, 29889, 20580, 353, 302, 29876, 29889, 16941, 2556, 10456, 29277, 29897, 13, 4706, 1583, 29889, 4905, 29918, 29939, 353, 10050, 12697, 29898, 17608, 29892, 29871, 1132, 29892, 302, 29880, 29918, 1853, 29922, 12283, 12697, 1542, 29889, 1367, 3919, 11937, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 9995, 13, 4706, 450, 6375, 740, 310, 278, 512, 1765, 287, 1666, 333, 950, 3883, 13, 4706, 584, 3207, 921, 29901, 10567, 12489, 921, 13, 4706, 584, 2457, 29901, 319, 12489, 1156, 512, 1765, 287, 1666, 333, 950, 13, 4706, 9995, 13, 4706, 565, 1583, 29889, 1509, 29918, 690, 29918, 6915, 29901, 13, 9651, 343, 353, 1583, 29889, 20580, 29898, 29916, 29897, 13, 9651, 736, 1583, 29889, 4905, 29918, 29939, 29898, 29916, 718, 343, 29897, 13, 4706, 1683, 29901, 13, 9651, 921, 353, 1583, 29889, 20580, 29898, 29916, 29897, 13, 9651, 736, 1583, 29889, 4905, 29918, 29939, 29898, 29916, 29897, 13, 13, 13, 1990, 830, 412, 630, 797, 1765, 287, 1666, 333, 950, 29898, 15755, 29889, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 29883, 29892, 302, 29918, 14358, 29892, 297, 29918, 305, 12629, 29892, 714, 29918, 305, 12629, 29892, 380, 2426, 29918, 4102, 29892, 7985, 29918, 3605, 601, 29892, 8466, 29918, 2311, 29922, 29941, 29892, 13, 462, 302, 29880, 29918, 1853, 29922, 12283, 12697, 1542, 29889, 1525, 29931, 29965, 29953, 29892, 13, 462, 409, 29918, 3605, 601, 29922, 29900, 29892, 13, 462, 10503, 2561, 29918, 22795, 29918, 2962, 29922, 29900, 29892, 5768, 29918, 10492, 29922, 29900, 29892, 9853, 29918, 12324, 29918, 5463, 29922, 29896, 29872, 29899, 29945, 29892, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 29900, 29889, 29896, 29892, 13, 462, 15886, 29918, 12791, 29922, 8824, 1125, 13, 4706, 9995, 13, 4706, 319, 2908, 278, 28424, 1065, 278, 512, 1765, 287, 1666, 333, 950, 2908, 13, 4706, 584, 3207, 302, 29883, 29901, 1576, 3564, 4323, 2133, 4701, 13, 4706, 584, 3207, 302, 29918, 14358, 29901, 13, 4706, 584, 3207, 297, 29918, 305, 12629, 29901, 450, 1353, 310, 1881, 18196, 13, 4706, 584, 3207, 714, 29918, 305, 12629, 29901, 450, 1353, 310, 1962, 18196, 13, 4706, 584, 3207, 380, 2426, 29918, 4102, 29901, 450, 10809, 19396, 26851, 380, 2426, 297, 278, 937, 2908, 13, 4706, 584, 3207, 7985, 29918, 3605, 601, 29901, 450, 2908, 7985, 11959, 363, 10809, 29899, 3538, 26851, 13, 4706, 584, 3207, 8466, 29918, 2311, 29901, 450, 8466, 2159, 13, 4706, 584, 3207, 302, 29880, 29918, 1853, 29901, 29871, 14115, 393, 2106, 278, 1661, 29899, 10660, 1134, 29889, 13, 4706, 584, 3207, 409, 29918, 3605, 601, 29901, 278, 11959, 1546, 278, 1353, 310, 1881, 8242, 322, 7145, 18196, 297, 3725, 11447, 1698, 13, 4706, 584, 3207, 10503, 2561, 29918, 22795, 29918, 2962, 29901, 278, 6976, 565, 3957, 10503, 2561, 297, 278, 937, 2908, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 5463, 29901, 450, 9853, 4226, 2133, 321, 3232, 13, 4706, 584, 3207, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29901, 450, 9853, 4226, 2133, 19399, 13, 4706, 584, 3207, 15886, 29918, 12791, 29901, 4803, 323, 6073, 17907, 7164, 313, 1454, 382, 4543, 6779, 29897, 13, 4706, 9995, 13, 4706, 2428, 29898, 1123, 412, 630, 797, 1765, 287, 1666, 333, 950, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 15359, 353, 5159, 13, 4706, 363, 474, 297, 3464, 29898, 29876, 29918, 14358, 1125, 13, 9651, 565, 10503, 2561, 29918, 22795, 29918, 2962, 1405, 29871, 29900, 322, 5768, 29918, 10492, 1405, 29871, 29900, 29901, 13, 18884, 10503, 2561, 29918, 22795, 353, 10503, 2561, 29918, 22795, 29918, 2962, 448, 5768, 29918, 10492, 334, 5785, 29898, 29875, 29897, 13, 9651, 1683, 29901, 13, 18884, 10503, 2561, 29918, 22795, 353, 29871, 29900, 13, 9651, 2908, 353, 512, 1765, 287, 1666, 333, 950, 29898, 17608, 29892, 297, 29918, 305, 12629, 565, 474, 1275, 29871, 29900, 1683, 714, 29918, 305, 12629, 29892, 714, 29918, 305, 12629, 29892, 13, 462, 462, 268, 380, 2426, 29918, 4102, 565, 474, 1275, 29871, 29900, 1683, 29871, 29896, 29892, 7985, 29918, 3605, 601, 29892, 8466, 29918, 2311, 29922, 17460, 29918, 2311, 29892, 13, 462, 462, 268, 302, 29880, 29918, 1853, 29922, 12938, 29918, 1853, 29892, 409, 29918, 3605, 601, 29922, 344, 29918, 3605, 601, 29892, 10503, 2561, 29918, 22795, 29922, 7610, 29894, 2561, 29918, 22795, 29892, 13, 462, 462, 268, 9853, 29918, 12324, 29918, 5463, 29922, 16175, 29918, 12324, 29918, 5463, 29892, 9853, 29918, 12324, 29918, 29885, 2932, 398, 29922, 16175, 29918, 12324, 29918, 29885, 2932, 398, 29892, 13, 462, 462, 268, 15886, 29918, 12791, 29922, 13264, 29918, 12791, 29897, 13, 9651, 15359, 29889, 4397, 29898, 1271, 29897, 13, 4706, 1583, 29889, 1271, 29879, 353, 302, 29876, 29889, 16941, 2556, 10456, 29277, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 921, 1125, 13, 4706, 9995, 13, 4706, 450, 6375, 740, 310, 278, 830, 412, 630, 797, 1765, 287, 1666, 333, 950, 3883, 13, 4706, 584, 3207, 921, 29901, 10567, 12489, 921, 13, 4706, 584, 2457, 29901, 319, 12489, 1156, 830, 412, 630, 797, 1765, 287, 1666, 333, 950, 13, 4706, 9995, 13, 4706, 736, 1583, 29889, 1271, 29879, 29898, 29916, 29897, 13, 2 ]
prac2_2.py
JulianAZW/bookish-lamp
1
23223
<reponame>JulianAZW/bookish-lamp # -*- coding: utf-8 -*- """ Created on Thu Mar 17 19:08:54 2022 @author: julian """ import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def heatmap(df): correlation_matrix = df.corr().round(2) print(correlation_matrix) sns_h = sns.heatmap(data=correlation_matrix, annot=True) sns_h.figure.savefig("Mapa de calor de correlacion") sns_h.figure.clear() def plotXY(df): for i in range(0,8): plt_disp = plt.scatter(df.iloc[:,i],df.iloc[:,8]) plt.xlabel(df.columns[i]) plt.ylabel(df.columns[8]) cadena = "plt"+str(i)+"_"+str(8)+".png" print(cadena) plt_disp plt_disp.figure.clear() if __name__=='__main__': df1 = pd.read_csv("data_train.csv", sep=',', engine='python') df2 = pd.read_csv("medianHouseValue_train.csv", sep=',', engine='python') df = pd.concat([df1,df2], axis=1) print("El DataFrame con el 80 por ciento de los datos: \n", df) #plt.scatter(df.iloc[:,7],df.iloc[:,8]) #plt.xlabel(df.columns[7]) #plt.ylabel(df.columns[8]) #plt.show() heatmap(df) plotXY(df)
[ 1, 529, 276, 1112, 420, 29958, 27501, 713, 29909, 29999, 29956, 29914, 2909, 728, 29899, 29880, 1160, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 13, 20399, 373, 498, 29884, 1085, 29871, 29896, 29955, 29871, 29896, 29929, 29901, 29900, 29947, 29901, 29945, 29946, 29871, 29906, 29900, 29906, 29906, 13, 13, 29992, 8921, 29901, 5757, 713, 13, 15945, 29908, 13, 5215, 11701, 408, 10518, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 5215, 409, 370, 1398, 408, 269, 1983, 13, 13, 13, 13, 13, 1753, 12871, 1958, 29898, 2176, 1125, 13, 1678, 19869, 29918, 5344, 353, 4489, 29889, 29725, 2141, 14486, 29898, 29906, 29897, 13, 1678, 1596, 29898, 2616, 23445, 29918, 5344, 29897, 13, 1678, 269, 1983, 29918, 29882, 353, 269, 1983, 29889, 354, 271, 1958, 29898, 1272, 29922, 2616, 23445, 29918, 5344, 29892, 9732, 29922, 5574, 29897, 13, 1678, 269, 1983, 29918, 29882, 29889, 4532, 29889, 7620, 1003, 703, 3388, 29874, 316, 1208, 272, 316, 14515, 4620, 291, 1159, 13, 1678, 269, 1983, 29918, 29882, 29889, 4532, 29889, 8551, 580, 13, 13, 1753, 6492, 18454, 29898, 2176, 1125, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 29947, 1125, 13, 4706, 14770, 29918, 2218, 29886, 353, 14770, 29889, 1557, 2620, 29898, 2176, 29889, 309, 542, 7503, 29892, 29875, 1402, 2176, 29889, 309, 542, 7503, 29892, 29947, 2314, 13, 4706, 14770, 29889, 29916, 1643, 29898, 2176, 29889, 13099, 29961, 29875, 2314, 13, 4706, 14770, 29889, 29891, 1643, 29898, 2176, 29889, 13099, 29961, 29947, 2314, 13, 4706, 13840, 2386, 353, 376, 572, 29873, 17969, 710, 29898, 29875, 7240, 29908, 29918, 17969, 710, 29898, 29947, 7240, 1642, 2732, 29908, 13, 4706, 1596, 29898, 29883, 328, 2386, 29897, 13, 4706, 14770, 29918, 2218, 29886, 13, 4706, 14770, 29918, 2218, 29886, 29889, 4532, 29889, 8551, 580, 13, 308, 13, 308, 13, 361, 4770, 978, 1649, 1360, 29915, 1649, 3396, 1649, 2396, 13, 1678, 4489, 29896, 353, 10518, 29889, 949, 29918, 7638, 703, 1272, 29918, 14968, 29889, 7638, 613, 16345, 29922, 742, 742, 6012, 2433, 4691, 1495, 13, 1678, 4489, 29906, 353, 10518, 29889, 949, 29918, 7638, 703, 2168, 713, 29950, 1709, 1917, 29918, 14968, 29889, 7638, 613, 16345, 29922, 742, 742, 6012, 2433, 4691, 1495, 13, 1678, 4489, 353, 10518, 29889, 17685, 4197, 2176, 29896, 29892, 2176, 29906, 1402, 9685, 29922, 29896, 29897, 13, 1678, 1596, 703, 6489, 3630, 4308, 378, 560, 29871, 29947, 29900, 1277, 274, 5230, 316, 1232, 18683, 29901, 320, 29876, 613, 4489, 29897, 13, 1678, 396, 572, 29873, 29889, 1557, 2620, 29898, 2176, 29889, 309, 542, 7503, 29892, 29955, 1402, 2176, 29889, 309, 542, 7503, 29892, 29947, 2314, 13, 1678, 396, 572, 29873, 29889, 29916, 1643, 29898, 2176, 29889, 13099, 29961, 29955, 2314, 13, 1678, 396, 572, 29873, 29889, 29891, 1643, 29898, 2176, 29889, 13099, 29961, 29947, 2314, 13, 1678, 396, 572, 29873, 29889, 4294, 580, 13, 1678, 12871, 1958, 29898, 2176, 29897, 13, 1678, 6492, 18454, 29898, 2176, 29897, 13, 268, 2 ]
fix_readme.py
vmstarchenko/jiml
0
106322
import re import sys with open('README.md') as f: data = f.read() print(re.sub( r'\n>>> \n>>> # (.*)\n', r'\n```\n- \1\n```python\n', sys.stdin.read(), ))
[ 1, 1053, 337, 13, 5215, 10876, 13, 13, 2541, 1722, 877, 16310, 2303, 29889, 3487, 1495, 408, 285, 29901, 13, 1678, 848, 353, 285, 29889, 949, 580, 13, 13, 2158, 29898, 276, 29889, 1491, 29898, 13, 1678, 364, 12764, 29876, 6778, 29958, 320, 29876, 6778, 29958, 396, 313, 5575, 2144, 29876, 742, 13, 1678, 364, 12764, 29876, 28956, 29905, 29876, 29899, 320, 29896, 29905, 29876, 28956, 4691, 29905, 29876, 742, 13, 1678, 10876, 29889, 4172, 262, 29889, 949, 3285, 13, 876, 13, 2 ]
Chapter 08/mcb_ext.pyw
roelr1/python-1
143
166249
#!/usr/bin/env python3 """Saves, loads and deletes pieces of text to the clipboard. Usage: py.exe mcb_ext.pyw save <keyword> - Saves clipboard to keyword py.exe mcb_ext.pyw <keyword> - Loads keyword contents to clipboard py.exe mcb_ext.pyw list - Loads all keywords to clipboard py.exe mcb_ext.pyw delete <keyword>- Deletes saved keyword and contents py.exe mcb_ext.pyw delete_all - Deletes all keywords from clipboard """ import shelve import sys import pyperclip mcb_shelf = shelve.open('mcb') # Save the clipboard contents to keyword if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': mcb_shelf[sys.argv[2]] = pyperclip.paste() print(sys.argv[2] + ' saved successfully') # Delete keyword and associated content elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete': del mcb_shelf[sys.argv[2]] print([sys.argv[2] + ' deleted']) elif len(sys.argv) == 2 and sys.argv[1].lower() != 'delete_all': # List stored keywords if sys.argv[1].lower() == 'list': pyperclip.copy(str(list(mcb_shelf.keys()))) print('List of all keywords copied to clipboard') # Load content associated with chosen keyword to the clipboard elif sys.argv[1] in mcb_shelf: pyperclip.copy(mcb_shelf[sys.argv[1]]) print(sys.argv[1] + ' loaded successfully') # Inform user that their input doesn't match a saved keyword else: print('That keyword doesn\'t exist - so nothing' 'has been loaded to the clipboard') # Clear all shelved entries elif len(sys.argv) == 2 and sys.argv[1].lower() == 'delete_all': mcb_shelf.clear() print('All keywords and associated contents have been deleted') mcb_shelf.close()
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 29941, 13, 13, 15945, 29908, 29903, 5989, 29892, 15376, 322, 7374, 267, 12785, 310, 1426, 304, 278, 20102, 3377, 29889, 13, 13, 27573, 29901, 13, 2272, 29889, 8097, 286, 10702, 29918, 1062, 29889, 2272, 29893, 4078, 529, 26766, 29958, 448, 317, 5989, 20102, 3377, 304, 13553, 13, 2272, 29889, 8097, 286, 10702, 29918, 1062, 29889, 2272, 29893, 529, 26766, 29958, 448, 4309, 7925, 13553, 8118, 304, 20102, 3377, 13, 2272, 29889, 8097, 286, 10702, 29918, 1062, 29889, 2272, 29893, 1051, 448, 4309, 7925, 599, 29361, 304, 20102, 3377, 13, 2272, 29889, 8097, 286, 10702, 29918, 1062, 29889, 2272, 29893, 5217, 529, 26766, 29958, 29899, 897, 1026, 267, 7160, 13553, 322, 8118, 13, 2272, 29889, 8097, 286, 10702, 29918, 1062, 29889, 2272, 29893, 5217, 29918, 497, 448, 897, 1026, 267, 599, 29361, 515, 20102, 3377, 13, 15945, 29908, 13, 13, 5215, 528, 13841, 13, 5215, 10876, 13, 5215, 11451, 546, 24049, 13, 13, 29885, 10702, 29918, 845, 761, 353, 528, 13841, 29889, 3150, 877, 29885, 10702, 1495, 13, 13, 29937, 16913, 278, 20102, 3377, 8118, 304, 13553, 13, 361, 7431, 29898, 9675, 29889, 19218, 29897, 1275, 29871, 29941, 322, 10876, 29889, 19218, 29961, 29896, 1822, 13609, 580, 1275, 525, 7620, 2396, 13, 1678, 286, 10702, 29918, 845, 761, 29961, 9675, 29889, 19218, 29961, 29906, 5262, 353, 11451, 546, 24049, 29889, 16179, 580, 13, 1678, 1596, 29898, 9675, 29889, 19218, 29961, 29906, 29962, 718, 525, 7160, 8472, 1495, 13, 13, 29937, 21267, 13553, 322, 6942, 2793, 13, 23681, 7431, 29898, 9675, 29889, 19218, 29897, 1275, 29871, 29941, 322, 10876, 29889, 19218, 29961, 29896, 1822, 13609, 580, 1275, 525, 8143, 2396, 13, 1678, 628, 286, 10702, 29918, 845, 761, 29961, 9675, 29889, 19218, 29961, 29906, 5262, 13, 1678, 1596, 4197, 9675, 29889, 19218, 29961, 29906, 29962, 718, 525, 11132, 11287, 13, 13, 23681, 7431, 29898, 9675, 29889, 19218, 29897, 1275, 29871, 29906, 322, 10876, 29889, 19218, 29961, 29896, 1822, 13609, 580, 2804, 525, 8143, 29918, 497, 2396, 13, 1678, 396, 2391, 6087, 29361, 13, 1678, 565, 10876, 29889, 19218, 29961, 29896, 1822, 13609, 580, 1275, 525, 1761, 2396, 13, 4706, 11451, 546, 24049, 29889, 8552, 29898, 710, 29898, 1761, 29898, 29885, 10702, 29918, 845, 761, 29889, 8149, 580, 4961, 13, 4706, 1596, 877, 1293, 310, 599, 29361, 13746, 304, 20102, 3377, 1495, 13, 1678, 396, 16012, 2793, 6942, 411, 10434, 13553, 304, 278, 20102, 3377, 13, 1678, 25342, 10876, 29889, 19218, 29961, 29896, 29962, 297, 286, 10702, 29918, 845, 761, 29901, 13, 4706, 11451, 546, 24049, 29889, 8552, 29898, 29885, 10702, 29918, 845, 761, 29961, 9675, 29889, 19218, 29961, 29896, 24960, 13, 4706, 1596, 29898, 9675, 29889, 19218, 29961, 29896, 29962, 718, 525, 7500, 8472, 1495, 13, 1678, 396, 15162, 1404, 393, 1009, 1881, 1838, 29915, 29873, 1993, 263, 7160, 13553, 13, 1678, 1683, 29901, 13, 4706, 1596, 877, 7058, 13553, 1838, 20333, 29873, 1863, 448, 577, 3078, 29915, 13, 795, 525, 5349, 1063, 7500, 304, 278, 20102, 3377, 1495, 13, 13, 29937, 17732, 599, 528, 295, 1490, 9976, 13, 23681, 7431, 29898, 9675, 29889, 19218, 29897, 1275, 29871, 29906, 322, 10876, 29889, 19218, 29961, 29896, 1822, 13609, 580, 1275, 525, 8143, 29918, 497, 2396, 13, 1678, 286, 10702, 29918, 845, 761, 29889, 8551, 580, 13, 1678, 1596, 877, 3596, 29361, 322, 6942, 8118, 505, 1063, 11132, 1495, 13, 13, 29885, 10702, 29918, 845, 761, 29889, 5358, 580, 13, 2 ]
train/utils.py
sahandilshan/PruneLM
0
174383
<filename>train/utils.py import torch def batchify(data, batch_size, device='cpu'): # Get number of batches num_batch = data.size(0) // batch_size # Trim off any extra elements that wouldn't cleanly fit (remainders). data = data.narrow(0, 0, num_batch * batch_size) # Evenly divide the data across the batch_size batches. data = data.view(batch_size, -1).t().contiguous() return data.to(device) def repackage_hidden(h): """Wraps hidden states in new Tensors, to detach them from their history.""" if isinstance(h, torch.Tensor): return h.detach() else: return tuple(repackage_hidden(v) for v in h) def get_batch(source, i, sequence_length=6): seq_len = min(sequence_length, len(source) - 1 - i) data = source[i:i + seq_len] target = source[i + 1:i + 1 + seq_len].view(-1) return data, target def evaluate(data_source, model, criterion, num_tokens, batch_size, sequence_length=6): model.eval() # batchnorm or dropout layers will work in eval mode total_loss = 0. hidden = model.init_hidden(batch_size) with torch.no_grad(): # Stop calculating gradients for i in range(0, data_source.size(0) - 1, sequence_length): data, targets = get_batch(data_source, i, sequence_length) output, hidden = model(data, hidden) output_flat = output.view(-1, num_tokens) total_loss += len(data) * criterion(output_flat, targets).item() hidden = repackage_hidden(hidden) return total_loss / len(data_source)
[ 1, 529, 9507, 29958, 14968, 29914, 13239, 29889, 2272, 13, 5215, 4842, 305, 13, 13, 13, 1753, 9853, 1598, 29898, 1272, 29892, 9853, 29918, 2311, 29892, 4742, 2433, 21970, 29374, 13, 1678, 396, 3617, 1353, 310, 9853, 267, 13, 1678, 954, 29918, 16175, 353, 848, 29889, 2311, 29898, 29900, 29897, 849, 9853, 29918, 2311, 13, 1678, 396, 1605, 326, 1283, 738, 4805, 3161, 393, 7656, 29915, 29873, 5941, 368, 6216, 313, 1745, 475, 8623, 467, 13, 1678, 848, 353, 848, 29889, 29876, 2936, 29898, 29900, 29892, 29871, 29900, 29892, 954, 29918, 16175, 334, 9853, 29918, 2311, 29897, 13, 1678, 396, 7753, 368, 16429, 278, 848, 4822, 278, 9853, 29918, 2311, 9853, 267, 29889, 13, 1678, 848, 353, 848, 29889, 1493, 29898, 16175, 29918, 2311, 29892, 448, 29896, 467, 29873, 2141, 1285, 5526, 681, 580, 13, 1678, 736, 848, 29889, 517, 29898, 10141, 29897, 13, 13, 13, 1753, 1634, 2229, 29918, 10892, 29898, 29882, 1125, 13, 1678, 9995, 29956, 336, 567, 7934, 5922, 297, 716, 323, 575, 943, 29892, 304, 1439, 496, 963, 515, 1009, 4955, 1213, 15945, 13, 13, 1678, 565, 338, 8758, 29898, 29882, 29892, 4842, 305, 29889, 29911, 6073, 1125, 13, 4706, 736, 298, 29889, 4801, 496, 580, 13, 1678, 1683, 29901, 13, 4706, 736, 18761, 29898, 3445, 2229, 29918, 10892, 29898, 29894, 29897, 363, 325, 297, 298, 29897, 13, 13, 13, 1753, 679, 29918, 16175, 29898, 4993, 29892, 474, 29892, 5665, 29918, 2848, 29922, 29953, 1125, 13, 1678, 19359, 29918, 2435, 353, 1375, 29898, 16506, 29918, 2848, 29892, 7431, 29898, 4993, 29897, 448, 29871, 29896, 448, 474, 29897, 13, 1678, 848, 353, 2752, 29961, 29875, 29901, 29875, 718, 19359, 29918, 2435, 29962, 13, 1678, 3646, 353, 2752, 29961, 29875, 718, 29871, 29896, 29901, 29875, 718, 29871, 29896, 718, 19359, 29918, 2435, 1822, 1493, 6278, 29896, 29897, 13, 1678, 736, 848, 29892, 3646, 13, 13, 13, 1753, 14707, 29898, 1272, 29918, 4993, 29892, 1904, 29892, 28770, 291, 29892, 954, 29918, 517, 12360, 29892, 9853, 29918, 2311, 29892, 5665, 29918, 2848, 29922, 29953, 1125, 13, 1678, 1904, 29889, 14513, 580, 29871, 396, 9853, 12324, 470, 5768, 449, 15359, 674, 664, 297, 19745, 4464, 13, 1678, 3001, 29918, 6758, 353, 29871, 29900, 29889, 13, 1678, 7934, 353, 1904, 29889, 2344, 29918, 10892, 29898, 16175, 29918, 2311, 29897, 13, 1678, 411, 4842, 305, 29889, 1217, 29918, 5105, 7295, 396, 22303, 25202, 4656, 10070, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 848, 29918, 4993, 29889, 2311, 29898, 29900, 29897, 448, 29871, 29896, 29892, 5665, 29918, 2848, 1125, 13, 9651, 848, 29892, 22525, 353, 679, 29918, 16175, 29898, 1272, 29918, 4993, 29892, 474, 29892, 5665, 29918, 2848, 29897, 13, 9651, 1962, 29892, 7934, 353, 1904, 29898, 1272, 29892, 7934, 29897, 13, 9651, 1962, 29918, 20620, 353, 1962, 29889, 1493, 6278, 29896, 29892, 954, 29918, 517, 12360, 29897, 13, 9651, 3001, 29918, 6758, 4619, 7431, 29898, 1272, 29897, 334, 28770, 291, 29898, 4905, 29918, 20620, 29892, 22525, 467, 667, 580, 13, 9651, 7934, 353, 1634, 2229, 29918, 10892, 29898, 10892, 29897, 13, 1678, 736, 3001, 29918, 6758, 847, 7431, 29898, 1272, 29918, 4993, 29897, 13, 2 ]
django_testing_tutorial_2018/products/tests/test_views.py
bluebamus/django_pytest
0
68876
<filename>django_testing_tutorial_2018/products/tests/test_views.py from django.test import RequestFactory from django.urls import reverse from django.contrib.auth.models import AnonymousUser, User from mixer.backend.django import mixer from products.views import product_detail import pytest @pytest.mark.django_db class TestViews: def test_product_detail_authenticated(self): mixer.blend('products.Product') path = reverse('detail',kwargs={'pk':1}) request = RequestFactory().get(path) request.user = mixer.blend(User) response = product_detail(request, pk=1) assert response.status_code == 200 def test_product_detail_unauthenticated(self): mixer.blend('products.Product') path = reverse('detail',kwargs={'pk':1}) request = RequestFactory().get(path) request.user = AnonymousUser() response = product_detail(request, pk=1) # assert response.status_code == 200 assert 'accounts/login' in response.url
[ 1, 529, 9507, 29958, 14095, 29918, 13424, 29918, 12631, 29918, 29906, 29900, 29896, 29947, 29914, 14456, 29914, 21150, 29914, 1688, 29918, 7406, 29889, 2272, 13, 3166, 9557, 29889, 1688, 1053, 10729, 5126, 13, 3166, 9557, 29889, 26045, 1053, 11837, 13, 3166, 9557, 29889, 21570, 29889, 5150, 29889, 9794, 1053, 530, 11428, 2659, 29892, 4911, 13, 3166, 6837, 261, 29889, 27852, 29889, 14095, 1053, 6837, 261, 13, 3166, 9316, 29889, 7406, 1053, 3234, 29918, 16432, 13, 5215, 11451, 1688, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 14095, 29918, 2585, 13, 1990, 4321, 23825, 29901, 13, 13, 1678, 822, 1243, 29918, 4704, 29918, 16432, 29918, 27218, 630, 29898, 1311, 1125, 13, 4706, 6837, 261, 29889, 2204, 355, 877, 14456, 29889, 7566, 1495, 13, 4706, 2224, 353, 11837, 877, 16432, 742, 19290, 3790, 29915, 20571, 2396, 29896, 1800, 13, 4706, 2009, 353, 10729, 5126, 2141, 657, 29898, 2084, 29897, 13, 4706, 2009, 29889, 1792, 353, 6837, 261, 29889, 2204, 355, 29898, 2659, 29897, 13, 13, 4706, 2933, 353, 3234, 29918, 16432, 29898, 3827, 29892, 282, 29895, 29922, 29896, 29897, 13, 4706, 4974, 2933, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 13, 13, 13, 1678, 822, 1243, 29918, 4704, 29918, 16432, 29918, 348, 27218, 630, 29898, 1311, 1125, 13, 4706, 6837, 261, 29889, 2204, 355, 877, 14456, 29889, 7566, 1495, 13, 4706, 2224, 353, 11837, 877, 16432, 742, 19290, 3790, 29915, 20571, 2396, 29896, 1800, 13, 4706, 2009, 353, 10729, 5126, 2141, 657, 29898, 2084, 29897, 13, 4706, 2009, 29889, 1792, 353, 530, 11428, 2659, 580, 13, 13, 4706, 2933, 353, 3234, 29918, 16432, 29898, 3827, 29892, 282, 29895, 29922, 29896, 29897, 13, 4706, 396, 4974, 2933, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 13, 4706, 4974, 525, 10149, 29879, 29914, 7507, 29915, 297, 2933, 29889, 2271, 2 ]
naeval/segment/score.py
sdspieg/naeval
36
131657
<gh_stars>10-100 from naeval.score import F1 def score_partitions(preds, targets): score = F1() for pred, target in zip(preds, targets): pred = set(pred.splits) target = set(target.splits) intersection = len(pred & target) score.prec.total += len(pred) score.prec.correct += intersection score.recall.total += len(target) score.recall.correct += intersection return score
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 13, 3166, 1055, 14513, 29889, 13628, 1053, 383, 29896, 13, 13, 13, 1753, 8158, 29918, 1595, 2187, 29898, 11965, 29879, 29892, 22525, 1125, 13, 1678, 8158, 353, 383, 29896, 580, 13, 1678, 363, 4450, 29892, 3646, 297, 14319, 29898, 11965, 29879, 29892, 22525, 1125, 13, 4706, 4450, 353, 731, 29898, 11965, 29889, 23579, 1169, 29897, 13, 4706, 3646, 353, 731, 29898, 5182, 29889, 23579, 1169, 29897, 13, 4706, 17686, 353, 7431, 29898, 11965, 669, 3646, 29897, 13, 4706, 8158, 29889, 17990, 29889, 7827, 4619, 7431, 29898, 11965, 29897, 13, 4706, 8158, 29889, 17990, 29889, 15728, 4619, 17686, 13, 4706, 8158, 29889, 3757, 497, 29889, 7827, 4619, 7431, 29898, 5182, 29897, 13, 4706, 8158, 29889, 3757, 497, 29889, 15728, 4619, 17686, 13, 1678, 736, 8158, 13, 2 ]
yudzuki/role.py
LunaProject-Discord/yudzuki.py
6
2865
<gh_stars>1-10 __all__ = ( "Role", ) class Role: def __init__(self, data): self.data = data self._update(data) def _get_json(self): return self.data def __repr__(self): return ( f"<Role id={self.id} name={self.name}>" ) def __str__(self): return ( f"{self.name}" ) def _update(self, data): self._id = data["id"] self._color = data["color"] self._managed = data["managed"] self._name = data["name"] self._guild_id = data["guild_id"] self._mentionable = data["mentionable"] self._position = data["potition"] self._hoisted = data["hoisted"] @property def id(self): return self._id @property def color(self): return self._color @property def managed(self): return self._managed @property def name(self): return self._name @property def guild_id(self): return self._guild_id @property def mentionable(self): return self._mentionable @property def position(self): return self._position @property def hoisted(self): return self._hoisted
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 1649, 497, 1649, 353, 313, 13, 1678, 376, 16727, 613, 13, 29897, 13, 13, 1990, 1528, 280, 29901, 13, 268, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 848, 1125, 13, 4706, 1583, 29889, 1272, 353, 848, 13, 4706, 1583, 3032, 5504, 29898, 1272, 29897, 13, 268, 13, 1678, 822, 903, 657, 29918, 3126, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 1272, 13, 13, 1678, 822, 4770, 276, 558, 12035, 1311, 1125, 13, 4706, 736, 313, 13, 9651, 285, 29908, 29966, 16727, 1178, 3790, 1311, 29889, 333, 29913, 1024, 3790, 1311, 29889, 978, 29913, 11903, 13, 4706, 1723, 13, 268, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 736, 313, 13, 9651, 285, 29908, 29912, 1311, 29889, 978, 5038, 13, 4706, 1723, 13, 268, 13, 1678, 822, 903, 5504, 29898, 1311, 29892, 848, 1125, 13, 4706, 1583, 3032, 333, 353, 848, 3366, 333, 3108, 13, 4706, 1583, 3032, 2780, 353, 848, 3366, 2780, 3108, 13, 4706, 1583, 3032, 25240, 353, 848, 3366, 25240, 3108, 13, 4706, 1583, 3032, 978, 353, 848, 3366, 978, 3108, 13, 4706, 1583, 3032, 2543, 789, 29918, 333, 353, 848, 3366, 2543, 789, 29918, 333, 3108, 13, 4706, 1583, 3032, 358, 291, 519, 353, 848, 3366, 358, 291, 519, 3108, 13, 4706, 1583, 3032, 3283, 353, 848, 3366, 17765, 654, 3108, 13, 4706, 1583, 3032, 1251, 12652, 353, 848, 3366, 1251, 12652, 3108, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 1178, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 333, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 2927, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 2780, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 8745, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 25240, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 1024, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 978, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 1410, 789, 29918, 333, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 2543, 789, 29918, 333, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 3585, 519, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 358, 291, 519, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 2602, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 3283, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 5089, 12652, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 1251, 12652, 13, 2 ]
app/django/apps/filament/forms.py
aoirint/Mnemosyne
0
79018
from django import forms from filament.models import * class FilamentForm(forms.Form): material = forms.ChoiceField( required=True, choices=FILAMENT_MATERIAL_CHOICES, widget=forms.Select(attrs={ 'class': 'form-control', 'form': 'filament_form', }), ) amount = forms.FloatField( required=True, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': 'g単位', 'min': 0, }), ) price = forms.IntegerField( required=True, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': '円単位', 'min': 0, }), ) shop = forms.CharField( required=False, widget=forms.TextInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': 'Amazon', }), ) url = forms.URLField( required=False, widget=forms.URLInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': 'https://www.amazon.co.jp/dp/XXXXXXXXXX', }), ) owner = forms.CharField( required=False, widget=forms.TextInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': 'your name', }), ) name = forms.CharField( required=False, widget=forms.TextInput(attrs={ 'class': 'form-control', 'form': 'filament_form', 'placeholder': 'マイフィラメント', }), ) image = forms.ImageField( required=False, widget=forms.ClearableFileInput(attrs={ 'class': 'form-control', 'form': 'filament_form', }), )
[ 1, 515, 9557, 1053, 7190, 30004, 13, 3166, 977, 1166, 29889, 9794, 1053, 334, 30004, 13, 30004, 13, 1990, 2514, 1166, 2500, 29898, 9514, 29889, 2500, 1125, 30004, 13, 1678, 5518, 353, 7190, 29889, 29620, 3073, 29898, 30004, 13, 4706, 3734, 29922, 5574, 11167, 13, 4706, 19995, 29922, 3738, 4375, 13780, 29918, 29924, 1299, 1001, 25758, 29918, 3210, 29949, 2965, 2890, 11167, 13, 4706, 11109, 29922, 9514, 29889, 3549, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 5253, 353, 7190, 29889, 11031, 3073, 29898, 30004, 13, 4706, 3734, 29922, 5574, 11167, 13, 4706, 11109, 29922, 9514, 29889, 4557, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 29887, 232, 144, 155, 30956, 23592, 13, 9651, 525, 1195, 2396, 29871, 29900, 11167, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 8666, 353, 7190, 29889, 7798, 3073, 29898, 30004, 13, 4706, 3734, 29922, 5574, 11167, 13, 4706, 11109, 29922, 9514, 29889, 4557, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 232, 137, 137, 232, 144, 155, 30956, 23592, 13, 9651, 525, 1195, 2396, 29871, 29900, 11167, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 18296, 353, 7190, 29889, 27890, 29898, 30004, 13, 4706, 3734, 29922, 8824, 11167, 13, 4706, 11109, 29922, 9514, 29889, 1626, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 29909, 655, 6626, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 3142, 353, 7190, 29889, 4219, 3073, 29898, 30004, 13, 4706, 3734, 29922, 8824, 11167, 13, 4706, 11109, 29922, 9514, 29889, 4219, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 991, 597, 1636, 29889, 17260, 29889, 1111, 29889, 16865, 29914, 6099, 29914, 19165, 19165, 6247, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 12271, 353, 7190, 29889, 27890, 29898, 30004, 13, 4706, 3734, 29922, 8824, 11167, 13, 4706, 11109, 29922, 9514, 29889, 1626, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 8066, 1024, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 1024, 353, 7190, 29889, 27890, 29898, 30004, 13, 4706, 3734, 29922, 8824, 11167, 13, 4706, 11109, 29922, 9514, 29889, 1626, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 9651, 525, 27074, 2396, 525, 30388, 30260, 30423, 30532, 30281, 30604, 30203, 30279, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 1678, 1967, 353, 7190, 29889, 2940, 3073, 29898, 30004, 13, 4706, 3734, 29922, 8824, 11167, 13, 4706, 11109, 29922, 9514, 29889, 18759, 519, 2283, 4290, 29898, 5552, 29879, 3790, 30004, 13, 9651, 525, 1990, 2396, 525, 689, 29899, 6451, 23592, 13, 9651, 525, 689, 2396, 525, 1777, 1166, 29918, 689, 23592, 13, 4706, 500, 511, 30004, 13, 1678, 1723, 30004, 13, 2 ]
functions/fingerprinter.py
DalavanCloud/UGESCO
1
193044
# -*- coding: utf-8 -*- import re import string from unidecode import unidecode PUNCTUATION = re.compile('[%s]' % re.escape(string.punctuation)) class Fingerprinter(object): ''' Python implementation of Google Refine fingerprinting algorithm described here: https://github.com/OpenRefine/OpenRefine/wiki/Clustering-In-Depth Requires the unidecode module: https://github.com/iki/unidecode ''' def __init__(self, string): self.string = self._preprocess(string) def _preprocess(self, string): ''' Strip leading and trailing whitespace, lowercase the string, remove all punctuation, in that order. ''' return PUNCTUATION.sub('', string.strip().lower()) def _latinize(self, string): ''' Replaces unicode characters with closest Latin equivalent. For example, <NAME> becomes <NAME>. ''' return unidecode(string) def _unique_preserving_order(self, seq): ''' Returns unique tokens in a list, preserving order. Fastest version found in this exercise: http://www.peterbe.com/plog/uniqifiers-benchmark ''' seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))] def get_fingerprint_nonsorted(self): ''' Gets non sorted fingerpint that remove isolated letters ''' result = self._latinize(' '.join( self._unique_preserving_order( self.string.split() ) )) return re.sub(r'\b\w{1}\b', '', result) def get_fingerprint(self): ''' Gets conventional fingerpint. ''' return self._latinize(' '.join( self._unique_preserving_order( sorted(self.string.split()) ) )) def get_ngram_fingerprint(self, n=1): ''' Gets ngram fingerpint based on n-length shingles of the string. Default is 1. ''' return self._latinize(''.join( self._unique_preserving_order( sorted([self.string[i:i + n] for i in range(len(self.string) - n + 1)]) ) )) if __name__ == '__main__': f = Fingerprinter("hôtel de ville de Bruxeles à bruxeles") print(f.get_fingerprint()) print(f.get_fingerprint_nonsorted()) print(f.get_ngram_fingerprint(n=1)) print(f.get_ngram_fingerprint(n=2))
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 13, 5215, 337, 13, 5215, 1347, 13, 3166, 443, 680, 401, 1053, 443, 680, 401, 13, 13, 29925, 3904, 1783, 29965, 8098, 353, 337, 29889, 12198, 877, 29961, 29995, 29879, 29962, 29915, 1273, 337, 29889, 21587, 29898, 1807, 29889, 29886, 18049, 29884, 362, 876, 13, 13, 13, 1990, 383, 5621, 558, 1639, 29898, 3318, 1125, 13, 1678, 14550, 13, 1678, 5132, 5314, 310, 5087, 9897, 457, 19917, 2158, 292, 5687, 5439, 1244, 29901, 13, 1678, 2045, 597, 3292, 29889, 510, 29914, 6585, 5620, 457, 29914, 6585, 5620, 457, 29914, 4594, 29914, 6821, 504, 3241, 29899, 797, 29899, 8498, 386, 13, 1678, 830, 339, 2658, 278, 443, 680, 401, 3883, 29901, 2045, 597, 3292, 29889, 510, 29914, 10058, 29914, 348, 680, 401, 13, 1678, 14550, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1347, 1125, 13, 4706, 1583, 29889, 1807, 353, 1583, 3032, 1457, 5014, 29898, 1807, 29897, 13, 13, 1678, 822, 903, 1457, 5014, 29898, 1311, 29892, 1347, 1125, 13, 4706, 14550, 13, 4706, 624, 6472, 8236, 322, 25053, 24358, 29892, 5224, 4878, 278, 1347, 29892, 3349, 599, 6035, 22999, 362, 29892, 13, 4706, 297, 393, 1797, 29889, 13, 4706, 14550, 13, 4706, 736, 349, 3904, 1783, 29965, 8098, 29889, 1491, 877, 742, 1347, 29889, 17010, 2141, 13609, 3101, 13, 13, 1678, 822, 903, 5066, 262, 675, 29898, 1311, 29892, 1347, 1125, 13, 4706, 14550, 13, 4706, 10088, 6048, 29104, 4890, 411, 21438, 13548, 7126, 29889, 1152, 1342, 29892, 13, 4706, 529, 5813, 29958, 7415, 529, 5813, 15513, 13, 4706, 14550, 13, 4706, 736, 443, 680, 401, 29898, 1807, 29897, 13, 13, 1678, 822, 903, 13092, 29918, 4569, 29530, 29918, 2098, 29898, 1311, 29892, 19359, 1125, 13, 4706, 14550, 13, 4706, 16969, 5412, 18897, 297, 263, 1051, 29892, 2225, 29530, 1797, 29889, 23786, 342, 1873, 1476, 297, 445, 13, 4706, 15058, 29901, 1732, 597, 1636, 29889, 29886, 1308, 915, 29889, 510, 29914, 29886, 1188, 29914, 3909, 29939, 14903, 29899, 1785, 16580, 13, 4706, 14550, 13, 4706, 3595, 353, 731, 580, 13, 4706, 3595, 29918, 1202, 353, 3595, 29889, 1202, 13, 4706, 736, 518, 29916, 363, 921, 297, 19359, 565, 451, 313, 29916, 297, 3595, 470, 3595, 29918, 1202, 29898, 29916, 28166, 13, 13, 1678, 822, 679, 29918, 29888, 5621, 2158, 29918, 29876, 787, 18054, 29898, 1311, 1125, 13, 4706, 14550, 13, 4706, 402, 1691, 1661, 12705, 19917, 29886, 524, 393, 3349, 23968, 8721, 13, 4706, 14550, 13, 4706, 1121, 353, 1583, 3032, 5066, 262, 675, 877, 15300, 7122, 29898, 13, 9651, 1583, 3032, 13092, 29918, 4569, 29530, 29918, 2098, 29898, 13, 18884, 1583, 29889, 1807, 29889, 5451, 580, 13, 13, 9651, 1723, 13, 308, 876, 13, 13, 4706, 736, 337, 29889, 1491, 29898, 29878, 12764, 29890, 29905, 29893, 29912, 29896, 1012, 29890, 742, 15516, 1121, 29897, 13, 13, 1678, 822, 679, 29918, 29888, 5621, 2158, 29898, 1311, 1125, 13, 4706, 14550, 13, 4706, 402, 1691, 28557, 19917, 29886, 524, 29889, 13, 4706, 14550, 13, 4706, 736, 1583, 3032, 5066, 262, 675, 877, 15300, 7122, 29898, 13, 9651, 1583, 3032, 13092, 29918, 4569, 29530, 29918, 2098, 29898, 13, 18884, 12705, 29898, 1311, 29889, 1807, 29889, 5451, 3101, 13, 9651, 1723, 13, 308, 876, 13, 13, 1678, 822, 679, 29918, 29876, 1393, 29918, 29888, 5621, 2158, 29898, 1311, 29892, 302, 29922, 29896, 1125, 13, 4706, 14550, 13, 4706, 402, 1691, 302, 1393, 19917, 29886, 524, 2729, 373, 302, 29899, 2848, 528, 292, 793, 310, 278, 1347, 29889, 13, 4706, 13109, 338, 29871, 29896, 29889, 13, 4706, 14550, 13, 4706, 736, 1583, 3032, 5066, 262, 675, 877, 4286, 7122, 29898, 13, 9651, 1583, 3032, 13092, 29918, 4569, 29530, 29918, 2098, 29898, 13, 18884, 12705, 4197, 1311, 29889, 1807, 29961, 29875, 29901, 29875, 718, 302, 29962, 13, 462, 4706, 363, 474, 297, 3464, 29898, 2435, 29898, 1311, 29889, 1807, 29897, 448, 302, 718, 29871, 29896, 29897, 2314, 13, 9651, 1723, 13, 308, 876, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 285, 353, 383, 5621, 558, 1639, 703, 29882, 25892, 316, 8441, 316, 8135, 29916, 5830, 818, 19702, 29916, 5830, 1159, 13, 1678, 1596, 29898, 29888, 29889, 657, 29918, 29888, 5621, 2158, 3101, 13, 13, 1678, 1596, 29898, 29888, 29889, 657, 29918, 29888, 5621, 2158, 29918, 29876, 787, 18054, 3101, 13, 13, 1678, 1596, 29898, 29888, 29889, 657, 29918, 29876, 1393, 29918, 29888, 5621, 2158, 29898, 29876, 29922, 29896, 876, 13, 13, 1678, 1596, 29898, 29888, 29889, 657, 29918, 29876, 1393, 29918, 29888, 5621, 2158, 29898, 29876, 29922, 29906, 876, 13, 2 ]
Printing/BlenderScripts/ColorFabUI/convertToBWOperator.py
HCIELab/ColorMod
3
118134
import bpy from bpy.types import Operator class ConvertToBWOperator(Operator): bl_idname = "object.convert_to_bw_operator" bl_label = "Convert Colored Voxels to Black" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(self, context): return True def execute(self, context): color = ['white', 'red', 'blue'] for i in range(1,len(color)+1): objects_on_current_layer = [ob for ob in bpy.context.scene.objects if ob.layers[i]] for obj in objects_on_current_layer: if obj.data.materials[0] == bpy.data.materials[color[i]]: obj.data.materials[0] = bpy.data.materials['black'] else: obj.data.materials[0] = bpy.data.materials['white'] return {'FINISHED'} def register(): bpy.utils.register_class(ConvertToBWOperator) def unregister(): bpy.utils.unregister_class(ConvertToBWOperator) if __name__ == "__main__": register()
[ 1, 1053, 289, 2272, 29871, 13, 3166, 289, 2272, 29889, 8768, 1053, 6607, 1061, 13, 268, 13, 1990, 14806, 1762, 29933, 29956, 26486, 29898, 26486, 1125, 13, 1678, 1999, 29918, 333, 978, 353, 376, 3318, 29889, 13441, 29918, 517, 29918, 29890, 29893, 29918, 6891, 29908, 13, 1678, 1999, 29918, 1643, 353, 376, 18455, 1530, 4395, 478, 2251, 1379, 304, 6054, 29908, 13, 1678, 1999, 29918, 6768, 353, 11117, 18166, 9047, 1001, 742, 525, 18783, 29949, 10827, 13, 268, 13, 1678, 732, 1990, 5696, 29871, 13, 1678, 822, 21180, 29898, 1311, 29892, 3030, 1125, 13, 4706, 736, 5852, 29871, 13, 268, 13, 1678, 822, 6222, 29898, 1311, 29892, 3030, 1125, 13, 4706, 2927, 353, 6024, 10921, 742, 525, 1127, 742, 525, 9539, 2033, 29871, 13, 4706, 363, 474, 297, 3464, 29898, 29896, 29892, 2435, 29898, 2780, 7240, 29896, 1125, 29871, 13, 9651, 3618, 29918, 265, 29918, 3784, 29918, 13148, 353, 518, 711, 363, 704, 297, 289, 2272, 29889, 4703, 29889, 24645, 29889, 12650, 565, 704, 29889, 29277, 29961, 29875, 5262, 13, 9651, 363, 5446, 297, 3618, 29918, 265, 29918, 3784, 29918, 13148, 29901, 29871, 13, 18884, 565, 5446, 29889, 1272, 29889, 15388, 29879, 29961, 29900, 29962, 1275, 289, 2272, 29889, 1272, 29889, 15388, 29879, 29961, 2780, 29961, 29875, 5262, 29901, 13, 462, 1678, 5446, 29889, 1272, 29889, 15388, 29879, 29961, 29900, 29962, 353, 289, 2272, 29889, 1272, 29889, 15388, 29879, 1839, 8517, 2033, 13, 18884, 1683, 29901, 29871, 13, 462, 1678, 5446, 29889, 1272, 29889, 15388, 29879, 29961, 29900, 29962, 353, 289, 2272, 29889, 1272, 29889, 15388, 29879, 1839, 10921, 2033, 29871, 13, 4706, 736, 11117, 29943, 1177, 3235, 29950, 3352, 10827, 13, 268, 13, 268, 13, 1753, 6036, 7295, 13, 1678, 289, 2272, 29889, 13239, 29889, 9573, 29918, 1990, 29898, 18455, 1762, 29933, 29956, 26486, 29897, 13, 13, 1753, 443, 9573, 7295, 13, 1678, 289, 2272, 29889, 13239, 29889, 348, 9573, 29918, 1990, 29898, 18455, 1762, 29933, 29956, 26486, 29897, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 6036, 580, 13, 13, 2 ]
test/mitmproxy/test_examples.py
e7appew/pkg-mitmproxy
0
142627
<gh_stars>0 import json import os import six from mitmproxy import options from mitmproxy import contentviews from mitmproxy.builtins import script from mitmproxy.flow import master from mitmproxy.flow import state import netlib.utils from netlib import tutils as netutils from netlib.http import Headers from netlib.http import cookies from . import tutils, mastertest example_dir = netlib.utils.Data(__name__).push("../../examples") class ScriptError(Exception): pass class RaiseMaster(master.FlowMaster): def add_log(self, e, level): if level in ("warn", "error"): raise ScriptError(e) def tscript(cmd, args=""): o = options.Options() cmd = example_dir.path(cmd) + " " + args m = RaiseMaster(o, None, state.State()) sc = script.Script(cmd) m.addons.add(sc) return m, sc class TestScripts(mastertest.MasterTest): def test_add_header(self): m, _ = tscript("add_header.py") f = tutils.tflow(resp=netutils.tresp()) m.response(f) assert f.response.headers["newheader"] == "foo" def test_custom_contentviews(self): m, sc = tscript("custom_contentviews.py") pig = contentviews.get("pig_latin_HTML") _, fmt = pig(b"<html>test!</html>") assert any(b'esttay!' in val[0][1] for val in fmt) assert not pig(b"gobbledygook") def test_iframe_injector(self): with tutils.raises(ScriptError): tscript("iframe_injector.py") m, sc = tscript("iframe_injector.py", "http://example.org/evil_iframe") f = tutils.tflow(resp=netutils.tresp(content=b"<html>mitmproxy</html>")) m.response(f) content = f.response.content assert b'iframe' in content and b'evil_iframe' in content def test_modify_form(self): m, sc = tscript("modify_form.py") form_header = Headers(content_type="application/x-www-form-urlencoded") f = tutils.tflow(req=netutils.treq(headers=form_header)) m.request(f) assert f.request.urlencoded_form[b"mitmproxy"] == b"rocks" f.request.headers["content-type"] = "" m.request(f) assert list(f.request.urlencoded_form.items()) == [(b"foo", b"bar")] def test_modify_querystring(self): m, sc = tscript("modify_querystring.py") f = tutils.tflow(req=netutils.treq(path="/search?q=term")) m.request(f) assert f.request.query["mitmproxy"] == "rocks" f.request.path = "/" m.request(f) assert f.request.query["mitmproxy"] == "rocks" def test_arguments(self): m, sc = tscript("arguments.py", "mitmproxy rocks") f = tutils.tflow(resp=netutils.tresp(content=b"I <3 mitmproxy")) m.response(f) assert f.response.content == b"I <3 rocks" def test_redirect_requests(self): m, sc = tscript("redirect_requests.py") f = tutils.tflow(req=netutils.treq(host="example.org")) m.request(f) assert f.request.host == "mitmproxy.org" class TestHARDump(): def flow(self, resp_content=b'message'): times = dict( timestamp_start=746203272, timestamp_end=746203272, ) # Create a dummy flow for testing return tutils.tflow( req=netutils.treq(method=b'GET', **times), resp=netutils.tresp(content=resp_content, **times) ) def test_no_file_arg(self): with tutils.raises(ScriptError): tscript("har_dump.py") def test_simple(self): with tutils.tmpdir() as tdir: path = os.path.join(tdir, "somefile") m, sc = tscript("har_dump.py", six.moves.shlex_quote(path)) m.addons.invoke(m, "response", self.flow()) m.addons.remove(sc) with open(path, "r") as inp: har = json.load(inp) assert len(har["log"]["entries"]) == 1 def test_base64(self): with tutils.tmpdir() as tdir: path = os.path.join(tdir, "somefile") m, sc = tscript("har_dump.py", six.moves.shlex_quote(path)) m.addons.invoke(m, "response", self.flow(resp_content=b"foo" + b"\xFF" * 10)) m.addons.remove(sc) with open(path, "r") as inp: har = json.load(inp) assert har["log"]["entries"][0]["response"]["content"]["encoding"] == "base64" def test_format_cookies(self): m, sc = tscript("har_dump.py", "-") format_cookies = sc.ns.ns["format_cookies"] CA = cookies.CookieAttrs f = format_cookies([("n", "v", CA([("k", "v")]))])[0] assert f['name'] == "n" assert f['value'] == "v" assert not f['httpOnly'] assert not f['secure'] f = format_cookies([("n", "v", CA([("httponly", None), ("secure", None)]))])[0] assert f['httpOnly'] assert f['secure'] f = format_cookies([("n", "v", CA([("expires", "Mon, 24-Aug-2037 00:00:00 GMT")]))])[0] assert f['expires']
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 5215, 4390, 13, 5215, 2897, 13, 13, 5215, 4832, 13, 13, 3166, 1380, 29885, 14701, 1053, 3987, 13, 3166, 1380, 29885, 14701, 1053, 2793, 7406, 13, 3166, 1380, 29885, 14701, 29889, 16145, 1144, 1053, 2471, 13, 3166, 1380, 29885, 14701, 29889, 1731, 1053, 5835, 13, 3166, 1380, 29885, 14701, 29889, 1731, 1053, 2106, 13, 13, 5215, 7787, 1982, 29889, 13239, 13, 13, 3166, 7787, 1982, 1053, 7149, 2719, 408, 7787, 13239, 13, 3166, 7787, 1982, 29889, 1124, 1053, 12252, 414, 13, 3166, 7787, 1982, 29889, 1124, 1053, 21046, 13, 13, 3166, 869, 1053, 7149, 2719, 29892, 5835, 1688, 13, 13, 4773, 29918, 3972, 353, 7787, 1982, 29889, 13239, 29889, 1469, 22168, 978, 1649, 467, 5910, 703, 21546, 19057, 1159, 13, 13, 13, 1990, 14415, 2392, 29898, 2451, 1125, 13, 1678, 1209, 13, 13, 13, 1990, 6981, 895, 19203, 29898, 6207, 29889, 17907, 19203, 1125, 13, 1678, 822, 788, 29918, 1188, 29898, 1311, 29892, 321, 29892, 3233, 1125, 13, 4706, 565, 3233, 297, 4852, 25442, 613, 376, 2704, 29908, 1125, 13, 9651, 12020, 14415, 2392, 29898, 29872, 29897, 13, 13, 13, 1753, 260, 2154, 29898, 9006, 29892, 6389, 13776, 1125, 13, 1678, 288, 353, 3987, 29889, 5856, 580, 13, 1678, 9920, 353, 1342, 29918, 3972, 29889, 2084, 29898, 9006, 29897, 718, 376, 376, 718, 6389, 13, 1678, 286, 353, 6981, 895, 19203, 29898, 29877, 29892, 6213, 29892, 2106, 29889, 2792, 3101, 13, 1678, 885, 353, 2471, 29889, 4081, 29898, 9006, 29897, 13, 1678, 286, 29889, 1202, 787, 29889, 1202, 29898, 1557, 29897, 13, 1678, 736, 286, 29892, 885, 13, 13, 13, 1990, 4321, 4081, 29879, 29898, 6207, 1688, 29889, 19203, 3057, 1125, 13, 1678, 822, 1243, 29918, 1202, 29918, 6672, 29898, 1311, 1125, 13, 4706, 286, 29892, 903, 353, 260, 2154, 703, 1202, 29918, 6672, 29889, 2272, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 13713, 29922, 1212, 13239, 29889, 5888, 29886, 3101, 13, 4706, 286, 29889, 5327, 29898, 29888, 29897, 13, 4706, 4974, 285, 29889, 5327, 29889, 13662, 3366, 1482, 6672, 3108, 1275, 376, 5431, 29908, 13, 13, 1678, 822, 1243, 29918, 6341, 29918, 3051, 7406, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 6341, 29918, 3051, 7406, 29889, 2272, 1159, 13, 4706, 282, 335, 353, 2793, 7406, 29889, 657, 703, 29886, 335, 29918, 5066, 262, 29918, 7020, 1159, 13, 4706, 17117, 19200, 353, 282, 335, 29898, 29890, 29908, 29966, 1420, 29958, 1688, 29991, 829, 1420, 29958, 1159, 13, 4706, 4974, 738, 29898, 29890, 29915, 342, 29873, 388, 20714, 297, 659, 29961, 29900, 3816, 29896, 29962, 363, 659, 297, 19200, 29897, 13, 4706, 4974, 451, 282, 335, 29898, 29890, 29908, 29887, 711, 569, 4518, 1484, 554, 1159, 13, 13, 1678, 822, 1243, 29918, 22000, 29918, 21920, 272, 29898, 1311, 1125, 13, 4706, 411, 7149, 2719, 29889, 336, 4637, 29898, 4081, 2392, 1125, 13, 9651, 260, 2154, 703, 22000, 29918, 21920, 272, 29889, 2272, 1159, 13, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 22000, 29918, 21920, 272, 29889, 2272, 613, 376, 1124, 597, 4773, 29889, 990, 29914, 5750, 309, 29918, 22000, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 13713, 29922, 1212, 13239, 29889, 5888, 29886, 29898, 3051, 29922, 29890, 29908, 29966, 1420, 29958, 2415, 29885, 14701, 829, 1420, 29958, 5783, 13, 4706, 286, 29889, 5327, 29898, 29888, 29897, 13, 4706, 2793, 353, 285, 29889, 5327, 29889, 3051, 13, 4706, 4974, 289, 29915, 22000, 29915, 297, 2793, 322, 289, 29915, 5750, 309, 29918, 22000, 29915, 297, 2793, 13, 13, 1678, 822, 1243, 29918, 1545, 1598, 29918, 689, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 1545, 1598, 29918, 689, 29889, 2272, 1159, 13, 13, 4706, 883, 29918, 6672, 353, 12252, 414, 29898, 3051, 29918, 1853, 543, 6214, 29914, 29916, 29899, 1636, 29899, 689, 29899, 2271, 26716, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 7971, 29922, 1212, 13239, 29889, 2484, 29939, 29898, 13662, 29922, 689, 29918, 6672, 876, 13, 4706, 286, 29889, 3827, 29898, 29888, 29897, 13, 13, 4706, 4974, 285, 29889, 3827, 29889, 2271, 26716, 29918, 689, 29961, 29890, 29908, 2415, 29885, 14701, 3108, 1275, 289, 29908, 307, 4684, 29908, 13, 13, 4706, 285, 29889, 3827, 29889, 13662, 3366, 3051, 29899, 1853, 3108, 353, 5124, 13, 4706, 286, 29889, 3827, 29898, 29888, 29897, 13, 4706, 4974, 1051, 29898, 29888, 29889, 3827, 29889, 2271, 26716, 29918, 689, 29889, 7076, 3101, 1275, 17288, 29890, 29908, 5431, 613, 289, 29908, 1646, 13531, 13, 13, 1678, 822, 1243, 29918, 1545, 1598, 29918, 1972, 1807, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 1545, 1598, 29918, 1972, 1807, 29889, 2272, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 7971, 29922, 1212, 13239, 29889, 2484, 29939, 29898, 2084, 13802, 4478, 29973, 29939, 29922, 8489, 5783, 13, 13, 4706, 286, 29889, 3827, 29898, 29888, 29897, 13, 4706, 4974, 285, 29889, 3827, 29889, 1972, 3366, 2415, 29885, 14701, 3108, 1275, 376, 307, 4684, 29908, 13, 13, 4706, 285, 29889, 3827, 29889, 2084, 353, 5591, 29908, 13, 4706, 286, 29889, 3827, 29898, 29888, 29897, 13, 4706, 4974, 285, 29889, 3827, 29889, 1972, 3366, 2415, 29885, 14701, 3108, 1275, 376, 307, 4684, 29908, 13, 13, 1678, 822, 1243, 29918, 25699, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 25699, 29889, 2272, 613, 376, 2415, 29885, 14701, 23150, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 13713, 29922, 1212, 13239, 29889, 5888, 29886, 29898, 3051, 29922, 29890, 29908, 29902, 529, 29941, 1380, 29885, 14701, 5783, 13, 4706, 286, 29889, 5327, 29898, 29888, 29897, 13, 4706, 4974, 285, 29889, 5327, 29889, 3051, 1275, 289, 29908, 29902, 529, 29941, 23150, 29908, 13, 13, 1678, 822, 1243, 29918, 17886, 29918, 24830, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 17886, 29918, 24830, 29889, 2272, 1159, 13, 4706, 285, 353, 7149, 2719, 29889, 29873, 1731, 29898, 7971, 29922, 1212, 13239, 29889, 2484, 29939, 29898, 3069, 543, 4773, 29889, 990, 5783, 13, 4706, 286, 29889, 3827, 29898, 29888, 29897, 13, 4706, 4974, 285, 29889, 3827, 29889, 3069, 1275, 376, 2415, 29885, 14701, 29889, 990, 29908, 13, 13, 13, 1990, 4321, 29950, 17011, 3427, 7295, 13, 13, 1678, 822, 4972, 29898, 1311, 29892, 4613, 29918, 3051, 29922, 29890, 29915, 4906, 29374, 13, 4706, 3064, 353, 9657, 29898, 13, 9651, 14334, 29918, 2962, 29922, 29955, 29946, 29953, 29906, 29900, 29941, 29906, 29955, 29906, 29892, 13, 9651, 14334, 29918, 355, 29922, 29955, 29946, 29953, 29906, 29900, 29941, 29906, 29955, 29906, 29892, 13, 4706, 1723, 13, 13, 4706, 396, 6204, 263, 20254, 4972, 363, 6724, 13, 4706, 736, 7149, 2719, 29889, 29873, 1731, 29898, 13, 9651, 12428, 29922, 1212, 13239, 29889, 2484, 29939, 29898, 5696, 29922, 29890, 29915, 7194, 742, 3579, 3706, 511, 13, 9651, 4613, 29922, 1212, 13239, 29889, 5888, 29886, 29898, 3051, 29922, 13713, 29918, 3051, 29892, 3579, 3706, 29897, 13, 4706, 1723, 13, 13, 1678, 822, 1243, 29918, 1217, 29918, 1445, 29918, 1191, 29898, 1311, 1125, 13, 4706, 411, 7149, 2719, 29889, 336, 4637, 29898, 4081, 2392, 1125, 13, 9651, 260, 2154, 703, 8222, 29918, 15070, 29889, 2272, 1159, 13, 13, 1678, 822, 1243, 29918, 12857, 29898, 1311, 1125, 13, 4706, 411, 7149, 2719, 29889, 7050, 3972, 580, 408, 260, 3972, 29901, 13, 9651, 2224, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1594, 381, 29892, 376, 5372, 1445, 1159, 13, 13, 9651, 286, 29892, 885, 353, 260, 2154, 703, 8222, 29918, 15070, 29889, 2272, 613, 4832, 29889, 13529, 267, 29889, 845, 2506, 29918, 1396, 29898, 2084, 876, 13, 9651, 286, 29889, 1202, 787, 29889, 9772, 29898, 29885, 29892, 376, 5327, 613, 1583, 29889, 1731, 3101, 13, 9651, 286, 29889, 1202, 787, 29889, 5992, 29898, 1557, 29897, 13, 13, 9651, 411, 1722, 29898, 2084, 29892, 376, 29878, 1159, 408, 297, 29886, 29901, 13, 18884, 4023, 353, 4390, 29889, 1359, 29898, 262, 29886, 29897, 13, 13, 4706, 4974, 7431, 29898, 8222, 3366, 1188, 3108, 3366, 26586, 20068, 1275, 29871, 29896, 13, 13, 1678, 822, 1243, 29918, 3188, 29953, 29946, 29898, 1311, 1125, 13, 4706, 411, 7149, 2719, 29889, 7050, 3972, 580, 408, 260, 3972, 29901, 13, 9651, 2224, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1594, 381, 29892, 376, 5372, 1445, 1159, 13, 13, 9651, 286, 29892, 885, 353, 260, 2154, 703, 8222, 29918, 15070, 29889, 2272, 613, 4832, 29889, 13529, 267, 29889, 845, 2506, 29918, 1396, 29898, 2084, 876, 13, 9651, 286, 29889, 1202, 787, 29889, 9772, 29898, 29885, 29892, 376, 5327, 613, 1583, 29889, 1731, 29898, 13713, 29918, 3051, 29922, 29890, 29908, 5431, 29908, 718, 289, 26732, 29916, 4198, 29908, 334, 29871, 29896, 29900, 876, 13, 9651, 286, 29889, 1202, 787, 29889, 5992, 29898, 1557, 29897, 13, 13, 9651, 411, 1722, 29898, 2084, 29892, 376, 29878, 1159, 408, 297, 29886, 29901, 13, 18884, 4023, 353, 4390, 29889, 1359, 29898, 262, 29886, 29897, 13, 13, 4706, 4974, 4023, 3366, 1188, 3108, 3366, 26586, 3108, 29961, 29900, 29962, 3366, 5327, 3108, 3366, 3051, 3108, 3366, 22331, 3108, 1275, 376, 3188, 29953, 29946, 29908, 13, 13, 1678, 822, 1243, 29918, 4830, 29918, 15108, 583, 29898, 1311, 1125, 13, 4706, 286, 29892, 885, 353, 260, 2154, 703, 8222, 29918, 15070, 29889, 2272, 613, 11663, 1159, 13, 4706, 3402, 29918, 15108, 583, 353, 885, 29889, 1983, 29889, 1983, 3366, 4830, 29918, 15108, 583, 3108, 13, 13, 4706, 12766, 353, 21046, 29889, 24914, 25098, 29879, 13, 13, 4706, 285, 353, 3402, 29918, 15108, 583, 4197, 703, 29876, 613, 376, 29894, 613, 12766, 4197, 703, 29895, 613, 376, 29894, 1159, 12622, 2314, 29961, 29900, 29962, 13, 4706, 4974, 285, 1839, 978, 2033, 1275, 376, 29876, 29908, 13, 4706, 4974, 285, 1839, 1767, 2033, 1275, 376, 29894, 29908, 13, 4706, 4974, 451, 285, 1839, 1124, 11730, 2033, 13, 4706, 4974, 451, 285, 1839, 24216, 2033, 13, 13, 4706, 285, 353, 3402, 29918, 15108, 583, 4197, 703, 29876, 613, 376, 29894, 613, 12766, 4197, 703, 691, 1112, 368, 613, 6213, 511, 4852, 24216, 613, 6213, 4638, 876, 2314, 29961, 29900, 29962, 13, 4706, 4974, 285, 1839, 1124, 11730, 2033, 13, 4706, 4974, 285, 1839, 24216, 2033, 13, 13, 4706, 285, 353, 3402, 29918, 15108, 583, 4197, 703, 29876, 613, 376, 29894, 613, 12766, 4197, 703, 4548, 2658, 613, 376, 7185, 29892, 29871, 29906, 29946, 29899, 29909, 688, 29899, 29906, 29900, 29941, 29955, 29871, 29900, 29900, 29901, 29900, 29900, 29901, 29900, 29900, 402, 11490, 1159, 12622, 2314, 29961, 29900, 29962, 13, 4706, 4974, 285, 1839, 4548, 2658, 2033, 13, 2 ]
pytorch/src/train.py
LotusWhu/xynet
0
1617191
import argparse import os import numpy as np import torch import torch.nn as nn import torch.optim as optim import network import loss import pre_process as prep import torch.utils.data as util_data import lr_schedule from data_list import ImageList from torch.autograd import Variable optim_dict = {"SGD": optim.SGD} def image_classification_predict(loader, model, test_10crop=True, gpu=True): start_test = True if test_10crop: iter_test = [iter(loader['test'+str(i)]) for i in xrange(10)] for i in xrange(len(loader['test0'])): data = [iter_test[j].next() for j in xrange(10)] inputs = [data[j][0] for j in xrange(10)] if gpu: for j in xrange(10): inputs[j] = Variable(inputs[j].cuda()) else: for j in xrange(10): inputs[j] = Variable(inputs[j]) outputs = [] for j in xrange(10): outputs.append(model(inputs[j])) outputs = sum(outputs) if start_test: all_output = outputs.data.float() start_test = False else: all_output = torch.cat((all_output, outputs.data.float()), 0) else: iter_val = iter(loader["test"]) for i in xrange(len(loader['test'])): data = iter_val.next() inputs = data[0] if gpu: inputs = Variable(inputs.cuda()) else: inputs = Variable(inputs) outputs = model(inputs) if start_test: all_output = outputs.data.cpu().float() start_test = False else: all_output = torch.cat((all_output, outputs.data.cpu().float()), 0) _, predict = torch.max(all_output, 1) return all_output, predict def image_classification_test(loader, model, test_10crop=True, gpu=True): start_test = True if test_10crop: iter_test = [iter(loader['test'+str(i)]) for i in xrange(10)] for i in xrange(len(loader['test0'])): data = [iter_test[j].next() for j in xrange(10)] inputs = [data[j][0] for j in xrange(10)] labels = data[0][1] if gpu: for j in xrange(10): inputs[j] = Variable(inputs[j].cuda()) labels = Variable(labels.cuda()) else: for j in xrange(10): inputs[j] = Variable(inputs[j]) labels = Variable(labels) outputs = [] for j in xrange(10): outputs.append(model(inputs[j])) outputs = sum(outputs) if start_test: all_output = outputs.data.float() all_label = labels.data.float() start_test = False else: all_output = torch.cat((all_output, outputs.data.float()), 0) all_label = torch.cat((all_label, labels.data.float()), 0) else: iter_test = iter(loader["test"]) for i in xrange(len(loader["test"])): data = iter_test.next() inputs = data[0] labels = data[1] if gpu: inputs = Variable(inputs.cuda()) labels = Variable(labels.cuda()) else: inputs = Variable(inputs) labels = Variable(labels) outputs = model(inputs) if start_test: all_output = outputs.data.float() all_label = labels.data.float() start_test = False else: all_output = torch.cat((all_output, outputs.data.float()), 0) all_label = torch.cat((all_label, labels.data.float()), 0) _, predict = torch.max(all_output, 1) accuracy = torch.sum(torch.squeeze(predict).float() == all_label).item() / float(all_label.size()[0]) return accuracy def transfer_classification(config): ## set pre-process prep_dict = {} for prep_config in config["prep"]: prep_dict[prep_config["name"]] = {} if prep_config["type"] == "image": prep_dict[prep_config["name"]]["test_10crop"] = prep_config["test_10crop"] prep_dict[prep_config["name"]]["train"] = prep.image_train(resize_size=prep_config["resize_size"], crop_size=prep_config["crop_size"]) if prep_config["test_10crop"]: prep_dict[prep_config["name"]]["test"] = prep.image_test_10crop(resize_size=prep_config["resize_size"], crop_size=prep_config["crop_size"]) else: prep_dict[prep_config["name"]]["test"] = prep.image_test(resize_size=prep_config["resize_size"], crop_size=prep_config["crop_size"]) ## set loss class_criterion = nn.CrossEntropyLoss() loss_config = config["loss"] transfer_criterion = loss.loss_dict[loss_config["name"]] if "params" not in loss_config: loss_config["params"] = {} ## prepare data dsets = {} dset_loaders = {} for data_config in config["data"]: dsets[data_config["name"]] = {} dset_loaders[data_config["name"]] = {} ## image data if data_config["type"] == "image": dsets[data_config["name"]]["train"] = ImageList(open(data_config["list_path"]["train"]).readlines(), transform=prep_dict[data_config["name"]]["train"]) dset_loaders[data_config["name"]]["train"] = util_data.DataLoader(dsets[data_config["name"]]["train"], batch_size=data_config["batch_size"]["train"], shuffle=True, num_workers=4) if "test" in data_config["list_path"]: if prep_dict[data_config["name"]]["test_10crop"]: for i in range(10): dsets[data_config["name"]]["test"+str(i)] = ImageList(open(data_config["list_path"]["test"]).readlines(), transform=prep_dict[data_config["name"]]["test"]["val"+str(i)] ) dset_loaders[data_config["name"]]["test"+str(i)] = util_data.DataLoader(dsets[data_config["name"]]["test"+str(i)], batch_size=data_config["batch_size"]["test"], shuffle=False, num_workers=4) else: dsets[data_config["name"]]["test"] = ImageList(open(data_config["list_path"]["test"]).readlines(), transform=prep_dict[data_config["name"]]["test"]) dset_loaders[data_config["name"]]["test"] = util_data.DataLoader(dsets[data_config["name"]]["test"], batch_size=data_config["batch_size"]["test"], shuffle=False, num_workers=4) else: if prep_dict[data_config["name"]]["test_10crop"]: for i in range(10): dsets[data_config["name"]]["test"+str(i)] = ImageList(open(data_config["list_path"]["train"]).readlines(), transform=prep_dict[data_config["name"]]["test"]["val"+str(i)]) dset_loaders[data_config["name"]]["test"+str(i)] = util_data.DataLoader(dsets[data_config["name"]]["test"+str(i)], batch_size=data_config["batch_size"]["test"], shuffle=False, num_workers=4) else: dsets[data_config["name"]]["test"] = ImageList(open(data_config["list_path"]["train"]).readlines(), transform=prep_dict[data_config["name"]]["test"]) dset_loaders[data_config["name"]]["test"] = util_data.DataLoader(dsets[data_config["name"]]["test"], batch_size=data_config["batch_size"]["test"], shuffle=False, num_workers=4) class_num = 31 ## set base network net_config = config["network"] base_network = network.network_dict[net_config["name"]]() if net_config["use_bottleneck"]: bottleneck_layer = nn.Linear(base_network.output_num(), net_config["bottleneck_dim"]) classifier_layer = nn.Linear(bottleneck_layer.out_features, class_num) else: classifier_layer = nn.Linear(base_network.output_num(), class_num) for param in base_network.parameters(): param.requires_grad = False ## initialization if net_config["use_bottleneck"]: bottleneck_layer.weight.data.normal_(0, 0.005) bottleneck_layer.bias.data.fill_(0.1) bottleneck_layer = nn.Sequential(bottleneck_layer, nn.ReLU(), nn.Dropout(0.5)) classifier_layer.weight.data.normal_(0, 0.01) classifier_layer.bias.data.fill_(0.0) use_gpu = torch.cuda.is_available() if use_gpu: if net_config["use_bottleneck"]: bottleneck_layer = bottleneck_layer.cuda() classifier_layer = classifier_layer.cuda() base_network = base_network.cuda() ## collect parameters if net_config["use_bottleneck"]: parameter_list = [{"params":bottleneck_layer.parameters(), "lr":10}, {"params":classifier_layer.parameters(), "lr":10}] else: parameter_list = [{"params":classifier_layer.parameters(), "lr":10}] ## add additional network for some methods if loss_config["name"] == "JAN": softmax_layer = nn.Softmax() if use_gpu: softmax_layer = softmax_layer.cuda() ## set optimizer optimizer_config = config["optimizer"] optimizer = optim_dict[optimizer_config["type"]](parameter_list, **(optimizer_config["optim_params"])) param_lr = [] for param_group in optimizer.param_groups: param_lr.append(param_group["lr"]) schedule_param = optimizer_config["lr_param"] lr_scheduler = lr_schedule.schedule_dict[optimizer_config["lr_type"]] ## train len_train_source = len(dset_loaders["source"]["train"]) - 1 len_train_target = len(dset_loaders["target"]["train"]) - 1 transfer_loss_value = classifier_loss_value = total_loss_value = 0.0 for i in range(config["num_iterations"]): ## test in the train if i % config["test_interval"] == 0: base_network.train(False) classifier_layer.train(False) if net_config["use_bottleneck"]: bottleneck_layer.train(False) print image_classification_test(dset_loaders["target"], nn.Sequential(base_network, bottleneck_layer, classifier_layer), test_10crop=prep_dict["target"]["test_10crop"], gpu=use_gpu) else: print image_classification_test(dset_loaders["target"], nn.Sequential(base_network, classifier_layer), test_10crop=prep_dict["target"]["test_10crop"], gpu=use_gpu) loss_test = nn.BCELoss() ## train one iter if net_config["use_bottleneck"]: bottleneck_layer.train(True) classifier_layer.train(True) optimizer = lr_scheduler(param_lr, optimizer, i, **schedule_param) optimizer.zero_grad() if i % len_train_source == 0: iter_source = iter(dset_loaders["source"]["train"]) if i % len_train_target == 0: iter_target = iter(dset_loaders["target"]["train"]) inputs_source, labels_source = iter_source.next() inputs_target, labels_target = iter_target.next() if use_gpu: inputs_source, inputs_target, labels_source = Variable(inputs_source).cuda(), Variable(inputs_target).cuda(), Variable(labels_source).cuda() else: inputs_source, inputs_target, labels_source = Variable(inputs_source), Variable(inputs_target), Variable(labels_source) inputs = torch.cat((inputs_source, inputs_target), dim=0) features = base_network(inputs) if net_config["use_bottleneck"]: features = bottleneck_layer(features) outputs = classifier_layer(features) classifier_loss = class_criterion(outputs.narrow(0, 0, inputs.size(0)/2), labels_source) ## switch between different transfer loss if loss_config["name"] == "DAN": transfer_loss = transfer_criterion(features.narrow(0, 0, features.size(0)/2), features.narrow(0, features.size(0)/2, features.size(0)/2), **loss_config["params"]) elif loss_config["name"] == "RTN": ## RTN is still under developing transfer_loss = 0 elif loss_config["name"] == "JAN": softmax_out = softmax_layer(outputs) transfer_loss = transfer_criterion([features.narrow(0, 0, features.size(0)/2), softmax_out.narrow(0, 0, softmax_out.size(0)/2)], [features.narrow(0, features.size(0)/2, features.size(0)/2), softmax_out.narrow(0, softmax_out.size(0)/2, softmax_out.size(0)/2)], **loss_config["params"]) total_loss = loss_config["trade_off"] * transfer_loss + classifier_loss total_loss.backward() optimizer.step() if __name__ == "__main__": parser = argparse.ArgumentParser(description='Transfer Learning') parser.add_argument('--gpu_id', type=str, nargs='?', default='0', help="device id to run") parser.add_argument('--source', type=str, nargs='?', default='amazon', help="source data") parser.add_argument('--target', type=str, nargs='?', default='webcam', help="target data") parser.add_argument('--loss_name', type=str, nargs='?', default='JAN', help="loss name") parser.add_argument('--tradeoff', type=float, nargs='?', default=1.0, help="tradeoff") parser.add_argument('--using_bottleneck', type=int, nargs='?', default=1, help="whether to use bottleneck") args = parser.parse_args() os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id config = {} config["num_iterations"] = 20000 config["test_interval"] = 500 config["prep"] = [{"name":"source", "type":"image", "test_10crop":True, "resize_size":256, "crop_size":224}, {"name":"target", "type":"image", "test_10crop":True, "resize_size":256, "crop_size":224}] config["loss"] = {"name":args.loss_name, "trade_off":args.tradeoff } config["data"] = [{"name":"source", "type":"image", "list_path":{"train":"../data/office/"+args.source+"_list.txt"}, "batch_size":{"train":36, "test":4} }, {"name":"target", "type":"image", "list_path":{"train":"../data/office/"+args.target+"_list.txt"}, "batch_size":{"train":36, "test":4} }] config["network"] = {"name":"ResNet50", "use_bottleneck":args.using_bottleneck, "bottleneck_dim":256} config["optimizer"] = {"type":"SGD", "optim_params":{"lr":1.0, "momentum":0.9, "weight_decay":0.0005, "nesterov":True}, "lr_type":"inv", "lr_param":{"init_lr":0.0003, "gamma":0.0003, "power":0.75} } print config["loss"] transfer_classification(config)
[ 1, 1053, 1852, 5510, 30004, 13, 5215, 2897, 30004, 13, 30004, 13, 5215, 12655, 408, 7442, 30004, 13, 5215, 4842, 305, 30004, 13, 5215, 4842, 305, 29889, 15755, 408, 302, 29876, 30004, 13, 5215, 4842, 305, 29889, 20640, 408, 5994, 30004, 13, 5215, 3564, 30004, 13, 5215, 6410, 30004, 13, 5215, 758, 29918, 5014, 408, 8273, 30004, 13, 5215, 4842, 305, 29889, 13239, 29889, 1272, 408, 3667, 29918, 1272, 30004, 13, 5215, 301, 29878, 29918, 816, 11272, 30004, 13, 3166, 848, 29918, 1761, 1053, 7084, 1293, 30004, 13, 3166, 4842, 305, 29889, 1300, 468, 3665, 1053, 28736, 30004, 13, 30004, 13, 20640, 29918, 8977, 353, 8853, 26016, 29928, 1115, 5994, 29889, 26016, 29928, 8117, 13, 30004, 13, 1753, 1967, 29918, 1990, 2450, 29918, 27711, 29898, 12657, 29892, 1904, 29892, 1243, 29918, 29896, 29900, 29883, 1336, 29922, 5574, 29892, 330, 3746, 29922, 5574, 1125, 30004, 13, 1678, 1369, 29918, 1688, 353, 5852, 30004, 13, 1678, 565, 1243, 29918, 29896, 29900, 29883, 1336, 29901, 30004, 13, 4706, 4256, 29918, 1688, 353, 518, 1524, 29898, 12657, 1839, 1688, 18717, 710, 29898, 29875, 29897, 2314, 363, 474, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 4706, 363, 474, 297, 921, 3881, 29898, 2435, 29898, 12657, 1839, 1688, 29900, 2033, 22164, 30004, 13, 9651, 848, 353, 518, 1524, 29918, 1688, 29961, 29926, 1822, 4622, 580, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 9651, 10970, 353, 518, 1272, 29961, 29926, 3816, 29900, 29962, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 9651, 565, 330, 3746, 29901, 30004, 13, 18884, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 462, 1678, 10970, 29961, 29926, 29962, 353, 28736, 29898, 2080, 29879, 29961, 29926, 1822, 29883, 6191, 3101, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 462, 1678, 10970, 29961, 29926, 29962, 353, 28736, 29898, 2080, 29879, 29961, 29926, 2314, 30004, 13, 9651, 14391, 353, 5159, 30004, 13, 9651, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 18884, 14391, 29889, 4397, 29898, 4299, 29898, 2080, 29879, 29961, 29926, 12622, 30004, 13, 9651, 14391, 353, 2533, 29898, 4905, 29879, 8443, 13, 9651, 565, 1369, 29918, 1688, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 14391, 29889, 1272, 29889, 7411, 26471, 13, 18884, 1369, 29918, 1688, 353, 7700, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 4905, 29892, 14391, 29889, 1272, 29889, 7411, 25739, 29871, 29900, 8443, 13, 1678, 1683, 29901, 30004, 13, 4706, 4256, 29918, 791, 353, 4256, 29898, 12657, 3366, 1688, 20068, 30004, 13, 4706, 363, 474, 297, 921, 3881, 29898, 2435, 29898, 12657, 1839, 1688, 2033, 22164, 30004, 13, 9651, 848, 353, 4256, 29918, 791, 29889, 4622, 26471, 13, 9651, 10970, 353, 848, 29961, 29900, 29962, 30004, 13, 9651, 565, 330, 3746, 29901, 30004, 13, 18884, 10970, 353, 28736, 29898, 2080, 29879, 29889, 29883, 6191, 3101, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 10970, 353, 28736, 29898, 2080, 29879, 8443, 13, 9651, 14391, 353, 1904, 29898, 2080, 29879, 8443, 13, 9651, 565, 1369, 29918, 1688, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 14391, 29889, 1272, 29889, 21970, 2141, 7411, 26471, 13, 18884, 1369, 29918, 1688, 353, 7700, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 4905, 29892, 14391, 29889, 1272, 29889, 21970, 2141, 7411, 25739, 29871, 29900, 8443, 13, 1678, 17117, 8500, 353, 4842, 305, 29889, 3317, 29898, 497, 29918, 4905, 29892, 29871, 29896, 8443, 13, 1678, 736, 599, 29918, 4905, 29892, 8500, 30004, 13, 30004, 13, 1753, 1967, 29918, 1990, 2450, 29918, 1688, 29898, 12657, 29892, 1904, 29892, 1243, 29918, 29896, 29900, 29883, 1336, 29922, 5574, 29892, 330, 3746, 29922, 5574, 1125, 30004, 13, 1678, 1369, 29918, 1688, 353, 5852, 30004, 13, 1678, 565, 1243, 29918, 29896, 29900, 29883, 1336, 29901, 30004, 13, 4706, 4256, 29918, 1688, 353, 518, 1524, 29898, 12657, 1839, 1688, 18717, 710, 29898, 29875, 29897, 2314, 363, 474, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 4706, 363, 474, 297, 921, 3881, 29898, 2435, 29898, 12657, 1839, 1688, 29900, 2033, 22164, 30004, 13, 9651, 848, 353, 518, 1524, 29918, 1688, 29961, 29926, 1822, 4622, 580, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 9651, 10970, 353, 518, 1272, 29961, 29926, 3816, 29900, 29962, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 4638, 30004, 13, 9651, 11073, 353, 848, 29961, 29900, 3816, 29896, 29962, 30004, 13, 9651, 565, 330, 3746, 29901, 30004, 13, 18884, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 462, 1678, 10970, 29961, 29926, 29962, 353, 28736, 29898, 2080, 29879, 29961, 29926, 1822, 29883, 6191, 3101, 30004, 13, 18884, 11073, 353, 28736, 29898, 21134, 29889, 29883, 6191, 3101, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 462, 1678, 10970, 29961, 29926, 29962, 353, 28736, 29898, 2080, 29879, 29961, 29926, 2314, 30004, 13, 18884, 11073, 353, 28736, 29898, 21134, 8443, 13, 9651, 14391, 353, 5159, 30004, 13, 9651, 363, 432, 297, 921, 3881, 29898, 29896, 29900, 1125, 30004, 13, 18884, 14391, 29889, 4397, 29898, 4299, 29898, 2080, 29879, 29961, 29926, 12622, 30004, 13, 9651, 14391, 353, 2533, 29898, 4905, 29879, 8443, 13, 9651, 565, 1369, 29918, 1688, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 14391, 29889, 1272, 29889, 7411, 26471, 13, 18884, 599, 29918, 1643, 353, 11073, 29889, 1272, 29889, 7411, 26471, 13, 18884, 1369, 29918, 1688, 353, 7700, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 4905, 29892, 14391, 29889, 1272, 29889, 7411, 25739, 29871, 29900, 8443, 13, 18884, 599, 29918, 1643, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 1643, 29892, 11073, 29889, 1272, 29889, 7411, 25739, 29871, 29900, 8443, 13, 1678, 1683, 29901, 30004, 13, 4706, 4256, 29918, 1688, 353, 4256, 29898, 12657, 3366, 1688, 20068, 30004, 13, 4706, 363, 474, 297, 921, 3881, 29898, 2435, 29898, 12657, 3366, 1688, 3108, 22164, 30004, 13, 9651, 848, 353, 4256, 29918, 1688, 29889, 4622, 26471, 13, 9651, 10970, 353, 848, 29961, 29900, 29962, 30004, 13, 9651, 11073, 353, 848, 29961, 29896, 29962, 30004, 13, 9651, 565, 330, 3746, 29901, 30004, 13, 18884, 10970, 353, 28736, 29898, 2080, 29879, 29889, 29883, 6191, 3101, 30004, 13, 18884, 11073, 353, 28736, 29898, 21134, 29889, 29883, 6191, 3101, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 10970, 353, 28736, 29898, 2080, 29879, 8443, 13, 18884, 11073, 353, 28736, 29898, 21134, 8443, 13, 9651, 14391, 353, 1904, 29898, 2080, 29879, 8443, 13, 9651, 565, 1369, 29918, 1688, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 14391, 29889, 1272, 29889, 7411, 26471, 13, 18884, 599, 29918, 1643, 353, 11073, 29889, 1272, 29889, 7411, 26471, 13, 18884, 1369, 29918, 1688, 353, 7700, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 599, 29918, 4905, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 4905, 29892, 14391, 29889, 1272, 29889, 7411, 25739, 29871, 29900, 8443, 13, 18884, 599, 29918, 1643, 353, 4842, 305, 29889, 4117, 3552, 497, 29918, 1643, 29892, 11073, 29889, 1272, 29889, 7411, 25739, 29871, 29900, 8443, 13, 539, 6756, 13, 1678, 17117, 8500, 353, 4842, 305, 29889, 3317, 29898, 497, 29918, 4905, 29892, 29871, 29896, 8443, 13, 1678, 13600, 353, 4842, 305, 29889, 2083, 29898, 7345, 305, 29889, 29879, 802, 29872, 911, 29898, 27711, 467, 7411, 580, 1275, 599, 29918, 1643, 467, 667, 580, 847, 5785, 29898, 497, 29918, 1643, 29889, 2311, 580, 29961, 29900, 2314, 30004, 13, 1678, 736, 13600, 30004, 13, 30004, 13, 30004, 13, 1753, 6782, 29918, 1990, 2450, 29898, 2917, 1125, 30004, 13, 1678, 444, 731, 758, 29899, 5014, 30004, 13, 1678, 8273, 29918, 8977, 353, 6571, 30004, 13, 1678, 363, 8273, 29918, 2917, 297, 2295, 3366, 15287, 3108, 29901, 30004, 13, 4706, 8273, 29918, 8977, 29961, 15287, 29918, 2917, 3366, 978, 3108, 29962, 353, 6571, 30004, 13, 4706, 565, 8273, 29918, 2917, 3366, 1853, 3108, 1275, 376, 3027, 1115, 30004, 13, 9651, 8273, 29918, 8977, 29961, 15287, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 3108, 353, 8273, 29918, 2917, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 3108, 30004, 13, 9651, 8273, 29918, 8977, 29961, 15287, 29918, 2917, 3366, 978, 3108, 29962, 3366, 14968, 3108, 29871, 353, 8273, 29889, 3027, 29918, 14968, 29898, 21476, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 21476, 29918, 2311, 12436, 274, 1336, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 29883, 1336, 29918, 2311, 20068, 30004, 13, 9651, 565, 8273, 29918, 2917, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 3108, 29901, 30004, 13, 18884, 8273, 29918, 8977, 29961, 15287, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 8273, 29889, 3027, 29918, 1688, 29918, 29896, 29900, 29883, 1336, 29898, 21476, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 21476, 29918, 2311, 12436, 274, 1336, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 29883, 1336, 29918, 2311, 20068, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 8273, 29918, 8977, 29961, 15287, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 8273, 29889, 3027, 29918, 1688, 29898, 21476, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 21476, 29918, 2311, 12436, 274, 1336, 29918, 2311, 29922, 15287, 29918, 2917, 3366, 29883, 1336, 29918, 2311, 20068, 30004, 13, 1669, 6756, 13, 1678, 444, 731, 6410, 30004, 13, 1678, 770, 29918, 29883, 5385, 291, 353, 302, 29876, 29889, 29907, 2124, 5292, 14441, 29931, 2209, 26471, 13, 1678, 6410, 29918, 2917, 353, 2295, 3366, 6758, 3108, 30004, 13, 1678, 6782, 29918, 29883, 5385, 291, 353, 6410, 29889, 6758, 29918, 8977, 29961, 6758, 29918, 2917, 3366, 978, 3108, 29962, 30004, 13, 1678, 565, 376, 7529, 29908, 451, 297, 6410, 29918, 2917, 29901, 30004, 13, 4706, 6410, 29918, 2917, 3366, 7529, 3108, 353, 6571, 30004, 13, 30004, 13, 1678, 444, 19012, 848, 30004, 13, 1678, 270, 7224, 353, 6571, 30004, 13, 1678, 270, 842, 29918, 1359, 414, 353, 6571, 30004, 13, 1678, 363, 848, 29918, 2917, 297, 2295, 3366, 1272, 3108, 29901, 30004, 13, 4706, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 353, 6571, 30004, 13, 4706, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 353, 6571, 30004, 13, 4706, 444, 1967, 848, 30004, 13, 4706, 565, 848, 29918, 2917, 3366, 1853, 3108, 1275, 376, 3027, 1115, 30004, 13, 9651, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 14968, 3108, 353, 7084, 1293, 29898, 3150, 29898, 1272, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 3366, 14968, 3108, 467, 949, 9012, 3285, 4327, 29922, 15287, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 14968, 20068, 30004, 13, 9651, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 14968, 3108, 353, 3667, 29918, 1272, 29889, 1469, 10036, 29898, 29881, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 14968, 12436, 9853, 29918, 2311, 29922, 1272, 29918, 2917, 3366, 16175, 29918, 2311, 3108, 3366, 14968, 12436, 528, 21897, 29922, 5574, 29892, 954, 29918, 1287, 414, 29922, 29946, 8443, 13, 9651, 565, 376, 1688, 29908, 297, 848, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 29901, 30004, 13, 18884, 565, 8273, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 3108, 29901, 30004, 13, 462, 1678, 363, 474, 297, 3464, 29898, 29896, 29900, 1125, 30004, 13, 462, 4706, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 4638, 353, 7084, 1293, 29898, 3150, 29898, 1272, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 3366, 1688, 3108, 467, 949, 9012, 3285, 4327, 29922, 15287, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 3366, 791, 17969, 710, 29898, 29875, 4638, 30004, 13, 8443, 13, 462, 4706, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 4638, 353, 3667, 29918, 1272, 29889, 1469, 10036, 29898, 29881, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 29897, 1402, 9853, 29918, 2311, 29922, 1272, 29918, 2917, 3366, 16175, 29918, 2311, 3108, 3366, 1688, 12436, 528, 21897, 29922, 8824, 29892, 954, 29918, 1287, 414, 29922, 29946, 29897, 965, 6756, 13, 18884, 1683, 29901, 30004, 13, 462, 1678, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 7084, 1293, 29898, 3150, 29898, 1272, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 3366, 1688, 3108, 467, 949, 9012, 3285, 4327, 29922, 15287, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 20068, 29871, 6756, 13, 462, 1678, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 3667, 29918, 1272, 29889, 1469, 10036, 29898, 29881, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 12436, 9853, 29918, 2311, 29922, 1272, 29918, 2917, 3366, 16175, 29918, 2311, 3108, 3366, 1688, 12436, 528, 21897, 29922, 8824, 29892, 954, 29918, 1287, 414, 29922, 29946, 29897, 3986, 6756, 13, 9651, 1683, 29901, 30004, 13, 18884, 565, 8273, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 3108, 29901, 30004, 13, 462, 1678, 363, 474, 297, 3464, 29898, 29896, 29900, 1125, 30004, 13, 462, 4706, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 4638, 353, 7084, 1293, 29898, 3150, 29898, 1272, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 3366, 14968, 3108, 467, 949, 9012, 3285, 4327, 29922, 15287, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 3366, 791, 17969, 710, 29898, 29875, 29897, 2314, 30004, 13, 462, 4706, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 4638, 353, 3667, 29918, 1272, 29889, 1469, 10036, 29898, 29881, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 17969, 710, 29898, 29875, 29897, 1402, 9853, 29918, 2311, 29922, 1272, 29918, 2917, 3366, 16175, 29918, 2311, 3108, 3366, 1688, 12436, 528, 21897, 29922, 8824, 29892, 954, 29918, 1287, 414, 29922, 29946, 29897, 308, 6756, 13, 18884, 1683, 29901, 30004, 13, 462, 1678, 270, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 7084, 1293, 29898, 3150, 29898, 1272, 29918, 2917, 3366, 1761, 29918, 2084, 3108, 3366, 14968, 3108, 467, 949, 9012, 3285, 4327, 29922, 15287, 29918, 8977, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 20068, 30004, 13, 462, 1678, 270, 842, 29918, 1359, 414, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 3108, 353, 3667, 29918, 1272, 29889, 1469, 10036, 29898, 29881, 7224, 29961, 1272, 29918, 2917, 3366, 978, 3108, 29962, 3366, 1688, 12436, 9853, 29918, 2311, 29922, 1272, 29918, 2917, 3366, 16175, 29918, 2311, 3108, 3366, 1688, 12436, 528, 21897, 29922, 8824, 29892, 954, 29918, 1287, 414, 29922, 29946, 8443, 13, 1678, 770, 29918, 1949, 353, 29871, 29941, 29896, 30004, 13, 30004, 13, 1678, 444, 731, 2967, 3564, 30004, 13, 1678, 7787, 29918, 2917, 353, 2295, 3366, 11618, 3108, 30004, 13, 1678, 2967, 29918, 11618, 353, 3564, 29889, 11618, 29918, 8977, 29961, 1212, 29918, 2917, 3366, 978, 3108, 29962, 26471, 13, 1678, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 4706, 18046, 29880, 1600, 384, 29918, 13148, 353, 302, 29876, 29889, 12697, 29898, 3188, 29918, 11618, 29889, 4905, 29918, 1949, 3285, 7787, 29918, 2917, 3366, 29890, 1501, 29880, 1600, 384, 29918, 6229, 20068, 30004, 13, 4706, 770, 3709, 29918, 13148, 353, 302, 29876, 29889, 12697, 29898, 29890, 1501, 29880, 1600, 384, 29918, 13148, 29889, 449, 29918, 22100, 29892, 770, 29918, 1949, 8443, 13, 1678, 1683, 29901, 30004, 13, 4706, 770, 3709, 29918, 13148, 353, 302, 29876, 29889, 12697, 29898, 3188, 29918, 11618, 29889, 4905, 29918, 1949, 3285, 770, 29918, 1949, 8443, 13, 1678, 363, 1828, 297, 2967, 29918, 11618, 29889, 16744, 7295, 30004, 13, 4706, 1828, 29889, 276, 339, 2658, 29918, 5105, 353, 7700, 30004, 13, 30004, 13, 1678, 444, 17865, 30004, 13, 1678, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 4706, 18046, 29880, 1600, 384, 29918, 13148, 29889, 7915, 29889, 1272, 29889, 8945, 23538, 29900, 29892, 29871, 29900, 29889, 29900, 29900, 29945, 8443, 13, 4706, 18046, 29880, 1600, 384, 29918, 13148, 29889, 29890, 3173, 29889, 1272, 29889, 5589, 23538, 29900, 29889, 29896, 8443, 13, 4706, 18046, 29880, 1600, 384, 29918, 13148, 353, 302, 29876, 29889, 16941, 2556, 29898, 29890, 1501, 29880, 1600, 384, 29918, 13148, 29892, 302, 29876, 29889, 1123, 29931, 29965, 3285, 302, 29876, 29889, 15063, 449, 29898, 29900, 29889, 29945, 876, 30004, 13, 1678, 770, 3709, 29918, 13148, 29889, 7915, 29889, 1272, 29889, 8945, 23538, 29900, 29892, 29871, 29900, 29889, 29900, 29896, 8443, 13, 1678, 770, 3709, 29918, 13148, 29889, 29890, 3173, 29889, 1272, 29889, 5589, 23538, 29900, 29889, 29900, 8443, 13, 30004, 13, 1678, 671, 29918, 29887, 3746, 353, 4842, 305, 29889, 29883, 6191, 29889, 275, 29918, 16515, 26471, 13, 1678, 565, 671, 29918, 29887, 3746, 29901, 30004, 13, 4706, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 9651, 18046, 29880, 1600, 384, 29918, 13148, 353, 18046, 29880, 1600, 384, 29918, 13148, 29889, 29883, 6191, 26471, 13, 4706, 770, 3709, 29918, 13148, 353, 770, 3709, 29918, 13148, 29889, 29883, 6191, 26471, 13, 4706, 2967, 29918, 11618, 353, 2967, 29918, 11618, 29889, 29883, 6191, 26471, 13, 30004, 13, 30004, 13, 1678, 444, 6314, 4128, 30004, 13, 1678, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 4706, 3443, 29918, 1761, 353, 518, 6377, 7529, 1115, 29890, 1501, 29880, 1600, 384, 29918, 13148, 29889, 16744, 3285, 376, 29212, 1115, 29896, 29900, 1118, 8853, 7529, 1115, 1990, 3709, 29918, 13148, 29889, 16744, 3285, 376, 29212, 1115, 29896, 29900, 6525, 30004, 13, 539, 6756, 13, 1678, 1683, 29901, 30004, 13, 4706, 3443, 29918, 1761, 353, 518, 6377, 7529, 1115, 1990, 3709, 29918, 13148, 29889, 16744, 3285, 376, 29212, 1115, 29896, 29900, 6525, 30004, 13, 30004, 13, 1678, 444, 788, 5684, 3564, 363, 777, 3519, 30004, 13, 1678, 565, 6410, 29918, 2917, 3366, 978, 3108, 1275, 376, 29967, 2190, 1115, 30004, 13, 4706, 4964, 3317, 29918, 13148, 353, 302, 29876, 29889, 6295, 615, 3317, 26471, 13, 4706, 565, 671, 29918, 29887, 3746, 29901, 30004, 13, 9651, 4964, 3317, 29918, 13148, 353, 4964, 3317, 29918, 13148, 29889, 29883, 6191, 26471, 13, 965, 6756, 13, 6756, 13, 1678, 444, 731, 5994, 3950, 30004, 13, 1678, 5994, 3950, 29918, 2917, 353, 2295, 3366, 20640, 3950, 3108, 30004, 13, 1678, 5994, 3950, 353, 5994, 29918, 8977, 29961, 20640, 3950, 29918, 2917, 3366, 1853, 3108, 850, 15501, 29918, 1761, 29892, 3579, 29898, 20640, 3950, 29918, 2917, 3366, 20640, 29918, 7529, 3108, 876, 30004, 13, 1678, 1828, 29918, 29212, 353, 5159, 30004, 13, 1678, 363, 1828, 29918, 2972, 297, 5994, 3950, 29889, 3207, 29918, 13155, 29901, 30004, 13, 4706, 1828, 29918, 29212, 29889, 4397, 29898, 3207, 29918, 2972, 3366, 29212, 20068, 30004, 13, 1678, 20410, 29918, 3207, 353, 5994, 3950, 29918, 2917, 3366, 29212, 29918, 3207, 3108, 30004, 13, 1678, 301, 29878, 29918, 816, 14952, 353, 301, 29878, 29918, 816, 11272, 29889, 816, 11272, 29918, 8977, 29961, 20640, 3950, 29918, 2917, 3366, 29212, 29918, 1853, 3108, 29962, 30004, 13, 30004, 13, 30004, 13, 1678, 444, 7945, 259, 6756, 13, 1678, 7431, 29918, 14968, 29918, 4993, 353, 7431, 29898, 29881, 842, 29918, 1359, 414, 3366, 4993, 3108, 3366, 14968, 20068, 448, 29871, 29896, 30004, 13, 1678, 7431, 29918, 14968, 29918, 5182, 353, 7431, 29898, 29881, 842, 29918, 1359, 414, 3366, 5182, 3108, 3366, 14968, 20068, 448, 29871, 29896, 30004, 13, 1678, 6782, 29918, 6758, 29918, 1767, 353, 770, 3709, 29918, 6758, 29918, 1767, 353, 3001, 29918, 6758, 29918, 1767, 353, 29871, 29900, 29889, 29900, 30004, 13, 1678, 363, 474, 297, 3464, 29898, 2917, 3366, 1949, 29918, 1524, 800, 3108, 1125, 30004, 13, 4706, 444, 1243, 297, 278, 7945, 30004, 13, 4706, 565, 474, 1273, 2295, 3366, 1688, 29918, 19207, 3108, 1275, 29871, 29900, 29901, 30004, 13, 9651, 2967, 29918, 11618, 29889, 14968, 29898, 8824, 8443, 13, 9651, 770, 3709, 29918, 13148, 29889, 14968, 29898, 8824, 8443, 13, 9651, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 18884, 18046, 29880, 1600, 384, 29918, 13148, 29889, 14968, 29898, 8824, 8443, 13, 18884, 1596, 1967, 29918, 1990, 2450, 29918, 1688, 29898, 29881, 842, 29918, 1359, 414, 3366, 5182, 12436, 302, 29876, 29889, 16941, 2556, 29898, 3188, 29918, 11618, 29892, 18046, 29880, 1600, 384, 29918, 13148, 29892, 770, 3709, 29918, 13148, 511, 1243, 29918, 29896, 29900, 29883, 1336, 29922, 15287, 29918, 8977, 3366, 5182, 3108, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 12436, 330, 3746, 29922, 1509, 29918, 29887, 3746, 8443, 13, 30004, 13, 9651, 1683, 29901, 30004, 13, 18884, 1596, 1967, 29918, 1990, 2450, 29918, 1688, 29898, 29881, 842, 29918, 1359, 414, 3366, 5182, 12436, 302, 29876, 29889, 16941, 2556, 29898, 3188, 29918, 11618, 29892, 770, 3709, 29918, 13148, 511, 1243, 29918, 29896, 29900, 29883, 1336, 29922, 15287, 29918, 8977, 3366, 5182, 3108, 3366, 1688, 29918, 29896, 29900, 29883, 1336, 12436, 330, 3746, 29922, 1509, 29918, 29887, 3746, 8443, 13, 30004, 13, 4706, 6410, 29918, 1688, 353, 302, 29876, 29889, 29933, 4741, 29931, 2209, 26471, 13, 4706, 444, 7945, 697, 4256, 30004, 13, 4706, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 9651, 18046, 29880, 1600, 384, 29918, 13148, 29889, 14968, 29898, 5574, 8443, 13, 4706, 770, 3709, 29918, 13148, 29889, 14968, 29898, 5574, 8443, 13, 4706, 5994, 3950, 353, 301, 29878, 29918, 816, 14952, 29898, 3207, 29918, 29212, 29892, 5994, 3950, 29892, 474, 29892, 3579, 816, 11272, 29918, 3207, 8443, 13, 4706, 5994, 3950, 29889, 9171, 29918, 5105, 26471, 13, 4706, 565, 474, 1273, 7431, 29918, 14968, 29918, 4993, 1275, 29871, 29900, 29901, 30004, 13, 9651, 4256, 29918, 4993, 353, 4256, 29898, 29881, 842, 29918, 1359, 414, 3366, 4993, 3108, 3366, 14968, 20068, 30004, 13, 4706, 565, 474, 1273, 7431, 29918, 14968, 29918, 5182, 1275, 29871, 29900, 29901, 30004, 13, 9651, 4256, 29918, 5182, 353, 4256, 29898, 29881, 842, 29918, 1359, 414, 3366, 5182, 3108, 3366, 14968, 20068, 30004, 13, 4706, 10970, 29918, 4993, 29892, 11073, 29918, 4993, 353, 4256, 29918, 4993, 29889, 4622, 26471, 13, 4706, 10970, 29918, 5182, 29892, 11073, 29918, 5182, 353, 4256, 29918, 5182, 29889, 4622, 26471, 13, 4706, 565, 671, 29918, 29887, 3746, 29901, 30004, 13, 9651, 10970, 29918, 4993, 29892, 10970, 29918, 5182, 29892, 11073, 29918, 4993, 353, 28736, 29898, 2080, 29879, 29918, 4993, 467, 29883, 6191, 3285, 28736, 29898, 2080, 29879, 29918, 5182, 467, 29883, 6191, 3285, 28736, 29898, 21134, 29918, 4993, 467, 29883, 6191, 26471, 13, 4706, 1683, 29901, 30004, 13, 9651, 10970, 29918, 4993, 29892, 10970, 29918, 5182, 29892, 11073, 29918, 4993, 353, 28736, 29898, 2080, 29879, 29918, 4993, 511, 28736, 29898, 2080, 29879, 29918, 5182, 511, 28736, 29898, 21134, 29918, 4993, 8443, 13, 965, 6756, 13, 4706, 10970, 353, 4842, 305, 29889, 4117, 3552, 2080, 29879, 29918, 4993, 29892, 10970, 29918, 5182, 511, 3964, 29922, 29900, 8443, 13, 4706, 5680, 353, 2967, 29918, 11618, 29898, 2080, 29879, 8443, 13, 4706, 565, 7787, 29918, 2917, 3366, 1509, 29918, 29890, 1501, 29880, 1600, 384, 3108, 29901, 30004, 13, 9651, 5680, 353, 18046, 29880, 1600, 384, 29918, 13148, 29898, 22100, 8443, 13, 30004, 13, 4706, 14391, 353, 770, 3709, 29918, 13148, 29898, 22100, 8443, 13, 30004, 13, 4706, 770, 3709, 29918, 6758, 353, 770, 29918, 29883, 5385, 291, 29898, 4905, 29879, 29889, 29876, 2936, 29898, 29900, 29892, 29871, 29900, 29892, 10970, 29889, 2311, 29898, 29900, 6802, 29906, 511, 11073, 29918, 4993, 8443, 13, 4706, 444, 4607, 1546, 1422, 6782, 6410, 30004, 13, 4706, 565, 6410, 29918, 2917, 3366, 978, 3108, 1275, 376, 29928, 2190, 1115, 30004, 13, 9651, 6782, 29918, 6758, 353, 6782, 29918, 29883, 5385, 291, 29898, 22100, 29889, 29876, 2936, 29898, 29900, 29892, 29871, 29900, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 511, 5680, 29889, 29876, 2936, 29898, 29900, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 511, 3579, 6758, 29918, 2917, 3366, 7529, 20068, 30004, 13, 4706, 25342, 6410, 29918, 2917, 3366, 978, 3108, 1275, 376, 13079, 29940, 1115, 30004, 13, 9651, 444, 390, 29911, 29940, 338, 1603, 1090, 14338, 30004, 13, 9651, 6782, 29918, 6758, 353, 29871, 29900, 30004, 13, 4706, 25342, 6410, 29918, 2917, 3366, 978, 3108, 1275, 376, 29967, 2190, 1115, 30004, 13, 9651, 4964, 3317, 29918, 449, 353, 4964, 3317, 29918, 13148, 29898, 4905, 29879, 8443, 13, 9651, 6782, 29918, 6758, 353, 6782, 29918, 29883, 5385, 291, 4197, 22100, 29889, 29876, 2936, 29898, 29900, 29892, 29871, 29900, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 511, 4964, 3317, 29918, 449, 29889, 29876, 2936, 29898, 29900, 29892, 29871, 29900, 29892, 4964, 3317, 29918, 449, 29889, 2311, 29898, 29900, 6802, 29906, 29897, 1402, 518, 22100, 29889, 29876, 2936, 29898, 29900, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 29892, 5680, 29889, 2311, 29898, 29900, 6802, 29906, 511, 4964, 3317, 29918, 449, 29889, 29876, 2936, 29898, 29900, 29892, 4964, 3317, 29918, 449, 29889, 2311, 29898, 29900, 6802, 29906, 29892, 4964, 3317, 29918, 449, 29889, 2311, 29898, 29900, 6802, 29906, 29897, 1402, 3579, 6758, 29918, 2917, 3366, 7529, 20068, 30004, 13, 30004, 13, 4706, 3001, 29918, 6758, 353, 6410, 29918, 2917, 3366, 3018, 311, 29918, 2696, 3108, 334, 6782, 29918, 6758, 718, 770, 3709, 29918, 6758, 30004, 13, 4706, 3001, 29918, 6758, 29889, 1627, 1328, 26471, 13, 4706, 5994, 3950, 29889, 10568, 26471, 13, 30004, 13, 30004, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 30004, 13, 1678, 13812, 353, 1852, 5510, 29889, 15730, 11726, 29898, 8216, 2433, 4300, 571, 29257, 1495, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 29887, 3746, 29918, 333, 742, 1134, 29922, 710, 29892, 302, 5085, 2433, 29973, 742, 2322, 2433, 29900, 742, 1371, 543, 10141, 1178, 304, 1065, 1159, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 4993, 742, 1134, 29922, 710, 29892, 302, 5085, 2433, 29973, 742, 2322, 2433, 17260, 742, 1371, 543, 4993, 848, 1159, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 5182, 742, 1134, 29922, 710, 29892, 302, 5085, 2433, 29973, 742, 2322, 2433, 2676, 11108, 742, 1371, 543, 5182, 848, 1159, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 6758, 29918, 978, 742, 1134, 29922, 710, 29892, 302, 5085, 2433, 29973, 742, 2322, 2433, 29967, 2190, 742, 1371, 543, 6758, 1024, 1159, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 3018, 311, 2696, 742, 1134, 29922, 7411, 29892, 302, 5085, 2433, 29973, 742, 2322, 29922, 29896, 29889, 29900, 29892, 1371, 543, 3018, 311, 2696, 1159, 30004, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 489, 4746, 29918, 29890, 1501, 29880, 1600, 384, 742, 1134, 29922, 524, 29892, 302, 5085, 2433, 29973, 742, 2322, 29922, 29896, 29892, 1371, 543, 1332, 1979, 304, 671, 18046, 29880, 1600, 384, 1159, 30004, 13, 1678, 6389, 353, 13812, 29889, 5510, 29918, 5085, 26471, 13, 1678, 2897, 29889, 21813, 3366, 29907, 29965, 7698, 29918, 28607, 8979, 1307, 29918, 2287, 29963, 2965, 2890, 3108, 353, 6389, 29889, 29887, 3746, 29918, 333, 6756, 13, 30004, 13, 1678, 2295, 353, 6571, 30004, 13, 1678, 2295, 3366, 1949, 29918, 1524, 800, 3108, 353, 29871, 29906, 29900, 29900, 29900, 29900, 30004, 13, 1678, 2295, 3366, 1688, 29918, 19207, 3108, 353, 29871, 29945, 29900, 29900, 30004, 13, 1678, 2295, 3366, 15287, 3108, 353, 518, 6377, 978, 4710, 4993, 613, 376, 1853, 4710, 3027, 613, 376, 1688, 29918, 29896, 29900, 29883, 1336, 1115, 5574, 29892, 376, 21476, 29918, 2311, 1115, 29906, 29945, 29953, 29892, 376, 29883, 1336, 29918, 2311, 1115, 29906, 29906, 29946, 1118, 8853, 978, 4710, 5182, 613, 376, 1853, 4710, 3027, 613, 376, 1688, 29918, 29896, 29900, 29883, 1336, 1115, 5574, 29892, 376, 21476, 29918, 2311, 1115, 29906, 29945, 29953, 29892, 376, 29883, 1336, 29918, 2311, 1115, 29906, 29906, 29946, 6525, 30004, 13, 1678, 2295, 3366, 6758, 3108, 353, 8853, 978, 1115, 5085, 29889, 6758, 29918, 978, 29892, 376, 3018, 311, 29918, 2696, 1115, 5085, 29889, 3018, 311, 2696, 4970, 13, 1678, 2295, 3366, 1272, 3108, 353, 518, 6377, 978, 4710, 4993, 613, 376, 1853, 4710, 3027, 613, 376, 1761, 29918, 2084, 28819, 14968, 4710, 6995, 1272, 29914, 20205, 12975, 29974, 5085, 29889, 4993, 13578, 29918, 1761, 29889, 3945, 10758, 376, 16175, 29918, 2311, 28819, 14968, 1115, 29941, 29953, 29892, 376, 1688, 1115, 29946, 29913, 2981, 8853, 978, 4710, 5182, 613, 376, 1853, 4710, 3027, 613, 376, 1761, 29918, 2084, 28819, 14968, 4710, 6995, 1272, 29914, 20205, 12975, 29974, 5085, 29889, 5182, 13578, 29918, 1761, 29889, 3945, 10758, 376, 16175, 29918, 2311, 28819, 14968, 1115, 29941, 29953, 29892, 376, 1688, 1115, 29946, 29913, 500, 29962, 30004, 13, 1678, 2295, 3366, 11618, 3108, 353, 8853, 978, 4710, 1666, 6779, 29945, 29900, 613, 376, 1509, 29918, 29890, 1501, 29880, 1600, 384, 1115, 5085, 29889, 4746, 29918, 29890, 1501, 29880, 1600, 384, 29892, 376, 29890, 1501, 29880, 1600, 384, 29918, 6229, 1115, 29906, 29945, 29953, 8117, 13, 1678, 2295, 3366, 20640, 3950, 3108, 353, 8853, 1853, 4710, 26016, 29928, 613, 376, 20640, 29918, 7529, 28819, 29212, 1115, 29896, 29889, 29900, 29892, 376, 29885, 2932, 398, 1115, 29900, 29889, 29929, 29892, 376, 7915, 29918, 7099, 388, 1115, 29900, 29889, 29900, 29900, 29900, 29945, 29892, 376, 29876, 4156, 586, 1115, 5574, 1118, 376, 29212, 29918, 1853, 4710, 11569, 613, 376, 29212, 29918, 3207, 28819, 2344, 29918, 29212, 1115, 29900, 29889, 29900, 29900, 29900, 29941, 29892, 376, 4283, 1115, 29900, 29889, 29900, 29900, 29900, 29941, 29892, 376, 13519, 1115, 29900, 29889, 29955, 29945, 29913, 4970, 13, 1678, 1596, 2295, 3366, 6758, 3108, 30004, 13, 1678, 6782, 29918, 1990, 2450, 29898, 2917, 8443, 13, 2 ]
create_tacacs.py
cromulon-actual/ise_automation
0
23658
<reponame>cromulon-actual/ise_automation from ciscoisesdk import IdentityServicesEngineAPI from ciscoisesdk.exceptions import ApiError from dotenv import load_dotenv import os from pprint import pprint as ppr load_dotenv() admin = os.getenv("ISE_ADMIN") pw = os.getenv("ISE_PW") base_url = os.getenv("ISE_URL") api = IdentityServicesEngineAPI( username=admin, password=pw, base_url=base_url, version="3.0.0", verify=False) print("=" * 50) # Get Admin Users search_result = api.admin_user.get_all() ppr(search_result.response) print("=" * 50) # Get All TACACS Users search_result = api.tacacs_profile.get_all() ppr(search_result.response) print("=" * 50)
[ 1, 529, 276, 1112, 420, 29958, 29883, 456, 352, 265, 29899, 19304, 29914, 895, 29918, 17405, 362, 13, 3166, 274, 275, 1111, 4637, 8181, 1053, 27486, 13779, 12412, 8787, 13, 3166, 274, 275, 1111, 4637, 8181, 29889, 11739, 29879, 1053, 29749, 2392, 13, 3166, 8329, 6272, 1053, 2254, 29918, 6333, 6272, 13, 5215, 2897, 13, 3166, 282, 2158, 1053, 282, 2158, 408, 282, 558, 13, 13, 1359, 29918, 6333, 6272, 580, 13, 6406, 353, 2897, 29889, 657, 6272, 703, 29902, 1660, 29918, 3035, 16173, 1159, 13, 29886, 29893, 353, 2897, 29889, 657, 6272, 703, 29902, 1660, 29918, 29925, 29956, 1159, 13, 3188, 29918, 2271, 353, 2897, 29889, 657, 6272, 703, 29902, 1660, 29918, 4219, 1159, 13, 13, 2754, 353, 27486, 13779, 12412, 8787, 29898, 13, 1678, 8952, 29922, 6406, 29892, 4800, 29922, 29886, 29893, 29892, 2967, 29918, 2271, 29922, 3188, 29918, 2271, 29892, 1873, 543, 29941, 29889, 29900, 29889, 29900, 613, 11539, 29922, 8824, 29897, 13, 13, 13, 2158, 703, 543, 334, 29871, 29945, 29900, 29897, 13, 29937, 3617, 10229, 23861, 13, 4478, 29918, 2914, 353, 7882, 29889, 6406, 29918, 1792, 29889, 657, 29918, 497, 580, 13, 407, 29878, 29898, 4478, 29918, 2914, 29889, 5327, 29897, 13, 13, 2158, 703, 543, 334, 29871, 29945, 29900, 29897, 13, 13, 29937, 3617, 2178, 323, 2477, 2477, 29903, 23861, 13, 4478, 29918, 2914, 353, 7882, 29889, 21229, 16815, 29918, 10185, 29889, 657, 29918, 497, 580, 13, 407, 29878, 29898, 4478, 29918, 2914, 29889, 5327, 29897, 13, 2158, 703, 543, 334, 29871, 29945, 29900, 29897, 13, 2 ]
python2.7/site-packages/twisted/test/app_qtstub.py
84KaliPleXon3/sslstrip-hsts-openwrt
19
159230
# Copyright (c) 2006 Twisted Matrix Laboratories. # See LICENSE for details. """ L{twisted.test.test_application.PluggableReactorTestCase.test_qtStub} uses this helper program to test that when the QT reactor plugin is not available, an attempt to select it via the deprecated name C{qt} fails appropriately. When installation fails, no output is produced. When it succeeds, a message is printed. """ import sys from twisted.application import reactors class QTNotImporter: """ Import hook which unilaterally rejects any attempt to import C{qtreactor} so that we can reliably test the behavior of attempting to install it when it is not present. """ def find_module(self, fullname, path): """ Reject attempts to import C{qtreactor}. Ignore everything else. """ if fullname == 'qtreactor': raise ImportError('qtreactor does not exist!') def main(): """ Try to install the reactor named C{qt}. Expect it to not work. Print diagnostics to stdout if something goes wrong, print nothing otherwise. """ sys.meta_path.insert(0, QTNotImporter()) try: reactors.installReactor('qt') except reactors.NoSuchReactor, e: if e.args != ('qt',): print 'Wrong arguments to NoSuchReactor:', e.args else: # Do nothing to indicate success. pass else: print 'installed qtreactor succesfully' sys.stdout.flush() if __name__ == '__main__': main()
[ 1, 396, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29900, 29953, 8168, 12652, 22513, 16715, 1061, 583, 29889, 13, 29937, 2823, 365, 2965, 1430, 1660, 363, 4902, 29889, 13, 13, 15945, 29908, 13, 29931, 29912, 7516, 12652, 29889, 1688, 29889, 1688, 29918, 6214, 29889, 3247, 12981, 519, 1123, 7168, 3057, 8259, 29889, 1688, 29918, 17915, 855, 431, 29913, 3913, 13, 1366, 16876, 1824, 304, 1243, 393, 746, 278, 660, 29911, 337, 7168, 7079, 338, 451, 13, 16515, 29892, 385, 4218, 304, 1831, 372, 3025, 278, 18164, 1024, 315, 29912, 17915, 29913, 8465, 13, 932, 6649, 2486, 29889, 13, 13, 10401, 11161, 8465, 29892, 694, 1962, 338, 7371, 29889, 29871, 1932, 372, 9269, 29879, 29892, 263, 2643, 13, 275, 13350, 29889, 13, 15945, 29908, 13, 13, 5215, 10876, 13, 13, 3166, 3252, 12652, 29889, 6214, 1053, 7657, 943, 13, 13, 13, 1990, 660, 29911, 3664, 24192, 9555, 29901, 13, 1678, 9995, 13, 1678, 16032, 12422, 607, 443, 309, 1008, 635, 12560, 29879, 738, 4218, 304, 1053, 13, 1678, 315, 29912, 29939, 2484, 7168, 29913, 577, 393, 591, 508, 12536, 2197, 1243, 278, 6030, 310, 15661, 304, 13, 1678, 2601, 372, 746, 372, 338, 451, 2198, 29889, 13, 1678, 9995, 13, 1678, 822, 1284, 29918, 5453, 29898, 1311, 29892, 2989, 978, 29892, 2224, 1125, 13, 4706, 9995, 13, 4706, 830, 622, 14734, 304, 1053, 315, 29912, 29939, 2484, 7168, 1836, 29871, 18076, 487, 4129, 1683, 29889, 13, 4706, 9995, 13, 4706, 565, 2989, 978, 1275, 525, 29939, 2484, 7168, 2396, 13, 9651, 12020, 16032, 2392, 877, 29939, 2484, 7168, 947, 451, 1863, 29991, 1495, 13, 13, 13, 13, 1753, 1667, 7295, 13, 1678, 9995, 13, 1678, 3967, 304, 2601, 278, 337, 7168, 4257, 315, 29912, 17915, 1836, 29871, 1222, 1103, 372, 304, 451, 664, 29889, 29871, 13905, 13, 1678, 652, 20921, 304, 27591, 565, 1554, 5771, 2743, 29892, 1596, 3078, 6467, 29889, 13, 1678, 9995, 13, 1678, 10876, 29889, 7299, 29918, 2084, 29889, 7851, 29898, 29900, 29892, 660, 29911, 3664, 24192, 9555, 3101, 13, 1678, 1018, 29901, 13, 4706, 7657, 943, 29889, 6252, 1123, 7168, 877, 17915, 1495, 13, 1678, 5174, 7657, 943, 29889, 3782, 29903, 987, 1123, 7168, 29892, 321, 29901, 13, 4706, 565, 321, 29889, 5085, 2804, 6702, 17915, 742, 1125, 13, 9651, 1596, 525, 29956, 29373, 6273, 304, 1939, 29903, 987, 1123, 7168, 29901, 742, 321, 29889, 5085, 13, 4706, 1683, 29901, 13, 9651, 396, 1938, 3078, 304, 12266, 2551, 29889, 13, 9651, 1209, 13, 1678, 1683, 29901, 13, 4706, 1596, 525, 25537, 3855, 2484, 7168, 8348, 267, 3730, 29915, 13, 1678, 10876, 29889, 25393, 29889, 23126, 580, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1667, 580, 13, 2 ]
parking_permits/tests/factories/order.py
SuviVappula/parking-permits
0
174029
<reponame>SuviVappula/parking-permits from decimal import Decimal import factory from parking_permits.models import Order, OrderItem from .customer import CustomerFactory from .parking_permit import ParkingPermitFactory from .product import ProductFactory class OrderFactory(factory.django.DjangoModelFactory): customer = factory.SubFactory(CustomerFactory) class Meta: model = Order class OrderItemFactory(factory.django.DjangoModelFactory): order = factory.SubFactory(OrderFactory) product = factory.SubFactory(ProductFactory) permit = factory.SubFactory(ParkingPermitFactory) unit_price = Decimal(30) vat = Decimal(0.24) quantity = 6 class Meta: model = OrderItem
[ 1, 529, 276, 1112, 420, 29958, 5091, 1403, 29963, 932, 2497, 29914, 6378, 292, 29899, 17858, 1169, 13, 3166, 13677, 1053, 3826, 3039, 13, 13, 5215, 12529, 13, 13, 3166, 610, 9292, 29918, 17858, 1169, 29889, 9794, 1053, 8170, 29892, 8170, 2001, 13, 13, 3166, 869, 15539, 1053, 21886, 5126, 13, 3166, 869, 6378, 292, 29918, 546, 2415, 1053, 4815, 292, 15737, 277, 5126, 13, 3166, 869, 4704, 1053, 10969, 5126, 13, 13, 13, 1990, 8170, 5126, 29898, 14399, 29889, 14095, 29889, 29928, 5364, 3195, 5126, 1125, 13, 1678, 11962, 353, 12529, 29889, 4035, 5126, 29898, 15122, 5126, 29897, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 1904, 353, 8170, 13, 13, 13, 1990, 8170, 2001, 5126, 29898, 14399, 29889, 14095, 29889, 29928, 5364, 3195, 5126, 1125, 13, 1678, 1797, 353, 12529, 29889, 4035, 5126, 29898, 7514, 5126, 29897, 13, 1678, 3234, 353, 12529, 29889, 4035, 5126, 29898, 7566, 5126, 29897, 13, 1678, 14257, 353, 12529, 29889, 4035, 5126, 29898, 29925, 935, 292, 15737, 277, 5126, 29897, 13, 1678, 5190, 29918, 9175, 353, 3826, 3039, 29898, 29941, 29900, 29897, 13, 1678, 325, 271, 353, 3826, 3039, 29898, 29900, 29889, 29906, 29946, 29897, 13, 1678, 14728, 353, 29871, 29953, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 1904, 353, 8170, 2001, 13, 2 ]
control/test_stand/generate_test_sequence.py
sentree/hover-jet
10
93883
<gh_stars>1-10 import numpy as np from functools import partial import os MAX_SERVO_ANGLE_RAD = 1.1 MS_PER_TICK = 25 SEC_PER_MS = 1e-3 LENGTH_TICKS = 1000 ALL_INDICES = {0, 1, 2, 3} def generate_yaml(command_list): assert command_list.ndim == 2 assert command_list.shape[1] == 4 text = "commands:\n" for cmd in command_list: text += " - [{servo_0}, {servo_1}, {servo_2}, {servo_3}]\n".format( servo_0=cmd[0], servo_1=cmd[1], servo_2=cmd[2], servo_3=cmd[3] ) return text def write_file(text, path): with open(path, 'w') as f: f.write(text) def set_zero(): cmds = np.array([ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], ]) return cmds def sine_wave_all(freq_hz, scaling_factor=np.array([1.0, 1.0, 1.0, 1.0])): ticks = np.arange(0.0, LENGTH_TICKS) millseconds = MS_PER_TICK * ticks seconds = millseconds * SEC_PER_MS angular_freq_radps = freq_hz * (2.0 * np.pi) result = MAX_SERVO_ANGLE_RAD * np.vstack([ np.sin(angular_freq_radps * seconds), np.sin(angular_freq_radps * seconds), np.sin(angular_freq_radps * seconds), np.sin(angular_freq_radps * seconds) ]).transpose() return scaling_factor * result def all_hold(target_angle): result = np.ones((LENGTH_TICKS, 4)) * target_angle return result if __name__ == '__main__': from matplotlib import pyplot as plt import argparse parser = argparse.ArgumentParser() parser.add_argument('-p', '--plot', action='store_true') args = parser.parse_args() tests = { "set_zero": set_zero(), "sine_wave_slow": sine_wave_all(freq_hz=0.1), "sine_wave_medium": sine_wave_all(freq_hz=0.5), "sine_wave_fast": sine_wave_all(freq_hz=1.0), "02_symmetric": sine_wave_all(freq_hz=0.1, scaling_factor=np.array([1.0, 0.0, 1.0, 0.0])), "13_symmetric": sine_wave_all(freq_hz=0.1, scaling_factor=np.array([0.0, 1.0, 0.0, 1.0])), "02_antisymmetric": sine_wave_all(freq_hz=0.1, scaling_factor=np.array([1.0, 0.0, -1.0, 0.0])), "13_antisymmetric": sine_wave_all(freq_hz=0.1, scaling_factor=np.array([0.0, 1.0, 0.0, -1.0])), "all_max": all_hold(target_angle=MAX_SERVO_ANGLE_RAD), "all_min": all_hold(target_angle=-MAX_SERVO_ANGLE_RAD), } for test_name, command_sequence in tests.items(): if (args.plot): ticks = np.arange(0.0, command_sequence.shape[0]) tt_milliseconds = ticks * MS_PER_TICK tt_seconds = tt_milliseconds * SEC_PER_MS for servo_index in range(4): plt.plot(tt_seconds, command_sequence[:, servo_index], label='Angle: {}'.format(servo_index)) plt.ylim(np.array([-MAX_SERVO_ANGLE_RAD, MAX_SERVO_ANGLE_RAD]) * 1.1) plt.xlabel("Time From Start (Seconds)") plt.ylabel("Servo Angle (Radians)") plt.title("Command sequence for {}".format(test_name)) plt.grid() plt.legend() plt.show() test_yaml_text = generate_yaml(command_sequence) test_file_name = "{}.yaml".format(test_name) output_path = os.path.join(os.getcwdu(), test_file_name) test_file_path = os.path.realpath(output_path) write_file(test_yaml_text, test_file_path) print("Writing to {} to {}".format(test_name, output_path))
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 5215, 12655, 408, 7442, 13, 3166, 2090, 312, 8789, 1053, 7687, 13, 5215, 2897, 13, 13, 13, 12648, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 353, 29871, 29896, 29889, 29896, 13, 4345, 29918, 13171, 29918, 29911, 2965, 29968, 353, 29871, 29906, 29945, 13, 1660, 29907, 29918, 13171, 29918, 4345, 353, 29871, 29896, 29872, 29899, 29941, 13, 19433, 29918, 29911, 2965, 17557, 353, 29871, 29896, 29900, 29900, 29900, 13, 9818, 29918, 22255, 2965, 2890, 353, 426, 29900, 29892, 29871, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 29913, 13, 13, 13, 1753, 5706, 29918, 25162, 29898, 6519, 29918, 1761, 1125, 13, 1678, 4974, 1899, 29918, 1761, 29889, 299, 326, 1275, 29871, 29906, 13, 1678, 4974, 1899, 29918, 1761, 29889, 12181, 29961, 29896, 29962, 1275, 29871, 29946, 13, 1678, 1426, 353, 376, 26381, 3583, 29876, 29908, 13, 1678, 363, 9920, 297, 1899, 29918, 1761, 29901, 13, 4706, 1426, 4619, 376, 29871, 448, 15974, 643, 1365, 29918, 29900, 1118, 426, 643, 1365, 29918, 29896, 1118, 426, 643, 1365, 29918, 29906, 1118, 426, 643, 1365, 29918, 29941, 6525, 29905, 29876, 1642, 4830, 29898, 13, 9651, 724, 1365, 29918, 29900, 29922, 9006, 29961, 29900, 1402, 13, 9651, 724, 1365, 29918, 29896, 29922, 9006, 29961, 29896, 1402, 13, 9651, 724, 1365, 29918, 29906, 29922, 9006, 29961, 29906, 1402, 13, 9651, 724, 1365, 29918, 29941, 29922, 9006, 29961, 29941, 29962, 13, 4706, 1723, 13, 13, 1678, 736, 1426, 13, 13, 13, 1753, 2436, 29918, 1445, 29898, 726, 29892, 2224, 1125, 13, 1678, 411, 1722, 29898, 2084, 29892, 525, 29893, 1495, 408, 285, 29901, 13, 4706, 285, 29889, 3539, 29898, 726, 29897, 13, 13, 13, 1753, 731, 29918, 9171, 7295, 13, 1678, 9920, 29879, 353, 7442, 29889, 2378, 4197, 13, 4706, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 13, 4706, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 13, 4706, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 13, 268, 2314, 13, 13, 1678, 736, 9920, 29879, 13, 13, 13, 1753, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29892, 21640, 29918, 19790, 29922, 9302, 29889, 2378, 4197, 29896, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 12622, 29901, 13, 1678, 260, 7358, 353, 7442, 29889, 279, 927, 29898, 29900, 29889, 29900, 29892, 365, 1430, 29954, 4690, 29918, 29911, 2965, 17557, 29897, 13, 13, 1678, 3533, 23128, 353, 10888, 29918, 13171, 29918, 29911, 2965, 29968, 334, 260, 7358, 13, 1678, 6923, 353, 3533, 23128, 334, 3725, 29907, 29918, 13171, 29918, 4345, 13, 13, 1678, 6401, 29918, 29888, 7971, 29918, 3665, 567, 353, 3005, 29939, 29918, 29882, 29920, 334, 313, 29906, 29889, 29900, 334, 7442, 29889, 1631, 29897, 13, 13, 1678, 1121, 353, 18134, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 334, 7442, 29889, 29894, 1429, 4197, 13, 4706, 7442, 29889, 5223, 29898, 6825, 29918, 29888, 7971, 29918, 3665, 567, 334, 6923, 511, 13, 4706, 7442, 29889, 5223, 29898, 6825, 29918, 29888, 7971, 29918, 3665, 567, 334, 6923, 511, 13, 4706, 7442, 29889, 5223, 29898, 6825, 29918, 29888, 7971, 29918, 3665, 567, 334, 6923, 511, 13, 4706, 7442, 29889, 5223, 29898, 6825, 29918, 29888, 7971, 29918, 3665, 567, 334, 6923, 29897, 13, 1678, 4514, 467, 3286, 4220, 580, 13, 13, 1678, 736, 21640, 29918, 19790, 334, 1121, 13, 13, 13, 1753, 599, 29918, 8948, 29898, 5182, 29918, 2521, 1125, 13, 1678, 1121, 353, 7442, 29889, 2873, 3552, 19433, 29918, 29911, 2965, 17557, 29892, 29871, 29946, 876, 334, 3646, 29918, 2521, 13, 1678, 736, 1121, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 515, 22889, 1053, 11451, 5317, 408, 14770, 13, 1678, 1053, 1852, 5510, 13, 1678, 13812, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 1678, 13812, 29889, 1202, 29918, 23516, 877, 29899, 29886, 742, 525, 489, 5317, 742, 3158, 2433, 8899, 29918, 3009, 1495, 13, 1678, 6389, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 1678, 6987, 353, 426, 13, 4706, 376, 842, 29918, 9171, 1115, 731, 29918, 9171, 3285, 13, 4706, 376, 29879, 457, 29918, 27766, 29918, 28544, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29896, 511, 13, 4706, 376, 29879, 457, 29918, 27766, 29918, 27891, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29945, 511, 13, 4706, 376, 29879, 457, 29918, 27766, 29918, 11255, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29896, 29889, 29900, 511, 13, 4706, 376, 29900, 29906, 29918, 11967, 16414, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29896, 29892, 21640, 29918, 19790, 29922, 9302, 29889, 2378, 4197, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 2314, 511, 13, 4706, 376, 29896, 29941, 29918, 11967, 16414, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29896, 29892, 21640, 29918, 19790, 29922, 9302, 29889, 2378, 4197, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 2314, 511, 13, 4706, 376, 29900, 29906, 29918, 424, 275, 962, 16414, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29896, 29892, 21640, 29918, 19790, 29922, 9302, 29889, 2378, 4197, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 448, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 2314, 511, 13, 4706, 376, 29896, 29941, 29918, 424, 275, 962, 16414, 1115, 269, 457, 29918, 27766, 29918, 497, 29898, 29888, 7971, 29918, 29882, 29920, 29922, 29900, 29889, 29896, 29892, 21640, 29918, 19790, 29922, 9302, 29889, 2378, 4197, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 448, 29896, 29889, 29900, 2314, 511, 13, 4706, 376, 497, 29918, 3317, 1115, 599, 29918, 8948, 29898, 5182, 29918, 2521, 29922, 12648, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 511, 13, 4706, 376, 497, 29918, 1195, 1115, 599, 29918, 8948, 29898, 5182, 29918, 2521, 10457, 12648, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 511, 13, 1678, 500, 13, 13, 1678, 363, 1243, 29918, 978, 29892, 1899, 29918, 16506, 297, 6987, 29889, 7076, 7295, 13, 4706, 565, 313, 5085, 29889, 5317, 1125, 13, 9651, 260, 7358, 353, 7442, 29889, 279, 927, 29898, 29900, 29889, 29900, 29892, 1899, 29918, 16506, 29889, 12181, 29961, 29900, 2314, 13, 9651, 260, 29873, 29918, 19958, 21462, 353, 260, 7358, 334, 10888, 29918, 13171, 29918, 29911, 2965, 29968, 13, 9651, 260, 29873, 29918, 23128, 353, 260, 29873, 29918, 19958, 21462, 334, 3725, 29907, 29918, 13171, 29918, 4345, 13, 9651, 363, 724, 1365, 29918, 2248, 297, 3464, 29898, 29946, 1125, 13, 18884, 14770, 29889, 5317, 29898, 698, 29918, 23128, 29892, 1899, 29918, 16506, 7503, 29892, 724, 1365, 29918, 2248, 1402, 3858, 2433, 19582, 29901, 6571, 4286, 4830, 29898, 643, 1365, 29918, 2248, 876, 13, 13, 9651, 14770, 29889, 29891, 2576, 29898, 9302, 29889, 2378, 4197, 29899, 12648, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 29892, 18134, 29918, 6304, 24898, 29918, 19453, 1307, 29918, 29934, 3035, 2314, 334, 29871, 29896, 29889, 29896, 29897, 13, 9651, 14770, 29889, 29916, 1643, 703, 2481, 3645, 7370, 313, 27535, 25760, 13, 9651, 14770, 29889, 29891, 1643, 703, 1748, 1365, 3218, 280, 313, 9908, 5834, 25760, 13, 9651, 14770, 29889, 3257, 703, 6255, 5665, 363, 6571, 1642, 4830, 29898, 1688, 29918, 978, 876, 13, 9651, 14770, 29889, 7720, 580, 13, 9651, 14770, 29889, 26172, 580, 13, 9651, 14770, 29889, 4294, 580, 13, 13, 4706, 1243, 29918, 25162, 29918, 726, 353, 5706, 29918, 25162, 29898, 6519, 29918, 16506, 29897, 13, 4706, 1243, 29918, 1445, 29918, 978, 353, 29850, 1836, 25162, 1642, 4830, 29898, 1688, 29918, 978, 29897, 13, 4706, 1962, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 359, 29889, 657, 29883, 29893, 700, 3285, 1243, 29918, 1445, 29918, 978, 29897, 13, 4706, 1243, 29918, 1445, 29918, 2084, 353, 2897, 29889, 2084, 29889, 6370, 2084, 29898, 4905, 29918, 2084, 29897, 13, 4706, 2436, 29918, 1445, 29898, 1688, 29918, 25162, 29918, 726, 29892, 1243, 29918, 1445, 29918, 2084, 29897, 13, 4706, 1596, 703, 29956, 768, 292, 304, 6571, 304, 6571, 1642, 4830, 29898, 1688, 29918, 978, 29892, 1962, 29918, 2084, 876, 13, 2 ]
hash_dict/__init__.py
Cologler/hash-dict-python
0
69814
<filename>hash_dict/__init__.py<gh_stars>0 # -*- coding: utf-8 -*- # # Copyright (c) 2019~2999 - Cologler <<EMAIL>> # ---------- # # ---------- from .hash_dict import HashDict from .hash_set import HashSet from .comparer import ( IEqualityComparer, ObjectComparer, AnyComparer, StringComparers, )
[ 1, 529, 9507, 29958, 8568, 29918, 8977, 29914, 1649, 2344, 26914, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 13, 29937, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29896, 29929, 30022, 29906, 29929, 29929, 29929, 448, 315, 1189, 1358, 3532, 26862, 6227, 6778, 13, 29937, 448, 1378, 29899, 13, 29937, 13, 29937, 448, 1378, 29899, 13, 13, 3166, 869, 8568, 29918, 8977, 1053, 11874, 21533, 13, 3166, 869, 8568, 29918, 842, 1053, 11874, 2697, 13, 13, 3166, 869, 510, 862, 261, 1053, 313, 13, 1678, 306, 6108, 2877, 1523, 862, 261, 29892, 13, 1678, 4669, 1523, 862, 261, 29892, 3139, 1523, 862, 261, 29892, 13, 1678, 1714, 1523, 862, 414, 29892, 13, 29897, 13, 2 ]
target/opsdev/WEB-INF/classes/shell/updateMobileManagerDataSource.py
ws02752587/opsdev
0
28264
import sys import re argvs = list(sys.argv) result = '' dataSourceName=argvs[1] name=argvs[2] if not dataSourceName or not name: return path="/mobile/app/upload/"+name+"/WEB-INF/classes/spring/applicationContext-ibatis.xml" with open(path) as file: result = file.read() result = re.sub('<bean\\s+id\\s*=\\s*"dataSourceFrom".*?org.apache.commons.dbcp.BasicDataSource.*?</bean>', "", result,flags=re.S,count=1) jndiStr = re.findall('<!--\\s*(<bean\\s+id\\s*=\\s*"dataSourceFrom".*?org.springframework.jndi.JndiObjectFactoryBean.*?)-->', result, flags=re.S) if not jndiStr: jndiStr=""" <bean id="dataSourceFrom" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>"""+dataSourceName+"""</value> </property> </bean> """ else: jndiStr = jndiStr[0] result = re.sub('<!--\\s*(<bean\\s+id\\s*=\\s*"dataSourceFrom".*?org.springframework.jndi.JndiObjectFactoryBean.*?)-->',jndiStr ,result, flags=re.S) with open(path, "w", encoding="UTF-8") as file: file.write(result) print "success"
[ 1, 1053, 10876, 13, 5215, 337, 13, 13, 1191, 4270, 353, 1051, 29898, 9675, 29889, 19218, 29897, 13, 2914, 353, 6629, 13, 1272, 4435, 1170, 29922, 1191, 4270, 29961, 29896, 29962, 13, 978, 29922, 1191, 4270, 29961, 29906, 29962, 13, 361, 451, 848, 4435, 1170, 470, 451, 1024, 29901, 13, 1678, 736, 13, 2084, 13802, 16769, 29914, 932, 29914, 9009, 12975, 29974, 978, 13578, 29914, 8851, 29933, 29899, 24065, 29914, 13203, 29914, 4278, 29914, 6214, 2677, 29899, 747, 18792, 29889, 3134, 29908, 13, 2541, 1722, 29898, 2084, 29897, 408, 934, 29901, 13, 1678, 1121, 353, 934, 29889, 949, 580, 13, 13, 2914, 353, 337, 29889, 1491, 877, 29966, 14471, 1966, 29879, 29974, 333, 1966, 29879, 29930, 29922, 1966, 29879, 20605, 1272, 4435, 4591, 1642, 29930, 29973, 990, 29889, 4288, 29889, 22382, 29889, 2585, 6814, 29889, 16616, 15559, 5575, 29973, 829, 14471, 29958, 742, 12633, 1121, 29892, 15764, 29922, 276, 29889, 29903, 29892, 2798, 29922, 29896, 29897, 13, 29926, 299, 29875, 5015, 353, 337, 29889, 2886, 497, 877, 14136, 1966, 29879, 16395, 29966, 14471, 1966, 29879, 29974, 333, 1966, 29879, 29930, 29922, 1966, 29879, 20605, 1272, 4435, 4591, 1642, 29930, 29973, 990, 29889, 6688, 29889, 29926, 299, 29875, 29889, 29967, 299, 29875, 2061, 5126, 8217, 5575, 7897, 15110, 742, 1121, 29892, 13449, 29922, 276, 29889, 29903, 29897, 13, 361, 451, 432, 299, 29875, 5015, 29901, 13, 1678, 432, 299, 29875, 5015, 13776, 29908, 13, 1678, 529, 14471, 1178, 543, 1272, 4435, 4591, 29908, 770, 543, 990, 29889, 6688, 29889, 29926, 299, 29875, 29889, 29967, 299, 29875, 2061, 5126, 8217, 1013, 13, 12, 12, 29966, 6799, 1024, 543, 29926, 299, 29875, 1170, 3254, 1767, 11903, 15945, 29974, 1272, 4435, 1170, 13578, 15945, 829, 1767, 29958, 13, 12, 12, 829, 6799, 29958, 13, 12, 829, 14471, 29958, 13, 1678, 9995, 13, 2870, 29901, 13, 1678, 432, 299, 29875, 5015, 353, 432, 299, 29875, 5015, 29961, 29900, 29962, 13, 2914, 353, 337, 29889, 1491, 877, 14136, 1966, 29879, 16395, 29966, 14471, 1966, 29879, 29974, 333, 1966, 29879, 29930, 29922, 1966, 29879, 20605, 1272, 4435, 4591, 1642, 29930, 29973, 990, 29889, 6688, 29889, 29926, 299, 29875, 29889, 29967, 299, 29875, 2061, 5126, 8217, 5575, 7897, 15110, 742, 29926, 299, 29875, 5015, 1919, 2914, 29892, 13449, 29922, 276, 29889, 29903, 29897, 13, 2541, 1722, 29898, 2084, 29892, 376, 29893, 613, 8025, 543, 10496, 29899, 29947, 1159, 408, 934, 29901, 13, 1678, 934, 29889, 3539, 29898, 2914, 29897, 13, 2158, 376, 8698, 29908, 2 ]
anyway/widgets/suburban_widgets/pedestrian_injured_in_junctions_widget.py
shaysw/anyway
0
1615473
from anyway.request_params import RequestParams from anyway.widgets.widget import register from anyway.widgets.suburban_widgets.sub_urban_widget import SubUrbanWidget from typing import Dict # TODO: unregister? this widget produces only mock data @register class PedestrianInjuredInJunctionsWidget(SubUrbanWidget): name: str = "pedestrian_injured_in_junctions" def __init__(self, request_params: RequestParams): super().__init__(request_params, type(self).name) self.rank = 23 # TODO: add real data def generate_items(self) -> None: self.items = PedestrianInjuredInJunctionsWidget.pedestrian_injured_in_junctions_mock_data() @staticmethod def pedestrian_injured_in_junctions_mock_data(): # Temporary for Frontend return [ {"street name": "גורדון י ל", "count": 18}, {"street name": "אידלסון אברהם", "count": 10}, {"street name": "פרישמן", "count": 7}, ] @staticmethod def localize_items(request_params: RequestParams, items: Dict) -> Dict: items["data"]["text"] = { "title": "Number of pedestrian accidents on junctions in Ben Yehuda street in Tel Aviv" } return items
[ 1, 515, 8763, 29889, 3827, 29918, 7529, 1053, 10729, 9629, 30004, 13, 3166, 8763, 29889, 8030, 29879, 29889, 8030, 1053, 6036, 30004, 13, 3166, 8763, 29889, 8030, 29879, 29889, 1491, 25006, 29918, 8030, 29879, 29889, 1491, 29918, 25006, 29918, 8030, 1053, 3323, 29965, 29878, 2571, 8801, 30004, 13, 3166, 19229, 1053, 360, 919, 30004, 13, 30004, 13, 29937, 14402, 29901, 443, 9573, 29973, 445, 11109, 13880, 871, 11187, 848, 30004, 13, 29992, 9573, 30004, 13, 1990, 9293, 342, 6392, 797, 29926, 2955, 797, 29967, 651, 29879, 8801, 29898, 4035, 29965, 29878, 2571, 8801, 1125, 30004, 13, 1678, 1024, 29901, 851, 353, 376, 9795, 342, 6392, 29918, 262, 29926, 2955, 29918, 262, 29918, 29926, 651, 29879, 19451, 13, 30004, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2009, 29918, 7529, 29901, 10729, 9629, 1125, 30004, 13, 4706, 2428, 2141, 1649, 2344, 12035, 3827, 29918, 7529, 29892, 1134, 29898, 1311, 467, 978, 8443, 13, 4706, 1583, 29889, 10003, 353, 29871, 29906, 29941, 30004, 13, 30004, 13, 1678, 396, 14402, 29901, 788, 1855, 848, 30004, 13, 1678, 822, 5706, 29918, 7076, 29898, 1311, 29897, 1599, 6213, 29901, 30004, 13, 4706, 1583, 29889, 7076, 353, 9293, 342, 6392, 797, 29926, 2955, 797, 29967, 651, 29879, 8801, 29889, 9795, 342, 6392, 29918, 262, 29926, 2955, 29918, 262, 29918, 29926, 651, 29879, 29918, 17640, 29918, 1272, 26471, 13, 30004, 13, 1678, 732, 7959, 5696, 30004, 13, 1678, 822, 8939, 342, 6392, 29918, 262, 29926, 2955, 29918, 262, 29918, 29926, 651, 29879, 29918, 17640, 29918, 1272, 7295, 29871, 396, 6789, 1971, 653, 363, 13960, 355, 30004, 13, 4706, 736, 518, 30004, 13, 9651, 8853, 29352, 1024, 1115, 376, 30554, 30205, 30236, 30336, 30205, 30447, 29871, 30196, 29871, 30249, 613, 376, 2798, 1115, 29871, 29896, 29947, 1118, 30004, 13, 9651, 8853, 29352, 1024, 1115, 376, 30253, 30196, 30336, 30249, 30504, 30205, 30447, 29871, 30253, 30276, 30236, 30235, 30404, 613, 376, 2798, 1115, 29871, 29896, 29900, 1118, 30004, 13, 9651, 8853, 29352, 1024, 1115, 376, 30471, 30236, 30196, 30294, 30285, 30447, 613, 376, 2798, 1115, 29871, 29955, 1118, 30004, 13, 4706, 4514, 30004, 13, 30004, 13, 1678, 732, 7959, 5696, 30004, 13, 1678, 822, 1887, 675, 29918, 7076, 29898, 3827, 29918, 7529, 29901, 10729, 9629, 29892, 4452, 29901, 360, 919, 29897, 1599, 360, 919, 29901, 30004, 13, 4706, 4452, 3366, 1272, 3108, 3366, 726, 3108, 353, 3336, 13, 9651, 376, 3257, 1115, 376, 4557, 310, 8939, 342, 6392, 1035, 16719, 373, 432, 651, 29879, 297, 4111, 10134, 29882, 6191, 11952, 297, 18815, 7740, 440, 19451, 13, 4706, 4970, 13, 4706, 736, 4452, 30004, 13, 2 ]
src/compute_results.py
sgk98/CRM-Better-Mistakes
4
53498
<filename>src/compute_results.py import argparse import os import json import shutil import numpy as np from distutils.util import strtobool as boolean import torch import torch.optim import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.utils.data import torch.utils.data.distributed import torchvision.datasets as datasets import torchvision.models as models from config import load_config from softmax_cascade import SoftmaxCascade from transforms import train_transforms, val_transforms from trees import load_hierarchy, get_weighting, load_distances, get_classes from helper import guo_ECE,MCE import heapq import math torch.backends.cudnn.benchmark = True MODEL_NAMES = sorted(name for name in models.__dict__ if name.islower() and not name.startswith("__") and callable(models.__dict__[name])) LOSS_NAMES = ["cross-entropy", "soft-labels", "hierarchical-cross-entropy", "cosine-distance", "ranking-loss", "cosine-plus-xent", "yolo-v2"] OPTIMIZER_NAMES = ["adagrad", "adam", "adam_amsgrad", "rmsprop", "SGD"] DATASET_NAMES = ["tiered-imagenet-84", "inaturalist19-84", "tiered-imagenet-224", "inaturalist19-224"] def init_model_on_gpu(gpus_per_node, opts): arch_dict = models.__dict__ pretrained = False if not hasattr(opts, "pretrained") else opts.pretrained distributed = False if not hasattr(opts, "distributed") else opts.distributed print("=> using model '{}', pretrained={}".format(opts.arch, pretrained)) model = arch_dict[opts.arch](pretrained=pretrained) if opts.arch == "resnet18": feature_dim = 512 elif opts.arch == "resnet50": feature_dim = 2048 else: ValueError("Unknown architecture ", opts.arch) model.fc = torch.nn.Sequential(torch.nn.Dropout(opts.dropout), torch.nn.Linear(in_features=feature_dim, out_features=opts.num_classes, bias=True)) if distributed: # For multiprocessing distributed, DistributedDataParallel constructor # should always set the single device scope, otherwise, # DistributedDataParallel will use all available devices. if opts.gpu is not None: torch.cuda.set_device(opts.gpu) model.cuda(opts.gpu) # When using a single GPU per process and per # DistributedDataParallel, we need to divide the batch size # ourselves based on the total number of GPUs we have opts.batch_size = int(opts.batch_size / gpus_per_node) opts.workers = int(opts.workers / gpus_per_node) model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[opts.gpu]) else: model.cuda() # DistributedDataParallel will divide and allocate batch_size to all # available GPUs if device_ids are not set model = torch.nn.parallel.DistributedDataParallel(model) elif opts.gpu is not None: torch.cuda.set_device(opts.gpu) model = model.cuda(opts.gpu) else: # DataParallel will divide and allocate batch_size to all available GPUs model = torch.nn.DataParallel(model).cuda() return model def _load_checkpoint(opts, model, optimizer,model_path): if os.path.isfile(model_path): print("=> loading checkpoint '{}'".format(model_path)) checkpoint = torch.load(model_path,map_location='cuda:0') opts.start_epoch = checkpoint["epoch"] model.load_state_dict(checkpoint["state_dict"]) optimizer.load_state_dict(checkpoint["optimizer"]) steps = checkpoint["steps"] print("=> loaded checkpoint '{}' (epoch {})".format(model_path, checkpoint["epoch"])) elif opts.pretrained_folder is not None: if os.path.exists(opts.pretrained_folder): print("=> loading pretrained checkpoint '{}'".format(opts.pretrained_folder)) if os.path.isdir(opts.pretrained_folder): checkpoint = torch.load(os.path.join(opts.pretrained_folder, "checkpoint.pth.tar")) else: checkpoint = torch.load(opts.pretrained_folder) model.load_state_dict(checkpoint["state_dict"], strict=False) steps = 0 print("=> loaded pretrained checkpoint '{}' (epoch {})".format(opts.pretrained_folder, checkpoint["epoch"])) else: raise FileNotFoundError("Can not find {}".format(opts.pretrained_folder)) else: steps = 0 print("=> no checkpoint found at '{}'".format(opts.out_folder)) return steps def _select_optimizer(model, opts): if opts.optimizer == "adagrad": return torch.optim.Adagrad(model.parameters(), opts.lr, weight_decay=opts.weight_decay) elif opts.optimizer == "adam": return torch.optim.Adam(model.parameters(), opts.lr, weight_decay=opts.weight_decay, amsgrad=False) elif opts.optimizer == "adam_amsgrad": return torch.optim.Adam(model.parameters(), opts.lr, weight_decay=opts.weight_decay, amsgrad=True, ) elif opts.optimizer == "rmsprop": return torch.optim.RMSprop(model.parameters(), opts.lr, weight_decay=opts.weight_decay, momentum=0) elif opts.optimizer == "SGD": return torch.optim.SGD(model.parameters(), opts.lr, weight_decay=opts.weight_decay, momentum=0, nesterov=False, ) else: raise ValueError("Unknown optimizer", opts.loss) def softmax(x): '''Compute softmax values for a single vector.''' return np.exp(x) / np.sum(np.exp(x)) def row_softmax(output): '''Compute Row-Wise SoftMax given a matrix of logits''' new=np.array([softmax(i) for i in output]) return new def get_all_cost_sensitive(output,distances,classes): '''Re-Rank all predictions in the dataset using CRM''' num_classes=len(classes) C=[[0 for i in range(num_classes)] for j in range(num_classes)] for i in range(num_classes): for j in range(num_classes): C[i][j]=distances[(classes[i],classes[j])] final=np.dot(output,C) return -1*final def get_topk(prediction,target,distances,classes,k=1): '''Computing hierarchical distance@k''' ind=heapq.nlargest(k, range(len(prediction)), prediction.take) scores=[] s1,s2=0,0 for i in ind: scores.append(distances[(classes[i],classes[target])]) return scores def get_metrics(opts,output,target,distances,classes): ##Random Shuffling if Required if opts.shuffle_classes==1: np.random.seed(42)##Seed used to Train HXE/Soft-Labels. However, can be changed np.random.shuffle(classes) ##Apply CRM if opts.rerank==1: output=get_all_cost_sensitive(output,distances,classes) orig_top1=[] orig_mistake=[] orig_avg_1=[] orig_avg_5=[] orig_avg_20=[] for i in range(len(output)): if output[i].argmax()==target[i]: orig_top1.append(1) else: orig_top1.append(0) orig_mistake.append(distances[(classes[target[i]],classes[output[i].argmax()])]) orig_avg_1.extend(get_topk(output[i],target[i],distances,classes,1)) orig_avg_5.append(get_topk(output[i],target[i],distances,classes,5)) orig_avg_20.append(get_topk(output[i],target[i],distances,classes,20)) print("Top-1 Accuracy",np.array(orig_top1).mean()) print("Mistake Severity",np.array(orig_mistake).mean()) print("Hierarchical Distance@1",np.array(orig_avg_1).mean()) print("Hierarchical Distance@5",np.array(orig_avg_5).mean()) print("Hierarchical Distance@20",np.array(orig_avg_20).mean()) result=[np.array(orig_top1).mean(),np.array(orig_avg_1).mean(),np.array(orig_avg_5).mean(),np.array(orig_avg_20).mean(), np.array(orig_mistake).mean()] return result def main(opts,model_path): ##Setup Dataset test_dir = os.path.join(opts.data_path, "test") test_dataset = datasets.ImageFolder(test_dir, val_transforms(opts.data, resize=(224,224),normalize=True)) test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=opts.batch_size, shuffle=False, num_workers=opts.workers, pin_memory=True, drop_last=False) gpus_per_node=1 ##Load Hierarchy Information distances = load_distances(opts.data, 'ilsvrc', opts.data_dir) hierarchy = load_hierarchy(opts.data, opts.data_dir) if opts.loss == "yolo-v2": classes, _ = get_classes(hierarchy, output_all_nodes=True) else: classes = test_dataset.classes opts.num_classes = len(classes) if opts.loss == "yolo-v2": cascade = SoftmaxCascade(hierarchy, classes).cuda(opts.gpu) num_leaf_classes = len(hierarchy.treepositions("leaves")) weights = get_weighting(hierarchy, "exponential", value=opts.alpha) def yolo2_corrector(output): return cascade.final_probabilities(output)[:, :num_leaf_classes] model = init_model_on_gpu(gpus_per_node, opts) # setup optimizer optimizer = _select_optimizer(model, opts) # load from checkpoint if existing steps = _load_checkpoint(opts, model, optimizer,model_path) corrector = yolo2_corrector if opts.loss == "yolo-v2" else lambda x: x model.eval() torch.no_grad() ##Iterate Over Dataset and collect logits and labels test_output=[] test_target=[] for batch_idx,(embeddings,target) in enumerate(test_loader): if opts.gpu is not None: embeddings = embeddings.cuda(opts.gpu,non_blocking=True) output=model(embeddings) output=corrector(output) test_output.extend(output.cpu().tolist()) test_target.extend(target.tolist()) test_output=np.array(test_output) test_target=np.array(test_target) ##The corrector applies softmax cascade for YOLOv2 if opts.loss!='yolo-v2': softmax_output=row_softmax(test_output) else: softmax_output=test_output ##Compute Metrics and Return Logs model_ece=guo_ECE(softmax_output,test_target) model_mce=MCE(softmax_output,test_target) print("ECE:",model_ece) print("MCE:",model_mce) result=get_metrics(opts,softmax_output,test_target,distances,classes) result.append(model_ece) result.append(model_mce) return result if __name__=="__main__": parser = argparse.ArgumentParser() parser.add_argument("--arch", default="resnet18", choices=MODEL_NAMES, help="model architecture: | ".join(MODEL_NAMES)) parser.add_argument("--loss", default="cross-entropy", choices=LOSS_NAMES, help="loss type: | ".join(LOSS_NAMES)) parser.add_argument("--optimizer", default="adam_amsgrad", choices=OPTIMIZER_NAMES, help="loss type: | ".join(OPTIMIZER_NAMES)) parser.add_argument("--lr", default=1e-5, type=float, help="initial learning rate of optimizer") parser.add_argument("--weight_decay", default=0.0, type=float, help="weight decay of optimizer") parser.add_argument("--pretrained", type=boolean, default=True, help="start from ilsvrc12/imagenet model weights") parser.add_argument("--pretrained_folder", type=str, default=None, help="folder or file from which to load the network weights") parser.add_argument("--dropout", default=0.0, type=float, help="Prob of dropout for network FC layer") parser.add_argument("--data_augmentation", type=boolean, default=True, help="Train with basic data augmentation") parser.add_argument("--num_training_steps", default=200000, type=int, help="number of total steps to train for (num_batches*num_epochs)") parser.add_argument("--start-epoch", default=0, type=int, help="manual epoch number (useful on restarts)") parser.add_argument("--batch-size", default=256, type=int, help="total batch size") parser.add_argument("--shuffle_classes", default=False, type=boolean, help="Shuffle classes in the hierarchy") parser.add_argument("--beta", default=0, type=float, help="Softness parameter: the higher, the closer to one-hot encoding") parser.add_argument("--alpha", type=float, default=0, help="Decay parameter for hierarchical cross entropy.") # Devise/B&D ---------------------------------------------------------------------------------------------------------------------------------------------- parser.add_argument("--devise", type=boolean, default=False, help="Use DeViSe label embeddings") parser.add_argument("--devise_single_negative", type=boolean, default=False, help="Use one negative per samples instead of all") parser.add_argument("--barzdenzler", type=boolean, default=False, help="Use Barz&Denzler label embeddings") parser.add_argument("--train_backbone_after", default=float("inf"), type=float, help="Start training backbone too after this many steps") parser.add_argument("--use_2fc", default=False, type=boolean, help="Use two FC layers for Devise") parser.add_argument("--fc_inner_dim", default=1024, type=int, help="If use_2fc is True, their inner dimension.") parser.add_argument("--lr_fc", default=1e-3, type=float, help="learning rate for FC layers") parser.add_argument("--weight_decay_fc", default=0.0, type=float, help="weight decay of FC layers") parser.add_argument("--use_fc_batchnorm", default=False, type=boolean, help="Batchnorm layer in network head") # Data/paths ---------------------------------------------------------------------------------------------------------------------------------------------- parser.add_argument("--data", default="tiered-imagenet-224", help="id of the dataset to use: | ".join(DATASET_NAMES)) parser.add_argument("--target_size", default=224, type=int, help="Size of image input to the network (target resize after data augmentation)") parser.add_argument("--data-paths-config", help="Path to data paths yaml file", default="../data_paths.yml") parser.add_argument("--data-path", default=None, help="explicit location of the data folder, if None use config file.") parser.add_argument("--data_dir", default="../data/", help="Folder containing the supplementary data") parser.add_argument("--output", default=None, help="path to the model folder") parser.add_argument("--expm_id", default="", type=str, help="Name log folder as: out/<scriptname>/<date>_<expm_id>. If empty, expm_id=time") # Log/val ------------------------------------------------------------------------------------------------------------------------------------------------- parser.add_argument("--log_freq", default=100, type=int, help="Log every log_freq batches") parser.add_argument("--val_freq", default=5, type=int, help="Validate every val_freq epochs (except the first 10 and last 10)") # Execution ----------------------------------------------------------------------------------------------------------------------------------------------- parser.add_argument("--workers", default=2, type=int, help="number of data loading workers") parser.add_argument("--seed", default=None, type=int, help="seed for initializing training. ") parser.add_argument("--gpu", default=0, type=int, help="GPU id to use.") ## CRM ---------------------------------------------------------------------------------- parser.add_argument("--rerank",default=0,type=int,help='whether to use CRM or not') ### Logs --------------------------------------------------------------------------------- parser.add_argument("--expname",default='cross-entropy',type=str,help="Name of model") parser.add_argument("--epoch1",default=10,type=int,help="First epoch to evaluate") parser.add_argument("--out_folder1",default=None,type=str,help="Path to model checkpoint") parser.add_argument("--out_folder2",default=None,type=str,help="Path to model checkpoint") parser.add_argument("--out_folder3",default=None,type=str,help="Path to model checkpoint") parser.add_argument("--out_folder4",default=None,type=str,help="Path to model checkpoint") parser.add_argument("--out_folder5",default=None,type=str,help="Path to model checkpoint") opts=parser.parse_args() if opts.data_path is None: opts.data_paths = load_config(opts.data_paths_config) opts.data_path = opts.data_paths[opts.data] logs=[] ##Evaluating Results on 5 checkpoints logs.append(main(opts,opts.out_folder1)) logs.append(main(opts,opts.out_folder2)) logs.append(main(opts,opts.out_folder3)) logs.append(main(opts,opts.out_folder4)) logs.append(main(opts,opts.out_folder5)) logs=np.array(logs,dtype='float64') savename=opts.expname np.savetxt(savename,logs, fmt="%.5f", delimiter=",")
[ 1, 529, 9507, 29958, 4351, 29914, 26017, 29918, 9902, 29889, 2272, 13, 5215, 1852, 5510, 13, 5215, 2897, 13, 5215, 4390, 13, 5215, 528, 4422, 13, 5215, 12655, 408, 7442, 13, 3166, 1320, 13239, 29889, 4422, 1053, 851, 517, 11227, 408, 7223, 13, 13, 5215, 4842, 305, 13, 5215, 4842, 305, 29889, 20640, 13, 5215, 4842, 305, 29889, 15755, 408, 302, 29876, 13, 5215, 4842, 305, 29889, 15755, 29889, 23482, 13, 5215, 4842, 305, 29889, 1627, 1975, 29889, 29883, 566, 15755, 408, 274, 566, 15755, 13, 5215, 4842, 305, 29889, 13239, 29889, 1272, 13, 5215, 4842, 305, 29889, 13239, 29889, 1272, 29889, 5721, 7541, 13, 5215, 4842, 305, 4924, 29889, 14538, 1691, 408, 20035, 13, 5215, 4842, 305, 4924, 29889, 9794, 408, 4733, 13, 13, 13, 3166, 2295, 1053, 2254, 29918, 2917, 13, 3166, 4964, 3317, 29918, 9398, 6332, 1053, 1105, 615, 3317, 29907, 294, 6332, 13, 3166, 4327, 29879, 1053, 7945, 29918, 9067, 29879, 29892, 659, 29918, 9067, 29879, 13, 3166, 10697, 1053, 2254, 29918, 29882, 631, 12040, 29892, 679, 29918, 7915, 292, 29892, 2254, 29918, 5721, 2925, 29892, 679, 29918, 13203, 13, 13, 3166, 16876, 1053, 1410, 29877, 29918, 29923, 4741, 29892, 29924, 4741, 13, 5215, 16947, 29939, 13, 5215, 5844, 13, 13, 7345, 305, 29889, 1627, 1975, 29889, 29883, 566, 15755, 29889, 1785, 16580, 353, 5852, 13, 20387, 29931, 29918, 5813, 29903, 353, 12705, 29898, 978, 363, 1024, 297, 4733, 17255, 8977, 1649, 565, 1024, 29889, 275, 13609, 580, 322, 451, 1024, 29889, 27382, 2541, 703, 1649, 1159, 322, 1246, 519, 29898, 9794, 17255, 8977, 1649, 29961, 978, 12622, 13, 3927, 1799, 29918, 5813, 29903, 353, 6796, 19128, 29899, 296, 14441, 613, 376, 2695, 29899, 21134, 613, 376, 29882, 631, 1279, 936, 29899, 19128, 29899, 296, 14441, 613, 376, 3944, 457, 29899, 19244, 613, 376, 661, 9292, 29899, 6758, 613, 376, 3944, 457, 29899, 11242, 29899, 29916, 296, 613, 376, 29891, 3543, 29899, 29894, 29906, 3108, 13, 14094, 7833, 26664, 1001, 29918, 5813, 29903, 353, 6796, 328, 351, 3665, 613, 376, 328, 314, 613, 376, 328, 314, 29918, 2232, 5105, 613, 376, 29878, 1516, 7728, 613, 376, 26016, 29928, 3108, 13, 25832, 8127, 29911, 29918, 5813, 29903, 353, 6796, 29873, 631, 287, 29899, 326, 5370, 300, 29899, 29947, 29946, 613, 376, 262, 18771, 391, 29896, 29929, 29899, 29947, 29946, 613, 376, 29873, 631, 287, 29899, 326, 5370, 300, 29899, 29906, 29906, 29946, 613, 376, 262, 18771, 391, 29896, 29929, 29899, 29906, 29906, 29946, 3108, 13, 13, 1753, 2069, 29918, 4299, 29918, 265, 29918, 29887, 3746, 29898, 29887, 13364, 29918, 546, 29918, 3177, 29892, 29111, 1125, 13, 1678, 3190, 29918, 8977, 353, 4733, 17255, 8977, 1649, 13, 1678, 758, 3018, 1312, 353, 7700, 565, 451, 756, 5552, 29898, 25707, 29892, 376, 1457, 3018, 1312, 1159, 1683, 29111, 29889, 1457, 3018, 1312, 13, 1678, 13235, 353, 7700, 565, 451, 756, 5552, 29898, 25707, 29892, 376, 5721, 7541, 1159, 1683, 29111, 29889, 5721, 7541, 13, 1678, 1596, 703, 4261, 773, 1904, 525, 8875, 742, 758, 3018, 1312, 3790, 29913, 1642, 4830, 29898, 25707, 29889, 1279, 29892, 758, 3018, 1312, 876, 13, 1678, 1904, 353, 3190, 29918, 8977, 29961, 25707, 29889, 1279, 850, 1457, 3018, 1312, 29922, 1457, 3018, 1312, 29897, 13, 13, 1678, 565, 29111, 29889, 1279, 1275, 376, 690, 1212, 29896, 29947, 1115, 13, 4706, 4682, 29918, 6229, 353, 29871, 29945, 29896, 29906, 13, 1678, 25342, 29111, 29889, 1279, 1275, 376, 690, 1212, 29945, 29900, 1115, 13, 4706, 4682, 29918, 6229, 353, 29871, 29906, 29900, 29946, 29947, 13, 1678, 1683, 29901, 13, 4706, 7865, 2392, 703, 14148, 11258, 9162, 29111, 29889, 1279, 29897, 13, 13, 1678, 1904, 29889, 13801, 353, 4842, 305, 29889, 15755, 29889, 16941, 2556, 29898, 7345, 305, 29889, 15755, 29889, 15063, 449, 29898, 25707, 29889, 8865, 449, 511, 4842, 305, 29889, 15755, 29889, 12697, 29898, 262, 29918, 22100, 29922, 14394, 29918, 6229, 29892, 714, 29918, 22100, 29922, 25707, 29889, 1949, 29918, 13203, 29892, 24003, 29922, 5574, 876, 13, 13, 1678, 565, 13235, 29901, 13, 4706, 396, 1152, 6674, 307, 985, 292, 13235, 29892, 6652, 7541, 1469, 2177, 6553, 5823, 13, 4706, 396, 881, 2337, 731, 278, 2323, 4742, 6874, 29892, 6467, 29892, 13, 4706, 396, 6652, 7541, 1469, 2177, 6553, 674, 671, 599, 3625, 9224, 29889, 13, 4706, 565, 29111, 29889, 29887, 3746, 338, 451, 6213, 29901, 13, 9651, 4842, 305, 29889, 29883, 6191, 29889, 842, 29918, 10141, 29898, 25707, 29889, 29887, 3746, 29897, 13, 9651, 1904, 29889, 29883, 6191, 29898, 25707, 29889, 29887, 3746, 29897, 13, 9651, 396, 1932, 773, 263, 2323, 22796, 639, 1889, 322, 639, 13, 9651, 396, 6652, 7541, 1469, 2177, 6553, 29892, 591, 817, 304, 16429, 278, 9853, 2159, 13, 9651, 396, 20278, 2729, 373, 278, 3001, 1353, 310, 22796, 29879, 591, 505, 13, 9651, 29111, 29889, 16175, 29918, 2311, 353, 938, 29898, 25707, 29889, 16175, 29918, 2311, 847, 330, 13364, 29918, 546, 29918, 3177, 29897, 13, 9651, 29111, 29889, 1287, 414, 353, 938, 29898, 25707, 29889, 1287, 414, 847, 330, 13364, 29918, 546, 29918, 3177, 29897, 13, 9651, 1904, 353, 4842, 305, 29889, 15755, 29889, 23482, 29889, 13398, 7541, 1469, 2177, 6553, 29898, 4299, 29892, 4742, 29918, 4841, 11759, 25707, 29889, 29887, 3746, 2314, 13, 4706, 1683, 29901, 13, 9651, 1904, 29889, 29883, 6191, 580, 13, 9651, 396, 6652, 7541, 1469, 2177, 6553, 674, 16429, 322, 23632, 9853, 29918, 2311, 304, 599, 13, 9651, 396, 3625, 22796, 29879, 565, 4742, 29918, 4841, 526, 451, 731, 13, 9651, 1904, 353, 4842, 305, 29889, 15755, 29889, 23482, 29889, 13398, 7541, 1469, 2177, 6553, 29898, 4299, 29897, 13, 1678, 25342, 29111, 29889, 29887, 3746, 338, 451, 6213, 29901, 13, 4706, 4842, 305, 29889, 29883, 6191, 29889, 842, 29918, 10141, 29898, 25707, 29889, 29887, 3746, 29897, 13, 4706, 1904, 353, 1904, 29889, 29883, 6191, 29898, 25707, 29889, 29887, 3746, 29897, 13, 1678, 1683, 29901, 13, 4706, 396, 3630, 2177, 6553, 674, 16429, 322, 23632, 9853, 29918, 2311, 304, 599, 3625, 22796, 29879, 13, 4706, 1904, 353, 4842, 305, 29889, 15755, 29889, 1469, 2177, 6553, 29898, 4299, 467, 29883, 6191, 580, 13, 13, 1678, 736, 1904, 13, 13, 1753, 903, 1359, 29918, 3198, 3149, 29898, 25707, 29892, 1904, 29892, 5994, 3950, 29892, 4299, 29918, 2084, 1125, 13, 1678, 565, 2897, 29889, 2084, 29889, 275, 1445, 29898, 4299, 29918, 2084, 1125, 13, 4706, 1596, 703, 4261, 8363, 1423, 3149, 525, 8875, 29915, 1642, 4830, 29898, 4299, 29918, 2084, 876, 13, 4706, 1423, 3149, 353, 4842, 305, 29889, 1359, 29898, 4299, 29918, 2084, 29892, 1958, 29918, 5479, 2433, 29883, 6191, 29901, 29900, 1495, 13, 4706, 29111, 29889, 2962, 29918, 1022, 2878, 353, 1423, 3149, 3366, 1022, 2878, 3108, 13, 4706, 1904, 29889, 1359, 29918, 3859, 29918, 8977, 29898, 3198, 3149, 3366, 3859, 29918, 8977, 20068, 13, 4706, 5994, 3950, 29889, 1359, 29918, 3859, 29918, 8977, 29898, 3198, 3149, 3366, 20640, 3950, 20068, 13, 4706, 6576, 353, 1423, 3149, 3366, 24530, 3108, 13, 4706, 1596, 703, 4261, 7500, 1423, 3149, 525, 8875, 29915, 313, 1022, 2878, 426, 1800, 1642, 4830, 29898, 4299, 29918, 2084, 29892, 1423, 3149, 3366, 1022, 2878, 3108, 876, 13, 1678, 25342, 29111, 29889, 1457, 3018, 1312, 29918, 12083, 338, 451, 6213, 29901, 13, 4706, 565, 2897, 29889, 2084, 29889, 9933, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 1125, 13, 9651, 1596, 703, 4261, 8363, 758, 3018, 1312, 1423, 3149, 525, 8875, 29915, 1642, 4830, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 876, 13, 9651, 565, 2897, 29889, 2084, 29889, 275, 3972, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 1125, 13, 18884, 1423, 3149, 353, 4842, 305, 29889, 1359, 29898, 359, 29889, 2084, 29889, 7122, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 29892, 376, 3198, 3149, 29889, 29886, 386, 29889, 12637, 5783, 13, 9651, 1683, 29901, 13, 18884, 1423, 3149, 353, 4842, 305, 29889, 1359, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 29897, 13, 13, 9651, 1904, 29889, 1359, 29918, 3859, 29918, 8977, 29898, 3198, 3149, 3366, 3859, 29918, 8977, 12436, 9406, 29922, 8824, 29897, 13, 9651, 6576, 353, 29871, 29900, 13, 9651, 1596, 703, 4261, 7500, 758, 3018, 1312, 1423, 3149, 525, 8875, 29915, 313, 1022, 2878, 426, 1800, 1642, 4830, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 29892, 1423, 3149, 3366, 1022, 2878, 3108, 876, 13, 4706, 1683, 29901, 13, 9651, 12020, 3497, 17413, 2392, 703, 6028, 451, 1284, 6571, 1642, 4830, 29898, 25707, 29889, 1457, 3018, 1312, 29918, 12083, 876, 13, 1678, 1683, 29901, 13, 4706, 6576, 353, 29871, 29900, 13, 4706, 1596, 703, 4261, 694, 1423, 3149, 1476, 472, 525, 8875, 29915, 1642, 4830, 29898, 25707, 29889, 449, 29918, 12083, 876, 13, 13, 1678, 736, 6576, 13, 1753, 903, 2622, 29918, 20640, 3950, 29898, 4299, 29892, 29111, 1125, 13, 1678, 565, 29111, 29889, 20640, 3950, 1275, 376, 328, 351, 3665, 1115, 13, 4706, 736, 4842, 305, 29889, 20640, 29889, 3253, 351, 3665, 29898, 4299, 29889, 16744, 3285, 29111, 29889, 29212, 29892, 7688, 29918, 7099, 388, 29922, 25707, 29889, 7915, 29918, 7099, 388, 29897, 13, 1678, 25342, 29111, 29889, 20640, 3950, 1275, 376, 328, 314, 1115, 13, 4706, 736, 4842, 305, 29889, 20640, 29889, 3253, 314, 29898, 4299, 29889, 16744, 3285, 29111, 29889, 29212, 29892, 7688, 29918, 7099, 388, 29922, 25707, 29889, 7915, 29918, 7099, 388, 29892, 626, 29879, 5105, 29922, 8824, 29897, 13, 1678, 25342, 29111, 29889, 20640, 3950, 1275, 376, 328, 314, 29918, 2232, 5105, 1115, 13, 4706, 736, 4842, 305, 29889, 20640, 29889, 3253, 314, 29898, 4299, 29889, 16744, 3285, 29111, 29889, 29212, 29892, 7688, 29918, 7099, 388, 29922, 25707, 29889, 7915, 29918, 7099, 388, 29892, 626, 29879, 5105, 29922, 5574, 29892, 1723, 13, 1678, 25342, 29111, 29889, 20640, 3950, 1275, 376, 29878, 1516, 7728, 1115, 13, 4706, 736, 4842, 305, 29889, 20640, 29889, 29934, 4345, 7728, 29898, 4299, 29889, 16744, 3285, 29111, 29889, 29212, 29892, 7688, 29918, 7099, 388, 29922, 25707, 29889, 7915, 29918, 7099, 388, 29892, 19399, 29922, 29900, 29897, 13, 1678, 25342, 29111, 29889, 20640, 3950, 1275, 376, 26016, 29928, 1115, 13, 4706, 736, 4842, 305, 29889, 20640, 29889, 26016, 29928, 29898, 4299, 29889, 16744, 3285, 29111, 29889, 29212, 29892, 7688, 29918, 7099, 388, 29922, 25707, 29889, 7915, 29918, 7099, 388, 29892, 19399, 29922, 29900, 29892, 302, 4156, 586, 29922, 8824, 29892, 1723, 13, 1678, 1683, 29901, 13, 4706, 12020, 7865, 2392, 703, 14148, 5994, 3950, 613, 29111, 29889, 6758, 29897, 13, 13, 1753, 4964, 3317, 29898, 29916, 1125, 13, 1678, 14550, 20606, 29872, 4964, 3317, 1819, 363, 263, 2323, 4608, 29889, 12008, 13, 1678, 736, 7442, 29889, 4548, 29898, 29916, 29897, 847, 7442, 29889, 2083, 29898, 9302, 29889, 4548, 29898, 29916, 876, 13, 13, 1753, 1948, 29918, 2695, 3317, 29898, 4905, 1125, 13, 1678, 14550, 20606, 29872, 11438, 29899, 29956, 895, 1105, 615, 7976, 2183, 263, 4636, 310, 1480, 1169, 12008, 13, 1678, 716, 29922, 9302, 29889, 2378, 4197, 2695, 3317, 29898, 29875, 29897, 363, 474, 297, 1962, 2314, 13, 1678, 736, 716, 13, 13, 13, 1753, 679, 29918, 497, 29918, 18253, 29918, 23149, 3321, 29898, 4905, 29892, 5721, 2925, 29892, 13203, 1125, 13, 1678, 14550, 1123, 29899, 29934, 804, 599, 27303, 297, 278, 8783, 773, 15600, 29924, 12008, 13, 268, 13, 1678, 954, 29918, 13203, 29922, 2435, 29898, 13203, 29897, 13, 1678, 315, 29922, 8999, 29900, 363, 474, 297, 3464, 29898, 1949, 29918, 13203, 4638, 363, 432, 297, 3464, 29898, 1949, 29918, 13203, 4638, 13, 1678, 363, 474, 297, 3464, 29898, 1949, 29918, 13203, 1125, 13, 4706, 363, 432, 297, 3464, 29898, 1949, 29918, 13203, 1125, 13, 9651, 315, 29961, 29875, 3816, 29926, 13192, 5721, 2925, 15625, 13203, 29961, 29875, 1402, 13203, 29961, 29926, 2314, 29962, 13, 13, 1678, 2186, 29922, 9302, 29889, 6333, 29898, 4905, 29892, 29907, 29897, 13, 1678, 736, 448, 29896, 29930, 8394, 13, 13, 268, 13, 13, 1753, 679, 29918, 3332, 29895, 29898, 11965, 2463, 29892, 5182, 29892, 5721, 2925, 29892, 13203, 29892, 29895, 29922, 29896, 1125, 13, 1678, 14550, 20606, 292, 6128, 1279, 936, 5418, 29992, 29895, 12008, 13, 1678, 1399, 29922, 354, 481, 29939, 29889, 12938, 1191, 342, 29898, 29895, 29892, 3464, 29898, 2435, 29898, 11965, 2463, 8243, 18988, 29889, 19730, 29897, 13, 1678, 19435, 29922, 2636, 13, 1678, 269, 29896, 29892, 29879, 29906, 29922, 29900, 29892, 29900, 13, 1678, 363, 474, 297, 1399, 29901, 13, 4706, 19435, 29889, 4397, 29898, 5721, 2925, 15625, 13203, 29961, 29875, 1402, 13203, 29961, 5182, 2314, 2314, 13, 1678, 736, 19435, 13, 13, 13, 13, 1753, 679, 29918, 2527, 10817, 29898, 25707, 29892, 4905, 29892, 5182, 29892, 5721, 2925, 29892, 13203, 1125, 13, 13, 13, 1678, 444, 17875, 1383, 3096, 1847, 565, 830, 5958, 13, 1678, 565, 29111, 29889, 845, 21897, 29918, 13203, 1360, 29896, 29901, 13, 4706, 7442, 29889, 8172, 29889, 26776, 29898, 29946, 29906, 29897, 2277, 2008, 287, 1304, 304, 28186, 379, 29990, 29923, 29914, 6295, 615, 29899, 4775, 29879, 29889, 2398, 29892, 508, 367, 3939, 13, 4706, 7442, 29889, 8172, 29889, 845, 21897, 29898, 13203, 29897, 13, 13, 1678, 444, 2052, 368, 15600, 29924, 13, 1678, 565, 29111, 29889, 2872, 804, 1360, 29896, 29901, 13, 4706, 1962, 29922, 657, 29918, 497, 29918, 18253, 29918, 23149, 3321, 29898, 4905, 29892, 5721, 2925, 29892, 13203, 29897, 13, 13, 1678, 1677, 29918, 3332, 29896, 29922, 2636, 13, 1678, 1677, 29918, 29885, 391, 1296, 29922, 2636, 13, 1678, 1677, 29918, 485, 29887, 29918, 29896, 29922, 2636, 13, 1678, 1677, 29918, 485, 29887, 29918, 29945, 29922, 2636, 13, 1678, 1677, 29918, 485, 29887, 29918, 29906, 29900, 29922, 2636, 13, 13, 13, 13, 1678, 363, 474, 297, 3464, 29898, 2435, 29898, 4905, 22164, 13, 13, 4706, 565, 1962, 29961, 29875, 1822, 1191, 3317, 580, 1360, 5182, 29961, 29875, 5387, 13, 9651, 1677, 29918, 3332, 29896, 29889, 4397, 29898, 29896, 29897, 13, 4706, 1683, 29901, 13, 9651, 1677, 29918, 3332, 29896, 29889, 4397, 29898, 29900, 29897, 13, 9651, 1677, 29918, 29885, 391, 1296, 29889, 4397, 29898, 5721, 2925, 15625, 13203, 29961, 5182, 29961, 29875, 20526, 13203, 29961, 4905, 29961, 29875, 1822, 1191, 3317, 580, 2314, 2314, 13, 13, 4706, 1677, 29918, 485, 29887, 29918, 29896, 29889, 21843, 29898, 657, 29918, 3332, 29895, 29898, 4905, 29961, 29875, 1402, 5182, 29961, 29875, 1402, 5721, 2925, 29892, 13203, 29892, 29896, 876, 13, 13, 4706, 1677, 29918, 485, 29887, 29918, 29945, 29889, 4397, 29898, 657, 29918, 3332, 29895, 29898, 4905, 29961, 29875, 1402, 5182, 29961, 29875, 1402, 5721, 2925, 29892, 13203, 29892, 29945, 876, 13, 13, 4706, 1677, 29918, 485, 29887, 29918, 29906, 29900, 29889, 4397, 29898, 657, 29918, 3332, 29895, 29898, 4905, 29961, 29875, 1402, 5182, 29961, 29875, 1402, 5721, 2925, 29892, 13203, 29892, 29906, 29900, 876, 13, 13, 13, 1678, 1596, 703, 7031, 29899, 29896, 4831, 332, 4135, 613, 9302, 29889, 2378, 29898, 12683, 29918, 3332, 29896, 467, 12676, 3101, 13, 268, 13, 1678, 1596, 703, 29924, 391, 1296, 14621, 537, 613, 9302, 29889, 2378, 29898, 12683, 29918, 29885, 391, 1296, 467, 12676, 3101, 13, 13, 1678, 1596, 703, 29950, 631, 1279, 936, 6652, 749, 29992, 29896, 613, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29896, 467, 12676, 3101, 13, 13, 1678, 1596, 703, 29950, 631, 1279, 936, 6652, 749, 29992, 29945, 613, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29945, 467, 12676, 3101, 13, 13, 1678, 1596, 703, 29950, 631, 1279, 936, 6652, 749, 29992, 29906, 29900, 613, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29906, 29900, 467, 12676, 3101, 13, 1678, 1121, 11759, 9302, 29889, 2378, 29898, 12683, 29918, 3332, 29896, 467, 12676, 3285, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29896, 467, 12676, 3285, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29945, 467, 12676, 3285, 9302, 29889, 2378, 29898, 12683, 29918, 485, 29887, 29918, 29906, 29900, 467, 12676, 3285, 13, 1678, 7442, 29889, 2378, 29898, 12683, 29918, 29885, 391, 1296, 467, 12676, 580, 29962, 13, 268, 13, 1678, 736, 1121, 268, 13, 13, 29871, 13, 13, 1753, 1667, 29898, 25707, 29892, 4299, 29918, 2084, 1125, 13, 13, 1678, 444, 26947, 13373, 24541, 13, 1678, 1243, 29918, 3972, 353, 2897, 29889, 2084, 29889, 7122, 29898, 25707, 29889, 1272, 29918, 2084, 29892, 376, 1688, 1159, 13, 1678, 1243, 29918, 24713, 353, 20035, 29889, 2940, 12924, 29898, 1688, 29918, 3972, 29892, 659, 29918, 9067, 29879, 29898, 25707, 29889, 1272, 29892, 19490, 7607, 29906, 29906, 29946, 29892, 29906, 29906, 29946, 511, 8945, 675, 29922, 5574, 876, 13, 1678, 1243, 29918, 12657, 353, 4842, 305, 29889, 13239, 29889, 1272, 29889, 1469, 10036, 29898, 1688, 29918, 24713, 29892, 9853, 29918, 2311, 29922, 25707, 29889, 16175, 29918, 2311, 29892, 528, 21897, 29922, 8824, 29892, 954, 29918, 1287, 414, 29922, 25707, 29889, 1287, 414, 29892, 12534, 29918, 14834, 29922, 5574, 29892, 5768, 29918, 4230, 29922, 8824, 29897, 13, 1678, 330, 13364, 29918, 546, 29918, 3177, 29922, 29896, 13, 13, 1678, 444, 5896, 12433, 12040, 10343, 13, 1678, 24610, 353, 2254, 29918, 5721, 2925, 29898, 25707, 29889, 1272, 29892, 525, 2719, 29894, 2214, 742, 29111, 29889, 1272, 29918, 3972, 29897, 13, 1678, 21277, 353, 2254, 29918, 29882, 631, 12040, 29898, 25707, 29889, 1272, 29892, 29111, 29889, 1272, 29918, 3972, 29897, 13, 1678, 565, 29111, 29889, 6758, 1275, 376, 29891, 3543, 29899, 29894, 29906, 1115, 13, 4706, 4413, 29892, 903, 353, 679, 29918, 13203, 29898, 29882, 631, 12040, 29892, 1962, 29918, 497, 29918, 18010, 29922, 5574, 29897, 13, 1678, 1683, 29901, 13, 4706, 4413, 353, 1243, 29918, 24713, 29889, 13203, 13, 1678, 29111, 29889, 1949, 29918, 13203, 353, 7431, 29898, 13203, 29897, 13, 13, 13, 1678, 565, 29111, 29889, 6758, 1275, 376, 29891, 3543, 29899, 29894, 29906, 1115, 13, 13, 4706, 3209, 6332, 353, 1105, 615, 3317, 29907, 294, 6332, 29898, 29882, 631, 12040, 29892, 4413, 467, 29883, 6191, 29898, 25707, 29889, 29887, 3746, 29897, 13, 4706, 954, 29918, 29500, 29918, 13203, 353, 7431, 29898, 29882, 631, 12040, 29889, 8336, 1066, 2187, 703, 280, 5989, 5783, 13, 4706, 18177, 353, 679, 29918, 7915, 292, 29898, 29882, 631, 12040, 29892, 376, 735, 1112, 2556, 613, 995, 29922, 25707, 29889, 2312, 29897, 13, 13, 4706, 822, 343, 3543, 29906, 29918, 15728, 272, 29898, 4905, 1125, 13, 9651, 736, 3209, 6332, 29889, 8394, 29918, 22795, 11614, 29898, 4905, 29897, 7503, 29892, 584, 1949, 29918, 29500, 29918, 13203, 29962, 13, 13, 13, 1678, 1904, 353, 2069, 29918, 4299, 29918, 265, 29918, 29887, 3746, 29898, 29887, 13364, 29918, 546, 29918, 3177, 29892, 29111, 29897, 13, 13, 1678, 396, 6230, 5994, 3950, 13, 1678, 5994, 3950, 353, 903, 2622, 29918, 20640, 3950, 29898, 4299, 29892, 29111, 29897, 13, 13, 1678, 396, 2254, 515, 1423, 3149, 565, 5923, 13, 1678, 6576, 353, 903, 1359, 29918, 3198, 3149, 29898, 25707, 29892, 1904, 29892, 5994, 3950, 29892, 4299, 29918, 2084, 29897, 13, 13, 1678, 1959, 272, 353, 343, 3543, 29906, 29918, 15728, 272, 565, 29111, 29889, 6758, 1275, 376, 29891, 3543, 29899, 29894, 29906, 29908, 1683, 14013, 921, 29901, 921, 13, 13, 1678, 1904, 29889, 14513, 580, 13, 1678, 4842, 305, 29889, 1217, 29918, 5105, 580, 13, 13, 1678, 444, 13463, 403, 6811, 13373, 24541, 322, 6314, 1480, 1169, 322, 11073, 13, 1678, 1243, 29918, 4905, 29922, 2636, 13, 1678, 1243, 29918, 5182, 29922, 2636, 13, 1678, 363, 9853, 29918, 13140, 22657, 17987, 29881, 886, 29892, 5182, 29897, 297, 26985, 29898, 1688, 29918, 12657, 1125, 13, 4706, 565, 29111, 29889, 29887, 3746, 338, 451, 6213, 29901, 13, 9651, 8297, 29881, 886, 353, 8297, 29881, 886, 29889, 29883, 6191, 29898, 25707, 29889, 29887, 3746, 29892, 5464, 29918, 1271, 292, 29922, 5574, 29897, 13, 13, 4706, 1962, 29922, 4299, 29898, 17987, 29881, 886, 29897, 13, 4706, 1962, 29922, 15728, 272, 29898, 4905, 29897, 13, 308, 13, 4706, 1243, 29918, 4905, 29889, 21843, 29898, 4905, 29889, 21970, 2141, 25027, 391, 3101, 13, 4706, 1243, 29918, 5182, 29889, 21843, 29898, 5182, 29889, 25027, 391, 3101, 13, 13, 1678, 1243, 29918, 4905, 29922, 9302, 29889, 2378, 29898, 1688, 29918, 4905, 29897, 13, 1678, 1243, 29918, 5182, 29922, 9302, 29889, 2378, 29898, 1688, 29918, 5182, 29897, 13, 13, 1678, 444, 1576, 1959, 272, 16058, 4964, 3317, 3209, 6332, 363, 612, 29949, 3927, 29894, 29906, 13, 1678, 565, 29111, 29889, 6758, 29991, 2433, 29891, 3543, 29899, 29894, 29906, 2396, 13, 4706, 4964, 3317, 29918, 4905, 29922, 798, 29918, 2695, 3317, 29898, 1688, 29918, 4905, 29897, 13, 1678, 1683, 29901, 13, 4706, 4964, 3317, 29918, 4905, 29922, 1688, 29918, 4905, 13, 13, 1678, 444, 20606, 29872, 4737, 10817, 322, 7106, 4522, 29879, 13, 1678, 1904, 29918, 29872, 346, 29922, 2543, 29877, 29918, 29923, 4741, 29898, 2695, 3317, 29918, 4905, 29892, 1688, 29918, 5182, 29897, 13, 1678, 1904, 29918, 29885, 346, 29922, 29924, 4741, 29898, 2695, 3317, 29918, 4905, 29892, 1688, 29918, 5182, 29897, 13, 1678, 1596, 703, 29923, 4741, 29901, 613, 4299, 29918, 29872, 346, 29897, 13, 1678, 1596, 703, 29924, 4741, 29901, 613, 4299, 29918, 29885, 346, 29897, 13, 1678, 1121, 29922, 657, 29918, 2527, 10817, 29898, 25707, 29892, 2695, 3317, 29918, 4905, 29892, 1688, 29918, 5182, 29892, 5721, 2925, 29892, 13203, 29897, 13, 1678, 1121, 29889, 4397, 29898, 4299, 29918, 29872, 346, 29897, 13, 1678, 1121, 29889, 4397, 29898, 4299, 29918, 29885, 346, 29897, 13, 1678, 736, 1121, 13, 13, 13, 13, 13, 361, 4770, 978, 1649, 26359, 1649, 3396, 1649, 1115, 13, 13, 13, 1678, 13812, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1279, 613, 2322, 543, 690, 1212, 29896, 29947, 613, 19995, 29922, 20387, 29931, 29918, 5813, 29903, 29892, 1371, 543, 4299, 11258, 29901, 891, 11393, 7122, 29898, 20387, 29931, 29918, 5813, 29903, 876, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 6758, 613, 2322, 543, 19128, 29899, 296, 14441, 613, 19995, 29922, 3927, 1799, 29918, 5813, 29903, 29892, 1371, 543, 6758, 1134, 29901, 891, 11393, 7122, 29898, 3927, 1799, 29918, 5813, 29903, 876, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 20640, 3950, 613, 2322, 543, 328, 314, 29918, 2232, 5105, 613, 19995, 29922, 14094, 7833, 26664, 1001, 29918, 5813, 29903, 29892, 1371, 543, 6758, 1134, 29901, 891, 11393, 7122, 29898, 14094, 7833, 26664, 1001, 29918, 5813, 29903, 876, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 29212, 613, 2322, 29922, 29896, 29872, 29899, 29945, 29892, 1134, 29922, 7411, 29892, 1371, 543, 11228, 6509, 6554, 310, 5994, 3950, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 7915, 29918, 7099, 388, 613, 2322, 29922, 29900, 29889, 29900, 29892, 1134, 29922, 7411, 29892, 1371, 543, 7915, 20228, 310, 5994, 3950, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1457, 3018, 1312, 613, 1134, 29922, 20054, 29892, 2322, 29922, 5574, 29892, 1371, 543, 2962, 515, 980, 4501, 2214, 29896, 29906, 29914, 326, 5370, 300, 1904, 18177, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1457, 3018, 1312, 29918, 12083, 613, 1134, 29922, 710, 29892, 2322, 29922, 8516, 29892, 1371, 543, 12083, 470, 934, 515, 607, 304, 2254, 278, 3564, 18177, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 8865, 449, 613, 2322, 29922, 29900, 29889, 29900, 29892, 1134, 29922, 7411, 29892, 1371, 543, 1184, 29890, 310, 5768, 449, 363, 3564, 7992, 7546, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1272, 29918, 2987, 358, 362, 613, 1134, 29922, 20054, 29892, 2322, 29922, 5574, 29892, 1371, 543, 5323, 262, 411, 6996, 848, 18765, 362, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1949, 29918, 26495, 29918, 24530, 613, 2322, 29922, 29906, 29900, 29900, 29900, 29900, 29900, 29892, 1134, 29922, 524, 29892, 1371, 543, 4537, 310, 3001, 6576, 304, 7945, 363, 313, 1949, 29918, 16175, 267, 29930, 1949, 29918, 1022, 2878, 29879, 25760, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 2962, 29899, 1022, 2878, 613, 2322, 29922, 29900, 29892, 1134, 29922, 524, 29892, 1371, 543, 11288, 21502, 305, 1353, 313, 1509, 1319, 373, 1791, 5708, 25760, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 16175, 29899, 2311, 613, 2322, 29922, 29906, 29945, 29953, 29892, 1134, 29922, 524, 29892, 1371, 543, 7827, 9853, 2159, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 845, 21897, 29918, 13203, 613, 2322, 29922, 8824, 29892, 1134, 29922, 20054, 29892, 1371, 543, 2713, 21897, 4413, 297, 278, 21277, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 3571, 613, 2322, 29922, 29900, 29892, 1134, 29922, 7411, 29892, 1371, 543, 6295, 615, 2264, 3443, 29901, 278, 6133, 29892, 278, 17649, 304, 697, 29899, 8711, 8025, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 2312, 613, 1134, 29922, 7411, 29892, 2322, 29922, 29900, 29892, 1371, 543, 6185, 388, 3443, 363, 6128, 1279, 936, 4891, 24687, 23157, 13, 1678, 396, 9481, 895, 29914, 29933, 29987, 29928, 448, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 9072, 29899, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 3359, 895, 613, 1134, 29922, 20054, 29892, 2322, 29922, 8824, 29892, 1371, 543, 11403, 897, 29963, 29875, 2008, 3858, 8297, 29881, 886, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 3359, 895, 29918, 14369, 29918, 22198, 613, 1134, 29922, 20054, 29892, 2322, 29922, 8824, 29892, 1371, 543, 11403, 697, 8178, 639, 11916, 2012, 310, 599, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1646, 29920, 1145, 29920, 1358, 613, 1134, 29922, 20054, 29892, 2322, 29922, 8824, 29892, 1371, 543, 11403, 2261, 29920, 29987, 29928, 4666, 1358, 3858, 8297, 29881, 886, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 14968, 29918, 1627, 15933, 29918, 7045, 613, 2322, 29922, 7411, 703, 7192, 4968, 1134, 29922, 7411, 29892, 1371, 543, 4763, 6694, 1250, 15933, 2086, 1156, 445, 1784, 6576, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1509, 29918, 29906, 13801, 613, 2322, 29922, 8824, 29892, 1134, 29922, 20054, 29892, 1371, 543, 11403, 1023, 7992, 15359, 363, 9481, 895, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 13801, 29918, 3993, 29918, 6229, 613, 2322, 29922, 29896, 29900, 29906, 29946, 29892, 1134, 29922, 524, 29892, 1371, 543, 3644, 671, 29918, 29906, 13801, 338, 5852, 29892, 1009, 6426, 9927, 23157, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 29212, 29918, 13801, 613, 2322, 29922, 29896, 29872, 29899, 29941, 29892, 1134, 29922, 7411, 29892, 1371, 543, 21891, 6554, 363, 7992, 15359, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 7915, 29918, 7099, 388, 29918, 13801, 613, 2322, 29922, 29900, 29889, 29900, 29892, 1134, 29922, 7411, 29892, 1371, 543, 7915, 20228, 310, 7992, 15359, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1509, 29918, 13801, 29918, 16175, 12324, 613, 2322, 29922, 8824, 29892, 1134, 29922, 20054, 29892, 1371, 543, 23145, 12324, 7546, 297, 3564, 2343, 1159, 13, 1678, 396, 3630, 29914, 24772, 448, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 9072, 29899, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1272, 613, 2322, 543, 29873, 631, 287, 29899, 326, 5370, 300, 29899, 29906, 29906, 29946, 613, 1371, 543, 333, 310, 278, 8783, 304, 671, 29901, 891, 11393, 7122, 29898, 25832, 8127, 29911, 29918, 5813, 29903, 876, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 5182, 29918, 2311, 613, 2322, 29922, 29906, 29906, 29946, 29892, 1134, 29922, 524, 29892, 1371, 543, 3505, 310, 1967, 1881, 304, 278, 3564, 313, 5182, 19490, 1156, 848, 18765, 362, 25760, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1272, 29899, 24772, 29899, 2917, 613, 1371, 543, 2605, 304, 848, 10898, 343, 8807, 934, 613, 2322, 543, 6995, 1272, 29918, 24772, 29889, 21053, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1272, 29899, 2084, 613, 2322, 29922, 8516, 29892, 1371, 543, 4548, 4019, 4423, 310, 278, 848, 4138, 29892, 565, 6213, 671, 2295, 934, 23157, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1272, 29918, 3972, 613, 2322, 543, 6995, 1272, 29914, 613, 1371, 543, 12924, 6943, 278, 1462, 944, 653, 848, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 4905, 613, 2322, 29922, 8516, 29892, 1371, 543, 2084, 304, 278, 1904, 4138, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 735, 3358, 29918, 333, 613, 2322, 543, 613, 1134, 29922, 710, 29892, 1371, 543, 1170, 1480, 4138, 408, 29901, 714, 29914, 29966, 2154, 978, 20690, 29966, 1256, 29958, 29918, 29966, 735, 3358, 29918, 333, 15513, 960, 4069, 29892, 1518, 29885, 29918, 333, 29922, 2230, 1159, 13, 1678, 396, 4522, 29914, 791, 448, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1188, 29918, 29888, 7971, 613, 2322, 29922, 29896, 29900, 29900, 29892, 1134, 29922, 524, 29892, 1371, 543, 3403, 1432, 1480, 29918, 29888, 7971, 9853, 267, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 791, 29918, 29888, 7971, 613, 2322, 29922, 29945, 29892, 1134, 29922, 524, 29892, 1371, 543, 7211, 403, 1432, 659, 29918, 29888, 7971, 21502, 12168, 313, 19499, 278, 937, 29871, 29896, 29900, 322, 1833, 29871, 29896, 29900, 25760, 13, 1678, 396, 11080, 918, 448, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 2683, 9072, 489, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1287, 414, 613, 2322, 29922, 29906, 29892, 1134, 29922, 524, 29892, 1371, 543, 4537, 310, 848, 8363, 17162, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 26776, 613, 2322, 29922, 8516, 29892, 1134, 29922, 524, 29892, 1371, 543, 26776, 363, 2847, 5281, 6694, 29889, 16521, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 29887, 3746, 613, 2322, 29922, 29900, 29892, 1134, 29922, 524, 29892, 1371, 543, 29954, 7056, 1178, 304, 671, 23157, 13, 1678, 444, 15600, 29924, 448, 2683, 2683, 2683, 2683, 2683, 29899, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 2872, 804, 613, 4381, 29922, 29900, 29892, 1853, 29922, 524, 29892, 8477, 2433, 1332, 1979, 304, 671, 15600, 29924, 470, 451, 1495, 13, 13, 13, 1678, 835, 4522, 29879, 448, 2683, 2683, 2683, 2683, 2683, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 4548, 978, 613, 4381, 2433, 19128, 29899, 296, 14441, 742, 1853, 29922, 710, 29892, 8477, 543, 1170, 310, 1904, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 1022, 2878, 29896, 613, 4381, 29922, 29896, 29900, 29892, 1853, 29922, 524, 29892, 8477, 543, 6730, 21502, 305, 304, 14707, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 449, 29918, 12083, 29896, 613, 4381, 29922, 8516, 29892, 1853, 29922, 710, 29892, 8477, 543, 2605, 304, 1904, 1423, 3149, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 449, 29918, 12083, 29906, 613, 4381, 29922, 8516, 29892, 1853, 29922, 710, 29892, 8477, 543, 2605, 304, 1904, 1423, 3149, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 449, 29918, 12083, 29941, 613, 4381, 29922, 8516, 29892, 1853, 29922, 710, 29892, 8477, 543, 2605, 304, 1904, 1423, 3149, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 449, 29918, 12083, 29946, 613, 4381, 29922, 8516, 29892, 1853, 29922, 710, 29892, 8477, 543, 2605, 304, 1904, 1423, 3149, 1159, 13, 1678, 13812, 29889, 1202, 29918, 23516, 703, 489, 449, 29918, 12083, 29945, 613, 4381, 29922, 8516, 29892, 1853, 29922, 710, 29892, 8477, 543, 2605, 304, 1904, 1423, 3149, 1159, 13, 13, 13, 1678, 29111, 29922, 16680, 29889, 5510, 29918, 5085, 580, 13, 1678, 565, 29111, 29889, 1272, 29918, 2084, 338, 6213, 29901, 13, 4706, 29111, 29889, 1272, 29918, 24772, 353, 2254, 29918, 2917, 29898, 25707, 29889, 1272, 29918, 24772, 29918, 2917, 29897, 13, 4706, 29111, 29889, 1272, 29918, 2084, 353, 29111, 29889, 1272, 29918, 24772, 29961, 25707, 29889, 1272, 29962, 13, 13, 1678, 10748, 29922, 2636, 13, 1678, 444, 29923, 4387, 1218, 17212, 373, 29871, 29945, 1423, 9748, 13, 1678, 10748, 29889, 4397, 29898, 3396, 29898, 25707, 29892, 25707, 29889, 449, 29918, 12083, 29896, 876, 13, 1678, 10748, 29889, 4397, 29898, 3396, 29898, 25707, 29892, 25707, 29889, 449, 29918, 12083, 29906, 876, 13, 1678, 10748, 29889, 4397, 29898, 3396, 29898, 25707, 29892, 25707, 29889, 449, 29918, 12083, 29941, 876, 13, 1678, 10748, 29889, 4397, 29898, 3396, 29898, 25707, 29892, 25707, 29889, 449, 29918, 12083, 29946, 876, 13, 1678, 10748, 29889, 4397, 29898, 3396, 29898, 25707, 29892, 25707, 29889, 449, 29918, 12083, 29945, 876, 13, 1678, 10748, 29922, 9302, 29889, 2378, 29898, 20756, 29892, 29881, 1853, 2433, 7411, 29953, 29946, 1495, 13, 1678, 269, 3496, 420, 29922, 25707, 29889, 4548, 978, 13, 1678, 7442, 29889, 29879, 485, 300, 486, 29898, 29879, 3496, 420, 29892, 20756, 29892, 19200, 543, 15543, 29945, 29888, 613, 28552, 543, 29892, 1159, 13, 13, 13, 2 ]
kubespawner/clients.py
moskiGithub/spawner_test
0
13678
<reponame>moskiGithub/spawner_test """Shared clients for kubernetes avoids creating multiple kubernetes client objects, each of which spawns an unused max-size thread pool """ from unittest.mock import Mock import weakref import kubernetes.client from kubernetes.client import api_client # FIXME: remove when instantiating a kubernetes client # doesn't create N-CPUs threads unconditionally. # monkeypatch threadpool in kubernetes api_client # to avoid instantiating ThreadPools. # This is known to work for kubernetes-4.0 # and may need updating with later kubernetes clients _dummy_pool = Mock() api_client.ThreadPool = lambda *args, **kwargs: _dummy_pool _client_cache = {} def shared_client(ClientType, *args, **kwargs): """Return a single shared kubernetes client instance A weak reference to the instance is cached, so that concurrent calls to shared_client will all return the same instance until all references to the client are cleared. """ kwarg_key = tuple((key, kwargs[key]) for key in sorted(kwargs)) cache_key = (ClientType, args, kwarg_key) client = None if cache_key in _client_cache: # resolve cached weakref # client can still be None after this! client = _client_cache[cache_key]() if client is None: Client = getattr(kubernetes.client, ClientType) client = Client(*args, **kwargs) # cache weakref so that clients can be garbage collected _client_cache[cache_key] = weakref.ref(client) return client
[ 1, 529, 276, 1112, 420, 29958, 7681, 1984, 29954, 2985, 29914, 1028, 1450, 1089, 29918, 1688, 13, 15945, 29908, 21741, 13154, 363, 413, 17547, 30004, 13, 30004, 13, 485, 3398, 29879, 4969, 2999, 413, 17547, 3132, 3618, 11167, 13, 4204, 310, 607, 29178, 29879, 385, 443, 3880, 4236, 29899, 2311, 3244, 11565, 30004, 13, 15945, 19451, 13, 30004, 13, 3166, 443, 27958, 29889, 17640, 1053, 26297, 30004, 13, 5215, 8062, 999, 30004, 13, 30004, 13, 5215, 413, 17547, 29889, 4645, 30004, 13, 3166, 413, 17547, 29889, 4645, 1053, 7882, 29918, 4645, 30004, 13, 30004, 13, 29937, 383, 6415, 2303, 29901, 3349, 746, 13213, 1218, 263, 413, 17547, 3132, 30004, 13, 29937, 1838, 29915, 29873, 1653, 405, 29899, 6271, 15922, 9717, 443, 16122, 635, 22993, 13, 29937, 1601, 446, 1478, 905, 3244, 10109, 297, 413, 17547, 7882, 29918, 4645, 30004, 13, 29937, 304, 4772, 13213, 1218, 10480, 29925, 8789, 22993, 13, 29937, 910, 338, 2998, 304, 664, 363, 413, 17547, 29899, 29946, 29889, 29900, 30004, 13, 29937, 322, 1122, 817, 13271, 411, 2678, 413, 17547, 13154, 30004, 13, 29918, 29881, 11770, 29918, 10109, 353, 26297, 26471, 13, 2754, 29918, 4645, 29889, 23574, 353, 14013, 334, 5085, 29892, 3579, 19290, 29901, 903, 29881, 11770, 29918, 10109, 30004, 13, 30004, 13, 29918, 4645, 29918, 8173, 353, 6571, 30004, 13, 30004, 13, 30004, 13, 1753, 7258, 29918, 4645, 29898, 4032, 1542, 29892, 334, 5085, 29892, 3579, 19290, 1125, 30004, 13, 1678, 9995, 11609, 263, 2323, 7258, 413, 17547, 3132, 2777, 30004, 13, 30004, 13, 1678, 319, 8062, 3407, 304, 278, 2777, 338, 22152, 11167, 13, 1678, 577, 393, 21984, 5717, 304, 7258, 29918, 4645, 30004, 13, 1678, 674, 599, 736, 278, 1021, 2777, 2745, 30004, 13, 1678, 599, 9282, 304, 278, 3132, 526, 24639, 22993, 13, 1678, 9995, 30004, 13, 1678, 9049, 1191, 29918, 1989, 353, 18761, 3552, 1989, 29892, 9049, 5085, 29961, 1989, 2314, 363, 1820, 297, 12705, 29898, 19290, 876, 30004, 13, 1678, 7090, 29918, 1989, 353, 313, 4032, 1542, 29892, 6389, 29892, 9049, 1191, 29918, 1989, 8443, 13, 1678, 3132, 353, 6213, 30004, 13, 1678, 565, 7090, 29918, 1989, 297, 903, 4645, 29918, 8173, 29901, 30004, 13, 4706, 396, 8814, 22152, 8062, 999, 30004, 13, 4706, 396, 3132, 508, 1603, 367, 6213, 1156, 445, 29991, 30004, 13, 4706, 3132, 353, 903, 4645, 29918, 8173, 29961, 8173, 29918, 1989, 29962, 26471, 13, 30004, 13, 1678, 565, 3132, 338, 6213, 29901, 30004, 13, 4706, 12477, 353, 679, 5552, 29898, 29895, 17547, 29889, 4645, 29892, 12477, 1542, 8443, 13, 4706, 3132, 353, 12477, 10456, 5085, 29892, 3579, 19290, 8443, 13, 4706, 396, 7090, 8062, 999, 577, 393, 13154, 508, 367, 25861, 16531, 30004, 13, 4706, 903, 4645, 29918, 8173, 29961, 8173, 29918, 1989, 29962, 353, 8062, 999, 29889, 999, 29898, 4645, 8443, 13, 1678, 736, 3132, 30004, 13, 2 ]
classifiers/keyword_selection/datasets/loaders.py
topicaxis/trained-models
1
134709
import csv from sklearn.model_selection import train_test_split from classifiers.datasets import TrainTestDataset, Dataset class KeywordSelectionClassifierDatasetLoader(object): """Keyword selection classifier dataset loader object""" def __init__(self, dataset_file): """Create a newKeywordSelectionClassifierDatasetLoader object :param str dataset_file: the path to the dataset file """ self._dataset_file = dataset_file def _load_dataset(self): keywords = [] is_valid = [] with open(self._dataset_file) as f: reader = csv.reader(f, delimiter=',', quotechar='"') next(reader) # skip the header for row in reader: keywords.append(row[0]) is_valid.append(int(row[1])) return keywords, is_valid def create_train_test_dataset(self, test_size=0.3): """Create a training/testing dataset :param float test_size: the test size percentage in the 0-1 value range :rtype: TrainTestDataset :return: the training/testing dataset object """ keywords, is_valid = self._load_dataset() train_keywords, test_keywords, train_is_valid, test_is_valid = \ train_test_split(keywords, is_valid, test_size=test_size, random_state=42, stratify=is_valid) return TrainTestDataset( train=Dataset(data=train_keywords, targets=train_is_valid), test=Dataset(data=test_keywords, targets=test_is_valid) )
[ 1, 1053, 11799, 13, 13, 3166, 2071, 19668, 29889, 4299, 29918, 21731, 1053, 7945, 29918, 1688, 29918, 5451, 13, 13, 3166, 770, 14903, 29889, 14538, 1691, 1053, 28186, 3057, 16390, 24541, 29892, 13373, 24541, 13, 13, 13, 1990, 7670, 1742, 15097, 2385, 3709, 16390, 24541, 10036, 29898, 3318, 1125, 13, 1678, 9995, 2558, 1742, 9262, 770, 3709, 8783, 23466, 1203, 15945, 29908, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 8783, 29918, 1445, 1125, 13, 4706, 9995, 4391, 263, 716, 2558, 1742, 15097, 2385, 3709, 16390, 24541, 10036, 1203, 13, 13, 4706, 584, 3207, 851, 8783, 29918, 1445, 29901, 278, 2224, 304, 278, 8783, 934, 13, 4706, 9995, 13, 4706, 1583, 3032, 24713, 29918, 1445, 353, 8783, 29918, 1445, 13, 13, 1678, 822, 903, 1359, 29918, 24713, 29898, 1311, 1125, 13, 4706, 29361, 353, 5159, 13, 4706, 338, 29918, 3084, 353, 5159, 13, 13, 4706, 411, 1722, 29898, 1311, 3032, 24713, 29918, 1445, 29897, 408, 285, 29901, 13, 9651, 9591, 353, 11799, 29889, 16950, 29898, 29888, 29892, 28552, 29922, 742, 742, 14978, 3090, 2433, 29908, 1495, 13, 9651, 2446, 29898, 16950, 29897, 29871, 396, 14383, 278, 4839, 13, 9651, 363, 1948, 297, 9591, 29901, 13, 18884, 29361, 29889, 4397, 29898, 798, 29961, 29900, 2314, 13, 18884, 338, 29918, 3084, 29889, 4397, 29898, 524, 29898, 798, 29961, 29896, 12622, 13, 13, 4706, 736, 29361, 29892, 338, 29918, 3084, 13, 13, 1678, 822, 1653, 29918, 14968, 29918, 1688, 29918, 24713, 29898, 1311, 29892, 1243, 29918, 2311, 29922, 29900, 29889, 29941, 1125, 13, 4706, 9995, 4391, 263, 6694, 29914, 13424, 8783, 13, 13, 4706, 584, 3207, 5785, 1243, 29918, 2311, 29901, 278, 1243, 2159, 19649, 297, 278, 29871, 29900, 29899, 29896, 995, 3464, 13, 4706, 584, 29878, 1853, 29901, 28186, 3057, 16390, 24541, 13, 4706, 584, 2457, 29901, 278, 6694, 29914, 13424, 8783, 1203, 13, 4706, 9995, 13, 4706, 29361, 29892, 338, 29918, 3084, 353, 1583, 3032, 1359, 29918, 24713, 580, 13, 13, 4706, 7945, 29918, 1989, 9303, 29892, 1243, 29918, 1989, 9303, 29892, 7945, 29918, 275, 29918, 3084, 29892, 1243, 29918, 275, 29918, 3084, 353, 320, 13, 9651, 7945, 29918, 1688, 29918, 5451, 29898, 1989, 9303, 29892, 338, 29918, 3084, 29892, 1243, 29918, 2311, 29922, 1688, 29918, 2311, 29892, 13, 462, 632, 4036, 29918, 3859, 29922, 29946, 29906, 29892, 26742, 1598, 29922, 275, 29918, 3084, 29897, 13, 13, 4706, 736, 28186, 3057, 16390, 24541, 29898, 13, 9651, 7945, 29922, 16390, 24541, 29898, 1272, 29922, 14968, 29918, 1989, 9303, 29892, 22525, 29922, 14968, 29918, 275, 29918, 3084, 511, 13, 9651, 1243, 29922, 16390, 24541, 29898, 1272, 29922, 1688, 29918, 1989, 9303, 29892, 22525, 29922, 1688, 29918, 275, 29918, 3084, 29897, 13, 4706, 1723, 13, 2 ]
tensorflowpractice/MNIST_data/progressbar.py
nifannn/MachineLearningNotes
1
124421
import sys import time class ProgressBar(object): """ProgressBar""" def __init__(self, progressname = 'Progress',total = 100, current = 0, flushfreq = 0.001): self.total = total self.current = current self.progressname = progressname self.flushfreq = flushfreq @property def percentage(self): return int(self.current * 100 // self.total) def __len__(self): return self.percentage // 2 @property def content(self): return self.progressname + ': [' + '#' * len(self) + '.' * (50 - len(self)) + '] ' + str(self.percentage) + '%' +'\r' def show(self): sys.stdout.write(' ' * len(self.content) + '\r') sys.stdout.flush() sys.stdout.write(self.content) sys.stdout.flush() time.sleep(self.flushfreq) def present(self): print(self.content) def modify(self, newcurrent, newtotal): self.total = newtotal self.current = newcurrent def update(self, newcurrent): self.current = newcurrent self.show() def increase(self, increment = 1): self.current = self.current + increment self.show() def restart(self): self.current = 0
[ 1, 1053, 10876, 13, 5215, 931, 13, 13, 1990, 20018, 4297, 29898, 3318, 1125, 13, 12, 15945, 29908, 14470, 4297, 15945, 29908, 13, 12, 1753, 4770, 2344, 12035, 1311, 29892, 6728, 978, 353, 525, 14470, 742, 7827, 353, 29871, 29896, 29900, 29900, 29892, 1857, 353, 29871, 29900, 29892, 28371, 29888, 7971, 353, 29871, 29900, 29889, 29900, 29900, 29896, 1125, 13, 12, 12, 1311, 29889, 7827, 353, 3001, 13, 12, 12, 1311, 29889, 3784, 353, 1857, 13, 12, 12, 1311, 29889, 18035, 978, 353, 6728, 978, 13, 12, 12, 1311, 29889, 23126, 29888, 7971, 353, 28371, 29888, 7971, 13, 13, 12, 29992, 6799, 13, 12, 1753, 19649, 29898, 1311, 1125, 13, 12, 12, 2457, 938, 29898, 1311, 29889, 3784, 334, 29871, 29896, 29900, 29900, 849, 1583, 29889, 7827, 29897, 13, 13, 12, 1753, 4770, 2435, 12035, 1311, 1125, 13, 12, 12, 2457, 1583, 29889, 25376, 482, 849, 29871, 29906, 13, 12, 12, 13, 12, 29992, 6799, 13, 12, 1753, 2793, 29898, 1311, 1125, 13, 12, 12, 2457, 1583, 29889, 18035, 978, 718, 525, 29901, 29871, 6024, 718, 16321, 29915, 334, 7431, 29898, 1311, 29897, 718, 525, 6169, 334, 313, 29945, 29900, 448, 7431, 29898, 1311, 876, 718, 525, 29962, 29871, 525, 718, 851, 29898, 1311, 29889, 25376, 482, 29897, 718, 14210, 29915, 718, 12764, 29878, 29915, 13, 13, 12, 1753, 1510, 29898, 1311, 1125, 13, 12, 12, 9675, 29889, 25393, 29889, 3539, 877, 525, 334, 7431, 29898, 1311, 29889, 3051, 29897, 718, 11297, 29878, 1495, 13, 12, 12, 9675, 29889, 25393, 29889, 23126, 580, 13, 12, 12, 9675, 29889, 25393, 29889, 3539, 29898, 1311, 29889, 3051, 29897, 13, 12, 12, 9675, 29889, 25393, 29889, 23126, 580, 13, 12, 12, 2230, 29889, 17059, 29898, 1311, 29889, 23126, 29888, 7971, 29897, 13, 13, 12, 1753, 2198, 29898, 1311, 1125, 13, 12, 12, 2158, 29898, 1311, 29889, 3051, 29897, 13, 13, 12, 1753, 6623, 29898, 1311, 29892, 716, 3784, 29892, 716, 7827, 1125, 13, 12, 12, 1311, 29889, 7827, 353, 716, 7827, 13, 12, 12, 1311, 29889, 3784, 353, 716, 3784, 13, 13, 12, 1753, 2767, 29898, 1311, 29892, 716, 3784, 1125, 13, 12, 12, 1311, 29889, 3784, 353, 716, 3784, 13, 12, 12, 1311, 29889, 4294, 580, 13, 13, 12, 1753, 7910, 29898, 1311, 29892, 11924, 353, 29871, 29896, 1125, 13, 12, 12, 1311, 29889, 3784, 353, 1583, 29889, 3784, 718, 11924, 13, 12, 12, 1311, 29889, 4294, 580, 13, 13, 12, 1753, 10715, 29898, 1311, 1125, 13, 12, 12, 1311, 29889, 3784, 353, 29871, 29900, 13, 2 ]
utils/dataflow_utils.py
CSuppan/two-shot-brdf-shape
0
186056
<reponame>CSuppan/two-shot-brdf-shape # ----------------------------------------------------------------------- # Copyright (c) 2020, NVIDIA Corporation. All rights reserved. # # This work is made available # under the Nvidia Source Code License (1-way Commercial). # # Official Implementation of the CVPR2020 Paper # Two-shot Spatially-varying BRDF and Shape Estimation # <NAME>, <NAME>, <NAME>, <NAME>, <NAME> # ----------------------------------------------------------------------- import glob import os from typing import Optional import cv2 import numpy as np import pyexr from utils.config import * def apply_mask( img: np.ndarray, mask: np.ndarray, undefined: np.ndarray = np.asarray([0, 0, 0]) ): return np.where(mask == 1, img, undefined) def hwcToChw(hwc: np.ndarray) -> np.ndarray: return np.moveaxis(hwc, -1, 0) def chwToHwc(chw: np.ndarray) -> np.ndarray: return np.moveaxis(chw, 0, -1) def _is_hdr(path: str) -> bool: _, ext = os.path.splitext(path) return ext == ".exr" or ext == ".hdr" def write_image(path: str, img: np.ndarray, gray: bool = False): hdr = _is_hdr(path) if not hdr: img = (img * 255).astype(np.uint8) if not gray: img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) cv2.imwrite(path, img) def read_image(path: str, gray: bool = False) -> np.ndarray: hdr = _is_hdr(path) # Read image if hdr: img = pyexr.open(path).get() else: img = cv2.imread(path, cv2.IMREAD_UNCHANGED) if not gray: # Ensure correct color space img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) if gray: # Ensure single channel for gray scale img = ensureSingleChannel(img) if hdr: # Always return float return img.astype(np.float32) else: return img.astype(np.float32) / 255 def save( data: np.ndarray, save_path: str, grayscale: bool = False, alpha: bool = False ): """Saves the data to a specified path and handles all required extensions Args: img: The numpy RGB or Grayscale float image with range 0 to 1. save_path: The path the image is saved to. grayscale: True if the image is in grayscale, False if RGB. alpha: True if the image contains transparency, False if opaque """ hdr = _is_hdr(save_path) npy = os.path.splitext(save_path)[1] == ".npy" if hdr: pyexr.write(save_path, data) elif npy: np.save(save_path, data) else: asUint8 = (data * 255).astype(np.uint8) if alpha: if grayscale: print("ALPHA AND GRAYSCALE IS NOT FULLY SUPPORTED") proc = cv2.COLOR_RGBA2BGRA elif not alpha and grayscale: proc = cv2.COLOR_GRAY2BGR else: proc = cv2.COLOR_RGB2BGR toSave = cv2.cvtColor(asUint8, proc) cv2.imwrite(save_path, toSave) def ensureSingleChannel(x: np.ndarray) -> np.ndarray: ret = x if len(x.shape) > 2: ret = ret[:, :, 0] return np.expand_dims(ret, -1) def compressDepth( d: np.ndarray, sigma: float = 2.5, epsilon: float = 0.7 ) -> np.ndarray: """Compresses the full depth range to a 0 to 1 range. The possible depth range is modelled by sigma and epsilon and with sigma=2.5 and epsilon=0.7 it is between 0.17 and 1.4. """ d[d <= 0] = 1e-6 return np.clip((-epsilon * d + 1) / (2 * sigma * d), 0, 1) def uncompressDepth( d: np.ndarray, sigma: float = 2.5, epsilon: float = 0.7 ) -> np.ndarray: """From 0-1 values to full depth range. The possible depth range is modelled by sigma and epsilon and with sigma=2.5 and epsilon=0.7 it is between 0.17 and 1.4. """ return 1 / (2 * sigma * d + epsilon) def sRGBToLinear(x: np.ndarray) -> np.ndarray: return np.where(x >= 0.04045, ((x + 0.055) / 1.055) ** 2.4, x / 12.92) def linearTosRGB(x: np.ndarray) -> np.ndarray: return np.where(x >= 0.0031308, 1.055 * np.power(x, 1.0 / 2.4) - 0.055, x * 12.92) def convert_luminance(x: np.ndarray) -> np.ndarray: return 0.212671 * x[:, :, 0] + 0.71516 * x[:, :, 1] + 0.072169 * x[:, :, 2] def center_weight(x): def smoothStep(x, edge0=0.0, edge1=1.0): x = np.clip((x - edge0) / (edge1 - edge0), 0.0, 1.0) return x * x * x * (x * (x * 6 - 15) + 10) idx = np.argwhere(np.ones_like(x)) idxs = np.reshape(idx, (x.shape[0], x.shape[1], 2)) center_dist = np.linalg.norm( idxs - np.array([x.shape[0] / 2, x.shape[1] / 2]), axis=2 ) return 1 - smoothStep(center_dist / x.shape[1] * 2) def compute_avg_luminance(x: np.ndarray) -> np.ndarray: L = convert_luminance(x) L = L * center_weight(L) avgL1 = np.average(L, axis=(0, 1)) return avgL1 def compute_ev100_from_avg_luminance(avgL): return np.log2(avgL * 100.0 / 12.5) # or 12.7 def convert_ev100_to_exp(ev100): maxL = 1.2 * np.power(2.0, ev100) return np.clip(1.0 / maxL, 1e-7, None) def calculate_ev100_from_metadata(aperture_f: float, shutter_s: float, iso: int): ev_s = np.log2((aperture_f * aperture_f) / shutter_s) ev_100 = ev_s - np.log2(iso / 100) return ev_100 def compute_auto_exp(x: np.ndarray, clip: bool = True) -> np.ndarray: avgL = np.clip(compute_avg_luminance(x), 1e-5, None) ev100 = compute_ev100_from_avg_luminance(avgL) exp = convert_ev100_to_exp(ev100) # This can become an invalid number. why? exposed = x * exp if clip: exposed = np.clip(exposed, 0.0, 1.0) return exposed, exp
[ 1, 529, 276, 1112, 420, 29958, 29907, 20182, 273, 29914, 10184, 29899, 8962, 29899, 1182, 2176, 29899, 12181, 13, 29937, 448, 2683, 2683, 2683, 2683, 22158, 13, 29937, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29906, 29900, 29892, 405, 13044, 10764, 15025, 29889, 2178, 10462, 21676, 29889, 13, 29937, 13, 29937, 910, 664, 338, 1754, 3625, 13, 29937, 1090, 278, 405, 28584, 7562, 5920, 19245, 313, 29896, 29899, 1582, 422, 1050, 1455, 467, 13, 29937, 13, 29937, 10564, 1954, 14607, 310, 278, 25778, 10593, 29906, 29900, 29906, 29900, 349, 7202, 13, 29937, 7803, 29899, 8962, 1706, 15238, 368, 29899, 29894, 653, 292, 25185, 4037, 322, 1383, 4085, 2661, 7715, 13, 29937, 529, 5813, 10202, 529, 5813, 10202, 529, 5813, 10202, 529, 5813, 10202, 529, 5813, 29958, 13, 29937, 448, 2683, 2683, 2683, 2683, 22158, 13, 13, 5215, 13149, 13, 5215, 2897, 13, 3166, 19229, 1053, 28379, 13, 13, 5215, 13850, 29906, 13, 5215, 12655, 408, 7442, 13, 5215, 11451, 735, 29878, 13, 13, 3166, 3667, 29879, 29889, 2917, 1053, 334, 13, 13, 13, 1753, 3394, 29918, 13168, 29898, 13, 1678, 10153, 29901, 7442, 29889, 299, 2378, 29892, 11105, 29901, 7442, 29889, 299, 2378, 29892, 7580, 29901, 7442, 29889, 299, 2378, 353, 7442, 29889, 294, 2378, 4197, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 2314, 13, 1125, 13, 1678, 736, 7442, 29889, 3062, 29898, 13168, 1275, 29871, 29896, 29892, 10153, 29892, 7580, 29897, 13, 13, 13, 1753, 298, 29893, 29883, 1762, 1451, 29893, 29898, 26828, 29883, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 736, 7442, 29889, 11631, 8990, 29898, 26828, 29883, 29892, 448, 29896, 29892, 29871, 29900, 29897, 13, 13, 13, 1753, 521, 29893, 1762, 29950, 29893, 29883, 29898, 305, 29893, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 736, 7442, 29889, 11631, 8990, 29898, 305, 29893, 29892, 29871, 29900, 29892, 448, 29896, 29897, 13, 13, 13, 1753, 903, 275, 29918, 29882, 7707, 29898, 2084, 29901, 851, 29897, 1599, 6120, 29901, 13, 1678, 17117, 1294, 353, 2897, 29889, 2084, 29889, 23579, 568, 486, 29898, 2084, 29897, 13, 1678, 736, 1294, 1275, 11393, 735, 29878, 29908, 470, 1294, 1275, 11393, 29882, 7707, 29908, 13, 13, 13, 1753, 2436, 29918, 3027, 29898, 2084, 29901, 851, 29892, 10153, 29901, 7442, 29889, 299, 2378, 29892, 16749, 29901, 6120, 353, 7700, 1125, 13, 1678, 298, 7707, 353, 903, 275, 29918, 29882, 7707, 29898, 2084, 29897, 13, 13, 1678, 565, 451, 298, 7707, 29901, 13, 4706, 10153, 353, 313, 2492, 334, 29871, 29906, 29945, 29945, 467, 579, 668, 29898, 9302, 29889, 13470, 29947, 29897, 13, 1678, 565, 451, 16749, 29901, 13, 4706, 10153, 353, 13850, 29906, 29889, 11023, 29873, 3306, 29898, 2492, 29892, 13850, 29906, 29889, 15032, 1955, 29918, 28212, 29906, 29933, 14345, 29897, 13, 13, 1678, 13850, 29906, 29889, 326, 3539, 29898, 2084, 29892, 10153, 29897, 13, 13, 13, 1753, 1303, 29918, 3027, 29898, 2084, 29901, 851, 29892, 16749, 29901, 6120, 353, 7700, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 298, 7707, 353, 903, 275, 29918, 29882, 7707, 29898, 2084, 29897, 13, 1678, 396, 7523, 1967, 13, 1678, 565, 298, 7707, 29901, 13, 4706, 10153, 353, 11451, 735, 29878, 29889, 3150, 29898, 2084, 467, 657, 580, 13, 1678, 1683, 29901, 13, 4706, 10153, 353, 13850, 29906, 29889, 326, 949, 29898, 2084, 29892, 13850, 29906, 29889, 7833, 16310, 29918, 3904, 3210, 24336, 29928, 29897, 13, 4706, 565, 451, 16749, 29901, 29871, 396, 22521, 545, 1959, 2927, 2913, 13, 9651, 10153, 353, 13850, 29906, 29889, 11023, 29873, 3306, 29898, 2492, 29892, 13850, 29906, 29889, 15032, 1955, 29918, 29933, 14345, 29906, 28212, 29897, 13, 13, 1678, 565, 16749, 29901, 29871, 396, 22521, 545, 2323, 8242, 363, 16749, 6287, 13, 4706, 10153, 353, 9801, 15771, 13599, 29898, 2492, 29897, 13, 13, 1678, 565, 298, 7707, 29901, 29871, 396, 29849, 736, 5785, 13, 4706, 736, 10153, 29889, 579, 668, 29898, 9302, 29889, 7411, 29941, 29906, 29897, 13, 1678, 1683, 29901, 13, 4706, 736, 10153, 29889, 579, 668, 29898, 9302, 29889, 7411, 29941, 29906, 29897, 847, 29871, 29906, 29945, 29945, 13, 13, 13, 1753, 4078, 29898, 13, 1678, 848, 29901, 7442, 29889, 299, 2378, 29892, 4078, 29918, 2084, 29901, 851, 29892, 16749, 7052, 29901, 6120, 353, 7700, 29892, 15595, 29901, 6120, 353, 7700, 13, 1125, 13, 1678, 9995, 29903, 5989, 278, 848, 304, 263, 6790, 2224, 322, 17766, 599, 3734, 17752, 13, 1678, 826, 3174, 29901, 13, 4706, 10153, 29901, 450, 12655, 390, 7210, 470, 18956, 7052, 5785, 1967, 411, 3464, 29871, 29900, 304, 29871, 29896, 29889, 13, 4706, 4078, 29918, 2084, 29901, 450, 2224, 278, 1967, 338, 7160, 304, 29889, 13, 4706, 16749, 7052, 29901, 5852, 565, 278, 1967, 338, 297, 16749, 7052, 29892, 7700, 565, 390, 7210, 29889, 13, 4706, 15595, 29901, 5852, 565, 278, 1967, 3743, 1301, 862, 3819, 29892, 7700, 565, 1015, 19772, 29871, 13, 1678, 9995, 13, 1678, 298, 7707, 353, 903, 275, 29918, 29882, 7707, 29898, 7620, 29918, 2084, 29897, 13, 1678, 302, 2272, 353, 2897, 29889, 2084, 29889, 23579, 568, 486, 29898, 7620, 29918, 2084, 9601, 29896, 29962, 1275, 11393, 29876, 2272, 29908, 13, 1678, 565, 298, 7707, 29901, 13, 4706, 11451, 735, 29878, 29889, 3539, 29898, 7620, 29918, 2084, 29892, 848, 29897, 13, 1678, 25342, 302, 2272, 29901, 13, 4706, 7442, 29889, 7620, 29898, 7620, 29918, 2084, 29892, 848, 29897, 13, 1678, 1683, 29901, 13, 4706, 408, 29965, 524, 29947, 353, 313, 1272, 334, 29871, 29906, 29945, 29945, 467, 579, 668, 29898, 9302, 29889, 13470, 29947, 29897, 13, 4706, 565, 15595, 29901, 13, 9651, 565, 16749, 7052, 29901, 13, 18884, 1596, 703, 1964, 29925, 15715, 5300, 402, 4717, 21554, 5454, 1307, 8519, 6058, 383, 3299, 29979, 317, 4897, 15082, 3352, 1159, 13, 9651, 9580, 353, 13850, 29906, 29889, 15032, 1955, 29918, 29934, 29954, 5688, 29906, 29933, 29954, 4717, 13, 4706, 25342, 451, 15595, 322, 16749, 7052, 29901, 13, 9651, 9580, 353, 13850, 29906, 29889, 15032, 1955, 29918, 29954, 22800, 29906, 29933, 14345, 13, 4706, 1683, 29901, 13, 9651, 9580, 353, 13850, 29906, 29889, 15032, 1955, 29918, 28212, 29906, 29933, 14345, 13, 13, 4706, 304, 11371, 353, 13850, 29906, 29889, 11023, 29873, 3306, 29898, 294, 29965, 524, 29947, 29892, 9580, 29897, 13, 13, 4706, 13850, 29906, 29889, 326, 3539, 29898, 7620, 29918, 2084, 29892, 304, 11371, 29897, 13, 13, 13, 1753, 9801, 15771, 13599, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 3240, 353, 921, 13, 1678, 565, 7431, 29898, 29916, 29889, 12181, 29897, 1405, 29871, 29906, 29901, 13, 4706, 3240, 353, 3240, 7503, 29892, 584, 29892, 29871, 29900, 29962, 13, 13, 1678, 736, 7442, 29889, 18837, 29918, 6229, 29879, 29898, 2267, 29892, 448, 29896, 29897, 13, 13, 13, 1753, 27122, 8498, 386, 29898, 13, 1678, 270, 29901, 7442, 29889, 299, 2378, 29892, 269, 2934, 29901, 5785, 353, 29871, 29906, 29889, 29945, 29892, 321, 3232, 29901, 5785, 353, 29871, 29900, 29889, 29955, 13, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 9995, 1523, 2139, 267, 278, 2989, 10809, 3464, 304, 263, 29871, 29900, 304, 29871, 29896, 3464, 29889, 450, 1950, 10809, 3464, 13, 1678, 338, 1904, 839, 491, 269, 2934, 322, 321, 3232, 322, 411, 269, 2934, 29922, 29906, 29889, 29945, 322, 321, 3232, 29922, 29900, 29889, 29955, 13, 1678, 372, 338, 1546, 29871, 29900, 29889, 29896, 29955, 322, 29871, 29896, 29889, 29946, 29889, 13, 1678, 9995, 13, 1678, 270, 29961, 29881, 5277, 29871, 29900, 29962, 353, 29871, 29896, 29872, 29899, 29953, 13, 1678, 736, 7442, 29889, 24049, 3552, 29899, 5463, 334, 270, 718, 29871, 29896, 29897, 847, 313, 29906, 334, 269, 2934, 334, 270, 511, 29871, 29900, 29892, 29871, 29896, 29897, 13, 13, 13, 1753, 443, 510, 2139, 8498, 386, 29898, 13, 1678, 270, 29901, 7442, 29889, 299, 2378, 29892, 269, 2934, 29901, 5785, 353, 29871, 29906, 29889, 29945, 29892, 321, 3232, 29901, 5785, 353, 29871, 29900, 29889, 29955, 13, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 9995, 4591, 29871, 29900, 29899, 29896, 1819, 304, 2989, 10809, 3464, 29889, 450, 1950, 10809, 3464, 13, 1678, 338, 1904, 839, 491, 269, 2934, 322, 321, 3232, 322, 411, 269, 2934, 29922, 29906, 29889, 29945, 322, 321, 3232, 29922, 29900, 29889, 29955, 13, 1678, 372, 338, 1546, 29871, 29900, 29889, 29896, 29955, 322, 29871, 29896, 29889, 29946, 29889, 13, 1678, 9995, 13, 1678, 736, 29871, 29896, 847, 313, 29906, 334, 269, 2934, 334, 270, 718, 321, 3232, 29897, 13, 13, 13, 1753, 269, 28212, 1762, 12697, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 736, 7442, 29889, 3062, 29898, 29916, 6736, 29871, 29900, 29889, 29900, 29946, 29900, 29946, 29945, 29892, 5135, 29916, 718, 29871, 29900, 29889, 29900, 29945, 29945, 29897, 847, 29871, 29896, 29889, 29900, 29945, 29945, 29897, 3579, 29871, 29906, 29889, 29946, 29892, 921, 847, 29871, 29896, 29906, 29889, 29929, 29906, 29897, 13, 13, 13, 1753, 5608, 29911, 359, 28212, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 736, 7442, 29889, 3062, 29898, 29916, 6736, 29871, 29900, 29889, 29900, 29900, 29941, 29896, 29941, 29900, 29947, 29892, 29871, 29896, 29889, 29900, 29945, 29945, 334, 7442, 29889, 13519, 29898, 29916, 29892, 29871, 29896, 29889, 29900, 847, 29871, 29906, 29889, 29946, 29897, 448, 29871, 29900, 29889, 29900, 29945, 29945, 29892, 921, 334, 29871, 29896, 29906, 29889, 29929, 29906, 29897, 13, 13, 13, 1753, 3588, 29918, 29880, 9735, 749, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 736, 29871, 29900, 29889, 29906, 29896, 29906, 29953, 29955, 29896, 334, 921, 7503, 29892, 584, 29892, 29871, 29900, 29962, 718, 29871, 29900, 29889, 29955, 29896, 29945, 29896, 29953, 334, 921, 7503, 29892, 584, 29892, 29871, 29896, 29962, 718, 29871, 29900, 29889, 29900, 29955, 29906, 29896, 29953, 29929, 334, 921, 7503, 29892, 584, 29892, 29871, 29906, 29962, 13, 13, 13, 1753, 4818, 29918, 7915, 29898, 29916, 1125, 13, 1678, 822, 10597, 14448, 29898, 29916, 29892, 7636, 29900, 29922, 29900, 29889, 29900, 29892, 7636, 29896, 29922, 29896, 29889, 29900, 1125, 13, 4706, 921, 353, 7442, 29889, 24049, 3552, 29916, 448, 7636, 29900, 29897, 847, 313, 12864, 29896, 448, 7636, 29900, 511, 29871, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29897, 13, 4706, 736, 921, 334, 921, 334, 921, 334, 313, 29916, 334, 313, 29916, 334, 29871, 29953, 448, 29871, 29896, 29945, 29897, 718, 29871, 29896, 29900, 29897, 13, 13, 1678, 22645, 353, 7442, 29889, 1191, 3062, 29898, 9302, 29889, 2873, 29918, 4561, 29898, 29916, 876, 13, 1678, 1178, 10351, 353, 7442, 29889, 690, 14443, 29898, 13140, 29892, 313, 29916, 29889, 12181, 29961, 29900, 1402, 921, 29889, 12181, 29961, 29896, 1402, 29871, 29906, 876, 13, 1678, 4818, 29918, 5721, 353, 7442, 29889, 29880, 979, 29887, 29889, 12324, 29898, 13, 4706, 1178, 10351, 448, 7442, 29889, 2378, 4197, 29916, 29889, 12181, 29961, 29900, 29962, 847, 29871, 29906, 29892, 921, 29889, 12181, 29961, 29896, 29962, 847, 29871, 29906, 11724, 9685, 29922, 29906, 13, 1678, 1723, 13, 13, 1678, 736, 29871, 29896, 448, 10597, 14448, 29898, 5064, 29918, 5721, 847, 921, 29889, 12181, 29961, 29896, 29962, 334, 29871, 29906, 29897, 13, 13, 13, 1753, 10272, 29918, 485, 29887, 29918, 29880, 9735, 749, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 365, 353, 3588, 29918, 29880, 9735, 749, 29898, 29916, 29897, 13, 1678, 365, 353, 365, 334, 4818, 29918, 7915, 29898, 29931, 29897, 13, 1678, 1029, 29887, 29931, 29896, 353, 7442, 29889, 12483, 482, 29898, 29931, 29892, 9685, 7607, 29900, 29892, 29871, 29896, 876, 13, 1678, 736, 1029, 29887, 29931, 29896, 13, 13, 13, 1753, 10272, 29918, 5750, 29896, 29900, 29900, 29918, 3166, 29918, 485, 29887, 29918, 29880, 9735, 749, 29898, 485, 29887, 29931, 1125, 13, 1678, 736, 7442, 29889, 1188, 29906, 29898, 485, 29887, 29931, 334, 29871, 29896, 29900, 29900, 29889, 29900, 847, 29871, 29896, 29906, 29889, 29945, 29897, 29871, 396, 470, 29871, 29896, 29906, 29889, 29955, 13, 13, 13, 1753, 3588, 29918, 5750, 29896, 29900, 29900, 29918, 517, 29918, 4548, 29898, 5750, 29896, 29900, 29900, 1125, 13, 1678, 4236, 29931, 353, 29871, 29896, 29889, 29906, 334, 7442, 29889, 13519, 29898, 29906, 29889, 29900, 29892, 3415, 29896, 29900, 29900, 29897, 13, 1678, 736, 7442, 29889, 24049, 29898, 29896, 29889, 29900, 847, 4236, 29931, 29892, 29871, 29896, 29872, 29899, 29955, 29892, 6213, 29897, 13, 13, 13, 1753, 8147, 29918, 5750, 29896, 29900, 29900, 29918, 3166, 29918, 19635, 29898, 481, 814, 545, 29918, 29888, 29901, 5785, 29892, 528, 6463, 29918, 29879, 29901, 5785, 29892, 338, 29877, 29901, 938, 1125, 13, 1678, 3415, 29918, 29879, 353, 7442, 29889, 1188, 29906, 3552, 481, 814, 545, 29918, 29888, 334, 263, 10700, 545, 29918, 29888, 29897, 847, 528, 6463, 29918, 29879, 29897, 13, 1678, 3415, 29918, 29896, 29900, 29900, 353, 3415, 29918, 29879, 448, 7442, 29889, 1188, 29906, 29898, 10718, 847, 29871, 29896, 29900, 29900, 29897, 13, 1678, 736, 3415, 29918, 29896, 29900, 29900, 13, 13, 13, 1753, 10272, 29918, 6921, 29918, 4548, 29898, 29916, 29901, 7442, 29889, 299, 2378, 29892, 20102, 29901, 6120, 353, 5852, 29897, 1599, 7442, 29889, 299, 2378, 29901, 13, 1678, 1029, 29887, 29931, 353, 7442, 29889, 24049, 29898, 26017, 29918, 485, 29887, 29918, 29880, 9735, 749, 29898, 29916, 511, 29871, 29896, 29872, 29899, 29945, 29892, 6213, 29897, 13, 1678, 3415, 29896, 29900, 29900, 353, 10272, 29918, 5750, 29896, 29900, 29900, 29918, 3166, 29918, 485, 29887, 29918, 29880, 9735, 749, 29898, 485, 29887, 29931, 29897, 13, 1678, 1518, 353, 3588, 29918, 5750, 29896, 29900, 29900, 29918, 517, 29918, 4548, 29898, 5750, 29896, 29900, 29900, 29897, 29871, 396, 910, 508, 4953, 385, 8340, 1353, 29889, 2020, 29973, 13, 13, 1678, 19884, 353, 921, 334, 1518, 13, 1678, 565, 20102, 29901, 13, 4706, 19884, 353, 7442, 29889, 24049, 29898, 735, 4752, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29897, 13, 13, 1678, 736, 19884, 29892, 1518, 13, 2 ]
auth_framework/settings.py
DrChai/django-auth-framework
0
2379
from importlib import import_module from django.conf import settings from django.core.signals import setting_changed SOCIALACCOUNT_MODEL = getattr(settings, "REST_AUTH_SOCIALACCOUNT_MODEL", "auth_framework.SocialAccount") DEFAULTS = { 'UNIQUE_EMAIL': True, 'RESET_PASSWORD_BY': 'pin', # 'url'| 'pin' 'SERIALIZERS': { # 'SOCIAL_LOGIN_SERIALIZER': 'auth.social.serializers.DefaultSocialLoginSerializer', 'SIGNUP_SERIALIZER': 'auth_framework.serializers.signup_serializers.DefaultSignUpSerializer', 'USERINFO_SERIALIZER': None }, 'SOCIALACCOUNT_MODEL': SOCIALACCOUNT_MODEL, 'SOCIALACCOUNT_ADMIN_CLASS': "auth_framework.admin.SocialAccountAdmin", # SOCIAL LOGINS 'SOCIAL_CALLBACK_URL': None, # eg: 'https://developers.google.com/oauthplayground' 'SOCIAL_AUTO_SIGNUP': False, # SIGN UP # 'SIGNUP_EMAIL_VERIFICATION': 'none', # trimmed out email verification celery task in closed source. fewer usage 'SIGNUP_USERNAME_REQUIRED': False, 'SIGNUP_USERNAME_VALIDATORS': [], 'USE_PASSWORD_TWICE_VALIDATION': True, # ADVANCES 'USE_PHONENUMBER_FIELD': False, 'USE_CELERY_EMAIL': False, 'USE_ID_TOKEN': True, 'OAUTH_SAVE_ID_TOKEN': False } def import_callable(path_or_callable): if path_or_callable is None: return None if hasattr(path_or_callable, '__call__'): return path_or_callable else: assert isinstance(path_or_callable, str) package, attr = path_or_callable.rsplit('.', 1) return getattr(import_module(package), attr) class AuthSettings: """ """ def __init__(self, user_settings=None, defaults=None): if user_settings: self._user_settings = user_settings self.defaults = defaults or DEFAULTS self._cached_attrs = set() @property def user_settings(self): if not hasattr(self, '_user_settings'): self._user_settings = getattr(settings, 'AUTH_FRAMEWORK', {}) return self._user_settings @property def username_validators(self): from django.core.exceptions import ImproperlyConfigured from django.contrib.auth import get_user_model validators = self.user_settings.get("SIGNUP_USERNAME_VALIDATORS", None) if validators: ret = [] if not isinstance(validators, list): raise ImproperlyConfigured( "SIGNUP_USERNAME_VALIDATORS is expected to be a list" ) for path in validators: pkg, attr = path.rsplit(".", 1) validator = getattr(import_module(pkg), attr) ret.append(validator()) else: ret = ( get_user_model()._meta.get_field('username').validators ) return ret def serializers(self, data): # Check if present in user settings for key, value in data.items(): data[key] = import_callable(value) return data def __getattr__(self, attr): if attr not in self.defaults: raise AttributeError("Invalid setting: '%s'" % attr) try: # Check if present in user settings val = self.user_settings[attr] if isinstance(val, dict): val = self.defaults[attr].copy() val.update(self.user_settings[attr]) except KeyError: # Fall back to defaults val = self.defaults[attr] if attr == 'SERIALIZERS': val = self.serializers(val) # Cache the result self._cached_attrs.add(attr) setattr(self, attr, val) return val def reload(self): for attr in self._cached_attrs: delattr(self, attr) self._cached_attrs.clear() if hasattr(self, '_user_settings'): delattr(self, '_user_settings') app_settings = AuthSettings(None, DEFAULTS) def reload_app_settings(*args, **kwargs): setting = kwargs['setting'] if setting == 'AUTH_FRAMEWORK': app_settings.reload() setting_changed.connect(reload_app_settings)
[ 1, 515, 1053, 1982, 1053, 1053, 29918, 5453, 13, 13, 3166, 9557, 29889, 5527, 1053, 6055, 13, 3166, 9557, 29889, 3221, 29889, 4530, 1338, 1053, 4444, 29918, 15033, 13, 13, 6156, 8426, 1964, 2477, 18736, 29918, 20387, 29931, 353, 679, 5552, 29898, 11027, 29892, 376, 1525, 1254, 29918, 20656, 29950, 29918, 6156, 8426, 1964, 2477, 18736, 29918, 20387, 29931, 613, 376, 5150, 29918, 4468, 29889, 6295, 1455, 10601, 1159, 13, 13, 23397, 29903, 353, 426, 13, 1678, 525, 3904, 29902, 11144, 29918, 26862, 6227, 2396, 5852, 29892, 13, 1678, 525, 1525, 10490, 29918, 25711, 17013, 29918, 22716, 2396, 525, 12687, 742, 29871, 396, 525, 2271, 29915, 29989, 525, 12687, 29915, 13, 1678, 525, 6304, 25758, 26664, 23598, 2396, 426, 13, 4706, 396, 525, 6156, 8426, 1964, 29918, 14480, 1177, 29918, 6304, 25758, 26664, 1001, 2396, 525, 5150, 29889, 24911, 29889, 15550, 19427, 29889, 4592, 6295, 1455, 11049, 17679, 742, 13, 4706, 525, 5425, 20728, 4897, 29918, 6304, 25758, 26664, 1001, 2396, 525, 5150, 29918, 4468, 29889, 15550, 19427, 29889, 4530, 786, 29918, 15550, 19427, 29889, 4592, 10140, 3373, 17679, 742, 13, 4706, 525, 11889, 11690, 29918, 6304, 25758, 26664, 1001, 2396, 6213, 13, 1678, 2981, 13, 1678, 525, 6156, 8426, 1964, 2477, 18736, 29918, 20387, 29931, 2396, 7791, 8426, 1964, 2477, 18736, 29918, 20387, 29931, 29892, 13, 1678, 525, 6156, 8426, 1964, 2477, 18736, 29918, 3035, 16173, 29918, 13875, 1799, 2396, 376, 5150, 29918, 4468, 29889, 6406, 29889, 6295, 1455, 10601, 12754, 613, 13, 1678, 396, 7791, 8426, 1964, 25401, 1177, 29903, 13, 1678, 525, 6156, 8426, 1964, 29918, 29907, 9818, 29933, 11375, 29918, 4219, 2396, 6213, 29892, 29871, 396, 8087, 29901, 525, 991, 597, 17426, 29889, 3608, 29889, 510, 29914, 23106, 1456, 2057, 29915, 13, 1678, 525, 6156, 8426, 1964, 29918, 20656, 29949, 29918, 5425, 20728, 4897, 2396, 7700, 29892, 13, 1678, 396, 317, 17298, 11901, 13, 1678, 396, 525, 5425, 20728, 4897, 29918, 26862, 6227, 29918, 5348, 6545, 28541, 2396, 525, 9290, 742, 396, 17151, 2168, 714, 4876, 1147, 2450, 6432, 708, 3414, 297, 5764, 2752, 29889, 28145, 8744, 13, 1678, 525, 5425, 20728, 4897, 29918, 11889, 5813, 29918, 1525, 29984, 3120, 19386, 2396, 7700, 29892, 13, 1678, 525, 5425, 20728, 4897, 29918, 11889, 5813, 29918, 26707, 1299, 24125, 2396, 19997, 13, 1678, 525, 17171, 29918, 25711, 17013, 29918, 16240, 12107, 29918, 26707, 8098, 2396, 5852, 29892, 13, 1678, 396, 11033, 29963, 2190, 27266, 13, 1678, 525, 17171, 29918, 19689, 1164, 1430, 5005, 13635, 29918, 3738, 27286, 2396, 7700, 29892, 13, 1678, 525, 17171, 29918, 4741, 29931, 24422, 29918, 26862, 6227, 2396, 7700, 29892, 13, 1678, 525, 17171, 29918, 1367, 29918, 4986, 29968, 1430, 2396, 5852, 29892, 13, 1678, 525, 29949, 20656, 29950, 29918, 29903, 7520, 29923, 29918, 1367, 29918, 4986, 29968, 1430, 2396, 7700, 13, 29913, 13, 13, 13, 1753, 1053, 29918, 4804, 519, 29898, 2084, 29918, 272, 29918, 4804, 519, 1125, 13, 1678, 565, 2224, 29918, 272, 29918, 4804, 519, 338, 6213, 29901, 13, 4706, 736, 6213, 13, 1678, 565, 756, 5552, 29898, 2084, 29918, 272, 29918, 4804, 519, 29892, 525, 1649, 4804, 1649, 29374, 13, 4706, 736, 2224, 29918, 272, 29918, 4804, 519, 13, 1678, 1683, 29901, 13, 4706, 4974, 338, 8758, 29898, 2084, 29918, 272, 29918, 4804, 519, 29892, 851, 29897, 13, 4706, 3577, 29892, 12421, 353, 2224, 29918, 272, 29918, 4804, 519, 29889, 2288, 2830, 12839, 742, 29871, 29896, 29897, 13, 4706, 736, 679, 5552, 29898, 5215, 29918, 5453, 29898, 5113, 511, 12421, 29897, 13, 13, 13, 1990, 13189, 9585, 29901, 13, 1678, 9995, 13, 1678, 9995, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1404, 29918, 11027, 29922, 8516, 29892, 21274, 29922, 8516, 1125, 13, 4706, 565, 1404, 29918, 11027, 29901, 13, 9651, 1583, 3032, 1792, 29918, 11027, 353, 1404, 29918, 11027, 13, 4706, 1583, 29889, 4381, 29879, 353, 21274, 470, 22236, 29903, 13, 4706, 1583, 3032, 29883, 3791, 29918, 5552, 29879, 353, 731, 580, 13, 13, 1678, 732, 6799, 13, 1678, 822, 1404, 29918, 11027, 29898, 1311, 1125, 13, 4706, 565, 451, 756, 5552, 29898, 1311, 29892, 22868, 1792, 29918, 11027, 29374, 13, 9651, 1583, 3032, 1792, 29918, 11027, 353, 679, 5552, 29898, 11027, 29892, 525, 20656, 29950, 29918, 29943, 4717, 2303, 11686, 29968, 742, 426, 1800, 13, 4706, 736, 1583, 3032, 1792, 29918, 11027, 13, 13, 1678, 732, 6799, 13, 1678, 822, 8952, 29918, 3084, 4097, 29898, 1311, 1125, 13, 4706, 515, 9557, 29889, 3221, 29889, 11739, 29879, 1053, 1954, 771, 546, 368, 3991, 2955, 13, 4706, 515, 9557, 29889, 21570, 29889, 5150, 1053, 679, 29918, 1792, 29918, 4299, 13, 4706, 2854, 4097, 353, 1583, 29889, 1792, 29918, 11027, 29889, 657, 703, 5425, 20728, 4897, 29918, 11889, 5813, 29918, 26707, 1299, 24125, 613, 6213, 29897, 13, 4706, 565, 2854, 4097, 29901, 13, 9651, 3240, 353, 5159, 13, 9651, 565, 451, 338, 8758, 29898, 3084, 4097, 29892, 1051, 1125, 13, 18884, 12020, 1954, 771, 546, 368, 3991, 2955, 29898, 13, 462, 1678, 376, 5425, 20728, 4897, 29918, 11889, 5813, 29918, 26707, 1299, 24125, 338, 3806, 304, 367, 263, 1051, 29908, 13, 18884, 1723, 13, 9651, 363, 2224, 297, 2854, 4097, 29901, 13, 18884, 282, 9415, 29892, 12421, 353, 2224, 29889, 2288, 2830, 17350, 613, 29871, 29896, 29897, 13, 18884, 2854, 1061, 353, 679, 5552, 29898, 5215, 29918, 5453, 29898, 15865, 511, 12421, 29897, 13, 18884, 3240, 29889, 4397, 29898, 3084, 1061, 3101, 13, 4706, 1683, 29901, 13, 9651, 3240, 353, 313, 13, 18884, 679, 29918, 1792, 29918, 4299, 2141, 29918, 7299, 29889, 657, 29918, 2671, 877, 6786, 2824, 3084, 4097, 13, 9651, 1723, 13, 4706, 736, 3240, 13, 13, 1678, 822, 7797, 19427, 29898, 1311, 29892, 848, 1125, 13, 4706, 396, 5399, 565, 2198, 297, 1404, 6055, 13, 4706, 363, 1820, 29892, 995, 297, 848, 29889, 7076, 7295, 13, 9651, 848, 29961, 1989, 29962, 353, 1053, 29918, 4804, 519, 29898, 1767, 29897, 13, 4706, 736, 848, 13, 13, 1678, 822, 4770, 657, 5552, 12035, 1311, 29892, 12421, 1125, 13, 4706, 565, 12421, 451, 297, 1583, 29889, 4381, 29879, 29901, 13, 9651, 12020, 23833, 2392, 703, 13919, 4444, 29901, 14210, 29879, 11838, 1273, 12421, 29897, 13, 13, 4706, 1018, 29901, 13, 9651, 396, 5399, 565, 2198, 297, 1404, 6055, 13, 9651, 659, 353, 1583, 29889, 1792, 29918, 11027, 29961, 5552, 29962, 13, 9651, 565, 338, 8758, 29898, 791, 29892, 9657, 1125, 13, 18884, 659, 353, 1583, 29889, 4381, 29879, 29961, 5552, 1822, 8552, 580, 13, 18884, 659, 29889, 5504, 29898, 1311, 29889, 1792, 29918, 11027, 29961, 5552, 2314, 13, 4706, 5174, 7670, 2392, 29901, 13, 9651, 396, 14053, 1250, 304, 21274, 13, 9651, 659, 353, 1583, 29889, 4381, 29879, 29961, 5552, 29962, 13, 4706, 565, 12421, 1275, 525, 6304, 25758, 26664, 23598, 2396, 13, 9651, 659, 353, 1583, 29889, 15550, 19427, 29898, 791, 29897, 13, 4706, 396, 28540, 278, 1121, 13, 4706, 1583, 3032, 29883, 3791, 29918, 5552, 29879, 29889, 1202, 29898, 5552, 29897, 13, 4706, 731, 5552, 29898, 1311, 29892, 12421, 29892, 659, 29897, 13, 4706, 736, 659, 13, 13, 1678, 822, 19763, 29898, 1311, 1125, 13, 4706, 363, 12421, 297, 1583, 3032, 29883, 3791, 29918, 5552, 29879, 29901, 13, 9651, 628, 5552, 29898, 1311, 29892, 12421, 29897, 13, 4706, 1583, 3032, 29883, 3791, 29918, 5552, 29879, 29889, 8551, 580, 13, 4706, 565, 756, 5552, 29898, 1311, 29892, 22868, 1792, 29918, 11027, 29374, 13, 9651, 628, 5552, 29898, 1311, 29892, 22868, 1792, 29918, 11027, 1495, 13, 13, 13, 932, 29918, 11027, 353, 13189, 9585, 29898, 8516, 29892, 22236, 29903, 29897, 13, 13, 13, 1753, 19763, 29918, 932, 29918, 11027, 10456, 5085, 29892, 3579, 19290, 1125, 13, 1678, 4444, 353, 9049, 5085, 1839, 26740, 2033, 13, 1678, 565, 4444, 1275, 525, 20656, 29950, 29918, 29943, 4717, 2303, 11686, 29968, 2396, 13, 4706, 623, 29918, 11027, 29889, 28120, 580, 13, 13, 13, 26740, 29918, 15033, 29889, 6915, 29898, 28120, 29918, 932, 29918, 11027, 29897, 13, 2 ]
dialogs.py
rdbende/Sun-Valley-messageboxes
5
17840
<reponame>rdbende/Sun-Valley-messageboxes<gh_stars>1-10 import tkinter as tk from tkinter import ttk from functools import partial def popup(parent, title, details, icon, *, buttons): dialog = tk.Toplevel() result = None big_frame = ttk.Frame(dialog) big_frame.pack(fill="both", expand=True) big_frame.columnconfigure(0, weight=1) big_frame.rowconfigure(0, weight=1) info_frame = ttk.Frame(big_frame, padding=(10, 12), style="Dialog_info.TFrame") info_frame.grid(row=0, column=0, sticky="nsew") info_frame.columnconfigure(1, weight=1) info_frame.rowconfigure(1, weight=1) try: color = big_frame.tk.call("set", "themeColors::dialogInfoBg") except tk.TclError: color = big_frame.tk.call("ttk::style", "lookup", "TFrame", "-background") icon_label = ttk.Label(info_frame, image=icon, anchor="nw", background=color) if icon is not None: icon_label.grid( row=0, column=0, sticky="nsew", padx=(12, 0), pady=10, rowspan=2 ) title_label = ttk.Label( info_frame, text=title, anchor="nw", font=("", 14, "bold"), background=color ) title_label.grid(row=0, column=1, sticky="nsew", padx=(12, 17), pady=(10, 8)) detail_label = ttk.Label(info_frame, text=details, anchor="nw", background=color) detail_label.grid(row=1, column=1, sticky="nsew", padx=(12, 17), pady=(5, 10)) button_frame = ttk.Frame( big_frame, padding=(22, 22, 12, 22), style="Dialog_buttons.TFrame" ) button_frame.grid(row=2, column=0, sticky="nsew") def on_button(value): nonlocal result result = value dialog.destroy() for index, button_value in enumerate(buttons): style = None state = None default = False sticky = "nes" if len(buttons) == 1 else "nsew" if len(button_value) > 2: if button_value[2] == "accent": style = "Accent.TButton" default = True elif button_value[2] == "disabled": state = "disabled" elif button_value[2] == "default": default = True button = ttk.Button( button_frame, text=button_value[0], width=18, command=partial(on_button, button_value[1]), style=style, state=state, ) if default: button.bind("<Return>", button["command"]) button.focus() button.grid(row=0, column=index, sticky=sticky, padx=(0, 10)) button_frame.columnconfigure(index, weight=1) dialog.overrideredirect(True) dialog.update() dialog_width = dialog.winfo_width() dialog_height = dialog.winfo_height() if parent is None: parent_width = dialog.winfo_screenwidth() parent_height = dialog.winfo_screenheight() parent_x = 0 parent_y = 0 else: parent_width = parent.winfo_width() parent_height = parent.winfo_height() parent_x = parent.winfo_x() parent_y = parent.winfo_y() x_coord = int(parent_width / 2 + parent_x - dialog_width / 2) y_coord = int(parent_height / 2 + parent_y - dialog_height / 2) dialog.geometry("+{}+{}".format(x_coord, y_coord)) dialog.minsize(320, dialog_height) dialog.transient(parent) dialog.grab_set() dialog.wait_window() return result def show_message(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Ok", None, "default")], ) def ask_ok_cancel(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Ok", True, "accent"), ("Cancel", None)], ) def ask_yes_no(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Yes", True, "accent"), ("No", False)], ) def ask_yes_no_cancel(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Yes", True, "accent"), ("No", False), ("Cancel", None)], ) def ask_retry_cancel(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Retry", True, "accent"), ("Cancel", None)], ) def ask_allow_block(title="Title", details="Description", *, parent=None, icon=None): return popup( parent, title, details, icon, buttons=[("Allow", True, "accent"), ("Block", False)], ) if __name__ == "__main__": window = tk.Tk() window.tk.call("source", "sun-valley.tcl") window.tk.call("set_theme", "dark") window.geometry("600x600") show_message("No WiFi connection", "Check your connection and try again.") window.mainloop()
[ 1, 529, 276, 1112, 420, 29958, 5499, 1785, 311, 29914, 29903, 348, 29899, 1440, 2330, 29899, 4906, 1884, 267, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 5215, 18883, 1639, 408, 18883, 13, 3166, 18883, 1639, 1053, 260, 11178, 13, 3166, 2090, 312, 8789, 1053, 7687, 13, 13, 13, 1753, 18218, 29898, 3560, 29892, 3611, 29892, 4902, 29892, 9849, 29892, 334, 29892, 9828, 1125, 13, 1678, 7928, 353, 18883, 29889, 29911, 1991, 955, 580, 13, 13, 1678, 1121, 353, 6213, 13, 13, 1678, 4802, 29918, 2557, 353, 260, 11178, 29889, 4308, 29898, 15901, 29897, 13, 1678, 4802, 29918, 2557, 29889, 4058, 29898, 5589, 543, 20313, 613, 7985, 29922, 5574, 29897, 13, 1678, 4802, 29918, 2557, 29889, 4914, 17591, 29898, 29900, 29892, 7688, 29922, 29896, 29897, 13, 1678, 4802, 29918, 2557, 29889, 798, 17591, 29898, 29900, 29892, 7688, 29922, 29896, 29897, 13, 13, 1678, 5235, 29918, 2557, 353, 260, 11178, 29889, 4308, 29898, 3752, 29918, 2557, 29892, 7164, 7607, 29896, 29900, 29892, 29871, 29896, 29906, 511, 3114, 543, 7647, 29918, 3888, 29889, 29911, 4308, 1159, 13, 1678, 5235, 29918, 2557, 29889, 7720, 29898, 798, 29922, 29900, 29892, 1897, 29922, 29900, 29892, 12070, 29891, 543, 29876, 344, 29893, 1159, 13, 1678, 5235, 29918, 2557, 29889, 4914, 17591, 29898, 29896, 29892, 7688, 29922, 29896, 29897, 13, 1678, 5235, 29918, 2557, 29889, 798, 17591, 29898, 29896, 29892, 7688, 29922, 29896, 29897, 13, 13, 1678, 1018, 29901, 13, 4706, 2927, 353, 4802, 29918, 2557, 29889, 11178, 29889, 4804, 703, 842, 613, 376, 18193, 1625, 943, 1057, 15901, 3401, 29933, 29887, 1159, 13, 1678, 5174, 18883, 29889, 29911, 695, 2392, 29901, 13, 4706, 2927, 353, 4802, 29918, 2557, 29889, 11178, 29889, 4804, 703, 698, 29895, 1057, 3293, 613, 376, 20401, 613, 376, 29911, 4308, 613, 11663, 7042, 1159, 13, 13, 1678, 9849, 29918, 1643, 353, 260, 11178, 29889, 4775, 29898, 3888, 29918, 2557, 29892, 1967, 29922, 4144, 29892, 17360, 543, 29876, 29893, 613, 3239, 29922, 2780, 29897, 13, 1678, 565, 9849, 338, 451, 6213, 29901, 13, 4706, 9849, 29918, 1643, 29889, 7720, 29898, 13, 9651, 1948, 29922, 29900, 29892, 1897, 29922, 29900, 29892, 12070, 29891, 543, 29876, 344, 29893, 613, 17132, 29916, 7607, 29896, 29906, 29892, 29871, 29900, 511, 282, 3714, 29922, 29896, 29900, 29892, 1948, 9653, 29922, 29906, 13, 4706, 1723, 13, 13, 1678, 3611, 29918, 1643, 353, 260, 11178, 29889, 4775, 29898, 13, 4706, 5235, 29918, 2557, 29892, 1426, 29922, 3257, 29892, 17360, 543, 29876, 29893, 613, 4079, 29922, 703, 613, 29871, 29896, 29946, 29892, 376, 8934, 4968, 3239, 29922, 2780, 13, 1678, 1723, 13, 1678, 3611, 29918, 1643, 29889, 7720, 29898, 798, 29922, 29900, 29892, 1897, 29922, 29896, 29892, 12070, 29891, 543, 29876, 344, 29893, 613, 17132, 29916, 7607, 29896, 29906, 29892, 29871, 29896, 29955, 511, 282, 3714, 7607, 29896, 29900, 29892, 29871, 29947, 876, 13, 13, 1678, 9493, 29918, 1643, 353, 260, 11178, 29889, 4775, 29898, 3888, 29918, 2557, 29892, 1426, 29922, 14144, 29892, 17360, 543, 29876, 29893, 613, 3239, 29922, 2780, 29897, 13, 1678, 9493, 29918, 1643, 29889, 7720, 29898, 798, 29922, 29896, 29892, 1897, 29922, 29896, 29892, 12070, 29891, 543, 29876, 344, 29893, 613, 17132, 29916, 7607, 29896, 29906, 29892, 29871, 29896, 29955, 511, 282, 3714, 7607, 29945, 29892, 29871, 29896, 29900, 876, 13, 13, 1678, 2826, 29918, 2557, 353, 260, 11178, 29889, 4308, 29898, 13, 4706, 4802, 29918, 2557, 29892, 7164, 7607, 29906, 29906, 29892, 29871, 29906, 29906, 29892, 29871, 29896, 29906, 29892, 29871, 29906, 29906, 511, 3114, 543, 7647, 29918, 4187, 7453, 29889, 29911, 4308, 29908, 13, 1678, 1723, 13, 1678, 2826, 29918, 2557, 29889, 7720, 29898, 798, 29922, 29906, 29892, 1897, 29922, 29900, 29892, 12070, 29891, 543, 29876, 344, 29893, 1159, 13, 13, 1678, 822, 373, 29918, 3092, 29898, 1767, 1125, 13, 4706, 1661, 2997, 1121, 13, 4706, 1121, 353, 995, 13, 4706, 7928, 29889, 20524, 580, 13, 13, 1678, 363, 2380, 29892, 2826, 29918, 1767, 297, 26985, 29898, 4187, 7453, 1125, 13, 4706, 3114, 353, 6213, 13, 4706, 2106, 353, 6213, 13, 4706, 2322, 353, 7700, 13, 4706, 12070, 29891, 353, 376, 4515, 29908, 565, 7431, 29898, 4187, 7453, 29897, 1275, 29871, 29896, 1683, 376, 29876, 344, 29893, 29908, 13, 13, 4706, 565, 7431, 29898, 3092, 29918, 1767, 29897, 1405, 29871, 29906, 29901, 13, 9651, 565, 2826, 29918, 1767, 29961, 29906, 29962, 1275, 376, 562, 1760, 1115, 13, 18884, 3114, 353, 376, 7504, 296, 29889, 29911, 3125, 29908, 13, 18884, 2322, 353, 5852, 13, 9651, 25342, 2826, 29918, 1767, 29961, 29906, 29962, 1275, 376, 18279, 1115, 13, 18884, 2106, 353, 376, 18279, 29908, 13, 9651, 25342, 2826, 29918, 1767, 29961, 29906, 29962, 1275, 376, 4381, 1115, 13, 18884, 2322, 353, 5852, 13, 13, 4706, 2826, 353, 260, 11178, 29889, 3125, 29898, 13, 9651, 2826, 29918, 2557, 29892, 13, 9651, 1426, 29922, 3092, 29918, 1767, 29961, 29900, 1402, 13, 9651, 2920, 29922, 29896, 29947, 29892, 13, 9651, 1899, 29922, 3846, 29898, 265, 29918, 3092, 29892, 2826, 29918, 1767, 29961, 29896, 11724, 13, 9651, 3114, 29922, 3293, 29892, 13, 9651, 2106, 29922, 3859, 29892, 13, 4706, 1723, 13, 4706, 565, 2322, 29901, 13, 9651, 2826, 29889, 5355, 28945, 11609, 28341, 2826, 3366, 6519, 20068, 13, 9651, 2826, 29889, 18037, 580, 13, 13, 4706, 2826, 29889, 7720, 29898, 798, 29922, 29900, 29892, 1897, 29922, 2248, 29892, 12070, 29891, 29922, 303, 18219, 29892, 17132, 29916, 7607, 29900, 29892, 29871, 29896, 29900, 876, 13, 13, 4706, 2826, 29918, 2557, 29889, 4914, 17591, 29898, 2248, 29892, 7688, 29922, 29896, 29897, 13, 13, 1678, 7928, 29889, 957, 29878, 1241, 287, 1088, 29898, 5574, 29897, 13, 1678, 7928, 29889, 5504, 580, 13, 13, 1678, 7928, 29918, 2103, 353, 7928, 29889, 29893, 3888, 29918, 2103, 580, 13, 1678, 7928, 29918, 3545, 353, 7928, 29889, 29893, 3888, 29918, 3545, 580, 13, 13, 1678, 565, 3847, 338, 6213, 29901, 13, 4706, 3847, 29918, 2103, 353, 7928, 29889, 29893, 3888, 29918, 10525, 2103, 580, 13, 4706, 3847, 29918, 3545, 353, 7928, 29889, 29893, 3888, 29918, 10525, 3545, 580, 13, 4706, 3847, 29918, 29916, 353, 29871, 29900, 13, 4706, 3847, 29918, 29891, 353, 29871, 29900, 13, 1678, 1683, 29901, 13, 4706, 3847, 29918, 2103, 353, 3847, 29889, 29893, 3888, 29918, 2103, 580, 13, 4706, 3847, 29918, 3545, 353, 3847, 29889, 29893, 3888, 29918, 3545, 580, 13, 4706, 3847, 29918, 29916, 353, 3847, 29889, 29893, 3888, 29918, 29916, 580, 13, 4706, 3847, 29918, 29891, 353, 3847, 29889, 29893, 3888, 29918, 29891, 580, 13, 13, 1678, 921, 29918, 1111, 536, 353, 938, 29898, 3560, 29918, 2103, 847, 29871, 29906, 718, 3847, 29918, 29916, 448, 7928, 29918, 2103, 847, 29871, 29906, 29897, 13, 1678, 343, 29918, 1111, 536, 353, 938, 29898, 3560, 29918, 3545, 847, 29871, 29906, 718, 3847, 29918, 29891, 448, 7928, 29918, 3545, 847, 29871, 29906, 29897, 13, 13, 1678, 7928, 29889, 19156, 703, 29974, 29912, 7517, 8875, 1642, 4830, 29898, 29916, 29918, 1111, 536, 29892, 343, 29918, 1111, 536, 876, 13, 1678, 7928, 29889, 29885, 1144, 675, 29898, 29941, 29906, 29900, 29892, 7928, 29918, 3545, 29897, 13, 13, 1678, 7928, 29889, 3286, 993, 29898, 3560, 29897, 13, 1678, 7928, 29889, 3874, 29890, 29918, 842, 580, 13, 13, 1678, 7928, 29889, 10685, 29918, 7165, 580, 13, 1678, 736, 1121, 13, 13, 13, 1753, 1510, 29918, 4906, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 20434, 613, 6213, 29892, 376, 4381, 1159, 1402, 13, 1678, 1723, 13, 13, 13, 1753, 2244, 29918, 554, 29918, 20713, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 20434, 613, 5852, 29892, 376, 562, 1760, 4968, 4852, 19420, 613, 6213, 29897, 1402, 13, 1678, 1723, 13, 13, 13, 1753, 2244, 29918, 3582, 29918, 1217, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 8241, 613, 5852, 29892, 376, 562, 1760, 4968, 4852, 3782, 613, 7700, 29897, 1402, 13, 1678, 1723, 13, 13, 13, 1753, 2244, 29918, 3582, 29918, 1217, 29918, 20713, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 8241, 613, 5852, 29892, 376, 562, 1760, 4968, 4852, 3782, 613, 7700, 511, 4852, 19420, 613, 6213, 29897, 1402, 13, 1678, 1723, 13, 13, 13, 1753, 2244, 29918, 276, 2202, 29918, 20713, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 8015, 719, 613, 5852, 29892, 376, 562, 1760, 4968, 4852, 19420, 613, 6213, 29897, 1402, 13, 1678, 1723, 13, 13, 13, 1753, 2244, 29918, 9536, 29918, 1271, 29898, 3257, 543, 7030, 613, 4902, 543, 9868, 613, 334, 29892, 3847, 29922, 8516, 29892, 9849, 29922, 8516, 1125, 13, 1678, 736, 18218, 29898, 13, 4706, 3847, 29892, 13, 4706, 3611, 29892, 13, 4706, 4902, 29892, 13, 4706, 9849, 29892, 13, 4706, 9828, 11759, 703, 15930, 613, 5852, 29892, 376, 562, 1760, 4968, 4852, 7445, 613, 7700, 29897, 1402, 13, 1678, 1723, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 3474, 353, 18883, 29889, 29911, 29895, 580, 13, 13, 1678, 3474, 29889, 11178, 29889, 4804, 703, 4993, 613, 376, 11445, 29899, 791, 2330, 29889, 29873, 695, 1159, 13, 1678, 3474, 29889, 11178, 29889, 4804, 703, 842, 29918, 18193, 613, 376, 26031, 1159, 13, 13, 1678, 3474, 29889, 19156, 703, 29953, 29900, 29900, 29916, 29953, 29900, 29900, 1159, 13, 13, 1678, 1510, 29918, 4906, 703, 3782, 14570, 18800, 3957, 613, 376, 5596, 596, 3957, 322, 1018, 1449, 23157, 13, 13, 1678, 3474, 29889, 3396, 7888, 580, 13, 2 ]
src/controllers/thread.py
xoudini/tsoha
1
62362
<gh_stars>1-10 from flask import render_template from typing import Dict, List from src.models.thread import Thread from src.models.tag import Tag class ThreadController: ### View rendering. @staticmethod def view_for_threads(): threads = Thread.find_all() return render_template('threads.html', title="Threads", threads=threads) @staticmethod def view_for_thread(uid: int, messages: Dict[str, str] = None): thread = Thread.find_by_id(uid) return render_template('thread.html', title="Thread", thread=thread, messages=messages) @staticmethod def view_for_new_thread(messages: Dict[str, str] = None): tags = Tag.find_all() return render_template('new_thread.html', title="New thread", tags=tags, messages=messages) @staticmethod def view_for_edit_thread(uid: int, messages: Dict[str, str] = None): thread = Thread.find_by_id(uid) tags = Tag.find_all() return render_template('edit_thread.html', title="Edit thread", thread=thread, tags=tags, messages=messages) ### Database updates. @staticmethod def create(user_id: int, title: str, content: str, tag_ids: List[int]): result = Thread.create(user_id, title, content, tag_ids) return result @staticmethod def update(uid: int, title: str, tag_ids: List[int]): result = Thread.update(uid, title, tag_ids) return result @staticmethod def delete(uid: int): Thread.delete(uid) ### Helper methods. @staticmethod def thread_exists(uid: int): return Thread.find_by_id(uid) is not None @staticmethod def author_for_thread(uid: int): return Thread.author_for_thread(uid)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 3166, 29784, 1053, 4050, 29918, 6886, 13, 13, 3166, 19229, 1053, 360, 919, 29892, 2391, 13, 13, 3166, 4765, 29889, 9794, 29889, 7097, 1053, 10480, 13, 3166, 4765, 29889, 9794, 29889, 4039, 1053, 10522, 13, 13, 1990, 10480, 2956, 29901, 13, 13, 1678, 835, 4533, 15061, 29889, 13, 268, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1776, 29918, 1454, 29918, 28993, 7295, 13, 4706, 9717, 353, 10480, 29889, 2886, 29918, 497, 580, 13, 4706, 736, 4050, 29918, 6886, 877, 28993, 29889, 1420, 742, 3611, 543, 4899, 29879, 613, 9717, 29922, 28993, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1776, 29918, 1454, 29918, 7097, 29898, 5416, 29901, 938, 29892, 7191, 29901, 360, 919, 29961, 710, 29892, 851, 29962, 353, 6213, 1125, 13, 4706, 3244, 353, 10480, 29889, 2886, 29918, 1609, 29918, 333, 29898, 5416, 29897, 13, 4706, 736, 4050, 29918, 6886, 877, 7097, 29889, 1420, 742, 3611, 543, 4899, 613, 3244, 29922, 7097, 29892, 7191, 29922, 19158, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1776, 29918, 1454, 29918, 1482, 29918, 7097, 29898, 19158, 29901, 360, 919, 29961, 710, 29892, 851, 29962, 353, 6213, 1125, 13, 4706, 8282, 353, 10522, 29889, 2886, 29918, 497, 580, 13, 4706, 736, 4050, 29918, 6886, 877, 1482, 29918, 7097, 29889, 1420, 742, 3611, 543, 4373, 3244, 613, 8282, 29922, 11338, 29892, 7191, 29922, 19158, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1776, 29918, 1454, 29918, 5628, 29918, 7097, 29898, 5416, 29901, 938, 29892, 7191, 29901, 360, 919, 29961, 710, 29892, 851, 29962, 353, 6213, 1125, 13, 4706, 3244, 353, 10480, 29889, 2886, 29918, 1609, 29918, 333, 29898, 5416, 29897, 13, 4706, 8282, 353, 10522, 29889, 2886, 29918, 497, 580, 13, 4706, 736, 4050, 29918, 6886, 877, 5628, 29918, 7097, 29889, 1420, 742, 3611, 543, 6103, 3244, 613, 3244, 29922, 7097, 29892, 8282, 29922, 11338, 29892, 7191, 29922, 19158, 29897, 13, 13, 13, 1678, 835, 5470, 11217, 29889, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1653, 29898, 1792, 29918, 333, 29901, 938, 29892, 3611, 29901, 851, 29892, 2793, 29901, 851, 29892, 4055, 29918, 4841, 29901, 2391, 29961, 524, 29962, 1125, 13, 4706, 1121, 353, 10480, 29889, 3258, 29898, 1792, 29918, 333, 29892, 3611, 29892, 2793, 29892, 4055, 29918, 4841, 29897, 13, 4706, 736, 1121, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 2767, 29898, 5416, 29901, 938, 29892, 3611, 29901, 851, 29892, 4055, 29918, 4841, 29901, 2391, 29961, 524, 29962, 1125, 13, 4706, 1121, 353, 10480, 29889, 5504, 29898, 5416, 29892, 3611, 29892, 4055, 29918, 4841, 29897, 13, 4706, 736, 1121, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 5217, 29898, 5416, 29901, 938, 1125, 13, 4706, 10480, 29889, 8143, 29898, 5416, 29897, 13, 13, 13, 1678, 835, 6162, 546, 3519, 29889, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 3244, 29918, 9933, 29898, 5416, 29901, 938, 1125, 13, 4706, 736, 10480, 29889, 2886, 29918, 1609, 29918, 333, 29898, 5416, 29897, 338, 451, 6213, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 4148, 29918, 1454, 29918, 7097, 29898, 5416, 29901, 938, 1125, 13, 4706, 736, 10480, 29889, 8921, 29918, 1454, 29918, 7097, 29898, 5416, 29897, 13, 2 ]
LeetCode/October 2020 Leetcoding Challenge/Bag of Tokens.py
UtkarshPathrabe/Competitive-Coding
13
43014
<reponame>UtkarshPathrabe/Competitive-Coding<gh_stars>10-100 class Solution: def bagOfTokensScore(self, tokens: List[int], P: int) -> int: tokens.sort() tokens, maxScore, currentScore = deque(tokens), 0, 0 while tokens and (P >= tokens[0] or currentScore): while tokens and P >= tokens[0]: P -= tokens.popleft() currentScore += 1 maxScore = max(maxScore, currentScore) if tokens and currentScore: P += tokens.pop() currentScore -= 1 return maxScore
[ 1, 529, 276, 1112, 420, 29958, 29965, 29873, 5689, 845, 2605, 336, 915, 29914, 6843, 300, 3321, 29899, 29907, 3689, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 1990, 24380, 29901, 13, 1678, 822, 19548, 2776, 29911, 554, 575, 20097, 29898, 1311, 29892, 18897, 29901, 2391, 29961, 524, 1402, 349, 29901, 938, 29897, 1599, 938, 29901, 13, 4706, 18897, 29889, 6605, 580, 13, 4706, 18897, 29892, 4236, 20097, 29892, 1857, 20097, 353, 316, 802, 29898, 517, 12360, 511, 29871, 29900, 29892, 29871, 29900, 13, 4706, 1550, 18897, 322, 313, 29925, 6736, 18897, 29961, 29900, 29962, 470, 1857, 20097, 1125, 13, 9651, 1550, 18897, 322, 349, 6736, 18897, 29961, 29900, 5387, 13, 18884, 349, 22361, 18897, 29889, 7323, 1563, 580, 13, 18884, 1857, 20097, 4619, 29871, 29896, 13, 9651, 4236, 20097, 353, 4236, 29898, 3317, 20097, 29892, 1857, 20097, 29897, 13, 9651, 565, 18897, 322, 1857, 20097, 29901, 13, 18884, 349, 4619, 18897, 29889, 7323, 580, 13, 18884, 1857, 20097, 22361, 29871, 29896, 13, 4706, 736, 4236, 20097, 2 ]
src/main.py
sudosubin/bins
0
114841
import asyncio import uvloop from rich import traceback from command import Command if __name__ == '__main__': traceback.install() uvloop.install() asyncio.run(Command.execute())
[ 1, 1053, 408, 948, 3934, 13, 13, 5215, 318, 29894, 7888, 13, 3166, 8261, 1053, 9637, 1627, 13, 13, 3166, 1899, 1053, 10516, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 9637, 1627, 29889, 6252, 580, 13, 1678, 318, 29894, 7888, 29889, 6252, 580, 13, 1678, 408, 948, 3934, 29889, 3389, 29898, 6255, 29889, 7978, 3101, 13, 2 ]
sharpy/events/unit_destroyed_event.py
MadManSC2/sharpy-sc2
1
111665
from typing import Optional from sc2.unit import Unit class UnitDestroyedEvent: """An event indicating which unit just died.""" def __init__(self, unit_tag: int, unit: Optional[Unit]): assert isinstance(unit_tag, int) assert isinstance(unit, Unit) or unit is None self.unit_tag: int = unit_tag self.unit: Optional[Unit] = unit
[ 1, 515, 19229, 1053, 28379, 30004, 13, 30004, 13, 3166, 885, 29906, 29889, 5441, 1053, 13223, 30004, 13, 30004, 13, 30004, 13, 1990, 13223, 14994, 4727, 287, 2624, 29901, 30004, 13, 1678, 9995, 2744, 1741, 23941, 607, 5190, 925, 6423, 1213, 15945, 30004, 13, 30004, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 5190, 29918, 4039, 29901, 938, 29892, 5190, 29901, 28379, 29961, 8325, 29962, 1125, 30004, 13, 4706, 4974, 338, 8758, 29898, 5441, 29918, 4039, 29892, 938, 8443, 13, 4706, 4974, 338, 8758, 29898, 5441, 29892, 13223, 29897, 470, 5190, 338, 6213, 30004, 13, 30004, 13, 4706, 1583, 29889, 5441, 29918, 4039, 29901, 938, 353, 5190, 29918, 4039, 30004, 13, 4706, 1583, 29889, 5441, 29901, 28379, 29961, 8325, 29962, 353, 5190, 30004, 13, 2 ]
curso_hector/17-funcionalidades-avanzadas/funciones_decoradoras.py
corahama/python
1
57422
def hola(): def bienvenido(): print("hola!") return bienvenido # hola()() def mensaje(): return "Este es un mensaje" def test(function): print(mensaje()) test(mensaje)
[ 1, 822, 298, 2963, 7295, 13, 13, 1678, 822, 6079, 854, 1941, 7295, 13, 4706, 1596, 703, 29882, 2963, 29991, 1159, 13, 13, 1678, 736, 6079, 854, 1941, 13, 13, 29937, 298, 2963, 580, 580, 13, 13, 1753, 18664, 8339, 7295, 13, 1678, 736, 376, 29923, 1655, 831, 443, 18664, 8339, 29908, 13, 13, 1753, 1243, 29898, 2220, 1125, 13, 1678, 1596, 29898, 29885, 575, 8339, 3101, 13, 13, 1688, 29898, 29885, 575, 8339, 29897, 13, 2 ]
remio/sevent.py
Hikki12/remio
0
144007
<reponame>Hikki12/remio class Emitter: """This class implements a simple event emitter. Args: emitterIsEnabled: enable callbacks execution? Example usage:: callback = lambda message: print(message) event = Emitter() event.on('ready', callback) event.emit('ready', 'Finished!') """ def __init__(self, emitterIsEnabled: bool = True, *args, **kwargs): self.callbacks = None self.emitterIsEnabled = emitterIsEnabled def on(self, eventName: str = "", callback=None): """It sets the callback functions. Args: eventName: name of the event callback: function """ if self.callbacks is None: self.callbacks = {} if eventName in self.callbacks: self.callbacks[eventName].append(callback) else: self.callbacks[eventName] = [callback] def emit(self, eventName: str = "", *args, **kwargs): """It emits an event, and calls the corresponding callback function. Args: eventName: name of the event. """ if self.emitterIsEnabled: if self.callbacks is not None and len(eventName) > 0: if eventName in self.callbacks: for callback in self.callbacks[eventName]: if callback.__code__.co_argcount > 0: callback(*args, **kwargs) else: callback() def clearEvent(self, eventName: str): """It clears the callbacks associated to a specific event name. Args: eventName: name of the event. """ if eventName in self.callbacks: del self.callbacks[eventName] def clearAllEvents(self): """It clears all events.""" self.callbacks = None def disableEvents(self): """It disables emit function.""" self.emitterIsEnabled = False def enableEvents(self): """It enables emit function.""" self.emitterIsEnabled = True
[ 1, 529, 276, 1112, 420, 29958, 29950, 638, 1984, 29896, 29906, 29914, 1745, 601, 13, 1990, 382, 2415, 357, 29901, 13, 1678, 9995, 4013, 770, 10703, 263, 2560, 1741, 953, 5171, 29889, 13, 1678, 826, 3174, 29901, 13, 4706, 953, 5171, 3624, 10861, 29901, 9025, 6939, 29879, 8225, 29973, 13, 13, 1678, 8741, 8744, 1057, 13, 4706, 6939, 353, 14013, 2643, 29901, 1596, 29898, 4906, 29897, 13, 4706, 1741, 353, 382, 2415, 357, 580, 13, 4706, 1741, 29889, 265, 877, 2040, 742, 6939, 29897, 13, 4706, 1741, 29889, 21976, 877, 2040, 742, 525, 12881, 3276, 29991, 1495, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 953, 5171, 3624, 10861, 29901, 6120, 353, 5852, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 1583, 29889, 14035, 29879, 353, 6213, 13, 4706, 1583, 29889, 331, 5171, 3624, 10861, 353, 953, 5171, 3624, 10861, 13, 13, 1678, 822, 373, 29898, 1311, 29892, 1741, 1170, 29901, 851, 353, 12633, 6939, 29922, 8516, 1125, 13, 4706, 9995, 3112, 6166, 278, 6939, 3168, 29889, 13, 4706, 826, 3174, 29901, 13, 9651, 1741, 1170, 29901, 1024, 310, 278, 1741, 13, 9651, 6939, 29901, 740, 13, 4706, 9995, 13, 4706, 565, 1583, 29889, 14035, 29879, 338, 6213, 29901, 13, 9651, 1583, 29889, 14035, 29879, 353, 6571, 13, 13, 4706, 565, 1741, 1170, 297, 1583, 29889, 14035, 29879, 29901, 13, 9651, 1583, 29889, 14035, 29879, 29961, 3696, 1170, 1822, 4397, 29898, 14035, 29897, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 14035, 29879, 29961, 3696, 1170, 29962, 353, 518, 14035, 29962, 13, 13, 1678, 822, 20076, 29898, 1311, 29892, 1741, 1170, 29901, 851, 353, 12633, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 9995, 3112, 953, 1169, 385, 1741, 29892, 322, 5717, 278, 6590, 6939, 740, 29889, 13, 13, 4706, 826, 3174, 29901, 13, 9651, 1741, 1170, 29901, 1024, 310, 278, 1741, 29889, 13, 4706, 9995, 13, 4706, 565, 1583, 29889, 331, 5171, 3624, 10861, 29901, 13, 9651, 565, 1583, 29889, 14035, 29879, 338, 451, 6213, 322, 7431, 29898, 3696, 1170, 29897, 1405, 29871, 29900, 29901, 13, 18884, 565, 1741, 1170, 297, 1583, 29889, 14035, 29879, 29901, 13, 462, 1678, 363, 6939, 297, 1583, 29889, 14035, 29879, 29961, 3696, 1170, 5387, 13, 462, 4706, 565, 6939, 17255, 401, 26914, 1111, 29918, 1191, 2798, 1405, 29871, 29900, 29901, 13, 462, 9651, 6939, 10456, 5085, 29892, 3579, 19290, 29897, 13, 462, 4706, 1683, 29901, 13, 462, 9651, 6939, 580, 13, 13, 1678, 822, 2821, 2624, 29898, 1311, 29892, 1741, 1170, 29901, 851, 1125, 13, 4706, 9995, 3112, 4531, 1503, 278, 6939, 29879, 6942, 304, 263, 2702, 1741, 1024, 29889, 13, 13, 4706, 826, 3174, 29901, 13, 9651, 1741, 1170, 29901, 1024, 310, 278, 1741, 29889, 13, 4706, 9995, 13, 4706, 565, 1741, 1170, 297, 1583, 29889, 14035, 29879, 29901, 13, 9651, 628, 1583, 29889, 14035, 29879, 29961, 3696, 1170, 29962, 13, 13, 1678, 822, 2821, 3596, 13634, 29898, 1311, 1125, 13, 4706, 9995, 3112, 4531, 1503, 599, 4959, 1213, 15945, 13, 4706, 1583, 29889, 14035, 29879, 353, 6213, 13, 13, 1678, 822, 11262, 13634, 29898, 1311, 1125, 13, 4706, 9995, 3112, 766, 1849, 20076, 740, 1213, 15945, 13, 4706, 1583, 29889, 331, 5171, 3624, 10861, 353, 7700, 13, 13, 1678, 822, 9025, 13634, 29898, 1311, 1125, 13, 4706, 9995, 3112, 28936, 20076, 740, 1213, 15945, 13, 4706, 1583, 29889, 331, 5171, 3624, 10861, 353, 5852, 13, 2 ]
saleor/core/migrations/0005_alter_eventdelivery_webhook.py
eanknd/saleor
1,392
49142
# Generated by Django 3.2.12 on 2022-04-08 12:37 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ("webhook", "0008_webhook_subscription_query"), ("core", "0004_delete_delivery_without_webhook"), ] operations = [ migrations.AlterField( model_name="eventdelivery", name="webhook", field=models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, to="webhook.webhook" ), ), ]
[ 1, 396, 3251, 630, 491, 15337, 29871, 29941, 29889, 29906, 29889, 29896, 29906, 373, 29871, 29906, 29900, 29906, 29906, 29899, 29900, 29946, 29899, 29900, 29947, 29871, 29896, 29906, 29901, 29941, 29955, 13, 13, 3166, 9557, 29889, 2585, 1053, 9725, 800, 29892, 4733, 13, 5215, 9557, 29889, 2585, 29889, 9794, 29889, 311, 1026, 291, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 13, 4706, 4852, 2676, 20849, 613, 376, 29900, 29900, 29900, 29947, 29918, 2676, 20849, 29918, 1491, 22371, 29918, 1972, 4968, 13, 4706, 4852, 3221, 613, 376, 29900, 29900, 29900, 29946, 29918, 8143, 29918, 29881, 27657, 29918, 14037, 29918, 2676, 20849, 4968, 13, 1678, 4514, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 2499, 357, 3073, 29898, 13, 9651, 1904, 29918, 978, 543, 3696, 29881, 27657, 613, 13, 9651, 1024, 543, 2676, 20849, 613, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 13, 18884, 373, 29918, 8143, 29922, 14095, 29889, 2585, 29889, 9794, 29889, 311, 1026, 291, 29889, 29907, 3289, 5454, 2287, 29892, 304, 543, 2676, 20849, 29889, 2676, 20849, 29908, 13, 9651, 10353, 13, 4706, 10353, 13, 1678, 4514, 13, 2 ]
server.py
zillwc/iploc
0
60111
# -*- coding: utf-8 -*- """ IPLoc Retrieve location information for an IP """ import sys from iploc import IpLoc from flask import Flask, jsonify, abort, make_response app = Flask(__name__) @app.route("/<ip_addr>/") def ip_search(ip_addr=None): if ip_addr is None: abort(make_response("Error: Missing IP Address", 400)) if not is_valid_ipv4(ip_addr): abort(make_response("Error: Invalid IP Address", 400)) loc_data = iploc.lookup(ip_addr) return jsonify(loc_data) @app.route("/<ip_addr>/<key>/") def ip_search_by_key(ip_addr=None, key=None): if ip_addr is None or key is None: abort(make_response("Error: Invalid parameters provided", 400)) if not is_valid_ipv4(ip_addr): abort(make_response("Error: Invalid IP Address", 400)) loc_data = iploc.lookup(ip_addr) response_obj = {} keys = key.split(',') for k in keys: if loc_data.get(str(k)) is not None: response_obj[k] = loc_data.get(str(k)) return jsonify(response_obj) def is_valid_ipv4(addr): pieces = addr.split('.') if len(pieces) != 4: return False try: return all(0<=int(p)<256 for p in pieces) except ValueError: return False defaults = { "loc_data_file": 'data/Location.csv', "ips_data_file": 'data/Blocks.csv' } if len(sys.argv) < 3: loc_file = defaults['loc_data_file'] ips_file = defaults['ips_data_file'] else: loc_file = sys.argv[1] ips_file = sys.argv[2] iploc = IpLoc(loc_file, ips_file) app.run(host='0.0.0.0')
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 13, 1678, 5641, 3524, 13, 1678, 4649, 29878, 2418, 4423, 2472, 363, 385, 5641, 13, 15945, 29908, 13, 13, 5215, 10876, 13, 3166, 10377, 2029, 1053, 306, 29886, 3524, 13, 3166, 29784, 1053, 2379, 1278, 29892, 4390, 1598, 29892, 27450, 29892, 1207, 29918, 5327, 13, 13, 932, 353, 2379, 1278, 22168, 978, 1649, 29897, 13, 13, 29992, 932, 29889, 13134, 11974, 29966, 666, 29918, 10030, 20690, 1159, 13, 1753, 10377, 29918, 4478, 29898, 666, 29918, 10030, 29922, 8516, 1125, 13, 1678, 565, 10377, 29918, 10030, 338, 6213, 29901, 13, 4706, 27450, 29898, 5675, 29918, 5327, 703, 2392, 29901, 4750, 292, 5641, 16428, 613, 29871, 29946, 29900, 29900, 876, 13, 1678, 565, 451, 338, 29918, 3084, 29918, 666, 29894, 29946, 29898, 666, 29918, 10030, 1125, 13, 4706, 27450, 29898, 5675, 29918, 5327, 703, 2392, 29901, 21403, 5641, 16428, 613, 29871, 29946, 29900, 29900, 876, 13, 1678, 1180, 29918, 1272, 353, 10377, 2029, 29889, 20401, 29898, 666, 29918, 10030, 29897, 13, 1678, 736, 4390, 1598, 29898, 2029, 29918, 1272, 29897, 13, 13, 29992, 932, 29889, 13134, 11974, 29966, 666, 29918, 10030, 20690, 29966, 1989, 20690, 1159, 13, 1753, 10377, 29918, 4478, 29918, 1609, 29918, 1989, 29898, 666, 29918, 10030, 29922, 8516, 29892, 1820, 29922, 8516, 1125, 13, 1678, 565, 10377, 29918, 10030, 338, 6213, 470, 1820, 338, 6213, 29901, 13, 4706, 27450, 29898, 5675, 29918, 5327, 703, 2392, 29901, 21403, 4128, 4944, 613, 29871, 29946, 29900, 29900, 876, 13, 1678, 565, 451, 338, 29918, 3084, 29918, 666, 29894, 29946, 29898, 666, 29918, 10030, 1125, 13, 4706, 27450, 29898, 5675, 29918, 5327, 703, 2392, 29901, 21403, 5641, 16428, 613, 29871, 29946, 29900, 29900, 876, 13, 1678, 1180, 29918, 1272, 353, 10377, 2029, 29889, 20401, 29898, 666, 29918, 10030, 29897, 13, 1678, 2933, 29918, 5415, 353, 6571, 13, 1678, 6611, 353, 1820, 29889, 5451, 29317, 1495, 13, 1678, 363, 413, 297, 6611, 29901, 13, 4706, 565, 1180, 29918, 1272, 29889, 657, 29898, 710, 29898, 29895, 876, 338, 451, 6213, 29901, 13, 9651, 2933, 29918, 5415, 29961, 29895, 29962, 353, 1180, 29918, 1272, 29889, 657, 29898, 710, 29898, 29895, 876, 13, 1678, 736, 4390, 1598, 29898, 5327, 29918, 5415, 29897, 13, 13, 1753, 338, 29918, 3084, 29918, 666, 29894, 29946, 29898, 10030, 1125, 13, 1678, 12785, 353, 28915, 29889, 5451, 12839, 1495, 13, 1678, 565, 7431, 29898, 12343, 778, 29897, 2804, 29871, 29946, 29901, 736, 7700, 13, 1678, 1018, 29901, 736, 599, 29898, 29900, 14065, 524, 29898, 29886, 29897, 29966, 29906, 29945, 29953, 363, 282, 297, 12785, 29897, 13, 1678, 5174, 7865, 2392, 29901, 736, 7700, 13, 13, 4381, 29879, 353, 426, 13, 1678, 376, 2029, 29918, 1272, 29918, 1445, 1115, 525, 1272, 29914, 6508, 29889, 7638, 742, 13, 1678, 376, 4512, 29918, 1272, 29918, 1445, 1115, 525, 1272, 29914, 7445, 29879, 29889, 7638, 29915, 13, 29913, 13, 13, 361, 7431, 29898, 9675, 29889, 19218, 29897, 529, 29871, 29941, 29901, 13, 1678, 1180, 29918, 1445, 353, 21274, 1839, 2029, 29918, 1272, 29918, 1445, 2033, 13, 1678, 474, 567, 29918, 1445, 353, 21274, 1839, 4512, 29918, 1272, 29918, 1445, 2033, 13, 2870, 29901, 13, 1678, 1180, 29918, 1445, 353, 10876, 29889, 19218, 29961, 29896, 29962, 13, 1678, 474, 567, 29918, 1445, 353, 10876, 29889, 19218, 29961, 29906, 29962, 13, 13, 666, 2029, 353, 306, 29886, 3524, 29898, 2029, 29918, 1445, 29892, 474, 567, 29918, 1445, 29897, 13, 932, 29889, 3389, 29898, 3069, 2433, 29900, 29889, 29900, 29889, 29900, 29889, 29900, 1495, 2 ]
artifact/generateJSON.py
darchr/gem5art
19
73104
import json from uuid import UUID from pymongo import MongoClient data = {} def _convertForJson(d): for k,v in d.items(): if isinstance(v, UUID): d[k] = str(v) if isinstance(v, list): v = [str(s) for s in v] d[k] = v return d db = MongoClient().artifact_database data['gem5Data'] = [] for i in db.artifacts.find(limit=20): data['gem5Data'].append(_convertForJson(i)) with open('data.json', 'w') as outfile: json.dump(data['gem5Data'],outfile)
[ 1, 1053, 4390, 13, 3166, 318, 5416, 1053, 501, 11150, 13, 3166, 282, 962, 7443, 1053, 18294, 4032, 13, 1272, 353, 6571, 13, 1753, 903, 13441, 2831, 8148, 29898, 29881, 1125, 13, 1678, 363, 413, 29892, 29894, 297, 270, 29889, 7076, 7295, 13, 4706, 565, 338, 8758, 29898, 29894, 29892, 501, 11150, 1125, 13, 9651, 270, 29961, 29895, 29962, 353, 851, 29898, 29894, 29897, 13, 4706, 565, 338, 8758, 29898, 29894, 29892, 1051, 1125, 13, 9651, 325, 353, 518, 710, 29898, 29879, 29897, 363, 269, 297, 325, 29962, 13, 9651, 270, 29961, 29895, 29962, 353, 325, 13, 1678, 736, 270, 13, 2585, 353, 18294, 4032, 2141, 8813, 29918, 9803, 13, 1272, 1839, 17797, 29945, 1469, 2033, 353, 5159, 13, 1454, 474, 297, 4833, 29889, 8813, 29879, 29889, 2886, 29898, 13400, 29922, 29906, 29900, 1125, 13, 1678, 848, 1839, 17797, 29945, 1469, 13359, 4397, 7373, 13441, 2831, 8148, 29898, 29875, 876, 13, 13, 2541, 1722, 877, 1272, 29889, 3126, 742, 525, 29893, 1495, 408, 714, 1445, 29901, 13, 1678, 4390, 29889, 15070, 29898, 1272, 1839, 17797, 29945, 1469, 7464, 449, 1445, 29897, 13, 2 ]
sam_auto_start_stop_ec2/lambda/AutoStopEC2Instance.py
aws-samples/aws-cfn-save-costs-auto-start-stop-ec2
1
161653
import boto3 import logging import os logger = logging.getLogger() logger.setLevel(logging.INFO) region = os.environ['AWS_REGION'] ec2 = boto3.resource('ec2', region_name=region) def lambda_handler(event, context): filters = [ { 'Name': 'tag:AutoStop', 'Values': ['TRUE','True','true'] }, { 'Name': 'instance-state-name', 'Values': ['running'] } ] instances = ec2.instances.filter(Filters=filters) RunningInstances = [instance.id for instance in instances] print("Running Instances with AutoStop Tag : " + str(RunningInstances)) if len(RunningInstances) > 0: for instance in instances: if instance.state['Name'] == 'running': print("Stopping Instance : " + instance.id) AutoStopping = ec2.instances.filter(InstanceIds=RunningInstances).stop() print("Stopped Instances : " + str(RunningInstances)) else: print("Instance not in Running state or AutoStop Tag not set...")
[ 1, 1053, 289, 3747, 29941, 30004, 13, 5215, 12183, 30004, 13, 5215, 2897, 30004, 13, 30004, 13, 21707, 353, 12183, 29889, 657, 16363, 26471, 13, 21707, 29889, 842, 10108, 29898, 21027, 29889, 11690, 8443, 13, 30004, 13, 12803, 353, 2897, 29889, 21813, 1839, 29909, 7811, 29918, 18166, 2725, 2033, 30004, 13, 687, 29906, 353, 289, 3747, 29941, 29889, 10314, 877, 687, 29906, 742, 5120, 29918, 978, 29922, 12803, 8443, 13, 30004, 13, 1753, 14013, 29918, 13789, 29898, 3696, 29892, 3030, 1125, 30004, 13, 30004, 13, 1678, 18094, 353, 518, 30004, 13, 4706, 3336, 13, 9651, 525, 1170, 2396, 525, 4039, 29901, 12300, 16329, 23592, 13, 9651, 525, 9065, 2396, 6024, 20652, 3788, 5574, 3788, 3009, 2033, 30004, 13, 4706, 2981, 30004, 13, 4706, 3336, 13, 9651, 525, 1170, 2396, 525, 8758, 29899, 3859, 29899, 978, 23592, 13, 9651, 525, 9065, 2396, 6024, 21094, 2033, 30004, 13, 4706, 4970, 13, 1678, 4514, 30004, 13, 30004, 13, 1678, 8871, 353, 21226, 29906, 29889, 2611, 2925, 29889, 4572, 29898, 3434, 2153, 29922, 26705, 8443, 13, 1678, 19509, 3379, 2925, 353, 518, 8758, 29889, 333, 363, 2777, 297, 8871, 29962, 30004, 13, 1678, 1596, 703, 27795, 2799, 2925, 411, 11133, 16329, 10522, 584, 376, 718, 851, 29898, 27795, 3379, 2925, 876, 30004, 13, 30004, 13, 1678, 565, 7431, 29898, 27795, 3379, 2925, 29897, 1405, 29871, 29900, 29901, 30004, 13, 4706, 363, 2777, 297, 8871, 29901, 30004, 13, 9651, 565, 2777, 29889, 3859, 1839, 1170, 2033, 1275, 525, 21094, 2396, 30004, 13, 18884, 1596, 703, 20754, 3262, 2799, 749, 584, 376, 718, 2777, 29889, 333, 8443, 13, 4706, 11133, 20754, 3262, 353, 21226, 29906, 29889, 2611, 2925, 29889, 4572, 29898, 4998, 21943, 29922, 27795, 3379, 2925, 467, 9847, 26471, 13, 4706, 1596, 703, 20754, 2986, 2799, 2925, 584, 376, 718, 851, 29898, 27795, 3379, 2925, 876, 30004, 13, 1678, 1683, 29901, 30004, 13, 4706, 1596, 703, 4998, 451, 297, 19509, 2106, 470, 11133, 16329, 10522, 451, 731, 856, 1159, 30004, 13, 2 ]
Coursera/Week.6/Task.18.py
v1nnyb0y/Coursera.BasePython
0
161274
''' Семипроцентный барьер ''' parties = [] votes = [] sum_votes = 0 with open('input.txt', 'r', encoding='utf8') as file: flag = False for line in file: line_el = line.split() line = line.replace('\n', '') if (line_el[0][1:] == 'PARTIES:'): continue elif (line_el[0] == 'VOTES:'): flag = True continue if (flag): sum_votes += 1 votes[parties.index(line)] += 1 else: parties.append(line) votes.append(0) for id in range(len(parties)): if (votes[id] / sum_votes >= 0.07): print(parties[id])
[ 1, 14550, 13, 30008, 29919, 989, 5945, 23537, 2370, 836, 1515, 29978, 780, 13, 12008, 13, 1595, 583, 353, 5159, 13, 29894, 4769, 353, 5159, 13, 2083, 29918, 29894, 4769, 353, 29871, 29900, 13, 2541, 1722, 877, 2080, 29889, 3945, 742, 525, 29878, 742, 8025, 2433, 9420, 29947, 1495, 408, 934, 29901, 13, 1678, 7353, 353, 7700, 13, 1678, 363, 1196, 297, 934, 29901, 13, 4706, 1196, 29918, 295, 353, 1196, 29889, 5451, 580, 13, 4706, 1196, 353, 1196, 29889, 6506, 28909, 29876, 742, 27255, 13, 4706, 565, 313, 1220, 29918, 295, 29961, 29900, 3816, 29896, 17531, 1275, 525, 26092, 29059, 11283, 1125, 13, 9651, 6773, 13, 4706, 25342, 313, 1220, 29918, 295, 29961, 29900, 29962, 1275, 525, 29963, 2891, 2890, 11283, 1125, 13, 9651, 7353, 353, 5852, 13, 9651, 6773, 13, 4706, 565, 313, 15581, 1125, 13, 9651, 2533, 29918, 29894, 4769, 4619, 29871, 29896, 13, 9651, 18952, 29961, 1595, 583, 29889, 2248, 29898, 1220, 4638, 4619, 29871, 29896, 13, 4706, 1683, 29901, 13, 9651, 13973, 29889, 4397, 29898, 1220, 29897, 13, 9651, 18952, 29889, 4397, 29898, 29900, 29897, 13, 1454, 1178, 297, 3464, 29898, 2435, 29898, 1595, 583, 22164, 13, 1678, 565, 313, 29894, 4769, 29961, 333, 29962, 847, 2533, 29918, 29894, 4769, 6736, 29871, 29900, 29889, 29900, 29955, 1125, 13, 4706, 1596, 29898, 1595, 583, 29961, 333, 2314, 13, 2 ]
etl_e2e/census_etl/tests/census_spec_scanner_test.py
thinkmoore/das
35
107084
#!/usr/bin/python # -*- coding: utf-8 -*- # # Test for the MDF import os import os.path import sys sys.path.append(os.path.join(os.path.dirname(__file__),"..")) from schema import Range,Variable,Table from census_spec_scanner import CensusSpec TEST_FNAME = os.path.join(os.path.dirname(__file__), "docx_test/test_file_layout.docx") def test_mdf_reader(): cs = CensusSpec() cs.load_schema_from_file(TEST_FNAME) mdf = list(cs.tables()) assert type(mdf)==list assert len(mdf) == 1 # demo file has but a single table assert type(mdf[0]) == Table assert mdf[0].name == "Test_Apples" if __name__=="__main__": test_mdf_reader()
[ 1, 18787, 4855, 29914, 2109, 29914, 4691, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 13, 29937, 4321, 363, 278, 341, 4037, 13, 13, 5215, 2897, 13, 5215, 2897, 29889, 2084, 13, 5215, 10876, 13, 13, 9675, 29889, 2084, 29889, 4397, 29898, 359, 29889, 2084, 29889, 7122, 29898, 359, 29889, 2084, 29889, 25721, 22168, 1445, 1649, 511, 29908, 636, 5783, 13, 13, 3166, 10938, 1053, 12146, 29892, 16174, 29892, 3562, 13, 3166, 16411, 29918, 6550, 29918, 1557, 7310, 1053, 20121, 10299, 13, 13, 18267, 29918, 29943, 5813, 353, 2897, 29889, 2084, 29889, 7122, 29898, 359, 29889, 2084, 29889, 25721, 22168, 1445, 1649, 511, 376, 1514, 29916, 29918, 1688, 29914, 1688, 29918, 1445, 29918, 2680, 29889, 1514, 29916, 1159, 13, 13, 1753, 1243, 29918, 29885, 2176, 29918, 16950, 7295, 13, 1678, 5939, 353, 20121, 10299, 580, 13, 1678, 5939, 29889, 1359, 29918, 11010, 29918, 3166, 29918, 1445, 29898, 18267, 29918, 29943, 5813, 29897, 13, 1678, 286, 2176, 353, 1051, 29898, 2395, 29889, 24051, 3101, 13, 1678, 4974, 1134, 29898, 29885, 2176, 29897, 1360, 1761, 13, 1678, 4974, 7431, 29898, 29885, 2176, 29897, 1275, 29871, 29896, 4706, 396, 13455, 934, 756, 541, 263, 2323, 1591, 13, 1678, 4974, 1134, 29898, 29885, 2176, 29961, 29900, 2314, 1275, 6137, 13, 1678, 4974, 286, 2176, 29961, 29900, 1822, 978, 1275, 376, 3057, 29918, 2052, 793, 29908, 13, 13, 13, 361, 4770, 978, 1649, 26359, 1649, 3396, 1649, 1115, 13, 1678, 1243, 29918, 29885, 2176, 29918, 16950, 580, 13, 2 ]
py/qaviton/locator.py
qaviton/qaviton
9
156227
# Licensed to the Software Freedom Conservancy (SFC) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The SFC licenses this file # to you 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 appium.webdriver.webelement import WebElement from selenium.webdriver.common.by import By from appium.webdriver.common.mobileby import MobileBy from qaviton.utils.condition import value_in_many_any class ByExtension(By): """ This is an extension to the By class use this class to choose a locating strategy for web elements! """ ELEMENT = 'element' ELEMENTS = 'elements' INDEX = 'index' class ByExtensionMap: """ This extension is intended for mappings in the By class """ CLS = 'class' CSS = 'css' TEXT = 'text' ATTRIBUTE_NAME = 'attribute name' class Locator: """ this is the WebPage element webLocator class it is intended to be inherited by other locators of real pages. place all common search methods under this super class: format method: is used only when a paired search (list/tuple that consists of 2 values) is required to change the format of its index[1] value. example usage: import Locator class Locator(Locator): button1 = ('id', 'button{}-id') name = ('text', '{name}') webLocator = Locator print(webLocator.format(webLocator.button1, 1)) print(webLocator.format(webLocator.common.name, name="louis bow")) >> ['id', 'button1-id'] >> ['text', '<NAME>'] element method: give it an element and get in return a tuple like so: (webLocator.element(element)) text method: give it a text and get in return a tuple like so: ('text', element) __call__ method: give it any attribute name & value and get in return a tuple like so: (<attribute name string>, <attribute value string>) """ class BY(ByExtension, ByExtensionMap, MobileBy): pass @staticmethod def format(locator, *args, **kw): """ :type locator: tuple :rtype: tuple """ if len(locator) > 1: if isinstance(locator[1], str): return locator[0], locator[1].format(*args, **kw) @staticmethod def add(locator, value): """ :type locator: tuple :type value: str :rtype: tuple """ if len(locator) > 1: return locator[0], locator[1] + value @staticmethod def xpath_translator(by, value): return By.XPATH, "//*[@{}='{}']".format(by, value) @staticmethod def any(locator): """ this method maps the element locating strategy to its value :type locator: tuple example: webLocator=('class', 'top.right') """ by, value = locator # match to existing strategies if value_in_many_any(by, (vars(ByExtension).values(), vars(By).values(), vars(MobileBy).values())): return locator # map to extension strategies elif by == ByExtensionMap.CLS: return Locator.cls(value) elif by == ByExtensionMap.CSS: return Locator.css(value) elif by == ByExtensionMap.TEXT: return Locator.text(value) elif by == ByExtensionMap.ATTRIBUTE_NAME: return Locator.attribute_name(value) # find element using any attribute else: by, value = Locator.xpath_translator(by, value) return by, value @staticmethod def index(locator, index=0): """ return an element from a list :type locator: tuple :param index: what element to return """ return ByExtension.INDEX, index, locator @staticmethod def list(*list_of_locators): """ return a mapped list of locators :type list_of_locators: list or tuple :param list_of_locators: a list of locator tuples """ return [locator for locator in list_of_locators] @staticmethod def tuple(*tuple_of_locators): """ return a mapped tuple of locators :type tuple_of_locators: tuple or list :param tuple_of_locators: a tuple of locator tuples """ return tuple_of_locators @staticmethod def element(web_element): """ return a mapped web element :type web_element: WebElement """ return ByExtension.ELEMENT, web_element @staticmethod def elements(list_of_web_elements): """ return a mapped list of web elements :type list_of_web_elements: list[WebElement] """ return ByExtension.ELEMENTS, list_of_web_elements @staticmethod def attribute_name(attribute_name_locator: str): """ return a mapped web element by its attribute name""" return By.XPATH, "//*[starts-with(@{},'')]".format(attribute_name_locator) @staticmethod def text(text_locator: str): """ return a mapped web element by its text""" return By.XPATH, "//*[{}()='{}']".format(ByExtensionMap.TEXT, text_locator) @staticmethod def xpath(xpath_locator: str): """ return a mapped web element by xpath""" return By.XPATH, xpath_locator @staticmethod def css(css_locator: str): """ return a mapped web element by css""" return By.CSS_SELECTOR, css_locator @staticmethod def cls(class_locator: str): """ return a mapped web element by its class""" return By.CLASS_NAME, class_locator @staticmethod def id(id_locator: str): """ return a mapped web element by its id""" return By.ID, id_locator @staticmethod def link_text(link_text_locator: str): """ return a mapped web element by its link text""" return By.LINK_TEXT, link_text_locator @staticmethod def partial_link_text(partial_link_text_locator: str): """ return a mapped web element by its partial link text""" return By.PARTIAL_LINK_TEXT, partial_link_text_locator @staticmethod def tag_name(tag_name_locator: str): """ return a mapped web element by its html tag name""" return By.TAG_NAME, tag_name_locator @staticmethod def name(name_locator: str): """ return a mapped web element by its name property""" return By.NAME, name_locator @staticmethod def ios_predicate(ios_predicate_locator: str): """ return a mapped web element by its ios predicate string""" return MobileBy.IOS_PREDICATE, ios_predicate_locator @staticmethod def ios_ui_automation(ios_ui_automation_locator: str): """ return a mapped web element by its ios ui automation""" return MobileBy.IOS_UIAUTOMATION, ios_ui_automation_locator @staticmethod def ios_class_chain(ios_class_chain_locator: str): """ return a mapped web element by its ios class chain""" return MobileBy.IOS_CLASS_CHAIN, ios_class_chain_locator @staticmethod def android_ui_automation(android_ui_automation_locator: str): """ return a mapped web element by its android ui automation""" return MobileBy.ANDROID_UIAUTOMATOR, android_ui_automation_locator @staticmethod def accessibility_id(accessibility_id_locator: str): """ return a mapped web element by its accessibility id""" return MobileBy.ACCESSIBILITY_ID, accessibility_id_locator @staticmethod def image(image_locator: str): """ return a mapped web element by image""" return MobileBy.IMAGE, image_locator
[ 1, 396, 10413, 21144, 304, 278, 18540, 3878, 11607, 15312, 6906, 313, 29903, 8610, 29897, 1090, 697, 13, 29937, 470, 901, 17737, 3406, 19405, 8571, 4110, 29889, 29871, 2823, 278, 6058, 12107, 934, 13, 29937, 13235, 411, 445, 664, 363, 5684, 2472, 13, 29937, 11211, 3509, 1266, 27428, 29889, 29871, 450, 317, 8610, 7794, 11259, 445, 934, 13, 29937, 304, 366, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 13, 29937, 376, 29931, 293, 1947, 1496, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 13, 29937, 411, 278, 19245, 29889, 29871, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 259, 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, 13, 29937, 7047, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 13, 29937, 376, 3289, 8519, 29908, 350, 3289, 3235, 29892, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 13, 29937, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 29871, 2823, 278, 19245, 363, 278, 13, 29937, 2702, 4086, 14765, 1076, 11239, 322, 27028, 13, 29937, 1090, 278, 19245, 29889, 13, 13, 13, 3166, 623, 1974, 29889, 29813, 29889, 705, 915, 944, 1053, 2563, 2642, 13, 3166, 18866, 29889, 29813, 29889, 9435, 29889, 1609, 1053, 2648, 13, 3166, 623, 1974, 29889, 29813, 29889, 9435, 29889, 16769, 1609, 1053, 21600, 2059, 13, 3166, 3855, 485, 277, 265, 29889, 13239, 29889, 16122, 1053, 995, 29918, 262, 29918, 13011, 29918, 1384, 13, 13, 13, 1990, 2648, 17657, 29898, 2059, 1125, 13, 1678, 9995, 13, 1678, 910, 338, 385, 6081, 304, 278, 2648, 770, 13, 1678, 671, 445, 770, 304, 6755, 263, 1180, 1218, 13705, 363, 1856, 3161, 29991, 13, 1678, 9995, 13, 1678, 382, 1307, 13780, 353, 525, 5029, 29915, 13, 1678, 382, 1307, 13780, 29903, 353, 525, 17664, 29915, 13, 1678, 2672, 19577, 353, 525, 2248, 29915, 13, 13, 13, 1990, 2648, 17657, 3388, 29901, 13, 1678, 9995, 13, 1678, 910, 6081, 338, 9146, 363, 611, 27775, 297, 278, 2648, 770, 13, 1678, 9995, 13, 1678, 315, 8547, 353, 525, 1990, 29915, 13, 1678, 6783, 353, 525, 4268, 29915, 13, 1678, 323, 12194, 353, 525, 726, 29915, 13, 1678, 15531, 29911, 3960, 29933, 26027, 29918, 5813, 353, 525, 12715, 1024, 29915, 13, 13, 13, 1990, 5976, 1061, 29901, 13, 1678, 9995, 445, 338, 278, 2563, 5074, 1543, 1856, 3524, 1061, 770, 13, 4706, 372, 338, 9146, 304, 367, 23878, 491, 916, 1180, 4097, 310, 1855, 6515, 29889, 13, 4706, 2058, 599, 3619, 2740, 3519, 1090, 445, 2428, 770, 29901, 13, 13, 4706, 3402, 1158, 29901, 13, 9651, 338, 1304, 871, 746, 263, 3300, 2859, 2740, 313, 1761, 29914, 23583, 393, 11624, 310, 29871, 29906, 1819, 29897, 13, 9651, 338, 3734, 304, 1735, 278, 3402, 310, 967, 2380, 29961, 29896, 29962, 995, 29889, 13, 9651, 1342, 8744, 29901, 13, 13, 18884, 1053, 5976, 1061, 13, 13, 18884, 770, 5976, 1061, 29898, 3524, 1061, 1125, 13, 462, 1678, 2826, 29896, 353, 6702, 333, 742, 525, 3092, 29912, 7402, 333, 1495, 13, 462, 1678, 1024, 353, 6702, 726, 742, 22372, 978, 29913, 1495, 13, 13, 18884, 1856, 3524, 1061, 353, 5976, 1061, 13, 13, 18884, 1596, 29898, 2676, 3524, 1061, 29889, 4830, 29898, 2676, 3524, 1061, 29889, 3092, 29896, 29892, 29871, 29896, 876, 13, 18884, 1596, 29898, 2676, 3524, 1061, 29889, 4830, 29898, 2676, 3524, 1061, 29889, 9435, 29889, 978, 29892, 1024, 543, 23581, 275, 12580, 5783, 13, 13, 18884, 5099, 6024, 333, 742, 525, 3092, 29896, 29899, 333, 2033, 13, 18884, 5099, 6024, 726, 742, 12801, 5813, 29958, 2033, 13, 13, 4706, 1543, 1158, 29901, 13, 9651, 2367, 372, 385, 1543, 322, 679, 297, 736, 263, 18761, 763, 577, 29901, 13, 9651, 313, 2676, 3524, 1061, 29889, 5029, 29898, 5029, 876, 13, 13, 4706, 1426, 1158, 29901, 13, 9651, 2367, 372, 263, 1426, 322, 679, 297, 736, 263, 18761, 763, 577, 29901, 13, 9651, 6702, 726, 742, 1543, 29897, 13, 13, 4706, 4770, 4804, 1649, 1158, 29901, 13, 9651, 2367, 372, 738, 5352, 1024, 669, 995, 322, 679, 297, 736, 263, 18761, 763, 577, 29901, 13, 9651, 313, 29966, 12715, 1024, 1347, 10202, 529, 12715, 995, 1347, 12948, 13, 1678, 9995, 13, 13, 1678, 770, 6770, 29898, 2059, 17657, 29892, 2648, 17657, 3388, 29892, 21600, 2059, 1125, 13, 4706, 1209, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 3402, 29898, 2029, 1061, 29892, 334, 5085, 29892, 3579, 11022, 1125, 13, 4706, 9995, 13, 4706, 584, 1853, 1180, 1061, 29901, 18761, 13, 4706, 584, 29878, 1853, 29901, 18761, 13, 4706, 9995, 13, 4706, 565, 7431, 29898, 2029, 1061, 29897, 1405, 29871, 29896, 29901, 13, 9651, 565, 338, 8758, 29898, 2029, 1061, 29961, 29896, 1402, 851, 1125, 13, 18884, 736, 1180, 1061, 29961, 29900, 1402, 1180, 1061, 29961, 29896, 1822, 4830, 10456, 5085, 29892, 3579, 11022, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 788, 29898, 2029, 1061, 29892, 995, 1125, 13, 4706, 9995, 13, 4706, 584, 1853, 1180, 1061, 29901, 18761, 13, 4706, 584, 1853, 995, 29901, 851, 13, 4706, 584, 29878, 1853, 29901, 18761, 13, 4706, 9995, 13, 4706, 565, 7431, 29898, 2029, 1061, 29897, 1405, 29871, 29896, 29901, 13, 9651, 736, 1180, 1061, 29961, 29900, 1402, 1180, 1061, 29961, 29896, 29962, 718, 995, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 921, 2084, 29918, 3286, 29880, 1061, 29898, 1609, 29892, 995, 1125, 13, 4706, 736, 2648, 29889, 29990, 10145, 29892, 376, 458, 29930, 17548, 8875, 2433, 8875, 2033, 1642, 4830, 29898, 1609, 29892, 995, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 738, 29898, 2029, 1061, 1125, 13, 4706, 9995, 13, 4706, 445, 1158, 11053, 278, 1543, 1180, 1218, 13705, 304, 967, 995, 13, 4706, 584, 1853, 1180, 1061, 29901, 18761, 13, 18884, 1342, 29901, 1856, 3524, 1061, 29922, 877, 1990, 742, 525, 3332, 29889, 1266, 1495, 13, 4706, 9995, 13, 4706, 491, 29892, 995, 353, 1180, 1061, 13, 13, 4706, 396, 1993, 304, 5923, 16650, 583, 13, 4706, 565, 995, 29918, 262, 29918, 13011, 29918, 1384, 29898, 1609, 29892, 313, 16908, 29898, 2059, 17657, 467, 5975, 3285, 24987, 29898, 2059, 467, 5975, 3285, 24987, 29898, 29295, 2059, 467, 5975, 22130, 29901, 13, 9651, 736, 1180, 1061, 13, 13, 4706, 396, 2910, 304, 6081, 16650, 583, 13, 4706, 25342, 491, 1275, 2648, 17657, 3388, 29889, 6154, 29903, 29901, 13, 9651, 736, 5976, 1061, 29889, 25932, 29898, 1767, 29897, 13, 4706, 25342, 491, 1275, 2648, 17657, 3388, 29889, 19407, 29901, 13, 9651, 736, 5976, 1061, 29889, 4268, 29898, 1767, 29897, 13, 4706, 25342, 491, 1275, 2648, 17657, 3388, 29889, 16975, 29901, 13, 9651, 736, 5976, 1061, 29889, 726, 29898, 1767, 29897, 13, 4706, 25342, 491, 1275, 2648, 17657, 3388, 29889, 1299, 29911, 3960, 29933, 26027, 29918, 5813, 29901, 13, 9651, 736, 5976, 1061, 29889, 12715, 29918, 978, 29898, 1767, 29897, 13, 13, 4706, 396, 1284, 1543, 773, 738, 5352, 13, 4706, 1683, 29901, 13, 9651, 491, 29892, 995, 353, 5976, 1061, 29889, 23635, 29918, 3286, 29880, 1061, 29898, 1609, 29892, 995, 29897, 13, 4706, 736, 491, 29892, 995, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 2380, 29898, 2029, 1061, 29892, 2380, 29922, 29900, 1125, 13, 4706, 9995, 736, 385, 1543, 515, 263, 1051, 13, 4706, 584, 1853, 1180, 1061, 29901, 18761, 13, 4706, 584, 3207, 2380, 29901, 825, 1543, 304, 736, 9995, 13, 4706, 736, 2648, 17657, 29889, 27992, 29892, 2380, 29892, 1180, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1051, 10456, 1761, 29918, 974, 29918, 2029, 4097, 1125, 13, 4706, 9995, 736, 263, 20545, 1051, 310, 1180, 4097, 13, 4706, 584, 1853, 1051, 29918, 974, 29918, 2029, 4097, 29901, 1051, 470, 18761, 13, 4706, 584, 3207, 1051, 29918, 974, 29918, 2029, 4097, 29901, 263, 1051, 310, 1180, 1061, 5291, 2701, 9995, 13, 4706, 736, 518, 2029, 1061, 363, 1180, 1061, 297, 1051, 29918, 974, 29918, 2029, 4097, 29962, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 18761, 10456, 23583, 29918, 974, 29918, 2029, 4097, 1125, 13, 4706, 9995, 736, 263, 20545, 18761, 310, 1180, 4097, 13, 4706, 584, 1853, 18761, 29918, 974, 29918, 2029, 4097, 29901, 18761, 470, 1051, 13, 4706, 584, 3207, 18761, 29918, 974, 29918, 2029, 4097, 29901, 263, 18761, 310, 1180, 1061, 5291, 2701, 9995, 13, 4706, 736, 18761, 29918, 974, 29918, 2029, 4097, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1543, 29898, 2676, 29918, 5029, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 13, 4706, 584, 1853, 1856, 29918, 5029, 29901, 2563, 2642, 9995, 13, 4706, 736, 2648, 17657, 29889, 29923, 1307, 13780, 29892, 1856, 29918, 5029, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 3161, 29898, 1761, 29918, 974, 29918, 2676, 29918, 17664, 1125, 13, 4706, 9995, 736, 263, 20545, 1051, 310, 1856, 3161, 13, 4706, 584, 1853, 1051, 29918, 974, 29918, 2676, 29918, 17664, 29901, 1051, 29961, 3609, 2642, 29962, 9995, 13, 4706, 736, 2648, 17657, 29889, 29923, 1307, 13780, 29903, 29892, 1051, 29918, 974, 29918, 2676, 29918, 17664, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 5352, 29918, 978, 29898, 12715, 29918, 978, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 5352, 1024, 15945, 29908, 13, 4706, 736, 2648, 29889, 29990, 10145, 29892, 376, 458, 29930, 29961, 27382, 29899, 2541, 10394, 29912, 1118, 29915, 1495, 29962, 1642, 4830, 29898, 12715, 29918, 978, 29918, 2029, 1061, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1426, 29898, 726, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 1426, 15945, 29908, 13, 4706, 736, 2648, 29889, 29990, 10145, 29892, 376, 458, 29930, 29961, 8875, 580, 2433, 8875, 2033, 1642, 4830, 29898, 2059, 17657, 3388, 29889, 16975, 29892, 1426, 29918, 2029, 1061, 29897, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 921, 2084, 29898, 23635, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 921, 2084, 15945, 29908, 13, 4706, 736, 2648, 29889, 29990, 10145, 29892, 921, 2084, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 5997, 29898, 4268, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 5997, 15945, 29908, 13, 4706, 736, 2648, 29889, 19407, 29918, 6404, 1955, 29892, 5997, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1067, 29879, 29898, 1990, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 770, 15945, 29908, 13, 4706, 736, 2648, 29889, 13875, 1799, 29918, 5813, 29892, 770, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1178, 29898, 333, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 1178, 15945, 29908, 13, 4706, 736, 2648, 29889, 1367, 29892, 1178, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1544, 29918, 726, 29898, 2324, 29918, 726, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 1544, 1426, 15945, 29908, 13, 4706, 736, 2648, 29889, 23714, 29968, 29918, 16975, 29892, 1544, 29918, 726, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 7687, 29918, 2324, 29918, 726, 29898, 3846, 29918, 2324, 29918, 726, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 7687, 1544, 1426, 15945, 29908, 13, 4706, 736, 2648, 29889, 26092, 25758, 29918, 23714, 29968, 29918, 16975, 29892, 7687, 29918, 2324, 29918, 726, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 4055, 29918, 978, 29898, 4039, 29918, 978, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 3472, 4055, 1024, 15945, 29908, 13, 4706, 736, 2648, 29889, 16881, 29918, 5813, 29892, 4055, 29918, 978, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1024, 29898, 978, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 1024, 2875, 15945, 29908, 13, 4706, 736, 2648, 29889, 5813, 29892, 1024, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 10615, 29918, 11965, 9593, 29898, 2363, 29918, 11965, 9593, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 10615, 24384, 1347, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 25925, 29918, 15094, 29928, 2965, 3040, 29892, 10615, 29918, 11965, 9593, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 10615, 29918, 1481, 29918, 17405, 362, 29898, 2363, 29918, 1481, 29918, 17405, 362, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 10615, 14313, 3345, 362, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 25925, 29918, 3120, 20656, 6488, 8098, 29892, 10615, 29918, 1481, 29918, 17405, 362, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 10615, 29918, 1990, 29918, 14153, 29898, 2363, 29918, 1990, 29918, 14153, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 10615, 770, 9704, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 25925, 29918, 13875, 1799, 29918, 3210, 29909, 1177, 29892, 10615, 29918, 1990, 29918, 14153, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1442, 29918, 1481, 29918, 17405, 362, 29898, 2843, 29918, 1481, 29918, 17405, 362, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 1442, 14313, 3345, 362, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 9468, 1672, 1367, 29918, 3120, 20656, 6488, 1299, 1955, 29892, 1442, 29918, 1481, 29918, 17405, 362, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 2130, 4127, 29918, 333, 29898, 5943, 4127, 29918, 333, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 967, 2130, 4127, 1178, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 2477, 23524, 8979, 6227, 11937, 29918, 1367, 29892, 2130, 4127, 29918, 333, 29918, 2029, 1061, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 1967, 29898, 3027, 29918, 2029, 1061, 29901, 851, 1125, 13, 4706, 9995, 736, 263, 20545, 1856, 1543, 491, 1967, 15945, 29908, 13, 4706, 736, 21600, 2059, 29889, 2382, 29892, 1967, 29918, 2029, 1061, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 2 ]
code/oversample.py
DonaldWhyte/high-performance-data-processing-in-python
16
192409
<reponame>DonaldWhyte/high-performance-data-processing-in-python """ TODO: explain """ import argparse import datetime import csv from typing import List, Tuple import pandas as pd _NON_MEASUREMENT_COLUMNS = { 'STATION', 'STATION_NAME', 'ELEVATION', 'LATITUDE', 'LONGITUDE', 'DATE' #'STATION', 'DATE', 'SOURCE', 'LATITUDE', 'LONGITUDE', 'ELEVATION', 'NAME', #'REPORT_TYPE', 'CALL_SIGN', 'QUALITY_CONTROL' } def _main(): args = _parse_args() step_size = { '1sec': 1, '5sec': 5, '10sec': 10, '30sec': 30, '1min': 60, '5min': 60 * 5, '10min': 60 * 10, '30min': 60 * 30 }[args.granularity] df = pd.read_csv(args.input) df.sort_values(['STATION', 'DATE'], inplace=True) float_cols = list(df.select_dtypes(include=['float']).columns) rows = df.to_dict(orient='record') with open(args.output, 'wt') as f: writer = csv.DictWriter(f, fieldnames=rows[0].keys()) writer.writeheader() for a, b in zip(rows[:-1], rows[1:]): writer.writerow(a) if _primary_key(a) == _primary_key(b): a_dt = _to_dt(a['DATE']) b_dt = _to_dt(b['DATE']) # Based on the input granularity/step size, determine how many # samples to add between point a and b, n_steps = int((b_dt - a_dt).total_seconds() / step_size) interpolated_values = { col: _interpolate(float(a[col]), float(b[col]), n_steps) for col in a.keys() if col in float_cols } for step in range(1, n_steps): row = { col: val for col, val in a.items() if col not in float_cols } row['DATE'] = ( (a_dt + datetime.timedelta(seconds=(step * step_size))) .strftime(_DT_FORMAT)) row.update({ col: f'{interpolated_values[col][step]:.4f}' for col in a.keys() if col in float_cols }) writer.writerow(row) # Need to write the final row of the input CSV after the interpolation # loop. writer.writerow(b) def _parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument( '-i', '--input', required=True, help='path to input file to oversample') parser.add_argument( '-o', '--output', required=True, help='path of oversampled file to generate') parser.add_argument( '-g', '--granularity', required=True, choices=('1min', '10min'), help='granularity of oversampling. This determines how many extra ' 'samples will be generated between two time points.') return parser.parse_args() def _primary_key(row: dict) -> Tuple[str, str]: return row['STATION'] def _to_dt(val: str) -> datetime.datetime: return datetime.datetime.strptime(val, _DT_FORMAT) _DT_FORMAT = '%Y-%m-%dT%H:%M%S' def _interpolate(start: float, end: float, n_steps: int) -> List[float]: step_size = (end - start) / n_steps return [start + step_size * step for step in range(n_steps)] if __name__ == '__main__': _main()
[ 1, 529, 276, 1112, 420, 29958, 28080, 11008, 371, 29914, 9812, 29899, 546, 13390, 29899, 1272, 29899, 19170, 29899, 262, 29899, 4691, 13, 15945, 29908, 13, 4986, 3970, 29901, 5649, 13, 15945, 29908, 13, 13, 5215, 1852, 5510, 13, 5215, 12865, 13, 5215, 11799, 13, 3166, 19229, 1053, 2391, 29892, 12603, 552, 13, 13, 5215, 11701, 408, 10518, 13, 13, 13, 29918, 29940, 1164, 29918, 2303, 3289, 11499, 13780, 29918, 15032, 5005, 3059, 353, 426, 13, 1678, 525, 1254, 8098, 742, 525, 1254, 8098, 29918, 5813, 742, 525, 29923, 1307, 29963, 8098, 742, 525, 29931, 1299, 1806, 29965, 2287, 742, 525, 29931, 20614, 1806, 29965, 2287, 742, 525, 6248, 29915, 13, 1678, 396, 29915, 1254, 8098, 742, 525, 6248, 742, 525, 27839, 4741, 742, 525, 29931, 1299, 1806, 29965, 2287, 742, 525, 29931, 20614, 1806, 29965, 2287, 742, 525, 29923, 1307, 29963, 8098, 742, 525, 5813, 742, 13, 1678, 396, 29915, 1525, 15082, 29918, 11116, 742, 525, 29907, 9818, 29918, 5425, 20728, 742, 525, 13356, 1964, 11937, 29918, 22412, 1672, 29931, 29915, 13, 29913, 13, 13, 1753, 903, 3396, 7295, 13, 1678, 6389, 353, 903, 5510, 29918, 5085, 580, 13, 1678, 4331, 29918, 2311, 353, 426, 13, 4706, 525, 29896, 3471, 2396, 29871, 29896, 29892, 13, 4706, 525, 29945, 3471, 2396, 29871, 29945, 29892, 13, 4706, 525, 29896, 29900, 3471, 2396, 29871, 29896, 29900, 29892, 13, 4706, 525, 29941, 29900, 3471, 2396, 29871, 29941, 29900, 29892, 13, 4706, 525, 29896, 1195, 2396, 29871, 29953, 29900, 29892, 13, 4706, 525, 29945, 1195, 2396, 29871, 29953, 29900, 334, 29871, 29945, 29892, 13, 4706, 525, 29896, 29900, 1195, 2396, 29871, 29953, 29900, 334, 29871, 29896, 29900, 29892, 13, 4706, 525, 29941, 29900, 1195, 2396, 29871, 29953, 29900, 334, 29871, 29941, 29900, 13, 1678, 500, 29961, 5085, 29889, 629, 273, 1070, 537, 29962, 13, 13, 1678, 4489, 353, 10518, 29889, 949, 29918, 7638, 29898, 5085, 29889, 2080, 29897, 13, 1678, 4489, 29889, 6605, 29918, 5975, 18959, 1254, 8098, 742, 525, 6248, 7464, 297, 6689, 29922, 5574, 29897, 13, 1678, 5785, 29918, 22724, 353, 1051, 29898, 2176, 29889, 2622, 29918, 29881, 8768, 29898, 2856, 29922, 1839, 7411, 2033, 467, 13099, 29897, 13, 1678, 4206, 353, 4489, 29889, 517, 29918, 8977, 29898, 12236, 2433, 11651, 1495, 13, 13, 1678, 411, 1722, 29898, 5085, 29889, 4905, 29892, 525, 14554, 1495, 408, 285, 29901, 13, 4706, 9227, 353, 11799, 29889, 21533, 10507, 29898, 29888, 29892, 1746, 7039, 29922, 5727, 29961, 29900, 1822, 8149, 3101, 13, 4706, 9227, 29889, 3539, 6672, 580, 13, 4706, 363, 263, 29892, 289, 297, 14319, 29898, 5727, 7503, 29899, 29896, 1402, 4206, 29961, 29896, 17531, 1125, 13, 9651, 9227, 29889, 13236, 340, 29898, 29874, 29897, 13, 9651, 565, 903, 16072, 29918, 1989, 29898, 29874, 29897, 1275, 903, 16072, 29918, 1989, 29898, 29890, 1125, 13, 18884, 263, 29918, 6008, 353, 903, 517, 29918, 6008, 29898, 29874, 1839, 6248, 11287, 13, 18884, 289, 29918, 6008, 353, 903, 517, 29918, 6008, 29898, 29890, 1839, 6248, 11287, 13, 13, 18884, 396, 16564, 373, 278, 1881, 3803, 1070, 537, 29914, 10568, 2159, 29892, 8161, 920, 1784, 13, 18884, 396, 11916, 304, 788, 1546, 1298, 263, 322, 289, 29892, 13, 18884, 302, 29918, 24530, 353, 938, 3552, 29890, 29918, 6008, 448, 263, 29918, 6008, 467, 7827, 29918, 23128, 580, 847, 4331, 29918, 2311, 29897, 13, 18884, 20064, 630, 29918, 5975, 353, 426, 13, 462, 1678, 784, 29901, 903, 1639, 3733, 403, 29898, 7411, 29898, 29874, 29961, 1054, 11724, 5785, 29898, 29890, 29961, 1054, 11724, 302, 29918, 24530, 29897, 13, 462, 1678, 363, 784, 297, 263, 29889, 8149, 580, 565, 784, 297, 5785, 29918, 22724, 13, 18884, 500, 13, 18884, 363, 4331, 297, 3464, 29898, 29896, 29892, 302, 29918, 24530, 1125, 13, 462, 1678, 1948, 353, 426, 13, 462, 4706, 784, 29901, 659, 363, 784, 29892, 659, 297, 263, 29889, 7076, 580, 13, 462, 4706, 565, 784, 451, 297, 5785, 29918, 22724, 13, 462, 1678, 500, 13, 462, 1678, 1948, 1839, 6248, 2033, 353, 313, 13, 462, 4706, 313, 29874, 29918, 6008, 718, 12865, 29889, 9346, 287, 2554, 29898, 23128, 7607, 10568, 334, 4331, 29918, 2311, 4961, 13, 462, 4706, 869, 710, 615, 603, 7373, 12972, 29918, 19094, 1299, 876, 13, 462, 1678, 1948, 29889, 5504, 3319, 13, 462, 4706, 784, 29901, 285, 29915, 29912, 1639, 3733, 630, 29918, 5975, 29961, 1054, 3816, 10568, 5387, 29889, 29946, 29888, 10162, 13, 462, 4706, 363, 784, 297, 263, 29889, 8149, 580, 13, 462, 4706, 565, 784, 297, 5785, 29918, 22724, 13, 462, 1678, 5615, 13, 462, 1678, 9227, 29889, 13236, 340, 29898, 798, 29897, 13, 13, 4706, 396, 20768, 304, 2436, 278, 2186, 1948, 310, 278, 1881, 16874, 1156, 278, 29694, 13, 4706, 396, 2425, 29889, 13, 4706, 9227, 29889, 13236, 340, 29898, 29890, 29897, 13, 13, 13, 1753, 903, 5510, 29918, 5085, 580, 1599, 1852, 5510, 29889, 23335, 29901, 13, 1678, 13812, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 1678, 13812, 29889, 1202, 29918, 23516, 29898, 13, 4706, 17411, 29875, 742, 525, 489, 2080, 742, 13, 4706, 3734, 29922, 5574, 29892, 13, 4706, 1371, 2433, 2084, 304, 1881, 934, 304, 288, 874, 981, 1495, 13, 1678, 13812, 29889, 1202, 29918, 23516, 29898, 13, 4706, 17411, 29877, 742, 525, 489, 4905, 742, 13, 4706, 3734, 29922, 5574, 29892, 13, 4706, 1371, 2433, 2084, 310, 288, 874, 981, 29881, 934, 304, 5706, 1495, 13, 1678, 13812, 29889, 1202, 29918, 23516, 29898, 13, 4706, 17411, 29887, 742, 525, 489, 629, 273, 1070, 537, 742, 13, 4706, 3734, 29922, 5574, 29892, 13, 4706, 19995, 29922, 877, 29896, 1195, 742, 525, 29896, 29900, 1195, 5477, 13, 4706, 1371, 2433, 629, 273, 1070, 537, 310, 288, 874, 314, 10335, 29889, 910, 3683, 1475, 920, 1784, 4805, 525, 13, 632, 525, 27736, 674, 367, 5759, 1546, 1023, 931, 3291, 29889, 1495, 13, 1678, 736, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 13, 13, 1753, 903, 16072, 29918, 1989, 29898, 798, 29901, 9657, 29897, 1599, 12603, 552, 29961, 710, 29892, 851, 5387, 13, 1678, 736, 1948, 1839, 1254, 8098, 2033, 13, 13, 13, 1753, 903, 517, 29918, 6008, 29898, 791, 29901, 851, 29897, 1599, 12865, 29889, 12673, 29901, 13, 1678, 736, 12865, 29889, 12673, 29889, 710, 415, 603, 29898, 791, 29892, 903, 12972, 29918, 19094, 1299, 29897, 13, 13, 13, 29918, 12972, 29918, 19094, 1299, 353, 14210, 29979, 19222, 29885, 19222, 29881, 29911, 29995, 29950, 16664, 29924, 29995, 29903, 29915, 13, 13, 13, 1753, 903, 1639, 3733, 403, 29898, 2962, 29901, 5785, 29892, 1095, 29901, 5785, 29892, 302, 29918, 24530, 29901, 938, 29897, 1599, 2391, 29961, 7411, 5387, 13, 1678, 4331, 29918, 2311, 353, 313, 355, 448, 1369, 29897, 847, 302, 29918, 24530, 13, 1678, 736, 518, 2962, 718, 4331, 29918, 2311, 334, 4331, 363, 4331, 297, 3464, 29898, 29876, 29918, 24530, 4638, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 903, 3396, 580, 13, 2 ]
refresh_dynspec_files.py
jackievilladsen/dynspec
2
53132
''' refresh_dynspec_files.py Purpose: Re-run the step of going from tbavg.ms to tbavg.ms.dynspec for all observations. This is useful because I found a bug in dyn_spec (which reads the dynspec out of tbavg.ms) and so want to redo just this step. ''' import dynspec.ms2dynspec reload(dynspec.ms2dynspec) from dynspec.pipeline_utils import load_ds_filelist from dynspec.ms2dynspec import tbavg2dsfile ds_filelist = load_ds_filelist() failed_list = [] for obs in ds_filelist: obs_filelist = ds_filelist[obs] for ds_file in obs_filelist: tbavg_ms_file = ds_file[:-8] if os.path.exists(tbavg_ms_file): ds_file = tbavg2dsfile(tbavg_ms_file) else: print tbavg_ms_file, 'does not exist' failed_list.append(tbavg_ms_file) print 'Failed list:' print failed_list # failed on VLBA data (except for UVCet_3X...no it wasn't in ds_filelist) --> need to do those separately # (although they shouldn't have much flagging so it shouldn't be as much of an issue) # to do: find code used to create VLBA dynspecs in the first place # find VLBA dynspecs # write script to recreate VLBA dynspecs ls -d /data/jrv/BV071/*/*/*tbavg.ms* /data/jrv/BV071/ADLeo/3/ADLeo_3X.tbavg.ms /data/jrv/BV071/UVCet/3/UVCet_3X.tbavg.ms /data/jrv/BV071/ADLeo/3/ADLeo_3X.tbavg.ms.dynspec /data/jrv/BV071/UVCet/3/UVCet_3X.tbavg.ms.dynspec /data/jrv/BV071/ADLeo/4/ADLeo_4X.tbavg.ms /data/jrv/BV071/UVCet/4/UVCet_4X.tbavg.ms /data/jrv/BV071/ADLeo/4/ADLeo_4X.tbavg.ms.dynspec /data/jrv/BV071/UVCet/4/UVCet_4X.tbavg.ms.dynspec /data/jrv/BV071/ADLeo/5/ADLeo_5X.tbavg.ms /data/jrv/BV071/UVCet/5/UVCet_5X.tbavg.ms /data/jrv/BV071/ADLeo/5/ADLeo_5X.tbavg.ms.dynspec /data/jrv/BV071/UVCet/5/UVCet_5X.tbavg.ms.dynspec # Conclusion: I want to use selfcal'd versions of the data sets for dynspecs anyways, so don't worry about re-creating these dynspecs for the moment.
[ 1, 14550, 13, 22379, 29918, 29881, 948, 6550, 29918, 5325, 29889, 2272, 13, 13, 29925, 332, 4220, 29901, 830, 29899, 3389, 278, 4331, 310, 2675, 515, 260, 29890, 485, 29887, 29889, 1516, 304, 260, 29890, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 363, 599, 13917, 29889, 910, 338, 13, 308, 5407, 1363, 306, 1476, 263, 6494, 297, 270, 948, 29918, 6550, 313, 4716, 13623, 278, 270, 948, 6550, 714, 310, 260, 29890, 485, 29887, 29889, 1516, 29897, 322, 577, 13, 308, 864, 304, 337, 1867, 925, 445, 4331, 29889, 13, 12008, 13, 5215, 270, 948, 6550, 29889, 1516, 29906, 29881, 948, 6550, 13, 28120, 29898, 29881, 948, 6550, 29889, 1516, 29906, 29881, 948, 6550, 29897, 13, 3166, 270, 948, 6550, 29889, 13096, 5570, 29918, 13239, 1053, 2254, 29918, 6289, 29918, 1445, 1761, 13, 3166, 270, 948, 6550, 29889, 1516, 29906, 29881, 948, 6550, 1053, 260, 29890, 485, 29887, 29906, 6289, 1445, 13, 13, 6289, 29918, 1445, 1761, 353, 2254, 29918, 6289, 29918, 1445, 1761, 580, 13, 13, 26061, 29918, 1761, 353, 5159, 13, 1454, 20881, 297, 18031, 29918, 1445, 1761, 29901, 13, 1678, 20881, 29918, 1445, 1761, 353, 18031, 29918, 1445, 1761, 29961, 26290, 29962, 13, 1678, 363, 18031, 29918, 1445, 297, 20881, 29918, 1445, 1761, 29901, 13, 4706, 260, 29890, 485, 29887, 29918, 1516, 29918, 1445, 353, 18031, 29918, 1445, 7503, 29899, 29947, 29962, 13, 4706, 565, 2897, 29889, 2084, 29889, 9933, 29898, 22625, 485, 29887, 29918, 1516, 29918, 1445, 1125, 13, 9651, 18031, 29918, 1445, 353, 260, 29890, 485, 29887, 29906, 6289, 1445, 29898, 22625, 485, 29887, 29918, 1516, 29918, 1445, 29897, 13, 4706, 1683, 29901, 13, 9651, 1596, 260, 29890, 485, 29887, 29918, 1516, 29918, 1445, 29892, 525, 13221, 451, 1863, 29915, 13, 9651, 5229, 29918, 1761, 29889, 4397, 29898, 22625, 485, 29887, 29918, 1516, 29918, 1445, 29897, 13, 13, 2158, 525, 17776, 1051, 11283, 13, 2158, 5229, 29918, 1761, 13, 29937, 5229, 373, 478, 29931, 5688, 848, 313, 19499, 363, 501, 8257, 300, 29918, 29941, 29990, 856, 1217, 372, 9007, 29915, 29873, 297, 18031, 29918, 1445, 1761, 29897, 6660, 817, 304, 437, 1906, 16949, 13, 29937, 313, 26492, 896, 9273, 29915, 29873, 505, 1568, 7353, 3460, 577, 372, 9273, 29915, 29873, 367, 408, 1568, 310, 385, 2228, 29897, 13, 13, 29937, 304, 437, 29901, 1284, 775, 1304, 304, 1653, 478, 29931, 5688, 270, 948, 5965, 2395, 297, 278, 937, 2058, 13, 29937, 1284, 478, 29931, 5688, 270, 948, 5965, 2395, 13, 29937, 2436, 2471, 304, 337, 3258, 478, 29931, 5688, 270, 948, 5965, 2395, 13, 3137, 448, 29881, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3877, 3877, 29930, 22625, 485, 29887, 29889, 1516, 29930, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29941, 29914, 3035, 3226, 29877, 29918, 29941, 29990, 29889, 22625, 485, 29887, 29889, 1516, 3986, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29941, 29914, 29965, 8257, 300, 29918, 29941, 29990, 29889, 22625, 485, 29887, 29889, 1516, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29941, 29914, 3035, 3226, 29877, 29918, 29941, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 29871, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29941, 29914, 29965, 8257, 300, 29918, 29941, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29946, 29914, 3035, 3226, 29877, 29918, 29946, 29990, 29889, 22625, 485, 29887, 29889, 1516, 3986, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29946, 29914, 29965, 8257, 300, 29918, 29946, 29990, 29889, 22625, 485, 29887, 29889, 1516, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29946, 29914, 3035, 3226, 29877, 29918, 29946, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 29871, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29946, 29914, 29965, 8257, 300, 29918, 29946, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29945, 29914, 3035, 3226, 29877, 29918, 29945, 29990, 29889, 22625, 485, 29887, 29889, 1516, 3986, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29945, 29914, 29965, 8257, 300, 29918, 29945, 29990, 29889, 22625, 485, 29887, 29889, 1516, 13, 29914, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 3035, 3226, 29877, 29914, 29945, 29914, 3035, 3226, 29877, 29918, 29945, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 29871, 847, 1272, 29914, 29926, 15291, 29914, 29933, 29963, 29900, 29955, 29896, 29914, 29965, 8257, 300, 29914, 29945, 29914, 29965, 8257, 300, 29918, 29945, 29990, 29889, 22625, 485, 29887, 29889, 1516, 29889, 29881, 948, 6550, 13, 13, 29937, 1281, 10085, 29901, 306, 864, 304, 671, 1583, 1052, 29915, 29881, 6910, 310, 278, 848, 6166, 363, 270, 948, 5965, 2395, 738, 1994, 29892, 577, 1016, 29915, 29873, 15982, 1048, 337, 29899, 1037, 1218, 1438, 270, 948, 5965, 2395, 363, 278, 3256, 29889, 13, 13, 2 ]
sdk/python/pulumi_aws/ec2/vpc_endpoint.py
pulumi-bot/pulumi-aws
0
1604969
<reponame>pulumi-bot/pulumi-aws<gh_stars>0 # coding=utf-8 # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import pulumi import pulumi.runtime class VpcEndpoint(pulumi.CustomResource): """ Provides a VPC Endpoint resource. ~> **NOTE on VPC Endpoints and VPC Endpoint Associations:** Terraform provides both standalone VPC Endpoint Associations for [Route Tables](vpc_endpoint_route_table_association.html) - (an association between a VPC endpoint and a single `route_table_id`) and [Subnets](vpc_endpoint_subnet_association.html) - (an association between a VPC endpoint and a single `subnet_id`) and a VPC Endpoint resource with `route_table_ids` and `subnet_ids` attributes. Do not use the same resource ID in both a VPC Endpoint resource and a VPC Endpoint Association resource. Doing so will cause a conflict of associations and will overwrite the association. """ def __init__(__self__, __name__, __opts__=None, auto_accept=None, policy=None, private_dns_enabled=None, route_table_ids=None, security_group_ids=None, service_name=None, subnet_ids=None, vpc_endpoint_type=None, vpc_id=None): """Create a VpcEndpoint resource with the given unique name, props, and options.""" if not __name__: raise TypeError('Missing resource name argument (for URN creation)') if not isinstance(__name__, basestring): raise TypeError('Expected resource name to be a string') if __opts__ and not isinstance(__opts__, pulumi.ResourceOptions): raise TypeError('Expected resource options to be a ResourceOptions instance') __props__ = dict() if auto_accept and not isinstance(auto_accept, bool): raise TypeError('Expected property auto_accept to be a bool') __self__.auto_accept = auto_accept """ Accept the VPC endpoint (the VPC endpoint and service need to be in the same AWS account). """ __props__['autoAccept'] = auto_accept if policy and not isinstance(policy, basestring): raise TypeError('Expected property policy to be a basestring') __self__.policy = policy """ A policy to attach to the endpoint that controls access to the service. Applicable for endpoints of type `Gateway`. Defaults to full access. """ __props__['policy'] = policy if private_dns_enabled and not isinstance(private_dns_enabled, bool): raise TypeError('Expected property private_dns_enabled to be a bool') __self__.private_dns_enabled = private_dns_enabled """ Whether or not to associate a private hosted zone with the specified VPC. Applicable for endpoints of type `Interface`. Defaults to `false`. """ __props__['privateDnsEnabled'] = private_dns_enabled if route_table_ids and not isinstance(route_table_ids, list): raise TypeError('Expected property route_table_ids to be a list') __self__.route_table_ids = route_table_ids """ One or more route table IDs. Applicable for endpoints of type `Gateway`. """ __props__['routeTableIds'] = route_table_ids if security_group_ids and not isinstance(security_group_ids, list): raise TypeError('Expected property security_group_ids to be a list') __self__.security_group_ids = security_group_ids """ The ID of one or more security groups to associate with the network interface. Required for endpoints of type `Interface`. """ __props__['securityGroupIds'] = security_group_ids if not service_name: raise TypeError('Missing required property service_name') elif not isinstance(service_name, basestring): raise TypeError('Expected property service_name to be a basestring') __self__.service_name = service_name """ The service name, in the form `com.amazonaws.region.service` for AWS services. """ __props__['serviceName'] = service_name if subnet_ids and not isinstance(subnet_ids, list): raise TypeError('Expected property subnet_ids to be a list') __self__.subnet_ids = subnet_ids """ The ID of one or more subnets in which to create a network interface for the endpoint. Applicable for endpoints of type `Interface`. """ __props__['subnetIds'] = subnet_ids if vpc_endpoint_type and not isinstance(vpc_endpoint_type, basestring): raise TypeError('Expected property vpc_endpoint_type to be a basestring') __self__.vpc_endpoint_type = vpc_endpoint_type """ The VPC endpoint type, `Gateway` or `Interface`. Defaults to `Gateway`. """ __props__['vpcEndpointType'] = vpc_endpoint_type if not vpc_id: raise TypeError('Missing required property vpc_id') elif not isinstance(vpc_id, basestring): raise TypeError('Expected property vpc_id to be a basestring') __self__.vpc_id = vpc_id """ The ID of the VPC in which the endpoint will be used. """ __props__['vpcId'] = vpc_id __self__.cidr_blocks = pulumi.runtime.UNKNOWN """ The list of CIDR blocks for the exposed AWS service. Applicable for endpoints of type `Gateway`. """ __self__.dns_entries = pulumi.runtime.UNKNOWN """ The DNS entries for the VPC Endpoint. Applicable for endpoints of type `Interface`. DNS blocks are documented below. """ __self__.network_interface_ids = pulumi.runtime.UNKNOWN """ One or more network interfaces for the VPC Endpoint. Applicable for endpoints of type `Interface`. """ __self__.prefix_list_id = pulumi.runtime.UNKNOWN """ The prefix list ID of the exposed AWS service. Applicable for endpoints of type `Gateway`. """ __self__.state = pulumi.runtime.UNKNOWN """ The state of the VPC endpoint. """ super(VpcEndpoint, __self__).__init__( 'aws:ec2/vpcEndpoint:VpcEndpoint', __name__, __props__, __opts__) def set_outputs(self, outs): if 'autoAccept' in outs: self.auto_accept = outs['autoAccept'] if 'cidrBlocks' in outs: self.cidr_blocks = outs['cidrBlocks'] if 'dnsEntries' in outs: self.dns_entries = outs['dnsEntries'] if 'networkInterfaceIds' in outs: self.network_interface_ids = outs['networkInterfaceIds'] if 'policy' in outs: self.policy = outs['policy'] if 'prefixListId' in outs: self.prefix_list_id = outs['prefixListId'] if 'privateDnsEnabled' in outs: self.private_dns_enabled = outs['privateDnsEnabled'] if 'routeTableIds' in outs: self.route_table_ids = outs['routeTableIds'] if 'securityGroupIds' in outs: self.security_group_ids = outs['securityGroupIds'] if 'serviceName' in outs: self.service_name = outs['serviceName'] if 'state' in outs: self.state = outs['state'] if 'subnetIds' in outs: self.subnet_ids = outs['subnetIds'] if 'vpcEndpointType' in outs: self.vpc_endpoint_type = outs['vpcEndpointType'] if 'vpcId' in outs: self.vpc_id = outs['vpcId']
[ 1, 529, 276, 1112, 420, 29958, 29886, 352, 15547, 29899, 7451, 29914, 29886, 352, 15547, 29899, 10467, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 14137, 29922, 9420, 29899, 29947, 13, 29937, 18610, 399, 25614, 29901, 445, 934, 471, 5759, 491, 278, 27477, 15547, 20839, 689, 16230, 313, 13264, 1885, 29897, 21704, 29889, 18610, 13, 29937, 18610, 1938, 451, 3863, 491, 1361, 6521, 366, 29915, 276, 3058, 366, 1073, 825, 366, 526, 2599, 29991, 18610, 13, 13, 5215, 9505, 15547, 13, 5215, 9505, 15547, 29889, 15634, 13, 13, 1990, 478, 6739, 25602, 29898, 29886, 352, 15547, 29889, 7281, 6848, 1125, 13, 1678, 9995, 13, 1678, 9133, 2247, 263, 478, 9026, 2796, 3149, 6503, 29889, 13, 268, 13, 1678, 3695, 29958, 3579, 12256, 29923, 373, 478, 9026, 2796, 9748, 322, 478, 9026, 2796, 3149, 6853, 800, 29901, 1068, 20839, 689, 8128, 1716, 2317, 18785, 478, 9026, 2796, 3149, 6853, 800, 363, 13, 1678, 518, 12085, 323, 1849, 850, 29894, 6739, 29918, 29734, 29918, 13134, 29918, 2371, 29918, 21264, 362, 29889, 1420, 29897, 448, 313, 273, 15477, 1546, 263, 478, 9026, 16248, 322, 263, 2323, 421, 13134, 29918, 2371, 29918, 333, 6348, 322, 13, 1678, 518, 4035, 1212, 29879, 850, 29894, 6739, 29918, 29734, 29918, 1491, 1212, 29918, 21264, 362, 29889, 1420, 29897, 448, 313, 273, 15477, 1546, 263, 478, 9026, 16248, 322, 263, 2323, 421, 1491, 1212, 29918, 333, 6348, 322, 13, 1678, 263, 478, 9026, 2796, 3149, 6503, 411, 421, 13134, 29918, 2371, 29918, 4841, 29952, 322, 421, 1491, 1212, 29918, 4841, 29952, 8393, 29889, 13, 1678, 1938, 451, 671, 278, 1021, 6503, 3553, 297, 1716, 263, 478, 9026, 2796, 3149, 6503, 322, 263, 478, 9026, 2796, 3149, 7993, 6503, 29889, 13, 1678, 1938, 292, 577, 674, 4556, 263, 14529, 310, 27733, 322, 674, 26556, 278, 15477, 29889, 13, 1678, 9995, 13, 1678, 822, 4770, 2344, 12035, 1649, 1311, 1649, 29892, 4770, 978, 1649, 29892, 4770, 25707, 1649, 29922, 8516, 29892, 4469, 29918, 16044, 29922, 8516, 29892, 8898, 29922, 8516, 29892, 2024, 29918, 29881, 1983, 29918, 17590, 29922, 8516, 29892, 5782, 29918, 2371, 29918, 4841, 29922, 8516, 29892, 6993, 29918, 2972, 29918, 4841, 29922, 8516, 29892, 2669, 29918, 978, 29922, 8516, 29892, 1014, 1212, 29918, 4841, 29922, 8516, 29892, 325, 6739, 29918, 29734, 29918, 1853, 29922, 8516, 29892, 325, 6739, 29918, 333, 29922, 8516, 1125, 13, 4706, 9995, 4391, 263, 478, 6739, 25602, 6503, 411, 278, 2183, 5412, 1024, 29892, 17761, 29892, 322, 3987, 1213, 15945, 13, 4706, 565, 451, 4770, 978, 1649, 29901, 13, 9651, 12020, 20948, 877, 18552, 292, 6503, 1024, 2980, 313, 1454, 501, 29934, 29940, 11265, 29897, 1495, 13, 4706, 565, 451, 338, 8758, 22168, 978, 1649, 29892, 2362, 342, 5393, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 6503, 1024, 304, 367, 263, 1347, 1495, 13, 4706, 565, 4770, 25707, 1649, 322, 451, 338, 8758, 22168, 25707, 1649, 29892, 9505, 15547, 29889, 6848, 5856, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 6503, 3987, 304, 367, 263, 18981, 5856, 2777, 1495, 13, 13, 4706, 4770, 11030, 1649, 353, 9657, 580, 13, 13, 4706, 565, 4469, 29918, 16044, 322, 451, 338, 8758, 29898, 6921, 29918, 16044, 29892, 6120, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 4469, 29918, 16044, 304, 367, 263, 6120, 1495, 13, 4706, 4770, 1311, 26914, 6921, 29918, 16044, 353, 4469, 29918, 16044, 13, 4706, 9995, 13, 4706, 29848, 278, 478, 9026, 16248, 313, 1552, 478, 9026, 16248, 322, 2669, 817, 304, 367, 297, 278, 1021, 15540, 3633, 467, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 6921, 23965, 2033, 353, 4469, 29918, 16044, 13, 13, 4706, 565, 8898, 322, 451, 338, 8758, 29898, 22197, 29892, 2362, 342, 5393, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 8898, 304, 367, 263, 2362, 342, 5393, 1495, 13, 4706, 4770, 1311, 26914, 22197, 353, 8898, 13, 4706, 9995, 13, 4706, 319, 8898, 304, 10641, 304, 278, 16248, 393, 11761, 2130, 304, 278, 2669, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 29954, 403, 1582, 1412, 13, 4706, 13109, 29879, 304, 2989, 2130, 29889, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 22197, 2033, 353, 8898, 13, 13, 4706, 565, 2024, 29918, 29881, 1983, 29918, 17590, 322, 451, 338, 8758, 29898, 9053, 29918, 29881, 1983, 29918, 17590, 29892, 6120, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 2024, 29918, 29881, 1983, 29918, 17590, 304, 367, 263, 6120, 1495, 13, 4706, 4770, 1311, 26914, 9053, 29918, 29881, 1983, 29918, 17590, 353, 2024, 29918, 29881, 1983, 29918, 17590, 13, 4706, 9995, 13, 4706, 26460, 470, 451, 304, 25836, 263, 2024, 17791, 10640, 411, 278, 6790, 478, 9026, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 10448, 1412, 13, 4706, 13109, 29879, 304, 421, 4541, 1412, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 9053, 29928, 1983, 10861, 2033, 353, 2024, 29918, 29881, 1983, 29918, 17590, 13, 13, 4706, 565, 5782, 29918, 2371, 29918, 4841, 322, 451, 338, 8758, 29898, 13134, 29918, 2371, 29918, 4841, 29892, 1051, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 5782, 29918, 2371, 29918, 4841, 304, 367, 263, 1051, 1495, 13, 4706, 4770, 1311, 26914, 13134, 29918, 2371, 29918, 4841, 353, 5782, 29918, 2371, 29918, 4841, 13, 4706, 9995, 13, 4706, 3118, 470, 901, 5782, 1591, 23481, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 29954, 403, 1582, 1412, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 13134, 3562, 21943, 2033, 353, 5782, 29918, 2371, 29918, 4841, 13, 13, 4706, 565, 6993, 29918, 2972, 29918, 4841, 322, 451, 338, 8758, 29898, 8926, 29918, 2972, 29918, 4841, 29892, 1051, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 6993, 29918, 2972, 29918, 4841, 304, 367, 263, 1051, 1495, 13, 4706, 4770, 1311, 26914, 8926, 29918, 2972, 29918, 4841, 353, 6993, 29918, 2972, 29918, 4841, 13, 4706, 9995, 13, 4706, 450, 3553, 310, 697, 470, 901, 6993, 6471, 304, 25836, 411, 278, 3564, 5067, 29889, 830, 5958, 363, 1095, 9748, 310, 1134, 421, 10448, 1412, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 8926, 4782, 21943, 2033, 353, 6993, 29918, 2972, 29918, 4841, 13, 13, 4706, 565, 451, 2669, 29918, 978, 29901, 13, 9651, 12020, 20948, 877, 18552, 292, 3734, 2875, 2669, 29918, 978, 1495, 13, 4706, 25342, 451, 338, 8758, 29898, 5509, 29918, 978, 29892, 2362, 342, 5393, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 2669, 29918, 978, 304, 367, 263, 2362, 342, 5393, 1495, 13, 4706, 4770, 1311, 26914, 5509, 29918, 978, 353, 2669, 29918, 978, 13, 4706, 9995, 13, 4706, 450, 2669, 1024, 29892, 297, 278, 883, 421, 510, 29889, 17260, 10467, 29889, 12803, 29889, 5509, 29952, 363, 15540, 5786, 29889, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 5509, 1170, 2033, 353, 2669, 29918, 978, 13, 13, 4706, 565, 1014, 1212, 29918, 4841, 322, 451, 338, 8758, 29898, 1491, 1212, 29918, 4841, 29892, 1051, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 1014, 1212, 29918, 4841, 304, 367, 263, 1051, 1495, 13, 4706, 4770, 1311, 26914, 1491, 1212, 29918, 4841, 353, 1014, 1212, 29918, 4841, 13, 4706, 9995, 13, 4706, 450, 3553, 310, 697, 470, 901, 1014, 1212, 29879, 297, 607, 304, 1653, 263, 3564, 5067, 363, 278, 16248, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 10448, 1412, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 1491, 1212, 21943, 2033, 353, 1014, 1212, 29918, 4841, 13, 13, 4706, 565, 325, 6739, 29918, 29734, 29918, 1853, 322, 451, 338, 8758, 29898, 29894, 6739, 29918, 29734, 29918, 1853, 29892, 2362, 342, 5393, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 325, 6739, 29918, 29734, 29918, 1853, 304, 367, 263, 2362, 342, 5393, 1495, 13, 4706, 4770, 1311, 26914, 29894, 6739, 29918, 29734, 29918, 1853, 353, 325, 6739, 29918, 29734, 29918, 1853, 13, 4706, 9995, 13, 4706, 450, 478, 9026, 16248, 1134, 29892, 421, 29954, 403, 1582, 29952, 470, 421, 10448, 1412, 13109, 29879, 304, 421, 29954, 403, 1582, 1412, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 29894, 6739, 25602, 1542, 2033, 353, 325, 6739, 29918, 29734, 29918, 1853, 13, 13, 4706, 565, 451, 325, 6739, 29918, 333, 29901, 13, 9651, 12020, 20948, 877, 18552, 292, 3734, 2875, 325, 6739, 29918, 333, 1495, 13, 4706, 25342, 451, 338, 8758, 29898, 29894, 6739, 29918, 333, 29892, 2362, 342, 5393, 1125, 13, 9651, 12020, 20948, 877, 1252, 6021, 2875, 325, 6739, 29918, 333, 304, 367, 263, 2362, 342, 5393, 1495, 13, 4706, 4770, 1311, 26914, 29894, 6739, 29918, 333, 353, 325, 6739, 29918, 333, 13, 4706, 9995, 13, 4706, 450, 3553, 310, 278, 478, 9026, 297, 607, 278, 16248, 674, 367, 1304, 29889, 13, 4706, 9995, 13, 4706, 4770, 11030, 1649, 1839, 29894, 6739, 1204, 2033, 353, 325, 6739, 29918, 333, 13, 13, 4706, 4770, 1311, 26914, 25232, 29878, 29918, 1271, 29879, 353, 9505, 15547, 29889, 15634, 29889, 3904, 29968, 6632, 16048, 13, 4706, 9995, 13, 4706, 450, 1051, 310, 315, 1367, 29934, 10930, 363, 278, 19884, 15540, 2669, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 29954, 403, 1582, 1412, 13, 4706, 9995, 13, 4706, 4770, 1311, 26914, 29881, 1983, 29918, 26586, 353, 9505, 15547, 29889, 15634, 29889, 3904, 29968, 6632, 16048, 13, 4706, 9995, 13, 4706, 450, 16332, 9976, 363, 278, 478, 9026, 2796, 3149, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 10448, 1412, 16332, 10930, 526, 23531, 2400, 29889, 13, 4706, 9995, 13, 4706, 4770, 1311, 26914, 11618, 29918, 13248, 29918, 4841, 353, 9505, 15547, 29889, 15634, 29889, 3904, 29968, 6632, 16048, 13, 4706, 9995, 13, 4706, 3118, 470, 901, 3564, 19510, 363, 278, 478, 9026, 2796, 3149, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 10448, 1412, 13, 4706, 9995, 13, 4706, 4770, 1311, 26914, 13506, 29918, 1761, 29918, 333, 353, 9505, 15547, 29889, 15634, 29889, 3904, 29968, 6632, 16048, 13, 4706, 9995, 13, 4706, 450, 10944, 1051, 3553, 310, 278, 19884, 15540, 2669, 29889, 2401, 506, 519, 363, 1095, 9748, 310, 1134, 421, 29954, 403, 1582, 1412, 13, 4706, 9995, 13, 4706, 4770, 1311, 26914, 3859, 353, 9505, 15547, 29889, 15634, 29889, 3904, 29968, 6632, 16048, 13, 4706, 9995, 13, 4706, 450, 2106, 310, 278, 478, 9026, 16248, 29889, 13, 4706, 9995, 13, 13, 4706, 2428, 29898, 29963, 6739, 25602, 29892, 4770, 1311, 1649, 467, 1649, 2344, 12035, 13, 9651, 525, 10467, 29901, 687, 29906, 29914, 29894, 6739, 25602, 29901, 29963, 6739, 25602, 742, 13, 9651, 4770, 978, 1649, 29892, 13, 9651, 4770, 11030, 1649, 29892, 13, 9651, 4770, 25707, 1649, 29897, 13, 13, 1678, 822, 731, 29918, 4905, 29879, 29898, 1311, 29892, 714, 29879, 1125, 13, 4706, 565, 525, 6921, 23965, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 6921, 29918, 16044, 353, 714, 29879, 1839, 6921, 23965, 2033, 13, 4706, 565, 525, 25232, 29878, 7445, 29879, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 25232, 29878, 29918, 1271, 29879, 353, 714, 29879, 1839, 25232, 29878, 7445, 29879, 2033, 13, 4706, 565, 525, 29881, 1983, 5292, 2722, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 29881, 1983, 29918, 26586, 353, 714, 29879, 1839, 29881, 1983, 5292, 2722, 2033, 13, 4706, 565, 525, 11618, 10448, 21943, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 11618, 29918, 13248, 29918, 4841, 353, 714, 29879, 1839, 11618, 10448, 21943, 2033, 13, 4706, 565, 525, 22197, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 22197, 353, 714, 29879, 1839, 22197, 2033, 13, 4706, 565, 525, 13506, 1293, 1204, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 13506, 29918, 1761, 29918, 333, 353, 714, 29879, 1839, 13506, 1293, 1204, 2033, 13, 4706, 565, 525, 9053, 29928, 1983, 10861, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 9053, 29918, 29881, 1983, 29918, 17590, 353, 714, 29879, 1839, 9053, 29928, 1983, 10861, 2033, 13, 4706, 565, 525, 13134, 3562, 21943, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 13134, 29918, 2371, 29918, 4841, 353, 714, 29879, 1839, 13134, 3562, 21943, 2033, 13, 4706, 565, 525, 8926, 4782, 21943, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 8926, 29918, 2972, 29918, 4841, 353, 714, 29879, 1839, 8926, 4782, 21943, 2033, 13, 4706, 565, 525, 5509, 1170, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 5509, 29918, 978, 353, 714, 29879, 1839, 5509, 1170, 2033, 13, 4706, 565, 525, 3859, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 3859, 353, 714, 29879, 1839, 3859, 2033, 13, 4706, 565, 525, 1491, 1212, 21943, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 1491, 1212, 29918, 4841, 353, 714, 29879, 1839, 1491, 1212, 21943, 2033, 13, 4706, 565, 525, 29894, 6739, 25602, 1542, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 29894, 6739, 29918, 29734, 29918, 1853, 353, 714, 29879, 1839, 29894, 6739, 25602, 1542, 2033, 13, 4706, 565, 525, 29894, 6739, 1204, 29915, 297, 714, 29879, 29901, 13, 9651, 1583, 29889, 29894, 6739, 29918, 333, 353, 714, 29879, 1839, 29894, 6739, 1204, 2033, 13, 2 ]
tests/Unit/Elliptic/Systems/Elasticity/BoundaryConditions/LaserBeam.py
nilsvu/spectre
117
144559
# Distributed under the MIT License. # See LICENSE.txt for details. import numpy as np from numpy import sqrt, exp, pi def normal_dot_minus_stress(x, n, beam_width): n /= np.linalg.norm(n) r = sqrt(np.linalg.norm(x)**2 - np.dot(x, n)**2) beam_profile = exp(-(r / beam_width)**2) / pi / beam_width**2 return np.tensordot(-n, beam_profile, axes=0) def normal_dot_minus_stress_linearized(x, n, beam_width): return np.zeros(3)
[ 1, 396, 6652, 7541, 1090, 278, 341, 1806, 19245, 29889, 13, 29937, 2823, 365, 2965, 1430, 1660, 29889, 3945, 363, 4902, 29889, 13, 13, 5215, 12655, 408, 7442, 13, 3166, 12655, 1053, 18074, 2273, 29892, 1518, 29892, 2930, 13, 13, 13, 1753, 4226, 29918, 6333, 29918, 12254, 29918, 710, 404, 29898, 29916, 29892, 302, 29892, 22913, 29918, 2103, 1125, 13, 1678, 302, 847, 29922, 7442, 29889, 29880, 979, 29887, 29889, 12324, 29898, 29876, 29897, 13, 1678, 364, 353, 18074, 2273, 29898, 9302, 29889, 29880, 979, 29887, 29889, 12324, 29898, 29916, 29897, 1068, 29906, 448, 7442, 29889, 6333, 29898, 29916, 29892, 302, 29897, 1068, 29906, 29897, 13, 1678, 22913, 29918, 10185, 353, 1518, 6278, 29898, 29878, 847, 22913, 29918, 2103, 29897, 1068, 29906, 29897, 847, 2930, 847, 22913, 29918, 2103, 1068, 29906, 13, 1678, 736, 7442, 29889, 29873, 575, 536, 327, 6278, 29876, 29892, 22913, 29918, 10185, 29892, 27815, 29922, 29900, 29897, 13, 13, 13, 1753, 4226, 29918, 6333, 29918, 12254, 29918, 710, 404, 29918, 10660, 1891, 29898, 29916, 29892, 302, 29892, 22913, 29918, 2103, 1125, 13, 1678, 736, 7442, 29889, 3298, 359, 29898, 29941, 29897, 13, 2 ]
scripts/get_passing_tests.py
gokhankici/xenon
1
199086
<reponame>gokhankici/xenon #!/usr/bin/env python3 FILENAME = "/tmp/passed" bmks = [] with open(FILENAME, "r") as f: for l in f: [m, a] = l.split(" ") t = (m, a.strip()) bmks.append(t) def quote(s): return '"{}"'.format(s) indent = " " output = '{}[ {}\n{}]'.format(indent, f'\n{indent}, '.join(f'("{m}", "{a}")' for m, a in bmks), indent) print("passedTests :: [(String, String)]") print("passedTests =") print(output)
[ 1, 529, 276, 1112, 420, 29958, 29887, 554, 29882, 804, 1654, 29914, 29916, 264, 265, 13, 29937, 14708, 4855, 29914, 2109, 29914, 6272, 3017, 29941, 13, 13, 7724, 5813, 353, 5591, 7050, 29914, 3364, 287, 29908, 13, 13, 5838, 2039, 353, 5159, 13, 13, 2541, 1722, 29898, 7724, 5813, 29892, 376, 29878, 1159, 408, 285, 29901, 13, 1678, 363, 301, 297, 285, 29901, 13, 4706, 518, 29885, 29892, 263, 29962, 353, 301, 29889, 5451, 703, 16521, 13, 4706, 260, 353, 313, 29885, 29892, 263, 29889, 17010, 3101, 13, 4706, 289, 29885, 2039, 29889, 4397, 29898, 29873, 29897, 13, 13, 1753, 14978, 29898, 29879, 1125, 13, 1678, 736, 18793, 29912, 5038, 4286, 4830, 29898, 29879, 29897, 13, 13, 12860, 353, 376, 29871, 376, 13, 4905, 353, 22372, 4400, 426, 1012, 29876, 29912, 6525, 4286, 4830, 29898, 12860, 29892, 285, 12764, 29876, 29912, 12860, 1118, 15300, 7122, 29898, 29888, 29915, 703, 29912, 29885, 17671, 29850, 29874, 27195, 29915, 363, 286, 29892, 263, 297, 289, 29885, 2039, 511, 29536, 29897, 13, 13, 2158, 703, 3364, 287, 24376, 4761, 17288, 1231, 29892, 1714, 4638, 1159, 13, 2158, 703, 3364, 287, 24376, 353, 1159, 13, 2158, 29898, 4905, 29897, 13, 13, 2 ]
base/admin.py
ExpertOfNone/expert_of_none
0
183
from django.contrib import admin from base.models import Topic, Photo class EONBaseAdmin(admin.ModelAdmin): def get_changeform_initial_data(self, request): initial = super().get_changeform_initial_data(request) if 'add' in request.META['PATH_INFO']: initial['created_by'] = request.user initial['modified_by'] = request.user return initial def save_model(self, request, obj, form, change): if not obj.created_by: obj.created_by = request.user return super().save_model(request, obj, form, change) class TopicAdmin(EONBaseAdmin): list_display = [ 'name', 'parent_topic', 'top_level', 'modified_by', 'modified', 'created_by', 'created', ] class PhotoAdmin(EONBaseAdmin): # TODO Add Proper List Display pass admin.site.register(Topic, TopicAdmin) admin.site.register(Photo, PhotoAdmin)
[ 1, 515, 9557, 29889, 21570, 1053, 4113, 13, 13, 3166, 2967, 29889, 9794, 1053, 7488, 293, 29892, 1963, 3747, 13, 13, 13, 1990, 382, 1164, 5160, 12754, 29898, 6406, 29889, 3195, 12754, 1125, 13, 13, 1678, 822, 679, 29918, 3167, 689, 29918, 11228, 29918, 1272, 29898, 1311, 29892, 2009, 1125, 13, 13, 4706, 2847, 353, 2428, 2141, 657, 29918, 3167, 689, 29918, 11228, 29918, 1272, 29898, 3827, 29897, 13, 13, 4706, 565, 525, 1202, 29915, 297, 2009, 29889, 2303, 6040, 1839, 10145, 29918, 11690, 2033, 29901, 13, 9651, 2847, 1839, 11600, 29918, 1609, 2033, 353, 2009, 29889, 1792, 13, 13, 4706, 2847, 1839, 1545, 2164, 29918, 1609, 2033, 353, 2009, 29889, 1792, 13, 13, 4706, 736, 2847, 13, 13, 1678, 822, 4078, 29918, 4299, 29898, 1311, 29892, 2009, 29892, 5446, 29892, 883, 29892, 1735, 1125, 13, 13, 4706, 565, 451, 5446, 29889, 11600, 29918, 1609, 29901, 13, 9651, 5446, 29889, 11600, 29918, 1609, 353, 2009, 29889, 1792, 13, 13, 4706, 736, 2428, 2141, 7620, 29918, 4299, 29898, 3827, 29892, 5446, 29892, 883, 29892, 1735, 29897, 13, 13, 13, 1990, 7488, 293, 12754, 29898, 29923, 1164, 5160, 12754, 1125, 13, 13, 1678, 1051, 29918, 4990, 353, 518, 13, 4706, 525, 978, 742, 525, 3560, 29918, 13010, 742, 525, 3332, 29918, 5563, 742, 525, 1545, 2164, 29918, 1609, 742, 525, 1545, 2164, 742, 525, 11600, 29918, 1609, 742, 525, 11600, 742, 13, 1678, 4514, 13, 13, 13, 1990, 1963, 3747, 12754, 29898, 29923, 1164, 5160, 12754, 1125, 13, 13, 1678, 396, 14402, 3462, 1019, 546, 2391, 17440, 13, 13, 1678, 1209, 13, 13, 13, 6406, 29889, 2746, 29889, 9573, 29898, 7031, 293, 29892, 7488, 293, 12754, 29897, 13, 6406, 29889, 2746, 29889, 9573, 29898, 25971, 29892, 1963, 3747, 12754, 29897, 13, 2 ]
gigglebot/nes-controlled/shared_config.py
carlosperate/microbit-programs
0
120795
<gh_stars>0 # microbit-module: [email protected] RADIO_CHANNEL = 17 MSG_DEYLAY = 50
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 9200, 2966, 29899, 5453, 29901, 7258, 29918, 2917, 29992, 29900, 29889, 29896, 29889, 29900, 13, 13, 29934, 3035, 5971, 29918, 3210, 2190, 29940, 6670, 353, 29871, 29896, 29955, 13, 4345, 29954, 29918, 2287, 29979, 18799, 353, 29871, 29945, 29900, 13, 2 ]
data_management/cct_to_wi.py
alsnothome/CameraTraps
0
122127
<reponame>alsnothome/CameraTraps # # cct_to_wi.py # # Converts COCO Camera Traps .json files to the Wildlife Insights # batch upload format # # Also see: # # https://github.com/ConservationInternational/Wildlife-Insights----Data-Migration #%% Imports import os #%% Paths input_file = r'c:\temp\camera_trap_images_no_people\bellevue_camera_traps.2020-12-26.json' assert os.path.isfile(input_file) templates_dir = r'c:\temp\wi_batch_upload_templates' assert os.path.isdir(templates_dir) output_base = r'c:\temp\wi_output' os.makedirs(output_base,exist_ok = True) #%% Constants projects_file_name = 'projects.csv' deployments_file_name = 'deployments.csv' images_file_name = 'images.csv' cameras_file_name = 'cameras.csv' #%% Project information project_info = {} project_info['project_name'] = 'Bellevue Camera Traps' project_info['project_id'] = 'bct_001' project_info['project_short_name'] = 'BCT' project_info['project_objectives'] = 'none' project_info['project_species'] = 'Multiple' project_info['project_species_individual'] = '' project_info['project_sensor_layout'] = 'Convenience' project_info['project_sensor_layout_targeted_type'] = '' project_info['project_bait_use'] = 'No' project_info['project_bait_type'] = '' project_info['project_stratification'] = 'No' project_info['project_stratification_type'] = '' project_info['project_sensor_method'] = 'Sensor Detection' project_info['project_individual_animals'] = 'No' project_info['project_admin'] = '<NAME>' project_info['project_admin_email'] = '<EMAIL>' project_info['country_code'] = 'USA' project_info['embargo'] = str(0) project_info['initiative_id'] = '' project_info['metadata_license'] = 'CC0' project_info['image_license'] = 'CC0' project_info['project_blank_images'] = 'No' project_info['project_sensor_cluster'] = 'No' camera_info = {} camera_info['project_id'] = project_info['project_id'] camera_info['camera_id'] = '' camera_info['make'] = '' camera_info['model'] = '' camera_info['serial_number'] = '' camera_info['year_purchased'] = '' deployment_info = {} deployment_info['project_id'] = project_info['project_id'] deployment_info['deployment_id'] = 'test_deployment' deployment_info['subproject_name'] = 'test_subproject' deployment_info['subproject_design'] = '' deployment_info['placename'] = 'yard' deployment_info['longitude'] = '47.6101' deployment_info['latitude'] = '-122.2015' deployment_info['start_date'] = '2016-01-01 00:00:00' deployment_info['end_date'] = '2026-01-01 00:00:00' deployment_info['event_name'] = '' deployment_info['event_description'] = '' deployment_info['event_type'] = '' deployment_info['bait_type'] = '' deployment_info['bait_description'] = '' deployment_info['feature_type'] = 'None' deployment_info['feature_type_methodology'] = '' deployment_info['camera_id'] = camera_info['camera_id'] deployment_info['quiet_period'] = str(60) deployment_info['camera_functioning'] = 'Camera Functioning' deployment_info['sensor_height'] = 'Chest height' deployment_info['height_other'] = '' deployment_info['sensor_orientation'] = 'Parallel' deployment_info['orientation_other'] = '' deployment_info['recorded_by'] = '<NAME>' image_blank_fields = ['uncertainty'] #%% Read templates def parse_fields(templates_dir,file_name): with open(os.path.join(templates_dir,file_name),'r') as f: lines = f.readlines() lines = [s.strip() for s in lines if len(s.strip().replace(',','')) > 0] assert len(lines) == 1, 'Error processing template {}'.format(file_name) fields = lines[0].split(',') print('Parsed {} columns from {}'.format(len(fields),file_name)) return fields projects_fields = parse_fields(templates_dir,projects_file_name) deployments_fields = parse_fields(templates_dir,deployments_file_name) images_fields = parse_fields(templates_dir,images_file_name) cameras_fields = parse_fields(templates_dir,cameras_file_name) #%% Compare dictionary to template lists def compare_info_to_template(info,template_fields,name): for s in info.keys(): assert s in template_fields,'Field {} not specified in {}_fields'.format(s,name) for s in template_fields: assert s in info.keys(),'Field {} not specified in {}_info'.format(s,name) def write_table(file_name,info,template_fields): assert len(info) == len(template_fields) project_output_file = os.path.join(output_base,file_name) with open(project_output_file,'w') as f: # Write the header for i_field,s in enumerate(template_fields): f.write(s) if i_field != len(template_fields)-1: f.write(',') f.write('\n') # Write values for i_field,s in enumerate(template_fields): f.write(info[s]) if i_field != len(template_fields)-1: f.write(',') f.write('\n') #%% Project file compare_info_to_template(project_info,projects_fields,'project') write_table(projects_file_name,project_info,projects_fields) #%% Camera file compare_info_to_template(camera_info,cameras_fields,'camera') write_table(cameras_file_name,camera_info,cameras_fields) #%% Deployment file compare_info_to_template(deployment_info,deployments_fields,'deployment') write_table(projects_file_name,deployment_info,deployments_fields) #%%
[ 1, 529, 276, 1112, 420, 29958, 1338, 29876, 720, 608, 29914, 20717, 5323, 567, 13, 29937, 13, 29937, 274, 312, 29918, 517, 29918, 4353, 29889, 2272, 13, 29937, 13, 29937, 1281, 369, 1372, 4810, 3217, 24321, 3201, 567, 869, 3126, 2066, 304, 278, 11821, 19264, 13377, 5861, 13, 29937, 9853, 6441, 3402, 13, 29937, 13, 29937, 3115, 1074, 29901, 13, 29937, 13, 29937, 2045, 597, 3292, 29889, 510, 29914, 1168, 2140, 362, 17579, 1288, 29914, 29956, 789, 19264, 29899, 797, 29879, 5861, 807, 1469, 29899, 29924, 16783, 13, 13, 13, 29937, 7686, 1954, 4011, 13, 13, 5215, 2897, 13, 13, 13, 29937, 7686, 10802, 29879, 13, 13, 2080, 29918, 1445, 353, 364, 29915, 29883, 3583, 7382, 29905, 26065, 29918, 29873, 2390, 29918, 8346, 29918, 1217, 29918, 25719, 29905, 29890, 1808, 19682, 29918, 26065, 29918, 3018, 567, 29889, 29906, 29900, 29906, 29900, 29899, 29896, 29906, 29899, 29906, 29953, 29889, 3126, 29915, 13, 9294, 2897, 29889, 2084, 29889, 275, 1445, 29898, 2080, 29918, 1445, 29897, 13, 13, 20943, 29918, 3972, 353, 364, 29915, 29883, 3583, 7382, 29905, 4353, 29918, 16175, 29918, 9009, 29918, 20943, 29915, 13, 9294, 2897, 29889, 2084, 29889, 275, 3972, 29898, 20943, 29918, 3972, 29897, 13, 13, 4905, 29918, 3188, 353, 364, 29915, 29883, 3583, 7382, 29905, 4353, 29918, 4905, 29915, 13, 359, 29889, 29885, 12535, 12935, 29898, 4905, 29918, 3188, 29892, 28997, 29918, 554, 353, 5852, 29897, 13, 13, 13, 29937, 7686, 5798, 1934, 13, 13, 16418, 29918, 1445, 29918, 978, 353, 525, 16418, 29889, 7638, 29915, 13, 16519, 1860, 29918, 1445, 29918, 978, 353, 525, 16519, 1860, 29889, 7638, 29915, 13, 8346, 29918, 1445, 29918, 978, 353, 525, 8346, 29889, 7638, 29915, 13, 29883, 4183, 294, 29918, 1445, 29918, 978, 353, 525, 29883, 4183, 294, 29889, 7638, 29915, 13, 13, 13, 29937, 7686, 8010, 2472, 13, 13, 4836, 29918, 3888, 353, 6571, 13, 4836, 29918, 3888, 1839, 4836, 29918, 978, 2033, 353, 525, 29933, 1808, 19682, 24321, 3201, 567, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 333, 2033, 353, 525, 29890, 312, 29918, 29900, 29900, 29896, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 12759, 29918, 978, 2033, 353, 525, 29933, 1783, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 3318, 3145, 2033, 353, 525, 9290, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 24091, 2033, 353, 525, 15329, 552, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 24091, 29918, 513, 23352, 2033, 353, 6629, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29879, 6073, 29918, 2680, 2033, 353, 525, 1168, 854, 5597, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29879, 6073, 29918, 2680, 29918, 5182, 287, 29918, 1853, 2033, 353, 6629, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29890, 1249, 29918, 1509, 2033, 353, 525, 3782, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29890, 1249, 29918, 1853, 2033, 353, 6629, 13, 4836, 29918, 3888, 1839, 4836, 29918, 710, 271, 2450, 2033, 353, 525, 3782, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 710, 271, 2450, 29918, 1853, 2033, 353, 6629, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29879, 6073, 29918, 5696, 2033, 353, 525, 29903, 6073, 360, 2650, 428, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 513, 23352, 29918, 11576, 1338, 2033, 353, 525, 3782, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 6406, 2033, 353, 12801, 5813, 16299, 13, 4836, 29918, 3888, 1839, 4836, 29918, 6406, 29918, 5269, 2033, 353, 12801, 26862, 6227, 16299, 13, 4836, 29918, 3888, 1839, 13509, 29918, 401, 2033, 353, 525, 27019, 29915, 13, 4836, 29918, 3888, 1839, 1590, 7921, 2033, 353, 851, 29898, 29900, 29897, 13, 4836, 29918, 3888, 1839, 2344, 29875, 1230, 29918, 333, 2033, 353, 6629, 13, 4836, 29918, 3888, 1839, 19635, 29918, 506, 1947, 2033, 353, 525, 4174, 29900, 29915, 13, 4836, 29918, 3888, 1839, 3027, 29918, 506, 1947, 2033, 353, 525, 4174, 29900, 29915, 13, 13, 4836, 29918, 3888, 1839, 4836, 29918, 19465, 29918, 8346, 2033, 353, 525, 3782, 29915, 13, 4836, 29918, 3888, 1839, 4836, 29918, 29879, 6073, 29918, 19594, 2033, 353, 525, 3782, 29915, 13, 13, 26065, 29918, 3888, 353, 6571, 13, 26065, 29918, 3888, 1839, 4836, 29918, 333, 2033, 353, 2060, 29918, 3888, 1839, 4836, 29918, 333, 2033, 29871, 13, 26065, 29918, 3888, 1839, 26065, 29918, 333, 2033, 353, 6629, 13, 26065, 29918, 3888, 1839, 5675, 2033, 353, 6629, 13, 26065, 29918, 3888, 1839, 4299, 2033, 353, 6629, 13, 26065, 29918, 3888, 1839, 15550, 29918, 4537, 2033, 353, 6629, 13, 26065, 29918, 3888, 1839, 6360, 29918, 29886, 2458, 1463, 2033, 353, 6629, 13, 13, 16519, 358, 29918, 3888, 353, 6571, 13, 13, 16519, 358, 29918, 3888, 1839, 4836, 29918, 333, 2033, 353, 2060, 29918, 3888, 1839, 4836, 29918, 333, 2033, 29871, 13, 16519, 358, 29918, 3888, 1839, 16519, 358, 29918, 333, 2033, 353, 525, 1688, 29918, 16519, 358, 29915, 13, 16519, 358, 29918, 3888, 1839, 1491, 4836, 29918, 978, 2033, 353, 525, 1688, 29918, 1491, 4836, 29915, 13, 16519, 358, 29918, 3888, 1839, 1491, 4836, 29918, 13892, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 29886, 4620, 3871, 2033, 353, 525, 19852, 29915, 13, 16519, 358, 29918, 3888, 1839, 5426, 4279, 2033, 353, 525, 29946, 29955, 29889, 29953, 29896, 29900, 29896, 29915, 13, 16519, 358, 29918, 3888, 1839, 5066, 4279, 2033, 353, 17411, 29896, 29906, 29906, 29889, 29906, 29900, 29896, 29945, 29915, 13, 16519, 358, 29918, 3888, 1839, 2962, 29918, 1256, 2033, 353, 525, 29906, 29900, 29896, 29953, 29899, 29900, 29896, 29899, 29900, 29896, 29871, 29900, 29900, 29901, 29900, 29900, 29901, 29900, 29900, 29915, 13, 16519, 358, 29918, 3888, 1839, 355, 29918, 1256, 2033, 353, 525, 29906, 29900, 29906, 29953, 29899, 29900, 29896, 29899, 29900, 29896, 29871, 29900, 29900, 29901, 29900, 29900, 29901, 29900, 29900, 29915, 13, 16519, 358, 29918, 3888, 1839, 3696, 29918, 978, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 3696, 29918, 8216, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 3696, 29918, 1853, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 29890, 1249, 29918, 1853, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 29890, 1249, 29918, 8216, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 14394, 29918, 1853, 2033, 353, 525, 8516, 29915, 13, 16519, 358, 29918, 3888, 1839, 14394, 29918, 1853, 29918, 5696, 3002, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 26065, 29918, 333, 2033, 353, 10656, 29918, 3888, 1839, 26065, 29918, 333, 2033, 13, 16519, 358, 29918, 3888, 1839, 339, 2035, 29918, 19145, 2033, 353, 851, 29898, 29953, 29900, 29897, 13, 16519, 358, 29918, 3888, 1839, 26065, 29918, 2220, 292, 2033, 353, 525, 20717, 6680, 292, 29915, 13, 16519, 358, 29918, 3888, 1839, 29879, 6073, 29918, 3545, 2033, 353, 525, 1451, 342, 3171, 29915, 13, 16519, 358, 29918, 3888, 1839, 3545, 29918, 1228, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 29879, 6073, 29918, 20659, 2033, 353, 525, 2177, 6553, 29915, 13, 16519, 358, 29918, 3888, 1839, 20659, 29918, 1228, 2033, 353, 6629, 13, 16519, 358, 29918, 3888, 1839, 11651, 287, 29918, 1609, 2033, 353, 12801, 5813, 16299, 13, 13, 3027, 29918, 19465, 29918, 9621, 353, 6024, 4661, 13946, 1017, 2033, 13, 13, 13, 29937, 7686, 7523, 17475, 13, 13, 1753, 6088, 29918, 9621, 29898, 20943, 29918, 3972, 29892, 1445, 29918, 978, 1125, 13, 268, 13, 1678, 411, 1722, 29898, 359, 29889, 2084, 29889, 7122, 29898, 20943, 29918, 3972, 29892, 1445, 29918, 978, 511, 29915, 29878, 1495, 408, 285, 29901, 13, 4706, 3454, 353, 285, 29889, 949, 9012, 580, 13, 4706, 3454, 353, 518, 29879, 29889, 17010, 580, 363, 269, 297, 3454, 565, 7431, 29898, 29879, 29889, 17010, 2141, 6506, 29317, 3788, 8785, 1405, 29871, 29900, 29962, 13, 4706, 4974, 7431, 29898, 9012, 29897, 1275, 29871, 29896, 29892, 525, 2392, 9068, 4472, 6571, 4286, 4830, 29898, 1445, 29918, 978, 29897, 13, 4706, 4235, 353, 3454, 29961, 29900, 1822, 5451, 29317, 1495, 13, 4706, 1596, 877, 29925, 1503, 287, 6571, 4341, 515, 6571, 4286, 4830, 29898, 2435, 29898, 9621, 511, 1445, 29918, 978, 876, 13, 1678, 736, 4235, 13, 13, 16418, 29918, 9621, 353, 6088, 29918, 9621, 29898, 20943, 29918, 3972, 29892, 16418, 29918, 1445, 29918, 978, 29897, 13, 16519, 1860, 29918, 9621, 353, 6088, 29918, 9621, 29898, 20943, 29918, 3972, 29892, 16519, 1860, 29918, 1445, 29918, 978, 29897, 13, 8346, 29918, 9621, 353, 6088, 29918, 9621, 29898, 20943, 29918, 3972, 29892, 8346, 29918, 1445, 29918, 978, 29897, 13, 29883, 4183, 294, 29918, 9621, 353, 6088, 29918, 9621, 29898, 20943, 29918, 3972, 29892, 29883, 4183, 294, 29918, 1445, 29918, 978, 29897, 13, 13, 13, 29937, 7686, 3831, 598, 8600, 304, 4472, 8857, 13, 13, 1753, 7252, 29918, 3888, 29918, 517, 29918, 6886, 29898, 3888, 29892, 6886, 29918, 9621, 29892, 978, 1125, 13, 268, 13, 1678, 363, 269, 297, 5235, 29889, 8149, 7295, 13, 4706, 4974, 269, 297, 4472, 29918, 9621, 5501, 3073, 6571, 451, 6790, 297, 426, 2403, 9621, 4286, 4830, 29898, 29879, 29892, 978, 29897, 13, 1678, 363, 269, 297, 4472, 29918, 9621, 29901, 13, 4706, 4974, 269, 297, 5235, 29889, 8149, 3285, 29915, 3073, 6571, 451, 6790, 297, 426, 2403, 3888, 4286, 4830, 29898, 29879, 29892, 978, 29897, 13, 13, 13, 1753, 2436, 29918, 2371, 29898, 1445, 29918, 978, 29892, 3888, 29892, 6886, 29918, 9621, 1125, 13, 268, 13, 1678, 4974, 7431, 29898, 3888, 29897, 1275, 7431, 29898, 6886, 29918, 9621, 29897, 13, 268, 13, 1678, 2060, 29918, 4905, 29918, 1445, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 3188, 29892, 1445, 29918, 978, 29897, 13, 1678, 411, 1722, 29898, 4836, 29918, 4905, 29918, 1445, 5501, 29893, 1495, 408, 285, 29901, 13, 268, 13, 4706, 396, 14350, 278, 4839, 13, 4706, 363, 474, 29918, 2671, 29892, 29879, 297, 26985, 29898, 6886, 29918, 9621, 1125, 13, 9651, 285, 29889, 3539, 29898, 29879, 29897, 13, 9651, 565, 474, 29918, 2671, 2804, 7431, 29898, 6886, 29918, 9621, 6817, 29896, 29901, 13, 18884, 285, 29889, 3539, 29317, 1495, 13, 4706, 285, 29889, 3539, 28909, 29876, 1495, 13, 308, 13, 4706, 396, 14350, 1819, 13, 4706, 363, 474, 29918, 2671, 29892, 29879, 297, 26985, 29898, 6886, 29918, 9621, 1125, 13, 9651, 285, 29889, 3539, 29898, 3888, 29961, 29879, 2314, 13, 9651, 565, 474, 29918, 2671, 2804, 7431, 29898, 6886, 29918, 9621, 6817, 29896, 29901, 13, 18884, 285, 29889, 3539, 29317, 1495, 13, 4706, 285, 29889, 3539, 28909, 29876, 1495, 13, 268, 13, 13, 29937, 7686, 8010, 934, 13, 13, 18307, 29918, 3888, 29918, 517, 29918, 6886, 29898, 4836, 29918, 3888, 29892, 16418, 29918, 9621, 5501, 4836, 1495, 13, 3539, 29918, 2371, 29898, 16418, 29918, 1445, 29918, 978, 29892, 4836, 29918, 3888, 29892, 16418, 29918, 9621, 29897, 13, 13, 13, 29937, 7686, 24321, 934, 13, 13, 18307, 29918, 3888, 29918, 517, 29918, 6886, 29898, 26065, 29918, 3888, 29892, 29883, 4183, 294, 29918, 9621, 5501, 26065, 1495, 13, 3539, 29918, 2371, 29898, 29883, 4183, 294, 29918, 1445, 29918, 978, 29892, 26065, 29918, 3888, 29892, 29883, 4183, 294, 29918, 9621, 29897, 13, 13, 13, 29937, 7686, 10034, 22812, 934, 13, 13, 18307, 29918, 3888, 29918, 517, 29918, 6886, 29898, 16519, 358, 29918, 3888, 29892, 16519, 1860, 29918, 9621, 5501, 16519, 358, 1495, 13, 3539, 29918, 2371, 29898, 16418, 29918, 1445, 29918, 978, 29892, 16519, 358, 29918, 3888, 29892, 16519, 1860, 29918, 9621, 29897, 13, 13, 13, 29937, 7686, 29871, 2 ]
tests/unit/models/test_device.py
jzalger/particle-hub
0
130242
from unittest import TestCase from particlehub.models import Device class TestDevice(TestCase): def test_create_device(self): self.fail() def test_from_dict(self): self.fail() def test_get_all_variable_data(self): self.fail() def test_device_health(self): self.fail() def test__update_variable_names(self): self.fail() def test_full_device_data(self): self.fail() def test_get_variable_data(self): self.fail() def test__call_func(self): self.fail()
[ 1, 515, 443, 27958, 1053, 4321, 8259, 13, 3166, 16445, 29882, 431, 29889, 9794, 1053, 21830, 13, 13, 13, 1990, 4321, 11501, 29898, 3057, 8259, 1125, 13, 13, 1678, 822, 1243, 29918, 3258, 29918, 10141, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 29918, 3166, 29918, 8977, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 29918, 657, 29918, 497, 29918, 11918, 29918, 1272, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 29918, 10141, 29918, 354, 4298, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 1649, 5504, 29918, 11918, 29918, 7039, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 29918, 8159, 29918, 10141, 29918, 1272, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 29918, 657, 29918, 11918, 29918, 1272, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 13, 1678, 822, 1243, 1649, 4804, 29918, 9891, 29898, 1311, 1125, 13, 4706, 1583, 29889, 14057, 580, 13, 2 ]
keras_train.py
jmeisele/mlflow_demo
0
13610
<gh_stars>0 """ Author: <NAME> Email: <EMAIL> Date: August 1, 2020 """ import argparse import keras import tensorflow as tf import cloudpickle parser = argparse.ArgumentParser( description='Train a Keras feed-forward network for MNIST classification') parser.add_argument('--batch-size', '-b', type=int, default=128) parser.add_argument('--epochs', '-e', type=int, default=1) parser.add_argument('--learning_rate', '-l', type=float, default=0.05) parser.add_argument('--num-hidden-units', '-n', type=float, default=512) parser.add_argument('--dropout', '-d', type=float, default=0.25) parser.add_argument('--momentum', '-m', type=float, default=0.85) args = parser.parse_args() mnist = keras.datasets.mnist (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train, X_test = X_train / 255.0, X_test / 255.0 model = keras.models.Sequential([ keras.layers.Flatten(input_shape=X_train[0].shape), keras.layers.Dense(args.num_hidden_units, activation=tf.nn.relu), keras.layers.Dropout(args.dropout), keras.layers.Dense(10, activation=tf.nn.softmax) ]) optimizer = keras.optimizers.SGD(lr=args.learning_rate, momentum=args.momentum) model.compile(optimizer=optimizer, loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.fit(X_train, y_train, epochs=args.epochs, batch_size=args.batch_size) test_loss, test_acc = model.evaluate(X_test, y_test, verbose=2)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 15945, 29908, 13, 13720, 29901, 529, 5813, 29958, 13, 9823, 29901, 529, 26862, 6227, 29958, 13, 2539, 29901, 3111, 29871, 29896, 29892, 29871, 29906, 29900, 29906, 29900, 13, 15945, 29908, 13, 5215, 1852, 5510, 13, 5215, 13023, 294, 13, 5215, 26110, 408, 15886, 13, 5215, 9570, 23945, 280, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 29898, 13, 29871, 6139, 2433, 5323, 262, 263, 12693, 294, 8343, 29899, 11333, 3564, 363, 341, 29940, 9047, 12965, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 16175, 29899, 2311, 742, 17411, 29890, 742, 1134, 29922, 524, 29892, 2322, 29922, 29896, 29906, 29947, 29897, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 1022, 2878, 29879, 742, 17411, 29872, 742, 1134, 29922, 524, 29892, 2322, 29922, 29896, 29897, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 21891, 29918, 10492, 742, 17411, 29880, 742, 1134, 29922, 7411, 29892, 2322, 29922, 29900, 29889, 29900, 29945, 29897, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 1949, 29899, 10892, 29899, 348, 1169, 742, 17411, 29876, 742, 1134, 29922, 7411, 29892, 2322, 29922, 29945, 29896, 29906, 29897, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 8865, 449, 742, 17411, 29881, 742, 1134, 29922, 7411, 29892, 2322, 29922, 29900, 29889, 29906, 29945, 29897, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 29885, 2932, 398, 742, 17411, 29885, 742, 1134, 29922, 7411, 29892, 2322, 29922, 29900, 29889, 29947, 29945, 29897, 13, 5085, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 23521, 391, 353, 13023, 294, 29889, 14538, 1691, 29889, 23521, 391, 13, 29898, 29990, 29918, 14968, 29892, 343, 29918, 14968, 511, 313, 29990, 29918, 1688, 29892, 343, 29918, 1688, 29897, 353, 28597, 391, 29889, 1359, 29918, 1272, 580, 13, 29990, 29918, 14968, 29892, 1060, 29918, 1688, 353, 1060, 29918, 14968, 847, 29871, 29906, 29945, 29945, 29889, 29900, 29892, 1060, 29918, 1688, 847, 29871, 29906, 29945, 29945, 29889, 29900, 13, 13, 4299, 353, 13023, 294, 29889, 9794, 29889, 16941, 2556, 4197, 13, 29871, 13023, 294, 29889, 29277, 29889, 29943, 5066, 841, 29898, 2080, 29918, 12181, 29922, 29990, 29918, 14968, 29961, 29900, 1822, 12181, 511, 13, 29871, 13023, 294, 29889, 29277, 29889, 29928, 1947, 29898, 5085, 29889, 1949, 29918, 10892, 29918, 348, 1169, 29892, 26229, 29922, 13264, 29889, 15755, 29889, 2674, 29884, 511, 13, 29871, 13023, 294, 29889, 29277, 29889, 15063, 449, 29898, 5085, 29889, 8865, 449, 511, 13, 29871, 13023, 294, 29889, 29277, 29889, 29928, 1947, 29898, 29896, 29900, 29892, 26229, 29922, 13264, 29889, 15755, 29889, 2695, 3317, 29897, 13, 2314, 13, 13, 20640, 3950, 353, 13023, 294, 29889, 20640, 19427, 29889, 26016, 29928, 29898, 29212, 29922, 5085, 29889, 21891, 29918, 10492, 29892, 19399, 29922, 5085, 29889, 29885, 2932, 398, 29897, 13, 13, 4299, 29889, 12198, 29898, 20640, 3950, 29922, 20640, 3950, 29892, 13, 795, 6410, 2433, 29879, 5510, 29918, 29883, 20440, 936, 29918, 19128, 296, 14441, 742, 13, 795, 21556, 29922, 1839, 562, 2764, 4135, 11287, 13, 13, 4299, 29889, 9202, 29898, 29990, 29918, 14968, 29892, 343, 29918, 14968, 29892, 21502, 12168, 29922, 5085, 29889, 1022, 2878, 29879, 29892, 9853, 29918, 2311, 29922, 5085, 29889, 16175, 29918, 2311, 29897, 13, 13, 1688, 29918, 6758, 29892, 1243, 29918, 5753, 353, 1904, 29889, 24219, 403, 29898, 29990, 29918, 1688, 29892, 343, 29918, 1688, 29892, 26952, 29922, 29906, 29897, 13, 2 ]
mongodumper.py
ahmedshabib/evergreen-gainsight-hack
0
70243
<gh_stars>0 __author__ = 'Ahmed' from pymongo import MongoClient import json import re from os import listdir from os.path import isfile, join client = MongoClient() db = client.hotelinfo j = 0 for i in [ f for f in listdir('json') if isfile(join('json',f)) ]: if i.find(".json") == -1: continue print i hotel = {} try: hotelinfo = json.load(open('json/'+i)) except: continue hotel["HotelInfo"] = hotelinfo["HotelInfo"] reviews = hotelinfo["Reviews"] finalReviewList = [] for i in range(len(reviews)): review ={} text = re.sub('[^A-Za-z0-9\.\s]+', '', reviews[i]["Content"]) text = '"' +text + '"' try: review["Content"] = text review["ReviewID"] = reviews[i]["ReviewID"] review["Ratings"] = review[i]["Ratings"] review["Author"] = review[i]["Author"] review["AuthorLocation"] = review[i]["AuthorLocation"] review["Title"] = review[i]["Title"] review["Date"] = review[i]["Date"] finalReviewList.append(review) except: continue hotel["Reviews"] = finalReviewList db.hotels.insert(hotel) print j j+=1
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 1649, 8921, 1649, 353, 525, 17565, 2168, 29915, 13, 3166, 282, 962, 7443, 1053, 18294, 4032, 13, 5215, 4390, 13, 5215, 337, 13, 3166, 2897, 1053, 1051, 3972, 13, 3166, 2897, 29889, 2084, 1053, 338, 1445, 29892, 5988, 13, 13, 4645, 353, 18294, 4032, 580, 13, 13, 13, 2585, 353, 3132, 29889, 8711, 295, 3888, 13, 13, 29926, 353, 29871, 29900, 13, 13, 1454, 474, 297, 29871, 518, 285, 363, 285, 297, 1051, 3972, 877, 3126, 1495, 565, 338, 1445, 29898, 7122, 877, 3126, 742, 29888, 876, 4514, 29901, 13, 418, 565, 474, 29889, 2886, 17350, 3126, 1159, 1275, 448, 29896, 29901, 13, 3986, 6773, 13, 418, 1596, 474, 13, 418, 16730, 353, 6571, 13, 418, 1018, 29901, 13, 4706, 16730, 3888, 353, 4390, 29889, 1359, 29898, 3150, 877, 3126, 29914, 18717, 29875, 876, 13, 418, 5174, 29901, 13, 4706, 6773, 13, 418, 16730, 3366, 28917, 295, 3401, 3108, 353, 29871, 16730, 3888, 3366, 28917, 295, 3401, 3108, 13, 418, 21804, 353, 16730, 3888, 3366, 1123, 7406, 3108, 13, 418, 2186, 1123, 1493, 1293, 353, 5159, 13, 418, 363, 474, 297, 3464, 29898, 2435, 29898, 276, 7406, 22164, 13, 3986, 9076, 353, 8875, 13, 3986, 1426, 353, 337, 29889, 1491, 877, 22896, 29909, 29899, 29999, 29874, 29899, 29920, 29900, 29899, 29929, 29905, 7790, 29879, 10062, 742, 15516, 21804, 29961, 29875, 29962, 3366, 3916, 20068, 13, 3986, 1426, 353, 18793, 29915, 718, 726, 718, 18793, 29915, 13, 3986, 1018, 29901, 13, 795, 9076, 3366, 3916, 3108, 353, 1426, 13, 795, 9076, 3366, 1123, 1493, 1367, 3108, 353, 21804, 29961, 29875, 29962, 3366, 1123, 1493, 1367, 3108, 13, 795, 9076, 3366, 29934, 271, 886, 3108, 353, 9076, 29961, 29875, 29962, 3366, 29934, 271, 886, 3108, 13, 795, 9076, 3366, 13720, 3108, 353, 9076, 29961, 29875, 29962, 3366, 13720, 3108, 13, 795, 9076, 3366, 13720, 6508, 3108, 353, 9076, 29961, 29875, 29962, 3366, 13720, 6508, 3108, 13, 795, 9076, 3366, 7030, 3108, 353, 9076, 29961, 29875, 29962, 3366, 7030, 3108, 13, 795, 9076, 3366, 2539, 3108, 353, 9076, 29961, 29875, 29962, 3366, 2539, 3108, 13, 795, 2186, 1123, 1493, 1293, 29889, 4397, 29898, 27828, 29897, 13, 3986, 5174, 29901, 13, 795, 6773, 13, 418, 16730, 3366, 1123, 7406, 3108, 353, 2186, 1123, 1493, 1293, 13, 418, 4833, 29889, 8711, 1379, 29889, 7851, 29898, 8711, 295, 29897, 13, 418, 1596, 432, 13, 418, 432, 23661, 29896, 13, 13, 2 ]
test/test_blog.py
Jn-mic/blog
0
41638
from app.models import User,Post, Comment,Clap from app import db # def setUp(self): # self.user_Jack = User(username = 'Jack',password = '<PASSWORD>', email = '<EMAIL>') def tearDown(self): Post.query.delete() User.query.delete() Comment.query.delete() Clap.query.delete()
[ 1, 515, 623, 29889, 9794, 1053, 4911, 29892, 6747, 29892, 461, 29892, 29907, 6984, 13, 3166, 623, 1053, 4833, 13, 13, 29937, 822, 731, 3373, 29898, 1311, 1125, 13, 29937, 268, 1583, 29889, 1792, 29918, 27006, 353, 4911, 29898, 6786, 353, 525, 27006, 742, 5630, 353, 12801, 25711, 17013, 29958, 742, 4876, 353, 12801, 26862, 6227, 29958, 1495, 13, 268, 13, 1753, 734, 279, 6767, 29898, 1311, 1125, 13, 4706, 4918, 29889, 1972, 29889, 8143, 580, 13, 4706, 4911, 29889, 1972, 29889, 8143, 580, 13, 4706, 461, 29889, 1972, 29889, 8143, 580, 13, 4706, 6015, 29886, 29889, 1972, 29889, 8143, 580, 2 ]
create_test_config.py
renovate-bot/python-spanner-sqlalchemy
16
185725
# -*- coding: utf-8 -*- # # Copyright 2021 Google LLC # # 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 # # https://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 configparser import sys def set_test_config(project, instance): config = configparser.ConfigParser() url = ( f"spanner:///projects/{project}/instances/{instance}/" "databases/compliance-test" ) config.add_section("db") config["db"]["default"] = url with open("test.cfg", "w") as configfile: config.write(configfile) def main(argv): project = argv[0] instance = argv[1] set_test_config(project, instance) if __name__ == "__main__": main(sys.argv[1:])
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29906, 29896, 5087, 365, 12182, 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, 2045, 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, 5215, 2295, 16680, 13, 5215, 10876, 13, 13, 13, 1753, 731, 29918, 1688, 29918, 2917, 29898, 4836, 29892, 2777, 1125, 13, 1678, 2295, 353, 2295, 16680, 29889, 3991, 11726, 580, 13, 1678, 3142, 353, 313, 13, 4706, 285, 29908, 1028, 7310, 597, 29914, 16418, 19248, 4836, 6822, 2611, 2925, 19248, 8758, 6822, 29908, 13, 4706, 376, 29503, 2129, 29914, 2388, 13036, 29899, 1688, 29908, 13, 1678, 1723, 13, 1678, 2295, 29889, 1202, 29918, 2042, 703, 2585, 1159, 13, 1678, 2295, 3366, 2585, 3108, 3366, 4381, 3108, 353, 3142, 13, 13, 1678, 411, 1722, 703, 1688, 29889, 16859, 613, 376, 29893, 1159, 408, 2295, 1445, 29901, 13, 4706, 2295, 29889, 3539, 29898, 2917, 1445, 29897, 13, 13, 13, 1753, 1667, 29898, 19218, 1125, 13, 1678, 2060, 353, 1852, 29894, 29961, 29900, 29962, 13, 1678, 2777, 353, 1852, 29894, 29961, 29896, 29962, 13, 1678, 731, 29918, 1688, 29918, 2917, 29898, 4836, 29892, 2777, 29897, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 259, 1667, 29898, 9675, 29889, 19218, 29961, 29896, 29901, 2314, 13, 2 ]
Week#3__Assignment#3/join.py
P7h/IntroToDataScience__Coursera_Course
1
17815
import MapReduce import sys """ SQL style Joins in MapReduce """ mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(record): # key: document identifier # value: document contents value = str(record[0]) num = str(record[1]) mr.emit_intermediate(num, (value, record)) def reducer(key, list_of_values): # key: word # value: list of occurrence counts x,y = list_of_values[0] for val in range(len(list_of_values)): f = [] a,b = list_of_values[val] if a == 'line_item': f += y f += b mr.emit(f) # Do not modify below this line # ============================= if __name__ == '__main__': inputdata = open(sys.argv[1]) mr.execute(inputdata, mapper, reducer)
[ 1, 1053, 7315, 29934, 6085, 346, 13, 5215, 10876, 13, 13, 15945, 29908, 13, 4176, 3114, 3650, 1144, 297, 7315, 29934, 6085, 346, 13, 15945, 29908, 13, 13, 29885, 29878, 353, 7315, 29934, 6085, 346, 29889, 3388, 29934, 6085, 346, 580, 13, 13, 29937, 1275, 9166, 4936, 25512, 13, 29937, 1938, 451, 6623, 2038, 445, 1196, 13, 13, 1753, 611, 2496, 29898, 11651, 1125, 13, 12, 12, 29937, 1820, 29901, 1842, 15882, 13, 12, 12, 29937, 995, 29901, 1842, 8118, 13, 12, 12, 1767, 353, 851, 29898, 11651, 29961, 29900, 2314, 13, 12, 12, 1949, 353, 851, 29898, 11651, 29961, 29896, 2314, 13, 12, 12, 29885, 29878, 29889, 21976, 29918, 1639, 13847, 29898, 1949, 29892, 313, 1767, 29892, 2407, 876, 13, 13, 1753, 3724, 2265, 29898, 1989, 29892, 1051, 29918, 974, 29918, 5975, 1125, 13, 12, 12, 29937, 1820, 29901, 1734, 13, 12, 12, 29937, 995, 29901, 1051, 310, 27170, 18139, 13, 12, 12, 29916, 29892, 29891, 353, 1051, 29918, 974, 29918, 5975, 29961, 29900, 29962, 13, 12, 12, 1454, 659, 297, 3464, 29898, 2435, 29898, 1761, 29918, 974, 29918, 5975, 22164, 13, 12, 12, 12, 29888, 353, 5159, 13, 12, 12, 12, 29874, 29892, 29890, 353, 1051, 29918, 974, 29918, 5975, 29961, 791, 29962, 13, 12, 12, 12, 361, 263, 1275, 525, 1220, 29918, 667, 2396, 13, 12, 12, 12, 12, 29888, 4619, 343, 13, 12, 12, 12, 12, 29888, 4619, 289, 13, 12, 12, 12, 12, 29885, 29878, 29889, 21976, 29898, 29888, 29897, 13, 13, 29937, 1938, 451, 6623, 2400, 445, 1196, 13, 29937, 1275, 9166, 4936, 25512, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 12, 2080, 1272, 353, 1722, 29898, 9675, 29889, 19218, 29961, 29896, 2314, 13, 12, 29885, 29878, 29889, 7978, 29898, 2080, 1272, 29892, 611, 2496, 29892, 3724, 2265, 29897, 13, 2 ]
tests/events/test_user_event.py
STYLER-Inc/styler-rest-framework
3
87123
<filename>tests/events/test_user_event.py """ Tests for user_event module """ from datetime import datetime from decimal import Decimal from unittest.mock import patch, Mock import json from styler_rest_framework.events import user_event from styler_rest_framework.api.request_scope import Identity class TestGetUserId: """ Tests for user_event.get_user_id """ def test_get_user_id(self, token): data = { 0: Identity(token(sysadmin=True, user_id='111')), 1: 'some parameter' } result = user_event.get_user_id(data) assert result == '111' def test_no_identity(self, token): data = { 0: '1234', 1: 'some parameter' } result = user_event.get_user_id(data) assert result is None def test_no_data(self, token): result = user_event.get_user_id(None) assert result is None class MyCustomClass: def __init__(self): self.prop1 = '1234' self.prop2 = 5555 class TestExtractNamedArgs: """ Tests for user_event.extract_named_args """ def test_extract_named_args(self): now = datetime.now() kwargs = { 'key1': 'string', 'key2': 1234, 'key3': Decimal('12.30'), 'key4': now, 'key5': MyCustomClass() } result = user_event.extract_named_args(kwargs) assert result == { 'key1': 'string', 'key2': 1234, 'key3': repr(Decimal('12.30')), 'key4': repr(now), 'key5': '{"prop1": "1234", "prop2": 5555}' } def test_no_data(self): result = user_event.extract_named_args(None) assert result == {} class TestExtractArgs: """ Tests for user_event.extract_args """ def test_extract_args(self): now = datetime.now() args = [1, 'something', now, Decimal('20.01'), MyCustomClass()] result = user_event.extract_args(args) assert result == { 0: 1, 1: 'something', 2: repr(now), 3: repr(Decimal('20.01')), 4: '{"prop1": "1234", "prop2": 5555}' } class TestTrack: """ Tests for user_event.track """ @patch('styler_rest_framework.events.user_event.handler') def test_track_function(self, mocked_handler, token): @user_event.track def do_something(a, b, c, d): return 'something' iden = Identity(token(sysadmin=True, user_id='111')) with patch( 'styler_rest_framework.events.user_event.time.time', Mock(return_value='timestamp') ): do_something(1234, 'aaa', c='parameter c', d=iden) mocked_handler.assert_called_once_with( user_event._TABLE, 'tests.events.test_user_event.do_something', '111#tests.events.test_user_event.do_something#timestamp', { 0: 1234, 1: 'aaa', 'c': 'parameter c', 'd': json.dumps(iden.__dict__), 'return': '"something"' } )
[ 1, 529, 9507, 29958, 21150, 29914, 13604, 29914, 1688, 29918, 1792, 29918, 3696, 29889, 2272, 13, 15945, 29908, 4321, 29879, 363, 1404, 29918, 3696, 3883, 13, 15945, 29908, 13, 3166, 12865, 1053, 12865, 13, 3166, 13677, 1053, 3826, 3039, 13, 3166, 443, 27958, 29889, 17640, 1053, 13261, 29892, 26297, 13, 5215, 4390, 13, 13, 3166, 15877, 1358, 29918, 5060, 29918, 4468, 29889, 13604, 1053, 1404, 29918, 3696, 13, 3166, 15877, 1358, 29918, 5060, 29918, 4468, 29889, 2754, 29889, 3827, 29918, 6078, 1053, 27486, 13, 13, 13, 1990, 4321, 2577, 2659, 1204, 29901, 13, 1678, 9995, 4321, 29879, 363, 1404, 29918, 3696, 29889, 657, 29918, 1792, 29918, 333, 13, 1678, 9995, 13, 1678, 822, 1243, 29918, 657, 29918, 1792, 29918, 333, 29898, 1311, 29892, 5993, 1125, 13, 4706, 848, 353, 426, 13, 632, 29900, 29901, 27486, 29898, 6979, 29898, 9675, 6406, 29922, 5574, 29892, 1404, 29918, 333, 2433, 29896, 29896, 29896, 1495, 511, 13, 632, 29896, 29901, 525, 5372, 3443, 29915, 13, 4706, 500, 13, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 657, 29918, 1792, 29918, 333, 29898, 1272, 29897, 13, 13, 4706, 4974, 1121, 1275, 525, 29896, 29896, 29896, 29915, 13, 13, 1678, 822, 1243, 29918, 1217, 29918, 22350, 29898, 1311, 29892, 5993, 1125, 13, 4706, 848, 353, 426, 13, 632, 29900, 29901, 525, 29896, 29906, 29941, 29946, 742, 13, 632, 29896, 29901, 525, 5372, 3443, 29915, 13, 4706, 500, 13, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 657, 29918, 1792, 29918, 333, 29898, 1272, 29897, 13, 13, 4706, 4974, 1121, 338, 6213, 13, 13, 1678, 822, 1243, 29918, 1217, 29918, 1272, 29898, 1311, 29892, 5993, 1125, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 657, 29918, 1792, 29918, 333, 29898, 8516, 29897, 13, 13, 4706, 4974, 1121, 338, 6213, 13, 13, 13, 1990, 1619, 7281, 2385, 29901, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 7728, 29896, 353, 525, 29896, 29906, 29941, 29946, 29915, 13, 4706, 1583, 29889, 7728, 29906, 353, 29871, 29945, 29945, 29945, 29945, 13, 13, 13, 1990, 4321, 5647, 1461, 22175, 7883, 29901, 13, 1678, 9995, 4321, 29879, 363, 1404, 29918, 3696, 29889, 21111, 29918, 17514, 29918, 5085, 13, 1678, 9995, 13, 1678, 822, 1243, 29918, 21111, 29918, 17514, 29918, 5085, 29898, 1311, 1125, 13, 4706, 1286, 353, 12865, 29889, 3707, 580, 13, 4706, 9049, 5085, 353, 426, 13, 9651, 525, 1989, 29896, 2396, 525, 1807, 742, 13, 9651, 525, 1989, 29906, 2396, 29871, 29896, 29906, 29941, 29946, 29892, 13, 9651, 525, 1989, 29941, 2396, 3826, 3039, 877, 29896, 29906, 29889, 29941, 29900, 5477, 13, 9651, 525, 1989, 29946, 2396, 1286, 29892, 13, 9651, 525, 1989, 29945, 2396, 1619, 7281, 2385, 580, 13, 4706, 500, 13, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 21111, 29918, 17514, 29918, 5085, 29898, 19290, 29897, 13, 13, 4706, 4974, 1121, 1275, 426, 13, 9651, 525, 1989, 29896, 2396, 525, 1807, 742, 13, 9651, 525, 1989, 29906, 2396, 29871, 29896, 29906, 29941, 29946, 29892, 13, 9651, 525, 1989, 29941, 2396, 2062, 29898, 23307, 877, 29896, 29906, 29889, 29941, 29900, 1495, 511, 13, 9651, 525, 1989, 29946, 2396, 2062, 29898, 3707, 511, 13, 9651, 525, 1989, 29945, 2396, 525, 6377, 7728, 29896, 1115, 376, 29896, 29906, 29941, 29946, 613, 376, 7728, 29906, 1115, 29871, 29945, 29945, 29945, 29945, 10162, 13, 4706, 500, 13, 13, 1678, 822, 1243, 29918, 1217, 29918, 1272, 29898, 1311, 1125, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 21111, 29918, 17514, 29918, 5085, 29898, 8516, 29897, 13, 13, 4706, 4974, 1121, 1275, 6571, 13, 13, 13, 1990, 4321, 5647, 1461, 7883, 29901, 13, 1678, 9995, 4321, 29879, 363, 1404, 29918, 3696, 29889, 21111, 29918, 5085, 13, 1678, 9995, 13, 1678, 822, 1243, 29918, 21111, 29918, 5085, 29898, 1311, 1125, 13, 4706, 1286, 353, 12865, 29889, 3707, 580, 13, 4706, 6389, 353, 518, 29896, 29892, 525, 14481, 742, 1286, 29892, 3826, 3039, 877, 29906, 29900, 29889, 29900, 29896, 5477, 1619, 7281, 2385, 580, 29962, 13, 13, 4706, 1121, 353, 1404, 29918, 3696, 29889, 21111, 29918, 5085, 29898, 5085, 29897, 13, 13, 4706, 4974, 1121, 1275, 426, 13, 632, 29900, 29901, 29871, 29896, 29892, 13, 632, 29896, 29901, 525, 14481, 742, 13, 632, 29906, 29901, 2062, 29898, 3707, 511, 13, 632, 29941, 29901, 2062, 29898, 23307, 877, 29906, 29900, 29889, 29900, 29896, 1495, 511, 13, 632, 29946, 29901, 525, 6377, 7728, 29896, 1115, 376, 29896, 29906, 29941, 29946, 613, 376, 7728, 29906, 1115, 29871, 29945, 29945, 29945, 29945, 10162, 13, 4706, 500, 13, 13, 13, 1990, 4321, 17936, 29901, 13, 1678, 9995, 4321, 29879, 363, 1404, 29918, 3696, 29889, 11294, 13, 1678, 9995, 13, 1678, 732, 5041, 877, 22062, 1358, 29918, 5060, 29918, 4468, 29889, 13604, 29889, 1792, 29918, 3696, 29889, 13789, 1495, 13, 1678, 822, 1243, 29918, 11294, 29918, 2220, 29898, 1311, 29892, 11187, 287, 29918, 13789, 29892, 5993, 1125, 13, 4706, 732, 1792, 29918, 3696, 29889, 11294, 13, 4706, 822, 437, 29918, 14481, 29898, 29874, 29892, 289, 29892, 274, 29892, 270, 1125, 13, 9651, 736, 525, 14481, 29915, 13, 4706, 1178, 264, 353, 27486, 29898, 6979, 29898, 9675, 6406, 29922, 5574, 29892, 1404, 29918, 333, 2433, 29896, 29896, 29896, 8785, 13, 13, 4706, 411, 13261, 29898, 13, 9651, 525, 22062, 1358, 29918, 5060, 29918, 4468, 29889, 13604, 29889, 1792, 29918, 3696, 29889, 2230, 29889, 2230, 742, 13, 9651, 26297, 29898, 2457, 29918, 1767, 2433, 16394, 1495, 13, 308, 1125, 13, 9651, 437, 29918, 14481, 29898, 29896, 29906, 29941, 29946, 29892, 525, 7340, 29874, 742, 274, 2433, 15501, 274, 742, 270, 29922, 3615, 29897, 13, 13, 4706, 11187, 287, 29918, 13789, 29889, 9294, 29918, 13998, 29918, 10646, 29918, 2541, 29898, 13, 9651, 1404, 29918, 3696, 3032, 21009, 29892, 13, 9651, 525, 21150, 29889, 13604, 29889, 1688, 29918, 1792, 29918, 3696, 29889, 1867, 29918, 14481, 742, 13, 9651, 525, 29896, 29896, 29896, 29937, 21150, 29889, 13604, 29889, 1688, 29918, 1792, 29918, 3696, 29889, 1867, 29918, 14481, 29937, 16394, 742, 13, 9651, 426, 13, 462, 29900, 29901, 29871, 29896, 29906, 29941, 29946, 29892, 13, 462, 29896, 29901, 525, 7340, 29874, 742, 13, 18884, 525, 29883, 2396, 525, 15501, 274, 742, 13, 18884, 525, 29881, 2396, 4390, 29889, 29881, 17204, 29898, 3615, 17255, 8977, 1649, 511, 13, 18884, 525, 2457, 2396, 18793, 14481, 29908, 29915, 13, 9651, 500, 13, 4706, 1723, 13, 2 ]
ti_python_sdk/use_tensorboard/code/tf_mnist.py
mengsuix/tencent-ti-examples
2
166139
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import argparse import numpy as np IMAGE_SIZE = 28 LABELS_SIZE = 10 HIDDEN_SIZE = 2048 INPUT_FEATURE = 'image' def raw_input_fn(dataset): return dataset.images, dataset.labels.astype(np.int32) def serve_input_fn(): reciever_tensors = { INPUT_FEATURE: tf.placeholder(tf.float32, [None, None, None, 1]), } features = { INPUT_FEATURE: tf.image.resize_images(reciever_tensors[INPUT_FEATURE], [IMAGE_SIZE, IMAGE_SIZE]), } return tf.estimator.export.ServingInputReceiver(receiver_tensors=reciever_tensors, features=features) def train(data_dir, model_dir, checkpoints_dir, train_steps): # Set logging level tf.logging.set_verbosity(tf.logging.INFO) # Read Mnist dataset mnist = input_data.read_data_sets(data_dir, one_hot=False) # Define training checkpoints config checkpointing_config = tf.estimator.RunConfig( save_checkpoints_secs = 30, keep_checkpoint_max = 100, ) # Define training classifier feature_columns = [tf.feature_column.numeric_column(INPUT_FEATURE, shape=[IMAGE_SIZE, IMAGE_SIZE])] classifier = tf.estimator.DNNClassifier(feature_columns=feature_columns, hidden_units=[HIDDEN_SIZE], n_classes=LABELS_SIZE, optimizer=tf.train.AdamOptimizer(), config=checkpointing_config, model_dir=checkpoints_dir) # Define training model train_input_fn = tf.estimator.inputs.numpy_input_fn( x={INPUT_FEATURE : raw_input_fn(mnist.train)[0]}, y=raw_input_fn(mnist.train)[1], num_epochs=None, batch_size=128, shuffle=True ) classifier.train(input_fn=train_input_fn, steps=train_steps) # Save training Model model_dir = classifier.export_savedmodel("/opt/ml/model", serve_input_fn) print("model path: %s" % model_dir) if __name__ == '__main__': args_parser = argparse.ArgumentParser() args_parser.add_argument( '--data_dir', default='/opt/ml/input/data/training', type=str, help='the training data directory.') args_parser.add_argument( '--model_dir', default='/opt/ml/model', type=str, help='the model directory.') args_parser.add_argument( '--checkpoints_dir', default='/opt/ml/checkpoints', type=str, help='the checkpoints directory.') args_parser.add_argument( '--train-steps', type=int, default=100, help='Ttrain steps number.') args = args_parser.parse_args() train(**vars(args))
[ 1, 1053, 26110, 408, 15886, 13, 3166, 26110, 29889, 19057, 29889, 12631, 29879, 29889, 23521, 391, 1053, 1881, 29918, 1272, 13, 5215, 1852, 5510, 13, 5215, 12655, 408, 7442, 13, 13, 2382, 29918, 14226, 353, 29871, 29906, 29947, 13, 24461, 6670, 29903, 29918, 14226, 353, 29871, 29896, 29900, 13, 29950, 1367, 29928, 1430, 29918, 14226, 353, 29871, 29906, 29900, 29946, 29947, 13, 1177, 12336, 29918, 16359, 1299, 11499, 353, 525, 3027, 29915, 13, 13, 1753, 10650, 29918, 2080, 29918, 9144, 29898, 24713, 1125, 13, 1678, 736, 8783, 29889, 8346, 29892, 8783, 29889, 21134, 29889, 579, 668, 29898, 9302, 29889, 524, 29941, 29906, 29897, 13, 13, 1753, 9080, 29918, 2080, 29918, 9144, 7295, 13, 1678, 1162, 347, 369, 29918, 29873, 575, 943, 353, 426, 13, 4706, 2672, 12336, 29918, 16359, 1299, 11499, 29901, 15886, 29889, 27074, 29898, 13264, 29889, 7411, 29941, 29906, 29892, 518, 8516, 29892, 6213, 29892, 6213, 29892, 29871, 29896, 11724, 13, 1678, 500, 13, 13, 1678, 5680, 353, 426, 13, 4706, 2672, 12336, 29918, 16359, 1299, 11499, 29901, 15886, 29889, 3027, 29889, 21476, 29918, 8346, 29898, 3757, 347, 369, 29918, 29873, 575, 943, 29961, 1177, 12336, 29918, 16359, 1299, 11499, 1402, 518, 2382, 29918, 14226, 29892, 306, 1529, 1692, 29918, 14226, 11724, 13, 1678, 500, 13, 1678, 736, 15886, 29889, 342, 326, 1061, 29889, 15843, 29889, 1748, 1747, 4290, 22068, 29898, 13556, 2147, 29918, 29873, 575, 943, 29922, 3757, 347, 369, 29918, 29873, 575, 943, 29892, 13, 462, 1678, 5680, 29922, 22100, 29897, 13, 13, 1753, 7945, 29898, 1272, 29918, 3972, 29892, 1904, 29918, 3972, 29892, 1423, 9748, 29918, 3972, 29892, 7945, 29918, 24530, 1125, 13, 1678, 396, 3789, 12183, 3233, 13, 1678, 15886, 29889, 21027, 29889, 842, 29918, 18248, 359, 537, 29898, 13264, 29889, 21027, 29889, 11690, 29897, 13, 268, 13, 1678, 396, 7523, 341, 29876, 391, 8783, 13, 1678, 28597, 391, 353, 1881, 29918, 1272, 29889, 949, 29918, 1272, 29918, 7224, 29898, 1272, 29918, 3972, 29892, 697, 29918, 8711, 29922, 8824, 29897, 13, 13, 1678, 396, 22402, 6694, 1423, 9748, 2295, 13, 1678, 1423, 3149, 292, 29918, 2917, 353, 15886, 29889, 342, 326, 1061, 29889, 6558, 3991, 29898, 13, 4706, 4078, 29918, 3198, 9748, 29918, 344, 2395, 353, 29871, 29941, 29900, 29892, 13, 4706, 3013, 29918, 3198, 3149, 29918, 3317, 353, 29871, 29896, 29900, 29900, 29892, 268, 13, 1678, 1723, 13, 268, 13, 1678, 396, 22402, 6694, 770, 3709, 13, 1678, 4682, 29918, 13099, 353, 518, 13264, 29889, 14394, 29918, 4914, 29889, 21574, 29918, 4914, 29898, 1177, 12336, 29918, 16359, 1299, 11499, 29892, 8267, 11759, 2382, 29918, 14226, 29892, 306, 1529, 1692, 29918, 14226, 2314, 29962, 13, 1678, 770, 3709, 353, 15886, 29889, 342, 326, 1061, 29889, 29928, 10262, 2385, 3709, 29898, 14394, 29918, 13099, 29922, 14394, 29918, 13099, 29892, 13, 462, 462, 9651, 7934, 29918, 348, 1169, 11759, 29950, 1367, 29928, 1430, 29918, 14226, 1402, 13, 462, 462, 9651, 302, 29918, 13203, 29922, 24461, 6670, 29903, 29918, 14226, 29892, 13, 462, 462, 9651, 5994, 3950, 29922, 13264, 29889, 14968, 29889, 3253, 314, 20624, 326, 3950, 3285, 13, 462, 462, 9651, 2295, 29922, 3198, 3149, 292, 29918, 2917, 29892, 13, 462, 462, 9651, 1904, 29918, 3972, 29922, 3198, 9748, 29918, 3972, 29897, 13, 13, 1678, 396, 22402, 6694, 1904, 13, 1678, 7945, 29918, 2080, 29918, 9144, 353, 15886, 29889, 342, 326, 1061, 29889, 2080, 29879, 29889, 23749, 29918, 2080, 29918, 9144, 29898, 13, 4706, 921, 3790, 1177, 12336, 29918, 16359, 1299, 11499, 584, 10650, 29918, 2080, 29918, 9144, 29898, 23521, 391, 29889, 14968, 9601, 29900, 29962, 1118, 13, 4706, 343, 29922, 1610, 29918, 2080, 29918, 9144, 29898, 23521, 391, 29889, 14968, 9601, 29896, 1402, 13, 4706, 954, 29918, 1022, 2878, 29879, 29922, 8516, 29892, 13, 4706, 9853, 29918, 2311, 29922, 29896, 29906, 29947, 29892, 13, 4706, 528, 21897, 29922, 5574, 13, 1678, 1723, 13, 13, 1678, 770, 3709, 29889, 14968, 29898, 2080, 29918, 9144, 29922, 14968, 29918, 2080, 29918, 9144, 29892, 6576, 29922, 14968, 29918, 24530, 29897, 13, 13, 1678, 396, 16913, 6694, 8125, 13, 1678, 1904, 29918, 3972, 353, 770, 3709, 29889, 15843, 29918, 17314, 4299, 11974, 3670, 29914, 828, 29914, 4299, 613, 9080, 29918, 2080, 29918, 9144, 29897, 13, 1678, 1596, 703, 4299, 2224, 29901, 1273, 29879, 29908, 1273, 1904, 29918, 3972, 29897, 13, 268, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 6389, 29918, 16680, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 1678, 6389, 29918, 16680, 29889, 1202, 29918, 23516, 29898, 13, 4706, 525, 489, 1272, 29918, 3972, 742, 13, 4706, 2322, 2433, 29914, 3670, 29914, 828, 29914, 2080, 29914, 1272, 29914, 26495, 742, 13, 4706, 1134, 29922, 710, 29892, 13, 4706, 1371, 2433, 1552, 6694, 848, 3884, 29889, 1495, 13, 13, 1678, 6389, 29918, 16680, 29889, 1202, 29918, 23516, 29898, 13, 4706, 525, 489, 4299, 29918, 3972, 742, 13, 4706, 2322, 2433, 29914, 3670, 29914, 828, 29914, 4299, 742, 13, 4706, 1134, 29922, 710, 29892, 13, 4706, 1371, 2433, 1552, 1904, 3884, 29889, 1495, 13, 13, 1678, 6389, 29918, 16680, 29889, 1202, 29918, 23516, 29898, 13, 4706, 525, 489, 3198, 9748, 29918, 3972, 742, 13, 4706, 2322, 2433, 29914, 3670, 29914, 828, 29914, 3198, 9748, 742, 13, 4706, 1134, 29922, 710, 29892, 13, 4706, 1371, 2433, 1552, 1423, 9748, 3884, 29889, 1495, 13, 13, 1678, 6389, 29918, 16680, 29889, 1202, 29918, 23516, 29898, 13, 4706, 525, 489, 14968, 29899, 24530, 742, 13, 4706, 1134, 29922, 524, 29892, 13, 4706, 2322, 29922, 29896, 29900, 29900, 29892, 13, 4706, 1371, 2433, 29911, 14968, 6576, 1353, 29889, 1495, 13, 13, 1678, 6389, 353, 6389, 29918, 16680, 29889, 5510, 29918, 5085, 580, 13, 1678, 7945, 29898, 1068, 16908, 29898, 5085, 876, 2 ]
crawler_peopleadvice.py
JiawenXing/Flame
0
149557
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 30 23:03:39 2019 @author: xingjiawen """ # 爬取人民建议征集网站 # Part I 爬取前一千条的标题、超链接、时间 # Part II 爬取现在到2019/1/1的、标题含垃圾二字的标题、超链接、时间 import requests from bs4 import BeautifulSoup import pandas as pd import time u21 = 'http://wsxf.sh.gov.cn/xf_rmyjzj/list.aspx?nav=&pageindex=' index = 1 u22 = '&pagesize=20' # 第一页的网址: u21 + str(index) + u22 ###################################### # Part I 爬取前一千条的标题、超链接、时间 # ###################################### titles2 = [] # 接收标题 hrefs2 = [] # 接收超链接 finishtimes2 = [] # 接收完结时间 number = 1000 # 想爬取的问题数目 while len(titles2) < number: url = u21 + str(index) + u22 index = index + 1 res = requests.get(url) if res.status_code == 200: html = res.text mysoup = BeautifulSoup(html,'lxml') question_list = mysoup.find('ul', attrs = {'class':'list'}).find_all('li') # 包含了当前页面所有的问题相关的信息 for item in question_list: # 提取建议标题 title2 = item.find('a').getText() # 提取标题 titles2.append(title2) # 提取建议超链接 href2 = item.find('a')['href'] # 提取超链接 hrefs2.append('http://wsxf.sh.gov.cn/xf_rmyjzj/' + href2) # 提取时间 time2 = item.find('span').next_sibling.next_sibling.getText() finishtimes2.append(time2) print('Get',number, 'suggestions !') # Get 1000 suggestions ! # 储存上一部分爬取的内容 with open('/Users/xingjiawen/OneDrive/文档/SJTU/2019-2020Autumn/大数据分析/renminjianyi.txt','w') as f: i = 0 # 第 i 次写入第 i 个问题的三个属性 # titles2 = [],hrefs2 = [],finishtimes2 = [] while i < len(titles2): f.writelines([titles2[i], ';', hrefs2[i], ';', finishtimes2[i], '\n']) i = i + 1 print('Finished.', len(titles2),'questions crawled.') ############################################################ # Part II 爬取现在到2019/1/1的、标题含垃圾二字的标题、超链接、时间 # ############################################################ trashtitles = [] trashhrefs = [] trashfinishtimes = [] while index < 88: url = u21 + str(index) + u22 index = index + 1 res = requests.get(url) if res.status_code == 200: html = res.text mysoup = BeautifulSoup(html,'lxml') question_list = mysoup.find('ul', attrs = {'class':'list'}).find_all('li') # 包含了当前页面所有的问题相关的信息 for item in question_list: # 提取建议标题 title = item.find('a').getText() if '垃圾' in title: # 只针对标题中含有垃圾二字的进行操作 trashtitles.append(title) # 提取建议超链接 href = item.find('a')['href'] # 提取超链接 trashhrefs.append('http://wsxf.sh.gov.cn/xf_rmyjzj/' + href) # 提取时间 time = item.find('span').next_sibling.next_sibling.getText() trashfinishtimes.append(time) print('Get',len(trashtitles), 'suggestions !') # Get 162 suggestions ! # 爬取垃圾相关问题的二级网页。 for u in trashhrefs: trashres = requests.get(u) if trashres.status_code == 200: trashhtml = trashres.text trashsoup = BeautifulSoup(trashhtml, 'lxml') # ……没写完 ############################################################以下是参考的代码。 # 进入二级网页提取问题类别、阅读数 for href in q_href: q_res = requests.get(href) if q_res.status_code == 200: q_html = q_res.text q_soup = BeautifulSoup(q_html, 'lxml') # 提取问题类别 type_of_q = q_soup.find('ul', attrs = {'class':'label detail-tag'}).find_all('li') tq = [] for i in type_of_q: t = i.getText() tq.append(t) types.append(tq) # 提取问题阅读数 reader = q_soup.find('span', attrs = {'class':'absoulte-img'}).find('a').getText() readers.append(reader) else: print(page, res.status_code) break
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 29941, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 13, 20399, 373, 12178, 2864, 29871, 29941, 29900, 29871, 29906, 29941, 29901, 29900, 29941, 29901, 29941, 29929, 29871, 29906, 29900, 29896, 29929, 13, 13, 29992, 8921, 29901, 921, 292, 29926, 423, 15556, 13, 15945, 29908, 13, 13, 29937, 29871, 234, 139, 175, 30683, 30313, 30855, 30886, 235, 177, 177, 232, 193, 132, 30893, 31222, 31433, 13, 29937, 3455, 306, 29871, 234, 139, 175, 30683, 30658, 30287, 31159, 31217, 30210, 31062, 31596, 30330, 31480, 236, 150, 193, 31092, 30330, 30594, 31016, 13, 29937, 3455, 1944, 29871, 234, 139, 175, 30683, 31424, 30505, 30780, 29906, 29900, 29896, 29929, 29914, 29896, 29914, 29896, 30210, 30330, 31062, 31596, 232, 147, 174, 232, 161, 134, 232, 159, 193, 30685, 30578, 30210, 31062, 31596, 30330, 31480, 236, 150, 193, 31092, 30330, 30594, 31016, 13, 13, 5215, 7274, 13, 3166, 24512, 29946, 1053, 25685, 29903, 1132, 13, 5215, 11701, 408, 10518, 13, 5215, 931, 13, 13, 29884, 29906, 29896, 353, 525, 1124, 597, 5652, 24660, 29889, 845, 29889, 13513, 29889, 18038, 29914, 24660, 29918, 29878, 1357, 29926, 29920, 29926, 29914, 1761, 29889, 6307, 29973, 6654, 29332, 3488, 2248, 2433, 13, 2248, 353, 29871, 29896, 13, 29884, 29906, 29906, 353, 525, 29987, 12292, 675, 29922, 29906, 29900, 29915, 396, 29871, 30622, 30287, 31610, 30210, 31222, 31702, 30383, 318, 29906, 29896, 718, 851, 29898, 2248, 29897, 718, 318, 29906, 29906, 13, 13, 13383, 13383, 4136, 2277, 13, 29937, 3455, 306, 29871, 234, 139, 175, 30683, 30658, 30287, 31159, 31217, 30210, 31062, 31596, 30330, 31480, 236, 150, 193, 31092, 30330, 30594, 31016, 396, 13, 13383, 13383, 4136, 2277, 13, 23545, 793, 29906, 353, 5159, 396, 29871, 31092, 31997, 31062, 31596, 13, 12653, 29879, 29906, 353, 5159, 396, 29871, 31092, 31997, 31480, 236, 150, 193, 31092, 13, 4951, 275, 400, 1355, 29906, 353, 5159, 396, 29871, 31092, 31997, 31366, 31320, 30594, 31016, 13, 4537, 353, 29871, 29896, 29900, 29900, 29900, 396, 29871, 31522, 234, 139, 175, 30683, 30210, 31658, 31596, 30354, 30895, 13, 8000, 7431, 29898, 23545, 793, 29906, 29897, 529, 1353, 29901, 13, 1678, 3142, 353, 318, 29906, 29896, 718, 851, 29898, 2248, 29897, 718, 318, 29906, 29906, 13, 1678, 2380, 353, 2380, 718, 29871, 29896, 13, 1678, 620, 353, 7274, 29889, 657, 29898, 2271, 29897, 13, 1678, 565, 620, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 4706, 3472, 353, 620, 29889, 726, 13, 4706, 590, 29879, 1132, 353, 25685, 29903, 1132, 29898, 1420, 5501, 29880, 3134, 1495, 13, 4706, 1139, 29918, 1761, 353, 590, 29879, 1132, 29889, 2886, 877, 352, 742, 12421, 29879, 353, 11117, 1990, 22099, 1761, 29915, 7690, 2886, 29918, 497, 877, 492, 1495, 396, 29871, 31473, 232, 147, 174, 30743, 30948, 30658, 31610, 30806, 30744, 30417, 30210, 31658, 31596, 30990, 31057, 30210, 30689, 31021, 13, 13, 4706, 363, 2944, 297, 1139, 29918, 1761, 29901, 13, 9651, 396, 29871, 31302, 30683, 30886, 235, 177, 177, 31062, 31596, 13, 9651, 3611, 29906, 353, 2944, 29889, 2886, 877, 29874, 2824, 18516, 580, 29871, 396, 29871, 31302, 30683, 31062, 31596, 13, 9651, 17735, 29906, 29889, 4397, 29898, 3257, 29906, 29897, 13, 9651, 396, 29871, 31302, 30683, 30886, 235, 177, 177, 31480, 236, 150, 193, 31092, 13, 9651, 2822, 29906, 353, 2944, 29889, 2886, 877, 29874, 1495, 1839, 12653, 2033, 396, 29871, 31302, 30683, 31480, 236, 150, 193, 31092, 13, 9651, 2822, 29879, 29906, 29889, 4397, 877, 1124, 597, 5652, 24660, 29889, 845, 29889, 13513, 29889, 18038, 29914, 24660, 29918, 29878, 1357, 29926, 29920, 29926, 22208, 718, 2822, 29906, 29897, 13, 9651, 396, 29871, 31302, 30683, 30594, 31016, 13, 9651, 931, 29906, 353, 2944, 29889, 2886, 877, 9653, 2824, 4622, 29918, 29879, 747, 1847, 29889, 4622, 29918, 29879, 747, 1847, 29889, 18516, 580, 13, 9651, 1436, 275, 400, 1355, 29906, 29889, 4397, 29898, 2230, 29906, 29897, 13, 13, 2158, 877, 2577, 742, 4537, 29892, 525, 29879, 12981, 2297, 1738, 1495, 396, 3617, 29871, 29896, 29900, 29900, 29900, 10529, 1738, 13, 13, 29937, 29871, 232, 133, 171, 30946, 30429, 30287, 30636, 30748, 234, 139, 175, 30683, 30210, 30728, 31294, 13, 2541, 1722, 11219, 5959, 29914, 29916, 292, 29926, 423, 15556, 29914, 6716, 29928, 4401, 29914, 30333, 233, 164, 166, 29914, 29903, 29967, 29911, 29965, 29914, 29906, 29900, 29896, 29929, 29899, 29906, 29900, 29906, 29900, 6147, 1227, 29914, 30257, 30354, 30763, 30748, 233, 161, 147, 29914, 1267, 1195, 29926, 713, 25675, 29889, 3945, 3788, 29893, 1495, 408, 285, 29901, 13, 1678, 474, 353, 29871, 29900, 13, 1678, 396, 29871, 30622, 474, 29871, 30936, 31479, 30752, 30622, 474, 29871, 30502, 31658, 31596, 30210, 30457, 30502, 31360, 30952, 13, 1678, 396, 17735, 29906, 353, 5159, 30214, 12653, 29879, 29906, 353, 5159, 30214, 4951, 275, 400, 1355, 29906, 353, 5159, 13, 1678, 1550, 474, 529, 7431, 29898, 23545, 793, 29906, 1125, 13, 4706, 285, 29889, 8231, 24210, 4197, 23545, 793, 29906, 29961, 29875, 1402, 21921, 742, 2822, 29879, 29906, 29961, 29875, 1402, 21921, 742, 1436, 275, 400, 1355, 29906, 29961, 29875, 1402, 11297, 29876, 11287, 13, 4706, 474, 353, 474, 718, 29871, 29896, 13, 2158, 877, 12881, 3276, 29889, 742, 7431, 29898, 23545, 793, 29906, 511, 29915, 2619, 29349, 839, 29889, 1495, 13, 13, 13383, 13383, 13383, 7346, 4136, 13, 29937, 3455, 1944, 29871, 234, 139, 175, 30683, 31424, 30505, 30780, 29906, 29900, 29896, 29929, 29914, 29896, 29914, 29896, 30210, 30330, 31062, 31596, 232, 147, 174, 232, 161, 134, 232, 159, 193, 30685, 30578, 30210, 31062, 31596, 30330, 31480, 236, 150, 193, 31092, 30330, 30594, 31016, 396, 13, 13383, 13383, 13383, 7346, 4136, 13, 10678, 400, 277, 793, 353, 5159, 13, 509, 1161, 12653, 29879, 353, 5159, 13, 509, 1161, 4951, 275, 400, 1355, 353, 5159, 13, 13, 8000, 2380, 529, 29871, 29947, 29947, 29901, 13, 1678, 3142, 353, 318, 29906, 29896, 718, 851, 29898, 2248, 29897, 718, 318, 29906, 29906, 13, 1678, 2380, 353, 2380, 718, 29871, 29896, 13, 1678, 620, 353, 7274, 29889, 657, 29898, 2271, 29897, 13, 1678, 565, 620, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 4706, 3472, 353, 620, 29889, 726, 13, 4706, 590, 29879, 1132, 353, 25685, 29903, 1132, 29898, 1420, 5501, 29880, 3134, 1495, 13, 4706, 1139, 29918, 1761, 353, 590, 29879, 1132, 29889, 2886, 877, 352, 742, 12421, 29879, 353, 11117, 1990, 22099, 1761, 29915, 7690, 2886, 29918, 497, 877, 492, 1495, 396, 29871, 31473, 232, 147, 174, 30743, 30948, 30658, 31610, 30806, 30744, 30417, 30210, 31658, 31596, 30990, 31057, 30210, 30689, 31021, 13, 13, 4706, 363, 2944, 297, 1139, 29918, 1761, 29901, 13, 9651, 396, 29871, 31302, 30683, 30886, 235, 177, 177, 31062, 31596, 13, 9651, 3611, 353, 2944, 29889, 2886, 877, 29874, 2824, 18516, 580, 13, 9651, 565, 525, 232, 161, 134, 232, 159, 193, 29915, 297, 3611, 29901, 396, 29871, 31557, 236, 149, 139, 30783, 31062, 31596, 30275, 232, 147, 174, 30417, 232, 161, 134, 232, 159, 193, 30685, 30578, 30210, 31174, 30448, 31904, 30732, 13, 18884, 6809, 400, 277, 793, 29889, 4397, 29898, 3257, 29897, 13, 18884, 396, 29871, 31302, 30683, 30886, 235, 177, 177, 31480, 236, 150, 193, 31092, 13, 18884, 2822, 353, 2944, 29889, 2886, 877, 29874, 1495, 1839, 12653, 2033, 396, 29871, 31302, 30683, 31480, 236, 150, 193, 31092, 13, 18884, 534, 1161, 12653, 29879, 29889, 4397, 877, 1124, 597, 5652, 24660, 29889, 845, 29889, 13513, 29889, 18038, 29914, 24660, 29918, 29878, 1357, 29926, 29920, 29926, 22208, 718, 2822, 29897, 13, 18884, 396, 29871, 31302, 30683, 30594, 31016, 13, 18884, 931, 353, 2944, 29889, 2886, 877, 9653, 2824, 4622, 29918, 29879, 747, 1847, 29889, 4622, 29918, 29879, 747, 1847, 29889, 18516, 580, 13, 18884, 534, 1161, 4951, 275, 400, 1355, 29889, 4397, 29898, 2230, 29897, 13, 13, 2158, 877, 2577, 742, 2435, 29898, 10678, 400, 277, 793, 511, 525, 29879, 12981, 2297, 1738, 1495, 396, 3617, 29871, 29896, 29953, 29906, 10529, 1738, 13, 13, 29937, 29871, 234, 139, 175, 30683, 232, 161, 134, 232, 159, 193, 30990, 31057, 31658, 31596, 30210, 30685, 234, 189, 170, 31222, 31610, 30267, 13, 1454, 318, 297, 534, 1161, 12653, 29879, 29901, 13, 1678, 534, 1161, 690, 353, 7274, 29889, 657, 29898, 29884, 29897, 13, 1678, 565, 534, 1161, 690, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 4706, 534, 1161, 1420, 353, 534, 1161, 690, 29889, 726, 13, 4706, 534, 1161, 29879, 1132, 353, 25685, 29903, 1132, 29898, 509, 1161, 1420, 29892, 525, 29880, 3134, 1495, 13, 4706, 396, 16088, 30098, 31423, 31479, 31366, 13, 13383, 13383, 13383, 7346, 4136, 30651, 30557, 30392, 31125, 235, 131, 134, 30210, 30690, 31183, 30267, 13, 4706, 396, 29871, 31174, 30752, 30685, 234, 189, 170, 31222, 31610, 31302, 30683, 31658, 31596, 30832, 232, 139, 174, 30330, 236, 155, 136, 235, 178, 190, 30354, 13, 4706, 363, 2822, 297, 3855, 29918, 12653, 29901, 13, 9651, 3855, 29918, 690, 353, 7274, 29889, 657, 29898, 12653, 29897, 13, 9651, 565, 3855, 29918, 690, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 18884, 3855, 29918, 1420, 353, 3855, 29918, 690, 29889, 726, 13, 18884, 3855, 29918, 29879, 1132, 353, 25685, 29903, 1132, 29898, 29939, 29918, 1420, 29892, 525, 29880, 3134, 1495, 13, 18884, 396, 29871, 31302, 30683, 31658, 31596, 30832, 232, 139, 174, 13, 18884, 1134, 29918, 974, 29918, 29939, 353, 3855, 29918, 29879, 1132, 29889, 2886, 877, 352, 742, 12421, 29879, 353, 11117, 1990, 22099, 1643, 9493, 29899, 4039, 29915, 7690, 2886, 29918, 497, 877, 492, 1495, 13, 18884, 260, 29939, 353, 5159, 13, 18884, 363, 474, 297, 1134, 29918, 974, 29918, 29939, 29901, 13, 462, 1678, 260, 353, 474, 29889, 18516, 580, 13, 462, 1678, 260, 29939, 29889, 4397, 29898, 29873, 29897, 13, 18884, 4072, 29889, 4397, 29898, 29873, 29939, 29897, 13, 18884, 396, 29871, 31302, 30683, 31658, 31596, 236, 155, 136, 235, 178, 190, 30354, 13, 18884, 9591, 353, 3855, 29918, 29879, 1132, 29889, 2886, 877, 9653, 742, 12421, 29879, 353, 11117, 1990, 22099, 6897, 5059, 371, 29899, 2492, 29915, 7690, 2886, 877, 29874, 2824, 18516, 580, 13, 18884, 22176, 29889, 4397, 29898, 16950, 29897, 13, 13, 13, 9651, 1683, 29901, 13, 18884, 1596, 29898, 3488, 29892, 620, 29889, 4882, 29918, 401, 29897, 13, 18884, 2867, 13, 2 ]
python-if/exercise1.py
ATelders/learn-python
0
54329
<filename>python-if/exercise1.py value = '6' if value == '7': print('The value is 7') elif value == '8': print('The value is 8') else: print('The value is not one we are looking for') print('Finished!')
[ 1, 529, 9507, 29958, 4691, 29899, 361, 29914, 735, 6269, 895, 29896, 29889, 2272, 13, 1767, 353, 525, 29953, 29915, 13, 13, 361, 995, 1275, 525, 29955, 2396, 13, 1678, 1596, 877, 1576, 995, 338, 29871, 29955, 1495, 13, 23681, 995, 1275, 525, 29947, 2396, 13, 1678, 1596, 877, 1576, 995, 338, 29871, 29947, 1495, 13, 2870, 29901, 13, 1678, 1596, 877, 1576, 995, 338, 451, 697, 591, 526, 3063, 363, 1495, 13, 13, 2158, 877, 12881, 3276, 29991, 1495, 13, 2 ]
src/miner/modules/build.py
cathook/PTTArticleRecommender
1
187802
# -*- coding: utf-8 -*- import json import os from pprint import pprint from modules.backend_interface import BackendInterface from modules.protocol.types import DocMetaData,DocRealData,ReplyMode,ReplyMessage class BuildData(object): def __init__(self,str): #global metadata self.metadata = [] self.metadatapath = str+"/Metadata_json" self.str = str self.d = {} # To add a key->value pair, do this: with open(self.metadatapath) as data_file: self.jsondata = json.load(data_file) os.chdir(str) #pprint(self.jsondata) for i in range(0,len(self.jsondata)): Rstr = self.jsondata[i]['Title'] if Rstr in self.d : Rid = self.d[Rstr][0] # has some values for key else: Rid = self.jsondata[i]['Id'] # no values for key self.d.setdefault(Rstr, []).append(self.jsondata[i]['Id']) """ if Rstr in self.mapdata: Rid = self.mapdata[Rstr] self.mapdata[Rstr].append(self.jsondata[i]['Id']) else: self.mapdata[Rstr] = self.jsondata[i]['Id'] Rid = self.jsondata[i]['Id'] """ #print(self.jsondata[i]['Title']) #print(Rid) self.metadata.append( DocMetaData(self.jsondata[i]['Id'],Rid, self.jsondata[i]['Title'],self.jsondata[i]['Author'], self.jsondata[i]['Time'],self.jsondata[i]['Board'], [self.jsondata[i]['Push'][0],self.jsondata[i]['Push'][1],self.jsondata[i]['Push'][2]]) ) #print(jsondata[i]['Title']) #pass def get_max_id(self, board): cnt = 0 for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board : cnt = cnt + 1 return cnt def get_doc_meta_data_after_id(self, board, idid): idid = idid + 1 ansList = [] for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board and self.jsondata[i]['Id'] >= idid : ansList.append(self.metadata[i]) return ansList def get_doc_meta_data_after_time(self, board, post_time): ansList = [] #return ansList # 2005-06-21 19:34:53 for i in range(0,len(self.jsondata)): date_object = datetime.strptime(self.jsondata[i]['Time'],'%Y-%m-%d %H:%M:%S') if self.jsondata[i]['Board'] == board and post_time > date_object : ansList.append(self.metadata[i]) return ansList def get_doc_meta_data_of_author(self, board, author): ansList = [] #return ansList # 2005-06-21 19:34:53 for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board and self.jsondata[i]['Author'] == author : ansList.append(self.metadata[i]) return ansList def get_doc_meta_data_series(self, board, idid): ansList = [] idid = idid+1 for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board and self.jsondata[i]['Id'] == idid : #for Rid in self.mapdata[Rstr]: if self.jsondata[i]['Title'] in self.d : for X in self.d[self.jsondata[i]['Title']]: #print(X) ansList.append(self.metadata[X]) return ansList def get_doc_real_data(self, board, idid): idid = idid+1 for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board and self.jsondata[i]['Id'] == idid : #'http://www.ptt.cc/bbs/' + board + self.jsondata[i]['Name'] + '.html' with open(self.str+'/'+self.jsondata[i]['Name'],'r') as fileFp: strr = fileFp.read() s = '發信站: 批踢踢實業坊(ptt.cc)' List = strr[strr.find(s)+len(s):].split('\n') # --> ['Line 1', 'Line 2', 'Line 3'] Reply = [] LikeChinese = '推' DislikeChinese = '噓' ArrowChinese = '→' # ReplyMessage(self, mode, user, message): for replyString in List: if len(replyString) != 0: if replyString[0] == LikeChinese : Reply.append(ReplyMessage(ReplyMode.GOOD,replyString[2:replyString.find(':')],replyString[replyString.find(':')+1:])) elif replyString[0] == ArrowChinese: Reply.append(ReplyMessage(ReplyMode.NORMAL,replyString[2:replyString.find(':')],replyString[replyString.find(':')+1:])) elif replyString[0] == DislikeChinese: Reply.append(ReplyMessage(ReplyMode.WOO,replyString[2:replyString.find(':')],replyString[replyString.find(':')+1:])) return DocRealData(strr[strr[1:].find('\n')+2:strr.find(s)-5], Reply) def get_id_by_url(self, url): print(url[url.rfind('/')+1:url.find('.html')]) for i in range(0,len(self.jsondata)): if self.jsondata[i]['Name'] == url[url.rfind('/')+1:url.find('.html')] : return self.jsondata[i]['Id'] def get_url_by_id(self, board, idid): idid = idid + 1 for i in range(0,len(self.jsondata)): if self.jsondata[i]['Board'] == board and self.jsondata[i]['Id'] == idid : return 'http://www.ptt.cc/bbs/' + board + self.jsondata[i]['Name'] + '.html'
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 5215, 4390, 13, 5215, 2897, 13, 3166, 282, 2158, 1053, 282, 2158, 13, 3166, 10585, 29889, 27852, 29918, 13248, 1053, 7437, 355, 10448, 13, 3166, 10585, 29889, 20464, 29889, 8768, 1053, 28197, 19346, 1469, 29892, 14526, 21713, 1469, 29892, 5612, 368, 6818, 29892, 5612, 368, 3728, 13, 13, 1990, 8878, 1469, 29898, 3318, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 710, 1125, 13, 13, 4706, 396, 10945, 15562, 13, 4706, 1583, 29889, 19635, 353, 5159, 13, 4706, 1583, 29889, 2527, 328, 271, 481, 493, 353, 851, 13578, 29914, 18417, 29918, 3126, 29908, 13, 4706, 1583, 29889, 710, 353, 851, 13, 4706, 1583, 29889, 29881, 353, 6571, 13, 4706, 396, 1763, 788, 263, 1820, 976, 1767, 5101, 29892, 437, 445, 29901, 13, 13, 4706, 411, 1722, 29898, 1311, 29889, 2527, 328, 271, 481, 493, 29897, 408, 848, 29918, 1445, 29901, 13, 9651, 1583, 29889, 1315, 898, 532, 353, 4390, 29889, 1359, 29898, 1272, 29918, 1445, 29897, 13, 4706, 2897, 29889, 305, 3972, 29898, 710, 29897, 13, 4706, 396, 407, 29878, 524, 29898, 1311, 29889, 1315, 898, 532, 29897, 13, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 13, 13, 9651, 390, 710, 353, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 7030, 2033, 13, 13, 9651, 565, 390, 710, 297, 1583, 29889, 29881, 584, 13, 18884, 390, 333, 353, 1583, 29889, 29881, 29961, 29934, 710, 3816, 29900, 29962, 13, 18884, 396, 756, 777, 1819, 363, 1820, 13, 9651, 1683, 29901, 13, 18884, 390, 333, 353, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 13, 18884, 396, 694, 1819, 363, 1820, 13, 9651, 1583, 29889, 29881, 29889, 842, 4381, 29898, 29934, 710, 29892, 5159, 467, 4397, 29898, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 11287, 13, 9651, 9995, 13, 9651, 565, 390, 710, 297, 1583, 29889, 1958, 1272, 29901, 13, 18884, 390, 333, 353, 1583, 29889, 1958, 1272, 29961, 29934, 710, 29962, 13, 18884, 1583, 29889, 1958, 1272, 29961, 29934, 710, 1822, 4397, 29898, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 11287, 13, 9651, 1683, 29901, 13, 18884, 1583, 29889, 1958, 1272, 29961, 29934, 710, 29962, 353, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 13, 18884, 390, 333, 353, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 13, 9651, 9995, 13, 9651, 396, 2158, 29898, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 7030, 11287, 13, 9651, 396, 2158, 29898, 29934, 333, 29897, 13, 9651, 1583, 29889, 19635, 29889, 4397, 29898, 13, 462, 9651, 28197, 19346, 1469, 29898, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 7464, 29934, 333, 29892, 13, 462, 462, 418, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 7030, 7464, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 13720, 7464, 13, 462, 462, 418, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 2481, 7464, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 7464, 13, 462, 462, 418, 518, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 27031, 2033, 29961, 29900, 1402, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 27031, 2033, 29961, 29896, 1402, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 27031, 2033, 29961, 29906, 24960, 13, 462, 9651, 1723, 13, 9651, 396, 2158, 29898, 1315, 898, 532, 29961, 29875, 22322, 7030, 11287, 13, 4706, 396, 3364, 13, 1678, 822, 679, 29918, 3317, 29918, 333, 29898, 1311, 29892, 7613, 1125, 13, 4706, 274, 593, 353, 29871, 29900, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 584, 13, 18884, 274, 593, 353, 274, 593, 718, 29871, 29896, 13, 4706, 736, 274, 593, 13, 13, 1678, 822, 679, 29918, 1514, 29918, 7299, 29918, 1272, 29918, 7045, 29918, 333, 29898, 1311, 29892, 7613, 29892, 1178, 333, 1125, 13, 4706, 1178, 333, 353, 1178, 333, 718, 29871, 29896, 13, 4706, 6063, 1293, 353, 5159, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 6736, 1178, 333, 584, 13, 18884, 6063, 1293, 29889, 4397, 29898, 1311, 29889, 19635, 29961, 29875, 2314, 13, 4706, 736, 6063, 1293, 13, 13, 1678, 822, 679, 29918, 1514, 29918, 7299, 29918, 1272, 29918, 7045, 29918, 2230, 29898, 1311, 29892, 7613, 29892, 1400, 29918, 2230, 1125, 13, 4706, 6063, 1293, 353, 5159, 13, 4706, 396, 2457, 6063, 1293, 13, 4706, 396, 1678, 29906, 29900, 29900, 29945, 29899, 29900, 29953, 29899, 29906, 29896, 29871, 29896, 29929, 29901, 29941, 29946, 29901, 29945, 29941, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 2635, 29918, 3318, 353, 12865, 29889, 710, 415, 603, 29898, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 2481, 7464, 29915, 29995, 29979, 19222, 29885, 19222, 29881, 1273, 29950, 16664, 29924, 16664, 29903, 1495, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1400, 29918, 2230, 1405, 2635, 29918, 3318, 584, 13, 18884, 6063, 1293, 29889, 4397, 29898, 1311, 29889, 19635, 29961, 29875, 2314, 13, 4706, 736, 6063, 1293, 13, 13, 1678, 822, 679, 29918, 1514, 29918, 7299, 29918, 1272, 29918, 974, 29918, 8921, 29898, 1311, 29892, 7613, 29892, 4148, 1125, 13, 4706, 6063, 1293, 353, 5159, 13, 4706, 396, 2457, 6063, 1293, 13, 4706, 396, 1678, 29906, 29900, 29900, 29945, 29899, 29900, 29953, 29899, 29906, 29896, 29871, 29896, 29929, 29901, 29941, 29946, 29901, 29945, 29941, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 13720, 2033, 1275, 4148, 584, 13, 18884, 6063, 1293, 29889, 4397, 29898, 1311, 29889, 19635, 29961, 29875, 2314, 13, 4706, 736, 6063, 1293, 13, 13, 1678, 822, 679, 29918, 1514, 29918, 7299, 29918, 1272, 29918, 13757, 29898, 1311, 29892, 7613, 29892, 1178, 333, 1125, 13, 4706, 6063, 1293, 353, 5159, 13, 4706, 1178, 333, 353, 1178, 333, 29974, 29896, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 1275, 1178, 333, 584, 13, 18884, 396, 1454, 390, 333, 297, 1583, 29889, 1958, 1272, 29961, 29934, 710, 5387, 13, 18884, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 7030, 2033, 297, 1583, 29889, 29881, 584, 13, 462, 1678, 363, 1060, 297, 1583, 29889, 29881, 29961, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 7030, 2033, 5387, 13, 462, 4706, 396, 2158, 29898, 29990, 29897, 13, 462, 4706, 6063, 1293, 29889, 4397, 29898, 1311, 29889, 19635, 29961, 29990, 2314, 13, 4706, 736, 6063, 1293, 13, 13, 1678, 822, 679, 29918, 1514, 29918, 6370, 29918, 1272, 29898, 1311, 29892, 7613, 29892, 1178, 333, 1125, 13, 4706, 1178, 333, 353, 1178, 333, 29974, 29896, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 1275, 1178, 333, 584, 13, 18884, 396, 29915, 1124, 597, 1636, 29889, 415, 29873, 29889, 617, 29914, 1327, 29879, 22208, 718, 7613, 718, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1170, 2033, 718, 15300, 1420, 29915, 13, 18884, 411, 1722, 29898, 1311, 29889, 710, 23097, 29914, 18717, 1311, 29889, 1315, 898, 532, 29961, 29875, 22322, 1170, 7464, 29915, 29878, 1495, 408, 934, 29943, 29886, 29901, 13, 462, 1678, 851, 29878, 353, 934, 29943, 29886, 29889, 949, 580, 13, 462, 1678, 269, 353, 525, 234, 156, 191, 30689, 31433, 29901, 29871, 233, 140, 188, 235, 187, 165, 235, 187, 165, 232, 178, 169, 31564, 232, 160, 141, 29898, 415, 29873, 29889, 617, 16029, 13, 462, 1678, 2391, 353, 851, 29878, 29961, 710, 29878, 29889, 2886, 29898, 29879, 7240, 2435, 29898, 29879, 1125, 1822, 5451, 28909, 29876, 1495, 29871, 396, 6660, 6024, 3542, 29871, 29896, 742, 525, 3542, 29871, 29906, 742, 525, 3542, 29871, 29941, 2033, 13, 462, 1678, 10088, 368, 353, 5159, 13, 462, 1678, 8502, 1451, 8233, 353, 525, 233, 145, 171, 29915, 13, 462, 1678, 3295, 4561, 1451, 8233, 353, 525, 232, 156, 150, 29915, 13, 462, 1678, 826, 798, 1451, 8233, 353, 525, 30121, 29915, 13, 462, 1678, 396, 259, 10088, 368, 3728, 29898, 1311, 29892, 4464, 29892, 1404, 29892, 2643, 1125, 13, 462, 1678, 363, 8908, 1231, 297, 2391, 29901, 13, 462, 4706, 565, 7431, 29898, 3445, 368, 1231, 29897, 2804, 29871, 29900, 29901, 13, 462, 9651, 565, 8908, 1231, 29961, 29900, 29962, 1275, 8502, 1451, 8233, 584, 13, 462, 18884, 10088, 368, 29889, 4397, 29898, 5612, 368, 3728, 29898, 5612, 368, 6818, 29889, 17080, 13668, 29892, 3445, 368, 1231, 29961, 29906, 29901, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 1402, 3445, 368, 1231, 29961, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 29974, 29896, 29901, 12622, 13, 462, 9651, 25342, 8908, 1231, 29961, 29900, 29962, 1275, 826, 798, 1451, 8233, 29901, 13, 462, 18884, 10088, 368, 29889, 4397, 29898, 5612, 368, 3728, 29898, 5612, 368, 6818, 29889, 29940, 1955, 1529, 29931, 29892, 3445, 368, 1231, 29961, 29906, 29901, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 1402, 3445, 368, 1231, 29961, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 29974, 29896, 29901, 12622, 13, 462, 9651, 25342, 8908, 1231, 29961, 29900, 29962, 1275, 3295, 4561, 1451, 8233, 29901, 13, 462, 18884, 10088, 368, 29889, 4397, 29898, 5612, 368, 3728, 29898, 5612, 368, 6818, 29889, 29956, 29949, 29949, 29892, 3445, 368, 1231, 29961, 29906, 29901, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 1402, 3445, 368, 1231, 29961, 3445, 368, 1231, 29889, 2886, 877, 29901, 1495, 29974, 29896, 29901, 12622, 13, 462, 1678, 736, 28197, 21713, 1469, 29898, 710, 29878, 29961, 710, 29878, 29961, 29896, 29901, 1822, 2886, 28909, 29876, 1495, 29974, 29906, 29901, 710, 29878, 29889, 2886, 29898, 29879, 6817, 29945, 1402, 10088, 368, 29897, 13, 13, 1678, 822, 679, 29918, 333, 29918, 1609, 29918, 2271, 29898, 1311, 29892, 3142, 1125, 13, 4706, 1596, 29898, 2271, 29961, 2271, 29889, 29878, 2886, 11219, 1495, 29974, 29896, 29901, 2271, 29889, 2886, 12839, 1420, 1495, 2314, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1170, 2033, 1275, 29871, 3142, 29961, 2271, 29889, 29878, 2886, 11219, 1495, 29974, 29896, 29901, 2271, 29889, 2886, 12839, 1420, 1495, 29962, 584, 13, 18884, 736, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 13, 13, 1678, 822, 679, 29918, 2271, 29918, 1609, 29918, 333, 29898, 1311, 29892, 7613, 29892, 1178, 333, 1125, 13, 4706, 1178, 333, 353, 1178, 333, 718, 29871, 29896, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 2435, 29898, 1311, 29889, 1315, 898, 532, 22164, 13, 9651, 565, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 28397, 2033, 1275, 7613, 322, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1204, 2033, 1275, 1178, 333, 584, 13, 18884, 736, 525, 1124, 597, 1636, 29889, 415, 29873, 29889, 617, 29914, 1327, 29879, 22208, 718, 7613, 718, 1583, 29889, 1315, 898, 532, 29961, 29875, 22322, 1170, 2033, 718, 15300, 1420, 29915, 13, 13, 2 ]
sqlalchemy/sqlalchemy-0.3.6+codebay/test/base/dependency.py
nakedible/vpnease-l2tp
5
25048
from testbase import PersistTest import sqlalchemy.topological as topological import unittest, sys, os from sqlalchemy import util # TODO: need assertion conditions in this suite class DependencySorter(topological.QueueDependencySorter):pass class DependencySortTest(PersistTest): def assert_sort(self, tuples, node, collection=None): print str(node) def assert_tuple(tuple, node): if node.cycles: cycles = [i.item for i in node.cycles] else: cycles = [] if tuple[0] is node.item or tuple[0] in cycles: tuple.pop() if tuple[0] is node.item or tuple[0] in cycles: return elif len(tuple) > 1 and tuple[1] is node.item: assert False, "Tuple not in dependency tree: " + str(tuple) for c in node.children: assert_tuple(tuple, c) for tuple in tuples: assert_tuple(list(tuple), node) if collection is None: collection = [] items = util.Set() def assert_unique(node): for item in [n.item for n in node.cycles or [node,]]: assert item not in items items.add(item) if item in collection: collection.remove(item) for c in node.children: assert_unique(c) assert_unique(node) assert len(collection) == 0 def testsort(self): rootnode = 'root' node2 = 'node2' node3 = 'node3' node4 = 'node4' subnode1 = 'subnode1' subnode2 = 'subnode2' subnode3 = 'subnode3' subnode4 = 'subnode4' subsubnode1 = 'subsubnode1' tuples = [ (subnode3, subsubnode1), (node2, subnode1), (node2, subnode2), (rootnode, node2), (rootnode, node3), (rootnode, node4), (node4, subnode3), (node4, subnode4) ] head = DependencySorter(tuples, []).sort() self.assert_sort(tuples, head) def testsort2(self): node1 = 'node1' node2 = 'node2' node3 = 'node3' node4 = 'node4' node5 = 'node5' node6 = 'node6' node7 = 'node7' tuples = [ (node1, node2), (node3, node4), (node4, node5), (node5, node6), (node6, node2) ] head = DependencySorter(tuples, [node7]).sort() self.assert_sort(tuples, head, [node7]) def testsort3(self): ['Mapper|Keyword|keywords,Mapper|IKAssociation|itemkeywords', 'Mapper|Item|items,Mapper|IKAssociation|itemkeywords'] node1 = 'keywords' node2 = 'itemkeyowrds' node3 = 'items' tuples = [ (node1, node2), (node3, node2), (node1,node3) ] head1 = DependencySorter(tuples, [node1, node2, node3]).sort() head2 = DependencySorter(tuples, [node3, node1, node2]).sort() head3 = DependencySorter(tuples, [node3, node2, node1]).sort() # TODO: figure out a "node == node2" function #self.assert_(str(head1) == str(head2) == str(head3)) print "\n" + str(head1) print "\n" + str(head2) print "\n" + str(head3) def testsort4(self): node1 = 'keywords' node2 = 'itemkeyowrds' node3 = 'items' node4 = 'hoho' tuples = [ (node1, node2), (node4, node1), (node1, node3), (node3, node2) ] head = DependencySorter(tuples, []).sort() self.assert_sort(tuples, head) def testsort5(self): # this one, depenending on the weather, node1 = 'node1' #'00B94190' node2 = 'node2' #'00B94990' node3 = 'node3' #'00B9A9B0' node4 = 'node4' #'00B4F210' tuples = [ (node4, node1), (node1, node2), (node4, node3), (node2, node3), (node4, node2), (node3, node3) ] allitems = [ node1, node2, node3, node4 ] head = DependencySorter(tuples, allitems).sort() self.assert_sort(tuples, head) def testcircular(self): node1 = 'node1' node2 = 'node2' node3 = 'node3' node4 = 'node4' node5 = 'node5' tuples = [ (node4, node5), (node5, node4), (node1, node2), (node2, node3), (node3, node1), (node4, node1) ] head = DependencySorter(tuples, []).sort(allow_all_cycles=True) self.assert_sort(tuples, head) def testcircular2(self): # this condition was arising from ticket:362 # and was not treated properly by topological sort node1 = 'node1' node2 = 'node2' node3 = 'node3' node4 = 'node4' tuples = [ (node1, node2), (node3, node1), (node2, node4), (node3, node2), (node2, node3) ] head = DependencySorter(tuples, []).sort(allow_all_cycles=True) self.assert_sort(tuples, head) def testcircular3(self): nodes = {} tuples = [('Question', 'Issue'), ('ProviderService', 'Issue'), ('Provider', 'Question'), ('Question', 'Provider'), ('ProviderService', 'Question'), ('Provider', 'ProviderService'), ('Question', 'Answer'), ('Issue', 'Question')] head = DependencySorter(tuples, []).sort(allow_all_cycles=True) self.assert_sort(tuples, head) def testbigsort(self): tuples = [] for i in range(0,1500, 2): tuples.append((i, i+1)) head = DependencySorter(tuples, []).sort() if __name__ == "__main__": unittest.main()
[ 1, 515, 1243, 3188, 1053, 9034, 391, 3057, 13, 5215, 4576, 284, 305, 6764, 29889, 3332, 5996, 408, 25002, 13, 5215, 443, 27958, 29892, 10876, 29892, 2897, 13, 3166, 4576, 284, 305, 6764, 1053, 3667, 13, 13, 29937, 14402, 29901, 29871, 817, 28306, 5855, 297, 445, 9460, 13, 13, 13, 1990, 10034, 5197, 29903, 9555, 29898, 3332, 5996, 29889, 10620, 8498, 5197, 29903, 9555, 1125, 3364, 13, 268, 13, 308, 13, 1990, 10034, 5197, 13685, 3057, 29898, 15136, 391, 3057, 1125, 13, 1678, 822, 4974, 29918, 6605, 29898, 1311, 29892, 5291, 2701, 29892, 2943, 29892, 4333, 29922, 8516, 1125, 13, 4706, 1596, 851, 29898, 3177, 29897, 13, 4706, 822, 4974, 29918, 23583, 29898, 23583, 29892, 2943, 1125, 13, 9651, 565, 2943, 29889, 1270, 7799, 29901, 13, 18884, 25785, 353, 518, 29875, 29889, 667, 363, 474, 297, 2943, 29889, 1270, 7799, 29962, 13, 9651, 1683, 29901, 13, 18884, 25785, 353, 5159, 13, 9651, 565, 18761, 29961, 29900, 29962, 338, 2943, 29889, 667, 470, 18761, 29961, 29900, 29962, 297, 25785, 29901, 13, 18884, 18761, 29889, 7323, 580, 13, 18884, 565, 18761, 29961, 29900, 29962, 338, 2943, 29889, 667, 470, 18761, 29961, 29900, 29962, 297, 25785, 29901, 13, 462, 1678, 736, 13, 9651, 25342, 7431, 29898, 23583, 29897, 1405, 29871, 29896, 322, 18761, 29961, 29896, 29962, 338, 2943, 29889, 667, 29901, 13, 18884, 4974, 7700, 29892, 376, 23215, 552, 451, 297, 10609, 5447, 29901, 376, 718, 851, 29898, 23583, 29897, 13, 9651, 363, 274, 297, 2943, 29889, 11991, 29901, 13, 18884, 4974, 29918, 23583, 29898, 23583, 29892, 274, 29897, 13, 308, 13, 4706, 363, 18761, 297, 5291, 2701, 29901, 13, 9651, 4974, 29918, 23583, 29898, 1761, 29898, 23583, 511, 2943, 29897, 13, 13, 4706, 565, 4333, 338, 6213, 29901, 13, 9651, 4333, 353, 5159, 13, 4706, 4452, 353, 3667, 29889, 2697, 580, 13, 4706, 822, 4974, 29918, 13092, 29898, 3177, 1125, 13, 9651, 363, 2944, 297, 518, 29876, 29889, 667, 363, 302, 297, 2943, 29889, 1270, 7799, 470, 518, 3177, 29892, 5262, 29901, 13, 18884, 4974, 2944, 451, 297, 4452, 13, 18884, 4452, 29889, 1202, 29898, 667, 29897, 13, 18884, 565, 2944, 297, 4333, 29901, 13, 462, 1678, 4333, 29889, 5992, 29898, 667, 29897, 13, 9651, 363, 274, 297, 2943, 29889, 11991, 29901, 13, 18884, 4974, 29918, 13092, 29898, 29883, 29897, 13, 4706, 4974, 29918, 13092, 29898, 3177, 29897, 13, 4706, 4974, 7431, 29898, 10855, 29897, 1275, 29871, 29900, 13, 308, 13, 1678, 822, 1243, 6605, 29898, 1311, 1125, 13, 4706, 3876, 3177, 353, 525, 4632, 29915, 13, 4706, 2943, 29906, 353, 525, 3177, 29906, 29915, 13, 4706, 2943, 29941, 353, 525, 3177, 29941, 29915, 13, 4706, 2943, 29946, 353, 525, 3177, 29946, 29915, 13, 4706, 1014, 3177, 29896, 353, 525, 1491, 3177, 29896, 29915, 13, 4706, 1014, 3177, 29906, 353, 525, 1491, 3177, 29906, 29915, 13, 4706, 1014, 3177, 29941, 353, 525, 1491, 3177, 29941, 29915, 13, 4706, 1014, 3177, 29946, 353, 525, 1491, 3177, 29946, 29915, 13, 4706, 1014, 1491, 3177, 29896, 353, 525, 1491, 1491, 3177, 29896, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 1491, 3177, 29941, 29892, 1014, 1491, 3177, 29896, 511, 13, 9651, 313, 3177, 29906, 29892, 1014, 3177, 29896, 511, 13, 9651, 313, 3177, 29906, 29892, 1014, 3177, 29906, 511, 13, 9651, 313, 4632, 3177, 29892, 2943, 29906, 511, 13, 9651, 313, 4632, 3177, 29892, 2943, 29941, 511, 13, 9651, 313, 4632, 3177, 29892, 2943, 29946, 511, 13, 9651, 313, 3177, 29946, 29892, 1014, 3177, 29941, 511, 13, 9651, 313, 3177, 29946, 29892, 1014, 3177, 29946, 29897, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 580, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 13, 1678, 822, 1243, 6605, 29906, 29898, 1311, 1125, 13, 4706, 2943, 29896, 353, 525, 3177, 29896, 29915, 13, 4706, 2943, 29906, 353, 525, 3177, 29906, 29915, 13, 4706, 2943, 29941, 353, 525, 3177, 29941, 29915, 13, 4706, 2943, 29946, 353, 525, 3177, 29946, 29915, 13, 4706, 2943, 29945, 353, 525, 3177, 29945, 29915, 13, 4706, 2943, 29953, 353, 525, 3177, 29953, 29915, 13, 4706, 2943, 29955, 353, 525, 3177, 29955, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29946, 511, 13, 9651, 313, 3177, 29946, 29892, 2943, 29945, 511, 13, 9651, 313, 3177, 29945, 29892, 2943, 29953, 511, 13, 9651, 313, 3177, 29953, 29892, 2943, 29906, 29897, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 518, 3177, 29955, 14664, 6605, 580, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29892, 518, 3177, 29955, 2314, 13, 13, 1678, 822, 1243, 6605, 29941, 29898, 1311, 1125, 13, 4706, 6024, 19968, 29989, 2558, 1742, 29989, 1989, 9303, 29892, 19968, 29989, 23328, 29254, 362, 29989, 667, 1989, 9303, 742, 525, 19968, 29989, 2001, 29989, 7076, 29892, 19968, 29989, 23328, 29254, 362, 29989, 667, 1989, 9303, 2033, 13, 4706, 2943, 29896, 353, 525, 1989, 9303, 29915, 13, 4706, 2943, 29906, 353, 525, 667, 1989, 340, 5499, 29879, 29915, 13, 4706, 2943, 29941, 353, 525, 7076, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29896, 29892, 3177, 29941, 29897, 13, 4706, 4514, 13, 4706, 2343, 29896, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 518, 3177, 29896, 29892, 2943, 29906, 29892, 2943, 29941, 14664, 6605, 580, 13, 4706, 2343, 29906, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 518, 3177, 29941, 29892, 2943, 29896, 29892, 2943, 29906, 14664, 6605, 580, 13, 4706, 2343, 29941, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 518, 3177, 29941, 29892, 2943, 29906, 29892, 2943, 29896, 14664, 6605, 580, 13, 308, 13, 4706, 396, 14402, 29901, 4377, 714, 263, 376, 3177, 1275, 2943, 29906, 29908, 740, 13, 4706, 396, 1311, 29889, 9294, 23538, 710, 29898, 2813, 29896, 29897, 1275, 851, 29898, 2813, 29906, 29897, 1275, 851, 29898, 2813, 29941, 876, 13, 4706, 1596, 6634, 29876, 29908, 718, 851, 29898, 2813, 29896, 29897, 13, 4706, 1596, 6634, 29876, 29908, 718, 851, 29898, 2813, 29906, 29897, 13, 4706, 1596, 6634, 29876, 29908, 718, 851, 29898, 2813, 29941, 29897, 13, 13, 1678, 822, 1243, 6605, 29946, 29898, 1311, 1125, 13, 4706, 2943, 29896, 353, 525, 1989, 9303, 29915, 13, 4706, 2943, 29906, 353, 525, 667, 1989, 340, 5499, 29879, 29915, 13, 4706, 2943, 29941, 353, 525, 7076, 29915, 13, 4706, 2943, 29946, 353, 525, 29882, 1148, 29877, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29946, 29892, 2943, 29896, 511, 13, 9651, 313, 3177, 29896, 29892, 2943, 29941, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29906, 29897, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 580, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 13, 1678, 822, 1243, 6605, 29945, 29898, 1311, 1125, 13, 4706, 396, 445, 697, 29892, 1401, 264, 2548, 373, 278, 14826, 29892, 29871, 13, 4706, 2943, 29896, 353, 525, 3177, 29896, 29915, 396, 29915, 29900, 29900, 29933, 29929, 29946, 29896, 29929, 29900, 29915, 13, 4706, 2943, 29906, 353, 525, 3177, 29906, 29915, 396, 29915, 29900, 29900, 29933, 29929, 29946, 29929, 29929, 29900, 29915, 13, 4706, 2943, 29941, 353, 525, 3177, 29941, 29915, 396, 29915, 29900, 29900, 29933, 29929, 29909, 29929, 29933, 29900, 29915, 13, 4706, 2943, 29946, 353, 525, 3177, 29946, 29915, 396, 29915, 29900, 29900, 29933, 29946, 29943, 29906, 29896, 29900, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29946, 29892, 2943, 29896, 511, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29946, 29892, 2943, 29941, 511, 13, 9651, 313, 3177, 29906, 29892, 2943, 29941, 511, 13, 9651, 313, 3177, 29946, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29941, 29897, 13, 4706, 4514, 13, 4706, 599, 7076, 353, 518, 13, 9651, 2943, 29896, 29892, 13, 9651, 2943, 29906, 29892, 13, 9651, 2943, 29941, 29892, 13, 9651, 2943, 29946, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 599, 7076, 467, 6605, 580, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 13, 1678, 822, 1243, 6034, 1070, 29898, 1311, 1125, 13, 4706, 2943, 29896, 353, 525, 3177, 29896, 29915, 13, 4706, 2943, 29906, 353, 525, 3177, 29906, 29915, 13, 4706, 2943, 29941, 353, 525, 3177, 29941, 29915, 13, 4706, 2943, 29946, 353, 525, 3177, 29946, 29915, 13, 4706, 2943, 29945, 353, 525, 3177, 29945, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29946, 29892, 2943, 29945, 511, 13, 9651, 313, 3177, 29945, 29892, 2943, 29946, 511, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29906, 29892, 2943, 29941, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29896, 511, 13, 9651, 313, 3177, 29946, 29892, 2943, 29896, 29897, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 29898, 9536, 29918, 497, 29918, 1270, 7799, 29922, 5574, 29897, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 308, 13, 1678, 822, 1243, 6034, 1070, 29906, 29898, 1311, 1125, 13, 4706, 396, 445, 4195, 471, 564, 5921, 515, 23381, 29901, 29941, 29953, 29906, 13, 4706, 396, 322, 471, 451, 14914, 6284, 491, 25002, 2656, 13, 4706, 2943, 29896, 353, 525, 3177, 29896, 29915, 13, 4706, 2943, 29906, 353, 525, 3177, 29906, 29915, 13, 4706, 2943, 29941, 353, 525, 3177, 29941, 29915, 13, 4706, 2943, 29946, 353, 525, 3177, 29946, 29915, 13, 4706, 5291, 2701, 353, 518, 13, 9651, 313, 3177, 29896, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29896, 511, 13, 9651, 313, 3177, 29906, 29892, 2943, 29946, 511, 13, 9651, 313, 3177, 29941, 29892, 2943, 29906, 511, 13, 9651, 313, 3177, 29906, 29892, 2943, 29941, 29897, 13, 4706, 4514, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 29898, 9536, 29918, 497, 29918, 1270, 7799, 29922, 5574, 29897, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 268, 13, 1678, 822, 1243, 6034, 1070, 29941, 29898, 1311, 1125, 13, 4706, 7573, 353, 6571, 13, 4706, 5291, 2701, 353, 518, 877, 16492, 742, 525, 29902, 893, 434, 5477, 6702, 6980, 3170, 742, 525, 29902, 893, 434, 5477, 6702, 6980, 742, 525, 16492, 5477, 6702, 16492, 742, 525, 6980, 5477, 6702, 6980, 3170, 742, 525, 16492, 5477, 6702, 6980, 742, 525, 6980, 3170, 5477, 6702, 16492, 742, 525, 22550, 5477, 6702, 29902, 893, 434, 742, 525, 16492, 1495, 29962, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 29898, 9536, 29918, 497, 29918, 1270, 7799, 29922, 5574, 29897, 13, 4706, 1583, 29889, 9294, 29918, 6605, 29898, 9161, 2701, 29892, 2343, 29897, 13, 308, 13, 1678, 822, 1243, 3752, 6605, 29898, 1311, 1125, 13, 4706, 5291, 2701, 353, 5159, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 29896, 29945, 29900, 29900, 29892, 29871, 29906, 1125, 13, 9651, 5291, 2701, 29889, 4397, 3552, 29875, 29892, 474, 29974, 29896, 876, 13, 4706, 2343, 353, 10034, 5197, 29903, 9555, 29898, 9161, 2701, 29892, 5159, 467, 6605, 580, 13, 632, 13, 632, 13, 632, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 443, 27958, 29889, 3396, 580, 13, 2 ]
split_genome_into_miRNA_kmers.py
TelfordLab/microRNAs
1
1604136
import argparse, concurrent.futures, os, subprocess, sys from Bio import SeqIO parser = argparse.ArgumentParser(description='Splits genome into 6-mers for efficient microRNA seed scan') parser.add_argument("-c", "--conservation", required=True, help="CSV file containing miRNA family information") parser.add_argument("-g","--genome", required=True, help="FASTA file containing the genome assembly") parser.add_argument("-n", "--num-threads", default=1, help="Number of threads to run in parallel (default: 1)") args = parser.parse_args() mirna_families_file = args.conservation genome_file = args.genome genome_dir = os.getcwd() + "/" kmers_dir = genome_dir + genome_file.split("/")[-1].split(".")[0] + "_kmers/" # split genome into 6-mers if not os.path.exists(kmers_dir): os.makedirs(kmers_dir) print("SPLITTING: {}".format(genome_file)) genome_sequences = SeqIO.to_dict(SeqIO.parse(genome_file, "fasta")) b = set(genome_sequences.keys()) while len(b) > 0: print("Sequences left:", len(b)) for gs in genome_sequences: if os.path.exists(kmers_dir + gs + ".kmers"): if gs in b: b.remove(gs) print("Sequences left:", len(b)) #print("SKIPPING: {}.kmers already exists!".format(gs)) continue seq = str(genome_sequences[gs].seq).upper() out = ["{} {}\n".format(i, seq[i:i+6]) for i in range(0, len(seq)-6)] try: with open(kmers_dir + gs + ".kmers", "w") as f: f.write("".join(out)) except OSError: # Buffer issues when writing print("Caught OSError: Trying to split writing!") with open(kmers_dir + gs + ".kmers", "w") as f: f.write("".join(out[:100000000])) with open(kmers_dir + gs + ".kmers", "a") as f: f.write("".join(out[100000000:])) os.makedirs(kmers_dir + "pos_unfiltered") # create kmer grep bash script if os.path.exists(kmers_dir + "kmer_grep.sh"): print("WARNING: {}kmer_grep.sh already exists!".format(genome_dir)) else: with open(kmers_dir + "kmer_grep.sh", "w") as f: f.write('if [ "$3" == "r" ]\nthen\nout=$1/pos_unfiltered/$2_reversed.pos\nelse\nout=$1/pos_unfiltered/$2.pos\nfi\nfor i in $1/*.kmers\n\ndo\necho `basename $i .kmers` `grep $2 $i | cut -d " " -f1`\ndone > ${out}') # grep seeds from split files def reverse(sequence): reverse_sequence = "" for nucleotide in sequence: if nucleotide.upper() == "A": if "U" in sequence: reverse_sequence += "U" else: reverse_sequence += "T" elif nucleotide.upper() == "C": reverse_sequence += "G" elif nucleotide.upper() == "G": reverse_sequence += "C" elif nucleotide.upper() == "T" or nucleotide.upper() == "U": reverse_sequence += "A" else: reverse_sequence += nucleotide return reverse_sequence[::-1] seeds = [] seeds_reversed = [] with open(mirna_families_file, "r") as f: for line in f: if line.startswith("family") or len(line) < 2: continue seeds.append(line.split(",")[2].replace("U", "T")) seeds_reversed.append(reverse(line.split(",")[2].replace("U", "T"))) all_seeds = (set(seeds) | set(seeds_reversed)) def grep(seed): ret = "" if seed in seeds: if os.path.exists(kmers_dir + "pos_unfiltered/" + seed + ".pos"): ret += seed + ".pos already exists!\n" else: p = subprocess.Popen(["sh", kmers_dir + "kmer_grep.sh", kmers_dir, seed]) p.wait() if seed in seeds_reversed: if os.path.exists(kmers_dir + "pos_unfiltered/" + seed + "_reversed.pos"): ret += seed + "_reversed.pos already exists!" else: p = subprocess.Popen(["sh", kmers_dir + "kmer_grep.sh", kmers_dir, seed, "r"]) p.wait() return ret with concurrent.futures.ProcessPoolExecutor(max_workers=int(args.num_threads)) as executor: futures = [executor.submit(grep, seed) for seed in all_seeds] results = concurrent.futures.wait(futures) for rd in results.done: print(rd.result()) # create and execute bash script to get all non-empty grep results with open(kmers_dir + "grep.sh", "w") as f: f.write('for s in {}/pos_unfiltered/*.pos; do grep " " $s > {}/`basename $s`; done'.format(kmers_dir, kmers_dir)) p = subprocess.Popen(["sh", kmers_dir + "grep.sh"]) p.wait() # clean up os.remove(kmers_dir + "kmer_grep.sh") os.remove(kmers_dir + "grep.sh")
[ 1, 1053, 1852, 5510, 29892, 21984, 29889, 29888, 329, 1973, 29892, 2897, 29892, 1014, 5014, 29892, 10876, 13, 3166, 21184, 1053, 25981, 5971, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 29898, 8216, 2433, 29903, 572, 1169, 2531, 608, 964, 29871, 29953, 29899, 13269, 363, 8543, 9200, 29934, 3521, 16717, 12812, 1495, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29883, 613, 376, 489, 535, 2140, 362, 613, 3734, 29922, 5574, 29892, 1371, 543, 29907, 7597, 934, 6943, 3737, 29934, 3521, 3942, 2472, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29887, 3284, 489, 1885, 608, 613, 3734, 29922, 5574, 29892, 1371, 543, 4519, 1254, 29909, 934, 6943, 278, 2531, 608, 11470, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29876, 613, 376, 489, 1949, 29899, 28993, 613, 2322, 29922, 29896, 29892, 1371, 543, 4557, 310, 9717, 304, 1065, 297, 8943, 313, 4381, 29901, 29871, 29896, 25760, 13, 5085, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 11038, 1056, 29918, 8302, 583, 29918, 1445, 353, 6389, 29889, 535, 2140, 362, 13, 1885, 608, 29918, 1445, 353, 6389, 29889, 1885, 608, 13, 1885, 608, 29918, 3972, 353, 2897, 29889, 657, 29883, 9970, 580, 718, 5591, 29908, 13, 8848, 414, 29918, 3972, 353, 2531, 608, 29918, 3972, 718, 2531, 608, 29918, 1445, 29889, 5451, 11974, 1159, 14352, 29896, 1822, 5451, 17350, 1159, 29961, 29900, 29962, 718, 11119, 8848, 414, 12975, 13, 13, 29937, 6219, 2531, 608, 964, 29871, 29953, 29899, 13269, 13, 361, 451, 2897, 29889, 2084, 29889, 9933, 29898, 8848, 414, 29918, 3972, 1125, 13, 1678, 2897, 29889, 29885, 12535, 12935, 29898, 8848, 414, 29918, 3972, 29897, 13, 1678, 1596, 703, 5550, 29931, 1806, 29911, 4214, 29901, 6571, 1642, 4830, 29898, 1885, 608, 29918, 1445, 876, 268, 13, 13, 1678, 2531, 608, 29918, 6831, 2063, 353, 25981, 5971, 29889, 517, 29918, 8977, 29898, 23718, 5971, 29889, 5510, 29898, 1885, 608, 29918, 1445, 29892, 376, 29888, 5427, 5783, 13, 13, 1678, 289, 353, 731, 29898, 1885, 608, 29918, 6831, 2063, 29889, 8149, 3101, 13, 1678, 1550, 7431, 29898, 29890, 29897, 1405, 29871, 29900, 29901, 13, 4706, 1596, 703, 16941, 2063, 2175, 29901, 613, 7431, 29898, 29890, 876, 13, 4706, 363, 330, 29879, 297, 2531, 608, 29918, 6831, 2063, 29901, 13, 9651, 565, 2897, 29889, 2084, 29889, 9933, 29898, 8848, 414, 29918, 3972, 718, 330, 29879, 718, 11393, 8848, 414, 29908, 1125, 13, 18884, 565, 330, 29879, 297, 289, 29901, 13, 462, 1678, 289, 29889, 5992, 29898, 3174, 29897, 13, 462, 1678, 1596, 703, 16941, 2063, 2175, 29901, 613, 7431, 29898, 29890, 876, 13, 18884, 396, 2158, 703, 16033, 5690, 29925, 4214, 29901, 426, 1836, 8848, 414, 2307, 4864, 29991, 1642, 4830, 29898, 3174, 876, 13, 18884, 6773, 13, 632, 13, 9651, 19359, 353, 851, 29898, 1885, 608, 29918, 6831, 2063, 29961, 3174, 1822, 11762, 467, 21064, 580, 13, 9651, 714, 353, 6796, 8875, 426, 1012, 29876, 1642, 4830, 29898, 29875, 29892, 19359, 29961, 29875, 29901, 29875, 29974, 29953, 2314, 363, 474, 297, 3464, 29898, 29900, 29892, 7431, 29898, 11762, 6817, 29953, 4638, 13, 9651, 1018, 29901, 13, 18884, 411, 1722, 29898, 8848, 414, 29918, 3972, 718, 330, 29879, 718, 11393, 8848, 414, 613, 376, 29893, 1159, 408, 285, 29901, 13, 462, 1678, 285, 29889, 3539, 703, 1642, 7122, 29898, 449, 876, 13, 9651, 5174, 438, 29173, 29901, 396, 16534, 5626, 746, 5007, 29871, 13, 18884, 1596, 703, 29907, 6482, 438, 29173, 29901, 24428, 304, 6219, 5007, 29991, 1159, 13, 18884, 411, 1722, 29898, 8848, 414, 29918, 3972, 718, 330, 29879, 718, 11393, 8848, 414, 613, 376, 29893, 1159, 408, 285, 29901, 13, 462, 1678, 285, 29889, 3539, 703, 1642, 7122, 29898, 449, 7503, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29900, 29900, 12622, 13, 18884, 411, 1722, 29898, 8848, 414, 29918, 3972, 718, 330, 29879, 718, 11393, 8848, 414, 613, 376, 29874, 1159, 408, 285, 29901, 13, 462, 1678, 285, 29889, 3539, 703, 1642, 7122, 29898, 449, 29961, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29900, 29900, 29901, 12622, 13, 268, 13, 1678, 2897, 29889, 29885, 12535, 12935, 29898, 8848, 414, 29918, 3972, 718, 376, 1066, 29918, 348, 4572, 287, 1159, 13, 13, 29937, 1653, 413, 1050, 12680, 10891, 2471, 13, 361, 2897, 29889, 2084, 29889, 9933, 29898, 8848, 414, 29918, 3972, 718, 376, 29895, 1050, 29918, 22385, 29889, 845, 29908, 1125, 13, 1678, 1596, 703, 29956, 25614, 29901, 6571, 29895, 1050, 29918, 22385, 29889, 845, 2307, 4864, 29991, 1642, 4830, 29898, 1885, 608, 29918, 3972, 876, 13, 2870, 29901, 13, 1678, 411, 1722, 29898, 8848, 414, 29918, 3972, 718, 376, 29895, 1050, 29918, 22385, 29889, 845, 613, 376, 29893, 1159, 408, 285, 29901, 13, 4706, 285, 29889, 3539, 877, 361, 518, 3908, 29941, 29908, 1275, 376, 29878, 29908, 4514, 29905, 29876, 6098, 29905, 29876, 449, 6080, 29896, 29914, 1066, 29918, 348, 4572, 287, 13346, 29906, 29918, 276, 874, 287, 29889, 1066, 29905, 29876, 2870, 29905, 29876, 449, 6080, 29896, 29914, 1066, 29918, 348, 4572, 287, 13346, 29906, 29889, 1066, 29905, 29876, 7241, 29905, 29876, 1454, 474, 297, 395, 29896, 5515, 29889, 8848, 414, 29905, 29876, 29905, 299, 29877, 29905, 484, 1859, 421, 6500, 3871, 395, 29875, 869, 8848, 414, 29952, 421, 22385, 395, 29906, 395, 29875, 891, 5700, 448, 29881, 376, 376, 448, 29888, 29896, 29952, 29905, 299, 650, 1405, 6435, 449, 29913, 1495, 13, 13, 29937, 12680, 409, 5779, 515, 6219, 2066, 13, 1753, 11837, 29898, 16506, 1125, 13, 1678, 11837, 29918, 16506, 353, 5124, 13, 1678, 363, 22699, 327, 680, 297, 5665, 29901, 13, 4706, 565, 22699, 327, 680, 29889, 21064, 580, 1275, 376, 29909, 1115, 13, 9651, 565, 376, 29965, 29908, 297, 5665, 29901, 13, 18884, 11837, 29918, 16506, 4619, 376, 29965, 29908, 13, 9651, 1683, 29901, 13, 18884, 11837, 29918, 16506, 4619, 376, 29911, 29908, 13, 4706, 25342, 22699, 327, 680, 29889, 21064, 580, 1275, 376, 29907, 1115, 13, 9651, 11837, 29918, 16506, 4619, 376, 29954, 29908, 13, 4706, 25342, 22699, 327, 680, 29889, 21064, 580, 1275, 376, 29954, 1115, 13, 9651, 11837, 29918, 16506, 4619, 376, 29907, 29908, 13, 4706, 25342, 22699, 327, 680, 29889, 21064, 580, 1275, 376, 29911, 29908, 470, 22699, 327, 680, 29889, 21064, 580, 1275, 376, 29965, 1115, 13, 9651, 11837, 29918, 16506, 4619, 376, 29909, 29908, 13, 4706, 1683, 29901, 13, 9651, 11837, 29918, 16506, 4619, 22699, 327, 680, 13, 1678, 736, 11837, 29918, 16506, 29961, 1057, 29899, 29896, 29962, 13, 13, 344, 5779, 353, 5159, 13, 344, 5779, 29918, 276, 874, 287, 353, 5159, 13, 13, 2541, 1722, 29898, 11038, 1056, 29918, 8302, 583, 29918, 1445, 29892, 376, 29878, 1159, 408, 285, 29901, 13, 1678, 363, 1196, 297, 285, 29901, 13, 4706, 565, 1196, 29889, 27382, 2541, 703, 11922, 1159, 470, 7431, 29898, 1220, 29897, 529, 29871, 29906, 29901, 13, 9651, 6773, 13, 4706, 409, 5779, 29889, 4397, 29898, 1220, 29889, 5451, 28165, 1159, 29961, 29906, 1822, 6506, 703, 29965, 613, 376, 29911, 5783, 13, 4706, 409, 5779, 29918, 276, 874, 287, 29889, 4397, 29898, 24244, 29898, 1220, 29889, 5451, 28165, 1159, 29961, 29906, 1822, 6506, 703, 29965, 613, 376, 29911, 29908, 4961, 13, 13, 497, 29918, 344, 5779, 353, 313, 842, 29898, 344, 5779, 29897, 891, 731, 29898, 344, 5779, 29918, 276, 874, 287, 876, 13, 13, 1753, 12680, 29898, 26776, 1125, 13, 1678, 3240, 353, 5124, 13, 1678, 565, 16717, 297, 409, 5779, 29901, 13, 4706, 565, 2897, 29889, 2084, 29889, 9933, 29898, 8848, 414, 29918, 3972, 718, 376, 1066, 29918, 348, 4572, 287, 12975, 718, 16717, 718, 11393, 1066, 29908, 1125, 13, 9651, 3240, 4619, 16717, 718, 11393, 1066, 2307, 4864, 9903, 29876, 29908, 13, 4706, 1683, 29901, 13, 9651, 282, 353, 1014, 5014, 29889, 29925, 3150, 29898, 3366, 845, 613, 2383, 414, 29918, 3972, 718, 376, 29895, 1050, 29918, 22385, 29889, 845, 613, 2383, 414, 29918, 3972, 29892, 16717, 2314, 13, 9651, 282, 29889, 10685, 580, 13, 1678, 565, 16717, 297, 409, 5779, 29918, 276, 874, 287, 29901, 13, 4706, 565, 2897, 29889, 2084, 29889, 9933, 29898, 8848, 414, 29918, 3972, 718, 376, 1066, 29918, 348, 4572, 287, 12975, 718, 16717, 718, 11119, 276, 874, 287, 29889, 1066, 29908, 1125, 13, 9651, 3240, 4619, 16717, 718, 11119, 276, 874, 287, 29889, 1066, 2307, 4864, 3850, 13, 4706, 1683, 29901, 13, 9651, 282, 353, 1014, 5014, 29889, 29925, 3150, 29898, 3366, 845, 613, 2383, 414, 29918, 3972, 718, 376, 29895, 1050, 29918, 22385, 29889, 845, 613, 2383, 414, 29918, 3972, 29892, 16717, 29892, 376, 29878, 20068, 13, 9651, 282, 29889, 10685, 580, 13, 1678, 736, 3240, 13, 13, 2541, 21984, 29889, 29888, 329, 1973, 29889, 7032, 11426, 13366, 29898, 3317, 29918, 1287, 414, 29922, 524, 29898, 5085, 29889, 1949, 29918, 28993, 876, 408, 2279, 3406, 29901, 13, 1678, 3105, 1973, 353, 518, 4258, 3406, 29889, 7892, 29898, 22385, 29892, 16717, 29897, 363, 16717, 297, 599, 29918, 344, 5779, 29962, 13, 13, 9902, 353, 21984, 29889, 29888, 329, 1973, 29889, 10685, 29898, 29888, 329, 1973, 29897, 13, 1454, 364, 29881, 297, 2582, 29889, 15091, 29901, 13, 1678, 1596, 29898, 5499, 29889, 2914, 3101, 13, 13, 29937, 1653, 322, 6222, 10891, 2471, 304, 679, 599, 1661, 29899, 6310, 12680, 2582, 13, 2541, 1722, 29898, 8848, 414, 29918, 3972, 718, 376, 22385, 29889, 845, 613, 376, 29893, 1159, 408, 285, 29901, 13, 1678, 285, 29889, 3539, 877, 1454, 269, 297, 6571, 29914, 1066, 29918, 348, 4572, 287, 5515, 29889, 1066, 29936, 437, 12680, 376, 376, 395, 29879, 1405, 6571, 16527, 6500, 3871, 395, 29879, 21966, 2309, 4286, 4830, 29898, 8848, 414, 29918, 3972, 29892, 2383, 414, 29918, 3972, 876, 13, 13, 29886, 353, 1014, 5014, 29889, 29925, 3150, 29898, 3366, 845, 613, 2383, 414, 29918, 3972, 718, 376, 22385, 29889, 845, 20068, 13, 29886, 29889, 10685, 580, 13, 13, 29937, 5941, 701, 13, 359, 29889, 5992, 29898, 8848, 414, 29918, 3972, 718, 376, 29895, 1050, 29918, 22385, 29889, 845, 1159, 13, 359, 29889, 5992, 29898, 8848, 414, 29918, 3972, 718, 376, 22385, 29889, 845, 1159, 13, 2 ]
src/rekognition_online_action_detection/models/transformer/multihead_attention.py
amazon-research/long-short-term-transformer
52
97589
<reponame>amazon-research/long-short-term-transformer # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 import torch import torch.nn as nn import torch.nn.functional as F class DotProductAttention(nn.Module): def __init__(self, dropout=0.0): super(DotProductAttention, self).__init__() self.dropout = dropout def forward(self, q, k, v, attn_mask=None): attn_output_weights = torch.bmm(q, k.transpose(1, 2)) if attn_mask is not None: attn_output_weights += attn_mask attn_output_weights = F.softmax(attn_output_weights, dim=-1) attn_output_weights = F.dropout(attn_output_weights, p=self.dropout, training=self.training) attn_output = torch.bmm(attn_output_weights, v) return attn_output class DotProductAttentionStream(DotProductAttention): def __init__(self, dropout=0.0): super(DotProductAttentionStream, self).__init__(dropout) ############################ # Cache for stream inference ############################ self.k_weights_cache = None self.k_pos_weights_cache = None def stream_inference(self, q, k, v, k_pos, v_pos, attn_mask=None): if self.k_weights_cache is not None: k_weights_new = torch.bmm(q, k[:, [-1]].transpose(1, 2)) k_weights = torch.cat((self.k_weights_cache[:, :, 1:], k_weights_new), dim=-1) self.k_weights_cache = k_weights k_pos_weights = self.k_pos_weights_cache else: k_weights = torch.bmm(q, k.transpose(1, 2)) self.k_weights_cache = k_weights k_pos_weights = torch.bmm(q, k_pos.transpose(1, 2)) self.k_pos_weights_cache = k_pos_weights attn_output_weights = k_weights + k_pos_weights if attn_mask is not None: attn_output_weights += attn_mask attn_output_weights = F.softmax(attn_output_weights, dim=-1) attn_output_weights = F.dropout(attn_output_weights, p=self.dropout, training=self.training) attn_output = torch.bmm(attn_output_weights, (v + v_pos)) return attn_output class MultiheadAttention(nn.Module): def __init__(self, embed_dim, num_heads, dropout=0.0, bias=True, kdim=None, vdim=None): super(MultiheadAttention, self).__init__() self.embed_dim = embed_dim self.num_heads = num_heads self.kdim = kdim if kdim is not None else embed_dim self.vdim = vdim if vdim is not None else embed_dim self._qkv_same_embed_dim = self.kdim == embed_dim and self.vdim == embed_dim if self._qkv_same_embed_dim: self.in_proj_weight = nn.Parameter(torch.empty(3 * embed_dim, embed_dim)) else: raise RuntimeError('Do not support q, k, v have different dimensions') if bias: self.in_proj_bias = nn.Parameter(torch.empty(3 * embed_dim)) else: self.register_parameter('in_proj_bias', None) self.out_proj = nn.Linear(embed_dim, embed_dim) if self._qkv_same_embed_dim: nn.init.xavier_uniform_(self.in_proj_weight) if self.in_proj_bias is not None: nn.init.constant_(self.in_proj_bias, 0.) nn.init.constant_(self.out_proj.bias, 0.) self.dotproductattention = DotProductAttention(dropout) def forward(self, q, k, v, attn_mask=None, key_padding_mask=None): tsz, bsz, embed_dim = q.shape[0], q.shape[1], q.shape[2] head_dim = embed_dim // self.num_heads assert head_dim * self.num_heads == embed_dim, \ 'embed_dim must be divisible by num_heads' scaling = float(head_dim) ** -0.5 _b = self.in_proj_bias _start = None _end = embed_dim _w = self.in_proj_weight[:_end, :] if _b is not None: _b = _b[:_end] q = F.linear(q, _w, _b) _b = self.in_proj_bias _start = embed_dim _end = embed_dim * 2 _w = self.in_proj_weight[_start:_end, :] if _b is not None: _b = _b[_start:_end] k = F.linear(k, _w, _b) _b = self.in_proj_bias _start = embed_dim * 2 _end = None _w = self.in_proj_weight[_start:, :] if _b is not None: _b = _b[_start:] v = F.linear(v, _w, _b) q = q * scaling q = q.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) k = k.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) v = v.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) if attn_mask is not None: attn_mask = attn_mask.unsqueeze(0).repeat(bsz, 1, 1) attn_mask = attn_mask.unsqueeze(1).repeat(1, self.num_heads, 1, 1) attn_mask = attn_mask.reshape(-1, *attn_mask.shape[2:]) if key_padding_mask is not None: key_padding_mask = key_padding_mask.unsqueeze(1).repeat(1, tsz, 1) key_padding_mask = key_padding_mask.unsqueeze(1).repeat(1, self.num_heads, 1, 1) key_padding_mask = key_padding_mask.reshape(-1, *key_padding_mask.shape[2:]) if attn_mask is not None and key_padding_mask is not None: mask = attn_mask + key_padding_mask elif attn_mask is not None: mask = attn_mask elif key_padding_mask is not None: mask = key_padding_mask else: mask = None attn_output = self.dotproductattention(q, k, v, mask) attn_output = attn_output.transpose(0, 1).contiguous().view(tsz, bsz, self.embed_dim) return self.out_proj(attn_output), None class MultiheadAttentionStream(MultiheadAttention): def __init__(self, embed_dim, num_heads, dropout=0.0, bias=True, kdim=None, vdim=None): super(MultiheadAttentionStream, self).__init__(embed_dim, num_heads, dropout, bias, kdim, vdim) self.dotproductattention = DotProductAttentionStream(dropout) ############################ # Cache for stream inference ############################ self.q_cache = None self.k_cache = None self.v_cache = None self.k_pos_cache = None self.v_pos_cache = None def stream_inference(self, q, k, v, pos, attn_mask=None, key_padding_mask=None): tsz, bsz, embed_dim = q.shape[0], q.shape[1], q.shape[2] head_dim = embed_dim // self.num_heads assert head_dim * self.num_heads == embed_dim, \ 'embed_dim must be divisible by num_heads' scaling = float(head_dim) ** -0.5 if self.q_cache is not None: q = self.q_cache else: _b = self.in_proj_bias _start = None _end = embed_dim _w = self.in_proj_weight[:_end, :] if _b is not None: _b = _b[:_end] q = F.linear(q, _w, _b) self.q_cache = q assert (self.k_cache is None) == (self.k_pos_cache is None) if self.k_cache is not None: _b = self.in_proj_bias _start = embed_dim _end = embed_dim * 2 _w = self.in_proj_weight[_start:_end, :] if _b is not None: _b = _b[_start:_end] k_new = F.linear(k[[-1]], _w, None) k = torch.cat((self.k_cache[1:], k_new)) self.k_cache = k k_pos = self.k_pos_cache else: _b = self.in_proj_bias _start = embed_dim _end = embed_dim * 2 _w = self.in_proj_weight[_start:_end, :] if _b is not None: _b = _b[_start:_end] k = F.linear(k, _w, None) self.k_cache = k k_pos = F.linear(pos, _w, _b) self.k_pos_cache = k_pos assert (self.v_cache is None) == (self.v_pos_cache is None) if self.v_cache is not None: _b = self.in_proj_bias _start = embed_dim * 2 _end = None _w = self.in_proj_weight[_start:, :] if _b is not None: _b = _b[_start:] v_new = F.linear(v[[-1]], _w, None) v = torch.cat((self.v_cache[1:], v_new)) self.v_cache = v v_pos = self.v_pos_cache else: _b = self.in_proj_bias _start = embed_dim * 2 _end = None _w = self.in_proj_weight[_start:, :] if _b is not None: _b = _b[_start:] v = F.linear(v, _w, None) self.v_cache = v v_pos = F.linear(pos, _w, _b) self.v_pos_cache = v_pos q = q * scaling q = q.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) k = k.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) v = v.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) k_pos = k_pos.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) v_pos = v_pos.contiguous().view(-1, bsz * self.num_heads, head_dim).transpose(0, 1) if attn_mask is not None: attn_mask = attn_mask.unsqueeze(0).repeat(bsz, 1, 1) attn_mask = attn_mask.unsqueeze(1).repeat(1, self.num_heads, 1, 1) attn_mask = attn_mask.reshape(-1, *attn_mask.shape[2:]) if key_padding_mask is not None: key_padding_mask = key_padding_mask.unsqueeze(1).repeat(1, tsz, 1) key_padding_mask = key_padding_mask.unsqueeze(1).repeat(1, self.num_heads, 1, 1) key_padding_mask = key_padding_mask.reshape(-1, *key_padding_mask.shape[2:]) if attn_mask is not None and key_padding_mask is not None: mask = attn_mask + key_padding_mask elif attn_mask is not None: mask = attn_mask elif key_padding_mask is not None: mask = key_padding_mask else: mask = None attn_output = self.dotproductattention.stream_inference(q, k, v, k_pos, v_pos, mask) attn_output = attn_output.transpose(0, 1).contiguous().view(tsz, bsz, self.embed_dim) return self.out_proj(attn_output), None
[ 1, 529, 276, 1112, 420, 29958, 17260, 29899, 690, 2842, 29914, 5426, 29899, 12759, 29899, 8489, 29899, 9067, 261, 13, 29937, 14187, 1266, 16631, 29889, 510, 29892, 9266, 29889, 470, 967, 23736, 1078, 29889, 2178, 26863, 2538, 9841, 29889, 13, 29937, 10937, 29928, 29990, 29899, 29931, 293, 1947, 29899, 12889, 29901, 13380, 29899, 29906, 29889, 29900, 13, 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, 360, 327, 7566, 4165, 2509, 29898, 15755, 29889, 7355, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 5768, 449, 29922, 29900, 29889, 29900, 1125, 13, 4706, 2428, 29898, 29928, 327, 7566, 4165, 2509, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 4706, 1583, 29889, 8865, 449, 353, 5768, 449, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 3855, 29892, 413, 29892, 325, 29892, 1098, 29876, 29918, 13168, 29922, 8516, 1125, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 4842, 305, 29889, 29890, 4317, 29898, 29939, 29892, 413, 29889, 3286, 4220, 29898, 29896, 29892, 29871, 29906, 876, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1098, 29876, 29918, 4905, 29918, 705, 5861, 4619, 1098, 29876, 29918, 13168, 13, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 383, 29889, 2695, 3317, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 3964, 10457, 29896, 29897, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 383, 29889, 8865, 449, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 13, 462, 462, 4706, 282, 29922, 1311, 29889, 8865, 449, 29892, 13, 462, 462, 4706, 6694, 29922, 1311, 29889, 26495, 29897, 13, 4706, 1098, 29876, 29918, 4905, 353, 4842, 305, 29889, 29890, 4317, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 325, 29897, 13, 4706, 736, 1098, 29876, 29918, 4905, 13, 13, 13, 1990, 360, 327, 7566, 4165, 2509, 3835, 29898, 29928, 327, 7566, 4165, 2509, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 5768, 449, 29922, 29900, 29889, 29900, 1125, 13, 4706, 2428, 29898, 29928, 327, 7566, 4165, 2509, 3835, 29892, 1583, 467, 1649, 2344, 12035, 8865, 449, 29897, 13, 13, 4706, 835, 13383, 7346, 29937, 13, 4706, 396, 28540, 363, 4840, 27262, 13, 4706, 835, 13383, 7346, 29937, 13, 4706, 1583, 29889, 29895, 29918, 705, 5861, 29918, 8173, 353, 6213, 13, 4706, 1583, 29889, 29895, 29918, 1066, 29918, 705, 5861, 29918, 8173, 353, 6213, 13, 13, 1678, 822, 4840, 29918, 262, 1659, 29898, 1311, 29892, 3855, 29892, 413, 29892, 325, 29892, 413, 29918, 1066, 29892, 325, 29918, 1066, 29892, 1098, 29876, 29918, 13168, 29922, 8516, 1125, 13, 4706, 565, 1583, 29889, 29895, 29918, 705, 5861, 29918, 8173, 338, 451, 6213, 29901, 13, 9651, 413, 29918, 705, 5861, 29918, 1482, 353, 4842, 305, 29889, 29890, 4317, 29898, 29939, 29892, 413, 7503, 29892, 21069, 29896, 29962, 1822, 3286, 4220, 29898, 29896, 29892, 29871, 29906, 876, 13, 9651, 413, 29918, 705, 5861, 353, 4842, 305, 29889, 4117, 3552, 1311, 29889, 29895, 29918, 705, 5861, 29918, 8173, 7503, 29892, 584, 29892, 29871, 29896, 29901, 1402, 413, 29918, 705, 5861, 29918, 1482, 511, 3964, 10457, 29896, 29897, 13, 9651, 1583, 29889, 29895, 29918, 705, 5861, 29918, 8173, 353, 413, 29918, 705, 5861, 13, 9651, 413, 29918, 1066, 29918, 705, 5861, 353, 1583, 29889, 29895, 29918, 1066, 29918, 705, 5861, 29918, 8173, 13, 4706, 1683, 29901, 13, 9651, 413, 29918, 705, 5861, 353, 4842, 305, 29889, 29890, 4317, 29898, 29939, 29892, 413, 29889, 3286, 4220, 29898, 29896, 29892, 29871, 29906, 876, 13, 9651, 1583, 29889, 29895, 29918, 705, 5861, 29918, 8173, 353, 413, 29918, 705, 5861, 13, 9651, 413, 29918, 1066, 29918, 705, 5861, 353, 4842, 305, 29889, 29890, 4317, 29898, 29939, 29892, 413, 29918, 1066, 29889, 3286, 4220, 29898, 29896, 29892, 29871, 29906, 876, 13, 9651, 1583, 29889, 29895, 29918, 1066, 29918, 705, 5861, 29918, 8173, 353, 413, 29918, 1066, 29918, 705, 5861, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 413, 29918, 705, 5861, 718, 413, 29918, 1066, 29918, 705, 5861, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1098, 29876, 29918, 4905, 29918, 705, 5861, 4619, 1098, 29876, 29918, 13168, 13, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 383, 29889, 2695, 3317, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 3964, 10457, 29896, 29897, 13, 4706, 1098, 29876, 29918, 4905, 29918, 705, 5861, 353, 383, 29889, 8865, 449, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 13, 462, 462, 4706, 282, 29922, 1311, 29889, 8865, 449, 29892, 13, 462, 462, 4706, 6694, 29922, 1311, 29889, 26495, 29897, 13, 4706, 1098, 29876, 29918, 4905, 353, 4842, 305, 29889, 29890, 4317, 29898, 1131, 29876, 29918, 4905, 29918, 705, 5861, 29892, 313, 29894, 718, 325, 29918, 1066, 876, 13, 4706, 736, 1098, 29876, 29918, 4905, 13, 13, 13, 1990, 14974, 2813, 4165, 2509, 29898, 15755, 29889, 7355, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 8297, 29918, 6229, 29892, 954, 29918, 2813, 29879, 29892, 5768, 449, 29922, 29900, 29889, 29900, 29892, 24003, 29922, 5574, 29892, 413, 6229, 29922, 8516, 29892, 325, 6229, 29922, 8516, 1125, 13, 4706, 2428, 29898, 15329, 2813, 4165, 2509, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 4706, 1583, 29889, 17987, 29918, 6229, 353, 8297, 29918, 6229, 13, 4706, 1583, 29889, 1949, 29918, 2813, 29879, 353, 954, 29918, 2813, 29879, 13, 4706, 1583, 29889, 29895, 6229, 353, 413, 6229, 565, 413, 6229, 338, 451, 6213, 1683, 8297, 29918, 6229, 13, 4706, 1583, 29889, 29894, 6229, 353, 325, 6229, 565, 325, 6229, 338, 451, 6213, 1683, 8297, 29918, 6229, 13, 4706, 1583, 3032, 29939, 27049, 29918, 17642, 29918, 17987, 29918, 6229, 353, 1583, 29889, 29895, 6229, 1275, 8297, 29918, 6229, 322, 1583, 29889, 29894, 6229, 1275, 8297, 29918, 6229, 13, 13, 4706, 565, 1583, 3032, 29939, 27049, 29918, 17642, 29918, 17987, 29918, 6229, 29901, 13, 9651, 1583, 29889, 262, 29918, 20865, 29918, 7915, 353, 302, 29876, 29889, 9329, 29898, 7345, 305, 29889, 6310, 29898, 29941, 334, 8297, 29918, 6229, 29892, 8297, 29918, 6229, 876, 13, 4706, 1683, 29901, 13, 9651, 12020, 24875, 2392, 877, 6132, 451, 2304, 3855, 29892, 413, 29892, 325, 505, 1422, 13391, 1495, 13, 13, 4706, 565, 24003, 29901, 13, 9651, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 353, 302, 29876, 29889, 9329, 29898, 7345, 305, 29889, 6310, 29898, 29941, 334, 8297, 29918, 6229, 876, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 9573, 29918, 15501, 877, 262, 29918, 20865, 29918, 29890, 3173, 742, 6213, 29897, 13, 13, 4706, 1583, 29889, 449, 29918, 20865, 353, 302, 29876, 29889, 12697, 29898, 17987, 29918, 6229, 29892, 8297, 29918, 6229, 29897, 13, 13, 4706, 565, 1583, 3032, 29939, 27049, 29918, 17642, 29918, 17987, 29918, 6229, 29901, 13, 9651, 302, 29876, 29889, 2344, 29889, 29916, 18852, 29918, 29590, 23538, 1311, 29889, 262, 29918, 20865, 29918, 7915, 29897, 13, 13, 4706, 565, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 338, 451, 6213, 29901, 13, 9651, 302, 29876, 29889, 2344, 29889, 23362, 23538, 1311, 29889, 262, 29918, 20865, 29918, 29890, 3173, 29892, 29871, 29900, 1846, 13, 9651, 302, 29876, 29889, 2344, 29889, 23362, 23538, 1311, 29889, 449, 29918, 20865, 29889, 29890, 3173, 29892, 29871, 29900, 1846, 13, 13, 4706, 1583, 29889, 6333, 4704, 1131, 2509, 353, 360, 327, 7566, 4165, 2509, 29898, 8865, 449, 29897, 13, 13, 1678, 822, 6375, 29898, 1311, 29892, 3855, 29892, 413, 29892, 325, 29892, 1098, 29876, 29918, 13168, 29922, 8516, 29892, 1820, 29918, 12791, 29918, 13168, 29922, 8516, 1125, 13, 4706, 260, 3616, 29892, 289, 3616, 29892, 8297, 29918, 6229, 353, 3855, 29889, 12181, 29961, 29900, 1402, 3855, 29889, 12181, 29961, 29896, 1402, 3855, 29889, 12181, 29961, 29906, 29962, 13, 13, 4706, 2343, 29918, 6229, 353, 8297, 29918, 6229, 849, 1583, 29889, 1949, 29918, 2813, 29879, 13, 4706, 4974, 2343, 29918, 6229, 334, 1583, 29889, 1949, 29918, 2813, 29879, 1275, 8297, 29918, 6229, 29892, 320, 13, 9651, 525, 17987, 29918, 6229, 1818, 367, 8572, 1821, 491, 954, 29918, 2813, 29879, 29915, 13, 4706, 21640, 353, 5785, 29898, 2813, 29918, 6229, 29897, 3579, 448, 29900, 29889, 29945, 13, 13, 4706, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 4706, 903, 2962, 353, 6213, 13, 4706, 903, 355, 353, 8297, 29918, 6229, 13, 4706, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 7503, 29918, 355, 29892, 584, 29962, 13, 4706, 565, 903, 29890, 338, 451, 6213, 29901, 13, 9651, 903, 29890, 353, 903, 29890, 7503, 29918, 355, 29962, 13, 4706, 3855, 353, 383, 29889, 10660, 29898, 29939, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 13, 4706, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 4706, 903, 2962, 353, 8297, 29918, 6229, 13, 4706, 903, 355, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 4706, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29918, 355, 29892, 584, 29962, 13, 4706, 565, 903, 29890, 338, 451, 6213, 29901, 13, 9651, 903, 29890, 353, 903, 29890, 28513, 2962, 29901, 29918, 355, 29962, 13, 4706, 413, 353, 383, 29889, 10660, 29898, 29895, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 13, 4706, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 4706, 903, 2962, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 4706, 903, 355, 353, 6213, 13, 4706, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29892, 584, 29962, 13, 4706, 565, 903, 29890, 338, 451, 6213, 29901, 13, 9651, 903, 29890, 353, 903, 29890, 28513, 2962, 17531, 13, 4706, 325, 353, 383, 29889, 10660, 29898, 29894, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 13, 4706, 3855, 353, 3855, 334, 21640, 13, 13, 4706, 3855, 353, 3855, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 413, 353, 413, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 325, 353, 325, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29900, 467, 14358, 29898, 29890, 3616, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 690, 14443, 6278, 29896, 29892, 334, 1131, 29876, 29918, 13168, 29889, 12181, 29961, 29906, 29901, 2314, 13, 13, 4706, 565, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 260, 3616, 29892, 29871, 29896, 29897, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 690, 14443, 6278, 29896, 29892, 334, 1989, 29918, 12791, 29918, 13168, 29889, 12181, 29961, 29906, 29901, 2314, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 322, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1098, 29876, 29918, 13168, 718, 1820, 29918, 12791, 29918, 13168, 13, 4706, 25342, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1098, 29876, 29918, 13168, 13, 4706, 25342, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1820, 29918, 12791, 29918, 13168, 13, 4706, 1683, 29901, 13, 9651, 11105, 353, 6213, 13, 13, 4706, 1098, 29876, 29918, 4905, 353, 1583, 29889, 6333, 4704, 1131, 2509, 29898, 29939, 29892, 413, 29892, 325, 29892, 11105, 29897, 13, 4706, 1098, 29876, 29918, 4905, 353, 1098, 29876, 29918, 4905, 29889, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 467, 1285, 5526, 681, 2141, 1493, 29898, 1372, 29920, 29892, 289, 3616, 29892, 13, 462, 462, 462, 462, 1678, 1583, 29889, 17987, 29918, 6229, 29897, 13, 4706, 736, 1583, 29889, 449, 29918, 20865, 29898, 1131, 29876, 29918, 4905, 511, 6213, 13, 13, 13, 1990, 14974, 2813, 4165, 2509, 3835, 29898, 15329, 2813, 4165, 2509, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 8297, 29918, 6229, 29892, 954, 29918, 2813, 29879, 29892, 5768, 449, 29922, 29900, 29889, 29900, 29892, 24003, 29922, 5574, 29892, 413, 6229, 29922, 8516, 29892, 325, 6229, 29922, 8516, 1125, 13, 4706, 2428, 29898, 15329, 2813, 4165, 2509, 3835, 29892, 1583, 467, 1649, 2344, 12035, 17987, 29918, 6229, 29892, 954, 29918, 2813, 29879, 29892, 5768, 449, 29892, 24003, 29892, 413, 6229, 29892, 325, 6229, 29897, 13, 13, 4706, 1583, 29889, 6333, 4704, 1131, 2509, 353, 360, 327, 7566, 4165, 2509, 3835, 29898, 8865, 449, 29897, 13, 13, 4706, 835, 13383, 7346, 29937, 13, 4706, 396, 28540, 363, 4840, 27262, 13, 4706, 835, 13383, 7346, 29937, 13, 4706, 1583, 29889, 29939, 29918, 8173, 353, 6213, 13, 4706, 1583, 29889, 29895, 29918, 8173, 353, 6213, 13, 4706, 1583, 29889, 29894, 29918, 8173, 353, 6213, 13, 4706, 1583, 29889, 29895, 29918, 1066, 29918, 8173, 353, 6213, 13, 4706, 1583, 29889, 29894, 29918, 1066, 29918, 8173, 353, 6213, 13, 13, 1678, 822, 4840, 29918, 262, 1659, 29898, 1311, 29892, 3855, 29892, 413, 29892, 325, 29892, 926, 29892, 1098, 29876, 29918, 13168, 29922, 8516, 29892, 1820, 29918, 12791, 29918, 13168, 29922, 8516, 1125, 13, 4706, 260, 3616, 29892, 289, 3616, 29892, 8297, 29918, 6229, 353, 3855, 29889, 12181, 29961, 29900, 1402, 3855, 29889, 12181, 29961, 29896, 1402, 3855, 29889, 12181, 29961, 29906, 29962, 13, 13, 4706, 2343, 29918, 6229, 353, 8297, 29918, 6229, 849, 1583, 29889, 1949, 29918, 2813, 29879, 13, 4706, 4974, 2343, 29918, 6229, 334, 1583, 29889, 1949, 29918, 2813, 29879, 1275, 8297, 29918, 6229, 29892, 320, 13, 9651, 525, 17987, 29918, 6229, 1818, 367, 8572, 1821, 491, 954, 29918, 2813, 29879, 29915, 13, 4706, 21640, 353, 5785, 29898, 2813, 29918, 6229, 29897, 3579, 448, 29900, 29889, 29945, 13, 13, 4706, 565, 1583, 29889, 29939, 29918, 8173, 338, 451, 6213, 29901, 13, 9651, 3855, 353, 1583, 29889, 29939, 29918, 8173, 13, 4706, 1683, 29901, 13, 9651, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 9651, 903, 2962, 353, 6213, 13, 9651, 903, 355, 353, 8297, 29918, 6229, 13, 9651, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 7503, 29918, 355, 29892, 584, 29962, 13, 9651, 565, 903, 29890, 338, 451, 6213, 29901, 13, 18884, 903, 29890, 353, 903, 29890, 7503, 29918, 355, 29962, 13, 9651, 3855, 353, 383, 29889, 10660, 29898, 29939, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 9651, 1583, 29889, 29939, 29918, 8173, 353, 3855, 13, 13, 4706, 4974, 313, 1311, 29889, 29895, 29918, 8173, 338, 6213, 29897, 1275, 313, 1311, 29889, 29895, 29918, 1066, 29918, 8173, 338, 6213, 29897, 13, 4706, 565, 1583, 29889, 29895, 29918, 8173, 338, 451, 6213, 29901, 13, 9651, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 9651, 903, 2962, 353, 8297, 29918, 6229, 13, 9651, 903, 355, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 9651, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29918, 355, 29892, 584, 29962, 13, 9651, 565, 903, 29890, 338, 451, 6213, 29901, 13, 18884, 903, 29890, 353, 903, 29890, 28513, 2962, 29901, 29918, 355, 29962, 13, 9651, 413, 29918, 1482, 353, 383, 29889, 10660, 29898, 29895, 8999, 29899, 29896, 20526, 903, 29893, 29892, 6213, 29897, 13, 9651, 413, 353, 4842, 305, 29889, 4117, 3552, 1311, 29889, 29895, 29918, 8173, 29961, 29896, 29901, 1402, 413, 29918, 1482, 876, 13, 9651, 1583, 29889, 29895, 29918, 8173, 353, 413, 13, 9651, 413, 29918, 1066, 353, 1583, 29889, 29895, 29918, 1066, 29918, 8173, 13, 4706, 1683, 29901, 13, 9651, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 9651, 903, 2962, 353, 8297, 29918, 6229, 13, 9651, 903, 355, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 9651, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29918, 355, 29892, 584, 29962, 13, 9651, 565, 903, 29890, 338, 451, 6213, 29901, 13, 18884, 903, 29890, 353, 903, 29890, 28513, 2962, 29901, 29918, 355, 29962, 13, 9651, 413, 353, 383, 29889, 10660, 29898, 29895, 29892, 903, 29893, 29892, 6213, 29897, 13, 9651, 1583, 29889, 29895, 29918, 8173, 353, 413, 13, 9651, 413, 29918, 1066, 353, 383, 29889, 10660, 29898, 1066, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 9651, 1583, 29889, 29895, 29918, 1066, 29918, 8173, 353, 413, 29918, 1066, 13, 13, 4706, 4974, 313, 1311, 29889, 29894, 29918, 8173, 338, 6213, 29897, 1275, 313, 1311, 29889, 29894, 29918, 1066, 29918, 8173, 338, 6213, 29897, 13, 4706, 565, 1583, 29889, 29894, 29918, 8173, 338, 451, 6213, 29901, 13, 9651, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 9651, 903, 2962, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 9651, 903, 355, 353, 6213, 13, 9651, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29892, 584, 29962, 13, 9651, 565, 903, 29890, 338, 451, 6213, 29901, 13, 18884, 903, 29890, 353, 903, 29890, 28513, 2962, 17531, 13, 9651, 325, 29918, 1482, 353, 383, 29889, 10660, 29898, 29894, 8999, 29899, 29896, 20526, 903, 29893, 29892, 6213, 29897, 13, 9651, 325, 353, 4842, 305, 29889, 4117, 3552, 1311, 29889, 29894, 29918, 8173, 29961, 29896, 29901, 1402, 325, 29918, 1482, 876, 13, 9651, 1583, 29889, 29894, 29918, 8173, 353, 325, 13, 9651, 325, 29918, 1066, 353, 1583, 29889, 29894, 29918, 1066, 29918, 8173, 13, 4706, 1683, 29901, 13, 9651, 903, 29890, 353, 1583, 29889, 262, 29918, 20865, 29918, 29890, 3173, 13, 9651, 903, 2962, 353, 8297, 29918, 6229, 334, 29871, 29906, 13, 9651, 903, 355, 353, 6213, 13, 9651, 903, 29893, 353, 1583, 29889, 262, 29918, 20865, 29918, 7915, 28513, 2962, 29901, 29892, 584, 29962, 13, 9651, 565, 903, 29890, 338, 451, 6213, 29901, 13, 18884, 903, 29890, 353, 903, 29890, 28513, 2962, 17531, 13, 9651, 325, 353, 383, 29889, 10660, 29898, 29894, 29892, 903, 29893, 29892, 6213, 29897, 13, 9651, 1583, 29889, 29894, 29918, 8173, 353, 325, 13, 9651, 325, 29918, 1066, 353, 383, 29889, 10660, 29898, 1066, 29892, 903, 29893, 29892, 903, 29890, 29897, 13, 9651, 1583, 29889, 29894, 29918, 1066, 29918, 8173, 353, 325, 29918, 1066, 13, 13, 4706, 3855, 353, 3855, 334, 21640, 13, 13, 4706, 3855, 353, 3855, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 413, 353, 413, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 325, 353, 325, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 413, 29918, 1066, 353, 413, 29918, 1066, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 325, 29918, 1066, 353, 325, 29918, 1066, 29889, 1285, 5526, 681, 2141, 1493, 6278, 29896, 29892, 289, 3616, 334, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 2343, 29918, 6229, 467, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 29897, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29900, 467, 14358, 29898, 29890, 3616, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1098, 29876, 29918, 13168, 353, 1098, 29876, 29918, 13168, 29889, 690, 14443, 6278, 29896, 29892, 334, 1131, 29876, 29918, 13168, 29889, 12181, 29961, 29906, 29901, 2314, 13, 13, 4706, 565, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 260, 3616, 29892, 29871, 29896, 29897, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 6948, 802, 29872, 911, 29898, 29896, 467, 14358, 29898, 29896, 29892, 1583, 29889, 1949, 29918, 2813, 29879, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 1820, 29918, 12791, 29918, 13168, 353, 1820, 29918, 12791, 29918, 13168, 29889, 690, 14443, 6278, 29896, 29892, 334, 1989, 29918, 12791, 29918, 13168, 29889, 12181, 29961, 29906, 29901, 2314, 13, 13, 4706, 565, 1098, 29876, 29918, 13168, 338, 451, 6213, 322, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1098, 29876, 29918, 13168, 718, 1820, 29918, 12791, 29918, 13168, 13, 4706, 25342, 1098, 29876, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1098, 29876, 29918, 13168, 13, 4706, 25342, 1820, 29918, 12791, 29918, 13168, 338, 451, 6213, 29901, 13, 9651, 11105, 353, 1820, 29918, 12791, 29918, 13168, 13, 4706, 1683, 29901, 13, 9651, 11105, 353, 6213, 13, 13, 4706, 1098, 29876, 29918, 4905, 353, 1583, 29889, 6333, 4704, 1131, 2509, 29889, 5461, 29918, 262, 1659, 29898, 29939, 29892, 413, 29892, 325, 29892, 413, 29918, 1066, 29892, 325, 29918, 1066, 29892, 11105, 29897, 13, 4706, 1098, 29876, 29918, 4905, 353, 1098, 29876, 29918, 4905, 29889, 3286, 4220, 29898, 29900, 29892, 29871, 29896, 467, 1285, 5526, 681, 2141, 1493, 29898, 1372, 29920, 29892, 289, 3616, 29892, 13, 462, 462, 462, 462, 1678, 1583, 29889, 17987, 29918, 6229, 29897, 13, 4706, 736, 1583, 29889, 449, 29918, 20865, 29898, 1131, 29876, 29918, 4905, 511, 6213, 13, 2 ]
normalWordCloud1.py
praneethr1000/youtube-song-comment-highlights
0
55964
<filename>normalWordCloud1.py<gh_stars>0 # -*- coding: utf-8 -*- """ @author: praneeth """ import os from os import path from wordcloud import WordCloud d = path.dirname(__file__) if "__file__" in locals() else os.getcwd() text = open(path.join(d, 'comments.txt')).read() # Generate a word cloud image wordcloud = WordCloud().generate(text) # Display the generated image: import matplotlib.pyplot as plt plt.imshow(wordcloud, interpolation='bilinear') plt.axis("off") wordcloud.to_file("sample1.png") plt.show()
[ 1, 529, 9507, 29958, 8945, 14463, 20442, 29896, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 13, 29992, 8921, 29901, 544, 1662, 621, 13, 15945, 29908, 13, 13, 5215, 2897, 13, 13, 3166, 2897, 1053, 2224, 13, 3166, 1734, 9274, 1053, 10803, 20442, 13, 13, 29881, 353, 2224, 29889, 25721, 22168, 1445, 1649, 29897, 565, 376, 1649, 1445, 1649, 29908, 297, 1180, 1338, 580, 1683, 2897, 29889, 657, 29883, 9970, 580, 13, 13, 726, 353, 1722, 29898, 2084, 29889, 7122, 29898, 29881, 29892, 525, 21032, 29889, 3945, 1495, 467, 949, 580, 13, 13, 29937, 3251, 403, 263, 1734, 9570, 1967, 13, 1742, 9274, 353, 10803, 20442, 2141, 17158, 29898, 726, 29897, 13, 13, 29937, 17440, 278, 5759, 1967, 29901, 13, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 572, 29873, 29889, 326, 4294, 29898, 1742, 9274, 29892, 29694, 2433, 18152, 457, 279, 1495, 13, 572, 29873, 29889, 8990, 703, 2696, 1159, 13, 1742, 9274, 29889, 517, 29918, 1445, 703, 11249, 29896, 29889, 2732, 1159, 13, 572, 29873, 29889, 4294, 580, 13, 13, 2 ]
bugtests/test262p/y.py
doom38/jython_v2.2.1
0
116365
assert __name__ == "test262p.y"
[ 1, 29871, 13, 9294, 4770, 978, 1649, 1275, 376, 1688, 29906, 29953, 29906, 29886, 29889, 29891, 29908, 13, 2 ]
savepointradio/radio/migrations/0005_replaygain_data.py
RecursiveGreen/spradio-django2
0
104527
# Generated by Django 2.2.2 on 2019-07-03 13:16 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('radio', '0004_new_song_path_structure'), ] operations = [ migrations.AddField( model_name='store', name='track_gain', field=models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True, verbose_name='recommended replaygain adjustment'), ), migrations.AddField( model_name='store', name='track_peak', field=models.DecimalField(blank=True, decimal_places=6, max_digits=10, null=True, verbose_name='highest volume level in the track'), ), ]
[ 1, 396, 3251, 630, 491, 15337, 29871, 29906, 29889, 29906, 29889, 29906, 373, 29871, 29906, 29900, 29896, 29929, 29899, 29900, 29955, 29899, 29900, 29941, 29871, 29896, 29941, 29901, 29896, 29953, 13, 13, 3166, 9557, 29889, 2585, 1053, 9725, 800, 29892, 4733, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 13, 4706, 6702, 13399, 742, 525, 29900, 29900, 29900, 29946, 29918, 1482, 29918, 21453, 29918, 2084, 29918, 23905, 5477, 13, 1678, 4514, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 8899, 742, 13, 9651, 1024, 2433, 11294, 29918, 29887, 475, 742, 13, 9651, 1746, 29922, 9794, 29889, 23307, 3073, 29898, 19465, 29922, 5574, 29892, 13677, 29918, 29886, 6048, 29922, 29906, 29892, 4236, 29918, 7501, 1169, 29922, 29953, 29892, 1870, 29922, 5574, 29892, 26952, 29918, 978, 2433, 276, 2055, 2760, 337, 1456, 29887, 475, 10365, 358, 5477, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 8899, 742, 13, 9651, 1024, 2433, 11294, 29918, 412, 557, 742, 13, 9651, 1746, 29922, 9794, 29889, 23307, 3073, 29898, 19465, 29922, 5574, 29892, 13677, 29918, 29886, 6048, 29922, 29953, 29892, 4236, 29918, 7501, 1169, 29922, 29896, 29900, 29892, 1870, 29922, 5574, 29892, 26952, 29918, 978, 2433, 9812, 342, 7977, 3233, 297, 278, 5702, 5477, 13, 4706, 10353, 13, 1678, 4514, 13, 2 ]
tests/make_conf.py
philiparvidsson/pymake
2
84960
#!/usr/bin/env python #--------------------------------------- # IMPORTS #--------------------------------------- import test from pymake2 import * #--------------------------------------- # FUNCTIONS #--------------------------------------- @target def my_target_1(conf): test.equal(conf.value, '123abc', "conf.value is incorrect") conf.value = 'xyz456' @target @depends_on('my_target_1') def my_target_2(conf): test.equal(conf.value, '123abc', "conf.value should be immutable") #--------------------------------------- # SCRIPT #--------------------------------------- pymake2({ 'value': '123abc' }, [ 'my_target_2' ]) test.success()
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 13, 29937, 2683, 2683, 26589, 13, 29937, 306, 3580, 8476, 29903, 13, 29937, 2683, 2683, 26589, 13, 13, 5215, 1243, 13, 13, 3166, 11451, 5675, 29906, 1053, 334, 13, 13, 29937, 2683, 2683, 26589, 13, 29937, 383, 28700, 29903, 13, 29937, 2683, 2683, 26589, 13, 13, 29992, 5182, 13, 1753, 590, 29918, 5182, 29918, 29896, 29898, 5527, 1125, 13, 1678, 1243, 29889, 11745, 29898, 5527, 29889, 1767, 29892, 525, 29896, 29906, 29941, 10736, 742, 376, 5527, 29889, 1767, 338, 10240, 1159, 13, 13, 1678, 1970, 29889, 1767, 353, 525, 20230, 29946, 29945, 29953, 29915, 13, 13, 29992, 5182, 13, 29992, 2716, 1975, 29918, 265, 877, 1357, 29918, 5182, 29918, 29896, 1495, 13, 1753, 590, 29918, 5182, 29918, 29906, 29898, 5527, 1125, 13, 1678, 1243, 29889, 11745, 29898, 5527, 29889, 1767, 29892, 525, 29896, 29906, 29941, 10736, 742, 376, 5527, 29889, 1767, 881, 367, 5198, 9246, 1159, 13, 13, 29937, 2683, 2683, 26589, 13, 29937, 12314, 24290, 13, 29937, 2683, 2683, 26589, 13, 13, 2272, 5675, 29906, 3319, 525, 1767, 2396, 525, 29896, 29906, 29941, 10736, 29915, 2981, 518, 525, 1357, 29918, 5182, 29918, 29906, 29915, 29871, 2314, 13, 13, 1688, 29889, 8698, 580, 13, 2 ]
stormpath/client.py
denibertovic/stormpath-sdk-python
0
65319
"""Stormpath API client.""" from .auth import Auth from .data_store import DataStore from .http import HttpExecutor from .resources.account import AccountList from .resources.account_store_mapping import AccountStoreMappingList from .resources.group import GroupList from .resources.group_membership import GroupMembershipList from .resources.tenant import Tenant class Client(object): """The root entry point for SDK functionality. Using the client instance, you can access all tenant data, such as applications, directories, groups, and accounts. More info in documentation: http://docs.stormpath.com/python/product-guide/#sdk-concepts The client contains the following attributes that represent resource lists: :py:attr:`applications` - :class:`stormpath.resources.application.ApplicationList` :py:attr:`directories` - :class:`stormpath.resources.directory.DirectoryList` :py:attr:`accounts` - :class:`stormpath.resources.account.AccountList` :py:attr:`groups` - :class:`stormpath.resources.group.GroupList` :py:attr:`group_memberships` - :class:`stormpath.resources.group_membership.GroupMembershipList` :py:attr:`account_store_mappings` - :class:`stormpath.resources.account_store_mapping.AccountStoreMappingList` """ BASE_URL = 'https://api.stormpath.com/v1' def __init__(self, base_url=None, cache_options=None, expand=None, proxies=None, user_agent=None, backoff_strategy=None, **auth_kwargs): """ Initialize the client by setting the :class:`stormpath.data_store.DataStore` and :class:`stormpath.resources.tenant.Tenant`. The parameters the Client accepts are those used by the :class:`stormpath.http.HttpExecutor`, :class:`stormpath.auth.Auth`, and :class:`stormpath.data_store.DataStore` classes. :param str user_agent: (optional) The custom user agent to set. :param backoff_strategy: A Function that will return the number of milliseconds to wait before retrying the request. The function must take one parameter which is the number of retries already done. If no function is supplied the default backoff strategy is used (see the :meth:`stormpath.http.HttpExecutor.pause_exponentially` method). """ self.BASE_URL = base_url or self.BASE_URL self.auth = Auth(**auth_kwargs) executor = HttpExecutor(self.BASE_URL, self.auth.scheme, proxies, user_agent=user_agent, get_delay=backoff_strategy) self.data_store = DataStore(executor, cache_options) self.tenant = Tenant(client=self, href='/tenants/current', expand=expand) @property def applications(self): return self.tenant.applications @property def directories(self): return self.tenant.directories @property def accounts(self): return AccountList(self, href='/accounts') @property def groups(self): return GroupList(self, href='/groups') @property def group_memberships(self): return GroupMembershipList(self, href='/groupMemberships') @property def account_store_mappings(self): return AccountStoreMappingList(self, href='/accountStoreMappings')
[ 1, 9995, 855, 555, 2084, 3450, 3132, 1213, 15945, 13, 13, 13, 3166, 869, 5150, 1053, 13189, 13, 3166, 869, 1272, 29918, 8899, 1053, 3630, 9044, 13, 3166, 869, 1124, 1053, 9056, 13366, 13, 3166, 869, 13237, 29889, 10149, 1053, 16535, 1293, 13, 3166, 869, 13237, 29889, 10149, 29918, 8899, 29918, 20698, 1053, 16535, 9044, 15845, 1293, 13, 3166, 869, 13237, 29889, 2972, 1053, 6431, 1293, 13, 3166, 869, 13237, 29889, 2972, 29918, 29885, 1590, 10475, 1053, 6431, 29924, 1590, 10475, 1293, 13, 3166, 869, 13237, 29889, 841, 424, 1053, 12444, 424, 13, 13, 13, 1990, 12477, 29898, 3318, 1125, 13, 1678, 9995, 1576, 3876, 6251, 1298, 363, 12967, 9863, 29889, 13, 13, 1678, 5293, 278, 3132, 2777, 29892, 366, 508, 2130, 599, 3006, 424, 848, 29892, 1316, 408, 13, 1678, 8324, 29892, 17525, 29892, 6471, 29892, 322, 15303, 29889, 13, 13, 1678, 5853, 5235, 297, 5106, 29901, 13, 1678, 1732, 597, 2640, 29889, 303, 555, 2084, 29889, 510, 29914, 4691, 29914, 4704, 29899, 13075, 8484, 15348, 29899, 535, 1547, 29879, 13, 13, 1678, 450, 3132, 3743, 278, 1494, 8393, 393, 2755, 6503, 8857, 29901, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 932, 5795, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 6214, 29889, 4873, 1293, 29952, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 11851, 3842, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 12322, 29889, 9882, 1293, 29952, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 10149, 29879, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 10149, 29889, 10601, 1293, 29952, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 13155, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 2972, 29889, 4782, 1293, 29952, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 2972, 29918, 28109, 14587, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 2972, 29918, 29885, 1590, 10475, 29889, 4782, 29924, 1590, 10475, 1293, 29952, 13, 13, 1678, 584, 2272, 29901, 5552, 18078, 10149, 29918, 8899, 29918, 655, 27775, 29952, 448, 13, 1678, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 10149, 29918, 8899, 29918, 20698, 29889, 10601, 9044, 15845, 1293, 29952, 13, 1678, 9995, 13, 1678, 350, 8127, 29918, 4219, 353, 525, 991, 597, 2754, 29889, 303, 555, 2084, 29889, 510, 29914, 29894, 29896, 29915, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2967, 29918, 2271, 29922, 8516, 29892, 7090, 29918, 6768, 29922, 8516, 29892, 7985, 29922, 8516, 29892, 410, 29916, 583, 29922, 8516, 29892, 1404, 29918, 14748, 29922, 8516, 29892, 1250, 2696, 29918, 710, 8963, 29922, 8516, 29892, 3579, 5150, 29918, 19290, 1125, 13, 4706, 9995, 13, 4706, 25455, 278, 3132, 491, 4444, 278, 13, 4706, 584, 1990, 18078, 303, 555, 2084, 29889, 1272, 29918, 8899, 29889, 1469, 9044, 29952, 322, 13, 4706, 584, 1990, 18078, 303, 555, 2084, 29889, 13237, 29889, 841, 424, 29889, 29911, 27153, 1412, 13, 13, 4706, 450, 4128, 278, 12477, 21486, 526, 1906, 1304, 491, 278, 13, 4706, 584, 1990, 18078, 303, 555, 2084, 29889, 1124, 29889, 5506, 13366, 1673, 584, 1990, 18078, 303, 555, 2084, 29889, 5150, 29889, 6444, 1673, 322, 13, 4706, 584, 1990, 18078, 303, 555, 2084, 29889, 1272, 29918, 8899, 29889, 1469, 9044, 29952, 4413, 29889, 13, 13, 4706, 584, 3207, 851, 1404, 29918, 14748, 29901, 313, 25253, 29897, 450, 2888, 1404, 10823, 304, 731, 29889, 13, 13, 4706, 584, 3207, 1250, 2696, 29918, 710, 8963, 29901, 319, 6680, 393, 674, 736, 278, 1353, 310, 3533, 21462, 13, 9651, 304, 4480, 1434, 337, 2202, 292, 278, 2009, 29889, 450, 740, 1818, 2125, 697, 3443, 13, 9651, 607, 338, 278, 1353, 310, 3240, 2722, 2307, 2309, 29889, 960, 694, 740, 338, 19056, 13, 9651, 278, 2322, 1250, 2696, 13705, 338, 1304, 313, 4149, 278, 584, 29885, 621, 18078, 303, 555, 2084, 29889, 1124, 29889, 5506, 13366, 29889, 29886, 1071, 29918, 735, 1112, 9247, 29952, 1158, 467, 13, 4706, 9995, 13, 4706, 1583, 29889, 25416, 29918, 4219, 353, 2967, 29918, 2271, 470, 1583, 29889, 25416, 29918, 4219, 13, 13, 4706, 1583, 29889, 5150, 353, 13189, 29898, 1068, 5150, 29918, 19290, 29897, 13, 4706, 2279, 3406, 353, 9056, 13366, 29898, 1311, 29889, 25416, 29918, 4219, 29892, 1583, 29889, 5150, 29889, 816, 2004, 29892, 410, 29916, 583, 29892, 1404, 29918, 14748, 29922, 1792, 29918, 14748, 29892, 679, 29918, 18829, 29922, 1627, 2696, 29918, 710, 8963, 29897, 13, 4706, 1583, 29889, 1272, 29918, 8899, 353, 3630, 9044, 29898, 4258, 3406, 29892, 7090, 29918, 6768, 29897, 13, 4706, 1583, 29889, 841, 424, 353, 12444, 424, 29898, 4645, 29922, 1311, 29892, 2822, 2433, 29914, 841, 1934, 29914, 3784, 742, 7985, 29922, 18837, 29897, 13, 13, 1678, 732, 6799, 13, 1678, 822, 8324, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 841, 424, 29889, 932, 5795, 13, 13, 1678, 732, 6799, 13, 1678, 822, 17525, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 841, 424, 29889, 11851, 3842, 13, 13, 1678, 732, 6799, 13, 1678, 822, 15303, 29898, 1311, 1125, 13, 4706, 736, 16535, 1293, 29898, 1311, 29892, 2822, 2433, 29914, 10149, 29879, 1495, 13, 13, 1678, 732, 6799, 13, 1678, 822, 6471, 29898, 1311, 1125, 13, 4706, 736, 6431, 1293, 29898, 1311, 29892, 2822, 2433, 29914, 13155, 1495, 13, 13, 1678, 732, 6799, 13, 1678, 822, 2318, 29918, 28109, 14587, 29898, 1311, 1125, 13, 4706, 736, 6431, 29924, 1590, 10475, 1293, 29898, 1311, 29892, 2822, 2433, 29914, 2972, 29924, 13415, 14587, 1495, 13, 13, 1678, 732, 6799, 13, 1678, 822, 3633, 29918, 8899, 29918, 655, 27775, 29898, 1311, 1125, 13, 4706, 736, 16535, 9044, 15845, 1293, 29898, 1311, 29892, 2822, 2433, 29914, 10149, 9044, 9689, 886, 1495, 13, 2 ]
NICNetwork/CountryCharts.py
billbsing/NICNetwork
0
196048
<reponame>billbsing/NICNetwork<filename>NICNetwork/CountryCharts.py import collections import matplotlib.pyplot as plot import pygal class CountryCharts: def __init__(self, data_source): self._data_source = data_source @staticmethod def draw_label_size(percent): #absolute = int(round(percentt/100.*np.sum(all_values))) if percent < 2: return '' return f'{percent:.1f}%' def draw_pie_chart(self): country_size = self._data_source.countries country_size = dict(sorted(country_size.items(), key=lambda x: x[1], reverse=True)) labels = [] sizes = country_size.values() for label, size in country_size.items(): percent = (size / sum(sizes)) * 100 labels.append(f'{label} ({size}) {percent:.1f}%') explode = [] last_explode = 0.1 for value in sizes: explode_value = 0 if value < 2: explode_value = last_explode last_explode += 0.02 explode.append(explode_value) fig1, ax1 = plot.subplots() wedges, texts, autotexts = ax1.pie(sizes, #explode=explode, labels=country_size.keys(), autopct=CountryCharts.draw_label_size, shadow=True, startangle=90, rotatelabels=True, labeldistance=None, textprops={'fontsize': 14} ) ax1.legend(wedges, labels, title='Countries', loc='center left', bbox_to_anchor=(1, 0, 0.5, 1) ) # ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. def draw_bar_chart(self): country_size = dict(sorted(self._data_source.countries.items(), reverse=True)) labels = country_size.keys() sizes = country_size.values() label_index = [] for label in labels: label_index.append(len(label_index) + 1) fix, ax = plot.subplots(figsize=(12, 8)) """ ax.set_ylabel('Number of people') ax.set_title('Number of people grouped by country') ax.set_xticklabels(labels, rotation=45) plot.subplots_adjust(bottom=0.40) # plot.margins(0.4) points = ax.bar(labels, sizes, 1, label='Country') ax.bar_label(points) """ barh = ax.barh(label_index, sizes) plot.subplots_adjust(left=0.40) ax.set_yticks(label_index) ax.set_yticklabels(labels) ax.set_xlabel('Number of NIC members') ax.set_ylabel('Country') ax.set_title('Number of NIC members per country') if hasattr(ax, 'bar_label'): ax.bar_label(barh) def draw_world_map(self, filename): country_size = dict(sorted(self._data_source.country_size.items())) style = pygal.style.Style( background='white', plot_background='white', foreground_subtle='black' ) worldmap = pygal.maps.world.World(style=style) worldmap.title = 'NIC Members by country' for country_code_2, value in country_size.items(): country_code = self._data_source.country_codes[country_code_2] country_name = country_code.name #if len(country_name) > 10: #country_name = f'{country_name[:10]}..' worldmap.add(f'{value}: {country_name}', [(country_code_2, value)]) # worldmap.add('Visitors', country_size) worldmap.render_to_file(filename) # worldmap.render()
[ 1, 529, 276, 1112, 420, 29958, 29890, 453, 29890, 2976, 29914, 29940, 2965, 13724, 29966, 9507, 29958, 29940, 2965, 13724, 29914, 20779, 1451, 5708, 29889, 2272, 13, 5215, 16250, 13, 5215, 22889, 29889, 2272, 5317, 408, 6492, 13, 5215, 19484, 284, 13, 13, 13, 1990, 15456, 1451, 5708, 29901, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 848, 29918, 4993, 1125, 13, 4706, 1583, 3032, 1272, 29918, 4993, 353, 848, 29918, 4993, 13, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 4216, 29918, 1643, 29918, 2311, 29898, 25376, 1125, 13, 4706, 396, 23552, 353, 938, 29898, 14486, 29898, 25376, 29873, 29914, 29896, 29900, 29900, 5575, 9302, 29889, 2083, 29898, 497, 29918, 5975, 4961, 13, 4706, 565, 10151, 529, 29871, 29906, 29901, 13, 9651, 736, 6629, 13, 4706, 736, 285, 29915, 29912, 25376, 29901, 29889, 29896, 29888, 10560, 29915, 13, 13, 1678, 822, 4216, 29918, 12343, 29918, 15425, 29898, 1311, 1125, 13, 13, 4706, 4234, 29918, 2311, 353, 1583, 3032, 1272, 29918, 4993, 29889, 2798, 2722, 13, 4706, 4234, 29918, 2311, 353, 9657, 29898, 24582, 29898, 13509, 29918, 2311, 29889, 7076, 3285, 1820, 29922, 2892, 921, 29901, 921, 29961, 29896, 1402, 11837, 29922, 5574, 876, 13, 13, 4706, 11073, 353, 5159, 13, 4706, 15786, 353, 4234, 29918, 2311, 29889, 5975, 580, 13, 4706, 363, 3858, 29892, 2159, 297, 4234, 29918, 2311, 29889, 7076, 7295, 13, 9651, 10151, 353, 29871, 313, 2311, 847, 2533, 29898, 29879, 7093, 876, 334, 29871, 29896, 29900, 29900, 13, 9651, 11073, 29889, 4397, 29898, 29888, 29915, 29912, 1643, 29913, 21313, 2311, 1800, 426, 25376, 29901, 29889, 29896, 29888, 10560, 1495, 13, 13, 4706, 3902, 356, 353, 5159, 13, 4706, 1833, 29918, 24516, 356, 353, 29871, 29900, 29889, 29896, 13, 4706, 363, 995, 297, 15786, 29901, 13, 9651, 3902, 356, 29918, 1767, 353, 29871, 29900, 13, 9651, 565, 995, 529, 29871, 29906, 29901, 13, 18884, 3902, 356, 29918, 1767, 353, 1833, 29918, 24516, 356, 13, 18884, 1833, 29918, 24516, 356, 4619, 29871, 29900, 29889, 29900, 29906, 13, 9651, 3902, 356, 29889, 4397, 29898, 24516, 356, 29918, 1767, 29897, 13, 13, 13, 4706, 2537, 29896, 29892, 4853, 29896, 353, 6492, 29889, 1491, 26762, 580, 13, 4706, 14837, 2710, 29892, 26442, 29892, 1120, 866, 486, 29879, 353, 4853, 29896, 29889, 12343, 29898, 29879, 7093, 29892, 13, 9651, 396, 24516, 356, 29922, 24516, 356, 29892, 13, 9651, 11073, 29922, 13509, 29918, 2311, 29889, 8149, 3285, 13, 9651, 1120, 459, 312, 29922, 20779, 1451, 5708, 29889, 4012, 29918, 1643, 29918, 2311, 29892, 13, 9651, 15504, 29922, 5574, 29892, 13, 9651, 1369, 2521, 29922, 29929, 29900, 29892, 13, 9651, 5731, 14830, 1107, 29879, 29922, 5574, 29892, 13, 9651, 3858, 19244, 29922, 8516, 29892, 13, 9651, 1426, 11030, 3790, 29915, 5657, 2311, 2396, 29871, 29896, 29946, 29913, 13, 4706, 1723, 13, 13, 4706, 4853, 29896, 29889, 26172, 29898, 8734, 2710, 29892, 13, 9651, 11073, 29892, 13, 9651, 3611, 2433, 3981, 2722, 742, 13, 9651, 1180, 2433, 5064, 2175, 742, 13, 9651, 289, 1884, 29918, 517, 29918, 25367, 7607, 29896, 29892, 29871, 29900, 29892, 29871, 29900, 29889, 29945, 29892, 29871, 29896, 29897, 13, 4706, 1723, 13, 4706, 396, 4853, 29896, 29889, 8990, 877, 11745, 1495, 29871, 396, 11243, 284, 9565, 11959, 5662, 1973, 393, 5036, 338, 12061, 408, 263, 8607, 29889, 13, 13, 1678, 822, 4216, 29918, 1646, 29918, 15425, 29898, 1311, 1125, 13, 4706, 4234, 29918, 2311, 353, 9657, 29898, 24582, 29898, 1311, 3032, 1272, 29918, 4993, 29889, 2798, 2722, 29889, 7076, 3285, 29871, 11837, 29922, 5574, 876, 13, 4706, 11073, 353, 4234, 29918, 2311, 29889, 8149, 580, 13, 4706, 15786, 353, 4234, 29918, 2311, 29889, 5975, 580, 13, 4706, 3858, 29918, 2248, 353, 5159, 13, 4706, 363, 3858, 297, 11073, 29901, 13, 9651, 3858, 29918, 2248, 29889, 4397, 29898, 2435, 29898, 1643, 29918, 2248, 29897, 718, 29871, 29896, 29897, 13, 13, 4706, 2329, 29892, 4853, 353, 6492, 29889, 1491, 26762, 29898, 1003, 2311, 7607, 29896, 29906, 29892, 29871, 29947, 876, 13, 4706, 9995, 13, 4706, 4853, 29889, 842, 29918, 29891, 1643, 877, 4557, 310, 2305, 1495, 13, 4706, 4853, 29889, 842, 29918, 3257, 877, 4557, 310, 2305, 27831, 491, 4234, 1495, 13, 4706, 4853, 29889, 842, 29918, 486, 860, 21134, 29898, 21134, 29892, 13733, 29922, 29946, 29945, 29897, 13, 4706, 6492, 29889, 1491, 26762, 29918, 328, 5143, 29898, 8968, 29922, 29900, 29889, 29946, 29900, 29897, 13, 4706, 396, 6492, 29889, 29885, 1191, 1144, 29898, 29900, 29889, 29946, 29897, 13, 4706, 3291, 353, 4853, 29889, 1646, 29898, 21134, 29892, 15786, 29892, 259, 29896, 29892, 3858, 2433, 20779, 1495, 13, 4706, 4853, 29889, 1646, 29918, 1643, 29898, 9748, 29897, 13, 4706, 9995, 13, 4706, 2594, 29882, 353, 4853, 29889, 1646, 29882, 29898, 1643, 29918, 2248, 29892, 15786, 29897, 13, 4706, 6492, 29889, 1491, 26762, 29918, 328, 5143, 29898, 1563, 29922, 29900, 29889, 29946, 29900, 29897, 13, 4706, 4853, 29889, 842, 29918, 3637, 7358, 29898, 1643, 29918, 2248, 29897, 13, 4706, 4853, 29889, 842, 29918, 3637, 860, 21134, 29898, 21134, 29897, 13, 4706, 4853, 29889, 842, 29918, 29916, 1643, 877, 4557, 310, 405, 2965, 5144, 1495, 13, 4706, 4853, 29889, 842, 29918, 29891, 1643, 877, 20779, 1495, 13, 4706, 4853, 29889, 842, 29918, 3257, 877, 4557, 310, 405, 2965, 5144, 639, 4234, 1495, 13, 4706, 565, 756, 5552, 29898, 1165, 29892, 525, 1646, 29918, 1643, 29374, 13, 9651, 4853, 29889, 1646, 29918, 1643, 29898, 1646, 29882, 29897, 13, 13, 13, 1678, 822, 4216, 29918, 11526, 29918, 1958, 29898, 1311, 29892, 10422, 1125, 13, 4706, 4234, 29918, 2311, 353, 9657, 29898, 24582, 29898, 1311, 3032, 1272, 29918, 4993, 29889, 13509, 29918, 2311, 29889, 7076, 22130, 13, 13, 4706, 3114, 353, 19484, 284, 29889, 3293, 29889, 5568, 29898, 13, 9651, 3239, 2433, 10921, 742, 13, 9651, 6492, 29918, 7042, 2433, 10921, 742, 13, 9651, 363, 18128, 29918, 1491, 29873, 280, 2433, 8517, 29915, 13, 4706, 1723, 13, 4706, 3186, 1958, 353, 19484, 284, 29889, 10339, 29889, 11526, 29889, 14058, 29898, 3293, 29922, 3293, 29897, 13, 4706, 3186, 1958, 29889, 3257, 353, 525, 29940, 2965, 341, 13415, 491, 4234, 29915, 13, 13, 4706, 363, 4234, 29918, 401, 29918, 29906, 29892, 995, 297, 4234, 29918, 2311, 29889, 7076, 7295, 13, 9651, 4234, 29918, 401, 353, 1583, 3032, 1272, 29918, 4993, 29889, 13509, 29918, 18137, 29961, 13509, 29918, 401, 29918, 29906, 29962, 13, 9651, 4234, 29918, 978, 353, 4234, 29918, 401, 29889, 978, 13, 9651, 396, 361, 7431, 29898, 13509, 29918, 978, 29897, 1405, 29871, 29896, 29900, 29901, 13, 18884, 396, 13509, 29918, 978, 353, 285, 29915, 29912, 13509, 29918, 978, 7503, 29896, 29900, 12258, 636, 29915, 13, 9651, 3186, 1958, 29889, 1202, 29898, 29888, 29915, 29912, 1767, 6177, 426, 13509, 29918, 978, 29913, 742, 17288, 13509, 29918, 401, 29918, 29906, 29892, 995, 29897, 2314, 13, 13, 4706, 396, 3186, 1958, 29889, 1202, 877, 6116, 17259, 742, 4234, 29918, 2311, 29897, 13, 4706, 3186, 1958, 29889, 9482, 29918, 517, 29918, 1445, 29898, 9507, 29897, 13, 4706, 396, 3186, 1958, 29889, 9482, 580, 13, 2 ]
Python27/Lib/test/test_functools.py
Jeff-Tian/mybnb
1
66882
import functools import sys import unittest from test import test_support from weakref import proxy import pickle @staticmethod def PythonPartial(func, *args, **keywords): 'Pure Python approximation of partial()' def newfunc(*fargs, **fkeywords): newkeywords = keywords.copy() newkeywords.update(fkeywords) return func(*(args + fargs), **newkeywords) newfunc.func = func newfunc.args = args newfunc.keywords = keywords return newfunc def capture(*args, **kw): """capture all positional and keyword arguments""" return args, kw def signature(part): """ return the signature of a partial object """ return (part.func, part.args, part.keywords, part.__dict__) class TestPartial(unittest.TestCase): thetype = functools.partial def test_basic_examples(self): p = self.thetype(capture, 1, 2, a=10, b=20) self.assertEqual(p(3, 4, b=30, c=40), ((1, 2, 3, 4), dict(a=10, b=30, c=40))) p = self.thetype(map, lambda x: x*10) self.assertEqual(p([1,2,3,4]), [10, 20, 30, 40]) def test_attributes(self): p = self.thetype(capture, 1, 2, a=10, b=20) # attributes should be readable self.assertEqual(p.func, capture) self.assertEqual(p.args, (1, 2)) self.assertEqual(p.keywords, dict(a=10, b=20)) # attributes should not be writable self.assertRaises(TypeError, setattr, p, 'func', map) self.assertRaises(TypeError, setattr, p, 'args', (1, 2)) self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2)) p = self.thetype(hex) try: del p.__dict__ except TypeError: pass else: self.fail('partial object allowed __dict__ to be deleted') def test_argument_checking(self): self.assertRaises(TypeError, self.thetype) # need at least a func arg try: self.thetype(2)() except TypeError: pass else: self.fail('First arg not checked for callability') def test_protection_of_callers_dict_argument(self): # a caller's dictionary should not be altered by partial def func(a=10, b=20): return a d = {'a':3} p = self.thetype(func, a=5) self.assertEqual(p(**d), 3) self.assertEqual(d, {'a':3}) p(b=7) self.assertEqual(d, {'a':3}) def test_arg_combinations(self): # exercise special code paths for zero args in either partial # object or the caller p = self.thetype(capture) self.assertEqual(p(), ((), {})) self.assertEqual(p(1,2), ((1,2), {})) p = self.thetype(capture, 1, 2) self.assertEqual(p(), ((1,2), {})) self.assertEqual(p(3,4), ((1,2,3,4), {})) def test_kw_combinations(self): # exercise special code paths for no keyword args in # either the partial object or the caller p = self.thetype(capture) self.assertEqual(p.keywords, {}) self.assertEqual(p(), ((), {})) self.assertEqual(p(a=1), ((), {'a':1})) p = self.thetype(capture, a=1) self.assertEqual(p.keywords, {'a':1}) self.assertEqual(p(), ((), {'a':1})) self.assertEqual(p(b=2), ((), {'a':1, 'b':2})) # keyword args in the call override those in the partial object self.assertEqual(p(a=3, b=2), ((), {'a':3, 'b':2})) def test_positional(self): # make sure positional arguments are captured correctly for args in [(), (0,), (0,1), (0,1,2), (0,1,2,3)]: p = self.thetype(capture, *args) expected = args + ('x',) got, empty = p('x') self.assertTrue(expected == got and empty == {}) def test_keyword(self): # make sure keyword arguments are captured correctly for a in ['a', 0, None, 3.5]: p = self.thetype(capture, a=a) expected = {'a':a,'x':None} empty, got = p(x=None) self.assertTrue(expected == got and empty == ()) def test_no_side_effects(self): # make sure there are no side effects that affect subsequent calls p = self.thetype(capture, 0, a=1) args1, kw1 = p(1, b=2) self.assertTrue(args1 == (0,1) and kw1 == {'a':1,'b':2}) args2, kw2 = p() self.assertTrue(args2 == (0,) and kw2 == {'a':1}) def test_error_propagation(self): def f(x, y): x // y self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0)) self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0) self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) def test_weakref(self): f = self.thetype(int, base=16) p = proxy(f) self.assertEqual(f.func, p.func) f = None self.assertRaises(ReferenceError, getattr, p, 'func') def test_with_bound_and_unbound_methods(self): data = map(str, range(10)) join = self.thetype(str.join, '') self.assertEqual(join(data), '0123456789') join = self.thetype(''.join) self.assertEqual(join(data), '0123456789') def test_pickle(self): f = self.thetype(signature, 'asdf', bar=True) f.add_something_to__dict__ = True for proto in range(pickle.HIGHEST_PROTOCOL + 1): f_copy = pickle.loads(pickle.dumps(f, proto)) self.assertEqual(signature(f), signature(f_copy)) # Issue 6083: Reference counting bug def test_setstate_refcount(self): class BadSequence: def __len__(self): return 4 def __getitem__(self, key): if key == 0: return max elif key == 1: return tuple(range(1000000)) elif key in (2, 3): return {} raise IndexError f = self.thetype(object) self.assertRaises(SystemError, f.__setstate__, BadSequence()) class PartialSubclass(functools.partial): pass class TestPartialSubclass(TestPartial): thetype = PartialSubclass class TestPythonPartial(TestPartial): thetype = PythonPartial # the python version isn't picklable test_pickle = test_setstate_refcount = None # the python version isn't a type test_attributes = None class TestUpdateWrapper(unittest.TestCase): def check_wrapper(self, wrapper, wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES): # Check attributes were assigned for name in assigned: self.assertTrue(getattr(wrapper, name) is getattr(wrapped, name)) # Check attributes were updated for name in updated: wrapper_attr = getattr(wrapper, name) wrapped_attr = getattr(wrapped, name) for key in wrapped_attr: self.assertTrue(wrapped_attr[key] is wrapper_attr[key]) def _default_update(self): def f(): """This is a test""" pass f.attr = 'This is also a test' def wrapper(): pass functools.update_wrapper(wrapper, f) return wrapper, f def test_default_update(self): wrapper, f = self._default_update() self.check_wrapper(wrapper, f) self.assertEqual(wrapper.__name__, 'f') self.assertEqual(wrapper.attr, 'This is also a test') @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_default_update_doc(self): wrapper, f = self._default_update() self.assertEqual(wrapper.__doc__, 'This is a test') def test_no_update(self): def f(): """This is a test""" pass f.attr = 'This is also a test' def wrapper(): pass functools.update_wrapper(wrapper, f, (), ()) self.check_wrapper(wrapper, f, (), ()) self.assertEqual(wrapper.__name__, 'wrapper') self.assertEqual(wrapper.__doc__, None) self.assertFalse(hasattr(wrapper, 'attr')) def test_selective_update(self): def f(): pass f.attr = 'This is a different test' f.dict_attr = dict(a=1, b=2, c=3) def wrapper(): pass wrapper.dict_attr = {} assign = ('attr',) update = ('dict_attr',) functools.update_wrapper(wrapper, f, assign, update) self.check_wrapper(wrapper, f, assign, update) self.assertEqual(wrapper.__name__, 'wrapper') self.assertEqual(wrapper.__doc__, None) self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) @test_support.requires_docstrings def test_builtin_update(self): # Test for bug #1576241 def wrapper(): pass functools.update_wrapper(wrapper, max) self.assertEqual(wrapper.__name__, 'max') self.assertTrue(wrapper.__doc__.startswith('max(')) class TestWraps(TestUpdateWrapper): def _default_update(self): def f(): """This is a test""" pass f.attr = 'This is also a test' @functools.wraps(f) def wrapper(): pass self.check_wrapper(wrapper, f) return wrapper def test_default_update(self): wrapper = self._default_update() self.assertEqual(wrapper.__name__, 'f') self.assertEqual(wrapper.attr, 'This is also a test') @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_default_update_doc(self): wrapper = self._default_update() self.assertEqual(wrapper.__doc__, 'This is a test') def test_no_update(self): def f(): """This is a test""" pass f.attr = 'This is also a test' @functools.wraps(f, (), ()) def wrapper(): pass self.check_wrapper(wrapper, f, (), ()) self.assertEqual(wrapper.__name__, 'wrapper') self.assertEqual(wrapper.__doc__, None) self.assertFalse(hasattr(wrapper, 'attr')) def test_selective_update(self): def f(): pass f.attr = 'This is a different test' f.dict_attr = dict(a=1, b=2, c=3) def add_dict_attr(f): f.dict_attr = {} return f assign = ('attr',) update = ('dict_attr',) @functools.wraps(f, assign, update) @add_dict_attr def wrapper(): pass self.check_wrapper(wrapper, f, assign, update) self.assertEqual(wrapper.__name__, 'wrapper') self.assertEqual(wrapper.__doc__, None) self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) class TestReduce(unittest.TestCase): def test_reduce(self): class Squares: def __init__(self, max): self.max = max self.sofar = [] def __len__(self): return len(self.sofar) def __getitem__(self, i): if not 0 <= i < self.max: raise IndexError n = len(self.sofar) while n <= i: self.sofar.append(n*n) n += 1 return self.sofar[i] reduce = functools.reduce self.assertEqual(reduce(lambda x, y: x+y, ['a', 'b', 'c'], ''), 'abc') self.assertEqual( reduce(lambda x, y: x+y, [['a', 'c'], [], ['d', 'w']], []), ['a','c','d','w'] ) self.assertEqual(reduce(lambda x, y: x*y, range(2,8), 1), 5040) self.assertEqual( reduce(lambda x, y: x*y, range(2,21), 1L), 2432902008176640000L ) self.assertEqual(reduce(lambda x, y: x+y, Squares(10)), 285) self.assertEqual(reduce(lambda x, y: x+y, Squares(10), 0), 285) self.assertEqual(reduce(lambda x, y: x+y, Squares(0), 0), 0) self.assertRaises(TypeError, reduce) self.assertRaises(TypeError, reduce, 42, 42) self.assertRaises(TypeError, reduce, 42, 42, 42) self.assertEqual(reduce(42, "1"), "1") # func is never called with one item self.assertEqual(reduce(42, "", "1"), "1") # func is never called with one item self.assertRaises(TypeError, reduce, 42, (42, 42)) class TestCmpToKey(unittest.TestCase): def test_cmp_to_key(self): def mycmp(x, y): return y - x self.assertEqual(sorted(range(5), key=functools.cmp_to_key(mycmp)), [4, 3, 2, 1, 0]) def test_hash(self): def mycmp(x, y): return y - x key = functools.cmp_to_key(mycmp) k = key(10) self.assertRaises(TypeError, hash(k)) class TestTotalOrdering(unittest.TestCase): def test_total_ordering_lt(self): @functools.total_ordering class A: def __init__(self, value): self.value = value def __lt__(self, other): return self.value < other.value def __eq__(self, other): return self.value == other.value self.assertTrue(A(1) < A(2)) self.assertTrue(A(2) > A(1)) self.assertTrue(A(1) <= A(2)) self.assertTrue(A(2) >= A(1)) self.assertTrue(A(2) <= A(2)) self.assertTrue(A(2) >= A(2)) def test_total_ordering_le(self): @functools.total_ordering class A: def __init__(self, value): self.value = value def __le__(self, other): return self.value <= other.value def __eq__(self, other): return self.value == other.value self.assertTrue(A(1) < A(2)) self.assertTrue(A(2) > A(1)) self.assertTrue(A(1) <= A(2)) self.assertTrue(A(2) >= A(1)) self.assertTrue(A(2) <= A(2)) self.assertTrue(A(2) >= A(2)) def test_total_ordering_gt(self): @functools.total_ordering class A: def __init__(self, value): self.value = value def __gt__(self, other): return self.value > other.value def __eq__(self, other): return self.value == other.value self.assertTrue(A(1) < A(2)) self.assertTrue(A(2) > A(1)) self.assertTrue(A(1) <= A(2)) self.assertTrue(A(2) >= A(1)) self.assertTrue(A(2) <= A(2)) self.assertTrue(A(2) >= A(2)) def test_total_ordering_ge(self): @functools.total_ordering class A: def __init__(self, value): self.value = value def __ge__(self, other): return self.value >= other.value def __eq__(self, other): return self.value == other.value self.assertTrue(A(1) < A(2)) self.assertTrue(A(2) > A(1)) self.assertTrue(A(1) <= A(2)) self.assertTrue(A(2) >= A(1)) self.assertTrue(A(2) <= A(2)) self.assertTrue(A(2) >= A(2)) def test_total_ordering_no_overwrite(self): # new methods should not overwrite existing @functools.total_ordering class A(str): pass self.assertTrue(A("a") < A("b")) self.assertTrue(A("b") > A("a")) self.assertTrue(A("a") <= A("b")) self.assertTrue(A("b") >= A("a")) self.assertTrue(A("b") <= A("b")) self.assertTrue(A("b") >= A("b")) def test_no_operations_defined(self): with self.assertRaises(ValueError): @functools.total_ordering class A: pass def test_bug_10042(self): @functools.total_ordering class TestTO: def __init__(self, value): self.value = value def __eq__(self, other): if isinstance(other, TestTO): return self.value == other.value return False def __lt__(self, other): if isinstance(other, TestTO): return self.value < other.value raise TypeError with self.assertRaises(TypeError): TestTO(8) <= () def test_main(verbose=None): test_classes = ( TestPartial, TestPartialSubclass, TestPythonPartial, TestUpdateWrapper, TestTotalOrdering, TestWraps, TestReduce, ) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts if __name__ == '__main__': test_main(verbose=True)
[ 1, 1053, 2090, 312, 8789, 30004, 13, 5215, 10876, 30004, 13, 5215, 443, 27958, 30004, 13, 3166, 1243, 1053, 1243, 29918, 5924, 30004, 13, 3166, 8062, 999, 1053, 10166, 30004, 13, 5215, 5839, 280, 30004, 13, 30004, 13, 29992, 7959, 5696, 30004, 13, 1753, 5132, 7439, 616, 29898, 9891, 29892, 334, 5085, 29892, 3579, 1989, 9303, 1125, 30004, 13, 1678, 525, 29925, 545, 5132, 16845, 310, 7687, 580, 29915, 30004, 13, 1678, 822, 716, 9891, 10456, 29888, 5085, 29892, 3579, 29888, 1989, 9303, 1125, 30004, 13, 4706, 716, 1989, 9303, 353, 29361, 29889, 8552, 26471, 13, 4706, 716, 1989, 9303, 29889, 5504, 29898, 29888, 1989, 9303, 8443, 13, 4706, 736, 3653, 10456, 29898, 5085, 718, 285, 5085, 511, 3579, 1482, 1989, 9303, 8443, 13, 1678, 716, 9891, 29889, 9891, 353, 3653, 30004, 13, 1678, 716, 9891, 29889, 5085, 353, 6389, 30004, 13, 1678, 716, 9891, 29889, 1989, 9303, 353, 29361, 30004, 13, 1678, 736, 716, 9891, 30004, 13, 30004, 13, 1753, 10446, 10456, 5085, 29892, 3579, 11022, 1125, 30004, 13, 1678, 9995, 17885, 545, 599, 2602, 284, 322, 13553, 6273, 15945, 19451, 13, 1678, 736, 6389, 29892, 9049, 30004, 13, 30004, 13, 1753, 12608, 29898, 1595, 1125, 30004, 13, 1678, 9995, 736, 278, 12608, 310, 263, 7687, 1203, 9995, 30004, 13, 1678, 736, 313, 1595, 29889, 9891, 29892, 760, 29889, 5085, 29892, 760, 29889, 1989, 9303, 29892, 760, 17255, 8977, 1649, 8443, 13, 30004, 13, 1990, 4321, 7439, 616, 29898, 348, 27958, 29889, 3057, 8259, 1125, 30004, 13, 30004, 13, 1678, 278, 1853, 353, 2090, 312, 8789, 29889, 3846, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 16121, 29918, 19057, 29898, 1311, 1125, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 29871, 29896, 29892, 29871, 29906, 29892, 263, 29922, 29896, 29900, 29892, 289, 29922, 29906, 29900, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29941, 29892, 29871, 29946, 29892, 289, 29922, 29941, 29900, 29892, 274, 29922, 29946, 29900, 511, 30004, 13, 462, 308, 5135, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29946, 511, 9657, 29898, 29874, 29922, 29896, 29900, 29892, 289, 29922, 29941, 29900, 29892, 274, 29922, 29946, 29900, 4961, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 1958, 29892, 14013, 921, 29901, 921, 29930, 29896, 29900, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 4197, 29896, 29892, 29906, 29892, 29941, 29892, 29946, 11724, 518, 29896, 29900, 29892, 29871, 29906, 29900, 29892, 29871, 29941, 29900, 29892, 29871, 29946, 29900, 2314, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 15697, 29898, 1311, 1125, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 29871, 29896, 29892, 29871, 29906, 29892, 263, 29922, 29896, 29900, 29892, 289, 29922, 29906, 29900, 8443, 13, 4706, 396, 8393, 881, 367, 19909, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29889, 9891, 29892, 10446, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29889, 5085, 29892, 313, 29896, 29892, 29871, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29889, 1989, 9303, 29892, 9657, 29898, 29874, 29922, 29896, 29900, 29892, 289, 29922, 29906, 29900, 876, 30004, 13, 4706, 396, 8393, 881, 451, 367, 2044, 519, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 731, 5552, 29892, 282, 29892, 525, 9891, 742, 2910, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 731, 5552, 29892, 282, 29892, 525, 5085, 742, 313, 29896, 29892, 29871, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 731, 5552, 29892, 282, 29892, 525, 1989, 9303, 742, 9657, 29898, 29874, 29922, 29896, 29892, 289, 29922, 29906, 876, 30004, 13, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 20970, 8443, 13, 4706, 1018, 29901, 30004, 13, 9651, 628, 282, 17255, 8977, 1649, 30004, 13, 4706, 5174, 20948, 29901, 30004, 13, 9651, 1209, 30004, 13, 4706, 1683, 29901, 30004, 13, 9651, 1583, 29889, 14057, 877, 3846, 1203, 6068, 4770, 8977, 1649, 304, 367, 11132, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 23516, 29918, 3198, 292, 29898, 1311, 1125, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 1583, 29889, 386, 300, 668, 29897, 268, 396, 817, 472, 3203, 263, 3653, 1852, 30004, 13, 4706, 1018, 29901, 30004, 13, 9651, 1583, 29889, 386, 300, 668, 29898, 29906, 29897, 26471, 13, 4706, 5174, 20948, 29901, 30004, 13, 9651, 1209, 30004, 13, 4706, 1683, 29901, 30004, 13, 9651, 1583, 29889, 14057, 877, 6730, 1852, 451, 7120, 363, 1246, 3097, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 14676, 428, 29918, 974, 29918, 4804, 414, 29918, 8977, 29918, 23516, 29898, 1311, 1125, 30004, 13, 4706, 396, 263, 24959, 29915, 29879, 8600, 881, 451, 367, 10551, 287, 491, 7687, 30004, 13, 4706, 822, 3653, 29898, 29874, 29922, 29896, 29900, 29892, 289, 29922, 29906, 29900, 1125, 30004, 13, 9651, 736, 263, 30004, 13, 4706, 270, 353, 11117, 29874, 2396, 29941, 8117, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 9891, 29892, 263, 29922, 29945, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 1068, 29881, 511, 29871, 29941, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29881, 29892, 11117, 29874, 2396, 29941, 1800, 30004, 13, 4706, 282, 29898, 29890, 29922, 29955, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29881, 29892, 11117, 29874, 2396, 29941, 1800, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1191, 29918, 510, 2109, 800, 29898, 1311, 1125, 30004, 13, 4706, 396, 15058, 4266, 775, 10898, 363, 5225, 6389, 297, 2845, 7687, 30004, 13, 4706, 396, 1203, 470, 278, 24959, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 3285, 313, 3285, 6571, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29896, 29892, 29906, 511, 5135, 29896, 29892, 29906, 511, 6571, 876, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 29871, 29896, 29892, 29871, 29906, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 3285, 5135, 29896, 29892, 29906, 511, 6571, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29941, 29892, 29946, 511, 5135, 29896, 29892, 29906, 29892, 29941, 29892, 29946, 511, 6571, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 11022, 29918, 510, 2109, 800, 29898, 1311, 1125, 30004, 13, 4706, 396, 15058, 4266, 775, 10898, 363, 694, 13553, 6389, 297, 30004, 13, 4706, 396, 2845, 278, 7687, 1203, 470, 278, 24959, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29889, 1989, 9303, 29892, 426, 1800, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 3285, 313, 3285, 6571, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29874, 29922, 29896, 511, 313, 3285, 11117, 29874, 2396, 29896, 20073, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 263, 29922, 29896, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29889, 1989, 9303, 29892, 11117, 29874, 2396, 29896, 1800, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 3285, 313, 3285, 11117, 29874, 2396, 29896, 20073, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29890, 29922, 29906, 511, 313, 3285, 11117, 29874, 2396, 29896, 29892, 525, 29890, 2396, 29906, 20073, 30004, 13, 4706, 396, 13553, 6389, 297, 278, 1246, 5712, 1906, 297, 278, 7687, 1203, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29886, 29898, 29874, 29922, 29941, 29892, 289, 29922, 29906, 511, 313, 3285, 11117, 29874, 2396, 29941, 29892, 525, 29890, 2396, 29906, 20073, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1066, 3245, 29898, 1311, 1125, 30004, 13, 4706, 396, 1207, 1854, 2602, 284, 6273, 526, 15468, 5149, 30004, 13, 4706, 363, 6389, 297, 518, 3285, 313, 29900, 29892, 511, 313, 29900, 29892, 29896, 511, 313, 29900, 29892, 29896, 29892, 29906, 511, 313, 29900, 29892, 29896, 29892, 29906, 29892, 29941, 4638, 29901, 30004, 13, 9651, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 334, 5085, 8443, 13, 9651, 3806, 353, 6389, 718, 6702, 29916, 742, 8443, 13, 9651, 2355, 29892, 4069, 353, 282, 877, 29916, 1495, 30004, 13, 9651, 1583, 29889, 9294, 5574, 29898, 9684, 1275, 2355, 322, 4069, 1275, 426, 1800, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 26766, 29898, 1311, 1125, 30004, 13, 4706, 396, 1207, 1854, 13553, 6273, 526, 15468, 5149, 30004, 13, 4706, 363, 263, 297, 6024, 29874, 742, 29871, 29900, 29892, 6213, 29892, 29871, 29941, 29889, 29945, 5387, 30004, 13, 9651, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 263, 29922, 29874, 8443, 13, 9651, 3806, 353, 11117, 29874, 2396, 29874, 5501, 29916, 2396, 8516, 8117, 13, 9651, 4069, 29892, 2355, 353, 282, 29898, 29916, 29922, 8516, 8443, 13, 9651, 1583, 29889, 9294, 5574, 29898, 9684, 1275, 2355, 322, 4069, 1275, 313, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1217, 29918, 2975, 29918, 15987, 29879, 29898, 1311, 1125, 30004, 13, 4706, 396, 1207, 1854, 727, 526, 694, 2625, 9545, 393, 6602, 15352, 5717, 30004, 13, 4706, 282, 353, 1583, 29889, 386, 300, 668, 29898, 17885, 545, 29892, 29871, 29900, 29892, 263, 29922, 29896, 8443, 13, 4706, 6389, 29896, 29892, 9049, 29896, 353, 282, 29898, 29896, 29892, 289, 29922, 29906, 8443, 13, 4706, 1583, 29889, 9294, 5574, 29898, 5085, 29896, 1275, 313, 29900, 29892, 29896, 29897, 322, 9049, 29896, 1275, 11117, 29874, 2396, 29896, 5501, 29890, 2396, 29906, 1800, 30004, 13, 4706, 6389, 29906, 29892, 9049, 29906, 353, 282, 26471, 13, 4706, 1583, 29889, 9294, 5574, 29898, 5085, 29906, 1275, 313, 29900, 29892, 29897, 322, 9049, 29906, 1275, 11117, 29874, 2396, 29896, 1800, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 2704, 29918, 7728, 351, 362, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 29898, 29916, 29892, 343, 1125, 30004, 13, 9651, 921, 849, 343, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 24214, 12596, 2459, 2392, 29892, 1583, 29889, 386, 300, 668, 29898, 29888, 29892, 29871, 29896, 29892, 29871, 29900, 876, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 24214, 12596, 2459, 2392, 29892, 1583, 29889, 386, 300, 668, 29898, 29888, 29892, 29871, 29896, 511, 29871, 29900, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 24214, 12596, 2459, 2392, 29892, 1583, 29889, 386, 300, 668, 29898, 29888, 511, 29871, 29896, 29892, 29871, 29900, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 24214, 12596, 2459, 2392, 29892, 1583, 29889, 386, 300, 668, 29898, 29888, 29892, 343, 29922, 29900, 511, 29871, 29896, 8443, 13, 30004, 13, 1678, 822, 1243, 29918, 25129, 999, 29898, 1311, 1125, 30004, 13, 4706, 285, 353, 1583, 29889, 386, 300, 668, 29898, 524, 29892, 2967, 29922, 29896, 29953, 8443, 13, 4706, 282, 353, 10166, 29898, 29888, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 29888, 29889, 9891, 29892, 282, 29889, 9891, 8443, 13, 4706, 285, 353, 6213, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 7422, 2392, 29892, 679, 5552, 29892, 282, 29892, 525, 9891, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 2541, 29918, 9917, 29918, 392, 29918, 348, 9917, 29918, 23515, 29898, 1311, 1125, 30004, 13, 4706, 848, 353, 2910, 29898, 710, 29892, 3464, 29898, 29896, 29900, 876, 30004, 13, 4706, 5988, 353, 1583, 29889, 386, 300, 668, 29898, 710, 29889, 7122, 29892, 27255, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 7122, 29898, 1272, 511, 525, 29900, 29896, 29906, 29941, 29946, 29945, 29953, 29955, 29947, 29929, 1495, 30004, 13, 4706, 5988, 353, 1583, 29889, 386, 300, 668, 877, 4286, 7122, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 7122, 29898, 1272, 511, 525, 29900, 29896, 29906, 29941, 29946, 29945, 29953, 29955, 29947, 29929, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 23945, 280, 29898, 1311, 1125, 30004, 13, 4706, 285, 353, 1583, 29889, 386, 300, 668, 29898, 4530, 1535, 29892, 525, 294, 2176, 742, 2594, 29922, 5574, 8443, 13, 4706, 285, 29889, 1202, 29918, 14481, 29918, 517, 1649, 8977, 1649, 353, 5852, 30004, 13, 4706, 363, 17814, 297, 3464, 29898, 23945, 280, 29889, 29950, 6259, 9606, 1254, 29918, 8618, 4986, 15032, 718, 29871, 29896, 1125, 30004, 13, 9651, 285, 29918, 8552, 353, 5839, 280, 29889, 18132, 29898, 23945, 280, 29889, 29881, 17204, 29898, 29888, 29892, 17814, 876, 30004, 13, 9651, 1583, 29889, 9294, 9843, 29898, 4530, 1535, 29898, 29888, 511, 12608, 29898, 29888, 29918, 8552, 876, 30004, 13, 30004, 13, 1678, 396, 26246, 29871, 29953, 29900, 29947, 29941, 29901, 12105, 21248, 6494, 30004, 13, 1678, 822, 1243, 29918, 842, 3859, 29918, 999, 2798, 29898, 1311, 1125, 30004, 13, 4706, 770, 9178, 20529, 29901, 30004, 13, 9651, 822, 4770, 2435, 12035, 1311, 1125, 30004, 13, 18884, 736, 29871, 29946, 30004, 13, 9651, 822, 4770, 657, 667, 12035, 1311, 29892, 1820, 1125, 30004, 13, 18884, 565, 1820, 1275, 29871, 29900, 29901, 30004, 13, 462, 1678, 736, 4236, 30004, 13, 18884, 25342, 1820, 1275, 29871, 29896, 29901, 30004, 13, 462, 1678, 736, 18761, 29898, 3881, 29898, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 876, 30004, 13, 18884, 25342, 1820, 297, 313, 29906, 29892, 29871, 29941, 1125, 30004, 13, 462, 1678, 736, 6571, 30004, 13, 18884, 12020, 11374, 2392, 30004, 13, 30004, 13, 4706, 285, 353, 1583, 29889, 386, 300, 668, 29898, 3318, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 3924, 2392, 29892, 285, 17255, 842, 3859, 1649, 29892, 9178, 20529, 3101, 30004, 13, 30004, 13, 1990, 3455, 616, 4035, 1990, 29898, 7692, 312, 8789, 29889, 3846, 1125, 30004, 13, 1678, 1209, 30004, 13, 30004, 13, 1990, 4321, 7439, 616, 4035, 1990, 29898, 3057, 7439, 616, 1125, 30004, 13, 30004, 13, 1678, 278, 1853, 353, 3455, 616, 4035, 1990, 30004, 13, 30004, 13, 1990, 4321, 11980, 7439, 616, 29898, 3057, 7439, 616, 1125, 30004, 13, 30004, 13, 1678, 278, 1853, 353, 5132, 7439, 616, 30004, 13, 30004, 13, 1678, 396, 278, 3017, 1873, 3508, 29915, 29873, 5839, 29880, 519, 30004, 13, 1678, 1243, 29918, 23945, 280, 353, 1243, 29918, 842, 3859, 29918, 999, 2798, 353, 6213, 30004, 13, 30004, 13, 1678, 396, 278, 3017, 1873, 3508, 29915, 29873, 263, 1134, 30004, 13, 1678, 1243, 29918, 15697, 353, 6213, 30004, 13, 30004, 13, 1990, 4321, 6422, 15646, 29898, 348, 27958, 29889, 3057, 8259, 1125, 30004, 13, 30004, 13, 1678, 822, 1423, 29918, 17699, 29898, 1311, 29892, 14476, 29892, 21021, 11167, 13, 462, 418, 9859, 29922, 7692, 312, 8789, 29889, 9980, 3301, 13171, 29918, 22933, 17298, 13780, 29903, 11167, 13, 462, 418, 4784, 29922, 7692, 312, 8789, 29889, 9980, 3301, 13171, 29918, 4897, 25832, 2890, 1125, 30004, 13, 4706, 396, 5399, 8393, 892, 9859, 30004, 13, 4706, 363, 1024, 297, 9859, 29901, 30004, 13, 9651, 1583, 29889, 9294, 5574, 29898, 657, 5552, 29898, 17699, 29892, 1024, 29897, 338, 679, 5552, 29898, 29893, 336, 2986, 29892, 1024, 876, 30004, 13, 4706, 396, 5399, 8393, 892, 4784, 30004, 13, 4706, 363, 1024, 297, 4784, 29901, 30004, 13, 9651, 14476, 29918, 5552, 353, 679, 5552, 29898, 17699, 29892, 1024, 8443, 13, 9651, 21021, 29918, 5552, 353, 679, 5552, 29898, 29893, 336, 2986, 29892, 1024, 8443, 13, 9651, 363, 1820, 297, 21021, 29918, 5552, 29901, 30004, 13, 18884, 1583, 29889, 9294, 5574, 29898, 29893, 336, 2986, 29918, 5552, 29961, 1989, 29962, 338, 14476, 29918, 5552, 29961, 1989, 2314, 30004, 13, 30004, 13, 1678, 822, 903, 4381, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 9995, 4013, 338, 263, 1243, 15945, 19451, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 884, 263, 1243, 29915, 30004, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 2090, 312, 8789, 29889, 5504, 29918, 17699, 29898, 17699, 29892, 285, 8443, 13, 4706, 736, 14476, 29892, 285, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 4381, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 14476, 29892, 285, 353, 1583, 3032, 4381, 29918, 5504, 26471, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 29888, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 5552, 29892, 525, 4013, 338, 884, 263, 1243, 1495, 30004, 13, 30004, 13, 1678, 732, 348, 27958, 29889, 11014, 3644, 29898, 9675, 29889, 15764, 29889, 20640, 675, 6736, 29871, 29906, 11167, 13, 462, 268, 376, 14526, 19651, 526, 25811, 411, 448, 29949, 29906, 322, 2038, 1159, 30004, 13, 1678, 822, 1243, 29918, 4381, 29918, 5504, 29918, 1514, 29898, 1311, 1125, 30004, 13, 4706, 14476, 29892, 285, 353, 1583, 3032, 4381, 29918, 5504, 26471, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 525, 4013, 338, 263, 1243, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1217, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 9995, 4013, 338, 263, 1243, 15945, 19451, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 884, 263, 1243, 29915, 30004, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 2090, 312, 8789, 29889, 5504, 29918, 17699, 29898, 17699, 29892, 285, 29892, 313, 511, 313, 876, 30004, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 29892, 313, 511, 313, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 17699, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 6213, 8443, 13, 4706, 1583, 29889, 9294, 8824, 29898, 5349, 5552, 29898, 17699, 29892, 525, 5552, 8785, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 2622, 573, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 263, 1422, 1243, 29915, 30004, 13, 4706, 285, 29889, 8977, 29918, 5552, 353, 9657, 29898, 29874, 29922, 29896, 29892, 289, 29922, 29906, 29892, 274, 29922, 29941, 8443, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 14476, 29889, 8977, 29918, 5552, 353, 6571, 30004, 13, 4706, 3566, 353, 6702, 5552, 742, 8443, 13, 4706, 2767, 353, 6702, 8977, 29918, 5552, 742, 8443, 13, 4706, 2090, 312, 8789, 29889, 5504, 29918, 17699, 29898, 17699, 29892, 285, 29892, 3566, 29892, 2767, 8443, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 29892, 3566, 29892, 2767, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 17699, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 6213, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 5552, 29892, 525, 4013, 338, 263, 1422, 1243, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 8977, 29918, 5552, 29892, 285, 29889, 8977, 29918, 5552, 8443, 13, 30004, 13, 1678, 732, 1688, 29918, 5924, 29889, 276, 339, 2658, 29918, 1514, 19651, 30004, 13, 1678, 822, 1243, 29918, 16145, 262, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 396, 4321, 363, 6494, 396, 29896, 29945, 29955, 29953, 29906, 29946, 29896, 30004, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 2090, 312, 8789, 29889, 5504, 29918, 17699, 29898, 17699, 29892, 4236, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 3317, 1495, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 17699, 17255, 1514, 26914, 27382, 2541, 877, 3317, 877, 876, 30004, 13, 30004, 13, 1990, 4321, 29956, 336, 567, 29898, 3057, 6422, 15646, 1125, 30004, 13, 30004, 13, 1678, 822, 903, 4381, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 9995, 4013, 338, 263, 1243, 15945, 19451, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 884, 263, 1243, 29915, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 29893, 336, 567, 29898, 29888, 8443, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 8443, 13, 4706, 736, 14476, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 4381, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 14476, 353, 1583, 3032, 4381, 29918, 5504, 26471, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 29888, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 5552, 29892, 525, 4013, 338, 884, 263, 1243, 1495, 30004, 13, 30004, 13, 1678, 732, 348, 27958, 29889, 11014, 3644, 29898, 9675, 29889, 15764, 29889, 20640, 675, 6736, 29871, 29906, 11167, 13, 462, 268, 376, 14526, 19651, 526, 25811, 411, 448, 29949, 29906, 322, 2038, 1159, 30004, 13, 1678, 822, 1243, 29918, 4381, 29918, 5504, 29918, 1514, 29898, 1311, 1125, 30004, 13, 4706, 14476, 353, 1583, 3032, 4381, 29918, 5504, 26471, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 525, 4013, 338, 263, 1243, 1495, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1217, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 9995, 4013, 338, 263, 1243, 15945, 19451, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 884, 263, 1243, 29915, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 29893, 336, 567, 29898, 29888, 29892, 313, 511, 313, 876, 30004, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 29892, 313, 511, 313, 876, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 17699, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 6213, 8443, 13, 4706, 1583, 29889, 9294, 8824, 29898, 5349, 5552, 29898, 17699, 29892, 525, 5552, 8785, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 2622, 573, 29918, 5504, 29898, 1311, 1125, 30004, 13, 4706, 822, 285, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 285, 29889, 5552, 353, 525, 4013, 338, 263, 1422, 1243, 29915, 30004, 13, 4706, 285, 29889, 8977, 29918, 5552, 353, 9657, 29898, 29874, 29922, 29896, 29892, 289, 29922, 29906, 29892, 274, 29922, 29941, 8443, 13, 4706, 822, 788, 29918, 8977, 29918, 5552, 29898, 29888, 1125, 30004, 13, 9651, 285, 29889, 8977, 29918, 5552, 353, 6571, 30004, 13, 9651, 736, 285, 30004, 13, 4706, 3566, 353, 6702, 5552, 742, 8443, 13, 4706, 2767, 353, 6702, 8977, 29918, 5552, 742, 8443, 13, 4706, 732, 7692, 312, 8789, 29889, 29893, 336, 567, 29898, 29888, 29892, 3566, 29892, 2767, 8443, 13, 4706, 732, 1202, 29918, 8977, 29918, 5552, 30004, 13, 4706, 822, 14476, 7295, 30004, 13, 9651, 1209, 30004, 13, 4706, 1583, 29889, 3198, 29918, 17699, 29898, 17699, 29892, 285, 29892, 3566, 29892, 2767, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 978, 1649, 29892, 525, 17699, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 17255, 1514, 1649, 29892, 6213, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 5552, 29892, 525, 4013, 338, 263, 1422, 1243, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17699, 29889, 8977, 29918, 5552, 29892, 285, 29889, 8977, 29918, 5552, 8443, 13, 30004, 13, 30004, 13, 1990, 4321, 29934, 6085, 346, 29898, 348, 27958, 29889, 3057, 8259, 1125, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 17469, 29898, 1311, 1125, 30004, 13, 4706, 770, 317, 339, 5114, 29901, 30004, 13, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 4236, 1125, 30004, 13, 18884, 1583, 29889, 3317, 353, 4236, 30004, 13, 18884, 1583, 29889, 578, 15641, 353, 5159, 30004, 13, 30004, 13, 9651, 822, 4770, 2435, 12035, 1311, 1125, 736, 7431, 29898, 1311, 29889, 578, 15641, 8443, 13, 30004, 13, 9651, 822, 4770, 657, 667, 12035, 1311, 29892, 474, 1125, 30004, 13, 18884, 565, 451, 29871, 29900, 5277, 474, 529, 1583, 29889, 3317, 29901, 12020, 11374, 2392, 30004, 13, 18884, 302, 353, 7431, 29898, 1311, 29889, 578, 15641, 8443, 13, 18884, 1550, 302, 5277, 474, 29901, 30004, 13, 462, 1678, 1583, 29889, 578, 15641, 29889, 4397, 29898, 29876, 29930, 29876, 8443, 13, 462, 1678, 302, 4619, 29871, 29896, 30004, 13, 18884, 736, 1583, 29889, 578, 15641, 29961, 29875, 29962, 30004, 13, 30004, 13, 4706, 10032, 353, 2090, 312, 8789, 29889, 17469, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 2892, 921, 29892, 343, 29901, 921, 29974, 29891, 29892, 6024, 29874, 742, 525, 29890, 742, 525, 29883, 7464, 525, 5477, 525, 10736, 1495, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 30004, 13, 9651, 10032, 29898, 2892, 921, 29892, 343, 29901, 921, 29974, 29891, 29892, 518, 1839, 29874, 742, 525, 29883, 7464, 19997, 6024, 29881, 742, 525, 29893, 2033, 1402, 5159, 511, 30004, 13, 9651, 6024, 29874, 3788, 29883, 3788, 29881, 3788, 29893, 2033, 30004, 13, 4706, 1723, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 2892, 921, 29892, 343, 29901, 921, 29930, 29891, 29892, 3464, 29898, 29906, 29892, 29947, 511, 29871, 29896, 511, 29871, 29945, 29900, 29946, 29900, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 30004, 13, 9651, 10032, 29898, 2892, 921, 29892, 343, 29901, 921, 29930, 29891, 29892, 3464, 29898, 29906, 29892, 29906, 29896, 511, 29871, 29896, 29931, 511, 30004, 13, 632, 29906, 29946, 29941, 29906, 29929, 29900, 29906, 29900, 29900, 29947, 29896, 29955, 29953, 29953, 29946, 29900, 29900, 29900, 29900, 29931, 30004, 13, 4706, 1723, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 2892, 921, 29892, 343, 29901, 921, 29974, 29891, 29892, 317, 339, 5114, 29898, 29896, 29900, 8243, 29871, 29906, 29947, 29945, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 2892, 921, 29892, 343, 29901, 921, 29974, 29891, 29892, 317, 339, 5114, 29898, 29896, 29900, 511, 29871, 29900, 511, 29871, 29906, 29947, 29945, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 2892, 921, 29892, 343, 29901, 921, 29974, 29891, 29892, 317, 339, 5114, 29898, 29900, 511, 29871, 29900, 511, 29871, 29900, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 10032, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 10032, 29892, 29871, 29946, 29906, 29892, 29871, 29946, 29906, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 10032, 29892, 29871, 29946, 29906, 29892, 29871, 29946, 29906, 29892, 29871, 29946, 29906, 8443, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 29946, 29906, 29892, 376, 29896, 4968, 376, 29896, 1159, 396, 3653, 338, 2360, 2000, 411, 697, 2944, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 17469, 29898, 29946, 29906, 29892, 12633, 376, 29896, 4968, 376, 29896, 1159, 396, 3653, 338, 2360, 2000, 411, 697, 2944, 30004, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 10032, 29892, 29871, 29946, 29906, 29892, 313, 29946, 29906, 29892, 29871, 29946, 29906, 876, 30004, 13, 30004, 13, 1990, 4321, 29907, 1526, 1762, 2558, 29898, 348, 27958, 29889, 3057, 8259, 1125, 30004, 13, 1678, 822, 1243, 29918, 21058, 29918, 517, 29918, 1989, 29898, 1311, 1125, 30004, 13, 4706, 822, 590, 21058, 29898, 29916, 29892, 343, 1125, 30004, 13, 9651, 736, 343, 448, 921, 30004, 13, 4706, 1583, 29889, 9294, 9843, 29898, 24582, 29898, 3881, 29898, 29945, 511, 1820, 29922, 7692, 312, 8789, 29889, 21058, 29918, 517, 29918, 1989, 29898, 1357, 21058, 8243, 30004, 13, 462, 308, 518, 29946, 29892, 29871, 29941, 29892, 29871, 29906, 29892, 29871, 29896, 29892, 29871, 29900, 2314, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 8568, 29898, 1311, 1125, 30004, 13, 4706, 822, 590, 21058, 29898, 29916, 29892, 343, 1125, 30004, 13, 9651, 736, 343, 448, 921, 30004, 13, 4706, 1820, 353, 2090, 312, 8789, 29889, 21058, 29918, 517, 29918, 1989, 29898, 1357, 21058, 8443, 13, 4706, 413, 353, 1820, 29898, 29896, 29900, 8443, 13, 4706, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 29892, 6608, 29898, 29895, 876, 30004, 13, 30004, 13, 1990, 4321, 11536, 7514, 292, 29898, 348, 27958, 29889, 3057, 8259, 1125, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 7827, 29918, 2098, 292, 29918, 1896, 29898, 1311, 1125, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 319, 29901, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 995, 1125, 30004, 13, 18884, 1583, 29889, 1767, 353, 995, 30004, 13, 9651, 822, 4770, 1896, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 529, 916, 29889, 1767, 30004, 13, 9651, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 1275, 916, 29889, 1767, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 529, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 1405, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29906, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 7827, 29918, 2098, 292, 29918, 280, 29898, 1311, 1125, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 319, 29901, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 995, 1125, 30004, 13, 18884, 1583, 29889, 1767, 353, 995, 30004, 13, 9651, 822, 4770, 280, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 5277, 916, 29889, 1767, 30004, 13, 9651, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 1275, 916, 29889, 1767, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 529, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 1405, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29906, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 7827, 29918, 2098, 292, 29918, 4141, 29898, 1311, 1125, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 319, 29901, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 995, 1125, 30004, 13, 18884, 1583, 29889, 1767, 353, 995, 30004, 13, 9651, 822, 4770, 4141, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 1405, 916, 29889, 1767, 30004, 13, 9651, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 1275, 916, 29889, 1767, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 529, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 1405, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29906, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 7827, 29918, 2098, 292, 29918, 479, 29898, 1311, 1125, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 319, 29901, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 995, 1125, 30004, 13, 18884, 1583, 29889, 1767, 353, 995, 30004, 13, 9651, 822, 4770, 479, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 6736, 916, 29889, 1767, 30004, 13, 9651, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 736, 1583, 29889, 1767, 1275, 916, 29889, 1767, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 529, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 1405, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29896, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29896, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 5277, 319, 29898, 29906, 876, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 29898, 29906, 29897, 6736, 319, 29898, 29906, 876, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 7827, 29918, 2098, 292, 29918, 1217, 29918, 957, 3539, 29898, 1311, 1125, 30004, 13, 4706, 396, 716, 3519, 881, 451, 26556, 5923, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 319, 29898, 710, 1125, 30004, 13, 9651, 1209, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29874, 1159, 529, 319, 703, 29890, 5783, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29890, 1159, 1405, 319, 703, 29874, 5783, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29874, 1159, 5277, 319, 703, 29890, 5783, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29890, 1159, 6736, 319, 703, 29874, 5783, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29890, 1159, 5277, 319, 703, 29890, 5783, 30004, 13, 4706, 1583, 29889, 9294, 5574, 29898, 29909, 703, 29890, 1159, 6736, 319, 703, 29890, 5783, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 1217, 29918, 3372, 800, 29918, 12119, 29898, 1311, 1125, 30004, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1917, 2392, 1125, 30004, 13, 9651, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 9651, 770, 319, 29901, 30004, 13, 18884, 1209, 30004, 13, 30004, 13, 1678, 822, 1243, 29918, 6152, 29918, 29896, 29900, 29900, 29946, 29906, 29898, 1311, 1125, 30004, 13, 4706, 732, 7692, 312, 8789, 29889, 7827, 29918, 2098, 292, 30004, 13, 4706, 770, 4321, 4986, 29901, 30004, 13, 9651, 822, 4770, 2344, 12035, 1311, 29892, 995, 1125, 30004, 13, 18884, 1583, 29889, 1767, 353, 995, 30004, 13, 9651, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 565, 338, 8758, 29898, 1228, 29892, 4321, 4986, 1125, 30004, 13, 462, 1678, 736, 1583, 29889, 1767, 1275, 916, 29889, 1767, 30004, 13, 18884, 736, 7700, 30004, 13, 9651, 822, 4770, 1896, 12035, 1311, 29892, 916, 1125, 30004, 13, 18884, 565, 338, 8758, 29898, 1228, 29892, 4321, 4986, 1125, 30004, 13, 462, 1678, 736, 1583, 29889, 1767, 529, 916, 29889, 1767, 30004, 13, 18884, 12020, 20948, 30004, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1542, 2392, 1125, 30004, 13, 9651, 4321, 4986, 29898, 29947, 29897, 5277, 3861, 30004, 13, 30004, 13, 1753, 1243, 29918, 3396, 29898, 369, 15828, 29922, 8516, 1125, 30004, 13, 1678, 1243, 29918, 13203, 353, 313, 30004, 13, 4706, 4321, 7439, 616, 11167, 13, 4706, 4321, 7439, 616, 4035, 1990, 11167, 13, 4706, 4321, 11980, 7439, 616, 11167, 13, 4706, 4321, 6422, 15646, 11167, 13, 4706, 4321, 11536, 7514, 292, 11167, 13, 4706, 4321, 29956, 336, 567, 11167, 13, 4706, 4321, 29934, 6085, 346, 11167, 13, 1678, 1723, 30004, 13, 1678, 1243, 29918, 5924, 29889, 3389, 29918, 348, 27958, 10456, 1688, 29918, 13203, 8443, 13, 30004, 13, 1678, 396, 11539, 3407, 21248, 30004, 13, 1678, 565, 26952, 322, 756, 5552, 29898, 9675, 29892, 376, 657, 7827, 999, 2798, 29908, 1125, 30004, 13, 4706, 1053, 330, 29883, 30004, 13, 4706, 18139, 353, 518, 8516, 29962, 334, 29871, 29945, 30004, 13, 4706, 363, 474, 297, 921, 3881, 29898, 2435, 29898, 2798, 29879, 22164, 30004, 13, 9651, 1243, 29918, 5924, 29889, 3389, 29918, 348, 27958, 10456, 1688, 29918, 13203, 8443, 13, 9651, 330, 29883, 29889, 15914, 26471, 13, 9651, 18139, 29961, 29875, 29962, 353, 10876, 29889, 657, 7827, 999, 2798, 26471, 13, 4706, 1596, 18139, 30004, 13, 30004, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 30004, 13, 1678, 1243, 29918, 3396, 29898, 369, 15828, 29922, 5574, 8443, 13, 2 ]
rdkit/ML/InfoTheory/BitRank.py
kazuyaujihara/rdkit
1,609
9818
<filename>rdkit/ML/InfoTheory/BitRank.py # # Copyright (C) 2001,2002,2003 <NAME> and Rational Discovery LLC # """ Functionality for ranking bits using info gains **Definitions used in this module** - *sequence*: an object capable of containing other objects which supports __getitem__() and __len__(). Examples of these include lists, tuples, and Numeric arrays. - *IntVector*: an object containing integers which supports __getitem__() and __len__(). Examples include lists, tuples, Numeric Arrays, and BitVects. **NOTE**: Neither *sequences* nor *IntVectors* need to support item assignment. It is perfectly acceptable for them to be read-only, so long as they are random-access. """ import numpy from rdkit.ML.InfoTheory import entropy def FormCounts(bitVects, actVals, whichBit, nPossibleActs, nPossibleBitVals=2): """ generates the counts matrix for a particular bit **Arguments** - bitVects: a *sequence* containing *IntVectors* - actVals: a *sequence* - whichBit: an integer, the bit number to use. - nPossibleActs: the (integer) number of possible activity values. - nPossibleBitVals: (optional) if specified, this integer provides the maximum value attainable by the (increasingly inaccurately named) bits in _bitVects_. **Returns** a Numeric array with the counts **Notes** This is really intended for internal use. """ if len(bitVects) != len(actVals): raise ValueError('var and activity lists should be the same length') res = numpy.zeros((nPossibleBitVals, nPossibleActs), numpy.integer) for i in range(len(bitVects)): res[bitVects[i][whichBit], actVals[i]] += 1 return res def CalcInfoGains(bitVects, actVals, nPossibleActs, nPossibleBitVals=2): """ Calculates the information gain for a set of points and activity values **Arguments** - bitVects: a *sequence* containing *IntVectors* - actVals: a *sequence* - nPossibleActs: the (integer) number of possible activity values. - nPossibleBitVals: (optional) if specified, this integer provides the maximum value attainable by the (increasingly inaccurately named) bits in _bitVects_. **Returns** a list of floats """ if len(bitVects) != len(actVals): raise ValueError('var and activity lists should be the same length') nBits = len(bitVects[0]) res = numpy.zeros(nBits, numpy.float) for bit in range(nBits): counts = FormCounts(bitVects, actVals, bit, nPossibleActs, nPossibleBitVals=nPossibleBitVals) res[bit] = entropy.InfoGain(counts) return res def RankBits(bitVects, actVals, nPossibleBitVals=2, metricFunc=CalcInfoGains): """ Rank a set of bits according to a metric function **Arguments** - bitVects: a *sequence* containing *IntVectors* - actVals: a *sequence* - nPossibleBitVals: (optional) if specified, this integer provides the maximum value attainable by the (increasingly inaccurately named) bits in _bitVects_. - metricFunc: (optional) the metric function to be used. See _CalcInfoGains()_ for a description of the signature of this function. **Returns** A 2-tuple containing: - the relative order of the bits (a list of ints) - the metric calculated for each bit (a list of floats) """ nPossibleActs = max(actVals) + 1 metrics = metricFunc(bitVects, actVals, nPossibleActs, nPossibleBitVals=nPossibleBitVals) bitOrder = list(numpy.argsort(metrics)) bitOrder.reverse() return bitOrder, metrics def AnalyzeSparseVects(bitVects, actVals): """ #DOC **Arguments** - bitVects: a *sequence* containing SBVs - actVals: a *sequence* **Returns** a list of floats **Notes** - these need to be bit vects and binary activities """ nPts = len(bitVects) if nPts != len(actVals): raise ValueError('var and activity lists should be the same length') nBits = bitVects[0].GetSize() actives = numpy.zeros(nBits, numpy.integer) inactives = numpy.zeros(nBits, numpy.integer) nActives, nInactives = 0, 0 for i in range(nPts): sig, act = bitVects[i], actVals[i] onBitList = sig.GetOnBits() if act: for bit in onBitList: actives[bit] += 1 nActives += 1 else: for bit in onBitList: inactives[bit] += 1 nInactives += 1 resTbl = numpy.zeros((2, 2), numpy.integer) res = [] gains = [] for bit in range(nBits): nAct, nInact = actives[bit], inactives[bit] if nAct or nInact: resTbl[0, 0] = nAct resTbl[1, 0] = nPts - nAct resTbl[0, 1] = nInact resTbl[1, 1] = nPts - nInact gain = entropy.InfoGain(resTbl) gains.append(gain) res.append((bit, gain, nAct, nInact)) return res, gains def SparseRankBits(bitVects, actVals, metricFunc=AnalyzeSparseVects): """ Rank a set of bits according to a metric function **Arguments** - bitVects: a *sequence* containing SBVs - actVals: a *sequence* - metricFunc: (optional) the metric function to be used. See _SparseCalcInfoGains()_ for a description of the signature of this function. **Returns** A 2-tuple containing: - the relative order of the bits (a list of ints) - the metric calculated for each bit (a list of floats) **Notes** - these need to be bit vects and binary activities """ info, metrics = metricFunc(bitVects, actVals) bitOrder = list(numpy.argsort(metrics)) bitOrder.reverse() return bitOrder, info
[ 1, 529, 9507, 29958, 5499, 7354, 29914, 1988, 29914, 3401, 1576, 706, 29914, 21591, 29934, 804, 29889, 2272, 13, 29937, 13, 29937, 29871, 14187, 1266, 313, 29907, 29897, 29871, 29906, 29900, 29900, 29896, 29892, 29906, 29900, 29900, 29906, 29892, 29906, 29900, 29900, 29941, 29871, 529, 5813, 29958, 322, 390, 1288, 8565, 22205, 365, 12182, 13, 29937, 13, 15945, 29908, 6680, 2877, 363, 24034, 9978, 773, 5235, 330, 2708, 13, 13, 3579, 3206, 262, 2187, 1304, 297, 445, 3883, 1068, 13, 13, 1678, 448, 334, 16506, 29930, 29901, 385, 1203, 15390, 310, 6943, 916, 3618, 607, 11286, 13, 418, 4770, 657, 667, 1649, 580, 322, 4770, 2435, 1649, 2141, 29871, 1222, 9422, 310, 1438, 3160, 8857, 29892, 5291, 2701, 29892, 322, 13, 418, 405, 25099, 7049, 29889, 13, 13, 1678, 448, 334, 2928, 12877, 29930, 29901, 385, 1203, 6943, 11920, 607, 11286, 4770, 657, 667, 1649, 580, 322, 13, 539, 4770, 2435, 1649, 2141, 1222, 9422, 3160, 8857, 29892, 5291, 2701, 29892, 405, 25099, 4398, 29879, 29892, 322, 18531, 29963, 522, 29879, 29889, 13, 13, 13, 3579, 12256, 29923, 1068, 29901, 2448, 2121, 334, 6831, 2063, 29930, 3643, 334, 2928, 29963, 11142, 29930, 817, 304, 2304, 2944, 12827, 29889, 13, 259, 739, 338, 7970, 22691, 363, 963, 304, 367, 1303, 29899, 6194, 29892, 577, 1472, 408, 896, 526, 13, 259, 4036, 29899, 5943, 29889, 13, 13, 15945, 29908, 13, 5215, 12655, 13, 13, 3166, 364, 29881, 7354, 29889, 1988, 29889, 3401, 1576, 706, 1053, 24687, 13, 13, 13, 1753, 3812, 3981, 29879, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 607, 21591, 29892, 302, 9135, 1687, 2865, 29879, 29892, 302, 9135, 1687, 21591, 29963, 1338, 29922, 29906, 1125, 13, 29871, 9995, 16785, 278, 18139, 4636, 363, 263, 3153, 2586, 13, 13, 29871, 3579, 26915, 1068, 13, 13, 1678, 448, 2586, 29963, 522, 29879, 29901, 263, 334, 16506, 29930, 6943, 334, 2928, 29963, 11142, 29930, 13, 13, 1678, 448, 1044, 29963, 1338, 29901, 263, 334, 16506, 29930, 13, 13, 1678, 448, 607, 21591, 29901, 385, 6043, 29892, 278, 2586, 1353, 304, 671, 29889, 13, 13, 1678, 448, 302, 9135, 1687, 2865, 29879, 29901, 278, 313, 16031, 29897, 1353, 310, 1950, 6354, 1819, 29889, 13, 13, 1678, 448, 302, 9135, 1687, 21591, 29963, 1338, 29901, 313, 25253, 29897, 565, 6790, 29892, 445, 6043, 8128, 278, 7472, 13, 418, 995, 1098, 475, 519, 491, 278, 313, 262, 1037, 5832, 368, 297, 562, 2764, 2486, 4257, 29897, 9978, 297, 903, 2966, 29963, 522, 29879, 5396, 13, 13, 29871, 3579, 11609, 29879, 1068, 13, 13, 1678, 263, 405, 25099, 1409, 411, 278, 18139, 13, 13, 29871, 3579, 3664, 267, 1068, 13, 13, 1678, 910, 338, 2289, 9146, 363, 7463, 671, 29889, 13, 13, 29871, 9995, 13, 29871, 565, 7431, 29898, 2966, 29963, 522, 29879, 29897, 2804, 7431, 29898, 627, 29963, 1338, 1125, 13, 1678, 12020, 7865, 2392, 877, 1707, 322, 6354, 8857, 881, 367, 278, 1021, 3309, 1495, 13, 29871, 620, 353, 12655, 29889, 3298, 359, 3552, 29876, 9135, 1687, 21591, 29963, 1338, 29892, 302, 9135, 1687, 2865, 29879, 511, 12655, 29889, 16031, 29897, 13, 29871, 363, 474, 297, 3464, 29898, 2435, 29898, 2966, 29963, 522, 29879, 22164, 13, 1678, 620, 29961, 2966, 29963, 522, 29879, 29961, 29875, 3816, 4716, 21591, 1402, 1044, 29963, 1338, 29961, 29875, 5262, 4619, 29871, 29896, 13, 29871, 736, 620, 13, 13, 13, 1753, 3037, 29883, 3401, 29954, 2708, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 302, 9135, 1687, 2865, 29879, 29892, 302, 9135, 1687, 21591, 29963, 1338, 29922, 29906, 1125, 13, 29871, 9995, 29871, 20535, 1078, 278, 2472, 11581, 363, 263, 731, 310, 3291, 322, 6354, 1819, 13, 13, 29871, 3579, 26915, 1068, 13, 13, 1678, 448, 2586, 29963, 522, 29879, 29901, 263, 334, 16506, 29930, 6943, 334, 2928, 29963, 11142, 29930, 13, 13, 1678, 448, 1044, 29963, 1338, 29901, 263, 334, 16506, 29930, 13, 13, 1678, 448, 302, 9135, 1687, 2865, 29879, 29901, 278, 313, 16031, 29897, 1353, 310, 1950, 6354, 1819, 29889, 13, 13, 1678, 448, 302, 9135, 1687, 21591, 29963, 1338, 29901, 313, 25253, 29897, 565, 6790, 29892, 445, 6043, 8128, 278, 7472, 13, 418, 995, 1098, 475, 519, 491, 278, 313, 262, 1037, 5832, 368, 297, 562, 2764, 2486, 4257, 29897, 9978, 297, 903, 2966, 29963, 522, 29879, 5396, 13, 13, 259, 3579, 11609, 29879, 1068, 13, 13, 268, 263, 1051, 310, 5685, 1446, 13, 13, 29871, 9995, 13, 29871, 565, 7431, 29898, 2966, 29963, 522, 29879, 29897, 2804, 7431, 29898, 627, 29963, 1338, 1125, 13, 1678, 12020, 7865, 2392, 877, 1707, 322, 6354, 8857, 881, 367, 278, 1021, 3309, 1495, 13, 29871, 302, 29933, 1169, 353, 7431, 29898, 2966, 29963, 522, 29879, 29961, 29900, 2314, 13, 29871, 620, 353, 12655, 29889, 3298, 359, 29898, 29876, 29933, 1169, 29892, 12655, 29889, 7411, 29897, 13, 13, 29871, 363, 2586, 297, 3464, 29898, 29876, 29933, 1169, 1125, 13, 1678, 18139, 353, 3812, 3981, 29879, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 2586, 29892, 302, 9135, 1687, 2865, 29879, 29892, 302, 9135, 1687, 21591, 29963, 1338, 29922, 29876, 9135, 1687, 21591, 29963, 1338, 29897, 13, 1678, 620, 29961, 2966, 29962, 353, 24687, 29889, 3401, 29954, 475, 29898, 2798, 29879, 29897, 13, 29871, 736, 620, 13, 13, 13, 1753, 22125, 29933, 1169, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 302, 9135, 1687, 21591, 29963, 1338, 29922, 29906, 29892, 12714, 14400, 29922, 7856, 29883, 3401, 29954, 2708, 1125, 13, 29871, 9995, 22125, 263, 731, 310, 9978, 5034, 304, 263, 12714, 740, 13, 13, 29871, 3579, 26915, 1068, 13, 13, 1678, 448, 2586, 29963, 522, 29879, 29901, 263, 334, 16506, 29930, 6943, 334, 2928, 29963, 11142, 29930, 13, 13, 1678, 448, 1044, 29963, 1338, 29901, 263, 334, 16506, 29930, 13, 13, 1678, 448, 302, 9135, 1687, 21591, 29963, 1338, 29901, 313, 25253, 29897, 565, 6790, 29892, 445, 6043, 8128, 278, 7472, 13, 418, 995, 1098, 475, 519, 491, 278, 313, 262, 1037, 5832, 368, 297, 562, 2764, 2486, 4257, 29897, 9978, 297, 903, 2966, 29963, 522, 29879, 5396, 13, 13, 1678, 448, 12714, 14400, 29901, 313, 25253, 29897, 278, 12714, 740, 304, 367, 1304, 29889, 29871, 2823, 903, 7856, 29883, 3401, 29954, 2708, 580, 29918, 13, 418, 363, 263, 6139, 310, 278, 12608, 310, 445, 740, 29889, 13, 13, 259, 3579, 11609, 29879, 1068, 13, 13, 268, 319, 29871, 29906, 29899, 23583, 6943, 29901, 13, 13, 539, 448, 278, 6198, 1797, 310, 278, 9978, 313, 29874, 1051, 310, 938, 29879, 29897, 13, 13, 539, 448, 278, 12714, 12833, 363, 1269, 2586, 313, 29874, 1051, 310, 5685, 1446, 29897, 13, 13, 29871, 9995, 13, 29871, 302, 9135, 1687, 2865, 29879, 353, 4236, 29898, 627, 29963, 1338, 29897, 718, 29871, 29896, 13, 29871, 21556, 353, 12714, 14400, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 302, 9135, 1687, 2865, 29879, 29892, 302, 9135, 1687, 21591, 29963, 1338, 29922, 29876, 9135, 1687, 21591, 29963, 1338, 29897, 13, 29871, 2586, 7514, 353, 1051, 29898, 23749, 29889, 5085, 441, 29898, 2527, 10817, 876, 13, 29871, 2586, 7514, 29889, 24244, 580, 13, 29871, 736, 2586, 7514, 29892, 21556, 13, 13, 13, 1753, 11597, 29891, 911, 29903, 5510, 29963, 522, 29879, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 1125, 13, 29871, 9995, 396, 28665, 13, 13, 29871, 3579, 26915, 1068, 13, 13, 1678, 448, 2586, 29963, 522, 29879, 29901, 263, 334, 16506, 29930, 6943, 317, 29933, 29963, 29879, 13, 13, 1678, 448, 1044, 29963, 1338, 29901, 263, 334, 16506, 29930, 13, 13, 259, 3579, 11609, 29879, 1068, 13, 13, 268, 263, 1051, 310, 5685, 1446, 13, 13, 259, 3579, 3664, 267, 1068, 13, 13, 418, 448, 1438, 817, 304, 367, 2586, 325, 522, 29879, 322, 7581, 14188, 13, 13, 29871, 9995, 13, 29871, 302, 29925, 1372, 353, 7431, 29898, 2966, 29963, 522, 29879, 29897, 13, 29871, 565, 302, 29925, 1372, 2804, 7431, 29898, 627, 29963, 1338, 1125, 13, 1678, 12020, 7865, 2392, 877, 1707, 322, 6354, 8857, 881, 367, 278, 1021, 3309, 1495, 13, 29871, 302, 29933, 1169, 353, 2586, 29963, 522, 29879, 29961, 29900, 1822, 2577, 3505, 580, 13, 13, 29871, 1044, 3145, 353, 12655, 29889, 3298, 359, 29898, 29876, 29933, 1169, 29892, 12655, 29889, 16031, 29897, 13, 29871, 297, 627, 3145, 353, 12655, 29889, 3298, 359, 29898, 29876, 29933, 1169, 29892, 12655, 29889, 16031, 29897, 13, 29871, 302, 2865, 3145, 29892, 302, 797, 627, 3145, 353, 29871, 29900, 29892, 29871, 29900, 13, 29871, 363, 474, 297, 3464, 29898, 29876, 29925, 1372, 1125, 13, 1678, 4365, 29892, 1044, 353, 2586, 29963, 522, 29879, 29961, 29875, 1402, 1044, 29963, 1338, 29961, 29875, 29962, 13, 1678, 373, 21591, 1293, 353, 4365, 29889, 2577, 2951, 29933, 1169, 580, 13, 1678, 565, 1044, 29901, 13, 418, 363, 2586, 297, 373, 21591, 1293, 29901, 13, 4706, 1044, 3145, 29961, 2966, 29962, 4619, 29871, 29896, 13, 418, 302, 2865, 3145, 4619, 29871, 29896, 13, 1678, 1683, 29901, 13, 418, 363, 2586, 297, 373, 21591, 1293, 29901, 13, 4706, 297, 627, 3145, 29961, 2966, 29962, 4619, 29871, 29896, 13, 418, 302, 797, 627, 3145, 4619, 29871, 29896, 13, 29871, 620, 29911, 2204, 353, 12655, 29889, 3298, 359, 3552, 29906, 29892, 29871, 29906, 511, 12655, 29889, 16031, 29897, 13, 29871, 620, 353, 5159, 13, 29871, 330, 2708, 353, 5159, 13, 29871, 363, 2586, 297, 3464, 29898, 29876, 29933, 1169, 1125, 13, 1678, 302, 2865, 29892, 302, 797, 627, 353, 1044, 3145, 29961, 2966, 1402, 297, 627, 3145, 29961, 2966, 29962, 13, 1678, 565, 302, 2865, 470, 302, 797, 627, 29901, 13, 418, 620, 29911, 2204, 29961, 29900, 29892, 29871, 29900, 29962, 353, 302, 2865, 13, 418, 620, 29911, 2204, 29961, 29896, 29892, 29871, 29900, 29962, 353, 302, 29925, 1372, 448, 302, 2865, 13, 418, 620, 29911, 2204, 29961, 29900, 29892, 29871, 29896, 29962, 353, 302, 797, 627, 13, 418, 620, 29911, 2204, 29961, 29896, 29892, 29871, 29896, 29962, 353, 302, 29925, 1372, 448, 302, 797, 627, 13, 418, 11581, 353, 24687, 29889, 3401, 29954, 475, 29898, 690, 29911, 2204, 29897, 13, 418, 330, 2708, 29889, 4397, 29898, 29887, 475, 29897, 13, 418, 620, 29889, 4397, 3552, 2966, 29892, 11581, 29892, 302, 2865, 29892, 302, 797, 627, 876, 13, 29871, 736, 620, 29892, 330, 2708, 13, 13, 13, 1753, 317, 5510, 29934, 804, 29933, 1169, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29892, 12714, 14400, 29922, 2744, 14997, 911, 29903, 5510, 29963, 522, 29879, 1125, 13, 29871, 9995, 22125, 263, 731, 310, 9978, 5034, 304, 263, 12714, 740, 13, 13, 29871, 3579, 26915, 1068, 13, 13, 1678, 448, 2586, 29963, 522, 29879, 29901, 263, 334, 16506, 29930, 6943, 317, 29933, 29963, 29879, 13, 13, 1678, 448, 1044, 29963, 1338, 29901, 263, 334, 16506, 29930, 13, 13, 1678, 448, 12714, 14400, 29901, 313, 25253, 29897, 278, 12714, 740, 304, 367, 1304, 29889, 29871, 2823, 903, 29903, 5510, 7856, 29883, 3401, 29954, 2708, 580, 29918, 13, 418, 363, 263, 6139, 310, 278, 12608, 310, 445, 740, 29889, 13, 13, 259, 3579, 11609, 29879, 1068, 13, 13, 268, 319, 29871, 29906, 29899, 23583, 6943, 29901, 13, 13, 539, 448, 278, 6198, 1797, 310, 278, 9978, 313, 29874, 1051, 310, 938, 29879, 29897, 13, 13, 539, 448, 278, 12714, 12833, 363, 1269, 2586, 313, 29874, 1051, 310, 5685, 1446, 29897, 13, 13, 1678, 3579, 3664, 267, 1068, 13, 13, 418, 448, 1438, 817, 304, 367, 2586, 325, 522, 29879, 322, 7581, 14188, 13, 13, 29871, 9995, 13, 29871, 5235, 29892, 21556, 353, 12714, 14400, 29898, 2966, 29963, 522, 29879, 29892, 1044, 29963, 1338, 29897, 13, 29871, 2586, 7514, 353, 1051, 29898, 23749, 29889, 5085, 441, 29898, 2527, 10817, 876, 13, 29871, 2586, 7514, 29889, 24244, 580, 13, 29871, 736, 2586, 7514, 29892, 5235, 13, 2 ]
freezer-7.1.0/freezer/utils/config.py
scottwedge/OpenStack-Stein
0
1609172
<filename>freezer-7.1.0/freezer/utils/config.py # (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. # # 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. import os import re from oslo_log import log import six from six.moves import configparser from freezer.utils import utils LOG = log.getLogger(__name__) EXPORT = re.compile(r"^\s*export\s+([^=^#^\s]+)\s*=\s*([^#^\n]*)\s*$", re.MULTILINE) INI = re.compile(r"^\s*([^=#\s]+)\s*=[\t]*([^#\n]*)\s*$", re.MULTILINE) class Config(object): @staticmethod def parse(config_path): if config_path: if not os.path.exists(config_path): LOG.error("Critical Error: Configuration file {0} not" " found".format(config_path)) raise Exception("Configuration file {0} not found !".format( config_path)) # SafeConfigParser was deprecated in Python 3.2 if six.PY3: config = configparser.ConfigParser() else: config = configparser.SafeConfigParser() config.read([config_path]) sections = config.sections() storages = [] default_options = {} for section in sections: dict = {} for option in config.options(section): option_value = config.get(section, option) if option_value in ('False', 'None'): option_value = False dict[option] = option_value if section.startswith("storage:"): storages.append(dict) else: default_options.update(dict) return Config(default_options, storages) def __init__(self, default, storages): """ :param default: :type default: dict :param storages: :type storages: list[dict] :return: """ self.default = default self.storages = storages def osrc_parse(lines): """ :param lines: :type lines: str :return: """ return find_all(EXPORT, lines) def ini_parse(fd): """ :param fd: :type fd: file_descriptor :return: """ parser = configparser.ConfigParser() parser.readfp(fd) return dict(parser.items('default')) def find_all(regex, lines): return dict([(k.strip(), utils.dequote(v.strip())) for k, v in regex.findall(lines)])
[ 1, 529, 9507, 29958, 9021, 3298, 29899, 29955, 29889, 29896, 29889, 29900, 29914, 9021, 3298, 29914, 13239, 29914, 2917, 29889, 2272, 13, 29937, 313, 29883, 29897, 14187, 1266, 29871, 29906, 29900, 29896, 29946, 29892, 29906, 29900, 29896, 29945, 379, 809, 13650, 29899, 16638, 538, 14650, 6938, 29892, 365, 29889, 29925, 29889, 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, 1678, 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, 5215, 2897, 13, 5215, 337, 13, 13, 3166, 2897, 417, 29918, 1188, 1053, 1480, 13, 5215, 4832, 13, 3166, 4832, 29889, 13529, 267, 1053, 2295, 16680, 13, 13, 3166, 3889, 3298, 29889, 13239, 1053, 3667, 29879, 13, 13, 14480, 353, 1480, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 13, 13, 5746, 15082, 353, 337, 29889, 12198, 29898, 29878, 29908, 3823, 29879, 29930, 15843, 29905, 29879, 29974, 4197, 29985, 29922, 29985, 29937, 3823, 29879, 10062, 2144, 29879, 29930, 2013, 29879, 29930, 4197, 29985, 29937, 3823, 29876, 14178, 2144, 29879, 29394, 613, 13, 462, 1678, 337, 29889, 29924, 8647, 6227, 8895, 29897, 13, 13, 1177, 29902, 353, 337, 29889, 12198, 29898, 29878, 29908, 3823, 29879, 29930, 4197, 29985, 29922, 29937, 29905, 29879, 10062, 2144, 29879, 29930, 29922, 7110, 29873, 14178, 4197, 29985, 29937, 29905, 29876, 14178, 2144, 29879, 29394, 613, 337, 29889, 29924, 8647, 6227, 8895, 29897, 13, 13, 13, 1990, 12782, 29898, 3318, 1125, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 6088, 29898, 2917, 29918, 2084, 1125, 13, 4706, 565, 2295, 29918, 2084, 29901, 13, 9651, 565, 451, 2897, 29889, 2084, 29889, 9933, 29898, 2917, 29918, 2084, 1125, 13, 18884, 25401, 29889, 2704, 703, 29907, 768, 936, 4829, 29901, 20999, 934, 426, 29900, 29913, 451, 29908, 13, 462, 3986, 376, 1476, 1642, 4830, 29898, 2917, 29918, 2084, 876, 13, 18884, 12020, 8960, 703, 8614, 934, 426, 29900, 29913, 451, 1476, 1738, 1642, 4830, 29898, 13, 462, 1678, 2295, 29918, 2084, 876, 13, 4706, 396, 5701, 1725, 3991, 11726, 471, 18164, 297, 5132, 29871, 29941, 29889, 29906, 13, 4706, 565, 4832, 29889, 20055, 29941, 29901, 13, 9651, 2295, 353, 2295, 16680, 29889, 3991, 11726, 580, 13, 4706, 1683, 29901, 13, 9651, 2295, 353, 2295, 16680, 29889, 17618, 1725, 3991, 11726, 580, 13, 4706, 2295, 29889, 949, 4197, 2917, 29918, 2084, 2314, 13, 4706, 13926, 353, 2295, 29889, 27117, 580, 13, 4706, 2840, 1179, 353, 5159, 13, 4706, 2322, 29918, 6768, 353, 6571, 13, 4706, 363, 4004, 297, 13926, 29901, 13, 9651, 9657, 353, 6571, 13, 9651, 363, 2984, 297, 2295, 29889, 6768, 29898, 2042, 1125, 13, 18884, 2984, 29918, 1767, 353, 2295, 29889, 657, 29898, 2042, 29892, 2984, 29897, 13, 18884, 565, 2984, 29918, 1767, 297, 6702, 8824, 742, 525, 8516, 29374, 13, 462, 1678, 2984, 29918, 1767, 353, 7700, 13, 18884, 9657, 29961, 3385, 29962, 353, 2984, 29918, 1767, 13, 9651, 565, 4004, 29889, 27382, 2541, 703, 12925, 6160, 1125, 13, 18884, 2840, 1179, 29889, 4397, 29898, 8977, 29897, 13, 9651, 1683, 29901, 13, 18884, 2322, 29918, 6768, 29889, 5504, 29898, 8977, 29897, 13, 4706, 736, 12782, 29898, 4381, 29918, 6768, 29892, 2840, 1179, 29897, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2322, 29892, 2840, 1179, 1125, 13, 4706, 9995, 13, 4706, 584, 3207, 2322, 29901, 13, 4706, 584, 1853, 2322, 29901, 9657, 13, 4706, 584, 3207, 2840, 1179, 29901, 13, 4706, 584, 1853, 2840, 1179, 29901, 1051, 29961, 8977, 29962, 13, 4706, 584, 2457, 29901, 13, 4706, 9995, 13, 4706, 1583, 29889, 4381, 353, 2322, 13, 4706, 1583, 29889, 28957, 1179, 353, 2840, 1179, 13, 13, 13, 1753, 2897, 2214, 29918, 5510, 29898, 9012, 1125, 13, 1678, 9995, 13, 1678, 584, 3207, 3454, 29901, 13, 1678, 584, 1853, 3454, 29901, 851, 13, 1678, 584, 2457, 29901, 13, 1678, 9995, 13, 1678, 736, 1284, 29918, 497, 29898, 5746, 15082, 29892, 3454, 29897, 13, 13, 13, 1753, 297, 29875, 29918, 5510, 29898, 11512, 1125, 13, 1678, 9995, 13, 1678, 584, 3207, 285, 29881, 29901, 13, 1678, 584, 1853, 285, 29881, 29901, 934, 29918, 2783, 11709, 13, 1678, 584, 2457, 29901, 13, 1678, 9995, 13, 1678, 13812, 353, 2295, 16680, 29889, 3991, 11726, 580, 13, 1678, 13812, 29889, 949, 18091, 29898, 11512, 29897, 13, 1678, 736, 9657, 29898, 16680, 29889, 7076, 877, 4381, 8785, 13, 13, 13, 1753, 1284, 29918, 497, 29898, 13087, 29892, 3454, 1125, 13, 1678, 736, 9657, 4197, 29898, 29895, 29889, 17010, 3285, 3667, 29879, 29889, 311, 1396, 29898, 29894, 29889, 17010, 22130, 363, 413, 29892, 325, 297, 13, 462, 6528, 29889, 2886, 497, 29898, 9012, 29897, 2314, 13, 2 ]
SA_DS_placement.py
Christopher-v/parity-placement-algortihm
0
143486
import random from random import randint import networkx as nx import math import matplotlib.pyplot as plt import Evaluation as eval #This is local search heuristic Simulated Annealing. def anneal_DS(old_solution, allocated_network_topology): #This is algortihm 9 - Optimize DDS placement #print('----------SA---------') #get the cost from the initialized solution. #old_solution = solution(allocated_network_topology) old_cost = cost(old_solution, allocated_network_topology) T = 1.0 T_min = 0.000500 alpha = 0.9 c = 0.25 linear_factor = 0.25 i = 1 while T > T_min: print('/') #indicating the max iteration number for the algorithm. while i < 300: #Logarithmic schedule #T = c / (math.log(i) + 1) #Linear schedule #T -= linear_factor #Adaptive #if T < 00.9: # T = T * 0.9 #elif T < 0.9: # T = T * 0.5 #else: # T = T * 0.1 new_solution = neighbor(old_solution,allocated_network_topology) new_cost = cost(new_solution, allocated_network_topology) ap = acceptance_probability(old_cost, new_cost, T) if ap > random.random(): #check this. old_solution = new_solution old_cost = new_cost i += 1 #else: # T = 0 assert i == i T = T*alpha eval.eval_annealing_DS(T) print('DS-annealing finished!') print('cost',old_cost) #plt.show() assert cost != 0 return old_solution def solution(allocated_network_topology): #This method finds the existing solution based on the allocate_DS() #A list containing the placed nodes is derived from the graph - to minimize memory and iterations through the whole graph solution = [] for node in allocated_network_topology.nodes(data=True): if node[1]['placed'] == True: n = len(node[1]) for i in range(n): list.append(solution,node) break return solution def neighbor(solution, allocated_network_topology): #This is algortihm 10 - Neighbour / New solution #this function finds the neighbour of the node. - We use a list representing the nodes in the graph. #To avoid copying the whole graph - hence, making it more scalable. assert len(solution) > 0 old_solution = solution #Copying the old solution to manipulate new_solution = old_solution placed = False while placed == False: #picks random in solution #random_node = random.choice(solution_nodes) random_pick = random.choice(new_solution) random_node = random_pick[0] print('random node', random_node) #getting the random node's neigbours from the graph nodes_neighbours = list(allocated_network_topology.neighbors(random_node)) #Shuffling the nodes-neighbour random.shuffle(nodes_neighbours) n = len(nodes_neighbours) #-------------------------------------------------------------------- assert len(nodes_neighbours) > 0 #Checking if the random-nodes-neighbours is already in the list. for o, p in enumerate(nodes_neighbours): neighbouring_node = nodes_neighbours[o] print('neighbouring node',neighbouring_node) #Finding the neighbours neighbour in order to check for the connectivity contraint. neighbours_neighbours = list(allocated_network_topology.neighbors(neighbouring_node)) u = len(neighbours_neighbours) u -= 1 #trying to catch the exception - the exception means that the random-neighbour is not in the list. try: neighbouring_node_int = int(neighbouring_node) check = new_solution[neighbouring_node_int][0] break except IndexError: if allocated_network_topology.node[neighbouring_node]['storage_capacity'] >= allocated_network_topology.node[random_node]['storage_capacity'] and allocated_network_topology.node[neighbouring_node]['storage_usage'] == 0 and u > 2: print('loop') #switching the random node with the random node's neighbour. - look at RB_placement for optimized code. #Checking all nodes in the network topology for node in allocated_network_topology.nodes(data=True): #picks the random neighbour in the graph if node[0] == neighbouring_node: print('loop2') #takes the length of the node's attributes and appending it to the solution. #print(neighbouring_node) k = len(node[1]) list.append(new_solution,node) print('placed node', node) list.remove(new_solution, random_pick) print('node removed', random_pick) break break #list.append(new_solution,nodes) print('new sol', new_solution) return new_solution def cost(solution, allocated_network_topology): #This is algortihm 11 - Cost #Here goes the cost solution. This method calculates the cost from the new-solution generated by the previous method. assert len(solution) > 0 latencies = [] while True: #print('--went here--') #Iterates the new solution for the source node from which we want to find the latency for u, i in enumerate(solution[:-1]): current_source = int(solution[u][0]) next_source = solution[u+1][0] #iterates the new solution for the target want to find the latency to. for j, L in enumerate(solution): target = int(solution[j][0]) #This picks the current source in the new_solution - this is done because we want to #compare the source node with every node in the same cluster/same DS. if current_source != next_source and target != current_source: #And marks the latency between assert isinstance(current_source, int) assert isinstance(target, int) #Here we pick the target with the same cluster ID as the current source. if solution[j][1]['cluster_ID'] == solution[u][1]['cluster_ID']: assert solution[j][1]['cluster_ID'] != None assert solution[u][1]['cluster_ID'] != None try: latency = nx.shortest_path_length(allocated_network_topology, source=current_source, target=target) latencies.append(latency) assert len(latencies) != 0 except nx.NetworkXNoPath: print('no path between', current_source, 'and', target) pass continue #else if current_cluster-ID does have a match else: assert isinstance(solution[j][1]['cluster_ID'], int) continue cost = sum(latencies) eval.eval_topology_DS(cost) print(cost) #could MST been used here? - using the solution as a graph. return cost def acceptance_probability(old_cost, new_cost, T): assert old_cost > 0 assert new_cost > 0 if new_cost < old_cost: acceptance_probability = 1.0 else: try: acceptance_probability = math.exp((new_cost - old_cost) / T) except (OverflowError , ZeroDivisionError): print('overflowerror') acceptance_probability = float('inf') print('acceptance prop', acceptance_probability) print('temperature', T) return acceptance_probability def place_optimization(solution, allocated_network_topology): assert len(solution) > 0 ##This method places the final annealed solution in the actual graph. print('final solution',solution) #Remove all storage in node. - to make space for a clean solution #allocated_network_topology.add_node(random_node, storage_usage=0, placed=False) for node in allocated_network_topology.nodes(data=True): graph_node = node[0] allocated_network_topology.add_node(graph_node, storage_usage=0, placed=False) #Place Storage - taking the storage-usage of the randomly picked node and puts it into the randomly picked node's also randomly picked neibour for node in allocated_network_topology.nodes(data=True): graph_node = node[0] for u, i in enumerate(solution): solution_node = solution[u][0] allocated_network_topology.add_node(solution_node, storage_usage=allocated_network_topology.node[solution_node]['storage_capacity'], placed=True) return ###When scaling - be sure- that it compares target to all the nodes in cluster_ID!!!
[ 1, 1053, 4036, 13, 3166, 4036, 1053, 20088, 524, 13, 5215, 3564, 29916, 408, 302, 29916, 13, 5215, 5844, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 5215, 382, 4387, 362, 408, 19745, 13, 13, 29937, 4013, 338, 1887, 2740, 540, 332, 4695, 3439, 7964, 10558, 12818, 29889, 13, 13, 1753, 385, 484, 284, 29918, 8452, 29898, 1025, 29918, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 1125, 13, 29937, 4013, 338, 3093, 441, 4861, 29885, 29871, 29929, 448, 20693, 326, 675, 360, 8452, 2174, 13561, 13, 1678, 396, 2158, 877, 28400, 8132, 1378, 29899, 1495, 13, 13, 1678, 396, 657, 278, 3438, 515, 278, 16601, 1650, 29889, 13, 1678, 396, 1025, 29918, 2929, 918, 353, 1650, 29898, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29897, 13, 1678, 2030, 29918, 18253, 353, 3438, 29898, 1025, 29918, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 29897, 13, 13, 1678, 323, 353, 29871, 29896, 29889, 29900, 13, 1678, 323, 29918, 1195, 353, 29871, 29900, 29889, 29900, 29900, 29900, 29945, 29900, 29900, 13, 1678, 15595, 353, 29871, 29900, 29889, 29929, 13, 1678, 274, 353, 29871, 29900, 29889, 29906, 29945, 13, 1678, 5608, 29918, 19790, 353, 29871, 29900, 29889, 29906, 29945, 13, 1678, 474, 353, 29871, 29896, 13, 1678, 1550, 323, 1405, 323, 29918, 1195, 29901, 13, 13, 4706, 1596, 11219, 1495, 13, 4706, 396, 513, 293, 1218, 278, 4236, 12541, 1353, 363, 278, 5687, 29889, 13, 13, 4706, 1550, 474, 529, 29871, 29941, 29900, 29900, 29901, 13, 9651, 396, 3403, 23830, 13076, 20410, 13, 9651, 396, 29911, 353, 274, 847, 313, 755, 29889, 1188, 29898, 29875, 29897, 718, 29871, 29896, 29897, 13, 9651, 396, 12697, 20410, 13, 9651, 396, 29911, 22361, 5608, 29918, 19790, 13, 9651, 396, 29909, 1388, 415, 573, 13, 9651, 396, 361, 323, 529, 29871, 29900, 29900, 29889, 29929, 29901, 13, 9651, 396, 1678, 323, 353, 323, 334, 29871, 29900, 29889, 29929, 13, 9651, 396, 23681, 323, 529, 29871, 29900, 29889, 29929, 29901, 13, 9651, 396, 1678, 323, 353, 323, 334, 29871, 29900, 29889, 29945, 13, 9651, 396, 2870, 29901, 13, 13, 9651, 396, 1678, 323, 353, 323, 334, 29871, 29900, 29889, 29896, 13, 13, 9651, 716, 29918, 2929, 918, 353, 12307, 29898, 1025, 29918, 2929, 918, 29892, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29897, 13, 9651, 716, 29918, 18253, 353, 3438, 29898, 1482, 29918, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 29897, 13, 9651, 3095, 353, 3544, 749, 29918, 22795, 3097, 29898, 1025, 29918, 18253, 29892, 716, 29918, 18253, 29892, 323, 29897, 13, 9651, 565, 3095, 1405, 4036, 29889, 8172, 7295, 13, 18884, 396, 3198, 445, 29889, 13, 18884, 2030, 29918, 2929, 918, 353, 716, 29918, 2929, 918, 13, 18884, 2030, 29918, 18253, 353, 716, 29918, 18253, 13, 9651, 474, 4619, 29871, 29896, 13, 4706, 396, 2870, 29901, 13, 4706, 396, 1678, 323, 353, 29871, 29900, 13, 9651, 4974, 474, 1275, 474, 13, 13, 4706, 323, 353, 323, 29930, 2312, 13, 4706, 19745, 29889, 14513, 29918, 11276, 12818, 29918, 8452, 29898, 29911, 29897, 13, 13, 1678, 1596, 877, 8452, 29899, 11276, 12818, 7743, 29991, 1495, 13, 1678, 1596, 877, 18253, 742, 1025, 29918, 18253, 29897, 13, 13, 1678, 396, 572, 29873, 29889, 4294, 580, 13, 1678, 4974, 3438, 2804, 29871, 29900, 13, 1678, 736, 2030, 29918, 2929, 918, 13, 13, 13, 1753, 1650, 29898, 15956, 630, 29918, 11618, 29918, 3332, 3002, 1125, 13, 1678, 396, 4013, 1158, 14061, 278, 5923, 1650, 2729, 373, 278, 23632, 29918, 8452, 580, 13, 1678, 396, 29909, 1051, 6943, 278, 7180, 7573, 338, 10723, 515, 278, 3983, 448, 304, 6260, 675, 3370, 322, 24372, 1549, 278, 3353, 3983, 13, 13, 1678, 1650, 353, 5159, 13, 1678, 363, 2943, 297, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 18010, 29898, 1272, 29922, 5574, 1125, 13, 4706, 565, 2943, 29961, 29896, 22322, 13974, 1133, 2033, 1275, 5852, 29901, 13, 9651, 302, 353, 7431, 29898, 3177, 29961, 29896, 2314, 13, 9651, 363, 474, 297, 3464, 29898, 29876, 1125, 13, 18884, 1051, 29889, 4397, 29898, 2929, 918, 29892, 3177, 29897, 13, 18884, 2867, 13, 13, 1678, 736, 1650, 13, 13, 1753, 12307, 29898, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 1125, 13, 1678, 396, 4013, 338, 3093, 441, 4861, 29885, 29871, 29896, 29900, 448, 2448, 1141, 6526, 847, 1570, 1650, 13, 1678, 396, 1366, 740, 14061, 278, 17647, 310, 278, 2943, 29889, 448, 1334, 671, 263, 1051, 15783, 278, 7573, 297, 278, 3983, 29889, 13, 1678, 396, 1762, 4772, 17596, 278, 3353, 3983, 448, 8151, 29892, 3907, 372, 901, 8716, 519, 29889, 13, 13, 1678, 4974, 7431, 29898, 2929, 918, 29897, 1405, 29871, 29900, 13, 13, 1678, 2030, 29918, 2929, 918, 353, 1650, 13, 1678, 396, 11882, 292, 278, 2030, 1650, 304, 26749, 13, 1678, 716, 29918, 2929, 918, 353, 2030, 29918, 2929, 918, 13, 13, 1678, 7180, 353, 7700, 13, 1678, 1550, 7180, 1275, 7700, 29901, 13, 13, 4706, 396, 29886, 7358, 4036, 297, 1650, 13, 4706, 396, 8172, 29918, 3177, 353, 4036, 29889, 16957, 29898, 2929, 918, 29918, 18010, 29897, 13, 4706, 4036, 29918, 23945, 353, 4036, 29889, 16957, 29898, 1482, 29918, 2929, 918, 29897, 13, 4706, 4036, 29918, 3177, 353, 4036, 29918, 23945, 29961, 29900, 29962, 13, 4706, 1596, 877, 8172, 2943, 742, 4036, 29918, 3177, 29897, 13, 13, 4706, 396, 29264, 278, 4036, 2943, 29915, 29879, 29871, 452, 335, 29890, 2470, 515, 278, 3983, 13, 4706, 7573, 29918, 484, 1141, 29890, 2470, 353, 1051, 29898, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29889, 484, 1141, 29890, 943, 29898, 8172, 29918, 3177, 876, 13, 4706, 396, 2713, 3096, 1847, 278, 7573, 29899, 484, 1141, 6526, 13, 4706, 4036, 29889, 845, 21897, 29898, 18010, 29918, 484, 1141, 29890, 2470, 29897, 13, 13, 4706, 302, 353, 7431, 29898, 18010, 29918, 484, 1141, 29890, 2470, 29897, 13, 13, 4706, 396, 2683, 2683, 2683, 2683, 807, 13, 13, 4706, 4974, 7431, 29898, 18010, 29918, 484, 1141, 29890, 2470, 29897, 1405, 29871, 29900, 13, 4706, 396, 5596, 292, 565, 278, 4036, 29899, 18010, 29899, 484, 1141, 29890, 2470, 338, 2307, 297, 278, 1051, 29889, 13, 4706, 363, 288, 29892, 282, 297, 26985, 29898, 18010, 29918, 484, 1141, 29890, 2470, 1125, 13, 9651, 17647, 292, 29918, 3177, 353, 7573, 29918, 484, 1141, 29890, 2470, 29961, 29877, 29962, 13, 9651, 1596, 877, 484, 1141, 6526, 292, 2943, 742, 484, 1141, 6526, 292, 29918, 3177, 29897, 13, 13, 9651, 396, 29943, 4015, 278, 22092, 2470, 17647, 297, 1797, 304, 1423, 363, 278, 4511, 2068, 640, 5270, 29889, 13, 9651, 22092, 2470, 29918, 484, 1141, 29890, 2470, 353, 1051, 29898, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29889, 484, 1141, 29890, 943, 29898, 484, 1141, 6526, 292, 29918, 3177, 876, 13, 9651, 318, 353, 7431, 29898, 484, 1141, 29890, 2470, 29918, 484, 1141, 29890, 2470, 29897, 13, 9651, 318, 22361, 29871, 29896, 13, 13, 9651, 396, 2202, 292, 304, 4380, 278, 3682, 448, 278, 3682, 2794, 393, 278, 4036, 29899, 484, 1141, 6526, 338, 451, 297, 278, 1051, 29889, 13, 9651, 1018, 29901, 13, 18884, 17647, 292, 29918, 3177, 29918, 524, 353, 938, 29898, 484, 1141, 6526, 292, 29918, 3177, 29897, 13, 18884, 1423, 353, 716, 29918, 2929, 918, 29961, 484, 1141, 6526, 292, 29918, 3177, 29918, 524, 3816, 29900, 29962, 13, 18884, 2867, 13, 9651, 5174, 11374, 2392, 29901, 13, 13, 18884, 565, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 3177, 29961, 484, 1141, 6526, 292, 29918, 3177, 22322, 12925, 29918, 5030, 5946, 2033, 6736, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 3177, 29961, 8172, 29918, 3177, 22322, 12925, 29918, 5030, 5946, 2033, 322, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 3177, 29961, 484, 1141, 6526, 292, 29918, 3177, 22322, 12925, 29918, 21125, 2033, 1275, 29871, 29900, 322, 318, 1405, 29871, 29906, 29901, 13, 13, 462, 1678, 1596, 877, 7888, 1495, 13, 462, 1678, 396, 15123, 292, 278, 4036, 2943, 411, 278, 4036, 2943, 29915, 29879, 17647, 29889, 448, 1106, 472, 390, 29933, 29918, 29886, 9552, 363, 27545, 775, 29889, 13, 462, 1678, 396, 5596, 292, 599, 7573, 297, 278, 3564, 20159, 13, 462, 1678, 363, 2943, 297, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 18010, 29898, 1272, 29922, 5574, 1125, 13, 462, 4706, 396, 29886, 7358, 278, 4036, 17647, 297, 278, 3983, 13, 462, 4706, 565, 2943, 29961, 29900, 29962, 1275, 17647, 292, 29918, 3177, 29901, 13, 462, 9651, 1596, 877, 7888, 29906, 1495, 13, 462, 9651, 396, 29873, 6926, 278, 3309, 310, 278, 2943, 29915, 29879, 8393, 322, 623, 2548, 372, 304, 278, 1650, 29889, 13, 462, 9651, 396, 2158, 29898, 484, 1141, 6526, 292, 29918, 3177, 29897, 13, 462, 9651, 413, 353, 7431, 29898, 3177, 29961, 29896, 2314, 13, 462, 9651, 1051, 29889, 4397, 29898, 1482, 29918, 2929, 918, 29892, 3177, 29897, 13, 462, 9651, 1596, 877, 13974, 1133, 2943, 742, 2943, 29897, 13, 462, 9651, 1051, 29889, 5992, 29898, 1482, 29918, 2929, 918, 29892, 4036, 29918, 23945, 29897, 13, 462, 9651, 1596, 877, 3177, 6206, 742, 4036, 29918, 23945, 29897, 13, 462, 9651, 2867, 13, 462, 1678, 2867, 13, 13, 4706, 396, 1761, 29889, 4397, 29898, 1482, 29918, 2929, 918, 29892, 18010, 29897, 13, 4706, 1596, 877, 1482, 899, 742, 716, 29918, 2929, 918, 29897, 13, 4706, 736, 716, 29918, 2929, 918, 13, 13, 1753, 3438, 29898, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 1125, 13, 1678, 396, 4013, 338, 3093, 441, 4861, 29885, 29871, 29896, 29896, 448, 9839, 13, 1678, 396, 10605, 5771, 278, 3438, 1650, 29889, 910, 1158, 3408, 1078, 278, 3438, 515, 278, 716, 29899, 2929, 918, 5759, 491, 278, 3517, 1158, 29889, 13, 13, 1678, 4974, 7431, 29898, 2929, 918, 29897, 1405, 29871, 29900, 13, 13, 1678, 23316, 2478, 353, 5159, 13, 1678, 1550, 5852, 29901, 13, 4706, 396, 2158, 877, 489, 29893, 296, 1244, 489, 1495, 13, 4706, 396, 13463, 1078, 278, 716, 1650, 363, 278, 2752, 2943, 515, 607, 591, 864, 304, 1284, 278, 23316, 1270, 13, 4706, 363, 318, 29892, 474, 297, 26985, 29898, 2929, 918, 7503, 29899, 29896, 29962, 1125, 13, 9651, 1857, 29918, 4993, 353, 938, 29898, 2929, 918, 29961, 29884, 3816, 29900, 2314, 13, 13, 9651, 2446, 29918, 4993, 1678, 353, 1650, 29961, 29884, 29974, 29896, 3816, 29900, 29962, 13, 9651, 396, 1524, 1078, 278, 716, 1650, 363, 278, 3646, 864, 304, 1284, 278, 23316, 1270, 304, 29889, 13, 9651, 363, 432, 29892, 365, 297, 26985, 29898, 2929, 918, 1125, 13, 18884, 3646, 353, 938, 29898, 2929, 918, 29961, 29926, 3816, 29900, 2314, 13, 18884, 396, 4013, 5839, 29879, 278, 1857, 2752, 297, 278, 716, 29918, 2929, 918, 448, 445, 338, 2309, 1363, 591, 864, 304, 13, 18884, 396, 18307, 278, 2752, 2943, 411, 1432, 2943, 297, 278, 1021, 9867, 29914, 17642, 360, 29903, 29889, 13, 18884, 565, 1857, 29918, 4993, 2804, 2446, 29918, 4993, 322, 3646, 2804, 1857, 29918, 4993, 29901, 13, 462, 1678, 396, 2855, 17997, 278, 23316, 1270, 1546, 13, 462, 1678, 4974, 338, 8758, 29898, 3784, 29918, 4993, 29892, 938, 29897, 13, 462, 1678, 4974, 338, 8758, 29898, 5182, 29892, 938, 29897, 13, 13, 462, 1678, 396, 10605, 591, 5839, 278, 3646, 411, 278, 1021, 9867, 3553, 408, 278, 1857, 2752, 29889, 13, 462, 1678, 565, 1650, 29961, 29926, 3816, 29896, 22322, 19594, 29918, 1367, 2033, 1275, 1650, 29961, 29884, 3816, 29896, 22322, 19594, 29918, 1367, 2033, 29901, 13, 462, 4706, 4974, 1650, 29961, 29926, 3816, 29896, 22322, 19594, 29918, 1367, 2033, 2804, 6213, 13, 462, 4706, 4974, 1650, 29961, 29884, 3816, 29896, 22322, 19594, 29918, 1367, 2033, 2804, 6213, 13, 462, 4706, 1018, 29901, 13, 462, 9651, 23316, 1270, 353, 29871, 302, 29916, 29889, 12759, 342, 29918, 2084, 29918, 2848, 29898, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29892, 2752, 29922, 3784, 29918, 4993, 29892, 3646, 29922, 5182, 29897, 13, 462, 9651, 23316, 2478, 29889, 4397, 29898, 29880, 2579, 1270, 29897, 13, 462, 9651, 4974, 7431, 29898, 29880, 2579, 2478, 29897, 2804, 29871, 29900, 13, 462, 4706, 5174, 302, 29916, 29889, 13724, 29990, 3782, 2605, 29901, 13, 462, 9651, 1596, 877, 1217, 2224, 1546, 742, 1857, 29918, 4993, 29892, 525, 392, 742, 3646, 29897, 13, 462, 9651, 1209, 13, 462, 4706, 6773, 13, 462, 4706, 396, 2870, 565, 1857, 29918, 19594, 29899, 1367, 947, 505, 263, 1993, 13, 462, 1678, 1683, 29901, 13, 462, 4706, 4974, 338, 8758, 29898, 2929, 918, 29961, 29926, 3816, 29896, 22322, 19594, 29918, 1367, 7464, 938, 29897, 13, 462, 4706, 6773, 13, 4706, 3438, 353, 2533, 29898, 29880, 2579, 2478, 29897, 13, 4706, 19745, 29889, 14513, 29918, 3332, 3002, 29918, 8452, 29898, 18253, 29897, 13, 4706, 1596, 29898, 18253, 29897, 13, 4706, 396, 26680, 341, 1254, 1063, 1304, 1244, 29973, 448, 773, 278, 1650, 408, 263, 3983, 29889, 13, 4706, 736, 3438, 13, 13, 1753, 3544, 749, 29918, 22795, 3097, 29898, 1025, 29918, 18253, 29892, 716, 29918, 18253, 29892, 323, 1125, 13, 13, 1678, 4974, 2030, 29918, 18253, 1405, 29871, 29900, 13, 1678, 4974, 716, 29918, 18253, 1405, 29871, 29900, 13, 13, 1678, 565, 716, 29918, 18253, 529, 2030, 29918, 18253, 29901, 13, 4706, 3544, 749, 29918, 22795, 3097, 353, 29871, 29896, 29889, 29900, 13, 13, 1678, 1683, 29901, 13, 4706, 1018, 29901, 13, 9651, 3544, 749, 29918, 22795, 3097, 353, 5844, 29889, 4548, 3552, 1482, 29918, 18253, 448, 2030, 29918, 18253, 29897, 847, 323, 29897, 13, 4706, 5174, 313, 23773, 2392, 1919, 28933, 12596, 2459, 2392, 1125, 13, 9651, 1596, 877, 2262, 2704, 1495, 13, 9651, 3544, 749, 29918, 22795, 3097, 353, 5785, 877, 7192, 1495, 13, 13, 1678, 1596, 877, 16044, 749, 3107, 742, 3544, 749, 29918, 22795, 3097, 29897, 13, 1678, 1596, 877, 12863, 1535, 742, 323, 29897, 13, 1678, 736, 3544, 749, 29918, 22795, 3097, 13, 13, 1753, 2058, 29918, 20640, 2133, 29898, 2929, 918, 29892, 19591, 29918, 11618, 29918, 3332, 3002, 1125, 13, 1678, 4974, 7431, 29898, 2929, 918, 29897, 1405, 29871, 29900, 13, 1678, 444, 4013, 1158, 7600, 278, 2186, 385, 484, 7943, 1650, 297, 278, 3935, 3983, 29889, 13, 1678, 1596, 877, 8394, 1650, 742, 2929, 918, 29897, 13, 1678, 396, 15941, 599, 8635, 297, 2943, 29889, 448, 304, 1207, 2913, 363, 263, 5941, 1650, 13, 1678, 396, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29889, 1202, 29918, 3177, 29898, 8172, 29918, 3177, 29892, 8635, 29918, 21125, 29922, 29900, 29892, 7180, 29922, 8824, 29897, 13, 13, 1678, 363, 2943, 297, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 18010, 29898, 1272, 29922, 5574, 1125, 13, 4706, 3983, 29918, 3177, 353, 2943, 29961, 29900, 29962, 13, 4706, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 1202, 29918, 3177, 29898, 4262, 29918, 3177, 29892, 8635, 29918, 21125, 29922, 29900, 29892, 7180, 29922, 8824, 29897, 13, 1678, 396, 22150, 26162, 448, 5622, 278, 8635, 29899, 21125, 310, 278, 20459, 18691, 2943, 322, 15223, 372, 964, 278, 20459, 18691, 2943, 29915, 29879, 884, 20459, 18691, 452, 747, 473, 13, 1678, 363, 2943, 297, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 18010, 29898, 1272, 29922, 5574, 1125, 13, 4706, 3983, 29918, 3177, 353, 2943, 29961, 29900, 29962, 13, 4706, 363, 318, 29892, 474, 297, 26985, 29898, 2929, 918, 1125, 13, 9651, 1650, 29918, 3177, 353, 1650, 29961, 29884, 3816, 29900, 29962, 13, 9651, 19591, 29918, 11618, 29918, 3332, 3002, 29889, 1202, 29918, 3177, 29898, 2929, 918, 29918, 3177, 29892, 8635, 29918, 21125, 29922, 15956, 630, 29918, 11618, 29918, 3332, 3002, 29889, 3177, 29961, 2929, 918, 29918, 3177, 22322, 12925, 29918, 5030, 5946, 7464, 7180, 29922, 5574, 29897, 13, 13, 1678, 736, 13, 13, 1678, 835, 10401, 21640, 448, 367, 1854, 29899, 393, 372, 752, 5114, 3646, 304, 599, 278, 7573, 297, 9867, 29918, 1367, 21004, 2 ]
pychron/entry/entry_views/sensitivity_entry.py
ASUPychron/pychron
31
129636
<gh_stars>10-100 # =============================================================================== # Copyright 2012 <NAME> # # 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. # =============================================================================== # ============= enthought library imports ======================= from __future__ import absolute_import from datetime import datetime from traits.api import HasTraits, List, Str, Float, Date, Any, TraitError # ============= standard library imports ======================== # ============= local library imports ========================== from pychron.core.helpers.iterfuncs import groupby_key from pychron.dvc.dvc_irradiationable import DVCAble from pychron.paths import paths from pychron.pychron_constants import DATE_FORMAT class SensitivityRecord(HasTraits): user = Str(dictable=True) note = Str(dictable=True) mass_spectrometer = Str(dictable=True) sensitivity = Float(dictable=True) create_date = Date(dictable=True) units = Str("mol/fA", dictable=True) def to_dict(self): d = {k: getattr(self, k) for k in self.traits(dictable=True)} cd = d["create_date"] if not cd: self.create_date = cd = datetime.now() d["create_date"] = cd.strftime(DATE_FORMAT) return d @classmethod def from_dict(cls, d): record = cls() for attr in record.traits(dictable=True): if attr == "create_date": cd = d.get(attr) if cd and not isinstance(cd, datetime): cd = datetime.strptime(cd, DATE_FORMAT) record.create_date = cd else: try: setattr(record, attr, d.get(attr)) except TraitError: pass return record # primary_key = Int # editable = Bool(True) # def __init__(self, rec=None, *args, **kw): # super(SensitivityRecord, self).__init__(*args, **kw) # if rec: # self._create(rec) # # def _create(self, dbrecord): # self.user = dbrecord.user or '' # self.note = dbrecord.note or '' # self.create_date = dbrecord.create_date # self.primary_key = int(dbrecord.id) # self.editable = False # # if dbrecord.mass_spectrometer: # self.mass_spectrometer = dbrecord.mass_spectrometer.name # # self.sensitivity = dbrecord.sensitivity # # def flush(self, dbrecord): # attrs = ['sensitivity', 'note', 'user'] # for ai in attrs: # v = getattr(self, ai) # setattr(dbrecord, ai, v) # dbrecord = Any # spectrometer = Property # _spectrometer = Str # # def _get_spectrometer(self): # # if self._spectrometer: # return self._spectrometer # # if self.dbrecord: # return self.dbrecord.mass_spectrometer.name # # def _set_spectrometer(self, v): # self._spectrometer = v # # def __getattr__(self, attr): # if hasattr(self.dbrecord, attr): # return getattr(self.dbrecord, attr) # def sync(self, spec): # attrs = ['sensitivity', 'note', 'user'] # for ai in attrs: # v = getattr(self, ai) # setattr(self.dbrecord, ai, v) # # self.dbrecord.mass_spectrometer = spec # class database_enabled(object): # def __call__(self, func): # def wrapper(obj, *args, **kw): # if obj.db is not None: # return func(obj, *args, **kw) # else: # obj.warning('database not enabled') # # return wrapper class SensitivityEntry(DVCAble): records = List(SensitivityRecord) selected = Any def _add_item(self, db): pass def activate(self): self._load_records() # @database_enabled() def _load_records(self): specs = self.dvc.get_sensitivities() print("asdf", specs) self.records = [ SensitivityRecord.from_dict(sens) for spec in specs.values() for sens in spec ] # @database_enabled() def save(self): sens = {} for ms, ss in groupby_key(self.records, "mass_spectrometer"): sens[ms] = [ri.to_dict() for ri in ss] self.dvc.save_sensitivities(sens) def add(self): rec = SensitivityRecord() self.records.append(rec) # =============================================================================== # handlers # =============================================================================== # def _add_button_fired(self): # s = SensitivityRecord() # self._records.append(s) # # self.records_dirty = True # def _save_button_fired(self): # db = self.db # for si in self.records: # # print si.note, si.dbrecord. # if si.dbrecord is None: # user = si.user # if user == 'None': # user = db.save_username # db.add_sensitivity(si.spectrometer, # user=user, note=si.note, sensitivity=si.sensitivity) # else: # spec = db.get_mass_spectrometer(si.spectrometer) # si.sync(spec) # # for ai in ['sensitivity',''] # # # # db.commit() # =============================================================================== # property get/set # =============================================================================== # def _get_records(self): # if not self._records: # recs = self.db.get_sensitivities() # self._records = [SensitivityRecord(dbrecord=ri) for ri in recs] # return self._records # =============================================================================== # views # =============================================================================== # def traits_view(self): # v = View(Item('records', show_label=False, # editor=TabularEditor(adapter=SensitivityAdapter(), # operations=['edit'], # editable=True, # ) # ), # # HGroup(Item('add_button', show_label=False), # Item('save_button', show_label=False)), # resizable=True, # width=500, # height=200, # title='Sensitivity Table' # ) # return v class SensitivitySelector(SensitivityEntry): pass if __name__ == "__main__": from pychron.core.helpers.logger_setup import logging_setup paths.build("_experiment") logging_setup("runid") m = SensitivityEntry() m.configure_traits() # ============= EOF =============================================
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29896, 29906, 529, 5813, 29958, 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, 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, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 13, 29937, 1275, 4936, 25512, 875, 29882, 1774, 3489, 24802, 1275, 9166, 2751, 29922, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 13, 13, 3166, 12865, 1053, 12865, 13, 13, 3166, 1020, 1169, 29889, 2754, 1053, 11699, 5323, 1169, 29892, 2391, 29892, 3767, 29892, 27842, 29892, 4712, 29892, 3139, 29892, 3201, 277, 2392, 13, 13, 29937, 1275, 4936, 25512, 3918, 3489, 24802, 1275, 9166, 2751, 1360, 13, 29937, 1275, 4936, 25512, 1887, 3489, 24802, 29871, 1275, 9166, 4936, 13, 3166, 282, 3376, 1617, 29889, 3221, 29889, 3952, 6774, 29889, 1524, 7692, 2395, 1053, 2318, 1609, 29918, 1989, 13, 3166, 282, 3376, 1617, 29889, 29881, 7071, 29889, 29881, 7071, 29918, 381, 3665, 11685, 519, 1053, 360, 29963, 5454, 569, 13, 3166, 282, 3376, 1617, 29889, 24772, 1053, 10898, 13, 3166, 282, 3376, 1617, 29889, 2272, 5904, 29918, 3075, 1934, 1053, 20231, 29918, 19094, 1299, 13, 13, 13, 1990, 317, 575, 24858, 9182, 29898, 14510, 5323, 1169, 1125, 13, 1678, 1404, 353, 3767, 29898, 8977, 519, 29922, 5574, 29897, 13, 1678, 4443, 353, 3767, 29898, 8977, 519, 29922, 5574, 29897, 13, 1678, 4158, 29918, 21494, 456, 1308, 353, 3767, 29898, 8977, 519, 29922, 5574, 29897, 13, 1678, 4771, 24858, 353, 27842, 29898, 8977, 519, 29922, 5574, 29897, 13, 1678, 1653, 29918, 1256, 353, 4712, 29898, 8977, 519, 29922, 5574, 29897, 13, 1678, 10340, 353, 3767, 703, 29885, 324, 29914, 29888, 29909, 613, 9657, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 304, 29918, 8977, 29898, 1311, 1125, 13, 4706, 270, 353, 426, 29895, 29901, 679, 5552, 29898, 1311, 29892, 413, 29897, 363, 413, 297, 1583, 29889, 3018, 1169, 29898, 8977, 519, 29922, 5574, 2915, 13, 13, 4706, 14965, 353, 270, 3366, 3258, 29918, 1256, 3108, 13, 4706, 565, 451, 14965, 29901, 13, 9651, 1583, 29889, 3258, 29918, 1256, 353, 14965, 353, 12865, 29889, 3707, 580, 13, 13, 4706, 270, 3366, 3258, 29918, 1256, 3108, 353, 14965, 29889, 710, 615, 603, 29898, 6248, 29918, 19094, 1299, 29897, 13, 4706, 736, 270, 13, 13, 1678, 732, 1990, 5696, 13, 1678, 822, 515, 29918, 8977, 29898, 25932, 29892, 270, 1125, 13, 4706, 2407, 353, 1067, 29879, 580, 13, 4706, 363, 12421, 297, 2407, 29889, 3018, 1169, 29898, 8977, 519, 29922, 5574, 1125, 13, 9651, 565, 12421, 1275, 376, 3258, 29918, 1256, 1115, 13, 18884, 14965, 353, 270, 29889, 657, 29898, 5552, 29897, 13, 18884, 565, 14965, 322, 451, 338, 8758, 29898, 2252, 29892, 12865, 1125, 13, 462, 1678, 14965, 353, 12865, 29889, 710, 415, 603, 29898, 2252, 29892, 20231, 29918, 19094, 1299, 29897, 13, 18884, 2407, 29889, 3258, 29918, 1256, 353, 14965, 13, 9651, 1683, 29901, 13, 18884, 1018, 29901, 13, 462, 1678, 731, 5552, 29898, 11651, 29892, 12421, 29892, 270, 29889, 657, 29898, 5552, 876, 13, 18884, 5174, 3201, 277, 2392, 29901, 13, 462, 1678, 1209, 13, 4706, 736, 2407, 13, 13, 1678, 396, 7601, 29918, 1989, 353, 3159, 13, 1678, 396, 3863, 519, 353, 18912, 29898, 5574, 29897, 13, 13, 1678, 396, 822, 4770, 2344, 12035, 1311, 29892, 1162, 29922, 8516, 29892, 334, 5085, 29892, 3579, 11022, 1125, 13, 1678, 396, 268, 2428, 29898, 29903, 575, 24858, 9182, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 11022, 29897, 13, 1678, 396, 268, 565, 1162, 29901, 13, 1678, 396, 308, 1583, 3032, 3258, 29898, 3757, 29897, 13, 1678, 396, 13, 1678, 396, 822, 903, 3258, 29898, 1311, 29892, 270, 1030, 16090, 1125, 13, 1678, 396, 268, 1583, 29889, 1792, 353, 270, 1030, 16090, 29889, 1792, 470, 6629, 13, 1678, 396, 268, 1583, 29889, 6812, 353, 270, 1030, 16090, 29889, 6812, 470, 6629, 13, 1678, 396, 268, 1583, 29889, 3258, 29918, 1256, 353, 270, 1030, 16090, 29889, 3258, 29918, 1256, 13, 1678, 396, 268, 1583, 29889, 16072, 29918, 1989, 353, 938, 29898, 29881, 1030, 16090, 29889, 333, 29897, 13, 1678, 396, 268, 1583, 29889, 5628, 519, 353, 7700, 13, 1678, 396, 13, 1678, 396, 268, 565, 270, 1030, 16090, 29889, 25379, 29918, 21494, 456, 1308, 29901, 13, 1678, 396, 308, 1583, 29889, 25379, 29918, 21494, 456, 1308, 353, 270, 1030, 16090, 29889, 25379, 29918, 21494, 456, 1308, 29889, 978, 13, 1678, 396, 13, 1678, 396, 268, 1583, 29889, 23149, 24858, 353, 270, 1030, 16090, 29889, 23149, 24858, 13, 1678, 396, 13, 1678, 396, 822, 28371, 29898, 1311, 29892, 270, 1030, 16090, 1125, 13, 1678, 396, 268, 12421, 29879, 353, 6024, 23149, 24858, 742, 525, 6812, 742, 525, 1792, 2033, 13, 1678, 396, 268, 363, 7468, 297, 12421, 29879, 29901, 13, 1678, 396, 308, 325, 353, 679, 5552, 29898, 1311, 29892, 7468, 29897, 13, 1678, 396, 308, 731, 5552, 29898, 29881, 1030, 16090, 29892, 7468, 29892, 325, 29897, 13, 13, 13, 29937, 268, 270, 1030, 16090, 353, 3139, 13, 29937, 268, 6683, 456, 1308, 353, 9079, 13, 29937, 268, 903, 21494, 456, 1308, 353, 3767, 13, 29937, 13, 29937, 268, 822, 903, 657, 29918, 21494, 456, 1308, 29898, 1311, 1125, 13, 29937, 13, 29937, 308, 565, 1583, 3032, 21494, 456, 1308, 29901, 13, 29937, 632, 736, 1583, 3032, 21494, 456, 1308, 13, 29937, 13, 29937, 308, 565, 1583, 29889, 29881, 1030, 16090, 29901, 13, 29937, 632, 736, 1583, 29889, 29881, 1030, 16090, 29889, 25379, 29918, 21494, 456, 1308, 29889, 978, 13, 29937, 13, 29937, 268, 822, 903, 842, 29918, 21494, 456, 1308, 29898, 1311, 29892, 325, 1125, 13, 29937, 308, 1583, 3032, 21494, 456, 1308, 353, 325, 13, 29937, 13, 29937, 268, 822, 4770, 657, 5552, 12035, 1311, 29892, 12421, 1125, 13, 29937, 308, 565, 756, 5552, 29898, 1311, 29889, 29881, 1030, 16090, 29892, 12421, 1125, 13, 29937, 632, 736, 679, 5552, 29898, 1311, 29889, 29881, 1030, 16090, 29892, 12421, 29897, 13, 13, 29937, 268, 822, 16523, 29898, 1311, 29892, 1580, 1125, 13, 29937, 308, 12421, 29879, 353, 6024, 23149, 24858, 742, 525, 6812, 742, 525, 1792, 2033, 13, 29937, 308, 363, 7468, 297, 12421, 29879, 29901, 13, 29937, 632, 325, 353, 679, 5552, 29898, 1311, 29892, 7468, 29897, 13, 29937, 632, 731, 5552, 29898, 1311, 29889, 29881, 1030, 16090, 29892, 7468, 29892, 325, 29897, 13, 29937, 13, 29937, 308, 1583, 29889, 29881, 1030, 16090, 29889, 25379, 29918, 21494, 456, 1308, 353, 1580, 13, 13, 29937, 770, 2566, 29918, 17590, 29898, 3318, 1125, 13, 29937, 268, 822, 4770, 4804, 12035, 1311, 29892, 3653, 1125, 13, 29937, 308, 822, 14476, 29898, 5415, 29892, 334, 5085, 29892, 3579, 11022, 1125, 13, 29937, 632, 565, 5446, 29889, 2585, 338, 451, 6213, 29901, 13, 29937, 462, 736, 3653, 29898, 5415, 29892, 334, 5085, 29892, 3579, 11022, 29897, 13, 29937, 632, 1683, 29901, 13, 29937, 462, 5446, 29889, 27392, 877, 9803, 451, 9615, 1495, 13, 29937, 13, 29937, 308, 736, 14476, 13, 13, 13, 1990, 317, 575, 24858, 9634, 29898, 29928, 29963, 5454, 569, 1125, 13, 1678, 6475, 353, 2391, 29898, 29903, 575, 24858, 9182, 29897, 13, 1678, 4629, 353, 3139, 13, 13, 1678, 822, 903, 1202, 29918, 667, 29898, 1311, 29892, 4833, 1125, 13, 4706, 1209, 13, 13, 1678, 822, 5039, 403, 29898, 1311, 1125, 13, 4706, 1583, 3032, 1359, 29918, 3757, 4339, 580, 13, 13, 1678, 396, 732, 9803, 29918, 17590, 580, 13, 1678, 822, 903, 1359, 29918, 3757, 4339, 29898, 1311, 1125, 13, 4706, 1580, 29879, 353, 1583, 29889, 29881, 7071, 29889, 657, 29918, 23149, 277, 440, 1907, 580, 13, 4706, 1596, 703, 294, 2176, 613, 1580, 29879, 29897, 13, 4706, 1583, 29889, 3757, 4339, 353, 518, 13, 9651, 317, 575, 24858, 9182, 29889, 3166, 29918, 8977, 29898, 23149, 29897, 13, 9651, 363, 1580, 297, 1580, 29879, 29889, 5975, 580, 13, 9651, 363, 4771, 297, 1580, 13, 4706, 4514, 13, 13, 1678, 396, 732, 9803, 29918, 17590, 580, 13, 1678, 822, 4078, 29898, 1311, 1125, 13, 4706, 4771, 353, 6571, 13, 4706, 363, 10887, 29892, 17971, 297, 2318, 1609, 29918, 1989, 29898, 1311, 29889, 3757, 4339, 29892, 376, 25379, 29918, 21494, 456, 1308, 29908, 1125, 13, 9651, 4771, 29961, 1516, 29962, 353, 518, 374, 29889, 517, 29918, 8977, 580, 363, 10107, 297, 17971, 29962, 13, 13, 4706, 1583, 29889, 29881, 7071, 29889, 7620, 29918, 23149, 277, 440, 1907, 29898, 23149, 29897, 13, 13, 1678, 822, 788, 29898, 1311, 1125, 13, 4706, 1162, 353, 317, 575, 24858, 9182, 580, 13, 4706, 1583, 29889, 3757, 4339, 29889, 4397, 29898, 3757, 29897, 13, 13, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 25795, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 268, 822, 903, 1202, 29918, 3092, 29918, 29888, 2859, 29898, 1311, 1125, 13, 29937, 308, 269, 353, 317, 575, 24858, 9182, 580, 13, 29937, 308, 1583, 3032, 3757, 4339, 29889, 4397, 29898, 29879, 29897, 13, 29937, 396, 4706, 1583, 29889, 3757, 4339, 29918, 3972, 1017, 353, 5852, 13, 29937, 268, 822, 903, 7620, 29918, 3092, 29918, 29888, 2859, 29898, 1311, 1125, 13, 29937, 308, 4833, 353, 1583, 29889, 2585, 13, 29937, 308, 363, 1354, 297, 1583, 29889, 3757, 4339, 29901, 13, 29937, 396, 9651, 1596, 1354, 29889, 6812, 29892, 1354, 29889, 29881, 1030, 16090, 29889, 13, 29937, 632, 565, 1354, 29889, 29881, 1030, 16090, 338, 6213, 29901, 13, 29937, 462, 1404, 353, 1354, 29889, 1792, 13, 29937, 462, 565, 1404, 1275, 525, 8516, 2396, 13, 29937, 462, 268, 1404, 353, 4833, 29889, 7620, 29918, 6786, 13, 29937, 462, 4833, 29889, 1202, 29918, 23149, 24858, 29898, 1039, 29889, 21494, 456, 1308, 29892, 13, 29937, 462, 462, 1678, 1404, 29922, 1792, 29892, 4443, 29922, 1039, 29889, 6812, 29892, 4771, 24858, 29922, 1039, 29889, 23149, 24858, 29897, 13, 29937, 632, 1683, 29901, 13, 29937, 462, 1580, 353, 4833, 29889, 657, 29918, 25379, 29918, 21494, 456, 1308, 29898, 1039, 29889, 21494, 456, 1308, 29897, 13, 29937, 462, 1354, 29889, 16593, 29898, 6550, 29897, 13, 29937, 396, 18884, 363, 7468, 297, 6024, 23149, 24858, 3788, 2033, 13, 29937, 13, 29937, 13, 29937, 13, 29937, 308, 4833, 29889, 15060, 580, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 2875, 679, 29914, 842, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 268, 822, 903, 657, 29918, 3757, 4339, 29898, 1311, 1125, 13, 29937, 308, 565, 451, 1583, 3032, 3757, 4339, 29901, 13, 29937, 632, 1162, 29879, 353, 1583, 29889, 2585, 29889, 657, 29918, 23149, 277, 440, 1907, 580, 13, 29937, 632, 1583, 3032, 3757, 4339, 353, 518, 29903, 575, 24858, 9182, 29898, 29881, 1030, 16090, 29922, 374, 29897, 363, 10107, 297, 1162, 29879, 29962, 13, 29937, 308, 736, 1583, 3032, 3757, 4339, 13, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 8386, 13, 29937, 1275, 9166, 9166, 9166, 9166, 4936, 2751, 29922, 13, 29937, 268, 822, 1020, 1169, 29918, 1493, 29898, 1311, 1125, 13, 29937, 308, 325, 353, 4533, 29898, 2001, 877, 3757, 4339, 742, 1510, 29918, 1643, 29922, 8824, 29892, 13, 29937, 462, 539, 6920, 29922, 8863, 1070, 15280, 29898, 21412, 29922, 29903, 575, 24858, 6168, 3285, 13, 29937, 462, 462, 9651, 6931, 29922, 1839, 5628, 7464, 13, 29937, 462, 462, 9651, 3863, 519, 29922, 5574, 29892, 13, 29937, 462, 462, 9651, 1723, 13, 29937, 462, 539, 10353, 13, 29937, 13, 29937, 462, 29871, 379, 4782, 29898, 2001, 877, 1202, 29918, 3092, 742, 1510, 29918, 1643, 29922, 8824, 511, 13, 29937, 462, 308, 10976, 877, 7620, 29918, 3092, 742, 1510, 29918, 1643, 29922, 8824, 8243, 13, 29937, 462, 29871, 620, 13902, 29922, 5574, 29892, 13, 29937, 462, 29871, 2920, 29922, 29945, 29900, 29900, 29892, 13, 29937, 462, 29871, 3171, 29922, 29906, 29900, 29900, 29892, 13, 29937, 462, 29871, 3611, 2433, 29903, 575, 24858, 6137, 29915, 13, 29937, 462, 29871, 1723, 13, 29937, 308, 736, 325, 13, 13, 13, 1990, 317, 575, 24858, 10378, 29898, 29903, 575, 24858, 9634, 1125, 13, 1678, 1209, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 515, 282, 3376, 1617, 29889, 3221, 29889, 3952, 6774, 29889, 21707, 29918, 14669, 1053, 12183, 29918, 14669, 13, 13, 1678, 10898, 29889, 4282, 703, 29918, 735, 15362, 1159, 13, 13, 1678, 12183, 29918, 14669, 703, 3389, 333, 1159, 13, 1678, 286, 353, 317, 575, 24858, 9634, 580, 13, 1678, 286, 29889, 17591, 29918, 3018, 1169, 580, 13, 29937, 1275, 4936, 25512, 382, 9800, 1275, 9166, 9166, 4936, 25512, 13, 2 ]
src/data_module.py
ishine/Neural-HMM
66
176210
<gh_stars>10-100 r""" data_module.py Contains PyTorch-Lightning's datamodule and dataloaders """ import torch from torch.utils.data import DataLoader import pytorch_lightning as pl from src.utilities.data import TextMelCollate, TextMelLoader import nltk class LightningLoader(pl.LightningDataModule): def __init__(self, hparams): super(LightningLoader, self).__init__() self.hparams.update(vars(hparams)) self.collate_fn = TextMelCollate(self.hparams.n_frames_per_step) self.num_workers = hparams.num_workers def prepare_data(self): try: nltk.data.find('tokenizers/punkt') print("NLTK Tokenizer already present will not download it!") except LookupError: nltk.download('punkt') def setup(self, stage=None): self.trainset = TextMelLoader(self.hparams.training_files, self.hparams, [ self.hparams.normaliser]) self.valset = TextMelLoader(self.hparams.validation_files, self.hparams, [ self.hparams.normaliser]) def train_dataloader(self): return DataLoader(self.trainset, batch_size=self.hparams.batch_size, collate_fn=self.collate_fn, num_workers=self.hparams.num_workers, pin_memory=True) def val_dataloader(self): return DataLoader(self.valset, batch_size=self.hparams.batch_size, collate_fn=self.collate_fn, num_workers=self.hparams.num_workers, pin_memory=True)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 29878, 15945, 29908, 13, 1272, 29918, 5453, 29889, 2272, 13, 13, 21409, 10772, 29911, 25350, 29899, 20769, 1076, 29915, 29879, 1418, 314, 397, 1297, 322, 1418, 7003, 24574, 29871, 13, 15945, 29908, 13, 5215, 4842, 305, 13, 3166, 4842, 305, 29889, 13239, 29889, 1272, 1053, 3630, 10036, 13, 5215, 282, 3637, 25350, 29918, 4366, 1076, 408, 715, 13, 3166, 4765, 29889, 4422, 1907, 29889, 1272, 1053, 3992, 29924, 295, 1625, 9632, 29892, 3992, 29924, 295, 10036, 13, 5215, 302, 1896, 29895, 13, 13, 13, 1990, 12790, 1076, 10036, 29898, 572, 29889, 20769, 1076, 1469, 7355, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 298, 7529, 1125, 13, 4706, 2428, 29898, 20769, 1076, 10036, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 4706, 1583, 29889, 29882, 7529, 29889, 5504, 29898, 16908, 29898, 29882, 7529, 876, 13, 4706, 1583, 29889, 1054, 9632, 29918, 9144, 353, 3992, 29924, 295, 1625, 9632, 29898, 1311, 29889, 29882, 7529, 29889, 29876, 29918, 19935, 29918, 546, 29918, 10568, 29897, 13, 4706, 1583, 29889, 1949, 29918, 1287, 414, 353, 298, 7529, 29889, 1949, 29918, 1287, 414, 13, 13, 1678, 822, 19012, 29918, 1272, 29898, 1311, 1125, 13, 4706, 1018, 29901, 13, 9651, 302, 1896, 29895, 29889, 1272, 29889, 2886, 877, 6979, 19427, 29914, 19294, 1495, 13, 9651, 1596, 703, 29940, 5850, 29968, 25159, 3950, 2307, 2198, 674, 451, 5142, 372, 29991, 1159, 13, 4706, 5174, 7419, 786, 2392, 29901, 13, 9651, 302, 1896, 29895, 29889, 10382, 877, 19294, 1495, 13, 13, 1678, 822, 6230, 29898, 1311, 29892, 7408, 29922, 8516, 1125, 13, 4706, 1583, 29889, 14968, 842, 353, 3992, 29924, 295, 10036, 29898, 1311, 29889, 29882, 7529, 29889, 26495, 29918, 5325, 29892, 1583, 29889, 29882, 7529, 29892, 518, 13, 462, 462, 418, 1583, 29889, 29882, 7529, 29889, 8945, 7608, 2314, 13, 4706, 1583, 29889, 791, 842, 353, 3992, 29924, 295, 10036, 29898, 1311, 29889, 29882, 7529, 29889, 18157, 29918, 5325, 29892, 1583, 29889, 29882, 7529, 29892, 518, 13, 462, 462, 1678, 1583, 29889, 29882, 7529, 29889, 8945, 7608, 2314, 13, 13, 1678, 822, 7945, 29918, 29881, 2075, 29877, 1664, 29898, 1311, 1125, 13, 4706, 736, 3630, 10036, 29898, 1311, 29889, 14968, 842, 29892, 9853, 29918, 2311, 29922, 1311, 29889, 29882, 7529, 29889, 16175, 29918, 2311, 29892, 5321, 403, 29918, 9144, 29922, 1311, 29889, 1054, 9632, 29918, 9144, 29892, 13, 462, 3986, 954, 29918, 1287, 414, 29922, 1311, 29889, 29882, 7529, 29889, 1949, 29918, 1287, 414, 29892, 12534, 29918, 14834, 29922, 5574, 29897, 13, 13, 1678, 822, 659, 29918, 29881, 2075, 29877, 1664, 29898, 1311, 1125, 13, 4706, 736, 3630, 10036, 29898, 1311, 29889, 791, 842, 29892, 9853, 29918, 2311, 29922, 1311, 29889, 29882, 7529, 29889, 16175, 29918, 2311, 29892, 5321, 403, 29918, 9144, 29922, 1311, 29889, 1054, 9632, 29918, 9144, 29892, 13, 462, 3986, 954, 29918, 1287, 414, 29922, 1311, 29889, 29882, 7529, 29889, 1949, 29918, 1287, 414, 29892, 12534, 29918, 14834, 29922, 5574, 29897, 13, 2 ]
leetcode/87. Scramble String.py
CSU-FulChou/IOS_er
2
21801
<filename>leetcode/87. Scramble String.py # 2021.04.16 hard: class Solution: def isScramble(self, s1: str, s2: str) -> bool: ''' dp 问题: 1. 子字符串应该一样长. 很简单已经保证了 子字符串一样,那么久直接返回 True 2. 子字符串中 存在的字母应该一样, 同一个字母的数量应该一样多 Count() 两种分割方式,交换 或者 不交换不断的迭代下去: 分割的两种方式要写对! ''' @cache def dfs(idx1, idx2, length): if s1[idx1:length+idx1] == s2[idx2:idx2+length]: return True if Counter(s1[idx1:length+idx1]) != Counter(s2[idx2:idx2+length]): return False for i in range(1,length): # no swarp if dfs(idx1,idx2,i) and dfs(idx1+i, idx2+i, length-i): # 这两个的 位置 idx1, idx2 传入要注意: return True if dfs(idx1, idx2+length-i, i) and dfs(idx1+i, idx2, length-i): return True return False res = dfs(0,0,len(s1)) dfs.cache_clear() # print(res) return res
[ 1, 529, 9507, 29958, 280, 300, 401, 29914, 29947, 29955, 29889, 2522, 2572, 569, 1714, 29889, 2272, 13, 29937, 29871, 29906, 29900, 29906, 29896, 29889, 29900, 29946, 29889, 29896, 29953, 2898, 29901, 29871, 13, 1990, 24380, 29901, 13, 1678, 822, 338, 4421, 2572, 569, 29898, 1311, 29892, 269, 29896, 29901, 851, 29892, 269, 29906, 29901, 851, 29897, 1599, 6120, 29901, 13, 4706, 14550, 13, 4706, 270, 29886, 29871, 31658, 31596, 30383, 13, 308, 29896, 29889, 29871, 30319, 30578, 31277, 31767, 31370, 31751, 30287, 31819, 31143, 29889, 29871, 232, 193, 139, 234, 177, 131, 31166, 31290, 31412, 30982, 235, 178, 132, 30743, 13, 965, 30319, 30578, 31277, 31767, 30287, 31819, 30214, 31356, 31882, 31347, 31157, 31092, 31086, 30742, 5852, 13, 308, 29906, 29889, 29871, 30319, 30578, 31277, 31767, 30275, 29871, 30946, 30505, 30210, 30578, 31763, 31370, 31751, 30287, 31819, 30214, 29871, 30980, 30287, 30502, 30578, 31763, 30210, 30354, 31180, 31370, 31751, 30287, 31819, 30923, 3917, 580, 13, 308, 31977, 31893, 30748, 232, 140, 181, 30525, 30607, 30214, 31398, 31640, 29871, 31391, 30767, 29871, 30413, 31398, 31640, 30413, 31683, 30210, 235, 194, 176, 30690, 30557, 31475, 30383, 13, 308, 30748, 232, 140, 181, 30210, 31977, 31893, 30525, 30607, 30698, 31479, 30783, 30584, 13, 4706, 14550, 13, 4706, 732, 8173, 13, 4706, 822, 4489, 29879, 29898, 13140, 29896, 29892, 22645, 29906, 29892, 3309, 1125, 13, 9651, 565, 269, 29896, 29961, 13140, 29896, 29901, 2848, 29974, 13140, 29896, 29962, 1275, 269, 29906, 29961, 13140, 29906, 29901, 13140, 29906, 29974, 2848, 5387, 13, 18884, 736, 5852, 13, 9651, 565, 315, 5336, 29898, 29879, 29896, 29961, 13140, 29896, 29901, 2848, 29974, 13140, 29896, 2314, 2804, 315, 5336, 29898, 29879, 29906, 29961, 13140, 29906, 29901, 13140, 29906, 29974, 2848, 29962, 1125, 13, 18884, 736, 7700, 13, 9651, 363, 474, 297, 3464, 29898, 29896, 29892, 2848, 1125, 13, 18884, 396, 694, 2381, 6834, 13, 18884, 565, 4489, 29879, 29898, 13140, 29896, 29892, 13140, 29906, 29892, 29875, 29897, 322, 4489, 29879, 29898, 13140, 29896, 29974, 29875, 29892, 22645, 29906, 29974, 29875, 29892, 3309, 29899, 29875, 1125, 396, 29871, 30810, 31977, 30502, 30210, 29871, 30956, 30669, 22645, 29896, 29892, 22645, 29906, 29871, 31471, 30752, 30698, 31368, 31474, 29901, 13, 462, 1678, 736, 5852, 13, 18884, 565, 4489, 29879, 29898, 13140, 29896, 29892, 22645, 29906, 29974, 2848, 29899, 29875, 29892, 474, 29897, 322, 4489, 29879, 29898, 13140, 29896, 29974, 29875, 29892, 22645, 29906, 29892, 3309, 29899, 29875, 1125, 13, 462, 1678, 736, 5852, 13, 9651, 736, 7700, 13, 13, 4706, 620, 353, 4489, 29879, 29898, 29900, 29892, 29900, 29892, 2435, 29898, 29879, 29896, 876, 13, 4706, 4489, 29879, 29889, 8173, 29918, 8551, 580, 13, 4706, 396, 1596, 29898, 690, 29897, 13, 4706, 736, 620, 2 ]