content
stringlengths 1
1.04M
| input_ids
sequencelengths 1
774k
| ratio_char_token
float64 0.38
22.9
| token_count
int64 1
774k
|
---|---|---|---|
from itests.utils import get_sleep_time
from blacksheep.client.pool import ClientConnectionPools
import os
import pathlib
import asyncio
from multiprocessing import Process
from time import sleep
import pytest
from blacksheep.client import ClientSession
from .flask_app import app
@pytest.fixture(scope="session")
def event_loop():
"""Create an instance of the default event loop for all test cases."""
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()
@pytest.fixture(scope="module")
@pytest.fixture(scope="module")
@pytest.fixture(scope="module")
@pytest.fixture(scope="module")
@pytest.fixture(scope="module", autouse=True)
| [
6738,
340,
3558,
13,
26791,
1330,
651,
62,
42832,
62,
2435,
198,
6738,
2042,
7091,
538,
13,
16366,
13,
7742,
1330,
20985,
32048,
47,
10141,
198,
11748,
28686,
198,
11748,
3108,
8019,
198,
11748,
30351,
952,
198,
6738,
18540,
305,
919,
278,
1330,
10854,
198,
6738,
640,
1330,
3993,
198,
198,
11748,
12972,
9288,
198,
198,
6738,
2042,
7091,
538,
13,
16366,
1330,
20985,
36044,
198,
198,
6738,
764,
2704,
2093,
62,
1324,
1330,
598,
628,
198,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
29891,
4943,
198,
4299,
1785,
62,
26268,
33529,
198,
220,
220,
220,
37227,
16447,
281,
4554,
286,
262,
4277,
1785,
9052,
329,
477,
1332,
2663,
526,
15931,
198,
220,
220,
220,
9052,
796,
30351,
952,
13,
1136,
62,
15596,
62,
26268,
62,
30586,
22446,
3605,
62,
15596,
62,
26268,
3419,
198,
220,
220,
220,
7800,
9052,
198,
220,
220,
220,
9052,
13,
19836,
3419,
628,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
21412,
4943,
628,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
21412,
4943,
628,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
21412,
4943,
628,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
21412,
4943,
628,
198,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
21412,
1600,
1960,
1076,
28,
17821,
8,
198
] | 3.09417 | 223 |
print("part1:", iterate(80))
print("part2:", iterate(256))
| [
198,
4798,
7203,
3911,
16,
25,
1600,
11629,
378,
7,
1795,
4008,
198,
4798,
7203,
3911,
17,
25,
1600,
11629,
378,
7,
11645,
4008,
198
] | 2.4 | 25 |
"""
==============================================
Repository of Updaters, Dividers, and Derivers
==============================================
You should interpret words and phrases that appear fully capitalized in
this document as described in :rfc:`2119`. Here is a brief summary of
the RFC:
* "MUST" indicates absolute requirements. Vivarium may not work
correctly if you don't follow these.
* "SHOULD" indicates strong suggestions. You might have a valid reason
for deviating from them, but be careful that you understand the
ramifications.
* "MAY" indicates truly optional features that you can include or
exclude as you wish.
--------
Updaters
--------
Each :term:`updater` is defined as a function whose name begins with
``update_``. Vivarium uses these functions to apply :term:`updates` to
:term:`variables`. Updater names are defined in
:py:data:`updater_library`, which maps these names to updater functions.
Updater API
===========
An updater function MUST have a name that begins with ``update_``. The
function MUST accept exactly two positional arguments: the first MUST be
the current value of the variable (i.e. before applying the update), and
the second MUST be the value associated with the variable in the update.
The function SHOULD not accept any other parameters. The function MUST
return the updated value of the variable only.
--------
Dividers
--------
Each :term:`divider` is defined by a function that follows the API we
describe below. Vivarium uses these dividers to generate daughter cell
states from the mother cell's state. Divider names are defined in
:py:data:`divider_library`, which maps these names to divider functions.
Divider API
===========
Each divider function MUST have a name prefixed with ``_divide``. The
function MUST accept a single positional argument, the value of the
variable in the mother cell. It SHOULD accept no other arguments. The
function MUST return a :py:class:`list` with two elements: the values of
the variables in each of the daughter cells.
.. note:: Dividers MAY not be deterministic and MAY not be symmetric.
For example, a divider splitting an odd, integer-valued value may
randomly decide which daughter cell receives the remainder.
--------
Derivers
--------
Each :term:`deriver` is defined as a separate :term:`process`, but here
deriver names are mapped to processes by :py:data:`deriver_library`. The
available derivers are:
* **mmol_to_counts**: :py:class:`vivarium.processes.derive_counts.DeriveCounts`
* **counts_to_mmol**:
:py:class:`vivarium.processes.derive_concentrations.DeriveConcentrations`
* **mass**: :py:class:`vivarium.processes.tree_mass.TreeMass`
* **globals**:
:py:class:`vivarium.processes.derive_globals.DeriveGlobals`
See the documentation for each :term:`process class` for more details on
that deriver.
"""
from __future__ import absolute_import, division, print_function
import copy
import random
import numpy as np
from vivarium.library.dict_utils import deep_merge
from vivarium.library.units import Quantity
# deriver processes
from vivarium.processes.derive_concentrations import DeriveConcentrations
from vivarium.processes.derive_counts import DeriveCounts
from vivarium.processes.derive_globals import DeriveGlobals
from vivarium.processes.tree_mass import TreeMass
## updater functions
def update_merge(current_value, new_value):
"""Merge Updater
Arguments:
current_value (dict):
new_value (dict):
Returns:
dict: The merger of ``current_value`` and ``new_value``. For any
shared keys, the value in ``new_value`` is used.
"""
update = current_value.copy()
for k, v in current_value.items():
new = new_value.get(k)
if isinstance(new, dict):
update[k] = deep_merge(dict(v), new)
else:
update[k] = new
return update
def update_set(current_value, new_value):
"""Set Updater
Returns:
The value provided in ``new_value``.
"""
return new_value
def update_accumulate(current_value, new_value):
"""Accumulate Updater
Returns:
The sum of ``current_value`` and ``new_value``.
"""
return current_value + new_value
#: Maps updater names to updater functions
updater_library = {
'accumulate': update_accumulate,
'set': update_set,
'merge': update_merge}
## divider functions
def divide_set(state):
"""Set Divider
Returns:
A list ``[state, state]``. No copying is performed.
"""
return [state, state]
def divide_split(state):
"""Split Divider
Arguments:
state: Must be an :py:class:`int`, a :py:class:`float`, or a
:py:class:`str` of value ``Infinity``.
Returns:
A list, each of whose elements contains half of ``state``. If
``state`` is an :py:class:`int`, the remainder is placed at
random in one of the two elements. If ``state`` is infinite, the
return value is ``[state, state]`` (no copying is done).
Raises:
Exception: if ``state`` is of an unrecognized type.
"""
if isinstance(state, int):
remainder = state % 2
half = int(state / 2)
if random.choice([True, False]):
return [half + remainder, half]
else:
return [half, half + remainder]
elif state == float('inf') or state == 'Infinity':
# some concentrations are considered infinite in the environment
# an alternative option is to not divide the local environment state
return [state, state]
elif isinstance(state, (float, Quantity)):
half = state/2
return [half, half]
else:
raise Exception('can not divide state {} of type {}'.format(state, type(state)))
def divide_zero(state):
"""Zero Divider
Returns:
``[0, 0]`` regardless of input
"""
return [0, 0]
def divide_split_dict(state):
"""Split-Dictionary Divider
Returns:
A list of two dictionaries. The first dictionary stores the
first half of the key-value pairs in ``state``, and the second
dictionary stores the rest of the key-value pairs.
.. note:: Since dictionaries are unordered, you should avoid
making any assumptions about which keys will be sent to
which daughter cell.
"""
if state is None:
state = {}
d1 = dict(list(state.items())[len(state) // 2:])
d2 = dict(list(state.items())[:len(state) // 2])
return [d1, d2]
#: Maps divider names to divider functions
divider_library = {
'set': divide_set,
'split': divide_split,
'split_dict': divide_split_dict,
'zero': divide_zero}
# Derivers
#: Maps deriver names to :term:`process classes`
deriver_library = {
'mmol_to_counts': DeriveCounts,
'counts_to_mmol': DeriveConcentrations,
'mass': TreeMass,
'globals': DeriveGlobals,
}
# Serializers
serializer_library = {
'numpy': NumpySerializer(),
}
| [
37811,
198,
10052,
25609,
855,
198,
6207,
13264,
286,
3205,
67,
8605,
11,
360,
1699,
364,
11,
290,
9626,
1191,
198,
10052,
25609,
855,
198,
198,
1639,
815,
6179,
2456,
290,
20144,
326,
1656,
3938,
3139,
1143,
287,
198,
5661,
3188,
355,
3417,
287,
1058,
81,
16072,
25,
63,
2481,
1129,
44646,
3423,
318,
257,
4506,
10638,
286,
198,
1169,
30978,
25,
198,
198,
9,
366,
44,
7759,
1,
9217,
4112,
5359,
13,
25313,
17756,
743,
407,
670,
198,
220,
9380,
611,
345,
836,
470,
1061,
777,
13,
198,
9,
366,
9693,
24010,
1,
9217,
1913,
11776,
13,
921,
1244,
423,
257,
4938,
1738,
198,
220,
329,
1614,
26336,
422,
606,
11,
475,
307,
8161,
326,
345,
1833,
262,
198,
220,
36093,
13,
198,
9,
366,
44,
4792,
1,
9217,
4988,
11902,
3033,
326,
345,
460,
2291,
393,
198,
220,
19607,
355,
345,
4601,
13,
198,
198,
982,
198,
4933,
67,
8605,
198,
982,
198,
198,
10871,
1058,
4354,
25,
63,
929,
67,
729,
63,
318,
5447,
355,
257,
2163,
3025,
1438,
6140,
351,
198,
15506,
19119,
62,
15506,
13,
25313,
17756,
3544,
777,
5499,
284,
4174,
1058,
4354,
25,
63,
929,
19581,
63,
284,
198,
25,
4354,
25,
63,
25641,
2977,
44646,
3205,
67,
729,
3891,
389,
5447,
287,
198,
25,
9078,
25,
7890,
25,
63,
929,
67,
729,
62,
32016,
47671,
543,
8739,
777,
3891,
284,
2325,
729,
5499,
13,
198,
198,
4933,
67,
729,
7824,
198,
2559,
18604,
198,
198,
2025,
2325,
729,
2163,
17191,
423,
257,
1438,
326,
6140,
351,
7559,
19119,
62,
15506,
13,
383,
198,
8818,
17191,
2453,
3446,
734,
45203,
7159,
25,
262,
717,
17191,
307,
198,
1169,
1459,
1988,
286,
262,
7885,
357,
72,
13,
68,
13,
878,
11524,
262,
4296,
828,
290,
198,
1169,
1218,
17191,
307,
262,
1988,
3917,
351,
262,
7885,
287,
262,
4296,
13,
198,
464,
2163,
40312,
407,
2453,
597,
584,
10007,
13,
383,
2163,
17191,
198,
7783,
262,
6153,
1988,
286,
262,
7885,
691,
13,
198,
198,
982,
198,
35,
1699,
364,
198,
982,
198,
198,
10871,
1058,
4354,
25,
63,
7146,
1304,
63,
318,
5447,
416,
257,
2163,
326,
5679,
262,
7824,
356,
198,
20147,
4892,
2174,
13,
25313,
17756,
3544,
777,
13576,
364,
284,
7716,
4957,
2685,
198,
27219,
422,
262,
2802,
2685,
338,
1181,
13,
4777,
1304,
3891,
389,
5447,
287,
198,
25,
9078,
25,
7890,
25,
63,
7146,
1304,
62,
32016,
47671,
543,
8739,
777,
3891,
284,
2659,
1304,
5499,
13,
198,
198,
24095,
1304,
7824,
198,
2559,
18604,
198,
198,
10871,
2659,
1304,
2163,
17191,
423,
257,
1438,
7694,
2966,
351,
7559,
62,
7146,
485,
15506,
13,
383,
198,
8818,
17191,
2453,
257,
2060,
45203,
4578,
11,
262,
1988,
286,
262,
198,
45286,
287,
262,
2802,
2685,
13,
632,
40312,
2453,
645,
584,
7159,
13,
383,
198,
8818,
17191,
1441,
257,
1058,
9078,
25,
4871,
25,
63,
4868,
63,
351,
734,
4847,
25,
262,
3815,
286,
198,
1169,
9633,
287,
1123,
286,
262,
4957,
4778,
13,
198,
198,
492,
3465,
3712,
360,
1699,
364,
26720,
407,
307,
2206,
49228,
290,
26720,
407,
307,
23606,
19482,
13,
198,
220,
220,
220,
1114,
1672,
11,
257,
2659,
1304,
26021,
281,
5629,
11,
18253,
12,
39728,
1988,
743,
198,
220,
220,
220,
15456,
5409,
543,
4957,
2685,
11583,
262,
17675,
13,
198,
198,
982,
198,
28532,
1191,
198,
982,
198,
198,
10871,
1058,
4354,
25,
63,
1082,
1428,
63,
318,
5447,
355,
257,
4553,
1058,
4354,
25,
63,
14681,
47671,
475,
994,
198,
1082,
1428,
3891,
389,
27661,
284,
7767,
416,
1058,
9078,
25,
7890,
25,
63,
1082,
1428,
62,
32016,
44646,
383,
198,
15182,
4587,
1191,
389,
25,
198,
198,
9,
12429,
3020,
349,
62,
1462,
62,
9127,
82,
1174,
25,
1058,
9078,
25,
4871,
25,
63,
85,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
9127,
82,
13,
28532,
425,
12332,
82,
63,
198,
9,
12429,
9127,
82,
62,
1462,
62,
3020,
349,
1174,
25,
198,
220,
1058,
9078,
25,
4871,
25,
63,
85,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
1102,
1087,
9143,
13,
28532,
425,
3103,
1087,
9143,
63,
198,
9,
12429,
22208,
1174,
25,
1058,
9078,
25,
4871,
25,
63,
85,
452,
17756,
13,
14681,
274,
13,
21048,
62,
22208,
13,
27660,
20273,
63,
198,
9,
12429,
4743,
672,
874,
1174,
25,
198,
220,
1058,
9078,
25,
4871,
25,
63,
85,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
4743,
672,
874,
13,
28532,
425,
9861,
672,
874,
63,
198,
198,
6214,
262,
10314,
329,
1123,
1058,
4354,
25,
63,
14681,
1398,
63,
329,
517,
3307,
319,
198,
5562,
4587,
1428,
13,
198,
37811,
628,
198,
6738,
11593,
37443,
834,
1330,
4112,
62,
11748,
11,
7297,
11,
3601,
62,
8818,
198,
198,
11748,
4866,
198,
11748,
4738,
198,
198,
11748,
299,
32152,
355,
45941,
198,
198,
6738,
410,
452,
17756,
13,
32016,
13,
11600,
62,
26791,
1330,
2769,
62,
647,
469,
198,
6738,
410,
452,
17756,
13,
32016,
13,
41667,
1330,
39789,
198,
198,
2,
4587,
1428,
7767,
198,
6738,
410,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
1102,
1087,
9143,
1330,
9626,
425,
3103,
1087,
9143,
198,
6738,
410,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
9127,
82,
1330,
9626,
425,
12332,
82,
198,
6738,
410,
452,
17756,
13,
14681,
274,
13,
1082,
425,
62,
4743,
672,
874,
1330,
9626,
425,
9861,
672,
874,
198,
6738,
410,
452,
17756,
13,
14681,
274,
13,
21048,
62,
22208,
1330,
12200,
20273,
628,
198,
2235,
2325,
729,
5499,
198,
198,
4299,
4296,
62,
647,
469,
7,
14421,
62,
8367,
11,
649,
62,
8367,
2599,
198,
220,
220,
220,
37227,
13102,
469,
3205,
67,
729,
628,
220,
220,
220,
20559,
2886,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1459,
62,
8367,
357,
11600,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
649,
62,
8367,
357,
11600,
2599,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
8633,
25,
383,
24589,
286,
7559,
14421,
62,
8367,
15506,
290,
7559,
3605,
62,
8367,
15506,
13,
1114,
597,
198,
220,
220,
220,
220,
220,
220,
220,
4888,
8251,
11,
262,
1988,
287,
7559,
3605,
62,
8367,
15506,
318,
973,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
4296,
796,
1459,
62,
8367,
13,
30073,
3419,
198,
220,
220,
220,
329,
479,
11,
410,
287,
1459,
62,
8367,
13,
23814,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
649,
796,
649,
62,
8367,
13,
1136,
7,
74,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
39098,
7,
3605,
11,
8633,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4296,
58,
74,
60,
796,
2769,
62,
647,
469,
7,
11600,
7,
85,
828,
649,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4296,
58,
74,
60,
796,
649,
198,
220,
220,
220,
1441,
4296,
198,
198,
4299,
4296,
62,
2617,
7,
14421,
62,
8367,
11,
649,
62,
8367,
2599,
198,
220,
220,
220,
37227,
7248,
3205,
67,
729,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
383,
1988,
2810,
287,
7559,
3605,
62,
8367,
15506,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1441,
649,
62,
8367,
198,
198,
4299,
4296,
62,
4134,
388,
5039,
7,
14421,
62,
8367,
11,
649,
62,
8367,
2599,
198,
220,
220,
220,
37227,
17320,
388,
5039,
3205,
67,
729,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
383,
2160,
286,
7559,
14421,
62,
8367,
15506,
290,
7559,
3605,
62,
8367,
15506,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1441,
1459,
62,
8367,
1343,
649,
62,
8367,
198,
198,
2,
25,
20347,
2325,
729,
3891,
284,
2325,
729,
5499,
198,
929,
67,
729,
62,
32016,
796,
1391,
198,
220,
220,
220,
705,
4134,
388,
5039,
10354,
4296,
62,
4134,
388,
5039,
11,
198,
220,
220,
220,
705,
2617,
10354,
4296,
62,
2617,
11,
198,
220,
220,
220,
705,
647,
469,
10354,
4296,
62,
647,
469,
92,
198,
198,
2235,
2659,
1304,
5499,
198,
4299,
14083,
62,
2617,
7,
5219,
2599,
198,
220,
220,
220,
37227,
7248,
4777,
1304,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
317,
1351,
7559,
58,
5219,
11,
1181,
60,
15506,
13,
1400,
23345,
318,
6157,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1441,
685,
5219,
11,
1181,
60,
198,
198,
4299,
14083,
62,
35312,
7,
5219,
2599,
198,
220,
220,
220,
37227,
41205,
4777,
1304,
628,
220,
220,
220,
20559,
2886,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1181,
25,
12039,
307,
281,
1058,
9078,
25,
4871,
25,
63,
600,
47671,
257,
1058,
9078,
25,
4871,
25,
63,
22468,
47671,
393,
257,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
9078,
25,
4871,
25,
63,
2536,
63,
286,
1988,
7559,
18943,
6269,
15506,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
317,
1351,
11,
1123,
286,
3025,
4847,
4909,
2063,
286,
7559,
5219,
15506,
13,
1002,
198,
220,
220,
220,
220,
220,
220,
220,
7559,
5219,
15506,
318,
281,
1058,
9078,
25,
4871,
25,
63,
600,
47671,
262,
17675,
318,
4624,
379,
198,
220,
220,
220,
220,
220,
220,
220,
4738,
287,
530,
286,
262,
734,
4847,
13,
1002,
7559,
5219,
15506,
318,
15541,
11,
262,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1988,
318,
7559,
58,
5219,
11,
1181,
60,
15506,
357,
3919,
23345,
318,
1760,
737,
628,
220,
220,
220,
7567,
2696,
25,
198,
220,
220,
220,
220,
220,
220,
220,
35528,
25,
611,
7559,
5219,
15506,
318,
286,
281,
43483,
1143,
2099,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
318,
39098,
7,
5219,
11,
493,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
17675,
796,
1181,
4064,
362,
198,
220,
220,
220,
220,
220,
220,
220,
2063,
796,
493,
7,
5219,
1220,
362,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4738,
13,
25541,
26933,
17821,
11,
10352,
60,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
685,
13959,
1343,
17675,
11,
2063,
60,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
685,
13959,
11,
2063,
1343,
17675,
60,
198,
220,
220,
220,
1288,
361,
1181,
6624,
12178,
10786,
10745,
11537,
393,
1181,
6624,
705,
18943,
6269,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
617,
14587,
389,
3177,
15541,
287,
262,
2858,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
281,
5559,
3038,
318,
284,
407,
14083,
262,
1957,
2858,
1181,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
685,
5219,
11,
1181,
60,
198,
220,
220,
220,
1288,
361,
318,
39098,
7,
5219,
11,
357,
22468,
11,
39789,
8,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
2063,
796,
1181,
14,
17,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
685,
13959,
11,
2063,
60,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
35528,
10786,
5171,
407,
14083,
1181,
23884,
286,
2099,
23884,
4458,
18982,
7,
5219,
11,
2099,
7,
5219,
22305,
198,
198,
4299,
14083,
62,
22570,
7,
5219,
2599,
198,
220,
220,
220,
37227,
28667,
4777,
1304,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
7559,
58,
15,
11,
657,
60,
15506,
7692,
286,
5128,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1441,
685,
15,
11,
657,
60,
198,
198,
4299,
14083,
62,
35312,
62,
11600,
7,
5219,
2599,
198,
220,
220,
220,
37227,
41205,
12,
35,
14188,
4777,
1304,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
317,
1351,
286,
734,
48589,
3166,
13,
383,
717,
22155,
7000,
262,
198,
220,
220,
220,
220,
220,
220,
220,
717,
2063,
286,
262,
1994,
12,
8367,
14729,
287,
7559,
5219,
15506,
11,
290,
262,
1218,
198,
220,
220,
220,
220,
220,
220,
220,
22155,
7000,
262,
1334,
286,
262,
1994,
12,
8367,
14729,
13,
628,
220,
220,
220,
220,
220,
220,
220,
11485,
3465,
3712,
4619,
48589,
3166,
389,
555,
24071,
11,
345,
815,
3368,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1642,
597,
14895,
546,
543,
8251,
481,
307,
1908,
284,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
543,
4957,
2685,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
1181,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1181,
796,
23884,
198,
220,
220,
220,
288,
16,
796,
8633,
7,
4868,
7,
5219,
13,
23814,
28955,
58,
11925,
7,
5219,
8,
3373,
362,
25,
12962,
198,
220,
220,
220,
288,
17,
796,
8633,
7,
4868,
7,
5219,
13,
23814,
28955,
58,
25,
11925,
7,
5219,
8,
3373,
362,
12962,
198,
220,
220,
220,
1441,
685,
67,
16,
11,
288,
17,
60,
198,
198,
2,
25,
20347,
2659,
1304,
3891,
284,
2659,
1304,
5499,
198,
7146,
1304,
62,
32016,
796,
1391,
198,
220,
220,
220,
705,
2617,
10354,
14083,
62,
2617,
11,
198,
220,
220,
220,
705,
35312,
10354,
14083,
62,
35312,
11,
198,
220,
220,
220,
705,
35312,
62,
11600,
10354,
14083,
62,
35312,
62,
11600,
11,
198,
220,
220,
220,
705,
22570,
10354,
14083,
62,
22570,
92,
198,
198,
2,
9626,
1191,
198,
198,
2,
25,
20347,
4587,
1428,
3891,
284,
1058,
4354,
25,
63,
14681,
6097,
63,
198,
1082,
1428,
62,
32016,
796,
1391,
198,
220,
220,
220,
705,
3020,
349,
62,
1462,
62,
9127,
82,
10354,
9626,
425,
12332,
82,
11,
198,
220,
220,
220,
705,
9127,
82,
62,
1462,
62,
3020,
349,
10354,
9626,
425,
3103,
1087,
9143,
11,
198,
220,
220,
220,
705,
22208,
10354,
12200,
20273,
11,
198,
220,
220,
220,
705,
4743,
672,
874,
10354,
9626,
425,
9861,
672,
874,
11,
198,
92,
628,
198,
2,
23283,
11341,
198,
198,
46911,
7509,
62,
32016,
796,
1391,
198,
220,
220,
220,
705,
77,
32152,
10354,
399,
32152,
32634,
7509,
22784,
198,
92,
198
] | 2.935973 | 2,374 |
import torch
from torch import Tensor
def compute_accuracy(pred: Tensor, gt: Tensor, ignore: int = 0):
"""
pred (torch.Tensor): predicted words shape of [L, N]
gt (torch.Tensor): GT words shape of [L, N]
ignore (int): ignored label
"""
mask = gt != ignore
tp = torch.logical_and(pred == gt, mask)
return tp.sum() / mask.sum()
| [
11748,
28034,
198,
6738,
28034,
1330,
309,
22854,
628,
198,
4299,
24061,
62,
4134,
23843,
7,
28764,
25,
309,
22854,
11,
308,
83,
25,
309,
22854,
11,
8856,
25,
493,
796,
657,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2747,
357,
13165,
354,
13,
51,
22854,
2599,
11001,
2456,
5485,
286,
685,
43,
11,
399,
60,
198,
220,
220,
220,
308,
83,
357,
13165,
354,
13,
51,
22854,
2599,
7963,
2456,
5485,
286,
685,
43,
11,
399,
60,
198,
220,
220,
220,
8856,
357,
600,
2599,
9514,
6167,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
9335,
796,
308,
83,
14512,
8856,
198,
220,
220,
220,
256,
79,
796,
28034,
13,
6404,
605,
62,
392,
7,
28764,
6624,
308,
83,
11,
9335,
8,
628,
220,
220,
220,
1441,
256,
79,
13,
16345,
3419,
1220,
9335,
13,
16345,
3419,
628
] | 2.531469 | 143 |
from django.apps import AppConfig
| [
6738,
42625,
14208,
13,
18211,
1330,
2034,
16934,
628
] | 3.888889 | 9 |
# this is a make/python hybrid file
# Normal make files are a make/sh hybrid.
# This makefile uses python instead of sh (or bash)
test_cxx_sources ?=
checkcxxsources $(cxxsources):$(out_init)
$(origin)
if (this == "checkcxxsources") and (not os.path.exists(env.cxxsources)):
leave()
caption()
if (this == env.cxxsources):
lib_cxx, main_cxx = [],[]
quote = "'"
else:
quote = ""
test_cxx=[]
for root, dirs, files in os.walk(env.cxxsrc) :
for file in files:
if file.endswith(".cxx"):
cxx = quote+os.path.join(root, file)+quote
if root.endswith("/main"):
if (this == env.cxxsources): lib_cxx.append(cxx); main_cxx.append(cxx)
test_cxx.append(cxx)
elif root.endswith("/test"):
test_cxx.append(cxx)
test_cxx.sort()
if (this == env.cxxsources):
lib_cxx.sort()
main_cxx.sort()
with open (this, "w") as f:
f.write("# === Generated by %s:%s ===\n\n" % (env.MAKEFILE_LIST, this))
f.write("lib_cxx_sources := %s\n\n" % (",".join(lib_cxx)))
f.write("main_cxx_sources := %s\n\n" % (",".join(main_cxx)))
f.write("test_cxx_sources := %s\n\n" % (",".join(test_cxx)))
leave()
before = set([$(test_cxx_sources)])
after = set(test_cxx)
removed = str(before-after).replace(root_prefix,"")
added = str(after-before).replace(root_prefix,"")
removals = removed != "set()"
additions = added != "set()"
if removals or additions:
print ("cxx source files were added or removed\n")
if removals: print("removals:", removed)
if additions: print("additions:", added)
print ("\nForcing dependency and rule regeneration and re-link.\n")
run(env.MAKE, "re-dep")
cxx_dep0 := $(CXX), "-E", "--trace-includes", $(DEP_CXX_FLAGS)
cxx_dep1 := "-I$(cxxinc)", cxx, "-o/dev/null"
cxx_dep := $(cxx_dep0), $(cxx_dep1)
$(cxxdeps): $(cxxsources);$(caption)
queues, process = [],[]
fd_a=types.SimpleNamespace()
fd_a.gorge = gorge
fd_a.root = root_prefix_len
prefix = "test_cxx_sources := "
prefix_len = len(prefix)
with open(first) as f:
lines = f.readlines()
for line in lines:
if line.startswith(prefix):
sources = line[prefix_len:].rstrip()
test_cxx = sources.split(",")
for _cxx in test_cxx:
cxx = _cxx.replace("'","")
q = multiprocessing.Queue()
p = multiprocessing.Process(target=find_dep, args=(cxx, q, fd_a))
process.append(p)
queues.append(q)
p.start()
break
with open (this, "w") as f:
f.write("# === Generated by %s:%s ===\n\n" % (env.MAKEFILE_LIST, this))
n = 1
for q in queues:
obj = q.get()
deps = q.get()
f.write("\n# %d\n%s := " % (n, obj))
f.write(" ".join(deps))
f.write("\n")
n+=1
for p in process: p.join()
$(objrules): $(cxxdeps); $(caption)
suffix = "_obj_deps"
prefix = "cxxsrc_"
main_prefix = prefix + "main_"
test_prefix = prefix + "test_"
sep = " := "
sep_len = len(sep)
prefix_len = len(prefix)
main_obj0, test_obj0, lib_obj0 = [],[],[]
main_objs, test_objs, lib_objs = {},{},{}
cxx_ext = ".cxx"
cxx_ext_len = len(cxx_ext)
with open(first) as f:
lines = f.readlines()
for line in lines:
if line.startswith(prefix):
i = line.find(sep)
if i == -1: raise RuntimeError("Source deps line not formatted correctly")
deps = line[:i]
sources = line [i+sep_len:]
j = sources.find(cxx_ext)+cxx_ext_len
if j == -1: raise RuntimeError("Source deps line not formatted correctly")
cxxfile = sources[root_prefix_len:j]
cxxfile_i = "need to work on ctfe wrapper..."
deps1 = deps.replace(suffix,".o")
deps1 = deps1.replace("cxxsrc","$$(obj)")
deps1 = deps1.replace("_","/",2)
obj = deps1
if deps.startswith(main_prefix):
lib_obj = obj.replace("$$(obj)/main","$$(obj)/lib")
test_obj = obj.replace("$$(obj)/main/","$$(obj)/test/main__")
main_objs[obj] = (cxxfile,deps,cxxfile_i)
lib_objs[lib_obj] = (cxxfile,deps,cxxfile_i)
test_objs[test_obj] = (cxxfile,deps,cxxfile_i)
main_obj0.append(obj)
lib_obj0.append(lib_obj)
test_obj0.append(test_obj)
continue
if deps.startswith(test_prefix):
test_objs[obj] = (cxxfile,deps,cxxfile_i)
test_obj0.append(obj)
with open (this, "w") as f:
f.write("# === Generated by %s:%s ===\n\n" % (env.MAKEFILE_LIST, this))
f.write("\nmain_exe_objects := %s\n" % (" ".join(main_obj0)))
f.write("\nlib_so_objects := %s\n" % (" ".join(lib_obj0)))
f.write("\ntest_exe_objects := %s\n" % (" ".join(test_obj0)))
f.write("\n__main_exe_objects__ := %s\n" % (make_quoted_list(main_obj0)))
f.write("\n__lib_so_objects__ := %s\n" % (make_quoted_list(lib_obj0)))
f.write("\n__test_exe_objects__ := %s\n" % (make_quoted_list(test_obj0)))
ipch = "'-include-pch',"
rule = "$$(__CXX_FLAGS), '-c', '$$<', '-o$$@'"
main = ipch + "'$$(main_sysheaders_pch)'," + rule + ", $$(MAIN_EXTRA)"
test = ipch + "'$$(test_sysheaders_pch)'," + rule + ", $$(TEST_EXTRA)"
lib = ipch + "'$$(lib_sysheaders_pch)'," + rule + ", $$(LIB_EXTRA)"
cxx = "$$(CXX)"
main_d = "$$(obj_main_init) $$(main_sysheaders_pch)"
lib_d = "$$(obj_lib_init) $$(lib_sysheaders_pch)"
test_d = "$$(obj_test_init) $$(test_sysheaders_pch)"
target("main", main_objs, main, cxx, main_d, f)
target("lib", lib_objs, lib, cxx, lib_d, f)
target("test", test_objs, test, cxx, test_d, f)
| [
2,
428,
318,
257,
787,
14,
29412,
14554,
2393,
198,
198,
2,
14435,
787,
3696,
389,
257,
787,
14,
1477,
14554,
13,
198,
2,
770,
787,
7753,
3544,
21015,
2427,
286,
427,
357,
273,
27334,
8,
198,
198,
9288,
62,
66,
5324,
62,
82,
2203,
5633,
28,
198,
198,
9122,
66,
5324,
82,
2203,
29568,
66,
5324,
82,
2203,
2599,
3,
7,
448,
62,
15003,
8,
198,
220,
29568,
47103,
8,
198,
220,
611,
357,
5661,
6624,
366,
9122,
66,
5324,
82,
2203,
4943,
290,
357,
1662,
28686,
13,
6978,
13,
1069,
1023,
7,
24330,
13,
66,
5324,
82,
2203,
8,
2599,
198,
220,
220,
220,
2666,
3419,
198,
220,
8305,
3419,
628,
220,
611,
357,
5661,
6624,
17365,
13,
66,
5324,
82,
2203,
2599,
198,
220,
220,
220,
9195,
62,
66,
5324,
11,
1388,
62,
66,
5324,
796,
685,
4357,
21737,
198,
220,
220,
220,
9577,
796,
24018,
1,
198,
220,
2073,
25,
198,
220,
220,
220,
9577,
796,
13538,
628,
220,
1332,
62,
66,
5324,
28,
21737,
628,
220,
329,
6808,
11,
288,
17062,
11,
3696,
287,
28686,
13,
11152,
7,
24330,
13,
66,
5324,
10677,
8,
1058,
198,
220,
220,
220,
329,
2393,
287,
3696,
25,
198,
220,
220,
220,
220,
220,
611,
2393,
13,
437,
2032,
342,
7,
1911,
66,
5324,
1,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
269,
5324,
796,
9577,
10,
418,
13,
6978,
13,
22179,
7,
15763,
11,
2393,
47762,
22708,
198,
220,
220,
220,
220,
220,
220,
220,
611,
6808,
13,
437,
2032,
342,
7203,
14,
12417,
1,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
357,
5661,
6624,
17365,
13,
66,
5324,
82,
2203,
2599,
9195,
62,
66,
5324,
13,
33295,
7,
66,
5324,
1776,
1388,
62,
66,
5324,
13,
33295,
7,
66,
5324,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
66,
5324,
13,
33295,
7,
66,
5324,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
6808,
13,
437,
2032,
342,
7203,
14,
9288,
1,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
66,
5324,
13,
33295,
7,
66,
5324,
8,
628,
220,
1332,
62,
66,
5324,
13,
30619,
3419,
628,
220,
611,
357,
5661,
6624,
17365,
13,
66,
5324,
82,
2203,
2599,
198,
220,
220,
220,
9195,
62,
66,
5324,
13,
30619,
3419,
198,
220,
220,
220,
1388,
62,
66,
5324,
13,
30619,
3419,
198,
220,
220,
220,
351,
1280,
357,
5661,
11,
366,
86,
4943,
355,
277,
25,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
2,
24844,
2980,
515,
416,
4064,
82,
25,
4,
82,
24844,
59,
77,
59,
77,
1,
4064,
357,
24330,
13,
5673,
7336,
25664,
62,
45849,
11,
428,
4008,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
8019,
62,
66,
5324,
62,
82,
2203,
19039,
4064,
82,
59,
77,
59,
77,
1,
4064,
357,
2430,
13,
22179,
7,
8019,
62,
66,
5324,
22305,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
12417,
62,
66,
5324,
62,
82,
2203,
19039,
4064,
82,
59,
77,
59,
77,
1,
4064,
357,
2430,
13,
22179,
7,
12417,
62,
66,
5324,
22305,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
9288,
62,
66,
5324,
62,
82,
2203,
19039,
4064,
82,
59,
77,
59,
77,
1,
4064,
357,
2430,
13,
22179,
7,
9288,
62,
66,
5324,
22305,
198,
220,
220,
220,
2666,
3419,
628,
220,
878,
796,
900,
26933,
3,
7,
9288,
62,
66,
5324,
62,
82,
2203,
8,
12962,
198,
220,
706,
796,
900,
7,
9288,
62,
66,
5324,
8,
198,
220,
4615,
796,
965,
7,
19052,
12,
8499,
737,
33491,
7,
15763,
62,
40290,
553,
4943,
198,
220,
2087,
796,
965,
7,
8499,
12,
19052,
737,
33491,
7,
15763,
62,
40290,
553,
4943,
198,
220,
816,
709,
874,
796,
4615,
14512,
366,
2617,
3419,
1,
198,
220,
19885,
796,
2087,
14512,
366,
2617,
3419,
1,
198,
220,
611,
816,
709,
874,
393,
19885,
25,
198,
220,
220,
220,
3601,
5855,
66,
5324,
2723,
3696,
547,
2087,
393,
4615,
59,
77,
4943,
198,
220,
220,
220,
611,
816,
709,
874,
25,
3601,
7203,
2787,
709,
874,
25,
1600,
4615,
8,
198,
220,
220,
220,
611,
19885,
25,
3601,
7203,
2860,
1756,
25,
1600,
2087,
8,
198,
220,
220,
220,
3601,
5855,
59,
77,
1890,
2259,
20203,
290,
3896,
27597,
290,
302,
12,
8726,
13,
59,
77,
4943,
198,
220,
220,
220,
1057,
7,
24330,
13,
5673,
7336,
11,
366,
260,
12,
10378,
4943,
198,
198,
66,
5324,
62,
10378,
15,
19039,
29568,
34,
8051,
828,
27444,
36,
1600,
366,
438,
40546,
12,
42813,
1600,
29568,
46162,
62,
34,
8051,
62,
38948,
50,
8,
198,
66,
5324,
62,
10378,
16,
19039,
27444,
40,
3,
7,
66,
5324,
1939,
42501,
269,
5324,
11,
27444,
78,
14,
7959,
14,
8423,
1,
198,
66,
5324,
62,
10378,
19039,
29568,
66,
5324,
62,
10378,
15,
828,
29568,
66,
5324,
62,
10378,
16,
8,
198,
198,
3,
7,
66,
5324,
10378,
82,
2599,
29568,
66,
5324,
82,
2203,
1776,
3,
7,
6888,
1159,
8,
628,
220,
43359,
11,
1429,
796,
685,
4357,
21737,
198,
220,
277,
67,
62,
64,
28,
19199,
13,
26437,
36690,
10223,
3419,
198,
220,
277,
67,
62,
64,
13,
70,
3643,
796,
17177,
198,
220,
277,
67,
62,
64,
13,
15763,
796,
6808,
62,
40290,
62,
11925,
628,
220,
21231,
796,
366,
9288,
62,
66,
5324,
62,
82,
2203,
19039,
366,
198,
220,
21231,
62,
11925,
796,
18896,
7,
40290,
8,
628,
220,
351,
1280,
7,
11085,
8,
355,
277,
25,
198,
220,
220,
220,
3951,
796,
277,
13,
961,
6615,
3419,
198,
220,
220,
220,
329,
1627,
287,
3951,
25,
198,
220,
220,
220,
220,
220,
611,
1627,
13,
9688,
2032,
342,
7,
40290,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
4237,
796,
1627,
58,
40290,
62,
11925,
25,
4083,
81,
36311,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
66,
5324,
796,
4237,
13,
35312,
7,
2430,
8,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4808,
66,
5324,
287,
1332,
62,
66,
5324,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
5324,
796,
4808,
66,
5324,
13,
33491,
7203,
6,
2430,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10662,
796,
18540,
305,
919,
278,
13,
34991,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
796,
18540,
305,
919,
278,
13,
18709,
7,
16793,
28,
19796,
62,
10378,
11,
26498,
16193,
66,
5324,
11,
10662,
11,
277,
67,
62,
64,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1429,
13,
33295,
7,
79,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43359,
13,
33295,
7,
80,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
13,
9688,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2270,
628,
220,
351,
1280,
357,
5661,
11,
366,
86,
4943,
355,
277,
25,
198,
220,
220,
220,
277,
13,
13564,
7203,
2,
24844,
2980,
515,
416,
4064,
82,
25,
4,
82,
24844,
59,
77,
59,
77,
1,
4064,
357,
24330,
13,
5673,
7336,
25664,
62,
45849,
11,
428,
4008,
198,
220,
220,
220,
299,
796,
352,
198,
220,
220,
220,
329,
10662,
287,
43359,
25,
198,
220,
220,
220,
220,
220,
26181,
796,
10662,
13,
1136,
3419,
198,
220,
220,
220,
220,
220,
390,
862,
796,
10662,
13,
1136,
3419,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
2,
4064,
67,
59,
77,
4,
82,
19039,
366,
4064,
357,
77,
11,
26181,
4008,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
27071,
22179,
7,
10378,
82,
4008,
198,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
299,
47932,
16,
628,
220,
329,
279,
287,
1429,
25,
279,
13,
22179,
3419,
198,
198,
3,
7,
26801,
38785,
2599,
29568,
66,
5324,
10378,
82,
1776,
29568,
6888,
1159,
8,
198,
220,
35488,
796,
45434,
26801,
62,
10378,
82,
1,
198,
220,
21231,
796,
366,
66,
5324,
10677,
62,
1,
198,
220,
1388,
62,
40290,
796,
21231,
1343,
366,
12417,
62,
1,
198,
220,
1332,
62,
40290,
796,
21231,
1343,
366,
9288,
62,
1,
198,
220,
41767,
796,
366,
19039,
366,
198,
220,
41767,
62,
11925,
796,
18896,
7,
325,
79,
8,
198,
220,
21231,
62,
11925,
796,
18896,
7,
40290,
8,
628,
220,
1388,
62,
26801,
15,
11,
1332,
62,
26801,
15,
11,
9195,
62,
26801,
15,
796,
685,
38430,
4357,
21737,
198,
220,
1388,
62,
672,
8457,
11,
1332,
62,
672,
8457,
11,
9195,
62,
672,
8457,
796,
1391,
5512,
90,
5512,
90,
92,
628,
220,
269,
5324,
62,
2302,
796,
27071,
66,
5324,
1,
198,
220,
269,
5324,
62,
2302,
62,
11925,
796,
18896,
7,
66,
5324,
62,
2302,
8,
628,
220,
351,
1280,
7,
11085,
8,
355,
277,
25,
198,
220,
220,
220,
3951,
796,
277,
13,
961,
6615,
3419,
198,
220,
220,
220,
329,
1627,
287,
3951,
25,
198,
220,
220,
220,
220,
220,
611,
1627,
13,
9688,
2032,
342,
7,
40290,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1312,
796,
1627,
13,
19796,
7,
325,
79,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1312,
6624,
532,
16,
25,
5298,
43160,
12331,
7203,
7416,
390,
862,
1627,
407,
39559,
9380,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
390,
862,
796,
1627,
58,
25,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4237,
796,
1627,
685,
72,
10,
325,
79,
62,
11925,
47715,
198,
220,
220,
220,
220,
220,
220,
220,
474,
796,
4237,
13,
19796,
7,
66,
5324,
62,
2302,
47762,
66,
5324,
62,
2302,
62,
11925,
198,
220,
220,
220,
220,
220,
220,
220,
611,
474,
6624,
532,
16,
25,
5298,
43160,
12331,
7203,
7416,
390,
862,
1627,
407,
39559,
9380,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
269,
5324,
7753,
796,
4237,
58,
15763,
62,
40290,
62,
11925,
25,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
269,
5324,
7753,
62,
72,
796,
366,
31227,
284,
670,
319,
269,
83,
5036,
29908,
9313,
198,
220,
220,
220,
220,
220,
220,
220,
390,
862,
16,
796,
390,
862,
13,
33491,
7,
37333,
844,
553,
13,
78,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
390,
862,
16,
796,
390,
862,
16,
13,
33491,
7203,
66,
5324,
10677,
2430,
13702,
7,
26801,
8,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
390,
862,
16,
796,
390,
862,
16,
13,
33491,
7203,
62,
2430,
14,
1600,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
26181,
796,
390,
862,
16,
198,
220,
220,
220,
220,
220,
220,
220,
611,
390,
862,
13,
9688,
2032,
342,
7,
12417,
62,
40290,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9195,
62,
26801,
796,
26181,
13,
33491,
7203,
13702,
7,
26801,
20679,
12417,
2430,
13702,
7,
26801,
20679,
8019,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
26801,
796,
26181,
13,
33491,
7203,
13702,
7,
26801,
20679,
12417,
14,
2430,
13702,
7,
26801,
20679,
9288,
14,
12417,
834,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1388,
62,
672,
8457,
58,
26801,
60,
796,
357,
66,
5324,
7753,
11,
10378,
82,
11,
66,
5324,
7753,
62,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9195,
62,
672,
8457,
58,
8019,
62,
26801,
60,
796,
357,
66,
5324,
7753,
11,
10378,
82,
11,
66,
5324,
7753,
62,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
672,
8457,
58,
9288,
62,
26801,
60,
796,
357,
66,
5324,
7753,
11,
10378,
82,
11,
66,
5324,
7753,
62,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1388,
62,
26801,
15,
13,
33295,
7,
26801,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9195,
62,
26801,
15,
13,
33295,
7,
8019,
62,
26801,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
26801,
15,
13,
33295,
7,
9288,
62,
26801,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
611,
390,
862,
13,
9688,
2032,
342,
7,
9288,
62,
40290,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
672,
8457,
58,
26801,
60,
796,
357,
66,
5324,
7753,
11,
10378,
82,
11,
66,
5324,
7753,
62,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
26801,
15,
13,
33295,
7,
26801,
8,
628,
220,
351,
1280,
357,
5661,
11,
366,
86,
4943,
355,
277,
25,
198,
220,
220,
220,
277,
13,
13564,
7203,
2,
24844,
2980,
515,
416,
4064,
82,
25,
4,
82,
24844,
59,
77,
59,
77,
1,
4064,
357,
24330,
13,
5673,
7336,
25664,
62,
45849,
11,
428,
4008,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
12417,
62,
13499,
62,
48205,
19039,
4064,
82,
59,
77,
1,
4064,
5855,
27071,
22179,
7,
12417,
62,
26801,
15,
22305,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
8019,
62,
568,
62,
48205,
19039,
4064,
82,
59,
77,
1,
4064,
5855,
27071,
22179,
7,
8019,
62,
26801,
15,
22305,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
429,
395,
62,
13499,
62,
48205,
19039,
4064,
82,
59,
77,
1,
4064,
5855,
27071,
22179,
7,
9288,
62,
26801,
15,
22305,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
834,
12417,
62,
13499,
62,
48205,
834,
19039,
4064,
82,
59,
77,
1,
4064,
357,
15883,
62,
421,
5191,
62,
4868,
7,
12417,
62,
26801,
15,
22305,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
834,
8019,
62,
568,
62,
48205,
834,
19039,
4064,
82,
59,
77,
1,
4064,
357,
15883,
62,
421,
5191,
62,
4868,
7,
8019,
62,
26801,
15,
22305,
198,
220,
220,
220,
277,
13,
13564,
7203,
59,
77,
834,
9288,
62,
13499,
62,
48205,
834,
19039,
4064,
82,
59,
77,
1,
4064,
357,
15883,
62,
421,
5191,
62,
4868,
7,
9288,
62,
26801,
15,
22305,
628,
220,
220,
220,
20966,
354,
796,
24018,
12,
17256,
12,
79,
354,
40264,
198,
220,
220,
220,
3896,
796,
366,
13702,
7,
834,
34,
8051,
62,
38948,
50,
828,
705,
12,
66,
3256,
705,
13702,
27,
3256,
705,
12,
78,
13702,
31,
29653,
198,
220,
220,
220,
1388,
796,
20966,
354,
1343,
24018,
13702,
7,
12417,
62,
17597,
50145,
62,
79,
354,
33047,
553,
1343,
3896,
1343,
33172,
32382,
7,
5673,
1268,
62,
13918,
3861,
16725,
198,
220,
220,
220,
1332,
796,
20966,
354,
1343,
24018,
13702,
7,
9288,
62,
17597,
50145,
62,
79,
354,
33047,
553,
1343,
3896,
1343,
33172,
32382,
7,
51,
6465,
62,
13918,
3861,
16725,
198,
220,
220,
220,
9195,
796,
20966,
354,
1343,
24018,
13702,
7,
8019,
62,
17597,
50145,
62,
79,
354,
33047,
553,
1343,
3896,
1343,
33172,
32382,
7,
40347,
62,
13918,
3861,
16725,
198,
220,
220,
220,
269,
5324,
796,
366,
13702,
7,
34,
8051,
16725,
628,
220,
220,
220,
1388,
62,
67,
796,
366,
13702,
7,
26801,
62,
12417,
62,
15003,
8,
32382,
7,
12417,
62,
17597,
50145,
62,
79,
354,
16725,
198,
220,
220,
220,
9195,
62,
67,
796,
366,
13702,
7,
26801,
62,
8019,
62,
15003,
8,
32382,
7,
8019,
62,
17597,
50145,
62,
79,
354,
16725,
198,
220,
220,
220,
1332,
62,
67,
796,
366,
13702,
7,
26801,
62,
9288,
62,
15003,
8,
32382,
7,
9288,
62,
17597,
50145,
62,
79,
354,
16725,
628,
220,
220,
220,
2496,
7203,
12417,
1600,
1388,
62,
672,
8457,
11,
1388,
11,
269,
5324,
11,
1388,
62,
67,
11,
277,
8,
198,
220,
220,
220,
2496,
7203,
8019,
1600,
9195,
62,
672,
8457,
11,
9195,
11,
269,
5324,
11,
9195,
62,
67,
11,
277,
8,
198,
220,
220,
220,
2496,
7203,
9288,
1600,
1332,
62,
672,
8457,
11,
1332,
11,
269,
5324,
11,
1332,
62,
67,
11,
277,
8,
198
] | 2.09716 | 2,676 |
from binance.lib.utils import (
check_required_parameter,
)
from binance.lib.utils import check_required_parameters
def ping(self):
"""
|
| **Test Connectivity**
| *Test connectivity to the Rest API.*
:API endpoint: ``GET /dapi/v1/ping``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#test-connectivity
|
"""
url_path = "/dapi/v1/ping"
return self.query(url_path)
def time(self):
"""
|
| **Check Server Time**
| *Test connectivity to the Rest API and get the current server time.*
:API endpoint: ``GET /dapi/v1/time``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#check-server-time
|
"""
url_path = "/dapi/v1/time"
return self.query(url_path)
def exchange_info(self):
"""
|
| **Exchange Information**
| *Current exchange trading rules and symbol information*
:API endpoint: ``GET /dapi/v1/exchangeInfo``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#exchange-information
|
"""
url_path = "/dapi/v1/exchangeInfo"
return self.query(url_path)
def depth(self, symbol: str, **kwargs):
"""
|
| **Get Orderbook**
:API endpoint: ``GET /dapi/v1/depth``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#order-book
:parameter symbol: string; the trading pair
:parameter limit: optional int; limit the results. Default 500, valid limits: [5, 10, 20, 50, 100, 500, 1000].
|
"""
check_required_parameter(symbol, "symbol")
params = {"symbol": symbol, **kwargs}
return self.query("/dapi/v1/depth", params)
def trades(self, symbol: str, **kwargs):
"""
|
| **Get Recent Market Trades**
:API endpoint: ``GET /dapi/v1/trades``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#recent-trades-list
:parameter symbol: string; the trading pair
:parameter limit: optional int; limit the results. Default 500, max 1000.
|
"""
check_required_parameter(symbol, "symbol")
params = {"symbol": symbol, **kwargs}
return self.query("/dapi/v1/trades", params)
def historical_trades(self, symbol: str, **kwargs):
"""
|
| **Old Trade Lookup**
| *Get older market historical trades.*
:API endpoint: ``GET /dapi/v1/historicalTrades``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#old-trades-lookup-market_data
:parameter symbol: string; the trading pair
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter formId: optional int; trade ID to fetch from. Default gets most recent trades.
|
"""
check_required_parameter(symbol, "symbol")
params = {"symbol": symbol, **kwargs}
return self.limit_request("GET", "/dapi/v1/historicalTrades", params)
def agg_trades(self, symbol: str, **kwargs):
"""
|
| **Compressed/Aggregate Trades List**
| *Get compressed, aggregate market trades. Market trades that fill at the time, from the same order, with the same price will have the quantity aggregated.*
:API endpoint: ``GET /dapi/v1/aggTrades``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#compressed-aggregate-trades-list
:parameter symbol: string; the trading pair
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter formId: optional int; trade ID to fetch from. Default gets most recent trades.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
|
"""
check_required_parameter(symbol, "symbol")
params = {"symbol": symbol, **kwargs}
return self.query("/dapi/v1/aggTrades", params)
def klines(self, symbol: str, interval: str, **kwargs):
"""
|
| **Kline/Candlestick Data**
| *Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.*
:API endpoint: ``GET /dapi/v1/klines``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
:parameter symbol: string; the trading pair
:parameter interval: string; the interval of kline, e.g 1m, 5m, 1h, 1d, etc. (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
|
"""
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
params = {"symbol": symbol, "interval": interval, **kwargs}
return self.query("/dapi/v1/klines", params)
def continuous_klines(self, pair: str, contractType: str, interval: str, **kwargs):
"""
|
| **Continuous Kline/Candlestick Data**
| *Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.*
:API endpoint: ``GET /dapi/v1/continuousKlines``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#continuous-contract-kline-candlestick-data
:parameter pair: string; the trading pair
:parameter contractType: string; PERPETUAL, CURRENT_MONTH, NEXT_MONTH, CURRENT_QUARTER, NEXT_QUARTER.
:parameter interval: string; the interval of kline, e.g 1m, 5m, 1h, 1d, etc. (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
|
"""
check_required_parameters([[pair, "pair"], [contractType,"contractType"], [interval, "interval"]])
params = {"pair": pair, "contractType":contractType, "interval": interval, **kwargs}
return self.query("/dapi/v1/continuousKlines", params)
def index_price_klines(self, pair: str, interval: str, **kwargs):
"""
|
| **Kline/Candlestick Data for the index price of a pair.**
| *Klines are uniquely identified by their open time.*
:API endpoint: ``GET /dapi/v1/indexPriceKlines``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#index-price-kline-candlestick-data
:parameter pair: string; the trading pair
:parameter interval: string; the interval of kline, e.g 1m, 5m, 1h, 1d, etc. (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
|
"""
check_required_parameters([[pair, "pair"], [interval, "interval"]])
params = {"pair": pair, "interval": interval, **kwargs}
return self.query("/dapi/v1/indexPriceKlines", params)
def mark_price_klines(self, symbol: str, interval: str, **kwargs):
"""
|
| **Kline/candlestick bars for the mark price of a symbol.**
| *Klines are uniquely identified by their open time.*
:API endpoint: ``GET /dapi/v1/markPriceKlines``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-data
:parameter pair: string; the trading pair
:parameter interval: string; the interval of kline, e.g 1m, 5m, 1h, 1d, etc. (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
**Notes**
- The difference between startTime and endTime can only be up to 200 days
- Between startTime and endTime, the most recent limit data from endTime will be returned:
- If startTime and endTime are not sent, current timestamp will be set as endTime, and the most recent data will be returned.
- If startTime is sent only, the timestamp of 200 days after startTime will be set as endTime(up to the current time)
- If endTime is sent only, the timestamp of 200 days before endTime will be set as startTime
|
"""
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
params = {"symbol": symbol, "interval": interval, **kwargs}
return self.query("/dapi/v1/markPriceKlines", params)
def mark_price(self, symbol: str):
"""
|
| **Mark Price and Funding Rate**
:API endpoint: ``GET /dapi/v1/premiumIndex``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
:parameter symbol: string; the trading pair
|
"""
check_required_parameter(symbol, "symbol")
params = {
"symbol": symbol,
}
return self.query("/dapi/v1/premiumIndex", params)
def funding_rate(self, symbol: str, **kwargs):
"""
|
| **Funding Rate History**
:API endpoint: ``GET /dapi/v1/fundingRate``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#get-funding-rate-history-of-perpetual-futures
:parameter symbol: string; the trading pair
:parameter limit: optional int; limit the results. Default 500, max 1000.
:parameter startTime: optional int; Timestamp in ms to get aggregate trades from INCLUSIVE.
:parameter endTime: optional int; Timestamp in ms to get aggregate trades until INCLUSIVE.
**Notes**
- Empty array will be returned for delivery symbols.
|
"""
params = {"symbol": symbol, **kwargs}
return self.query("/dapi/v1/fundingRate", params)
def ticker_24hr_price_change(self, symbol: str = None, pair: str = None):
"""
|
| **24 hour rolling window price change statistics.**
| *Careful when accessing this with no symbol.*
| *If the symbol is not sent, tickers for all symbols will be returned in an array.*
:API endpoint: ``GET /dapi/v1/ticker/24hr``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics
:parameter symbol: optional string; the trading symbol
:parameter pair: optional string; the trading pair
**Notes**
- Symbol and pair cannot be sent together
- If a pair is sent, tickers for all symbols of the pair will be returned
- If either a pair or symbol is sent, tickers for all symbols of all pairs will be returned
|
"""
if (symbol is None) and (pair is None):
return self.query("/dapi/v1/ticker/24hr")
elif (symbol is None):
params = {"pair": pair}
else:
params = {"symbol": symbol}
return self.query("/dapi/v1/ticker/24hr", params)
def ticker_price(self, symbol: str = None, pair: str = None):
"""
|
| **Latest price for a symbol or symbols**
:API endpoint: ``GET /dapi/v1/ticker/price``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker
:parameter symbol: optional string; the trading symbol
:parameter pair: optional string; the trading pair
**Notes**
- Symbol and pair cannot be sent together
- If a pair is sent,tickers for all symbols of the pair will be returned
- If either a pair or symbol is sent, tickers for all symbols of all pairs will be returned
|
"""
if (symbol is None) and (pair is None):
return self.query("/dapi/v1/ticker/price")
elif (symbol is None):
params = {"pair": pair}
else:
params = {"symbol": symbol}
return self.query("/dapi/v1/ticker/price", params)
def book_ticker(self, symbol: str = None, pair: str = None):
"""
|
| **Best price/qty on the order book for a symbol or symbols**
:API endpoint: ``GET /dapi/v1/ticker/bookTicker``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker
:parameter symbol: optional string; the trading symbol
**Notes**
- If the symbol is not sent, bookTickers for all symbols will be returned in an array.
|
"""
if (symbol is None) and (pair is None):
return self.query("/dapi/v1/ticker/bookTicker")
elif (symbol is None):
params = {"pair": pair}
else:
params = {"symbol": symbol}
return self.query("/dapi/v1/ticker/bookTicker", params)
def open_interest(self, symbol: str):
"""
|
| **Get present open interest of a specific symbol**
:API endpoint: ``GET /dapi/v1/openInterest``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#open-interest
:parameter symbol: string; the trading symbol
|
"""
check_required_parameter(symbol, "symbol")
params = {"symbol": symbol}
return self.query("/dapi/v1/ticker/bookTicker", params)
def open_interest_hist(self, pair: str, contractType: str, period: str, **kwargs):
"""
|
| **Get historical open interest of a specific symbol**
:API endpoint: ``GET /futures/data/openInterestHist``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#open-interest-statistics-market-data
:parameter pair: string; the trading pair
:parameter contractType: string; ALL, CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL.
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [contractType, "contractType"], [period, "period"]])
params = {"pair": pair, "contractType": contractType, "period": period, **kwargs}
return self.query("/futures/data/openInterestHist", params)
def top_long_short_account_ratio(self, pair: str, period: str, **kwargs):
"""
|
| **Get top long short account ratio**
:API endpoint: `GET /futures/data/topLongShortAccountRatio`
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#top-trader-long-short-ratio-accounts-market-data
:parameter pair: string; the trading pair
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [period, "period"]])
params = {"pair": pair, "period": period, **kwargs}
return self.query("/futures/data/topLongShortAccountRatio", params)
def top_long_short_position_ratio(self, pair: str, period: str, **kwargs):
"""
|
| **Get top long short position ratio**
:API endpoint: ``GET /futures/data/topLongShortPositionRatio``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#top-trader-long-short-ratio-positions-market-data
:parameter pair: string; the trading pair
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [period, "period"]])
params = {"pair": pair, "period": period, **kwargs}
return self.query("/futures/data/topLongShortPositionRatio", params)
def long_short_account_ratio(self, pair: str, period: str, **kwargs):
"""
|
| **Get top long short account ratio**
:API endpoint: ``GET /futures/data/globalLongShortAccountRatio``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#top-trader-long-short-ratio-accounts-market-data
:parameter pair: string; the trading pair
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [period, "period"]])
params = {"pair": pair, "period": period, **kwargs}
return self.query("/futures/data/globalLongShortAccountRatio", params)
def taker_long_short_ratio(self, pair: str, contractType: str, period: str, **kwargs):
"""
|
| **Get taker long short ratio**
:API endpoint: ``GET /futures/data/takerBuySellVol``
:API doc: https://binance-docs.github.io/apidocs/delivery/en/#taker-buy-sell-volume-market-data
:parameter pair: string; the trading pair
:parameter contractType: string; CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL.
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [contractType, "contractType"], [period, "period"]])
params = {"pair": pair, "contractType": contractType, "period": period, **kwargs}
return self.query("/futures/data/takerBuySellVol", params)
def basis(self, pair: str, contractType: str, period: str, **kwargs):
"""
|
| **Get Index Composite**
:API endpoint: ``GET /futures/data/basis``
:API doc: xshttps://binance-docs.github.io/apidocs/delivery/en/#basis-market-data
:parameter pair: string; the trading pair
:parameter contractType: string; CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL.
:parameter period: string; the period of open interest, "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d". (see more in https://binance-docs.github.io/apidocs/delivery/en/#public-endpoints-info)
:parameter limit: optional int; limit the results. Default 30, max 500.
:parameter startTime: optional int
:parameter endTime: optional int
**Notes**
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
|
"""
check_required_parameters([[pair, "pair"], [contractType, "contractType"], [period, "period"]])
params = {"pair": pair, "contractType": contractType, "period": period, **kwargs}
return self.query("/futures/data/basis", params)
| [
6738,
9874,
590,
13,
8019,
13,
26791,
1330,
357,
198,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
11,
198,
8,
198,
6738,
9874,
590,
13,
8019,
13,
26791,
1330,
2198,
62,
35827,
62,
17143,
7307,
628,
198,
4299,
29400,
7,
944,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
14402,
8113,
3458,
1174,
198,
220,
220,
220,
930,
1635,
14402,
19843,
284,
262,
8324,
7824,
15885,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
13886,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9288,
12,
8443,
3458,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
19016,
62,
6978,
796,
12813,
67,
15042,
14,
85,
16,
14,
13886,
1,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7,
6371,
62,
6978,
8,
628,
198,
4299,
640,
7,
944,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
9787,
9652,
3862,
1174,
198,
220,
220,
220,
930,
1635,
14402,
19843,
284,
262,
8324,
7824,
290,
651,
262,
1459,
4382,
640,
15885,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
2435,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9122,
12,
15388,
12,
2435,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
19016,
62,
6978,
796,
12813,
67,
15042,
14,
85,
16,
14,
2435,
1,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7,
6371,
62,
6978,
8,
628,
198,
4299,
5163,
62,
10951,
7,
944,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3109,
3803,
6188,
1174,
198,
220,
220,
220,
930,
1635,
11297,
5163,
7313,
3173,
290,
6194,
1321,
9,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
1069,
3803,
12360,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
1069,
3803,
12,
17018,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
19016,
62,
6978,
796,
12813,
67,
15042,
14,
85,
16,
14,
1069,
3803,
12360,
1,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7,
6371,
62,
6978,
8,
628,
198,
4299,
6795,
7,
944,
11,
6194,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
8284,
2070,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
18053,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
2875,
12,
2070,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
4938,
7095,
25,
685,
20,
11,
838,
11,
1160,
11,
2026,
11,
1802,
11,
5323,
11,
8576,
4083,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
18053,
1600,
42287,
8,
628,
198,
4299,
17674,
7,
944,
11,
6194,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
22926,
5991,
833,
2367,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
2213,
2367,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
49921,
12,
2213,
2367,
12,
4868,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
198,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
2213,
2367,
1600,
42287,
8,
628,
198,
4299,
6754,
62,
2213,
2367,
7,
944,
11,
6194,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
19620,
9601,
6803,
929,
1174,
198,
220,
220,
220,
930,
1635,
3855,
4697,
1910,
6754,
17674,
15885,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
10034,
12409,
2898,
2367,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
727,
12,
2213,
2367,
12,
5460,
929,
12,
10728,
62,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
1296,
7390,
25,
11902,
493,
26,
3292,
4522,
284,
21207,
422,
13,
15161,
3011,
749,
2274,
17674,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
32374,
62,
25927,
7203,
18851,
1600,
12813,
67,
15042,
14,
85,
16,
14,
10034,
12409,
2898,
2367,
1600,
42287,
8,
628,
198,
4299,
4194,
62,
2213,
2367,
7,
944,
11,
6194,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
7293,
2790,
14,
46384,
49373,
833,
2367,
7343,
1174,
198,
220,
220,
220,
930,
1635,
3855,
25388,
11,
19406,
1910,
17674,
13,
5991,
17674,
326,
6070,
379,
262,
640,
11,
422,
262,
976,
1502,
11,
351,
262,
976,
2756,
481,
423,
262,
12040,
13262,
515,
15885,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
9460,
2898,
2367,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
5589,
2790,
12,
9460,
49373,
12,
2213,
2367,
12,
4868,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
1296,
7390,
25,
11902,
493,
26,
3292,
4522,
284,
21207,
422,
13,
15161,
3011,
749,
2274,
17674,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
9460,
2898,
2367,
1600,
42287,
8,
628,
198,
4299,
479,
6615,
7,
944,
11,
6194,
25,
965,
11,
16654,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
42,
1370,
14,
41572,
32712,
624,
6060,
1174,
198,
220,
220,
220,
930,
1635,
42,
1370,
14,
46188,
32712,
624,
9210,
329,
257,
6194,
13,
509,
6615,
389,
24139,
5174,
416,
511,
1280,
640,
15885,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
74,
6615,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
74,
1370,
12,
46188,
32712,
624,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
16654,
25,
4731,
26,
262,
16654,
286,
479,
1370,
11,
304,
13,
70,
352,
76,
11,
642,
76,
11,
352,
71,
11,
352,
67,
11,
3503,
13,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
1837,
23650,
11,
366,
1837,
23650,
33116,
685,
3849,
2100,
11,
366,
3849,
2100,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
366,
3849,
2100,
1298,
16654,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
74,
6615,
1600,
42287,
8,
628,
198,
4299,
12948,
62,
74,
6615,
7,
944,
11,
5166,
25,
965,
11,
2775,
6030,
25,
965,
11,
16654,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
17875,
5623,
509,
1370,
14,
41572,
32712,
624,
6060,
1174,
198,
220,
220,
220,
930,
1635,
42,
1370,
14,
46188,
32712,
624,
9210,
329,
257,
2176,
2775,
2099,
13,
509,
6615,
389,
24139,
5174,
416,
511,
1280,
640,
15885,
220,
220,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
18487,
5623,
42,
6615,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
18487,
5623,
12,
28484,
12,
74,
1370,
12,
46188,
32712,
624,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2775,
6030,
25,
4731,
26,
19878,
47731,
25620,
11,
327,
39237,
62,
27857,
4221,
11,
39726,
62,
27857,
4221,
11,
327,
39237,
62,
10917,
1503,
5781,
11,
39726,
62,
10917,
1503,
5781,
13,
198,
220,
220,
220,
1058,
17143,
2357,
16654,
25,
4731,
26,
262,
16654,
286,
479,
1370,
11,
304,
13,
70,
352,
76,
11,
642,
76,
11,
352,
71,
11,
352,
67,
11,
3503,
13,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
28484,
6030,
553,
28484,
6030,
33116,
685,
3849,
2100,
11,
366,
3849,
2100,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
28484,
6030,
1298,
28484,
6030,
11,
366,
3849,
2100,
1298,
16654,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
18487,
5623,
42,
6615,
1600,
42287,
8,
628,
198,
4299,
6376,
62,
20888,
62,
74,
6615,
7,
944,
11,
5166,
25,
965,
11,
16654,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
42,
1370,
14,
41572,
32712,
624,
6060,
329,
262,
6376,
2756,
286,
257,
5166,
13,
1174,
198,
220,
220,
220,
930,
1635,
42,
6615,
389,
24139,
5174,
416,
511,
1280,
640,
15885,
220,
220,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
9630,
18124,
42,
6615,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9630,
12,
20888,
12,
74,
1370,
12,
46188,
32712,
624,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
16654,
25,
4731,
26,
262,
16654,
286,
479,
1370,
11,
304,
13,
70,
352,
76,
11,
642,
76,
11,
352,
71,
11,
352,
67,
11,
3503,
13,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
3849,
2100,
11,
366,
3849,
2100,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
3849,
2100,
1298,
16654,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
9630,
18124,
42,
6615,
1600,
42287,
8,
628,
198,
4299,
1317,
62,
20888,
62,
74,
6615,
7,
944,
11,
6194,
25,
965,
11,
16654,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
42,
1370,
14,
46188,
32712,
624,
9210,
329,
262,
1317,
2756,
286,
257,
6194,
13,
1174,
198,
220,
220,
220,
930,
1635,
42,
6615,
389,
24139,
5174,
416,
511,
1280,
640,
15885,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
4102,
18124,
42,
6615,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
4102,
12,
20888,
12,
74,
1370,
12,
46188,
32712,
624,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
16654,
25,
4731,
26,
262,
16654,
286,
479,
1370,
11,
304,
13,
70,
352,
76,
11,
642,
76,
11,
352,
71,
11,
352,
67,
11,
3503,
13,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
220,
198,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
383,
3580,
1022,
923,
7575,
290,
886,
7575,
460,
691,
307,
510,
284,
939,
1528,
198,
220,
220,
220,
220,
220,
220,
220,
532,
14307,
923,
7575,
290,
886,
7575,
11,
262,
749,
2274,
4179,
1366,
422,
886,
7575,
481,
307,
4504,
25,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
1459,
41033,
481,
307,
900,
355,
886,
7575,
11,
290,
262,
749,
2274,
1366,
481,
307,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
318,
1908,
691,
11,
262,
41033,
286,
939,
1528,
706,
923,
7575,
481,
307,
900,
355,
886,
7575,
7,
929,
284,
262,
1459,
640,
8,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
886,
7575,
318,
1908,
691,
11,
262,
41033,
286,
939,
1528,
878,
886,
7575,
481,
307,
900,
355,
923,
7575,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
1837,
23650,
11,
366,
1837,
23650,
33116,
685,
3849,
2100,
11,
366,
3849,
2100,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
366,
3849,
2100,
1298,
16654,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
4102,
18124,
42,
6615,
1600,
42287,
8,
628,
198,
4299,
1317,
62,
20888,
7,
944,
11,
6194,
25,
965,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
9704,
7886,
290,
35249,
14806,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
31605,
1505,
15732,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9630,
12,
20888,
12,
392,
12,
4102,
12,
20888,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
366,
1837,
23650,
1298,
6194,
11,
198,
220,
220,
220,
1782,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
31605,
1505,
15732,
1600,
42287,
8,
628,
198,
4299,
4918,
62,
4873,
7,
944,
11,
6194,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
24553,
278,
14806,
7443,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
25032,
32184,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
1136,
12,
25032,
12,
4873,
12,
23569,
12,
1659,
12,
525,
6449,
723,
12,
69,
315,
942,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
5323,
11,
3509,
8576,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
422,
3268,
28332,
9306,
13,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
26,
5045,
27823,
287,
13845,
284,
651,
19406,
17674,
1566,
3268,
28332,
9306,
13,
198,
220,
220,
220,
220,
198,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
33523,
7177,
481,
307,
4504,
329,
7585,
14354,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
25032,
32184,
1600,
42287,
8,
628,
198,
4299,
4378,
263,
62,
1731,
11840,
62,
20888,
62,
3803,
7,
944,
11,
6194,
25,
965,
796,
6045,
11,
5166,
25,
965,
796,
6045,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
1731,
1711,
10708,
4324,
2756,
1487,
7869,
13,
1174,
198,
220,
220,
220,
930,
1635,
17784,
913,
618,
22534,
428,
351,
645,
6194,
15885,
198,
220,
220,
220,
930,
1635,
1532,
262,
6194,
318,
407,
1908,
11,
4378,
364,
329,
477,
14354,
481,
307,
4504,
287,
281,
7177,
15885,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
1731,
11840,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
1731,
11840,
12,
83,
15799,
12,
20888,
12,
3803,
12,
14269,
3969,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
11902,
4731,
26,
262,
7313,
6194,
198,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
11902,
4731,
26,
262,
7313,
5166,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
38357,
290,
5166,
2314,
307,
1908,
1978,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
257,
5166,
318,
1908,
11,
4378,
364,
329,
477,
14354,
286,
262,
5166,
481,
307,
4504,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
2035,
257,
5166,
393,
6194,
318,
1908,
11,
4378,
364,
329,
477,
14354,
286,
477,
14729,
481,
307,
4504,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
611,
357,
1837,
23650,
318,
6045,
8,
290,
357,
24874,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
1731,
11840,
4943,
198,
220,
220,
220,
1288,
361,
357,
1837,
23650,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
92,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
92,
628,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
1731,
11840,
1600,
42287,
8,
628,
198,
4299,
4378,
263,
62,
20888,
7,
944,
11,
6194,
25,
965,
796,
6045,
11,
5166,
25,
965,
796,
6045,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
39478,
2756,
329,
257,
6194,
393,
14354,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
20888,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
1837,
23650,
12,
20888,
12,
83,
15799,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
11902,
4731,
26,
262,
7313,
6194,
198,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
11902,
4731,
26,
262,
7313,
5166,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
38357,
290,
5166,
2314,
307,
1908,
1978,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
257,
5166,
318,
1908,
11,
83,
21630,
329,
477,
14354,
286,
262,
5166,
481,
307,
4504,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
2035,
257,
5166,
393,
6194,
318,
1908,
11,
4378,
364,
329,
477,
14354,
286,
477,
14729,
481,
307,
4504,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
611,
357,
1837,
23650,
318,
6045,
8,
290,
357,
24874,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
20888,
4943,
198,
220,
220,
220,
1288,
361,
357,
1837,
23650,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
92,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
92,
628,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
20888,
1600,
42287,
8,
628,
198,
4299,
1492,
62,
83,
15799,
7,
944,
11,
6194,
25,
965,
796,
6045,
11,
5166,
25,
965,
796,
6045,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
13014,
2756,
14,
80,
774,
319,
262,
1502,
1492,
329,
257,
6194,
393,
14354,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
2070,
51,
15799,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
1837,
23650,
12,
2875,
12,
2070,
12,
83,
15799,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
11902,
4731,
26,
262,
7313,
6194,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
262,
6194,
318,
407,
1908,
11,
1492,
51,
21630,
329,
477,
14354,
481,
307,
4504,
287,
281,
7177,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
611,
357,
1837,
23650,
318,
6045,
8,
290,
357,
24874,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
2070,
51,
15799,
4943,
198,
220,
220,
220,
1288,
361,
357,
1837,
23650,
318,
6045,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
92,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
92,
628,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
2070,
51,
15799,
1600,
42287,
8,
628,
198,
4299,
1280,
62,
9446,
7,
944,
11,
6194,
25,
965,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
1944,
1280,
1393,
286,
257,
2176,
6194,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
67,
15042,
14,
85,
16,
14,
9654,
19302,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9654,
12,
9446,
628,
220,
220,
220,
1058,
17143,
2357,
6194,
25,
4731,
26,
262,
7313,
6194,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
2357,
7,
1837,
23650,
11,
366,
1837,
23650,
4943,
198,
220,
220,
220,
42287,
796,
19779,
1837,
23650,
1298,
6194,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
67,
15042,
14,
85,
16,
14,
83,
15799,
14,
2070,
51,
15799,
1600,
42287,
8,
628,
198,
4299,
1280,
62,
9446,
62,
10034,
7,
944,
11,
5166,
25,
965,
11,
2775,
6030,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
6754,
1280,
1393,
286,
257,
2176,
6194,
1174,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
69,
315,
942,
14,
7890,
14,
9654,
19302,
13749,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
9654,
12,
9446,
12,
14269,
3969,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2775,
6030,
25,
4731,
26,
11096,
11,
327,
39237,
62,
10917,
1503,
5781,
11,
39726,
62,
10917,
1503,
5781,
11,
19878,
47731,
25620,
13,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
28484,
6030,
11,
366,
28484,
6030,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
28484,
6030,
1298,
2775,
6030,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
9654,
19302,
13749,
1600,
42287,
8,
628,
198,
4299,
1353,
62,
6511,
62,
19509,
62,
23317,
62,
10366,
952,
7,
944,
11,
5166,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
1353,
890,
1790,
1848,
8064,
1174,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
4600,
18851,
1220,
69,
315,
942,
14,
7890,
14,
4852,
14617,
16438,
30116,
29665,
952,
63,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
4852,
12,
2213,
5067,
12,
6511,
12,
19509,
12,
10366,
952,
12,
23317,
82,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
4852,
14617,
16438,
30116,
29665,
952,
1600,
42287,
8,
628,
198,
4299,
1353,
62,
6511,
62,
19509,
62,
9150,
62,
10366,
952,
7,
944,
11,
5166,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
1353,
890,
1790,
2292,
8064,
1174,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
69,
315,
942,
14,
7890,
14,
4852,
14617,
16438,
26545,
29665,
952,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
4852,
12,
2213,
5067,
12,
6511,
12,
19509,
12,
10366,
952,
12,
1930,
1756,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
4852,
14617,
16438,
26545,
29665,
952,
1600,
42287,
8,
628,
198,
4299,
890,
62,
19509,
62,
23317,
62,
10366,
952,
7,
944,
11,
5166,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
1353,
890,
1790,
1848,
8064,
1174,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
69,
315,
942,
14,
7890,
14,
20541,
14617,
16438,
30116,
29665,
952,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
4852,
12,
2213,
5067,
12,
6511,
12,
19509,
12,
10366,
952,
12,
23317,
82,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
20541,
14617,
16438,
30116,
29665,
952,
1600,
42287,
8,
628,
198,
4299,
256,
3110,
62,
6511,
62,
19509,
62,
10366,
952,
7,
944,
11,
5166,
25,
965,
11,
2775,
6030,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
256,
3110,
890,
1790,
8064,
1174,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
69,
315,
942,
14,
7890,
14,
30157,
14518,
50,
695,
16598,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
30157,
12,
17846,
12,
7255,
12,
29048,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2775,
6030,
25,
4731,
26,
327,
39237,
62,
10917,
1503,
5781,
11,
39726,
62,
10917,
1503,
5781,
11,
19878,
47731,
25620,
13,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
28484,
6030,
11,
366,
28484,
6030,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
28484,
6030,
1298,
2775,
6030,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
30157,
14518,
50,
695,
16598,
1600,
42287,
8,
628,
198,
4299,
4308,
7,
944,
11,
5166,
25,
965,
11,
2775,
6030,
25,
965,
11,
2278,
25,
965,
11,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
930,
198,
220,
220,
220,
930,
12429,
3855,
12901,
49355,
1174,
628,
220,
220,
220,
1058,
17614,
36123,
25,
7559,
18851,
1220,
69,
315,
942,
14,
7890,
14,
12093,
271,
15506,
198,
220,
220,
220,
1058,
17614,
2205,
25,
2124,
1477,
926,
862,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
12093,
271,
12,
10728,
12,
7890,
628,
220,
220,
220,
1058,
17143,
2357,
5166,
25,
4731,
26,
262,
7313,
5166,
198,
220,
220,
220,
1058,
17143,
2357,
2775,
6030,
25,
4731,
26,
327,
39237,
62,
10917,
1503,
5781,
11,
39726,
62,
10917,
1503,
5781,
11,
19878,
47731,
25620,
13,
198,
220,
220,
220,
1058,
17143,
2357,
2278,
25,
4731,
26,
262,
2278,
286,
1280,
1393,
11,
366,
20,
76,
1600,
366,
1314,
76,
1600,
366,
1270,
76,
1600,
366,
16,
71,
1600,
366,
17,
71,
1600,
366,
19,
71,
1600,
366,
21,
71,
1600,
366,
1065,
71,
1600,
366,
16,
67,
1911,
357,
3826,
517,
287,
3740,
1378,
8800,
590,
12,
31628,
13,
12567,
13,
952,
14,
499,
312,
420,
82,
14,
12381,
6315,
14,
268,
31113,
11377,
12,
437,
13033,
12,
10951,
8,
198,
220,
220,
220,
1058,
17143,
2357,
4179,
25,
11902,
493,
26,
4179,
262,
2482,
13,
15161,
1542,
11,
3509,
5323,
13,
198,
220,
220,
220,
1058,
17143,
2357,
923,
7575,
25,
11902,
493,
198,
220,
220,
220,
1058,
17143,
2357,
886,
7575,
25,
11902,
493,
628,
220,
220,
220,
12429,
16130,
1174,
198,
220,
220,
220,
220,
220,
220,
220,
532,
1002,
923,
7575,
290,
886,
7575,
389,
407,
1908,
11,
262,
749,
2274,
1366,
318,
4504,
13,
198,
220,
220,
220,
220,
220,
220,
220,
532,
5514,
262,
1366,
286,
262,
3452,
1542,
1528,
318,
1695,
13,
198,
220,
220,
220,
930,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2198,
62,
35827,
62,
17143,
7307,
26933,
58,
24874,
11,
366,
24874,
33116,
685,
28484,
6030,
11,
366,
28484,
6030,
33116,
685,
41007,
11,
366,
41007,
8973,
12962,
198,
220,
220,
220,
42287,
796,
19779,
24874,
1298,
5166,
11,
366,
28484,
6030,
1298,
2775,
6030,
11,
366,
41007,
1298,
2278,
11,
12429,
46265,
22046,
92,
198,
220,
220,
220,
1441,
2116,
13,
22766,
7203,
14,
69,
315,
942,
14,
7890,
14,
12093,
271,
1600,
42287,
8,
198
] | 2.74541 | 7,298 |
import click
from gitkit.util.shell import get_output
@click.command()
def what():
"""
What _is_ the current revision anyway?
"""
description = get_output("git describe")
revision = get_output("git rev-parse HEAD")
print(f"{description} ({revision})")
| [
11748,
3904,
198,
198,
6738,
17606,
15813,
13,
22602,
13,
29149,
1330,
651,
62,
22915,
628,
198,
31,
12976,
13,
21812,
3419,
198,
4299,
644,
33529,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1867,
4808,
271,
62,
262,
1459,
18440,
6949,
30,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
6764,
796,
651,
62,
22915,
7203,
18300,
6901,
4943,
198,
220,
220,
220,
18440,
796,
651,
62,
22915,
7203,
18300,
2710,
12,
29572,
39837,
4943,
198,
220,
220,
220,
3601,
7,
69,
1,
90,
11213,
92,
37913,
260,
10178,
30072,
4943,
198
] | 2.936842 | 95 |
# --------------
# Importing header files
import numpy as np
import warnings
warnings.filterwarnings('ignore')
#New record
new_record=[[50, 9, 4, 1, 0, 0, 40, 0]]
#Reading file
# data = np.genfromtxt(path, delimiter=",", skip_header=1)
#Code starts here
data = np.genfromtxt(path, delimiter = ",", skip_header = 1)
census = np.concatenate((new_record,data),axis = 0)
age = census[:,0]
max_age = np.max(age)
min_age = np.min(age)
age_mean = np.mean(age)
age_std = np.std(age)
race_0 = census[census[:,2]==0]
race_1 = census[census[:,2]==1]
race_2 = census[census[:,2]==2]
race_3 = census[census[:,3]==3]
race_4 = census[census[:,4]==4]
len_0 = len(race_0)
len_1 = len(race_1)
len_2 = len(race_2)
len_3 = len(race_3)
len_4 = len(race_4)
a = [len_0, len_1, len_2, len_3, len_4]
minority_race = min(a)
senior_citizens = census[census[:,0]>60]
working_hours_sum = senior_citizens.sum(axis=0)[6]
senior_citizens_len = len(senior_citizens)
avg_working_hours = working_hours_sum/senior_citizens_len
print(round(avg_working_hours,2))
high = census[census[:,1]>10]
low = census[census[:,1]<=10]
avg_pay_high = round(np.mean(high[:,7]),2)
avg_pay_low = round(np.mean(low[:,7]),2)
print(avg_pay_high)
print(avg_pay_low)
| [
2,
220,
26171,
198,
2,
17267,
278,
13639,
3696,
201,
198,
11748,
299,
32152,
355,
45941,
201,
198,
11748,
14601,
201,
198,
201,
198,
40539,
654,
13,
24455,
40539,
654,
10786,
46430,
11537,
201,
198,
201,
198,
2,
3791,
1700,
201,
198,
3605,
62,
22105,
28,
30109,
1120,
11,
220,
860,
11,
220,
604,
11,
220,
352,
11,
220,
657,
11,
220,
657,
11,
2319,
11,
220,
657,
11907,
201,
198,
201,
198,
2,
36120,
2393,
201,
198,
2,
1366,
796,
45941,
13,
5235,
6738,
14116,
7,
6978,
11,
46728,
2676,
28,
2430,
11,
14267,
62,
25677,
28,
16,
8,
201,
198,
201,
198,
2,
10669,
4940,
994,
201,
198,
7890,
796,
45941,
13,
5235,
6738,
14116,
7,
6978,
11,
46728,
2676,
796,
366,
553,
11,
14267,
62,
25677,
796,
352,
8,
201,
198,
66,
7314,
796,
45941,
13,
1102,
9246,
268,
378,
19510,
3605,
62,
22105,
11,
7890,
828,
22704,
796,
657,
8,
201,
198,
201,
198,
496,
796,
21649,
58,
45299,
15,
60,
201,
198,
9806,
62,
496,
796,
45941,
13,
9806,
7,
496,
8,
201,
198,
1084,
62,
496,
796,
45941,
13,
1084,
7,
496,
8,
201,
198,
201,
198,
496,
62,
32604,
796,
45941,
13,
32604,
7,
496,
8,
201,
198,
496,
62,
19282,
796,
45941,
13,
19282,
7,
496,
8,
201,
198,
16740,
62,
15,
796,
21649,
58,
66,
7314,
58,
45299,
17,
60,
855,
15,
60,
201,
198,
16740,
62,
16,
796,
21649,
58,
66,
7314,
58,
45299,
17,
60,
855,
16,
60,
201,
198,
16740,
62,
17,
796,
21649,
58,
66,
7314,
58,
45299,
17,
60,
855,
17,
60,
201,
198,
16740,
62,
18,
796,
21649,
58,
66,
7314,
58,
45299,
18,
60,
855,
18,
60,
201,
198,
16740,
62,
19,
796,
21649,
58,
66,
7314,
58,
45299,
19,
60,
855,
19,
60,
201,
198,
201,
198,
11925,
62,
15,
796,
18896,
7,
16740,
62,
15,
8,
201,
198,
11925,
62,
16,
796,
18896,
7,
16740,
62,
16,
8,
201,
198,
11925,
62,
17,
796,
18896,
7,
16740,
62,
17,
8,
201,
198,
11925,
62,
18,
796,
18896,
7,
16740,
62,
18,
8,
201,
198,
11925,
62,
19,
796,
18896,
7,
16740,
62,
19,
8,
201,
198,
201,
198,
64,
796,
685,
11925,
62,
15,
11,
18896,
62,
16,
11,
18896,
62,
17,
11,
18896,
62,
18,
11,
18896,
62,
19,
60,
201,
198,
1084,
29134,
62,
16740,
796,
949,
7,
64,
8,
201,
198,
201,
198,
6248,
1504,
62,
46801,
796,
21649,
58,
66,
7314,
58,
45299,
15,
60,
29,
1899,
60,
201,
198,
16090,
62,
24425,
62,
16345,
796,
4664,
62,
46801,
13,
16345,
7,
22704,
28,
15,
38381,
21,
60,
201,
198,
6248,
1504,
62,
46801,
62,
11925,
796,
18896,
7,
6248,
1504,
62,
46801,
8,
201,
198,
615,
70,
62,
16090,
62,
24425,
796,
1762,
62,
24425,
62,
16345,
14,
6248,
1504,
62,
46801,
62,
11925,
201,
198,
201,
198,
4798,
7,
744,
7,
615,
70,
62,
16090,
62,
24425,
11,
17,
4008,
201,
198,
201,
198,
8929,
796,
21649,
58,
66,
7314,
58,
45299,
16,
60,
29,
940,
60,
201,
198,
9319,
796,
21649,
58,
66,
7314,
58,
45299,
16,
60,
27,
28,
940,
60,
201,
198,
201,
198,
615,
70,
62,
15577,
62,
8929,
796,
2835,
7,
37659,
13,
32604,
7,
8929,
58,
45299,
22,
46570,
17,
8,
220,
201,
198,
615,
70,
62,
15577,
62,
9319,
796,
2835,
7,
37659,
13,
32604,
7,
9319,
58,
45299,
22,
46570,
17,
8,
201,
198,
4798,
7,
615,
70,
62,
15577,
62,
8929,
8,
201,
198,
4798,
7,
615,
70,
62,
15577,
62,
9319,
8,
201,
628,
628
] | 2.138564 | 599 |
from stack_class import *
def reverse_file(path):
"""Overwrite given file using its context line-by-line reversed"""
s=ArrayStack()
with open(path,"r") as original:
for line in original:
s.push(line.rstrip("\n")) # removing newline characters
# overwrite the contents in LIFO order
with open(path,"w") as new:
while not s.is_empty():
new.write(s.pop()+"\n") # re-insert newline characters.
return "Reversed"
print(reverse_file("sample.txt"))
| [
6738,
8931,
62,
4871,
1330,
1635,
198,
4299,
9575,
62,
7753,
7,
6978,
2599,
198,
220,
220,
220,
37227,
5886,
13564,
1813,
2393,
1262,
663,
4732,
1627,
12,
1525,
12,
1370,
17687,
37811,
198,
220,
220,
220,
264,
28,
19182,
25896,
3419,
198,
220,
220,
220,
351,
1280,
7,
6978,
553,
81,
4943,
355,
2656,
25,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1627,
287,
2656,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
13,
14689,
7,
1370,
13,
81,
36311,
7203,
59,
77,
48774,
1303,
10829,
649,
1370,
3435,
628,
220,
220,
220,
1303,
49312,
262,
10154,
287,
406,
5064,
46,
1502,
198,
220,
220,
220,
351,
1280,
7,
6978,
553,
86,
4943,
355,
649,
25,
198,
220,
220,
220,
220,
220,
220,
220,
981,
407,
264,
13,
271,
62,
28920,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
649,
13,
13564,
7,
82,
13,
12924,
3419,
10,
1,
59,
77,
4943,
1303,
302,
12,
28463,
649,
1370,
3435,
13,
628,
220,
220,
220,
1441,
366,
3041,
690,
276,
1,
198,
198,
4798,
7,
50188,
62,
7753,
7203,
39873,
13,
14116,
48774,
198
] | 2.583756 | 197 |
import sys
import os
from simulaqron.toolbox import get_simulaqron_path
# Get path to SimulaQron folder
simulaqron_path = get_simulaqron_path.main()
tot_nr = int(sys.argv[1])
# configure run files for nodes
with open("run.sh", "w") as f:
f.write("#!/bin/sh\n\n")
for i in range(tot_nr - 1):
f.write("python3 node.py {} {} &\n".format(i, tot_nr))
f.write("python3 node.py {} {}\n".format(tot_nr - 1, tot_nr))
with open("run_v2.sh", "w") as f:
f.write("#!/bin/sh\n\n")
for i in range(tot_nr - 1):
f.write("python3 node_v2.py {} {} &\n".format(i, tot_nr))
f.write("python3 node_v2.py {} {}\n".format(tot_nr - 1, tot_nr))
# configure network
nodes = "".join(["n" + str(i) + " " for i in range(tot_nr)])
os.system("python3 " + simulaqron_path + "configFiles.py " + nodes)
| [
11748,
25064,
198,
11748,
28686,
198,
198,
6738,
985,
4712,
80,
1313,
13,
25981,
3524,
1330,
651,
62,
14323,
4712,
80,
1313,
62,
6978,
198,
198,
2,
3497,
3108,
284,
3184,
4712,
48,
1313,
9483,
198,
14323,
4712,
80,
1313,
62,
6978,
796,
651,
62,
14323,
4712,
80,
1313,
62,
6978,
13,
12417,
3419,
198,
198,
83,
313,
62,
48624,
796,
493,
7,
17597,
13,
853,
85,
58,
16,
12962,
198,
198,
2,
17425,
1057,
3696,
329,
13760,
198,
198,
4480,
1280,
7203,
5143,
13,
1477,
1600,
366,
86,
4943,
355,
277,
25,
198,
220,
220,
220,
277,
13,
13564,
7203,
2,
48443,
8800,
14,
1477,
59,
77,
59,
77,
4943,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
83,
313,
62,
48624,
532,
352,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
29412,
18,
10139,
13,
9078,
23884,
23884,
1222,
59,
77,
1911,
18982,
7,
72,
11,
2006,
62,
48624,
4008,
198,
220,
220,
220,
277,
13,
13564,
7203,
29412,
18,
10139,
13,
9078,
23884,
23884,
59,
77,
1911,
18982,
7,
83,
313,
62,
48624,
532,
352,
11,
2006,
62,
48624,
4008,
198,
198,
4480,
1280,
7203,
5143,
62,
85,
17,
13,
1477,
1600,
366,
86,
4943,
355,
277,
25,
198,
220,
220,
220,
277,
13,
13564,
7203,
2,
48443,
8800,
14,
1477,
59,
77,
59,
77,
4943,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
83,
313,
62,
48624,
532,
352,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
277,
13,
13564,
7203,
29412,
18,
10139,
62,
85,
17,
13,
9078,
23884,
23884,
1222,
59,
77,
1911,
18982,
7,
72,
11,
2006,
62,
48624,
4008,
198,
220,
220,
220,
277,
13,
13564,
7203,
29412,
18,
10139,
62,
85,
17,
13,
9078,
23884,
23884,
59,
77,
1911,
18982,
7,
83,
313,
62,
48624,
532,
352,
11,
2006,
62,
48624,
4008,
198,
198,
2,
17425,
3127,
198,
198,
77,
4147,
796,
366,
1911,
22179,
7,
14692,
77,
1,
1343,
965,
7,
72,
8,
1343,
366,
366,
329,
1312,
287,
2837,
7,
83,
313,
62,
48624,
8,
12962,
198,
198,
418,
13,
10057,
7203,
29412,
18,
366,
1343,
985,
4712,
80,
1313,
62,
6978,
1343,
366,
11250,
25876,
13,
9078,
366,
1343,
13760,
8,
198
] | 2.193548 | 372 |
from .selection import Selection
from .logging import logger
from .dir import config_dir, cache_dir
__all__ = [
'Selection',
'logger',
'config_dir',
'cache_dir',
]
| [
6738,
764,
49283,
1330,
29538,
198,
6738,
764,
6404,
2667,
1330,
49706,
198,
6738,
764,
15908,
1330,
4566,
62,
15908,
11,
12940,
62,
15908,
198,
198,
834,
439,
834,
796,
685,
198,
220,
220,
220,
705,
4653,
1564,
3256,
198,
220,
220,
220,
705,
6404,
1362,
3256,
198,
220,
220,
220,
705,
11250,
62,
15908,
3256,
198,
220,
220,
220,
705,
23870,
62,
15908,
3256,
198,
60,
198
] | 2.661765 | 68 |
from __future__ import division,print_function
#matplotlib inline
#load_ext autoreload
#autoreload 2
import sys
from tqdm import tqdm_notebook as tqdm
import random
import matplotlib.pyplot as plt
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.nn.init as init
from torch.autograd import Variable, grad
from torchvision import datasets, transforms
from torch.nn.parameter import Parameter
import calculate_log as callog
import warnings
warnings.filterwarnings('ignore')
torch.cuda.set_device(0) #Select the GPU
torch_model = ResNet(BasicBlock, [3, 4, 6, 3], num_classes=10)
torch_model.load('/nobackup-slow/dataset/my_xfdu/resnet_cifar10.pth')
torch_model.cuda()
torch_model.params = list(torch_model.parameters())
torch_model.eval()
print("Done")
batch_size = 128
mean = np.array([[0.4914, 0.4822, 0.4465]]).T
std = np.array([[0.2023, 0.1994, 0.2010]]).T
normalize = transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010))
transform_train = transforms.Compose([
transforms.RandomCrop(32, padding=4),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
normalize
])
transform_test = transforms.Compose([
transforms.CenterCrop(size=(32, 32)),
transforms.ToTensor(),
normalize
])
train_loader = torch.utils.data.DataLoader(
datasets.CIFAR10('/nobackup-slow/dataset/cifarpy', train=True, download=True,
transform=transform_train),
batch_size=batch_size, shuffle=True)
test_loader = torch.utils.data.DataLoader(
datasets.CIFAR10('/nobackup-slow/dataset/cifarpy', train=False, transform=transform_test),
batch_size=batch_size)
data_train = list(torch.utils.data.DataLoader(
datasets.CIFAR10('/nobackup-slow/dataset/cifarpy', train=True, download=True,
transform=transform_test),
batch_size=1, shuffle=False))
data = list(torch.utils.data.DataLoader(
datasets.CIFAR10('/nobackup-slow/dataset/cifarpy', train=False, download=True,
transform=transform_test),
batch_size=1, shuffle=False))
torch_model.eval()
# correct = 0
# total = 0
# for x,y in test_loader:
# x = x.cuda()
# y = y.numpy()
# correct += (y==np.argmax(torch_model(x).detach().cpu().numpy(),axis=1)).sum()
# total += y.shape[0]
# print("Accuracy: ",correct/total)
cifar100 = list(torch.utils.data.DataLoader(
datasets.CIFAR100('/nobackup-slow/dataset/cifarpy', train=False, download=True,
transform=transform_test),
batch_size=1, shuffle=True))
train_preds = []
train_confs = []
train_logits = []
for idx in range(0, len(data_train), 128):
batch = torch.squeeze(torch.stack([x[0] for x in data_train[idx:idx + 128]]), dim=1).cuda()
logits = torch_model(batch)
confs = F.softmax(logits, dim=1).cpu().detach().numpy()
preds = np.argmax(confs, axis=1)
logits = (logits.cpu().detach().numpy())
train_confs.extend(np.max(confs, axis=1))
train_preds.extend(preds)
train_logits.extend(logits)
print("Done")
test_preds = []
test_confs = []
test_logits = []
for idx in range(0, len(data), 128):
batch = torch.squeeze(torch.stack([x[0] for x in data[idx:idx + 128]]), dim=1).cuda()
logits = torch_model(batch)
confs = F.softmax(logits, dim=1).cpu().detach().numpy()
preds = np.argmax(confs, axis=1)
logits = (logits.cpu().detach().numpy())
test_confs.extend(np.max(confs, axis=1))
test_preds.extend(preds)
test_logits.extend(logits)
print("Done")
import calculate_log as callog
detector = Detector()
detector.compute_minmaxs(data_train, POWERS=range(1, 11))
detector.compute_test_deviations(POWERS=range(1, 11))
print("CIFAR-100")
c100_results = detector.compute_ood_deviations(cifar100,POWERS=range(1,11)) | [
6738,
11593,
37443,
834,
1330,
7297,
11,
4798,
62,
8818,
198,
198,
2,
6759,
29487,
8019,
26098,
198,
2,
2220,
62,
2302,
1960,
382,
2220,
198,
2,
2306,
382,
2220,
362,
198,
198,
11748,
25064,
198,
6738,
256,
80,
36020,
1330,
256,
80,
36020,
62,
11295,
2070,
355,
256,
80,
36020,
198,
198,
11748,
4738,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
11748,
10688,
198,
198,
11748,
299,
32152,
355,
45941,
198,
198,
11748,
28034,
198,
11748,
28034,
13,
20471,
355,
299,
77,
198,
11748,
28034,
13,
20471,
13,
45124,
355,
376,
198,
11748,
28034,
13,
40085,
355,
6436,
198,
11748,
28034,
13,
20471,
13,
15003,
355,
2315,
198,
6738,
28034,
13,
2306,
519,
6335,
1330,
35748,
11,
3915,
198,
6738,
28034,
10178,
1330,
40522,
11,
31408,
198,
6738,
28034,
13,
20471,
13,
17143,
2357,
1330,
25139,
2357,
198,
198,
11748,
15284,
62,
6404,
355,
869,
519,
198,
198,
11748,
14601,
198,
40539,
654,
13,
24455,
40539,
654,
10786,
46430,
11537,
628,
198,
13165,
354,
13,
66,
15339,
13,
2617,
62,
25202,
7,
15,
8,
1303,
17563,
262,
11362,
628,
628,
198,
198,
13165,
354,
62,
19849,
796,
1874,
7934,
7,
26416,
12235,
11,
685,
18,
11,
604,
11,
718,
11,
513,
4357,
997,
62,
37724,
28,
940,
8,
198,
13165,
354,
62,
19849,
13,
2220,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
1820,
62,
26152,
646,
14,
411,
3262,
62,
66,
361,
283,
940,
13,
79,
400,
11537,
198,
13165,
354,
62,
19849,
13,
66,
15339,
3419,
198,
13165,
354,
62,
19849,
13,
37266,
796,
1351,
7,
13165,
354,
62,
19849,
13,
17143,
7307,
28955,
198,
13165,
354,
62,
19849,
13,
18206,
3419,
198,
4798,
7203,
45677,
4943,
198,
198,
43501,
62,
7857,
796,
13108,
198,
32604,
796,
45941,
13,
18747,
26933,
58,
15,
13,
2920,
1415,
11,
657,
13,
2780,
1828,
11,
657,
13,
2598,
2996,
11907,
737,
51,
198,
198,
19282,
796,
45941,
13,
18747,
26933,
58,
15,
13,
1238,
1954,
11,
657,
13,
22666,
11,
657,
13,
10333,
11907,
737,
51,
198,
11265,
1096,
796,
31408,
13,
26447,
1096,
19510,
15,
13,
2920,
1415,
11,
657,
13,
2780,
1828,
11,
657,
13,
2598,
2996,
828,
357,
15,
13,
1238,
1954,
11,
657,
13,
22666,
11,
657,
13,
10333,
4008,
198,
198,
35636,
62,
27432,
796,
31408,
13,
7293,
577,
26933,
198,
220,
220,
220,
31408,
13,
29531,
34,
1773,
7,
2624,
11,
24511,
28,
19,
828,
198,
220,
220,
220,
31408,
13,
29531,
27991,
38342,
7414,
541,
22784,
198,
220,
220,
220,
31408,
13,
2514,
51,
22854,
22784,
198,
220,
220,
220,
3487,
1096,
198,
198,
12962,
198,
35636,
62,
9288,
796,
31408,
13,
7293,
577,
26933,
198,
220,
220,
220,
31408,
13,
23656,
34,
1773,
7,
7857,
16193,
2624,
11,
3933,
36911,
198,
220,
220,
220,
31408,
13,
2514,
51,
22854,
22784,
198,
220,
220,
220,
3487,
1096,
198,
12962,
198,
198,
27432,
62,
29356,
796,
28034,
13,
26791,
13,
7890,
13,
6601,
17401,
7,
198,
220,
220,
220,
40522,
13,
34,
5064,
1503,
940,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
66,
361,
5117,
88,
3256,
4512,
28,
17821,
11,
4321,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6121,
28,
35636,
62,
27432,
828,
198,
220,
220,
220,
15458,
62,
7857,
28,
43501,
62,
7857,
11,
36273,
28,
17821,
8,
198,
9288,
62,
29356,
796,
28034,
13,
26791,
13,
7890,
13,
6601,
17401,
7,
198,
220,
220,
220,
40522,
13,
34,
5064,
1503,
940,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
66,
361,
5117,
88,
3256,
4512,
28,
25101,
11,
6121,
28,
35636,
62,
9288,
828,
198,
220,
220,
220,
15458,
62,
7857,
28,
43501,
62,
7857,
8,
198,
198,
7890,
62,
27432,
796,
1351,
7,
13165,
354,
13,
26791,
13,
7890,
13,
6601,
17401,
7,
198,
220,
220,
220,
220,
220,
220,
220,
40522,
13,
34,
5064,
1503,
940,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
66,
361,
5117,
88,
3256,
4512,
28,
17821,
11,
4321,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6121,
28,
35636,
62,
9288,
828,
198,
220,
220,
220,
220,
220,
220,
220,
15458,
62,
7857,
28,
16,
11,
36273,
28,
25101,
4008,
198,
198,
7890,
796,
1351,
7,
13165,
354,
13,
26791,
13,
7890,
13,
6601,
17401,
7,
198,
220,
220,
220,
40522,
13,
34,
5064,
1503,
940,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
66,
361,
5117,
88,
3256,
4512,
28,
25101,
11,
4321,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6121,
28,
35636,
62,
9288,
828,
198,
220,
220,
220,
15458,
62,
7857,
28,
16,
11,
36273,
28,
25101,
4008,
628,
198,
13165,
354,
62,
19849,
13,
18206,
3419,
198,
2,
3376,
796,
657,
198,
2,
2472,
796,
657,
198,
2,
329,
2124,
11,
88,
287,
1332,
62,
29356,
25,
198,
2,
220,
220,
220,
220,
2124,
796,
2124,
13,
66,
15339,
3419,
198,
2,
220,
220,
220,
220,
331,
796,
331,
13,
77,
32152,
3419,
198,
2,
220,
220,
220,
220,
3376,
15853,
357,
88,
855,
37659,
13,
853,
9806,
7,
13165,
354,
62,
19849,
7,
87,
737,
15255,
620,
22446,
36166,
22446,
77,
32152,
22784,
22704,
28,
16,
29720,
16345,
3419,
198,
2,
220,
220,
220,
220,
2472,
15853,
331,
13,
43358,
58,
15,
60,
198,
2,
3601,
7203,
17320,
23843,
25,
33172,
30283,
14,
23350,
8,
628,
198,
66,
361,
283,
3064,
796,
1351,
7,
13165,
354,
13,
26791,
13,
7890,
13,
6601,
17401,
7,
198,
220,
220,
220,
40522,
13,
34,
5064,
1503,
3064,
10786,
14,
34952,
441,
929,
12,
38246,
14,
19608,
292,
316,
14,
66,
361,
5117,
88,
3256,
4512,
28,
25101,
11,
4321,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6121,
28,
35636,
62,
9288,
828,
198,
220,
220,
220,
15458,
62,
7857,
28,
16,
11,
36273,
28,
17821,
4008,
198,
198,
27432,
62,
28764,
82,
796,
17635,
198,
27432,
62,
1102,
9501,
796,
17635,
198,
27432,
62,
6404,
896,
796,
17635,
198,
1640,
4686,
87,
287,
2837,
7,
15,
11,
18896,
7,
7890,
62,
27432,
828,
13108,
2599,
198,
220,
220,
220,
15458,
796,
28034,
13,
16485,
1453,
2736,
7,
13165,
354,
13,
25558,
26933,
87,
58,
15,
60,
329,
2124,
287,
1366,
62,
27432,
58,
312,
87,
25,
312,
87,
1343,
13108,
11907,
828,
5391,
28,
16,
737,
66,
15339,
3419,
628,
220,
220,
220,
2604,
896,
796,
28034,
62,
19849,
7,
43501,
8,
198,
220,
220,
220,
1013,
82,
796,
376,
13,
4215,
9806,
7,
6404,
896,
11,
5391,
28,
16,
737,
36166,
22446,
15255,
620,
22446,
77,
32152,
3419,
198,
220,
220,
220,
2747,
82,
796,
45941,
13,
853,
9806,
7,
1102,
9501,
11,
16488,
28,
16,
8,
198,
220,
220,
220,
2604,
896,
796,
357,
6404,
896,
13,
36166,
22446,
15255,
620,
22446,
77,
32152,
28955,
628,
220,
220,
220,
4512,
62,
1102,
9501,
13,
2302,
437,
7,
37659,
13,
9806,
7,
1102,
9501,
11,
16488,
28,
16,
4008,
198,
220,
220,
220,
4512,
62,
28764,
82,
13,
2302,
437,
7,
28764,
82,
8,
198,
220,
220,
220,
4512,
62,
6404,
896,
13,
2302,
437,
7,
6404,
896,
8,
198,
4798,
7203,
45677,
4943,
198,
198,
9288,
62,
28764,
82,
796,
17635,
198,
9288,
62,
1102,
9501,
796,
17635,
198,
9288,
62,
6404,
896,
796,
17635,
198,
198,
1640,
4686,
87,
287,
2837,
7,
15,
11,
18896,
7,
7890,
828,
13108,
2599,
198,
220,
220,
220,
15458,
796,
28034,
13,
16485,
1453,
2736,
7,
13165,
354,
13,
25558,
26933,
87,
58,
15,
60,
329,
2124,
287,
1366,
58,
312,
87,
25,
312,
87,
1343,
13108,
11907,
828,
5391,
28,
16,
737,
66,
15339,
3419,
628,
220,
220,
220,
2604,
896,
796,
28034,
62,
19849,
7,
43501,
8,
198,
220,
220,
220,
1013,
82,
796,
376,
13,
4215,
9806,
7,
6404,
896,
11,
5391,
28,
16,
737,
36166,
22446,
15255,
620,
22446,
77,
32152,
3419,
198,
220,
220,
220,
2747,
82,
796,
45941,
13,
853,
9806,
7,
1102,
9501,
11,
16488,
28,
16,
8,
198,
220,
220,
220,
2604,
896,
796,
357,
6404,
896,
13,
36166,
22446,
15255,
620,
22446,
77,
32152,
28955,
628,
220,
220,
220,
1332,
62,
1102,
9501,
13,
2302,
437,
7,
37659,
13,
9806,
7,
1102,
9501,
11,
16488,
28,
16,
4008,
198,
220,
220,
220,
1332,
62,
28764,
82,
13,
2302,
437,
7,
28764,
82,
8,
198,
220,
220,
220,
1332,
62,
6404,
896,
13,
2302,
437,
7,
6404,
896,
8,
198,
4798,
7203,
45677,
4943,
198,
198,
11748,
15284,
62,
6404,
355,
869,
519,
628,
628,
628,
198,
198,
15255,
9250,
796,
4614,
9250,
3419,
198,
15255,
9250,
13,
5589,
1133,
62,
1084,
9806,
82,
7,
7890,
62,
27432,
11,
24148,
4877,
28,
9521,
7,
16,
11,
1367,
4008,
198,
198,
15255,
9250,
13,
5589,
1133,
62,
9288,
62,
7959,
40356,
7,
47,
3913,
4877,
28,
9521,
7,
16,
11,
1367,
4008,
198,
198,
4798,
7203,
34,
5064,
1503,
12,
3064,
4943,
198,
66,
3064,
62,
43420,
796,
31029,
13,
5589,
1133,
62,
702,
62,
7959,
40356,
7,
66,
361,
283,
3064,
11,
47,
3913,
4877,
28,
9521,
7,
16,
11,
1157,
4008
] | 2.419497 | 1,590 |
import logging
import math
from misaka import Markdown, HtmlRenderer
from lxml.html import fromstring
# https://stackoverflow.com/a/3155023
millnames = ['',' thousand',' million',' billion',' trillion'] | [
11748,
18931,
198,
11748,
10688,
198,
198,
6738,
2984,
8130,
1330,
2940,
2902,
11,
367,
20369,
49,
437,
11882,
198,
6738,
300,
19875,
13,
6494,
1330,
422,
8841,
198,
198,
2,
3740,
1378,
25558,
2502,
11125,
13,
785,
14,
64,
14,
27936,
1120,
1954,
198,
17805,
14933,
796,
37250,
41707,
7319,
41707,
1510,
41707,
2997,
41707,
12989,
20520
] | 3.517241 | 58 |
from flask import Flask
from elasticsearch import Elasticsearch
from contact import Contact
class Handler(object):
"""
Handles operations on elasticsearch.
"""
def list_contacts(self, arguments):
"""
Returns a list of contacts or False.
"""
try:
self.es.indices.refresh(index = self.index_name)
res = self.es.search(index = self.index_name, body = {
"from": arguments["page"] * arguments["pageSize"],
"size": arguments["pageSize"],
"query": arguments["query"]
})
return res['hits']['hits']
except:
return False
def create_contact(self, form):
"""
Creates contact from form data. Returns True if successful.
"""
try:
if self._get_contact(form['name']): #contact by that name exists
return False
else:
contact = Contact(form)
res = self.es.index(index = self.index_name, doc_type = '_doc',
body = str(contact))
return res['result'] == 'created'
except:
return False
def list_a_contact(self, name):
"""
Returns data on a single contact identified by name.
"""
try:
return self._get_contact(name)['_source']
except:
return False
def update_contact(self, form):
"""
Update a contact using form data. Returns True if successful.
"""
try:
if self.delete_contact(form['name']):
return self.create_contact(form)
else:
return False
except:
return False
def delete_contact(self, name):
"""
Delete a contact identified by name. Returns True if successful.
"""
try:
contact_id = self._get_contact(name)['_id']
res = self.es.delete(index = self.index_name, doc_type = '_doc',
id = contact_id)
return res['result'] == 'deleted'
except:
return False
| [
6738,
42903,
1330,
46947,
198,
6738,
27468,
12947,
1330,
48567,
12947,
198,
6738,
2800,
1330,
14039,
628,
198,
4871,
32412,
7,
15252,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
7157,
829,
4560,
319,
27468,
12947,
13,
198,
220,
220,
220,
37227,
628,
198,
220,
220,
220,
825,
1351,
62,
3642,
8656,
7,
944,
11,
7159,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
16409,
257,
1351,
286,
13961,
393,
10352,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
274,
13,
521,
1063,
13,
5420,
3447,
7,
9630,
796,
2116,
13,
9630,
62,
3672,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
581,
796,
2116,
13,
274,
13,
12947,
7,
9630,
796,
2116,
13,
9630,
62,
3672,
11,
1767,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
6738,
1298,
7159,
14692,
7700,
8973,
1635,
7159,
14692,
7700,
10699,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
7857,
1298,
7159,
14692,
7700,
10699,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
22766,
1298,
7159,
14692,
22766,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
32092,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
581,
17816,
71,
896,
6,
7131,
6,
71,
896,
20520,
628,
220,
220,
220,
220,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
628,
198,
220,
220,
220,
825,
2251,
62,
32057,
7,
944,
11,
1296,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
7921,
274,
2800,
422,
1296,
1366,
13,
16409,
6407,
611,
4388,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2116,
13557,
1136,
62,
32057,
7,
687,
17816,
3672,
20520,
2599,
1303,
32057,
416,
326,
1438,
7160,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2800,
796,
14039,
7,
687,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
581,
796,
2116,
13,
274,
13,
9630,
7,
9630,
796,
2116,
13,
9630,
62,
3672,
11,
2205,
62,
4906,
796,
705,
62,
15390,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1767,
796,
965,
7,
32057,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
581,
17816,
20274,
20520,
6624,
705,
25598,
6,
628,
220,
220,
220,
220,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
628,
198,
220,
220,
220,
825,
1351,
62,
64,
62,
32057,
7,
944,
11,
1438,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
16409,
1366,
319,
257,
2060,
2800,
5174,
416,
1438,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
220,
2116,
13557,
1136,
62,
32057,
7,
3672,
8,
17816,
62,
10459,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
628,
198,
220,
220,
220,
825,
4296,
62,
32057,
7,
944,
11,
1296,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
10133,
257,
2800,
1262,
1296,
1366,
13,
16409,
6407,
611,
4388,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2116,
13,
33678,
62,
32057,
7,
687,
17816,
3672,
20520,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13,
17953,
62,
32057,
7,
687,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
628,
220,
220,
220,
825,
12233,
62,
32057,
7,
944,
11,
1438,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
23520,
257,
2800,
5174,
416,
1438,
13,
16409,
6407,
611,
4388,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2800,
62,
312,
796,
2116,
13557,
1136,
62,
32057,
7,
3672,
8,
17816,
62,
312,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
581,
796,
2116,
13,
274,
13,
33678,
7,
9630,
796,
2116,
13,
9630,
62,
3672,
11,
2205,
62,
4906,
796,
705,
62,
15390,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4686,
796,
2800,
62,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
581,
17816,
20274,
20520,
6624,
705,
2934,
33342,
6,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
198
] | 2.058052 | 1,068 |
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
| [
6738,
42625,
14208,
13,
9945,
1330,
4981,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
27530,
1330,
11787,
198,
198,
2,
13610,
534,
4981,
994,
13,
628,
628,
198,
220,
220,
220,
220,
198,
220,
220,
220,
220,
628
] | 2.829268 | 41 |
import arcpy
source = "C:\\TxDOT\\Shapefiles\\District_Offices.shp"
outputcopy = "T:\\DATAMGT\\MAPPING\\Personal Folders\\Adam\\District_Offices.shp"
copyPhone()
| [
11748,
10389,
9078,
198,
10459,
796,
366,
34,
25,
6852,
46047,
35,
2394,
6852,
33383,
16624,
6852,
44857,
62,
9362,
1063,
13,
1477,
79,
1,
198,
22915,
30073,
796,
366,
51,
25,
6852,
35,
1404,
2390,
19555,
6852,
44,
24805,
2751,
6852,
30228,
39957,
364,
6852,
23159,
6852,
44857,
62,
9362,
1063,
13,
1477,
79,
1,
198,
30073,
6132,
3419,
198
] | 2.655738 | 61 |
from novmpy.bridge import *
from capstone import *
from capstone.x86 import *
from novmpy.x86_deobf import *
from novmpy.match_helper import *
| [
6738,
645,
85,
3149,
88,
13,
9458,
1330,
1635,
198,
6738,
1451,
6440,
1330,
1635,
198,
6738,
1451,
6440,
13,
87,
4521,
1330,
1635,
198,
6738,
645,
85,
3149,
88,
13,
87,
4521,
62,
2934,
672,
69,
1330,
1635,
198,
6738,
645,
85,
3149,
88,
13,
15699,
62,
2978,
525,
1330,
1635,
628,
198
] | 2.685185 | 54 |
#!/usr/bin/env python
import rospy
import smach_ros
from smach_tutorial.BasicStateMachine import BasicStateMachine_0,\
BasicStateMachine_1,\
BasicStateMachine_2
##-----------------------------------------------------------------------------------
# Example
##-----------------------------------------------------------------------------------
if __name__ == '__main__':
rospy.init_node('tutorial_node')
main() #Change to main1 to call your function
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
11748,
686,
2777,
88,
198,
11748,
895,
620,
62,
4951,
198,
198,
6738,
895,
620,
62,
83,
44917,
13,
26416,
9012,
37573,
1330,
14392,
9012,
37573,
62,
15,
11,
59,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14392,
9012,
37573,
62,
16,
11,
59,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14392,
9012,
37573,
62,
17,
198,
2235,
10097,
1783,
6329,
198,
2,
17934,
198,
198,
2235,
10097,
1783,
6329,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
686,
2777,
88,
13,
15003,
62,
17440,
10786,
83,
44917,
62,
17440,
11537,
198,
220,
220,
220,
1388,
3419,
1303,
19400,
284,
1388,
16,
284,
869,
534,
2163,
198
] | 2.741294 | 201 |
#!/usr/bin/env python
from translate.convert import xliff2po
from translate.misc import wStringIO
from translate.storage.test_base import headerless_len, first_translatable
class TestBasicXLIFF2PO(TestXLIFF2PO):
"""This tests a basic XLIFF file without xmlns attribute"""
xliffskeleton = '''<?xml version="1.0" ?>
<xliff version="1.1">
<file original="filename.po" source-language="en-US" datatype="po">
<body>
%s
</body>
</file>
</xliff>'''
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
6738,
15772,
13,
1102,
1851,
1330,
2124,
75,
733,
17,
7501,
198,
6738,
15772,
13,
44374,
1330,
266,
10100,
9399,
198,
6738,
15772,
13,
35350,
13,
9288,
62,
8692,
1330,
13639,
1203,
62,
11925,
11,
717,
62,
7645,
49009,
628,
198,
4871,
6208,
26416,
32457,
29267,
17,
16402,
7,
14402,
32457,
29267,
17,
16402,
2599,
198,
220,
220,
220,
37227,
1212,
5254,
257,
4096,
16276,
29267,
2393,
1231,
35555,
5907,
11688,
37811,
628,
220,
220,
220,
2124,
75,
10203,
38800,
796,
705,
7061,
47934,
19875,
2196,
2625,
16,
13,
15,
1,
5633,
29,
198,
27,
87,
75,
733,
2196,
2625,
16,
13,
16,
5320,
198,
220,
1279,
7753,
2656,
2625,
34345,
13,
7501,
1,
2723,
12,
16129,
2625,
268,
12,
2937,
1,
4818,
265,
2981,
2625,
7501,
5320,
198,
220,
220,
220,
1279,
2618,
29,
198,
220,
220,
220,
220,
220,
220,
220,
4064,
82,
198,
220,
220,
220,
7359,
2618,
29,
198,
220,
7359,
7753,
29,
198,
3556,
87,
75,
733,
29,
7061,
6,
198
] | 2.693182 | 176 |
""" Your colleagues have been looking over you shoulder. When you should have been doing your boring real job, you've been using the work computers to smash in endless hours of codewars.
In a team meeting, a terrible, awful person declares to the group that you aren't working. You're in trouble. You quickly have to gauge the feeling in the room to decide whether or not you should gather your things and leave.
Given an object (meet) containing team member names as keys, and their happiness rating out of 10 as the value, you need to assess the overall happiness rating of the group. If <= 5, return 'Get Out Now!'. Else return 'Nice Work Champ!'.
Happiness rating will be total score / number of people in the room.
Note that your boss is in the room (boss), their score is worth double it's face value (but they are still just one person!). """
"""
test.assert_equals(outed({'tim':0, 'jim':2, 'randy':0, 'sandy':7, 'andy':0, 'katie':5, 'laura':1, 'saajid':2, 'alex':3, 'john':2, 'mr':0}, 'laura'), 'Get Out Now!')
test.assert_equals(outed({'tim':1, 'jim':3, 'randy':9, 'sandy':6, 'andy':7, 'katie':6, 'laura':9, 'saajid':9, 'alex':9, 'john':9, 'mr':8}, 'katie'), 'Nice Work Champ!')
test.assert_equals(outed({'tim':2, 'jim':4, 'randy':0, 'sandy':5, 'andy':8, 'katie':6, 'laura':2, 'saajid':2, 'alex':3, 'john':2, 'mr':8}, 'john'), 'Get Out Now!') """
| [
37811,
3406,
7810,
423,
587,
2045,
625,
345,
8163,
13,
1649,
345,
815,
423,
587,
1804,
534,
14262,
1103,
1693,
11,
345,
1053,
587,
1262,
262,
670,
9061,
284,
24273,
287,
13079,
2250,
286,
14873,
413,
945,
13,
198,
198,
818,
257,
1074,
3249,
11,
257,
7818,
11,
12659,
1048,
24183,
284,
262,
1448,
326,
345,
3588,
470,
1762,
13,
921,
821,
287,
5876,
13,
921,
2952,
423,
284,
18266,
262,
4203,
287,
262,
2119,
284,
5409,
1771,
393,
407,
345,
815,
6431,
534,
1243,
290,
2666,
13,
198,
198,
15056,
281,
2134,
357,
47745,
8,
7268,
1074,
2888,
3891,
355,
8251,
11,
290,
511,
12157,
7955,
503,
286,
838,
355,
262,
1988,
11,
345,
761,
284,
4659,
262,
4045,
12157,
7955,
286,
262,
1448,
13,
1002,
19841,
642,
11,
1441,
705,
3855,
3806,
2735,
0,
4458,
25974,
1441,
705,
35284,
5521,
29260,
0,
4458,
198,
198,
39,
42661,
7955,
481,
307,
2472,
4776,
1220,
1271,
286,
661,
287,
262,
2119,
13,
198,
198,
6425,
326,
534,
6478,
318,
287,
262,
2119,
357,
42820,
828,
511,
4776,
318,
2861,
4274,
340,
338,
1986,
1988,
357,
4360,
484,
389,
991,
655,
530,
1048,
19588,
37227,
198,
198,
37811,
220,
198,
9288,
13,
30493,
62,
4853,
874,
7,
18534,
15090,
6,
16514,
10354,
15,
11,
705,
73,
320,
10354,
17,
11,
705,
81,
10757,
10354,
15,
11,
705,
82,
10757,
10354,
22,
11,
705,
10757,
10354,
15,
11,
705,
41826,
494,
10354,
20,
11,
705,
75,
33830,
10354,
16,
11,
705,
11400,
1228,
312,
10354,
17,
11,
705,
1000,
87,
10354,
18,
11,
705,
30686,
10354,
17,
11,
705,
43395,
10354,
15,
5512,
705,
75,
33830,
33809,
705,
3855,
3806,
2735,
0,
11537,
198,
9288,
13,
30493,
62,
4853,
874,
7,
18534,
15090,
6,
16514,
10354,
16,
11,
705,
73,
320,
10354,
18,
11,
705,
81,
10757,
10354,
24,
11,
705,
82,
10757,
10354,
21,
11,
705,
10757,
10354,
22,
11,
705,
41826,
494,
10354,
21,
11,
705,
75,
33830,
10354,
24,
11,
705,
11400,
1228,
312,
10354,
24,
11,
705,
1000,
87,
10354,
24,
11,
705,
30686,
10354,
24,
11,
705,
43395,
10354,
23,
5512,
705,
41826,
494,
33809,
705,
35284,
5521,
29260,
0,
11537,
198,
9288,
13,
30493,
62,
4853,
874,
7,
18534,
15090,
6,
16514,
10354,
17,
11,
705,
73,
320,
10354,
19,
11,
705,
81,
10757,
10354,
15,
11,
705,
82,
10757,
10354,
20,
11,
705,
10757,
10354,
23,
11,
705,
41826,
494,
10354,
21,
11,
705,
75,
33830,
10354,
17,
11,
705,
11400,
1228,
312,
10354,
17,
11,
705,
1000,
87,
10354,
18,
11,
705,
30686,
10354,
17,
11,
705,
43395,
10354,
23,
5512,
705,
30686,
33809,
705,
3855,
3806,
2735,
0,
11537,
37227,
198
] | 3.040179 | 448 |
from app_couriers.serializers import CourierSerializer
from .models import Orders
| [
6738,
598,
62,
66,
280,
8910,
13,
46911,
11341,
1330,
34268,
32634,
7509,
198,
6738,
764,
27530,
1330,
30689,
628
] | 4.15 | 20 |
'''
Implementation of Rapid Automatic Keyword Extraction (RAKE) algorithm for Chinese
Original algorithm described in: Rose, S., Engel, D., Cramer, N., & Cowley, W. (2010).
Automatic Keyword Extraction from Individual Documents. In M. W. Berry & J. Kogan
(Eds.), Text Mining: Theory and Applications: John Wiley & Sons.
'''
__author__ = "Ruoyang Xu"
import jieba
import jieba.posseg as pseg
import operator
import json
from collections import Counter
# Data structure for holding data
# Check if contains num
# Read Target Case if Json
if __name__ == '__main__':
with open('data/testCase/文本1.txt','r') as fp:
text = fp.read()
result = run(text)
print(result)
| [
7061,
6,
198,
3546,
32851,
286,
26430,
30199,
7383,
4775,
5683,
7861,
357,
3861,
7336,
8,
11862,
329,
3999,
198,
20556,
11862,
3417,
287,
25,
8049,
11,
311,
1539,
46073,
11,
360,
1539,
327,
29172,
11,
399,
1539,
1222,
10417,
1636,
11,
370,
13,
357,
10333,
737,
198,
16541,
13730,
7383,
4775,
5683,
7861,
422,
18629,
33267,
13,
554,
337,
13,
370,
13,
20165,
1222,
449,
13,
509,
9632,
198,
7,
7407,
82,
12179,
8255,
29269,
25,
17003,
290,
26622,
25,
1757,
43424,
1222,
27989,
13,
220,
198,
7061,
6,
198,
834,
9800,
834,
796,
366,
40464,
726,
648,
33591,
1,
198,
198,
11748,
474,
494,
7012,
198,
11748,
474,
494,
7012,
13,
1930,
325,
70,
355,
15838,
70,
198,
11748,
10088,
198,
11748,
33918,
198,
6738,
17268,
1330,
15034,
628,
198,
2,
6060,
4645,
329,
4769,
1366,
198,
198,
2,
6822,
611,
4909,
997,
198,
198,
2,
4149,
12744,
8913,
611,
449,
1559,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
351,
1280,
10786,
7890,
14,
9288,
20448,
14,
23877,
229,
17312,
105,
16,
13,
14116,
41707,
81,
11537,
355,
277,
79,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2420,
796,
277,
79,
13,
961,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1255,
796,
1057,
7,
5239,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
20274,
8,
198
] | 2.965812 | 234 |
from pwn import * # type: ignore
context.binary = "./SaveTheWorld"
p = process()
p.sendline(b"A" * 72 + b"Jotaro!!" + b"Star Platinum!!!" + b"HORA" + b"9999")
p.recvuntil(b"Congratulation, you won!!!")
os.system("grep .*{.*}.* victory_recap.txt")
| [
6738,
279,
675,
1330,
1635,
220,
1303,
2099,
25,
8856,
198,
198,
22866,
13,
39491,
796,
366,
19571,
16928,
464,
10603,
1,
198,
79,
796,
1429,
3419,
198,
79,
13,
21280,
1370,
7,
65,
1,
32,
1,
1635,
7724,
1343,
275,
1,
41,
313,
12022,
37160,
1343,
275,
1,
8248,
23851,
3228,
2474,
1343,
275,
1,
39,
1581,
32,
1,
1343,
275,
1,
24214,
4943,
198,
79,
13,
8344,
85,
28446,
7,
65,
1,
18649,
10366,
1741,
11,
345,
1839,
3228,
2474,
8,
198,
418,
13,
10057,
7203,
70,
7856,
764,
9,
90,
15885,
92,
15885,
5373,
62,
8344,
499,
13,
14116,
4943,
198
] | 2.394231 | 104 |
Desc = cellDescClass("CMPR32X1")
Desc.properties["cell_leakage_power"] = "3632.359140"
Desc.properties["cell_footprint"] = "add32"
Desc.properties["area"] = "69.854400"
Desc.pinOrder = ['A', 'B', 'C', 'CO', 'S']
Desc.add_arc("A","S","combi")
Desc.add_arc("B","S","combi")
Desc.add_arc("C","S","combi")
Desc.add_arc("A","CO","combi")
Desc.add_arc("B","CO","combi")
Desc.add_arc("C","CO","combi")
Desc.add_param("area",69.854400);
Desc.add_pin("A","input")
Desc.add_pin("C","input")
Desc.add_pin("B","input")
Desc.add_pin("CO","output")
Desc.add_pin_func("CO","unknown")
Desc.add_pin("S","output")
Desc.add_pin_func("S","unknown")
CellLib["CMPR32X1"]=Desc
| [
24564,
796,
2685,
24564,
9487,
7203,
24187,
4805,
2624,
55,
16,
4943,
198,
24564,
13,
48310,
14692,
3846,
62,
293,
461,
496,
62,
6477,
8973,
796,
366,
2623,
2624,
13,
30743,
15187,
1,
198,
24564,
13,
48310,
14692,
3846,
62,
5898,
4798,
8973,
796,
366,
2860,
2624,
1,
198,
24564,
13,
48310,
14692,
20337,
8973,
796,
366,
3388,
13,
5332,
2598,
405,
1,
198,
24564,
13,
11635,
18743,
796,
37250,
32,
3256,
705,
33,
3256,
705,
34,
3256,
705,
8220,
3256,
705,
50,
20520,
198,
24564,
13,
2860,
62,
5605,
7203,
32,
2430,
50,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
5605,
7203,
33,
2430,
50,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
5605,
7203,
34,
2430,
50,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
5605,
7203,
32,
2430,
8220,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
5605,
7203,
33,
2430,
8220,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
5605,
7203,
34,
2430,
8220,
2430,
785,
8482,
4943,
198,
24564,
13,
2860,
62,
17143,
7203,
20337,
1600,
3388,
13,
5332,
2598,
405,
1776,
198,
24564,
13,
2860,
62,
11635,
7203,
32,
2430,
15414,
4943,
198,
24564,
13,
2860,
62,
11635,
7203,
34,
2430,
15414,
4943,
198,
24564,
13,
2860,
62,
11635,
7203,
33,
2430,
15414,
4943,
198,
24564,
13,
2860,
62,
11635,
7203,
8220,
2430,
22915,
4943,
198,
24564,
13,
2860,
62,
11635,
62,
20786,
7203,
8220,
2430,
34680,
4943,
198,
24564,
13,
2860,
62,
11635,
7203,
50,
2430,
22915,
4943,
198,
24564,
13,
2860,
62,
11635,
62,
20786,
7203,
50,
2430,
34680,
4943,
198,
28780,
25835,
14692,
24187,
4805,
2624,
55,
16,
8973,
28,
24564,
198
] | 2.361011 | 277 |
"""
---> Univalued Binary Tree
---> Easy
"""
from tree_func import *
in_array = [1, 1, 1, 1, 1, None, 1]
in_root = to_binary_tree(in_array)
pretty_print(in_root)
a = Solution()
print("Answer -", a.isUnivalTree(in_root))
# print("Answer -", a.isUnivalTree(in_root))
"""
Check if node is none or node.value should be equal to root value for that and every other node in its children
Reference - https://leetcode.com/problems/univalued-binary-tree/discuss/211397/JavaPython-3-BFS-and-DFS-clean-codes-w-brief-analysis.
"""
| [
37811,
198,
198,
438,
3784,
791,
2473,
1739,
45755,
12200,
198,
438,
3784,
16789,
198,
198,
37811,
628,
198,
6738,
5509,
62,
20786,
1330,
1635,
628,
198,
198,
259,
62,
18747,
796,
685,
16,
11,
352,
11,
352,
11,
352,
11,
352,
11,
6045,
11,
352,
60,
198,
259,
62,
15763,
796,
284,
62,
39491,
62,
21048,
7,
259,
62,
18747,
8,
198,
37784,
62,
4798,
7,
259,
62,
15763,
8,
198,
64,
796,
28186,
3419,
198,
4798,
7203,
33706,
532,
1600,
257,
13,
271,
3118,
2473,
27660,
7,
259,
62,
15763,
4008,
198,
2,
3601,
7203,
33706,
532,
1600,
257,
13,
271,
3118,
2473,
27660,
7,
259,
62,
15763,
4008,
628,
198,
37811,
198,
9787,
611,
10139,
318,
4844,
393,
10139,
13,
8367,
815,
307,
4961,
284,
6808,
1988,
329,
326,
290,
790,
584,
10139,
287,
663,
1751,
198,
26687,
532,
3740,
1378,
293,
316,
8189,
13,
785,
14,
1676,
22143,
14,
403,
2473,
1739,
12,
39491,
12,
21048,
14,
15410,
1046,
14,
21895,
33372,
14,
29584,
37906,
12,
18,
12,
33,
10652,
12,
392,
12,
8068,
50,
12,
27773,
12,
40148,
12,
86,
12,
65,
3796,
12,
20930,
13,
198,
37811,
198
] | 2.721649 | 194 |
import os
import struct
import numpy as np
def load_mnist(path, kind='train'):
"""Load MNIST data from `path`"""
labels_path = os.path.join(path,
'%s-labels.idx1-ubyte'
% kind)
images_path = os.path.join(path,
'%s-images.idx3-ubyte'
% kind)
with open(labels_path, 'rb') as lbpath:
magic, n = struct.unpack('>II',
lbpath.read(8))
labels = np.fromfile(lbpath,
dtype=np.uint8)
labels = labels.reshape(labels.shape[0], 1)
with open(images_path, 'rb') as imgpath:
magic, num, rows, cols = struct.unpack('>IIII',
imgpath.read(16))
images = np.fromfile(imgpath,
dtype=np.uint8).reshape(len(labels), 784)
return images, labels | [
11748,
28686,
198,
11748,
2878,
198,
11748,
299,
32152,
355,
45941,
198,
198,
4299,
3440,
62,
10295,
396,
7,
6978,
11,
1611,
11639,
27432,
6,
2599,
198,
220,
220,
220,
37227,
8912,
29060,
8808,
1366,
422,
4600,
6978,
63,
37811,
198,
220,
220,
220,
14722,
62,
6978,
796,
28686,
13,
6978,
13,
22179,
7,
6978,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
4,
82,
12,
23912,
1424,
13,
312,
87,
16,
12,
549,
88,
660,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
1611,
8,
198,
220,
220,
220,
4263,
62,
6978,
796,
28686,
13,
6978,
13,
22179,
7,
6978,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
4,
82,
12,
17566,
13,
312,
87,
18,
12,
549,
88,
660,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
1611,
8,
198,
220,
220,
220,
351,
1280,
7,
23912,
1424,
62,
6978,
11,
705,
26145,
11537,
355,
18360,
6978,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5536,
11,
299,
796,
2878,
13,
403,
8002,
10786,
29,
3978,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18360,
6978,
13,
961,
7,
23,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
14722,
796,
45941,
13,
6738,
7753,
7,
23160,
6978,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
28,
37659,
13,
28611,
23,
8,
198,
220,
220,
220,
220,
220,
220,
220,
14722,
796,
14722,
13,
3447,
1758,
7,
23912,
1424,
13,
43358,
58,
15,
4357,
352,
8,
628,
220,
220,
220,
351,
1280,
7,
17566,
62,
6978,
11,
705,
26145,
11537,
355,
33705,
6978,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5536,
11,
997,
11,
15274,
11,
951,
82,
796,
2878,
13,
403,
8002,
10786,
29,
3978,
3978,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33705,
6978,
13,
961,
7,
1433,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
4263,
796,
45941,
13,
6738,
7753,
7,
9600,
6978,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
28,
37659,
13,
28611,
23,
737,
3447,
1758,
7,
11925,
7,
23912,
1424,
828,
767,
5705,
8,
628,
220,
220,
220,
1441,
4263,
11,
14722
] | 1.688057 | 561 |
arr = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 9]
arr.sort()
my_dict = {i:arr.count(i) for i in arr}
# sorting the dictionary based on value
my_dict = {k: v for k, v in sorted(my_dict.items(), key=lambda item: item[1])}
print(len(my_dict))
print(my_dict)
list = list(my_dict.keys())
print(list[-1])
| [
3258,
796,
685,
16,
11,
362,
11,
513,
11,
604,
11,
604,
11,
604,
11,
642,
11,
718,
11,
718,
11,
767,
11,
807,
11,
860,
60,
198,
3258,
13,
30619,
3419,
198,
1820,
62,
11600,
796,
1391,
72,
25,
3258,
13,
9127,
7,
72,
8,
329,
1312,
287,
5240,
92,
198,
198,
2,
29407,
262,
22155,
1912,
319,
1988,
198,
1820,
62,
11600,
796,
1391,
74,
25,
410,
329,
479,
11,
410,
287,
23243,
7,
1820,
62,
11600,
13,
23814,
22784,
1994,
28,
50033,
2378,
25,
2378,
58,
16,
12962,
92,
198,
198,
4798,
7,
11925,
7,
1820,
62,
11600,
4008,
198,
4798,
7,
1820,
62,
11600,
8,
198,
4868,
796,
1351,
7,
1820,
62,
11600,
13,
13083,
28955,
198,
4798,
7,
4868,
58,
12,
16,
12962,
628
] | 2.286822 | 129 |
#coding=utf-8
'''
Created on 2016-1-18
@author: Devuser
'''
from django import template
from doraemon.auth_extend.user.templatetags.auth_required_node import LogoutRequiredNode,LoginRequiredNode,UserRequiredNode,ManagerRequiredNode,AdminRequiredNode
register = template.Library()
@register.tag()
@register.tag()
@register.tag()
@register.tag()
@register.tag() | [
2,
66,
7656,
28,
40477,
12,
23,
198,
7061,
6,
198,
41972,
319,
1584,
12,
16,
12,
1507,
198,
198,
31,
9800,
25,
6245,
7220,
198,
7061,
6,
198,
198,
6738,
42625,
14208,
1330,
11055,
198,
6738,
288,
5799,
7966,
13,
18439,
62,
2302,
437,
13,
7220,
13,
11498,
489,
265,
316,
3775,
13,
18439,
62,
35827,
62,
17440,
1330,
5972,
448,
37374,
19667,
11,
47790,
37374,
19667,
11,
12982,
37374,
19667,
11,
13511,
37374,
19667,
11,
46787,
37374,
19667,
198,
198,
30238,
796,
11055,
13,
23377,
3419,
628,
198,
198,
31,
30238,
13,
12985,
3419,
198,
198,
31,
30238,
13,
12985,
3419,
198,
198,
31,
30238,
13,
12985,
3419,
198,
198,
31,
30238,
13,
12985,
3419,
198,
198,
31,
30238,
13,
12985,
3419
] | 2.975806 | 124 |
import yaml
import schoolopy
import sys
def err(msg):
"""
Prints out error message and exits with error.
"""
print(f"Error: {msg}")
exit(1)
def main(limit):
"""
Likes all the posts & comments
in your most recent feed (20 posts).
Args:
limit: How many posts to like.
Returns:
A message of the number of posts & comments that were newly liked.
"""
with open('config.yaml', 'r') as file:
config = yaml.load(file, Loader=yaml.FullLoader)
sc = schoolopy.Schoology(schoolopy.Auth(config['key'],
config['secret']))
post_liked = 0
comments_liked = 0
# Set the number of posts to check
try:
sc.limit = int(limit)
except ValueError:
err("The 'limit' argument must be a number")
# Get updates
try:
updates = sc.get_feed()
except KeyError:
err("The key or secret is incorrect")
print("Liking posts...")
# Go through all most recent 20 posts
for update in updates:
# Like post
try:
sc.like(update.id)
post_liked += 1
except schoolopy.NoDifferenceError:
pass
# Get comments if post is in a group
if update.realm == "group":
comments = sc.get_group_update_comments(update.id,
update.group_id)
# Else get comments if post is in a course
elif update.realm == "section":
comments = sc.get_section_update_comments(update.id,
update.section_id)
else:
continue
# Go through the comments inside the group
for comment in comments:
# Like each comment
try:
sc.like_comment(update.id, comment.id)
comments_liked += 1
except schoolopy.NoDifferenceError:
continue
return ("---------------\n"
f"Liked {post_liked} posts and {comments_liked} comments")
if __name__ == "__main__":
# Too many arguments are specified
if len(sys.argv) > 2:
err("Only the 'limit' argument is allowed")
# Default limit is 20
limit = 20 if len(sys.argv) == 1 else sys.argv[1]
print(main(limit))
| [
11748,
331,
43695,
198,
11748,
1524,
11081,
198,
11748,
25064,
628,
198,
4299,
11454,
7,
19662,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
12578,
82,
503,
4049,
3275,
290,
30151,
351,
4049,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
3601,
7,
69,
1,
12331,
25,
1391,
19662,
92,
4943,
198,
220,
220,
220,
8420,
7,
16,
8,
628,
198,
4299,
1388,
7,
32374,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
46077,
477,
262,
6851,
1222,
3651,
198,
220,
220,
220,
287,
534,
749,
2274,
3745,
357,
1238,
6851,
737,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
4179,
25,
1374,
867,
6851,
284,
588,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
317,
3275,
286,
262,
1271,
286,
6851,
1222,
3651,
326,
547,
8308,
8288,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
351,
1280,
10786,
11250,
13,
88,
43695,
3256,
705,
81,
11537,
355,
2393,
25,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
796,
331,
43695,
13,
2220,
7,
7753,
11,
8778,
263,
28,
88,
43695,
13,
13295,
17401,
8,
198,
220,
220,
220,
629,
796,
1524,
11081,
13,
50,
6679,
1435,
7,
14347,
11081,
13,
30515,
7,
11250,
17816,
2539,
6,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4566,
17816,
21078,
20520,
4008,
198,
220,
220,
220,
1281,
62,
75,
17951,
796,
657,
198,
220,
220,
220,
3651,
62,
75,
17951,
796,
657,
628,
220,
220,
220,
1303,
5345,
262,
1271,
286,
6851,
284,
2198,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
629,
13,
32374,
796,
493,
7,
32374,
8,
198,
220,
220,
220,
2845,
11052,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
11454,
7203,
464,
705,
32374,
6,
4578,
1276,
307,
257,
1271,
4943,
628,
220,
220,
220,
1303,
3497,
5992,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5992,
796,
629,
13,
1136,
62,
12363,
3419,
198,
220,
220,
220,
2845,
7383,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
11454,
7203,
464,
1994,
393,
3200,
318,
11491,
4943,
628,
220,
220,
220,
3601,
7203,
43,
14132,
6851,
9313,
8,
628,
220,
220,
220,
1303,
1514,
832,
477,
749,
2274,
1160,
6851,
198,
220,
220,
220,
329,
4296,
287,
5992,
25,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
4525,
1281,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
629,
13,
2339,
7,
19119,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1281,
62,
75,
17951,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
1524,
11081,
13,
2949,
28813,
1945,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1208,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
3497,
3651,
611,
1281,
318,
287,
257,
1448,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4296,
13,
5305,
76,
6624,
366,
8094,
1298,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3651,
796,
629,
13,
1136,
62,
8094,
62,
19119,
62,
15944,
7,
19119,
13,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4296,
13,
8094,
62,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
25974,
651,
3651,
611,
1281,
318,
287,
257,
1781,
198,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
4296,
13,
5305,
76,
6624,
366,
5458,
1298,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3651,
796,
629,
13,
1136,
62,
5458,
62,
19119,
62,
15944,
7,
19119,
13,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4296,
13,
5458,
62,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1514,
832,
262,
3651,
2641,
262,
1448,
198,
220,
220,
220,
220,
220,
220,
220,
329,
2912,
287,
3651,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
4525,
1123,
2912,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
629,
13,
2339,
62,
23893,
7,
19119,
13,
312,
11,
2912,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3651,
62,
75,
17951,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2845,
1524,
11081,
13,
2949,
28813,
1945,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
628,
220,
220,
220,
1441,
5855,
24305,
59,
77,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
1,
43,
17951,
1391,
7353,
62,
75,
17951,
92,
6851,
290,
1391,
15944,
62,
75,
17951,
92,
3651,
4943,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1303,
14190,
867,
7159,
389,
7368,
198,
220,
220,
220,
611,
18896,
7,
17597,
13,
853,
85,
8,
1875,
362,
25,
198,
220,
220,
220,
220,
220,
220,
220,
11454,
7203,
10049,
262,
705,
32374,
6,
4578,
318,
3142,
4943,
198,
220,
220,
220,
1303,
15161,
4179,
318,
1160,
198,
220,
220,
220,
4179,
796,
1160,
611,
18896,
7,
17597,
13,
853,
85,
8,
6624,
352,
2073,
25064,
13,
853,
85,
58,
16,
60,
198,
220,
220,
220,
3601,
7,
12417,
7,
32374,
4008,
198
] | 2.171802 | 1,071 |
# Loopit eli silmukat
##### INFO #####
#
# Joskus monimutkaisen kuvion piirtäminen vaatii samojen
# komentojen toistamista moneen kertaan. Loopilla eli silmukalla
# voit toistaa koodipalikoita eli pätkiä koodia
import turtle
t = turtle.Turtle()
# Seuraava on esimerkki silmukasta.
#
# "for" kertoo tietokoneelle että sen tulee toistaa jotakin
# monta kertaa
#
# "in range(2)" kertoo että komento tulee toistaa 2 kertaa
#
# "i" on muuttuja jonka arvo kasvaa yhdellä jokaisen toiston
# (eli iteraation) jälkeen. Muuttujaa i ei käytetä tässä
# tehtäväss, mutta näet myöhemmin esimerkkejä, joissa siitä
# on hyötyä.
for i in range(2):
# Seuraavilla riveillä on komennot jotka toistetaan.
# Nämä rivit ollaan sisennetty, eli ne alkavat kahdella välilyönnillä
# Sisennyksellä kerrotaan mitkä rivit kuuluvat toistettavaan koodipalikkaan.
t.forward(30)
t.left(120)
t.forward(30)
t.right(60)
##### TEHTÄVÄ 1 #####
#
# Klikkaa 'run' ja katso mitä tapahtuu.
#
# Kuinka monta kertaa silmukka tulisi toistaa että tähti olisi valmis?
# Laita oikea numero komennon range(...) sulkujen sisään.
# Vinkkin: voit kokeilla useita eri numeroita ja katsoa mikä toimii
##### TEHTÄVÄ 2 #####
#
# Mieti muita muotoja joissa on toistuva kaava.
# Esimerkiksi: neliö, rappuset, aallot
#
# Muuta silmukkaa niin että se piirtää valitsemasi kuvion.
#
# Vinkki: Aloita piirtämällä vain yksi toisto kirjoittamalla
# "range(1)" ja saa se piirtämään kuten haluat. Voit sitten
# toistaa kuvion niin monta kertaa kuin haluat muuttamalla
# range arvoa.
| [
2,
26304,
270,
1288,
72,
3313,
76,
2724,
265,
198,
198,
4242,
2,
24890,
46424,
198,
2,
198,
2,
22568,
45614,
937,
320,
315,
4914,
13254,
479,
14795,
295,
31028,
2265,
11033,
1084,
268,
46935,
265,
4178,
6072,
13210,
268,
198,
2,
479,
296,
298,
13210,
268,
284,
396,
321,
12523,
285,
505,
268,
479,
861,
28340,
13,
26304,
5049,
1288,
72,
3313,
76,
2724,
30315,
198,
2,
7608,
270,
284,
396,
7252,
479,
702,
8521,
12125,
5350,
1288,
72,
279,
11033,
83,
4106,
11033,
479,
702,
544,
198,
198,
11748,
28699,
198,
83,
796,
28699,
13,
51,
17964,
3419,
198,
198,
2,
1001,
5330,
4170,
319,
1658,
320,
9587,
4106,
3313,
76,
2724,
40197,
13,
198,
2,
198,
2,
366,
1640,
1,
479,
861,
2238,
256,
1155,
482,
505,
13485,
304,
926,
11033,
3308,
256,
2261,
68,
284,
396,
7252,
474,
313,
27048,
198,
2,
40689,
64,
479,
861,
7252,
198,
2,
198,
2,
366,
259,
2837,
7,
17,
16725,
479,
861,
2238,
304,
926,
11033,
479,
296,
50217,
256,
2261,
68,
284,
396,
7252,
362,
479,
861,
7252,
198,
2,
198,
2,
366,
72,
1,
319,
38779,
15318,
84,
6592,
474,
261,
4914,
610,
13038,
479,
292,
6862,
64,
331,
31298,
695,
11033,
474,
17411,
13254,
284,
36363,
198,
2,
357,
43733,
340,
8607,
341,
8,
474,
11033,
75,
365,
268,
13,
8252,
15318,
84,
6592,
64,
1312,
304,
72,
479,
11033,
20760,
316,
11033,
256,
11033,
824,
11033,
198,
2,
573,
4352,
11033,
85,
11033,
824,
11,
4517,
8326,
299,
11033,
316,
616,
9101,
4411,
1084,
1658,
320,
9587,
365,
73,
11033,
11,
2525,
13808,
33721,
270,
11033,
198,
2,
319,
2537,
9101,
774,
11033,
13,
198,
198,
1640,
1312,
287,
2837,
7,
17,
2599,
198,
220,
1303,
1001,
5330,
615,
5049,
40112,
359,
11033,
319,
479,
3674,
1662,
474,
313,
4914,
284,
396,
17167,
272,
13,
198,
220,
1303,
399,
11033,
76,
11033,
374,
452,
270,
267,
8466,
272,
264,
271,
1697,
316,
774,
11,
1288,
72,
497,
32915,
615,
265,
479,
993,
67,
12627,
410,
11033,
75,
813,
9101,
20471,
359,
11033,
198,
220,
1303,
311,
271,
11870,
74,
7255,
11033,
41927,
305,
8326,
272,
10255,
74,
11033,
374,
452,
270,
479,
84,
377,
14795,
265,
284,
396,
3087,
4170,
272,
479,
702,
8521,
1134,
4914,
272,
13,
198,
220,
256,
13,
11813,
7,
1270,
8,
198,
220,
256,
13,
9464,
7,
10232,
8,
198,
220,
256,
13,
11813,
7,
1270,
8,
198,
220,
256,
13,
3506,
7,
1899,
8,
198,
198,
4242,
2,
13368,
6535,
127,
226,
53,
127,
226,
352,
46424,
198,
2,
198,
2,
14770,
1134,
4914,
64,
705,
5143,
6,
45091,
479,
265,
568,
10255,
11033,
9814,
993,
83,
12303,
13,
198,
2,
198,
2,
12554,
48955,
40689,
64,
479,
861,
7252,
3313,
76,
2724,
4914,
48373,
23267,
284,
396,
7252,
304,
926,
11033,
256,
11033,
4352,
72,
25776,
23267,
1188,
25413,
30,
198,
2,
406,
4548,
64,
267,
522,
64,
997,
3529,
479,
296,
1697,
261,
2837,
7,
23029,
264,
12171,
23577,
268,
264,
271,
11033,
11033,
77,
13,
198,
2,
569,
676,
5116,
25,
7608,
270,
479,
2088,
5049,
779,
5350,
1931,
72,
997,
3529,
5350,
45091,
479,
265,
568,
64,
285,
1134,
11033,
284,
320,
4178,
198,
198,
4242,
2,
13368,
6535,
127,
226,
53,
127,
226,
362,
46424,
198,
2,
198,
2,
337,
1155,
72,
285,
5013,
64,
38779,
2069,
6592,
2525,
13808,
319,
284,
396,
84,
6862,
38387,
4170,
13,
198,
2,
8678,
22723,
4106,
591,
72,
25,
299,
43733,
9101,
11,
29106,
385,
316,
11,
257,
439,
313,
198,
2,
198,
2,
8252,
29822,
3313,
76,
2724,
4914,
64,
37628,
259,
304,
926,
11033,
384,
31028,
2265,
11033,
11033,
1188,
270,
325,
5356,
72,
479,
14795,
295,
13,
198,
2,
198,
2,
569,
676,
4106,
25,
978,
78,
5350,
31028,
2265,
11033,
76,
11033,
297,
11033,
23469,
331,
591,
72,
284,
396,
78,
479,
343,
7639,
715,
321,
30315,
198,
2,
366,
9521,
7,
16,
16725,
45091,
473,
64,
384,
31028,
2265,
11033,
76,
11033,
11033,
77,
479,
7809,
10284,
84,
265,
13,
20687,
270,
264,
2621,
198,
2,
284,
396,
7252,
479,
14795,
295,
37628,
259,
40689,
64,
479,
861,
7252,
479,
48441,
10284,
84,
265,
38779,
15318,
321,
30315,
198,
2,
2837,
610,
85,
12162,
13,
198
] | 2.14986 | 714 |
from queue import Queue, Empty
from time import sleep
from threading import Timer
if __name__ == '__main__':
main()
| [
6738,
16834,
1330,
4670,
518,
11,
33523,
201,
198,
6738,
640,
1330,
3993,
201,
198,
6738,
4704,
278,
1330,
5045,
263,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
201,
198,
220,
220,
220,
1388,
3419,
201,
198
] | 2.66 | 50 |
# -*- coding: utf-8 -*-
import hashlib
import subprocess
import sys
import os
G_ZIP_SPLIT_LINE = 500
G_ZIP_SPLIT_UNIT = 100
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
11748,
12234,
8019,
198,
11748,
850,
14681,
198,
11748,
25064,
198,
11748,
28686,
198,
198,
38,
62,
57,
4061,
62,
4303,
43,
2043,
62,
24027,
796,
5323,
198,
38,
62,
57,
4061,
62,
4303,
43,
2043,
62,
4944,
2043,
796,
1802,
628,
628,
628,
628,
198
] | 2.216667 | 60 |
# Copyright 2019 The Sonnet Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# 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.
# ============================================================================
"""Parallel linear module."""
import math
from typing import Optional
from sonnet.src import base
from sonnet.src import initializers
from sonnet.src import once
from sonnet.src import utils
import tensorflow as tf
class ParallelLinears(base.Module):
"""Parallel linear.
This is equivalent to n separate linears applied in parallel to n inputs. It
takes an input of shape [num_linears, batch_size, input_size] and returns an
output of shape [num_linears, batch_size, output_size].
It uses a single batched matmul which is more efficient than stacking separate
snt.Linear layers. This is implemented using `num_linear`s first to avoid the
need for transposes in order to make it efficient when stacking these.
"""
def __init__(self,
output_size: int,
with_bias: bool = True,
w_init: Optional[initializers.Initializer] = None,
b_init: Optional[initializers.Initializer] = None,
name: Optional[str] = None):
"""Constructs a `ParallelLinear` module.
Args:
output_size: Output dimensionality.
with_bias: Whether to include bias parameters. Default `True`.
w_init: Optional initializer for the weights. By default the weights are
initialized truncated random normal values with a standard deviation of
`1 / sqrt(input_feature_size)`, which is commonly used when the inputs
are zero centered (see https://arxiv.org/abs/1502.03167v3).
b_init: Optional initializer for the bias. By default the bias is
initialized to zero.
name: Name of the module.
"""
super().__init__(name=name)
self.output_size = output_size
self.with_bias = with_bias
self.w_init = w_init
if with_bias:
self.b_init = b_init if b_init is not None else initializers.Zeros()
elif b_init is not None:
raise ValueError("When not using a bias the b_init must be None.")
@once.once
def _initialize(self, inputs: tf.Tensor):
"""Constructs parameters used by this module."""
utils.assert_rank(inputs, 3)
self.input_size = inputs.shape[2]
if self.input_size is None: # Can happen inside an @tf.function.
raise ValueError("Input size must be specified at module build time.")
num_linears = inputs.shape[0]
if num_linears is None: # Can happen inside an @tf.function.
raise ValueError(
"The number of linears must be specified at module build time.")
if self.w_init is None:
# See https://arxiv.org/abs/1502.03167v3.
stddev = 1. / math.sqrt(self.input_size)
self.w_init = initializers.TruncatedNormal(stddev=stddev)
self.w = tf.Variable(
self.w_init([num_linears, self.input_size, self.output_size],
inputs.dtype),
name="w")
if self.with_bias:
self.b = tf.Variable(
self.b_init([num_linears, 1, self.output_size], inputs.dtype),
name="b")
| [
2,
15069,
13130,
383,
6295,
3262,
46665,
13,
1439,
6923,
33876,
13,
198,
2,
198,
2,
49962,
739,
262,
24843,
13789,
11,
10628,
362,
13,
15,
357,
1169,
366,
34156,
15341,
198,
2,
345,
743,
407,
779,
428,
2393,
2845,
287,
11846,
351,
262,
13789,
13,
198,
2,
921,
743,
7330,
257,
4866,
286,
262,
13789,
379,
198,
2,
198,
2,
220,
220,
220,
2638,
1378,
2503,
13,
43073,
13,
2398,
14,
677,
4541,
14,
43,
2149,
24290,
12,
17,
13,
15,
198,
2,
198,
2,
17486,
2672,
416,
9723,
1099,
393,
4987,
284,
287,
3597,
11,
3788,
198,
2,
9387,
739,
262,
13789,
318,
9387,
319,
281,
366,
1921,
3180,
1,
29809,
1797,
11,
198,
2,
42881,
34764,
11015,
6375,
7102,
49828,
11053,
3963,
15529,
509,
12115,
11,
2035,
4911,
393,
220,
17142,
13,
198,
2,
4091,
262,
13789,
329,
262,
2176,
3303,
15030,
21627,
290,
198,
2,
11247,
739,
262,
13789,
13,
198,
2,
38093,
2559,
18604,
198,
37811,
10044,
29363,
14174,
8265,
526,
15931,
198,
198,
11748,
10688,
198,
6738,
19720,
1330,
32233,
198,
198,
6738,
3367,
3262,
13,
10677,
1330,
2779,
198,
6738,
3367,
3262,
13,
10677,
1330,
4238,
11341,
198,
6738,
3367,
3262,
13,
10677,
1330,
1752,
198,
6738,
3367,
3262,
13,
10677,
1330,
3384,
4487,
198,
11748,
11192,
273,
11125,
355,
48700,
628,
198,
4871,
42945,
14993,
4127,
7,
8692,
13,
26796,
2599,
198,
220,
37227,
10044,
29363,
14174,
13,
628,
220,
770,
318,
7548,
284,
299,
4553,
9493,
4127,
5625,
287,
10730,
284,
299,
17311,
13,
632,
198,
220,
2753,
281,
5128,
286,
5485,
685,
22510,
62,
2815,
4127,
11,
15458,
62,
7857,
11,
5128,
62,
7857,
60,
290,
5860,
281,
198,
220,
5072,
286,
5485,
685,
22510,
62,
2815,
4127,
11,
15458,
62,
7857,
11,
5072,
62,
7857,
4083,
628,
220,
632,
3544,
257,
2060,
7365,
1740,
2603,
76,
377,
543,
318,
517,
6942,
621,
41228,
4553,
198,
220,
264,
429,
13,
14993,
451,
11685,
13,
770,
318,
9177,
1262,
4600,
22510,
62,
29127,
63,
82,
717,
284,
3368,
262,
198,
220,
761,
329,
1007,
4832,
287,
1502,
284,
787,
340,
6942,
618,
41228,
777,
13,
198,
220,
37227,
628,
220,
825,
11593,
15003,
834,
7,
944,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5072,
62,
7857,
25,
493,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
351,
62,
65,
4448,
25,
20512,
796,
6407,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
266,
62,
15003,
25,
32233,
58,
36733,
11341,
13,
24243,
7509,
60,
796,
6045,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
62,
15003,
25,
32233,
58,
36733,
11341,
13,
24243,
7509,
60,
796,
6045,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
25,
32233,
58,
2536,
60,
796,
6045,
2599,
198,
220,
220,
220,
37227,
42316,
82,
257,
4600,
10044,
29363,
14993,
451,
63,
8265,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
5072,
62,
7857,
25,
25235,
15793,
1483,
13,
198,
220,
220,
220,
220,
220,
351,
62,
65,
4448,
25,
10127,
284,
2291,
10690,
10007,
13,
15161,
4600,
17821,
44646,
198,
220,
220,
220,
220,
220,
266,
62,
15003,
25,
32233,
4238,
7509,
329,
262,
19590,
13,
2750,
4277,
262,
19590,
389,
198,
220,
220,
220,
220,
220,
220,
220,
23224,
40122,
515,
4738,
3487,
3815,
351,
257,
3210,
28833,
286,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
16,
1220,
19862,
17034,
7,
15414,
62,
30053,
62,
7857,
8,
47671,
543,
318,
8811,
973,
618,
262,
17311,
198,
220,
220,
220,
220,
220,
220,
220,
389,
6632,
19254,
357,
3826,
3740,
1378,
283,
87,
452,
13,
2398,
14,
8937,
14,
8628,
17,
13,
3070,
21940,
85,
18,
737,
198,
220,
220,
220,
220,
220,
275,
62,
15003,
25,
32233,
4238,
7509,
329,
262,
10690,
13,
2750,
4277,
262,
10690,
318,
198,
220,
220,
220,
220,
220,
220,
220,
23224,
284,
6632,
13,
198,
220,
220,
220,
220,
220,
1438,
25,
6530,
286,
262,
8265,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2208,
22446,
834,
15003,
834,
7,
3672,
28,
3672,
8,
198,
220,
220,
220,
2116,
13,
22915,
62,
7857,
796,
5072,
62,
7857,
198,
220,
220,
220,
2116,
13,
4480,
62,
65,
4448,
796,
351,
62,
65,
4448,
198,
220,
220,
220,
2116,
13,
86,
62,
15003,
796,
266,
62,
15003,
198,
220,
220,
220,
611,
351,
62,
65,
4448,
25,
198,
220,
220,
220,
220,
220,
2116,
13,
65,
62,
15003,
796,
275,
62,
15003,
611,
275,
62,
15003,
318,
407,
6045,
2073,
4238,
11341,
13,
57,
27498,
3419,
198,
220,
220,
220,
1288,
361,
275,
62,
15003,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7203,
2215,
407,
1262,
257,
10690,
262,
275,
62,
15003,
1276,
307,
6045,
19570,
628,
220,
2488,
27078,
13,
27078,
198,
220,
825,
4808,
36733,
1096,
7,
944,
11,
17311,
25,
48700,
13,
51,
22854,
2599,
198,
220,
220,
220,
37227,
42316,
82,
10007,
973,
416,
428,
8265,
526,
15931,
198,
220,
220,
220,
3384,
4487,
13,
30493,
62,
43027,
7,
15414,
82,
11,
513,
8,
628,
220,
220,
220,
2116,
13,
15414,
62,
7857,
796,
17311,
13,
43358,
58,
17,
60,
198,
220,
220,
220,
611,
2116,
13,
15414,
62,
7857,
318,
6045,
25,
220,
1303,
1680,
1645,
2641,
281,
2488,
27110,
13,
8818,
13,
198,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7203,
20560,
2546,
1276,
307,
7368,
379,
8265,
1382,
640,
19570,
198,
220,
220,
220,
997,
62,
2815,
4127,
796,
17311,
13,
43358,
58,
15,
60,
198,
220,
220,
220,
611,
997,
62,
2815,
4127,
318,
6045,
25,
220,
1303,
1680,
1645,
2641,
281,
2488,
27110,
13,
8818,
13,
198,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
464,
1271,
286,
9493,
4127,
1276,
307,
7368,
379,
8265,
1382,
640,
19570,
628,
220,
220,
220,
611,
2116,
13,
86,
62,
15003,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
1303,
4091,
3740,
1378,
283,
87,
452,
13,
2398,
14,
8937,
14,
8628,
17,
13,
3070,
21940,
85,
18,
13,
198,
220,
220,
220,
220,
220,
336,
1860,
1990,
796,
352,
13,
1220,
10688,
13,
31166,
17034,
7,
944,
13,
15414,
62,
7857,
8,
198,
220,
220,
220,
220,
220,
2116,
13,
86,
62,
15003,
796,
4238,
11341,
13,
2898,
19524,
515,
26447,
7,
301,
1860,
1990,
28,
301,
1860,
1990,
8,
628,
220,
220,
220,
2116,
13,
86,
796,
48700,
13,
43015,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
86,
62,
15003,
26933,
22510,
62,
2815,
4127,
11,
2116,
13,
15414,
62,
7857,
11,
2116,
13,
22915,
62,
7857,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17311,
13,
67,
4906,
828,
198,
220,
220,
220,
220,
220,
220,
220,
1438,
2625,
86,
4943,
628,
220,
220,
220,
611,
2116,
13,
4480,
62,
65,
4448,
25,
198,
220,
220,
220,
220,
220,
2116,
13,
65,
796,
48700,
13,
43015,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
65,
62,
15003,
26933,
22510,
62,
2815,
4127,
11,
352,
11,
2116,
13,
22915,
62,
7857,
4357,
17311,
13,
67,
4906,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
2625,
65,
4943,
198
] | 2.871146 | 1,265 |
import responses
from urllib.parse import urlencode
from tests.util import random_str
from tests.util import mock_http_response
from binance.spot import Spot as Client
from binance.error import ParameterRequiredError, ClientError
mock_item = {"key_1": "value_1", "key_2": "value_2"}
mock_exception = {"code": -1105, "msg": "error message."}
key = random_str()
secret = random_str()
params = {"coin": "USDT", "collateralCoin": "BTC", "amount": "1"}
def test_futures_loan_borrow_without_coin():
"""Tests the API endpoint to borrow cross funds without coin"""
params = {"coin": "", "collateralCoin": "BTC"}
client = Client(key, secret)
client.futures_loan_borrow.when.called_with(**params).should.throw(
ParameterRequiredError
)
def test_futures_loan_borrow_without_collateralCoin():
"""Tests the API endpoint to borrow cross funds without collateralCoin"""
params = {"coin": "USDT", "collateralCoin": ""}
client = Client(key, secret)
client.futures_loan_borrow.when.called_with(**params).should.throw(
ParameterRequiredError
)
@mock_http_response(
responses.POST,
"/sapi/v1/futures/loan/borrow\\?" + urlencode(params),
mock_item,
200,
)
def test_futures_loan_borrow():
"""Tests the API endpoint to borrow cross funds"""
client = Client(key, secret)
response = client.futures_loan_borrow(**params)
response.should.equal(mock_item)
| [
11748,
9109,
198,
198,
6738,
2956,
297,
571,
13,
29572,
1330,
2956,
11925,
8189,
198,
6738,
5254,
13,
22602,
1330,
4738,
62,
2536,
198,
6738,
5254,
13,
22602,
1330,
15290,
62,
4023,
62,
26209,
198,
6738,
9874,
590,
13,
20485,
1330,
15899,
355,
20985,
198,
6738,
9874,
590,
13,
18224,
1330,
25139,
2357,
37374,
12331,
11,
20985,
12331,
198,
198,
76,
735,
62,
9186,
796,
19779,
2539,
62,
16,
1298,
366,
8367,
62,
16,
1600,
366,
2539,
62,
17,
1298,
366,
8367,
62,
17,
20662,
198,
76,
735,
62,
1069,
4516,
796,
19779,
8189,
1298,
532,
11442,
20,
11,
366,
19662,
1298,
366,
18224,
3275,
526,
92,
198,
198,
2539,
796,
4738,
62,
2536,
3419,
198,
21078,
796,
4738,
62,
2536,
3419,
198,
198,
37266,
796,
19779,
3630,
1298,
366,
2937,
24544,
1600,
366,
26000,
10534,
24387,
1298,
366,
35964,
1600,
366,
17287,
1298,
366,
16,
20662,
628,
198,
4299,
1332,
62,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
62,
19419,
62,
3630,
33529,
198,
220,
220,
220,
37227,
51,
3558,
262,
7824,
36123,
284,
8804,
3272,
5153,
1231,
10752,
37811,
628,
220,
220,
220,
42287,
796,
19779,
3630,
1298,
366,
1600,
366,
26000,
10534,
24387,
1298,
366,
35964,
20662,
628,
220,
220,
220,
5456,
796,
20985,
7,
2539,
11,
3200,
8,
198,
220,
220,
220,
5456,
13,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
13,
12518,
13,
7174,
62,
4480,
7,
1174,
37266,
737,
21754,
13,
16939,
7,
198,
220,
220,
220,
220,
220,
220,
220,
25139,
2357,
37374,
12331,
198,
220,
220,
220,
1267,
628,
198,
4299,
1332,
62,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
62,
19419,
62,
26000,
10534,
24387,
33529,
198,
220,
220,
220,
37227,
51,
3558,
262,
7824,
36123,
284,
8804,
3272,
5153,
1231,
27907,
24387,
37811,
628,
220,
220,
220,
42287,
796,
19779,
3630,
1298,
366,
2937,
24544,
1600,
366,
26000,
10534,
24387,
1298,
13538,
92,
628,
220,
220,
220,
5456,
796,
20985,
7,
2539,
11,
3200,
8,
198,
220,
220,
220,
5456,
13,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
13,
12518,
13,
7174,
62,
4480,
7,
1174,
37266,
737,
21754,
13,
16939,
7,
198,
220,
220,
220,
220,
220,
220,
220,
25139,
2357,
37374,
12331,
198,
220,
220,
220,
1267,
628,
198,
31,
76,
735,
62,
4023,
62,
26209,
7,
198,
220,
220,
220,
9109,
13,
32782,
11,
198,
220,
220,
220,
12813,
82,
15042,
14,
85,
16,
14,
69,
315,
942,
14,
5439,
272,
14,
2865,
808,
6852,
1701,
1343,
2956,
11925,
8189,
7,
37266,
828,
198,
220,
220,
220,
15290,
62,
9186,
11,
198,
220,
220,
220,
939,
11,
198,
8,
198,
4299,
1332,
62,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
33529,
198,
220,
220,
220,
37227,
51,
3558,
262,
7824,
36123,
284,
8804,
3272,
5153,
37811,
628,
220,
220,
220,
5456,
796,
20985,
7,
2539,
11,
3200,
8,
198,
220,
220,
220,
2882,
796,
5456,
13,
69,
315,
942,
62,
5439,
272,
62,
2865,
808,
7,
1174,
37266,
8,
198,
220,
220,
220,
2882,
13,
21754,
13,
40496,
7,
76,
735,
62,
9186,
8,
198
] | 2.762548 | 518 |
#
# Copyright (c) SAS Institute Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from testrunner import testhelp
from conary_test import rephelp
import os
from conary_test.cvctest.buildtest import policytest
from conary import versions
from conary.build import action, trovefilter
from conary.conaryclient import cmdline
from conary.deps import deps
from conary.lib import util
| [
2,
198,
2,
15069,
357,
66,
8,
35516,
5136,
3457,
13,
198,
2,
198,
2,
49962,
739,
262,
24843,
13789,
11,
10628,
362,
13,
15,
357,
1169,
366,
34156,
15341,
198,
2,
345,
743,
407,
779,
428,
2393,
2845,
287,
11846,
351,
262,
13789,
13,
198,
2,
921,
743,
7330,
257,
4866,
286,
262,
13789,
379,
198,
2,
198,
2,
220,
220,
220,
220,
2638,
1378,
2503,
13,
43073,
13,
2398,
14,
677,
4541,
14,
43,
2149,
24290,
12,
17,
13,
15,
198,
2,
198,
2,
17486,
2672,
416,
9723,
1099,
393,
4987,
284,
287,
3597,
11,
3788,
198,
2,
9387,
739,
262,
13789,
318,
9387,
319,
281,
366,
1921,
3180,
1,
29809,
1797,
11,
198,
2,
42881,
34764,
11015,
6375,
7102,
49828,
11053,
3963,
15529,
509,
12115,
11,
2035,
4911,
393,
17142,
13,
198,
2,
4091,
262,
13789,
329,
262,
2176,
3303,
15030,
21627,
290,
198,
2,
11247,
739,
262,
13789,
13,
198,
2,
628,
198,
6738,
1332,
16737,
1330,
1332,
16794,
628,
198,
6738,
369,
560,
62,
9288,
1330,
1128,
16794,
198,
198,
11748,
28686,
198,
198,
6738,
369,
560,
62,
9288,
13,
33967,
310,
395,
13,
11249,
9288,
1330,
2450,
9288,
198,
198,
6738,
369,
560,
1330,
6300,
198,
6738,
369,
560,
13,
11249,
1330,
2223,
11,
42377,
24455,
198,
6738,
369,
560,
13,
1102,
560,
16366,
1330,
23991,
1370,
198,
6738,
369,
560,
13,
10378,
82,
1330,
390,
862,
198,
6738,
369,
560,
13,
8019,
1330,
7736,
628
] | 3.677686 | 242 |
'''
#Students Name's: Ciaran Carroll
# Student Id Number's: 13113259
#
# Project 1:
# Implement image reconstruction from parallel-projection sinograms using Python.
#
# CAT Scanners (or CT scan) - Computer Axial Tomography
# CT scan: is a special X-ray tests that produce cross-sectional images of the body using X-rays and
# a computer
# FFTs - Fast Fourieris Transform
# FFT: is an algorithm that samples a signal over a period of time (or space) and divides it
# into its frequency components
# Laminogram: Reconstruct the sum of the backprojections (i.e. sum of the f(x,y))
# Coplanar rotational laminography (CRL) is a special case of laminography which is a
# tomographic technique used to image cross-sectional views through solid objects.
#
# Aim:
# (1) Reconstruct an image from the sinogram image (sinogram.png)
# (2) Investigate the behaviour of backprojection reconstruction with ramp-filtering
# (3) Investigate the behaviour of backprojection reconstruction without ramp-filtering
# (4) Investigate the behaviour of backprojection reconstruction with Hamming-windowed ramp-filtering
#
# A display of all the projections for all X-ray angles is called a Sinogram
#
# Rebuild the image from a sum of the 'Backprojections' of the 1-d projection data
Step 1 - Backprojection reconstruction of the sinogram without filtering:
When all the projection angles are combined the projection, the resulting image will
be blurred. This is due to the fact that the resulting image is concentrated towards the
center. (concentrated samples of the image towards the center, and more sparse samples near
the edges). To compensate for this we will need to apply a filter to the output image of the
backprojection such as the ramp filter or the Hamming-windowed ramp-filter
New Steps
(1) - Form the image projections and translate into the frequency domain using the FFT
'''
import numpy as np
import matplotlib.pylab as plt
from PIL import Image
from scipy.ndimage.filters import gaussian_filter
from skimage.transform import rotate
import scipy.fftpack as fft
#from skimage.transform import iradon
def imread(filename,greyscale=True):
"""Load an image, return as a Numpy array."""
if greyscale:
pil_im = Image.open(filename).convert('L')
else:
pil_im = Image.open(filename)
return np.array(pil_im)
def imshow(im, autoscale=False,colourmap='gray', newfig=True, title=None):
"""Display an image, turning off autoscaling (unless explicitly required)
and interpolation.
(1) 8-bit greyscale images and 24-bit RGB are scaled in 0..255.
(2) 0-1 binary images are scaled in 0..1.
(3) Float images are scaled in 0.0..1.0 if their min values are >= 0
and their max values <= 1.0
(4) Float images are scaled in 0.0..255.0 if their min values are >= 0
and their max values are > 1 and <= 255.0
(5) Any image not covered by the above cases is autoscaled. If
autoscaling is explicitly requested, it is always turned on.
A new figure is created by default. "newfig=False" turns off this
behaviour.
Interpolation is always off (unless the backend stops this).
"""
if newfig:
if title != None: fig = plt.figure(title)
else: fig = plt.figure()
if autoscale:
plt.imshow(im,interpolation='nearest',cmap=colourmap)
else:
maxval = im.max()
if im.dtype == 'uint8': ## 8-bit greyscale or 24-bit RGB
if maxval > 1: maxval = 255
plt.imshow(im,interpolation='nearest',vmin=0,vmax=maxval,cmap=colourmap)
elif im.dtype == 'float32' or im.dtype == 'float64':
minval = im.min()
if minval >= 0.0:
if maxval <= 1.0: ## Looks like 0..1 float greyscale
minval, maxval = 0.0, 1.0
elif maxval <= 255.0: ## Looks like a float 0 .. 255 image.
minval, maxval = 0.0, 255.0
plt.imshow(im,interpolation='nearest',vmin=minval,vmax=maxval,cmap=colourmap)
else:
plt.imshow(im,interpolation='nearest',cmap=colourmap)
plt.axis('image')
## plt.axis('off')
plt.show()
##return fig
def build_proj_ffts(projs):
"Build 1-d FFTs of an array of projections, each projection 1 row fo the array."
return fft.rfft(projs, axis=1)
def build_proj_iffts(projs):
"Build 1-d iFFTs of an array of projections, each projection 1 row fo the array."
return fft.irfft(projs, axis=1)
def build_laminogram(radonT):
"Generate a laminogram by simple backprojection using the Radon Transform of an image, 'radonT'."
laminogram = np.zeros((radonT.shape[1],radonT.shape[1]))
dTheta = 180.0 / radonT.shape[0]
for i in range(radonT.shape[0]):
temp = np.tile(radonT[i],(radonT.shape[1],1))
temp = rotate(temp, dTheta*i)
laminogram += temp
return laminogram
def ramp_filter_ffts(ffts):
"Ramp filter a 2-d array of 1-d FFTs (1-d FFTs along the rows)."
ramp = np.floor(np.arange(0.5, ffts.shape[1]//2 + 0.1, 0.5))
return ffts * ramp
def radon(image, steps):
"Build the Radon Transform using 'steps' projections of 'image’."
projections = [] # Accumulate projections in a list.
dTheta = -180.0 / steps # Angle increment for rotations.
for i in range(steps):
projections.append(rotate(image, i*dTheta).sum(axis=0))
return np.vstack(projections)
# Original Sinogram Image
sinogram = imread('sinogram.png')
imshow(sinogram, title="Original Sinogram Image")
# Backprojection reconstruction without ramp filtering
sinogram_laminogram = build_laminogram(sinogram)
imshow(sinogram_laminogram, title="Sinogram reconstruction by backprojection")
# Backprojection reconstruction with ramp filtering
# Apply an infinite ramp filter to the reconstruction
# Maybe apply a ramp filter with a cutoff at half the max frwquency
# But most likely no point
# Get the FFT of the image (Frequency Domain)
fourier = build_proj_ffts(sinogram)
# Filter the fourier transform by the ramp filter
ramp_filtered = ramp_filter_ffts(fourier)
# Take the inverse FFT of the image to convert it back to Special Domain
inverse_fourier_ramp_filtered = build_proj_iffts(ramp_filtered)
#imshow(iffts_projection_sinogram, title="Test ramp filter")
#test1 = radon(iffts_projection_sinogram, 180)
#imshow(test1, title="Test ramp filter")
# Build the filtered image by pbackprojecting the filtered projections
filtered_reconstrution = build_laminogram(inverse_fourier_ramp_filtered)
imshow(filtered_reconstrution, title="Test ramp filter")
| [
7061,
6,
198,
2,
28239,
6530,
338,
25,
220,
220,
197,
34,
12571,
272,
21298,
198,
2,
13613,
5121,
7913,
338,
25,
197,
1485,
16616,
25191,
198,
2,
198,
2,
4935,
352,
25,
198,
2,
48282,
2939,
25056,
422,
10730,
12,
16302,
295,
7813,
26836,
1262,
11361,
13,
198,
2,
198,
2,
38348,
1446,
15672,
357,
273,
16356,
9367,
8,
532,
13851,
12176,
498,
4186,
4867,
198,
2,
16356,
9367,
25,
318,
257,
2041,
1395,
12,
2433,
5254,
326,
4439,
3272,
12,
44330,
4263,
286,
262,
1767,
1262,
1395,
12,
20477,
290,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
3644,
198,
2,
376,
9792,
82,
532,
12549,
34296,
5277,
271,
26981,
198,
2,
376,
9792,
25,
318,
281,
11862,
326,
8405,
257,
6737,
625,
257,
2278,
286,
640,
357,
273,
2272,
8,
290,
36319,
340,
198,
2,
220,
220,
220,
220,
220,
656,
663,
8373,
6805,
198,
2,
406,
5669,
21857,
25,
23419,
7249,
262,
2160,
286,
262,
736,
16302,
507,
357,
72,
13,
68,
13,
2160,
286,
262,
277,
7,
87,
11,
88,
4008,
198,
2,
6955,
9620,
283,
5724,
864,
300,
5669,
4867,
357,
34,
7836,
8,
318,
257,
2041,
1339,
286,
300,
5669,
4867,
543,
318,
257,
198,
2,
220,
16667,
6826,
8173,
973,
284,
2939,
3272,
12,
44330,
5009,
832,
4735,
5563,
13,
198,
2,
198,
2,
36223,
25,
198,
2,
357,
16,
8,
23419,
7249,
281,
2939,
422,
262,
7813,
21857,
2939,
357,
31369,
21857,
13,
11134,
8,
198,
2,
357,
17,
8,
7488,
10055,
262,
9172,
286,
736,
16302,
295,
25056,
351,
10454,
12,
10379,
20212,
198,
2,
357,
18,
8,
7488,
10055,
262,
9172,
286,
736,
16302,
295,
25056,
1231,
10454,
12,
10379,
20212,
198,
2,
357,
19,
8,
7488,
10055,
262,
9172,
286,
736,
16302,
295,
25056,
351,
4345,
2229,
12,
7972,
6972,
10454,
12,
10379,
20212,
198,
2,
198,
2,
317,
3359,
286,
477,
262,
19887,
329,
477,
1395,
12,
2433,
18333,
318,
1444,
257,
10884,
21857,
198,
2,
198,
2,
797,
11249,
262,
2939,
422,
257,
2160,
286,
262,
705,
7282,
16302,
507,
6,
286,
262,
352,
12,
67,
20128,
1366,
198,
198,
8600,
352,
532,
5157,
16302,
295,
25056,
286,
262,
7813,
21857,
1231,
25431,
25,
198,
2215,
477,
262,
20128,
18333,
389,
5929,
262,
20128,
11,
262,
7186,
2939,
481,
198,
1350,
38258,
13,
770,
318,
2233,
284,
262,
1109,
326,
262,
7186,
2939,
318,
17298,
3371,
262,
198,
16159,
13,
357,
1102,
1087,
4111,
8405,
286,
262,
2939,
3371,
262,
3641,
11,
290,
517,
29877,
8405,
1474,
198,
1169,
13015,
737,
1675,
21392,
329,
428,
356,
481,
761,
284,
4174,
257,
8106,
284,
262,
5072,
2939,
286,
262,
198,
1891,
16302,
295,
884,
355,
262,
10454,
8106,
393,
262,
4345,
2229,
12,
7972,
6972,
10454,
12,
24455,
628,
628,
628,
628,
198,
3791,
32144,
198,
7,
16,
8,
532,
5178,
262,
2939,
19887,
290,
15772,
656,
262,
8373,
7386,
1262,
262,
376,
9792,
628,
198,
7061,
6,
198,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
2603,
29487,
8019,
13,
79,
2645,
397,
355,
458,
83,
198,
6738,
350,
4146,
1330,
7412,
198,
6738,
629,
541,
88,
13,
358,
9060,
13,
10379,
1010,
1330,
31986,
31562,
62,
24455,
198,
6738,
1341,
9060,
13,
35636,
1330,
23064,
198,
11748,
629,
541,
88,
13,
487,
83,
8002,
355,
277,
701,
198,
2,
6738,
1341,
9060,
13,
35636,
1330,
4173,
324,
261,
198,
198,
4299,
545,
961,
7,
34345,
11,
16694,
28349,
1000,
28,
17821,
2599,
198,
220,
220,
220,
37227,
8912,
281,
2939,
11,
1441,
355,
257,
399,
32152,
7177,
526,
15931,
198,
220,
220,
220,
611,
10536,
28349,
1000,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5560,
62,
320,
796,
7412,
13,
9654,
7,
34345,
737,
1102,
1851,
10786,
43,
11537,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5560,
62,
320,
796,
7412,
13,
9654,
7,
34345,
8,
198,
220,
220,
220,
1441,
45941,
13,
18747,
7,
79,
346,
62,
320,
8,
628,
198,
4299,
545,
12860,
7,
320,
11,
1960,
17500,
1000,
28,
25101,
11,
49903,
8899,
11639,
44605,
3256,
649,
5647,
28,
17821,
11,
3670,
28,
14202,
2599,
198,
220,
220,
220,
37227,
23114,
281,
2939,
11,
6225,
572,
1960,
17500,
4272,
357,
25252,
11777,
2672,
8,
198,
220,
220,
220,
220,
220,
220,
290,
39555,
341,
13,
628,
220,
220,
220,
220,
220,
220,
357,
16,
8,
807,
12,
2545,
10536,
28349,
1000,
4263,
290,
1987,
12,
2545,
25228,
389,
27464,
287,
657,
492,
13381,
13,
198,
220,
220,
220,
220,
220,
220,
357,
17,
8,
657,
12,
16,
13934,
4263,
389,
27464,
287,
657,
492,
16,
13,
198,
220,
220,
220,
220,
220,
220,
357,
18,
8,
48436,
4263,
389,
27464,
287,
657,
13,
15,
492,
16,
13,
15,
611,
511,
949,
3815,
389,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
290,
511,
3509,
3815,
19841,
352,
13,
15,
198,
220,
220,
220,
220,
220,
220,
357,
19,
8,
48436,
4263,
389,
27464,
287,
657,
13,
15,
492,
13381,
13,
15,
611,
511,
949,
3815,
389,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
290,
511,
3509,
3815,
389,
1875,
352,
290,
19841,
14280,
13,
15,
198,
220,
220,
220,
220,
220,
220,
357,
20,
8,
4377,
2939,
407,
5017,
416,
262,
2029,
2663,
318,
1960,
17500,
3021,
13,
220,
1002,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1960,
17500,
4272,
318,
11777,
9167,
11,
340,
318,
1464,
2900,
319,
13,
628,
220,
220,
220,
220,
220,
220,
317,
649,
3785,
318,
2727,
416,
4277,
13,
220,
366,
3605,
5647,
28,
25101,
1,
4962,
572,
428,
198,
220,
220,
220,
220,
220,
220,
9172,
13,
628,
220,
220,
220,
220,
220,
220,
4225,
16104,
341,
318,
1464,
572,
357,
25252,
262,
30203,
9911,
428,
737,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
649,
5647,
25,
198,
220,
220,
220,
220,
220,
220,
220,
611,
3670,
14512,
6045,
25,
2336,
796,
458,
83,
13,
26875,
7,
7839,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
2336,
796,
458,
83,
13,
26875,
3419,
198,
220,
220,
220,
611,
1960,
17500,
1000,
25,
198,
220,
220,
220,
220,
220,
220,
220,
458,
83,
13,
320,
12860,
7,
320,
11,
3849,
16104,
341,
11639,
710,
12423,
3256,
66,
8899,
28,
49903,
8899,
8,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
2100,
796,
545,
13,
9806,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
611,
545,
13,
67,
4906,
6624,
705,
28611,
23,
10354,
220,
220,
220,
220,
220,
220,
220,
22492,
807,
12,
2545,
10536,
28349,
1000,
393,
1987,
12,
2545,
25228,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
3509,
2100,
1875,
352,
25,
3509,
2100,
796,
14280,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
458,
83,
13,
320,
12860,
7,
320,
11,
3849,
16104,
341,
11639,
710,
12423,
3256,
85,
1084,
28,
15,
11,
85,
9806,
28,
9806,
2100,
11,
66,
8899,
28,
49903,
8899,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
545,
13,
67,
4906,
6624,
705,
22468,
2624,
6,
393,
545,
13,
67,
4906,
6624,
705,
22468,
2414,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
2100,
796,
545,
13,
1084,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
949,
2100,
18189,
657,
13,
15,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
3509,
2100,
19841,
352,
13,
15,
25,
220,
22492,
29403,
588,
657,
492,
16,
12178,
10536,
28349,
1000,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
2100,
11,
3509,
2100,
796,
657,
13,
15,
11,
352,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
3509,
2100,
19841,
14280,
13,
15,
25,
22492,
29403,
588,
257,
12178,
657,
11485,
14280,
2939,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
2100,
11,
3509,
2100,
796,
657,
13,
15,
11,
14280,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
458,
83,
13,
320,
12860,
7,
320,
11,
3849,
16104,
341,
11639,
710,
12423,
3256,
85,
1084,
28,
1084,
2100,
11,
85,
9806,
28,
9806,
2100,
11,
66,
8899,
28,
49903,
8899,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
458,
83,
13,
320,
12860,
7,
320,
11,
3849,
16104,
341,
11639,
710,
12423,
3256,
66,
8899,
28,
49903,
8899,
8,
198,
220,
220,
220,
458,
83,
13,
22704,
10786,
9060,
11537,
198,
220,
220,
220,
22492,
458,
83,
13,
22704,
10786,
2364,
11537,
198,
220,
220,
220,
458,
83,
13,
12860,
3419,
198,
220,
220,
220,
22492,
7783,
2336,
198,
198,
4299,
1382,
62,
1676,
73,
62,
487,
912,
7,
1676,
8457,
2599,
198,
220,
220,
220,
366,
15580,
352,
12,
67,
376,
9792,
82,
286,
281,
7177,
286,
19887,
11,
1123,
20128,
352,
5752,
11511,
262,
7177,
526,
628,
220,
220,
220,
1441,
277,
701,
13,
81,
487,
83,
7,
1676,
8457,
11,
16488,
28,
16,
8,
198,
198,
4299,
1382,
62,
1676,
73,
62,
361,
35594,
7,
1676,
8457,
2599,
198,
220,
220,
220,
366,
15580,
352,
12,
67,
1312,
5777,
33758,
286,
281,
7177,
286,
19887,
11,
1123,
20128,
352,
5752,
11511,
262,
7177,
526,
628,
220,
220,
220,
1441,
277,
701,
13,
343,
487,
83,
7,
1676,
8457,
11,
16488,
28,
16,
8,
198,
198,
4299,
1382,
62,
2543,
259,
21857,
7,
6335,
261,
51,
2599,
198,
220,
220,
220,
366,
8645,
378,
257,
300,
5669,
21857,
416,
2829,
736,
16302,
295,
1262,
262,
5325,
261,
26981,
286,
281,
2939,
11,
705,
6335,
261,
51,
30827,
198,
220,
220,
220,
300,
5669,
21857,
796,
45941,
13,
9107,
418,
19510,
6335,
261,
51,
13,
43358,
58,
16,
4357,
6335,
261,
51,
13,
43358,
58,
16,
60,
4008,
198,
220,
220,
220,
288,
464,
8326,
796,
11546,
13,
15,
1220,
2511,
261,
51,
13,
43358,
58,
15,
60,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
6335,
261,
51,
13,
43358,
58,
15,
60,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
20218,
796,
45941,
13,
40927,
7,
6335,
261,
51,
58,
72,
4357,
7,
6335,
261,
51,
13,
43358,
58,
16,
4357,
16,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
20218,
796,
23064,
7,
29510,
11,
288,
464,
8326,
9,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
300,
5669,
21857,
15853,
20218,
198,
220,
220,
220,
1441,
300,
5669,
21857,
198,
198,
4299,
10454,
62,
24455,
62,
487,
912,
7,
487,
912,
2599,
198,
220,
220,
220,
366,
49,
696,
8106,
257,
362,
12,
67,
7177,
286,
352,
12,
67,
376,
9792,
82,
357,
16,
12,
67,
376,
9792,
82,
1863,
262,
15274,
21387,
198,
220,
220,
220,
10454,
796,
45941,
13,
28300,
7,
37659,
13,
283,
858,
7,
15,
13,
20,
11,
277,
35594,
13,
43358,
58,
16,
60,
1003,
17,
1343,
657,
13,
16,
11,
657,
13,
20,
4008,
198,
220,
220,
220,
1441,
277,
35594,
1635,
10454,
198,
198,
4299,
2511,
261,
7,
9060,
11,
4831,
2599,
198,
220,
220,
220,
366,
15580,
262,
5325,
261,
26981,
1262,
705,
20214,
6,
19887,
286,
705,
9060,
447,
247,
526,
198,
220,
220,
220,
19887,
796,
17635,
220,
220,
220,
220,
220,
220,
220,
1303,
6366,
388,
5039,
19887,
287,
257,
1351,
13,
198,
220,
220,
220,
288,
464,
8326,
796,
532,
15259,
13,
15,
1220,
4831,
1303,
42375,
18703,
329,
5724,
602,
13,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
20214,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
19887,
13,
33295,
7,
10599,
378,
7,
9060,
11,
1312,
9,
67,
464,
8326,
737,
16345,
7,
22704,
28,
15,
4008,
198,
220,
220,
220,
1441,
45941,
13,
85,
25558,
7,
16302,
507,
8,
198,
198,
2,
13745,
10884,
21857,
7412,
198,
31369,
21857,
796,
545,
961,
10786,
31369,
21857,
13,
11134,
11537,
198,
320,
12860,
7,
31369,
21857,
11,
3670,
2625,
20556,
10884,
21857,
7412,
4943,
198,
198,
2,
5157,
16302,
295,
25056,
1231,
10454,
25431,
198,
31369,
21857,
62,
2543,
259,
21857,
796,
1382,
62,
2543,
259,
21857,
7,
31369,
21857,
8,
198,
320,
12860,
7,
31369,
21857,
62,
2543,
259,
21857,
11,
3670,
2625,
46200,
21857,
25056,
416,
736,
16302,
295,
4943,
198,
198,
2,
5157,
16302,
295,
25056,
351,
10454,
25431,
198,
198,
2,
27967,
281,
15541,
10454,
8106,
284,
262,
25056,
198,
198,
2,
220,
6674,
4174,
257,
10454,
8106,
351,
257,
45616,
379,
2063,
262,
3509,
1216,
86,
421,
1387,
198,
2,
887,
749,
1884,
645,
966,
198,
198,
2,
3497,
262,
376,
9792,
286,
262,
2939,
357,
37,
28707,
20021,
8,
198,
69,
280,
5277,
796,
1382,
62,
1676,
73,
62,
487,
912,
7,
31369,
21857,
8,
198,
198,
2,
25853,
262,
46287,
5277,
6121,
416,
262,
10454,
8106,
198,
81,
696,
62,
10379,
4400,
796,
10454,
62,
24455,
62,
487,
912,
7,
69,
280,
5277,
8,
198,
198,
2,
7214,
262,
34062,
376,
9792,
286,
262,
2939,
284,
10385,
340,
736,
284,
6093,
20021,
198,
259,
4399,
62,
69,
280,
5277,
62,
81,
696,
62,
10379,
4400,
796,
1382,
62,
1676,
73,
62,
361,
35594,
7,
81,
696,
62,
10379,
4400,
8,
198,
2,
320,
12860,
7,
361,
35594,
62,
16302,
295,
62,
31369,
21857,
11,
3670,
2625,
14402,
10454,
8106,
4943,
198,
2,
9288,
16,
796,
2511,
261,
7,
361,
35594,
62,
16302,
295,
62,
31369,
21857,
11,
11546,
8,
198,
2,
320,
12860,
7,
9288,
16,
11,
3670,
2625,
14402,
10454,
8106,
4943,
198,
198,
2,
10934,
262,
29083,
2939,
416,
279,
1891,
16302,
278,
262,
29083,
19887,
198,
10379,
4400,
62,
260,
1102,
2536,
1009,
796,
1382,
62,
2543,
259,
21857,
7,
259,
4399,
62,
69,
280,
5277,
62,
81,
696,
62,
10379,
4400,
8,
198,
320,
12860,
7,
10379,
4400,
62,
260,
1102,
2536,
1009,
11,
3670,
2625,
14402,
10454,
8106,
4943,
198
] | 2.775365 | 2,395 |
import argparse
import collections
import datetime
import json
import random
import re
import esprima
import requests
## Get the email and password
parser = argparse.ArgumentParser("messyger")
parser.add_argument("-u", "--email", required=True)
parser.add_argument("-p", "--password", required=True)
parser.add_argument("-m", "--message")
parser.add_argument("-r", "--recipient", type=int)
args = parser.parse_args()
## Parse the HTML response
html_resp = requests.get("https://www.messenger.com")
html_resp.raise_for_status()
html_page = html_resp.text
initial_request_id = re.search(
r'name="initial_request_id" value="([^"]+)"', html_page
).group(1)
lsd = re.search(r'name="lsd" value="([^"]+)"', html_page).group(1)
datr = re.search(r'"_js_datr","([^"]+)"', html_page).group(1)
## Make the login request
login = requests.post(
"https://www.messenger.com/login/password/",
cookies={"datr": datr},
data={
"lsd": lsd,
"initial_request_id": initial_request_id,
"email": args.email,
"pass": args.password,
},
allow_redirects=False,
)
assert login.status_code == 302
## Extract the inbox query parameters
inbox_html_resp = requests.get("https://www.messenger.com", cookies=login.cookies)
inbox_html_resp.raise_for_status()
inbox_html_page = inbox_html_resp.text
dtsg = re.search(r'"DTSGInitialData",\[\],\{"token":"([^"]+)"', inbox_html_page).group(
1
)
device_id = re.search(r'"deviceId":"([^"]+)"', inbox_html_page).group(1)
schema_version = re.search(r'"schemaVersion":"([0-9]+)"', inbox_html_page).group(1)
script_urls = re.findall(r'"([^"]+rsrc\.php/[^"]+\.js[^"]+)"', inbox_html_page)
scripts = []
for url in script_urls:
resp = requests.get(url)
resp.raise_for_status()
scripts.append(resp.text)
for script in scripts:
if "LSPlatformGraphQLLightspeedRequestQuery" not in script:
continue
doc_id = re.search(
r'id:"([0-9]+)",metadata:\{\},name:"LSPlatformGraphQLLightspeedRequestQuery"',
script,
).group(1)
break
if not args.message:
inbox_resp = requests.post(
"https://www.messenger.com/api/graphql/",
cookies=login.cookies,
data={
"fb_dtsg": dtsg,
"doc_id": doc_id,
"variables": json.dumps(
{
"deviceId": device_id,
"requestId": 0,
"requestPayload": json.dumps(
{
"database": 1,
"version": schema_version,
"sync_params": json.dumps({}),
}
),
"requestType": 1,
}
),
},
)
inbox_resp.raise_for_status()
## Parse the inbox data response
inbox_json = inbox_resp.json()
inbox_js = inbox_json["data"]["viewer"]["lightspeed_web_request"]["payload"]
ast = esprima.parseScript(inbox_js)
fn_calls = collections.defaultdict(list)
esprima.parseScript(inbox_js, delegate=handle_node)
conversations = collections.defaultdict(dict)
for args in fn_calls["deleteThenInsertThread"]:
last_sent_ts, last_read_ts, last_msg, *rest = args
user_id, last_msg_author = [
arg for arg in rest if isinstance(arg, int) and arg > 1e14
]
conversations[user_id]["unread"] = last_sent_ts != last_read_ts
conversations[user_id]["last_message"] = last_msg
conversations[user_id]["last_message_author"] = last_msg_author
for args in fn_calls["verifyContactRowExists"]:
user_id, _, _, name, *rest = args
conversations[user_id]["name"] = name
print(json.dumps(conversations, indent=2))
else:
## Replicate the send-message request
timestamp = int(datetime.datetime.now().timestamp() * 1000)
epoch = timestamp << 22
otid = epoch + random.randrange(2 ** 22)
send_message_resp = requests.post(
"https://www.messenger.com/api/graphql/",
cookies=login.cookies,
data={
"fb_dtsg": dtsg,
"doc_id": doc_id,
"variables": json.dumps(
{
"deviceId": device_id,
"requestId": 0,
"requestPayload": json.dumps(
{
"version_id": str(schema_version),
"tasks": [
{
"label": "46",
"payload": json.dumps(
{
"thread_id": args.recipient,
"otid": "6870463702739115830",
"source": 0,
"send_type": 1,
"text": args.message,
"initiating_source": 1,
}
),
"queue_name": str(args.recipient),
"task_id": 0,
"failure_count": None,
},
{
"label": "21",
"payload": json.dumps(
{
"thread_id": args.recipient,
"last_read_watermark_ts": timestamp,
"sync_group": 1,
}
),
"queue_name": str(args.recipient),
"task_id": 1,
"failure_count": None,
},
],
"epoch_id": 6870463702858032000,
}
),
"requestType": 3,
}
),
},
)
print(send_message_resp.text)
| [
11748,
1822,
29572,
198,
11748,
17268,
198,
11748,
4818,
8079,
198,
11748,
33918,
198,
11748,
4738,
198,
11748,
302,
198,
198,
11748,
1658,
1050,
8083,
198,
11748,
7007,
198,
198,
2235,
3497,
262,
3053,
290,
9206,
198,
198,
48610,
796,
1822,
29572,
13,
28100,
1713,
46677,
7203,
37348,
88,
1362,
4943,
198,
48610,
13,
2860,
62,
49140,
7203,
12,
84,
1600,
366,
438,
12888,
1600,
2672,
28,
17821,
8,
198,
48610,
13,
2860,
62,
49140,
7203,
12,
79,
1600,
366,
438,
28712,
1600,
2672,
28,
17821,
8,
198,
48610,
13,
2860,
62,
49140,
7203,
12,
76,
1600,
366,
438,
20500,
4943,
198,
48610,
13,
2860,
62,
49140,
7203,
12,
81,
1600,
366,
438,
8344,
48137,
1600,
2099,
28,
600,
8,
198,
22046,
796,
30751,
13,
29572,
62,
22046,
3419,
198,
198,
2235,
2547,
325,
262,
11532,
2882,
198,
198,
6494,
62,
4363,
796,
7007,
13,
1136,
7203,
5450,
1378,
2503,
13,
37348,
6540,
13,
785,
4943,
198,
6494,
62,
4363,
13,
40225,
62,
1640,
62,
13376,
3419,
198,
6494,
62,
7700,
796,
27711,
62,
4363,
13,
5239,
198,
198,
36733,
62,
25927,
62,
312,
796,
302,
13,
12947,
7,
198,
220,
220,
220,
374,
6,
3672,
2625,
36733,
62,
25927,
62,
312,
1,
1988,
2625,
26933,
61,
8973,
10,
16725,
3256,
27711,
62,
7700,
198,
737,
8094,
7,
16,
8,
198,
198,
7278,
67,
796,
302,
13,
12947,
7,
81,
6,
3672,
2625,
7278,
67,
1,
1988,
2625,
26933,
61,
8973,
10,
16725,
3256,
27711,
62,
7700,
737,
8094,
7,
16,
8,
198,
198,
19608,
81,
796,
302,
13,
12947,
7,
81,
29653,
62,
8457,
62,
19608,
81,
2430,
26933,
61,
8973,
10,
16725,
3256,
27711,
62,
7700,
737,
8094,
7,
16,
8,
198,
198,
2235,
6889,
262,
17594,
2581,
198,
198,
38235,
796,
7007,
13,
7353,
7,
198,
220,
220,
220,
366,
5450,
1378,
2503,
13,
37348,
6540,
13,
785,
14,
38235,
14,
28712,
14,
1600,
198,
220,
220,
220,
14746,
28,
4895,
19608,
81,
1298,
4818,
81,
5512,
198,
220,
220,
220,
1366,
34758,
198,
220,
220,
220,
220,
220,
220,
220,
366,
7278,
67,
1298,
300,
21282,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
36733,
62,
25927,
62,
312,
1298,
4238,
62,
25927,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
12888,
1298,
26498,
13,
12888,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
6603,
1298,
26498,
13,
28712,
11,
198,
220,
220,
220,
8964,
198,
220,
220,
220,
1249,
62,
445,
1060,
82,
28,
25101,
11,
198,
8,
198,
30493,
17594,
13,
13376,
62,
8189,
6624,
32591,
198,
198,
2235,
29677,
262,
13734,
12405,
10007,
198,
198,
259,
3524,
62,
6494,
62,
4363,
796,
7007,
13,
1136,
7203,
5450,
1378,
2503,
13,
37348,
6540,
13,
785,
1600,
14746,
28,
38235,
13,
27916,
444,
8,
198,
259,
3524,
62,
6494,
62,
4363,
13,
40225,
62,
1640,
62,
13376,
3419,
198,
259,
3524,
62,
6494,
62,
7700,
796,
13734,
62,
6494,
62,
4363,
13,
5239,
198,
198,
67,
912,
70,
796,
302,
13,
12947,
7,
81,
29653,
35,
4694,
38,
24243,
6601,
1600,
59,
58,
59,
4357,
59,
4895,
30001,
2404,
26933,
61,
8973,
10,
16725,
3256,
13734,
62,
6494,
62,
7700,
737,
8094,
7,
198,
220,
220,
220,
352,
198,
8,
198,
198,
25202,
62,
312,
796,
302,
13,
12947,
7,
81,
29653,
25202,
7390,
2404,
26933,
61,
8973,
10,
16725,
3256,
13734,
62,
6494,
62,
7700,
737,
8094,
7,
16,
8,
198,
198,
15952,
2611,
62,
9641,
796,
302,
13,
12947,
7,
81,
29653,
15952,
2611,
14815,
2404,
26933,
15,
12,
24,
48688,
16725,
3256,
13734,
62,
6494,
62,
7700,
737,
8094,
7,
16,
8,
198,
198,
12048,
62,
6371,
82,
796,
302,
13,
19796,
439,
7,
81,
6,
18109,
58,
61,
8973,
10,
3808,
6015,
17405,
10121,
14,
58,
61,
8973,
10,
17405,
8457,
58,
61,
8973,
10,
16725,
3256,
13734,
62,
6494,
62,
7700,
8,
198,
198,
46521,
796,
17635,
198,
1640,
19016,
287,
4226,
62,
6371,
82,
25,
198,
220,
220,
220,
1217,
796,
7007,
13,
1136,
7,
6371,
8,
198,
220,
220,
220,
1217,
13,
40225,
62,
1640,
62,
13376,
3419,
198,
220,
220,
220,
14750,
13,
33295,
7,
4363,
13,
5239,
8,
198,
198,
1640,
4226,
287,
14750,
25,
198,
220,
220,
220,
611,
366,
6561,
37148,
37065,
48,
3069,
2337,
39492,
18453,
20746,
1,
407,
287,
4226,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2555,
198,
220,
220,
220,
2205,
62,
312,
796,
302,
13,
12947,
7,
198,
220,
220,
220,
220,
220,
220,
220,
374,
6,
312,
11097,
26933,
15,
12,
24,
60,
28988,
1600,
38993,
7479,
31478,
5512,
3672,
11097,
6561,
37148,
37065,
48,
3069,
2337,
39492,
18453,
20746,
1,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
4226,
11,
198,
220,
220,
220,
6739,
8094,
7,
16,
8,
198,
220,
220,
220,
2270,
198,
198,
361,
407,
26498,
13,
20500,
25,
628,
220,
220,
220,
13734,
62,
4363,
796,
7007,
13,
7353,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
5450,
1378,
2503,
13,
37348,
6540,
13,
785,
14,
15042,
14,
34960,
13976,
14,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
14746,
28,
38235,
13,
27916,
444,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
34758,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
21855,
62,
67,
912,
70,
1298,
288,
912,
70,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15390,
62,
312,
1298,
2205,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25641,
2977,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25202,
7390,
1298,
3335,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
7390,
1298,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
19197,
2220,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
48806,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
9641,
1298,
32815,
62,
9641,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
27261,
62,
37266,
1298,
33918,
13,
67,
8142,
15090,
92,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
6030,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
8964,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
13734,
62,
4363,
13,
40225,
62,
1640,
62,
13376,
3419,
628,
220,
220,
220,
22492,
2547,
325,
262,
13734,
1366,
2882,
628,
220,
220,
220,
13734,
62,
17752,
796,
13734,
62,
4363,
13,
17752,
3419,
198,
220,
220,
220,
13734,
62,
8457,
796,
13734,
62,
17752,
14692,
7890,
1,
7131,
1,
1177,
263,
1,
7131,
1,
8091,
39492,
62,
12384,
62,
25927,
1,
7131,
1,
15577,
2220,
8973,
628,
220,
220,
220,
6468,
796,
1658,
1050,
8083,
13,
29572,
7391,
7,
259,
3524,
62,
8457,
8,
628,
220,
220,
220,
24714,
62,
66,
5691,
796,
17268,
13,
12286,
11600,
7,
4868,
8,
628,
220,
220,
220,
1658,
1050,
8083,
13,
29572,
7391,
7,
259,
3524,
62,
8457,
11,
23191,
28,
28144,
62,
17440,
8,
628,
220,
220,
220,
10275,
796,
17268,
13,
12286,
11600,
7,
11600,
8,
628,
220,
220,
220,
329,
26498,
287,
24714,
62,
66,
5691,
14692,
33678,
6423,
44402,
16818,
1,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
938,
62,
34086,
62,
912,
11,
938,
62,
961,
62,
912,
11,
938,
62,
19662,
11,
1635,
2118,
796,
26498,
198,
220,
220,
220,
220,
220,
220,
220,
2836,
62,
312,
11,
938,
62,
19662,
62,
9800,
796,
685,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1822,
329,
1822,
287,
1334,
611,
318,
39098,
7,
853,
11,
493,
8,
290,
1822,
1875,
352,
68,
1415,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
220,
220,
220,
220,
10275,
58,
7220,
62,
312,
7131,
1,
403,
961,
8973,
796,
938,
62,
34086,
62,
912,
14512,
938,
62,
961,
62,
912,
198,
220,
220,
220,
220,
220,
220,
220,
10275,
58,
7220,
62,
312,
7131,
1,
12957,
62,
20500,
8973,
796,
938,
62,
19662,
198,
220,
220,
220,
220,
220,
220,
220,
10275,
58,
7220,
62,
312,
7131,
1,
12957,
62,
20500,
62,
9800,
8973,
796,
938,
62,
19662,
62,
9800,
628,
220,
220,
220,
329,
26498,
287,
24714,
62,
66,
5691,
14692,
332,
1958,
17829,
25166,
3109,
1023,
1,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
2836,
62,
312,
11,
4808,
11,
4808,
11,
1438,
11,
1635,
2118,
796,
26498,
198,
220,
220,
220,
220,
220,
220,
220,
10275,
58,
7220,
62,
312,
7131,
1,
3672,
8973,
796,
1438,
628,
220,
220,
220,
3601,
7,
17752,
13,
67,
8142,
7,
1102,
690,
602,
11,
33793,
28,
17,
4008,
198,
198,
17772,
25,
628,
220,
220,
220,
22492,
18407,
5344,
262,
3758,
12,
20500,
2581,
628,
220,
220,
220,
41033,
796,
493,
7,
19608,
8079,
13,
19608,
8079,
13,
2197,
22446,
16514,
27823,
3419,
1635,
8576,
8,
198,
220,
220,
220,
36835,
796,
41033,
9959,
2534,
198,
220,
220,
220,
30972,
312,
796,
36835,
1343,
4738,
13,
25192,
9521,
7,
17,
12429,
2534,
8,
628,
220,
220,
220,
3758,
62,
20500,
62,
4363,
796,
7007,
13,
7353,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
5450,
1378,
2503,
13,
37348,
6540,
13,
785,
14,
15042,
14,
34960,
13976,
14,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
14746,
28,
38235,
13,
27916,
444,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
34758,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
21855,
62,
67,
912,
70,
1298,
288,
912,
70,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15390,
62,
312,
1298,
2205,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25641,
2977,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25202,
7390,
1298,
3335,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
7390,
1298,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
19197,
2220,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
9641,
62,
312,
1298,
965,
7,
15952,
2611,
62,
9641,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
83,
6791,
1298,
685,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
18242,
1298,
366,
3510,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15577,
2220,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
16663,
62,
312,
1298,
26498,
13,
8344,
48137,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
313,
312,
1298,
366,
3104,
2154,
3510,
20167,
1983,
2670,
1157,
3365,
1270,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
10459,
1298,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
21280,
62,
4906,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
5239,
1298,
26498,
13,
20500,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
259,
8846,
803,
62,
10459,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
36560,
62,
3672,
1298,
965,
7,
22046,
13,
8344,
48137,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
35943,
62,
312,
1298,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
32165,
495,
62,
9127,
1298,
6045,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8964,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
18242,
1298,
366,
2481,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15577,
2220,
1298,
33918,
13,
67,
8142,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
16663,
62,
312,
1298,
26498,
13,
8344,
48137,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
12957,
62,
961,
62,
7050,
4102,
62,
912,
1298,
41033,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
27261,
62,
8094,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
36560,
62,
3672,
1298,
965,
7,
22046,
13,
8344,
48137,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
35943,
62,
312,
1298,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
32165,
495,
62,
9127,
1298,
6045,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8964,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16589,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
538,
5374,
62,
312,
1298,
8257,
2154,
3510,
20167,
26279,
1795,
2624,
830,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
25927,
6030,
1298,
513,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
8964,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
3601,
7,
21280,
62,
20500,
62,
4363,
13,
5239,
8,
198
] | 1.758159 | 3,585 |
import os
import re
with open('PKGBUILD') as fp:
for line in fp.readlines():
line = line.strip()
current_build_number = re.search(r"^_pkgbuildnumber=(.+)$", line)
if current_build_number is None:
continue
current_build_number = current_build_number.group(1)
break
else:
raise ValueError("_pkgbuildnumber not found")
latest_version = os.environ['INPUT_VERSION']
latest_build_number = os.environ['INPUT_BUILD_NUMBER']
latest_hash_x86_64 = os.environ['INPUT_SHA256_x86_64']
print(f'Current build number: {current_build_number}')
print(f'Latest build number: {latest_build_number}')
print(f'Latest version: {latest_version}')
print(f'{latest_version}+{latest_build_number} x86_64 SHA256: {latest_hash_x86_64}')
if latest_build_number.isdigit() is False:
print('Latest build number is invalid')
exit(1)
if ' ' in latest_version or '-' in latest_version:
print('Latest version is invalid')
exit(1)
with open('PKGBUILD') as fp:
contents = fp.read()
if current_build_number != latest_build_number:
contents = re.sub(r"^pkgrel=.+$", 'pkgrel=1', contents, flags=re.MULTILINE)
contents = re.sub(r"^_pkgbuildnumber=.+$", f'_pkgbuildnumber={latest_build_number}', contents, flags=re.MULTILINE)
contents = re.sub(r"^_pkgversion=.+$", f'_pkgversion={latest_version}', contents, flags=re.MULTILINE)
contents = re.sub(r"(sha256sums_x86_64=\(\n ').+'\n", f"\g<1>{latest_hash_x86_64}'\n", contents)
with open('PKGBUILD', 'w') as fp:
fp.write(contents)
| [
11748,
28686,
198,
11748,
302,
628,
198,
4480,
1280,
10786,
40492,
4579,
52,
26761,
11537,
355,
277,
79,
25,
198,
220,
220,
220,
329,
1627,
287,
277,
79,
13,
961,
6615,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
1627,
796,
1627,
13,
36311,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1459,
62,
11249,
62,
17618,
796,
302,
13,
12947,
7,
81,
1,
61,
62,
35339,
11249,
17618,
16193,
13,
28988,
3,
1600,
1627,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1459,
62,
11249,
62,
17618,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
1459,
62,
11249,
62,
17618,
796,
1459,
62,
11249,
62,
17618,
13,
8094,
7,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7203,
62,
35339,
11249,
17618,
407,
1043,
4943,
198,
198,
42861,
62,
9641,
796,
28686,
13,
268,
2268,
17816,
1268,
30076,
62,
43717,
20520,
198,
42861,
62,
11249,
62,
17618,
796,
28686,
13,
268,
2268,
17816,
1268,
30076,
62,
19499,
26761,
62,
41359,
13246,
20520,
198,
42861,
62,
17831,
62,
87,
4521,
62,
2414,
796,
28686,
13,
268,
2268,
17816,
1268,
30076,
62,
37596,
11645,
62,
87,
4521,
62,
2414,
20520,
198,
198,
4798,
7,
69,
6,
11297,
1382,
1271,
25,
1391,
14421,
62,
11249,
62,
17618,
92,
11537,
198,
4798,
7,
69,
6,
39478,
1382,
1271,
25,
1391,
42861,
62,
11249,
62,
17618,
92,
11537,
198,
4798,
7,
69,
6,
39478,
2196,
25,
1391,
42861,
62,
9641,
92,
11537,
198,
4798,
7,
69,
6,
90,
42861,
62,
9641,
92,
10,
90,
42861,
62,
11249,
62,
17618,
92,
2124,
4521,
62,
2414,
25630,
11645,
25,
1391,
42861,
62,
17831,
62,
87,
4521,
62,
2414,
92,
11537,
198,
198,
361,
3452,
62,
11249,
62,
17618,
13,
9409,
328,
270,
3419,
318,
10352,
25,
198,
220,
220,
220,
3601,
10786,
39478,
1382,
1271,
318,
12515,
11537,
198,
220,
220,
220,
8420,
7,
16,
8,
198,
198,
361,
705,
705,
287,
3452,
62,
9641,
393,
705,
19355,
287,
3452,
62,
9641,
25,
198,
220,
220,
220,
3601,
10786,
39478,
2196,
318,
12515,
11537,
198,
220,
220,
220,
8420,
7,
16,
8,
198,
198,
4480,
1280,
10786,
40492,
4579,
52,
26761,
11537,
355,
277,
79,
25,
198,
220,
220,
220,
10154,
796,
277,
79,
13,
961,
3419,
198,
198,
361,
1459,
62,
11249,
62,
17618,
14512,
3452,
62,
11249,
62,
17618,
25,
198,
220,
220,
220,
10154,
796,
302,
13,
7266,
7,
81,
1,
61,
35339,
2411,
28,
13,
10,
3,
1600,
705,
35339,
2411,
28,
16,
3256,
10154,
11,
9701,
28,
260,
13,
44,
16724,
4146,
8881,
8,
198,
198,
3642,
658,
796,
302,
13,
7266,
7,
81,
1,
61,
62,
35339,
11249,
17618,
28,
13,
10,
3,
1600,
277,
6,
62,
35339,
11249,
17618,
34758,
42861,
62,
11249,
62,
17618,
92,
3256,
10154,
11,
9701,
28,
260,
13,
44,
16724,
4146,
8881,
8,
198,
3642,
658,
796,
302,
13,
7266,
7,
81,
1,
61,
62,
35339,
9641,
28,
13,
10,
3,
1600,
277,
6,
62,
35339,
9641,
34758,
42861,
62,
9641,
92,
3256,
10154,
11,
9701,
28,
260,
13,
44,
16724,
4146,
8881,
8,
198,
3642,
658,
796,
302,
13,
7266,
7,
81,
18109,
26270,
11645,
82,
5700,
62,
87,
4521,
62,
2414,
28,
59,
38016,
77,
220,
705,
737,
10,
6,
59,
77,
1600,
277,
1,
59,
70,
27,
16,
29,
90,
42861,
62,
17831,
62,
87,
4521,
62,
2414,
92,
6,
59,
77,
1600,
10154,
8,
198,
198,
4480,
1280,
10786,
40492,
4579,
52,
26761,
3256,
705,
86,
11537,
355,
277,
79,
25,
198,
220,
220,
220,
277,
79,
13,
13564,
7,
3642,
658,
8,
198
] | 2.429022 | 634 |
import pytest
import numpy as np
from functools import reduce
from hottbox.core.structures import Tensor,TensorCPD, TensorTKD, TensorTT
from hottbox.utils.validation.checks import is_super_symmetric
from ..basic import dense_tensor, sparse_tensor, super_diagonal_tensor, \
super_diag_tensor, super_symmetric_tensor, residual_tensor
def test_super_diag_tensor():
""" Tests for creating super-diagonal tensor"""
order = 3
rank = 2
correct_shape = (rank, ) * order
true_default_data = np.array([[[1., 0.],
[0., 0.]],
[[0., 0.],
[0., 1.]]])
true_default_mode_names = ['mode-0', 'mode-1', 'mode-2']
correct_values = np.arange(rank)
true_data = np.array([[[0., 0.],
[0., 0.]],
[[0., 0.],
[0., 1.]]])
# ------ tests for default super diagonal tensor
tensor = super_diag_tensor(correct_shape)
assert isinstance(tensor, Tensor)
np.testing.assert_array_equal(tensor.data, true_default_data)
assert (tensor.mode_names == true_default_mode_names)
# ------ tests for super diagonal tensor with custom values on the main diagonal
tensor = super_diag_tensor(correct_shape, values=correct_values)
assert isinstance(tensor, Tensor)
np.testing.assert_array_equal(tensor.data, true_data)
assert (tensor.mode_names == true_default_mode_names)
# ------ tests that should Fail
with pytest.raises(TypeError):
# shape should be passed as tuple
super_diag_tensor(shape=list(correct_shape))
with pytest.raises(ValueError):
# all values in shape should be the same
incorrect_shape = [rank] * order
incorrect_shape[1] = order+1
super_diag_tensor(shape=tuple(incorrect_shape))
with pytest.raises(ValueError):
# values should be an one dimensional numpy array
incorrect_values = np.ones([rank, rank])
super_diag_tensor(shape=correct_shape, values=incorrect_values)
with pytest.raises(ValueError):
# too many values for the specified shape
incorrect_values = np.ones(correct_shape[0]+1)
super_diag_tensor(shape=correct_shape, values=incorrect_values)
with pytest.raises(TypeError):
# values should be a numpy array
incorrect_values = [1] * correct_shape[0]
super_diag_tensor(shape=correct_shape, values=incorrect_values)
def test_residual_tensor():
""" Tests for computing/creating a residual tensor """
true_default_mode_names = ['mode-0', 'mode-1', 'mode-2']
# ------ tests for residual tensor with the Tensor
array_3d = np.array([[[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
true_residual_data = np.zeros(array_3d.shape)
tensor_1 = Tensor(array=array_3d)
tensor_2 = Tensor(array=array_3d)
residual = residual_tensor(tensor_orig=tensor_1, tensor_approx=tensor_2)
assert isinstance(residual, Tensor)
assert (residual.mode_names == true_default_mode_names)
np.testing.assert_array_equal(residual.data, true_residual_data)
# ------ tests for residual tensor with the TensorCPD
array_3d = np.array([[[100., 250., 400., 550.],
[250., 650., 1050., 1450.],
[400., 1050., 1700., 2350.]],
[[250., 650., 1050., 1450.],
[650., 1925., 3200., 4475.],
[1050., 3200., 5350., 7500.]]]
)
true_residual_data = np.zeros(array_3d.shape)
tensor = Tensor(array=array_3d)
ft_shape = (2, 3, 4) # define shape of the tensor in full form
R = 5 # define Kryskal rank of a tensor in CP form
core_values = np.ones(R)
fmat = [np.arange(orig_dim * R).reshape(orig_dim, R)
for orig_dim in ft_shape]
tensor_cpd = TensorCPD(fmat=fmat, core_values=core_values)
residual = residual_tensor(tensor_orig=tensor, tensor_approx=tensor_cpd)
assert isinstance(residual, Tensor)
assert (residual.mode_names == true_default_mode_names)
np.testing.assert_array_equal(residual.data, true_residual_data)
# ------ tests for residual tensor with the TensorTKD
array_3d = np.array([[[378, 1346, 2314, 3282, 4250],
[1368, 4856, 8344, 11832, 15320],
[2358, 8366, 14374, 20382, 26390],
[3348, 11876, 20404, 28932, 37460]],
[[1458, 5146, 8834, 12522, 16210],
[5112, 17944, 30776, 43608, 56440],
[8766, 30742, 52718, 74694, 96670],
[12420, 43540, 74660, 105780, 136900]],
[[2538, 8946, 15354, 21762, 28170],
[8856, 31032, 53208, 75384, 97560],
[15174, 53118, 91062, 129006, 166950],
[21492, 75204, 128916, 182628, 236340]]])
true_residual_data = np.zeros(array_3d.shape)
tensor = Tensor(array=array_3d)
ft_shape = (3, 4, 5) # define shape of the tensor in full form
ml_rank = (2, 3, 4) # define multi-linear rank of a tensor in Tucker form
core_size = reduce(lambda x, y: x * y, ml_rank)
core_values = np.arange(core_size).reshape(ml_rank)
fmat = [np.arange(ft_shape[mode] * ml_rank[mode]).reshape(ft_shape[mode],
ml_rank[mode]) for mode in range(len(ft_shape))]
tensor_tkd = TensorTKD(fmat=fmat, core_values=core_values)
residual = residual_tensor(tensor_orig=tensor, tensor_approx=tensor_tkd)
assert isinstance(residual, Tensor)
assert (residual.mode_names == true_default_mode_names)
np.testing.assert_array_equal(residual.data, true_residual_data)
# ------ tests for residual tensor with the TensorTT
array_3d = np.array([[[300, 348, 396, 444, 492, 540],
[354, 411, 468, 525, 582, 639],
[408, 474, 540, 606, 672, 738],
[462, 537, 612, 687, 762, 837],
[516, 600, 684, 768, 852, 936]],
[[960, 1110, 1260, 1410, 1560, 1710],
[1230, 1425, 1620, 1815, 2010, 2205],
[1500, 1740, 1980, 2220, 2460, 2700],
[1770, 2055, 2340, 2625, 2910, 3195],
[2040, 2370, 2700, 3030, 3360, 3690]],
[[1620, 1872, 2124, 2376, 2628, 2880],
[2106, 2439, 2772, 3105, 3438, 3771],
[2592, 3006, 3420, 3834, 4248, 4662],
[3078, 3573, 4068, 4563, 5058, 5553],
[3564, 4140, 4716, 5292, 5868, 6444]],
[[2280, 2634, 2988, 3342, 3696, 4050],
[2982, 3453, 3924, 4395, 4866, 5337],
[3684, 4272, 4860, 5448, 6036, 6624],
[4386, 5091, 5796, 6501, 7206, 7911],
[5088, 5910, 6732, 7554, 8376, 9198]]])
true_residual_data = np.zeros(array_3d.shape)
tensor = Tensor(array=array_3d)
r1, r2 = 2, 3
I, J, K = 4, 5, 6
core_1 = np.arange(I * r1).reshape(I, r1)
core_2 = np.arange(r1 * J * r2).reshape(r1, J, r2)
core_3 = np.arange(r2 * K).reshape(r2, K)
core_values = [core_1, core_2, core_3]
ft_shape = (I, J, K)
tensor_tt = TensorTT(core_values=core_values)
residual = residual_tensor(tensor_orig=tensor, tensor_approx=tensor_tt)
assert isinstance(residual, Tensor)
assert (residual.mode_names == true_default_mode_names)
np.testing.assert_array_equal(residual.data, true_residual_data)
# ------ tests that should FAIL for residual tensor due to wrong input type
array_3d = np.array([[[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
tensor_1 = Tensor(array=array_3d)
tensor_2 = array_3d
with pytest.raises(TypeError):
residual_tensor(tensor_orig=tensor_1, tensor_approx=tensor_2)
tensor_1 = array_3d
tensor_2 = Tensor(array=array_3d)
with pytest.raises(TypeError):
residual_tensor(tensor_orig=tensor_1, tensor_approx=tensor_2)
| [
11748,
12972,
9288,
198,
11748,
299,
32152,
355,
45941,
198,
6738,
1257,
310,
10141,
1330,
4646,
198,
6738,
289,
1252,
3524,
13,
7295,
13,
7249,
942,
1330,
309,
22854,
11,
51,
22854,
34,
5760,
11,
309,
22854,
51,
42,
35,
11,
309,
22854,
15751,
198,
6738,
289,
1252,
3524,
13,
26791,
13,
12102,
341,
13,
42116,
1330,
318,
62,
16668,
62,
1837,
3020,
19482,
198,
6738,
11485,
35487,
1330,
15715,
62,
83,
22854,
11,
29877,
62,
83,
22854,
11,
2208,
62,
10989,
27923,
62,
83,
22854,
11,
3467,
198,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
11,
2208,
62,
1837,
3020,
19482,
62,
83,
22854,
11,
29598,
62,
83,
22854,
628,
628,
198,
198,
4299,
1332,
62,
16668,
62,
10989,
363,
62,
83,
22854,
33529,
198,
220,
220,
220,
37227,
30307,
329,
4441,
2208,
12,
10989,
27923,
11192,
273,
37811,
198,
220,
220,
220,
1502,
796,
513,
198,
220,
220,
220,
4279,
796,
362,
198,
220,
220,
220,
3376,
62,
43358,
796,
357,
43027,
11,
1267,
1635,
1502,
198,
220,
220,
220,
2081,
62,
12286,
62,
7890,
796,
45941,
13,
18747,
26933,
30109,
16,
1539,
657,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
15,
1539,
657,
8183,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
15,
1539,
657,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
15,
1539,
352,
8183,
11907,
8,
198,
220,
220,
220,
2081,
62,
12286,
62,
14171,
62,
14933,
796,
37250,
14171,
12,
15,
3256,
705,
14171,
12,
16,
3256,
705,
14171,
12,
17,
20520,
198,
220,
220,
220,
3376,
62,
27160,
796,
45941,
13,
283,
858,
7,
43027,
8,
198,
220,
220,
220,
2081,
62,
7890,
796,
45941,
13,
18747,
26933,
30109,
15,
1539,
657,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
15,
1539,
657,
8183,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
15,
1539,
657,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
15,
1539,
352,
8183,
11907,
8,
628,
220,
220,
220,
1303,
40103,
5254,
329,
4277,
2208,
40039,
11192,
273,
198,
220,
220,
220,
11192,
273,
796,
2208,
62,
10989,
363,
62,
83,
22854,
7,
30283,
62,
43358,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
83,
22854,
11,
309,
22854,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
83,
22854,
13,
7890,
11,
2081,
62,
12286,
62,
7890,
8,
198,
220,
220,
220,
6818,
357,
83,
22854,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
628,
220,
220,
220,
1303,
40103,
5254,
329,
2208,
40039,
11192,
273,
351,
2183,
3815,
319,
262,
1388,
40039,
198,
220,
220,
220,
11192,
273,
796,
2208,
62,
10989,
363,
62,
83,
22854,
7,
30283,
62,
43358,
11,
3815,
28,
30283,
62,
27160,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
83,
22854,
11,
309,
22854,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
83,
22854,
13,
7890,
11,
2081,
62,
7890,
8,
198,
220,
220,
220,
6818,
357,
83,
22854,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
628,
220,
220,
220,
1303,
40103,
5254,
326,
815,
18448,
628,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
6030,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
5485,
815,
307,
3804,
355,
46545,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
7,
43358,
28,
4868,
7,
30283,
62,
43358,
4008,
628,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
11395,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
477,
3815,
287,
5485,
815,
307,
262,
976,
198,
220,
220,
220,
220,
220,
220,
220,
11491,
62,
43358,
796,
685,
43027,
60,
1635,
1502,
198,
220,
220,
220,
220,
220,
220,
220,
11491,
62,
43358,
58,
16,
60,
796,
1502,
10,
16,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
7,
43358,
28,
83,
29291,
7,
1939,
47315,
62,
43358,
4008,
628,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
11395,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
3815,
815,
307,
281,
530,
38517,
299,
32152,
7177,
198,
220,
220,
220,
220,
220,
220,
220,
11491,
62,
27160,
796,
45941,
13,
1952,
26933,
43027,
11,
4279,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
7,
43358,
28,
30283,
62,
43358,
11,
3815,
28,
1939,
47315,
62,
27160,
8,
628,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
11395,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1165,
867,
3815,
329,
262,
7368,
5485,
198,
220,
220,
220,
220,
220,
220,
220,
11491,
62,
27160,
796,
45941,
13,
1952,
7,
30283,
62,
43358,
58,
15,
48688,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
7,
43358,
28,
30283,
62,
43358,
11,
3815,
28,
1939,
47315,
62,
27160,
8,
628,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
6030,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
3815,
815,
307,
257,
299,
32152,
7177,
198,
220,
220,
220,
220,
220,
220,
220,
11491,
62,
27160,
796,
685,
16,
60,
1635,
3376,
62,
43358,
58,
15,
60,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
62,
10989,
363,
62,
83,
22854,
7,
43358,
28,
30283,
62,
43358,
11,
3815,
28,
1939,
47315,
62,
27160,
8,
628,
198,
198,
4299,
1332,
62,
411,
312,
723,
62,
83,
22854,
33529,
198,
220,
220,
220,
37227,
30307,
329,
14492,
14,
20123,
278,
257,
29598,
11192,
273,
37227,
198,
220,
220,
220,
2081,
62,
12286,
62,
14171,
62,
14933,
796,
37250,
14171,
12,
15,
3256,
705,
14171,
12,
16,
3256,
705,
14171,
12,
17,
20520,
628,
220,
220,
220,
1303,
40103,
5254,
329,
29598,
11192,
273,
351,
262,
309,
22854,
198,
220,
220,
220,
7177,
62,
18,
67,
796,
45941,
13,
18747,
26933,
30109,
15,
11,
220,
352,
11,
220,
362,
11,
220,
513,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
19,
11,
220,
642,
11,
220,
718,
11,
220,
767,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
23,
11,
220,
860,
11,
838,
11,
1367,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1065,
11,
1511,
11,
1478,
11,
1315,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1433,
11,
1596,
11,
1248,
11,
678,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1238,
11,
2310,
11,
2534,
11,
2242,
11907,
12962,
198,
220,
220,
220,
2081,
62,
411,
312,
723,
62,
7890,
796,
45941,
13,
9107,
418,
7,
18747,
62,
18,
67,
13,
43358,
8,
198,
220,
220,
220,
11192,
273,
62,
16,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
11192,
273,
62,
17,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
29598,
796,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
62,
16,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
17,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
411,
312,
723,
11,
309,
22854,
8,
198,
220,
220,
220,
6818,
357,
411,
312,
723,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
411,
312,
723,
13,
7890,
11,
2081,
62,
411,
312,
723,
62,
7890,
8,
628,
220,
220,
220,
1303,
40103,
5254,
329,
29598,
11192,
273,
351,
262,
309,
22854,
34,
5760,
198,
220,
220,
220,
7177,
62,
18,
67,
796,
45941,
13,
18747,
26933,
30109,
3064,
1539,
8646,
1539,
7337,
1539,
25240,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
9031,
1539,
22626,
1539,
47235,
1539,
1478,
1120,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
7029,
1539,
47235,
1539,
35665,
1539,
2242,
1120,
8183,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
9031,
1539,
22626,
1539,
47235,
1539,
1478,
1120,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
17544,
1539,
36864,
1539,
513,
2167,
1539,
5846,
2425,
13,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
940,
1120,
1539,
513,
2167,
1539,
7192,
1120,
1539,
767,
4059,
8183,
11907,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
2081,
62,
411,
312,
723,
62,
7890,
796,
45941,
13,
9107,
418,
7,
18747,
62,
18,
67,
13,
43358,
8,
198,
220,
220,
220,
11192,
273,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
10117,
62,
43358,
796,
357,
17,
11,
513,
11,
604,
8,
220,
220,
220,
1303,
8160,
5485,
286,
262,
11192,
273,
287,
1336,
1296,
198,
220,
220,
220,
371,
796,
642,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
8160,
41662,
8135,
282,
4279,
286,
257,
11192,
273,
287,
16932,
1296,
198,
220,
220,
220,
4755,
62,
27160,
796,
45941,
13,
1952,
7,
49,
8,
198,
220,
220,
220,
277,
6759,
796,
685,
37659,
13,
283,
858,
7,
11612,
62,
27740,
1635,
371,
737,
3447,
1758,
7,
11612,
62,
27740,
11,
371,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
1796,
62,
27740,
287,
10117,
62,
43358,
60,
198,
220,
220,
220,
11192,
273,
62,
13155,
67,
796,
309,
22854,
34,
5760,
7,
69,
6759,
28,
69,
6759,
11,
4755,
62,
27160,
28,
7295,
62,
27160,
8,
198,
220,
220,
220,
29598,
796,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
13155,
67,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
411,
312,
723,
11,
309,
22854,
8,
198,
220,
220,
220,
6818,
357,
411,
312,
723,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
411,
312,
723,
13,
7890,
11,
2081,
62,
411,
312,
723,
62,
7890,
8,
628,
220,
220,
220,
1303,
40103,
5254,
329,
29598,
11192,
273,
351,
262,
309,
22854,
51,
42,
35,
198,
220,
220,
220,
7177,
62,
18,
67,
796,
45941,
13,
18747,
26933,
30109,
30695,
11,
220,
220,
1511,
3510,
11,
220,
220,
2242,
1415,
11,
220,
220,
513,
32568,
11,
220,
220,
5433,
1120,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1485,
3104,
11,
220,
220,
4764,
3980,
11,
220,
220,
9698,
2598,
11,
220,
19035,
2624,
11,
220,
1315,
19504,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1954,
3365,
11,
220,
220,
807,
32459,
11,
220,
1478,
31020,
11,
220,
1160,
36243,
11,
220,
2608,
25964,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2091,
2780,
11,
220,
19035,
4304,
11,
220,
1160,
26429,
11,
220,
38902,
2624,
11,
220,
49020,
1899,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1415,
3365,
11,
220,
220,
642,
20964,
11,
220,
220,
9193,
2682,
11,
220,
13151,
1828,
11,
220,
1467,
21536,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
4349,
1065,
11,
220,
27228,
2598,
11,
220,
1542,
39509,
11,
220,
5946,
28688,
11,
220,
642,
2414,
1821,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
5774,
2791,
11,
220,
38369,
3682,
11,
220,
642,
1983,
1507,
11,
220,
8915,
45214,
11,
220,
860,
2791,
2154,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
17464,
1238,
11,
220,
42671,
1821,
11,
220,
767,
3510,
1899,
11,
838,
3553,
1795,
11,
1511,
3388,
405,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1495,
2548,
11,
220,
220,
9919,
3510,
11,
220,
1315,
32182,
11,
220,
24894,
5237,
11,
220,
2579,
17279,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
3459,
3980,
11,
220,
28947,
2624,
11,
220,
7192,
21315,
11,
220,
5441,
22842,
11,
220,
860,
2425,
1899,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1314,
22985,
11,
220,
7192,
16817,
11,
220,
860,
940,
5237,
11,
1105,
12865,
21,
11,
1467,
3388,
1120,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
22291,
5892,
11,
220,
5441,
18638,
11,
1105,
4531,
1433,
11,
1248,
2075,
2078,
11,
2242,
5066,
1821,
11907,
12962,
198,
220,
220,
220,
2081,
62,
411,
312,
723,
62,
7890,
796,
45941,
13,
9107,
418,
7,
18747,
62,
18,
67,
13,
43358,
8,
198,
220,
220,
220,
11192,
273,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
10117,
62,
43358,
796,
357,
18,
11,
604,
11,
642,
8,
220,
220,
220,
1303,
8160,
5485,
286,
262,
11192,
273,
287,
1336,
1296,
198,
220,
220,
220,
25962,
62,
43027,
796,
357,
17,
11,
513,
11,
604,
8,
220,
220,
220,
220,
1303,
8160,
5021,
12,
29127,
4279,
286,
257,
11192,
273,
287,
25951,
1296,
198,
220,
220,
220,
4755,
62,
7857,
796,
4646,
7,
50033,
2124,
11,
331,
25,
2124,
1635,
331,
11,
25962,
62,
43027,
8,
198,
220,
220,
220,
4755,
62,
27160,
796,
45941,
13,
283,
858,
7,
7295,
62,
7857,
737,
3447,
1758,
7,
4029,
62,
43027,
8,
198,
220,
220,
220,
277,
6759,
796,
685,
37659,
13,
283,
858,
7,
701,
62,
43358,
58,
14171,
60,
1635,
25962,
62,
43027,
58,
14171,
35944,
3447,
1758,
7,
701,
62,
43358,
58,
14171,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
25962,
62,
43027,
58,
14171,
12962,
329,
4235,
287,
2837,
7,
11925,
7,
701,
62,
43358,
4008,
60,
198,
220,
220,
220,
11192,
273,
62,
30488,
67,
796,
309,
22854,
51,
42,
35,
7,
69,
6759,
28,
69,
6759,
11,
4755,
62,
27160,
28,
7295,
62,
27160,
8,
198,
220,
220,
220,
29598,
796,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
30488,
67,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
411,
312,
723,
11,
309,
22854,
8,
198,
220,
220,
220,
6818,
357,
411,
312,
723,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
411,
312,
723,
13,
7890,
11,
2081,
62,
411,
312,
723,
62,
7890,
8,
628,
220,
220,
220,
1303,
40103,
5254,
329,
29598,
11192,
273,
351,
262,
309,
22854,
15751,
198,
220,
220,
220,
7177,
62,
18,
67,
796,
45941,
13,
18747,
26933,
30109,
6200,
11,
44084,
11,
48758,
11,
45095,
11,
5125,
17,
11,
38190,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
32182,
11,
43184,
11,
604,
3104,
11,
45719,
11,
642,
6469,
11,
718,
2670,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
26200,
11,
604,
4524,
11,
38190,
11,
3126,
21,
11,
718,
4761,
11,
767,
2548,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
39997,
11,
642,
2718,
11,
718,
1065,
11,
718,
5774,
11,
767,
5237,
11,
807,
2718,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
47493,
11,
10053,
11,
718,
5705,
11,
46720,
11,
807,
4309,
11,
860,
2623,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
39277,
11,
1367,
940,
11,
1105,
1899,
11,
1478,
940,
11,
1315,
1899,
11,
1596,
940,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1065,
1270,
11,
1478,
1495,
11,
1467,
1238,
11,
1248,
1314,
11,
3050,
11,
15629,
20,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
33698,
11,
1596,
1821,
11,
7169,
11,
2534,
1238,
11,
1987,
1899,
11,
2681,
405,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1558,
2154,
11,
1160,
2816,
11,
2242,
1821,
11,
2608,
1495,
11,
2808,
940,
11,
513,
22186,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1238,
1821,
11,
2242,
2154,
11,
2681,
405,
11,
1542,
1270,
11,
4747,
1899,
11,
513,
35844,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1433,
1238,
11,
1248,
4761,
11,
362,
17464,
11,
2242,
4304,
11,
2608,
2078,
11,
2579,
1795,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
17,
15801,
11,
1987,
2670,
11,
2681,
4761,
11,
513,
13348,
11,
4974,
2548,
11,
42163,
16,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1495,
5892,
11,
5867,
21,
11,
4974,
1238,
11,
4353,
2682,
11,
604,
23045,
11,
604,
39380,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1270,
3695,
11,
3439,
4790,
11,
2319,
3104,
11,
604,
46572,
11,
2026,
3365,
11,
44717,
18,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2327,
2414,
11,
604,
15187,
11,
6298,
1433,
11,
642,
32759,
11,
7618,
3104,
11,
718,
30272,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1828,
1795,
11,
2608,
2682,
11,
2808,
3459,
11,
513,
31575,
11,
513,
38205,
11,
2319,
1120,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1959,
6469,
11,
513,
36625,
11,
5014,
1731,
11,
604,
31010,
11,
4764,
2791,
11,
642,
31496,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2623,
5705,
11,
604,
29807,
11,
4764,
1899,
11,
642,
31115,
11,
3126,
2623,
11,
7930,
1731,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
19,
21734,
11,
2026,
6420,
11,
642,
41060,
11,
6135,
486,
11,
767,
22136,
11,
9225,
1157,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1120,
3459,
11,
7863,
940,
11,
8275,
2624,
11,
767,
44218,
11,
807,
32128,
11,
860,
22337,
11907,
12962,
198,
220,
220,
220,
2081,
62,
411,
312,
723,
62,
7890,
796,
45941,
13,
9107,
418,
7,
18747,
62,
18,
67,
13,
43358,
8,
198,
220,
220,
220,
11192,
273,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
374,
16,
11,
374,
17,
796,
362,
11,
513,
198,
220,
220,
220,
314,
11,
449,
11,
509,
796,
604,
11,
642,
11,
718,
198,
220,
220,
220,
4755,
62,
16,
796,
45941,
13,
283,
858,
7,
40,
1635,
374,
16,
737,
3447,
1758,
7,
40,
11,
374,
16,
8,
198,
220,
220,
220,
4755,
62,
17,
796,
45941,
13,
283,
858,
7,
81,
16,
1635,
449,
1635,
374,
17,
737,
3447,
1758,
7,
81,
16,
11,
449,
11,
374,
17,
8,
198,
220,
220,
220,
4755,
62,
18,
796,
45941,
13,
283,
858,
7,
81,
17,
1635,
509,
737,
3447,
1758,
7,
81,
17,
11,
509,
8,
198,
220,
220,
220,
4755,
62,
27160,
796,
685,
7295,
62,
16,
11,
4755,
62,
17,
11,
4755,
62,
18,
60,
198,
220,
220,
220,
10117,
62,
43358,
796,
357,
40,
11,
449,
11,
509,
8,
198,
220,
220,
220,
11192,
273,
62,
926,
796,
309,
22854,
15751,
7,
7295,
62,
27160,
28,
7295,
62,
27160,
8,
198,
220,
220,
220,
29598,
796,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
926,
8,
198,
220,
220,
220,
6818,
318,
39098,
7,
411,
312,
723,
11,
309,
22854,
8,
198,
220,
220,
220,
6818,
357,
411,
312,
723,
13,
14171,
62,
14933,
6624,
2081,
62,
12286,
62,
14171,
62,
14933,
8,
198,
220,
220,
220,
45941,
13,
33407,
13,
30493,
62,
18747,
62,
40496,
7,
411,
312,
723,
13,
7890,
11,
2081,
62,
411,
312,
723,
62,
7890,
8,
628,
220,
220,
220,
1303,
40103,
5254,
326,
815,
9677,
4146,
329,
29598,
11192,
273,
2233,
284,
2642,
5128,
2099,
198,
220,
220,
220,
7177,
62,
18,
67,
796,
45941,
13,
18747,
26933,
30109,
15,
11,
352,
11,
362,
11,
513,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
19,
11,
642,
11,
718,
11,
767,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
23,
11,
860,
11,
838,
11,
1367,
60,
4357,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16410,
1065,
11,
1511,
11,
1478,
11,
1315,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1433,
11,
1596,
11,
1248,
11,
678,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
1238,
11,
2310,
11,
2534,
11,
2242,
11907,
12962,
198,
220,
220,
220,
11192,
273,
62,
16,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
11192,
273,
62,
17,
796,
7177,
62,
18,
67,
198,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
6030,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
62,
16,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
17,
8,
628,
220,
220,
220,
11192,
273,
62,
16,
796,
7177,
62,
18,
67,
198,
220,
220,
220,
11192,
273,
62,
17,
796,
309,
22854,
7,
18747,
28,
18747,
62,
18,
67,
8,
198,
220,
220,
220,
351,
12972,
9288,
13,
430,
2696,
7,
6030,
12331,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
29598,
62,
83,
22854,
7,
83,
22854,
62,
11612,
28,
83,
22854,
62,
16,
11,
11192,
273,
62,
1324,
13907,
28,
83,
22854,
62,
17,
8,
198
] | 1.911174 | 4,582 |
"""Base classes for my data model."""
import decimal
from google.appengine.ext import ndb
from google.appengine.ext.ndb import polymodel
from appengine import history, rest, user
# From http://stackoverflow.com/questions/10035133/ndb-decimal-property
class DecimalProperty(ndb.IntegerProperty):
"""Decimal property ideal to store currency values, such as $20.34."""
# See https://developers.google.com/appengine/docs/python/ndb/subclassprop
class Base(polymodel.PolyModel):
"""Base for all objects."""
def to_dict(self):
"""Convert this object to a python dict."""
result = super(Base, self).to_dict()
result['id'] = self.key.id()
result['class'] = result['class_'][-1]
del result['class_']
# Should move this into detector mixin when I figure out how
if 'detector' in result:
del result['detector']
return result
@classmethod
def _put_async(self, **ctx_options):
"""Overrides _put_async and sends event to UI."""
classname = self._event_classname()
if classname is not None:
values = self.to_dict()
user.send_event(cls=classname, id=self.key.string_id(),
event='update', obj=values)
history.store_version(values)
return super(Base, self)._put_async(**ctx_options)
put_async = _put_async
@rest.command
def sync(self):
"""Called when fields on the object are updated
through the API."""
pass
| [
37811,
14881,
6097,
329,
616,
1366,
2746,
526,
15931,
198,
11748,
32465,
198,
198,
6738,
23645,
13,
1324,
18392,
13,
2302,
1330,
299,
9945,
198,
6738,
23645,
13,
1324,
18392,
13,
2302,
13,
358,
65,
1330,
7514,
19849,
198,
198,
6738,
598,
18392,
1330,
2106,
11,
1334,
11,
2836,
628,
198,
2,
3574,
2638,
1378,
25558,
2502,
11125,
13,
785,
14,
6138,
507,
14,
3064,
2327,
16945,
14,
358,
65,
12,
12501,
4402,
12,
26745,
198,
4871,
4280,
4402,
21746,
7,
358,
65,
13,
46541,
21746,
2599,
198,
220,
37227,
10707,
4402,
3119,
7306,
284,
3650,
7395,
3815,
11,
884,
355,
720,
1238,
13,
2682,
526,
15931,
198,
220,
1303,
4091,
3740,
1378,
16244,
364,
13,
13297,
13,
785,
14,
1324,
18392,
14,
31628,
14,
29412,
14,
358,
65,
14,
7266,
4871,
22930,
628,
198,
4871,
7308,
7,
35428,
19849,
13,
34220,
17633,
2599,
198,
220,
37227,
14881,
329,
477,
5563,
526,
15931,
628,
220,
825,
284,
62,
11600,
7,
944,
2599,
198,
220,
220,
220,
37227,
3103,
1851,
428,
2134,
284,
257,
21015,
8633,
526,
15931,
198,
220,
220,
220,
1255,
796,
2208,
7,
14881,
11,
2116,
737,
1462,
62,
11600,
3419,
198,
220,
220,
220,
1255,
17816,
312,
20520,
796,
2116,
13,
2539,
13,
312,
3419,
198,
220,
220,
220,
1255,
17816,
4871,
20520,
796,
1255,
17816,
4871,
62,
6,
7131,
12,
16,
60,
198,
220,
220,
220,
1619,
1255,
17816,
4871,
62,
20520,
628,
220,
220,
220,
1303,
10358,
1445,
428,
656,
31029,
5022,
259,
618,
314,
3785,
503,
703,
198,
220,
220,
220,
611,
705,
15255,
9250,
6,
287,
1255,
25,
198,
220,
220,
220,
220,
220,
1619,
1255,
17816,
15255,
9250,
20520,
198,
220,
220,
220,
1441,
1255,
628,
220,
2488,
4871,
24396,
628,
220,
825,
4808,
1996,
62,
292,
13361,
7,
944,
11,
12429,
49464,
62,
25811,
2599,
198,
220,
220,
220,
37227,
5886,
81,
1460,
4808,
1996,
62,
292,
13361,
290,
12800,
1785,
284,
12454,
526,
15931,
198,
220,
220,
220,
1398,
3672,
796,
2116,
13557,
15596,
62,
4871,
3672,
3419,
198,
220,
220,
220,
611,
1398,
3672,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
3815,
796,
2116,
13,
1462,
62,
11600,
3419,
198,
220,
220,
220,
220,
220,
2836,
13,
21280,
62,
15596,
7,
565,
82,
28,
4871,
3672,
11,
4686,
28,
944,
13,
2539,
13,
8841,
62,
312,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1785,
11639,
19119,
3256,
26181,
28,
27160,
8,
198,
220,
220,
220,
220,
220,
2106,
13,
8095,
62,
9641,
7,
27160,
8,
198,
220,
220,
220,
1441,
2208,
7,
14881,
11,
2116,
737,
62,
1996,
62,
292,
13361,
7,
1174,
49464,
62,
25811,
8,
198,
220,
1234,
62,
292,
13361,
796,
4808,
1996,
62,
292,
13361,
628,
220,
2488,
2118,
13,
21812,
628,
220,
825,
17510,
7,
944,
2599,
198,
220,
220,
220,
37227,
34,
4262,
618,
7032,
319,
262,
2134,
389,
6153,
198,
220,
220,
220,
220,
220,
220,
832,
262,
7824,
526,
15931,
198,
220,
220,
220,
1208,
198
] | 2.782101 | 514 |
#
# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
#
# This file is part of Power Sequencer.
#
# Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with Power Sequencer. If
# not, see <https://www.gnu.org/licenses/>.
#
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
class POWER_SEQUENCER_OT_scene_cycle(bpy.types.Operator):
"""
Cycle through scenes
"""
doc = {
"name": doc_name(__qualname__),
"demo": "https://i.imgur.com/7zhq8Tg.gif",
"description": doc_description(__doc__),
"shortcuts": [({"type": "TAB", "value": "PRESS", "shift": True}, {}, "Cycle Scenes")],
"keymap": "Sequencer",
}
bl_idname = doc_idname(__qualname__)
bl_label = doc["name"]
bl_description = doc_brief(doc["description"])
bl_options = {"REGISTER", "UNDO"}
@classmethod
| [
2,
198,
2,
15069,
357,
34,
8,
1584,
12,
42334,
416,
18106,
39911,
5549,
11,
7806,
440,
539,
88,
11,
38058,
10438,
5325,
377,
3798,
84,
11,
290,
20420,
198,
2,
198,
2,
770,
2393,
318,
636,
286,
4333,
24604,
12137,
13,
198,
2,
198,
2,
4333,
24604,
12137,
318,
1479,
3788,
25,
345,
460,
17678,
4163,
340,
290,
14,
273,
13096,
340,
739,
262,
2846,
286,
262,
198,
2,
22961,
3611,
5094,
13789,
355,
3199,
416,
262,
3232,
10442,
5693,
11,
2035,
2196,
513,
286,
262,
198,
2,
13789,
11,
393,
357,
265,
534,
3038,
8,
597,
1568,
2196,
13,
198,
2,
198,
2,
4333,
24604,
12137,
318,
9387,
287,
262,
2911,
326,
340,
481,
307,
4465,
11,
475,
42881,
15529,
34764,
56,
26,
198,
2,
1231,
772,
262,
17142,
18215,
286,
34482,
3398,
1565,
5603,
25382,
393,
376,
46144,
7473,
317,
16652,
2149,
37232,
33079,
48933,
13,
4091,
262,
198,
2,
22961,
3611,
5094,
13789,
329,
517,
3307,
13,
198,
2,
198,
2,
921,
815,
423,
2722,
257,
4866,
286,
262,
22961,
3611,
5094,
13789,
1863,
351,
4333,
24604,
12137,
13,
1002,
198,
2,
407,
11,
766,
1279,
5450,
1378,
2503,
13,
41791,
13,
2398,
14,
677,
4541,
15913,
13,
198,
2,
198,
11748,
275,
9078,
198,
198,
6738,
764,
26791,
13,
15390,
1330,
2205,
62,
3672,
11,
2205,
62,
312,
3672,
11,
2205,
62,
65,
3796,
11,
2205,
62,
11213,
628,
198,
4871,
40295,
62,
5188,
10917,
24181,
1137,
62,
2394,
62,
29734,
62,
13696,
7,
65,
9078,
13,
19199,
13,
18843,
1352,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
26993,
832,
8188,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
2205,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
366,
3672,
1298,
2205,
62,
3672,
7,
834,
13255,
3672,
834,
828,
198,
220,
220,
220,
220,
220,
220,
220,
366,
9536,
78,
1298,
366,
5450,
1378,
72,
13,
19791,
13,
785,
14,
22,
23548,
80,
23,
51,
70,
13,
27908,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
366,
11213,
1298,
2205,
62,
11213,
7,
834,
15390,
834,
828,
198,
220,
220,
220,
220,
220,
220,
220,
366,
19509,
23779,
1298,
47527,
4895,
4906,
1298,
366,
5603,
33,
1600,
366,
8367,
1298,
366,
32761,
1600,
366,
30846,
1298,
6407,
5512,
1391,
5512,
366,
20418,
2375,
49525,
4943,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
366,
2539,
8899,
1298,
366,
44015,
12137,
1600,
198,
220,
220,
220,
1782,
198,
220,
220,
220,
698,
62,
312,
3672,
796,
2205,
62,
312,
3672,
7,
834,
13255,
3672,
834,
8,
198,
220,
220,
220,
698,
62,
18242,
796,
2205,
14692,
3672,
8973,
198,
220,
220,
220,
698,
62,
11213,
796,
2205,
62,
65,
3796,
7,
15390,
14692,
11213,
8973,
8,
198,
220,
220,
220,
698,
62,
25811,
796,
19779,
31553,
41517,
1600,
366,
4944,
18227,
20662,
628,
220,
220,
220,
2488,
4871,
24396,
198
] | 2.94824 | 483 |
from sys import path as sys_path
from os import path as os_path
from subprocess import Popen, PIPE
import time
import logging
import warnings
import numpy as np
sys_path.append(os_path.abspath('../src'))
from config import RUNTIME_CONFIG
from config import john_nick_names, hc_nick_names
from common import PasswordPolicyConf, FilePath
from argparsing import setup_args, parse_args
from guess_count import GuessCount
from tokenstr import TokenString
from utility import read_passwords,read_wordlist,read_rulelist,get_look_cmd,build_trie_from_wordlist
from utility import filter_passwords_with_password_policy
from preprocess import precomputation
from invert_rule import invert_one_rule
from demo_common import match_inversion_result, search_exist_data, search_trie, estimate_guess_number
def start_processing():
""" Take in a wordlist, rulelist and test set, outputs the guessability and guess number of each pwd in the test set.
Steps:
1. read rulelist and do precomputation (detect invertibility)
2. read wordlist/pwlist, and get count for each rule
3. Rule Inversion (for each rule, invert all pwds)
"""
stime = time.perf_counter()
##################### Precomputation and Other Preparation #####################
# initialize a bash exe for communication
external_bash_process = Popen(['/bin/bash'], stdin=PIPE, stdout=PIPE)
# Logging Basic Info
logging.basicConfig(filename=RUNTIME_CONFIG.get_log_addr(),level=logging.DEBUG)
logging.info("Starting Time: {}\n\nConfigurations: {}\n".format(time.strftime("%Y-%m-%d %H:%M"), RUNTIME_CONFIG.short_config_string()))
logging.info("PasswordPolicy: {}\n".format(RUNTIME_CONFIG['password_policy'].to_debug_string()))
print("Reading Rulelist\n")
rulelist = read_rulelist(RUNTIME_CONFIG['rulelist_path']['name'], RUNTIME_CONFIG['rulelist_path']['prefix'])
print("Start Precomputation\n")
rulelist = precomputation(rulelist)
print("Reading Wordlist and Password Set\n")
wordlist = read_wordlist(RUNTIME_CONFIG['wordlist_path']['name'], RUNTIME_CONFIG['wordlist_path']['prefix'])
# Computing Guess Count
counts, cumsum = GuessCount.get_counts(wordlist, rulelist, RUNTIME_CONFIG['preprocess_path'])
# read other things
pwlist = read_passwords(RUNTIME_CONFIG['pwlist_path']['addr'])
# filter out pwds not consistent with the policy
not_filtered_pwds, filtered_pwds = filter_passwords_with_password_policy(pwlist)
trie = build_trie_from_wordlist(wordlist)
##################### Start Inversion #####################
print("Start Inverting Rules\n")
i_time = time.perf_counter()
# guessability of pwds
is_guessable = [False] * len(pwlist)
is_enable_regex = RUNTIME_CONFIG['enable_regex']
is_debug = RUNTIME_CONFIG['debug']
lookup_threshold = RUNTIME_CONFIG['lookup_threshold']
# tokenize pwds once.
tokenized_pwds = [TokenString(pwd) for pw_idx, pwd in not_filtered_pwds]
# invert rules (with special memory handling and other staff)
for r_idx, r in enumerate(rulelist):
if is_debug == True:
print(r.raw)
if r.feasibility.is_invertible(): # invertible, if blow up, use trie
for token_pwd, (pw_idx, pwd) in zip(tokenized_pwds,not_filtered_pwds):
result = invert_one_rule(token_pwd,r,is_enable_regex,r.feasibility.special_idx)
if result.is_normal():
if result.get_number_of_strings() <= lookup_threshold:
ret_vals = match_inversion_result(result, wordlist)
else:
ret_vals = search_trie(result, trie)
if len(ret_vals) != 0:
is_guessable[pw_idx] = True
for v in ret_vals:
logging.info("\nPasswordIdx:{}\nPassword:{}\nRule:{}\nWord:{}\nGuess:{} ( {} - {} )\n".format(pw_idx, pwd, r.raw, v, *estimate_guess_number(counts, cumsum, v, r_idx, wordlist)))
elif result.is_out_of_scope():
ret_vals = []
logging.info("Inversion error for {}(RL) {}(pw), error msg: {}\n".format(r.raw, pwd, "out_of_scope"))
print("Inversion error for {}(RL) {}(pw), error msg: {}".format(r.raw, pwd, "out_of_scope"))
else:
ret_vals = []
logging.info("Inversion error for {}(RL) {}(pw), error msg: {}\n".format(r.raw, pwd, result.error_msg))
print("Inversion error for {}(RL) {}(pw), error msg: {}".format(r.raw, pwd, result.error_msg))
elif r.feasibility.is_optimizable(): # uninvertible, if cannot handle, binary
# where the binary file is stored
enumerated_data_addr = "{}/enumerated/rule{}.txt".format(RUNTIME_CONFIG['preprocess_path'],r_idx)
for token_pwd, (pw_idx, pwd) in zip(tokenized_pwds,not_filtered_pwds):
result = invert_one_rule(token_pwd,r,is_enable_regex)
if result.is_normal():
if result.get_number_of_strings() <= lookup_threshold:
ret_vals = match_inversion_result(result, wordlist)
else:
ret_vals = search_exist_data(pwd,enumerated_data_addr,external_bash_process)
if len(ret_vals) != 0:
is_guessable[pw_idx] = True
for v in ret_vals:
logging.info("\nPasswordIdx:{}\nPassword:{}\nRule:{}\nWord:{}\nGuess:{} ( {} - {} )\n".format(pw_idx, pwd, r.raw, v, *estimate_guess_number(counts, cumsum, v, r_idx, wordlist)))
elif result.is_out_of_scope():
ret_vals = search_exist_data(pwd,enumerated_data_addr,external_bash_process)
if len(ret_vals) != 0:
is_guessable[pw_idx] = True
for v in ret_vals:
logging.info("\nPasswordIdx:{}\nPassword:{}\nRule:{}\nWord:{}\nGuess:{} ( {} - {} )\n".format(pw_idx, pwd, r.raw, v, *estimate_guess_number(counts, cumsum, v, r_idx, wordlist)))
else:
ret_vals = []
logging.info("Inversion error for {}(RL) {}(pw), error msg: {}\n".format(r.raw, pwd, result.error_msg))
print("Inversion error for {}(RL) {}(pw), error msg: {}".format(r.raw, pwd, result.error_msg))
else: # binary
# where the binary file is stored
enumerated_data_addr = "{}/enumerated/rule{}.txt".format(RUNTIME_CONFIG['preprocess_path'],r_idx)
for token_pwd, (pw_idx, pwd) in zip(tokenized_pwds,not_filtered_pwds):
ret_vals = search_exist_data(pwd,enumerated_data_addr,external_bash_process)
if len(ret_vals) != 0:
is_guessable[pw_idx] = True
for v in ret_vals:
logging.info("\nPasswordIdx:{}\nPassword:{}\nRule:{}\nWord:{}\nGuess:{} ( {} - {} )\n".format(pw_idx, pwd, r.raw, v, *estimate_guess_number(counts, cumsum, v, r_idx, wordlist)))
##################### End of Inversion #####################
# Write Not Guessable Data
for pw_idx, pwd in filtered_pwds:
logging.info("\nPasswordIdx:{}\nPassword:{}\nNot Guessable\n".format(pw_idx, pwd))
for is_guessed, (pw_idx, pwd) in zip(is_guessable, not_filtered_pwds):
if is_guessed == False:
logging.info("\nPasswordIdx:{}\nPassword:{}\nNot Guessable\n".format(pw_idx, pwd))
logging.info("Total guesses made by this configuration: {}\n".format(np.sum(counts)))
print("Finished Inverting Rules, Total Time: {}".format(time.perf_counter()-i_time))
if __name__ == "__main__":
main() | [
6738,
25064,
1330,
3108,
355,
25064,
62,
6978,
198,
6738,
28686,
1330,
3108,
355,
28686,
62,
6978,
198,
6738,
850,
14681,
1330,
8099,
268,
11,
350,
4061,
36,
198,
11748,
640,
198,
11748,
18931,
198,
11748,
14601,
198,
11748,
299,
32152,
355,
45941,
198,
198,
17597,
62,
6978,
13,
33295,
7,
418,
62,
6978,
13,
397,
2777,
776,
10786,
40720,
10677,
6,
4008,
198,
198,
6738,
4566,
1330,
32494,
34694,
62,
10943,
16254,
198,
6738,
4566,
1330,
45610,
62,
17172,
62,
14933,
11,
289,
66,
62,
17172,
62,
14933,
198,
6738,
2219,
1330,
30275,
36727,
18546,
11,
9220,
15235,
198,
6738,
1822,
79,
945,
278,
1330,
9058,
62,
22046,
11,
21136,
62,
22046,
198,
6738,
4724,
62,
9127,
1330,
37571,
12332,
198,
6738,
11241,
2536,
1330,
29130,
10100,
198,
6738,
10361,
1330,
1100,
62,
6603,
10879,
11,
961,
62,
4775,
4868,
11,
961,
62,
25135,
4868,
11,
1136,
62,
5460,
62,
28758,
11,
11249,
62,
83,
5034,
62,
6738,
62,
4775,
4868,
198,
6738,
10361,
1330,
8106,
62,
6603,
10879,
62,
4480,
62,
28712,
62,
30586,
198,
6738,
662,
14681,
1330,
662,
785,
1996,
341,
198,
6738,
287,
1851,
62,
25135,
1330,
287,
1851,
62,
505,
62,
25135,
198,
6738,
13605,
62,
11321,
1330,
2872,
62,
259,
9641,
62,
20274,
11,
2989,
62,
38476,
62,
7890,
11,
2989,
62,
83,
5034,
11,
8636,
62,
5162,
408,
62,
17618,
628,
198,
4299,
923,
62,
36948,
33529,
198,
220,
220,
220,
37227,
7214,
287,
257,
1573,
4868,
11,
3896,
4868,
290,
1332,
900,
11,
23862,
262,
4724,
1799,
290,
4724,
1271,
286,
1123,
279,
16993,
287,
262,
1332,
900,
13,
628,
220,
220,
220,
32144,
25,
198,
220,
220,
220,
220,
220,
220,
220,
352,
13,
1100,
3896,
4868,
290,
466,
662,
785,
1996,
341,
357,
15255,
478,
287,
1851,
2247,
8,
198,
220,
220,
220,
220,
220,
220,
220,
362,
13,
1100,
1573,
4868,
14,
79,
86,
4868,
11,
290,
651,
954,
329,
1123,
3896,
198,
220,
220,
220,
220,
220,
220,
220,
513,
13,
14330,
554,
9641,
357,
1640,
1123,
3896,
11,
287,
1851,
477,
279,
86,
9310,
8,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
336,
524,
796,
640,
13,
525,
69,
62,
24588,
3419,
628,
220,
220,
220,
1303,
14468,
4242,
3771,
785,
1996,
341,
290,
3819,
38397,
341,
1303,
14468,
4242,
198,
220,
220,
220,
1303,
41216,
257,
27334,
409,
68,
329,
6946,
198,
220,
220,
220,
7097,
62,
41757,
62,
14681,
796,
8099,
268,
7,
17816,
14,
8800,
14,
41757,
6,
4357,
14367,
259,
28,
47,
4061,
36,
11,
14367,
448,
28,
47,
4061,
36,
8,
628,
220,
220,
220,
1303,
5972,
2667,
14392,
14151,
198,
220,
220,
220,
18931,
13,
35487,
16934,
7,
34345,
28,
49,
4944,
34694,
62,
10943,
16254,
13,
1136,
62,
6404,
62,
29851,
22784,
5715,
28,
6404,
2667,
13,
30531,
8,
198,
220,
220,
220,
18931,
13,
10951,
7203,
22851,
3862,
25,
23884,
59,
77,
59,
77,
16934,
20074,
25,
23884,
59,
77,
1911,
18982,
7,
2435,
13,
2536,
31387,
7203,
4,
56,
12,
4,
76,
12,
4,
67,
4064,
39,
25,
4,
44,
12340,
32494,
34694,
62,
10943,
16254,
13,
19509,
62,
11250,
62,
8841,
3419,
4008,
198,
220,
220,
220,
18931,
13,
10951,
7203,
35215,
36727,
25,
23884,
59,
77,
1911,
18982,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
28712,
62,
30586,
6,
4083,
1462,
62,
24442,
62,
8841,
3419,
4008,
628,
220,
220,
220,
3601,
7203,
36120,
14330,
4868,
59,
77,
4943,
198,
220,
220,
220,
3896,
4868,
796,
1100,
62,
25135,
4868,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
25135,
4868,
62,
6978,
6,
7131,
6,
3672,
6,
4357,
32494,
34694,
62,
10943,
16254,
17816,
25135,
4868,
62,
6978,
6,
7131,
6,
40290,
6,
12962,
628,
220,
220,
220,
3601,
7203,
10434,
3771,
785,
1996,
341,
59,
77,
4943,
198,
220,
220,
220,
3896,
4868,
796,
662,
785,
1996,
341,
7,
25135,
4868,
8,
628,
220,
220,
220,
3601,
7203,
36120,
9678,
4868,
290,
30275,
5345,
59,
77,
4943,
198,
220,
220,
220,
1573,
4868,
796,
1100,
62,
4775,
4868,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
4775,
4868,
62,
6978,
6,
7131,
6,
3672,
6,
4357,
32494,
34694,
62,
10943,
16254,
17816,
4775,
4868,
62,
6978,
6,
7131,
6,
40290,
6,
12962,
628,
220,
220,
220,
1303,
38589,
37571,
2764,
198,
220,
220,
220,
9853,
11,
269,
5700,
388,
796,
37571,
12332,
13,
1136,
62,
9127,
82,
7,
4775,
4868,
11,
3896,
4868,
11,
32494,
34694,
62,
10943,
16254,
17816,
3866,
14681,
62,
6978,
6,
12962,
628,
220,
220,
220,
1303,
1100,
584,
1243,
198,
220,
220,
220,
279,
86,
4868,
796,
1100,
62,
6603,
10879,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
79,
86,
4868,
62,
6978,
6,
7131,
6,
29851,
6,
12962,
198,
220,
220,
220,
1303,
8106,
503,
279,
86,
9310,
407,
6414,
351,
262,
2450,
198,
220,
220,
220,
407,
62,
10379,
4400,
62,
79,
86,
9310,
11,
29083,
62,
79,
86,
9310,
796,
8106,
62,
6603,
10879,
62,
4480,
62,
28712,
62,
30586,
7,
79,
86,
4868,
8,
198,
220,
220,
220,
1333,
68,
796,
1382,
62,
83,
5034,
62,
6738,
62,
4775,
4868,
7,
4775,
4868,
8,
628,
220,
220,
220,
1303,
14468,
4242,
7253,
554,
9641,
1303,
14468,
4242,
198,
220,
220,
220,
3601,
7203,
10434,
554,
48820,
14252,
59,
77,
4943,
198,
220,
220,
220,
1312,
62,
2435,
796,
640,
13,
525,
69,
62,
24588,
3419,
198,
220,
220,
220,
1303,
4724,
1799,
286,
279,
86,
9310,
198,
220,
220,
220,
318,
62,
5162,
408,
540,
796,
685,
25101,
60,
1635,
18896,
7,
79,
86,
4868,
8,
198,
220,
220,
220,
318,
62,
21633,
62,
260,
25636,
796,
32494,
34694,
62,
10943,
16254,
17816,
21633,
62,
260,
25636,
20520,
198,
220,
220,
220,
318,
62,
24442,
796,
32494,
34694,
62,
10943,
16254,
17816,
24442,
20520,
198,
220,
220,
220,
35847,
62,
400,
10126,
796,
32494,
34694,
62,
10943,
16254,
17816,
5460,
929,
62,
400,
10126,
20520,
198,
220,
220,
220,
1303,
11241,
1096,
279,
86,
9310,
1752,
13,
198,
220,
220,
220,
11241,
1143,
62,
79,
86,
9310,
796,
685,
30642,
10100,
7,
79,
16993,
8,
329,
279,
86,
62,
312,
87,
11,
279,
16993,
287,
407,
62,
10379,
4400,
62,
79,
86,
9310,
60,
628,
220,
220,
220,
1303,
287,
1851,
3173,
357,
4480,
2041,
4088,
9041,
290,
584,
3085,
8,
198,
220,
220,
220,
329,
374,
62,
312,
87,
11,
374,
287,
27056,
378,
7,
25135,
4868,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
62,
24442,
6624,
6407,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
81,
13,
1831,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
611,
374,
13,
5036,
292,
2247,
13,
271,
62,
259,
1851,
856,
33529,
1303,
287,
1851,
856,
11,
611,
6611,
510,
11,
779,
1333,
68,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
11241,
62,
79,
16993,
11,
357,
79,
86,
62,
312,
87,
11,
279,
16993,
8,
287,
19974,
7,
30001,
1143,
62,
79,
86,
9310,
11,
1662,
62,
10379,
4400,
62,
79,
86,
9310,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1255,
796,
287,
1851,
62,
505,
62,
25135,
7,
30001,
62,
79,
16993,
11,
81,
11,
271,
62,
21633,
62,
260,
25636,
11,
81,
13,
5036,
292,
2247,
13,
20887,
62,
312,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
271,
62,
11265,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
1136,
62,
17618,
62,
1659,
62,
37336,
3419,
19841,
35847,
62,
400,
10126,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2872,
62,
259,
9641,
62,
20274,
7,
20274,
11,
1573,
4868,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2989,
62,
83,
5034,
7,
20274,
11,
1333,
68,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
1186,
62,
12786,
8,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5162,
408,
540,
58,
79,
86,
62,
312,
87,
60,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
1005,
62,
12786,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
31929,
29164,
32239,
77,
26449,
29164,
32239,
77,
8205,
408,
29164,
92,
357,
23884,
532,
23884,
1267,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
11,
374,
13,
1831,
11,
410,
11,
1635,
395,
1920,
62,
5162,
408,
62,
17618,
7,
9127,
82,
11,
269,
5700,
388,
11,
410,
11,
374,
62,
312,
87,
11,
1573,
4868,
22305,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
1255,
13,
271,
62,
448,
62,
1659,
62,
29982,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
17635,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
59,
77,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
366,
448,
62,
1659,
62,
29982,
48774,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
366,
448,
62,
1659,
62,
29982,
48774,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
17635,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
59,
77,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
1255,
13,
18224,
62,
19662,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
1255,
13,
18224,
62,
19662,
4008,
628,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
374,
13,
5036,
292,
2247,
13,
271,
62,
40085,
13821,
33529,
1303,
26329,
1851,
856,
11,
611,
2314,
5412,
11,
13934,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
810,
262,
13934,
2393,
318,
8574,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27056,
515,
62,
7890,
62,
29851,
796,
45144,
92,
14,
268,
6975,
515,
14,
25135,
90,
27422,
14116,
1911,
18982,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
3866,
14681,
62,
6978,
6,
4357,
81,
62,
312,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
11241,
62,
79,
16993,
11,
357,
79,
86,
62,
312,
87,
11,
279,
16993,
8,
287,
19974,
7,
30001,
1143,
62,
79,
86,
9310,
11,
1662,
62,
10379,
4400,
62,
79,
86,
9310,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1255,
796,
287,
1851,
62,
505,
62,
25135,
7,
30001,
62,
79,
16993,
11,
81,
11,
271,
62,
21633,
62,
260,
25636,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
271,
62,
11265,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
1136,
62,
17618,
62,
1659,
62,
37336,
3419,
19841,
35847,
62,
400,
10126,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2872,
62,
259,
9641,
62,
20274,
7,
20274,
11,
1573,
4868,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2989,
62,
38476,
62,
7890,
7,
79,
16993,
11,
268,
6975,
515,
62,
7890,
62,
29851,
11,
22615,
62,
41757,
62,
14681,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
1186,
62,
12786,
8,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5162,
408,
540,
58,
79,
86,
62,
312,
87,
60,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
1005,
62,
12786,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
31929,
29164,
32239,
77,
26449,
29164,
32239,
77,
8205,
408,
29164,
92,
357,
23884,
532,
23884,
1267,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
11,
374,
13,
1831,
11,
410,
11,
1635,
395,
1920,
62,
5162,
408,
62,
17618,
7,
9127,
82,
11,
269,
5700,
388,
11,
410,
11,
374,
62,
312,
87,
11,
1573,
4868,
22305,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
1255,
13,
271,
62,
448,
62,
1659,
62,
29982,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2989,
62,
38476,
62,
7890,
7,
79,
16993,
11,
268,
6975,
515,
62,
7890,
62,
29851,
11,
22615,
62,
41757,
62,
14681,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
1186,
62,
12786,
8,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5162,
408,
540,
58,
79,
86,
62,
312,
87,
60,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
1005,
62,
12786,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
31929,
29164,
32239,
77,
26449,
29164,
32239,
77,
8205,
408,
29164,
92,
357,
23884,
532,
23884,
1267,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
11,
374,
13,
1831,
11,
410,
11,
1635,
395,
1920,
62,
5162,
408,
62,
17618,
7,
9127,
82,
11,
269,
5700,
388,
11,
410,
11,
374,
62,
312,
87,
11,
1573,
4868,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
17635,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
59,
77,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
1255,
13,
18224,
62,
19662,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
818,
9641,
4049,
329,
23884,
7,
7836,
8,
23884,
7,
79,
86,
828,
4049,
31456,
25,
23884,
1911,
18982,
7,
81,
13,
1831,
11,
279,
16993,
11,
1255,
13,
18224,
62,
19662,
4008,
628,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
1303,
13934,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
810,
262,
13934,
2393,
318,
8574,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27056,
515,
62,
7890,
62,
29851,
796,
45144,
92,
14,
268,
6975,
515,
14,
25135,
90,
27422,
14116,
1911,
18982,
7,
49,
4944,
34694,
62,
10943,
16254,
17816,
3866,
14681,
62,
6978,
6,
4357,
81,
62,
312,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
11241,
62,
79,
16993,
11,
357,
79,
86,
62,
312,
87,
11,
279,
16993,
8,
287,
19974,
7,
30001,
1143,
62,
79,
86,
9310,
11,
1662,
62,
10379,
4400,
62,
79,
86,
9310,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
62,
12786,
796,
2989,
62,
38476,
62,
7890,
7,
79,
16993,
11,
268,
6975,
515,
62,
7890,
62,
29851,
11,
22615,
62,
41757,
62,
14681,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
1186,
62,
12786,
8,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5162,
408,
540,
58,
79,
86,
62,
312,
87,
60,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
1005,
62,
12786,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
31929,
29164,
32239,
77,
26449,
29164,
32239,
77,
8205,
408,
29164,
92,
357,
23884,
532,
23884,
1267,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
11,
374,
13,
1831,
11,
410,
11,
1635,
395,
1920,
62,
5162,
408,
62,
17618,
7,
9127,
82,
11,
269,
5700,
388,
11,
410,
11,
374,
62,
312,
87,
11,
1573,
4868,
22305,
198,
220,
220,
220,
1303,
14468,
4242,
5268,
286,
554,
9641,
1303,
14468,
4242,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1303,
19430,
1892,
37571,
540,
6060,
198,
220,
220,
220,
329,
279,
86,
62,
312,
87,
11,
279,
16993,
287,
29083,
62,
79,
86,
9310,
25,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
3673,
37571,
540,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
4008,
628,
220,
220,
220,
329,
318,
62,
5162,
6676,
11,
357,
79,
86,
62,
312,
87,
11,
279,
16993,
8,
287,
19974,
7,
271,
62,
5162,
408,
540,
11,
407,
62,
10379,
4400,
62,
79,
86,
9310,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
62,
5162,
6676,
6624,
10352,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
10951,
7203,
59,
77,
35215,
7390,
87,
29164,
32239,
77,
35215,
29164,
32239,
77,
3673,
37571,
540,
59,
77,
1911,
18982,
7,
79,
86,
62,
312,
87,
11,
279,
16993,
4008,
628,
220,
220,
220,
18931,
13,
10951,
7203,
14957,
44774,
925,
416,
428,
8398,
25,
23884,
59,
77,
1911,
18982,
7,
37659,
13,
16345,
7,
9127,
82,
22305,
628,
220,
220,
220,
3601,
7203,
18467,
1348,
554,
48820,
14252,
11,
7472,
3862,
25,
23884,
1911,
18982,
7,
2435,
13,
525,
69,
62,
24588,
3419,
12,
72,
62,
2435,
4008,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1388,
3419
] | 2.181439 | 3,599 |
'''
This file is for retrieving system environment variables and helper
variables directly derived from them.
In decreasing order of precedence, environment variables can be set by:
1. adding them to .env file at root of this project
2. exporting and then running bumblebee in then same terminal.
E.g. export BUMBLEBEE_ENV=local; bumblebee
3. prefixing 'bumblebee' command with the environment variable when running.
E.g. BUMBLEBEE_ENV=local bumblebee
'''
from dotenv import load_dotenv
import os
load_dotenv()
bumblebee_environment = os.environ.get('BUMBLEBEE_ENV', 'production').lower()
is_local = bumblebee_environment == 'local'
| [
7061,
6,
198,
1212,
2393,
318,
329,
50122,
1080,
2858,
9633,
290,
31904,
198,
25641,
2977,
3264,
10944,
422,
606,
13,
198,
198,
818,
24030,
1502,
286,
38177,
11,
2858,
9633,
460,
307,
900,
416,
25,
198,
16,
13,
4375,
606,
284,
764,
24330,
2393,
379,
6808,
286,
428,
1628,
198,
17,
13,
39133,
290,
788,
2491,
275,
10344,
20963,
287,
788,
976,
12094,
13,
198,
220,
220,
412,
13,
70,
13,
10784,
347,
5883,
19146,
33,
6500,
62,
1677,
53,
28,
12001,
26,
275,
10344,
20963,
198,
18,
13,
21231,
278,
705,
4435,
903,
20963,
6,
3141,
351,
262,
2858,
7885,
618,
2491,
13,
198,
220,
220,
412,
13,
70,
13,
347,
5883,
19146,
33,
6500,
62,
1677,
53,
28,
12001,
275,
10344,
20963,
198,
7061,
6,
198,
6738,
16605,
24330,
1330,
3440,
62,
26518,
24330,
198,
11748,
28686,
198,
198,
2220,
62,
26518,
24330,
3419,
198,
198,
4435,
903,
20963,
62,
38986,
796,
28686,
13,
268,
2268,
13,
1136,
10786,
33,
5883,
19146,
33,
6500,
62,
1677,
53,
3256,
705,
25493,
27691,
21037,
3419,
198,
271,
62,
12001,
796,
275,
10344,
20963,
62,
38986,
6624,
705,
12001,
6,
198
] | 3.361257 | 191 |
"""Pagination sample for Microsoft Graph."""
# Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
# See LICENSE in the project root for license information.
import os
import bottle
import graphrest
import config
MSGRAPH = graphrest.GraphSession(client_id=config.CLIENT_ID,
client_secret=config.CLIENT_SECRET,
redirect_uri=config.REDIRECT_URI,
scopes=['User.Read', 'Mail.Read'])
bottle.TEMPLATE_PATH = ['./static/templates']
@bottle.route('/')
@bottle.view('homepage.html')
def homepage():
"""Render the home page."""
return {'title': 'Pagination Basics'}
@bottle.route('/login')
def login():
"""Prompt user to authenticate."""
endpoint = MSGRAPH.api_endpoint('me/messages')
MSGRAPH.login(login_redirect=f'/pagination?endpoint={endpoint}')
@bottle.route('/login/authorized')
def authorized():
"""Handler for the application's Redirect URI."""
MSGRAPH.redirect_uri_handler()
@bottle.route('/pagination')
@bottle.view('pagination.html')
def pagination():
"""Example of paginated response from Microsoft Graph."""
endpoint = bottle.request.query.endpoint
graphdata = MSGRAPH.get(endpoint).json()
return {'graphdata': graphdata}
@bottle.route('/static/<filepath:path>')
def server_static(filepath):
"""Handler for static files, used with the development server."""
root_folder = os.path.abspath(os.path.dirname(__file__))
return bottle.static_file(filepath, root=os.path.join(root_folder, 'static'))
if __name__ == '__main__':
bottle.run(app=bottle.app(), server='wsgiref', host='localhost', port=5000)
| [
37811,
47,
363,
1883,
6291,
329,
5413,
29681,
526,
15931,
198,
2,
15069,
357,
66,
8,
5413,
13,
1439,
2489,
10395,
13,
49962,
739,
262,
17168,
5964,
13,
198,
2,
4091,
38559,
24290,
287,
262,
1628,
6808,
329,
5964,
1321,
13,
198,
11748,
28686,
198,
198,
11748,
9294,
198,
11748,
4823,
2118,
198,
198,
11748,
4566,
628,
198,
5653,
10761,
31300,
796,
4823,
2118,
13,
37065,
36044,
7,
16366,
62,
312,
28,
11250,
13,
5097,
28495,
62,
2389,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
62,
21078,
28,
11250,
13,
5097,
28495,
62,
23683,
26087,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18941,
62,
9900,
28,
11250,
13,
22083,
40,
23988,
62,
47269,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
629,
13920,
28,
17816,
12982,
13,
5569,
3256,
705,
25804,
13,
5569,
6,
12962,
198,
198,
10985,
293,
13,
51,
3620,
6489,
6158,
62,
34219,
796,
685,
4458,
14,
12708,
14,
11498,
17041,
20520,
628,
198,
31,
10985,
293,
13,
38629,
10786,
14,
11537,
198,
31,
10985,
293,
13,
1177,
10786,
11195,
7700,
13,
6494,
11537,
198,
4299,
34940,
33529,
198,
220,
220,
220,
37227,
45819,
262,
1363,
2443,
526,
15931,
198,
220,
220,
220,
1441,
1391,
6,
7839,
10354,
705,
47,
363,
1883,
45884,
6,
92,
628,
198,
31,
10985,
293,
13,
38629,
10786,
14,
38235,
11537,
198,
4299,
17594,
33529,
198,
220,
220,
220,
37227,
24129,
457,
2836,
284,
8323,
5344,
526,
15931,
198,
220,
220,
220,
36123,
796,
6579,
10761,
31300,
13,
15042,
62,
437,
4122,
10786,
1326,
14,
37348,
1095,
11537,
198,
220,
220,
220,
6579,
10761,
31300,
13,
38235,
7,
38235,
62,
445,
1060,
28,
69,
26488,
79,
363,
1883,
30,
437,
4122,
34758,
437,
4122,
92,
11537,
628,
198,
31,
10985,
293,
13,
38629,
10786,
14,
38235,
14,
19721,
11537,
198,
4299,
10435,
33529,
198,
220,
220,
220,
37227,
25060,
329,
262,
3586,
338,
2297,
1060,
43975,
526,
15931,
198,
220,
220,
220,
6579,
10761,
31300,
13,
445,
1060,
62,
9900,
62,
30281,
3419,
628,
198,
31,
10985,
293,
13,
38629,
10786,
14,
79,
363,
1883,
11537,
198,
31,
10985,
293,
13,
1177,
10786,
79,
363,
1883,
13,
6494,
11537,
198,
4299,
42208,
1883,
33529,
198,
220,
220,
220,
37227,
16281,
286,
42208,
3898,
2882,
422,
5413,
29681,
526,
15931,
198,
220,
220,
220,
36123,
796,
9294,
13,
25927,
13,
22766,
13,
437,
4122,
198,
220,
220,
220,
4823,
7890,
796,
6579,
10761,
31300,
13,
1136,
7,
437,
4122,
737,
17752,
3419,
198,
220,
220,
220,
1441,
1391,
6,
34960,
7890,
10354,
4823,
7890,
92,
628,
198,
31,
10985,
293,
13,
38629,
10786,
14,
12708,
14,
27,
7753,
6978,
25,
6978,
29,
11537,
198,
4299,
4382,
62,
12708,
7,
7753,
6978,
2599,
198,
220,
220,
220,
37227,
25060,
329,
9037,
3696,
11,
973,
351,
262,
2478,
4382,
526,
15931,
198,
220,
220,
220,
6808,
62,
43551,
796,
28686,
13,
6978,
13,
397,
2777,
776,
7,
418,
13,
6978,
13,
15908,
3672,
7,
834,
7753,
834,
4008,
198,
220,
220,
220,
1441,
9294,
13,
12708,
62,
7753,
7,
7753,
6978,
11,
6808,
28,
418,
13,
6978,
13,
22179,
7,
15763,
62,
43551,
11,
705,
12708,
6,
4008,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
9294,
13,
5143,
7,
1324,
28,
10985,
293,
13,
1324,
22784,
4382,
11639,
18504,
70,
557,
69,
3256,
2583,
11639,
36750,
3256,
2493,
28,
27641,
8,
198
] | 2.629057 | 647 |
from django.conf import settings
from django.db import models
from django.dispatch import receiver
from django.contrib.auth.models import User
import requests
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _, ugettext
from django.core import validators
from channels import Group, Channel
from django.utils import timezone
from datetime import timedelta,datetime
from django_auth_lti.patch_reverse import reverse
from .groups import group_for_attempt
from .report_outcome import report_outcome_for_attempt, ReportOutcomeFailure, ReportOutcomeConnectionError
import os
import shutil
from zipfile import ZipFile
from lxml import etree
import re
import json
from collections import defaultdict
@receiver(models.signals.post_save)
# Create your models here.
@receiver(models.signals.pre_save, sender=Exam)
GRADING_METHODS = [
('highest',_('Highest score')),
('last',_('Last attempt')),
]
REPORT_TIMES = [
('immediately',_('Immediately')),
('oncompletion',_('On completion')),
('manually',_('Manually, by instructor')),
]
REPORTING_STATUSES = [
('reporting',_('Reporting scores')),
('error',_('Error encountered')),
('complete',_('All scores reported')),
]
SHOW_SCORES_MODES = [
('always',_('Always')),
('complete',_('When attempt is complete')),
('never',_('Never')),
]
COMPLETION_STATUSES = [
('not attempted',_('Not attempted')),
('incomplete',_('Incomplete')),
('completed',_('Complete')),
]
models.signals.post_save.connect(remark_update_scaled_score,sender=RemarkPart)
models.signals.post_delete.connect(remark_update_scaled_score,sender=RemarkPart)
DISCOUNT_BEHAVIOURS = [
('remove','Remove from total'),
('fullmarks','Award everyone full credit'),
]
models.signals.post_save.connect(discount_update_scaled_score,sender=DiscountPart)
models.signals.post_delete.connect(discount_update_scaled_score,sender=DiscountPart)
@receiver(models.signals.post_save,sender=ScormElement)
@receiver(models.signals.post_save,sender=ScormElement)
@receiver(models.signals.post_save,sender=ScormElement)
@receiver(models.signals.post_save,sender=ScormElement)
def scorm_set_num_questions(sender,instance,created,**kwargs):
""" Set the number of questions for this resource - can only work this out once the exam has been run! """
if not re.match(r'^cmi.objectives.([0-9]+).id$',instance.key) or not created:
return
number = int(re.match(r'q(\d+)',instance.value).group(1))+1
resource = instance.attempt.resource
if number>resource.num_questions:
resource.num_questions = number
resource.save()
@receiver(models.signals.pre_save,sender=EditorLink)
| [
6738,
42625,
14208,
13,
10414,
1330,
6460,
198,
6738,
42625,
14208,
13,
9945,
1330,
4981,
198,
6738,
42625,
14208,
13,
6381,
17147,
1330,
9733,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
27530,
1330,
11787,
198,
11748,
7007,
198,
6738,
42625,
14208,
13,
26791,
13,
5239,
1330,
31065,
1958,
198,
6738,
42625,
14208,
13,
26791,
13,
41519,
1330,
334,
1136,
5239,
62,
75,
12582,
355,
4808,
11,
334,
1136,
5239,
198,
6738,
42625,
14208,
13,
7295,
1330,
4938,
2024,
198,
6738,
9619,
1330,
4912,
11,
11102,
198,
6738,
42625,
14208,
13,
26791,
1330,
640,
11340,
198,
6738,
4818,
8079,
1330,
28805,
12514,
11,
19608,
8079,
198,
6738,
42625,
14208,
62,
18439,
62,
2528,
72,
13,
17147,
62,
50188,
1330,
9575,
198,
198,
6738,
764,
24432,
1330,
1448,
62,
1640,
62,
1078,
1791,
198,
6738,
764,
13116,
62,
448,
2958,
1330,
989,
62,
448,
2958,
62,
1640,
62,
1078,
1791,
11,
6358,
7975,
2958,
50015,
11,
6358,
7975,
2958,
32048,
12331,
198,
198,
11748,
28686,
198,
11748,
4423,
346,
198,
6738,
19974,
7753,
1330,
38636,
8979,
198,
6738,
300,
19875,
1330,
2123,
631,
198,
11748,
302,
198,
11748,
33918,
198,
6738,
17268,
1330,
4277,
11600,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
8,
628,
198,
2,
13610,
534,
4981,
994,
13,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
3866,
62,
21928,
11,
29788,
28,
3109,
321,
8,
628,
198,
10761,
2885,
2751,
62,
49273,
50,
796,
685,
198,
220,
220,
220,
19203,
35323,
3256,
62,
10786,
36124,
3634,
4776,
11537,
828,
198,
220,
220,
220,
19203,
12957,
3256,
62,
10786,
5956,
2230,
11537,
828,
198,
60,
198,
198,
2200,
15490,
62,
51,
3955,
1546,
796,
685,
198,
220,
220,
220,
19203,
320,
23802,
3256,
62,
10786,
3546,
23802,
11537,
828,
198,
220,
220,
220,
19203,
261,
785,
24547,
3256,
62,
10786,
2202,
11939,
11537,
828,
198,
220,
220,
220,
19203,
805,
935,
3256,
62,
10786,
5124,
935,
11,
416,
21187,
11537,
828,
198,
60,
198,
2200,
15490,
2751,
62,
35744,
2937,
1546,
796,
685,
198,
220,
220,
220,
19203,
49914,
3256,
62,
10786,
42159,
8198,
11537,
828,
198,
220,
220,
220,
19203,
18224,
3256,
62,
10786,
12331,
12956,
11537,
828,
198,
220,
220,
220,
19203,
20751,
3256,
62,
10786,
3237,
8198,
2098,
11537,
828,
198,
60,
198,
198,
9693,
3913,
62,
6173,
1581,
1546,
62,
33365,
1546,
796,
685,
198,
220,
220,
220,
19203,
33770,
3256,
62,
10786,
30374,
11537,
828,
198,
220,
220,
220,
19203,
20751,
3256,
62,
10786,
2215,
2230,
318,
1844,
11537,
828,
198,
220,
220,
220,
19203,
12081,
3256,
62,
10786,
12295,
11537,
828,
198,
60,
198,
198,
41335,
24131,
62,
35744,
2937,
1546,
796,
685,
198,
220,
220,
220,
19203,
1662,
7482,
3256,
62,
10786,
3673,
7482,
11537,
828,
198,
220,
220,
220,
19203,
259,
20751,
3256,
62,
10786,
818,
20751,
11537,
828,
198,
220,
220,
220,
19203,
785,
16838,
3256,
62,
10786,
20988,
11537,
828,
198,
60,
198,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
13,
8443,
7,
2787,
668,
62,
19119,
62,
1416,
3021,
62,
26675,
11,
82,
2194,
28,
8413,
668,
7841,
8,
198,
27530,
13,
12683,
874,
13,
7353,
62,
33678,
13,
8443,
7,
2787,
668,
62,
19119,
62,
1416,
3021,
62,
26675,
11,
82,
2194,
28,
8413,
668,
7841,
8,
198,
198,
26288,
34,
28270,
62,
12473,
7801,
12861,
2606,
6998,
796,
685,
198,
220,
220,
220,
19203,
28956,
41707,
27914,
422,
2472,
33809,
198,
220,
220,
220,
19203,
12853,
14306,
41707,
32,
904,
2506,
1336,
3884,
33809,
198,
60,
198,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
13,
8443,
7,
15410,
608,
62,
19119,
62,
1416,
3021,
62,
26675,
11,
82,
2194,
28,
15642,
608,
7841,
8,
198,
27530,
13,
12683,
874,
13,
7353,
62,
33678,
13,
8443,
7,
15410,
608,
62,
19119,
62,
1416,
3021,
62,
26675,
11,
82,
2194,
28,
15642,
608,
7841,
8,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
11,
82,
2194,
28,
3351,
579,
20180,
8,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
11,
82,
2194,
28,
3351,
579,
20180,
8,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
11,
82,
2194,
28,
3351,
579,
20180,
8,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
7353,
62,
21928,
11,
82,
2194,
28,
3351,
579,
20180,
8,
198,
4299,
629,
579,
62,
2617,
62,
22510,
62,
6138,
507,
7,
82,
2194,
11,
39098,
11,
25598,
11,
1174,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
5345,
262,
1271,
286,
2683,
329,
428,
8271,
532,
460,
691,
670,
428,
503,
1752,
262,
2814,
468,
587,
1057,
0,
37227,
198,
220,
220,
220,
611,
407,
302,
13,
15699,
7,
81,
6,
61,
11215,
72,
13,
15252,
1083,
12195,
58,
15,
12,
24,
48688,
737,
312,
3,
3256,
39098,
13,
2539,
8,
393,
407,
2727,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
628,
220,
220,
220,
1271,
796,
493,
7,
260,
13,
15699,
7,
81,
6,
80,
38016,
67,
28988,
3256,
39098,
13,
8367,
737,
8094,
7,
16,
4008,
10,
16,
198,
220,
220,
220,
8271,
796,
4554,
13,
1078,
1791,
13,
31092,
198,
220,
220,
220,
220,
198,
220,
220,
220,
611,
1271,
29,
31092,
13,
22510,
62,
6138,
507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
8271,
13,
22510,
62,
6138,
507,
796,
1271,
198,
220,
220,
220,
220,
220,
220,
220,
8271,
13,
21928,
3419,
198,
198,
31,
260,
39729,
7,
27530,
13,
12683,
874,
13,
3866,
62,
21928,
11,
82,
2194,
28,
17171,
11280,
8,
198
] | 2.868644 | 944 |
import json
import re
import argparse
import sys
if __name__ == '__main__':
main()
| [
11748,
33918,
198,
11748,
302,
198,
11748,
1822,
29572,
198,
11748,
25064,
628,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1388,
3419,
198
] | 2.84375 | 32 |
import json
from src.mappers.heartbeatMapper import Heartbeat
| [
11748,
33918,
198,
198,
6738,
12351,
13,
76,
46629,
13,
11499,
12945,
44,
11463,
1330,
8894,
12945,
628
] | 3.555556 | 18 |
# Generated automatically using the command :
# c++2py h5py_io.hpp --members_read_only -N h5 -a _h5py -m _h5py -o _h5py --moduledoc="A lightweight hdf5 python interface" --cxxflags="-std=c++20" --includes=./../../c++ --only="object file group h5_read_bare h5_write_bare"
from cpp2py.wrap_generator import *
# The module
module = module_(full_name = "_h5py", doc = r"A lightweight hdf5 python interface", app_name = "_h5py")
# Imports
# Add here all includes
module.add_include("<h5py_io.hpp>")
# Add here anything to add in the C++ code at the start, e.g. namespace using
module.add_preamble("""
#include <cpp2py/converters/span.hpp>
#include <cpp2py/converters/string.hpp>
#include <cpp2py/converters/vector.hpp>
using namespace h5;
""")
# The class file
c = class_(
py_type = "File", # name of the python class
c_type = "file", # name of the C++ class
doc = r"""A little handler for the HDF5 file
The class is basically a pointer to the file.""", # doc of the C++ class
hdf5 = False,
)
c.add_constructor("""()""", doc = r"""Open a file in memory""")
c.add_constructor("""(std::string name, char mode)""", doc = r"""""")
c.add_constructor("""(std::span<std::byte> buf)""", doc = r"""Create a file in memory from a byte buffer""")
c.add_property(name = "name", getter = cfunction("""std::string name ()"""),
doc = r"""Name of the file""")
c.add_method("""void flush ()""",
doc = r"""Flush the file""")
c.add_method("""std::vector<std::byte> as_buffer ()""",
doc = r"""Get a copy of the associated byte buffer""")
module.add_class(c)
# The class group
c = class_(
py_type = "Group", # name of the python class
c_type = "group", # name of the C++ class
doc = r"""HDF5 group""", # doc of the C++ class
hdf5 = False,
)
c.add_constructor("""(file f)""", doc = r"""Takes the "/" group at the top of the file""")
c.add_property(name = "name", getter = cfunction("""std::string name ()"""),
doc = r"""Name of the group""")
c.add_method("""group open_group (std::string key)""",
doc = r"""Open a subgroup.
Throws std::runtime_error if it does not exist.
Parameters
----------
key
The name of the subgroup. If empty, return this group""")
c.add_method("""group create_group (std::string key, bool delete_if_exists = true)""",
doc = r"""Create a subgroup in this group
Parameters
----------
key
The name of the subgroup. If empty, return this group.
delete_if_exists
Unlink the group if it exists""")
c.add_method("""std::vector<std::string> get_all_subgroup_dataset_names ()""", name='keys',
doc = r"""Returns all names of dataset of G""")
c.add_property(name = "file", getter = cfunction("""file get_file ()"""),
doc = r"""The parent file""")
c.add_method("""bool has_subgroup (std::string key)""",
doc = r"""True iff key is a subgroup of this.
Parameters
----------
key""")
c.add_method("""bool has_dataset (std::string key)""",
doc = r"""True iff key is a dataset of this.
Parameters
----------
key""")
c.add_method("void write_attribute(std::string key, std::string val)", calling_pattern = "h5_write_attribute(self_c, key, val)", doc = "Write an attribute")
c.add_method("std::string read_attribute(std::string name)", calling_pattern = "std::string result = h5_read_attribute<std::string>(self_c, name)", doc = "Read an attribute")
c.add_method("std::string read_hdf5_format_from_key(std::string key)", calling_pattern = "std::string result; read_hdf5_format_from_key(self_c, key, result);", doc = "Read the format string from the key in the group")
module.add_class(c)
module.add_function (name = "h5_write", signature = "void h5_write_bare (group g, std::string name, PyObject * ob)", doc = r"""""")
module.add_function (name = "h5_read", signature = "PyObject * h5_read_bare (group g, std::string name)", doc = r"""""")
module.generate_code()
| [
2,
2980,
515,
6338,
1262,
262,
3141,
1058,
198,
2,
269,
4880,
17,
9078,
289,
20,
9078,
62,
952,
13,
71,
381,
1377,
30814,
62,
961,
62,
8807,
532,
45,
289,
20,
532,
64,
4808,
71,
20,
9078,
532,
76,
4808,
71,
20,
9078,
532,
78,
4808,
71,
20,
9078,
1377,
4666,
6309,
420,
2625,
32,
18700,
289,
7568,
20,
21015,
7071,
1,
1377,
66,
5324,
33152,
2625,
12,
19282,
28,
66,
4880,
1238,
1,
1377,
42813,
28,
19571,
40720,
40720,
66,
4880,
1377,
8807,
2625,
15252,
2393,
1448,
289,
20,
62,
961,
62,
49382,
289,
20,
62,
13564,
62,
49382,
1,
198,
6738,
269,
381,
17,
9078,
13,
37150,
62,
8612,
1352,
1330,
1635,
198,
198,
2,
383,
8265,
198,
21412,
796,
8265,
41052,
12853,
62,
3672,
796,
45434,
71,
20,
9078,
1600,
2205,
796,
374,
1,
32,
18700,
289,
7568,
20,
21015,
7071,
1600,
598,
62,
3672,
796,
45434,
71,
20,
9078,
4943,
198,
198,
2,
1846,
3742,
198,
198,
2,
3060,
994,
477,
3407,
198,
21412,
13,
2860,
62,
17256,
7203,
27,
71,
20,
9078,
62,
952,
13,
71,
381,
29,
4943,
198,
198,
2,
3060,
994,
1997,
284,
751,
287,
262,
327,
4880,
2438,
379,
262,
923,
11,
304,
13,
70,
13,
25745,
1262,
198,
21412,
13,
2860,
62,
79,
1476,
903,
7203,
15931,
198,
2,
17256,
1279,
20322,
17,
9078,
14,
1102,
332,
1010,
14,
12626,
13,
71,
381,
29,
198,
2,
17256,
1279,
20322,
17,
9078,
14,
1102,
332,
1010,
14,
8841,
13,
71,
381,
29,
198,
2,
17256,
1279,
20322,
17,
9078,
14,
1102,
332,
1010,
14,
31364,
13,
71,
381,
29,
198,
198,
3500,
25745,
289,
20,
26,
198,
15931,
4943,
628,
198,
2,
383,
1398,
2393,
198,
66,
796,
1398,
41052,
198,
220,
220,
220,
220,
220,
220,
220,
12972,
62,
4906,
796,
366,
8979,
1600,
220,
1303,
1438,
286,
262,
21015,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
269,
62,
4906,
796,
366,
7753,
1600,
220,
220,
1303,
1438,
286,
262,
327,
4880,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
32,
1310,
21360,
329,
262,
5572,
37,
20,
2393,
628,
220,
383,
1398,
318,
6209,
257,
17562,
284,
262,
2393,
32203,
1600,
220,
220,
1303,
2205,
286,
262,
327,
4880,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
289,
7568,
20,
796,
10352,
11,
198,
8,
198,
198,
66,
13,
2860,
62,
41571,
273,
7203,
15931,
3419,
15931,
1600,
2205,
796,
374,
37811,
11505,
257,
2393,
287,
4088,
15931,
4943,
198,
198,
66,
13,
2860,
62,
41571,
273,
7203,
15931,
7,
19282,
3712,
8841,
1438,
11,
1149,
4235,
8,
15931,
1600,
2205,
796,
374,
15931,
37811,
4943,
198,
198,
66,
13,
2860,
62,
41571,
273,
7203,
15931,
7,
19282,
3712,
12626,
27,
19282,
3712,
26327,
29,
42684,
8,
15931,
1600,
2205,
796,
374,
37811,
16447,
257,
2393,
287,
4088,
422,
257,
18022,
11876,
15931,
4943,
198,
198,
66,
13,
2860,
62,
26745,
7,
3672,
796,
366,
3672,
1600,
651,
353,
796,
269,
8818,
7203,
15931,
19282,
3712,
8841,
1438,
7499,
15931,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
5376,
286,
262,
2393,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
19382,
24773,
7499,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
7414,
1530,
262,
2393,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
19282,
3712,
31364,
27,
19282,
3712,
26327,
29,
355,
62,
22252,
7499,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
3855,
257,
4866,
286,
262,
3917,
18022,
11876,
15931,
4943,
198,
198,
21412,
13,
2860,
62,
4871,
7,
66,
8,
198,
198,
2,
383,
1398,
1448,
198,
66,
796,
1398,
41052,
198,
220,
220,
220,
220,
220,
220,
220,
12972,
62,
4906,
796,
366,
13247,
1600,
220,
1303,
1438,
286,
262,
21015,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
269,
62,
4906,
796,
366,
8094,
1600,
220,
220,
1303,
1438,
286,
262,
327,
4880,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
39,
8068,
20,
1448,
15931,
1600,
220,
220,
1303,
2205,
286,
262,
327,
4880,
1398,
198,
220,
220,
220,
220,
220,
220,
220,
289,
7568,
20,
796,
10352,
11,
198,
8,
198,
198,
66,
13,
2860,
62,
41571,
273,
7203,
15931,
7,
7753,
277,
8,
15931,
1600,
2205,
796,
374,
37811,
51,
1124,
262,
12813,
1,
1448,
379,
262,
1353,
286,
262,
2393,
15931,
4943,
198,
198,
66,
13,
2860,
62,
26745,
7,
3672,
796,
366,
3672,
1600,
651,
353,
796,
269,
8818,
7203,
15931,
19282,
3712,
8841,
1438,
7499,
15931,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
5376,
286,
262,
1448,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
8094,
1280,
62,
8094,
357,
19282,
3712,
8841,
1994,
8,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
11505,
257,
850,
8094,
13,
198,
536,
8516,
14367,
3712,
43282,
62,
18224,
611,
340,
857,
407,
2152,
13,
198,
198,
48944,
198,
35937,
198,
2539,
198,
220,
220,
220,
220,
383,
1438,
286,
262,
850,
8094,
13,
1002,
6565,
11,
1441,
428,
1448,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
8094,
2251,
62,
8094,
357,
19282,
3712,
8841,
1994,
11,
20512,
12233,
62,
361,
62,
1069,
1023,
796,
2081,
8,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
16447,
257,
850,
8094,
287,
428,
1448,
198,
198,
48944,
198,
35937,
198,
2539,
198,
220,
220,
220,
220,
383,
1438,
286,
262,
850,
8094,
13,
1002,
6565,
11,
1441,
428,
1448,
13,
198,
198,
33678,
62,
361,
62,
1069,
1023,
198,
220,
220,
220,
220,
791,
8726,
262,
1448,
611,
340,
7160,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
19282,
3712,
31364,
27,
19282,
3712,
8841,
29,
651,
62,
439,
62,
7266,
8094,
62,
19608,
292,
316,
62,
14933,
7499,
15931,
1600,
1438,
11639,
13083,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
35561,
477,
3891,
286,
27039,
286,
402,
15931,
4943,
198,
198,
66,
13,
2860,
62,
26745,
7,
3672,
796,
366,
7753,
1600,
651,
353,
796,
269,
8818,
7203,
15931,
7753,
651,
62,
7753,
7499,
15931,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
464,
2560,
2393,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
30388,
468,
62,
7266,
8094,
357,
19282,
3712,
8841,
1994,
8,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
17821,
611,
69,
1994,
318,
257,
850,
8094,
286,
428,
13,
198,
198,
48944,
198,
35937,
198,
2539,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
15931,
30388,
468,
62,
19608,
292,
316,
357,
19282,
3712,
8841,
1994,
8,
15931,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2205,
796,
374,
37811,
17821,
611,
69,
1994,
318,
257,
27039,
286,
428,
13,
198,
198,
48944,
198,
35937,
198,
2539,
15931,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
19382,
3551,
62,
42348,
7,
19282,
3712,
8841,
1994,
11,
14367,
3712,
8841,
1188,
42501,
4585,
62,
33279,
796,
366,
71,
20,
62,
13564,
62,
42348,
7,
944,
62,
66,
11,
1994,
11,
1188,
42501,
2205,
796,
366,
16594,
281,
11688,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
19282,
3712,
8841,
1100,
62,
42348,
7,
19282,
3712,
8841,
1438,
42501,
4585,
62,
33279,
796,
366,
19282,
3712,
8841,
1255,
796,
289,
20,
62,
961,
62,
42348,
27,
19282,
3712,
8841,
33994,
944,
62,
66,
11,
1438,
42501,
2205,
796,
366,
5569,
281,
11688,
4943,
198,
198,
66,
13,
2860,
62,
24396,
7203,
19282,
3712,
8841,
1100,
62,
71,
7568,
20,
62,
18982,
62,
6738,
62,
2539,
7,
19282,
3712,
8841,
1994,
42501,
4585,
62,
33279,
796,
366,
19282,
3712,
8841,
1255,
26,
1100,
62,
71,
7568,
20,
62,
18982,
62,
6738,
62,
2539,
7,
944,
62,
66,
11,
1994,
11,
1255,
1776,
1600,
2205,
796,
366,
5569,
262,
5794,
4731,
422,
262,
1994,
287,
262,
1448,
4943,
198,
198,
21412,
13,
2860,
62,
4871,
7,
66,
8,
198,
198,
21412,
13,
2860,
62,
8818,
357,
3672,
796,
366,
71,
20,
62,
13564,
1600,
9877,
796,
366,
19382,
289,
20,
62,
13564,
62,
49382,
357,
8094,
308,
11,
14367,
3712,
8841,
1438,
11,
9485,
10267,
1635,
909,
42501,
2205,
796,
374,
15931,
37811,
4943,
198,
198,
21412,
13,
2860,
62,
8818,
357,
3672,
796,
366,
71,
20,
62,
961,
1600,
9877,
796,
366,
20519,
10267,
1635,
289,
20,
62,
961,
62,
49382,
357,
8094,
308,
11,
14367,
3712,
8841,
1438,
42501,
2205,
796,
374,
15931,
37811,
4943,
628,
198,
198,
21412,
13,
8612,
378,
62,
8189,
3419,
198
] | 2.636364 | 1,518 |
# Copyright 2021 Google Inc.
#
# 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 testing_config # Must be imported first
import flask
from unittest import mock
import werkzeug
from internals import models
from internals import approval_defs
from internals import detect_intent
test_app = flask.Flask(__name__)
| [
2,
15069,
33448,
3012,
3457,
13,
198,
2,
198,
2,
49962,
739,
262,
24843,
13789,
11,
10628,
362,
13,
15,
357,
1169,
366,
34156,
4943,
198,
2,
345,
743,
407,
779,
428,
2393,
2845,
287,
11846,
351,
262,
13789,
13,
198,
2,
921,
743,
7330,
257,
4866,
286,
262,
13789,
379,
198,
2,
198,
2,
220,
220,
220,
220,
2638,
1378,
2503,
13,
43073,
13,
2398,
14,
677,
4541,
14,
43,
2149,
24290,
12,
17,
13,
15,
198,
2,
198,
2,
17486,
2672,
416,
9723,
1099,
393,
4987,
284,
287,
3597,
11,
3788,
198,
2,
9387,
739,
262,
13789,
318,
9387,
319,
281,
366,
1921,
3180,
1,
29809,
1797,
11,
198,
2,
42881,
34764,
11015,
6375,
7102,
49828,
11053,
3963,
15529,
509,
12115,
11,
2035,
4911,
393,
17142,
13,
198,
2,
4091,
262,
13789,
329,
262,
2176,
3303,
15030,
21627,
290,
198,
2,
11247,
739,
262,
13789,
13,
198,
198,
11748,
4856,
62,
11250,
220,
1303,
12039,
307,
17392,
717,
198,
198,
11748,
42903,
198,
6738,
555,
715,
395,
1330,
15290,
198,
11748,
266,
9587,
2736,
1018,
198,
198,
6738,
1788,
874,
1330,
4981,
198,
6738,
1788,
874,
1330,
7546,
62,
4299,
82,
198,
6738,
1788,
874,
1330,
4886,
62,
48536,
198,
198,
9288,
62,
1324,
796,
42903,
13,
7414,
2093,
7,
834,
3672,
834,
8,
628,
198
] | 3.747706 | 218 |
"""Citizens model."""
# Django
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.core.validators import RegexValidator
# models
from paranuara.companies.models import Company
# PostgreSQL fields
from django.contrib.postgres.fields import JSONField
# Utilities
from paranuara.utils.models import ParanuaraModel
class Citizen(ParanuaraModel, AbstractUser):
"""Citizen model.
Extend from Django's Abstract User, change the username field
to email and add some extra fields.
"""
index = models.IntegerField(
unique=True,
default=-1
)
favorite_food = models.ManyToManyField(
'foods.Food',
related_name='favorite_food'
)
has_died = models.BooleanField(
'died',
default=False,
help_text=(
'Help easily distinguish citizens died or alive. '
)
)
balance = models.DecimalField(
max_digits=15,
decimal_places=2,
default=None
)
picture = models.ImageField(
'profile picture',
upload_to='paranuara/citizens/pictures/',
blank=True,
null=True
)
age = models.IntegerField(
default=-1
)
eyeColor = models.CharField(
max_length=50,
blank=False
)
gender = models.CharField(
max_length=6,
blank=True
)
email = models.EmailField(
'email address',
unique=True,
error_messages={
'unique': 'A user with that email already exists.'
}
)
phone_regex = RegexValidator(
regex=r'\+?1?\d{9,15}$',
message="Phone number must be entered in the format: +999999999. Up to 15 digits allowed."
)
phone = models.CharField(
validators=[phone_regex],
max_length=20,
blank=True
)
address = models.CharField(
max_length=100,
blank=True
)
company = models.ForeignKey(
Company,
related_name='employees_company',
on_delete=models.SET_NULL,
null=True
)
about = models.CharField(
max_length=1000,
blank=True,
null=True
)
greeting = models.CharField(
max_length=1000,
blank=True,
null=True
)
tags = JSONField(
default=None,
blank=True,
null=True
)
REQUIRED_FIELDS = ['has_died', 'eyeColor', 'index']
class Relationship(models.Model):
"""Class to represent many to many relation between Ctizens"""
from_people = models.ForeignKey(Citizen, related_name='from_people', on_delete=models.CASCADE)
to_people = models.ForeignKey(Citizen, related_name='to_people', on_delete=models.CASCADE)
| [
37811,
34,
34100,
2746,
526,
15931,
198,
198,
2,
37770,
198,
6738,
42625,
14208,
13,
9945,
1330,
4981,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
27530,
1330,
27741,
12982,
198,
6738,
42625,
14208,
13,
7295,
13,
12102,
2024,
1330,
797,
25636,
47139,
1352,
198,
198,
2,
4981,
198,
6738,
23511,
84,
3301,
13,
34390,
444,
13,
27530,
1330,
5834,
198,
198,
2,
2947,
47701,
7032,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
7353,
34239,
13,
25747,
1330,
19449,
15878,
198,
198,
2,
41086,
198,
6738,
23511,
84,
3301,
13,
26791,
13,
27530,
1330,
2547,
42357,
3301,
17633,
628,
198,
4871,
22307,
7,
10044,
42357,
3301,
17633,
11,
27741,
12982,
2599,
198,
220,
220,
220,
37227,
34,
36958,
2746,
13,
198,
220,
220,
220,
46228,
422,
37770,
338,
27741,
11787,
11,
1487,
262,
20579,
2214,
198,
220,
220,
220,
284,
3053,
290,
751,
617,
3131,
7032,
13,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
6376,
796,
4981,
13,
46541,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
3748,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
10779,
16,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
4004,
62,
19425,
796,
4981,
13,
7085,
2514,
7085,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
705,
19425,
82,
13,
24602,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
3519,
62,
3672,
11639,
35200,
62,
19425,
6,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
468,
62,
67,
798,
796,
4981,
13,
46120,
13087,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
705,
67,
798,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
4277,
28,
25101,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1037,
62,
5239,
16193,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
22087,
3538,
15714,
4290,
3724,
393,
6776,
13,
705,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
5236,
796,
4981,
13,
10707,
4402,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
12894,
896,
28,
1314,
11,
198,
220,
220,
220,
220,
220,
220,
220,
32465,
62,
23625,
28,
17,
11,
198,
220,
220,
220,
220,
220,
220,
220,
4277,
28,
14202,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
4286,
796,
4981,
13,
5159,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
705,
13317,
4286,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
9516,
62,
1462,
11639,
1845,
42357,
3301,
14,
46801,
14,
18847,
942,
14,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9242,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
2479,
796,
4981,
13,
46541,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
10779,
16,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
4151,
10258,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
1120,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
25101,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
5279,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
21,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
3053,
796,
4981,
13,
15333,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
705,
12888,
2209,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
3748,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
37348,
1095,
34758,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
34642,
10354,
705,
32,
2836,
351,
326,
3053,
1541,
7160,
2637,
198,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
3072,
62,
260,
25636,
796,
797,
25636,
47139,
1352,
7,
198,
220,
220,
220,
220,
220,
220,
220,
40364,
28,
81,
6,
59,
10,
30,
16,
30,
59,
67,
90,
24,
11,
1314,
92,
3,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
2625,
6132,
1271,
1276,
307,
5982,
287,
262,
5794,
25,
1343,
24214,
2079,
17032,
13,
3205,
284,
1315,
19561,
3142,
526,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
3072,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
4938,
2024,
41888,
4862,
62,
260,
25636,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
1238,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
2209,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
3064,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
1664,
796,
4981,
13,
33616,
9218,
7,
198,
220,
220,
220,
220,
220,
220,
220,
5834,
11,
198,
220,
220,
220,
220,
220,
220,
220,
3519,
62,
3672,
11639,
7033,
2841,
62,
39722,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
319,
62,
33678,
28,
27530,
13,
28480,
62,
33991,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
9242,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
546,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
12825,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9242,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
31933,
796,
4981,
13,
12441,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
13664,
28,
12825,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9242,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
15940,
796,
19449,
15878,
7,
198,
220,
220,
220,
220,
220,
220,
220,
4277,
28,
14202,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9178,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
9242,
28,
17821,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
4526,
10917,
37819,
62,
11674,
3698,
5258,
796,
37250,
10134,
62,
67,
798,
3256,
705,
25379,
10258,
3256,
705,
9630,
20520,
628,
198,
4871,
39771,
7,
27530,
13,
17633,
2599,
198,
220,
220,
220,
37227,
9487,
284,
2380,
867,
284,
867,
8695,
1022,
43166,
44908,
37811,
628,
220,
220,
220,
422,
62,
15332,
796,
4981,
13,
33616,
9218,
7,
34,
36958,
11,
3519,
62,
3672,
11639,
6738,
62,
15332,
3256,
319,
62,
33678,
28,
27530,
13,
34,
42643,
19266,
8,
198,
220,
220,
220,
284,
62,
15332,
796,
4981,
13,
33616,
9218,
7,
34,
36958,
11,
3519,
62,
3672,
11639,
1462,
62,
15332,
3256,
319,
62,
33678,
28,
27530,
13,
34,
42643,
19266,
8,
198
] | 2.325424 | 1,180 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.urls import path
from .views import login_register, task_manage, analysis_page
urlpatterns = [
path('login/', login_register.Login.as_view()),
path('register/', login_register.SignIn.as_view()),
path('register/check_username', login_register.SignIn.as_view()),
path('task_manager/addition/', task_manage.TaskManage.as_view()),
path('task_manager/removing/', task_manage.TaskManage.as_view()),
path('task_manager/recovering/', task_manage.Recover.as_view()),
path('task_manager/upgrade/', task_manage.TaskManage.as_view()),
path('task_manager/tasks', task_manage.TaskManage.as_view()),
path('task_manager/schools', task_manage.SearchSchool.as_view()),
path('analysis_page/posts_data', analysis_page.GetData.as_view()),
path('analysis_page/users_analysis_data', analysis_page.GetUserAnalyseData.as_view()),
path('analysis_page/posts_analysis_data', analysis_page.GetPostsAnalysisData.as_view())
]
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
6738,
42625,
14208,
13,
6371,
82,
1330,
3108,
198,
6738,
764,
33571,
1330,
17594,
62,
30238,
11,
4876,
62,
805,
496,
11,
3781,
62,
7700,
198,
6371,
33279,
82,
796,
685,
198,
220,
220,
220,
3108,
10786,
38235,
14,
3256,
17594,
62,
30238,
13,
47790,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
30238,
14,
3256,
17594,
62,
30238,
13,
11712,
818,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
30238,
14,
9122,
62,
29460,
3256,
17594,
62,
30238,
13,
11712,
818,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
2860,
653,
14,
3256,
4876,
62,
805,
496,
13,
25714,
5124,
496,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
2787,
5165,
14,
3256,
4876,
62,
805,
496,
13,
25714,
5124,
496,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
260,
9631,
278,
14,
3256,
4876,
62,
805,
496,
13,
6690,
2502,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
929,
9526,
14,
3256,
4876,
62,
805,
496,
13,
25714,
5124,
496,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
83,
6791,
3256,
4876,
62,
805,
496,
13,
25714,
5124,
496,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
35943,
62,
37153,
14,
14347,
82,
3256,
4876,
62,
805,
496,
13,
18243,
26130,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
20930,
62,
7700,
14,
24875,
62,
7890,
3256,
3781,
62,
7700,
13,
3855,
6601,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
20930,
62,
7700,
14,
18417,
62,
20930,
62,
7890,
3256,
3781,
62,
7700,
13,
3855,
12982,
37702,
325,
6601,
13,
292,
62,
1177,
3419,
828,
198,
220,
220,
220,
3108,
10786,
20930,
62,
7700,
14,
24875,
62,
20930,
62,
7890,
3256,
3781,
62,
7700,
13,
3855,
21496,
32750,
6601,
13,
292,
62,
1177,
28955,
198,
60,
198
] | 2.683646 | 373 |
from django.conf import settings
from django.conf.urls import url, include
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from main import views
from django.contrib.auth import views as auth_views
from django.views.static import serve
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^$', views.index, name="home"),
url("^music/", include("audiotracks.urls")),
url("^(?P<username>[\w\._-]+)/music/", include("audiotracks.urls")),
url(r'^login$', auth_views.login, name="login"),
url(r'^logout$', auth_views.logout, name="logout"),
url(r'^admin/', include(admin.site.urls)),
]
if settings.DEBUG:
urlpatterns += [
url(r'^site_media/(?P<path>.*)$', serve, {
'document_root': settings.MEDIA_ROOT
})
]
urlpatterns += staticfiles_urlpatterns()
| [
6738,
42625,
14208,
13,
10414,
1330,
6460,
198,
6738,
42625,
14208,
13,
10414,
13,
6371,
82,
1330,
19016,
11,
2291,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
12708,
16624,
13,
6371,
82,
1330,
9037,
16624,
62,
6371,
33279,
82,
198,
6738,
1388,
1330,
5009,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
1330,
5009,
355,
6284,
62,
33571,
198,
6738,
42625,
14208,
13,
33571,
13,
12708,
1330,
4691,
198,
198,
2,
791,
23893,
262,
1306,
734,
3951,
284,
7139,
262,
13169,
25,
198,
6738,
42625,
14208,
13,
3642,
822,
1330,
13169,
198,
28482,
13,
2306,
375,
29392,
3419,
198,
198,
6371,
33279,
82,
796,
685,
198,
220,
220,
220,
19016,
7,
81,
6,
61,
3,
3256,
5009,
13,
9630,
11,
1438,
2625,
11195,
12340,
198,
220,
220,
220,
19016,
7203,
61,
28965,
14,
1600,
2291,
7203,
3885,
5151,
81,
4595,
13,
6371,
82,
4943,
828,
198,
220,
220,
220,
19016,
7203,
61,
7,
30,
47,
27,
29460,
36937,
59,
86,
59,
13557,
12,
48688,
20679,
28965,
14,
1600,
2291,
7203,
3885,
5151,
81,
4595,
13,
6371,
82,
4943,
828,
198,
220,
220,
220,
19016,
7,
81,
6,
61,
38235,
3,
3256,
6284,
62,
33571,
13,
38235,
11,
1438,
2625,
38235,
12340,
198,
220,
220,
220,
19016,
7,
81,
6,
61,
6404,
448,
3,
3256,
6284,
62,
33571,
13,
6404,
448,
11,
1438,
2625,
6404,
448,
12340,
198,
220,
220,
220,
19016,
7,
81,
6,
61,
28482,
14,
3256,
2291,
7,
28482,
13,
15654,
13,
6371,
82,
36911,
198,
60,
198,
198,
361,
6460,
13,
30531,
25,
198,
220,
220,
220,
19016,
33279,
82,
15853,
685,
198,
220,
220,
220,
220,
220,
220,
220,
19016,
7,
81,
6,
61,
15654,
62,
11431,
29006,
30,
47,
27,
6978,
29,
15885,
8,
3,
3256,
4691,
11,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
22897,
62,
15763,
10354,
6460,
13,
30733,
3539,
62,
13252,
2394,
198,
220,
220,
220,
220,
220,
220,
220,
32092,
198,
220,
220,
220,
2361,
198,
220,
220,
220,
19016,
33279,
82,
15853,
9037,
16624,
62,
6371,
33279,
82,
3419,
198
] | 2.585714 | 350 |
from mathbox.statistics.estimator import mean, std
# Generalized ESD Test for Outliers
# https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h3.htm | [
6738,
10688,
3524,
13,
14269,
3969,
13,
395,
320,
1352,
1330,
1612,
11,
14367,
198,
198,
2,
3611,
1143,
412,
10305,
6208,
329,
3806,
75,
3183,
198,
2,
3740,
1378,
2503,
13,
270,
75,
13,
77,
396,
13,
9567,
14,
7146,
23,
4089,
14,
4993,
2070,
14,
18082,
14,
5458,
18,
14,
18082,
2327,
71,
18,
13,
19211
] | 2.672414 | 58 |
#!/usr/bin/python
from requirement import *
from producer import producer
from scheduler import fcfs
from teller import teller
txt = open('result/processes','w')
txt.write('Processes\n\n')
#Thread(target = producer).start()
producer()
for process in processes:
txt.write(str(process)+'\n')
for i in range(teller_count):
tellers.append( teller() )
a = fcfs(processes,tellers)
txt.close()
| [
2,
48443,
14629,
14,
8800,
14,
29412,
198,
198,
6738,
9079,
1330,
1635,
198,
6738,
9920,
1330,
9920,
198,
6738,
6038,
18173,
1330,
277,
66,
9501,
198,
6738,
1560,
263,
1330,
1560,
263,
628,
198,
14116,
796,
1280,
10786,
20274,
14,
14681,
274,
41707,
86,
11537,
198,
14116,
13,
13564,
10786,
18709,
274,
59,
77,
59,
77,
11537,
198,
198,
2,
16818,
7,
16793,
796,
9920,
737,
9688,
3419,
198,
18230,
2189,
3419,
198,
198,
1640,
1429,
287,
7767,
25,
198,
197,
14116,
13,
13564,
7,
2536,
7,
14681,
47762,
6,
59,
77,
11537,
198,
198,
1640,
1312,
287,
2837,
7,
660,
6051,
62,
9127,
2599,
198,
197,
660,
13802,
13,
33295,
7,
1560,
263,
3419,
1267,
198,
198,
64,
796,
277,
66,
9501,
7,
14681,
274,
11,
660,
13802,
8,
198,
198,
14116,
13,
19836,
3419,
198
] | 2.876812 | 138 |
from floem import *
n_cores = 2
Enq, Deq, Release = queue.queue_custom('queue', Tuple, 4, n_cores, Tuple.task, enq_output=True)
RxWrite('mysend')
RxPrint('process')
c = Compiler()
c.testing = r'''
Tuple tuples[5];
for(int i=0; i<5;i++) {
tuples[i].task = 10;
tuples[i].val = i;
}
for(int i=0; i<5;i++) {
mysend(&tuples[i], 0);
process(0);
}
for(int i=0; i<5;i++) {
tuples[i].val = 100 + i;
mysend(&tuples[i], 1);
tuples[i].task = 0;
}
for(int i=0; i<5;i++) {
process(1);
}
'''
c.generate_code_and_run([0,0,-1,1,-2,2,-3,3,-4,4,-100,-101,-102,-103,-104,100,101,102,103]) | [
6738,
5530,
368,
1330,
1635,
198,
198,
77,
62,
66,
2850,
796,
362,
628,
198,
4834,
80,
11,
1024,
80,
11,
13868,
796,
16834,
13,
36560,
62,
23144,
10786,
36560,
3256,
309,
29291,
11,
604,
11,
299,
62,
66,
2850,
11,
309,
29291,
13,
35943,
11,
551,
80,
62,
22915,
28,
17821,
8,
628,
198,
49,
87,
16594,
10786,
28744,
437,
11537,
198,
49,
87,
18557,
10786,
14681,
11537,
198,
198,
66,
796,
3082,
5329,
3419,
198,
66,
13,
33407,
796,
374,
7061,
6,
198,
51,
29291,
12777,
2374,
58,
20,
11208,
198,
1640,
7,
600,
1312,
28,
15,
26,
1312,
27,
20,
26,
72,
29577,
1391,
198,
220,
220,
220,
12777,
2374,
58,
72,
4083,
35943,
796,
838,
26,
198,
220,
220,
220,
12777,
2374,
58,
72,
4083,
2100,
796,
1312,
26,
198,
92,
198,
198,
1640,
7,
600,
1312,
28,
15,
26,
1312,
27,
20,
26,
72,
29577,
1391,
198,
220,
220,
220,
616,
21280,
39434,
28047,
2374,
58,
72,
4357,
657,
1776,
198,
220,
220,
220,
1429,
7,
15,
1776,
198,
92,
198,
198,
1640,
7,
600,
1312,
28,
15,
26,
1312,
27,
20,
26,
72,
29577,
1391,
198,
220,
220,
220,
12777,
2374,
58,
72,
4083,
2100,
796,
1802,
1343,
1312,
26,
198,
220,
220,
220,
616,
21280,
39434,
28047,
2374,
58,
72,
4357,
352,
1776,
198,
220,
220,
220,
12777,
2374,
58,
72,
4083,
35943,
796,
657,
26,
198,
92,
198,
198,
1640,
7,
600,
1312,
28,
15,
26,
1312,
27,
20,
26,
72,
29577,
1391,
198,
220,
220,
220,
1429,
7,
16,
1776,
198,
92,
198,
7061,
6,
198,
66,
13,
8612,
378,
62,
8189,
62,
392,
62,
5143,
26933,
15,
11,
15,
12095,
16,
11,
16,
12095,
17,
11,
17,
12095,
18,
11,
18,
12095,
19,
11,
19,
12095,
3064,
12095,
8784,
12095,
15377,
12095,
15197,
12095,
13464,
11,
3064,
11,
8784,
11,
15377,
11,
15197,
12962
] | 1.93949 | 314 |
# -*- coding: utf-8 -*-
#
# Electrum-NMC - lightweight Namecoin client
# Copyright (C) 2018 The Namecoin developers
#
# License for all components not part of Electrum-DOGE:
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Based on Electrum-DOGE - lightweight Dogecoin client
# Copyright (C) 2014 The Electrum-DOGE contributors
#
# License for the Electrum-DOGE components:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import binascii
from .bitcoin import hash_encode, hash_decode
from .crypto import sha256d
from . import blockchain, constants, transaction
from .transaction import BCDataStream, Transaction, TxOutput, TYPE_SCRIPT
from .util import bfh, bh2u
# Maximum index of the merkle root hash in the coinbase transaction script,
# where no merged mining header is present.
MAX_INDEX_PC_BACKWARDS_COMPATIBILITY = 20
# Header for merge-mining data in the coinbase.
COINBASE_MERGED_MINING_HEADER = bfh('fabe') + b'mm'
def deserialize_auxpow_header(base_header, s, start_position=0) -> (dict, int):
"""Deserialises an AuxPoW instance.
Returns the deserialised AuxPoW dict and the end position in the byte
array as a pair."""
auxpow_header = {}
# Chain ID is the top 16 bits of the 32-bit version.
auxpow_header['chain_id'] = get_chain_id(base_header)
# The parent coinbase transaction is first.
# Deserialize it and save the trailing data.
parent_coinbase_tx = Transaction(s, expect_trailing_data=True, copy_input=False, start_position=start_position)
parent_coinbase_tx._allow_zero_outputs = True
start_position = fast_tx_deserialize(parent_coinbase_tx)
auxpow_header['parent_coinbase_tx'] = parent_coinbase_tx
# Next is the parent block hash. According to the Bitcoin.it wiki,
# this field is not actually consensus-critical. So we don't save it.
start_position = start_position + 32
# The coinbase and chain merkle branches/indices are next.
# Deserialize them and save the trailing data.
auxpow_header['coinbase_merkle_branch'], auxpow_header['coinbase_merkle_index'], start_position = deserialize_merkle_branch(s, start_position=start_position)
auxpow_header['chain_merkle_branch'], auxpow_header['chain_merkle_index'], start_position = deserialize_merkle_branch(s, start_position=start_position)
# Finally there's the parent header. Deserialize it.
parent_header_bytes = s[start_position : start_position + constants.net.HEADER_SIZE]
auxpow_header['parent_header'] = blockchain.deserialize_pure_header(parent_header_bytes, None)
start_position += constants.net.HEADER_SIZE
# The parent block header doesn't have any block height,
# so delete that field. (We used None as a dummy value above.)
del auxpow_header['parent_header']['block_height']
return auxpow_header, start_position
# Copied from merkle_branch_from_string in https://github.com/electrumalt/electrum-doge/blob/f74312822a14f59aa8d50186baff74cade449ccd/lib/blockchain.py#L622
# Returns list of hashes, merkle index, and position of trailing data in s
# TODO: Audit this function carefully.
# Reimplementation of btcutils.check_merkle_branch from Electrum-DOGE.
# btcutils seems to have an unclear license and no obvious Git repo, so it
# seemed wiser to re-implement.
# This re-implementation is roughly based on libdohj's calculateMerkleRoot.
# Copied from Electrum-DOGE
# TODO: Audit this function carefully.
# https://github.com/kR105/i0coin/compare/bitcoin:master...master#diff-610df86e65fce009eb271c2a4f7394ccR262
# Copied from Electrum-DOGE
# TODO: Audit this function carefully.
# This is calculated the same as the Transaction.txid() method, but doesn't
# reserialize it.
# Used by fast_tx_deserialize
# This is equivalent to (tx.deserialize(), ), but doesn't parse outputs. | [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
2,
198,
2,
5903,
6582,
12,
45,
9655,
532,
18700,
6530,
3630,
5456,
198,
2,
15069,
357,
34,
8,
2864,
383,
6530,
3630,
6505,
198,
2,
198,
2,
13789,
329,
477,
6805,
407,
636,
286,
5903,
6582,
12,
35,
7730,
36,
25,
198,
2,
198,
2,
2448,
3411,
318,
29376,
7520,
11,
1479,
286,
3877,
11,
284,
597,
1048,
198,
2,
16727,
257,
4866,
286,
428,
3788,
290,
3917,
10314,
3696,
198,
2,
357,
1169,
366,
25423,
12340,
284,
1730,
287,
262,
10442,
1231,
17504,
11,
198,
2,
1390,
1231,
17385,
262,
2489,
284,
779,
11,
4866,
11,
13096,
11,
20121,
11,
198,
2,
7715,
11,
14983,
11,
850,
43085,
11,
290,
14,
273,
3677,
9088,
286,
262,
10442,
11,
198,
2,
290,
284,
8749,
6506,
284,
4150,
262,
10442,
318,
30760,
284,
466,
523,
11,
198,
2,
2426,
284,
262,
1708,
3403,
25,
198,
2,
198,
2,
383,
2029,
6634,
4003,
290,
428,
7170,
4003,
2236,
307,
198,
2,
3017,
287,
477,
9088,
393,
8904,
16690,
286,
262,
10442,
13,
198,
2,
198,
2,
3336,
47466,
3180,
36592,
2389,
1961,
366,
1921,
3180,
1600,
42881,
34764,
56,
3963,
15529,
509,
12115,
11,
198,
2,
7788,
32761,
6375,
8959,
49094,
11,
47783,
2751,
21728,
5626,
40880,
5390,
3336,
34764,
11015,
3963,
198,
2,
34482,
3398,
1565,
5603,
25382,
11,
376,
46144,
7473,
317,
16652,
2149,
37232,
33079,
48933,
5357,
198,
2,
44521,
1268,
10913,
2751,
12529,
13,
3268,
8005,
49261,
50163,
3336,
37195,
20673,
6375,
27975,
38162,
9947,
367,
15173,
4877,
198,
2,
9348,
43031,
19146,
7473,
15529,
47666,
3955,
11,
29506,
25552,
6375,
25401,
43031,
25382,
11,
7655,
2767,
16879,
3268,
3537,
198,
2,
40282,
3963,
27342,
10659,
11,
309,
9863,
6375,
25401,
54,
24352,
11,
5923,
1797,
2751,
16034,
11,
16289,
3963,
6375,
3268,
198,
2,
7102,
45,
24565,
13315,
3336,
47466,
6375,
3336,
23210,
6375,
25401,
5550,
1847,
20754,
3268,
3336,
198,
2,
47466,
13,
198,
2,
198,
2,
13403,
319,
5903,
6582,
12,
35,
7730,
36,
532,
18700,
2141,
469,
3630,
5456,
198,
2,
15069,
357,
34,
8,
1946,
383,
5903,
6582,
12,
35,
7730,
36,
20420,
198,
2,
198,
2,
13789,
329,
262,
5903,
6582,
12,
35,
7730,
36,
6805,
25,
198,
2,
198,
2,
770,
1430,
318,
1479,
3788,
25,
345,
460,
17678,
4163,
340,
290,
14,
273,
13096,
198,
2,
340,
739,
262,
2846,
286,
262,
22961,
3611,
5094,
13789,
355,
3199,
416,
198,
2,
262,
3232,
10442,
5693,
11,
2035,
2196,
513,
286,
262,
13789,
11,
393,
198,
2,
357,
265,
534,
3038,
8,
597,
1568,
2196,
13,
198,
2,
198,
2,
770,
1430,
318,
9387,
287,
262,
2911,
326,
340,
481,
307,
4465,
11,
198,
2,
475,
42881,
15529,
34764,
56,
26,
1231,
772,
262,
17142,
18215,
286,
198,
2,
34482,
3398,
1565,
5603,
25382,
393,
376,
46144,
7473,
317,
16652,
2149,
37232,
33079,
48933,
13,
4091,
262,
198,
2,
22961,
3611,
5094,
13789,
329,
517,
3307,
13,
198,
2,
198,
2,
921,
815,
423,
2722,
257,
4866,
286,
262,
22961,
3611,
5094,
13789,
198,
2,
1863,
351,
428,
1430,
13,
1002,
407,
11,
766,
1279,
4023,
1378,
2503,
13,
41791,
13,
2398,
14,
677,
4541,
15913,
13,
198,
198,
11748,
9874,
292,
979,
72,
198,
198,
6738,
764,
35395,
1330,
12234,
62,
268,
8189,
11,
12234,
62,
12501,
1098,
198,
6738,
764,
29609,
78,
1330,
427,
64,
11645,
67,
198,
6738,
764,
1330,
11779,
11,
38491,
11,
8611,
198,
6738,
764,
7645,
2673,
1330,
11843,
6601,
12124,
11,
45389,
11,
309,
87,
26410,
11,
41876,
62,
6173,
46023,
198,
6738,
764,
22602,
1330,
275,
69,
71,
11,
275,
71,
17,
84,
198,
198,
2,
22246,
6376,
286,
262,
4017,
74,
293,
6808,
12234,
287,
262,
10752,
8692,
8611,
4226,
11,
198,
2,
810,
645,
23791,
9691,
13639,
318,
1944,
13,
198,
22921,
62,
12115,
6369,
62,
5662,
62,
31098,
16279,
5258,
62,
9858,
47,
1404,
40,
25382,
796,
1160,
198,
198,
2,
48900,
329,
20121,
12,
45374,
1366,
287,
262,
10752,
8692,
13,
198,
8220,
1268,
33,
11159,
62,
29296,
38,
1961,
62,
23678,
2751,
62,
37682,
1137,
796,
275,
69,
71,
10786,
69,
11231,
11537,
1343,
275,
1101,
76,
6,
198,
198,
4299,
748,
48499,
1096,
62,
14644,
79,
322,
62,
25677,
7,
8692,
62,
25677,
11,
264,
11,
923,
62,
9150,
28,
15,
8,
4613,
357,
11600,
11,
493,
2599,
198,
220,
220,
220,
37227,
5960,
48499,
2696,
281,
47105,
18833,
54,
4554,
13,
628,
220,
220,
220,
16409,
262,
748,
48499,
1417,
47105,
18833,
54,
8633,
290,
262,
886,
2292,
287,
262,
18022,
198,
220,
220,
220,
7177,
355,
257,
5166,
526,
15931,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
796,
23884,
628,
220,
220,
220,
1303,
21853,
4522,
318,
262,
1353,
1467,
10340,
286,
262,
3933,
12,
2545,
2196,
13,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
17816,
7983,
62,
312,
20520,
796,
651,
62,
7983,
62,
312,
7,
8692,
62,
25677,
8,
628,
220,
220,
220,
1303,
383,
2560,
10752,
8692,
8611,
318,
717,
13,
198,
220,
220,
220,
1303,
2935,
48499,
1096,
340,
290,
3613,
262,
25462,
1366,
13,
198,
220,
220,
220,
2560,
62,
3630,
8692,
62,
17602,
796,
45389,
7,
82,
11,
1607,
62,
9535,
4386,
62,
7890,
28,
17821,
11,
4866,
62,
15414,
28,
25101,
11,
923,
62,
9150,
28,
9688,
62,
9150,
8,
198,
220,
220,
220,
2560,
62,
3630,
8692,
62,
17602,
13557,
12154,
62,
22570,
62,
22915,
82,
796,
6407,
198,
220,
220,
220,
923,
62,
9150,
796,
3049,
62,
17602,
62,
8906,
48499,
1096,
7,
8000,
62,
3630,
8692,
62,
17602,
8,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
17816,
8000,
62,
3630,
8692,
62,
17602,
20520,
796,
2560,
62,
3630,
8692,
62,
17602,
628,
220,
220,
220,
1303,
7406,
318,
262,
2560,
2512,
12234,
13,
220,
4784,
284,
262,
6185,
13,
270,
22719,
11,
198,
220,
220,
220,
1303,
428,
2214,
318,
407,
1682,
11529,
12,
34666,
13,
220,
1406,
356,
836,
470,
3613,
340,
13,
198,
220,
220,
220,
923,
62,
9150,
796,
923,
62,
9150,
1343,
3933,
628,
220,
220,
220,
1303,
383,
10752,
8692,
290,
6333,
4017,
74,
293,
13737,
14,
521,
1063,
389,
1306,
13,
198,
220,
220,
220,
1303,
2935,
48499,
1096,
606,
290,
3613,
262,
25462,
1366,
13,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
17816,
3630,
8692,
62,
647,
74,
293,
62,
1671,
3702,
6,
4357,
27506,
79,
322,
62,
25677,
17816,
3630,
8692,
62,
647,
74,
293,
62,
9630,
6,
4357,
923,
62,
9150,
796,
748,
48499,
1096,
62,
647,
74,
293,
62,
1671,
3702,
7,
82,
11,
923,
62,
9150,
28,
9688,
62,
9150,
8,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
17816,
7983,
62,
647,
74,
293,
62,
1671,
3702,
6,
4357,
27506,
79,
322,
62,
25677,
17816,
7983,
62,
647,
74,
293,
62,
9630,
6,
4357,
923,
62,
9150,
796,
748,
48499,
1096,
62,
647,
74,
293,
62,
1671,
3702,
7,
82,
11,
923,
62,
9150,
28,
9688,
62,
9150,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1303,
9461,
612,
338,
262,
2560,
13639,
13,
220,
2935,
48499,
1096,
340,
13,
198,
220,
220,
220,
2560,
62,
25677,
62,
33661,
796,
264,
58,
9688,
62,
9150,
1058,
923,
62,
9150,
1343,
38491,
13,
3262,
13,
37682,
1137,
62,
33489,
60,
198,
220,
220,
220,
27506,
79,
322,
62,
25677,
17816,
8000,
62,
25677,
20520,
796,
11779,
13,
8906,
48499,
1096,
62,
37424,
62,
25677,
7,
8000,
62,
25677,
62,
33661,
11,
6045,
8,
198,
220,
220,
220,
923,
62,
9150,
15853,
38491,
13,
3262,
13,
37682,
1137,
62,
33489,
198,
220,
220,
220,
1303,
383,
2560,
2512,
13639,
1595,
470,
423,
597,
2512,
6001,
11,
198,
220,
220,
220,
1303,
523,
12233,
326,
2214,
13,
220,
357,
1135,
973,
6045,
355,
257,
31548,
1988,
2029,
2014,
198,
220,
220,
220,
1619,
27506,
79,
322,
62,
25677,
17816,
8000,
62,
25677,
6,
7131,
6,
9967,
62,
17015,
20520,
628,
220,
220,
220,
1441,
27506,
79,
322,
62,
25677,
11,
923,
62,
9150,
198,
198,
2,
6955,
798,
422,
4017,
74,
293,
62,
1671,
3702,
62,
6738,
62,
8841,
287,
3740,
1378,
12567,
13,
785,
14,
9509,
6582,
2501,
14,
9509,
6582,
12,
4598,
469,
14,
2436,
672,
14,
69,
22,
3559,
12762,
1828,
64,
1415,
69,
3270,
7252,
23,
67,
33548,
4521,
65,
2001,
4524,
46395,
31911,
535,
67,
14,
8019,
14,
9967,
7983,
13,
9078,
2,
43,
21,
1828,
198,
2,
16409,
1351,
286,
46621,
11,
4017,
74,
293,
6376,
11,
290,
2292,
286,
25462,
1366,
287,
264,
198,
2,
16926,
46,
25,
46450,
428,
2163,
7773,
13,
198,
198,
2,
797,
320,
32851,
286,
275,
83,
8968,
4487,
13,
9122,
62,
647,
74,
293,
62,
1671,
3702,
422,
5903,
6582,
12,
35,
7730,
36,
13,
198,
2,
275,
83,
8968,
4487,
2331,
284,
423,
281,
10061,
5964,
290,
645,
3489,
15151,
29924,
11,
523,
340,
198,
2,
3947,
47897,
284,
302,
12,
320,
26908,
13,
198,
2,
770,
302,
12,
320,
32851,
318,
7323,
1912,
319,
9195,
67,
1219,
73,
338,
15284,
44,
9587,
293,
30016,
13,
198,
198,
2,
6955,
798,
422,
5903,
6582,
12,
35,
7730,
36,
198,
2,
16926,
46,
25,
46450,
428,
2163,
7773,
13,
198,
2,
3740,
1378,
12567,
13,
785,
14,
74,
49,
13348,
14,
72,
15,
3630,
14,
5589,
533,
14,
35395,
25,
9866,
986,
9866,
2,
26069,
12,
39132,
7568,
4521,
68,
2996,
69,
344,
28694,
1765,
28977,
66,
17,
64,
19,
69,
22,
34626,
535,
49,
29119,
198,
198,
2,
6955,
798,
422,
5903,
6582,
12,
35,
7730,
36,
198,
2,
16926,
46,
25,
46450,
428,
2163,
7773,
13,
198,
198,
2,
770,
318,
10488,
262,
976,
355,
262,
45389,
13,
17602,
312,
3419,
2446,
11,
475,
1595,
470,
198,
2,
581,
48499,
1096,
340,
13,
198,
198,
2,
16718,
416,
3049,
62,
17602,
62,
8906,
48499,
1096,
198,
198,
2,
770,
318,
7548,
284,
357,
17602,
13,
8906,
48499,
1096,
22784,
10612,
475,
1595,
470,
21136,
23862,
13
] | 3.208209 | 1,681 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
def extract(file=None, path=None):
"""
Extract all of the YouTube links within a Headset user-made list.
:param file: headset json export file path
:param path: json path to extract, you can use [JSON Columns](http://json-columns.com) to get it
:return: `list` containing all of the links in the list
"""
if not file or not path:
print('error: file or json path not provided...')
return None
# todo: implement
pass
if __name__ == '__main__':
extract()
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
198,
11748,
25064,
628,
198,
4299,
7925,
7,
7753,
28,
14202,
11,
3108,
28,
14202,
2599,
198,
220,
37227,
198,
220,
29677,
477,
286,
262,
7444,
6117,
1626,
257,
7123,
2617,
2836,
12,
9727,
1351,
13,
628,
220,
1058,
17143,
2393,
25,
23492,
33918,
10784,
2393,
3108,
198,
220,
1058,
17143,
3108,
25,
33918,
3108,
284,
7925,
11,
345,
460,
779,
685,
40386,
29201,
82,
16151,
4023,
1378,
17752,
12,
28665,
82,
13,
785,
8,
284,
651,
340,
198,
220,
1058,
7783,
25,
4600,
4868,
63,
7268,
477,
286,
262,
6117,
287,
262,
1351,
198,
220,
37227,
198,
220,
611,
407,
2393,
393,
407,
3108,
25,
198,
220,
220,
220,
3601,
10786,
18224,
25,
2393,
393,
33918,
3108,
407,
2810,
986,
11537,
198,
220,
220,
220,
1441,
6045,
628,
220,
1303,
284,
4598,
25,
3494,
198,
220,
1208,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
7925,
3419,
198
] | 3.044693 | 179 |
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import login, authenticate
from django.contrib.auth.models import User
from django.http import JsonResponse
####################
# IMPORT OTHER LIBS
####################
import os
import numpy as np
import seaborn as sns
import cv2
from heatmappy import Heatmapper
from heatmappy.video import VideoHeatmapper
from PIL import Image
import moviepy.editor as mp
import urllib
import glob
import pandas as pd
from pathlib import Path
import shutil
import vimeo_dl as vimeo
import plotly.express as px
import plotly
import plotly.graph_objects as go
from .models import Video, VideoStat
EMOTIONS = [
'angry',
'disgusted',
'fearful',
'happy',
'neutral',
'sad',
'surprised'
]
# # Create your views here.
# def index(request):
# return render(request, 'index.html')
heatmap_points = []
def index(request):
'''
Renders login + main page
'''
global user
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
# if user is authentificated
data = Video.objects.all()
response_data = {
"video_data": data,
"name" : username,
"is_staff": user.is_staff,
}
return render(request, 'main.html', response_data)
return render(request, 'index.html')
else:
form = UserCreationForm()
return render(request, 'index.html', {'form': form})
def video(request, video_id):
'''
Renders video page
'''
global video
video = list(Video.objects.all())[video_id-1]
VideoStat.objects.filter(video_link= video.video_link, user_id= user.username).delete()
response_data = {
"name" : user.username,
"video_name": video.video_name,
"video_link": video.video_link,
"is_staff": user.is_staff
}
return render(request, 'video.html', response_data)
def recievePoints(request):
'''
Recieves gaze points via ajax request
'''
x, y = request.GET['x'], request.GET['y']
time = request.GET['time']
width, height = request.GET['width'], request.GET['height']
username = request.GET['username']
try:
expressions = urllib.parse.unquote(request.GET['expressions']).split(';')
expressions = list(map(float, expressions))
except:
expressions = []
try:
emotion = EMOTIONS[np.argmax(expressions)]
except:
emotion = 'None'
try:
x, y, time = int(float(x)), int(float(y)), int(float(time))
except:
x, y = 0, 0
try:
width, height = int(width), int(height)
except:
width, height = 0, 0
VideoStat.objects.create(video_link= video.video_link, user_id= user.username, timestamp = time, emotions=emotion, coordinates=f'{x}:{y}', screen_width=width, screen_height=height)
return JsonResponse({'ok': True})
def exportStats(request):
'''
Recieves export request via ajax
'''
# get video data
entries = VideoStat.objects.filter(video_link=video.video_link)
DOWNLOAD_PATH = Path('viewer/static/downloads') / video.video_link
try:
os.mkdir(DOWNLOAD_PATH)
except:
pass
video_data = vimeo.new(f'https://vimeo.com/{video.video_link}')
video_data.streams[0].download(quiet=False)
video_width, video_height = str(video_data.streams[0]).split('@')[-1].split('x')
video_width, video_height = int(video_width), int(video_height)
# get video db entries
heatmap_points = []
emotion_points = []
for e in entries:
x,y = list(map(int, e.coordinates.split(':')))
time = int(e.timestamp)
x *= video_width / int(e.screen_width)
y *= video_height / int(e.screen_height)
heatmap_points.append([x,y, time])
emotion_points.append([e.user_id, time//5000, e.emotions])
emotions = pd.DataFrame(emotion_points)
emotions.columns = ['user_name', 'timestamp', 'emotion']
emotion_counts = []
for (ts, item) in emotions.groupby('timestamp'):
COUNTER = {
'timestamp': item['timestamp'].iloc[0] * 5,
'angry': 0,
'disgusted': 0,
'fearful': 0,
'happy': 0,
'neutral': 0,
'sad': 0,
'surprised': 0,
'None': 0
}
for index, count in item['emotion'].value_counts().items():
COUNTER[index] = count
emotion_counts.append(COUNTER.values())
emotion_counts = pd.DataFrame(emotion_counts)
emotion_counts.columns = COUNTER.keys()
emotion_counts.to_csv(DOWNLOAD_PATH / 'out.csv', index = None)
heatmapper = Heatmapper(point_strength=0.6, opacity=0.8)
video_heatmapper = VideoHeatmapper(heatmapper)
heatmap_video = video_heatmapper.heatmap_on_video_path(
video_path=f'{video_data.title}.mp4',
points=heatmap_points
)
heatmap_video.write_videofile(str(DOWNLOAD_PATH / 'out.mp4'), bitrate="500k", fps=24)
mp4_files = glob.glob(str('*.mp4'))
for f in mp4_files:
if f != 'out.mp4':
os.remove(f)
shutil.make_archive(str(DOWNLOAD_PATH), 'zip', str(DOWNLOAD_PATH))
shutil.rmtree(str(DOWNLOAD_PATH))
# time based graph
fig = px.line(emotion_counts, x="timestamp", y=emotion_counts.columns[1:])
fig = plotly.graph_objs.Figure(fig.data, fig.layout)
fig_json_1 = fig.to_json()
# pie chart
labels, counts = list(emotions['emotion'].value_counts().index), list(emotions['emotion'].value_counts().values)
fig = go.Figure(data=[go.Pie(labels=labels, values=counts)])
fig_json_2 = fig.to_json()
return JsonResponse({'ok': True, 'plotly_graph_1': fig_json_1, 'plotly_graph_2': fig_json_2})
| [
6738,
42625,
14208,
13,
19509,
23779,
1330,
8543,
198,
6738,
42625,
14208,
13,
4023,
1330,
367,
29281,
31077,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
23914,
1330,
11787,
12443,
341,
8479,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
1330,
17594,
11,
8323,
5344,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
27530,
1330,
11787,
198,
6738,
42625,
14208,
13,
4023,
1330,
449,
1559,
31077,
628,
198,
14468,
4242,
198,
2,
30023,
9863,
25401,
24653,
4462,
198,
14468,
4242,
198,
11748,
28686,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
384,
397,
1211,
355,
3013,
82,
198,
11748,
269,
85,
17,
198,
6738,
4894,
76,
7774,
1330,
12308,
76,
11463,
198,
6738,
4894,
76,
7774,
13,
15588,
1330,
7623,
39596,
76,
11463,
198,
6738,
350,
4146,
1330,
7412,
198,
11748,
3807,
9078,
13,
35352,
355,
29034,
198,
11748,
2956,
297,
571,
198,
11748,
15095,
198,
11748,
19798,
292,
355,
279,
67,
198,
6738,
3108,
8019,
1330,
10644,
198,
11748,
4423,
346,
198,
11748,
410,
47776,
62,
25404,
355,
410,
47776,
198,
11748,
7110,
306,
13,
42712,
355,
279,
87,
198,
11748,
7110,
306,
198,
11748,
7110,
306,
13,
34960,
62,
48205,
355,
467,
198,
198,
6738,
764,
27530,
1330,
7623,
11,
7623,
17126,
198,
198,
3620,
2394,
11053,
796,
685,
198,
220,
220,
220,
705,
648,
563,
3256,
220,
198,
220,
220,
220,
705,
6381,
70,
8459,
3256,
220,
198,
220,
220,
220,
705,
69,
451,
913,
3256,
220,
198,
220,
220,
220,
705,
34191,
3256,
220,
198,
220,
220,
220,
705,
29797,
3256,
220,
198,
220,
220,
220,
705,
82,
324,
3256,
220,
198,
220,
220,
220,
705,
11793,
1050,
1417,
6,
198,
60,
198,
198,
2,
1303,
13610,
534,
5009,
994,
13,
198,
2,
825,
6376,
7,
25927,
2599,
198,
2,
220,
220,
220,
220,
1441,
8543,
7,
25927,
11,
705,
9630,
13,
6494,
11537,
198,
198,
25080,
8899,
62,
13033,
796,
17635,
198,
4299,
6376,
7,
25927,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
371,
7338,
17594,
1343,
1388,
2443,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
3298,
2836,
198,
220,
220,
220,
611,
2581,
13,
24396,
6624,
705,
32782,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
20579,
796,
2581,
13,
32782,
17816,
29460,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
9206,
796,
2581,
13,
32782,
17816,
28712,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
2836,
796,
8323,
5344,
7,
29460,
28,
29460,
11,
9206,
28,
28712,
8,
628,
220,
220,
220,
220,
220,
220,
220,
611,
2836,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
611,
2836,
318,
8323,
811,
515,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
7623,
13,
48205,
13,
439,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2882,
62,
7890,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15588,
62,
7890,
1298,
1366,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
3672,
1,
1058,
20579,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
271,
62,
28120,
1298,
2836,
13,
271,
62,
28120,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
8543,
7,
25927,
11,
705,
12417,
13,
6494,
3256,
2882,
62,
7890,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
8543,
7,
25927,
11,
705,
9630,
13,
6494,
11537,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1296,
796,
11787,
12443,
341,
8479,
3419,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1441,
8543,
7,
25927,
11,
705,
9630,
13,
6494,
3256,
1391,
6,
687,
10354,
1296,
30072,
628,
198,
4299,
2008,
7,
25927,
11,
2008,
62,
312,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
371,
7338,
2008,
2443,
198,
220,
220,
220,
705,
7061,
628,
220,
220,
220,
3298,
2008,
198,
220,
220,
220,
2008,
796,
1351,
7,
10798,
13,
48205,
13,
439,
28955,
58,
15588,
62,
312,
12,
16,
60,
628,
220,
220,
220,
7623,
17126,
13,
48205,
13,
24455,
7,
15588,
62,
8726,
28,
2008,
13,
15588,
62,
8726,
11,
2836,
62,
312,
28,
2836,
13,
29460,
737,
33678,
3419,
628,
220,
220,
220,
2882,
62,
7890,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
3672,
1,
1058,
2836,
13,
29460,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15588,
62,
3672,
1298,
2008,
13,
15588,
62,
3672,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15588,
62,
8726,
1298,
2008,
13,
15588,
62,
8726,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
271,
62,
28120,
1298,
2836,
13,
271,
62,
28120,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
628,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
1441,
8543,
7,
25927,
11,
705,
15588,
13,
6494,
3256,
2882,
62,
7890,
8,
628,
198,
4299,
664,
12311,
40710,
7,
25927,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
3311,
17974,
17841,
2173,
2884,
257,
73,
897,
2581,
198,
220,
220,
220,
705,
7061,
628,
220,
220,
220,
2124,
11,
331,
796,
2581,
13,
18851,
17816,
87,
6,
4357,
2581,
13,
18851,
17816,
88,
20520,
198,
220,
220,
220,
640,
796,
2581,
13,
18851,
17816,
2435,
20520,
198,
220,
220,
220,
9647,
11,
6001,
796,
2581,
13,
18851,
17816,
10394,
6,
4357,
2581,
13,
18851,
17816,
17015,
20520,
198,
220,
220,
220,
20579,
796,
2581,
13,
18851,
17816,
29460,
20520,
628,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
14700,
796,
2956,
297,
571,
13,
29572,
13,
403,
22708,
7,
25927,
13,
18851,
17816,
42712,
507,
20520,
737,
35312,
10786,
26,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
14700,
796,
1351,
7,
8899,
7,
22468,
11,
14700,
4008,
198,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
14700,
796,
17635,
628,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
9942,
796,
17228,
2394,
11053,
58,
37659,
13,
853,
9806,
7,
42712,
507,
15437,
198,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
9942,
796,
705,
14202,
6,
198,
220,
220,
220,
220,
628,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
11,
331,
11,
640,
796,
493,
7,
22468,
7,
87,
36911,
493,
7,
22468,
7,
88,
36911,
493,
7,
22468,
7,
2435,
4008,
198,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
11,
331,
796,
657,
11,
657,
628,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
9647,
11,
6001,
796,
493,
7,
10394,
828,
493,
7,
17015,
8,
198,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
9647,
11,
6001,
796,
657,
11,
657,
628,
198,
220,
220,
220,
7623,
17126,
13,
48205,
13,
17953,
7,
15588,
62,
8726,
28,
2008,
13,
15588,
62,
8726,
11,
2836,
62,
312,
28,
2836,
13,
29460,
11,
41033,
796,
640,
11,
10825,
28,
368,
9650,
11,
22715,
28,
69,
6,
90,
87,
92,
29164,
88,
92,
3256,
3159,
62,
10394,
28,
10394,
11,
3159,
62,
17015,
28,
17015,
8,
628,
198,
220,
220,
220,
1441,
449,
1559,
31077,
15090,
6,
482,
10354,
6407,
30072,
198,
198,
4299,
10784,
29668,
7,
25927,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
3311,
17974,
10784,
2581,
2884,
257,
73,
897,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
1303,
651,
2008,
1366,
198,
220,
220,
220,
12784,
796,
7623,
17126,
13,
48205,
13,
24455,
7,
15588,
62,
8726,
28,
15588,
13,
15588,
62,
8726,
8,
198,
220,
220,
220,
30320,
35613,
62,
34219,
796,
10644,
10786,
1177,
263,
14,
12708,
14,
15002,
82,
11537,
1220,
2008,
13,
15588,
62,
8726,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
28015,
15908,
7,
41925,
35613,
62,
34219,
8,
198,
220,
220,
220,
2845,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1208,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
2008,
62,
7890,
796,
410,
47776,
13,
3605,
7,
69,
6,
5450,
1378,
85,
47776,
13,
785,
14,
90,
15588,
13,
15588,
62,
8726,
92,
11537,
198,
220,
220,
220,
2008,
62,
7890,
13,
5532,
82,
58,
15,
4083,
15002,
7,
39624,
28,
25101,
8,
198,
220,
220,
220,
2008,
62,
10394,
11,
2008,
62,
17015,
796,
965,
7,
15588,
62,
7890,
13,
5532,
82,
58,
15,
35944,
35312,
10786,
31,
11537,
58,
12,
16,
4083,
35312,
10786,
87,
11537,
198,
220,
220,
220,
2008,
62,
10394,
11,
2008,
62,
17015,
796,
493,
7,
15588,
62,
10394,
828,
493,
7,
15588,
62,
17015,
8,
628,
220,
220,
220,
1303,
651,
2008,
20613,
12784,
198,
220,
220,
220,
4894,
8899,
62,
13033,
796,
17635,
198,
220,
220,
220,
9942,
62,
13033,
796,
17635,
198,
220,
220,
220,
329,
304,
287,
12784,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
11,
88,
796,
1351,
7,
8899,
7,
600,
11,
304,
13,
37652,
17540,
13,
35312,
7,
10354,
6,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
640,
796,
493,
7,
68,
13,
16514,
27823,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2124,
1635,
28,
2008,
62,
10394,
1220,
493,
7,
68,
13,
9612,
62,
10394,
8,
198,
220,
220,
220,
220,
220,
220,
220,
331,
1635,
28,
2008,
62,
17015,
1220,
493,
7,
68,
13,
9612,
62,
17015,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4894,
8899,
62,
13033,
13,
33295,
26933,
87,
11,
88,
11,
640,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
9942,
62,
13033,
13,
33295,
26933,
68,
13,
7220,
62,
312,
11,
640,
1003,
27641,
11,
304,
13,
368,
36083,
12962,
198,
220,
220,
220,
220,
198,
220,
220,
220,
10825,
796,
279,
67,
13,
6601,
19778,
7,
368,
9650,
62,
13033,
8,
198,
220,
220,
220,
10825,
13,
28665,
82,
796,
37250,
7220,
62,
3672,
3256,
705,
16514,
27823,
3256,
705,
368,
9650,
20520,
628,
220,
220,
220,
220,
198,
220,
220,
220,
9942,
62,
9127,
82,
796,
17635,
198,
220,
220,
220,
329,
357,
912,
11,
2378,
8,
287,
10825,
13,
8094,
1525,
10786,
16514,
27823,
6,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
31404,
5781,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
16514,
27823,
10354,
2378,
17816,
16514,
27823,
6,
4083,
346,
420,
58,
15,
60,
1635,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
648,
563,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
6381,
70,
8459,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
69,
451,
913,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
34191,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
29797,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
82,
324,
10354,
657,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
11793,
1050,
1417,
10354,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
14202,
10354,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
329,
6376,
11,
954,
287,
2378,
17816,
368,
9650,
6,
4083,
8367,
62,
9127,
82,
22446,
23814,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
31404,
5781,
58,
9630,
60,
796,
954,
198,
220,
220,
220,
220,
220,
220,
220,
9942,
62,
9127,
82,
13,
33295,
7,
34,
19385,
5781,
13,
27160,
28955,
198,
220,
220,
220,
9942,
62,
9127,
82,
796,
279,
67,
13,
6601,
19778,
7,
368,
9650,
62,
9127,
82,
8,
198,
220,
220,
220,
9942,
62,
9127,
82,
13,
28665,
82,
796,
31404,
5781,
13,
13083,
3419,
198,
220,
220,
220,
9942,
62,
9127,
82,
13,
1462,
62,
40664,
7,
41925,
35613,
62,
34219,
1220,
705,
448,
13,
40664,
3256,
6376,
796,
6045,
8,
628,
220,
220,
220,
220,
198,
220,
220,
220,
4894,
76,
11463,
796,
12308,
76,
11463,
7,
4122,
62,
41402,
28,
15,
13,
21,
11,
45912,
28,
15,
13,
23,
8,
198,
220,
220,
220,
2008,
62,
25080,
76,
11463,
796,
7623,
39596,
76,
11463,
7,
25080,
76,
11463,
8,
198,
220,
220,
220,
4894,
8899,
62,
15588,
796,
2008,
62,
25080,
76,
11463,
13,
25080,
8899,
62,
261,
62,
15588,
62,
6978,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2008,
62,
6978,
28,
69,
6,
90,
15588,
62,
7890,
13,
7839,
27422,
3149,
19,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
2173,
28,
25080,
8899,
62,
13033,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
4894,
8899,
62,
15588,
13,
13564,
62,
15588,
7753,
7,
2536,
7,
41925,
35613,
62,
34219,
1220,
705,
448,
13,
3149,
19,
33809,
1643,
4873,
2625,
4059,
74,
1600,
32977,
28,
1731,
8,
628,
220,
220,
220,
29034,
19,
62,
16624,
796,
15095,
13,
4743,
672,
7,
2536,
10786,
24620,
3149,
19,
6,
4008,
198,
220,
220,
220,
329,
277,
287,
29034,
19,
62,
16624,
25,
198,
220,
220,
220,
220,
220,
220,
220,
611,
277,
14512,
705,
448,
13,
3149,
19,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
28956,
7,
69,
8,
628,
220,
220,
220,
4423,
346,
13,
15883,
62,
17474,
7,
2536,
7,
41925,
35613,
62,
34219,
828,
705,
13344,
3256,
965,
7,
41925,
35613,
62,
34219,
4008,
198,
220,
220,
220,
4423,
346,
13,
81,
16762,
631,
7,
2536,
7,
41925,
35613,
62,
34219,
4008,
628,
198,
220,
220,
220,
1303,
640,
1912,
4823,
628,
220,
220,
220,
2336,
796,
279,
87,
13,
1370,
7,
368,
9650,
62,
9127,
82,
11,
2124,
2625,
16514,
27823,
1600,
331,
28,
368,
9650,
62,
9127,
82,
13,
28665,
82,
58,
16,
25,
12962,
198,
220,
220,
220,
2336,
796,
7110,
306,
13,
34960,
62,
672,
8457,
13,
11337,
7,
5647,
13,
7890,
11,
2336,
13,
39786,
8,
198,
220,
220,
220,
2336,
62,
17752,
62,
16,
796,
2336,
13,
1462,
62,
17752,
3419,
628,
220,
220,
220,
1303,
2508,
8262,
198,
220,
220,
220,
14722,
11,
9853,
796,
1351,
7,
368,
36083,
17816,
368,
9650,
6,
4083,
8367,
62,
9127,
82,
22446,
9630,
828,
1351,
7,
368,
36083,
17816,
368,
9650,
6,
4083,
8367,
62,
9127,
82,
22446,
27160,
8,
198,
220,
220,
220,
2336,
796,
467,
13,
11337,
7,
7890,
41888,
2188,
13,
48223,
7,
23912,
1424,
28,
23912,
1424,
11,
3815,
28,
9127,
82,
8,
12962,
198,
220,
220,
220,
2336,
62,
17752,
62,
17,
796,
2336,
13,
1462,
62,
17752,
3419,
628,
628,
198,
220,
220,
220,
1441,
449,
1559,
31077,
15090,
6,
482,
10354,
6407,
11,
705,
29487,
306,
62,
34960,
62,
16,
10354,
2336,
62,
17752,
62,
16,
11,
705,
29487,
306,
62,
34960,
62,
17,
10354,
2336,
62,
17752,
62,
17,
30072,
220,
220,
220,
198
] | 2.31539 | 2,638 |
import re
from importlib import import_module
import inspect
import sublime_plugin
import sublime
SCOPE_RE = re.compile(r'\bsource\.python\b')
LIB_MODULE_RE = re.compile(r'\bsupport\.module\.python\b')
def grab_module(view, cursor):
''' Grabs the entire module path under the cursor '''
word_sel = view.word(cursor)
pos = None
# Are we on a dot right now?
if view.substr(cursor.begin() - 1) == '.':
pos = cursor.begin() - 1
# Are we on a word?
elif view.substr(word_sel.begin() - 1) == '.':
pos = word_sel.begin() - 1
# Not a module
else:
return False
path_parts = []
while view.substr(pos) == '.':
# Expand prefix to a word
word_sel = view.word(pos - 1)
word = view.substr(word_sel)
path_parts.append(word)
pos = word_sel.begin() - 1
# Format the module path
path = '.'.join(reversed(path_parts))
return path
| [
11748,
302,
198,
6738,
1330,
8019,
1330,
1330,
62,
21412,
198,
11748,
10104,
198,
198,
11748,
41674,
62,
33803,
198,
11748,
41674,
628,
198,
6173,
32135,
62,
2200,
796,
302,
13,
5589,
576,
7,
81,
6,
59,
1443,
1668,
17405,
29412,
59,
65,
11537,
198,
40347,
62,
33365,
24212,
62,
2200,
796,
302,
13,
5589,
576,
7,
81,
6,
59,
1443,
84,
4926,
17405,
21412,
17405,
29412,
59,
65,
11537,
628,
198,
198,
4299,
5552,
62,
21412,
7,
1177,
11,
23493,
2599,
198,
220,
220,
220,
705,
7061,
1902,
8937,
262,
2104,
8265,
3108,
739,
262,
23493,
705,
7061,
198,
220,
220,
220,
1573,
62,
741,
796,
1570,
13,
4775,
7,
66,
21471,
8,
628,
220,
220,
220,
1426,
796,
6045,
628,
220,
220,
220,
1303,
4231,
356,
319,
257,
16605,
826,
783,
30,
198,
220,
220,
220,
611,
1570,
13,
7266,
2536,
7,
66,
21471,
13,
27471,
3419,
532,
352,
8,
6624,
705,
2637,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1426,
796,
23493,
13,
27471,
3419,
532,
352,
628,
220,
220,
220,
1303,
4231,
356,
319,
257,
1573,
30,
198,
220,
220,
220,
1288,
361,
1570,
13,
7266,
2536,
7,
4775,
62,
741,
13,
27471,
3419,
532,
352,
8,
6624,
705,
2637,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1426,
796,
1573,
62,
741,
13,
27471,
3419,
532,
352,
628,
220,
220,
220,
1303,
1892,
257,
8265,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
628,
220,
220,
220,
3108,
62,
42632,
796,
17635,
198,
220,
220,
220,
981,
1570,
13,
7266,
2536,
7,
1930,
8,
6624,
705,
2637,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
49368,
21231,
284,
257,
1573,
198,
220,
220,
220,
220,
220,
220,
220,
1573,
62,
741,
796,
1570,
13,
4775,
7,
1930,
532,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1573,
796,
1570,
13,
7266,
2536,
7,
4775,
62,
741,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3108,
62,
42632,
13,
33295,
7,
4775,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1426,
796,
1573,
62,
741,
13,
27471,
3419,
532,
352,
628,
220,
220,
220,
1303,
18980,
262,
8265,
3108,
198,
220,
220,
220,
3108,
796,
705,
2637,
13,
22179,
7,
260,
690,
276,
7,
6978,
62,
42632,
4008,
628,
220,
220,
220,
1441,
3108,
628,
198
] | 2.382872 | 397 |
"""
Calculates port ranks and distributes ports.
The rank of a port is a floating point number that represents its position
inside the containing layer. This depends on the node order of that layer and on the
port constraints of the nodes. Port ranks are used by {@link ICrossingMinimizationHeuristics
for calculating barycenter or median values for nodes. Furthermore, they are used in this
class for distributing the ports of nodes where the order of ports is not fixed,
which has to be done as the last step of each crossing minimization processor.
There are different ways to determine port ranks, therefore that is done in concrete subclasses.
"""
from collections import defaultdict
from math import inf
from typing import List
from layeredGraphLayouter.containers.constants import PortType, PortSide
from layeredGraphLayouter.containers.lNode import LNode
from layeredGraphLayouter.containers.lPort import LPort
class AbstractBarycenterPortDistributor():
"""
Constructs a port distributor for the given array of port ranks.
All ports are required to be assigned ids in the range of the given array.
:ivar portRanks: port ranks dict {port: rank} in which the results of ranks calculation are stored.
"""
# ######################################/
# Port Rank Assignment
def calculatePortRanks_many(self, layer: List[LNode], portType: PortType):
"""
Determine ranks for all ports of specific type in the given layer.
The ranks are written to the {@link #getPortRanks() array.
:param layer: a layer as node array
:param portType: the port type to consider
"""
#assert isinstance(layer, LNodeLayer), (layer, layer.__class__)
calculatePortRanks = self.calculatePortRanks
consumedRank = 0
for node in layer:
consumedRank += calculatePortRanks(node, consumedRank, portType)
def calculatePortRanks(self, node: LNode, rankSum: float, type_: PortType):
"""
Assign port ranks for the input or output ports of the given node. If the node's port
constraints imply a fixed order, the ports are assumed to be pre-ordered in the usual way,
i.e. in clockwise order north - east - south - west.
The ranks are written to the {@link #getPortRanks() array.
:param node: a node
:param rankSum: the sum of ranks of preceding nodes in the same layer
:param type: the port type to consider
:return the rank consumed by the given node the following node's ranks start at
{@code rankSum + consumedRank
:see: {@link org.eclipse.alg.layered.intermediate.PortListSorter
"""
raise NotImplementedError("Implement on child class")
# ######################################/
# Port Distribution
def distributePorts(self, node, ports):
"""
* Distribute the ports of the given node by their sides, connected ports, and input or output
* type.
*
* :param node
* node whose ports shall be sorted
"""
self.inLayerPorts.clear()
if ports:
self.iteratePortsAndCollectInLayerPorts(node, ports)
if self.inLayerPorts:
self.calculateInLayerPortsBarycenterValues(node)
def sortPorts(self, node):
"""
Sort the ports of a node using the given relative position values.
These values are interpreted as a hint for the clockwise order of ports.
:param node: a node
"""
portBarycenter = self.portBarycenter
for side in node.iterSides():
side.sort(key=lambda p: portBarycenter[p])
| [
198,
37811,
198,
9771,
3129,
689,
2493,
9803,
290,
1233,
7657,
14090,
13,
198,
464,
4279,
286,
257,
2493,
318,
257,
12462,
966,
1271,
326,
6870,
663,
2292,
198,
48787,
262,
7268,
7679,
13,
770,
8338,
319,
262,
10139,
1502,
286,
326,
7679,
290,
319,
262,
198,
634,
17778,
286,
262,
13760,
13,
4347,
9803,
389,
973,
416,
1391,
31,
8726,
12460,
1214,
278,
9452,
320,
1634,
1544,
333,
3969,
198,
1640,
26019,
275,
560,
16159,
393,
14288,
3815,
329,
13760,
13,
11399,
11,
484,
389,
973,
287,
428,
198,
4871,
329,
25950,
262,
14090,
286,
13760,
810,
262,
1502,
286,
14090,
318,
407,
5969,
11,
198,
4758,
468,
284,
307,
1760,
355,
262,
938,
2239,
286,
1123,
12538,
10356,
1634,
12649,
13,
198,
1858,
389,
1180,
2842,
284,
5004,
2493,
9803,
11,
4361,
326,
318,
1760,
287,
10017,
850,
37724,
13,
198,
37811,
198,
6738,
17268,
1330,
4277,
11600,
198,
6738,
10688,
1330,
1167,
198,
6738,
19720,
1330,
7343,
198,
198,
6738,
37748,
37065,
23763,
39605,
13,
3642,
50221,
13,
9979,
1187,
1330,
4347,
6030,
11,
4347,
24819,
198,
6738,
37748,
37065,
23763,
39605,
13,
3642,
50221,
13,
75,
19667,
1330,
406,
19667,
198,
6738,
37748,
37065,
23763,
39605,
13,
3642,
50221,
13,
75,
13924,
1330,
406,
13924,
628,
628,
198,
198,
4871,
27741,
33,
560,
16159,
13924,
20344,
2455,
273,
33529,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
28407,
82,
257,
2493,
32137,
329,
262,
1813,
7177,
286,
2493,
9803,
13,
220,
198,
220,
220,
220,
1439,
14090,
389,
2672,
284,
307,
8686,
220,
2340,
287,
262,
2837,
286,
262,
1813,
7177,
13,
628,
220,
220,
220,
1058,
452,
283,
2493,
49,
2283,
25,
2493,
9803,
8633,
1391,
634,
25,
4279,
92,
287,
543,
262,
2482,
286,
9803,
17952,
389,
8574,
13,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
1303,
1303,
29113,
4242,
2,
14,
198,
220,
220,
220,
1303,
4347,
10916,
50144,
628,
220,
220,
220,
825,
15284,
13924,
49,
2283,
62,
21834,
7,
944,
11,
7679,
25,
7343,
58,
43,
19667,
4357,
2493,
6030,
25,
4347,
6030,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
45559,
3810,
9803,
329,
477,
14090,
286,
2176,
2099,
287,
262,
1813,
7679,
13,
198,
220,
220,
220,
220,
220,
220,
220,
383,
9803,
389,
3194,
284,
262,
1391,
31,
8726,
1303,
1136,
13924,
49,
2283,
3419,
7177,
13,
628,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
7679,
25,
257,
7679,
355,
10139,
7177,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
2493,
6030,
25,
262,
2493,
2099,
284,
2074,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
30493,
318,
39098,
7,
29289,
11,
406,
19667,
49925,
828,
357,
29289,
11,
7679,
13,
834,
4871,
834,
8,
198,
220,
220,
220,
220,
220,
220,
220,
15284,
13924,
49,
2283,
796,
2116,
13,
9948,
3129,
378,
13924,
49,
2283,
198,
220,
220,
220,
220,
220,
220,
220,
13529,
27520,
796,
657,
198,
220,
220,
220,
220,
220,
220,
220,
329,
10139,
287,
7679,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13529,
27520,
15853,
15284,
13924,
49,
2283,
7,
17440,
11,
13529,
27520,
11,
2493,
6030,
8,
628,
220,
220,
220,
825,
15284,
13924,
49,
2283,
7,
944,
11,
10139,
25,
406,
19667,
11,
4279,
13065,
25,
12178,
11,
2099,
62,
25,
4347,
6030,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2195,
570,
2493,
9803,
329,
262,
5128,
393,
5072,
14090,
286,
262,
1813,
10139,
13,
1002,
262,
10139,
338,
2493,
198,
220,
220,
220,
220,
220,
220,
220,
17778,
20135,
257,
5969,
1502,
11,
262,
14090,
389,
9672,
284,
307,
662,
12,
24071,
287,
262,
6678,
835,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1312,
13,
68,
13,
287,
8801,
3083,
1502,
5093,
532,
7627,
532,
5366,
532,
7421,
13,
198,
220,
220,
220,
220,
220,
220,
220,
383,
9803,
389,
3194,
284,
262,
1391,
31,
8726,
1303,
1136,
13924,
49,
2283,
3419,
7177,
13,
628,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
10139,
25,
257,
10139,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
4279,
13065,
25,
262,
2160,
286,
9803,
286,
18148,
13760,
287,
262,
976,
7679,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
2099,
25,
262,
2493,
2099,
284,
2074,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
7783,
262,
4279,
13529,
416,
262,
1813,
10139,
262,
1708,
10139,
338,
9803,
923,
379,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
31,
8189,
4279,
13065,
1343,
13529,
27520,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
3826,
25,
220,
1391,
31,
8726,
8745,
13,
68,
17043,
13,
14016,
13,
10724,
1068,
13,
3849,
13857,
13,
13924,
8053,
50,
4337,
220,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
1892,
3546,
1154,
12061,
12331,
7203,
3546,
26908,
319,
1200,
1398,
4943,
628,
220,
220,
220,
1303,
1303,
29113,
4242,
2,
14,
198,
220,
220,
220,
1303,
4347,
27484,
628,
220,
220,
220,
825,
14983,
47,
2096,
7,
944,
11,
10139,
11,
14090,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
4307,
4163,
262,
14090,
286,
262,
1813,
10139,
416,
511,
5389,
11,
5884,
14090,
11,
290,
5128,
393,
5072,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
2099,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
1058,
17143,
10139,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10139,
3025,
14090,
2236,
307,
23243,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
259,
49925,
47,
2096,
13,
20063,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
611,
14090,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
2676,
378,
47,
2096,
1870,
31337,
818,
49925,
47,
2096,
7,
17440,
11,
14090,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2116,
13,
259,
49925,
47,
2096,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
9948,
3129,
378,
818,
49925,
47,
2096,
33,
560,
16159,
40161,
7,
17440,
8,
628,
220,
220,
220,
825,
3297,
47,
2096,
7,
944,
11,
10139,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
33947,
262,
14090,
286,
257,
10139,
1262,
262,
1813,
3585,
2292,
3815,
13,
198,
220,
220,
220,
220,
220,
220,
220,
2312,
3815,
389,
16173,
355,
257,
9254,
329,
262,
8801,
3083,
1502,
286,
14090,
13,
628,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
10139,
25,
257,
10139,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2493,
33,
560,
16159,
796,
2116,
13,
634,
33,
560,
16159,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1735,
287,
10139,
13,
2676,
50,
1460,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1735,
13,
30619,
7,
2539,
28,
50033,
279,
25,
2493,
33,
560,
16159,
58,
79,
12962,
198
] | 2.94127 | 1,260 |
from setuptools import setup, find_packages
PACKAGENAME = "deltasigma"
VERSION = "0.0.dev"
setup(
name=PACKAGENAME,
version=VERSION,
author="Antonio Villarreal",
author_email="[email protected]",
description="Source code for chopper / halotools implementation to calculate delta sigma.",
long_description="Source code for chopper / halotools implementation to calculate delta sigma.",
install_requires=["numpy", "halotools", "colossus", "yaml", "pyyaml", "psutil", "six"],
packages=find_packages(),
url="https://github.com/villarrealas/deltasigma"
)
| [
6738,
900,
37623,
10141,
1330,
9058,
11,
1064,
62,
43789,
628,
198,
47,
8120,
4760,
1677,
10067,
796,
366,
67,
2120,
292,
13495,
1,
198,
43717,
796,
366,
15,
13,
15,
13,
7959,
1,
628,
198,
40406,
7,
198,
220,
220,
220,
1438,
28,
47,
8120,
4760,
1677,
10067,
11,
198,
220,
220,
220,
2196,
28,
43717,
11,
198,
220,
220,
220,
1772,
2625,
13217,
261,
952,
9757,
283,
5305,
1600,
198,
220,
220,
220,
1772,
62,
12888,
2625,
615,
359,
283,
5305,
31,
272,
75,
13,
9567,
1600,
198,
220,
220,
220,
6764,
2625,
7416,
2438,
329,
1727,
2848,
1220,
10284,
313,
10141,
7822,
284,
15284,
25979,
264,
13495,
33283,
198,
220,
220,
220,
890,
62,
11213,
2625,
7416,
2438,
329,
1727,
2848,
1220,
10284,
313,
10141,
7822,
284,
15284,
25979,
264,
13495,
33283,
198,
220,
220,
220,
2721,
62,
47911,
28,
14692,
77,
32152,
1600,
366,
14201,
313,
10141,
1600,
366,
4033,
36533,
1600,
366,
88,
43695,
1600,
366,
9078,
88,
43695,
1600,
366,
862,
22602,
1600,
366,
19412,
33116,
198,
220,
220,
220,
10392,
28,
19796,
62,
43789,
22784,
198,
220,
220,
220,
19016,
2625,
5450,
1378,
12567,
13,
785,
14,
41082,
283,
5305,
292,
14,
67,
2120,
292,
13495,
1,
198,
8,
198
] | 2.859903 | 207 |
import itertools
import os
import csv
from loguru import logger
from datetime import *
class SensorPersistence(Persistence):
"""
Writes sensor data to a buffer and periodically flushes to file system.
"""
| [
11748,
340,
861,
10141,
201,
198,
11748,
28686,
201,
198,
11748,
269,
21370,
201,
198,
6738,
2604,
14717,
1330,
49706,
201,
198,
201,
198,
6738,
4818,
8079,
1330,
1635,
201,
198,
201,
198,
201,
198,
201,
198,
4871,
35367,
30946,
13274,
7,
30946,
13274,
2599,
201,
198,
220,
220,
220,
37227,
201,
198,
220,
220,
220,
220,
220,
220,
220,
12257,
274,
12694,
1366,
284,
257,
11876,
290,
26034,
781,
17237,
284,
2393,
1080,
13,
201,
198,
220,
220,
220,
37227,
201,
198
] | 2.86747 | 83 |
from picamera import PiCamera
from time import sleep
from gpiozero import Button
import keyboard
button = keyboard.is_pressed('h')
camera = PiCamera()
while True:
camera.start_preview()
button.wait_for_press()
print("Button has been pressed!")
sleep(3)
camera.capture('animateImage.jpg')
camera.stop_preview()
| [
6738,
8301,
18144,
1330,
13993,
35632,
198,
6738,
640,
1330,
3993,
198,
6738,
27809,
952,
22570,
1330,
20969,
198,
11748,
10586,
198,
198,
16539,
796,
10586,
13,
271,
62,
45477,
10786,
71,
11537,
198,
25695,
796,
13993,
35632,
3419,
198,
198,
4514,
6407,
25,
198,
197,
25695,
13,
9688,
62,
3866,
1177,
3419,
198,
197,
16539,
13,
17077,
62,
1640,
62,
8439,
3419,
198,
197,
4798,
7203,
21864,
468,
587,
12070,
2474,
8,
198,
197,
42832,
7,
18,
8,
198,
197,
25695,
13,
27144,
495,
10786,
45685,
5159,
13,
9479,
11537,
198,
197,
25695,
13,
11338,
62,
3866,
1177,
3419,
198
] | 3.148515 | 101 |
#!/usr/bin/env python
import os, sys, pickle
import keras.backend as K
import tensorflow as tf
import numpy as np
from argparse import ArgumentParser
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from datasets import mnist
from models import (train, accuracy, save_to_file, fc_100_100_10,
pca_filtered_model, fastica_filtered_model,
incrementalpca_filtered_model, nmf_filtered_model,
truncatedsvd_filtered_model, kernelpca_filtered_model)
argument_parser = ArgumentParser()
argument_parser.add_argument("--pca", action="store_true",
help="use PCA image filter defense")
argument_parser.add_argument("--fastica", action="store_true",
help="use FastICA image filter defense")
argument_parser.add_argument("--incrementalpca", action="store_true",
help="use IncrementalPCA image filter defense")
argument_parser.add_argument("--nmf", action="store_true",
help="use IncrementalPCA image filter defense")
argument_parser.add_argument("--truncatedsvd", action="store_true",
help="use TruncatedSVD image filter defense")
argument_parser.add_argument("--kernelpca", action="store_true",
help="use KernelPCA image filter defense")
argument_parser.add_argument("--n-components", type=int, nargs="+", default=[],
help="number of components for image filters")
argument_parser.add_argument("--epochs", type=int, default=-1,
help="default: let the model choose")
argument_parser.add_argument("--random-seed", action="store_true",
help="initialize model with random seed")
args = argument_parser.parse_args()
PREFIX = os.environ.get('PREFIX', '.')
X_train, y_train, X_test, y_test = mnist()
if not args.random_seed:
K.clear_session()
tf.set_random_seed(1234)
np.random.seed(1234)
no_defense_model = fc_100_100_10()
print(f"Training {no_defense_model.name}...")
train(no_defense_model, X_train, y_train, args.epochs, verbose=True,
stop_on_stable_weights=True, reduce_lr_on_plateau=True,
stop_on_stable_weights_patience=60, reduce_lr_on_plateau_patience=30)
print(f"Saving {no_defense_model.name}...")
save_to_file(no_defense_model, PREFIX)
for n_components in args.n_components:
if args.pca:
pca = cached(f"pca-{n_components}")
filtered_model = pca_filtered_model(no_defense_model, X_train,
n_components, pca=pca)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
if args.fastica:
fastica = cached(f"fastica-{n_components}")
filtered_model = fastica_filtered_model(no_defense_model, X_train,
n_components, fastica=fastica)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
if args.incrementalpca:
incrementalpca = cached(f"incrementalpca-{n_components}")
filtered_model = incrementalpca_filtered_model(no_defense_model, X_train,
n_components,
incrementalpca=incrementalpca)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
if args.nmf:
nmf = cached(f"nmf-{n_components}")
filtered_model = nmf_filtered_model(no_defense_model, X_train,
n_components, nmf=nmf)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
if args.truncatedsvd:
truncatedsvd = cached(f"truncatedsvd-{n_components}")
filtered_model = truncatedsvd_filtered_model(no_defense_model, X_train,
n_components,
truncatedsvd=truncatedsvd)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
if args.kernelpca:
kernelpca = cached(f"kernelpca-{n_components}")
filtered_model = kernelpca_filtered_model(no_defense_model, X_train,
n_components, kernelpca=kernelpca)
print(f"Saving {filtered_model.name}...")
save_to_file(filtered_model, PREFIX)
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
11748,
28686,
11,
25064,
11,
2298,
293,
198,
11748,
41927,
292,
13,
1891,
437,
355,
509,
198,
11748,
11192,
273,
11125,
355,
48700,
198,
11748,
299,
32152,
355,
45941,
198,
6738,
1822,
29572,
1330,
45751,
46677,
198,
198,
17597,
13,
6978,
13,
28463,
7,
15,
11,
28686,
13,
6978,
13,
397,
2777,
776,
7,
418,
13,
6978,
13,
22179,
7,
418,
13,
6978,
13,
15908,
3672,
7,
834,
7753,
834,
828,
705,
492,
6,
22305,
198,
6738,
40522,
1330,
285,
77,
396,
198,
6738,
4981,
1330,
357,
27432,
11,
9922,
11,
3613,
62,
1462,
62,
7753,
11,
277,
66,
62,
3064,
62,
3064,
62,
940,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
6888,
62,
10379,
4400,
62,
19849,
11,
3049,
3970,
62,
10379,
4400,
62,
19849,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
29497,
79,
6888,
62,
10379,
4400,
62,
19849,
11,
28642,
69,
62,
10379,
4400,
62,
19849,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
40122,
515,
82,
20306,
62,
10379,
4400,
62,
19849,
11,
9720,
79,
6888,
62,
10379,
4400,
62,
19849,
8,
198,
198,
49140,
62,
48610,
796,
45751,
46677,
3419,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
79,
6888,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
4217,
32,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
69,
3477,
64,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
12549,
25241,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
24988,
37098,
79,
6888,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
10791,
37098,
5662,
32,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
21533,
69,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
10791,
37098,
5662,
32,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
2213,
19524,
515,
82,
20306,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
833,
19524,
515,
50,
8898,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
33885,
79,
6888,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
1904,
32169,
5662,
32,
2939,
8106,
3761,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
77,
12,
5589,
3906,
1600,
2099,
28,
600,
11,
299,
22046,
2625,
10,
1600,
4277,
41888,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
17618,
286,
6805,
329,
2939,
16628,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
538,
5374,
82,
1600,
2099,
28,
600,
11,
4277,
10779,
16,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
12286,
25,
1309,
262,
2746,
3853,
4943,
198,
49140,
62,
48610,
13,
2860,
62,
49140,
7203,
438,
25120,
12,
28826,
1600,
2223,
2625,
8095,
62,
7942,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
36733,
1096,
2746,
351,
4738,
9403,
4943,
198,
22046,
796,
4578,
62,
48610,
13,
29572,
62,
22046,
3419,
198,
198,
47,
31688,
10426,
796,
28686,
13,
268,
2268,
13,
1136,
10786,
47,
31688,
10426,
3256,
705,
2637,
8,
198,
198,
55,
62,
27432,
11,
331,
62,
27432,
11,
1395,
62,
9288,
11,
331,
62,
9288,
796,
285,
77,
396,
3419,
198,
198,
361,
407,
26498,
13,
25120,
62,
28826,
25,
198,
220,
220,
220,
509,
13,
20063,
62,
29891,
3419,
198,
220,
220,
220,
48700,
13,
2617,
62,
25120,
62,
28826,
7,
1065,
2682,
8,
198,
220,
220,
220,
45941,
13,
25120,
13,
28826,
7,
1065,
2682,
8,
198,
198,
3919,
62,
19774,
62,
19849,
796,
277,
66,
62,
3064,
62,
3064,
62,
940,
3419,
198,
4798,
7,
69,
1,
44357,
1391,
3919,
62,
19774,
62,
19849,
13,
3672,
92,
9313,
8,
198,
27432,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
331,
62,
27432,
11,
26498,
13,
538,
5374,
82,
11,
15942,
577,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
2245,
62,
261,
62,
31284,
62,
43775,
28,
17821,
11,
4646,
62,
14050,
62,
261,
62,
6816,
559,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
2245,
62,
261,
62,
31284,
62,
43775,
62,
8071,
1240,
28,
1899,
11,
4646,
62,
14050,
62,
261,
62,
6816,
559,
62,
8071,
1240,
28,
1270,
8,
198,
198,
4798,
7,
69,
1,
50,
2703,
1391,
3919,
62,
19774,
62,
19849,
13,
3672,
92,
9313,
8,
198,
21928,
62,
1462,
62,
7753,
7,
3919,
62,
19774,
62,
19849,
11,
22814,
47084,
8,
198,
198,
1640,
299,
62,
5589,
3906,
287,
26498,
13,
77,
62,
5589,
3906,
25,
198,
220,
220,
220,
611,
26498,
13,
79,
6888,
25,
198,
220,
220,
220,
220,
220,
220,
220,
279,
6888,
796,
39986,
7,
69,
1,
79,
6888,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
279,
6888,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
279,
6888,
28,
79,
6888,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
628,
220,
220,
220,
611,
26498,
13,
69,
3477,
64,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3049,
3970,
796,
39986,
7,
69,
1,
69,
3477,
64,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
3049,
3970,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
3049,
3970,
28,
69,
3477,
64,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
628,
220,
220,
220,
611,
26498,
13,
24988,
37098,
79,
6888,
25,
198,
220,
220,
220,
220,
220,
220,
220,
29497,
79,
6888,
796,
39986,
7,
69,
1,
24988,
37098,
79,
6888,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
29497,
79,
6888,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
29497,
79,
6888,
28,
24988,
37098,
79,
6888,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
628,
220,
220,
220,
611,
26498,
13,
21533,
69,
25,
198,
220,
220,
220,
220,
220,
220,
220,
28642,
69,
796,
39986,
7,
69,
1,
21533,
69,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
28642,
69,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
28642,
69,
28,
21533,
69,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
628,
220,
220,
220,
611,
26498,
13,
2213,
19524,
515,
82,
20306,
25,
198,
220,
220,
220,
220,
220,
220,
220,
40122,
515,
82,
20306,
796,
39986,
7,
69,
1,
2213,
19524,
515,
82,
20306,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
40122,
515,
82,
20306,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
40122,
515,
82,
20306,
28,
2213,
19524,
515,
82,
20306,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
628,
220,
220,
220,
611,
26498,
13,
33885,
79,
6888,
25,
198,
220,
220,
220,
220,
220,
220,
220,
9720,
79,
6888,
796,
39986,
7,
69,
1,
33885,
79,
6888,
12,
90,
77,
62,
5589,
3906,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
29083,
62,
19849,
796,
9720,
79,
6888,
62,
10379,
4400,
62,
19849,
7,
3919,
62,
19774,
62,
19849,
11,
1395,
62,
27432,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
62,
5589,
3906,
11,
9720,
79,
6888,
28,
33885,
79,
6888,
8,
628,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
50,
2703,
1391,
10379,
4400,
62,
19849,
13,
3672,
92,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
1462,
62,
7753,
7,
10379,
4400,
62,
19849,
11,
22814,
47084,
8,
198
] | 2.054323 | 2,209 |
#!/usr/bin/env python
'''
VIMTern.py dispatch work to your intern via Slack from the command line.
'''
from random import randint
from sys import exit, argv
import argparse
import json
import yaml # To load the intrn file
VERBOSE = False
try:
import requests
except ImportError:
print "Unable to import requests. Run `pip install requests`."
exit(1)
def _load_intrn(intrn_file="default.intrn"):
'''
Load the config file.
'''
config = None
with open(intrn_file, 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as ex:
print str(ex)
exit(1)
return config
def vimtern_do(msg, intrn_file):
'''
Issue commands to 1ntern.
'''
global VERBOSE
if not intrn_file:
raise AttributeError("Path to .intrn file required.")
config = _load_intrn(intrn_file)
if not msg or msg == '':
num = len(config["default_msgs"])
msg = config["default_msgs"][randint(0, num - 1)]
if not isinstance(msg, basestring):
print "vimtern_do: msg is not a string."
print "msg: ", msg
exit(1)
# Build JSON message payload
msg = msg.replace('"', '').strip()
channel = config["Slack"]["channel"]
username = config["Slack"]["username"]
icon_emoji = config["Slack"]["icon_emoji"]
payload = json.dumps({
"text": msg,
"channel": channel,
"username": username,
"icon_emoji": icon_emoji,
"parse": "full"
})
# Create and send POST request to Slack webhook
slack_uri = config['Slack']['uri']
try:
r = requests.post(slack_uri, data=payload, headers={
'Content-type': 'application/json'})
r.raise_for_status()
except requests.exceptions.ConnectionError:
print "Could not establish connection to Slack."
exit(1)
except requests.exceptions.HTTPError as err:
print "Slack API request was not successful."
print err.message
exit(1)
except requests.exceptions.Timeout:
print "Slack API request timed out."
exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-f",
"--config",
dest='config',
help="Path to the .intrn config file.")
parser.add_argument("-m",
"--msg",
dest='msg',
help="Message to send.",
default="")
parser.add_argument('-v',
'--verbose',
dest='verbose',
action='store_true',
help='Verbose mode to help debug.')
parser.set_defaults(verbose=False)
args = parser.parse_args()
VERBOSE = args.verbose
if VERBOSE:
print "ARGS: ", argv
try:
vimtern_do(args.msg, args.config)
except Exception, e:
print str(e)
parser.print_help()
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
7061,
6,
198,
53,
3955,
51,
1142,
13,
9078,
27965,
670,
284,
534,
1788,
2884,
36256,
422,
262,
3141,
1627,
13,
198,
7061,
6,
198,
6738,
4738,
1330,
43720,
600,
198,
6738,
25064,
1330,
8420,
11,
1822,
85,
198,
11748,
1822,
29572,
198,
11748,
33918,
198,
11748,
331,
43695,
220,
1303,
1675,
3440,
262,
9913,
77,
2393,
198,
198,
5959,
33,
14058,
796,
10352,
198,
198,
28311,
25,
198,
220,
220,
220,
1330,
7007,
198,
16341,
17267,
12331,
25,
198,
220,
220,
220,
3601,
366,
3118,
540,
284,
1330,
7007,
13,
5660,
4600,
79,
541,
2721,
7007,
63,
526,
198,
220,
220,
220,
8420,
7,
16,
8,
628,
198,
4299,
4808,
2220,
62,
600,
35906,
7,
600,
35906,
62,
7753,
2625,
12286,
13,
600,
35906,
1,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
8778,
262,
4566,
2393,
13,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
4566,
796,
6045,
198,
220,
220,
220,
351,
1280,
7,
600,
35906,
62,
7753,
11,
705,
81,
11537,
355,
4269,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4566,
796,
331,
43695,
13,
2220,
7,
5532,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
331,
43695,
13,
56,
2390,
2538,
81,
1472,
355,
409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
965,
7,
1069,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8420,
7,
16,
8,
198,
220,
220,
220,
1441,
4566,
628,
198,
4299,
43907,
759,
62,
4598,
7,
19662,
11,
9913,
77,
62,
7753,
2599,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
18232,
9729,
284,
352,
77,
759,
13,
198,
220,
220,
220,
705,
7061,
198,
220,
220,
220,
3298,
33310,
33,
14058,
198,
220,
220,
220,
611,
407,
9913,
77,
62,
7753,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
3460,
4163,
12331,
7203,
15235,
284,
764,
600,
35906,
2393,
2672,
19570,
198,
220,
220,
220,
4566,
796,
4808,
2220,
62,
600,
35906,
7,
600,
35906,
62,
7753,
8,
198,
220,
220,
220,
611,
407,
31456,
393,
31456,
6624,
10148,
25,
198,
220,
220,
220,
220,
220,
220,
220,
997,
796,
18896,
7,
11250,
14692,
12286,
62,
907,
14542,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
31456,
796,
4566,
14692,
12286,
62,
907,
14542,
1,
7131,
25192,
600,
7,
15,
11,
997,
532,
352,
15437,
198,
220,
220,
220,
611,
407,
318,
39098,
7,
19662,
11,
1615,
395,
1806,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
31124,
759,
62,
4598,
25,
31456,
318,
407,
257,
4731,
526,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
19662,
25,
33172,
31456,
198,
220,
220,
220,
220,
220,
220,
220,
8420,
7,
16,
8,
628,
220,
220,
220,
1303,
10934,
19449,
3275,
21437,
198,
220,
220,
220,
31456,
796,
31456,
13,
33491,
10786,
1,
3256,
10148,
737,
36311,
3419,
198,
220,
220,
220,
6518,
796,
4566,
14692,
11122,
441,
1,
7131,
1,
17620,
8973,
198,
220,
220,
220,
20579,
796,
4566,
14692,
11122,
441,
1,
7131,
1,
29460,
8973,
198,
220,
220,
220,
7196,
62,
368,
31370,
796,
4566,
14692,
11122,
441,
1,
7131,
1,
4749,
62,
368,
31370,
8973,
198,
220,
220,
220,
21437,
796,
33918,
13,
67,
8142,
15090,
198,
220,
220,
220,
220,
220,
220,
220,
366,
5239,
1298,
31456,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
17620,
1298,
6518,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
29460,
1298,
20579,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
4749,
62,
368,
31370,
1298,
7196,
62,
368,
31370,
11,
198,
220,
220,
220,
220,
220,
220,
220,
366,
29572,
1298,
366,
12853,
1,
198,
220,
220,
220,
32092,
628,
220,
220,
220,
1303,
13610,
290,
3758,
24582,
2581,
284,
36256,
3992,
25480,
198,
220,
220,
220,
30740,
62,
9900,
796,
4566,
17816,
11122,
441,
6,
7131,
6,
9900,
20520,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
374,
796,
7007,
13,
7353,
7,
6649,
441,
62,
9900,
11,
1366,
28,
15577,
2220,
11,
24697,
34758,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
19746,
12,
4906,
10354,
705,
31438,
14,
17752,
6,
30072,
198,
220,
220,
220,
220,
220,
220,
220,
374,
13,
40225,
62,
1640,
62,
13376,
3419,
198,
220,
220,
220,
2845,
7007,
13,
1069,
11755,
13,
32048,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
23722,
407,
4474,
4637,
284,
36256,
526,
198,
220,
220,
220,
220,
220,
220,
220,
8420,
7,
16,
8,
198,
220,
220,
220,
2845,
7007,
13,
1069,
11755,
13,
40717,
12331,
355,
11454,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
11122,
441,
7824,
2581,
373,
407,
4388,
526,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
11454,
13,
20500,
198,
220,
220,
220,
220,
220,
220,
220,
8420,
7,
16,
8,
198,
220,
220,
220,
2845,
7007,
13,
1069,
11755,
13,
48031,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
11122,
441,
7824,
2581,
28805,
503,
526,
198,
220,
220,
220,
220,
220,
220,
220,
8420,
7,
16,
8,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
30751,
796,
1822,
29572,
13,
28100,
1713,
46677,
3419,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
7203,
12,
69,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
11250,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2244,
11639,
11250,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
15235,
284,
262,
764,
600,
35906,
4566,
2393,
19570,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
7203,
12,
76,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
19662,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2244,
11639,
19662,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
12837,
284,
3758,
33283,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
2625,
4943,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
12,
85,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
438,
19011,
577,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2244,
11639,
19011,
577,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2223,
11639,
8095,
62,
7942,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
11639,
13414,
65,
577,
4235,
284,
1037,
14257,
2637,
8,
198,
220,
220,
220,
30751,
13,
2617,
62,
12286,
82,
7,
19011,
577,
28,
25101,
8,
198,
220,
220,
220,
26498,
796,
30751,
13,
29572,
62,
22046,
3419,
628,
220,
220,
220,
33310,
33,
14058,
796,
26498,
13,
19011,
577,
628,
220,
220,
220,
611,
33310,
33,
14058,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
366,
1503,
14313,
25,
33172,
1822,
85,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
43907,
759,
62,
4598,
7,
22046,
13,
19662,
11,
26498,
13,
11250,
8,
198,
220,
220,
220,
2845,
35528,
11,
304,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
965,
7,
68,
8,
198,
220,
220,
220,
220,
220,
220,
220,
30751,
13,
4798,
62,
16794,
3419,
198
] | 2.134454 | 1,428 |
from numpy import array | [
6738,
299,
32152,
1330,
7177
] | 4.6 | 5 |
import stripe
from stripe.test.helper import StripeResourceTest
| [
11748,
39858,
198,
6738,
39858,
13,
9288,
13,
2978,
525,
1330,
26137,
431,
26198,
14402,
628
] | 4.0625 | 16 |
"""
Created on 10 Nov 2018
@author: Bruno Beloff ([email protected])
a dummy LED state, to maintain compatibility with the DFE Eng package
"""
from collections import OrderedDict
from scs_core.data.json import JSONable
# --------------------------------------------------------------------------------------------------------------------
class LEDState(JSONable):
"""
classdocs
"""
# ----------------------------------------------------------------------------------------------------------------
@classmethod
# ----------------------------------------------------------------------------------------------------------------
# noinspection PyUnusedLocal
def __init__(self, colour0, colour1):
"""
Constructor
"""
pass
# ----------------------------------------------------------------------------------------------------------------
@classmethod
# ----------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
@property
@property
# ----------------------------------------------------------------------------------------------------------------
| [
37811,
198,
41972,
319,
838,
5267,
2864,
198,
198,
31,
9800,
25,
31045,
3944,
2364,
357,
1671,
36909,
13,
6667,
2364,
31,
35782,
1073,
5773,
4234,
13,
785,
8,
198,
198,
64,
31548,
12365,
1181,
11,
284,
5529,
17764,
351,
262,
360,
15112,
1985,
5301,
198,
37811,
198,
198,
6738,
17268,
1330,
14230,
1068,
35,
713,
198,
198,
6738,
629,
82,
62,
7295,
13,
7890,
13,
17752,
1330,
19449,
540,
628,
198,
2,
16529,
3880,
19351,
198,
198,
4871,
12365,
9012,
7,
40386,
540,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1398,
31628,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
1303,
16529,
47232,
628,
220,
220,
220,
2488,
4871,
24396,
628,
198,
220,
220,
220,
1303,
16529,
47232,
628,
220,
220,
220,
1303,
645,
1040,
14978,
9485,
3118,
1484,
14565,
198,
220,
220,
220,
825,
11593,
15003,
834,
7,
944,
11,
9568,
15,
11,
9568,
16,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
28407,
273,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1208,
628,
198,
220,
220,
220,
1303,
16529,
47232,
628,
220,
220,
220,
2488,
4871,
24396,
628,
198,
220,
220,
220,
1303,
16529,
47232,
628,
198,
220,
220,
220,
1303,
16529,
47232,
628,
220,
220,
220,
2488,
26745,
628,
198,
220,
220,
220,
2488,
26745,
628,
198,
220,
220,
220,
1303,
16529,
47232,
198
] | 5.549587 | 242 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Les boucles et les instruction de contrôle
Quelques exemples de manipulations des boucles et des instructions
"""
# la suite de fibonnaci
a, b = 0, 1
while a < 20:
print(a, end=",") # on idente de 4 espace l'instruction suivante
a, b = b, a+b
print()
if a == 21:
print("_")
elif a == 13: # 'else if' se note 'elif' en python
print("°")
else:
print(")")
# Un peu d'unicode ;) et des boucles for
words = ["Bonjour", "Jeune", "Padawan"]
for w in words:
if w == "Yoda":
break # le 'break' permet de sortie de la boucle,
else: # par contre on passe dans le 'else' si le break
# n'est jamais appelé dans la boucle for'
# ici on utilise le r de raw_string
st = r"""
____
(xXXXX|xx======---(-
/ |
/ XX|
/xxx XXX|
/xxx X |
/ ________|
__ ____/_|_|_______\_
###|=||________|_________|_
~~ |==| __ _ __ /|~~~~~~~~~-------------_______
|==| ||(( ||()| | |XXXXXXXX| >
__ |==| ~~__~__~~__ \|_________-------------~~~~~~~
###|=||~~~~~~~~|_______ |"
~~ ~~~~\~|~| /~
\ ~~~~~~~~~
\xxx X |
\xxx XXX|
\ XX| Incom's T-65B X-wing Space
\ | Superiority Starfighter (4)
(xXXXX|xx======---(-
~~~~"""
print(st)
# on peut aussi utiliser range dans la même idée
# que la boucle for(i = 0; i < words.length; i++) dans d'autres langage
for i in range(len(words)):
print(words[i], len(words[i]))
# exemple de range qui est objet iterable,
# et pas une liste à proprement parlée
range(5) # 0, 1, 2, 3, 4
range(5, 10) # 5, 6, 7, 8, 9
range(0, 10, 3) # 0, 3, 6, 9
range(-10, -100, -30) # -10, -40, -70
# mot clé 'pass'
a = 9
if a < 10:
pass # 'pass' ne fait rien, mais est parfois nécessaire après une instruction
# TODO : Afficher un message d'erreur...
else:
print("a supérieur a 10")
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
198,
37811,
35882,
35833,
5427,
2123,
10287,
12064,
390,
3445,
27083,
293,
198,
198,
48,
2731,
13281,
409,
368,
2374,
390,
7704,
5768,
748,
35833,
5427,
2123,
748,
7729,
198,
37811,
198,
198,
2,
8591,
18389,
390,
12900,
261,
77,
32009,
198,
64,
11,
275,
796,
657,
11,
352,
198,
4514,
257,
1279,
1160,
25,
198,
220,
220,
220,
3601,
7,
64,
11,
886,
28,
2430,
8,
220,
220,
220,
220,
220,
220,
1303,
319,
1852,
68,
390,
604,
1658,
10223,
300,
6,
8625,
2762,
424,
452,
12427,
198,
220,
220,
220,
257,
11,
275,
796,
275,
11,
257,
10,
65,
198,
4798,
3419,
198,
198,
361,
257,
6624,
2310,
25,
198,
220,
220,
220,
3601,
7203,
62,
4943,
198,
417,
361,
257,
6624,
1511,
25,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
705,
17772,
611,
6,
384,
3465,
705,
417,
361,
6,
551,
21015,
198,
220,
220,
220,
3601,
7203,
7200,
4943,
198,
17772,
25,
198,
220,
220,
220,
3601,
7,
4943,
4943,
628,
198,
2,
791,
613,
84,
288,
6,
46903,
1098,
35540,
2123,
748,
35833,
5427,
329,
198,
10879,
796,
14631,
20682,
73,
454,
1600,
366,
40932,
1726,
1600,
366,
26114,
43004,
8973,
198,
1640,
266,
287,
2456,
25,
198,
220,
220,
220,
611,
266,
6624,
366,
56,
11329,
1298,
198,
220,
220,
220,
220,
220,
220,
220,
2270,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
443,
705,
9032,
6,
583,
4164,
390,
3297,
494,
390,
8591,
35833,
2375,
11,
198,
17772,
25,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1582,
542,
260,
319,
279,
21612,
288,
504,
443,
705,
17772,
6,
33721,
443,
2270,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
299,
6,
395,
474,
1689,
271,
598,
417,
2634,
288,
504,
8591,
35833,
2375,
329,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
14158,
72,
319,
7736,
786,
443,
374,
390,
8246,
62,
8841,
198,
220,
220,
220,
336,
796,
374,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1427,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
87,
24376,
91,
5324,
50155,
6329,
32590,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1220,
220,
220,
220,
220,
930,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1220,
220,
220,
220,
21044,
91,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1220,
31811,
27713,
91,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1220,
31811,
1395,
220,
220,
930,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1220,
220,
2602,
91,
198,
220,
220,
220,
220,
220,
220,
220,
11593,
220,
1427,
47835,
91,
62,
91,
37405,
59,
62,
198,
220,
220,
220,
44386,
91,
28,
15886,
2602,
91,
2602,
62,
91,
62,
198,
220,
220,
220,
220,
220,
220,
220,
220,
4907,
220,
220,
930,
855,
91,
11593,
220,
4808,
220,
11593,
220,
220,
1220,
91,
15116,
93,
32501,
37405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
855,
91,
8614,
19510,
8614,
3419,
91,
930,
930,
24376,
24376,
91,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1875,
198,
220,
220,
220,
220,
220,
220,
220,
11593,
220,
220,
930,
855,
91,
220,
4907,
834,
93,
834,
4907,
834,
3467,
91,
2602,
62,
32501,
8728,
4907,
93,
198,
220,
220,
220,
44386,
91,
28,
15886,
15116,
91,
37405,
220,
930,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
4907,
220,
8728,
59,
93,
91,
93,
91,
220,
220,
220,
220,
220,
220,
1220,
93,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
220,
15116,
93,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
31811,
1395,
220,
220,
930,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
31811,
27713,
91,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
220,
220,
220,
21044,
91,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
554,
785,
338,
309,
12,
2996,
33,
1395,
12,
5469,
4687,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
220,
220,
220,
220,
930,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
22953,
414,
2907,
24733,
357,
19,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
87,
24376,
91,
5324,
50155,
6329,
32590,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8728,
37811,
198,
220,
220,
220,
3601,
7,
301,
8,
628,
198,
2,
319,
613,
315,
257,
1046,
72,
7736,
5847,
2837,
288,
504,
8591,
285,
25792,
1326,
4686,
22161,
198,
2,
8358,
8591,
35833,
2375,
329,
7,
72,
796,
657,
26,
1312,
1279,
2456,
13,
13664,
26,
1312,
29577,
288,
504,
288,
6,
2306,
411,
42392,
496,
198,
1640,
1312,
287,
2837,
7,
11925,
7,
10879,
8,
2599,
198,
220,
220,
220,
3601,
7,
10879,
58,
72,
4357,
18896,
7,
10879,
58,
72,
60,
4008,
628,
198,
2,
409,
368,
1154,
390,
2837,
45567,
1556,
26181,
316,
11629,
540,
11,
198,
2,
2123,
38836,
17809,
1351,
68,
28141,
2632,
260,
434,
1582,
75,
22161,
198,
9521,
7,
20,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
657,
11,
352,
11,
362,
11,
513,
11,
604,
198,
9521,
7,
20,
11,
838,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
642,
11,
718,
11,
767,
11,
807,
11,
860,
198,
9521,
7,
15,
11,
838,
11,
513,
8,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
657,
11,
513,
11,
718,
11,
860,
198,
9521,
32590,
940,
11,
532,
3064,
11,
532,
1270,
8,
220,
220,
1303,
532,
940,
11,
532,
1821,
11,
532,
2154,
628,
198,
2,
2369,
537,
2634,
705,
6603,
6,
198,
64,
796,
860,
198,
361,
257,
1279,
838,
25,
198,
220,
220,
220,
1208,
220,
220,
220,
220,
220,
220,
220,
1303,
705,
6603,
6,
497,
277,
4548,
374,
2013,
11,
285,
15152,
1556,
1582,
6513,
271,
299,
2634,
919,
7626,
46593,
14064,
82,
17809,
12064,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
16926,
46,
1058,
317,
2108,
372,
555,
3275,
288,
6,
263,
260,
333,
986,
198,
17772,
25,
198,
220,
220,
220,
3601,
7203,
64,
7418,
2634,
5034,
333,
257,
838,
4943,
198
] | 1.794793 | 1,306 |
import time
| [
11748,
640,
628
] | 4.333333 | 3 |
"""Setup."""
from setuptools import setup, find_packages
inst_reqs = [
"mercantile == 1.1.5",
"requests",
"geojson",
"pillow",
"gdal == 2.4.2",
"shapely == 1.6.4",
"affine == 2.3.0",
"numpy == 1.19.0",
"rasterio == 1.1.5"
]
extra_reqs = {"test": ["pytest", "pytest-cov"]}
setup(
name="app",
version="0.5.0",
description=u"Lambda Download and Predict",
python_requires=">=3",
keywords="AWS-Lambda Python",
packages=find_packages(exclude=["ez_setup", "examples", "tests"]),
include_package_data=True,
zip_safe=False,
install_requires=inst_reqs,
extras_require=extra_reqs,
)
| [
37811,
40786,
526,
15931,
198,
198,
6738,
900,
37623,
10141,
1330,
9058,
11,
1064,
62,
43789,
198,
198,
8625,
62,
42180,
82,
796,
685,
198,
220,
220,
220,
366,
647,
66,
415,
576,
6624,
352,
13,
16,
13,
20,
1600,
198,
220,
220,
220,
366,
8897,
3558,
1600,
198,
220,
220,
220,
366,
469,
13210,
1559,
1600,
198,
220,
220,
220,
366,
27215,
322,
1600,
198,
220,
220,
220,
366,
21287,
282,
6624,
362,
13,
19,
13,
17,
1600,
198,
220,
220,
220,
366,
43358,
306,
6624,
352,
13,
21,
13,
19,
1600,
198,
220,
220,
220,
366,
2001,
500,
6624,
362,
13,
18,
13,
15,
1600,
198,
220,
220,
220,
366,
77,
32152,
6624,
352,
13,
1129,
13,
15,
1600,
220,
198,
220,
220,
220,
366,
81,
1603,
952,
6624,
352,
13,
16,
13,
20,
1,
198,
60,
198,
26086,
62,
42180,
82,
796,
19779,
9288,
1298,
14631,
9078,
9288,
1600,
366,
9078,
9288,
12,
66,
709,
8973,
92,
198,
198,
40406,
7,
198,
220,
220,
220,
1438,
2625,
1324,
1600,
198,
220,
220,
220,
2196,
2625,
15,
13,
20,
13,
15,
1600,
198,
220,
220,
220,
6764,
28,
84,
1,
43,
4131,
6814,
10472,
290,
49461,
1600,
198,
220,
220,
220,
21015,
62,
47911,
2625,
29,
28,
18,
1600,
198,
220,
220,
220,
26286,
2625,
12298,
50,
12,
43,
4131,
6814,
11361,
1600,
198,
220,
220,
220,
10392,
28,
19796,
62,
43789,
7,
1069,
9152,
28,
14692,
8471,
62,
40406,
1600,
366,
1069,
12629,
1600,
366,
41989,
8973,
828,
198,
220,
220,
220,
2291,
62,
26495,
62,
7890,
28,
17821,
11,
198,
220,
220,
220,
19974,
62,
21230,
28,
25101,
11,
198,
220,
220,
220,
2721,
62,
47911,
28,
8625,
62,
42180,
82,
11,
198,
220,
220,
220,
33849,
62,
46115,
28,
26086,
62,
42180,
82,
11,
198,
8,
198
] | 2.15894 | 302 |
# Copyright 2022 Yan Yan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from cumm.core_cc.tensorview_bind import (NVRTCParams, GemmAlgoDesp,
ConvAlgoDesp, ConvParams, ConvOpType,
ConvLayoutType, ShuffleStrideType,
ConvMode, run_nvrtc_conv_kernel,
GemmParams, run_nvrtc_gemm_kernel)
| [
2,
15069,
33160,
10642,
10642,
198,
2,
198,
2,
49962,
739,
262,
24843,
13789,
11,
10628,
362,
13,
15,
357,
1169,
366,
34156,
15341,
198,
2,
345,
743,
407,
779,
428,
2393,
2845,
287,
11846,
351,
262,
13789,
13,
198,
2,
921,
743,
7330,
257,
4866,
286,
262,
13789,
379,
198,
2,
198,
2,
220,
220,
220,
220,
2638,
1378,
2503,
13,
43073,
13,
2398,
14,
677,
4541,
14,
43,
2149,
24290,
12,
17,
13,
15,
198,
2,
198,
2,
17486,
2672,
416,
9723,
1099,
393,
4987,
284,
287,
3597,
11,
3788,
198,
2,
9387,
739,
262,
13789,
318,
9387,
319,
281,
366,
1921,
3180,
1,
29809,
1797,
11,
198,
2,
42881,
34764,
11015,
6375,
7102,
49828,
11053,
3963,
15529,
509,
12115,
11,
2035,
4911,
393,
17142,
13,
198,
2,
4091,
262,
13789,
329,
262,
2176,
3303,
15030,
21627,
290,
198,
2,
11247,
739,
262,
13789,
13,
198,
198,
6738,
10973,
76,
13,
7295,
62,
535,
13,
83,
22854,
1177,
62,
21653,
1330,
357,
45,
13024,
4825,
10044,
4105,
11,
15669,
76,
2348,
2188,
5960,
79,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
34872,
2348,
2188,
5960,
79,
11,
34872,
10044,
4105,
11,
34872,
18257,
6030,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
34872,
32517,
6030,
11,
911,
18137,
1273,
13154,
6030,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
34872,
19076,
11,
1057,
62,
48005,
17034,
66,
62,
42946,
62,
33885,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
15669,
76,
10044,
4105,
11,
1057,
62,
48005,
17034,
66,
62,
24090,
76,
62,
33885,
8,
198
] | 2.380952 | 399 |
#!/bin/python3
# author: Jan Hybs
from loguru import logger
from flask_restful import Resource
from cihpc.common.utils import strings
from cihpc.common.utils import datautils as du
| [
2,
48443,
8800,
14,
29412,
18,
198,
2,
1772,
25,
2365,
6707,
1443,
198,
198,
6738,
2604,
14717,
1330,
49706,
628,
198,
6738,
42903,
62,
2118,
913,
1330,
20857,
198,
6738,
269,
4449,
14751,
13,
11321,
13,
26791,
1330,
13042,
198,
6738,
269,
4449,
14751,
13,
11321,
13,
26791,
1330,
1366,
26791,
355,
7043,
628
] | 3.363636 | 55 |
from spinn_machine.utilities.progress_bar import ProgressBar
from spinn_front_end_common.abstract_models.\
abstract_data_specable_vertex import AbstractDataSpecableVertex
from spinn_front_end_common.utilities.utility_objs.executable_targets import \
ExecutableTargets
from spinn_front_end_common.utilities import exceptions
class FrontEndCommonPartitionableGraphDataSpecificationWriter(object):
""" Executes a partitionable graph data specification generation
"""
def __call__(
self, placements, graph_mapper, tags, executable_finder,
partitioned_graph, partitionable_graph, routing_infos, hostname,
report_default_directory, write_text_specs,
app_data_runtime_folder):
""" generates the dsg for the graph.
:return:
"""
# iterate though subvertices and call generate_data_spec for each
# vertex
executable_targets = ExecutableTargets()
dsg_targets = dict()
# create a progress bar for end users
progress_bar = ProgressBar(len(list(placements.placements)),
"Generating data specifications")
for placement in placements.placements:
associated_vertex = graph_mapper.get_vertex_from_subvertex(
placement.subvertex)
self._generate_data_spec_for_subvertices(
placement, associated_vertex, executable_targets, dsg_targets,
graph_mapper, tags, executable_finder, partitioned_graph,
partitionable_graph, routing_infos, hostname,
report_default_directory, write_text_specs,
app_data_runtime_folder)
progress_bar.update()
# finish the progress bar
progress_bar.end()
return {'executable_targets': executable_targets,
'dsg_targets': dsg_targets}
| [
6738,
599,
3732,
62,
30243,
13,
315,
2410,
13,
33723,
62,
5657,
1330,
18387,
10374,
198,
198,
6738,
599,
3732,
62,
8534,
62,
437,
62,
11321,
13,
397,
8709,
62,
27530,
13,
59,
198,
220,
220,
220,
12531,
62,
7890,
62,
16684,
540,
62,
332,
16886,
1330,
27741,
6601,
22882,
540,
13414,
16886,
198,
6738,
599,
3732,
62,
8534,
62,
437,
62,
11321,
13,
315,
2410,
13,
315,
879,
62,
672,
8457,
13,
18558,
18187,
62,
83,
853,
1039,
1330,
3467,
198,
220,
220,
220,
8393,
18187,
51,
853,
1039,
198,
6738,
599,
3732,
62,
8534,
62,
437,
62,
11321,
13,
315,
2410,
1330,
13269,
628,
198,
4871,
8880,
12915,
17227,
7841,
653,
540,
37065,
6601,
22882,
2649,
34379,
7,
15252,
2599,
198,
220,
220,
220,
37227,
8393,
1769,
257,
18398,
540,
4823,
1366,
20855,
5270,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
825,
11593,
13345,
834,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
11,
21957,
3196,
11,
4823,
62,
76,
11463,
11,
15940,
11,
28883,
62,
22805,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18398,
276,
62,
34960,
11,
18398,
540,
62,
34960,
11,
28166,
62,
10745,
418,
11,
2583,
3672,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
989,
62,
12286,
62,
34945,
11,
3551,
62,
5239,
62,
4125,
6359,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
598,
62,
7890,
62,
43282,
62,
43551,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
18616,
262,
288,
45213,
329,
262,
4823,
13,
628,
220,
220,
220,
220,
220,
220,
220,
1058,
7783,
25,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
11629,
378,
996,
850,
1851,
1063,
290,
869,
7716,
62,
7890,
62,
16684,
329,
1123,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
37423,
198,
220,
220,
220,
220,
220,
220,
220,
28883,
62,
83,
853,
1039,
796,
8393,
18187,
51,
853,
1039,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
288,
45213,
62,
83,
853,
1039,
796,
8633,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
2251,
257,
4371,
2318,
329,
886,
2985,
198,
220,
220,
220,
220,
220,
220,
220,
4371,
62,
5657,
796,
18387,
10374,
7,
11925,
7,
4868,
7,
489,
28613,
13,
489,
28613,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
8645,
803,
1366,
20640,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
329,
13127,
287,
21957,
3196,
13,
489,
28613,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3917,
62,
332,
16886,
796,
4823,
62,
76,
11463,
13,
1136,
62,
332,
16886,
62,
6738,
62,
7266,
332,
16886,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13127,
13,
7266,
332,
16886,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
8612,
378,
62,
7890,
62,
16684,
62,
1640,
62,
7266,
1851,
1063,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13127,
11,
3917,
62,
332,
16886,
11,
28883,
62,
83,
853,
1039,
11,
288,
45213,
62,
83,
853,
1039,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4823,
62,
76,
11463,
11,
15940,
11,
28883,
62,
22805,
11,
18398,
276,
62,
34960,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18398,
540,
62,
34960,
11,
28166,
62,
10745,
418,
11,
2583,
3672,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
989,
62,
12286,
62,
34945,
11,
3551,
62,
5239,
62,
4125,
6359,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
598,
62,
7890,
62,
43282,
62,
43551,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4371,
62,
5657,
13,
19119,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
5461,
262,
4371,
2318,
198,
220,
220,
220,
220,
220,
220,
220,
4371,
62,
5657,
13,
437,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
1391,
6,
18558,
18187,
62,
83,
853,
1039,
10354,
28883,
62,
83,
853,
1039,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
9310,
70,
62,
83,
853,
1039,
10354,
288,
45213,
62,
83,
853,
1039,
92,
198
] | 2.395965 | 793 |
# -*- coding: utf-8 -*-
import io, json
from pathlib import Path
class ColorRegistry:
"""
Open, read and store color names maps
Default shipped color registry is used on loading if no specific path is
given to ``load`` method.
"""
def load(self, path=None):
"""
Load registry and set maps
Keyword args:
path (pathlib.Path): Optionnal path object to open instead of
default of from ``ColorRegistry.map_path``.
"""
names = self.get_registry_file(path or self.map_path)
self.name_map, self.hexa_map = self.get_registry_maps(names)
def get_registry_file(self, path):
"""
Open registry file from given path
Args:
path (pathlib.Path): Path object to open.
Returns:
list: List of map items from registry.
"""
with io.open(str(path), 'r') as fp:
registry_map = json.load(fp)
return registry_map
def get_registry_maps(self, items):
"""
From registry items build maps, one indexed on name, another
one indexed on color.
Args:
items (list): Registry items
Returns:
tuple: First item is the names map, second item is the colors map.
Both are list object.
"""
name_map = items
# Reverse keys/values so map is indexed on hexa
hexa_map = list(zip([v for k,v in items], [k for k,v in items]))
return name_map, hexa_map
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
11748,
33245,
11,
33918,
198,
198,
6738,
3108,
8019,
1330,
10644,
628,
198,
4871,
5315,
8081,
4592,
25,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
4946,
11,
1100,
290,
3650,
3124,
3891,
8739,
628,
220,
220,
220,
15161,
14338,
3124,
20478,
318,
973,
319,
11046,
611,
645,
2176,
3108,
318,
198,
220,
220,
220,
1813,
284,
7559,
2220,
15506,
2446,
13,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
825,
3440,
7,
944,
11,
3108,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
8778,
20478,
290,
900,
8739,
628,
220,
220,
220,
220,
220,
220,
220,
7383,
4775,
26498,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3108,
357,
6978,
8019,
13,
15235,
2599,
16018,
77,
282,
3108,
2134,
284,
1280,
2427,
286,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
286,
422,
7559,
10258,
8081,
4592,
13,
8899,
62,
6978,
15506,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
3891,
796,
2116,
13,
1136,
62,
2301,
4592,
62,
7753,
7,
6978,
393,
2116,
13,
8899,
62,
6978,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
3672,
62,
8899,
11,
2116,
13,
258,
27865,
62,
8899,
796,
2116,
13,
1136,
62,
2301,
4592,
62,
31803,
7,
14933,
8,
628,
220,
220,
220,
825,
651,
62,
2301,
4592,
62,
7753,
7,
944,
11,
3108,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
4946,
20478,
2393,
422,
1813,
3108,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3108,
357,
6978,
8019,
13,
15235,
2599,
10644,
2134,
284,
1280,
13,
628,
220,
220,
220,
220,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1351,
25,
7343,
286,
3975,
3709,
422,
20478,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
351,
33245,
13,
9654,
7,
2536,
7,
6978,
828,
705,
81,
11537,
355,
277,
79,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20478,
62,
8899,
796,
33918,
13,
2220,
7,
46428,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
20478,
62,
8899,
628,
220,
220,
220,
825,
651,
62,
2301,
4592,
62,
31803,
7,
944,
11,
3709,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
3574,
20478,
3709,
1382,
8739,
11,
530,
41497,
319,
1438,
11,
1194,
198,
220,
220,
220,
220,
220,
220,
220,
530,
41497,
319,
3124,
13,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3709,
357,
4868,
2599,
33432,
3709,
628,
220,
220,
220,
220,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
46545,
25,
3274,
2378,
318,
262,
3891,
3975,
11,
1218,
2378,
318,
262,
7577,
3975,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5747,
389,
1351,
2134,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1438,
62,
8899,
796,
3709,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
31849,
8251,
14,
27160,
523,
3975,
318,
41497,
319,
17910,
64,
198,
220,
220,
220,
220,
220,
220,
220,
17910,
64,
62,
8899,
796,
1351,
7,
13344,
26933,
85,
329,
479,
11,
85,
287,
3709,
4357,
685,
74,
329,
479,
11,
85,
287,
3709,
60,
4008,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
1438,
62,
8899,
11,
17910,
64,
62,
8899,
198
] | 2.305847 | 667 |
#-*-coding:utf-8-*-
from futuquant import *
import pandas
if __name__ == '__main__':
GetMulHtryKl().test1() | [
2,
12,
9,
12,
66,
7656,
25,
40477,
12,
23,
12,
9,
12,
198,
198,
6738,
13294,
84,
40972,
1330,
1635,
198,
11748,
19798,
292,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
3497,
44,
377,
39,
28311,
42,
75,
22446,
9288,
16,
3419
] | 2.169811 | 53 |
#!/usr/bin/env python3
# Copyright (c) 2021 oatsu
"""
連続音歌詞を空白で区切って単独音にするUTAUプラグイン
"""
import utaupy
def ren2tan(plugin):
"""
歌詞を空白で区切って、空白より後ろ側だけ残す。
"""
for note in plugin.notes:
note.lyric = note.lyric.split()[-1]
if __name__ == '__main__':
utaupy.utauplugin.run(ren2tan)
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
2,
15069,
357,
66,
8,
33448,
267,
19231,
198,
37811,
198,
34460,
96,
163,
114,
21253,
253,
111,
29826,
234,
164,
102,
252,
31758,
163,
102,
118,
163,
50159,
30640,
44293,
118,
26344,
229,
33180,
28134,
39355,
246,
45379,
105,
165,
253,
111,
28618,
33623,
25748,
3843,
26830,
30965,
9263,
26095,
11482,
6527,
198,
37811,
628,
198,
11748,
3384,
559,
9078,
628,
198,
4299,
8851,
17,
38006,
7,
33803,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
10545,
255,
234,
164,
102,
252,
31758,
163,
102,
118,
163,
50159,
30640,
44293,
118,
26344,
229,
33180,
28134,
23513,
163,
102,
118,
163,
50159,
1792,
230,
28255,
36181,
234,
1792,
235,
161,
223,
112,
46777,
2515,
239,
162,
106,
233,
33623,
16764,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
329,
3465,
287,
13877,
13,
17815,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3465,
13,
306,
1173,
796,
3465,
13,
306,
1173,
13,
35312,
3419,
58,
12,
16,
60,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
3384,
559,
9078,
13,
315,
559,
33803,
13,
5143,
7,
918,
17,
38006,
8,
198
] | 1.517241 | 203 |
import cupy
def empty(shape, dtype=float):
"""Returns an array without initializing the elements.
This function currently does not support ``order`` option.
Args:
shape (tuple of ints): Dimensionalities of the array.
dtype: Data type specifier.
Returns:
cupy.ndarray: A new array with elements not initialized.
.. seealso:: :func:`numpy.empty`
"""
# TODO(beam2d): Support ordering option
return cupy.ndarray(shape, dtype=dtype)
def empty_like(a, dtype=None):
"""Returns a new array with same shape and dtype of a given array.
This function currently does not support ``order`` and ``subok`` options.
Args:
a (cupy.ndarray): Base array.
dtype: Data type specifier. The data type of ``a`` is used by default.
Returns:
cupy.ndarray: A new array with same shape and dtype of ``a`` with
elements not initialized.
.. seealso:: :func:`numpy.empty_like`
"""
# TODO(beam2d): Support ordering option
if dtype is None:
dtype = a.dtype
return empty(a.shape, dtype=dtype)
def eye(N, M=None, k=0, dtype=float):
"""Returns a 2-D array with ones on the diagonals and zeros elsewhere.
Args:
N (int): Number of rows.
M (int): Number of columns. M == N by default.
k (int): Index of the diagonal. Zero indicates the main diagonal,
a positive index an upper diagonal, and a negative index a lower
diagonal.
dtype: Data type specifier.
Returns:
cupy.ndarray: A 2-D array with given diagonals filled with ones and
zeros elsewhere.
.. seealso:: :func:`numpy.eye`
"""
if M is None:
M = N
ret = zeros((N, M), dtype)
ret.diagonal(k)[:] = 1
return ret
def identity(n, dtype=float):
"""Returns a 2-D identity array.
It is equivalent to ``eye(n, n, dtype)``.
Args:
n (int): Number of rows and columns.
dtype: Data type specifier.
Returns:
cupy.ndarray: A 2-D identity array.
.. seealso:: :func:`numpy.identity`
"""
return eye(n, dtype=dtype)
def ones(shape, dtype=float):
"""Returns a new array of given shape and dtype, filled with ones.
This function currently does not support ``order`` option.
Args:
shape (tuple of ints): Dimensionalities of the array.
dtype: Data type specifier.
Returns:
cupy.ndarray: An array filled with ones.
.. seealso:: :func:`numpy.ones`
"""
# TODO(beam2d): Support ordering option
return full(shape, 1, dtype)
def ones_like(a, dtype=None):
"""Returns an array of ones with same shape and dtype as a given array.
This function currently does not support ``order`` and ``subok`` options.
Args:
a (cupy.ndarray): Base array.
dtype: Data type specifier. The dtype of ``a`` is used by default.
Returns:
cupy.ndarray: An array filled with ones.
.. seealso:: :func:`numpy.ones_like`
"""
# TODO(beam2d): Support ordering option
if dtype is None:
dtype = a.dtype
return ones(a.shape, dtype)
def zeros(shape, dtype=float):
"""Returns a new array of given shape and dtype, filled with zeros.
This function currently does not support ``order`` option.
Args:
shape (tuple of ints): Dimensionalities of the array.
dtype: Data type specifier.
Returns:
cupy.ndarray: An array filled with ones.
.. seealso:: :func:`numpy.zeros`
"""
# TODO(beam2d): Support ordering option
a = empty(shape, dtype)
a.data.memset(0, a.nbytes)
return a
def zeros_like(a, dtype=None):
"""Returns an array of zeros with same shape and dtype as a given array.
This function currently does not support ``order`` and ``subok`` options.
Args:
a (cupy.ndarray): Base array.
dtype: Data type specifier. The dtype of ``a`` is used by default.
Returns:
cupy.ndarray: An array filled with ones.
.. seealso:: :func:`numpy.zeros_like`
"""
# TODO(beam2d): Support ordering option
if dtype is None:
dtype = a.dtype
return zeros(a.shape, dtype=dtype)
def full(shape, fill_value, dtype=None):
"""Returns a new array of given shape and dtype, filled with a given value.
This function currently does not support ``order`` option.
Args:
shape (tuple of ints): Dimensionalities of the array.
fill_value: A scalar value to fill a new array.
dtype: Data type specifier.
Returns:
cupy.ndarray: An array filled with ``fill_value``.
.. seealso:: :func:`numpy.full`
"""
# TODO(beam2d): Support ordering option
a = empty(shape, dtype)
a.fill(fill_value)
return a
def full_like(a, fill_value, dtype=None):
"""Returns a full array with same shape and dtype as a given array.
This function currently does not support ``order`` and ``subok`` options.
Args:
a (cupy.ndarray): Base array.
fill_value: A scalar value to fill a new array.
dtype: Data type specifier. The dtype of ``a`` is used by default.
Returns:
cupy.ndarray: An array filled with ``fill_value``.
.. seealso:: :func:`numpy.full_like`
"""
# TODO(beam2d): Support ordering option
if dtype is None:
dtype = a.dtype
return full(a.shape, fill_value, dtype)
| [
11748,
6508,
88,
628,
198,
4299,
6565,
7,
43358,
11,
288,
4906,
28,
22468,
2599,
198,
220,
220,
220,
37227,
35561,
281,
7177,
1231,
4238,
2890,
262,
4847,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
3038,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5485,
357,
83,
29291,
286,
493,
82,
2599,
360,
16198,
871,
286,
262,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
317,
649,
7177,
351,
4847,
407,
23224,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
28920,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
1441,
6508,
88,
13,
358,
18747,
7,
43358,
11,
288,
4906,
28,
67,
4906,
8,
628,
198,
4299,
6565,
62,
2339,
7,
64,
11,
288,
4906,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
257,
649,
7177,
351,
976,
5485,
290,
288,
4906,
286,
257,
1813,
7177,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
290,
7559,
7266,
482,
15506,
3689,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
257,
357,
25244,
88,
13,
358,
18747,
2599,
7308,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
383,
1366,
2099,
286,
7559,
64,
15506,
318,
973,
416,
4277,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
317,
649,
7177,
351,
976,
5485,
290,
288,
4906,
286,
7559,
64,
15506,
351,
198,
220,
220,
220,
220,
220,
220,
220,
4847,
407,
23224,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
28920,
62,
2339,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
611,
288,
4906,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
796,
257,
13,
67,
4906,
198,
220,
220,
220,
1441,
6565,
7,
64,
13,
43358,
11,
288,
4906,
28,
67,
4906,
8,
628,
198,
4299,
4151,
7,
45,
11,
337,
28,
14202,
11,
479,
28,
15,
11,
288,
4906,
28,
22468,
2599,
198,
220,
220,
220,
37227,
35561,
257,
362,
12,
35,
7177,
351,
3392,
319,
262,
2566,
1840,
874,
290,
1976,
27498,
8057,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
399,
357,
600,
2599,
7913,
286,
15274,
13,
198,
220,
220,
220,
220,
220,
220,
220,
337,
357,
600,
2599,
7913,
286,
15180,
13,
337,
6624,
399,
416,
4277,
13,
198,
220,
220,
220,
220,
220,
220,
220,
479,
357,
600,
2599,
12901,
286,
262,
40039,
13,
12169,
9217,
262,
1388,
40039,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
3967,
6376,
281,
6727,
40039,
11,
290,
257,
4633,
6376,
257,
2793,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
40039,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
317,
362,
12,
35,
7177,
351,
1813,
2566,
1840,
874,
5901,
351,
3392,
290,
198,
220,
220,
220,
220,
220,
220,
220,
1976,
27498,
8057,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
25379,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
337,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
337,
796,
399,
198,
220,
220,
220,
1005,
796,
1976,
27498,
19510,
45,
11,
337,
828,
288,
4906,
8,
198,
220,
220,
220,
1005,
13,
10989,
27923,
7,
74,
38381,
47715,
796,
352,
198,
220,
220,
220,
1441,
1005,
628,
198,
4299,
5369,
7,
77,
11,
288,
4906,
28,
22468,
2599,
198,
220,
220,
220,
37227,
35561,
257,
362,
12,
35,
5369,
7177,
13,
628,
220,
220,
220,
632,
318,
7548,
284,
7559,
25379,
7,
77,
11,
299,
11,
288,
4906,
8,
15506,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
299,
357,
600,
2599,
7913,
286,
15274,
290,
15180,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
317,
362,
12,
35,
5369,
7177,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
738,
414,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1441,
4151,
7,
77,
11,
288,
4906,
28,
67,
4906,
8,
628,
198,
4299,
3392,
7,
43358,
11,
288,
4906,
28,
22468,
2599,
198,
220,
220,
220,
37227,
35561,
257,
649,
7177,
286,
1813,
5485,
290,
288,
4906,
11,
5901,
351,
3392,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
3038,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5485,
357,
83,
29291,
286,
493,
82,
2599,
360,
16198,
871,
286,
262,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
3392,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
1952,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
1441,
1336,
7,
43358,
11,
352,
11,
288,
4906,
8,
628,
198,
4299,
3392,
62,
2339,
7,
64,
11,
288,
4906,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
281,
7177,
286,
3392,
351,
976,
5485,
290,
288,
4906,
355,
257,
1813,
7177,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
290,
7559,
7266,
482,
15506,
3689,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
257,
357,
25244,
88,
13,
358,
18747,
2599,
7308,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
383,
288,
4906,
286,
7559,
64,
15506,
318,
973,
416,
4277,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
3392,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
1952,
62,
2339,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
611,
288,
4906,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
796,
257,
13,
67,
4906,
198,
220,
220,
220,
1441,
3392,
7,
64,
13,
43358,
11,
288,
4906,
8,
628,
198,
4299,
1976,
27498,
7,
43358,
11,
288,
4906,
28,
22468,
2599,
198,
220,
220,
220,
37227,
35561,
257,
649,
7177,
286,
1813,
5485,
290,
288,
4906,
11,
5901,
351,
1976,
27498,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
3038,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5485,
357,
83,
29291,
286,
493,
82,
2599,
360,
16198,
871,
286,
262,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
3392,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
9107,
418,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
257,
796,
6565,
7,
43358,
11,
288,
4906,
8,
198,
220,
220,
220,
257,
13,
7890,
13,
11883,
2617,
7,
15,
11,
257,
13,
77,
33661,
8,
198,
220,
220,
220,
1441,
257,
628,
198,
4299,
1976,
27498,
62,
2339,
7,
64,
11,
288,
4906,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
281,
7177,
286,
1976,
27498,
351,
976,
5485,
290,
288,
4906,
355,
257,
1813,
7177,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
290,
7559,
7266,
482,
15506,
3689,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
257,
357,
25244,
88,
13,
358,
18747,
2599,
7308,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
383,
288,
4906,
286,
7559,
64,
15506,
318,
973,
416,
4277,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
3392,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
9107,
418,
62,
2339,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
611,
288,
4906,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
796,
257,
13,
67,
4906,
198,
220,
220,
220,
1441,
1976,
27498,
7,
64,
13,
43358,
11,
288,
4906,
28,
67,
4906,
8,
628,
198,
4299,
1336,
7,
43358,
11,
6070,
62,
8367,
11,
288,
4906,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
257,
649,
7177,
286,
1813,
5485,
290,
288,
4906,
11,
5901,
351,
257,
1813,
1988,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
3038,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5485,
357,
83,
29291,
286,
493,
82,
2599,
360,
16198,
871,
286,
262,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
6070,
62,
8367,
25,
317,
16578,
283,
1988,
284,
6070,
257,
649,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
7559,
20797,
62,
8367,
15506,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
12853,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
257,
796,
6565,
7,
43358,
11,
288,
4906,
8,
198,
220,
220,
220,
257,
13,
20797,
7,
20797,
62,
8367,
8,
198,
220,
220,
220,
1441,
257,
628,
198,
4299,
1336,
62,
2339,
7,
64,
11,
6070,
62,
8367,
11,
288,
4906,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
257,
1336,
7177,
351,
976,
5485,
290,
288,
4906,
355,
257,
1813,
7177,
13,
628,
220,
220,
220,
770,
2163,
3058,
857,
407,
1104,
7559,
2875,
15506,
290,
7559,
7266,
482,
15506,
3689,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
257,
357,
25244,
88,
13,
358,
18747,
2599,
7308,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
6070,
62,
8367,
25,
317,
16578,
283,
1988,
284,
6070,
257,
649,
7177,
13,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
25,
6060,
2099,
1020,
7483,
13,
383,
288,
4906,
286,
7559,
64,
15506,
318,
973,
416,
4277,
13,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6508,
88,
13,
358,
18747,
25,
1052,
7177,
5901,
351,
7559,
20797,
62,
8367,
15506,
13,
628,
220,
220,
220,
11485,
766,
14508,
3712,
1058,
20786,
25,
63,
77,
32152,
13,
12853,
62,
2339,
63,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
16926,
46,
7,
40045,
17,
67,
2599,
7929,
16216,
3038,
198,
220,
220,
220,
611,
288,
4906,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
288,
4906,
796,
257,
13,
67,
4906,
198,
220,
220,
220,
1441,
1336,
7,
64,
13,
43358,
11,
6070,
62,
8367,
11,
288,
4906,
8,
198
] | 2.563593 | 2,115 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import argparse
import json
from functools import reduce
import tensorflow as tf
from tensorflow.python.lib.io.file_io import FileIO # pylint: disable=E0611
from sciencebeam_gym.trainer.data.examples import (
get_matching_files,
read_examples
)
from sciencebeam_gym.preprocess.color_map import (
parse_color_map_from_file
)
from sciencebeam_gym.tools.calculate_class_weights import (
tf_calculate_efnet_weights_for_frequency_by_label
)
from sciencebeam_gym.trainer.models.pix2pix.tf_utils import (
find_nearest_centroid_indices
)
from sciencebeam_gym.preprocess.preprocessing_utils import (
parse_page_range
)
from sciencebeam_gym.trainer.models.pix2pix.pix2pix_core import (
BaseLoss,
ALL_BASE_LOSS,
create_pix2pix_model,
create_other_summaries
)
from sciencebeam_gym.trainer.models.pix2pix.evaluate import (
evaluate_separate_channels,
evaluate_predictions,
evaluation_summary
)
from sciencebeam_gym.model_utils.channels import (
calculate_color_masks
)
UNKNOWN_COLOR = (255, 255, 255)
UNKNOWN_LABEL = 'unknown'
DEFAULT_UNKNOWN_CLASS_WEIGHT = 0.1
class GraphReferences(object):
"""Holder of base tensors used for training model using common task."""
def create_model(argv=None):
"""Factory method that creates model to be used by generic task.py."""
parser = model_args_parser()
args, task_args = parser.parse_known_args(argv)
return Model(args), task_args
| [
6738,
11593,
37443,
834,
1330,
4112,
62,
11748,
198,
6738,
11593,
37443,
834,
1330,
7297,
198,
6738,
11593,
37443,
834,
1330,
3601,
62,
8818,
198,
198,
11748,
18931,
198,
11748,
1822,
29572,
198,
11748,
33918,
198,
6738,
1257,
310,
10141,
1330,
4646,
198,
198,
11748,
11192,
273,
11125,
355,
48700,
628,
198,
6738,
11192,
273,
11125,
13,
29412,
13,
8019,
13,
952,
13,
7753,
62,
952,
1330,
9220,
9399,
220,
1303,
279,
2645,
600,
25,
15560,
28,
36,
3312,
1157,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
2213,
10613,
13,
7890,
13,
1069,
12629,
1330,
357,
198,
220,
220,
220,
651,
62,
15699,
278,
62,
16624,
11,
198,
220,
220,
220,
1100,
62,
1069,
12629,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
3866,
14681,
13,
8043,
62,
8899,
1330,
357,
198,
220,
220,
220,
21136,
62,
8043,
62,
8899,
62,
6738,
62,
7753,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
31391,
13,
9948,
3129,
378,
62,
4871,
62,
43775,
1330,
357,
198,
220,
220,
220,
48700,
62,
9948,
3129,
378,
62,
891,
3262,
62,
43775,
62,
1640,
62,
35324,
62,
1525,
62,
18242,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
2213,
10613,
13,
27530,
13,
79,
844,
17,
79,
844,
13,
27110,
62,
26791,
1330,
357,
198,
220,
220,
220,
1064,
62,
710,
12423,
62,
1087,
3882,
62,
521,
1063,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
3866,
14681,
13,
3866,
36948,
62,
26791,
1330,
357,
198,
220,
220,
220,
21136,
62,
7700,
62,
9521,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
2213,
10613,
13,
27530,
13,
79,
844,
17,
79,
844,
13,
79,
844,
17,
79,
844,
62,
7295,
1330,
357,
198,
220,
220,
220,
7308,
43,
793,
11,
198,
220,
220,
220,
11096,
62,
33,
11159,
62,
43,
18420,
11,
198,
220,
220,
220,
2251,
62,
79,
844,
17,
79,
844,
62,
19849,
11,
198,
220,
220,
220,
2251,
62,
847,
62,
82,
13929,
3166,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
2213,
10613,
13,
27530,
13,
79,
844,
17,
79,
844,
13,
49786,
1330,
357,
198,
220,
220,
220,
13446,
62,
25512,
378,
62,
354,
8961,
11,
198,
220,
220,
220,
13446,
62,
28764,
9278,
11,
198,
220,
220,
220,
12660,
62,
49736,
198,
8,
198,
198,
6738,
3783,
40045,
62,
1360,
76,
13,
19849,
62,
26791,
13,
354,
8961,
1330,
357,
198,
220,
220,
220,
15284,
62,
8043,
62,
5356,
591,
198,
8,
628,
198,
4944,
44706,
62,
46786,
796,
357,
13381,
11,
14280,
11,
14280,
8,
198,
4944,
44706,
62,
48780,
3698,
796,
705,
34680,
6,
198,
198,
7206,
38865,
62,
4944,
44706,
62,
31631,
62,
8845,
9947,
796,
657,
13,
16,
628,
628,
198,
4871,
29681,
19927,
7,
15252,
2599,
198,
220,
220,
220,
37227,
39,
19892,
286,
2779,
11192,
669,
973,
329,
3047,
2746,
1262,
2219,
4876,
526,
15931,
628,
628,
628,
628,
628,
628,
628,
628,
628,
628,
628,
198,
198,
4299,
2251,
62,
19849,
7,
853,
85,
28,
14202,
2599,
198,
220,
220,
220,
37227,
22810,
2446,
326,
8075,
2746,
284,
307,
973,
416,
14276,
4876,
13,
9078,
526,
15931,
198,
220,
220,
220,
30751,
796,
2746,
62,
22046,
62,
48610,
3419,
198,
220,
220,
220,
26498,
11,
4876,
62,
22046,
796,
30751,
13,
29572,
62,
4002,
62,
22046,
7,
853,
85,
8,
198,
220,
220,
220,
1441,
9104,
7,
22046,
828,
4876,
62,
22046,
198
] | 2.757315 | 581 |
import aiohttp.web
from functools import wraps
import logging
from typing import Callable
import json
import dataclasses
import ray
import ray.dashboard.utils as dashboard_utils
from ray._private.job_manager import JobManager
from ray._private.runtime_env.packaging import (package_exists,
upload_package_to_gcs)
from ray.dashboard.modules.job.data_types import (
GetPackageResponse, JobStatus, JobSubmitRequest, JobSubmitResponse,
JobStatusResponse, JobLogsResponse)
logger = logging.getLogger(__name__)
routes = dashboard_utils.ClassMethodRouteTable
RAY_INTERNAL_JOBS_NAMESPACE = "_ray_internal_jobs_"
JOBS_API_PREFIX = "/api/jobs/"
JOBS_API_ROUTE_LOGS = JOBS_API_PREFIX + "logs"
JOBS_API_ROUTE_SUBMIT = JOBS_API_PREFIX + "submit"
JOBS_API_ROUTE_STATUS = JOBS_API_PREFIX + "status"
JOBS_API_ROUTE_PACKAGE = JOBS_API_PREFIX + "package"
| [
11748,
257,
952,
4023,
13,
12384,
198,
6738,
1257,
310,
10141,
1330,
27521,
198,
11748,
18931,
198,
6738,
19720,
1330,
4889,
540,
198,
11748,
33918,
198,
11748,
4818,
330,
28958,
198,
198,
11748,
26842,
198,
11748,
26842,
13,
42460,
3526,
13,
26791,
355,
30415,
62,
26791,
198,
6738,
26842,
13557,
19734,
13,
21858,
62,
37153,
1330,
15768,
13511,
198,
6738,
26842,
13557,
19734,
13,
43282,
62,
24330,
13,
8002,
3039,
1330,
357,
26495,
62,
1069,
1023,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9516,
62,
26495,
62,
1462,
62,
70,
6359,
8,
198,
6738,
26842,
13,
42460,
3526,
13,
18170,
13,
21858,
13,
7890,
62,
19199,
1330,
357,
198,
220,
220,
220,
3497,
27813,
31077,
11,
15768,
19580,
11,
15768,
45135,
18453,
11,
15768,
45135,
31077,
11,
198,
220,
220,
220,
15768,
19580,
31077,
11,
15768,
11187,
82,
31077,
8,
198,
198,
6404,
1362,
796,
18931,
13,
1136,
11187,
1362,
7,
834,
3672,
834,
8,
198,
81,
448,
274,
796,
30415,
62,
26791,
13,
9487,
17410,
43401,
10962,
198,
198,
30631,
62,
1268,
31800,
1847,
62,
45006,
4462,
62,
45,
29559,
47,
11598,
796,
45434,
2433,
62,
32538,
62,
43863,
62,
1,
198,
198,
45006,
4462,
62,
17614,
62,
47,
31688,
10426,
796,
12813,
15042,
14,
43863,
30487,
198,
45006,
4462,
62,
17614,
62,
49,
2606,
9328,
62,
25294,
50,
796,
32357,
4462,
62,
17614,
62,
47,
31688,
10426,
1343,
366,
6404,
82,
1,
198,
45006,
4462,
62,
17614,
62,
49,
2606,
9328,
62,
50,
10526,
36393,
796,
32357,
4462,
62,
17614,
62,
47,
31688,
10426,
1343,
366,
46002,
1,
198,
45006,
4462,
62,
17614,
62,
49,
2606,
9328,
62,
35744,
2937,
796,
32357,
4462,
62,
17614,
62,
47,
31688,
10426,
1343,
366,
13376,
1,
198,
45006,
4462,
62,
17614,
62,
49,
2606,
9328,
62,
47,
8120,
11879,
796,
32357,
4462,
62,
17614,
62,
47,
31688,
10426,
1343,
366,
26495,
1,
628,
198
] | 2.532394 | 355 |
#!/usr/bin/env python
import argparse
from .sql import MiniSpiderSQL
from .scheduler import MiniSpider
from .extractor import Extractor
from .downloader import MiniSpiderDownloader
__version__ = '0.0.3'
if __name__ == '__main__':
main()
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
11748,
1822,
29572,
198,
198,
6738,
764,
25410,
1330,
12558,
41294,
17861,
198,
6738,
764,
1416,
704,
18173,
1330,
12558,
41294,
198,
6738,
764,
2302,
40450,
1330,
29677,
273,
198,
6738,
764,
15002,
263,
1330,
12558,
41294,
10002,
263,
198,
198,
834,
9641,
834,
796,
705,
15,
13,
15,
13,
18,
6,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1388,
3419,
198
] | 3.037037 | 81 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 CERN.
#
# invenio-app-ils is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""ILL mail tasks."""
from invenio_app_ils.ill.errors import ILLError
from invenio_app_ils.ill.mail.factory import ill_message_creator_factory
from invenio_app_ils.mail.messages import get_common_message_ctx
from invenio_app_ils.mail.tasks import send_ils_email
def send_ill_mail(brw_req, action=None, message_ctx={}, **kwargs):
"""Send an ILL email.
:param brw_req: the borrowing request record.
:param action: the action performed, if any.
:param message_ctx: any other parameter to be passed as ctx in the msg.
"""
creator = ill_message_creator_factory()
message_ctx.update(get_common_message_ctx(record=brw_req))
try:
# fetch and inject in the email template the patron loan if available
loan = brw_req.patron_loan.get()
message_ctx["patron_loan"] = loan
except ILLError:
# no loan in the borrowin request
message_ctx["patron_loan"] = dict()
patron = message_ctx["patron"]
msg = creator(
brw_req,
action=action,
message_ctx=message_ctx,
recipients=[patron.email],
**kwargs,
)
send_ils_email(msg)
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
2,
198,
2,
15069,
357,
34,
8,
12131,
327,
28778,
13,
198,
2,
198,
2,
287,
574,
952,
12,
1324,
12,
4487,
318,
1479,
3788,
26,
345,
460,
17678,
4163,
340,
290,
14,
273,
13096,
340,
198,
2,
739,
262,
2846,
286,
262,
17168,
13789,
26,
766,
38559,
24290,
2393,
329,
517,
3307,
13,
198,
198,
37811,
8267,
6920,
8861,
526,
15931,
198,
198,
6738,
287,
574,
952,
62,
1324,
62,
4487,
13,
359,
13,
48277,
1330,
14639,
2538,
81,
1472,
198,
6738,
287,
574,
952,
62,
1324,
62,
4487,
13,
359,
13,
4529,
13,
69,
9548,
1330,
2801,
62,
20500,
62,
45382,
62,
69,
9548,
198,
6738,
287,
574,
952,
62,
1324,
62,
4487,
13,
4529,
13,
37348,
1095,
1330,
651,
62,
11321,
62,
20500,
62,
49464,
198,
6738,
287,
574,
952,
62,
1324,
62,
4487,
13,
4529,
13,
83,
6791,
1330,
3758,
62,
4487,
62,
12888,
628,
198,
4299,
3758,
62,
359,
62,
4529,
7,
1671,
86,
62,
42180,
11,
2223,
28,
14202,
11,
3275,
62,
49464,
34758,
5512,
12429,
46265,
22046,
2599,
198,
220,
220,
220,
37227,
25206,
281,
314,
3069,
3053,
13,
628,
220,
220,
220,
1058,
17143,
865,
86,
62,
42180,
25,
262,
23669,
2581,
1700,
13,
198,
220,
220,
220,
1058,
17143,
2223,
25,
262,
2223,
6157,
11,
611,
597,
13,
198,
220,
220,
220,
1058,
17143,
3275,
62,
49464,
25,
597,
584,
11507,
284,
307,
3804,
355,
269,
17602,
287,
262,
31456,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
13172,
796,
2801,
62,
20500,
62,
45382,
62,
69,
9548,
3419,
628,
220,
220,
220,
3275,
62,
49464,
13,
19119,
7,
1136,
62,
11321,
62,
20500,
62,
49464,
7,
22105,
28,
1671,
86,
62,
42180,
4008,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
21207,
290,
8677,
287,
262,
3053,
11055,
262,
19686,
8063,
611,
1695,
198,
220,
220,
220,
220,
220,
220,
220,
8063,
796,
865,
86,
62,
42180,
13,
8071,
1313,
62,
5439,
272,
13,
1136,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
62,
49464,
14692,
8071,
1313,
62,
5439,
272,
8973,
796,
8063,
198,
220,
220,
220,
2845,
14639,
2538,
81,
1472,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
645,
8063,
287,
262,
8804,
259,
2581,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
62,
49464,
14692,
8071,
1313,
62,
5439,
272,
8973,
796,
8633,
3419,
628,
220,
220,
220,
19686,
796,
3275,
62,
49464,
14692,
8071,
1313,
8973,
628,
220,
220,
220,
31456,
796,
13172,
7,
198,
220,
220,
220,
220,
220,
220,
220,
865,
86,
62,
42180,
11,
198,
220,
220,
220,
220,
220,
220,
220,
2223,
28,
2673,
11,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
62,
49464,
28,
20500,
62,
49464,
11,
198,
220,
220,
220,
220,
220,
220,
220,
20352,
41888,
8071,
1313,
13,
12888,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
12429,
46265,
22046,
11,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
3758,
62,
4487,
62,
12888,
7,
19662,
8,
198
] | 2.571702 | 523 |
from abc import abstractmethod
from csp.observer import Observer
class Propagator(Observer):
"""Abstract class for a constraint propagator."""
@abstractmethod
def on_domain_change(self, var):
"""Called when a variable domain has changed.
:param var: The variable that changed
:type var: Variable
"""
pass
def setup(self, problem):
"""Called to initialize this propagator with problem data
:param problem: The csp
:type problem: Problem
"""
for v in problem.variables:
v.add_observer(self)
self.map[v] = []
for c in problem.constraints:
for v in c.get_vars():
self.map[v].append(c)
| [
6738,
450,
66,
1330,
12531,
24396,
201,
198,
201,
198,
6738,
269,
2777,
13,
672,
15388,
1330,
27058,
201,
198,
201,
198,
201,
198,
4871,
8772,
363,
1352,
7,
31310,
18497,
2599,
201,
198,
220,
220,
220,
37227,
23839,
1398,
329,
257,
32315,
8928,
1352,
526,
15931,
201,
198,
220,
220,
220,
220,
201,
198,
220,
220,
220,
220,
201,
198,
220,
220,
220,
2488,
397,
8709,
24396,
201,
198,
220,
220,
220,
825,
319,
62,
27830,
62,
3803,
7,
944,
11,
1401,
2599,
201,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
34,
4262,
618,
257,
7885,
7386,
468,
3421,
13,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
1401,
25,
383,
7885,
326,
3421,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
4906,
1401,
25,
35748,
201,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1208,
201,
198,
220,
220,
220,
220,
201,
198,
220,
220,
220,
825,
9058,
7,
944,
11,
1917,
2599,
201,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
34,
4262,
284,
41216,
428,
8928,
1352,
351,
1917,
1366,
201,
198,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
17143,
1917,
25,
383,
269,
2777,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
4906,
1917,
25,
20647,
201,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
201,
198,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
1917,
13,
25641,
2977,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
13,
2860,
62,
672,
15388,
7,
944,
8,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
8899,
58,
85,
60,
796,
17635,
201,
198,
201,
198,
220,
220,
220,
220,
220,
220,
220,
329,
269,
287,
1917,
13,
1102,
2536,
6003,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
269,
13,
1136,
62,
85,
945,
33529,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
8899,
58,
85,
4083,
33295,
7,
66,
8,
201,
198
] | 2.119681 | 376 |
# Generated by Django 2.0 on 2019-04-02 09:57
from django.db import migrations, models
| [
2,
2980,
515,
416,
37770,
362,
13,
15,
319,
13130,
12,
3023,
12,
2999,
7769,
25,
3553,
198,
198,
6738,
42625,
14208,
13,
9945,
1330,
15720,
602,
11,
4981,
628
] | 2.966667 | 30 |
# coding:utf8
import re
options = {
'root_url': 'http://www.juooo.com',
'max_count': 1000,
'urlReg': {
'urlRegType': 1,
'urlFull': '',
'urlStr': 'http://(\w+).juooo.com/\w+'
},
'urlData': []
}
| [
2,
19617,
25,
40477,
23,
198,
11748,
302,
198,
198,
25811,
796,
1391,
198,
220,
220,
220,
705,
15763,
62,
6371,
10354,
705,
4023,
1378,
2503,
13,
14396,
34160,
13,
785,
3256,
198,
220,
220,
220,
705,
9806,
62,
9127,
10354,
8576,
11,
198,
220,
220,
220,
705,
6371,
8081,
10354,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
705,
6371,
8081,
6030,
10354,
352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
705,
6371,
13295,
10354,
705,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
705,
6371,
13290,
10354,
705,
4023,
1378,
38016,
86,
10,
737,
14396,
34160,
13,
785,
14,
59,
86,
10,
6,
198,
220,
220,
220,
8964,
198,
220,
220,
220,
705,
6371,
6601,
10354,
17635,
198,
92,
198,
220,
198
] | 1.875 | 128 |
import pandas as pd
import numpy as np
import os, sys, gc, random
import datetime
import dateutil.relativedelta
# Machine learning
from sklearn.preprocessing import LabelEncoder
from sklearn.impute import SimpleImputer
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import roc_auc_score
# Custom library
from utils import seed_everything, print_score
TOTAL_THRES = 300 # 구매액 임계값
SEED = 42 # 랜덤 시드
seed_everything(SEED) # 시드 고정
data_dir = '../input/train.csv' # os.environ['SM_CHANNEL_TRAIN']
model_dir = '../model' # os.environ['SM_MODEL_DIR']
'''
입력인자로 받는 year_month에 대해 고객 ID별로 총 구매액이
구매액 임계값을 넘는지 여부의 binary label을 생성하는 함수
'''
# def get_year_month_list(df, year_month):
# df = df.copy()
#
# df['year_month-mode'] = df['order_date'].dt.strftime('%Y-%m')
# dd = df.groupby(['year_month-mode', 'customer_id'])['total'].sum()
# cust_ids = df['customer_id'].unique()
#
# # year_month 이전 월 계산
# bef_12_d = datetime.datetime.strptime(year_month, "%Y-%m")
# bef_12_prev_ym = bef_12_d - dateutil.relativedelta.relativedelta(months=12)
# bef_12_prev_ym = bef_12_prev_ym.strftime('%Y-%m')
#
# # ddt = df[df['year_month-mode'] == bef_12_prev_ym]
#
# first_bef = []
# for id in cust_ids:
# dd[:, bef_12_prev_ym]
# # first_bef.append(dd.xs((id, bef_12_prev_ym)))
#
# # df['cycle_month'] = pd.Series(first_bef)
#
# print(df)
if __name__ == '__main__':
print('data_dir', data_dir)
| [
11748,
19798,
292,
355,
279,
67,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
28686,
11,
25064,
11,
308,
66,
11,
4738,
198,
11748,
4818,
8079,
198,
11748,
3128,
22602,
13,
2411,
265,
1572,
12514,
198,
198,
2,
10850,
4673,
198,
6738,
1341,
35720,
13,
3866,
36948,
1330,
36052,
27195,
12342,
198,
6738,
1341,
35720,
13,
11011,
1133,
1330,
17427,
3546,
10549,
198,
6738,
1341,
35720,
13,
19849,
62,
49283,
1330,
29186,
1431,
42,
37,
727,
198,
6738,
1341,
35720,
13,
4164,
10466,
1330,
686,
66,
62,
14272,
62,
26675,
198,
198,
2,
8562,
5888,
198,
6738,
3384,
4487,
1330,
9403,
62,
37814,
11,
3601,
62,
26675,
628,
198,
51,
27510,
62,
4221,
19535,
796,
5867,
1303,
220,
166,
113,
105,
167,
100,
97,
168,
243,
94,
23821,
252,
226,
166,
111,
226,
166,
108,
240,
198,
5188,
1961,
796,
5433,
1303,
31619,
252,
250,
167,
235,
97,
23821,
233,
250,
167,
241,
250,
198,
28826,
62,
37814,
7,
5188,
1961,
8,
1303,
23821,
233,
250,
167,
241,
250,
220,
166,
111,
254,
168,
254,
243,
198,
198,
7890,
62,
15908,
796,
705,
40720,
15414,
14,
27432,
13,
40664,
6,
1303,
28686,
13,
268,
2268,
17816,
12310,
62,
3398,
22846,
3698,
62,
51,
3861,
1268,
20520,
198,
19849,
62,
15908,
796,
705,
40720,
19849,
6,
1303,
28686,
13,
268,
2268,
17816,
12310,
62,
33365,
3698,
62,
34720,
20520,
628,
198,
7061,
6,
198,
220,
220,
220,
23821,
252,
227,
167,
254,
98,
35975,
116,
168,
252,
238,
167,
94,
250,
31619,
108,
249,
167,
232,
242,
614,
62,
8424,
168,
245,
238,
31619,
234,
222,
47991,
112,
220,
166,
111,
254,
166,
108,
251,
4522,
167,
111,
226,
167,
94,
250,
23821,
112,
251,
220,
166,
113,
105,
167,
100,
97,
168,
243,
94,
35975,
112,
198,
220,
220,
220,
220,
166,
113,
105,
167,
100,
97,
168,
243,
94,
23821,
252,
226,
166,
111,
226,
166,
108,
240,
35975,
226,
31619,
226,
246,
167,
232,
242,
168,
100,
222,
23821,
245,
105,
167,
114,
222,
35975,
246,
13934,
6167,
35975,
226,
23821,
225,
251,
168,
226,
109,
47991,
246,
167,
232,
242,
220,
47991,
101,
168,
230,
246,
198,
7061,
6,
198,
198,
2,
825,
651,
62,
1941,
62,
8424,
62,
4868,
7,
7568,
11,
614,
62,
8424,
2599,
198,
2,
220,
220,
220,
220,
47764,
796,
47764,
13,
30073,
3419,
198,
2,
198,
2,
220,
220,
220,
220,
47764,
17816,
1941,
62,
8424,
12,
14171,
20520,
796,
47764,
17816,
2875,
62,
4475,
6,
4083,
28664,
13,
2536,
31387,
10786,
4,
56,
12,
4,
76,
11537,
198,
2,
220,
220,
220,
220,
49427,
796,
47764,
13,
8094,
1525,
7,
17816,
1941,
62,
8424,
12,
14171,
3256,
705,
23144,
263,
62,
312,
6,
12962,
17816,
23350,
6,
4083,
16345,
3419,
198,
2,
220,
220,
220,
220,
9378,
62,
2340,
796,
47764,
17816,
23144,
263,
62,
312,
6,
4083,
34642,
3419,
198,
2,
198,
2,
220,
220,
220,
220,
1303,
614,
62,
8424,
23821,
251,
112,
168,
254,
226,
23821,
249,
242,
220,
166,
111,
226,
168,
224,
108,
198,
2,
220,
220,
220,
220,
307,
69,
62,
1065,
62,
67,
796,
4818,
8079,
13,
19608,
8079,
13,
2536,
457,
524,
7,
1941,
62,
8424,
11,
36521,
56,
12,
4,
76,
4943,
198,
2,
220,
220,
220,
220,
307,
69,
62,
1065,
62,
47050,
62,
4948,
796,
307,
69,
62,
1065,
62,
67,
532,
3128,
22602,
13,
2411,
265,
1572,
12514,
13,
2411,
265,
1572,
12514,
7,
41537,
28,
1065,
8,
198,
2,
220,
220,
220,
220,
307,
69,
62,
1065,
62,
47050,
62,
4948,
796,
307,
69,
62,
1065,
62,
47050,
62,
4948,
13,
2536,
31387,
10786,
4,
56,
12,
4,
76,
11537,
198,
2,
198,
2,
220,
220,
220,
220,
1303,
288,
28664,
796,
47764,
58,
7568,
17816,
1941,
62,
8424,
12,
14171,
20520,
6624,
307,
69,
62,
1065,
62,
47050,
62,
4948,
60,
198,
2,
198,
2,
220,
220,
220,
220,
717,
62,
65,
891,
796,
17635,
198,
2,
220,
220,
220,
220,
329,
4686,
287,
9378,
62,
2340,
25,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
49427,
58,
45299,
307,
69,
62,
1065,
62,
47050,
62,
4948,
60,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
717,
62,
65,
891,
13,
33295,
7,
1860,
13,
34223,
19510,
312,
11,
307,
69,
62,
1065,
62,
47050,
62,
4948,
22305,
198,
2,
198,
2,
220,
220,
220,
220,
1303,
47764,
17816,
13696,
62,
8424,
20520,
796,
279,
67,
13,
27996,
7,
11085,
62,
65,
891,
8,
198,
2,
198,
2,
220,
220,
220,
220,
3601,
7,
7568,
8,
628,
628,
628,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
220,
198,
220,
220,
220,
3601,
10786,
7890,
62,
15908,
3256,
1366,
62,
15908,
8,
198
] | 1.867665 | 801 |
from __future__ import unicode_literals
from __future__ import print_function
import unicodedata
import unittest
"""
Very simple assorted helpers for natural language processing that I've used a few times.
"""
_CHAR_TRANSLATIONS = {
# chars to remove
"\u00ae": None,
"\u2122": None,
# chars to normalize that aren't handled by combining char stripping
"\u2018": "'",
"\u2019": "'",
"\u201c": '"',
"\u201d": '"',
"\u2013": "-",
"\u2014": "-",
"\u00bd": "1/2"
}
_CODEPOINT_TRANSLATIONS = {ord(k): v for k, v in _CHAR_TRANSLATIONS.items()}
def strip_diacritics(s):
"""Remove accents and other diacritics"""
return "".join(c for c in unicodedata.normalize("NFD", s) if unicodedata.category(c) != "Mn")
def normalize_unicode(s):
"""Remove trademark sign, normalize smart quotes, etc"""
return s.translate(_CODEPOINT_TRANSLATIONS)
| [
6738,
11593,
37443,
834,
1330,
28000,
1098,
62,
17201,
874,
198,
6738,
11593,
37443,
834,
1330,
3601,
62,
8818,
198,
198,
11748,
28000,
9043,
1045,
198,
11748,
555,
715,
395,
198,
198,
37811,
198,
16371,
2829,
46603,
49385,
329,
3288,
3303,
7587,
326,
314,
1053,
973,
257,
1178,
1661,
13,
198,
37811,
198,
198,
62,
38019,
62,
5446,
1565,
8634,
18421,
796,
1391,
198,
220,
220,
220,
1303,
34534,
284,
4781,
198,
220,
220,
220,
37082,
84,
405,
3609,
1298,
6045,
11,
198,
220,
220,
220,
37082,
84,
17,
18376,
1298,
6045,
11,
628,
220,
220,
220,
1303,
34534,
284,
3487,
1096,
326,
3588,
470,
12118,
416,
19771,
1149,
37727,
198,
220,
220,
220,
37082,
84,
7908,
1298,
24018,
1600,
198,
220,
220,
220,
37082,
84,
23344,
1298,
24018,
1600,
198,
220,
220,
220,
37082,
84,
1264,
66,
1298,
705,
1,
3256,
198,
220,
220,
220,
37082,
84,
1264,
67,
1298,
705,
1,
3256,
198,
220,
220,
220,
37082,
84,
6390,
1298,
27444,
1600,
198,
220,
220,
220,
37082,
84,
4967,
1298,
27444,
1600,
198,
220,
220,
220,
37082,
84,
405,
17457,
1298,
366,
16,
14,
17,
1,
198,
92,
198,
198,
62,
34,
3727,
8905,
46,
12394,
62,
5446,
1565,
8634,
18421,
796,
1391,
585,
7,
74,
2599,
410,
329,
479,
11,
410,
287,
4808,
38019,
62,
5446,
1565,
8634,
18421,
13,
23814,
3419,
92,
628,
198,
4299,
10283,
62,
67,
9607,
799,
873,
7,
82,
2599,
198,
220,
220,
220,
37227,
27914,
39271,
290,
584,
2566,
330,
799,
873,
37811,
198,
220,
220,
220,
1441,
366,
1911,
22179,
7,
66,
329,
269,
287,
28000,
9043,
1045,
13,
11265,
1096,
7203,
21870,
35,
1600,
264,
8,
611,
28000,
9043,
1045,
13,
22872,
7,
66,
8,
14512,
366,
44,
77,
4943,
628,
198,
4299,
3487,
1096,
62,
46903,
1098,
7,
82,
2599,
198,
220,
220,
220,
37227,
27914,
16028,
1051,
11,
3487,
1096,
4451,
13386,
11,
3503,
37811,
198,
220,
220,
220,
1441,
264,
13,
7645,
17660,
28264,
34,
3727,
8905,
46,
12394,
62,
5446,
1565,
8634,
18421,
8,
628,
628
] | 2.630499 | 341 |
from manim_imports_ext import *
| [
6738,
582,
320,
62,
320,
3742,
62,
2302,
1330,
1635,
198
] | 2.909091 | 11 |
#!/usr/bin/env python
"""
genome_download: downloading genomes
Usage:
genome_download [options] <accession_table>
genome_download -h | --help
genome_download --version
Options:
<accessin_table> Taxon-accession table (see Description).
Use '-' if from STDIN.
-d=<d> Output directory. [Default: .]
-e=<e> Email to use for NCBI queries. [Default: [email protected]]
-a=<a> Number of ambiguous nucleotides allowed in a genome. [Default: 0]
-n=<n> Number of cpus. [Default: 1]
-t=<t> Number of tries to download genomes. [Default: 10]
-r Rename genome sequences based on taxon name?
--debug Debug mode (no multiprocessing).
-h --help Show this screen.
--version Show version.
Description:
Taxon-accession table
---------------------
* tab-delimited
* must contain 2 columns
* "Taxon" = taxon name
* "Accession" = NCBI accession used for downloading
* Possible accessions:
* ncbi nucleotide db
* ncbi assembly db
* ftp url to genome (direct download)
* other columns are allowed
Output
------
* Genome fasta files written to the specified output directory
* A table mapping taxa to the download genome fasta file is written to STDOUT
"""
# import
import sys,os
import logging
## batteries
from docopt import docopt
from MGSIM import Genome_Download
## logging
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.DEBUG)
# opt parse
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
37811,
198,
5235,
462,
62,
15002,
25,
22023,
42136,
198,
198,
28350,
25,
198,
220,
19270,
62,
15002,
685,
25811,
60,
1279,
15526,
295,
62,
11487,
29,
198,
220,
19270,
62,
15002,
532,
71,
930,
1377,
16794,
198,
220,
19270,
62,
15002,
1377,
9641,
198,
198,
29046,
25,
198,
220,
1279,
15526,
259,
62,
11487,
29,
220,
9241,
261,
12,
15526,
295,
3084,
357,
3826,
12489,
737,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5765,
705,
19355,
611,
422,
48571,
1268,
13,
198,
220,
532,
67,
28,
27,
67,
29,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
25235,
8619,
13,
685,
19463,
25,
764,
60,
198,
220,
532,
68,
28,
27,
68,
29,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9570,
284,
779,
329,
8823,
3483,
20743,
13,
685,
19463,
25,
9178,
31,
14816,
13,
785,
60,
198,
220,
532,
64,
28,
27,
64,
29,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7913,
286,
27102,
17751,
313,
1460,
3142,
287,
257,
19270,
13,
685,
19463,
25,
657,
60,
198,
220,
532,
77,
28,
27,
77,
29,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7913,
286,
31396,
385,
13,
685,
19463,
25,
352,
60,
198,
220,
532,
83,
28,
27,
83,
29,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7913,
286,
8404,
284,
4321,
42136,
13,
685,
19463,
25,
838,
60,
198,
220,
532,
81,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7152,
480,
19270,
16311,
1912,
319,
1687,
261,
1438,
30,
198,
220,
1377,
24442,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
31687,
4235,
357,
3919,
18540,
305,
919,
278,
737,
198,
220,
532,
71,
1377,
16794,
220,
220,
220,
220,
220,
220,
220,
220,
5438,
428,
3159,
13,
198,
220,
1377,
9641,
220,
220,
220,
220,
220,
220,
220,
220,
5438,
2196,
13,
198,
198,
11828,
25,
198,
220,
9241,
261,
12,
15526,
295,
3084,
198,
220,
41436,
12,
198,
220,
1635,
7400,
12,
12381,
320,
863,
198,
220,
1635,
1276,
3994,
362,
15180,
198,
220,
220,
220,
1635,
366,
27017,
261,
1,
796,
1687,
261,
1438,
198,
220,
220,
220,
1635,
366,
15457,
295,
1,
796,
8823,
3483,
1895,
295,
973,
329,
22023,
220,
198,
220,
220,
220,
220,
220,
1635,
33671,
1895,
507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
299,
66,
8482,
17751,
45608,
20613,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
299,
66,
8482,
10474,
20613,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
10117,
79,
19016,
284,
19270,
357,
12942,
4321,
8,
198,
220,
1635,
584,
15180,
389,
3142,
628,
220,
25235,
198,
220,
40103,
198,
220,
1635,
5215,
462,
3049,
64,
3696,
3194,
284,
262,
7368,
5072,
8619,
198,
220,
1635,
317,
3084,
16855,
1687,
64,
284,
262,
4321,
19270,
3049,
64,
2393,
318,
3194,
284,
48571,
12425,
198,
37811,
198,
198,
2,
1330,
198,
11748,
25064,
11,
418,
198,
11748,
18931,
198,
2235,
13591,
198,
6738,
2205,
8738,
1330,
2205,
8738,
198,
6738,
337,
14313,
3955,
1330,
5215,
462,
62,
10002,
198,
2235,
18931,
198,
6404,
2667,
13,
35487,
16934,
7,
18982,
11639,
4,
7,
292,
310,
524,
8,
82,
532,
4064,
7,
20500,
8,
82,
3256,
1241,
28,
6404,
2667,
13,
30531,
8,
628,
198,
2,
2172,
21136,
198,
220,
220,
220,
198
] | 2.615126 | 595 |
import logging
import multiprocessing
from typing import MutableMapping
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from Core.messages import Courier, Message
from .widgets import *
import os, sys
| [
11748,
18931,
198,
11748,
18540,
305,
919,
278,
198,
6738,
19720,
1330,
13859,
540,
44,
5912,
198,
6738,
9485,
48,
83,
21,
13,
48,
83,
14055,
1330,
1635,
198,
6738,
9485,
48,
83,
21,
13,
48,
83,
54,
312,
11407,
1330,
1635,
198,
6738,
7231,
13,
37348,
1095,
1330,
34268,
11,
16000,
198,
6738,
764,
28029,
11407,
1330,
1635,
198,
11748,
28686,
11,
25064,
628
] | 3.246154 | 65 |
# SPDX-License-Identifier: MIT
# Greetings to:
# - https://www.theiphonewiki.com/wiki/IMG4_File_Format
# - https://github.com/tihmstar/img4tool/
# - https://lapo.it/asn1js/
# - hexdump tool of choice
import functools
from asn1crypto.core import (
Enumerated, Choice, Sequence, SequenceOf, SetOf,
Integer, IA5String, OctetString, ParsableOctetString, Integer,
Any
)
from asn1crypto.x509 import Certificate
import restruct
class any_tag(tuple):
""" highly cursed tuple subtype to bully asn1crypto into accepting any tag """
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-r', '--raw', action='store_true', help='print raw parsed data')
parser.add_argument('infile', type=argparse.FileType('rb'), help='input .img4/.im4m/.im4p file')
parser.add_argument('outfile', type=argparse.FileType('wb'), nargs='?', help='output data file for payload')
args = parser.parse_args()
contents = args.infile.read()
errors = {}
for p in (IMG4, IMG4Manifest, IMG4Payload):
try:
img4 = p.load(contents)
img4.native # trigger parsing
break
except Exception as e:
errors[p] = e
else:
print('Could not parse file {}:'.format(args.infile.name))
for (p, e) in errors.items():
print(' - As {}: {}'.format(p.__name__, e))
sys.exit(1)
if isinstance(img4, IMG4):
payload = img4['payload']
manifest = img4['manifest']
elif isinstance(img4, IMG4Manifest):
payload = None
manifest = img4
elif isinstance(img4, IMG4Payload):
payload = img4
manifest = None
if payload:
p = payload.native
if args.raw:
print(restruct.format_value(p, str))
else:
print('payload:')
print(' type:', p['type'])
print(' desc:', p['description'])
if p['keybags']:
print(' keybags:')
keybags = payload['keybags'].parse(IMG4KeyBagSequence).native
for kb in keybags:
print(' id: ', kb['id'])
print(' iv: ', restruct.format_value(kb['iv'], str))
print(' key:', restruct.format_value(kb['key'], str))
print()
if p['compression']:
print(' compression:')
print(' algo:', p['compression']['algorithm'])
print(' size:', p['compression']['original_size'])
algo = p['compression']['algorithm']
else:
algo = None
print()
if args.outfile:
if algo == 'lzfse':
import lzfse
data = lzfse.decompress(p['data'])
elif algo:
raise ValueError('unknown algorithm: {}'.format(algo))
else:
data = p['data']
args.outfile.write(data)
if manifest:
m = manifest.native
if args.raw:
print(restruct.format_value(m, str))
else:
print('manifest:')
for p in m['contents']:
print(' body:')
if p['type'] == 'MANB':
for c in p['categories']:
cname = c['category']['type']
for v in c['category']['values']:
print(' {}.{}: {}'.format(cname, v['value']['key'], restruct.format_value(v['value']['value'], str)))
print()
| [
2,
30628,
55,
12,
34156,
12,
33234,
7483,
25,
17168,
198,
2,
402,
46648,
284,
25,
198,
2,
532,
3740,
1378,
2503,
13,
1169,
13323,
44181,
5580,
13,
785,
14,
15466,
14,
3955,
38,
19,
62,
8979,
62,
26227,
198,
2,
532,
3740,
1378,
12567,
13,
785,
14,
83,
4449,
76,
7364,
14,
9600,
19,
25981,
14,
198,
2,
532,
3740,
1378,
37796,
78,
13,
270,
14,
292,
77,
16,
8457,
14,
198,
2,
532,
17910,
39455,
2891,
286,
3572,
198,
198,
11748,
1257,
310,
10141,
198,
6738,
355,
77,
16,
29609,
78,
13,
7295,
1330,
357,
198,
220,
220,
220,
2039,
6975,
515,
11,
18502,
11,
45835,
11,
45835,
5189,
11,
5345,
5189,
11,
198,
220,
220,
220,
34142,
11,
35229,
20,
10100,
11,
2556,
316,
10100,
11,
23042,
540,
12349,
316,
10100,
11,
34142,
11,
198,
220,
220,
220,
4377,
198,
8,
198,
6738,
355,
77,
16,
29609,
78,
13,
87,
29022,
1330,
27895,
198,
11748,
27596,
628,
198,
4871,
597,
62,
12985,
7,
83,
29291,
2599,
198,
220,
220,
220,
37227,
4047,
25155,
46545,
850,
4906,
284,
27410,
355,
77,
16,
29609,
78,
656,
12598,
597,
7621,
37227,
628,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1330,
1822,
29572,
628,
220,
220,
220,
30751,
796,
1822,
29572,
13,
28100,
1713,
46677,
3419,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
12,
81,
3256,
705,
438,
1831,
3256,
2223,
11639,
8095,
62,
7942,
3256,
1037,
11639,
4798,
8246,
44267,
1366,
11537,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
259,
7753,
3256,
2099,
28,
853,
29572,
13,
8979,
6030,
10786,
26145,
33809,
1037,
11639,
15414,
764,
9600,
19,
11757,
320,
19,
76,
11757,
320,
19,
79,
2393,
11537,
198,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
448,
7753,
3256,
2099,
28,
853,
29572,
13,
8979,
6030,
10786,
39346,
33809,
299,
22046,
11639,
30,
3256,
1037,
11639,
22915,
1366,
2393,
329,
21437,
11537,
198,
220,
220,
220,
26498,
796,
30751,
13,
29572,
62,
22046,
3419,
628,
220,
220,
220,
10154,
796,
26498,
13,
259,
7753,
13,
961,
3419,
198,
220,
220,
220,
8563,
796,
23884,
198,
220,
220,
220,
329,
279,
287,
357,
3955,
38,
19,
11,
8959,
38,
19,
5124,
8409,
11,
8959,
38,
19,
19197,
2220,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33705,
19,
796,
279,
13,
2220,
7,
3642,
658,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33705,
19,
13,
30191,
220,
1303,
7616,
32096,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
35528,
355,
304,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8563,
58,
79,
60,
796,
304,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
23722,
407,
21136,
2393,
23884,
25,
4458,
18982,
7,
22046,
13,
259,
7753,
13,
3672,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
329,
357,
79,
11,
304,
8,
287,
8563,
13,
23814,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
532,
1081,
23884,
25,
23884,
4458,
18982,
7,
79,
13,
834,
3672,
834,
11,
304,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
25064,
13,
37023,
7,
16,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
611,
318,
39098,
7,
9600,
19,
11,
8959,
38,
19,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
21437,
796,
33705,
19,
17816,
15577,
2220,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
10561,
796,
33705,
19,
17816,
805,
8409,
20520,
198,
220,
220,
220,
1288,
361,
318,
39098,
7,
9600,
19,
11,
8959,
38,
19,
5124,
8409,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
21437,
796,
6045,
198,
220,
220,
220,
220,
220,
220,
220,
10561,
796,
33705,
19,
198,
220,
220,
220,
1288,
361,
318,
39098,
7,
9600,
19,
11,
8959,
38,
19,
19197,
2220,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
21437,
796,
33705,
19,
198,
220,
220,
220,
220,
220,
220,
220,
10561,
796,
6045,
628,
220,
220,
220,
611,
21437,
25,
198,
220,
220,
220,
220,
220,
220,
220,
279,
796,
21437,
13,
30191,
198,
220,
220,
220,
220,
220,
220,
220,
611,
26498,
13,
1831,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
2118,
1356,
13,
18982,
62,
8367,
7,
79,
11,
965,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
15577,
2220,
25,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
2099,
25,
3256,
279,
17816,
4906,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
1715,
25,
3256,
279,
17816,
11213,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
279,
17816,
2539,
34005,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
1994,
34005,
25,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1994,
34005,
796,
21437,
17816,
2539,
34005,
6,
4083,
29572,
7,
3955,
38,
19,
9218,
33,
363,
44015,
594,
737,
30191,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
47823,
287,
1994,
34005,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
4686,
25,
46083,
47823,
17816,
312,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
21628,
25,
46083,
27596,
13,
18982,
62,
8367,
7,
32812,
17816,
452,
6,
4357,
965,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
1994,
25,
3256,
27596,
13,
18982,
62,
8367,
7,
32812,
17816,
2539,
6,
4357,
965,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
279,
17816,
5589,
2234,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
19794,
25,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
435,
2188,
25,
3256,
279,
17816,
5589,
2234,
6,
7131,
6,
282,
42289,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
2546,
25,
3256,
279,
17816,
5589,
2234,
6,
7131,
6,
14986,
62,
7857,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
2188,
796,
279,
17816,
5589,
2234,
6,
7131,
6,
282,
42289,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
2188,
796,
6045,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
611,
26498,
13,
448,
7753,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
435,
2188,
6624,
705,
75,
89,
69,
325,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1330,
300,
89,
69,
325,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
300,
89,
69,
325,
13,
12501,
3361,
601,
7,
79,
17816,
7890,
6,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1288,
361,
435,
2188,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
10786,
34680,
11862,
25,
23884,
4458,
18982,
7,
282,
2188,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
279,
17816,
7890,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26498,
13,
448,
7753,
13,
13564,
7,
7890,
8,
198,
220,
220,
220,
611,
10561,
25,
198,
220,
220,
220,
220,
220,
220,
220,
285,
796,
10561,
13,
30191,
198,
220,
220,
220,
220,
220,
220,
220,
611,
26498,
13,
1831,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
2118,
1356,
13,
18982,
62,
8367,
7,
76,
11,
965,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
805,
8409,
25,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
279,
287,
285,
17816,
3642,
658,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
1767,
25,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
279,
17816,
4906,
20520,
6624,
705,
10725,
33,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
269,
287,
279,
17816,
66,
26129,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
3672,
796,
269,
17816,
22872,
6,
7131,
6,
4906,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
410,
287,
269,
17816,
22872,
6,
7131,
6,
27160,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
220,
220,
220,
23884,
13,
90,
38362,
23884,
4458,
18982,
7,
66,
3672,
11,
410,
17816,
8367,
6,
7131,
6,
2539,
6,
4357,
27596,
13,
18982,
62,
8367,
7,
85,
17816,
8367,
6,
7131,
6,
8367,
6,
4357,
965,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
3419,
198
] | 1.981278 | 1,816 |
import unittest
from programy.storage.stores.nosql.mongo.dao.rdf import RDF
| [
11748,
555,
715,
395,
198,
198,
6738,
1430,
88,
13,
35350,
13,
43409,
13,
39369,
13976,
13,
76,
25162,
13,
67,
5488,
13,
4372,
69,
1330,
371,
8068,
628
] | 2.689655 | 29 |
# (c) 2017 Gregor Mitscha-Baude
from matplotlib import pyplot as plt
import numpy as np
import dolfin
from nanopores.tools import fields
fields.set_dir_dropbox()
from nanopores.models.nanopore import Setup
from nanopores.geometries.alphahempoly import poly
from nanopores.geometries.alphahem import default
from nanopores.geometries.cylpore import Pore, get_geo
from nanopores.models.diffusion_ahem import diff_profile_z_ahem, get_diffusivity
# params for precomputed diffusivity
params = dict(dim=2, Nmax=1e5, h=.5, ahemqsuniform=True, rMolecule=0.11)
#ap1 = 18
#ap2 = 49
#x0 = poly[18]
#x1 = poly[49]
#
#zmem = .5*(x0[1] + x1[1])
#print zmem
#
#poly = [[x[0], x[1] - zmem] for x in poly]
#proteincs = [z - zmem for z in default["proteincs"]]
#cs = [z - zmem for z in default["cs"]]
#default.update(zmem=0., hmem=2.82, Htop=10, Hbot=6, R=6, proteincs=proteincs, cs=cs)
#print default
#
#def new_get_geo(**params):
# return get_geo(poly, **params)
#
#p = Pore(poly, **default)
#p.build(h=.5)
#
#p.polygons["alphahem"].plot("ok")
#p.polygons["membrane"].plot()
#p.polygons["bulkfluid_top"].plot()
#p.polygons["bulkfluid_bottom"].plot()
#plt.show()
#setup = Setup(get_geo=new_get_geo, geop=default, h=.5)
#setup = Setup(h=.5)
#setup.geo.plot_boundaries()
functions, mesh = fields.get_functions(name="Dalphahem-coupled", **params)
dist = functions["dist"]
#dolfin.plot(dist, interactive=True)
# construct D fit from Noskov2004 and plot tabulated D values
A = 0.64309
B = 0.00044
C = 0.06894
D = 0.35647
E = 0.19409
z, D = diff_profile_fit(a=-12, b=2, N=100)
plt.plot(z, D, "-b", label="Tabulated (infinite cylinder)")
data = diff_profile_z_ahem(a=-12, b=2, N=100, **params)
z = [x0[2] for x0 in data["x"]]
Dz = data["D"]
plt.plot(z, Dz, "og", label="Full hydrodynamic model")
plt.ylabel("Rel. diffusivity")
plt.xlabel("z [nm]")
plt.xlim(-10, 0)
ax = plt.gca()
#ax.yaxis.tick_right()
#ax.yaxis.set_label_position("right")
plt.legend(loc="upper left", frameon=False)
from nanopores import savefigs
from folders import FIGDIR
savefigs("Dz", FIGDIR + "/ahem", (6, 4.5))
#print results | [
2,
357,
66,
8,
2177,
8547,
273,
22424,
11693,
12,
34458,
2507,
198,
6738,
2603,
29487,
8019,
1330,
12972,
29487,
355,
458,
83,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
288,
4024,
259,
198,
6738,
46661,
2850,
13,
31391,
1330,
7032,
198,
25747,
13,
2617,
62,
15908,
62,
14781,
3524,
3419,
198,
6738,
46661,
2850,
13,
27530,
13,
12647,
404,
382,
1330,
31122,
198,
6738,
46661,
2850,
13,
469,
908,
1678,
13,
26591,
258,
3149,
3366,
1330,
7514,
198,
6738,
46661,
2850,
13,
469,
908,
1678,
13,
26591,
4411,
1330,
4277,
198,
6738,
46661,
2850,
13,
469,
908,
1678,
13,
948,
34431,
382,
1330,
350,
382,
11,
651,
62,
469,
78,
198,
6738,
46661,
2850,
13,
27530,
13,
26069,
4241,
62,
64,
4411,
1330,
814,
62,
13317,
62,
89,
62,
64,
4411,
11,
651,
62,
26069,
385,
3458,
198,
198,
2,
42287,
329,
662,
785,
17128,
814,
385,
3458,
198,
37266,
796,
8633,
7,
27740,
28,
17,
11,
399,
9806,
28,
16,
68,
20,
11,
289,
28,
13,
20,
11,
257,
4411,
80,
19155,
6933,
28,
17821,
11,
374,
44,
2305,
23172,
28,
15,
13,
1157,
8,
198,
198,
2,
499,
16,
796,
1248,
198,
2,
499,
17,
796,
5125,
198,
2,
87,
15,
796,
7514,
58,
1507,
60,
198,
2,
87,
16,
796,
7514,
58,
2920,
60,
198,
2,
198,
2,
89,
11883,
796,
764,
20,
9,
7,
87,
15,
58,
16,
60,
1343,
2124,
16,
58,
16,
12962,
198,
2,
4798,
1976,
11883,
198,
2,
198,
2,
35428,
796,
16410,
87,
58,
15,
4357,
2124,
58,
16,
60,
532,
1976,
11883,
60,
329,
2124,
287,
7514,
60,
198,
2,
1676,
660,
1939,
82,
796,
685,
89,
532,
1976,
11883,
329,
1976,
287,
4277,
14692,
1676,
660,
1939,
82,
8973,
60,
198,
2,
6359,
796,
685,
89,
532,
1976,
11883,
329,
1976,
287,
4277,
14692,
6359,
8973,
60,
198,
2,
12286,
13,
19119,
7,
89,
11883,
28,
15,
1539,
289,
11883,
28,
17,
13,
6469,
11,
367,
4852,
28,
940,
11,
367,
13645,
28,
21,
11,
371,
28,
21,
11,
5915,
1939,
82,
28,
1676,
660,
1939,
82,
11,
50115,
28,
6359,
8,
198,
2,
4798,
4277,
198,
2,
198,
2,
4299,
649,
62,
1136,
62,
469,
78,
7,
1174,
37266,
2599,
198,
2,
220,
220,
220,
1441,
651,
62,
469,
78,
7,
35428,
11,
12429,
37266,
8,
198,
2,
198,
2,
79,
796,
350,
382,
7,
35428,
11,
12429,
12286,
8,
198,
2,
79,
13,
11249,
7,
71,
28,
13,
20,
8,
198,
2,
198,
2,
79,
13,
35428,
70,
684,
14692,
26591,
4411,
1,
4083,
29487,
7203,
482,
4943,
198,
2,
79,
13,
35428,
70,
684,
14692,
11883,
1671,
1531,
1,
4083,
29487,
3419,
198,
2,
79,
13,
35428,
70,
684,
14692,
65,
12171,
35522,
312,
62,
4852,
1,
4083,
29487,
3419,
198,
2,
79,
13,
35428,
70,
684,
14692,
65,
12171,
35522,
312,
62,
22487,
1,
4083,
29487,
3419,
198,
2,
489,
83,
13,
12860,
3419,
198,
198,
2,
40406,
796,
31122,
7,
1136,
62,
469,
78,
28,
3605,
62,
1136,
62,
469,
78,
11,
30324,
28,
12286,
11,
289,
28,
13,
20,
8,
198,
2,
40406,
796,
31122,
7,
71,
28,
13,
20,
8,
198,
2,
40406,
13,
469,
78,
13,
29487,
62,
7784,
3166,
3419,
198,
12543,
2733,
11,
19609,
796,
7032,
13,
1136,
62,
12543,
2733,
7,
3672,
2625,
35,
26591,
4411,
12,
66,
280,
10137,
1600,
12429,
37266,
8,
198,
17080,
796,
5499,
14692,
17080,
8973,
198,
198,
2,
67,
4024,
259,
13,
29487,
7,
17080,
11,
14333,
28,
17821,
8,
198,
198,
2,
5678,
360,
4197,
422,
32798,
21862,
15724,
290,
7110,
7400,
4817,
360,
3815,
198,
32,
796,
657,
13,
2414,
26895,
198,
33,
796,
657,
13,
830,
2598,
198,
34,
796,
657,
13,
15,
3104,
5824,
198,
35,
796,
657,
13,
2327,
33981,
198,
36,
796,
657,
13,
1129,
29416,
198,
198,
89,
11,
360,
796,
814,
62,
13317,
62,
11147,
7,
64,
10779,
1065,
11,
275,
28,
17,
11,
399,
28,
3064,
8,
198,
489,
83,
13,
29487,
7,
89,
11,
360,
11,
27444,
65,
1600,
6167,
2625,
33349,
4817,
357,
10745,
9504,
24911,
8,
4943,
198,
198,
7890,
796,
814,
62,
13317,
62,
89,
62,
64,
4411,
7,
64,
10779,
1065,
11,
275,
28,
17,
11,
399,
28,
3064,
11,
12429,
37266,
8,
198,
89,
796,
685,
87,
15,
58,
17,
60,
329,
2124,
15,
287,
1366,
14692,
87,
8973,
60,
198,
35,
89,
796,
1366,
14692,
35,
8973,
198,
198,
489,
83,
13,
29487,
7,
89,
11,
360,
89,
11,
366,
519,
1600,
6167,
2625,
13295,
7409,
14892,
28995,
2746,
4943,
198,
489,
83,
13,
2645,
9608,
7203,
6892,
13,
814,
385,
3458,
4943,
198,
489,
83,
13,
87,
18242,
7203,
89,
685,
21533,
60,
4943,
198,
489,
83,
13,
87,
2475,
32590,
940,
11,
657,
8,
198,
897,
796,
458,
83,
13,
70,
6888,
3419,
198,
2,
897,
13,
88,
22704,
13,
42298,
62,
3506,
3419,
198,
2,
897,
13,
88,
22704,
13,
2617,
62,
18242,
62,
9150,
7203,
3506,
4943,
198,
489,
83,
13,
1455,
437,
7,
17946,
2625,
45828,
1364,
1600,
5739,
261,
28,
25101,
8,
198,
198,
6738,
46661,
2850,
1330,
3613,
5647,
82,
198,
6738,
24512,
1330,
19697,
34720,
198,
21928,
5647,
82,
7203,
35,
89,
1600,
19697,
34720,
1343,
12813,
64,
4411,
1600,
357,
21,
11,
604,
13,
20,
4008,
198,
2,
4798,
2482
] | 2.334078 | 895 |
"""This module solves kata https://www.codewars.com/kata/multiples-and-digit-sums/train/python."""
def procedure(i):
"""Return an integer derived by first finding all multiples of i up to 100,
then summing all up digit sums of all multiples."""
return sum(int(d) for i in range(n, 101, n) for d in str(i))
| [
37811,
1212,
8265,
39107,
479,
1045,
3740,
1378,
2503,
13,
19815,
413,
945,
13,
785,
14,
74,
1045,
14,
41684,
2374,
12,
392,
12,
27003,
12,
82,
5700,
14,
27432,
14,
29412,
526,
15931,
628,
198,
4299,
8771,
7,
72,
2599,
198,
220,
220,
220,
37227,
13615,
281,
18253,
10944,
416,
717,
4917,
477,
5021,
2374,
286,
1312,
510,
284,
1802,
11,
198,
220,
220,
220,
788,
2160,
2229,
477,
510,
16839,
21784,
286,
477,
5021,
2374,
526,
15931,
198,
220,
220,
220,
1441,
2160,
7,
600,
7,
67,
8,
329,
1312,
287,
2837,
7,
77,
11,
8949,
11,
299,
8,
329,
288,
287,
965,
7,
72,
4008,
198
] | 2.93578 | 109 |
import json
import folium
import folium.plugins
import tempfile
import os
import re
import argparse
if __name__ == "__main__":
cwd = os.getcwd()
args = get_args()
plot_privpurge(
os.path.join(cwd, args.zonefile),
os.path.join(cwd, args.directory),
filename=args.output,
)
| [
11748,
33918,
198,
11748,
5955,
1505,
198,
11748,
5955,
1505,
13,
37390,
198,
11748,
20218,
7753,
198,
11748,
28686,
198,
11748,
302,
628,
198,
198,
11748,
1822,
29572,
628,
198,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
269,
16993,
796,
28686,
13,
1136,
66,
16993,
3419,
628,
220,
220,
220,
26498,
796,
651,
62,
22046,
3419,
628,
220,
220,
220,
7110,
62,
13776,
14225,
469,
7,
198,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
6978,
13,
22179,
7,
66,
16993,
11,
26498,
13,
11340,
7753,
828,
198,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
6978,
13,
22179,
7,
66,
16993,
11,
26498,
13,
34945,
828,
198,
220,
220,
220,
220,
220,
220,
220,
29472,
28,
22046,
13,
22915,
11,
198,
220,
220,
220,
1267,
198
] | 2.335766 | 137 |
# pylint: skip-file
"""
Unit test for data utils functions.
"""
import numpy as np
import pandas as pd
import pytest
import tensorflow as tf
from tensorflow import test
from .data_utils import quantiles_handler, example_handler, fill_none
from ..data import random_ts
from ..dataset import WindowGenerator
@pytest.fixture(scope="class")
@pytest.mark.usefixtures("prepare_data")
@pytest.mark.usefixtures("prepare_data")
| [
2,
279,
2645,
600,
25,
14267,
12,
7753,
198,
198,
37811,
198,
26453,
1332,
329,
1366,
3384,
4487,
5499,
13,
198,
37811,
198,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
19798,
292,
355,
279,
67,
198,
11748,
12972,
9288,
198,
198,
11748,
11192,
273,
11125,
355,
48700,
198,
6738,
11192,
273,
11125,
1330,
1332,
198,
198,
6738,
764,
7890,
62,
26791,
1330,
5554,
2915,
62,
30281,
11,
1672,
62,
30281,
11,
6070,
62,
23108,
198,
6738,
11485,
7890,
1330,
4738,
62,
912,
198,
6738,
11485,
19608,
292,
316,
1330,
26580,
8645,
1352,
628,
198,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
4871,
4943,
628,
198,
31,
9078,
9288,
13,
4102,
13,
1904,
69,
25506,
7203,
46012,
533,
62,
7890,
4943,
628,
198,
31,
9078,
9288,
13,
4102,
13,
1904,
69,
25506,
7203,
46012,
533,
62,
7890,
4943,
198
] | 3.028169 | 142 |
# Copyright (C) Mesosphere, Inc. See LICENSE file for details.
"""
Shared code for DC/OS endpoints mocks used by AR instances, both EE and Open.
"""
import abc
import http.server
import logging
import os
import socket
import socketserver
import ssl
import threading
# pylint: disable=C0103
log = logging.getLogger(__name__)
# Just a dict would be no good as we want to have threading lock initialization
# as well.
# pylint: disable=R0903
class EndpointContext:
"""An endpoint context that holds all the endpoint data together with
threading lock that protects it."""
data = None
lock = None
def __init__(self, initial_data=None):
"""Initialize EndpointContext object.
This data is often manipulated by methods nested across
inheritance chains, so we need to use RLock() instead of Lock().
The need for the lock itself stems from the fact that very often certain
keys of the context need to be manipulated at the same time/in synchronized
manner.
In some of the places, code relies on thread safety/atomicity of
some of Python's expressions/statements:
https://docs.python.org/3.6/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
This is why some of the operations on the EndpointContext dictionary
are not protected by locks, esp. in case when it's only about fetching
a single value from context dict or storing/appending one there.
Args:
initial_data (dict): initial data to initialize context with
"""
self.lock = threading.RLock()
if initial_data is not None:
self.data = initial_data
else:
self.data = {}
class Endpoint(abc.ABC):
"""Endpoint base class, from which all Endpoints must inherit
This class represents common behaviour shared across all endpoints,
no matter the function or repository flavour (ee/open).
Ever endpoint must by default serve GOOD/expected data, and only after
changing it's state using it's methods, it may start serving something
else and/or simulate error conditions.
The state of the endpoint may be changed by tests/fixtures by executing
Mocker's .send_command() method which in turn redirect the call to the
correct endpoint call. For the sake of simplicity it is assumed that each
such method will have well-defined interface:
def do_something(self, aux_data=None):
return result
`aux_data` is a python dictionary that must provide all data required
by function to execute. It can be None if such data is not required
`result` can be anything that makes sense in particular function's case.
"""
_context = None
_httpd_thread = None
_httpd = None
def __init__(self, endpoint_id):
"""Initialize new Endpoint object
Args:
endpoint_id (str): ID of the endpoint that it should identify itself
with
"""
initial_data = {"always_bork": False,
"endpoint_id": endpoint_id,
"always_redirect": False,
"redirect_target": None,
"always_stall": False,
"response_headers": {},
"stall_time": 0,
}
self._context = EndpointContext(initial_data)
@property
def id(self):
"""Return ID of the endpoint"""
return self._context.data['endpoint_id']
def start(self):
"""Start endpoint's threaded httpd server"""
log.debug("Starting endpoint `%s`", self.id)
self._httpd_thread.start()
self._httpd.startup_done.wait()
def stop(self):
"""Perform cleanup of the endpoint threads
This method should be used right before destroying the Endpoint object.
It takes care of stopping internal httpd server.
"""
log.debug("Stopping endpoint `%s`", self.id)
self._httpd.shutdown()
self._httpd_thread.join()
self._httpd.server_close()
def reset(self, aux_data=None):
"""Reset endpoint to the default/good state
Args:
aux_data (dict): unused, present only to satisfy the endpoint's
method interface. See class description for details.
"""
del aux_data
log.debug("Resetting endpoint `%s`", self.id)
# Locking is not really needed here as it is atomic op anyway,
# but let's be consistent
with self._context.lock:
self._context.data['always_bork'] = False
self._context.data['always_stall'] = False
self._context.data['stall_time'] = 0
self._context.data["always_redirect"] = False
self._context.data["redirect_target"] = None
def set_response_headers(self, aux_data):
"""Make endpoint sent custom headers in the response
Args:
aux_data: a dict with header's name/content as keys/vals
"""
with self._context.lock:
self._context.data["response_headers"].update(aux_data)
def always_stall(self, aux_data=None):
"""Make endpoint always wait given time before answering the request
Args:
aux_data (numeric): time in seconds, as acepted by time.sleep()
function
"""
with self._context.lock:
self._context.data["always_stall"] = True
self._context.data["stall_time"] = aux_data
def always_bork(self, aux_data=True):
"""Make endpoint always respond with an error
Args:
aux_data (dict): True or False, depending whether endpoint should
always respond with errors or not.
"""
self._context.data["always_bork"] = aux_data
def always_redirect(self, aux_data=None):
"""Make endpoint always respond with a redirect
Args:
aux_data (str): target location for the redirect
"""
with self._context.lock:
self._context.data["always_redirect"] = True
self._context.data["redirect_target"] = aux_data
class StatefullHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
"""Base class for all endpoint-internal httpd servers.
This class serves as a base for all internal httpd server, it's role is
to pull in Threading mix-in and link Endpoint context to httpd itself,
so that it's available in the httpd request handler through request's
.server.context attribute.
Worth noting that this is by default a TCP/IP server.
It's based on:
https://mail.python.org/pipermail/python-list/2012-March/621727.html
"""
class TcpIpHttpEndpoint(Endpoint):
"""Base class for all endpoints that serve TCP/IP requests
This class binds together HTTPd server code, http request handler and
endpoint context to form a base class for all endpoints that serve
TCP/IP traffic.
"""
def __init__(self, handler_class, port, ip='', keyfile=None, certfile=None):
"""Initialize new TcpIpHttpEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
port (int): tcp port that httpd server will listen on
ip (str): ip address that httpd server will listen on, by default
listen on all addresses
"""
if certfile is not None and keyfile is not None:
endpoint_id = "https://{}:{}".format(ip, port)
else:
endpoint_id = "http://{}:{}".format(ip, port)
super().__init__(endpoint_id)
self._context.data['listen_ip'] = ip
self._context.data['listen_port'] = port
self._context.data['certfile'] = certfile
self._context.data['keyfile'] = keyfile
self._handler_class = handler_class
self.__setup_httpd_thread(ip, port)
def __setup_httpd_thread(self, ip, port):
"""Setup internal HTTPd server that this endpoints relies on to serve
requests.
"""
self._httpd = StatefullHTTPServer(self._context,
(ip, port),
self._handler_class)
httpd_thread_name = "TcpIpHttpdThread-{}".format(self.id)
self._httpd_thread = threading.Thread(target=self._httpd.serve_forever,
name=httpd_thread_name)
class UnixSocketStatefulHTTPServer(StatefullHTTPServer):
"""Base class for all endpoint-internal httpd servers that listen on
Unix socket.
This class inherits from StatefullHTTPServer and mofies it's behaviour
so that it's able to listen on Unix socket.
Attributes:
address_family: set only to override default value of the variable set
in the http.server.HTTPServer class, must not be modified.
"""
address_family = socket.AF_UNIX
def server_bind(self):
"""Override default server socket bind behaviour to adapt it to
serving on Unix socket.
Please check the documentation of http.server.HTTPServer class for more
details.
"""
socketserver.TCPServer.server_bind(self)
self.server_name = self.context.data['socket_path']
self.server_port = 0
def client_address(self):
"""Override default client_address method to adapt it to serving on Unix
socket. Without it logging will break as Unix socket has no notion of
the client's IP address.
Please check the documentation of http.server.HTTPServer class for more
details.
"""
return (self.context.data['socket_path'], 0)
# http://stackoverflow.com/questions/21650370/setting-up-an-http-server-that-listens-over-a-file-socket
# https://docs.python.org/3.3/library/socketserver.html
class UnixSocketHTTPEndpoint(Endpoint):
"""Base class for all endpoints that serve requests on the Unix socket
This class binds together HTTPd server code, http request handler and
endpoint context to form a base class for all endpoints that serve
Unix socket traffic.
"""
def __init__(self, handler_class, path, keyfile=None, certfile=None):
"""Initialize new UnixSocketHTTPEndpoint object
Args:
handler_class (obj): a request handler class that will be handling
requests received by internal httpd server
path (str): Unix socket path, that internal httpd server will listen
on
"""
if certfile is not None and keyfile is not None:
endpoint_id = "https://{}".format(path)
else:
endpoint_id = "http://{}".format(path)
super().__init__(endpoint_id)
self._context.data['socket_path'] = path
self._context.data['certfile'] = certfile
self._context.data['keyfile'] = keyfile
self._handler_class = handler_class
self.__cleanup_stale_socket(path)
self.__setup_httpd_thread(path)
@staticmethod
def __setup_httpd_thread(self, socket_path):
"""Setup internal HTTPd server that this endpoints relies on to serve
requests.
Args:
path (str): Unix socket path, that internal httpd server will listen
on
"""
self._httpd = UnixSocketStatefulHTTPServer(self._context,
socket_path,
self._handler_class)
httpd_thread_name = "UnixSocketHttpdThread-{}".format(self.id)
self._httpd_thread = threading.Thread(target=self._httpd.serve_forever,
name=httpd_thread_name)
# nginx spawns worker processes as 'nobody/nogroup', so we need to
# make the socket available to it.
os.chmod(socket_path, 0o777)
| [
2,
15069,
357,
34,
8,
14937,
22829,
11,
3457,
13,
4091,
38559,
24290,
2393,
329,
3307,
13,
198,
198,
37811,
198,
2484,
1144,
2438,
329,
6257,
14,
2640,
886,
13033,
285,
3320,
973,
416,
5923,
10245,
11,
1111,
27254,
290,
4946,
13,
198,
37811,
198,
198,
11748,
450,
66,
198,
11748,
2638,
13,
15388,
198,
11748,
18931,
198,
11748,
28686,
198,
11748,
17802,
198,
11748,
37037,
18497,
198,
11748,
264,
6649,
198,
11748,
4704,
278,
198,
198,
2,
279,
2645,
600,
25,
15560,
28,
34,
486,
3070,
198,
6404,
796,
18931,
13,
1136,
11187,
1362,
7,
834,
3672,
834,
8,
628,
198,
2,
2329,
257,
8633,
561,
307,
645,
922,
355,
356,
765,
284,
423,
4704,
278,
5793,
37588,
198,
2,
355,
880,
13,
198,
2,
279,
2645,
600,
25,
15560,
28,
49,
2931,
3070,
198,
4871,
5268,
4122,
21947,
25,
198,
220,
220,
220,
37227,
2025,
36123,
4732,
326,
6622,
477,
262,
36123,
1366,
1978,
351,
198,
220,
220,
220,
220,
220,
220,
4704,
278,
5793,
326,
17289,
340,
526,
15931,
198,
220,
220,
220,
1366,
796,
6045,
198,
220,
220,
220,
5793,
796,
6045,
628,
220,
220,
220,
825,
11593,
15003,
834,
7,
944,
11,
4238,
62,
7890,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
24243,
1096,
5268,
4122,
21947,
2134,
13,
628,
220,
220,
220,
220,
220,
220,
220,
770,
1366,
318,
1690,
25036,
416,
5050,
28376,
1973,
198,
220,
220,
220,
220,
220,
220,
220,
24155,
14659,
11,
523,
356,
761,
284,
779,
371,
25392,
3419,
2427,
286,
13656,
22446,
628,
220,
220,
220,
220,
220,
220,
220,
383,
761,
329,
262,
5793,
2346,
21552,
422,
262,
1109,
326,
845,
1690,
1728,
198,
220,
220,
220,
220,
220,
220,
220,
8251,
286,
262,
4732,
761,
284,
307,
25036,
379,
262,
976,
640,
14,
259,
47192,
198,
220,
220,
220,
220,
220,
220,
220,
5642,
13,
628,
220,
220,
220,
220,
220,
220,
220,
554,
617,
286,
262,
4113,
11,
2438,
16507,
319,
4704,
3747,
14,
37696,
8467,
286,
198,
220,
220,
220,
220,
220,
220,
220,
617,
286,
11361,
338,
14700,
14,
14269,
3196,
25,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3740,
1378,
31628,
13,
29412,
13,
2398,
14,
18,
13,
21,
14,
13331,
80,
14,
32016,
13,
6494,
2,
10919,
12,
11031,
82,
12,
1659,
12,
20541,
12,
8367,
12,
76,
7094,
12,
533,
12,
16663,
12,
21230,
628,
220,
220,
220,
220,
220,
220,
220,
770,
318,
1521,
617,
286,
262,
4560,
319,
262,
5268,
4122,
21947,
22155,
198,
220,
220,
220,
220,
220,
220,
220,
389,
407,
6861,
416,
19253,
11,
15024,
13,
287,
1339,
618,
340,
338,
691,
546,
21207,
278,
198,
220,
220,
220,
220,
220,
220,
220,
257,
2060,
1988,
422,
4732,
8633,
393,
23069,
14,
1324,
1571,
530,
612,
13,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4238,
62,
7890,
357,
11600,
2599,
4238,
1366,
284,
41216,
4732,
351,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
5354,
796,
4704,
278,
13,
7836,
735,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4238,
62,
7890,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
7890,
796,
4238,
62,
7890,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
7890,
796,
23884,
628,
198,
4871,
5268,
4122,
7,
39305,
13,
24694,
2599,
198,
220,
220,
220,
37227,
12915,
4122,
2779,
1398,
11,
422,
543,
477,
5268,
13033,
1276,
16955,
628,
220,
220,
220,
220,
220,
220,
770,
1398,
6870,
2219,
9172,
4888,
1973,
477,
886,
13033,
11,
198,
220,
220,
220,
220,
220,
220,
645,
2300,
262,
2163,
393,
16099,
29254,
357,
1453,
14,
9654,
737,
628,
220,
220,
220,
220,
220,
220,
10776,
36123,
1276,
416,
4277,
4691,
21090,
14,
40319,
1366,
11,
290,
691,
706,
198,
220,
220,
220,
220,
220,
220,
5609,
340,
338,
1181,
1262,
340,
338,
5050,
11,
340,
743,
923,
7351,
1223,
198,
220,
220,
220,
220,
220,
220,
2073,
290,
14,
273,
29308,
4049,
3403,
13,
628,
220,
220,
220,
220,
220,
220,
383,
1181,
286,
262,
36123,
743,
307,
3421,
416,
5254,
14,
69,
25506,
416,
23710,
198,
220,
220,
220,
220,
220,
220,
337,
12721,
338,
764,
21280,
62,
21812,
3419,
2446,
543,
287,
1210,
18941,
262,
869,
284,
262,
198,
220,
220,
220,
220,
220,
220,
3376,
36123,
869,
13,
1114,
262,
11060,
286,
21654,
340,
318,
9672,
326,
1123,
198,
220,
220,
220,
220,
220,
220,
884,
2446,
481,
423,
880,
12,
23211,
7071,
25,
198,
220,
220,
220,
220,
220,
220,
220,
825,
466,
62,
18927,
7,
944,
11,
27506,
62,
7890,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1255,
628,
220,
220,
220,
220,
220,
220,
220,
4600,
14644,
62,
7890,
63,
318,
257,
21015,
22155,
326,
1276,
2148,
477,
1366,
2672,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
416,
2163,
284,
12260,
13,
632,
460,
307,
6045,
611,
884,
1366,
318,
407,
2672,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
20274,
63,
460,
307,
1997,
326,
1838,
2565,
287,
1948,
2163,
338,
1339,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
4808,
22866,
796,
6045,
198,
220,
220,
220,
4808,
4023,
67,
62,
16663,
796,
6045,
198,
220,
220,
220,
4808,
4023,
67,
796,
6045,
628,
220,
220,
220,
825,
11593,
15003,
834,
7,
944,
11,
36123,
62,
312,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
24243,
1096,
649,
5268,
4122,
2134,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36123,
62,
312,
357,
2536,
2599,
4522,
286,
262,
36123,
326,
340,
815,
5911,
2346,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
351,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
4238,
62,
7890,
796,
19779,
33770,
62,
65,
967,
1298,
10352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
437,
4122,
62,
312,
1298,
36123,
62,
312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
33770,
62,
445,
1060,
1298,
10352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
445,
1060,
62,
16793,
1298,
6045,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
33770,
62,
32989,
1298,
10352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
26209,
62,
50145,
1298,
1391,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
32989,
62,
2435,
1298,
657,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
796,
5268,
4122,
21947,
7,
36733,
62,
7890,
8,
628,
220,
220,
220,
2488,
26745,
198,
220,
220,
220,
825,
4686,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
13615,
4522,
286,
262,
36123,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13557,
22866,
13,
7890,
17816,
437,
4122,
62,
312,
20520,
628,
220,
220,
220,
825,
923,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
10434,
36123,
338,
40945,
2638,
67,
4382,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
2604,
13,
24442,
7203,
22851,
36123,
4600,
4,
82,
63,
1600,
2116,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
62,
16663,
13,
9688,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
13,
9688,
929,
62,
28060,
13,
17077,
3419,
628,
220,
220,
220,
825,
2245,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
5990,
687,
27425,
286,
262,
36123,
14390,
628,
220,
220,
220,
220,
220,
220,
220,
770,
2446,
815,
307,
973,
826,
878,
13897,
262,
5268,
4122,
2134,
13,
198,
220,
220,
220,
220,
220,
220,
220,
632,
2753,
1337,
286,
12225,
5387,
2638,
67,
4382,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2604,
13,
24442,
7203,
1273,
33307,
36123,
4600,
4,
82,
63,
1600,
2116,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
13,
49625,
2902,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
62,
16663,
13,
22179,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
13,
15388,
62,
19836,
3419,
628,
220,
220,
220,
825,
13259,
7,
944,
11,
27506,
62,
7890,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
4965,
316,
36123,
284,
262,
4277,
14,
11274,
1181,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27506,
62,
7890,
357,
11600,
2599,
21958,
11,
1944,
691,
284,
15959,
262,
36123,
338,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2446,
7071,
13,
4091,
1398,
6764,
329,
3307,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1619,
27506,
62,
7890,
198,
220,
220,
220,
220,
220,
220,
220,
2604,
13,
24442,
7203,
4965,
35463,
36123,
4600,
4,
82,
63,
1600,
2116,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
406,
8629,
318,
407,
1107,
2622,
994,
355,
340,
318,
17226,
1034,
6949,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
475,
1309,
338,
307,
6414,
198,
220,
220,
220,
220,
220,
220,
220,
351,
2116,
13557,
22866,
13,
5354,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
33770,
62,
65,
967,
20520,
796,
10352,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
33770,
62,
32989,
20520,
796,
10352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
32989,
62,
2435,
20520,
796,
657,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
33770,
62,
445,
1060,
8973,
796,
10352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
445,
1060,
62,
16793,
8973,
796,
6045,
628,
220,
220,
220,
825,
900,
62,
26209,
62,
50145,
7,
944,
11,
27506,
62,
7890,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
12050,
36123,
1908,
2183,
24697,
287,
262,
2882,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27506,
62,
7890,
25,
257,
8633,
351,
13639,
338,
1438,
14,
11299,
355,
8251,
14,
12786,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
351,
2116,
13557,
22866,
13,
5354,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
26209,
62,
50145,
1,
4083,
19119,
7,
14644,
62,
7890,
8,
628,
220,
220,
220,
825,
1464,
62,
32989,
7,
944,
11,
27506,
62,
7890,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
12050,
36123,
1464,
4043,
1813,
640,
878,
18877,
262,
2581,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27506,
62,
7890,
357,
77,
39223,
2599,
640,
287,
4201,
11,
355,
257,
984,
276,
416,
640,
13,
42832,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2163,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
351,
2116,
13557,
22866,
13,
5354,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
33770,
62,
32989,
8973,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
32989,
62,
2435,
8973,
796,
27506,
62,
7890,
628,
220,
220,
220,
825,
1464,
62,
65,
967,
7,
944,
11,
27506,
62,
7890,
28,
17821,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
12050,
36123,
1464,
3031,
351,
281,
4049,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27506,
62,
7890,
357,
11600,
2599,
6407,
393,
10352,
11,
6906,
1771,
36123,
815,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1464,
3031,
351,
8563,
393,
407,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
33770,
62,
65,
967,
8973,
796,
27506,
62,
7890,
628,
220,
220,
220,
825,
1464,
62,
445,
1060,
7,
944,
11,
27506,
62,
7890,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
12050,
36123,
1464,
3031,
351,
257,
18941,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27506,
62,
7890,
357,
2536,
2599,
2496,
4067,
329,
262,
18941,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
351,
2116,
13557,
22866,
13,
5354,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
33770,
62,
445,
1060,
8973,
796,
6407,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
14692,
445,
1060,
62,
16793,
8973,
796,
27506,
62,
7890,
628,
198,
4871,
1812,
12853,
6535,
28820,
18497,
7,
82,
11603,
18497,
13,
16818,
278,
35608,
818,
11,
2638,
13,
15388,
13,
6535,
28820,
18497,
2599,
198,
220,
220,
220,
37227,
14881,
1398,
329,
477,
36123,
12,
32538,
2638,
67,
9597,
13,
628,
220,
220,
220,
770,
1398,
9179,
355,
257,
2779,
329,
477,
5387,
2638,
67,
4382,
11,
340,
338,
2597,
318,
198,
220,
220,
220,
284,
2834,
287,
14122,
278,
5022,
12,
259,
290,
2792,
5268,
4122,
4732,
284,
2638,
67,
2346,
11,
198,
220,
220,
220,
523,
326,
340,
338,
1695,
287,
262,
2638,
67,
2581,
21360,
832,
2581,
338,
198,
220,
220,
220,
764,
15388,
13,
22866,
11688,
13,
628,
220,
220,
220,
22301,
10820,
326,
428,
318,
416,
4277,
257,
23633,
14,
4061,
4382,
13,
628,
220,
220,
220,
632,
338,
1912,
319,
25,
198,
220,
220,
220,
3740,
1378,
4529,
13,
29412,
13,
2398,
14,
79,
9346,
4529,
14,
29412,
12,
4868,
14,
6999,
12,
16192,
14,
5237,
1558,
1983,
13,
6494,
198,
220,
220,
220,
37227,
628,
198,
4871,
309,
13155,
40,
79,
43481,
12915,
4122,
7,
12915,
4122,
2599,
198,
220,
220,
220,
37227,
14881,
1398,
329,
477,
886,
13033,
326,
4691,
23633,
14,
4061,
7007,
628,
220,
220,
220,
220,
220,
220,
220,
770,
1398,
37354,
1978,
14626,
67,
4382,
2438,
11,
2638,
2581,
21360,
290,
198,
220,
220,
220,
220,
220,
220,
220,
36123,
4732,
284,
1296,
257,
2779,
1398,
329,
477,
886,
13033,
326,
4691,
198,
220,
220,
220,
220,
220,
220,
220,
23633,
14,
4061,
4979,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
825,
11593,
15003,
834,
7,
944,
11,
21360,
62,
4871,
11,
2493,
11,
20966,
11639,
3256,
1994,
7753,
28,
14202,
11,
5051,
7753,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
24243,
1096,
649,
309,
13155,
40,
79,
43481,
12915,
4122,
2134,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
21360,
62,
4871,
357,
26801,
2599,
257,
2581,
21360,
1398,
326,
481,
307,
9041,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7007,
2722,
416,
5387,
2638,
67,
4382,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2493,
357,
600,
2599,
48265,
2493,
326,
2638,
67,
4382,
481,
6004,
319,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20966,
357,
2536,
2599,
20966,
2209,
326,
2638,
67,
4382,
481,
6004,
319,
11,
416,
4277,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6004,
319,
477,
9405,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5051,
7753,
318,
407,
6045,
290,
1994,
7753,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36123,
62,
312,
796,
366,
5450,
1378,
90,
92,
29164,
92,
1911,
18982,
7,
541,
11,
2493,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36123,
62,
312,
796,
366,
4023,
1378,
90,
92,
29164,
92,
1911,
18982,
7,
541,
11,
2493,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
22446,
834,
15003,
834,
7,
437,
4122,
62,
312,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
4868,
268,
62,
541,
20520,
796,
20966,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
4868,
268,
62,
634,
20520,
796,
2493,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
22583,
7753,
20520,
796,
5051,
7753,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
2539,
7753,
20520,
796,
1994,
7753,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
30281,
62,
4871,
796,
21360,
62,
4871,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
834,
40406,
62,
4023,
67,
62,
16663,
7,
541,
11,
2493,
8,
628,
220,
220,
220,
825,
11593,
40406,
62,
4023,
67,
62,
16663,
7,
944,
11,
20966,
11,
2493,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
40786,
5387,
14626,
67,
4382,
326,
428,
886,
13033,
16507,
319,
284,
4691,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7007,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
796,
1812,
12853,
6535,
28820,
18497,
7,
944,
13557,
22866,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
541,
11,
2493,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
30281,
62,
4871,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2638,
67,
62,
16663,
62,
3672,
796,
366,
51,
13155,
40,
79,
43481,
67,
16818,
12,
90,
92,
1911,
18982,
7,
944,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
62,
16663,
796,
4704,
278,
13,
16818,
7,
16793,
28,
944,
13557,
4023,
67,
13,
2655,
303,
62,
754,
332,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
28,
4023,
67,
62,
16663,
62,
3672,
8,
628,
198,
4871,
33501,
39105,
9012,
913,
6535,
28820,
18497,
7,
9012,
12853,
6535,
28820,
18497,
2599,
198,
220,
220,
220,
37227,
14881,
1398,
329,
477,
36123,
12,
32538,
2638,
67,
9597,
326,
6004,
319,
198,
220,
220,
220,
220,
220,
220,
33501,
17802,
13,
628,
220,
220,
220,
770,
1398,
10639,
896,
422,
1812,
12853,
6535,
28820,
18497,
290,
285,
1659,
444,
340,
338,
9172,
198,
220,
220,
220,
523,
326,
340,
338,
1498,
284,
6004,
319,
33501,
17802,
13,
628,
220,
220,
220,
49213,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2209,
62,
17989,
25,
900,
691,
284,
20957,
4277,
1988,
286,
262,
7885,
900,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
287,
262,
2638,
13,
15388,
13,
6535,
28820,
18497,
1398,
11,
1276,
407,
307,
9518,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2209,
62,
17989,
796,
17802,
13,
8579,
62,
4944,
10426,
628,
220,
220,
220,
825,
4382,
62,
21653,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
37961,
4277,
4382,
17802,
11007,
9172,
284,
6068,
340,
284,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7351,
319,
33501,
17802,
13,
628,
220,
220,
220,
220,
220,
220,
220,
4222,
2198,
262,
10314,
286,
2638,
13,
15388,
13,
6535,
28820,
18497,
1398,
329,
517,
198,
220,
220,
220,
220,
220,
220,
220,
3307,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
37037,
18497,
13,
4825,
3705,
18497,
13,
15388,
62,
21653,
7,
944,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
15388,
62,
3672,
796,
2116,
13,
22866,
13,
7890,
17816,
44971,
62,
6978,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
15388,
62,
634,
796,
657,
628,
220,
220,
220,
825,
5456,
62,
21975,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
37961,
4277,
5456,
62,
21975,
2446,
284,
6068,
340,
284,
7351,
319,
33501,
198,
220,
220,
220,
220,
220,
220,
220,
17802,
13,
9170,
340,
18931,
481,
2270,
355,
33501,
17802,
468,
645,
9495,
286,
198,
220,
220,
220,
220,
220,
220,
220,
262,
5456,
338,
6101,
2209,
13,
628,
220,
220,
220,
220,
220,
220,
220,
4222,
2198,
262,
10314,
286,
2638,
13,
15388,
13,
6535,
28820,
18497,
1398,
329,
517,
198,
220,
220,
220,
220,
220,
220,
220,
3307,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
944,
13,
22866,
13,
7890,
17816,
44971,
62,
6978,
6,
4357,
657,
8,
628,
198,
2,
2638,
1378,
25558,
2502,
11125,
13,
785,
14,
6138,
507,
14,
20666,
1120,
20167,
14,
33990,
12,
929,
12,
272,
12,
4023,
12,
15388,
12,
5562,
12,
4868,
641,
12,
2502,
12,
64,
12,
7753,
12,
44971,
198,
2,
3740,
1378,
31628,
13,
29412,
13,
2398,
14,
18,
13,
18,
14,
32016,
14,
82,
11603,
18497,
13,
6494,
198,
4871,
33501,
39105,
40717,
12915,
4122,
7,
12915,
4122,
2599,
198,
220,
220,
220,
37227,
14881,
1398,
329,
477,
886,
13033,
326,
4691,
7007,
319,
262,
33501,
17802,
628,
220,
220,
220,
220,
220,
220,
220,
770,
1398,
37354,
1978,
14626,
67,
4382,
2438,
11,
2638,
2581,
21360,
290,
198,
220,
220,
220,
220,
220,
220,
220,
36123,
4732,
284,
1296,
257,
2779,
1398,
329,
477,
886,
13033,
326,
4691,
198,
220,
220,
220,
220,
220,
220,
220,
33501,
17802,
4979,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
825,
11593,
15003,
834,
7,
944,
11,
21360,
62,
4871,
11,
3108,
11,
1994,
7753,
28,
14202,
11,
5051,
7753,
28,
14202,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
24243,
1096,
649,
33501,
39105,
40717,
12915,
4122,
2134,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
21360,
62,
4871,
357,
26801,
2599,
257,
2581,
21360,
1398,
326,
481,
307,
9041,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7007,
2722,
416,
5387,
2638,
67,
4382,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3108,
357,
2536,
2599,
33501,
17802,
3108,
11,
326,
5387,
2638,
67,
4382,
481,
6004,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
319,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5051,
7753,
318,
407,
6045,
290,
1994,
7753,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36123,
62,
312,
796,
366,
5450,
1378,
90,
92,
1911,
18982,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36123,
62,
312,
796,
366,
4023,
1378,
90,
92,
1911,
18982,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2208,
22446,
834,
15003,
834,
7,
437,
4122,
62,
312,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
44971,
62,
6978,
20520,
796,
3108,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
22583,
7753,
20520,
796,
5051,
7753,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
22866,
13,
7890,
17816,
2539,
7753,
20520,
796,
1994,
7753,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
30281,
62,
4871,
796,
21360,
62,
4871,
628,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
834,
27773,
929,
62,
301,
1000,
62,
44971,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
834,
40406,
62,
4023,
67,
62,
16663,
7,
6978,
8,
628,
220,
220,
220,
2488,
12708,
24396,
628,
220,
220,
220,
825,
11593,
40406,
62,
4023,
67,
62,
16663,
7,
944,
11,
17802,
62,
6978,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
40786,
5387,
14626,
67,
4382,
326,
428,
886,
13033,
16507,
319,
284,
4691,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7007,
13,
628,
220,
220,
220,
220,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3108,
357,
2536,
2599,
33501,
17802,
3108,
11,
326,
5387,
2638,
67,
4382,
481,
6004,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
319,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
796,
33501,
39105,
9012,
913,
6535,
28820,
18497,
7,
944,
13557,
22866,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17802,
62,
6978,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
30281,
62,
4871,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2638,
67,
62,
16663,
62,
3672,
796,
366,
47000,
39105,
43481,
67,
16818,
12,
90,
92,
1911,
18982,
7,
944,
13,
312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13557,
4023,
67,
62,
16663,
796,
4704,
278,
13,
16818,
7,
16793,
28,
944,
13557,
4023,
67,
13,
2655,
303,
62,
754,
332,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
28,
4023,
67,
62,
16663,
62,
3672,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
299,
42822,
44632,
8383,
7767,
355,
705,
34952,
1118,
14,
77,
519,
3233,
3256,
523,
356,
761,
284,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
787,
262,
17802,
1695,
284,
340,
13,
198,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
354,
4666,
7,
44971,
62,
6978,
11,
657,
78,
29331,
8,
198
] | 2.498764 | 4,856 |
import os
import argparse
from datetime import datetime
import time
import torch
import torch.nn.functional as F
import torch.multiprocessing as mp
import numpy as np
import pandas as pd
from tqdm import tqdm
import matplotlib
import matplotlib.pyplot as plt
from tensorboardX import SummaryWriter
import data
import track
import model
import utils
matplotlib.use("Qt5Agg")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("Process interrupted by user, emptying cache...")
torch.cuda.empty_cache()
| [
11748,
28686,
198,
11748,
1822,
29572,
198,
6738,
4818,
8079,
1330,
4818,
8079,
198,
11748,
640,
198,
198,
11748,
28034,
198,
11748,
28034,
13,
20471,
13,
45124,
355,
376,
198,
11748,
28034,
13,
16680,
541,
305,
919,
278,
355,
29034,
198,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
19798,
292,
355,
279,
67,
198,
6738,
256,
80,
36020,
1330,
256,
80,
36020,
198,
11748,
2603,
29487,
8019,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
198,
6738,
11192,
273,
3526,
55,
1330,
21293,
34379,
198,
198,
11748,
1366,
198,
11748,
2610,
198,
11748,
2746,
198,
11748,
3384,
4487,
198,
198,
6759,
29487,
8019,
13,
1904,
7203,
48,
83,
20,
46384,
4943,
628,
198,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1388,
3419,
198,
220,
220,
220,
2845,
31973,
9492,
3622,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
18709,
19072,
416,
2836,
11,
23909,
1112,
12940,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
28034,
13,
66,
15339,
13,
28920,
62,
23870,
3419,
198
] | 2.916667 | 192 |
import math
#def find_par(self):
if __name__ == "__main__":
main()
| [
11748,
10688,
198,
197,
197,
198,
197,
2,
4299,
1064,
62,
1845,
7,
944,
2599,
198,
197,
197,
198,
197,
197,
198,
197,
197,
198,
197,
198,
197,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
197,
12417,
3419,
198,
197,
197,
628,
198
] | 1.875 | 48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.