hexsha
string | size
int64 | ext
string | lang
string | max_stars_repo_path
string | max_stars_repo_name
string | max_stars_repo_head_hexsha
string | max_stars_repo_licenses
list | max_stars_count
int64 | max_stars_repo_stars_event_min_datetime
string | max_stars_repo_stars_event_max_datetime
string | max_issues_repo_path
string | max_issues_repo_name
string | max_issues_repo_head_hexsha
string | max_issues_repo_licenses
list | max_issues_count
int64 | max_issues_repo_issues_event_min_datetime
string | max_issues_repo_issues_event_max_datetime
string | max_forks_repo_path
string | max_forks_repo_name
string | max_forks_repo_head_hexsha
string | max_forks_repo_licenses
list | max_forks_count
int64 | max_forks_repo_forks_event_min_datetime
string | max_forks_repo_forks_event_max_datetime
string | content
string | avg_line_length
float64 | max_line_length
int64 | alphanum_fraction
float64 | qsc_code_num_words_quality_signal
int64 | qsc_code_num_chars_quality_signal
float64 | qsc_code_mean_word_length_quality_signal
float64 | qsc_code_frac_words_unique_quality_signal
float64 | qsc_code_frac_chars_top_2grams_quality_signal
float64 | qsc_code_frac_chars_top_3grams_quality_signal
float64 | qsc_code_frac_chars_top_4grams_quality_signal
float64 | qsc_code_frac_chars_dupe_5grams_quality_signal
float64 | qsc_code_frac_chars_dupe_6grams_quality_signal
float64 | qsc_code_frac_chars_dupe_7grams_quality_signal
float64 | qsc_code_frac_chars_dupe_8grams_quality_signal
float64 | qsc_code_frac_chars_dupe_9grams_quality_signal
float64 | qsc_code_frac_chars_dupe_10grams_quality_signal
float64 | qsc_code_frac_chars_replacement_symbols_quality_signal
float64 | qsc_code_frac_chars_digital_quality_signal
float64 | qsc_code_frac_chars_whitespace_quality_signal
float64 | qsc_code_size_file_byte_quality_signal
float64 | qsc_code_num_lines_quality_signal
float64 | qsc_code_num_chars_line_max_quality_signal
float64 | qsc_code_num_chars_line_mean_quality_signal
float64 | qsc_code_frac_chars_alphabet_quality_signal
float64 | qsc_code_frac_chars_comments_quality_signal
float64 | qsc_code_cate_xml_start_quality_signal
float64 | qsc_code_frac_lines_dupe_lines_quality_signal
float64 | qsc_code_cate_autogen_quality_signal
float64 | qsc_code_frac_lines_long_string_quality_signal
float64 | qsc_code_frac_chars_string_length_quality_signal
float64 | qsc_code_frac_chars_long_word_length_quality_signal
float64 | qsc_code_frac_lines_string_concat_quality_signal
float64 | qsc_code_cate_encoded_data_quality_signal
float64 | qsc_code_frac_chars_hex_words_quality_signal
float64 | qsc_code_frac_lines_prompt_comments_quality_signal
float64 | qsc_code_frac_lines_assert_quality_signal
float64 | qsc_codepython_cate_ast_quality_signal
float64 | qsc_codepython_frac_lines_func_ratio_quality_signal
float64 | qsc_codepython_cate_var_zero_quality_signal
bool | qsc_codepython_frac_lines_pass_quality_signal
float64 | qsc_codepython_frac_lines_import_quality_signal
float64 | qsc_codepython_frac_lines_simplefunc_quality_signal
float64 | qsc_codepython_score_lines_no_logic_quality_signal
float64 | qsc_codepython_frac_lines_print_quality_signal
float64 | qsc_code_num_words
int64 | qsc_code_num_chars
int64 | qsc_code_mean_word_length
int64 | qsc_code_frac_words_unique
null | qsc_code_frac_chars_top_2grams
int64 | qsc_code_frac_chars_top_3grams
int64 | qsc_code_frac_chars_top_4grams
int64 | qsc_code_frac_chars_dupe_5grams
int64 | qsc_code_frac_chars_dupe_6grams
int64 | qsc_code_frac_chars_dupe_7grams
int64 | qsc_code_frac_chars_dupe_8grams
int64 | qsc_code_frac_chars_dupe_9grams
int64 | qsc_code_frac_chars_dupe_10grams
int64 | qsc_code_frac_chars_replacement_symbols
int64 | qsc_code_frac_chars_digital
int64 | qsc_code_frac_chars_whitespace
int64 | qsc_code_size_file_byte
int64 | qsc_code_num_lines
int64 | qsc_code_num_chars_line_max
int64 | qsc_code_num_chars_line_mean
int64 | qsc_code_frac_chars_alphabet
int64 | qsc_code_frac_chars_comments
int64 | qsc_code_cate_xml_start
int64 | qsc_code_frac_lines_dupe_lines
int64 | qsc_code_cate_autogen
int64 | qsc_code_frac_lines_long_string
int64 | qsc_code_frac_chars_string_length
int64 | qsc_code_frac_chars_long_word_length
int64 | qsc_code_frac_lines_string_concat
null | qsc_code_cate_encoded_data
int64 | qsc_code_frac_chars_hex_words
int64 | qsc_code_frac_lines_prompt_comments
int64 | qsc_code_frac_lines_assert
int64 | qsc_codepython_cate_ast
int64 | qsc_codepython_frac_lines_func_ratio
int64 | qsc_codepython_cate_var_zero
int64 | qsc_codepython_frac_lines_pass
int64 | qsc_codepython_frac_lines_import
int64 | qsc_codepython_frac_lines_simplefunc
int64 | qsc_codepython_score_lines_no_logic
int64 | qsc_codepython_frac_lines_print
int64 | effective
string | hits
int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
96ab91e168f49b01f30f95262f20c9c6f8f22265
| 30
|
py
|
Python
|
hdmi/__init__.py
|
jackl-xilinx/PYNQ-derivative-overlays
|
66a1b9a4d83ef4c3bfae696f0f17f387e9f22219
|
[
"BSD-3-Clause"
] | 1
|
2021-07-21T07:10:31.000Z
|
2021-07-21T07:10:31.000Z
|
hdmi/__init__.py
|
jackl-xilinx/PYNQ-derivative-overlays
|
66a1b9a4d83ef4c3bfae696f0f17f387e9f22219
|
[
"BSD-3-Clause"
] | null | null | null |
hdmi/__init__.py
|
jackl-xilinx/PYNQ-derivative-overlays
|
66a1b9a4d83ef4c3bfae696f0f17f387e9f22219
|
[
"BSD-3-Clause"
] | null | null | null |
from .hdmi import HDMIOverlay
| 15
| 29
| 0.833333
| 4
| 30
| 6.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.133333
| 30
| 1
| 30
| 30
| 0.961538
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
7367108e3bf8253490f9009027006380251497e4
| 18,850
|
py
|
Python
|
pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/l2vpn/evpn/__init__.py
|
extremenetworks/pybind
|
44c467e71b2b425be63867aba6e6fa28b2cfe7fb
|
[
"Apache-2.0"
] | null | null | null |
pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/l2vpn/evpn/__init__.py
|
extremenetworks/pybind
|
44c467e71b2b425be63867aba6e6fa28b2cfe7fb
|
[
"Apache-2.0"
] | null | null | null |
pybind/slxos/v17s_1_02/routing_system/router/router_bgp/address_family/l2vpn/evpn/__init__.py
|
extremenetworks/pybind
|
44c467e71b2b425be63867aba6e6fa28b2cfe7fb
|
[
"Apache-2.0"
] | 1
|
2021-11-05T22:15:42.000Z
|
2021-11-05T22:15:42.000Z
|
from operator import attrgetter
import pyangbind.lib.xpathhelper as xpathhelper
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType
from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType
from pyangbind.lib.base import PybindBase
from decimal import Decimal
from bitarray import bitarray
import __builtin__
import graceful_restart
import retain
import neighbor
class evpn(PybindBase):
"""
This class was auto-generated by the PythonClass plugin for PYANG
from YANG module brocade-common-def - based on the path /routing-system/router/router-bgp/address-family/l2vpn/evpn. Each member element of
the container is represented as a class variable - with a specific
YANG type.
"""
__slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_rest_name', '_extmethods', '__client_to_client_reflection','__graceful_restart','__retain','__vtep_discovery','__neighbor',)
_yang_name = 'evpn'
_rest_name = 'evpn'
_pybind_generated_by = 'container'
def __init__(self, *args, **kwargs):
path_helper_ = kwargs.pop("path_helper", None)
if path_helper_ is False:
self._path_helper = False
elif path_helper_ is not None and isinstance(path_helper_, xpathhelper.YANGPathHelper):
self._path_helper = path_helper_
elif hasattr(self, "_parent"):
path_helper_ = getattr(self._parent, "_path_helper", False)
self._path_helper = path_helper_
else:
self._path_helper = False
extmethods = kwargs.pop("extmethods", None)
if extmethods is False:
self._extmethods = False
elif extmethods is not None and isinstance(extmethods, dict):
self._extmethods = extmethods
elif hasattr(self, "_parent"):
extmethods = getattr(self._parent, "_extmethods", None)
self._extmethods = extmethods
else:
self._extmethods = False
self.__vtep_discovery = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="vtep-discovery", rest_name="vtep-discovery", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no vtep-discovery\n)', u'info': u'Enable VTEP discovery'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
self.__retain = YANGDynClass(base=retain.retain, is_container='container', presence=False, yang_name="retain", rest_name="retain", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Retain route targets'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
self.__client_to_client_reflection = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="client-to-client-reflection", rest_name="client-to-client-reflection", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no client-to-client-reflection\n)', u'info': u'Configure client to client route reflection'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
self.__graceful_restart = YANGDynClass(base=graceful_restart.graceful_restart, is_container='container', presence=False, yang_name="graceful-restart", rest_name="graceful-restart", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Enables the BGP graceful restart capability', u'cli-incomplete-no': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
self.__neighbor = YANGDynClass(base=neighbor.neighbor, is_container='container', presence=False, yang_name="neighbor", rest_name="neighbor", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Specify a neighbor router', u'cli-incomplete-no': None, u'cli-incomplete-command': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
load = kwargs.pop("load", None)
if args:
if len(args) > 1:
raise TypeError("cannot create a YANG container with >1 argument")
all_attr = True
for e in self._pyangbind_elements:
if not hasattr(args[0], e):
all_attr = False
break
if not all_attr:
raise ValueError("Supplied object did not have the correct attributes")
for e in self._pyangbind_elements:
nobj = getattr(args[0], e)
if nobj._changed() is False:
continue
setmethod = getattr(self, "_set_%s" % e)
if load is None:
setmethod(getattr(args[0], e))
else:
setmethod(getattr(args[0], e), load=load)
def _path(self):
if hasattr(self, "_parent"):
return self._parent._path()+[self._yang_name]
else:
return [u'routing-system', u'router', u'router-bgp', u'address-family', u'l2vpn', u'evpn']
def _rest_path(self):
if hasattr(self, "_parent"):
if self._rest_name:
return self._parent._rest_path()+[self._rest_name]
else:
return self._parent._rest_path()
else:
return [u'router', u'bgp', u'address-family', u'l2vpn', u'evpn']
def _get_client_to_client_reflection(self):
"""
Getter method for client_to_client_reflection, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/client_to_client_reflection (empty)
"""
return self.__client_to_client_reflection
def _set_client_to_client_reflection(self, v, load=False):
"""
Setter method for client_to_client_reflection, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/client_to_client_reflection (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_client_to_client_reflection is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_client_to_client_reflection() directly.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGBool, is_leaf=True, yang_name="client-to-client-reflection", rest_name="client-to-client-reflection", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no client-to-client-reflection\n)', u'info': u'Configure client to client route reflection'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """client_to_client_reflection must be of a type compatible with empty""",
'defined-type': "empty",
'generated-type': """YANGDynClass(base=YANGBool, is_leaf=True, yang_name="client-to-client-reflection", rest_name="client-to-client-reflection", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no client-to-client-reflection\n)', u'info': u'Configure client to client route reflection'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)""",
})
self.__client_to_client_reflection = t
if hasattr(self, '_set'):
self._set()
def _unset_client_to_client_reflection(self):
self.__client_to_client_reflection = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="client-to-client-reflection", rest_name="client-to-client-reflection", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no client-to-client-reflection\n)', u'info': u'Configure client to client route reflection'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
def _get_graceful_restart(self):
"""
Getter method for graceful_restart, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/graceful_restart (container)
"""
return self.__graceful_restart
def _set_graceful_restart(self, v, load=False):
"""
Setter method for graceful_restart, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/graceful_restart (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_graceful_restart is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_graceful_restart() directly.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=graceful_restart.graceful_restart, is_container='container', presence=False, yang_name="graceful-restart", rest_name="graceful-restart", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Enables the BGP graceful restart capability', u'cli-incomplete-no': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """graceful_restart must be of a type compatible with container""",
'defined-type': "container",
'generated-type': """YANGDynClass(base=graceful_restart.graceful_restart, is_container='container', presence=False, yang_name="graceful-restart", rest_name="graceful-restart", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Enables the BGP graceful restart capability', u'cli-incomplete-no': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)""",
})
self.__graceful_restart = t
if hasattr(self, '_set'):
self._set()
def _unset_graceful_restart(self):
self.__graceful_restart = YANGDynClass(base=graceful_restart.graceful_restart, is_container='container', presence=False, yang_name="graceful-restart", rest_name="graceful-restart", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Enables the BGP graceful restart capability', u'cli-incomplete-no': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
def _get_retain(self):
"""
Getter method for retain, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/retain (container)
"""
return self.__retain
def _set_retain(self, v, load=False):
"""
Setter method for retain, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/retain (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_retain is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_retain() directly.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=retain.retain, is_container='container', presence=False, yang_name="retain", rest_name="retain", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Retain route targets'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """retain must be of a type compatible with container""",
'defined-type': "container",
'generated-type': """YANGDynClass(base=retain.retain, is_container='container', presence=False, yang_name="retain", rest_name="retain", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Retain route targets'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)""",
})
self.__retain = t
if hasattr(self, '_set'):
self._set()
def _unset_retain(self):
self.__retain = YANGDynClass(base=retain.retain, is_container='container', presence=False, yang_name="retain", rest_name="retain", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Retain route targets'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
def _get_vtep_discovery(self):
"""
Getter method for vtep_discovery, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/vtep_discovery (empty)
"""
return self.__vtep_discovery
def _set_vtep_discovery(self, v, load=False):
"""
Setter method for vtep_discovery, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/vtep_discovery (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_vtep_discovery is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_vtep_discovery() directly.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGBool, is_leaf=True, yang_name="vtep-discovery", rest_name="vtep-discovery", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no vtep-discovery\n)', u'info': u'Enable VTEP discovery'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """vtep_discovery must be of a type compatible with empty""",
'defined-type': "empty",
'generated-type': """YANGDynClass(base=YANGBool, is_leaf=True, yang_name="vtep-discovery", rest_name="vtep-discovery", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no vtep-discovery\n)', u'info': u'Enable VTEP discovery'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)""",
})
self.__vtep_discovery = t
if hasattr(self, '_set'):
self._set()
def _unset_vtep_discovery(self):
self.__vtep_discovery = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="vtep-discovery", rest_name="vtep-discovery", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'cli-full-command': None, u'cli-run-template': u'$(.?:no vtep-discovery\n)', u'info': u'Enable VTEP discovery'}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='empty', is_config=True)
def _get_neighbor(self):
"""
Getter method for neighbor, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/neighbor (container)
"""
return self.__neighbor
def _set_neighbor(self, v, load=False):
"""
Setter method for neighbor, mapped from YANG variable /routing_system/router/router_bgp/address_family/l2vpn/evpn/neighbor (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_neighbor is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_neighbor() directly.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=neighbor.neighbor, is_container='container', presence=False, yang_name="neighbor", rest_name="neighbor", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Specify a neighbor router', u'cli-incomplete-no': None, u'cli-incomplete-command': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """neighbor must be of a type compatible with container""",
'defined-type': "container",
'generated-type': """YANGDynClass(base=neighbor.neighbor, is_container='container', presence=False, yang_name="neighbor", rest_name="neighbor", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Specify a neighbor router', u'cli-incomplete-no': None, u'cli-incomplete-command': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)""",
})
self.__neighbor = t
if hasattr(self, '_set'):
self._set()
def _unset_neighbor(self):
self.__neighbor = YANGDynClass(base=neighbor.neighbor, is_container='container', presence=False, yang_name="neighbor", rest_name="neighbor", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Specify a neighbor router', u'cli-incomplete-no': None, u'cli-incomplete-command': None}}, namespace='urn:brocade.com:mgmt:brocade-bgp', defining_module='brocade-bgp', yang_type='container', is_config=True)
client_to_client_reflection = __builtin__.property(_get_client_to_client_reflection, _set_client_to_client_reflection)
graceful_restart = __builtin__.property(_get_graceful_restart, _set_graceful_restart)
retain = __builtin__.property(_get_retain, _set_retain)
vtep_discovery = __builtin__.property(_get_vtep_discovery, _set_vtep_discovery)
neighbor = __builtin__.property(_get_neighbor, _set_neighbor)
_pyangbind_elements = {'client_to_client_reflection': client_to_client_reflection, 'graceful_restart': graceful_restart, 'retain': retain, 'vtep_discovery': vtep_discovery, 'neighbor': neighbor, }
| 70.864662
| 550
| 0.740637
| 2,560
| 18,850
| 5.214063
| 0.073438
| 0.040456
| 0.046149
| 0.057537
| 0.823794
| 0.79053
| 0.77255
| 0.765058
| 0.76326
| 0.742883
| 0
| 0.001156
| 0.128064
| 18,850
| 265
| 551
| 71.132075
| 0.810964
| 0.155862
| 0
| 0.438596
| 0
| 0.02924
| 0.37405
| 0.151778
| 0
| 0
| 0
| 0
| 0
| 1
| 0.105263
| false
| 0
| 0.064327
| 0
| 0.292398
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
736e22885b2f2464b5219707b571f51a8a419433
| 38
|
py
|
Python
|
crslab/data/dataset/inspired/__init__.py
|
hcmus-nlp-chatbot/CRSLab
|
b3ab262a4ad93cbae98fe66541eb735377768a35
|
[
"MIT"
] | 315
|
2021-01-05T06:31:57.000Z
|
2022-03-16T21:12:23.000Z
|
crslab/data/dataset/inspired/__init__.py
|
hcmus-nlp-chatbot/CRSLab
|
b3ab262a4ad93cbae98fe66541eb735377768a35
|
[
"MIT"
] | 23
|
2021-01-09T05:43:26.000Z
|
2022-03-28T21:05:49.000Z
|
crslab/data/dataset/inspired/__init__.py
|
hcmus-nlp-chatbot/CRSLab
|
b3ab262a4ad93cbae98fe66541eb735377768a35
|
[
"MIT"
] | 71
|
2021-01-05T06:31:59.000Z
|
2022-03-06T06:30:35.000Z
|
from .inspired import InspiredDataset
| 19
| 37
| 0.868421
| 4
| 38
| 8.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.105263
| 38
| 1
| 38
| 38
| 0.970588
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
73c441062c71a6d6ae106cbf7cf82d4c34c942dd
| 38
|
py
|
Python
|
untitled.py
|
senpaiashley/example
|
4ccbe47b19875b9257e511ac867abd6d252771c2
|
[
"MIT"
] | null | null | null |
untitled.py
|
senpaiashley/example
|
4ccbe47b19875b9257e511ac867abd6d252771c2
|
[
"MIT"
] | 1
|
2018-04-21T16:05:47.000Z
|
2018-04-21T16:07:01.000Z
|
untitled.py
|
senpaiashley/example
|
4ccbe47b19875b9257e511ac867abd6d252771c2
|
[
"MIT"
] | null | null | null |
print("Welcome to MontyHacks, Bitch")
| 19
| 37
| 0.763158
| 5
| 38
| 5.8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.105263
| 38
| 1
| 38
| 38
| 0.852941
| 0
| 0
| 0
| 0
| 0
| 0.736842
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 6
|
73d4ad1d3699aa8507aafec0e16461db78c0fd30
| 1,973
|
py
|
Python
|
gestao/relatorio/views/pdf.py
|
Smartboxweb98/gestao_empresarial
|
ff41ccfc3c8bd2fc4b87dea5b2a48fa82f8e7195
|
[
"CC0-1.0"
] | 3
|
2015-05-19T17:20:52.000Z
|
2017-10-28T02:48:29.000Z
|
gestao/relatorio/views/pdf.py
|
Smartboxweb98/gestao_empresarial
|
ff41ccfc3c8bd2fc4b87dea5b2a48fa82f8e7195
|
[
"CC0-1.0"
] | null | null | null |
gestao/relatorio/views/pdf.py
|
Smartboxweb98/gestao_empresarial
|
ff41ccfc3c8bd2fc4b87dea5b2a48fa82f8e7195
|
[
"CC0-1.0"
] | 3
|
2015-06-20T05:05:22.000Z
|
2018-09-20T12:02:32.000Z
|
# -*- coding: utf-8 -*-
import cgi
import datetime
from django import http
from django.http import HttpResponse
from django.template import Context, loader
from xhtml2pdf import pisa
import cStringIO as StringIO
from gestao.settings import PROJECT_ROOT_PATH
def render_to_pdf(template_src, context_dict):
data_atual = datetime.datetime.now()
context_dict['data_atual'] = data_atual
context_dict['project_root'] = PROJECT_ROOT_PATH
template = loader.get_template(template_src)
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()
css = open(PROJECT_ROOT_PATH + '/static/admin/css/pisa.css').read()
pdf = pisa.CreatePDF(StringIO.StringIO(html.encode("utf-8")), result, default_css=css)
if not pdf.err:
response = HttpResponse(result.getvalue(), mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=relatorio_' + str(data_atual) + ".pdf"
return response
return http.HttpResponse('We had some errors<pre>%s</pre>' % cgi.escape(html))
def render_to_pdf_landscape(template_src, context_dict):
data_atual = datetime.datetime.now()
context_dict['data_atual'] = data_atual
context_dict['project_root'] = PROJECT_ROOT_PATH
template = loader.get_template(template_src)
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()
css_retrato = open(PROJECT_ROOT_PATH + '/static/admin/css/pisa_landscape.css').read()
pdf = pisa.CreatePDF(StringIO.StringIO(html.encode("utf-8")), result, default_css=css_retrato)
if not pdf.err:
response = HttpResponse(result.getvalue(), mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=relatorio_' + str(data_atual) + ".pdf"
return response
return http.HttpResponse('We had some errors<pre>%s</pre>' % cgi.escape(html))
| 37.942308
| 102
| 0.709072
| 247
| 1,973
| 5.477733
| 0.267206
| 0.065041
| 0.055432
| 0.059128
| 0.801183
| 0.801183
| 0.801183
| 0.801183
| 0.746489
| 0.746489
| 0
| 0.002454
| 0.173847
| 1,973
| 51
| 103
| 38.686275
| 0.827607
| 0.010644
| 0
| 0.631579
| 0
| 0
| 0.162051
| 0.031795
| 0
| 0
| 0
| 0
| 0
| 1
| 0.052632
| false
| 0
| 0.210526
| 0
| 0.368421
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
fb537caf26b88b355a047e08b95c0bd0eaed11d5
| 80
|
py
|
Python
|
nostalgify/views.py
|
henryfl/nostalgify
|
b6956d03f29d15f5ceae38f1f07d2b4dc2f4cc0f
|
[
"MIT"
] | null | null | null |
nostalgify/views.py
|
henryfl/nostalgify
|
b6956d03f29d15f5ceae38f1f07d2b4dc2f4cc0f
|
[
"MIT"
] | null | null | null |
nostalgify/views.py
|
henryfl/nostalgify
|
b6956d03f29d15f5ceae38f1f07d2b4dc2f4cc0f
|
[
"MIT"
] | null | null | null |
from nostalgify import app
@app.route('/')
def index():
return "main view"
| 13.333333
| 26
| 0.6625
| 11
| 80
| 4.818182
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1875
| 80
| 5
| 27
| 16
| 0.815385
| 0
| 0
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| true
| 0
| 0.25
| 0.25
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
fbadad8236111c8782baa19900d62718ef1cad6b
| 8,640
|
py
|
Python
|
testrecorder/app_websocket/consumers.py
|
LL08-MathematicalModelling-dowell/100060-dowelltestingscenerios
|
186037084d3184a583f0ff85ae6e71f54f974fcc
|
[
"Apache-2.0"
] | null | null | null |
testrecorder/app_websocket/consumers.py
|
LL08-MathematicalModelling-dowell/100060-dowelltestingscenerios
|
186037084d3184a583f0ff85ae6e71f54f974fcc
|
[
"Apache-2.0"
] | null | null | null |
testrecorder/app_websocket/consumers.py
|
LL08-MathematicalModelling-dowell/100060-dowelltestingscenerios
|
186037084d3184a583f0ff85ae6e71f54f974fcc
|
[
"Apache-2.0"
] | null | null | null |
import asyncio
import json
from blinker import receiver_connected
from channels.consumer import AsyncConsumer
from random import randint
from time import sleep
import subprocess
from django.conf import settings
class VideoConsumer(AsyncConsumer):
async def websocket_connect(self, event):
# when websocket connects
print("connected", event)
print("self", self)
await self.send({"type": "websocket.accept",
})
async def websocket_receive(self, event):
# when messages is received from websocket
#print("receive", event)
#print("receive", event['text'])
#print(event.keys())
# check for text key
if 'text' in event.keys():
data = event['text']
print("data: ",data)
# Check there is no audio from browser
if 'browser_sound' in data:
new_data = data.split(",")
print("new_data: ",new_data)
self.rtmpUrl = new_data[1]
print("Received RTMP url: ",self.rtmpUrl)
# rtmp part
#rtmpUrl = 'rtmp://a.rtmp.youtube.com/live2/ep16-03gf-5t9d-f29s-767h'
#rtmpUrl = 'rtmp://a.rtmp.youtube.com/live2/gumk-x365-hq2z-mwxp-8dj2'
fps = 15
command = ['ffmpeg',
# Facebook requires an audio track, so we create a silent one here.
# Remove this line, as well as `-shortest`, if you send audio from the browser.
#'-f', 'lavfi', '-i', 'anullsrc',
# FFmpeg will read input video from STDIN
'-i', '-',
# Because we're using a generated audio source which never ends,
# specify that we'll stop at end of other input. Remove this line if you
# send audio from the browser.
#'-shortest',
# If we're encoding H.264 in-browser, we can set the video codec to 'copy'
# so that we don't waste any CPU and quality with unnecessary transcoding.
# If the browser doesn't support H.264, set the video codec to 'libx264'
# or similar to transcode it to H.264 here on the server.
'-vcodec', 'copy',
# AAC audio is required for Facebook Live. No browser currently supports
# encoding AAC, so we must transcode the audio to AAC here on the server.
'-acodec', 'aac',
# FLV is the container format used in conjunction with RTMP
'-f', 'flv',
# The output RTMP URL.
# For debugging, you could set this to a filename like 'test.flv', and play
# the resulting file with VLC.
self.rtmpUrl
]
self.process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
#Send an acknowledgement for rtmp url received
msg = "RTMP url received: "+self.rtmpUrl
await self.send({"type": "websocket.send","text": msg})
elif 'rtmp://a.rtmp.youtube.com' in data or 'rtmps://a.rtmps.youtube.com' in data:
# Case where no browser audio is enabled
self.rtmpUrl = data
print("Received RTMP url: ",self.rtmpUrl)
# rtmp part
#rtmpUrl = 'rtmp://a.rtmp.youtube.com/live2/ep16-03gf-5t9d-f29s-767h'
#rtmpUrl = 'rtmp://a.rtmp.youtube.com/live2/gumk-x365-hq2z-mwxp-8dj2'
fps = 15
command = ['ffmpeg',
# Facebook requires an audio track, so we create a silent one here.
# Remove this line, as well as `-shortest`, if you send audio from the browser.
'-f', 'lavfi', '-i', 'anullsrc',
# FFmpeg will read input video from STDIN
'-i', '-',
# Because we're using a generated audio source which never ends,
# specify that we'll stop at end of other input. Remove this line if you
# send audio from the browser.
'-shortest',
# If we're encoding H.264 in-browser, we can set the video codec to 'copy'
# so that we don't waste any CPU and quality with unnecessary transcoding.
# If the browser doesn't support H.264, set the video codec to 'libx264'
# or similar to transcode it to H.264 here on the server.
'-vcodec', 'copy',
# AAC audio is required for Facebook Live. No browser currently supports
# encoding AAC, so we must transcode the audio to AAC here on the server.
'-acodec', 'aac',
# FLV is the container format used in conjunction with RTMP
'-f', 'flv',
# The output RTMP URL.
# For debugging, you could set this to a filename like 'test.flv', and play
# the resulting file with VLC.
self.rtmpUrl
]
self.process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
#Send an acknowledgement for rtmp url received
msg = "RTMP url received: "+self.rtmpUrl
await self.send({"type": "websocket.send","text": msg})
if 'bytes' in event.keys():
self.process.stdin.write(event['bytes'])
#Send an acknowledgement for bytes received
msg = "Bytes received"
await self.send({"type": "websocket.send","text": msg})
async def websocket_disconnect(self, event):
# when websocket disconnects
print("disconnected", event)
self.process.stdin.close()
class WebacamScreenVideoConsumer(AsyncConsumer):
"""
Handles the storage of webcam and screen videos
into a file.
"""
async def websocket_connect(self, event):
# when websocket connects
#print("connected", event)
#print("self", self)
await self.send({"type": "websocket.accept",
})
async def websocket_receive(self, event):
# when messages is received from websocket
#print("receive", event)
#print("receive", event['text'])
#print(event.keys())
# check for text key
if 'text' in event.keys():
data = event['text']
print("data: ",data)
# Check there is no audio from browser
if 'FILENAME,' in data:
new_data = data.split(",")
#print("new_data: ",new_data)
self.recording_file = new_data[1]
#print("Received Recording File Name: ",self.recording_file)
#Send an acknowledgement for rtmp url received
msg = "Received Recording File Name: "+self.recording_file
await self.send({"type": "websocket.send","text": msg})
elif 'rtmp://a.rtmp.youtube.com' in data or 'rtmps://a.rtmps.youtube.com' in data:
# Case where no browser audio is enabled
self.rtmpUrl = data
print("Received RTMP url: ",self.rtmpUrl)
#Send an acknowledgement for rtmp url received
msg = "RTMP url received: "+self.rtmpUrl
await self.send({"type": "websocket.send","text": msg})
if 'bytes' in event.keys():
# ToDo write data to file
#self.process.stdin.write(event['bytes'])
filedata = event['bytes']
file_name = self.recording_file
#recording_file_path = settings.MEDIA_ROOT+"/"+file_name
recording_file_path = settings.TEMP_FILES_ROOT+"/"+file_name
#print("recording_file_path: ",recording_file_path)
with open(recording_file_path, 'ab+') as destination:
#for chunk in filedata.chunks():
destination.write(filedata)
#Send an acknowledgement for bytes received
msg = "Bytes received"
#print("screen websocket Bytes received")
await self.send({"type": "websocket.send","text": msg})
async def websocket_disconnect(self, event):
# when websocket disconnects
print("disconnected", event)
| 41.73913
| 103
| 0.543866
| 984
| 8,640
| 4.738821
| 0.20935
| 0.018014
| 0.022303
| 0.029166
| 0.862964
| 0.853099
| 0.839803
| 0.821789
| 0.812781
| 0.792837
| 0
| 0.012334
| 0.361921
| 8,640
| 206
| 104
| 41.941748
| 0.833484
| 0.398843
| 0
| 0.658824
| 0
| 0
| 0.130964
| 0.02042
| 0
| 0
| 0
| 0.004854
| 0
| 1
| 0
| false
| 0
| 0.094118
| 0
| 0.117647
| 0.117647
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
fbb1cd700c5149d513928376bf59d3fbe3442961
| 40
|
py
|
Python
|
src/streamusb/__init__.py
|
latonaio/stream-usb-video-by-rtsp-multiple-camera
|
84519009899e22d7fc79b70e696136da10274b0d
|
[
"MIT"
] | 10
|
2021-09-22T07:15:59.000Z
|
2021-11-05T01:25:20.000Z
|
src/streamusb/__init__.py
|
latonaio/stream-usb-video-by-rtsp-multiple-camera
|
84519009899e22d7fc79b70e696136da10274b0d
|
[
"MIT"
] | null | null | null |
src/streamusb/__init__.py
|
latonaio/stream-usb-video-by-rtsp-multiple-camera
|
84519009899e22d7fc79b70e696136da10274b0d
|
[
"MIT"
] | null | null | null |
# coding: utf-8
from .core import main
| 10
| 22
| 0.7
| 7
| 40
| 4
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.03125
| 0.2
| 40
| 3
| 23
| 13.333333
| 0.84375
| 0.325
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
fbc0980de06ca63e3262d7096307ef51520c551c
| 105
|
py
|
Python
|
terrascript/bitbucket/__init__.py
|
hugovk/python-terrascript
|
08fe185904a70246822f5cfbdc9e64e9769ec494
|
[
"BSD-2-Clause"
] | 507
|
2017-07-26T02:58:38.000Z
|
2022-01-21T12:35:13.000Z
|
terrascript/bitbucket/__init__.py
|
hugovk/python-terrascript
|
08fe185904a70246822f5cfbdc9e64e9769ec494
|
[
"BSD-2-Clause"
] | 135
|
2017-07-20T12:01:59.000Z
|
2021-10-04T22:25:40.000Z
|
terrascript/bitbucket/__init__.py
|
hugovk/python-terrascript
|
08fe185904a70246822f5cfbdc9e64e9769ec494
|
[
"BSD-2-Clause"
] | 81
|
2018-02-20T17:55:28.000Z
|
2022-01-31T07:08:40.000Z
|
# terrascript/bitbucket/__init__.py
import terrascript
class bitbucket(terrascript.Provider):
pass
| 15
| 38
| 0.8
| 11
| 105
| 7.272727
| 0.727273
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12381
| 105
| 6
| 39
| 17.5
| 0.869565
| 0.314286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.333333
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
|
0
| 6
|
fbde094b07d341fdd35e589eb187d86cc10cc839
| 647
|
py
|
Python
|
nssrc/com/citrix/netscaler/nitro/resource/config/cluster/__init__.py
|
benfinke/ns_python
|
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
|
[
"Apache-2.0"
] | 2
|
2020-08-24T18:04:22.000Z
|
2020-08-24T18:04:47.000Z
|
nssrc/com/citrix/netscaler/nitro/resource/config/cluster/__init__.py
|
benfinke/ns_python
|
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
|
[
"Apache-2.0"
] | 1
|
2017-01-20T22:56:58.000Z
|
2017-01-20T22:56:58.000Z
|
nssrc/com/citrix/netscaler/nitro/resource/config/cluster/__init__.py
|
benfinke/ns_python
|
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
|
[
"Apache-2.0"
] | 6
|
2015-04-21T13:14:08.000Z
|
2020-12-03T07:27:52.000Z
|
__all__ = ['cluster', 'clusterfiles', 'clusterinstance', 'clusterinstance_binding', 'clusterinstance_clusternode_binding', 'clusternode', 'clusternodegroup', 'clusternodegroup_authenticationvserver_binding', 'clusternodegroup_binding', 'clusternodegroup_clusternode_binding', 'clusternodegroup_crvserver_binding', 'clusternodegroup_csvserver_binding', 'clusternodegroup_gslbsite_binding', 'clusternodegroup_gslbvserver_binding', 'clusternodegroup_lbvserver_binding', 'clusternodegroup_nslimitidentifier_binding', 'clusternodegroup_service_binding', 'clusternodegroup_streamidentifier_binding', 'clusternodegroup_vpnvserver_binding', 'clustersync']
| 647
| 647
| 0.871716
| 47
| 647
| 11.361702
| 0.382979
| 0.473783
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.032458
| 647
| 1
| 647
| 647
| 0.853035
| 0
| 0
| 0
| 0
| 0
| 0.859568
| 0.748457
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
83b9f851455c0e2edd90aec3247eca76fe8c757f
| 102
|
py
|
Python
|
test/test_color.py
|
SirWindfield/better-exceptions
|
a2b920c2d48592150329b816274208cb6c8ff2c0
|
[
"MIT"
] | 4,410
|
2017-03-12T11:27:56.000Z
|
2022-03-31T17:39:51.000Z
|
test/test_color.py
|
pralhad88/ng_exception
|
5d362bccf94b75d748a156e60e0ededb9dd29cbd
|
[
"MIT"
] | 104
|
2017-03-22T09:29:12.000Z
|
2022-03-22T01:51:27.000Z
|
test/test_color.py
|
pralhad88/ng_exception
|
5d362bccf94b75d748a156e60e0ededb9dd29cbd
|
[
"MIT"
] | 243
|
2017-03-22T09:10:42.000Z
|
2022-01-11T18:42:46.000Z
|
from __future__ import print_function
from better_exceptions import color
print(color.SUPPORTS_COLOR)
| 25.5
| 37
| 0.882353
| 14
| 102
| 5.928571
| 0.642857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.088235
| 102
| 3
| 38
| 34
| 0.892473
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0.666667
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
|
0
| 6
|
83fb651e4d6ca919e3cee2cf2fe334fca0e20ca3
| 24
|
py
|
Python
|
Algo/Proposed/Proposed.py
|
vigzmv/AB-Split-Tester
|
36a1c4c7b99f933b3f0f4be1219d0292f4ff6955
|
[
"MIT"
] | null | null | null |
Algo/Proposed/Proposed.py
|
vigzmv/AB-Split-Tester
|
36a1c4c7b99f933b3f0f4be1219d0292f4ff6955
|
[
"MIT"
] | null | null | null |
Algo/Proposed/Proposed.py
|
vigzmv/AB-Split-Tester
|
36a1c4c7b99f933b3f0f4be1219d0292f4ff6955
|
[
"MIT"
] | null | null | null |
print "Work In Progress"
| 24
| 24
| 0.791667
| 4
| 24
| 4.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| 24
| 1
| 24
| 24
| 0.904762
| 0
| 0
| 0
| 0
| 0
| 0.64
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 1
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 6
|
f7c460f5cd3b38ee6eed70d9c422e0a69d51587b
| 199
|
py
|
Python
|
entomb/exceptions.py
|
countermeasure/entomb
|
4eba79a66ca8d01ccd634f9d74928cb061b5efdb
|
[
"MIT"
] | null | null | null |
entomb/exceptions.py
|
countermeasure/entomb
|
4eba79a66ca8d01ccd634f9d74928cb061b5efdb
|
[
"MIT"
] | null | null | null |
entomb/exceptions.py
|
countermeasure/entomb
|
4eba79a66ca8d01ccd634f9d74928cb061b5efdb
|
[
"MIT"
] | null | null | null |
class GetAttributeError(Exception):
"""Raise when the immutable attribute cannot be accessed."""
class SetAttributeError(Exception):
"""Raise when the immutable attribute cannot be set."""
| 28.428571
| 64
| 0.748744
| 22
| 199
| 6.772727
| 0.590909
| 0.187919
| 0.241611
| 0.281879
| 0.630872
| 0.630872
| 0.630872
| 0.630872
| 0
| 0
| 0
| 0
| 0.150754
| 199
| 6
| 65
| 33.166667
| 0.881657
| 0.522613
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 6
|
7929487351a7c70ba36fde389614b9bd9427c440
| 195,326
|
py
|
Python
|
google/cloud/compute_v1/services/instances/transports/rest.py
|
georgiyekkert/python-compute
|
d128efbb3bf10af9b41e55b20aaa8080b3221e77
|
[
"Apache-2.0"
] | null | null | null |
google/cloud/compute_v1/services/instances/transports/rest.py
|
georgiyekkert/python-compute
|
d128efbb3bf10af9b41e55b20aaa8080b3221e77
|
[
"Apache-2.0"
] | null | null | null |
google/cloud/compute_v1/services/instances/transports/rest.py
|
georgiyekkert/python-compute
|
d128efbb3bf10af9b41e55b20aaa8080b3221e77
|
[
"Apache-2.0"
] | null | null | null |
from google.auth.transport.requests import AuthorizedSession # type: ignore
import json # type: ignore
import grpc # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.api_core import exceptions as core_exceptions
from google.api_core import retry as retries
from google.api_core import rest_helpers
from google.api_core import path_template
from google.api_core import gapic_v1
from requests import __version__ as requests_version
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import warnings
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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 google.cloud.compute_v1.types import compute
from .base import InstancesTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
)
class InstancesRestTransport(InstancesTransport):
"""REST backend transport for Instances.
The Instances API.
This class defines the same methods as the primary client, so the
primary client can load the underlying transport implementation
and call it.
It sends JSON representations of protocol buffers over HTTP/1.1
"""
def __init__(
self,
*,
host: str = "compute.googleapis.com",
credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
url_scheme: str = "https",
) -> None:
"""Instantiate the transport.
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
url_scheme: the protocol scheme for the API endpoint. Normally
"https", but for testing or local servers,
"http" can be specified.
"""
# Run the base constructor
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
# credentials object
super().__init__(
host=host,
credentials=credentials,
client_info=client_info,
always_use_jwt_access=always_use_jwt_access,
)
self._session = AuthorizedSession(
self._credentials, default_host=self.DEFAULT_HOST
)
if client_cert_source_for_mtls:
self._session.configure_mtls_channel(client_cert_source_for_mtls)
self._prep_wrapped_messages(client_info)
def _add_access_config(
self,
request: compute.AddAccessConfigInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the add access config method over HTTP.
Args:
request (~.compute.AddAccessConfigInstanceRequest):
The request object. A request message for
Instances.AddAccessConfig. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/addAccessConfig",
"body": "access_config_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("network_interface", "networkInterface"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.AddAccessConfigInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.AccessConfig.to_json(
compute.AccessConfig(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.AddAccessConfigInstanceRequest.to_json(
compute.AddAccessConfigInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _add_resource_policies(
self,
request: compute.AddResourcePoliciesInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the add resource policies method over HTTP.
Args:
request (~.compute.AddResourcePoliciesInstanceRequest):
The request object. A request message for
Instances.AddResourcePolicies. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/addResourcePolicies",
"body": "instances_add_resource_policies_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.AddResourcePoliciesInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesAddResourcePoliciesRequest.to_json(
compute.InstancesAddResourcePoliciesRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.AddResourcePoliciesInstanceRequest.to_json(
compute.AddResourcePoliciesInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _aggregated_list(
self,
request: compute.AggregatedListInstancesRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.InstanceAggregatedList:
r"""Call the aggregated list method over HTTP.
Args:
request (~.compute.AggregatedListInstancesRequest):
The request object. A request message for
Instances.AggregatedList. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.InstanceAggregatedList:
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/aggregated/instances",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
]
request_kwargs = compute.AggregatedListInstancesRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.AggregatedListInstancesRequest.to_json(
compute.AggregatedListInstancesRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.InstanceAggregatedList.from_json(
response.content, ignore_unknown_fields=True
)
def _attach_disk(
self,
request: compute.AttachDiskInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the attach disk method over HTTP.
Args:
request (~.compute.AttachDiskInstanceRequest):
The request object. A request message for
Instances.AttachDisk. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/attachDisk",
"body": "attached_disk_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.AttachDiskInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.AttachedDisk.to_json(
compute.AttachedDisk(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.AttachDiskInstanceRequest.to_json(
compute.AttachDiskInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _bulk_insert(
self,
request: compute.BulkInsertInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the bulk insert method over HTTP.
Args:
request (~.compute.BulkInsertInstanceRequest):
The request object. A request message for
Instances.BulkInsert. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/bulkInsert",
"body": "bulk_insert_instance_resource_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.BulkInsertInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.BulkInsertInstanceResource.to_json(
compute.BulkInsertInstanceResource(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.BulkInsertInstanceRequest.to_json(
compute.BulkInsertInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _delete(
self,
request: compute.DeleteInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the delete method over HTTP.
Args:
request (~.compute.DeleteInstanceRequest):
The request object. A request message for
Instances.Delete. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "delete",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.DeleteInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.DeleteInstanceRequest.to_json(
compute.DeleteInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _delete_access_config(
self,
request: compute.DeleteAccessConfigInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the delete access config method over HTTP.
Args:
request (~.compute.DeleteAccessConfigInstanceRequest):
The request object. A request message for
Instances.DeleteAccessConfig. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/deleteAccessConfig",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("access_config", "accessConfig"),
("instance", "instance"),
("network_interface", "networkInterface"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.DeleteAccessConfigInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.DeleteAccessConfigInstanceRequest.to_json(
compute.DeleteAccessConfigInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _detach_disk(
self,
request: compute.DetachDiskInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the detach disk method over HTTP.
Args:
request (~.compute.DetachDiskInstanceRequest):
The request object. A request message for
Instances.DetachDisk. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/detachDisk",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("device_name", "deviceName"),
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.DetachDiskInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.DetachDiskInstanceRequest.to_json(
compute.DetachDiskInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _get(
self,
request: compute.GetInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Instance:
r"""Call the get method over HTTP.
Args:
request (~.compute.GetInstanceRequest):
The request object. A request message for Instances.Get.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Instance:
Represents an Instance resource. An
instance is a virtual machine that is
hosted on Google Cloud Platform. For
more information, read Virtual Machine
Instances.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetInstanceRequest.to_json(
compute.GetInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Instance.from_json(response.content, ignore_unknown_fields=True)
def _get_effective_firewalls(
self,
request: compute.GetEffectiveFirewallsInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.InstancesGetEffectiveFirewallsResponse:
r"""Call the get effective firewalls method over HTTP.
Args:
request (~.compute.GetEffectiveFirewallsInstanceRequest):
The request object. A request message for
Instances.GetEffectiveFirewalls. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.InstancesGetEffectiveFirewallsResponse:
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getEffectiveFirewalls",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("network_interface", "networkInterface"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetEffectiveFirewallsInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetEffectiveFirewallsInstanceRequest.to_json(
compute.GetEffectiveFirewallsInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.InstancesGetEffectiveFirewallsResponse.from_json(
response.content, ignore_unknown_fields=True
)
def _get_guest_attributes(
self,
request: compute.GetGuestAttributesInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.GuestAttributes:
r"""Call the get guest attributes method over HTTP.
Args:
request (~.compute.GetGuestAttributesInstanceRequest):
The request object. A request message for
Instances.GetGuestAttributes. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.GuestAttributes:
A guest attributes entry.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getGuestAttributes",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetGuestAttributesInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetGuestAttributesInstanceRequest.to_json(
compute.GetGuestAttributesInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.GuestAttributes.from_json(
response.content, ignore_unknown_fields=True
)
def _get_iam_policy(
self,
request: compute.GetIamPolicyInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Policy:
r"""Call the get iam policy method over HTTP.
Args:
request (~.compute.GetIamPolicyInstanceRequest):
The request object. A request message for
Instances.GetIamPolicy. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Policy:
An Identity and Access Management (IAM) policy, which
specifies access controls for Google Cloud resources. A
``Policy`` is a collection of ``bindings``. A
``binding`` binds one or more ``members`` to a single
``role``. Members can be user accounts, service
accounts, Google groups, and domains (such as G Suite).
A ``role`` is a named list of permissions; each ``role``
can be an IAM predefined role or a user-created custom
role. For some types of Google Cloud resources, a
``binding`` can also specify a ``condition``, which is a
logical expression that allows access to a resource only
if the expression evaluates to ``true``. A condition can
add constraints based on attributes of the request, the
resource, or both. To learn which resources support
conditions in their IAM policies, see the `IAM
documentation <https://cloud.google.com/iam/help/conditions/resource-policies>`__.
**JSON example:** { "bindings": [ { "role":
"roles/resourcemanager.organizationAdmin", "members": [
"user:mike@example.com", "group:admins@example.com",
"domain:google.com",
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
] }, { "role":
"roles/resourcemanager.organizationViewer", "members": [
"user:eve@example.com" ], "condition": { "title":
"expirable access", "description": "Does not grant
access after Sep 2020", "expression": "request.time <
timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag":
"BwWWja0YfJA=", "version": 3 } **YAML example:**
bindings: - members: - user:mike@example.com -
group:admins@example.com - domain:google.com -
serviceAccount:my-project-id@appspot.gserviceaccount.com
role: roles/resourcemanager.organizationAdmin - members:
- user:eve@example.com role:
roles/resourcemanager.organizationViewer condition:
title: expirable access description: Does not grant
access after Sep 2020 expression: request.time <
timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA=
version: 3 For a description of IAM and its features,
see the `IAM
documentation <https://cloud.google.com/iam/docs/>`__.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/getIamPolicy",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("resource", "resource"),
("zone", "zone"),
]
request_kwargs = compute.GetIamPolicyInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetIamPolicyInstanceRequest.to_json(
compute.GetIamPolicyInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Policy.from_json(response.content, ignore_unknown_fields=True)
def _get_screenshot(
self,
request: compute.GetScreenshotInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Screenshot:
r"""Call the get screenshot method over HTTP.
Args:
request (~.compute.GetScreenshotInstanceRequest):
The request object. A request message for
Instances.GetScreenshot. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Screenshot:
An instance's screenshot.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/screenshot",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetScreenshotInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetScreenshotInstanceRequest.to_json(
compute.GetScreenshotInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Screenshot.from_json(
response.content, ignore_unknown_fields=True
)
def _get_serial_port_output(
self,
request: compute.GetSerialPortOutputInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.SerialPortOutput:
r"""Call the get serial port output method over HTTP.
Args:
request (~.compute.GetSerialPortOutputInstanceRequest):
The request object. A request message for
Instances.GetSerialPortOutput. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.SerialPortOutput:
An instance serial console output.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/serialPort",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetSerialPortOutputInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetSerialPortOutputInstanceRequest.to_json(
compute.GetSerialPortOutputInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.SerialPortOutput.from_json(
response.content, ignore_unknown_fields=True
)
def _get_shielded_instance_identity(
self,
request: compute.GetShieldedInstanceIdentityInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.ShieldedInstanceIdentity:
r"""Call the get shielded instance
identity method over HTTP.
Args:
request (~.compute.GetShieldedInstanceIdentityInstanceRequest):
The request object. A request message for
Instances.GetShieldedInstanceIdentity.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.ShieldedInstanceIdentity:
A Shielded Instance Identity.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/getShieldedInstanceIdentity",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.GetShieldedInstanceIdentityInstanceRequest.to_dict(
request
)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.GetShieldedInstanceIdentityInstanceRequest.to_json(
compute.GetShieldedInstanceIdentityInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.ShieldedInstanceIdentity.from_json(
response.content, ignore_unknown_fields=True
)
def _insert(
self,
request: compute.InsertInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the insert method over HTTP.
Args:
request (~.compute.InsertInstanceRequest):
The request object. A request message for
Instances.Insert. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances",
"body": "instance_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.InsertInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.Instance.to_json(
compute.Instance(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.InsertInstanceRequest.to_json(
compute.InsertInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _list(
self,
request: compute.ListInstancesRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.InstanceList:
r"""Call the list method over HTTP.
Args:
request (~.compute.ListInstancesRequest):
The request object. A request message for Instances.List.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.InstanceList:
Contains a list of instances.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.ListInstancesRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.ListInstancesRequest.to_json(
compute.ListInstancesRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.InstanceList.from_json(
response.content, ignore_unknown_fields=True
)
def _list_referrers(
self,
request: compute.ListReferrersInstancesRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.InstanceListReferrers:
r"""Call the list referrers method over HTTP.
Args:
request (~.compute.ListReferrersInstancesRequest):
The request object. A request message for
Instances.ListReferrers. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.InstanceListReferrers:
Contains a list of instance
referrers.
"""
http_options = [
{
"method": "get",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/referrers",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.ListReferrersInstancesRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.ListReferrersInstancesRequest.to_json(
compute.ListReferrersInstancesRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.InstanceListReferrers.from_json(
response.content, ignore_unknown_fields=True
)
def _remove_resource_policies(
self,
request: compute.RemoveResourcePoliciesInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the remove resource policies method over HTTP.
Args:
request (~.compute.RemoveResourcePoliciesInstanceRequest):
The request object. A request message for
Instances.RemoveResourcePolicies. See
the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/removeResourcePolicies",
"body": "instances_remove_resource_policies_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.RemoveResourcePoliciesInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesRemoveResourcePoliciesRequest.to_json(
compute.InstancesRemoveResourcePoliciesRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.RemoveResourcePoliciesInstanceRequest.to_json(
compute.RemoveResourcePoliciesInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _reset(
self,
request: compute.ResetInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the reset method over HTTP.
Args:
request (~.compute.ResetInstanceRequest):
The request object. A request message for
Instances.Reset. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/reset",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.ResetInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.ResetInstanceRequest.to_json(
compute.ResetInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _send_diagnostic_interrupt(
self,
request: compute.SendDiagnosticInterruptInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.SendDiagnosticInterruptInstanceResponse:
r"""Call the send diagnostic interrupt method over HTTP.
Args:
request (~.compute.SendDiagnosticInterruptInstanceRequest):
The request object. A request message for
Instances.SendDiagnosticInterrupt. See
the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.SendDiagnosticInterruptInstanceResponse:
A response message for
Instances.SendDiagnosticInterrupt. See
the method description for details.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/sendDiagnosticInterrupt",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SendDiagnosticInterruptInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SendDiagnosticInterruptInstanceRequest.to_json(
compute.SendDiagnosticInterruptInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.SendDiagnosticInterruptInstanceResponse.from_json(
response.content, ignore_unknown_fields=True
)
def _set_deletion_protection(
self,
request: compute.SetDeletionProtectionInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set deletion protection method over HTTP.
Args:
request (~.compute.SetDeletionProtectionInstanceRequest):
The request object. A request message for
Instances.SetDeletionProtection. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/setDeletionProtection",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("resource", "resource"),
("zone", "zone"),
]
request_kwargs = compute.SetDeletionProtectionInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetDeletionProtectionInstanceRequest.to_json(
compute.SetDeletionProtectionInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_disk_auto_delete(
self,
request: compute.SetDiskAutoDeleteInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set disk auto delete method over HTTP.
Args:
request (~.compute.SetDiskAutoDeleteInstanceRequest):
The request object. A request message for
Instances.SetDiskAutoDelete. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setDiskAutoDelete",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("auto_delete", "autoDelete"),
("device_name", "deviceName"),
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetDiskAutoDeleteInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetDiskAutoDeleteInstanceRequest.to_json(
compute.SetDiskAutoDeleteInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_iam_policy(
self,
request: compute.SetIamPolicyInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Policy:
r"""Call the set iam policy method over HTTP.
Args:
request (~.compute.SetIamPolicyInstanceRequest):
The request object. A request message for
Instances.SetIamPolicy. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Policy:
An Identity and Access Management (IAM) policy, which
specifies access controls for Google Cloud resources. A
``Policy`` is a collection of ``bindings``. A
``binding`` binds one or more ``members`` to a single
``role``. Members can be user accounts, service
accounts, Google groups, and domains (such as G Suite).
A ``role`` is a named list of permissions; each ``role``
can be an IAM predefined role or a user-created custom
role. For some types of Google Cloud resources, a
``binding`` can also specify a ``condition``, which is a
logical expression that allows access to a resource only
if the expression evaluates to ``true``. A condition can
add constraints based on attributes of the request, the
resource, or both. To learn which resources support
conditions in their IAM policies, see the `IAM
documentation <https://cloud.google.com/iam/help/conditions/resource-policies>`__.
**JSON example:** { "bindings": [ { "role":
"roles/resourcemanager.organizationAdmin", "members": [
"user:mike@example.com", "group:admins@example.com",
"domain:google.com",
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
] }, { "role":
"roles/resourcemanager.organizationViewer", "members": [
"user:eve@example.com" ], "condition": { "title":
"expirable access", "description": "Does not grant
access after Sep 2020", "expression": "request.time <
timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag":
"BwWWja0YfJA=", "version": 3 } **YAML example:**
bindings: - members: - user:mike@example.com -
group:admins@example.com - domain:google.com -
serviceAccount:my-project-id@appspot.gserviceaccount.com
role: roles/resourcemanager.organizationAdmin - members:
- user:eve@example.com role:
roles/resourcemanager.organizationViewer condition:
title: expirable access description: Does not grant
access after Sep 2020 expression: request.time <
timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA=
version: 3 For a description of IAM and its features,
see the `IAM
documentation <https://cloud.google.com/iam/docs/>`__.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/setIamPolicy",
"body": "zone_set_policy_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("resource", "resource"),
("zone", "zone"),
]
request_kwargs = compute.SetIamPolicyInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.ZoneSetPolicyRequest.to_json(
compute.ZoneSetPolicyRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetIamPolicyInstanceRequest.to_json(
compute.SetIamPolicyInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Policy.from_json(response.content, ignore_unknown_fields=True)
def _set_labels(
self,
request: compute.SetLabelsInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set labels method over HTTP.
Args:
request (~.compute.SetLabelsInstanceRequest):
The request object. A request message for
Instances.SetLabels. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setLabels",
"body": "instances_set_labels_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetLabelsInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesSetLabelsRequest.to_json(
compute.InstancesSetLabelsRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetLabelsInstanceRequest.to_json(
compute.SetLabelsInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_machine_resources(
self,
request: compute.SetMachineResourcesInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set machine resources method over HTTP.
Args:
request (~.compute.SetMachineResourcesInstanceRequest):
The request object. A request message for
Instances.SetMachineResources. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMachineResources",
"body": "instances_set_machine_resources_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetMachineResourcesInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesSetMachineResourcesRequest.to_json(
compute.InstancesSetMachineResourcesRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetMachineResourcesInstanceRequest.to_json(
compute.SetMachineResourcesInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_machine_type(
self,
request: compute.SetMachineTypeInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set machine type method over HTTP.
Args:
request (~.compute.SetMachineTypeInstanceRequest):
The request object. A request message for
Instances.SetMachineType. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMachineType",
"body": "instances_set_machine_type_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetMachineTypeInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesSetMachineTypeRequest.to_json(
compute.InstancesSetMachineTypeRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetMachineTypeInstanceRequest.to_json(
compute.SetMachineTypeInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_metadata(
self,
request: compute.SetMetadataInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set metadata method over HTTP.
Args:
request (~.compute.SetMetadataInstanceRequest):
The request object. A request message for
Instances.SetMetadata. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMetadata",
"body": "metadata_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetMetadataInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.Metadata.to_json(
compute.Metadata(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetMetadataInstanceRequest.to_json(
compute.SetMetadataInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_min_cpu_platform(
self,
request: compute.SetMinCpuPlatformInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set min cpu platform method over HTTP.
Args:
request (~.compute.SetMinCpuPlatformInstanceRequest):
The request object. A request message for
Instances.SetMinCpuPlatform. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setMinCpuPlatform",
"body": "instances_set_min_cpu_platform_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetMinCpuPlatformInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesSetMinCpuPlatformRequest.to_json(
compute.InstancesSetMinCpuPlatformRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetMinCpuPlatformInstanceRequest.to_json(
compute.SetMinCpuPlatformInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_scheduling(
self,
request: compute.SetSchedulingInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set scheduling method over HTTP.
Args:
request (~.compute.SetSchedulingInstanceRequest):
The request object. A request message for
Instances.SetScheduling. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setScheduling",
"body": "scheduling_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetSchedulingInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.Scheduling.to_json(
compute.Scheduling(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetSchedulingInstanceRequest.to_json(
compute.SetSchedulingInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_service_account(
self,
request: compute.SetServiceAccountInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set service account method over HTTP.
Args:
request (~.compute.SetServiceAccountInstanceRequest):
The request object. A request message for
Instances.SetServiceAccount. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setServiceAccount",
"body": "instances_set_service_account_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetServiceAccountInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesSetServiceAccountRequest.to_json(
compute.InstancesSetServiceAccountRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetServiceAccountInstanceRequest.to_json(
compute.SetServiceAccountInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_shielded_instance_integrity_policy(
self,
request: compute.SetShieldedInstanceIntegrityPolicyInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set shielded instance
integrity policy method over HTTP.
Args:
request (~.compute.SetShieldedInstanceIntegrityPolicyInstanceRequest):
The request object. A request message for
Instances.SetShieldedInstanceIntegrityPolicy.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "patch",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setShieldedInstanceIntegrityPolicy",
"body": "shielded_instance_integrity_policy_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetShieldedInstanceIntegrityPolicyInstanceRequest.to_dict(
request
)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.ShieldedInstanceIntegrityPolicy.to_json(
compute.ShieldedInstanceIntegrityPolicy(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetShieldedInstanceIntegrityPolicyInstanceRequest.to_json(
compute.SetShieldedInstanceIntegrityPolicyInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _set_tags(
self,
request: compute.SetTagsInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the set tags method over HTTP.
Args:
request (~.compute.SetTagsInstanceRequest):
The request object. A request message for
Instances.SetTags. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/setTags",
"body": "tags_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SetTagsInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.Tags.to_json(
compute.Tags(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SetTagsInstanceRequest.to_json(
compute.SetTagsInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _simulate_maintenance_event(
self,
request: compute.SimulateMaintenanceEventInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the simulate maintenance
event method over HTTP.
Args:
request (~.compute.SimulateMaintenanceEventInstanceRequest):
The request object. A request message for
Instances.SimulateMaintenanceEvent. See
the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/simulateMaintenanceEvent",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.SimulateMaintenanceEventInstanceRequest.to_dict(
request
)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.SimulateMaintenanceEventInstanceRequest.to_json(
compute.SimulateMaintenanceEventInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _start(
self,
request: compute.StartInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the start method over HTTP.
Args:
request (~.compute.StartInstanceRequest):
The request object. A request message for
Instances.Start. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/start",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.StartInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.StartInstanceRequest.to_json(
compute.StartInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _start_with_encryption_key(
self,
request: compute.StartWithEncryptionKeyInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the start with encryption key method over HTTP.
Args:
request (~.compute.StartWithEncryptionKeyInstanceRequest):
The request object. A request message for
Instances.StartWithEncryptionKey. See
the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/startWithEncryptionKey",
"body": "instances_start_with_encryption_key_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.StartWithEncryptionKeyInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.InstancesStartWithEncryptionKeyRequest.to_json(
compute.InstancesStartWithEncryptionKeyRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.StartWithEncryptionKeyInstanceRequest.to_json(
compute.StartWithEncryptionKeyInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _stop(
self,
request: compute.StopInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the stop method over HTTP.
Args:
request (~.compute.StopInstanceRequest):
The request object. A request message for Instances.Stop.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/stop",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.StopInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.StopInstanceRequest.to_json(
compute.StopInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _test_iam_permissions(
self,
request: compute.TestIamPermissionsInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.TestPermissionsResponse:
r"""Call the test iam permissions method over HTTP.
Args:
request (~.compute.TestIamPermissionsInstanceRequest):
The request object. A request message for
Instances.TestIamPermissions. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.TestPermissionsResponse:
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{resource}/testIamPermissions",
"body": "test_permissions_request_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("project", "project"),
("resource", "resource"),
("zone", "zone"),
]
request_kwargs = compute.TestIamPermissionsInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.TestPermissionsRequest.to_json(
compute.TestPermissionsRequest(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.TestIamPermissionsInstanceRequest.to_json(
compute.TestIamPermissionsInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.TestPermissionsResponse.from_json(
response.content, ignore_unknown_fields=True
)
def _update(
self,
request: compute.UpdateInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the update method over HTTP.
Args:
request (~.compute.UpdateInstanceRequest):
The request object. A request message for
Instances.Update. See the method
description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "put",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}",
"body": "instance_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.UpdateInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.Instance.to_json(
compute.Instance(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.UpdateInstanceRequest.to_json(
compute.UpdateInstanceRequest(transcoded_request["query_params"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _update_access_config(
self,
request: compute.UpdateAccessConfigInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the update access config method over HTTP.
Args:
request (~.compute.UpdateAccessConfigInstanceRequest):
The request object. A request message for
Instances.UpdateAccessConfig. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "post",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateAccessConfig",
"body": "access_config_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("network_interface", "networkInterface"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.UpdateAccessConfigInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.AccessConfig.to_json(
compute.AccessConfig(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.UpdateAccessConfigInstanceRequest.to_json(
compute.UpdateAccessConfigInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _update_display_device(
self,
request: compute.UpdateDisplayDeviceInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the update display device method over HTTP.
Args:
request (~.compute.UpdateDisplayDeviceInstanceRequest):
The request object. A request message for
Instances.UpdateDisplayDevice. See the
method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "patch",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateDisplayDevice",
"body": "display_device_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.UpdateDisplayDeviceInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.DisplayDevice.to_json(
compute.DisplayDevice(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.UpdateDisplayDeviceInstanceRequest.to_json(
compute.UpdateDisplayDeviceInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _update_network_interface(
self,
request: compute.UpdateNetworkInterfaceInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the update network interface method over HTTP.
Args:
request (~.compute.UpdateNetworkInterfaceInstanceRequest):
The request object. A request message for
Instances.UpdateNetworkInterface. See
the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "patch",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateNetworkInterface",
"body": "network_interface_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("network_interface", "networkInterface"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.UpdateNetworkInterfaceInstanceRequest.to_dict(request)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.NetworkInterface.to_json(
compute.NetworkInterface(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.UpdateNetworkInterfaceInstanceRequest.to_json(
compute.UpdateNetworkInterfaceInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def _update_shielded_instance_config(
self,
request: compute.UpdateShieldedInstanceConfigInstanceRequest,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Call the update shielded instance
config method over HTTP.
Args:
request (~.compute.UpdateShieldedInstanceConfigInstanceRequest):
The request object. A request message for
Instances.UpdateShieldedInstanceConfig.
See the method description for details.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
~.compute.Operation:
Represents an Operation resource. Google Compute Engine
has three Operation resources: \*
`Global </compute/docs/reference/rest/v1/globalOperations>`__
\*
`Regional </compute/docs/reference/rest/v1/regionOperations>`__
\*
`Zonal </compute/docs/reference/rest/v1/zoneOperations>`__
You can use an operation resource to manage asynchronous
API requests. For more information, read Handling API
responses. Operations can be global, regional or zonal.
- For global operations, use the ``globalOperations``
resource. - For regional operations, use the
``regionOperations`` resource. - For zonal operations,
use the ``zonalOperations`` resource. For more
information, read Global, Regional, and Zonal Resources.
"""
http_options = [
{
"method": "patch",
"uri": "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/updateShieldedInstanceConfig",
"body": "shielded_instance_config_resource",
},
]
required_fields = [
# (snake_case_name, camel_case_name)
("instance", "instance"),
("project", "project"),
("zone", "zone"),
]
request_kwargs = compute.UpdateShieldedInstanceConfigInstanceRequest.to_dict(
request
)
transcoded_request = path_template.transcode(http_options, **request_kwargs)
# Jsonify the request body
body = compute.ShieldedInstanceConfig.to_json(
compute.ShieldedInstanceConfig(transcoded_request["body"]),
including_default_value_fields=False,
use_integers_for_enums=False,
)
uri = transcoded_request["uri"]
method = transcoded_request["method"]
# Jsonify the query params
query_params = json.loads(
compute.UpdateShieldedInstanceConfigInstanceRequest.to_json(
compute.UpdateShieldedInstanceConfigInstanceRequest(
transcoded_request["query_params"]
),
including_default_value_fields=False,
use_integers_for_enums=False,
)
)
# Ensure required fields have values in query_params.
# If a required field has a default value, it can get lost
# by the to_json call above.
orig_query_params = transcoded_request["query_params"]
for snake_case_name, camel_case_name in required_fields:
if snake_case_name in orig_query_params:
if camel_case_name not in query_params:
query_params[camel_case_name] = orig_query_params[snake_case_name]
# Send the request
headers = dict(metadata)
headers["Content-Type"] = "application/json"
response = getattr(self._session, method)(
# Replace with proper schema configuration (http/https) logic
"https://{host}{uri}".format(host=self._host, uri=uri),
timeout=timeout,
headers=headers,
params=rest_helpers.flatten_query_params(query_params),
data=body,
)
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
# subclass.
if response.status_code >= 400:
raise core_exceptions.from_http_response(response)
# Return the response
return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
@property
def add_access_config(
self,
) -> Callable[[compute.AddAccessConfigInstanceRequest], compute.Operation]:
return self._add_access_config
@property
def add_resource_policies(
self,
) -> Callable[[compute.AddResourcePoliciesInstanceRequest], compute.Operation]:
return self._add_resource_policies
@property
def aggregated_list(
self,
) -> Callable[
[compute.AggregatedListInstancesRequest], compute.InstanceAggregatedList
]:
return self._aggregated_list
@property
def attach_disk(
self,
) -> Callable[[compute.AttachDiskInstanceRequest], compute.Operation]:
return self._attach_disk
@property
def bulk_insert(
self,
) -> Callable[[compute.BulkInsertInstanceRequest], compute.Operation]:
return self._bulk_insert
@property
def delete(self) -> Callable[[compute.DeleteInstanceRequest], compute.Operation]:
return self._delete
@property
def delete_access_config(
self,
) -> Callable[[compute.DeleteAccessConfigInstanceRequest], compute.Operation]:
return self._delete_access_config
@property
def detach_disk(
self,
) -> Callable[[compute.DetachDiskInstanceRequest], compute.Operation]:
return self._detach_disk
@property
def get(self) -> Callable[[compute.GetInstanceRequest], compute.Instance]:
return self._get
@property
def get_effective_firewalls(
self,
) -> Callable[
[compute.GetEffectiveFirewallsInstanceRequest],
compute.InstancesGetEffectiveFirewallsResponse,
]:
return self._get_effective_firewalls
@property
def get_guest_attributes(
self,
) -> Callable[[compute.GetGuestAttributesInstanceRequest], compute.GuestAttributes]:
return self._get_guest_attributes
@property
def get_iam_policy(
self,
) -> Callable[[compute.GetIamPolicyInstanceRequest], compute.Policy]:
return self._get_iam_policy
@property
def get_screenshot(
self,
) -> Callable[[compute.GetScreenshotInstanceRequest], compute.Screenshot]:
return self._get_screenshot
@property
def get_serial_port_output(
self,
) -> Callable[
[compute.GetSerialPortOutputInstanceRequest], compute.SerialPortOutput
]:
return self._get_serial_port_output
@property
def get_shielded_instance_identity(
self,
) -> Callable[
[compute.GetShieldedInstanceIdentityInstanceRequest],
compute.ShieldedInstanceIdentity,
]:
return self._get_shielded_instance_identity
@property
def insert(self) -> Callable[[compute.InsertInstanceRequest], compute.Operation]:
return self._insert
@property
def list(self) -> Callable[[compute.ListInstancesRequest], compute.InstanceList]:
return self._list
@property
def list_referrers(
self,
) -> Callable[
[compute.ListReferrersInstancesRequest], compute.InstanceListReferrers
]:
return self._list_referrers
@property
def remove_resource_policies(
self,
) -> Callable[[compute.RemoveResourcePoliciesInstanceRequest], compute.Operation]:
return self._remove_resource_policies
@property
def reset(self) -> Callable[[compute.ResetInstanceRequest], compute.Operation]:
return self._reset
@property
def send_diagnostic_interrupt(
self,
) -> Callable[
[compute.SendDiagnosticInterruptInstanceRequest],
compute.SendDiagnosticInterruptInstanceResponse,
]:
return self._send_diagnostic_interrupt
@property
def set_deletion_protection(
self,
) -> Callable[[compute.SetDeletionProtectionInstanceRequest], compute.Operation]:
return self._set_deletion_protection
@property
def set_disk_auto_delete(
self,
) -> Callable[[compute.SetDiskAutoDeleteInstanceRequest], compute.Operation]:
return self._set_disk_auto_delete
@property
def set_iam_policy(
self,
) -> Callable[[compute.SetIamPolicyInstanceRequest], compute.Policy]:
return self._set_iam_policy
@property
def set_labels(
self,
) -> Callable[[compute.SetLabelsInstanceRequest], compute.Operation]:
return self._set_labels
@property
def set_machine_resources(
self,
) -> Callable[[compute.SetMachineResourcesInstanceRequest], compute.Operation]:
return self._set_machine_resources
@property
def set_machine_type(
self,
) -> Callable[[compute.SetMachineTypeInstanceRequest], compute.Operation]:
return self._set_machine_type
@property
def set_metadata(
self,
) -> Callable[[compute.SetMetadataInstanceRequest], compute.Operation]:
return self._set_metadata
@property
def set_min_cpu_platform(
self,
) -> Callable[[compute.SetMinCpuPlatformInstanceRequest], compute.Operation]:
return self._set_min_cpu_platform
@property
def set_scheduling(
self,
) -> Callable[[compute.SetSchedulingInstanceRequest], compute.Operation]:
return self._set_scheduling
@property
def set_service_account(
self,
) -> Callable[[compute.SetServiceAccountInstanceRequest], compute.Operation]:
return self._set_service_account
@property
def set_shielded_instance_integrity_policy(
self,
) -> Callable[
[compute.SetShieldedInstanceIntegrityPolicyInstanceRequest], compute.Operation
]:
return self._set_shielded_instance_integrity_policy
@property
def set_tags(self) -> Callable[[compute.SetTagsInstanceRequest], compute.Operation]:
return self._set_tags
@property
def simulate_maintenance_event(
self,
) -> Callable[[compute.SimulateMaintenanceEventInstanceRequest], compute.Operation]:
return self._simulate_maintenance_event
@property
def start(self) -> Callable[[compute.StartInstanceRequest], compute.Operation]:
return self._start
@property
def start_with_encryption_key(
self,
) -> Callable[[compute.StartWithEncryptionKeyInstanceRequest], compute.Operation]:
return self._start_with_encryption_key
@property
def stop(self) -> Callable[[compute.StopInstanceRequest], compute.Operation]:
return self._stop
@property
def test_iam_permissions(
self,
) -> Callable[
[compute.TestIamPermissionsInstanceRequest], compute.TestPermissionsResponse
]:
return self._test_iam_permissions
@property
def update(self) -> Callable[[compute.UpdateInstanceRequest], compute.Operation]:
return self._update
@property
def update_access_config(
self,
) -> Callable[[compute.UpdateAccessConfigInstanceRequest], compute.Operation]:
return self._update_access_config
@property
def update_display_device(
self,
) -> Callable[[compute.UpdateDisplayDeviceInstanceRequest], compute.Operation]:
return self._update_display_device
@property
def update_network_interface(
self,
) -> Callable[[compute.UpdateNetworkInterfaceInstanceRequest], compute.Operation]:
return self._update_network_interface
@property
def update_shielded_instance_config(
self,
) -> Callable[
[compute.UpdateShieldedInstanceConfigInstanceRequest], compute.Operation
]:
return self._update_shielded_instance_config
def close(self):
self._session.close()
__all__ = ("InstancesRestTransport",)
| 40.591438
| 125
| 0.609673
| 19,251
| 195,326
| 5.99626
| 0.029661
| 0.049171
| 0.01937
| 0.024585
| 0.840194
| 0.823674
| 0.811659
| 0.807189
| 0.786917
| 0.783911
| 0
| 0.003067
| 0.308991
| 195,326
| 4,811
| 126
| 40.599875
| 0.852177
| 0.37675
| 0
| 0.649074
| 0
| 0
| 0.090511
| 0.036145
| 0
| 0
| 0
| 0.000208
| 0
| 1
| 0.034659
| false
| 0
| 0.005908
| 0.016936
| 0.074833
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
792fe53bd2136fed9107b846b83e9798bfeaea59
| 11,766
|
py
|
Python
|
grapple/helpers.py
|
NathHorrigan/wagtail-grapple
|
73a258e920eb0c5ac45f650311e8a9f6efe21941
|
[
"MIT"
] | 1
|
2019-06-28T13:43:53.000Z
|
2019-06-28T13:43:53.000Z
|
grapple/helpers.py
|
NathHorrigan/wagtail-grapple
|
73a258e920eb0c5ac45f650311e8a9f6efe21941
|
[
"MIT"
] | 3
|
2019-06-25T14:46:58.000Z
|
2019-07-04T13:57:53.000Z
|
grapple/helpers.py
|
NathHorrigan/wagtail-grapple
|
73a258e920eb0c5ac45f650311e8a9f6efe21941
|
[
"MIT"
] | 1
|
2019-06-25T13:28:27.000Z
|
2019-06-25T13:28:27.000Z
|
import inspect
from types import MethodType
import graphene
from django.utils.translation import gettext_lazy as _
from graphene.utils.str_converters import to_camel_case
from wagtail.core.models import Page
from .registry import registry
from .settings import grapple_settings
from .types.streamfield import StreamFieldInterface
streamfield_types = []
field_middlewares = {}
def register_streamfield_block(cls):
base_block = None
for block_class in inspect.getmro(cls):
if block_class in registry.streamfield_blocks:
base_block = registry.streamfield_blocks[block_class]
streamfield_types.append(
{
"cls": cls,
"type_prefix": "",
"interface": StreamFieldInterface,
"base_type": base_block,
}
)
return cls
def register_graphql_schema(schema_cls):
registry.schema.append(schema_cls)
return schema_cls
def register_field_middleware(field_name: str, middleware):
assert isinstance(middleware, list), "middleware should be list but got {}.".format(
type(middleware)
)
if grapple_settings.AUTO_CAMELCASE:
field_name = to_camel_case(field_name)
if field_name in field_middlewares:
field_middlewares[field_name] += middleware
else:
field_middlewares[field_name] = middleware
def register_query_field(
field_name,
plural_field_name=None,
query_params=None,
required=False,
plural_required=False,
plural_item_required=False,
middleware=None,
):
from .types.structures import QuerySetList
from .utils import resolve_queryset
if not plural_field_name:
plural_field_name = field_name + "s"
def inner(cls):
field_type = lambda: registry.models[cls] # noqa: E731
field_query_params = query_params
if field_query_params is None:
field_query_params = {"id": graphene.Int()}
if issubclass(cls, Page):
field_query_params["slug"] = graphene.Argument(
graphene.String, description=_("The page slug.")
)
field_query_params["url_path"] = graphene.Argument(
graphene.String, description=_("The url path.")
)
field_query_params["token"] = graphene.Argument(
graphene.String, description=_("The preview token.")
)
def Mixin():
# Generic methods to get all and query one model instance.
def resolve_singular(self, _, info, **kwargs):
# If no filters then return nothing,
if not kwargs:
return None
try:
# If is a Page then only query live/public pages.
if issubclass(cls, Page):
if "token" in kwargs and hasattr(
cls, "get_page_from_preview_token"
):
return cls.get_page_from_preview_token(kwargs.get("token"))
qs = cls.objects.live().public()
url_path = kwargs.pop("url_path", None)
if url_path:
if not url_path.endswith("/"):
url_path += "/"
return qs.filter(
url_path__endswith=url_path, **kwargs
).first()
return qs.get(**kwargs)
return cls.objects.get(**kwargs)
except Exception:
return None
def resolve_plural(self, _, info, **kwargs):
qs = cls.objects
if issubclass(cls, Page):
qs = qs.live().public()
if "order" not in kwargs:
kwargs["order"] = "-first_published_at"
return resolve_queryset(qs.all(), info, **kwargs)
# Create schema and add resolve methods
schema = type(cls.__name__ + "Query", (), {})
singular_field_type = field_type
if required:
singular_field_type = graphene.NonNull(field_type)
setattr(
schema,
field_name,
graphene.Field(singular_field_type, **field_query_params),
)
plural_field_type = field_type
if plural_item_required:
plural_field_type = graphene.NonNull(field_type)
setattr(
schema,
plural_field_name,
QuerySetList(plural_field_type, required=plural_required),
)
setattr(
schema, "resolve_" + field_name, MethodType(resolve_singular, schema)
)
setattr(
schema,
"resolve_" + plural_field_name,
MethodType(resolve_plural, schema),
)
return schema
# Send schema to Grapple schema.
register_graphql_schema(Mixin())
return cls
if middleware is not None:
register_field_middleware(field_name, middleware)
register_field_middleware(plural_field_name, middleware)
return inner
def register_paginated_query_field(
field_name,
plural_field_name=None,
query_params=None,
required=False,
plural_required=False,
plural_item_required=False,
middleware=None,
):
from .types.structures import PaginatedQuerySet
from .utils import resolve_paginated_queryset
if not plural_field_name:
plural_field_name = field_name + "s"
def inner(cls):
field_type = lambda: registry.models[cls] # noqa: E731
field_query_params = query_params
if field_query_params is None:
field_query_params = {"id": graphene.Int()}
if issubclass(cls, Page):
field_query_params["slug"] = graphene.Argument(
graphene.String, description=_("The page slug.")
)
field_query_params["url_path"] = graphene.Argument(
graphene.String, description=_("The page url path.")
)
field_query_params["token"] = graphene.Argument(
graphene.String, description=_("The preview token.")
)
def Mixin():
# Generic methods to get all and query one model instance.
def resolve_singular(self, _, info, **kwargs):
# If no filters then return nothing.
if not kwargs:
return None
try:
# If is a Page then only query live/public pages.
if issubclass(cls, Page):
if "token" in kwargs and hasattr(
cls, "get_page_from_preview_token"
):
return cls.get_page_from_preview_token(kwargs.get("token"))
qs = cls.objects.live().public()
url_path = kwargs.pop("url_path", None)
if url_path:
if not url_path.endswith("/"):
url_path += "/"
return qs.filter(
url_path__endswith=url_path, **kwargs
).first()
return qs.get(**kwargs)
return cls.objects.get(**kwargs)
except Exception:
return None
def resolve_plural(self, _, info, **kwargs):
qs = cls.objects
if issubclass(cls, Page):
qs = qs.live().public()
if "order" not in kwargs:
kwargs["order"] = "-first_published_at"
return resolve_paginated_queryset(qs.all(), info, **kwargs)
# Create schema and add resolve methods
schema = type(cls.__name__ + "Query", (), {})
singular_field_type = field_type
if required:
singular_field_type = graphene.NonNull(field_type)
setattr(
schema,
field_name,
graphene.Field(singular_field_type, **field_query_params),
)
plural_field_type = field_type
if plural_item_required:
plural_field_type = graphene.NonNull(field_type)
setattr(
schema,
plural_field_name,
PaginatedQuerySet(plural_field_type, cls, required=plural_required),
)
setattr(
schema, "resolve_" + field_name, MethodType(resolve_singular, schema)
)
setattr(
schema,
"resolve_" + plural_field_name,
MethodType(resolve_plural, schema),
)
return schema
# Send schema to Grapple schema.
register_graphql_schema(Mixin())
return cls
if middleware is not None:
register_field_middleware(field_name, middleware)
register_field_middleware(plural_field_name, middleware)
return inner
def register_singular_query_field(
field_name, query_params=None, required=False, middleware=None
):
def inner(cls):
field_type = lambda: registry.models[cls] # noqa: E731
field_query_params = query_params
if field_query_params is None:
field_query_params = {
"order": graphene.Argument(
graphene.String,
description=_("Use the Django QuerySet order_by format."),
),
}
if issubclass(cls, Page):
field_query_params["token"] = graphene.Argument(
graphene.String, description=_("The preview token.")
)
def Mixin():
# Generic methods to get all and query one model instance.
def resolve_singular(self, _, info, **kwargs):
try:
qs = cls.objects
if "order" in kwargs:
qs = qs.order_by(
*(x.strip() for x in kwargs.pop("order").split(","))
)
# If is a Page then only query live/public pages.
if issubclass(cls, Page):
if "token" in kwargs and hasattr(
cls, "get_page_from_preview_token"
):
return cls.get_page_from_preview_token(kwargs.get("token"))
return qs.live().public().filter(**kwargs).first()
return qs.filter(**kwargs).first()
except Exception:
return None
# Create schema and add resolve methods
schema = type(cls.__name__ + "Query", (), {})
singular_field_type = field_type
if required:
singular_field_type = graphene.NonNull(field_type)
setattr(
schema,
field_name,
graphene.Field(singular_field_type, **field_query_params),
)
setattr(
schema, "resolve_" + field_name, MethodType(resolve_singular, schema)
)
return schema
# Send schema to Grapple schema.
register_graphql_schema(Mixin())
return cls
if middleware is not None:
register_field_middleware(field_name, middleware)
return inner
| 33.617143
| 88
| 0.537566
| 1,145
| 11,766
| 5.263755
| 0.118777
| 0.047785
| 0.05044
| 0.02522
| 0.795255
| 0.765057
| 0.765057
| 0.761241
| 0.761241
| 0.752281
| 0
| 0.001244
| 0.385348
| 11,766
| 349
| 89
| 33.713467
| 0.832135
| 0.053034
| 0
| 0.701493
| 0
| 0
| 0.047375
| 0.007282
| 0
| 0
| 0
| 0
| 0.003731
| 1
| 0.063433
| false
| 0
| 0.048507
| 0
| 0.220149
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
f77194ef99e1ec7899793614aa2e875869114c0f
| 7,688
|
py
|
Python
|
tests/src/stanpy/test_reduction.py
|
DavidNaizheZhou/stanpy
|
257072bd52154e9e4d68be957fd12eee1ad3dc56
|
[
"MIT"
] | null | null | null |
tests/src/stanpy/test_reduction.py
|
DavidNaizheZhou/stanpy
|
257072bd52154e9e4d68be957fd12eee1ad3dc56
|
[
"MIT"
] | null | null | null |
tests/src/stanpy/test_reduction.py
|
DavidNaizheZhou/stanpy
|
257072bd52154e9e4d68be957fd12eee1ad3dc56
|
[
"MIT"
] | 1
|
2022-01-30T17:25:38.000Z
|
2022-01-30T17:25:38.000Z
|
import stanpy as stp
import numpy as np
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
def test_multiple_w0():
EI = 32000 # kN/m2
l = 3 # m
hinged_support = {"w": 0, "M": 0}
roller_support = {"w": 0, "M": 0, "H": 0}
fixed_support = {"w": 0, "phi": 0}
s1 = {"EI": EI, "l": l, "bc_i": hinged_support, "bc_k": {"w": 0}, "q": 10}
s2 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": 10}
# s2 = {"EI": EI, "l": l, "q": 10}
s3 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": 10}
s4 = {"EI": EI, "l": l, "bc_k": roller_support}
s = [s1, s2, s3, s4]
x = np.linspace(0,4*l,5)
Zi, Zk = stp.tr_solver(*s)
Fx = stp.tr(*s, x=x)
Zx = Fx.dot(Zi)
path = os.path.join(dir_path, "reduction_method_npz", "test_multiple_w0.npz")
# np.savez_compressed(path, Fx=Fx, Zx=Zx)
npz = np.load(path)
Zx_test = npz["Zx"]
Fx_test = npz["Fx"]
np.testing.assert_allclose(Fx, Fx_test,rtol=1e-5)
np.testing.assert_allclose(Zx.round(10), Zx_test,rtol=1e-5)
def test_multiple_w0_M0():
import numpy as np
np.set_printoptions(precision=6, threshold=5000)
import matplotlib.pyplot as plt
import stanpy as stp
EI = 32000 # kN/m2
l = 3 # m
hinged_support = {"w": 0, "M": 0}
roller_support = {"w": 0, "M": 0, "H": 0}
fixed_support = {"w": 0, "phi": 0}
s1 = {"EI": EI, "l": l, "bc_i": hinged_support, "bc_k": {"w": 0}, "q": 10}
s2 = {"EI": EI, "l": l, "bc_k": {"M": 0}, "q": 8}
# s2 = {"EI": EI, "l": l, "q": 10}
s3 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": 6}
s4 = {"EI": EI, "l": l, "bc_k": roller_support}
s = [s1, s2, s3, s4]
x = np.sort(np.append(np.linspace(0,4*l,4000), [l,2*l, 3*l, 4*l]))
Zi, Zk = stp.tr_solver(*s)
Fx = stp.tr(*s, x=x)
Zx = Fx.dot(Zi).round(10)
path = os.path.join(dir_path, "reduction_method_npz", "test_multiple_w0_M0.npz")
# np.savez_compressed(path, Fx=Fx, Zx=Zx)
npz = np.load(path)
Zx_test = npz["Zx"]
Fx_test = npz["Fx"]
np.testing.assert_allclose(Fx, Fx_test,rtol=1e-5)
np.testing.assert_allclose(Zx, Zx_test,rtol=1e-5)
def test_multiple_w0_combination():
"""testet einwertige Bindungen mit zusammengesetzten Stäben
"""
import numpy as np
np.set_printoptions(precision=6, threshold=5000)
import matplotlib.pyplot as plt
import stanpy as stp
EI = 32000 # kN/m2
l = 3 # m
hinged_support = {"w": 0, "M": 0}
roller_support = {"w": 0, "M": 0, "H": 0}
fixed_support = {"w": 0, "phi": 0}
s1 = {"EI": EI, "l": l, "bc_i": hinged_support, "bc_k": {"w": 0}, "q": 10}
# s2 = {"EI": EI, "l": l, "bc_k": {"M": 0}, "q": 10}
s2 = {"EI": EI, "l": l, "q": 8}
s3 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": 6}
s4 = {"EI": EI, "l": l, "bc_k": roller_support}
s = [s1, s2, s3, s4]
x = np.sort(np.append(np.linspace(0,4*l,4000), [l,2*l, 3*l, 4*l]))
Zi, Zk = stp.tr_solver(*s)
Fx = stp.tr(*s, x=x)
Zx = Fx.dot(Zi).round(10)
path = os.path.join(dir_path, "reduction_method_npz", "test_multiple_w0_combination.npz")
# np.savez_compressed(path, Fx=Fx, Zx=Zx)
npz = np.load(path)
Zx_test = npz["Zx"]
Fx_test = npz["Fx"]
np.testing.assert_allclose(Fx, Fx_test,rtol=1e-5)
np.testing.assert_allclose(Zx, Zx_test,rtol=1e-5)
def test_large_system():
import numpy as np
import sympy as sym
import stanpy as stp
import matplotlib.pyplot as plt
EI = 32000 # kN/m2
P = 5 # kN
q = 4 # kN/m
l = 3 # m
roller_support = {"w": 0, "M": 0, "H": 0}
fixed_support = {"w": 0, "phi": 0}
hinge = {"M": 0}
s0 = {"EI": EI, "l": l, "bc_i": fixed_support, "bc_k": {"w": 0}}
s1 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": q}
s2 = {"EI": EI, "l": l, "bc_k": {"w": 0}}
s3 = {"EI": EI, "l": l, "bc_k": hinge, "q": q, "P": (P, l)}
s4 = {"EI": EI, "l": l, "bc_k": {"w": 0}}
s5 = {"EI": EI, "l": l, "bc_k": hinge}
s6 = {"EI": EI, "l": l, "bc_k": roller_support, "P": (P, l / 2), }
s = [s0, s1, s2, s3, s4, s5, s6]
# fig, ax = plt.subplots(figsize=(12, 5))
# stp.plot_system(ax, s=22, *s)
# stp.plot_load(ax, *s, P_scale=0.5, q_scale=0.5)
# ax.set_ylim(-0.5, 1)
# plt.show()
x = np.sort(np.append(np.linspace(0,7*l,70),[l,2*l, 3*l, 4*l, 5*l, 6*l]))
Zi, Zk = stp.tr_solver(*s)
Fx = stp.tr(*s, x=x)
Zx = Fx.dot(Zi)
path = os.path.join(dir_path, "reduction_method_npz", "test_large_system.npz")
# np.savez_compressed(path, Fx=Fx, Zx=Zx)
npz = np.load(path)
Zx_test = npz["Zx"]
Fx_test = npz["Fx"]
np.testing.assert_allclose(Fx, Fx_test,rtol=1e-5)
np.testing.assert_allclose(Zx, Zx_test,rtol=1e-5)
# scale = 0.5
# fig, ax = plt.subplots()
# stp.plot_system(ax, *s, watermark=False)
# stp.plot_M(
# ax,
# x=x,
# Mx=Zx[:, 2],
# annotate_x=[l,2*l, 3*l, 4*l, 5*l, 6*l],
# fill_p="red",
# fill_n="blue",
# scale=scale,
# alpha=0.2,
# )
# ax.set_ylim(-1, 1)
# ax.axis('off')
# plt.show()
def test_large_system_II():
import numpy as np
import sympy as sym
import stanpy as stp
import matplotlib.pyplot as plt
EI = 32000 # kN/m2
P = 5 # kN
q = 4 # kN/m
l = 3 # m
roller_support = {"w": 0, "M": 0, "H": 0}
fixed_support = {"w": 0, "phi": 0}
hinge = {"M": 0}
s0 = {"EI": EI, "l": l, "bc_i": fixed_support, "bc_k": {"w": 0}, "N": -1000}
s1 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "q": q, "N": -1000}
s2 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "N": -1000}
s3 = {"EI": EI, "l": l, "bc_k": hinge, "q": q, "P": (P, l), "N": -1000}
s4 = {"EI": EI, "l": l, "bc_k": {"w": 0}, "N": -1000}
s5 = {"EI": EI, "l": l, "bc_k": hinge, "N": -1000}
s6 = {"EI": EI, "l": l, "bc_k": roller_support, "P": (P, l / 2), "N": -1000}
s = [s0, s1, s2, s3, s4, s5, s6]
# fig, ax = plt.subplots(figsize=(12, 5))
# stp.plot_system(ax, s=22, *s)
# stp.plot_load(ax, *s, P_scale=0.5, q_scale=0.5)
# ax.set_ylim(-0.5, 1)
# plt.show()
x = np.sort(np.append(np.linspace(0,7*l,70),[l,2*l, 3*l, 4*l, 5*l, 6*l]))
Zi, Zk = stp.tr_solver(*s)
Fx = stp.tr(*s, x=x)
Zx = Fx.dot(Zi)
path = os.path.join(dir_path, "reduction_method_npz", "test_large_system_II.npz")
# np.savez_compressed(path, Fx=Fx, Zx=Zx)
npz = np.load(path)
Zx_test = npz["Zx"]
Fx_test = npz["Fx"]
np.testing.assert_allclose(Fx, Fx_test,rtol=1e-5)
np.testing.assert_allclose(Zx, Zx_test,rtol=1e-5)
# scale = 0.5
# fig, ax = plt.subplots()
# stp.plot_system(ax, *s, watermark=False)
# stp.plot_M(
# ax,
# x=x,
# Mx=Zx[:, 2],
# annotate_x=[l,2*l, 3*l, 4*l, 5*l, 6*l],
# fill_p="red",
# fill_n="blue",
# scale=scale,
# alpha=0.2,
# )
# ax.set_ylim(-1, 1)
# ax.axis('off')
# plt.show()
def empty():
import matplotlib.pyplot as plt
import numpy as np
EI = 32000 # kNm²
GA = 20000 # kN
l = 6 # m
q = 4 # kN/m
P = 1500 # kN
H = 10 # kN
fixed = {"w":0, "phi":0}
hinged = {"w":0, "M":0, "H":0}
s = {"EI":EI, "GA":GA, "l":l, "q":q, "w_0":0.03,"N":(-P ),"P1":(H, l/2),"P2":(H, l/3),"P3":(H, 2*l/3), "bc_i":fixed, "bc_k":hinged}
fig, ax = plt.subplots()
stp.plot_system(ax, s)
stp.plot_load(ax, s)
stp.plot_w_0(ax, s, scale=0.4, dy=-0.2)
ax.set_ylim(-1,1)
plt.show()
x = np
Zi, Zk = stp.tr_solver(s)
Fxx = stp.tr(s)
Zx = Fxx.dot(Zi)
print(Zx)
if __name__=="__main__":
# test_large_system_II()
empty()
| 28.058394
| 135
| 0.512747
| 1,381
| 7,688
| 2.721217
| 0.099203
| 0.01703
| 0.038584
| 0.046301
| 0.894359
| 0.878659
| 0.858968
| 0.855508
| 0.846993
| 0.816924
| 0
| 0.064296
| 0.257544
| 7,688
| 274
| 136
| 28.058394
| 0.594078
| 0.175208
| 0
| 0.66875
| 0
| 0
| 0.089371
| 0.015959
| 0
| 0
| 0
| 0
| 0.0625
| 1
| 0.0375
| false
| 0
| 0.11875
| 0
| 0.15625
| 0.01875
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
f7872a853768d70eadfb27d6c69bf45c62f0298d
| 191
|
py
|
Python
|
todolistBE/list/urls.py
|
Jomornt/todolist
|
3d754807c7e89ec6bcd098759c24f1d6d2792814
|
[
"MIT"
] | null | null | null |
todolistBE/list/urls.py
|
Jomornt/todolist
|
3d754807c7e89ec6bcd098759c24f1d6d2792814
|
[
"MIT"
] | 6
|
2020-09-06T14:11:10.000Z
|
2022-02-26T15:34:03.000Z
|
todolistBE/list/urls.py
|
Jomornt/todolist
|
3d754807c7e89ec6bcd098759c24f1d6d2792814
|
[
"MIT"
] | null | null | null |
from django.conf.urls import url
import list.views
urlpatterns = [
url(r'^tododata/$', list.views.TaskTodo.as_view()),# 1
url(r'^tododata/(\d+)/$', list.views.TaskTodo.as_view())#2
]
| 27.285714
| 62
| 0.670157
| 29
| 191
| 4.344828
| 0.586207
| 0.214286
| 0.190476
| 0.301587
| 0.365079
| 0
| 0
| 0
| 0
| 0
| 0
| 0.011905
| 0.120419
| 191
| 7
| 63
| 27.285714
| 0.738095
| 0.010471
| 0
| 0
| 0
| 0
| 0.149733
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
f78ec30883a9c12c0b94f23edd294c232f091612
| 33
|
py
|
Python
|
redditnfl/reddittools/sidebarupdater/__init__.py
|
redditnfl/reddittools
|
68e25fc668a4b108dcf3b3fdfbeed6230a5405ab
|
[
"MIT"
] | null | null | null |
redditnfl/reddittools/sidebarupdater/__init__.py
|
redditnfl/reddittools
|
68e25fc668a4b108dcf3b3fdfbeed6230a5405ab
|
[
"MIT"
] | null | null | null |
redditnfl/reddittools/sidebarupdater/__init__.py
|
redditnfl/reddittools
|
68e25fc668a4b108dcf3b3fdfbeed6230a5405ab
|
[
"MIT"
] | null | null | null |
from .sidebarupdater import main
| 16.5
| 32
| 0.848485
| 4
| 33
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121212
| 33
| 1
| 33
| 33
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e3aae2c5a9718678f79747c182968c2d843cfb88
| 20,333
|
py
|
Python
|
spikesorters/sorterlist.py
|
alowet/spikesorters
|
1a5e810b5ba9bfa974ec91b5e0fa7f0901096268
|
[
"MIT"
] | null | null | null |
spikesorters/sorterlist.py
|
alowet/spikesorters
|
1a5e810b5ba9bfa974ec91b5e0fa7f0901096268
|
[
"MIT"
] | null | null | null |
spikesorters/sorterlist.py
|
alowet/spikesorters
|
1a5e810b5ba9bfa974ec91b5e0fa7f0901096268
|
[
"MIT"
] | null | null | null |
from .hdsort import HDSortSorter
from .klusta import KlustaSorter
from .tridesclous import TridesclousSorter
from .mountainsort4 import Mountainsort4Sorter
from .ironclust import IronClustSorter
from .kilosort import KilosortSorter
from .kilosort2 import Kilosort2Sorter
from .kilosort2_5 import Kilosort2_5Sorter
from .spyking_circus import SpykingcircusSorter
from .herdingspikes import HerdingspikesSorter
from .waveclus import WaveClusSorter
sorter_full_list = [
HDSortSorter,
KlustaSorter,
TridesclousSorter,
Mountainsort4Sorter,
IronClustSorter,
KilosortSorter,
Kilosort2Sorter,
Kilosort2_5Sorter,
SpykingcircusSorter,
HerdingspikesSorter,
WaveClusSorter
]
sorter_dict = {s.sorter_name: s for s in sorter_full_list}
# generic laucnher via function approach
def run_sorter(sorter_name_or_class, recording, output_folder=None, delete_output_folder=False,
grouping_property=None, parallel=False, verbose=False, raise_error=True, n_jobs=-1, joblib_backend='loky',
**params):
"""
Generic function to run a sorter via function approach.
Two usages with name or class:
by name:
>>> sorting = run_sorter('tridesclous', recording)
by class:
>>> sorting = run_sorter(TridesclousSorter, recording)
Parameters
----------
sorter_name_or_class: str or SorterClass
The sorter to retrieve default parameters from
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error is
logged in the log file.
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**params: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params(sorter_name_or_class)'
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
if isinstance(sorter_name_or_class, str):
SorterClass = sorter_dict[sorter_name_or_class]
elif sorter_name_or_class in sorter_full_list:
SorterClass = sorter_name_or_class
else:
raise (ValueError('Unknown sorter'))
sorter = SorterClass(recording=recording, output_folder=output_folder, grouping_property=grouping_property,
verbose=verbose, delete_output_folder=delete_output_folder)
sorter.set_params(**params)
sorter.run(raise_error=raise_error, parallel=parallel, n_jobs=n_jobs, joblib_backend=joblib_backend)
sortingextractor = sorter.get_result()
return sortingextractor
def available_sorters():
'''
Lists available sorters.
'''
return sorted(list(sorter_dict.keys()))
def installed_sorters():
'''
Lists installed sorters.
'''
l = sorted([s.sorter_name for s in sorter_full_list if s.is_installed()])
return l
def print_sorter_versions():
txt = ''
for name in installed_sorters():
version = sorter_dict[name].get_sorter_version()
txt += '{}: {}\n'.format(name, version)
txt = txt[:-1]
print(txt)
def get_default_params(sorter_name_or_class):
'''
Returns default parameters for the specified sorter.
Parameters
----------
sorter_name_or_class: str or SorterClass
The sorter to retrieve default parameters from
Returns
-------
default_params: dict
Dictionary with default params for the specified sorter
'''
if isinstance(sorter_name_or_class, str):
SorterClass = sorter_dict[sorter_name_or_class]
elif sorter_name_or_class in sorter_full_list:
SorterClass = sorter_name_or_class
else:
raise (ValueError('Unknown sorter'))
return SorterClass.default_params()
def get_params_description(sorter_name_or_class):
'''
Returns a description of the parameters for the specified sorter.
Parameters
----------
sorter_name_or_class: str or SorterClass
The sorter to retrieve parameters description from
Returns
-------
params_description: dict
Dictionary with parameter description
'''
if isinstance(sorter_name_or_class, str):
SorterClass = sorter_dict[sorter_name_or_class]
elif sorter_name_or_class in sorter_full_list:
SorterClass = sorter_name_or_class
else:
raise (ValueError('Unknown sorter'))
return SorterClass.params_description()
def get_sorter_description(sorter_name_or_class):
'''
Returns a brief description of the of the specified sorter.
Parameters
----------
sorter_name_or_class: str or SorterClass
The sorter to retrieve description from
Returns
-------
params_description: dict
Dictionary with parameter description
'''
if isinstance(sorter_name_or_class, str):
SorterClass = sorter_dict[sorter_name_or_class]
elif sorter_name_or_class in sorter_full_list:
SorterClass = sorter_name_or_class
else:
raise (ValueError('Unknown sorter'))
return SorterClass.sorter_description
def run_hdsort(*args, **kwargs):
"""
Runs HDsort sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('hdsort')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('hdsort', *args, **kwargs)
def run_klusta(*args, **kwargs):
"""
Runs klusta sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('klusta')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('klusta', *args, **kwargs)
def run_tridesclous(*args, **kwargs):
"""
Runs tridesclous sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('tridesclous')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('tridesclous', *args, **kwargs)
def run_mountainsort4(*args, **kwargs):
"""
Runs mountainsort4 sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('mountainsort4')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('mountainsort4', *args, **kwargs)
def run_ironclust(*args, **kwargs):
"""
Runs ironclust sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('ironclust')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('ironclust', *args, **kwargs)
def run_kilosort(*args, **kwargs):
"""
Runs kilosort sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('kilosort')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('kilosort', *args, **kwargs)
def run_kilosort2(*args, **kwargs):
"""
Runs kilosort2 sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('kilosort2')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('kilosort2', *args, **kwargs)
def run_kilosort2_5(*args, **kwargs):
"""
Runs kilosort2_5 sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('kilosort2')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('kilosort2_5', *args, **kwargs)
def run_spykingcircus(*args, **kwargs):
"""
Runs spykingcircus sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('spykingcircus')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('spykingcircus', *args, **kwargs)
def run_herdingspikes(*args, **kwargs):
"""
Runs herdingspikes sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('herdingspikes')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('herdingspikes', *args, **kwargs)
def run_waveclus(*args, **kwargs):
"""
Runs waveclus sorter
Parameters
----------
*args: arguments of 'run_sorter'
recording: RecordingExtractor
The recording extractor to be spike sorted
output_folder: str or Path
Path to output folder
delete_output_folder: bool
If True, output folder is deleted (default False)
grouping_property: str
Splits spike sorting by 'grouping_property' (e.g. 'groups')
parallel: bool
If True and spike sorting is by 'grouping_property', spike sorting jobs are launched in parallel
verbose: bool
If True, output is verbose
raise_error: bool
If True, an error is raised if spike sorting fails (default). If False, the process continues and the error
is logged in the log file
n_jobs: int
Number of jobs when parallel=True (default=-1)
joblib_backend: str
joblib backend when parallel=True (default='loky')
**kwargs: keyword args
Spike sorter specific arguments (they can be retrieved with 'get_default_params('waveclus')
Returns
-------
sortingextractor: SortingExtractor
The spike sorted data
"""
return run_sorter('waveclus', *args, **kwargs)
| 34.115772
| 121
| 0.653322
| 2,424
| 20,333
| 5.349835
| 0.058581
| 0.049969
| 0.037014
| 0.032773
| 0.81732
| 0.811151
| 0.808066
| 0.798658
| 0.793723
| 0.793723
| 0
| 0.002786
| 0.276152
| 20,333
| 595
| 122
| 34.173109
| 0.878312
| 0.708159
| 0
| 0.244898
| 0
| 0
| 0.041568
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.183673
| false
| 0
| 0.112245
| 0
| 0.469388
| 0.020408
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
e3f13f11d560ca522f1000ef763227ed14ba6b75
| 36
|
py
|
Python
|
cody/shell/__init__.py
|
lotrekagency/order66
|
dae9ec291a0436ee7d4fdffc427a2a4e912759b7
|
[
"MIT"
] | 2
|
2019-09-23T20:20:09.000Z
|
2021-05-26T11:38:38.000Z
|
cody/shell/__init__.py
|
lotrekagency/cody
|
dae9ec291a0436ee7d4fdffc427a2a4e912759b7
|
[
"MIT"
] | null | null | null |
cody/shell/__init__.py
|
lotrekagency/cody
|
dae9ec291a0436ee7d4fdffc427a2a4e912759b7
|
[
"MIT"
] | null | null | null |
from .shell import execute_commands
| 18
| 35
| 0.861111
| 5
| 36
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.111111
| 36
| 1
| 36
| 36
| 0.9375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
540a24741745e32183381c0728e831d3b1a7817e
| 67
|
py
|
Python
|
api/serializers/__init__.py
|
tavoxr/drf-ecommerce-api
|
61c6b84dc4e811987ca72c73dfdce08f99d7481d
|
[
"MIT"
] | null | null | null |
api/serializers/__init__.py
|
tavoxr/drf-ecommerce-api
|
61c6b84dc4e811987ca72c73dfdce08f99d7481d
|
[
"MIT"
] | null | null | null |
api/serializers/__init__.py
|
tavoxr/drf-ecommerce-api
|
61c6b84dc4e811987ca72c73dfdce08f99d7481d
|
[
"MIT"
] | null | null | null |
from .product import *
from .category import *
from .order import *
| 22.333333
| 23
| 0.746269
| 9
| 67
| 5.555556
| 0.555556
| 0.4
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.164179
| 67
| 3
| 24
| 22.333333
| 0.892857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
541772a68f19fc01e0a086987bb09d35e311e775
| 133
|
py
|
Python
|
hydralit/__init__.py
|
peter-ealu/hydralit
|
a5d091dd2c9492846e0ff928277352ab61070d10
|
[
"Apache-2.0"
] | 1
|
2021-10-09T10:25:42.000Z
|
2021-10-09T10:25:42.000Z
|
hydralit/__init__.py
|
nzagaspard/hydralit
|
a5d091dd2c9492846e0ff928277352ab61070d10
|
[
"Apache-2.0"
] | null | null | null |
hydralit/__init__.py
|
nzagaspard/hydralit
|
a5d091dd2c9492846e0ff928277352ab61070d10
|
[
"Apache-2.0"
] | null | null | null |
from hydralit.hydra_app import HydraApp
from hydralit.sessionstate import SessionState
from hydralit.app_template import HydraHeadApp
| 44.333333
| 46
| 0.894737
| 17
| 133
| 6.882353
| 0.529412
| 0.307692
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.082707
| 133
| 3
| 47
| 44.333333
| 0.959016
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
5859b54ec6f9eb2008e4a4a06396e361800911ef
| 30
|
py
|
Python
|
src/aleph/vms/__init__.py
|
olethanh/pyaleph
|
3a64fb89c54e74187679872d559fb00be0dfde43
|
[
"MIT"
] | null | null | null |
src/aleph/vms/__init__.py
|
olethanh/pyaleph
|
3a64fb89c54e74187679872d559fb00be0dfde43
|
[
"MIT"
] | null | null | null |
src/aleph/vms/__init__.py
|
olethanh/pyaleph
|
3a64fb89c54e74187679872d559fb00be0dfde43
|
[
"MIT"
] | null | null | null |
from .dockerized import python
| 30
| 30
| 0.866667
| 4
| 30
| 6.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1
| 30
| 1
| 30
| 30
| 0.962963
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
58a0a13487645e392581799d02313340fa5e3b01
| 4,495
|
py
|
Python
|
flask_sketch/questions/features.py
|
ericsouza/flask-sketch
|
65625a567e5492b3787c5da3ba5e12b1473783c4
|
[
"MIT"
] | 11
|
2020-08-19T14:33:00.000Z
|
2021-05-29T17:12:47.000Z
|
flask_sketch/questions/features.py
|
ericsouza/flask-sketch
|
65625a567e5492b3787c5da3ba5e12b1473783c4
|
[
"MIT"
] | 3
|
2021-03-16T19:33:39.000Z
|
2021-03-18T18:53:55.000Z
|
flask_sketch/questions/features.py
|
ericsouza/flask-sketch
|
65625a567e5492b3787c5da3ba5e12b1473783c4
|
[
"MIT"
] | 2
|
2020-08-19T14:33:11.000Z
|
2020-09-16T19:34:16.000Z
|
from flask_sketch.utils import has_answers
from flask_sketch.questions.const import (
FLASK_MIGRATE,
FLASK_ADMIN,
FLASK_CACHING,
FLASK_LIMITER,
FLASK_DEBUGTOOLBAR,
NONE,
MONGODB,
)
"""
{
"type": "checkbox",
"message": "Select the frontend features.",
"name": "frontend_features",
"choices": [
{"name": "Flask-HTMLmin", "disabled": "Not yet supported"},
{"name": "Flask-Assets", "disabled": "Not yet supported"},
{"name": "Flask-Talisman", "disabled": "Not yet supported"},
],
},
"""
features_questions = [
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{"name": "Migrations (Flask-Migrate)", "value": FLASK_MIGRATE},
{"name": "Admin Interface (Flask-Admin)", "value": FLASK_ADMIN},
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers,
have={"have_api": False},
not_have={"database": f"{NONE};{MONGODB}"},
),
},
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers, have={"have_api": False, "database": NONE},
),
},
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{"name": "Flask-CORS", "value": "cors"},
{"name": "Migrations (Flask-Migrate)", "value": FLASK_MIGRATE},
{"name": "Admin Interface (Flask-Admin)", "value": FLASK_ADMIN},
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers,
have={"have_api": True},
not_have={"database": f"{NONE};{MONGODB}"},
),
},
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{
"name": "Flask-CORS",
"disabled": "Not supported yet.",
"value": "cors",
},
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers, have={"have_api": True, "database": NONE},
),
},
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{"name": "Flask-CORS", "value": "cors"},
{"name": "Admin Interface (Flask-Admin)", "value": FLASK_ADMIN},
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers, have={"have_api": True, "database": MONGODB}
),
},
{
"type": "checkbox",
"message": "Select some more features for your project",
"name": "features",
"choices": [
{"name": "Admin Interface (Flask-Admin)", "value": FLASK_ADMIN},
{"name": "Cache (Flask-Caching)", "value": FLASK_CACHING},
{"name": "Rate Limiting (Flask-Limiter)", "value": FLASK_LIMITER},
{"name": "Flask-DebugToolbar", "value": FLASK_DEBUGTOOLBAR},
],
"when": lambda answers: has_answers(
answers, have={"have_api": False, "database": MONGODB}
),
},
]
| 36.844262
| 78
| 0.522803
| 408
| 4,495
| 5.642157
| 0.127451
| 0.104257
| 0.057776
| 0.076021
| 0.874457
| 0.874457
| 0.831017
| 0.831017
| 0.831017
| 0.831017
| 0
| 0
| 0.301669
| 4,495
| 121
| 79
| 37.14876
| 0.733355
| 0
| 0
| 0.672897
| 0
| 0
| 0.369227
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.018692
| 0
| 0.018692
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
5488a733d7213f9ba4657ee3cb687bfca87e8d87
| 101
|
py
|
Python
|
backend/beedare/user/__init__.py
|
gijs3ntius/BeeDare
|
9ad5a93dad9b531b332aeb58f9b97e98585bc1ac
|
[
"Apache-2.0"
] | null | null | null |
backend/beedare/user/__init__.py
|
gijs3ntius/BeeDare
|
9ad5a93dad9b531b332aeb58f9b97e98585bc1ac
|
[
"Apache-2.0"
] | 17
|
2020-06-05T18:27:11.000Z
|
2022-03-11T23:24:50.000Z
|
backend/beedare/user/__init__.py
|
gijsentius/BeeDare
|
9ad5a93dad9b531b332aeb58f9b97e98585bc1ac
|
[
"Apache-2.0"
] | null | null | null |
from flask import Blueprint
profile_blueprint = Blueprint('profile', __name__)
from . import views
| 16.833333
| 50
| 0.792079
| 12
| 101
| 6.25
| 0.583333
| 0.426667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.138614
| 101
| 5
| 51
| 20.2
| 0.862069
| 0
| 0
| 0
| 0
| 0
| 0.069307
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0.666667
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 1
|
0
| 6
|
54b3f431c7e017d1e3cdf0cdad30af23623c6264
| 14,409
|
py
|
Python
|
incident_io_client/api/incidents/incidents_create.py
|
expobrain/python-incidentio-client
|
be15e0370dc3feb979e448f87b40906d12331467
|
[
"MIT"
] | null | null | null |
incident_io_client/api/incidents/incidents_create.py
|
expobrain/python-incidentio-client
|
be15e0370dc3feb979e448f87b40906d12331467
|
[
"MIT"
] | null | null | null |
incident_io_client/api/incidents/incidents_create.py
|
expobrain/python-incidentio-client
|
be15e0370dc3feb979e448f87b40906d12331467
|
[
"MIT"
] | null | null | null |
from typing import Any, Dict, Optional
import httpx
from ...client import Client
from ...models.incidents_create_request_body import IncidentsCreateRequestBody
from ...models.incidents_create_response_body import IncidentsCreateResponseBody
from ...types import Response
def _get_kwargs(
*,
client: Client,
json_body: IncidentsCreateRequestBody,
) -> Dict[str, Any]:
url = f"{client.base_url}/v1/incidents"
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
json_json_body = json_body.to_dict()
return {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"json": json_json_body,
}
def _parse_response(*, response: httpx.Response) -> Optional[IncidentsCreateResponseBody]:
if response.status_code == 200:
response_200 = IncidentsCreateResponseBody.from_dict(response.json())
return response_200
return None
def _build_response(*, response: httpx.Response) -> Response[IncidentsCreateResponseBody]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)
def sync_detailed(
*,
client: Client,
json_body: IncidentsCreateRequestBody,
) -> Response[IncidentsCreateResponseBody]:
"""Create Incidents
Create a new incident.
Args:
json_body (IncidentsCreateRequestBody): Example: {'custom_field_entries':
[{'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}], 'idempotency_key': 'alert-uuid', 'incident_role_assignments': [{'assignee':
{'email': 'Dolore autem ea et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit
nihil.', 'slack_user_id': 'Alias aut rerum fugiat exercitationem maiores.'},
'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea
et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id':
'Alias aut rerum fugiat exercitationem maiores.'}, 'incident_role_id':
'01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea et voluptatem minus
aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id': 'Alias aut rerum fugiat
exercitationem maiores.'}, 'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}],
'incident_type_id': 'Quidem amet.', 'name': 'Our database is sad', 'severity_id': 'Aut
quis.', 'summary': "Our database is really really sad, and we don't know why yet.",
'visibility': 'public'}.
Returns:
Response[IncidentsCreateResponseBody]
"""
kwargs = _get_kwargs(
client=client,
json_body=json_body,
)
response = httpx.post(
verify=client.verify_ssl,
**kwargs,
)
return _build_response(response=response)
def sync(
*,
client: Client,
json_body: IncidentsCreateRequestBody,
) -> Optional[IncidentsCreateResponseBody]:
"""Create Incidents
Create a new incident.
Args:
json_body (IncidentsCreateRequestBody): Example: {'custom_field_entries':
[{'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}], 'idempotency_key': 'alert-uuid', 'incident_role_assignments': [{'assignee':
{'email': 'Dolore autem ea et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit
nihil.', 'slack_user_id': 'Alias aut rerum fugiat exercitationem maiores.'},
'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea
et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id':
'Alias aut rerum fugiat exercitationem maiores.'}, 'incident_role_id':
'01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea et voluptatem minus
aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id': 'Alias aut rerum fugiat
exercitationem maiores.'}, 'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}],
'incident_type_id': 'Quidem amet.', 'name': 'Our database is sad', 'severity_id': 'Aut
quis.', 'summary': "Our database is really really sad, and we don't know why yet.",
'visibility': 'public'}.
Returns:
Response[IncidentsCreateResponseBody]
"""
return sync_detailed(
client=client,
json_body=json_body,
).parsed
async def asyncio_detailed(
*,
client: Client,
json_body: IncidentsCreateRequestBody,
) -> Response[IncidentsCreateResponseBody]:
"""Create Incidents
Create a new incident.
Args:
json_body (IncidentsCreateRequestBody): Example: {'custom_field_entries':
[{'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}], 'idempotency_key': 'alert-uuid', 'incident_role_assignments': [{'assignee':
{'email': 'Dolore autem ea et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit
nihil.', 'slack_user_id': 'Alias aut rerum fugiat exercitationem maiores.'},
'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea
et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id':
'Alias aut rerum fugiat exercitationem maiores.'}, 'incident_role_id':
'01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea et voluptatem minus
aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id': 'Alias aut rerum fugiat
exercitationem maiores.'}, 'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}],
'incident_type_id': 'Quidem amet.', 'name': 'Our database is sad', 'severity_id': 'Aut
quis.', 'summary': "Our database is really really sad, and we don't know why yet.",
'visibility': 'public'}.
Returns:
Response[IncidentsCreateResponseBody]
"""
kwargs = _get_kwargs(
client=client,
json_body=json_body,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.post(**kwargs)
return _build_response(response=response)
async def asyncio(
*,
client: Client,
json_body: IncidentsCreateRequestBody,
) -> Optional[IncidentsCreateResponseBody]:
"""Create Incidents
Create a new incident.
Args:
json_body (IncidentsCreateRequestBody): Example: {'custom_field_entries':
[{'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}, {'custom_field_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'values': [{'id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_link': 'https://google.com/', 'value_numeric':
'123.456', 'value_option_id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text
field, I hope you like it'}, {'id': '01FCNDV6P870EA6S7TK1DSYDG0', 'value_link':
'https://google.com/', 'value_numeric': '123.456', 'value_option_id':
'01FCNDV6P870EA6S7TK1DSYDG0', 'value_text': 'This is my text field, I hope you like
it'}]}], 'idempotency_key': 'alert-uuid', 'incident_role_assignments': [{'assignee':
{'email': 'Dolore autem ea et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit
nihil.', 'slack_user_id': 'Alias aut rerum fugiat exercitationem maiores.'},
'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea
et voluptatem minus aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id':
'Alias aut rerum fugiat exercitationem maiores.'}, 'incident_role_id':
'01FH5TZRWMNAFB0DZ23FD1TV96'}, {'assignee': {'email': 'Dolore autem ea et voluptatem minus
aut.', 'id': 'Ut doloribus porro et sit nihil.', 'slack_user_id': 'Alias aut rerum fugiat
exercitationem maiores.'}, 'incident_role_id': '01FH5TZRWMNAFB0DZ23FD1TV96'}],
'incident_type_id': 'Quidem amet.', 'name': 'Our database is sad', 'severity_id': 'Aut
quis.', 'summary': "Our database is really really sad, and we don't know why yet.",
'visibility': 'public'}.
Returns:
Response[IncidentsCreateResponseBody]
"""
return (
await asyncio_detailed(
client=client,
json_body=json_body,
)
).parsed
| 53.565056
| 102
| 0.642862
| 1,521
| 14,409
| 5.901381
| 0.084813
| 0.187166
| 0.176471
| 0.09893
| 0.900735
| 0.889817
| 0.875
| 0.875
| 0.865642
| 0.865642
| 0
| 0.076412
| 0.217087
| 14,409
| 268
| 103
| 53.764925
| 0.719262
| 0.391491
| 0
| 0.4125
| 0
| 0
| 0.02297
| 0.011881
| 0
| 0
| 0
| 0
| 0
| 1
| 0.0625
| false
| 0
| 0.075
| 0.0125
| 0.2375
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
54b8d9447bebf28ed75ec3f7f3b417b11c1559b1
| 123
|
py
|
Python
|
cortex/quickflat/__init__.py
|
shahdloo/pycortex
|
08693a048cc66d77ada1126129349c7c1ad46d92
|
[
"BSD-2-Clause"
] | null | null | null |
cortex/quickflat/__init__.py
|
shahdloo/pycortex
|
08693a048cc66d77ada1126129349c7c1ad46d92
|
[
"BSD-2-Clause"
] | null | null | null |
cortex/quickflat/__init__.py
|
shahdloo/pycortex
|
08693a048cc66d77ada1126129349c7c1ad46d92
|
[
"BSD-2-Clause"
] | null | null | null |
from .view import make_figure, make_png, make_svg, make_movie
from .utils import make_flatmap_image
from . import composite
| 41
| 61
| 0.837398
| 20
| 123
| 4.85
| 0.6
| 0.206186
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.113821
| 123
| 3
| 62
| 41
| 0.889908
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
49a94a46b413017e932a705bd3e9e75766131358
| 27
|
py
|
Python
|
corehq/apps/groups/tests/__init__.py
|
dslowikowski/commcare-hq
|
ad8885cf8dab69dc85cb64f37aeaf06106124797
|
[
"BSD-3-Clause"
] | 1
|
2015-02-10T23:26:39.000Z
|
2015-02-10T23:26:39.000Z
|
corehq/apps/groups/tests/__init__.py
|
SEL-Columbia/commcare-hq
|
992ee34a679c37f063f86200e6df5a197d5e3ff6
|
[
"BSD-3-Clause"
] | 1
|
2022-03-12T01:03:25.000Z
|
2022-03-12T01:03:25.000Z
|
corehq/apps/groups/tests/__init__.py
|
johan--/commcare-hq
|
86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd
|
[
"BSD-3-Clause"
] | null | null | null |
from .test_groups import *
| 13.5
| 26
| 0.777778
| 4
| 27
| 5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148148
| 27
| 1
| 27
| 27
| 0.869565
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
49ca3775c4ace47b8f4895667ad3fb168673bb92
| 69
|
py
|
Python
|
ChromaGAN/__init__.py
|
iamharsha1999/theganbibliotheca
|
c764af367e850555d04d6760b6bca756737670d3
|
[
"MIT"
] | 1
|
2021-02-03T19:46:35.000Z
|
2021-02-03T19:46:35.000Z
|
ChromaGAN/__init__.py
|
iamharsha1999/theganbibliotheca
|
c764af367e850555d04d6760b6bca756737670d3
|
[
"MIT"
] | null | null | null |
ChromaGAN/__init__.py
|
iamharsha1999/theganbibliotheca
|
c764af367e850555d04d6760b6bca756737670d3
|
[
"MIT"
] | null | null | null |
from .chromagan import *
from .train import *
from .dataset import *
| 23
| 24
| 0.73913
| 9
| 69
| 5.666667
| 0.555556
| 0.392157
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.173913
| 69
| 3
| 25
| 23
| 0.894737
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
b70432833f941faec451433f52cfa31b827f6075
| 41
|
py
|
Python
|
examples/Adafruit_Nokia_LCD/__init__.py
|
SincereXIA/Adafruit_Nokia_LCD
|
329e01bcb25bf9970afee10aad7f365381571819
|
[
"MIT"
] | 92
|
2015-01-23T09:38:40.000Z
|
2021-11-08T11:19:45.000Z
|
examples/Adafruit_Nokia_LCD/__init__.py
|
SincereXIA/Adafruit_Nokia_LCD
|
329e01bcb25bf9970afee10aad7f365381571819
|
[
"MIT"
] | 9
|
2015-01-31T14:38:23.000Z
|
2019-10-29T00:37:15.000Z
|
examples/Adafruit_Nokia_LCD/__init__.py
|
SincereXIA/Adafruit_Nokia_LCD
|
329e01bcb25bf9970afee10aad7f365381571819
|
[
"MIT"
] | 60
|
2015-03-11T06:58:17.000Z
|
2022-01-13T04:47:33.000Z
|
from Adafruit_Nokia_LCD.PCD8544 import *
| 20.5
| 40
| 0.853659
| 6
| 41
| 5.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.108108
| 0.097561
| 41
| 1
| 41
| 41
| 0.783784
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
b70c6421ff870b7076ebcad539233a16664173ad
| 149
|
py
|
Python
|
Exames/Exercicio9.py
|
alexandrebatista84/python-exercises
|
0cb2fc11da82d84c959d6bb861cb45ba357f6dab
|
[
"MIT"
] | null | null | null |
Exames/Exercicio9.py
|
alexandrebatista84/python-exercises
|
0cb2fc11da82d84c959d6bb861cb45ba357f6dab
|
[
"MIT"
] | 3
|
2017-10-18T07:49:36.000Z
|
2017-10-19T16:55:44.000Z
|
Exames/Exercicio9.py
|
alexandrebatista84/python-exercises
|
0cb2fc11da82d84c959d6bb861cb45ba357f6dab
|
[
"MIT"
] | null | null | null |
from functools import reduce
def soma_quadrados(l):
return reduce(lambda x,y: x+y,list(map(lambda x:x**2,l)))
print(soma_quadrados([1,2,3,4]))
| 21.285714
| 61
| 0.704698
| 29
| 149
| 3.551724
| 0.655172
| 0.252427
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.038168
| 0.120805
| 149
| 7
| 62
| 21.285714
| 0.748092
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0.25
| 0.75
| 0.25
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
3f78148d92d1bd015e9a278416b4ffa6275cd4cb
| 39
|
py
|
Python
|
groundstation/transfer/notification_handlers/__init__.py
|
richo/groundstation
|
7ed48dd355051ee6b71164fc801e3893c09d11db
|
[
"MIT"
] | 26
|
2015-06-18T20:17:07.000Z
|
2019-09-26T09:55:35.000Z
|
groundstation/transfer/notification_handlers/__init__.py
|
richo/groundstation
|
7ed48dd355051ee6b71164fc801e3893c09d11db
|
[
"MIT"
] | null | null | null |
groundstation/transfer/notification_handlers/__init__.py
|
richo/groundstation
|
7ed48dd355051ee6b71164fc801e3893c09d11db
|
[
"MIT"
] | 5
|
2015-07-20T01:52:47.000Z
|
2017-01-08T09:54:07.000Z
|
from newobject import handle_newobject
| 19.5
| 38
| 0.897436
| 5
| 39
| 6.8
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.102564
| 39
| 1
| 39
| 39
| 0.971429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
3f812e933ecc11fd05477c9daf2caeb2ee0bde6f
| 527
|
py
|
Python
|
SaveMD.py
|
htomtom/AZGomo
|
2160122897391ff7e74385b7451e070dd8bf9f78
|
[
"MIT"
] | 5
|
2021-12-07T12:57:40.000Z
|
2021-12-15T06:20:52.000Z
|
SaveMD.py
|
htomtom/AZGomo
|
2160122897391ff7e74385b7451e070dd8bf9f78
|
[
"MIT"
] | null | null | null |
SaveMD.py
|
htomtom/AZGomo
|
2160122897391ff7e74385b7451e070dd8bf9f78
|
[
"MIT"
] | 1
|
2021-12-07T13:01:42.000Z
|
2021-12-07T13:01:42.000Z
|
import RNG as RN_Gomoku
import sys
if(len(sys.argv)<2):
a0eng=RN_Gomoku.A0_ENG(64,"./RNG64.tf",1e-1/(2.0**3),10)
a0eng.a0_eng.save("RNG")
a0eng2=RN_Gomoku.A0_ENG(64,"./weights/RNG64.tf",1e-1/(2.0**3),10)
a0eng2.a0_eng.save("RNG_Old")
quit()
if(sys.argv[1]=="n"):
a0eng=RN_Gomoku.A0_ENG(64,"./RNG64.tf",1e-1/(2.0**3),10)
a0eng.a0_eng.save("RNG")
elif(sys.argv[1]=="o"):
a0eng2=RN_Gomoku.A0_ENG(64,"./weights/RNG64.tf",1e-1/(2.0**3),10)
a0eng2.a0_eng.save("RNG_Old")
else:
print("Error")
| 29.277778
| 69
| 0.626186
| 106
| 527
| 2.971698
| 0.301887
| 0.126984
| 0.126984
| 0.165079
| 0.736508
| 0.736508
| 0.736508
| 0.736508
| 0.736508
| 0.736508
| 0
| 0.143777
| 0.11575
| 527
| 18
| 70
| 29.277778
| 0.532189
| 0
| 0
| 0.5
| 0
| 0
| 0.157197
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.125
| 0
| 0.125
| 0.0625
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
3f8548a594ff8a416ecaa65b6a5d76128c7bf7d6
| 86,592
|
py
|
Python
|
assignment_student_portal/assignment_student_portal/main.py
|
agianchandani2018/ISP
|
d86a9dd622313294efc86899689c2eb579a901af
|
[
"MIT"
] | 1
|
2018-06-02T17:50:12.000Z
|
2018-06-02T17:50:12.000Z
|
assignment_student_portal/assignment_student_portal/main.py
|
agianchandani2018/ISP
|
d86a9dd622313294efc86899689c2eb579a901af
|
[
"MIT"
] | 1
|
2018-06-03T15:34:00.000Z
|
2018-06-04T15:50:36.000Z
|
assignment_student_portal/assignment_student_portal/main.py
|
agianchandani2018/ISP
|
d86a9dd622313294efc86899689c2eb579a901af
|
[
"MIT"
] | null | null | null |
from .models import *
from .authenticate import AuthorizationError
import time
import json
try:
from json.decoder import JSONDecodeError
except ImportError:
JSONDecodeError = ValueError
class Schoology:
_ROOT = 'https://api.schoology.com/v1/'
key = ''
secret = ''
limit = 20
start = 0
def __init__(self, schoology_auth):
if not schoology_auth.authorized:
raise AuthorizationError('Auth instance not authorized. Run authorize() after requesting authorization.')
self.key = schoology_auth.consumer_key
self.secret = schoology_auth.consumer_secret
self.schoology_auth = schoology_auth
def _get(self, path):
"""
GET data from a given endpoint.
:param path: Path (following API root) to endpoint.
:return: JSON response.
"""
try:
response = self.schoology_auth.oauth.get(url='%s%s?limit=%s' % (self._ROOT, path, self.limit), headers=self.schoology_auth._request_header(), auth=self.schoology_auth.oauth.auth)
return response.json()
except JSONDecodeError:
return {}
def _post(self, path, data):
"""
POST valid JSON to a given endpoint.
:param path: Path (following API root) to endpoint.
:param data: JSON data to POST.
:return: JSON response.
"""
try:
return self.schoology_auth.oauth.post(url='%s%s?limit=%s' % (self._ROOT, path, self.limit), json=data, headers=self.schoology_auth._request_header(), auth=self.schoology_auth.oauth.auth).json()
except JSONDecodeError:
return {}
def _put(self, path, data):
"""
PUT valid JSON to a given endpoint.
:param path: Path (following API root) to endpoint.
:param data: JSON data to PUT.
:return: JSON response.
"""
try:
return self.schoology_auth.oauth.put(url='%s%s?limit=%s' % (self._ROOT, path, self.limit), json=data, headers=self.schoology_auth._request_header(), auth=self.schoology_auth.oauth.auth).json()
except JSONDecodeError:
return {}
def _delete(self, path):
"""
Send a DELETE request to a given endpoint.
:param path: Path (following API root) to endpoint.
"""
return self.schoology_auth.oauth.delete(url='%s%s' % (self._ROOT, path), headers=self.schoology_auth._request_header(), auth=self.schoology_auth.oauth.auth)
def get_schools(self):
"""
Get data on all schools.
:return: List of school objects of which a user is aware.
"""
return [School(raw) for raw in self._get('schools')['school']]
def get_school(self, school_id):
"""
Get data on a school.
:return: School object with data on the requested school.
"""
return School(self._get('schools/%s' % school_id))
def create_school(self, school):
"""
Create a new school.
:param school: School object containing necessary fields.
:return: School object obtained from API.
"""
return School(self._post('schools', school.json()))
def edit_school(self, school_id, school):
"""
Edit a school.
:param school_id: ID of school to edit.
:param school: School object containing necessary fields.
:return: School object obtained from API.
"""
# TODO: Does this endpoint return anything?
self._put('schools/%s' % school_id, school.json())
def get_buildings(self, school_id):
"""
Get data on buildings in a given school.
:param school_id: ID of school whose buildings to get.
:return: List of building objects in that school.
"""
return [Building(raw) for raw in self._get('schools/%s/buildings' % school_id)]
# There is currently no endpoint for getting data on individual buildings.
# This is due in part to the oft-blurred line Schoology draws between schools and buildings.
def create_building(self, school_id, building):
"""
Create a new building.
:param building: Building object containing necessary fields.
:return: Building object obtained from API.
"""
return Building(self._post('schools/%s/buildings' % school_id, building.json()))
def get_self_user_info(self):
"""
Gets user info for yourself, if you have a current Schoology sessions
:return: Session object obtained from API.
"""
return Session(self._get('app-user-info'))
def get_me(self):
"""
Get data of the client using this method (Yourself).
:return: User object obtained from API. (Of yourself)
"""
return User(self._get('users/me'))
def get_users(self, inactive=False):
"""
Get data on all users.
:param inactive: Gets inactive users instead of normal ones.
:return: List of User objects.
"""
return [User(raw) for raw in self._get('users' + ('/inactive' if inactive else ''))['user']]
def get_user(self, user_id, inactive=False):
"""
Get data on a user.
:param user_id: ID of user to get data from.
:param inactive: Gets inactive users instead of normal ones.
:return: User object.
"""
return User(self._get(('users/' + ('inactive/' if inactive else '') + '%s') % user_id))
def create_user(self, user):
"""
Create a new user.
:param user: User object containing necessary fields.
:return: User object obtained from API.
"""
return User(self._post('users', user))
def create_users(self, users):
"""
Bulk create users.
:param users: A list of User objects.
:return: User objects obtained from API.
"""
return [User(raw) for raw in self._post('users', {'users': {'user': [user.json() for user in users]}})]
def update_user(self, user, user_id):
"""
Update an existing user.
:param user: User object containing necessary fields.
:param user_id: ID of user you wish to update.
:return: User object obtained from API.
"""
self._put('users/%s' % user_id, user)
def update_users(self, users):
"""
Bulk update users.
:param users: A list of users.
:return: User objects obtained from API.
"""
return [User(raw) for raw in self._put('users', {'users': {'user': [user.json() for user in users]}})]
def delete_user(self, user_id):
"""
Delete a user.
:param user_id: ID of user you wish to delete.
"""
self._delete('users/%s' % user_id)
def get_languages(self):
"""
Get data on all supported languages.
:return: A list of Language objects.
"""
return [Language(raw) for raw in self._get('users/languages')['language']]
def get_groups(self):
"""
Get data on all groups.
:return: List of Group objects.
"""
return [Group(raw) for raw in self._get('groups')['group']]
def get_group(self, group_id):
"""
Get data on a group.
:param group_id: ID of group on which to get data.
:return: Group object.
"""
return Group(self._get('groups/%s' % group_id))
def get_courses(self):
"""
Get data on all courses.
:return: List of Course objects.
"""
return [Course(raw) for raw in self._get('courses')['course']]
def get_course(self, course_id):
"""
Get data on a course.
:param course_id: ID of course on which to get data.
:return: Course object.
"""
return Course(self._get('courses/%s' % course_id))
def get_sections(self):
"""
Get data on all sections.
:return: List of Section objects.
"""
return [Section(raw) for raw in self._get('sections')['section']]
def get_section(self, section_id):
"""
Get data on a section.
:param section_id: ID of section on which to get data.
:return: Section object.
"""
return Section(self._get('sections/%s' % section_id))
def create_enrollment(self, enrollment, section_id=None, group_id=None):
"""
Helper function for creating an enrollment in any realm.
:param enrollment: Enrollment object to post to API.
:param *_id: ID of realm.
:return: Enrollment object recieved from API.
"""
if section_id:
return self.create_section_enrollment(enrollment, section_id)
elif group_id:
return self.create_group_enrollment(enrollment, group_id)
else:
raise TypeError('Realm id property required.')
def create_section_enrollment(self, enrollment, section_id):
return Enrollment(self._post('sections/%s/enrollments' % section_id, enrollment.json()))
def create_group_enrollment(self, enrollment, group_id):
return Enrollment(self._post('groups/%s/enrollments' % group_id, enrollment.json()))
def get_enrollments(self, section_id=None, group_id=None):
"""
Helper function to get enrollments in any realm. Realm will be decided based on named parameters passed.
:param *_id: ID of realm.
:return: List of User objects.
"""
if section_id:
return self.get_section_enrollments(section_id)
elif group_id:
return self.get_group_enrollments(group_id)
else:
raise TypeError('Realm id property required.')
def get_section_enrollments(self, section_id):
return [Enrollment(raw) for raw in self._get('sections/%s/enrollments' % section_id)['enrollment']]
def get_group_enrollments(self, group_id):
return [Enrollment(raw) for raw in self._get('groups/%s/enrollments' % group_id)['enrollment']]
# TODO: Do we need to provide the ID of the realm?
def join_section(self, access_code):
return Enrollment(self._post('sections/accesscode' % access_code, {'access_code': access_code}))
def join_group(self, access_code):
return Enrollment(self._post('sections/accesscode' % access_code, {'access_code': access_code}))
def create_enrollments(self, enrollments, section_id=None, group_id=None):
"""
Create multiple enrollments.
:param enrollments: List of Enrollment objects to post to API.
:param *_id: ID of realm.
:return: List of User objects.
"""
if section_id:
return self.create_section_enrollments(enrollments, section_id)
elif group_id:
return self.create_group_enrollments(enrollments, group_id)
else:
raise TypeError('Realm id property required.')
def create_section_enrollments(self, enrollments, section_id):
return [Enrollment(raw) for raw in self._post('sections/%s/enrollments' % section_id, {'enrollments': {'enrollment': [enrollment.json() for enrollment in enrollments]}})]
def create_group_enrollments(self, enrollments, group_id):
return [Enrollment(raw) for raw in self._post('groups/%s/enrollments' % group_id, {'enrollments': {'enrollment': [enrollment.json() for enrollment in enrollments]}})]
def update_enrollment(self, enrollment, group_id=None, section_id=None):
"""
Helper function for updating an enrollment.
Either group_id or section_id must be specified by name in calls to this method.
:param enrollment: Enrollment object containing new data.
:param *_id: ID of realm.
:return: List of Enrollment objects recieved from API.
"""
if section_id:
return self.update_section_enrollment(section_id, enrollment)
elif group_id:
return self.update_group_enrollment(group_id, enrollment)
else:
raise TypeError('Realm id property required.')
def update_section_enrollment(self, enrollment, section_id):
return update_section_enrollments(section_id, [enrollment])
def update_group_enrollment(self, enrollment, group_id):
return update_group_enrollments(group_id, [enrollment])
def update_section_enrollments(self, enrollments, section_id):
return [Enrollment(raw) for raw in self._put('sections/%s/enrollments' % section_id, {'enrollments': {'enrollment': [enrollment.json() for enrollment in enrollments]}})]
def update_group_enrollments(self, enrollments, group_id):
return [Enrollment(raw) for raw in self._put('groups/%s/enrollments' % group_id, {'enrollments': {'enrollment': [enrollment.json() for enrollment in enrollments]}})]
def delete_enrollment(self, enrollment_id, section_id=None, group_id=None):
"""
Delete an enrollment in any realm.
Either group_id or section_id must be specified by name in calls to this method.
:param enrollment_id: ID of enrollment to delete.
:param *_id: ID of realm.
"""
if section_id:
return self.delete_section_enrollment(section_id, enrollment_id)
elif group_id:
return self.delete_group_enrollment(group_id, enrollment_id)
else:
raise TypeError('Realm id property required.')
def delete_section_enrollment(self, enrollment_id, section_id):
self._delete('sections/%s/enrollments/%s' % (section_id, enrollment_id))
def delete_group_enrollment(self, enrollment_id, group_id):
self._delete('groups/%s/enrollments/%s' % (group_id, enrollment_id))
def delete_enrollments(self, enrollment_ids):
self._delete('enrollments?enrollment_ids=' + ','.join(enr))
# Course enrollments imports not implemented, similar effect can be obtained through extant methods
def get_events(self, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Get data on events in any realm.
:param *_id: ID of realm.
:return: List of Event objects.
"""
if district_id:
return self.get_district_events(district_id)
elif school_id:
return self.get_school_events(school_id)
elif user_id:
return self.get_user_events(user_id)
elif section_id:
return self.get_section_events(section_id)
elif group_id:
return self.get_group_events(group_id)
else:
raise TypeError('Realm id property required.')
def get_district_events(self, district_id):
return [Event(raw) for raw in self._get('districts/%s/events' % district_id)['event']]
def get_school_events(self, school_id):
return [Event(raw) for raw in self._get('schools/%s/events' % school_id)['event']]
def get_user_events(self, user_id):
return [Event(raw) for raw in self._get('users/%s/events' % user_id)['event']]
def get_section_events(self, section_id):
return [Event(raw) for raw in self._get('sections/%s/events' % section_id)['event']]
def get_group_events(self, group_id):
return [Event(raw) for raw in self._get('groups/%s/events' % group_id)['event']]
def create_event(self, event, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating a new event in any realm.
:param event: Event object.
:param *_id: ID of realm.
:return: Event object from API.
"""
if district_id:
return self.create_district_event(event, district_id)
elif school_id:
return self.create_school_event(event, school_id)
elif user_id:
return self.create_user_event(event, user_id)
elif section_id:
return self.create_section_event(event, section_id)
elif group_id:
return self.create_group_event(event, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_event(self, event, district_id):
return Event(self._post('districts/%s/events' % district_id, event.json()))
def create_school_event(self, event, school_id):
return Event(self._post('schools/%s/events' % school_id, event.json()))
def create_user_event(self, event, user_id):
return Event(self._post('users/%s/events' % user_id, event.json()))
def create_section_event(self, event, section_id):
return Event(self._post('sections/%s/events' % section_id, event.json()))
def create_group_event(self, event, group_id):
return Event(self._post('groups/%s/events' % group_id, event.json()))
def get_event(self, event_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Get data on an event in any realm.
:param event_id: ID of event on which to get data.
:param *_id: ID of realm.
:return: Event object.
"""
if district_id:
return self.get_district_event(event_id, district_id)
elif school_id:
return self.get_school_event(event_id, school_id)
elif user_id:
return self.get_user_event(event_id, user_id)
elif section_id:
return self.get_section_event(event_id, section_id)
elif group_id:
return self.get_group_event(event_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_event(self, event_id, district_id):
return Event(self._get('districts/%s/events/%s' % (district_id, event_id)))
def get_school_event(self, event_id, school_id):
return Event(self._get('schools/%s/events/%s' % (school_id, event_id)))
def get_user_event(self, event_id, user_id):
return Event(self._get('users/%s/events/%s' % (user_id, event_id)))
def get_section_event(self, event_id, section_id):
return Event(self._get('sections/%s/events/%s' % (section_id, event_id)))
def get_group_event(self, event_id, group_id):
return Event(self._get('groups/%s/events/%s' % (group_id, event_id)))
def update_event(self, event, event_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for updating individual events in any realm.
:param event_id: ID of event on which to get data.
:param *_id: ID of realm.
"""
if district_id:
self.update_district_event(event, event_id, district_id)
elif school_id:
self.update_school_event(event, event_id, school_id)
elif user_id:
self.update_user_event(event, event_id, user_id)
elif section_id:
self.update_section_event(event, event_id, section_id)
elif group_id:
self.update_group_event(event, event_id, group_id)
else:
raise TypeError('Realm id property required.')
def update_district_event(self, event, event_id, district_id):
self._put('districts/%s/events/%s' % (district_id, event.id), event.json())
def update_school_event(self, event, event_id, school_id):
self._put('schools/%s/events/%s' % (school_id, event.id), event.json())
def update_user_event(self, event, event_id, user_id):
self._put('users/%s/events/%s' % (user_id, event.id), event.json())
def update_section_event(self, event, event_id, section_id):
self._put('sections/%s/events/%s' % (section_id, event.id), event.json())
def update_group_event(self, event, event_id, group_id):
self._put('groups/%s/events/%s' % (group_id, event.id), event.json())
def delete_event(self, event_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Delete an event in any realm.
:param event_id: ID of event to delete.
:param *_id: ID of realm.
"""
if district_id:
self.delete_district_event(event_id, district_id)
elif school_id:
self.delete_school_event(event_id, school_id)
elif user_id:
self.delete_user_event(event_id, user_id)
elif section_id:
self.delete_section_event(event_id, section_id)
elif group_id:
self.delete_group_event(event_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_district_event(self, event_id, district_id):
self._delete('districts/%s/events/%s' % (district_id, event_id))
def delete_school_event(self, event_id, school_id):
self._delete('schools/%s/events/%s' % (school_id, event_id))
def delete_user_event(self, event_id, user_id):
self._delete('users/%s/events/%s' % (user_id, event_id))
def delete_section_event(self, event_id, section_id):
self._delete('sections/%s/events/%s' % (section_id, event_id))
def delete_group_event(self, event_id, group_id):
self._delete('groups/%s/events/%s' % (group_id, event_id))
def create_blog_post(self, post, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating a blog post in any realm.
:param post: BlogPost object to post in the given realm.
:param *_id: ID of realm.
:return: BlogPost object recieved from API.
"""
if district_id:
return self.create_district_blog_post(post, district_id)
elif school_id:
return self.create_school_blog_post(post, school_id)
elif user_id:
return self.create_user_blog_post(post, user_id)
elif section_id:
return self.create_section_blog_post(post, section_id)
elif group_id:
return self.create_group_blog_post(post, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_blog_post(self, post, district_id):
return BlogPost(self._post('districts/%s/posts' % district_id, post.json()))
def create_school_blog_post(self, post, school_id):
return BlogPost(self._post('schools/%s/posts' % school_id, post.json()))
def create_user_blog_post(self, post, user_id):
return BlogPost(self._post('users/%s/posts' % user_id, post.json()))
def create_section_blog_post(self, post, section_id):
return BlogPost(self._post('sections/%s/posts' % section_id, post.json()))
def create_group_blog_post(self, post, group_id):
return BlogPost(self._post('groups/%s/posts' % group_id, post.json()))
def get_blog_posts(self, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating blog posts in any realm.
:param *_id: ID of realm.
:return: List of BlogPost objects recieved from API.
"""
if district_id:
return self.get_district_blog_posts(district_id)
elif school_id:
return self.get_school_blog_posts(school_id)
elif user_id:
return self.get_user_blog_posts(user_id)
elif section_id:
return self.get_section_blog_posts(section_id)
elif group_id:
return self.get_group_blog_posts(group_id)
else:
raise TypeError('Realm id property required.')
def get_district_blog_posts(self, district_id):
return [BlogPost(raw) for raw in self._get('districts/%s/posts' % district_id)['post']]
def get_school_blog_posts(self, school_id):
return [BlogPost(raw) for raw in self._get('schools/%s/posts' % school_id)['post']]
def get_user_blog_posts(self, user_id):
return [BlogPost(raw) for raw in self._get('users/%s/posts' % user_id)['post']]
def get_section_blog_posts(self, section_id):
return [BlogPost(raw) for raw in self._get('sections/%s/posts' % section_id)['post']]
def get_group_blog_posts(self, group_id):
return [BlogPost(raw) for raw in self._get('groups/%s/posts' % group_id)['post']]
def get_blog_post(self, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Get data on a blog post in any realm.
:param *_id: ID of realm.
:return: List of BlogPost objects recieved from API.
"""
if district_id:
return self.get_district_blog_posts(post_id, district_id)
elif school_id:
return self.get_school_blog_posts(post_id, school_id)
elif user_id:
return self.get_user_blog_posts(post_id, user_id)
elif section_id:
return self.get_section_blog_posts(post_id, section_id)
elif group_id:
return self.get_group_blog_posts(post_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_blog_post(self, post_id, district_id):
return BlogPost(self._get('districts/%s/posts/%s' % (district_id, post_id)))
def get_school_blog_post(self, post_id, school_id):
return BlogPost(self._get('schools/%s/posts/%s' % (school_id, post_id)))
def get_user_blog_post(self, post_id, user_id):
return BlogPost(self._get('users/%s/posts/%s' % (user_id, post_id)))
def get_section_blog_post(self, post_id, section_id):
return BlogPost(self._get('sections/%s/posts/%s' % (section_id, post_id)))
def get_group_blog_post(self, post_id, group_id):
return BlogPost(self._get('groups/%s/posts/%s' % (group_id, post_id)))
def update_blog_post(self, post, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating blog posts in any realm.
:param *_id: ID of realm.
:return: List of BlogPost objects recieved from API.
"""
if district_id:
self.update_district_blog_post(post, district_id)
elif school_id:
self.update_school_blog_post(post, school_id)
elif user_id:
self.update_user_blog_post(post, user_id)
elif section_id:
self.update_section_blog_post(post, section_id)
elif group_id:
self.update_group_blog_post(post, group_id)
else:
raise TypeError('Realm id property required.')
def update_district_blog_post(self, post, district_id):
self._put('districts/%s/posts/%s' % (district_id, post.id), post.json())
def update_school_blog_post(self, post, school_id):
self._put('schools/%s/posts/%s' % (school_id, post.id), post.json())
def update_user_blog_post(self, post, user_id):
self._put('users/%s/posts/%s' % (user_id, post.id), post.json())
def update_section_blog_post(self, post, section_id):
self._put('sections/%s/posts/%s' % (section_id, post.id), post.json())
def update_group_blog_post(self, post, group_id):
self._put('groups/%s/posts/%s' % (group_id, post.id), post.json())
def delete_blog_post(self, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Delete blog posts in any realm.
:param *_id: ID of realm.
"""
if district_id:
self.delete_district_blog_post(post_id, district_id)
elif school_id:
self.delete_school_blog_post(post_id, school_id)
elif user_id:
self.delete_user_blog_post(post_id, user_id)
elif section_id:
self.delete_section_blog_post(post_id, section_id)
elif group_id:
self.delete_group_blog_post(post_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_district_blog_post(self, post_id, district_id):
self._delete('districts/%s/posts/%s' % (district_id, post_id))
def delete_school_blog_post(self, post_id, school_id):
self._delete('schools/%s/posts/%s' % (school_id, post_id))
def delete_user_blog_post(self, post_id, user_id):
self._delete('users/%s/posts/%s' % (user_id, post_id))
def delete_section_blog_post(self, post_id, section_id):
self._delete('sections/%s/posts/%s' % (section_id, post_id))
def delete_group_blog_post(self, post_id, group_id):
self._delete('groups/%s/posts/%s' % (group_id, post_id))
def create_blog_post_comment(self, comment, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating blog posts in any realm.
:param post: BlogPost object to post in the given realm.
:param *_id: ID of realm.
:return: BlogPostComment object recieved from API.
"""
if district_id:
return self.create_district_blog_post(comment, post_id, district_id)
elif school_id:
return self.create_school_blog_post(comment, post_id, school_id)
elif user_id:
return self.create_user_blog_post(comment, post_id, user_id)
elif section_id:
return self.create_section_blog_post(comment, post_id, section_id)
elif group_id:
return self.create_group_blog_post(comment, post_id, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_blog_post_comment(self, comment, post_id, district_id):
return BlogPostComment(self._post('districts/%s/posts/%s/comments' % (district_id, post_id), comment.json()))
def create_school_blog_post_comment(self, comment, post_id, school_id):
return BlogPostComment(self._post('schools/%s/posts/%s/comments' % (school_id, post_id), comment.json()))
def create_user_blog_post_comment(self, comment, post_id, user_id):
return BlogPostComment(self._post('users/%s/posts/%s/comments' % (user_id, post_id), comment.json()))
def create_section_blog_post_comment(self, comment, post_id, section_id):
return BlogPostComment(self._post('sections/%s/posts/%s/comments' % (section_id, post_id), comment.json()))
def create_group_blog_post_comment(self, comment, post_id, group_id):
return BlogPostComment(self._post('groups/%s/posts/%s/comments' % (group_id, post_id), comment.json()))
def get_blog_post_comments(self, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Get data on blog post comments in any realm.
:param *_id: ID of realm.
:return: List of BlogPostComment objects recieved from API.
"""
if district_id:
return self.get_district_blog_post_comments(post_id, district_id)
elif school_id:
return self.get_school_blog_post_comments(post_id, school_id)
elif user_id:
return self.get_user_blog_post_comments(post_id, user_id)
elif section_id:
return self.get_section_blog_post_comments(post_id, section_id)
elif group_id:
return self.get_group_blog_post_comments(post_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_blog_post_comments(self, post_id, district_id):
return [BlogPostComment(raw) for raw in self._get('districts/%s/posts/%s/comments' % (district_id, post_id))['comment']]
def get_school_blog_post_comments(self, post_id, school_id):
return [BlogPostComment(raw) for raw in self._get('schools/%s/posts/%s/comments' % (school_id, post_id))['comment']]
def get_user_blog_post_comments(self, post_id, user_id):
return [BlogPostComment(raw) for raw in self._get('users/%s/posts/%s/comments' % (user_id, post_id))['comment']]
def get_section_blog_post_comments(self, post_id, section_id):
return [BlogPostComment(raw) for raw in self._get('sections/%s/posts/%s/comments' % (section_id, post_id))['comment']]
def get_group_blog_post_comments(self, post_id, group_id):
return [BlogPostComment(raw) for raw in self._get('groups/%s/posts/%s/comments' % (group_id, post_id))['comment']]
def get_blog_post_comment(self, comment_id, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Get data on individual blog post comments in any realm.
:param comment_id: ID of the comment to fetch.
:param post_id: ID of the post on which the comment is written.
:param *_id: ID of realm.
:return: List of BlogPostComment objects recieved from API.
"""
if district_id:
return self.get_district_blog_post_comment(comment_id, post_id, district_id)
elif school_id:
return self.get_school_blog_post_comment(comment_id, post_id, school_id)
elif user_id:
return self.get_user_blog_post_comment(comment_id, post_id, user_id)
elif section_id:
return self.get_section_blog_post_comment(comment_id, post_id, section_id)
elif group_id:
return self.get_group_blog_post_comment(comment_id, post_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_blog_post_comment(self, comment_id, post_id, district_id):
return BlogPostComment(self._get('districts/%s/posts/%s/comments/%s' % (district_id, post_id, comment_id)))
def get_school_blog_post_comment(self, comment_id, post_id, school_id):
return BlogPostComment(self._get('schools/%s/posts/%s/comments/%s' % (school_id, post_id, comment_id)))
def get_user_blog_post_comment(self, comment_id, post_id, user_id):
return BlogPostComment(self._get('users/%s/posts/%s/comments/%s' % (user_id, post_id, comment_id)))
def get_section_blog_post_comment(self, comment_id, post_id, section_id):
return BlogPostComment(self._get('sections/%s/posts/%s/comments/%s' % (section_id, post_id, comment_id)))
def get_group_blog_post_comment(self, comment_id, post_id, group_id):
return BlogPostComment(self._get('groups/%s/posts/%s/comments/%s' % (group_id, post_id, comment_id)))
def delete_blog_post_comment(self, comment_id, post_id, district_id=None, school_id=None, user_id=None, section_id=None, group_id=None):
"""
Delete blog post comments in any realm.
:param comment_id: ID of comment to delete.
:param post_id: ID of the post on which the comment is written.
:param *_id: ID of realm.
"""
if district_id:
self.delete_district_blog_post_comment(comment_id, post_id, district_id)
elif school_id:
self.delete_school_blog_post_comment(comment_id, post_id, school_id)
elif user_id:
self.delete_user_blog_post_comment(comment_id, post_id, user_id)
elif section_id:
self.delete_section_blog_post_comment(comment_id, post_id, section_id)
elif group_id:
self.delete_group_blog_post_comment(comment_id, post_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_district_blog_post_comment(self, comment_id, post_id, district_id):
self._delete('districts/%s/posts/%s/comments/%s' % (district_id, post_id, comment_id))
def delete_school_blog_post_comment(self, comment_id, post_id, school_id):
self._delete('schools/%s/posts/%s/comments/%s' % (school_id, post_id, comment_id))
def delete_user_blog_post_comment(self, comment_id, post_id, user_id):
self._delete('users/%s/posts/%s/comments/%s' % (user_id, post_id, comment_id))
def delete_section_blog_post_comment(self, comment_id, post_id, section_id):
self._delete('sections/%s/posts/%s/comments/%s' % (section_id, post_id, comment_id))
def delete_group_blog_post_comment(self, comment_id, post_id, group_id):
self._delete('groups/%s/posts/%s/comments/%s' % (group_id, post_id, comment_id))
def get_discussions(self, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Get data on all discussions in any realm.
:param *_id: ID of realm.
:return: List of BlogPostComment objects recieved from API.
"""
if district_id:
return self.get_district_discussions(district_id)
elif school_id:
return self.get_school_discussions(school_id)
elif section_id:
return self.get_section_discussions(section_id)
elif group_id:
return self.get_group_discussions(group_id)
else:
raise TypeError('Realm id property required.')
def get_district_discussions(self, district_id):
return [Discussion(raw) for raw in self._get('districts/%s/discussions' % district_id)['discussion']]
def get_school_discussions(self, school_id):
return [Discussion(raw) for raw in self._get('schools/%s/discussions' % school_id)['discussion']]
def get_section_discussions(self, section_id):
return [Discussion(raw) for raw in self._get('sections/%s/discussions' % section_id)['discussion']]
def get_group_discussions(self, group_id):
return [Discussion(raw) for raw in self._get('groups/%s/discussions' % group_id)['discussion']]
def create_discussion(self, discussion, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Helper function for creating a discussion in any realm.
:param discussion: Discussion object to post.
:param *_id: ID of realm.
:return: Discussion object recieved from API.
"""
if district_id:
return self.create_district_discussion(discussion, district_id)
elif school_id:
return self.create_school_discussion(discussion, school_id)
elif section_id:
return self.create_section_discussion(discussion, section_id)
elif group_id:
return self.create_group_discussion(discussion, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_discussion(self, discussion, district_id):
return Discussion(self._post('districts/%s/discussions/%s' % (district_id, discussion_id), discussion.json()))
def create_school_discussion(self, discussion, school_id):
return Discussion(self._post('schools/%s/discussions/%s' % (school_id, discussion_id), discussion.json()))
def create_section_discussion(self, discussion, section_id):
return Discussion(self._post('sections/%s/discussions/%s' % (section_id, discussion_id), discussion.json()))
def create_group_discussion(self, discussion, group_id):
return Discussion(self._post('groups/%s/discussions/%s' % (group_id, discussion_id), discussion.json()))
def get_discussion(self, discussion_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Get data on individual discussion in any realm.
:param discussion_id: ID of the discussion on which to get data.
:param *_id: ID of realm.
:return: Discussion object recieved from API.
"""
if district_id:
return self.get_district_discussion(discussion_id, district_id)
elif school_id:
return self.get_school_discussion(discussion_id, school_id)
elif section_id:
return self.get_section_discussion(discussion_id, section_id)
elif group_id:
return self.get_group_discussion(discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_discussion(self, discussion_id, district_id):
return Discussion(self._get('districts/%s/discussions/%s' % (district_id, discussion_id)))
def get_school_discussion(self, discussion_id, school_id):
return Discussion(self._get('schools/%s/discussions/%s' % (school_id, discussion_id)))
def get_section_discussion(self, discussion_id, section_id):
return Discussion(self._get('sections/%s/discussions/%s' % (section_id, discussion_id)))
def get_group_discussion(self, discussion_id, group_id):
return Discussion(self._get('groups/%s/discussions/%s' % (group_id, discussion_id)))
def delete_discussion(self, comment_id, post_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Delete discussions in any realm.
:param comment_id: ID of the comment to delete.
:param post_id: ID of the post on which the comment is written.
:param *_id: ID of realm.
"""
if district_id:
self.delete_district_discussion(discussion_id, district_id)
elif school_id:
self.delete_school_discussion(discussion_id, school_id)
elif section_id:
self.delete_section_discussion(discussion_id, section_id)
elif group_id:
self.delete_group_discussion(discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_district_discussion(self, discussion_id, district_id):
self._delete('districts/%s/discussions/%s' % (district_id, discussion_id))
def delete_school_discussion(self, discussion_id, school_id):
self._delete('schools/%s/discussions/%s' % (school_id, discussion_id))
def delete_section_discussion(self, discussion_id, section_id):
self._delete('sections/%s/discussions/%s' % (section_id, discussion_id))
def delete_group_discussion(self, discussion_id, group_id):
self._delete('groups/%s/discussions/%s' % (group_id, discussion_id))
def create_discussion_reply(self, reply, discussion_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Helper function for creating discussion replies in any realm.
:param reply: DiscussionReply object to post on the discussion with the given ID.
:param *_id: ID of realm.
:return: BlogPost object recieved from API.
"""
if district_id:
return self.create_district_discussion_reply(reply, discussion_id, district_id)
elif school_id:
return self.create_school_discussion_reply(reply, discussion_id, school_id)
elif section_id:
return self.create_section_discussion_reply(reply, discussion_id, section_id)
elif group_id:
return self.create_group_discussion_reply(reply, discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_discussion_reply(self, reply, discussion_id, district_id):
return DiscussionReply(self._post('districts/%s/discussions/%s/comments' % (district_id, discussion_id), reply))
def create_school_discussion_reply(self, reply, discussion_id, school_id):
return DiscussionReply(self._post('schools/%s/discussions/%s/comments' % (school_id, discussion_id), reply))
def create_section_discussion_reply(self, reply, discussion_id, section_id):
return DiscussionReply(self._post('sections/%s/discussions/%s/comments' % (section_id, discussion_id), reply))
def create_group_discussion_reply(self, reply, discussion_id, group_id):
return DiscussionReply(self._post('groups/%s/discussions/%s/comments' % (group_id, discussion_id), reply))
def get_discussion_replies(self, discussion_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Get data on discussion replies in any realm.
:param reply: DiscussionReply object to post on the discussion with the given ID.
:param *_id: ID of realm.
:return: List of DiscussionReply objects recieved from API.
"""
if district_id:
return self.get_district_discussion_replies(discussion_id, district_id)
elif school_id:
return self.get_school_discussion_replies(discussion_id, school_id)
elif section_id:
return self.get_section_discussion_replies(discussion_id, section_id)
elif group_id:
return self.get_group_discussion_replies(discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_discussion_replies(self, discussion_id, district_id):
return [DiscussionReply(raw) for raw in self._get('districts/%s/discussions/%s/comments' % (district_id, discussion_id))['comment']]
def get_school_discussion_replies(self, discussion_id, school_id):
return [DiscussionReply(raw) for raw in self._get('schools/%s/discussions/%s/comments' % (school_id, discussion_id))['comment']]
def get_section_discussion_replies(self, discussion_id, section_id):
return [DiscussionReply(raw) for raw in self._get('sections/%s/discussions/%s/comments' % (section_id, discussion_id))['comment']]
def get_group_discussion_replies(self, discussion_id, group_id):
return [DiscussionReply(raw) for raw in self._get('groups/%s/discussions/%s/comments' % (group_id, discussion_id))['comment']]
def get_discussion_reply(self, reply_id, discussion_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Get individual discussion replies in any realm.
:param comment_id: ID of the reply to get.
:param discussion_id: ID of the discussion on which the reply is written.
:param *_id: ID of realm.
"""
if district_id:
return self.get_district_discussion_reply(reply_id, discussion_id, district_id)
elif school_id:
return self.get_school_discussion_reply(reply_id, discussion_id, school_id)
elif user_id:
return self.get_user_discussion_reply(reply_id, discussion_id, user_id)
elif section_id:
return self.get_section_discussion_reply(reply_id, discussion_id, section_id)
elif group_id:
return self.get_group_discussion_reply(reply_id, discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_district_discussion_reply(self, reply_id, discussion_id, district_id):
return DiscussionReply(self._get('districts/%s/discussions/%s/comments/%s' % (district_id, discussion_id, reply_id)))
def get_school_discussion_reply(self, reply_id, discussion_id, school_id):
return DiscussionReply(self._get('schools/%s/discussions/%s/comments/%s' % (school_id, discussion_id, reply_id)))
def get_section_discussion_reply(self, reply_id, discussion_id, section_id):
return DiscussionReply(self._get('sections/%s/discussions/%s/comments/%s' % (section_id, discussion_id, reply_id)))
def get_group_discussion_reply(self, reply_id, discussion_id, group_id):
return DiscussionReply(self._get('groups/%s/discussions/%s/comments/%s' % (group_id, discussion_id, reply_id)))
def delete_discussion_reply(self, reply_id, discussion_id, district_id=None, school_id=None, section_id=None, group_id=None):
"""
Delete blog post comments in any realm.
:param comment_id: ID of the comment to delete.
:param post_id: ID of the post on which the comment is written.
:param *_id: ID of realm.
"""
if district_id:
self.delete_district_discussion_reply(reply_id, discussion_id, district_id)
elif school_id:
self.delete_school_discussion_reply(reply_id, discussion_id, school_id)
elif section_id:
self.delete_section_discussion_reply(reply_id, discussion_id, section_id)
elif group_id:
self.delete_group_discussion_reply(reply_id, discussion_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_district_discussion_reply(self, reply_id, discussion_id, district_id):
self._delete('districts/%s/discussions/%s/comments/%s' % (district_id, discussion_id, reply_id))
def delete_school_discussion_reply(self, reply_id, discussion_id, school_id):
self._delete('schools/%s/discussions/%s/comments/%s' % (school_id, discussion_id, reply_id))
def delete_section_discussion_reply(self, reply_id, discussion_id, section_id):
self._delete('sections/%s/discussions/%s/comments/%s' % (section_id, discussion_id, reply_id))
def delete_group_discussion_reply(self, reply_id, discussion_id, group_id):
self._delete('groups/%s/discussions/%s/comments/%s' % (group_id, discussion_id, reply_id))
def create_update(self, update, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating an update in any realm.
:param update: Update object to post.
:param *_id: ID of realm.
"""
if user_id:
self.create_district_update(update, district_id)
elif section_id:
self.create_school_update(update, school_id)
elif group_id:
self.create_group_update(update, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_update(update, district_id):
return Update(self._post('districts/%s/updates' % district_id, update.json()))
def create_section_update(update, section_id):
return Update(self._post('sections/%s/updates' % section_id, update.json()))
def create_group_update(update, group_id):
return Update(self._post('groups/%s/updates' % group_id, update.json()))
def get_updates(self, user_id=None, section_id=None, group_id=None):
"""
Get updates in any realm.
:param *_id: ID of realm.
"""
if user_id:
self.get_user_updates(user_id)
elif section_id:
self.get_user_updates(section_id)
elif group_id:
self.get_user_updates(group_id)
else:
raise TypeError('Realm id property required.')
def get_user_updates(self, user_id):
return [Update(raw) for raw in self._get('users/%s/updates' % user_id)['update']]
def get_section_updates(self, section_id):
return [Update(raw) for raw in self._get('sections/%s/updates' % section_id)['update']]
def get_group_updates(self, group_id):
return [Update(raw) for raw in self._get('groups/%s/updates' % group_id)['update']]
def get_feed(self):
"""
Get update feed for the current user.
Use this function to see what's on the user's home feed.
Theoretically, users/[user ID]/updates could be used as an alternative to this.
:return: List of recent updates.
"""
return [Update(raw) for raw in self._get('recent')['update']]
def get_update(self, update_id, user_id=None, section_id=None, group_id=None):
"""
Get updates in any realm.
:param *_id: ID of realm.
"""
if user_id:
self.get_user_update(update_id, district_id)
elif section_id:
self.get_section_update(update_id, section_id)
elif group_id:
self.get_group_update(update_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_user_update(self, update_id, user_id):
return Update(self._get('users/%s/updates/%s' % (user_id, update_id)))
def get_section_update(self, update_id, section_id):
return Update(self._get('sections/%s/updates/%s' % (section_id, update_id)))
def get_group_update(self, update_id, group_id):
return Update(self._get('groups/%s/updates/%s' % (group_id, update_id)))
def delete_update(self, update_id, user_id=None, section_id=None, group_id=None):
"""
Delete an update in any realm.
:param update_id: ID of update to delete.
:param *_id: ID of realm.
"""
if user_id:
self.delete_user_update(update_id, district_id)
elif section_id:
self.delete_section_update(update_id, section_id)
elif group_id:
self.delete_group_update(update_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_user_update(self, update_id, user_id):
return Update(self._delete('users/%s/updates/%s' % (user_id, update_id)))
def delete_section_update(self, update_id, section_id):
return Update(self._delete('sections/%s/updates/%s' % (section_id, update_id)))
def delete_group_update(self, update_id, group_id):
return Update(self._delete('groups/%s/updates/%s' % (group_id, update_id)))
def update_update(self, update, user_id=None, section_id=None, group_id=None):
"""
Helper function for updating an update in any realm.
:param update: Update object to post.
:param *_id: ID of realm.
"""
if user_id:
return self.update_district_update(update, district_id)
elif section_id:
return self.update_section_update(update, section_id)
elif group_id:
return self.update_group_update(update, group_id)
else:
raise TypeError('Realm id property required.')
def update_district_update(update, district_id):
return Update(self._put('districts/%s/updates' % district_id, update.json()))
def update_section_update(update, section_id):
return Update(self._put('sections/%s/updates' % section_id, update.json()))
def update_group_update(update, group_id):
return Update(self._put('groups/%s/updates' % group_id, update.json()))
def create_update_comment(self, comment, update_id, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating a comment on an update in any realm.
:param comment: UpdateComment object to post.
:param update_id: ID of update on which to create comment.
:param *_id: ID of realm.
"""
if user_id:
return self.create_user_update_comment(comment, update_id, district_id)
elif section_id:
return self.create_section_update_comment(comment, update_id, section_id)
elif group_id:
return self.create_group_update_comment(comment, update_id, group_id)
else:
raise TypeError('Realm id property required.')
def create_district_update(update, district_id):
return Update(self._post('districts/%s/updates' % district_id, comment.json()))
def create_section_update(update, section_id):
return Update(self._post('sections/%s/updates' % section_id, comment.json()))
def create_group_update(update, group_id):
return Update(self._post('groups/%s/updates' % group_id, comment.json()))
def get_update_comments(self, comment, update_id, user_id=None, section_id=None, group_id=None):
"""
Helper function for creating a comment on an update in any realm.
:param update_id: ID of update from which to get comments.
:param *_id: ID of realm.
"""
if user_id:
return self.get_user_update_comments(update_id, district_id)
elif section_id:
return self.get_section_update_comments(update_id, section_id)
elif group_id:
return self.get_group_update_comments(update_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_user_update_comments(self, update_id, user_id):
return [UpdateComment(raw) for raw in self._get('users/%s/updates/%s/comments' % (user_id, update_id))['comment']]
def get_section_update_comments(self, update_id, section_id):
return [UpdateComment(raw) for raw in self._get('sections/%s/updates/%s/comments' % (section_id, update_id))['comment']]
def get_group_update_comments(self, update_id, group_id):
return [UpdateComment(raw) for raw in self._get('groups/%s/updates/%s/comments' % (group_id, update_id))['comment']]
def get_update_comment(self, comment_id, update_id, user_id=None, section_id=None, group_id=None):
"""
Get data on an update comment in any realm.
:param comment_id: ID of comment on which to get data.
:param update_id: ID of update on which to create comment.
:param *_id: ID of realm.
"""
if user_id:
return self.get_user_update_comment(comment_id, update_id, district_id)
elif section_id:
return self.get_section_update_comment(comment_id, update_id, section_id)
elif group_id:
return self.get_group_update_comment(comment_id, update_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_user_update_comment(self, comment_id, update_id, user_id):
return UpdateComment(self._get('users/%s/updates/%s/comments/%s' % (user_id, update_id, comment_id)))
def get_section_update_comment(self, comment_id, update_id, section_id):
return UpdateComment(self._get('sections/%s/updates/%s/comments/%s' % (section_id, update_id, comment_id)))
def get_group_update_comment(self, comment_id, update_id, group_id):
return UpdateComment(self._get('groups/%s/updates/%s/comments/%s' % (group_id, update_id, comment_id)))
def delete_update_comment(self, comment_id, update_id, user_id=None, section_id=None, group_id=None):
"""
Get data on an update comment in any realm.
:param comment_id: ID of comment on which to get data.
:param update_id: ID of update on which to create comment.
:param *_id: ID of realm.
"""
if user_id:
self.delete_user_update_comment(comment_id, update_id, district_id)
elif section_id:
self.delete_section_update_comment(comment_id, update_id, section_id)
elif group_id:
self.delete_group_update_comment(comment_id, update_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_user_update_comment(self, comment_id, update_id, user_id):
self._delete('users/%s/updates/%s/comments/%s' % (user_id, update_id, comment_id))
def delete_section_update_comment(self, comment_id, update_id, section_id):
self._delete('sections/%s/updates/%s/comments/%s' % (section_id, update_id, comment_id))
def delete_group_update_comment(self, comment_id, update_id, group_id):
self._delete('groups/%s/updates/%s/comments/%s' % (group_id, update_id, comment_id))
# TODO: Implement Reminder requests
# It's unclear what endpoints we should use
def create_media_album(self, album, section_id=None, group_id=None):
"""
Get data on an update comment in any realm.
:param album: Album object to post to API.
:param *_id: ID of realm.
"""
if section_id:
return self.create_section_media_album(album, section)
elif group_id:
return self.create_group_media_album(album, group_id)
else:
raise TypeError('Realm id property required.')
def create_section_media_album(self, album, section_id):
return MediaAlbum(self._post('sections/%s/albums' % section_id, album.json()))
def create_group_media_album(self, album, group_id):
return MediaAlbum(self._post('groups/%s/albums' % group_id, album.json()))
def get_media_albums(self, section_id=None, group_id=None):
"""
Get data on media albums in any realm.
:param *_id: ID of realm.
:return: List of MediaAlbum objects.
"""
if section_id:
return self.get_school_media_albums(section_id)
elif group_id:
return self.get_group_media_albums(group_id)
else:
raise TypeError('Realm id property required.')
def get_section_media_albums(self, section_id):
return [MediaAlbum(raw) for raw in self._get('sections/%s/albums' % section_id)['album']]
def get_group_media_albums(self, group_id):
return [MediaAlbum(raw) for raw in self._get('groups/%s/albums' % group_id)['album']]
def get_media_album(self, album_id, section_id=None, group_id=None):
"""
Get data on a media album in any realm.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
return self.get_section_media_album(album_id, section_id)
elif group_id:
return self.get_group_media_album(album_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_section_media_album(self, album_id, section_id):
return MediaAlbum(self._get('sections/%s/albums/%s' % (section_id, album_id)))
def get_group_media_album(self, album_id, group_id):
return MediaAlbum(self._get('groups/%s/albums/%s' % (group_id, album_id)))
def update_media_album(self, album, section_id=None, group_id=None):
"""
Helper function for updating amedia album in any realm.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
return self.update_section_media_album(album_id, section_id)
elif group_id:
return self.update_group_media_album(album_id, group_id)
else:
raise TypeError('Realm id property required.')
def update_section_media_album(self, album_id, section_id):
return MediaAlbum(self._get('sections/%s/albums/%s' % (section_id, album_id)))
def update_group_media_album(self, album_id, group_id):
return MediaAlbum(self._get('groups/%s/albums/%s' % (group_id, album_id)))
def delete_media_album(self, album, section_id=None, group_id=None):
"""
Delete amedia album in any realm.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
self.delete_section_media_album(album_id, section_id)
elif group_id:
self.delete_group_media_album(album_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_section_media_album(self, album_id, section_id):
self._delete('sections/%s/albums/%s' % (section_id, album_id))
def delete_group_media_album(self, album_id, group_id):
self._delete('groups/%s/albums/%s' % (group_id, album_id))
def get_media_album_content(self, content_id, album_id, section_id=None, group_id=None):
"""
Get data on a media item from an album in any realm.
Note: We could use the realm-ambiguous /album/[id] for this, but as of 2/15/15
that endpoint is no longer maintained. For forward-compatibility, it's better to deal
with this request as we do others.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
self.get_section_media_album_content(content_id, album_id, section_id)
elif group_id:
self.get_group_media_album_content(content_id, album_id, group_id)
else:
raise TypeError('Realm id property required.')
def get_section_media_album_content(self, content_id, album_id, section_id):
return Media(self._get('sections/%s/albums/%s/content/%s' % (section_id, album_id, content_id)))
def get_group_media_album_content(self, content_id, album_id, group_id):
return Media(self._get('groups/%s/albums/%s/content/%s' % (group_id, album_id, content_id)))
def update_media_album_content(self, content, content_id, album_id, section_id=None, group_id=None):
"""
Helper function for updating a media item from an album in any realm.
Note: We could use the realm-ambiguous /album/[id] for this, but as of 2/15/15
that endpoint is no longer maintained. For forward-compatibility, it's better to deal
with this request as we do others.
:param content: Content object containing data to update.
:param content_id: ID of content to update.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
self.update_section_media_album_content(content, content_id, album_id, section_id)
elif group_id:
self.update_group_media_album_content(content, content_id, album_id, group_id)
else:
raise TypeError('Realm id property required.')
def update_section_media_album_content(self, content, content_id, album_id, section_id):
self._put('sections/%s/albums/%s/content/%s' % (section_id, album_id, content_id), content.json())
def update_group_media_album_content(self, content, content_id, album_id, group_id):
self._put('groups/%s/albums/%s/content/%s' % (group_id, album_id, content_id), content.json())
def create_media_album_content(self, content, content_id, album_id, section_id=None, group_id=None):
"""
Helper function for creating a media item in an album in any realm.
Note: We could use the realm-ambiguous /album/[id] for this, but as of 2/15/15
that endpoint is no longer maintained. For forward-compatibility, it's better to deal
with this request as we do others.
:param content: Content object containing data to update.
:param content_id: ID of content to update.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
self.create_section_media_album_content(content, content_id, album_id, section_id)
elif group_id:
self.create_group_media_album_content(content, content_id, album_id, group_id)
else:
raise TypeError('Realm id property required.')
def create_section_media_album_content(self, content, content_id, album_id, section_id):
return Media(self._post('sections/%s/albums/%s/content' % (section_id, album_id), content.json()))
def create_group_media_album_content(self, content, content_id, album_id, group_id):
return Media(self._post('groups/%s/albums/%s/content' % (group_id, album_id), content.json()))
def delete_media_album_content(self, content_id, album_id, section_id=None, group_id=None):
"""
Helper function for updating a media item from an album in any realm.
Note: We could use the realm-ambiguous /album/[id] for this, but as of 2/15/15
that endpoint is no longer maintained. For forward-compatibility, it's better to deal
with this request as we do others.
:param content: Content object containing data to update.
:param content_id: ID of content to update.
:param *_id: ID of realm.
:return: MediaAlbum object.
"""
if section_id:
self.delete_section_media_album_content(content_id, album_id, section_id)
elif group_id:
self.delete_group_media_album_content(content_id, album_id, group_id)
else:
raise TypeError('Realm id property required.')
def delete_section_media_album_content(self, content_id, album_id, section_id):
self._delete('sections/%s/albums/%s/content/%s' % (section_id, album_id, content_id))
def delete_group_media_album_content(self, content_id, album_id, group_id):
self._delete('groups/%s/albums/%s/content/%s' % (group_id, album_id, content_id))
def create_document(self, document, section_id=None, group_id=None):
"""
Helper function for creating a document in any realm.
:param document: Document object to post to API.
:param *_id: ID of realm.
"""
if school_id:
return self.create_section_media_album(document, school_id)
if section_id:
return self.create_section_media_album(document, section_id)
else:
raise TypeError('Realm id property required.')
def create_school_media_album(self, document, school_id):
return Document(self._post('schools/%s/documents' % school_id, document.json()))
def create_section_media_album(self, document, section_id):
return Document(self._post('sections/%s/documents' % section_id, document.json()))
def get_documents(self, section_id=None, group_id=None):
"""
Helper function for creating a document in any realm.
:param document: Document object to post to API.
:param *_id: ID of realm.
"""
if school_id:
return self.get_school_documents(school_id)
if section_id:
return self.get_section_documents(section_id)
else:
raise TypeError('Realm id property required.')
def get_school_documents(self, school_id):
return [Document(raw) for raw in self._post('schools/%s/documents' % school_id)['document']]
def get_section_documents(self, section_id):
return [Document(raw) for raw in self._post('sections/%s/documents' % section_id)['document']]
def get_document(self, document_id, section_id=None, group_id=None):
"""
Get data on a document in any realm.
:param document: Document object to post to API.
:param *_id: ID of realm.
"""
if school_id:
return self.get_school_document(document_id, school_id)
if section_id:
return self.get_section_document(document_id, section_id)
else:
raise TypeError('Realm id property required.')
def get_school_document(self, document_id, school_id):
return Document(self._post('schools/%s/documents/%s' % (school_id, document_id)))
def get_section_document(self, document_id, section_id):
return Document(self._post('sections/%s/documents/%s' % (section_id, document_id)))
def update_document(self, document, document_id, section_id=None, group_id=None):
"""
Helper function for updating adocument in any realm.
:param document: Document object to post to API.
:param *_id: ID of realm.
"""
if school_id:
self.update_school_document(document, document_id, school_id)
if section_id:
self.update_section_document(document, document_id, section_id)
else:
raise TypeError('Realm id property required.')
def update_school_document(self, document, document_id, school_id):
self._put('schools/%s/documents/%s' % (school_id, document_id), document.json())
def update_section_document(self, document, document_id, section_id):
self._put('sections/%s/documents/%s' % (section_id, document_id), document.json())
def delete_document(self, document_id, section_id=None, group_id=None):
"""
Delete adocument in any realm.
:param document_id: ID of document to delete.
:param *_id: ID of realm.
"""
if school_id:
self.delete_school_document(document_id, school_id)
if section_id:
self.delete_section_document(document_id, section_id)
else:
raise TypeError('Realm id property required.')
def delete_school_document(self, document_id, school_id):
self._put('schools/%s/documents/%s' % (school_id, document_id))
def delete_section_document(self, document_id, section_id):
self._put('sections/%s/documents/%s' % (section_id, document_id))
def get_grading_scale(self, section_id):
"""
Get data on the grading scale used in a course section.
The documentation on this endpoint is incorrect, a single object is returned rather than a list.
:param section_id: ID of section whose grading scale to get data on.
:return: GradingScale object.
"""
return GradingScale(self._get('sections/%s/grading_scales' % section_id))
def get_rubrics(self, section_id):
"""
Get list of rubrics used in a given course section.
:param section_id: ID of section from which to get rubrics.
:return: List of Rubric objects.
"""
return [Rubric(raw) for raw in self._get('sections/%s/grading_rubrics' % section_id)['grading_rubric']]
def get_rubric(self, rubric_id, section_id):
"""
Get data on a rubric.
:param rubric_id: ID of rubric on which to get data.
:param section_id: ID of section in which rubric is used.
"""
return Rubric(self._get('sections/%s/grading_rubrics/%s' % (section_id, rubric_id)))
def create_grading_categories(self, categories, section_id):
"""
Create multiple grading categories.
:param categories: List of GradingCategory objects to create.
:param section_id: ID of section in which to create categories.
"""
return [GradingCategory(raw) for raw in self._put('sections/%s/grading_categories' % section_id, {'grading_categories': {'grading_category': [category.json() for category in categories]}})['grading_category']]
def get_grading_categories(self, section_id):
"""
Get a list of grading categories in a course section.
:param section_id: ID of section whose categories to get.
"""
return [GradingCategory(raw) for raw in self._get('sections/%s/grading_categories' % section_id)['grading_category']]
def get_grading_category(self, category_id, section_id):
"""
Get agrading category in a course section.
:param category_id: ID of category.
:param section_id: ID of category's section.
"""
return GradingCategory(self._get('sections/%s/grading_categories/%s' % (section_id, category_id)))
def update_grading_category(self, category, section_id):
"""
Get data on a grading category in a course section.
:param category: Category object to update.
:param section_id: ID of category's section.
:return: GradingCategory object recieved from API.
"""
return self.create_grading_categories([category], section_id)[0]
def create_grading_categories(self, categories, section_id):
"""
Update multiple grading categories.
:param categories: List of GradingCategory objects to create.
:param section_id: ID of section in which to create categories.
"""
return [GradingCategory(raw) for raw in self._post('sections/%s/grading_categories' % section_id, {'grading_categories': {'grading_category': [category.json() for category in categories]}})['grading_category']]
def delete_grading_category(self, category_id, section_id):
"""
Delete agrading category in a course section.
:param category_id: ID of category.
:param section_id: ID of category's section.
"""
self._delete('sections/%s/grading_categories/%s' % (section_id, category_id))
def create_grading_groups(self, groups, section_id):
"""
Create multiple grading groups.
:param groups: List of GradingGroup objects to create.
:param section_id: ID of section in which to create groups.
"""
return [GradingGroup(raw) for raw in self._put('sections/%s/grading_groups' % section_id, {'grading_groups': {'grading_group': [group.json() for group in groups]}})['grading_group']]
def get_grading_groups(self, section_id):
"""
Get a list of grading groups in a course section.
:param section_id: ID of section whose groups to get.
"""
return [GradingGroup(raw) for raw in self._get('sections/%s/grading_groups' % section_id)['grading_group']]
def get_grading_group(self, group_id, section_id):
"""
Get a grading group in a course section.
:param group_id: ID of group.
:param section_id: ID of group's section.
"""
return GradingGroup(self._get('sections/%s/grading_groups/%s' % (section_id, group_id)))
def update_grading_group(self, group, section_id):
"""
Get data on a grading group in a course section.
:param group: Group object to update.
:param section_id: ID of group's section.
:return: GradingGroup object recieved from API.
"""
return self.create_grading_groups([group], section_id)[0]
def create_grading_groups(self, groups, section_id):
"""
Create multiple grading groups.
:param groups: List of GradingGroup objects to create.
:param section_id: ID of section in which to create groups.
"""
return [GradingGroup(raw) for raw in self._post('sections/%s/grading_groups' % section_id, {'grading_groups': {'grading_group': [group.json() for group in groups]}})['grading_group']]
def delete_grading_group(self, group_id, section_id):
"""
Delete agrading group in a course section.
:param group_id: ID of group.
:param section_id: ID of group's section.
"""
self._delete('sections/%s/grading_groups/%s' % (section_id, group_id))
def get_assignments(self, section_id):
return [Assignment(raw) for raw in self._get('sections/%s/assignments' % section_id)['assignment']]
def get_assignment(self, section_id, assignment_id):
return Assignment(self._get('sections/%s/assignments/%s' % (section_id, assignment_id)))
def get_assignment_comments(self, section_id, assignment_id):
return [Assignment(raw) for raw in self._get('sections/%s/assignments/%s/comments' % (section_id, assignment_id))['comment']]
def get_assignment_comment(self, section_id, assignment_id, comment_id):
return Assignment(self._get('sections/%s/assignments/%s' % (section_id, assignment_id)))
# TODO: Support Grades
# TODO: Support Attendance
# TODO: Support Submissions
# TODO: Support Course Content Folders
# TODO: Support Pages
# TODO: Support SCORM Packages
# TODO: Support Web Content Package
# TODO: Support Completion
def get_friend_requests(self, user_id):
return [FriendRequest(raw) for raw in self._get('users/%s/requests/friends' % user_id)['request']]
def get_friend_request(self, user_id, request_id):
return FriendRequest(self._get('users/%s/requests/friends/%s' % (user_id, request_id)))
def get_user_section_invites(self, user_id):
return [Invite(raw) for raw in self._get('users/%s/invites/sections' % user_id)['invite']]
def get_user_group_invites(self, user_id):
return [Invite(raw) for raw in self._get('users/%s/invites/groups' % user_id)['invite']]
def get_user_section_invite(self, user_id, invite_id):
return Invite(self._get('users/%s/invites/sections/%s' % (user_id, invite_id)))
def get_user_group_invite(self, user_id, invite_id):
return Invite(self._get('users/%s/invites/groups/%s' % (user_id, invite_id)))
def get_user_network(self, user_id):
return [User(raw) for raw in self._get('users/%s/network' % user_id)['users']]
def get_user_grades(self, user_id):
return [Grade(raw) for raw in self._get('users/%s/grades' % user_id)['section']]
def get_user_sections(self, user_id):
return [Section(raw) for raw in self._get('users/%s/sections' % user_id)['section']]
def get_user_groups(self, user_id):
return [Group(raw) for raw in self._get('users/%s/groups' % user_id)['group']]
# TODO: Implement get_user_requests
# TODO: Implement get_user_invites
# TODO: Implement get_user_external_id
# TODO: Implement get_grading_periods and get_grading_period
def get_roles(self):
return [Role(raw) for raw in self._get('roles')['role']]
def get_role(self, role_id):
return Role(self._get('roles/%s' % role_id))
def get_messages(self):
return [MessageThread(raw) for raw in self._get('messages')['message']]
def get_sent_messages(self):
return [MessageThread(raw) for raw in self._get('messages/sent')['message']]
def get_inbox_messages(self):
return [MessageThread(raw) for raw in self._get('messages/inbox')['message']]
def get_message(self, message_id):
"""
Fetch data on a specific message thread.
Note: The endpoints messages/inbox/[message id] and messages/sent/[message id] can be used for this with the same result. Odd that the API would be set up this way.
:param message_id: ID of the message thread desired.
:return: list of messages in that thread.
"""
return [Message(raw) for raw in self._get('messages/inbox/%s' % message_id)['message']]
def create_message(self, message):
"""
Create a new message.
:param message: Message object to create.
"""
if isinstance(message.recipient_ids, list):
message.recipient_ids = ','.join(message.recipient_ids)
return Message(self._post('messages', message.json()))
def send_message(self, subject, content, user_ids):
"""
Helper function for sending messages.
:param subject: A string holding the subject of a message.
:param content: A string holding the body of a message.
:param user_ids: A list of IDs of users to which to send the message.
"""
return self.create_message(Message({'subject': subject, 'message': content, 'recipient_ids': user_ids}))
# TODO: Implement resource collections, resource templates
def _like(self, path):
"""
Post a like request.
:param path: The path with values to POST to.
:return: Number of likes on the object.
"""
try:
return self._post(path, {'like_action': True})['likes']
except TypeError:
raise NoDifferenceError('You have already liked this post.')
def _unlike(self, path):
"""
Post an unlike request.
:param path: The path with values to POST to.
:return: Number of likes on the object.
"""
try:
return self._post(path, {'like_action': False})['likes']
except TypeError:
raise NoDifferenceError('You have already unliked this post.')
def like(self, id):
"""
Like an object.
:param id: ID of object to like.
:return: Number of likes on the object.
"""
return self._like('like/%s' % id)
def unlike(self, id):
"""
UNlike an object.
:param id: ID of object to unlike.
:return: Number of likes on the object.
"""
return self._unlike('like/%s' % id)
def get_likes(self, id):
"""
Get all users who have liked an object.
:param id: ID of object to check likes of.
:return: List of users who have liked an object.
"""
return [User(raw) for raw in self._get('like/%s' % id)['users']]
def like_comment(self, id, comment_id):
"""
Like a comment on an object.
:param id: ID of object on which the comment was written.
:param comment_id: ID of comment to like.
"""
return self._like('like/%s/comment/%s' % (id, comment_id))
def unlike_comment(self, id, comment_id):
"""
UNlike a comment on an object.
:param id: ID of object on which the comment was written.
:param comment_id: ID of comment to unlike.
"""
return self._unlike('like/%s/comment/%s' % (id, comment_id))
def vote(self, poll_id, choice_id):
"""
Cast a vote on a poll.
Poll data is packaged in update objects. Choice and poll IDs can be found there.
:param poll_id: ID of poll to vote on.
:param choice_id: ID of choice you'd like to make.
"""
return self._post('poll/%s/vote' % poll_id, {'id': choice_id, 'select': True})
def get_user_actions(self, user_id, start_time=None, end_time=int(time.time())):
"""
Get analysis of a user's actions over a given period of time.
This endpoint is typically only available to site admins.
:param user_id: ID of user to get actions of.
:param start_time: Timestamp at which to start action list. Defaults to 7 days before end.
:param end_time: Timestamp at which to end action list.
:return: List of Actions the user has completed.
"""
start_time = end_time - 604800 if start_time is None else start_time
if start_time < end_time - 604800:
raise AttributeError('Start timestamp must be no earlier than 7 days before end timestamp.')
return [Action(raw) for raw in self._get('analytics/users/%s?start_time=%s&end_time=%s&start=%s&limit=%s' % (user_id, start_time, end_time, self.start, self.limit))['actions']]
# TODO: Implement other analytics endpoints
# TODO: Implement multi-get(!) and multi-options requests. Don't seem to work right now.
# TODO: Support all User-Specific Objects, User Information, etc. requests
def _search(self, keywords, search_type):
"""
Get the items for a search of keywords and type.
:param keywords: The keywords you wish to search with.
:param type: The type of search (user, group, course).
:return: A list of dictionaries representing search outputs.
"""
return self._get('search?keywords=%s&type=%s' % ('+'.join(keywords), search_type))[search_type+'s']['search_result']
def search_users(self, keywords):
"""
Get the items for a search of keywords in users.
:param keywords: The keywords you wish to search with.
:return: A list of dictionaries representing search outputs.
"""
return self._search(keywords, 'user')
def search_groups(self, keywords):
"""
Get the items for a search of keywords in groups.
:param keywords: The keywords you wish to search with.
:return: A list of dictionaries representing search outputs.
"""
return self._search(keywords, 'group')
def search_courses(self, keywords):
"""
Get the items for a search of keywords in courses.
:param keywords: The keywords you wish to search with.
:return: A list of dictionaries representing search outputs.
"""
return self._search(keywords, 'course')
| 43.296
| 218
| 0.664334
| 11,777
| 86,592
| 4.630551
| 0.032266
| 0.050831
| 0.012653
| 0.014523
| 0.841182
| 0.791965
| 0.738695
| 0.67402
| 0.621319
| 0.517714
| 0
| 0.000601
| 0.231788
| 86,592
| 2,000
| 219
| 43.296
| 0.8192
| 0.197743
| 0
| 0.292683
| 0
| 0.000976
| 0.118108
| 0.054671
| 0
| 0
| 0
| 0.003
| 0
| 1
| 0.292683
| false
| 0
| 0.005854
| 0.138537
| 0.600976
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 6
|
3facdbab2ede11457d8300ca4e0071df95142ac8
| 108
|
py
|
Python
|
app_red/config/views.py
|
yeojin-dev/EB-Multicontainer-Docker-Deploy
|
3530dcdc40c687149f2ac9bb2f689b084e0ff470
|
[
"MIT"
] | null | null | null |
app_red/config/views.py
|
yeojin-dev/EB-Multicontainer-Docker-Deploy
|
3530dcdc40c687149f2ac9bb2f689b084e0ff470
|
[
"MIT"
] | null | null | null |
app_red/config/views.py
|
yeojin-dev/EB-Multicontainer-Docker-Deploy
|
3530dcdc40c687149f2ac9bb2f689b084e0ff470
|
[
"MIT"
] | null | null | null |
from django.http import HttpResponse
def index(request):
return HttpResponse('<h1>RED CONTAINER</h1>')
| 21.6
| 49
| 0.75
| 14
| 108
| 5.785714
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.021277
| 0.12963
| 108
| 4
| 50
| 27
| 0.840426
| 0
| 0
| 0
| 0
| 0
| 0.203704
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
3fb3cd742384b75e8c7ba81382115cd3500ccb23
| 71
|
py
|
Python
|
api/utils/json.py
|
ziegeer/autocert
|
285df181508573918e280948e51cdd7c65743281
|
[
"MIT"
] | null | null | null |
api/utils/json.py
|
ziegeer/autocert
|
285df181508573918e280948e51cdd7c65743281
|
[
"MIT"
] | null | null | null |
api/utils/json.py
|
ziegeer/autocert
|
285df181508573918e280948e51cdd7c65743281
|
[
"MIT"
] | null | null | null |
import json
def jsonify(string):
return json.loads(str(string))
| 10.142857
| 34
| 0.704225
| 10
| 71
| 5
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.183099
| 71
| 6
| 35
| 11.833333
| 0.862069
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
3fc385b90e38085a6d9d3e4b76eac62e4f1d04e6
| 54
|
py
|
Python
|
signhere/exceptions.py
|
MetLifeLegalPlans/sign-here
|
cbf2f7bcdcf16a3db681b9e95d761d7951f95dff
|
[
"MIT"
] | 1
|
2022-02-04T17:42:17.000Z
|
2022-02-04T17:42:17.000Z
|
signhere/exceptions.py
|
MetLifeLegalPlans/sign-here
|
cbf2f7bcdcf16a3db681b9e95d761d7951f95dff
|
[
"MIT"
] | 2
|
2021-06-03T15:06:49.000Z
|
2021-06-14T15:31:25.000Z
|
signhere/exceptions.py
|
MetLifeLegalPlans/sign-here
|
cbf2f7bcdcf16a3db681b9e95d761d7951f95dff
|
[
"MIT"
] | 2
|
2021-06-01T13:25:57.000Z
|
2022-02-04T17:42:21.000Z
|
class AddImageArgumentError(AssertionError):
pass
| 18
| 44
| 0.814815
| 4
| 54
| 11
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12963
| 54
| 2
| 45
| 27
| 0.93617
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
3feea624fcde2302a263cbf58bbff0fe96e969a6
| 59,483
|
py
|
Python
|
shenfun/legendre/bases.py
|
liqihao2000/shenfun
|
2164596ccf906242779d9ec361168246ee6214d8
|
[
"BSD-2-Clause"
] | 1
|
2021-10-09T06:48:30.000Z
|
2021-10-09T06:48:30.000Z
|
shenfun/legendre/bases.py
|
liqihao2000/shenfun
|
2164596ccf906242779d9ec361168246ee6214d8
|
[
"BSD-2-Clause"
] | null | null | null |
shenfun/legendre/bases.py
|
liqihao2000/shenfun
|
2164596ccf906242779d9ec361168246ee6214d8
|
[
"BSD-2-Clause"
] | null | null | null |
"""
Module for defining function spaces in the Legendre family
"""
from __future__ import division
import os
import functools
import sympy as sp
import numpy as np
from numpy.polynomial import legendre as leg
from scipy.special import eval_legendre
from mpi4py_fft import fftw
from shenfun.spectralbase import SpectralBase, work, Transform, islicedict, \
slicedict
from shenfun.matrixbase import SparseMatrix
from .lobatto import legendre_lobatto_nodes_and_weights
from . import fastgl
__all__ = ['LegendreBase',
'Orthogonal',
'ShenDirichlet',
'ShenBiharmonic',
'ShenNeumann',
'ShenBiPolar',
'ShenBiPolar0',
'LowerDirichlet',
'NeumannDirichlet',
'DirichletNeumann',
'UpperDirichlet',
'UpperDirichletNeumann',
'DirichletNeumannDirichlet',
'BCDirichlet',
'BCBiharmonic',
'BCNeumann',
'BCNeumannDirichlet',
'BCDirichletNeumann',
'BCBeamFixedFree',
'BCLowerDirichlet',
'BCUpperDirichlet',
'BCUpperDirichletNeumann',
'BCDirichletNeumannDirichlet',
'BCShenBiPolar0']
#pylint: disable=method-hidden,no-else-return,not-callable,abstract-method,no-member,cyclic-import
try:
import quadpy
from mpmath import mp
mp.dps = 30
has_quadpy = True
except:
has_quadpy = False
mp = None
mode = os.environ.get('SHENFUN_LEGENDRE_MODE', 'numpy')
mode = mode if has_quadpy else 'numpy'
xp = sp.Symbol('x', real=True)
class LegendreBase(SpectralBase):
"""Base class for all Legendre spaces
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", domain=(-1., 1.), dtype=float, padding_factor=1,
dealias_direct=False, coordinates=None):
SpectralBase.__init__(self, N, quad=quad, domain=domain, dtype=dtype,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
self.forward = functools.partial(self.forward, fast_transform=False)
self.backward = functools.partial(self.backward, fast_transform=False)
self.scalar_product = functools.partial(self.scalar_product, fast_transform=False)
self.plan(int(padding_factor*N), 0, dtype, {})
@staticmethod
def family():
return 'legendre'
def points_and_weights(self, N=None, map_true_domain=False, weighted=True, **kw):
if N is None:
N = self.shape(False)
if self.quad == "LG":
points, weights = fastgl.leggauss(N)
#points, weights = leg.leggauss(N)
elif self.quad == "GL":
points, weights = legendre_lobatto_nodes_and_weights(N)
else:
raise NotImplementedError
if map_true_domain is True:
points = self.map_true_domain(points)
return points, weights
def mpmath_points_and_weights(self, N=None, map_true_domain=False, weighted=True, **kw):
if mode == 'numpy' or not has_quadpy:
return self.points_and_weights(N=N, map_true_domain=map_true_domain, weighted=weighted, **kw)
if N is None:
N = self.shape(False)
if self.quad == 'LG':
pw = quadpy.c1.gauss_legendre(N, 'mpmath')
elif self.quad == 'GL':
pw = quadpy.c1.gauss_lobatto(N) # No mpmath in quadpy for lobatto:-(
points = pw.points_symbolic
if map_true_domain is True:
points = self.map_true_domain(points)
return points, pw.weights_symbolic
def vandermonde(self, x):
return leg.legvander(x, self.shape(False)-1)
def reference_domain(self):
return (-1, 1)
def plan(self, shape, axis, dtype, options):
if shape in (0, (0,)):
return
if isinstance(axis, tuple):
assert len(axis) == 1
axis = axis[0]
if isinstance(self.forward, Transform):
if self.forward.input_array.shape == shape and self.axis == axis:
# Already planned
return
U = fftw.aligned(shape, dtype=dtype)
V = fftw.aligned(shape, dtype=dtype)
U.fill(0)
V.fill(0)
self.axis = axis
if self.padding_factor > 1.+1e-8:
trunc_array = self._get_truncarray(shape, V.dtype)
self.scalar_product = Transform(self.scalar_product, None, U, V, trunc_array)
self.forward = Transform(self.forward, None, U, V, trunc_array)
self.backward = Transform(self.backward, None, trunc_array, V, U)
else:
self.scalar_product = Transform(self.scalar_product, None, U, V, V)
self.forward = Transform(self.forward, None, U, V, V)
self.backward = Transform(self.backward, None, V, V, U)
self.si = islicedict(axis=self.axis, dimensions=self.dimensions)
self.sl = slicedict(axis=self.axis, dimensions=self.dimensions)
def get_orthogonal(self):
return Orthogonal(self.N, quad=self.quad, dtype=self.dtype,
domain=self.domain,
padding_factor=self.padding_factor,
dealias_direct=self.dealias_direct,
coordinates=self.coors.coordinates)
class Orthogonal(LegendreBase):
"""Function space for regular (orthogonal) Legendre series
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", domain=(-1., 1.), dtype=float, padding_factor=1,
dealias_direct=False, coordinates=None):
LegendreBase.__init__(self, N, quad=quad, domain=domain, dtype=dtype,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
def sympy_basis(self, i=0, x=xp):
return sp.legendre(i, x)
def evaluate_basis(self, x, i=0, output_array=None):
x = np.atleast_1d(x)
if output_array is None:
output_array = np.zeros(x.shape)
output_array = eval_legendre(i, x, out=output_array)
return output_array
def evaluate_basis_all(self, x=None, argument=0):
if x is None:
x = self.mesh(False, False)
return self.vandermonde(x)
def evaluate_basis_derivative(self, x=None, i=0, k=0, output_array=None):
if x is None:
x = self.mesh(False, False)
if output_array is None:
output_array = np.zeros(x.shape)
x = np.atleast_1d(x)
basis = np.zeros(self.shape(True))
basis[i] = 1
basis = leg.Legendre(basis)
if k > 0:
basis = basis.deriv(k)
output_array[:] = basis(x)
return output_array
def evaluate_basis_derivative_all(self, x=None, k=0, argument=0):
if x is None:
x = self.mesh(False, False)
V = self.vandermonde(x)
M = V.shape[-1]
if k > 0:
D = np.zeros((M, M))
D[:-k] = leg.legder(np.eye(M, M), k)
V = np.dot(V, D)
return V
def eval(self, x, u, output_array=None):
if output_array is None:
output_array = np.zeros(x.shape, dtype=self.dtype)
x = self.map_reference_domain(x)
output_array[:] = leg.legval(x, u)
return output_array
@property
def is_orthogonal(self):
return True
@staticmethod
def short_name():
return 'L'
def to_ortho(self, input_array, output_array=None):
assert input_array.__class__.__name__ == 'Orthogonal'
if output_array:
output_array[:] = input_array
return output_array
return input_array
class CompositeSpace(Orthogonal):
"""Common class for all spaces based on composite bases"""
def __init__(self, N, quad="GC", bc=(0, 0), domain=(-1., 1.), dtype=float, scaled=False,
padding_factor=1, dealias_direct=False, coordinates=None):
Orthogonal.__init__(self, N, quad=quad, domain=domain, dtype=dtype,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
from shenfun.tensorproductspace import BoundaryValues
self._scaled = scaled
self._bc_basis = None
self.bc = BoundaryValues(self, bc=bc)
def plan(self, shape, axis, dtype, options):
Orthogonal.plan(self, shape, axis, dtype, options)
LegendreBase.plan(self, shape, axis, dtype, options)
def evaluate_basis_all(self, x=None, argument=0):
V = Orthogonal.evaluate_basis_all(self, x=x, argument=argument)
return self._composite(V, argument=argument)
def evaluate_basis_derivative_all(self, x=None, k=0, argument=0):
V = Orthogonal.evaluate_basis_derivative_all(self, x=x, k=k, argument=argument)
return self._composite(V, argument=argument)
def _evaluate_expansion_all(self, input_array, output_array, x=None, fast_transform=False):
if fast_transform is False:
SpectralBase._evaluate_expansion_all(self, input_array, output_array, x, False)
return
assert input_array is self.backward.tmp_array
assert output_array is self.backward.output_array
input_array[:] = self.to_ortho(input_array, output_array)
Orthogonal._evaluate_expansion_all(self, input_array, output_array, x, fast_transform)
def _evaluate_scalar_product(self, fast_transform=False):
output = self.scalar_product.tmp_array
if fast_transform is False:
SpectralBase._evaluate_scalar_product(self)
output[self.sl[slice(-(self.N-self.dim()), None)]] = 0
return
Orthogonal._evaluate_scalar_product(self, fast_transform)
nbcs = self.N-self.dim()
s = [np.newaxis]*self.dimensions
w0 = output.copy()
output.fill(0)
for key, val in self.stencil_matrix(self.shape(False)).items():
M = self.N if key >= 0 else self.dim()
s1 = slice(max(0, -key), M-max(0, key))
Q = s1.stop-s1.start
s2 = self.sl[slice(max(0, key), Q+max(0, key))]
sk = self.sl[s1]
s[self.axis] = slice(0, Q)
output[sk] += val[tuple(s)]*w0[s2]
output[self.sl[slice(-nbcs, None)]] = 0
@property
def is_orthogonal(self):
return False
@property
def has_nonhomogeneous_bcs(self):
return self.bc.has_nonhomogeneous_bcs()
def is_scaled(self):
"""Return True if scaled basis is used, otherwise False"""
return self._scaled
def stencil_matrix(self, N=None):
"""Matrix describing the linear combination of orthogonal basis
functions for the current basis.
Parameters
----------
N : int, optional
The number of quadrature points
"""
raise NotImplementedError
def _composite(self, V, argument=0):
"""Return Vandermonde matrix V adjusted for basis composition
Parameters
----------
V : Vandermonde type matrix
argument : int
Zero for test and 1 for trialfunction
"""
P = np.zeros_like(V)
P[:] = V * self.stencil_matrix(V.shape[1]).diags().T
if argument == 1: # if trial function
P[:, slice(-(self.N-self.dim()), None)] = self.get_bc_basis()._composite(V)
return P
def sympy_basis(self, i=0, x=xp):
assert i < self.N
if i < self.dim():
row = self.stencil_matrix().diags().getrow(i)
f = 0
for j, val in zip(row.indices, row.data):
f += sp.nsimplify(val)*Orthogonal.sympy_basis(self, i=j, x=x)
else:
f = self.get_bc_basis().sympy_basis(i=i-self.dim(), x=x)
return f
def to_ortho(self, input_array, output_array=None):
if output_array is None:
output_array = np.zeros_like(input_array)
else:
output_array.fill(0)
s = [np.newaxis]*self.dimensions
for key, val in self.stencil_matrix().items():
M = self.N if key >= 0 else self.dim()
s0 = slice(max(0, -key), min(self.dim(), M-max(0, key)))
Q = s0.stop-s0.start
s1 = slice(max(0, key), max(0, key)+Q)
s[self.axis] = slice(0, Q)
output_array[self.sl[s1]] += val[tuple(s)]*input_array[self.sl[s0]]
if self.has_nonhomogeneous_bcs:
self.bc.add_to_orthogonal(output_array, input_array)
return output_array
def evaluate_basis(self, x, i=0, output_array=None):
x = np.atleast_1d(x)
if output_array is None:
output_array = np.zeros(x.shape)
if i < self.dim():
row = self.stencil_matrix().diags().getrow(i)
w0 = np.zeros_like(output_array)
output_array.fill(0)
for j, val in zip(row.indices, row.data):
output_array[:] += val*Orthogonal.evaluate_basis(self, x, i=j, output_array=w0)
else:
assert i < self.N
output_array = self.get_bc_basis().evaluate_basis(x, i=i-self.dim(), output_array=output_array)
return output_array
def evaluate_basis_derivative(self, x=None, i=0, k=0, output_array=None):
if x is None:
x = self.mesh(False, False)
if output_array is None:
output_array = np.zeros(x.shape)
x = np.atleast_1d(x)
if i < self.dim():
basis = np.zeros(self.shape(True))
M = self.stencil_matrix()
row = M.diags().getrow(i)
indices = row.indices
vals = row.data
basis[np.array(indices)] = vals
basis = leg.Legendre(basis)
if k > 0:
basis = basis.deriv(k)
output_array[:] = basis(x)
else:
output_array[:] = self.get_bc_basis().evaluate_basis_derivative(x, i-self.dim(), k)
return output_array
def eval(self, x, u, output_array=None):
x = np.atleast_1d(x)
if output_array is None:
output_array = np.zeros(x.shape, dtype=self.dtype)
x = self.map_reference_domain(x)
w = self.to_ortho(u)
output_array[:] = leg.legval(x, w)
return output_array
class ShenDirichlet(CompositeSpace):
"""Function space for Dirichlet boundary conditions
u(-1)=a and u(1)=b.
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : tuple of numbers
Boundary conditions at edges of domain
domain : 2-tuple of floats, optional
The computational domain
scaled : bool, optional
Whether or not to scale test functions with 1/sqrt(4k+6).
Scaled test functions give a stiffness matrix equal to the
identity matrix.
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0., 0.), domain=(-1., 1.), dtype=float, scaled=False,
padding_factor=1, dealias_direct=False, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'Dirichlet'
@staticmethod
def short_name():
return 'SD'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(N)
d[-2:] = 0
if self.is_scaled():
k = np.arange(N)
d /= np.sqrt(4*k+6)
return SparseMatrix({0: d, 2: -d[:-2]}, (N, N))
def slice(self):
return slice(0, self.N-2)
def _evaluate_expansion_all(self, input_array, output_array,
x=None, fast_transform=False):
if fast_transform is False:
SpectralBase._evaluate_expansion_all(self, input_array, output_array, x, fast_transform)
return
assert input_array.ndim == 1, 'Use fast_transform=False'
xj, _ = self.points_and_weights(self.N)
from shenfun.optimization.numba import legendre as legn
legn.legendre_shendirichlet_evaluate_expansion_all(xj, input_array, output_array, self.is_scaled())
def _evaluate_scalar_product(self, fast_transform=False):
input_array = self.scalar_product.input_array
output_array = self.scalar_product.tmp_array
if fast_transform is False:
SpectralBase._evaluate_scalar_product(self)
output_array[self.si[-2]] = 0
output_array[self.si[-1]] = 0
return
M = self.shape(False)
xj, wj = self.points_and_weights(M)
assert input_array.ndim == 1, 'Use fast_transform=False'
from shenfun.optimization.numba import legendre as legn
legn.legendre_shendirichlet_scalar_product(xj, wj, input_array, output_array, self.is_scaled())
output_array[self.si[-2]] = 0
output_array[self.si[-1]] = 0
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCDirichlet(self.N, quad=self.quad, domain=self.domain,
scaled=self._scaled, coordinates=self.coors.coordinates)
return self._bc_basis
class ShenNeumann(CompositeSpace):
"""Function space for Neumann boundary conditions
u'(-1)=a and u'(1)=b
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
mean : number
mean value
bc : 2-tuple of numbers
Boundary conditions at edges of domain
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", mean=None, bc=(0., 0.), domain=(-1., 1.), padding_factor=1,
scaled=False, dealias_direct=False, dtype=float, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
self.mean = mean
@staticmethod
def boundary_condition():
return 'Neumann'
@staticmethod
def short_name():
return 'SN'
@property
def use_fixed_gauge(self):
if self.mean is None:
return False
T = self.tensorproductspace
if T:
return T.use_fixed_gauge
return True
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(N, dtype=int)
d[-2:] = 0
k = np.arange(N-2)
return SparseMatrix({0: d, 2: -k*(k+1)/(k+2)/(k+3)}, (N, N))
def _evaluate_scalar_product(self, fast_transform=False):
input_array = self.scalar_product.input_array
output_array = self.scalar_product.tmp_array
if fast_transform is False:
SpectralBase._evaluate_scalar_product(self)
output_array[self.sl[slice(-2, None)]] = 0
if self.use_fixed_gauge:
output_array[self.si[0]] = self.mean*np.pi
return
assert input_array.ndim == 1, 'Use fast_transform=False'
xj, wj = self.points_and_weights(self.N)
from shenfun.optimization.numba import legendre as legn
legn.legendre_shenneumann_scalar_product(xj, wj, input_array, output_array)
output_array[self.sl[slice(-2, None)]] = 0
if self.use_fixed_gauge:
output_array[self.si[0]] = self.mean*np.pi
def _evaluate_expansion_all(self, input_array, output_array,
x=None, fast_transform=False):
if fast_transform is False:
SpectralBase._evaluate_expansion_all(self, input_array, output_array, x, fast_transform)
return
assert input_array.ndim == 1, 'Use fast_transform=False'
xj, _ = self.points_and_weights(self.N)
try:
from shenfun.optimization.numba import legendre as legn
legn.legendre_shenneumann_evaluate_expansion_all(xj, input_array, output_array)
except:
raise RuntimeError('Requires Numba')
def slice(self):
return slice(0, self.N-2)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCNeumann(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class ShenBiharmonic(CompositeSpace):
"""Function space for biharmonic basis with both Dirichlet and
Neumann boundary conditions
u(-1)=a, u(1)=b, u'(-1)=c, u'(1)=d.
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : 4-tuple of numbers, optional
The values of the 4 boundary conditions at x=(-1, 1).
The two Dirichlet first and then the Neumann.
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0, 0, 0, 0), domain=(-1., 1.), padding_factor=1,
scaled=False, dealias_direct=False, dtype=float, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'Biharmonic'
@staticmethod
def short_name():
return 'SB'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(N, dtype=int)
d[-4:] = 0
k = np.arange(N)
return SparseMatrix({0: d, 2: -2*(2*k[:-2]+5)/(2*k[:-2]+7), 4: (2*k[:-4]+3)/(2*k[:-4]+7)}, (N, N))
def slice(self):
return slice(0, self.N-4)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCBiharmonic(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class BeamFixedFree(CompositeSpace):
"""Function space for biharmonic equation with boundary conditions
u(-1) = a, u'(-1) = b, u''(1) = c, u'''(1) = d.
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
4-tuple of numbers, optional
The values of the 4 boundary conditions
u(-1) = a, u'(-1) = b, u''(1) = c, u'''(1) = d
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbol('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0, 0, 0, 0), domain=(-1., 1.), padding_factor=1,
scaled=False, dealias_direct=False, dtype=float, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'BeamFixedFree'
@staticmethod
def short_name():
return 'BF'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(N, dtype=int)
d[-4:] = 0
k = np.arange(N)
f1 = 4*(2*k[:-1]+3)/(k[:-1]+3)**2
f2 = -(2*(k[:-2]-1)*(k[:-2]+1)*(k[:-2]+6)*(2*k[:-2]+5)/((k[:-2]+3)**2*(k[:-2]+4)*(2*k[:-2]+7)))
f3 = -4*(k[:-3]+1)**2*(2*k[:-3]+3)/((k[:-3]+3)**2*(k[:-3]+4)**2)
f4 = (((k[:-4]+1)/(k[:-4]+3))*((k[:-4]+2)/(k[:-4]+4)))**2*(2*k[:-4]+3)/(2*k[:-4]+7)
return SparseMatrix({0: d, 1: f1, 2: f2,3: f3, 4: f4}, (N, N))
def slice(self):
return slice(0, self.N-4)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCBeamFixedFree(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class UpperDirichlet(CompositeSpace):
"""Function space with boundary condition
u(1)=a
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(None, 0), domain=(-1., 1.), dtype=float,
scaled=False, padding_factor=1, dealias_direct=False, coordinates=None):
assert quad == "LG"
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'UpperDirichlet'
@staticmethod
def short_name():
return 'UD'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-1] = 0
return SparseMatrix({0: d, 1: -d[:-1]}, (self.N, self.N))
def slice(self):
return slice(0, self.N-1)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCUpperDirichlet(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class ShenBiPolar(CompositeSpace):
r"""Function space for the Biharmonic equation with boundary conditions
u(-1)=a, u(1)=b, u'(-1)=c, u'(1)=d.
The basis function is
.. math::
\phi_k = (x^2-1)^2 L'_{k+1}
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : 4-tuple of numbers, optional
The values of the 4 boundary conditions at x=(-1, 1).
The two Dirichlet first and then the Neumann.
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", domain=(-1., 1.), bc=(0, 0, 0, 0), dtype=float, scaled=False,
padding_factor=1, dealias_direct=False, coordinates=None):
assert quad == "LG"
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'Biharmonic'
@staticmethod
def short_name():
return 'SP'
def slice(self):
return slice(0, self.N-4)
def stencil_matrix(self, N=None):
N = self.N if N is None else N
k = np.arange(N)
ak = k*(k-1)/(2*k-1)/(2*k+1)
bk = -2*(k**2+k-1)/(2*k-1)/(2*k+3)
ck = (k+1)*(k+2)/(2*k+1)/(2*k+3)
d = np.zeros(N)
d[:-4] = (k[:-4]+1)*(k[:-4]+2)/(2*k[:-4]+3)*(ak[2:-2]-bk[:-4])
d[0] = 8/15
d[1] = 24/35
dm2 = np.zeros(N-2)
dm2[:-4] = -(k[2:-4]+1)*(k[2:-4]+2)/(2*k[2:-4]+3)*ak[2:-4]
dp2 = np.zeros(N-2)
dp2[:-2] = (k[:-4]+1)*(k[:-4]+2)/(2*k[:-4]+3)*(bk[2:-2]-ck[:-4])
dp2[0] = -16/21
dp2[1] = -16/15
dp4 = np.zeros(N-4)
dp4[:] = (k[:-4]+1)*(k[:-4]+2)/(2*k[:-4]+3)*ck[2:-2]
dp4[0] = 8/35
dp4[1] = 8/21
return SparseMatrix({-2: dm2, 0: d, 2: dp2, 4: dp4}, (N, N))
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCBiharmonic(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class ShenBiPolar0(CompositeSpace):
"""Function space for biharmonic equation in polar coordinates,
with merely three boundary conditions
u(1)=a, u'(-1)=b and u'(1)=c
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
bc : 3-tuple of numbers, optional
The values of the 3 boundary conditions at x=(-1, 1).
The two Dirichlet first and then the Neumann.
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", domain=(-1., 1.), bc=(0, 0, 0), padding_factor=1,
scaled=False, dealias_direct=False, dtype=float, coordinates=None):
assert quad == "LG"
CompositeSpace.__init__(self, N, quad="LG", domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'BiPolar0'
@staticmethod
def short_name():
return 'SP0'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-3:] = 0
k = np.arange(self.N)
f1 = -((2*k[:-1]+3)*(k[:-1]+4)/(2*k[:-1]+5)/(k[:-1]+2))
f2 = -(k[:-2]*(k[:-2]+1)/(k[:-2]+2)/(k[:-2]+3))
f3 = (k[:-3]+1)*(2*k[:-3]+3)/(k[:-3]+3)/(2*k[:-3]+5)
return SparseMatrix({0: d, 1: f1, 2: f2, 3: f3}, (self.N, self.N))
def slice(self):
return slice(0, self.N-3)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCShenBiPolar0(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class DirichletNeumann(CompositeSpace):
"""Function space for mixed Dirichlet/Neumann boundary conditions
u(-1)=a, u'(1)=b
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : tuple of numbers
Boundary conditions at edges of domain
domain : 2-tuple of floats, optional
The computational domain
scaled : bool, optional
Whether or not to scale test functions with 1/sqrt(4k+6).
Scaled test functions give a stiffness matrix equal to the
identity matrix.
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0., 0.), domain=(-1., 1.), dtype=float,
scaled=False, padding_factor=1, dealias_direct=False, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'DirichletNeumann'
@staticmethod
def short_name():
return 'DN'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-2:] = 0
k = np.arange(self.N)
f1 = (2*k[:-1]+3)/(k[:-1]+2)**2
f2 = -((k[:-2]+1)/(k[:-2]+2))**2
return SparseMatrix({0: d, 1: f1, 2: f2}, (self.N, self.N))
def slice(self):
return slice(0, self.N-2)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCDirichletNeumann(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class LowerDirichlet(CompositeSpace):
"""Function space with single Dirichlet boundary condition
u(-1)=a
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : tuple of (number, None)
Boundary conditions at edges of domain.
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0, None), domain=(-1., 1.), dtype=float,
scaled=False, padding_factor=1, dealias_direct=False, coordinates=None):
assert quad == "LG"
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'LowerDirichlet'
@staticmethod
def short_name():
return 'LD'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-1] = 0
return SparseMatrix({0: d, 1: d[:-1]}, (self.N, self.N))
def slice(self):
return slice(0, self.N-1)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCLowerDirichlet(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class DirichletNeumannDirichlet(CompositeSpace):
"""Function space for biharmonic basis with merely three boundary
conditions
u(-1)=a, u(1)=b and u'(-1)=c
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
3-tuple of numbers, optional
The values of the 3 boundary conditions at x=(-1, 1).
The two Dirichlet first and then the Neumann.
domain : 2-tuple of floats, optional
The computational domain
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0, 0, 0), domain=(-1., 1.), padding_factor=1,
scaled=False, dealias_direct=False, dtype=float, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'DirichletNeumannDirichlet'
@staticmethod
def short_name():
return 'DND'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-2:] = 0
k = np.arange(self.N)
f1 = (2*k[:-1]+3)/(2*k[:-1]+5)
f2 = -np.ones(N-2)
f3 = -(2*k[:-3]+3)/(2*k[:-3]+5)
return SparseMatrix({0: d, 1: f1, 2: f2, 3: f3}, (self.N, self.N))
def slice(self):
return slice(0, self.N-3)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCDirichletNeumannDirichlet(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class NeumannDirichlet(CompositeSpace):
"""Function space for mixed Dirichlet/Neumann boundary conditions
u'(-1)=a, u(1)=b
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : tuple of numbers
Boundary conditions at edges of domain
domain : 2-tuple of floats, optional
The computational domain
scaled : bool, optional
Whether or not to scale test functions with 1/sqrt(4k+6).
Scaled test functions give a stiffness matrix equal to the
identity matrix.
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="LG", bc=(0., 0.), domain=(-1., 1.), dtype=float,
scaled=False, padding_factor=1, dealias_direct=False, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'NeumannDirichlet'
@staticmethod
def short_name():
return 'ND'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-2:] = 0
k = np.arange(self.N)
f1 = -((2*k[:-1]+3)/(k[:-1]+2)**2)
f2 = -((k[:-2]+1)**2/(k[:-2]+2)**2)
return SparseMatrix({0: d, 1: f1, 2: f2}, (self.N, self.N))
def slice(self):
return slice(0, self.N-2)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCNeumannDirichlet(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class UpperDirichletNeumann(CompositeSpace):
"""Function space for mixed Dirichlet/Neumann boundary conditions
u(1)=a, u'(1)=b
Parameters
----------
N : int
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
bc : tuple of numbers
Boundary conditions at edges of domain
domain : 2-tuple of floats, optional
The computational domain
scaled : bool, optional
Whether or not to scale test functions with 1/sqrt(4k+6).
Scaled test functions give a stiffness matrix equal to the
identity matrix.
padding_factor : float, optional
Factor for padding backward transforms.
dealias_direct : bool, optional
Set upper 1/3 of coefficients to zero before backward transform
dtype : data-type, optional
Type of input data in real physical space. Will be overloaded when
basis is part of a :class:`.TensorProductSpace`.
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
Note
----
This basis is not recommended as it leads to a poorly conditioned
stiffness matrix.
"""
def __init__(self, N, quad="LG", bc=(0., 0.), domain=(-1., 1.), dtype=float,
scaled=False, padding_factor=1, dealias_direct=False, coordinates=None):
CompositeSpace.__init__(self, N, quad=quad, domain=domain, dtype=dtype, bc=bc, scaled=scaled,
padding_factor=padding_factor, dealias_direct=dealias_direct,
coordinates=coordinates)
@staticmethod
def boundary_condition():
return 'UpperDirichletNeumann'
@staticmethod
def short_name():
return 'UDN'
def stencil_matrix(self, N=None):
N = self.N if N is None else N
d = np.ones(self.N)
d[-2:] = 0
k = np.arange(self.N)
f1 = -((2*k[:-1]+3)/(k[:-1]+2))
f2 = ((k[:-2]+1)/(k[:-2]+2))
return SparseMatrix({0: d, 1: f1, 2: f2}, (self.N, self.N))
def slice(self):
return slice(0, self.N-2)
def get_bc_basis(self):
if self._bc_basis:
return self._bc_basis
self._bc_basis = BCUpperDirichletNeumann(self.N, quad=self.quad, domain=self.domain,
coordinates=self.coors.coordinates)
return self._bc_basis
class BCBase(CompositeSpace):
"""Function space for inhomogeneous boundary conditions
Parameters
----------
N : int, optional
Number of quadrature points
quad : str, optional
Type of quadrature
- LG - Legendre-Gauss
- GL - Legendre-Gauss-Lobatto
domain : 2-tuple of floats, optional
The computational domain
scaled : bool, optional
Whether or not to use scaled basis
coordinates: 2- or 3-tuple (coordinate, position vector (, sympy assumptions)), optional
Map for curvilinear coordinatesystem.
The new coordinate variable in the new coordinate system is the first item.
Second item is a tuple for the Cartesian position vector as function of the
new variable in the first tuple. Example::
theta = sp.Symbols('x', real=True, positive=True)
rv = (sp.cos(theta), sp.sin(theta))
"""
def __init__(self, N, quad="GC", domain=(-1., 1.),
dtype=float, coordinates=None, **kw):
CompositeSpace.__init__(self, N, quad=quad, domain=domain,
dtype=dtype, coordinates=coordinates)
def stencil_matrix(self, N=None):
raise NotImplementedError
@staticmethod
def short_name():
raise NotImplementedError
@staticmethod
def boundary_condition():
return 'Apply'
def shape(self, forward_output=True):
if forward_output:
return self.stencil_matrix().shape[0]
else:
return self.N
@property
def num_T(self):
return self.stencil_matrix().shape[1]
def slice(self):
return slice(self.N-self.shape(), self.N)
def vandermonde(self, x):
return leg.legvander(x, self.num_T-1)
def _composite(self, V, argument=1):
N = self.shape()
P = np.zeros(V[:, :N].shape)
P[:] = np.tensordot(V[:, :self.num_T], self.stencil_matrix(), (1, 1))
return P
def sympy_basis(self, i=0, x=xp):
M = self.stencil_matrix()
return np.sum(M[i]*np.array([sp.legendre(j, x) for j in range(self.num_T)]))
def evaluate_basis(self, x, i=0, output_array=None):
x = np.atleast_1d(x)
if output_array is None:
output_array = np.zeros(x.shape)
V = self.vandermonde(x)
output_array[:] = np.dot(V, self.stencil_matrix()[i])
return output_array
def evaluate_basis_derivative(self, x=None, i=0, k=0, output_array=None):
output_array = SpectralBase.evaluate_basis_derivative(self, x=x, i=i, k=k, output_array=output_array)
return output_array
def to_ortho(self, input_array, output_array=None):
from shenfun import Function
T = self.get_orthogonal()
if output_array is None:
output_array = Function(T)
else:
output_array.fill(0)
M = self.stencil_matrix().T
for k, row in enumerate(M):
output_array[k] = np.dot(row, input_array)
return output_array
def eval(self, x, u, output_array=None):
v = self.to_ortho(u)
output_array = v.eval(x, output_array=output_array)
return output_array
class BCDirichlet(BCBase):
@staticmethod
def short_name():
return 'BCD'
def stencil_matrix(self, N=None):
return sp.Rational(1, 2)*np.array([[1, -1],
[1, 1]])
class BCNeumann(BCBase):
@staticmethod
def short_name():
return 'BCN'
def stencil_matrix(self, N=None):
return sp.Rational(1, 6)*np.array([[0, 3, -1],
[0, 3, 1]])
class BCBiharmonic(BCBase):
@staticmethod
def short_name():
return 'BCB'
def stencil_matrix(self, N=None):
return sp.Rational(1, 30)*np.array([[15, -18, 0, 3],
[15, 18, 0, -3],
[5, -3, -5, 3],
[-5, -3, 5, 3]])
class BCBeamFixedFree(BCBase):
# u(-1), u'(-1), u''(1), u'''(1)
@staticmethod
def short_name():
return 'BCBF'
def stencil_matrix(self, N=None):
return sp.Rational(1, 15)*np.array([[15, 0, 0, 0],
[15, 15, 0, 0],
[10, 15, 5, 0],
[-15, -21, -5, 1]])
class BCLowerDirichlet(BCBase):
@staticmethod
def short_name():
return 'BCLD'
def stencil_matrix(self, N=None):
return sp.Rational(1, 2)*np.array([[1, -1]])
class BCUpperDirichlet(BCBase):
@staticmethod
def short_name():
return 'BCUD'
def stencil_matrix(self, N=None):
return sp.Rational(1, 2)*np.array([[1, 1]])
class BCNeumannDirichlet(BCBase):
@staticmethod
def short_name():
return 'BCND'
def stencil_matrix(self, N=None):
return sp.Rational(1, 2)*np.array([[2, -1, -1],
[2, 0, 0]])
class BCDirichletNeumann(BCBase):
@staticmethod
def short_name():
return 'BCDN'
def stencil_matrix(self, N=None):
return np.array([[1, 0],
[1, 1]])
class BCUpperDirichletNeumann(BCBase):
@staticmethod
def short_name():
return 'BCUDN'
def stencil_matrix(self, N=None):
return np.array([[1, 0, 0],
[1, -2, 1]])
class BCDirichletNeumannDirichlet(BCBase):
@staticmethod
def short_name():
return 'BCST'
def stencil_matrix(self, N=None):
return sp.Rational(1, 6)*np.array([[4, -3, -1],
[2, 0, -2],
[2, 3, 1]])
class BCShenBiPolar0(BCBase):
@staticmethod
def short_name():
return 'BCSP'
def stencil_matrix(self, N=None):
return sp.Rational(1, 6)*np.array([[6, 0, 0],
[-4, 3, 1],
[-2, 3, -1]])
| 37.410692
| 109
| 0.584537
| 7,527
| 59,483
| 4.506576
| 0.054603
| 0.019899
| 0.01589
| 0.012264
| 0.810855
| 0.780343
| 0.747384
| 0.732702
| 0.716872
| 0.706465
| 0
| 0.019944
| 0.308794
| 59,483
| 1,589
| 110
| 37.434235
| 0.805083
| 0.339055
| 0
| 0.576251
| 0
| 0
| 0.022142
| 0.004364
| 0
| 0
| 0
| 0
| 0.016298
| 1
| 0.171129
| false
| 0
| 0.023283
| 0.082654
| 0.394645
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
b2100123c0616cff835c03c6202ad116d2fc9b88
| 108
|
py
|
Python
|
deep500/lv2/validation/__init__.py
|
khoaideptrai/deep500
|
0953038f64bc73c8d41d01796e07d3a23ca97822
|
[
"BSD-3-Clause"
] | 90
|
2019-01-02T22:49:08.000Z
|
2022-02-17T21:11:38.000Z
|
deep500/lv2/validation/__init__.py
|
khoaideptrai/deep500
|
0953038f64bc73c8d41d01796e07d3a23ca97822
|
[
"BSD-3-Clause"
] | 4
|
2019-02-14T16:19:06.000Z
|
2022-01-11T17:54:42.000Z
|
deep500/lv2/validation/__init__.py
|
khoaideptrai/deep500
|
0953038f64bc73c8d41d01796e07d3a23ca97822
|
[
"BSD-3-Clause"
] | 24
|
2019-01-09T18:09:44.000Z
|
2022-01-10T13:04:42.000Z
|
from .optimizer import test_optimizer
from .training import test_training
from .sampler import test_sampler
| 27
| 37
| 0.861111
| 15
| 108
| 6
| 0.4
| 0.333333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.111111
| 108
| 3
| 38
| 36
| 0.9375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
b76a8781342db551b5e26f99f9e5482e67757047
| 237
|
py
|
Python
|
mayan/apps/storage/dependencies.py
|
atitaya1412/Mayan-EDMS
|
bda9302ba4b743e7d829ad118b8b836221888172
|
[
"Apache-2.0"
] | 343
|
2015-01-05T14:19:35.000Z
|
2018-12-10T19:07:48.000Z
|
mayan/apps/storage/dependencies.py
|
atitaya1412/Mayan-EDMS
|
bda9302ba4b743e7d829ad118b8b836221888172
|
[
"Apache-2.0"
] | 191
|
2015-01-03T00:48:19.000Z
|
2018-11-30T09:10:25.000Z
|
mayan/apps/storage/dependencies.py
|
atitaya1412/Mayan-EDMS
|
bda9302ba4b743e7d829ad118b8b836221888172
|
[
"Apache-2.0"
] | 257
|
2019-05-14T10:26:37.000Z
|
2022-03-30T03:37:36.000Z
|
from mayan.apps.dependencies.classes import PythonDependency
PythonDependency(
module=__name__, name='extract-msg', version_string='==0.28.7'
)
PythonDependency(
module=__name__, name='pycryptodome', version_string='==3.10.1'
)
| 26.333333
| 67
| 0.759494
| 28
| 237
| 6.071429
| 0.714286
| 0.258824
| 0.305882
| 0.352941
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.037383
| 0.097046
| 237
| 8
| 68
| 29.625
| 0.757009
| 0
| 0
| 0.285714
| 0
| 0
| 0.164557
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.142857
| 0
| 0.142857
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
b7a0179957b058a576a6de8d0f6f4edd4967ce49
| 18,486
|
py
|
Python
|
test/test_ipip.py
|
ydy1234/vpp
|
9f9e969f149e40044fee9d2e47b7dd96f3ae4dfa
|
[
"Apache-2.0"
] | null | null | null |
test/test_ipip.py
|
ydy1234/vpp
|
9f9e969f149e40044fee9d2e47b7dd96f3ae4dfa
|
[
"Apache-2.0"
] | null | null | null |
test/test_ipip.py
|
ydy1234/vpp
|
9f9e969f149e40044fee9d2e47b7dd96f3ae4dfa
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/env python
"""IP{4,6} over IP{v,6} tunnel functional tests"""
import unittest
from scapy.layers.inet6 import IPv6, Ether, IP, UDP, IPv6ExtHdrFragment
from scapy.all import fragment, fragment6, RandShort, defragment6
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
from socket import AF_INET, AF_INET6, inet_pton
import StringIO
""" Testipip is a subclass of VPPTestCase classes.
IPIP tests.
"""
# Replace by deframent from scapy.
def reassemble(listoffragments):
buffer = StringIO.StringIO()
first = listoffragments[0]
buffer.seek(20)
for pkt in listoffragments:
buffer.seek(pkt[IP].frag*8)
buffer.write(pkt[IP].payload)
first.len = len(buffer.getvalue()) + 20
first.flags = 0
del(first.chksum)
header = str(first[IP])[:20]
return first[IP].__class__(header + buffer.getvalue())
class TestIPIP(VppTestCase):
""" IPIP Test Case """
@classmethod
def setUpClass(cls):
super(TestIPIP, cls).setUpClass()
cls.create_pg_interfaces(range(2))
cls.interfaces = list(cls.pg_interfaces)
def setUp(cls):
super(TestIPIP, cls).setUp()
for i in cls.interfaces:
i.admin_up()
i.config_ip4()
i.config_ip6()
i.disable_ipv6_ra()
i.resolve_arp()
i.resolve_ndp()
def tearDown(self):
super(TestIPIP, self).tearDown()
if not self.vpp_dead:
for i in self.pg_interfaces:
i.unconfig_ip4()
i.unconfig_ip6()
i.admin_down()
def validate(self, rx, expected):
self.assertEqual(rx, expected.__class__(str(expected)))
def generate_ip4_frags(self, payload_length, fragment_size):
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
p_payload = UDP(sport=1234, dport=1234) / self.payload(payload_length)
p_ip4 = IP(src="1.2.3.4", dst=self.pg0.remote_ip4)
outer_ip4 = (p_ether / IP(src=self.pg1.remote_ip4,
id=RandShort(),
dst=self.pg0.local_ip4) / p_ip4 / p_payload)
frags = fragment(outer_ip4, fragment_size)
p4_reply = (p_ip4 / p_payload)
p4_reply.ttl -= 1
return frags, p4_reply
def test_ipip4(self):
""" ip{v4,v6} over ip4 test """
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
p_ip6 = IPv6(src="1::1", dst="DEAD::1", nh='UDP', tc=42)
p_ip4 = IP(src="1.2.3.4", dst="130.67.0.1", tos=42)
p_payload = UDP(sport=1234, dport=1234)
# IPv4 transport
rv = self.vapi.ipip_add_tunnel(
src_address=self.pg0.local_ip4n,
dst_address=self.pg1.remote_ip4n,
is_ipv6=0, tc_tos=0xFF)
sw_if_index = rv.sw_if_index
# Set interface up and enable IP on it
self.vapi.sw_interface_set_flags(sw_if_index, 1)
self.vapi.sw_interface_set_unnumbered(
ip_sw_if_index=self.pg0.sw_if_index,
sw_if_index=sw_if_index)
# Add IPv4 and IPv6 routes via tunnel interface
ip4_via_tunnel = VppIpRoute(
self, "130.67.0.0", 16,
[VppRoutePath("0.0.0.0",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP4)], is_ip6=0)
ip4_via_tunnel.add_vpp_config()
ip6_via_tunnel = VppIpRoute(
self, "dead::", 16,
[VppRoutePath("::",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)], is_ip6=1)
ip6_via_tunnel.add_vpp_config()
# IPv6 in to IPv4 tunnel
p6 = (p_ether / p_ip6 / p_payload)
p_inner_ip6 = p_ip6
p_inner_ip6.hlim -= 1
p6_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4,
proto='ipv6', id=0, tos=42) / p_inner_ip6 / p_payload)
p6_reply.ttl -= 1
rx = self.send_and_expect(self.pg0, p6*10, self.pg1)
for p in rx:
self.validate(p[1], p6_reply)
# IPv4 in to IPv4 tunnel
p4 = (p_ether / p_ip4 / p_payload)
p_ip4_inner = p_ip4
p_ip4_inner.ttl -= 1
p4_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4,
tos=42) /
p_ip4_inner / p_payload)
p4_reply.ttl -= 1
p4_reply.id = 0
rx = self.send_and_expect(self.pg0, p4*10, self.pg1)
for p in rx:
self.validate(p[1], p4_reply)
# Decapsulation
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
# IPv4 tunnel to IPv4
p_ip4 = IP(src="1.2.3.4", dst=self.pg0.remote_ip4)
p4 = (p_ether / IP(src=self.pg1.remote_ip4,
dst=self.pg0.local_ip4) / p_ip4 / p_payload)
p4_reply = (p_ip4 / p_payload)
p4_reply.ttl -= 1
rx = self.send_and_expect(self.pg1, p4*10, self.pg0)
for p in rx:
self.validate(p[1], p4_reply)
err = self.statistics.get_counter(
'/err/ipip4-input/packets decapsulated')
self.assertEqual(err, 10)
# IPv4 tunnel to IPv6
p_ip6 = IPv6(src="1:2:3::4", dst=self.pg0.remote_ip6)
p6 = (p_ether / IP(src=self.pg1.remote_ip4,
dst=self.pg0.local_ip4) / p_ip6 / p_payload)
p6_reply = (p_ip6 / p_payload)
p6_reply.hlim = 63
rx = self.send_and_expect(self.pg1, p6*10, self.pg0)
for p in rx:
self.validate(p[1], p6_reply)
err = self.statistics.get_counter(
'/err/ipip4-input/packets decapsulated')
self.assertEqual(err, 20)
#
# Fragmentation / Reassembly and Re-fragmentation
#
rv = self.vapi.ip_reassembly_enable_disable(
sw_if_index=self.pg1.sw_if_index,
enable_ip4=1)
# Send lots of fragments, verify reassembled packet
frags, p4_reply = self.generate_ip4_frags(3131, 1400)
f = []
for i in range(0, 1000):
f.extend(frags)
self.pg1.add_stream(f)
self.pg_enable_capture()
self.pg_start()
rx = self.pg0.get_capture(1000)
for p in rx:
self.validate(p[1], p4_reply)
err = self.statistics.get_counter(
'/err/ipip4-input/packets decapsulated')
self.assertEqual(err, 1020)
f = []
r = []
for i in range(1, 90):
frags, p4_reply = self.generate_ip4_frags(i * 100, 1000)
f.extend(frags)
r.extend(p4_reply)
self.pg_enable_capture()
self.pg1.add_stream(f)
self.pg_start()
rx = self.pg0.get_capture(89)
i = 0
for p in rx:
self.validate(p[1], r[i])
i += 1
# Now try with re-fragmentation
#
# Send fragments to tunnel head-end, for the tunnel head end
# to reassemble and then refragment
#
self.vapi.sw_interface_set_mtu(self.pg0.sw_if_index, [576, 0, 0, 0])
frags, p4_reply = self.generate_ip4_frags(3123, 1200)
self.pg_enable_capture()
self.pg1.add_stream(frags)
self.pg_start()
rx = self.pg0.get_capture(6)
reass_pkt = reassemble(rx)
p4_reply.ttl -= 1
p4_reply.id = 256
self.validate(reass_pkt, p4_reply)
self.vapi.sw_interface_set_mtu(self.pg0.sw_if_index, [1600, 0, 0, 0])
frags, p4_reply = self.generate_ip4_frags(3123, 1200)
self.pg_enable_capture()
self.pg1.add_stream(frags)
self.pg_start()
rx = self.pg0.get_capture(2)
reass_pkt = reassemble(rx)
p4_reply.ttl -= 1
p4_reply.id = 512
self.validate(reass_pkt, p4_reply)
def test_ipip_create(self):
""" ipip create / delete interface test """
rv = self.vapi.ipip_add_tunnel(
src_address=inet_pton(AF_INET, '1.2.3.4'),
dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0)
sw_if_index = rv.sw_if_index
self.vapi.ipip_del_tunnel(sw_if_index)
def test_ipip_vrf_create(self):
""" ipip create / delete interface VRF test """
t = VppIpTable(self, 20)
t.add_vpp_config()
rv = self.vapi.ipip_add_tunnel(
src_address=inet_pton(AF_INET, '1.2.3.4'),
dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0,
table_id=20)
sw_if_index = rv.sw_if_index
self.vapi.ipip_del_tunnel(sw_if_index)
def payload(self, len):
return 'x' * len
class TestIPIP6(VppTestCase):
""" IPIP6 Test Case """
@classmethod
def setUpClass(cls):
super(TestIPIP6, cls).setUpClass()
cls.create_pg_interfaces(range(2))
cls.interfaces = list(cls.pg_interfaces)
def setUp(self):
for i in self.interfaces:
i.admin_up()
i.config_ip4()
i.config_ip6()
i.disable_ipv6_ra()
i.resolve_arp()
i.resolve_ndp()
self.setup_tunnel()
def tearDown(self):
if not self.vpp_dead:
self.destroy_tunnel()
for i in self.pg_interfaces:
i.unconfig_ip4()
i.unconfig_ip6()
i.admin_down()
super(TestIPIP6, self).tearDown()
def setup_tunnel(self):
# IPv6 transport
rv = self.vapi.ipip_add_tunnel(
src_address=self.pg0.local_ip6n,
dst_address=self.pg1.remote_ip6n, tc_tos=255)
sw_if_index = rv.sw_if_index
self.tunnel_if_index = sw_if_index
self.vapi.sw_interface_set_flags(sw_if_index, 1)
self.vapi.sw_interface_set_unnumbered(
ip_sw_if_index=self.pg0.sw_if_index, sw_if_index=sw_if_index)
# Add IPv4 and IPv6 routes via tunnel interface
ip4_via_tunnel = VppIpRoute(
self, "130.67.0.0", 16,
[VppRoutePath("0.0.0.0",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP4)], is_ip6=0)
ip4_via_tunnel.add_vpp_config()
ip6_via_tunnel = VppIpRoute(
self, "dead::", 16,
[VppRoutePath("::",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)], is_ip6=1)
ip6_via_tunnel.add_vpp_config()
self.tunnel_ip6_via_tunnel = ip6_via_tunnel
self.tunnel_ip4_via_tunnel = ip4_via_tunnel
def destroy_tunnel(self):
# IPv6 transport
self.tunnel_ip4_via_tunnel.remove_vpp_config()
self.tunnel_ip6_via_tunnel.remove_vpp_config()
rv = self.vapi.ipip_del_tunnel(sw_if_index=self.tunnel_if_index)
def validate(self, rx, expected):
self.assertEqual(rx, expected.__class__(str(expected)))
def generate_ip6_frags(self, payload_length, fragment_size):
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
p_payload = UDP(sport=1234, dport=1234) / self.payload(payload_length)
p_ip6 = IPv6(src="1::1", dst=self.pg0.remote_ip6)
outer_ip6 = (p_ether / IPv6(src=self.pg1.remote_ip6,
dst=self.pg0.local_ip6) /
IPv6ExtHdrFragment() / p_ip6 / p_payload)
frags = fragment6(outer_ip6, fragment_size)
p6_reply = (p_ip6 / p_payload)
p6_reply.hlim -= 1
return frags, p6_reply
def generate_ip6_hairpin_frags(self, payload_length, fragment_size):
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
p_payload = UDP(sport=1234, dport=1234) / self.payload(payload_length)
p_ip6 = IPv6(src="1::1", dst="dead::1")
outer_ip6 = (p_ether / IPv6(src=self.pg1.remote_ip6,
dst=self.pg0.local_ip6) /
IPv6ExtHdrFragment() / p_ip6 / p_payload)
frags = fragment6(outer_ip6, fragment_size)
p_ip6.hlim -= 1
p6_reply = (IPv6(src=self.pg0.local_ip6, dst=self.pg1.remote_ip6,
hlim=63) / p_ip6 / p_payload)
return frags, p6_reply
def test_encap(self):
""" ip{v4,v6} over ip6 test encap """
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
p_ip6 = IPv6(src="1::1", dst="DEAD::1", tc=42, nh='UDP')
p_ip4 = IP(src="1.2.3.4", dst="130.67.0.1", tos=42)
p_payload = UDP(sport=1234, dport=1234)
# Encapsulation
# IPv6 in to IPv6 tunnel
p6 = (p_ether / p_ip6 / p_payload)
p6_reply = (IPv6(src=self.pg0.local_ip6, dst=self.pg1.remote_ip6,
hlim=64, tc=42) /
p_ip6 / p_payload)
p6_reply[1].hlim -= 1
rx = self.send_and_expect(self.pg0, p6*11, self.pg1)
for p in rx:
self.validate(p[1], p6_reply)
# IPv4 in to IPv6 tunnel
p4 = (p_ether / p_ip4 / p_payload)
p4_reply = (IPv6(src=self.pg0.local_ip6,
dst=self.pg1.remote_ip6, hlim=64, tc=42) /
p_ip4 / p_payload)
p4_reply[1].ttl -= 1
rx = self.send_and_expect(self.pg0, p4*11, self.pg1)
for p in rx:
self.validate(p[1], p4_reply)
def test_decap(self):
""" ip{v4,v6} over ip6 test decap """
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
p_ip6 = IPv6(src="1::1", dst="DEAD::1", tc=42, nh='UDP')
p_ip4 = IP(src="1.2.3.4", dst=self.pg0.remote_ip4)
p_payload = UDP(sport=1234, dport=1234)
# Decapsulation
# IPv6 tunnel to IPv4
p4 = (p_ether / IPv6(src=self.pg1.remote_ip6,
dst=self.pg0.local_ip6) / p_ip4 / p_payload)
p4_reply = (p_ip4 / p_payload)
p4_reply.ttl -= 1
rx = self.send_and_expect(self.pg1, p4*11, self.pg0)
for p in rx:
self.validate(p[1], p4_reply)
# IPv6 tunnel to IPv6
p_ip6 = IPv6(src="1:2:3::4", dst=self.pg0.remote_ip6)
p6 = (p_ether / IPv6(src=self.pg1.remote_ip6,
dst=self.pg0.local_ip6) / p_ip6 / p_payload)
p6_reply = (p_ip6 / p_payload)
p6_reply.hlim = 63
rx = self.send_and_expect(self.pg1, p6*11, self.pg0)
for p in rx:
self.validate(p[1], p6_reply)
def test_frag(self):
""" ip{v4,v6} over ip6 test frag """
p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac)
p_ip6 = IPv6(src="1::1", dst="DEAD::1", tc=42, nh='UDP')
p_ip4 = IP(src="1.2.3.4", dst=self.pg0.remote_ip4)
p_payload = UDP(sport=1234, dport=1234)
#
# Fragmentation / Reassembly and Re-fragmentation
#
rv = self.vapi.ip_reassembly_enable_disable(
sw_if_index=self.pg1.sw_if_index,
enable_ip6=1)
# Send lots of fragments, verify reassembled packet
before_cnt = self.statistics.get_counter(
'/err/ipip6-input/packets decapsulated')
frags, p6_reply = self.generate_ip6_frags(3131, 1400)
f = []
for i in range(0, 1000):
f.extend(frags)
self.pg1.add_stream(f)
self.pg_enable_capture()
self.pg_start()
rx = self.pg0.get_capture(1000)
for p in rx:
self.validate(p[1], p6_reply)
cnt = self.statistics.get_counter(
'/err/ipip6-input/packets decapsulated')
self.assertEqual(cnt, before_cnt + 1000)
f = []
r = []
# TODO: Check out why reassembly of atomic fragments don't work
for i in range(10, 90):
frags, p6_reply = self.generate_ip6_frags(i * 100, 1000)
f.extend(frags)
r.extend(p6_reply)
self.pg_enable_capture()
self.pg1.add_stream(f)
self.pg_start()
rx = self.pg0.get_capture(80)
i = 0
for p in rx:
self.validate(p[1], r[i])
i += 1
# Simple fragmentation
p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1280, 0, 0, 0])
# IPv6 in to IPv6 tunnel
p_payload = UDP(sport=1234, dport=1234) / self.payload(1300)
p6 = (p_ether / p_ip6 / p_payload)
p6_reply = (IPv6(src=self.pg0.local_ip6, dst=self.pg1.remote_ip6,
hlim=63, tc=42) /
p_ip6 / p_payload)
p6_reply[1].hlim -= 1
self.pg_enable_capture()
self.pg0.add_stream(p6)
self.pg_start()
rx = self.pg1.get_capture(2)
# Scapy defragment doesn't deal well with multiple layers
# of samy type / Ethernet header first
f = [p[1] for p in rx]
reass_pkt = defragment6(f)
self.validate(reass_pkt, p6_reply)
# Now try with re-fragmentation
#
# Send large fragments to tunnel head-end, for the tunnel head end
# to reassemble and then refragment out the tunnel again.
# Hair-pinning
#
self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1280, 0, 0, 0])
frags, p6_reply = self.generate_ip6_hairpin_frags(8000, 1200)
self.pg_enable_capture()
self.pg1.add_stream(frags)
self.pg_start()
rx = self.pg1.get_capture(7)
f = [p[1] for p in rx]
reass_pkt = defragment6(f)
p6_reply.id = 256
self.validate(reass_pkt, p6_reply)
def test_ipip_create(self):
""" ipip create / delete interface test """
rv = self.vapi.ipip_add_tunnel(
src_address=inet_pton(AF_INET, '1.2.3.4'),
dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0)
sw_if_index = rv.sw_if_index
self.vapi.ipip_del_tunnel(sw_if_index)
def test_ipip_vrf_create(self):
""" ipip create / delete interface VRF test """
t = VppIpTable(self, 20)
t.add_vpp_config()
rv = self.vapi.ipip_add_tunnel(
src_address=inet_pton(AF_INET, '1.2.3.4'),
dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0,
table_id=20)
sw_if_index = rv.sw_if_index
self.vapi.ipip_del_tunnel(sw_if_index)
def payload(self, len):
return 'x' * len
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
| 35.278626
| 78
| 0.581197
| 2,644
| 18,486
| 3.822995
| 0.099849
| 0.033241
| 0.035615
| 0.01108
| 0.823506
| 0.792442
| 0.774436
| 0.732192
| 0.700139
| 0.674021
| 0
| 0.064991
| 0.304988
| 18,486
| 523
| 79
| 35.34608
| 0.721747
| 0.079736
| 0
| 0.664948
| 0
| 0
| 0.026968
| 0.007128
| 0
| 0
| 0.000238
| 0.001912
| 0.015464
| 1
| 0.061856
| false
| 0
| 0.020619
| 0.005155
| 0.103093
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
b7c96c90d6ec9edfe65058d5cf2f41dc8adfe02a
| 42
|
py
|
Python
|
phathom/io/__init__.py
|
chunglabmit/phathom
|
304db7a95e898e9b03d6b2640172752d21a7e3ed
|
[
"MIT"
] | 1
|
2018-04-18T11:54:29.000Z
|
2018-04-18T11:54:29.000Z
|
phathom/io/__init__.py
|
chunglabmit/phathom
|
304db7a95e898e9b03d6b2640172752d21a7e3ed
|
[
"MIT"
] | 2
|
2018-04-05T20:53:52.000Z
|
2018-11-01T16:37:39.000Z
|
phathom/io/__init__.py
|
chunglabmit/phathom
|
304db7a95e898e9b03d6b2640172752d21a7e3ed
|
[
"MIT"
] | null | null | null |
from phathom.io import tiff, imaris, zarr
| 21
| 41
| 0.785714
| 7
| 42
| 4.714286
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.142857
| 42
| 1
| 42
| 42
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
b7cafb085ed19a53bc60b2631b1acb8f7736566f
| 244
|
py
|
Python
|
OpenGLCffi/GLES3/EXT/OVR/multiview.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GLES3/EXT/OVR/multiview.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GLES3/EXT/OVR/multiview.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
from OpenGLCffi.GLES3 import params
@params(api='gles3', prms=['target', 'attachment', 'texture', 'level', 'baseViewIndex', 'numViews'])
def glFramebufferTextureMultiviewOVR(target, attachment, texture, level, baseViewIndex, numViews):
pass
| 34.857143
| 100
| 0.762295
| 24
| 244
| 7.75
| 0.666667
| 0.172043
| 0.247312
| 0.301075
| 0.526882
| 0.526882
| 0
| 0
| 0
| 0
| 0
| 0.009009
| 0.090164
| 244
| 6
| 101
| 40.666667
| 0.828829
| 0
| 0
| 0
| 0
| 0
| 0.223141
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.25
| 0.25
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
b7e2847ccbd8bde6ee1e6ba9914e22184f735392
| 14,994
|
py
|
Python
|
test/test_basic.py
|
lutraconsulting/mergin-work-packages
|
87850b9ca5069fbaf973a9341dca6aee72912528
|
[
"MIT"
] | 4
|
2021-03-03T09:39:00.000Z
|
2021-08-01T00:00:37.000Z
|
test/test_basic.py
|
lutraconsulting/mergin-workpackages
|
87850b9ca5069fbaf973a9341dca6aee72912528
|
[
"MIT"
] | 33
|
2021-03-03T12:21:51.000Z
|
2022-02-17T10:24:20.000Z
|
test/test_basic.py
|
lutraconsulting/mergin-workpackages
|
87850b9ca5069fbaf973a9341dca6aee72912528
|
[
"MIT"
] | 1
|
2021-04-16T18:28:34.000Z
|
2021-04-16T18:28:34.000Z
|
import glob
import os
import shutil
from tempfile import TemporaryDirectory
import sqlite3
from .init_test_data import (
create_farm_dataset,
open_layer_and_create_feature,
open_layer_and_update_feature,
open_layer_and_delete_feature,
)
from wp import load_config_from_yaml, make_work_packages
from wp_utils import escape_double_quotes
this_dir = os.path.dirname(os.path.realpath(__file__))
def _assert_row_counts(gpkg_filename, expected_farms, expected_trees):
"""Raises assertion errors if tables do not have the right number of rows"""
db = sqlite3.connect(gpkg_filename)
c = db.cursor()
c.execute("SELECT COUNT(*) FROM farms")
assert c.fetchone()[0] == expected_farms
c.execute("SELECT COUNT(*) FROM trees")
assert c.fetchone()[0] == expected_trees
def _assert_value_equals(gpkg_filename, table_name, fid, field_name, expected_value):
"""Raises assertion error if value of a particular field of a given feature
does not equal the expected value"""
db = sqlite3.connect(gpkg_filename)
c = db.cursor()
field_name_escaped = escape_double_quotes(field_name)
table_name_escaped = escape_double_quotes(table_name)
c.execute(f"""SELECT {field_name_escaped} FROM {table_name_escaped} WHERE fid = ?""", (fid,))
row = c.fetchone()
if row is None:
assert False, f"Missing row for fid {fid}"
assert row[0] == expected_value
def _assert_row_missing(gpkg_filename, table_name, fid):
"""Raises assertion error if given feature is present in the table"""
db = sqlite3.connect(gpkg_filename)
c = db.cursor()
table_name_escaped = escape_double_quotes(table_name)
c.execute(f"""SELECT count(*) FROM {table_name_escaped} WHERE fid = ?""", (fid,))
row = c.fetchone()
assert row[0] == 0, f"Row for fid {fid} is present but it should not be"
def _assert_row_exists(gpkg_filename, table_name, fid):
"""Raises assertion error if given feature is NOT present in the table"""
db = sqlite3.connect(gpkg_filename)
c = db.cursor()
table_name_escaped = escape_double_quotes(table_name)
c.execute(f"""SELECT count(*) FROM {table_name_escaped} WHERE fid = ?""", (fid,))
row = c.fetchone()
assert row[0] == 1, f"Row for fid {fid} is not present but it should be"
def _make_initial_farm_work_packages(config_file):
"""
1. create the initial "farms" dataset
2. run the WP algorithm with the initial dataset and given config file
Returns temporary directory object.
"""
tmp_dir_obj = TemporaryDirectory(prefix="test-mergin-work-packages-")
tmp_dir = tmp_dir_obj.name
os.makedirs(os.path.join(tmp_dir, "input"))
# get data
create_farm_dataset(os.path.join(tmp_dir, "input", "master.gpkg"))
# get config
wp_config = load_config_from_yaml(config_file)
# run alg
make_work_packages(tmp_dir, wp_config)
return tmp_dir_obj
def _prepare_next_run_work_packages(tmp_dir_1):
"""Creates a new temp directory with base+input files being output from the first step.
After this, work packaging can be run using the new temp directory, which is returned.
"""
tmp_dir_2 = TemporaryDirectory(prefix="test-mergin-work-packages-")
os.makedirs(os.path.join(tmp_dir_2.name, "base"))
os.makedirs(os.path.join(tmp_dir_2.name, "input"))
shutil.copy(os.path.join(tmp_dir_1.name, "output", "remap.db"), os.path.join(tmp_dir_2.name, "base", "remap.db"))
for file_path in glob.glob(os.path.join(tmp_dir_1.name, "output", "*.gpkg")):
file_name = os.path.basename(file_path)
shutil.copy(file_path, os.path.join(tmp_dir_2.name, "base", file_name))
shutil.copy(file_path, os.path.join(tmp_dir_2.name, "input", file_name))
return tmp_dir_2
def _keep_tmp_dir(tmp_dir, new_dir):
"""Makes a copy of a TemporaryDirectory. This is useful for debugging because
TemporaryDirectory has no way to disable removal if needed"""
if os.path.exists(new_dir):
shutil.rmtree(new_dir)
shutil.copytree(tmp_dir.name, new_dir)
def test_farm_data():
"""Check whether the test data init function returns what we expect"""
tmp_dir_obj = TemporaryDirectory(prefix="test-mergin-work-packages-")
farm_gpkg = os.path.join(tmp_dir_obj.name, "farms.gpkg")
create_farm_dataset(farm_gpkg)
_assert_row_counts(farm_gpkg, expected_farms=4, expected_trees=9)
def test_first_run():
"""Checks whether the first run correctly generates work package data with 'filter-column' method"""
tmp_dir = _make_initial_farm_work_packages(os.path.join(this_dir, "config-farm-basic.yml"))
# run checks
output_dir = os.path.join(tmp_dir.name, "output")
output_files = os.listdir(output_dir)
assert "Emma.gpkg" in output_files
assert "Kyle.gpkg" in output_files
assert "master.gpkg" in output_files
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=9)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=2)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
def test_first_run_filtering_geom():
"""Checks whether the first run correctly generates work package data with 'filter-geometry' method"""
tmp_dir = _make_initial_farm_work_packages(os.path.join(this_dir, "config-farm-geom.yml"))
# run checks
output_dir = os.path.join(tmp_dir.name, "output")
output_files = os.listdir(output_dir)
assert "Emma.gpkg" in output_files
assert "Kyle.gpkg" in output_files
assert "master.gpkg" in output_files
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=9)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=2, expected_trees=3)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=3, expected_trees=1)
def test_update_row_wp():
"""One row has been updated in WP, no changes in master"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify a WP dataset - update a tree (master fid 8 mapped to 1000000 for Kyle)
open_layer_and_update_feature(
os.path.join(tmp_dir_2.name, "input", "Kyle.gpkg"), "trees", 1000000, {"age_years": 10}
)
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be the same number of rows as initially
# and updated age both in master + kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=9)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=2)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_value_equals(os.path.join(output_dir, "master.gpkg"), "trees", 8, "age_years", 10)
_assert_value_equals(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000000, "age_years", 10)
def test_update_row_master():
"""One row has been updated in master, no changes in WP"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify master dataset - update a tree (master fid 9 mapped to 1000001 for Kyle)
open_layer_and_update_feature(os.path.join(tmp_dir_2.name, "input", "master.gpkg"), "trees", 9, {"age_years": 20})
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be the same number of rows as initially
# and updated age both in master + kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=9)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=2)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_value_equals(os.path.join(output_dir, "master.gpkg"), "trees", 9, "age_years", 20)
_assert_value_equals(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000001, "age_years", 20)
def test_update_row_master_and_wp():
"""One row updated in master, another row in WP (no conflict)"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify a WP dataset - update a tree (master fid 8 mapped to 1000000 for Kyle)
open_layer_and_update_feature(
os.path.join(tmp_dir_2.name, "input", "Kyle.gpkg"), "trees", 1000000, {"age_years": 30}
)
# modify master dataset - update a tree (master fid 9 mapped to 1000001 for Kyle)
open_layer_and_update_feature(os.path.join(tmp_dir_2.name, "input", "master.gpkg"), "trees", 9, {"age_years": 40})
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be the same number of rows as initially
# and updated age both in master + kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=9)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=2)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_value_equals(os.path.join(output_dir, "master.gpkg"), "trees", 8, "age_years", 30)
_assert_value_equals(os.path.join(output_dir, "master.gpkg"), "trees", 9, "age_years", 40)
_assert_value_equals(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000000, "age_years", 30)
_assert_value_equals(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000001, "age_years", 40)
def test_delete_row_wp():
"""One row deleted in WP, no changes in master"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify a WP dataset - delete a tree (master fid 8 mapped to 1000000 for Kyle)
open_layer_and_delete_feature(os.path.join(tmp_dir_2.name, "input", "Kyle.gpkg"), "trees", 1000000)
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be one tree missing for master and for Kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=8)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=1)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_row_missing(os.path.join(output_dir, "master.gpkg"), "trees", 8)
def test_delete_row_master():
"""One row deleted in master, no changes in WP"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify a WP dataset - delete a tree (master fid 9 mapped to 1000001 for Kyle)
open_layer_and_delete_feature(os.path.join(tmp_dir_2.name, "input", "master.gpkg"), "trees", 9)
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be one tree missing for master and for Kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=8)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=1)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_row_missing(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000001)
def test_insert_row_wp():
"""One row has been added in WP, no changes in master"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify a WP dataset - add a row
open_layer_and_create_feature(
os.path.join(tmp_dir_2.name, "input", "Kyle.gpkg"), "trees", "POINT(6 16)", {"tree_species_id": 1, "farm_id": 4}
)
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be one new tree in master and one new tree for Kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=10)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=3)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_row_exists(os.path.join(output_dir, "master.gpkg"), "trees", 10)
def test_insert_row_master():
"""One row has inserted in master, no changes in WP"""
config_file = os.path.join(this_dir, "config-farm-basic.yml")
tmp_dir_1 = _make_initial_farm_work_packages(config_file)
tmp_dir_2 = _prepare_next_run_work_packages(tmp_dir_1)
# modify master dataset - add a row
open_layer_and_create_feature(
os.path.join(tmp_dir_2.name, "input", "master.gpkg"),
"trees",
"POINT(9 19)",
{"tree_species_id": 1, "farm_id": 4},
)
# run work packaging
wp_config = load_config_from_yaml(config_file)
make_work_packages(tmp_dir_2.name, wp_config)
output_dir = os.path.join(tmp_dir_2.name, "output")
# there should be one new tree in master and one new tree for Kyle
_assert_row_counts(os.path.join(output_dir, "master.gpkg"), expected_farms=4, expected_trees=10)
_assert_row_counts(os.path.join(output_dir, "Kyle.gpkg"), expected_farms=1, expected_trees=3)
_assert_row_counts(os.path.join(output_dir, "Emma.gpkg"), expected_farms=2, expected_trees=6)
_assert_row_exists(os.path.join(output_dir, "Kyle.gpkg"), "trees", 1000002)
# TODO: more test cases
# - delete_master_delete_wp # one row deleted in both master and WP
# - delete_master_update_wp # one row deleted in master while it is updated in WP
# - update_master_delete_wp # one row updated in master while it is deleted in WP
# - insert_row_master_and_wp # one row has bee inserted in master, another row in WP
# - update_master_update_wp # one row updated in master and the same row updated in WP
| 46.565217
| 120
| 0.73276
| 2,401
| 14,994
| 4.266556
| 0.08913
| 0.046271
| 0.073214
| 0.060914
| 0.82214
| 0.778504
| 0.748926
| 0.738286
| 0.712124
| 0.691332
| 0
| 0.02204
| 0.152728
| 14,994
| 321
| 121
| 46.71028
| 0.78432
| 0.201747
| 0
| 0.518135
| 0
| 0
| 0.134824
| 0.020833
| 0
| 0
| 0
| 0.003115
| 0.290155
| 1
| 0.088083
| false
| 0
| 0.041451
| 0
| 0.139896
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d01ab9ef37f626026ff8ff09e839d7841e95111
| 21,298
|
py
|
Python
|
tests/ile_components_test.py
|
NextCenturyCorporation/mcs-scene-generator
|
e0a6ee778359cadd2de682a5006581b7a6134431
|
[
"Apache-2.0"
] | 4
|
2021-02-04T03:57:52.000Z
|
2022-02-08T18:19:58.000Z
|
tests/ile_components_test.py
|
NextCenturyCorporation/mcs-scene-generator
|
e0a6ee778359cadd2de682a5006581b7a6134431
|
[
"Apache-2.0"
] | 68
|
2021-05-06T08:52:46.000Z
|
2022-03-23T16:46:03.000Z
|
tests/ile_components_test.py
|
NextCenturyCorporation/mcs-scene-generator
|
e0a6ee778359cadd2de682a5006581b7a6134431
|
[
"Apache-2.0"
] | 1
|
2021-02-04T03:21:57.000Z
|
2021-02-04T03:21:57.000Z
|
import pytest
from ideal_learning_env import ILEException, VectorFloatConfig
from ideal_learning_env.mock_component import MockClass, MockComponent
def test_ile_component_call_each_setter_on_init():
component = MockComponent({})
assert component._called_setter['bool_prop']
assert component._called_setter['class_prop']
assert component._called_setter['float_prop']
assert component._called_setter['int_prop']
assert component._called_setter['list_bool_prop']
assert component._called_setter['list_class_prop']
assert component._called_setter['list_float_prop']
assert component._called_setter['list_int_prop']
assert component._called_setter['list_str_prop']
assert component._called_setter['str_prop']
assert component._called_setter['union_bool_prop']
assert component._called_setter['union_class_prop']
assert component._called_setter['union_float_prop']
assert component._called_setter['union_int_prop']
assert component._called_setter['union_str_prop']
def test_ile_component_initialize_null():
component = MockComponent({})
assert component.bool_prop is None
assert component.class_prop is None
assert component.float_prop is None
assert component.int_prop is None
assert component.list_bool_prop is None
assert component.list_class_prop is None
assert component.list_float_prop is None
assert component.list_int_prop is None
assert component.list_str_prop is None
assert component.str_prop is None
assert component.union_bool_prop is None
assert component.union_class_prop is None
assert component.union_float_prop is None
assert component.union_int_prop is None
assert component.union_str_prop is None
component = MockComponent({
'bool_prop': None,
'class_prop': None,
'float_prop': None,
'int_prop': None,
'list_bool_prop': None,
'list_class_prop': None,
'list_float_prop': None,
'list_int_prop': None,
'list_str_prop': None,
'str_prop': None,
'union_bool_prop': None,
'union_class_prop': None,
'union_float_prop': None,
'union_int_prop': None,
'union_str_prop': None
})
assert component.bool_prop is None
assert component.class_prop is None
assert component.float_prop is None
assert component.int_prop is None
assert component.list_bool_prop is None
assert component.list_class_prop is None
assert component.list_float_prop is None
assert component.list_int_prop is None
assert component.list_str_prop is None
assert component.str_prop is None
assert component.union_bool_prop is None
assert component.union_class_prop is None
assert component.union_float_prop is None
assert component.union_int_prop is None
assert component.union_str_prop is None
def test_ile_component_initialize():
component = MockComponent({
'bool_prop': True,
'class_prop': {
'dict_prop': {'key1': 'value1'},
'int_prop': 0,
'list_dict_prop': [
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
'list_int_prop': [12, 34, 56, 78],
'list_vector_prop': [{}, {'x': 1, 'y': 2, 'z': 3}],
'union_int_prop': [78, 56, 34, 12],
'union_vector_prop': {'x': 0.3, 'y': 0.2, 'z': 0.1},
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 0.3}
},
'float_prop': 12.34,
'int_prop': 100,
'list_bool_prop': [False, True],
'list_class_prop': [{}, {
'dict_prop': {'key5': 'value5'},
'int_prop': -1,
'list_dict_prop': [
{'key6': 'value6'}, {'key7': 'value7', 'key8': 'value8'}
],
'list_int_prop': [87, 65, 43, 21],
'list_vector_prop': [{}, {'x': 9, 'y': 8, 'z': 7}],
'union_int_prop': [21, 43, 65, 87],
'union_vector_prop': {'x': 0.7, 'y': 0.8, 'z': 0.9},
'vector_prop': {'x': 0.9, 'y': 0.8, 'z': 0.7}
}],
'list_float_prop': [-1, -0.5, 0, 0.5, 1],
'list_int_prop': [-2, -1, 0, 1, 2],
'list_str_prop': ['a', 'b', 'c', 'd'],
'str_prop': 'foobar',
'union_bool_prop': False,
'union_class_prop': {
'dict_prop': {'keyA': 'valueA'},
'int_prop': 999,
'list_dict_prop': [
{'keyB': 'valueB'}, {'keyC': 'valueC', 'keyD': 'valueD'}
],
'list_int_prop': [123, 456],
'list_vector_prop': [{}, {'x': 4, 'y': 5, 'z': 6}],
'union_int_prop': [456, 123],
'union_vector_prop': {'x': 0.6, 'y': 0.5, 'z': 0.4},
'vector_prop': {'x': 0.4, 'y': 0.5, 'z': 0.6}
},
'union_float_prop': -12.34,
'union_int_prop': -100,
'union_str_prop': 'the quick brown fox'
})
assert component.bool_prop is True
assert component.class_prop == MockClass(
dict_prop={'key1': 'value1'},
int_prop=0,
list_dict_prop=[
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
list_int_prop=[12, 34, 56, 78],
list_vector_prop=[VectorFloatConfig(), VectorFloatConfig(1, 2, 3)],
union_int_prop=[78, 56, 34, 12],
union_vector_prop=VectorFloatConfig(0.3, 0.2, 0.1),
vector_prop=VectorFloatConfig(0.1, 0.2, 0.3)
)
assert component.float_prop == 12.34
assert component.int_prop == 100
assert component.list_bool_prop == [False, True]
assert component.list_class_prop == [
MockClass(),
MockClass(
dict_prop={'key5': 'value5'},
int_prop=-1,
list_dict_prop=[
{'key6': 'value6'}, {'key7': 'value7', 'key8': 'value8'}
],
list_int_prop=[87, 65, 43, 21],
list_vector_prop=[VectorFloatConfig(), VectorFloatConfig(9, 8, 7)],
union_int_prop=[21, 43, 65, 87],
union_vector_prop=VectorFloatConfig(0.7, 0.8, 0.9),
vector_prop=VectorFloatConfig(0.9, 0.8, 0.7)
)
]
assert component.list_float_prop == [-1, -0.5, 0, 0.5, 1]
assert component.list_int_prop == [-2, -1, 0, 1, 2]
assert component.list_str_prop == ['a', 'b', 'c', 'd']
assert component.str_prop == 'foobar'
assert component.union_bool_prop is False
assert component.union_class_prop == MockClass(
dict_prop={'keyA': 'valueA'},
int_prop=999,
list_dict_prop=[
{'keyB': 'valueB'}, {'keyC': 'valueC', 'keyD': 'valueD'}
],
list_int_prop=[123, 456],
list_vector_prop=[VectorFloatConfig(), VectorFloatConfig(4, 5, 6)],
union_int_prop=[456, 123],
union_vector_prop=VectorFloatConfig(0.6, 0.5, 0.4),
vector_prop=VectorFloatConfig(0.4, 0.5, 0.6)
)
assert component.union_float_prop == -12.34
assert component.union_int_prop == -100
assert component.union_str_prop == 'the quick brown fox'
def test_ile_component_update():
component = MockComponent({
'bool_prop': True,
'class_prop': {
'dict_prop': {'key1': 'value1'},
'int_prop': 0,
'list_dict_prop': [
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
'list_int_prop': [12, 34, 56, 78],
'list_vector_prop': [{}, {'x': 1, 'y': 2, 'z': 3}],
'union_int_prop': [78, 56, 34, 12],
'union_vector_prop': {'x': 0.3, 'y': 0.2, 'z': 0.1},
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 0.3}
},
'float_prop': 12.34,
'int_prop': 100,
'list_bool_prop': [False, True],
'list_class_prop': [{}, {
'dict_prop': {'key5': 'value5'},
'int_prop': -1,
'list_dict_prop': [
{'key6': 'value6'}, {'key7': 'value7', 'key8': 'value8'}
],
'list_int_prop': [87, 65, 43, 21],
'list_vector_prop': [{}, {'x': 9, 'y': 8, 'z': 7}],
'union_int_prop': [21, 43, 65, 87],
'union_vector_prop': {'x': 0.7, 'y': 0.8, 'z': 0.9},
'vector_prop': {'x': 0.9, 'y': 0.8, 'z': 0.7}
}],
'list_float_prop': [-1, -0.5, 0, 0.5, 1],
'list_int_prop': [-2, -1, 0, 1, 2],
'list_str_prop': ['a', 'b', 'c', 'd'],
'str_prop': 'foobar',
'union_bool_prop': False,
'union_class_prop': {
'dict_prop': {'keyA': 'valueA'},
'int_prop': 999,
'list_dict_prop': [
{'keyB': 'valueB'}, {'keyC': 'valueC', 'keyD': 'valueD'}
],
'list_int_prop': [123, 456],
'list_vector_prop': [{}, {'x': 4, 'y': 5, 'z': 6}],
'union_int_prop': [456, 123],
'union_vector_prop': {'x': 0.6, 'y': 0.5, 'z': 0.4},
'vector_prop': {'x': 0.4, 'y': 0.5, 'z': 0.6}
},
'union_float_prop': -12.34,
'union_int_prop': -100,
'union_str_prop': 'the quick brown fox'
})
scene = component.update_ile_scene({'existing_prop': True})
assert scene['existing_prop'] is True
assert scene['bool_prop'] is True
assert scene['class_prop'] == {
'dict_prop': {'key1': 'value1'},
'int_prop': 0,
'list_dict_prop': [
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
'list_int_prop': [12, 34, 56, 78],
'list_vector_prop': [
{'x': 0, 'y': 0, 'z': 0},
{'x': 1, 'y': 2, 'z': 3}
],
'union_int_prop': [78, 56, 34, 12],
'union_vector_prop': {'x': 0.3, 'y': 0.2, 'z': 0.1},
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 0.3}
}
assert scene['float_prop'] == 12.34
assert scene['int_prop'] == 100
assert scene['list_bool_prop'] == [False, True]
assert scene['list_class_prop'] == [{
'dict_prop': None,
'int_prop': None,
'list_dict_prop': None,
'list_int_prop': None,
'list_vector_prop': None,
'union_int_prop': None,
'union_vector_prop': None,
'vector_prop': None
}, {
'dict_prop': {'key5': 'value5'},
'int_prop': -1,
'list_dict_prop': [
{'key6': 'value6'}, {'key7': 'value7', 'key8': 'value8'}
],
'list_int_prop': [87, 65, 43, 21],
'list_vector_prop': [
{'x': 0, 'y': 0, 'z': 0},
{'x': 9, 'y': 8, 'z': 7}
],
'union_int_prop': [21, 43, 65, 87],
'union_vector_prop': {'x': 0.7, 'y': 0.8, 'z': 0.9},
'vector_prop': {'x': 0.9, 'y': 0.8, 'z': 0.7}
}]
assert scene['list_float_prop'] == [-1, -0.5, 0, 0.5, 1]
assert scene['list_int_prop'] == [-2, -1, 0, 1, 2]
assert scene['list_str_prop'] == ['a', 'b', 'c', 'd']
assert scene['str_prop'] == 'foobar'
assert scene['union_bool_prop'] is False
assert scene['union_class_prop'] == {
'dict_prop': {'keyA': 'valueA'},
'int_prop': 999,
'list_dict_prop': [
{'keyB': 'valueB'}, {'keyC': 'valueC', 'keyD': 'valueD'}
],
'list_int_prop': [123, 456],
'list_vector_prop': [
{'x': 0, 'y': 0, 'z': 0},
{'x': 4, 'y': 5, 'z': 6}
],
'union_int_prop': [456, 123],
'union_vector_prop': {'x': 0.6, 'y': 0.5, 'z': 0.4},
'vector_prop': {'x': 0.4, 'y': 0.5, 'z': 0.6}
}
assert scene['union_float_prop'] == -12.34
assert scene['union_int_prop'] == -100
assert scene['union_str_prop'] == 'the quick brown fox'
def test_ile_component_validate_fail_bool():
with pytest.raises(ILEException):
MockComponent({
'bool_prop': 'foobar'
})
def test_ile_component_validate_fail_class():
with pytest.raises(ILEException):
MockComponent({
'class_prop': 'foobar'
})
def test_ile_component_validate_fail_class_nested_class():
with pytest.raises(ILEException):
MockComponent({
'class_prop': {
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 'foobar'}
}
})
def test_ile_component_validate_fail_class_nested_dict():
with pytest.raises(ILEException):
MockComponent({
'class_prop': {
'dict_prop': {'key': 1234}
}
})
def test_ile_component_validate_fail_class_nested_list():
with pytest.raises(ILEException):
MockComponent({
'class_prop': {
'list_int_prop': [12, 'foobar']
}
})
def test_ile_component_validate_fail_class_nested_primitive():
with pytest.raises(ILEException):
MockComponent({
'class_prop': {
'int_prop': 'foobar'
}
})
def test_ile_component_validate_fail_float():
with pytest.raises(ILEException):
MockComponent({
'float_prop': 'foobar'
})
def test_ile_component_validate_fail_int():
with pytest.raises(ILEException):
MockComponent({
'int_prop': 'foobar'
})
def test_ile_component_validate_fail_int_if_bool():
# Specific case since bool extends int
with pytest.raises(ILEException):
MockComponent({
'int_prop': True
})
def test_ile_component_validate_fail_list_bool():
with pytest.raises(ILEException):
MockComponent({
'list_bool_prop': [False, 'foobar']
})
def test_ile_component_validate_fail_list_class():
with pytest.raises(ILEException):
MockComponent({
'list_class_prop': [{
'dict_prop': {'key1': 'value1'},
'int_prop': 0,
'list_dict_prop': [
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
'list_int_prop': [12, 34, 56, 78],
'list_vector_prop': [{}, {'x': 1, 'y': 2, 'z': 3}],
'union_int_prop': [78, 56, 34, 12],
'union_vector_prop': {'x': 0.3, 'y': 0.2, 'z': 0.1},
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 0.3}
}, 'foobar']
})
def test_ile_component_validate_fail_list_class_nested_class():
with pytest.raises(ILEException):
MockComponent({
'list_class_prop': [{
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 'foobar'}
}]
})
def test_ile_component_validate_fail_list_class_nested_dict():
with pytest.raises(ILEException):
MockComponent({
'list_class_prop': [{
'dict_prop': {'key': 1234}
}]
})
def test_ile_component_validate_fail_list_class_nested_list():
with pytest.raises(ILEException):
MockComponent({
'list_class_prop': [{
'list_int_prop': [12, 'foobar']
}]
})
def test_ile_component_validate_fail_list_class_nested_primitive():
with pytest.raises(ILEException):
MockComponent({
'list_class_prop': [{
'int_prop': 'foobar'
}]
})
def test_ile_component_validate_fail_list_float():
with pytest.raises(ILEException):
MockComponent({
'list_float_prop': [1.0, 'foobar']
})
def test_ile_component_validate_fail_list_int():
with pytest.raises(ILEException):
MockComponent({
'list_int_prop': [1, 'foobar']
})
def test_ile_component_validate_fail_list_int_if_bool():
# Specific case since bool extends int
with pytest.raises(ILEException):
MockComponent({
'list_int_prop': [True]
})
def test_ile_component_validate_fail_list_str():
with pytest.raises(ILEException):
MockComponent({
'list_str_prop': ['foobar', 1]
})
def test_ile_component_validate_fail_list_str_empty():
with pytest.raises(ILEException):
MockComponent({
'list_str_prop': ['']
})
def test_ile_component_validate_fail_str():
with pytest.raises(ILEException):
MockComponent({
'str_prop': 1
})
def test_ile_component_validate_fail_str_empty():
with pytest.raises(ILEException):
MockComponent({
'str_prop': ''
})
def test_ile_component_validate_fail_union_bool():
with pytest.raises(ILEException):
MockComponent({
'union_bool_prop': 'foobar'
})
def test_ile_component_validate_fail_union_class():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': 'foobar'
})
def test_ile_component_validate_fail_union_class_nested_class():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': {
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 'foobar'}
}
})
def test_ile_component_validate_fail_union_class_nested_dict():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': {
'dict_prop': {'key': 1234}
}
})
def test_ile_component_validate_fail_union_class_nested_list():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': {
'list_int_prop': [12, 'foobar']
}
})
def test_ile_component_validate_fail_union_class_nested_primitive():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': {
'int_prop': 'foobar'
}
})
def test_ile_component_validate_fail_union_float():
with pytest.raises(ILEException):
MockComponent({
'union_float_prop': 'foobar'
})
def test_ile_component_validate_fail_union_int():
with pytest.raises(ILEException):
MockComponent({
'union_int_prop': 'foobar'
})
def test_ile_component_validate_fail_union_int_if_bool():
# Specific case since bool extends int
with pytest.raises(ILEException):
MockComponent({
'union_int_prop': True
})
def test_ile_component_validate_fail_union_list_bool():
with pytest.raises(ILEException):
MockComponent({
'union_bool_prop': [False, 'foobar']
})
def test_ile_component_validate_fail_union_list_class():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': [{
'dict_prop': {'key1': 'value1'},
'int_prop': 0,
'list_dict_prop': [
{'key2': 'value2'}, {'key3': 'value3', 'key4': 'value4'}
],
'list_int_prop': [12, 34, 56, 78],
'list_vector_prop': [{}, {'x': 1, 'y': 2, 'z': 3}],
'union_int_prop': [78, 56, 34, 12],
'union_vector_prop': {'x': 0.3, 'y': 0.2, 'z': 0.1},
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 0.3}
}, 'foobar']
})
def test_ile_component_validate_fail_union_list_class_nested_class():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': [{
'vector_prop': {'x': 0.1, 'y': 0.2, 'z': 'foobar'}
}]
})
def test_ile_component_validate_fail_union_list_class_nested_dict():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': [{
'dict_prop': {'key': 1234}
}]
})
def test_ile_component_validate_fail_union_list_class_nested_list():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': [{
'list_int_prop': [12, 'foobar']
}]
})
def test_ile_component_validate_fail_union_list_class_nested_primitive():
with pytest.raises(ILEException):
MockComponent({
'union_class_prop': [{
'int_prop': 'foobar'
}]
})
def test_ile_component_validate_fail_union_list_float():
with pytest.raises(ILEException):
MockComponent({
'union_float_prop': [1.0, 'foobar']
})
def test_ile_component_validate_fail_union_list_int():
with pytest.raises(ILEException):
MockComponent({
'union_int_prop': [1, 'foobar']
})
def test_ile_component_validate_fail_union_list_int_if_bool():
# Specific case since bool extends int
with pytest.raises(ILEException):
MockComponent({
'union_int_prop': [True]
})
def test_ile_component_validate_fail_union_list_str():
with pytest.raises(ILEException):
MockComponent({
'union_str_prop': ['foobar', 1]
})
def test_ile_component_validate_fail_union_list_str_empty():
with pytest.raises(ILEException):
MockComponent({
'union_str_prop': ['']
})
def test_ile_component_validate_fail_union_str():
with pytest.raises(ILEException):
MockComponent({
'union_str_prop': 1
})
def test_ile_component_validate_fail_union_str_empty():
with pytest.raises(ILEException):
MockComponent({
'union_str_prop': ''
})
| 31.931034
| 79
| 0.561086
| 2,541
| 21,298
| 4.365998
| 0.044471
| 0.053633
| 0.043267
| 0.082207
| 0.929421
| 0.883
| 0.806652
| 0.770326
| 0.72697
| 0.62322
| 0
| 0.04505
| 0.288149
| 21,298
| 666
| 80
| 31.978979
| 0.686696
| 0.006902
| 0
| 0.671986
| 0
| 0
| 0.186466
| 0
| 0
| 0
| 0
| 0
| 0.134752
| 1
| 0.085106
| false
| 0
| 0.005319
| 0
| 0.090426
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d197e25e571496b92cc2b20fe9d9bf0813b771e
| 84
|
py
|
Python
|
src/easyterm/__init__.py
|
marco-mariotti/easyterm
|
ec7b620136662affc65492bebaa5e8f695a62cda
|
[
"MIT"
] | null | null | null |
src/easyterm/__init__.py
|
marco-mariotti/easyterm
|
ec7b620136662affc65492bebaa5e8f695a62cda
|
[
"MIT"
] | 1
|
2022-01-10T14:15:51.000Z
|
2022-01-10T14:15:51.000Z
|
src/easyterm/__init__.py
|
marco-mariotti/easyterm
|
ec7b620136662affc65492bebaa5e8f695a62cda
|
[
"MIT"
] | null | null | null |
from .colorprint import *
from .commandutils import *
from .commandlineopt import *
| 21
| 29
| 0.785714
| 9
| 84
| 7.333333
| 0.555556
| 0.30303
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.142857
| 84
| 3
| 30
| 28
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0.333333
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
4d26ef4466a29c568ad4b62a7304719bb60d319f
| 4,858
|
py
|
Python
|
ScratchPad_PyDev/com.neustar.programming.contest/nine/MyMainPyDev1.py
|
rsins/Scratchpad-Java
|
ed5593a1fa9afc62ef8d567f928001faae163880
|
[
"Apache-2.0"
] | null | null | null |
ScratchPad_PyDev/com.neustar.programming.contest/nine/MyMainPyDev1.py
|
rsins/Scratchpad-Java
|
ed5593a1fa9afc62ef8d567f928001faae163880
|
[
"Apache-2.0"
] | null | null | null |
ScratchPad_PyDev/com.neustar.programming.contest/nine/MyMainPyDev1.py
|
rsins/Scratchpad-Java
|
ed5593a1fa9afc62ef8d567f928001faae163880
|
[
"Apache-2.0"
] | null | null | null |
#----------- Question 1 ------------------
breakLoop = False
n = 0
while not breakLoop:
n = n + 1
sum = 0
for i in range (1, n+1):
sum = sum + 2 ** (i-1)
if (sum >= (200*i)):
breakLoop = True
print("----------------- Question 1 -------------------")
print(n)
print("Answer = ", n)
#------------ Question 2 --------------------
sues = dict()
sueMatch = dict()
with open("D:\\Ravi\\My_Programs\\Eclipse_Workspace\\ScratchPad\\src\\com\\neustar\\programming\\contest\\nine\\input.txt") as file:
for line in file:
words = line.replace(":","").replace(",","").replace("\n","").split()
n = int(words[1])
types = dict()
types["children"] = -1
types["cats"] = -1
types["samoyeds"] = -1
types["pomeranians"] = -1
types["akitas"] = -1
types["vizslas"] = -1
types["goldfish"] = -1
types["trees"] = -1
types["cars"] = -1
types["perfumes"] = -1
types[str(words[2])] = int(words[3])
types[str(words[4])] = int(words[5])
types[str(words[6])] = int(words[7])
sues[n] = types
matchCount = 0
if types["children"] == 3:
matchCount = matchCount + 1
if types["cats"] == 7:
matchCount = matchCount + 1
if types["samoyeds"] == 2:
matchCount = matchCount + 1
if types["pomeranians"] == 3:
matchCount = matchCount + 1
if types["akitas"] == 0:
matchCount = matchCount + 1
if types["vizslas"] == 0:
matchCount = matchCount + 1
if types["goldfish"] == 5:
matchCount = matchCount + 1
if types["trees"] == 3:
matchCount = matchCount + 1
if types["cars"] == 2:
matchCount = matchCount + 1
if types["perfumes"] == 1:
matchCount = matchCount + 1
if matchCount in sueMatch:
l = sueMatch[matchCount]
l.append(n)
sueMatch[matchCount] = l
else:
l = list()
l.append(n)
sueMatch[matchCount] = l
print("----------------- Question 2 -------------------")
print("Number of matches - Aunt Sue #")
for i in sueMatch:
print(i, " - ", str(sueMatch[i]))
print("Answer = ", sueMatch[max(sueMatch.keys())])
#------------------ Question 3 ----------------------
sues = dict()
sueMatch = dict()
with open("D:\\Ravi\\My_Programs\\Eclipse_Workspace\\ScratchPad\\src\\com\\neustar\\programming\\contest\\nine\\input.txt") as file:
for line in file:
words = line.replace(":","").replace(",","").replace("\n","").split()
n = int(words[1])
types = dict()
types["children"] = -1
types["cats"] = -1
types["samoyeds"] = -1
types["pomeranians"] = -1
types["akitas"] = -1
types["vizslas"] = -1
types["goldfish"] = -1
types["trees"] = -1
types["cars"] = -1
types["perfumes"] = -1
types[str(words[2])] = int(words[3])
types[str(words[4])] = int(words[5])
types[str(words[6])] = int(words[7])
sues[n] = types
matchCount = 0
if types["children"] == 3 and types["children"] != -1 :
matchCount = matchCount + 1
if types["cats"] > 7 and types["cats"] != -1:
matchCount = matchCount + 1
if types["samoyeds"] == 2 and types["samoyeds"] != -1:
matchCount = matchCount + 1
if types["pomeranians"] < 3 and types["pomeranians"] != -1:
matchCount = matchCount + 1
if types["akitas"] == 0 and types["akitas"] != -1:
matchCount = matchCount + 1
if types["vizslas"] == 0 and types["vizslas"] != -1:
matchCount = matchCount + 1
if types["goldfish"] < 5 and types["goldfish"] != -1:
matchCount = matchCount + 1
if types["trees"] > 3 and types["trees"] != -1:
matchCount = matchCount + 1
if types["cars"] == 2 and types["cars"] != -1:
matchCount = matchCount + 1
if types["perfumes"] == 1 and types["perfumes"] != -1:
matchCount = matchCount + 1
if matchCount in sueMatch:
l = sueMatch[matchCount]
l.append(n)
sueMatch[matchCount] = l
else:
l = list()
l.append(n)
sueMatch[matchCount] = l
print("----------------- Question 3 -------------------")
print("Number of matches - Aunt Sue #")
for i in sueMatch:
print(i, " - ", str(sueMatch[i]))
print("Answer = ", sueMatch[max(sueMatch.keys())])
| 34.453901
| 133
| 0.464594
| 508
| 4,858
| 4.435039
| 0.149606
| 0.058589
| 0.186418
| 0.204172
| 0.874834
| 0.874834
| 0.870839
| 0.591212
| 0.591212
| 0.591212
| 0
| 0.031796
| 0.339646
| 4,858
| 140
| 134
| 34.7
| 0.670511
| 0.028613
| 0
| 0.721311
| 0
| 0.016393
| 0.177204
| 0.04813
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.090164
| 0
| 0
| 0
| null | 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d5eadad3f5870ace99ebca38207187f55ce493a
| 1,426
|
py
|
Python
|
tests/api/v1/test_hints.py
|
AIica/Crypto-2020
|
8980fdd3c20651eb6fd4a66fa72c1f9099dc23d7
|
[
"Apache-2.0"
] | 2
|
2019-06-19T07:11:28.000Z
|
2019-06-21T05:30:07.000Z
|
tests/api/v1/test_hints.py
|
AIica/Crypto-2020
|
8980fdd3c20651eb6fd4a66fa72c1f9099dc23d7
|
[
"Apache-2.0"
] | null | null | null |
tests/api/v1/test_hints.py
|
AIica/Crypto-2020
|
8980fdd3c20651eb6fd4a66fa72c1f9099dc23d7
|
[
"Apache-2.0"
] | 1
|
2019-11-09T19:00:41.000Z
|
2019-11-09T19:00:41.000Z
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tests.helpers import *
def test_api_hint_get_non_admin():
"""Can the users get /api/v1/hints if not admin"""
app = create_ctfd()
with app.app_context():
with login_as_user(app) as client:
r = client.get('/api/v1/hints', json="")
assert r.status_code == 403
destroy_ctfd(app)
def test_api_hint_get_admin():
"""Can the users get /api/v1/hints if admin"""
app = create_ctfd()
with app.app_context():
with login_as_user(app, name="admin") as client:
r = client.get('/api/v1/hints', json="")
assert r.status_code == 200
destroy_ctfd(app)
def test_api_hint_post_non_admin():
"""Can the users post /api/v1/hints if not admin"""
app = create_ctfd()
with app.app_context():
with login_as_user(app) as client:
r = client.post('/api/v1/hints', json="")
assert r.status_code == 403
destroy_ctfd(app)
def test_api_hint_post_admin():
"""Can the users post /api/v1/hints if admin"""
app = create_ctfd()
with app.app_context():
gen_challenge(app.db)
with login_as_user(app, name="admin") as client:
r = client.post('/api/v1/hints', json={
"content": "hint",
"cost": "1",
"challenge": 1})
assert r.status_code == 200
destroy_ctfd(app)
| 29.102041
| 56
| 0.586957
| 205
| 1,426
| 3.873171
| 0.243902
| 0.050378
| 0.100756
| 0.070529
| 0.88665
| 0.853904
| 0.853904
| 0.853904
| 0.761965
| 0.63602
| 0
| 0.022137
| 0.271389
| 1,426
| 48
| 57
| 29.708333
| 0.74206
| 0.151473
| 0
| 0.666667
| 0
| 0
| 0.073232
| 0
| 0
| 0
| 0
| 0
| 0.121212
| 1
| 0.121212
| false
| 0
| 0.030303
| 0
| 0.151515
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d7115fd3744b9b7b6353469bb51b18b4556482b
| 145
|
py
|
Python
|
gunicorn_config.py
|
evan-rusin/fly-project
|
8afc697f2a9fb63317cca2763ed0ed76f9ef2ead
|
[
"BSD-2-Clause"
] | 15
|
2016-11-17T08:34:52.000Z
|
2021-11-12T07:08:58.000Z
|
gunicorn_config.py
|
evan-rusin/fly-project
|
8afc697f2a9fb63317cca2763ed0ed76f9ef2ead
|
[
"BSD-2-Clause"
] | 137
|
2015-12-07T19:48:03.000Z
|
2016-10-11T20:19:33.000Z
|
gunicorn_config.py
|
evan-rusin/fly-project
|
8afc697f2a9fb63317cca2763ed0ed76f9ef2ead
|
[
"BSD-2-Clause"
] | 11
|
2016-10-21T22:43:54.000Z
|
2021-08-28T14:41:02.000Z
|
command = '/usr/home/freebsd/py-fly/env/bin/gunicorn'
pythonpath = '/usr/home/freebsd/py-fly/src/fly_project'
bind = '127.0.0.1:8001'
workers = 3
| 36.25
| 55
| 0.724138
| 26
| 145
| 4
| 0.730769
| 0.134615
| 0.269231
| 0.307692
| 0.365385
| 0
| 0
| 0
| 0
| 0
| 0
| 0.08209
| 0.075862
| 145
| 4
| 56
| 36.25
| 0.69403
| 0
| 0
| 0
| 0
| 0
| 0.650685
| 0.554795
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d82f8c12ff32b9a039d3766c811641ac0ad84dd
| 10,034
|
py
|
Python
|
mlir/dialects/linalg.py
|
spcl/pymlir
|
88b81ab73d62d1bea81be79bd4a8a2fbae825d48
|
[
"BSD-3-Clause"
] | 80
|
2020-01-12T20:55:43.000Z
|
2022-03-29T09:23:41.000Z
|
mlir/dialects/linalg.py
|
spcl/pymlir
|
88b81ab73d62d1bea81be79bd4a8a2fbae825d48
|
[
"BSD-3-Clause"
] | 15
|
2020-04-05T22:43:37.000Z
|
2021-07-01T22:08:03.000Z
|
mlir/dialects/linalg.py
|
spcl/pymlir
|
88b81ab73d62d1bea81be79bd4a8a2fbae825d48
|
[
"BSD-3-Clause"
] | 15
|
2020-04-05T22:37:44.000Z
|
2022-03-28T06:36:12.000Z
|
""" Implementation of the Linalg dialect. """
import inspect
import sys
import mlir.astnodes as mast
from mlir.dialect import Dialect, DialectOp, is_op
from dataclasses import dataclass
from typing import Optional, List
@dataclass
class LinalgBatchMatmul(DialectOp):
a_id: mast.SsaId
b_id: mast.SsaId
a_type: mast.Type
b_type: mast.Type
c_id: mast.SsaId
c_type: mast.Type
out_type: Optional[mast.Type] = None
_syntax_ = [("linalg.batch_matmul"
" ins( {a_id.ssa_id} , {b_id.ssa_id} : {a_type.type} , {b_type.type} )"
" outs( {c_id.ssa_id} : {c_type.type} )"),
("linalg.batch_matmul"
" ins( {a_id.ssa_id} , {b_id.ssa_id} : {a_type.type} , {b_type.type} )"
" init( {c_id.ssa_id} : {c_type.type} ) -> {out_type.type}")]
@dataclass
class LinalgConvW(DialectOp):
in_id: mast.SsaId
filter_id: mast.SsaId
in_type: mast.Type
filter_type: mast.Type
out_id: mast.SsaId
out_type: mast.Type
_syntax_ = [("linalg.conv_1d"
" ins( {in_id.ssa_id} , {filter_id.ssa_id} : {in_type.type} , {filter_type.type} )"
" outs( {out_id.ssa_id} : {out_type.type} )")]
@dataclass
class LinalgConvHW(DialectOp):
in_id: mast.SsaId
filter_id: mast.SsaId
in_type: mast.Type
filter_type: mast.Type
out_id: mast.SsaId
out_type: mast.Type
_syntax_ = [("linalg.conv_2d"
" ins( {in_id.ssa_id} , {filter_id.ssa_id} : {in_type.type} , {filter_type.type} )"
" outs( {out_id.ssa_id} : {out_type.type} )")]
@dataclass
class LinalgConvDHW(DialectOp):
in_id: mast.SsaId
filter_id: mast.SsaId
in_type: mast.Type
filter_type: mast.Type
out_id: mast.SsaId
out_type: mast.Type
_syntax_ = [("linalg.conv_3d"
" ins( {in_id.ssa_id} , {filter_id.ssa_id} : {in_type.type} , {filter_type.type} )"
" outs( {out_id.ssa_id} : {out_type.type} )")]
@dataclass
class LinalgConv(DialectOp):
in_id: mast.SsaId
filter_id: mast.SsaId
in_type: mast.Type
filter_type: mast.Type
out_id: mast.SsaId
out_type: mast.Type
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.conv( {in_id.ssa_id} , {filter_id.ssa_id} , {out_id.ssa_id} ) "
"{attr.attribute_value} : {in_type.type} , {filter_type.type} , {out_type.type}"),
("linalg.conv( {in_id.ssa_id} , {filter_id.ssa_id} , {out_id.ssa_id} ) "
" : {in_type.type} , {filter_type.type} , {out_type.type}")]
@dataclass
class LinalgCopy(DialectOp):
a_id: mast.SsaId
b_id: mast.SsaId
a_type: mast.Type
b_type: mast.Type
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.copy( {a_id.ssa_id} , {b_id.ssa_id} ) "
"{attr.attribute_value} : {a_type.type} , {b_type.type}"),
("linalg.copy( {a_id.ssa_id} , {b_id.ssa_id} ) "
" : {a_type.type} , {b_type.type}")]
@dataclass
class LinalgDot(DialectOp):
in_a_id: mast.SsaId
in_b_id: mast.SsaId
in_a_type: mast.Type
in_b_type: mast.Type
out_id: mast.SsaId
out_type: mast.Type
_syntax_ = [("linalg.dot"
" ins( {in_a_id.ssa_id} , {in_b_id.ssa_id} : {in_a_type.type} , {in_b_type.type} )"
" outs( {out_id.ssa_id} : {out_type.type} )")]
@dataclass
class LinalgFill(DialectOp):
output_id: mast.SsaId
value_id: mast.SsaId
output_type: mast.Type
value_type: mast.Type
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.fill( {output_id.ssa_id} , {value_id.ssa_id} ) "
"{attr.attribute_value} : {output_type.type} , {value_type.type}"),
("linalg.fill( {output_id.ssa_id} , {value_id.ssa_id} ) "
" : {output_type.type} , {value_type.type}")]
@dataclass
class LinalgGeneric(DialectOp):
inargs: List[mast.SsaId]
in_types: List[mast.Type]
region: mast.Region
outargs: Optional[List[mast.SsaId]] = None
out_types: Optional[List[mast.Type]] = None
init_args: Optional[List[mast.SsaId]] = None
init_types: Optional[List[mast.Type]] = None
out_type: Optional[mast.Type] = None
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.generic {attr.attribute_value} "
" ins( {inargs.ssa_id_list} : {in_types.type_list_no_parens} )"
" outs( {outargs.ssa_id_list} : {out_types.type_list_no_parens} )"
" {region.region}"),
("linalg.generic {attr.attribute_value} "
" ins( {inargs.ssa_id_list} : {in_types.type_list_no_parens} )"
" init( {init_args.ssa_id_list} : {init_types.type_list_no_parens} )"
" {region.region} -> {out_type.type}")]
@dataclass
class LinalgIndexedGeneric(DialectOp):
inargs: List[mast.SsaId]
in_types: List[mast.Type]
region: mast.Region
outargs: Optional[List[mast.SsaId]] = None
out_types: Optional[List[mast.Type]] = None
init_args: Optional[List[mast.SsaId]] = None
init_types: Optional[List[mast.Type]] = None
out_type: Optional[mast.Type] = None
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.indexed_generic {attr.attribute_value} "
" ins( {inargs.ssa_id_list} : {in_types.type_list_no_parens} )"
" outs( {outargs.ssa_id_list} : {out_types.type_list_no_parens} )"
" {region.region}"),
("linalg.indexed_generic {attr.attribute_value} "
" ins( {inargs.ssa_id_list} : {in_types.type_list_no_parens} )"
" init( {init_args.ssa_id_list} : {init_types.type_list_no_parens} )"
" {region.region} -> {out_type.type}")]
@dataclass
class LinalgRange(DialectOp):
min_id: mast.SsaId
max_id: mast.SsaId
step_id: mast.SsaId
out_type: mast.Type
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.range {min_id.ssa_id} : {max_id.ssa_id} : {step_id.ssa_id}"
" {attr.attribute_value} : {out_type.type}"),
("linalg.range {min_id.ssa_id} : {max_id.ssa_id} : {step_id.ssa_id}"
" : {out_type.type}")]
@dataclass
class LinalgReshape(DialectOp):
src_id: mast.SsaId
src_type: mast.MemRefType
result_type: mast.MemRefType
reassociation: Optional[List[mast.AffineMap]] = None
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.reshape {src_id.ssa_id}"
" [ {reassociation.affine_map_list} ] "
" {attr.attribute_value} "
" : {src_type.memref_type} into {result_type.memref_type}"),
("linalg.reshape {src_id.ssa_id}"
" [ ] "
" {attr.attribute_value} "
" : {src_type.memref_type} into {result_type.memref_type}"),
("linalg.reshape {src_id.ssa_id}"
" [ {reassociation.affine_map_list} ] "
" : {src_type.memref_type} into {result_type.memref_type}"),
("linalg.reshape {src_id.ssa_id}"
" [ ] "
" : {src_type.memref_type} into {result_type.memref_type}")]
@dataclass
class LinalgSlice(DialectOp):
view_id: mast.SsaId
indexing_ids: List[mast.SsaId]
view_type: mast.Type
indexing_types: List[mast.Type]
result_type: mast.Type
_syntax_ = ("linalg.slice {view_id.ssa_id} [ {indexing_ids.ssa_id_list} ]"
" : {view_type.type} , {indexing_types.type_list_no_parens} "
" , {result_type.type}")
@dataclass
class TensorReshape(DialectOp):
src_id: mast.SsaId
src_type: mast.MemRefType
result_type: mast.MemRefType
reassociation: Optional[List[mast.AffineMap]] = None
attr: Optional[mast.Attribute] = None
_syntax_ = [("linalg.tensor_reshape {src_id.ssa_id}"
" [ {reassociation.affine_map_list} ] "
" {attr.attribute_value} "
" : {src_type.tensor_type} into {result_type.tensor_type}"),
("linalg.tensor_reshape {src_id.ssa_id}"
" [ ] "
" {attr.attribute_value} "
" : {src_type.tensor_type} into {result_type.tensor_type}"),
("linalg.tensor_reshape {src_id.ssa_id}"
" [ {reassociation.affine_map_list} ] "
" : {src_type.tensor_type} into {result_type.tensor_type}"),
("linalg.tensor_reshape {src_id.ssa_id}"
" [ ] "
" : {src_type.tensor_type} into {result_type.tensor_type}")]
@dataclass
class LinalgYield(DialectOp):
operand_ids: List[mast.SsaId]
operand_types: List[mast.Type]
_syntax_ = ("linalg.yield {operand_ids.ssa_id_list}"
" : {operand_types.type_list_no_parens}")
@dataclass
class LinalgMatmul(DialectOp):
a_id: mast.SsaId
b_id: mast.SsaId
a_type: mast.Type
b_type: mast.Type
c_id: mast.SsaId
c_type: mast.Type
out_type: Optional[mast.Type] = None
_syntax_ = [("linalg.matmul"
" ins( {a_id.ssa_id} , {b_id.ssa_id} : {a_type.type} , {b_type.type} )"
" outs( {c_id.ssa_id} : {c_type.type} )"),
("linalg.matmul"
" ins( {a_id.ssa_id} , {b_id.ssa_id} : {a_type.type} , {b_type.type} )"
" init( {c_id.ssa_id} : {c_type.type} ) -> {out_type.type}")]
@dataclass
class LinalgMatvec(DialectOp):
a_id: mast.SsaId
b_id: mast.SsaId
a_type: mast.Type
b_type: mast.Type
c_id: mast.SsaId
c_type: mast.Type
_syntax_ = [("linalg.matvec"
" ins( {a_id.ssa_id} , {b_id.ssa_id} : {a_type.type} , {b_type.type} )"
" outs( {c_id.ssa_id} : {c_type.type} )")]
# Inspect current module to get all classes defined above
linalg = Dialect("linalg", ops=[m[1] for m in inspect.getmembers(
sys.modules[__name__], lambda obj: is_op(obj, __name__))])
| 34.363014
| 100
| 0.59996
| 1,309
| 10,034
| 4.274255
| 0.087853
| 0.058981
| 0.070063
| 0.051117
| 0.803575
| 0.789634
| 0.763896
| 0.761394
| 0.756926
| 0.729759
| 0
| 0.000539
| 0.260315
| 10,034
| 291
| 101
| 34.4811
| 0.753301
| 0.009468
| 0
| 0.646809
| 0
| 0.051064
| 0.404954
| 0.135723
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.025532
| 0
| 0.6
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4d9fa403ce6b252624dbc04df0771323c80ccee8
| 20,327
|
py
|
Python
|
create_delete_transaction_from_search_bundle.py
|
Healthedata1/Flask-PL
|
88a2f40ca430c4cbb9fbded7fc92fdc166ebb9f1
|
[
"MIT"
] | null | null | null |
create_delete_transaction_from_search_bundle.py
|
Healthedata1/Flask-PL
|
88a2f40ca430c4cbb9fbded7fc92fdc166ebb9f1
|
[
"MIT"
] | null | null | null |
create_delete_transaction_from_search_bundle.py
|
Healthedata1/Flask-PL
|
88a2f40ca430c4cbb9fbded7fc92fdc166ebb9f1
|
[
"MIT"
] | null | null | null |
from json import dumps
# put search bundle inline here
dict_b = {
"resourceType": "Bundle",
"id": "5d592a0c-1d5a-4de0-8eb8-619f1fb8391e",
"meta": {
"lastUpdated": "2021-01-07T05:37:25.388+00:00"
},
"type": "searchset",
"total": 25,
"link": [
{
"relation": "self",
"url": "http://hapi.fhir.org/baseR4/Group?_elements=id&_tag=2020-Sep&_tag%3Anot=2021-Jan"
},
{
"relation": "next",
"url": "http://hapi.fhir.org/baseR4?_getpages=5d592a0c-1d5a-4de0-8eb8-619f1fb8391e&_getpagesoffset=20&_count=20&_pretty=true&_bundletype=searchset&_elements=id"
}
],
"entry": [
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-202",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-202",
"meta": {
"versionId": "5",
"lastUpdated": "2020-12-16T00:16:01.438+00:00",
"source": "Health_eData_Inc#nHzuB8UULkvS8LF6",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-301",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-301",
"meta": {
"versionId": "6",
"lastUpdated": "2020-12-16T00:09:50.373+00:00",
"source": "Health_eData_Inc#PMPix0aQoI3J8h27",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-300",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-300",
"meta": {
"versionId": "6",
"lastUpdated": "2020-12-16T00:07:45.984+00:00",
"source": "Health_eData_Inc#uW2JIdfJnr4e6IsI",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-200",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-200",
"meta": {
"versionId": "5",
"lastUpdated": "2020-12-15T23:49:49.764+00:00",
"source": "Health_eData_Inc#kTv3yYG3uFIhABTb",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-all-1002",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-all-1002",
"meta": {
"versionId": "5",
"lastUpdated": "2020-09-30T00:31:32.053+00:00",
"source": "Health_eData_Inc#xXG4ePql1TNKMBIT",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-all-1001",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-all-1001",
"meta": {
"versionId": "5",
"lastUpdated": "2020-09-30T00:31:32.053+00:00",
"source": "Health_eData_Inc#xXG4ePql1TNKMBIT",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2007",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2007",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2006",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2006",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2005",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2005",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2004",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2004",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2000",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2000",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-location-2008",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-location-2008",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:22:09.041+00:00",
"source": "Health_eData_Inc#xQnDXntef8Ihowbs",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3008",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3008",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3007",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3007",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3000",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3000",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3001",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3001",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3002",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3002",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/argo-pl-group-practitioner-3003",
"resource": {
"resourceType": "Group",
"id": "argo-pl-group-practitioner-3003",
"meta": {
"versionId": "2",
"lastUpdated": "2020-09-30T00:21:22.823+00:00",
"source": "Health_eData_Inc#avf4s5AkqVLaJF0N",
"tag": [
{
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/1494065",
"resource": {
"resourceType": "Group",
"id": "1494065",
"meta": {
"versionId": "1",
"lastUpdated": "2020-09-29T19:23:37.270+00:00",
"source": "#K1gzzIXvyOn8IR0x",
"tag": [
{
"system": "http://hl7.org/Connectathon",
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "http://hapi.fhir.org/baseR4/Group/1494064",
"resource": {
"resourceType": "Group",
"id": "1494064",
"meta": {
"versionId": "1",
"lastUpdated": "2020-09-29T19:23:36.975+00:00",
"source": "#gfxqly5bkf2BCzCf",
"tag": [
{
"system": "http://hl7.org/Connectathon",
"code": "2020-Sep"
},
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
}
},
"search": {
"mode": "match"
}
}
]
}
dict_del_b = {
"resourceType": "Bundle",
"type": "transaction",
"entry":[],
}
for e in dict_b['entry']:
request = dict(
method = 'DELETE',
url = '/'.join(e['fullUrl'].split('/')[-2:]),
)
entry = dict(
request = request
)
dict_del_b['entry'].append(entry)
print(len(dict_del_b['entry']))
# get transaction bundle from console here
print(dumps(dict_del_b, indent=2))
| 37.093066
| 172
| 0.348797
| 1,338
| 20,327
| 5.257848
| 0.116592
| 0.030704
| 0.05629
| 0.046908
| 0.894243
| 0.865814
| 0.835821
| 0.825586
| 0.693959
| 0.693959
| 0
| 0.088776
| 0.517883
| 20,327
| 547
| 173
| 37.160878
| 0.629082
| 0.003444
| 0
| 0.468519
| 0
| 0.037037
| 0.377506
| 0.086057
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.001852
| 0
| 0.001852
| 0.003704
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4dd6c0517bcfcebbda464a3fa5afbd324666b269
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/clikit/ui/components/__init__.py
|
Retraces/UkraineBot
|
3d5d7f8aaa58fa0cb8b98733b8808e5dfbdb8b71
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/clikit/ui/components/__init__.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/clikit/ui/components/__init__.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/b4/fb/29/f137ae7a88901de08f970eab89d3c9e564b994bc24e223617f766ee7c5
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.416667
| 0
| 96
| 1
| 96
| 96
| 0.479167
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4ded43f792aa04afb7ba13457a74347e2ee76879
| 26
|
py
|
Python
|
accounts/tests/__init__.py
|
AnjalBam/iw-capstone-project
|
38065885ada3d236823689c8a9e43f581d6f5a97
|
[
"MIT"
] | null | null | null |
accounts/tests/__init__.py
|
AnjalBam/iw-capstone-project
|
38065885ada3d236823689c8a9e43f581d6f5a97
|
[
"MIT"
] | 9
|
2021-04-08T20:15:32.000Z
|
2022-03-12T00:50:21.000Z
|
accounts/tests/__init__.py
|
AnjalBam/iw-capstone-project
|
38065885ada3d236823689c8a9e43f581d6f5a97
|
[
"MIT"
] | 1
|
2020-09-12T05:25:23.000Z
|
2020-09-12T05:25:23.000Z
|
from .user_tests import *
| 13
| 25
| 0.769231
| 4
| 26
| 4.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153846
| 26
| 1
| 26
| 26
| 0.863636
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
151d0e61360acb727d8a24e5188712dfd8c713e4
| 100
|
py
|
Python
|
src/structmodel/__init__.py
|
pursultani/struct-model
|
6ea3451b13814879c1fcce528344b74e179088c8
|
[
"MIT"
] | 2
|
2019-07-15T14:08:53.000Z
|
2020-07-13T05:46:57.000Z
|
src/structmodel/__init__.py
|
pursultani/struct-model
|
6ea3451b13814879c1fcce528344b74e179088c8
|
[
"MIT"
] | null | null | null |
src/structmodel/__init__.py
|
pursultani/struct-model
|
6ea3451b13814879c1fcce528344b74e179088c8
|
[
"MIT"
] | null | null | null |
#
# Copyright
#
from structmodel.model import Model, Struct
from structmodel.types import DataType
| 14.285714
| 43
| 0.8
| 12
| 100
| 6.666667
| 0.666667
| 0.375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.14
| 100
| 6
| 44
| 16.666667
| 0.930233
| 0.09
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
127d0e063979d390bb0b3bcb3a741383e668f973
| 67
|
py
|
Python
|
torchocr/postprocess/ctpn_postprocess.py
|
hua1024/OpenOCR
|
13ecfd18d103d5e70a87922cebe89077e8f0eb9c
|
[
"Apache-2.0"
] | 3
|
2021-02-02T06:10:50.000Z
|
2021-05-10T01:27:31.000Z
|
torchocr/postprocess/ctpn_postprocess.py
|
hua1024/OpenOCR
|
13ecfd18d103d5e70a87922cebe89077e8f0eb9c
|
[
"Apache-2.0"
] | null | null | null |
torchocr/postprocess/ctpn_postprocess.py
|
hua1024/OpenOCR
|
13ecfd18d103d5e70a87922cebe89077e8f0eb9c
|
[
"Apache-2.0"
] | 2
|
2021-02-02T06:11:25.000Z
|
2021-02-09T16:27:48.000Z
|
# coding=utf-8
# @Time : 2021/1/28 11:48
# @Auto : zzf-jeff
| 22.333333
| 28
| 0.537313
| 12
| 67
| 3
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.244898
| 0.268657
| 67
| 3
| 29
| 22.333333
| 0.489796
| 0.880597
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
12a52fffda27dd5dcaa7fa7c8d2ed6d149b37e69
| 156
|
py
|
Python
|
api_site/src/api_x/zyt/vas/entry/__init__.py
|
webee/pay
|
b48c6892686bf3f9014bb67ed119506e41050d45
|
[
"W3C"
] | 1
|
2019-10-14T11:51:49.000Z
|
2019-10-14T11:51:49.000Z
|
api_site/src/api_x/zyt/vas/entry/__init__.py
|
webee/pay
|
b48c6892686bf3f9014bb67ed119506e41050d45
|
[
"W3C"
] | null | null | null |
api_site/src/api_x/zyt/vas/entry/__init__.py
|
webee/pay
|
b48c6892686bf3f9014bb67ed119506e41050d45
|
[
"W3C"
] | null | null | null |
# coding=utf-8
from __future__ import unicode_literals
from flask import Blueprint
vas_entry_mod = Blueprint('vas_entry', __name__)
from . import views
| 15.6
| 48
| 0.794872
| 22
| 156
| 5.090909
| 0.681818
| 0.214286
| 0.303571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007463
| 0.141026
| 156
| 9
| 49
| 17.333333
| 0.828358
| 0.076923
| 0
| 0
| 0
| 0
| 0.06383
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.75
| 0
| 0.75
| 0.5
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
|
0
| 6
|
12d0d29cd5eb5e0773ca1e74d766d6c2b47ac024
| 34
|
py
|
Python
|
src/viur/utils/__init__.py
|
0x6369616e/viur-cli
|
6937ac3d02568d4aa5c068f8d12aac87506b31e9
|
[
"MIT"
] | null | null | null |
src/viur/utils/__init__.py
|
0x6369616e/viur-cli
|
6937ac3d02568d4aa5c068f8d12aac87506b31e9
|
[
"MIT"
] | null | null | null |
src/viur/utils/__init__.py
|
0x6369616e/viur-cli
|
6937ac3d02568d4aa5c068f8d12aac87506b31e9
|
[
"MIT"
] | 1
|
2021-12-11T23:36:28.000Z
|
2021-12-11T23:36:28.000Z
|
from .singleton import Singleton
| 11.333333
| 32
| 0.823529
| 4
| 34
| 7
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.147059
| 34
| 2
| 33
| 17
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
12d8ad5581a683a44f26eedab7bb48aadb430fc4
| 7,056
|
py
|
Python
|
pyrobolearn/values/polynomial.py
|
Pandinosaurus/pyrobolearn
|
9cd7c060723fda7d2779fa255ac998c2c82b8436
|
[
"Apache-2.0"
] | 2
|
2021-01-21T21:08:30.000Z
|
2022-03-29T16:45:49.000Z
|
pyrobolearn/values/polynomial.py
|
Pandinosaurus/pyrobolearn
|
9cd7c060723fda7d2779fa255ac998c2c82b8436
|
[
"Apache-2.0"
] | null | null | null |
pyrobolearn/values/polynomial.py
|
Pandinosaurus/pyrobolearn
|
9cd7c060723fda7d2779fa255ac998c2c82b8436
|
[
"Apache-2.0"
] | 1
|
2020-09-29T21:25:39.000Z
|
2020-09-29T21:25:39.000Z
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Provides the polynomial value function approximator.
"""
import copy
import torch
from pyrobolearn.approximators import PolynomialApproximator
from pyrobolearn.values.value import ParametrizedValue, ParametrizedQValue, ParametrizedQValueOutput
__author__ = "Brian Delhaisse"
__copyright__ = "Copyright 2018, PyRoboLearn"
__credits__ = ["Brian Delhaisse"]
__license__ = "GNU GPLv3"
__version__ = "1.0.0"
__maintainer__ = "Brian Delhaisse"
__email__ = "briandelhaisse@gmail.com"
__status__ = "Development"
class PolynomialValue(ParametrizedValue):
r"""Polynomial State Value Function Approximator
State value function :math:`V_{\phi}(s)` approximated by a polynomial model, where :math:`\phi` represents
the parameters of that model.
"""
def __init__(self, state, degree=1, preprocessors=None):
"""
Initialize the polynomial state value function approximator.
Args:
state (State): input state.
degree (int, list of int, np.array[D]): degree(s) of the polynomial. Setting `degree=3`, will apply
`[1,x,x^2,x^3]` to the inputs, while setting `degree=[1,3]` will apply `[x,x^3]` to the inputs.
preprocessors ((list of) Processor): pre-processors to be applied on the input state before being fed to
the inner model / function approximator.
"""
model = PolynomialApproximator(inputs=state, outputs=torch.Tensor([1]), degree=degree,
preprocessors=preprocessors)
super(PolynomialValue, self).__init__(state, model=model)
def __copy__(self):
"""Return a shallow copy of the value approximator. This can be overridden in the child class."""
return self.__class__(state=self.state, preprocessors=self.model.preprocessors)
def __deepcopy__(self, memo={}):
"""Return a deep copy of the value approximator. This can be overridden in the child class.
Args:
memo (dict): memo dictionary of objects already copied during the current copying pass
"""
if self in memo:
return memo[self]
state = copy.deepcopy(self.state, memo)
preprocessors = [copy.deepcopy(preprocessor, memo) for preprocessor in self.model.preprocessors]
value = self.__class__(state=state, preprocessors=preprocessors)
memo[self] = value
return value
class PolynomialQValue(ParametrizedQValue):
r"""Polynomial Q-value function approximator (which accepts as inputs the states and actions)
State-action value function :math:`Q_{\phi}(s, a)` approximated by a polynomial model, where :math:`\phi`
represents the parameters of that model. This approximator accepts as inputs the states :math:`s` and actions
:math:`a`, and outputs the value :math:`Q(s,a)`. This can be used for continuous actions as well as discrete actions.
"""
def __init__(self, state, action, degree=1, preprocessors=None):
"""
Initialize the polynomial state-action value function approximator.
Args:
state (State): input state.
action (Action): input action.
degree (int, list of int, np.array[D]): degree(s) of the polynomial. Setting `degree=3`, will apply
`[1,x,x^2,x^3]` to the inputs, while setting `degree=[1,3]` will apply `[x,x^3]` to the inputs.
preprocessors ((list of) Processor): pre-processors to be applied on the input state before being fed to
the inner model / function approximator.
"""
model = PolynomialApproximator(inputs=[state, action], outputs=torch.Tensor([1]), degree=degree,
preprocessors=preprocessors)
super(PolynomialQValue, self).__init__(state, action, model=model)
def __copy__(self):
"""Return a shallow copy of the value approximator. This can be overridden in the child class."""
return self.__class__(state=self.state, action=self.action, preprocessors=self.model.preprocessors)
def __deepcopy__(self, memo={}):
"""Return a deep copy of the value approximator. This can be overridden in the child class.
Args:
memo (dict): memo dictionary of objects already copied during the current copying pass
"""
if self in memo:
return memo[self]
state = copy.deepcopy(self.state, memo)
action = copy.deepcopy(self.action, memo)
preprocessors = [copy.deepcopy(preprocessor, memo) for preprocessor in self.model.preprocessors]
value = self.__class__(state=state, action=action, preprocessors=preprocessors)
memo[self] = value
return value
class PolynomialQValueOutput(ParametrizedQValueOutput):
r"""Polynomial Q-value function approximator (which accepts as inputs the states and outputs a Q-value for each
discrete action)
State-action value function :math:`Q_{\phi}(s, a)` approximated by a polynomial model, where :math:`\phi`
represents the parameters of that model. This approximator accepts as inputs the states :math:`s` and outputs the
value :math:`Q(s,a)` for each discrete action. This can NOT be used with continuous actions.
"""
def __init__(self, state, action, degree=1, preprocessors=None):
"""
Initialize the polynomial state-action value function approximator.
Args:
state (State): input state.
action (Action): output action.
degree (int, list of int, np.array[D]): degree(s) of the polynomial. Setting `degree=3`, will apply
`[1,x,x^2,x^3]` to the inputs, while setting `degree=[1,3]` will apply `[x,x^3]` to the inputs.
preprocessors ((list of) Processor): pre-processors to be applied on the input state before being fed to
the inner model / function approximator.
"""
model = PolynomialApproximator(inputs=state, outputs=action, degree=degree, preprocessors=preprocessors)
super(PolynomialQValueOutput, self).__init__(state, action, model=model)
def __copy__(self):
"""Return a shallow copy of the value approximator. This can be overridden in the child class."""
return self.__class__(state=self.state, action=self.action, preprocessors=self.model.preprocessors)
def __deepcopy__(self, memo={}):
"""Return a deep copy of the value approximator. This can be overridden in the child class.
Args:
memo (dict): memo dictionary of objects already copied during the current copying pass
"""
if self in memo:
return memo[self]
state = copy.deepcopy(self.state, memo)
action = copy.deepcopy(self.action, memo)
preprocessors = [copy.deepcopy(preprocessor, memo) for preprocessor in self.model.preprocessors]
value = self.__class__(state=state, action=action, preprocessors=preprocessors)
memo[self] = value
return value
| 46.421053
| 121
| 0.672052
| 870
| 7,056
| 5.327586
| 0.156322
| 0.035599
| 0.037756
| 0.009061
| 0.825243
| 0.807335
| 0.807335
| 0.807335
| 0.76246
| 0.737217
| 0
| 0.00646
| 0.232143
| 7,056
| 151
| 122
| 46.728477
| 0.849022
| 0.490646
| 0
| 0.557377
| 0
| 0
| 0.037979
| 0.007533
| 0
| 0
| 0
| 0
| 0
| 1
| 0.147541
| false
| 0
| 0.065574
| 0
| 0.409836
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
12e8bd08dc574aaa3294f93a4bef2489d101b85d
| 86
|
py
|
Python
|
powerline_vaulted_segment/__init__.py
|
sbarber/powerline-vaulted-segment
|
8740360b81d6c6855ded6dc37c80e546bbc77c27
|
[
"MIT"
] | 1
|
2019-05-03T04:43:58.000Z
|
2019-05-03T04:43:58.000Z
|
powerline_vaulted_segment/__init__.py
|
sbarber/powerline-vaulted-segment
|
8740360b81d6c6855ded6dc37c80e546bbc77c27
|
[
"MIT"
] | null | null | null |
powerline_vaulted_segment/__init__.py
|
sbarber/powerline-vaulted-segment
|
8740360b81d6c6855ded6dc37c80e546bbc77c27
|
[
"MIT"
] | 1
|
2018-03-15T21:31:06.000Z
|
2018-03-15T21:31:06.000Z
|
import pkg_resources
pkg_resources.declare_namespace(__name__)
from vaulted import *
| 17.2
| 41
| 0.860465
| 11
| 86
| 6.090909
| 0.727273
| 0.358209
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.093023
| 86
| 4
| 42
| 21.5
| 0.858974
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
12fbb0168ac769ab8a8610d414699c0d8872c648
| 24,741
|
py
|
Python
|
network_ui_dev/client/v1_api_client.py
|
benthomasson/network-ui
|
8c3e114d331a57848acb4004ccf090148fd36e86
|
[
"Apache-2.0"
] | 1
|
2018-09-21T17:33:39.000Z
|
2018-09-21T17:33:39.000Z
|
network_ui_dev/client/v1_api_client.py
|
benthomasson/network-ui
|
8c3e114d331a57848acb4004ccf090148fd36e86
|
[
"Apache-2.0"
] | 14
|
2020-06-18T14:42:24.000Z
|
2022-03-08T23:09:03.000Z
|
network_ui_dev/client/v1_api_client.py
|
benthomasson/network-ui
|
8c3e114d331a57848acb4004ccf090148fd36e86
|
[
"Apache-2.0"
] | 1
|
2020-06-23T11:34:34.000Z
|
2020-06-23T11:34:34.000Z
|
import requests
import util
import json
from collections import namedtuple
Device = namedtuple('Device', ['device_id',
'topology',
'name',
'x',
'y',
'id',
'device_type',
'interface_id_seq',
'process_id_seq',
'host_id',
])
Link = namedtuple('Link', ['link_id',
'from_device',
'to_device',
'from_interface',
'to_interface',
'id',
'name',
])
Topology = namedtuple('Topology', ['topology_id',
'name',
'scale',
'panX',
'panY',
'device_id_seq',
'link_id_seq',
'group_id_seq',
'stream_id_seq',
])
Interface = namedtuple('Interface', ['interface_id',
'device',
'name',
'id',
])
Group = namedtuple('Group', ['group_id',
'id',
'name',
'x1',
'y1',
'x2',
'y2',
'topology',
'group_type',
'inventory_group_id',
])
GroupDevice = namedtuple('GroupDevice', ['group_device_id',
'group',
'device',
])
Stream = namedtuple('Stream', ['stream_id',
'from_device',
'to_device',
'label',
'id',
])
Process = namedtuple('Process', ['process_id',
'device',
'name',
'process_type',
'id',
])
Toolbox = namedtuple('Toolbox', ['toolbox_id',
'name',
])
ToolboxItem = namedtuple('ToolboxItem', ['toolbox_item_id',
'toolbox',
'data',
])
TopologyInventory = namedtuple('TopologyInventory', ['topology_inventory_id',
'topology',
'inventory_id',
])
def list_device(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_device(device_id):
response = requests.get(util.get_url() + "" + str(device_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_device(topology, name, x, y, id, device_type, interface_id_seq=0, process_id_seq=0, host_id=0,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(topology=topology,
name=name,
x=x,
y=y,
id=id,
device_type=device_type,
interface_id_seq=interface_id_seq,
process_id_seq=process_id_seq,
host_id=host_id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_device(device_id, topology=None, name=None, x=None, y=None, id=None, device_type=None, interface_id_seq=None, process_id_seq=None, host_id=None,):
headers = {'content-type': 'application/json'}
data = dict(topology=topology,
name=name,
x=x,
y=y,
id=id,
device_type=device_type,
interface_id_seq=interface_id_seq,
process_id_seq=process_id_seq,
host_id=host_id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(device_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_device(device_id):
response = requests.delete(util.get_url() + "" + str(device_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_link(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_link(link_id):
response = requests.get(util.get_url() + "" + str(link_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_link(from_device, to_device, from_interface, to_interface, id, name,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(from_device=from_device,
to_device=to_device,
from_interface=from_interface,
to_interface=to_interface,
id=id,
name=name,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_link(link_id, from_device=None, to_device=None, from_interface=None, to_interface=None, id=None, name=None,):
headers = {'content-type': 'application/json'}
data = dict(from_device=from_device,
to_device=to_device,
from_interface=from_interface,
to_interface=to_interface,
id=id,
name=name,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(link_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_link(link_id):
response = requests.delete(util.get_url() + "" + str(link_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_topology(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_topology(topology_id):
response = requests.get(util.get_url() + "" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_topology(name, scale, panX, panY, device_id_seq=0, link_id_seq=0, group_id_seq=0, stream_id_seq=0,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(name=name,
scale=scale,
panX=panX,
panY=panY,
device_id_seq=device_id_seq,
link_id_seq=link_id_seq,
group_id_seq=group_id_seq,
stream_id_seq=stream_id_seq,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_topology(topology_id, name=None, scale=None, panX=None, panY=None, device_id_seq=None, link_id_seq=None, group_id_seq=None, stream_id_seq=None,):
headers = {'content-type': 'application/json'}
data = dict(name=name,
scale=scale,
panX=panX,
panY=panY,
device_id_seq=device_id_seq,
link_id_seq=link_id_seq,
group_id_seq=group_id_seq,
stream_id_seq=stream_id_seq,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(topology_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_topology(topology_id):
response = requests.delete(util.get_url() + "" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_interface(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_interface(interface_id):
response = requests.get(util.get_url() + "" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_interface(device, name, id,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(device=device,
name=name,
id=id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_interface(interface_id, device=None, name=None, id=None,):
headers = {'content-type': 'application/json'}
data = dict(device=device,
name=name,
id=id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(interface_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_interface(interface_id):
response = requests.delete(util.get_url() + "" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_group(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_group(group_id):
response = requests.get(util.get_url() + "" + str(group_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_group(id, name, x1, y1, x2, y2, topology, group_type, inventory_group_id=0,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(id=id,
name=name,
x1=x1,
y1=y1,
x2=x2,
y2=y2,
topology=topology,
group_type=group_type,
inventory_group_id=inventory_group_id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_group(group_id, id=None, name=None, x1=None, y1=None, x2=None, y2=None, topology=None, group_type=None, inventory_group_id=None,):
headers = {'content-type': 'application/json'}
data = dict(id=id,
name=name,
x1=x1,
y1=y1,
x2=x2,
y2=y2,
topology=topology,
group_type=group_type,
inventory_group_id=inventory_group_id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(group_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_group(group_id):
response = requests.delete(util.get_url() + "" + str(group_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_groupdevice(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_groupdevice(group_device_id):
response = requests.get(util.get_url() + "" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_groupdevice(group, device,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(group=group,
device=device,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_groupdevice(group_device_id, group=None, device=None,):
headers = {'content-type': 'application/json'}
data = dict(group=group,
device=device,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(group_device_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_groupdevice(group_device_id):
response = requests.delete(util.get_url() + "" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_stream(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_stream(stream_id):
response = requests.get(util.get_url() + "" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_stream(from_device, to_device, label, id=0,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(from_device=from_device,
to_device=to_device,
label=label,
id=id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_stream(stream_id, from_device=None, to_device=None, label=None, id=None,):
headers = {'content-type': 'application/json'}
data = dict(from_device=from_device,
to_device=to_device,
label=label,
id=id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(stream_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_stream(stream_id):
response = requests.delete(util.get_url() + "" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_process(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_process(process_id):
response = requests.get(util.get_url() + "" + str(process_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_process(device, name, process_type, id=0,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(device=device,
name=name,
process_type=process_type,
id=id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_process(process_id, device=None, name=None, process_type=None, id=None,):
headers = {'content-type': 'application/json'}
data = dict(device=device,
name=name,
process_type=process_type,
id=id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(process_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_process(process_id):
response = requests.delete(util.get_url() + "" + str(process_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_toolbox(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_toolbox(toolbox_id):
response = requests.get(util.get_url() + "" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_toolbox(name,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(name=name,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_toolbox(toolbox_id, name=None,):
headers = {'content-type': 'application/json'}
data = dict(name=name,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(toolbox_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_toolbox(toolbox_id):
response = requests.delete(util.get_url() + "" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_toolboxitem(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_toolboxitem(toolbox_item_id):
response = requests.get(util.get_url() + "" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_toolboxitem(toolbox, data,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(toolbox=toolbox,
data=data,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_toolboxitem(toolbox_item_id, toolbox=None, data=None,):
headers = {'content-type': 'application/json'}
data = dict(toolbox=toolbox,
data=data,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(toolbox_item_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_toolboxitem(toolbox_item_id):
response = requests.delete(util.get_url() + "" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())
return response
def list_topologyinventory(**kwargs):
response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)
return response
def get_topologyinventory(topology_inventory_id):
response = requests.get(util.get_url() + "" + str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())
return response.json()
def create_topologyinventory(topology, inventory_id,):
headers = {'content-type': 'application/json'}
response = requests.post(util.get_url() + "", data=json.dumps(dict(topology=topology,
inventory_id=inventory_id,
)),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response.json()
def update_topologyinventory(topology_inventory_id, topology=None, inventory_id=None,):
headers = {'content-type': 'application/json'}
data = dict(topology=topology,
inventory_id=inventory_id,
)
data = {x: y for x, y in data.items() if y is not None}
response = requests.patch(util.get_url() + "" + str(topology_inventory_id) + "/",
data=json.dumps(data),
verify=util.get_verify(),
auth=util.get_auth(),
headers=headers)
return response
def delete_topologyinventory(topology_inventory_id):
response = requests.delete(util.get_url() + "" + str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())
return response
| 42.148211
| 157
| 0.459601
| 2,321
| 24,741
| 4.686773
| 0.028436
| 0.106178
| 0.050561
| 0.076852
| 0.897408
| 0.841147
| 0.821107
| 0.805571
| 0.777533
| 0.74168
| 0
| 0.002711
| 0.433531
| 24,741
| 586
| 158
| 42.220137
| 0.773457
| 0
| 0
| 0.681818
| 0
| 0
| 0.047939
| 0.000849
| 0
| 0
| 0
| 0
| 0
| 1
| 0.119048
| false
| 0
| 0.008658
| 0
| 0.246753
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
4206751578a27e3c26626feb42ff037360268436
| 49
|
py
|
Python
|
bench_wizard/__init__.py
|
tetched/bench-wizard
|
de9c687909e43b84de1022108316522e8f4bf13a
|
[
"Apache-2.0"
] | 2
|
2021-04-04T20:45:39.000Z
|
2022-01-10T15:12:19.000Z
|
bench_wizard/__init__.py
|
tetched/bench-wizard
|
de9c687909e43b84de1022108316522e8f4bf13a
|
[
"Apache-2.0"
] | 7
|
2021-03-04T16:46:35.000Z
|
2021-04-06T07:21:42.000Z
|
bench_wizard/__init__.py
|
tetched/bench-wizard
|
de9c687909e43b84de1022108316522e8f4bf13a
|
[
"Apache-2.0"
] | 1
|
2021-04-03T12:35:26.000Z
|
2021-04-03T12:35:26.000Z
|
from bench_wizard.__version__ import __version__
| 24.5
| 48
| 0.897959
| 6
| 49
| 5.833333
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.081633
| 49
| 1
| 49
| 49
| 0.777778
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
420df9e7c08383ca2e03ae9702bbefb62a096333
| 188
|
py
|
Python
|
misa-mima/triangle.py
|
adadesions/python-afternoon
|
57b99cd5dbce0848260d38ef0b18c4ca021d5262
|
[
"MIT"
] | null | null | null |
misa-mima/triangle.py
|
adadesions/python-afternoon
|
57b99cd5dbce0848260d38ef0b18c4ca021d5262
|
[
"MIT"
] | null | null | null |
misa-mima/triangle.py
|
adadesions/python-afternoon
|
57b99cd5dbce0848260d38ef0b18c4ca021d5262
|
[
"MIT"
] | null | null | null |
from turtle import *
bgcolor('black')
pencolor('yellow')
forward(100)
left(120)
forward(100)
left(120)
forward(100)
forward(100)
right(120)
forward(100)
right(120)
forward(100)
done()
| 9.894737
| 20
| 0.723404
| 28
| 188
| 4.857143
| 0.464286
| 0.441176
| 0.382353
| 0.25
| 0.661765
| 0.661765
| 0
| 0
| 0
| 0
| 0
| 0.179641
| 0.111702
| 188
| 19
| 21
| 9.894737
| 0.634731
| 0
| 0
| 0.714286
| 0
| 0
| 0.058201
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.071429
| 0
| 0.071429
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
424b833c7875f10d719ca0759d52361d8c3adbc3
| 162
|
py
|
Python
|
fairepart/signals.py
|
thoas/django-fairepart
|
222c6c3d2125c33fc8f10a1f2c8a3a5ed273e8f4
|
[
"MIT"
] | 2
|
2016-04-09T19:09:30.000Z
|
2017-12-12T23:57:13.000Z
|
fairepart/signals.py
|
thoas/django-fairepart
|
222c6c3d2125c33fc8f10a1f2c8a3a5ed273e8f4
|
[
"MIT"
] | null | null | null |
fairepart/signals.py
|
thoas/django-fairepart
|
222c6c3d2125c33fc8f10a1f2c8a3a5ed273e8f4
|
[
"MIT"
] | null | null | null |
from django.dispatch import Signal
relation_linked = Signal(providing_args=['instance', 'user'])
relation_joined = Signal(providing_args=['instance', 'user'])
| 23.142857
| 61
| 0.765432
| 19
| 162
| 6.315789
| 0.631579
| 0.25
| 0.316667
| 0.45
| 0.516667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.092593
| 162
| 6
| 62
| 27
| 0.816327
| 0
| 0
| 0
| 0
| 0
| 0.148148
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
428a6fbb51191f632694d03402d002a7aa1efc31
| 84
|
py
|
Python
|
yunpipe/pipeline/__init__.py
|
wangyx2005/yunpipe
|
c3ccf09f9cd128e47ebd109e19cc4249c8272002
|
[
"Apache-2.0"
] | null | null | null |
yunpipe/pipeline/__init__.py
|
wangyx2005/yunpipe
|
c3ccf09f9cd128e47ebd109e19cc4249c8272002
|
[
"Apache-2.0"
] | null | null | null |
yunpipe/pipeline/__init__.py
|
wangyx2005/yunpipe
|
c3ccf09f9cd128e47ebd109e19cc4249c8272002
|
[
"Apache-2.0"
] | null | null | null |
from .config import generate_session
USER_CREDENTIAL, session = generate_session()
| 21
| 45
| 0.833333
| 10
| 84
| 6.7
| 0.7
| 0.447761
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107143
| 84
| 3
| 46
| 28
| 0.893333
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
4291a98b3880c34c520bf653eeaaed5c8eaf518e
| 2,722
|
py
|
Python
|
nrcan_etl/tests/test_database.py
|
Rockynrcan/nrcan_api
|
13d8fb306d8185f6bcd082c559ad3fe8b4340cc7
|
[
"MIT"
] | 7
|
2017-12-15T03:58:29.000Z
|
2018-04-23T22:48:53.000Z
|
nrcan_etl/tests/test_database.py
|
Rockynrcan/nrcan_api
|
13d8fb306d8185f6bcd082c559ad3fe8b4340cc7
|
[
"MIT"
] | 137
|
2018-01-24T16:44:57.000Z
|
2018-06-25T14:02:10.000Z
|
nrcan_etl/tests/test_database.py
|
Rockynrcan/nrcan_api
|
13d8fb306d8185f6bcd082c559ad3fe8b4340cc7
|
[
"MIT"
] | 4
|
2018-02-15T12:40:52.000Z
|
2018-07-03T14:22:51.000Z
|
import typing
import pymongo
import pytest
from energuide.embedded import region
from energuide import database
from energuide import dwelling
@pytest.fixture
def load_data() -> typing.List[dwelling.Dwelling]:
return [
dwelling.Dwelling(
house_id=1,
year_built=2000,
city='Ottawa',
region=region.Region.ONTARIO,
forward_sortation_area='K1P',
evaluations=[]
),
dwelling.Dwelling(
house_id=2,
year_built=2000,
city='Ottawa',
region=region.Region.ONTARIO,
forward_sortation_area='K1P',
evaluations=[]
),
dwelling.Dwelling(
house_id=3,
year_built=2000,
city='Ottawa',
region=region.Region.ONTARIO,
forward_sortation_area='K1P',
evaluations=[]
),
]
def test_load(database_coordinates: database.DatabaseCoordinates,
mongo_client: pymongo.MongoClient,
database_name: str,
collection: str,
load_data: typing.List[dwelling.Dwelling]):
database.load(
coords=database_coordinates,
database_name=database_name,
collection_name=collection,
data=load_data,
update=False
)
assert mongo_client[database_name][collection].count() == 3
def test_load_update(database_coordinates: database.DatabaseCoordinates,
mongo_client: pymongo.MongoClient,
database_name: str,
collection: str,
load_data: typing.List[dwelling.Dwelling]):
database.load(
coords=database_coordinates,
database_name=database_name,
collection_name=collection,
data=load_data,
update=False
)
assert mongo_client[database_name][collection].count() == 3
load_data[0] = dwelling.Dwelling(
house_id=1,
year_built=2001, city='Ottawa',
region=region.Region.ONTARIO,
forward_sortation_area='K1P',
evaluations=[]
)
load_data.append(
dwelling.Dwelling(
house_id=4,
year_built=2001,
city='Ottawa',
region=region.Region.ONTARIO,
forward_sortation_area='K1P',
evaluations=[]
)
)
database.load(
coords=database_coordinates,
database_name=database_name,
collection_name=collection,
data=load_data,
update=True
)
assert mongo_client[database_name][collection].count() == 4
assert mongo_client[database_name][collection].find_one({'houseId': 1})['yearBuilt'] == 2001
| 28.652632
| 96
| 0.594416
| 262
| 2,722
| 5.954198
| 0.209924
| 0.092308
| 0.098718
| 0.073718
| 0.835897
| 0.835897
| 0.789103
| 0.730128
| 0.730128
| 0.730128
| 0
| 0.020878
| 0.31374
| 2,722
| 94
| 97
| 28.957447
| 0.81424
| 0
| 0
| 0.674419
| 0
| 0
| 0.02241
| 0
| 0
| 0
| 0
| 0
| 0.046512
| 1
| 0.034884
| false
| 0
| 0.069767
| 0.011628
| 0.116279
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
429b8f0a128684d441a0b1f9578f56eb51da32fa
| 63
|
py
|
Python
|
cflearn/models/cv/encoder/backbone/__init__.py
|
carefree0910/carefree-learn
|
2043812afbe9c56f01ec1639961736313ee062ba
|
[
"MIT"
] | 400
|
2020-07-05T18:55:49.000Z
|
2022-02-21T02:33:08.000Z
|
cflearn/models/cv/encoder/backbone/__init__.py
|
carefree0910/carefree-learn
|
2043812afbe9c56f01ec1639961736313ee062ba
|
[
"MIT"
] | 82
|
2020-08-01T13:29:38.000Z
|
2021-10-09T07:13:44.000Z
|
cflearn/models/cv/encoder/backbone/__init__.py
|
carefree0910/carefree-learn
|
2043812afbe9c56f01ec1639961736313ee062ba
|
[
"MIT"
] | 34
|
2020-07-05T21:15:34.000Z
|
2021-12-20T08:45:17.000Z
|
from .api import *
from .core import *
from .settings import *
| 15.75
| 23
| 0.714286
| 9
| 63
| 5
| 0.555556
| 0.444444
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.190476
| 63
| 3
| 24
| 21
| 0.882353
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
c443d875c6c257b135e796c878acf9e691c2df0e
| 11,028
|
py
|
Python
|
ocr_utils.py
|
nhh1501/E2E_MLT_VN
|
dabbc1f7e12b45fbaef965200217cca41793dbc3
|
[
"MIT"
] | null | null | null |
ocr_utils.py
|
nhh1501/E2E_MLT_VN
|
dabbc1f7e12b45fbaef965200217cca41793dbc3
|
[
"MIT"
] | null | null | null |
ocr_utils.py
|
nhh1501/E2E_MLT_VN
|
dabbc1f7e12b45fbaef965200217cca41793dbc3
|
[
"MIT"
] | null | null | null |
'''
Created on Oct 25, 2018
@author: Michal.Busta at gmail.com
'''
import math
import numpy as np
import random
import torch
import torch.nn.functional as F
import cv2
device = 'cuda'
def print_seq_ext(wf, codec):
prev = 0
word = ''
current_word = ''
start_pos = 0
end_pos = 0
dec_splits = []
splits = []
hasLetter = False
for cx in range(0, wf.shape[0]):
c = wf[cx]
if prev == c:
if c > 2:
end_pos = cx
continue
if c > 3 and c < (len(codec)+4):
ordv = codec[c - 4]
char = ordv
if char == ' ' or char == '.' or char == ',' or char == ':':
if hasLetter:
if char != ' ':
current_word += char
splits.append(current_word)
dec_splits.append(cx + 1)
word += char
current_word = ''
else:
hasLetter = True
word += char
current_word += char
end_pos = cx
elif c > 0:
if hasLetter:
dec_splits.append(cx + 1)
word += ' '
end_pos = cx
splits.append(current_word)
current_word = ''
if len(word) == 0:
start_pos = cx
prev = c
dec_splits.append(end_pos + 1)
conf2 = [start_pos, end_pos + 1]
return word.strip(), np.array([conf2]), np.array([dec_splits]), splits
def ocr_image(net, codec, im_data, detection,target_h):
boxo = detection
boxr = boxo[0:8].reshape(-1, 2)
center = (boxr[0, :] + boxr[1, :] + boxr[2, :] + boxr[3, :]) / 4
dw = boxr[2, :] - boxr[1, :]
dh = boxr[1, :] - boxr[0, :]
w = math.sqrt(dw[0] * dw[0] + dw[1] * dw[1])
h = math.sqrt(dh[0] * dh[0] + dh[1] * dh[1]) + random.randint(-2, 2)
input_W = im_data.size(3)
input_H = im_data.size(2)
scale = target_h / max(1, h)
target_gw = int(w * scale) + target_h
target_gw = max(2, target_gw // 32) * 32
xc = center[0]
yc = center[1]
w2 = w
h2 = h
angle = math.atan2((boxr[2][1] - boxr[1][1]), boxr[2][0] - boxr[1][0])
#show pooled image in image layer
scalex = (w2 + h2) / input_W * 1.2
scaley = h2 / input_H * 1.3
th11 = scalex * math.cos(angle)
th12 = -math.sin(angle) * scaley
th13 = (2 * xc - input_W - 1) / (input_W - 1) #* torch.cos(angle_var) - (2 * yc - input_H - 1) / (input_H - 1) * torch.sin(angle_var)
th21 = math.sin(angle) * scalex
th22 = scaley * math.cos(angle)
th23 = (2 * yc - input_H - 1) / (input_H - 1) #* torch.cos(angle_var) + (2 * xc - input_W - 1) / (input_W - 1) * torch.sin(angle_var)
t = np.asarray([th11, th12, th13, th21, th22, th23], dtype=np.float)
t = torch.from_numpy(t).type(torch.FloatTensor)
t = t.to(device)
theta = t.view(-1, 2, 3)
grid = F.affine_grid(theta, torch.Size((1, 3, int(target_h), int(target_gw))))
x = F.grid_sample(im_data, grid)
mask_gray = cv2.normalize(src=x.data.numpy().squeeze(), dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX,
dtype=cv2.CV_8UC1)
cv2.imshow('abc', mask_gray.transpose(1, 2, 0))
cv2.waitKey(0)
features = net.forward_features(x)
labels_pred = net.forward_ocr(features)
ctc_f = labels_pred.data.cpu().numpy()
ctc_f = ctc_f.swapaxes(1, 2)
labels = ctc_f.argmax(2)
ind = np.unravel_index(labels, ctc_f.shape)
conf = np.mean( np.exp(ctc_f[ind]) )
det_text, conf2, dec_s, splits = print_seq_ext(labels[0, :], codec)
return det_text, conf2, dec_s
def ocr_batch(net, codec, im_data, gtso,lbso,target_h):
#e2e
num_gt = len(gtso)
rrois = []
labels = []
for kk in range(num_gt):
gts = gtso[kk]
lbs = lbso[kk]
if len(gts) != 0:
gt = np.asarray(gts)
# boxr = gts[0:8].reshape(-1, 2)
center = (gt[:, 0, :] + gt[:, 1, :] + gt[:, 2, :] + gt[:, 3, :]) / 4 # 求中心点
dw = gt[:, 2, :] - gt[:, 1, :]
dh = gt[:, 1, :] - gt[:, 0, :]
poww = pow(dw, 2)
powh = pow(dh, 2)
w = np.sqrt(poww[:, 0] + poww[:, 1])
h = np.sqrt(powh[:, 0] + powh[:, 1]) + random.randint(-2, 2)
# dw2= gt[:, 0, :] - gt[:, 3, :]
# dh2= gt[:, 3, :] - gt[:, 2, :]
# poww2 = pow(dw2, 2)
# powh2 = pow(dh2, 2)
# w2= np.sqrt(poww2[:, 0] + poww2[:, 1])
# h2= np.sqrt(powh2[:, 0] + powh2[:, 1]) + random.randint(-2, 2)
#
# w = (w + w2) / 2
# h = (h + h2) / 2
angle = (np.arctan2((gt[:, 2, 1] - gt[:, 1, 1]), gt[:, 2, 0] - gt[:, 1, 0]))
# angle2 = (np.arctan2((gt[:, 3, 1] - gt[:, 0, 1]), gt[:, 3, 0] - gt[:, 0, 0]))
# angle = angle + angle2
for gt_id in range(0, len(gts)):
gt_txt = lbs[gt_id] # 文字判断
if gt_txt.startswith('##'):
continue
gt = gts[gt_id] # 标注信息判断
if gt[:, 0].max() > im_data.size(3) or gt[:, 1].max() > im_data.size(2) or gt.min() < 0:
continue
rrois.append([kk, center[gt_id][0], center[gt_id][1], h[gt_id], w[gt_id], angle[gt_id]]) # 将标注的rroi写入
labels.append(gt_txt)
# show pooled image in image layer
rois = torch.tensor(rrois).to(torch.float)
id_img = rois[:,0]
xc = rois[:, 1]
yc = rois[:, 2]
h= rois[:,3]
w= rois[:,4]
angle = rois[:,5]
input_W = im_data.size(3)
input_H = im_data.size(2)
scale = target_h / torch.max(torch.ones_like(h), h) # h = rois[:,3]
target_gw = (w * scale) + target_h
target_gw = torch.max(2*torch.ones_like(target_gw), target_gw // 32) * 32
w2 = w
h2 = h
scalex = (w2 + h2) / input_W * 1.2
scaley = h2 / input_H * 1.3
th11 = scalex * torch.cos(angle)
th12 = -torch.sin(angle) * scaley
th13 = (2 * xc - input_W - 1) / (input_W - 1) # * torch.cos(angle_var) - (2 * yc - input_H - 1) / (input_H - 1) * torch.sin(angle_var)
th21 = torch.sin(angle) * scalex
th22 = scaley * torch.cos(angle)
th23 = (2 * yc - input_H - 1) / (input_H - 1) # * torch.cos(angle_var) + (2 * xc - input_W - 1) / (input_W - 1) * torch.sin(angle_var)
# t = np.asarray([th11, th12, th13, th21, th22, th23], dtype=np.float)
# t = torch.from_numpy(t).type(torch.FloatTensor)
t =torch.stack((th11, th12, th13, th21, th22, th23),-1)
t = t.to(device)
theta = t.view(-1, 2, 3)
det_texts = []
# labels_gt = []
for idx in range(len(labels)):
grid = F.affine_grid(theta[idx].unsqueeze(0), torch.Size((1, 3, int(target_h), int(target_gw[idx]))))
x = F.grid_sample(im_data[int(id_img[idx])].unsqueeze(0), grid)
# mask_gray = cv2.normalize(src=x.data.numpy().squeeze(), dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX,
# dtype=cv2.CV_8UC1)
# cv2.imshow('abc',mask_gray.transpose(1, 2, 0))
# cv2.waitKey(0)
features = net.forward_features(x)
labels_pred = net.forward_ocr(features)
ctc_f = labels_pred.data.cpu().numpy()
ctc_f = ctc_f.swapaxes(1, 2)
labelss = ctc_f.argmax(2)
ind = np.unravel_index(labelss, ctc_f.shape)
# conf = np.mean(np.exp(ctc_f[ind]))
det_text, conf2, dec_s, splits = print_seq_ext(labelss[0, :], codec)
# if conf < 0.01 and len(det_text) == 3:
# print('Too low conf short: {0} {1}'.format(det_text, conf))
# continue
det_texts.append(det_text)
# labels_gt.append()
return (det_texts, labels)
def crnn_batch(net, codec, im_data, gtso,lbso,target_h):
num_gt = len(gtso)
rrois = []
labels = []
for kk in range(num_gt):
gts = gtso[kk]
lbs = lbso[kk]
if len(gts) != 0:
gt = np.asarray(gts)
# boxr = gts[0:8].reshape(-1, 2)
center = (gt[:, 0, :] + gt[:, 1, :] + gt[:, 2, :] + gt[:, 3, :]) / 4 # 求中心点
dw = gt[:, 2, :] - gt[:, 1, :]
dh = gt[:, 1, :] - gt[:, 0, :]
poww = pow(dw, 2)
powh = pow(dh, 2)
w = np.sqrt(poww[:, 0] + poww[:, 1])
h = np.sqrt(powh[:, 0] + powh[:, 1]) + random.randint(-2, 2)
# dw2= gt[:, 0, :] - gt[:, 3, :]
# dh2= gt[:, 3, :] - gt[:, 2, :]
#
# poww2 = pow(dw2, 2)
# powh2 = pow(dh2, 2)
#
# w2= np.sqrt(poww2[:, 0] + poww2[:, 1])
# h2= np.sqrt(powh2[:, 0] + powh2[:, 1]) + random.randint(-2, 2)
#
# w = (w + w2) / 2
# h = (h + h2) / 2
angle = (np.arctan2((gt[:, 2, 1] - gt[:, 1, 1]), gt[:, 2, 0] - gt[:, 1, 0]))
# angle2 = (np.arctan2((gt[:, 3, 1] - gt[:, 0, 1]), gt[:, 3, 0] - gt[:, 0, 0]))
# angle = angle + angle2
for gt_id in range(0, len(gts)):
gt_txt = lbs[gt_id] # 文字判断
if gt_txt.startswith('##'):
continue
gt = gts[gt_id] # 标注信息判断
if gt[:, 0].max() > im_data.size(3) or gt[:, 1].max() > im_data.size(2) or gt.min() < 0:
continue
rrois.append([kk, center[gt_id][0], center[gt_id][1], h[gt_id], w[gt_id], angle[gt_id]]) # 将标注的rroi写入
labels.append(gt_txt)
# show pooled image in image layer
rois = torch.tensor(rrois).to(torch.float)
id_img = rois[:,0]
xc = rois[:, 1]
yc = rois[:, 2]
h= rois[:,3]
w= rois[:,4]
angle = rois[:,5]
input_W = im_data.size(3)
input_H = im_data.size(2)
# target_h = 44
scale = target_h / torch.max(torch.ones_like(h), h) # h = rois[:,3]
target_gw = (w * scale) + target_h
target_gw = torch.max(2*torch.ones_like(target_gw), target_gw // 32) * 32
w2 = w
h2 = h
scalex = (w2 + h2) / input_W * 1.2
scaley = h2 / input_H * 1.3
th11 = scalex * torch.cos(angle)
th12 = -torch.sin(angle) * scaley
th13 = (2 * xc - input_W - 1) / (input_W - 1) # * torch.cos(angle_var) - (2 * yc - input_H - 1) / (input_H - 1) * torch.sin(angle_var)
th21 = torch.sin(angle) * scalex
th22 = scaley * torch.cos(angle)
th23 = (2 * yc - input_H - 1) / (input_H - 1) # * torch.cos(angle_var) + (2 * xc - input_W - 1) / (input_W - 1) * torch.sin(angle_var)
# t = np.asarray([th11, th12, th13, th21, th22, th23], dtype=np.float)
# t = torch.from_numpy(t).type(torch.FloatTensor)
t =torch.stack((th11, th12, th13, th21, th22, th23),-1)
t = t.to(device)
theta = t.view(-1, 2, 3)
det_texts = []
# labels_gt = []
for idx in range(len(labels)):
grid = F.affine_grid(theta[idx].unsqueeze(0), torch.Size((1, 3, int(target_h), int(target_gw[idx]))))
x = F.grid_sample(im_data[int(id_img[idx])].unsqueeze(0), grid)
# mask_gray = cv2.normalize(src=x.data.numpy().squeeze(), dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX,
# dtype=cv2.CV_8UC1)
# cv2.imshow('abc',mask_gray.transpose(1, 2, 0))
# cv2.waitKey(0)
# features = net.forward_features(x)
labels_pred = net.forward_ocr(x)
labels_pred = labels_pred.permute(1, 2, 0)
ctc_f = labels_pred.data.cpu().numpy()
ctc_f = ctc_f.swapaxes(1, 2)
labelss = ctc_f.argmax(2)
# ind = np.unravel_index(labelss, ctc_f.shape)
# conf = np.mean(np.exp(ctc_f[ind]))
det_text, conf2, dec_s, splits = print_seq_ext(labelss[0, :], codec)
# if conf < 0.01 and len(det_text) == 3:
# print('Too low conf short: {0} {1}'.format(det_text, conf))
# continue
det_texts.append(det_text)
# labels_gt.append()
return (det_texts, labels)
| 29.967391
| 137
| 0.545702
| 1,777
| 11,028
| 3.251548
| 0.115926
| 0.018692
| 0.018172
| 0.009346
| 0.83316
| 0.816199
| 0.794219
| 0.794219
| 0.789373
| 0.777605
| 0
| 0.062638
| 0.263148
| 11,028
| 367
| 138
| 30.049046
| 0.648413
| 0.238937
| 0
| 0.686099
| 0
| 0
| 0.002045
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.017937
| false
| 0
| 0.026906
| 0
| 0.06278
| 0.017937
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
c44cad29c2ea8712ff8627089269538ae7120be0
| 628
|
py
|
Python
|
ephypype/tests/test_power.py
|
jasmainak/ephypype
|
257603cbb099cef7847a96c8eb141332fb85ebfa
|
[
"BSD-3-Clause"
] | null | null | null |
ephypype/tests/test_power.py
|
jasmainak/ephypype
|
257603cbb099cef7847a96c8eb141332fb85ebfa
|
[
"BSD-3-Clause"
] | null | null | null |
ephypype/tests/test_power.py
|
jasmainak/ephypype
|
257603cbb099cef7847a96c8eb141332fb85ebfa
|
[
"BSD-3-Clause"
] | null | null | null |
from ephypype.power import compute_and_save_psd
import os
def test_power_welch():
fmin = 0.1
fmax = 300
epochs_fname = 'test-epo.fif'
dir_path = os.path.dirname(os.path.realpath(__file__))
epochs_fname_abs = os.path.join(dir_path, epochs_fname)
compute_and_save_psd(epochs_fname_abs, fmin, fmax, method='welch')
def test_power_multitaper():
fmin = 0.1
fmax = 300
epochs_fname = 'test-epo.fif'
dir_path = os.path.dirname(os.path.realpath(__file__))
epochs_fname_abs = os.path.join(dir_path, epochs_fname)
compute_and_save_psd(epochs_fname_abs, fmin, fmax, method='multitaper')
| 29.904762
| 75
| 0.727707
| 98
| 628
| 4.285714
| 0.306122
| 0.209524
| 0.133333
| 0.121429
| 0.757143
| 0.757143
| 0.757143
| 0.757143
| 0.757143
| 0.757143
| 0
| 0.019011
| 0.16242
| 628
| 20
| 76
| 31.4
| 0.779468
| 0
| 0
| 0.625
| 0
| 0
| 0.062102
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.125
| false
| 0
| 0.125
| 0
| 0.25
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
c46fca760cc51e88cdb228c2ecb53b1e5acc6066
| 380
|
py
|
Python
|
clipboard_functions.py
|
4n4nd/UniClip_python
|
70a7b70662e78c3808d80892bfacc0d521de4221
|
[
"MIT"
] | null | null | null |
clipboard_functions.py
|
4n4nd/UniClip_python
|
70a7b70662e78c3808d80892bfacc0d521de4221
|
[
"MIT"
] | null | null | null |
clipboard_functions.py
|
4n4nd/UniClip_python
|
70a7b70662e78c3808d80892bfacc0d521de4221
|
[
"MIT"
] | null | null | null |
import pyperclip #Library for clipboard manipulation
import os
def local_get_clipboard():
return pyperclip.paste()
def local_set_clipboard(clipboard_data):
pyperclip.copy(clipboard_data)
# local_set_clipboard("My Name is Khan")
# print (local_get_clipboard())
# pyperclip.copy("hi")
# data = "myman"
# os.system("echo '%s' | pbcopy" % data)
# print (local_get_clipboard())
| 22.352941
| 52
| 0.75
| 51
| 380
| 5.352941
| 0.509804
| 0.087912
| 0.186813
| 0.161172
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121053
| 380
| 17
| 53
| 22.352941
| 0.817365
| 0.547368
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.166667
| 0.833333
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
671624fa5964c36732989b5770ee5f96277b869a
| 74
|
py
|
Python
|
foo_bar/bar.py
|
JPBeukes/foo_bar_pkg
|
7127b954b3f6ce66dacb4bf7221a7998f151728a
|
[
"MIT"
] | null | null | null |
foo_bar/bar.py
|
JPBeukes/foo_bar_pkg
|
7127b954b3f6ce66dacb4bf7221a7998f151728a
|
[
"MIT"
] | null | null | null |
foo_bar/bar.py
|
JPBeukes/foo_bar_pkg
|
7127b954b3f6ce66dacb4bf7221a7998f151728a
|
[
"MIT"
] | null | null | null |
import foo_bar.foo as foo
def bar_print():
print('bar')
foo.foo_print()
| 14.8
| 25
| 0.716216
| 14
| 74
| 3.571429
| 0.428571
| 0.24
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.135135
| 74
| 5
| 26
| 14.8
| 0.78125
| 0
| 0
| 0
| 0
| 0
| 0.04
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| true
| 0
| 0.25
| 0
| 0.5
| 0.75
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 6
|
6761cf95f7ac0dc935285955a4e450f12e1679e4
| 169,826
|
py
|
Python
|
chb/mips/simulation/MIPSimStubs.py
|
orinatic/CodeHawk-Binary
|
8b4fd728213e629736d5ece840ea3b43cea53f30
|
[
"MIT"
] | null | null | null |
chb/mips/simulation/MIPSimStubs.py
|
orinatic/CodeHawk-Binary
|
8b4fd728213e629736d5ece840ea3b43cea53f30
|
[
"MIT"
] | null | null | null |
chb/mips/simulation/MIPSimStubs.py
|
orinatic/CodeHawk-Binary
|
8b4fd728213e629736d5ece840ea3b43cea53f30
|
[
"MIT"
] | null | null | null |
# ------------------------------------------------------------------------------
# CodeHawk Binary Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2020-2021 Henny Sipma
# Copyright (c) 2021 Aarno Labs LLC
#
# 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.
# ------------------------------------------------------------------------------
"""Simulation code for library functions."""
from typing import (
Any,
BinaryIO,
Callable,
cast,
Dict,
IO,
List,
Optional,
Tuple,
Type,
TYPE_CHECKING)
import datetime
import ipaddress
import time
from chb.mips.simulation.MIPSimMemory import (
MIPSimStackMemory, MIPSimGlobalMemory, MIPSimBaseMemory)
import chb.simulation.SimSymbolicValue as SSV
import chb.simulation.SimValue as SV
import chb.simulation.SimUtil as SU
import chb.util.fileutil as UF
if TYPE_CHECKING:
from chb.mips.MIPSAccess import MIPSAccess
from chb.mips.simulation.MIPSimulationState import MIPSimulationState
stubbed_libc_functions: Dict[str, Callable[["MIPSAccess"], "MIPSimStub"]] = {
"accept": lambda app: MIPStub_accept(app),
"access": lambda app: MIPStub_access(app),
"atoi": lambda app: MIPStub_atoi(app),
"basename": lambda app: MIPStub_basename(app),
"bind": lambda app: MIPStub_bind(app),
"calculate_checksum": lambda app: MIPStub_calculate_checksum(app),
"calloc": lambda app: MIPStub_calloc(app),
"chdir": lambda app: MIPStub_chdir(app),
"clock_gettime": lambda app: MIPStub_clock_gettime(app),
"close": lambda app: MIPStub_close(app),
"closelog": lambda app: MIPStub_closelog(app),
"connect": lambda app: MIPStub_connect(app),
"daemon": lambda app: MIPStub_daemon(app),
"dlopen": lambda app: MIPStub_dlopen(app),
"dlsym": lambda app: MIPStub_dlsym(app),
"dprintf": lambda app: MIPStub_dprintf(app),
"dup": lambda app: MIPStub_dup(app),
"dup2": lambda app: MIPStub_dup2(app),
"epoll_create": lambda app: MIPStub_epoll_create(app),
"epoll_ctl": lambda app: MIPStub_epoll_ctl(app),
"epoll_wait": lambda app: MIPStub_epoll_wait(app),
"__errno_location": lambda app: MIPStub___errno_location(app),
"exit": lambda app: MIPStub_exit(app),
"fclose": lambda app: MIPStub_fclose(app),
"fcntl": lambda app: MIPStub_fcntl(app),
"fcntl64": lambda app: MIPStub_fcntl64(app),
"fdopen": lambda app: MIPStub_fdopen(app),
"feof": lambda app: MIPStub_feof(app),
"__fgetc_unlocked": lambda app: MIPStub___fgetc_unlocked(app),
"fflush": lambda app: MIPStub_fflush(app),
"fgets": lambda app: MIPStub_fgets(app),
"fileno": lambda app: MIPStub_fileno(app),
"fopen": lambda app: MIPStub_fopen(app),
"fopen64": lambda app: MIPStub_fopen64(app),
"fork": lambda app: MIPStub_fork(app),
"fprintf": lambda app: MIPStub_fprintf(app),
"fputs": lambda app: MIPStub_fputs(app),
"fread": lambda app: MIPStub_fread(app),
"free": lambda app: MIPStub_free(app),
"freeaddrinfo": lambda app: MIPStub_freeaddrinfo(app),
"fscanf": lambda app: MIPStub_fscanf(app),
"fstat": lambda app: MIPStub_fstat(app),
"fstat64": lambda app: MIPStub_fstat64(app),
"fwrite": lambda app: MIPStub_fwrite(app),
"getaddrinfo": lambda app: MIPStub_getaddrinfo(app),
"getcwd": lambda app: MIPStub_getcwd(app),
"getenv": lambda app: MIPStub_getenv(app),
"gethostname": lambda app: MIPStub_gethostname(app),
"getline": lambda app: MIPStub_getline(app),
"getopt": lambda app: MIPStub_getopt(app),
"getopt_long": lambda app: MIPStub_getopt_long(app),
"getpeername": lambda app: MIPStub_getpeername(app),
"getpid": lambda app: MIPStub_getpid(app),
"getrlimit64": lambda app: MIPStub_getrlimit64(app),
"getsockname": lambda app: MIPStub_getsockname(app),
"gettimeofday": lambda app: MIPStub_gettimeofday(app),
"getuid": lambda app: MIPStub_getuid(app),
"index": lambda app: MIPStub_index(app),
"inet_addr": lambda app: MIPStub_inet_addr(app),
"inet_aton": lambda app: MIPStub_inet_aton(app),
"inet_ntoa": lambda app: MIPStub_inet_ntoa(app),
"inet_pton": lambda app: MIPStub_inet_pton(app),
"ioctl": lambda app: MIPStub_ioctl(app),
"__libc_current_sigrtmax": lambda app: MIPStub___libc_current_sigrtmax(app),
"__libc_current_sigrtmin": lambda app: MIPStub___libc_current_sigrtmin(app),
"listen": lambda app: MIPStub_listen(app),
"localtime": lambda app: MIPStub_localtime(app),
"lockf": lambda app: MIPStub_lockf(app),
"longjmp": lambda app: MIPStub_longjmp(app),
"malloc": lambda app: MIPStub_malloc(app),
"memcmp": lambda app: MIPStub_memcmp(app),
"memcpy": lambda app: MIPStub_memcpy(app),
"memmove": lambda app: MIPStub_memmove(app),
"memset": lambda app: MIPStub_memset(app),
"mkdir": lambda app: MIPStub_mkdir(app),
"mktemp": lambda app: MIPStub_mktemp(app),
"mmap": lambda app: MIPStub_mmap(app),
"msgget": lambda app: MIPStub_msgget(app),
"open": lambda app: MIPStub_open(app),
"open64": lambda app: MIPStub_open64(app),
"openlog": lambda app: MIPStub_openlog(app),
"pclose": lambda app: MIPStub_pclose(app),
"perror": lambda app: MIPStub_perror(app),
"popen": lambda app: MIPStub_popen(app),
"printf": lambda app: MIPStub_printf(app),
"pthread_attr_init": lambda app: MIPStub_pthread_attr_init(app),
"pthread_attr_setschedparam": lambda app: MIPStub_pthread_attr_setschedparam(app),
"pthread_attr_setschedpolicy": lambda app: MIPStub_pthread_attr_setschedpolicy(app),
"pthread_cond_init": lambda app: MIPStub_pthread_cond_init(app),
"pthread_cond_signal": lambda app: MIPStub_pthread_cond_signal(app),
"pthread_create": lambda app: MIPStub_pthread_create(app),
"pthread_mutex_init": lambda app: MIPStub_pthread_mutex_init(app),
"pthread_mutex_lock": lambda app: MIPStub_pthread_mutex_lock(app),
"pthread_mutex_unlock": lambda app: MIPStub_pthread_mutex_unlock(app),
"pthread_self": lambda app: MIPStub_pthread_self(app),
"puts": lambda app: MIPStub_puts(app),
"rand": lambda app: MIPStub_rand(app),
"random": lambda app: MIPStub_random(app),
"read": lambda app: MIPStub_read(app),
"realloc": lambda app: MIPStub_realloc(app),
"realpath": lambda app: MIPStub_realpath(app),
"recv": lambda app: MIPStub_recv(app),
"recvfrom": lambda app: MIPStub_recvfrom(app),
"rt_sigaction": lambda app: MIPStub_sigaction(app, name="rt_sigaction"),
"sched_get_priority_max": lambda app: MIPStub_sched_get_priority_max(app),
"sched_get_priority_min": lambda app: MIPStub_sched_get_priority_max(app),
"sched_yield": lambda app: MIPStub_sched_yield(app),
"select": lambda app: MIPStub_select(app),
"semget": lambda app: MIPStub_semget(app),
"semop": lambda app: MIPStub_semop(app),
"send": lambda app: MIPStub_send(app),
"sendto": lambda app: MIPStub_sendto(app),
"setenv": lambda app: MIPStub_setenv(app),
"_setjmp": lambda app: MIPStub__setjmp(app),
"setlogmask": lambda app: MIPStub_setlogmask(app),
"setrlimit": lambda app: MIPStub_setrlimit(app),
"setrlimit64": lambda app: MIPStub_setrlimit(app),
"setsockopt": lambda app: MIPStub_setsockopt(app),
"shmat": lambda app: MIPStub_shmat(app),
"shmget": lambda app: MIPStub_shmget(app),
"sigaction": lambda app: MIPStub_sigaction(app),
"sigaddset": lambda app: MIPStub_sigaddset(app),
"sigemptyset": lambda app: MIPStub_sigemptyset(app),
"signal": lambda app: MIPStub_signal(app),
"sigprocmask": lambda app: MIPStub_sigprocmask(app),
"sleep": lambda app: MIPStub_sleep(app),
"snprintf": lambda app: MIPStub_snprintf(app),
"socket": lambda app: MIPStub_socket(app),
"sprintf": lambda app: MIPStub_sprintf(app),
"srand": lambda app: MIPStub_srand(app),
"sscanf": lambda app: MIPStub_sscanf(app),
"stat": lambda app: MIPStub_stat(app),
"strcasecmp": lambda app: MIPStub_strcasecmp(app),
"strcat": lambda app: MIPStub_strcat(app),
"strchr": lambda app: MIPStub_strchr(app),
"strcmp": lambda app: MIPStub_strcmp(app),
"strcpy": lambda app: MIPStub_strcpy(app),
"strdup": lambda app: MIPStub_strdup(app),
"strerror": lambda app: MIPStub_strerror(app),
"stristr": lambda app: MIPStub_stristr(app),
"strlen": lambda app: MIPStub_strlen(app),
"strncasecmp": lambda app: MIPStub_strncasecmp(app),
"strncat": lambda app: MIPStub_strncat(app),
"strncmp": lambda app: MIPStub_strncmp(app),
"strncpy": lambda app: MIPStub_strncpy(app),
"strrchr": lambda app: MIPStub_strrchr(app),
"strsep": lambda app: MIPStub_strsep(app),
"strstr": lambda app: MIPStub_strstr(app),
"strtof": lambda app: MIPStub_strtof(app),
"strtok": lambda app: MIPStub_strtok(app),
"strtok_r": lambda app: MIPStub_strtok_r(app),
"strtoul": lambda app: MIPStub_strtoul(app),
"syslog": lambda app: MIPStub_syslog(app),
"system": lambda app: MIPStub_system(app),
"time": lambda app: MIPStub_time(app),
"tolower": lambda app: MIPStub_tolower(app),
"umask": lambda app: MIPStub_umask(app),
"unlink": lambda app: MIPStub_unlink(app),
"usleep": lambda app: MIPStub_usleep(app),
"vsnprintf": lambda app: MIPStub_vsnprintf(app),
"vsprintf": lambda app: MIPStub_vsprintf(app),
"waitpid": lambda app: MIPStub_waitpid(app),
"write": lambda app: MIPStub_write(app),
"isLanSubnet": lambda app: MIPStub_isLanSubnet(app),
"msglogd": lambda app: MIPStub_msglogd(app) # libmsglog.so
}
fcntl_cmds = {
"0x0": "F_DUPFD",
"0x1": "F_GETFD",
"0x2": "F_SETFD",
"0x3": "F_GETFL",
"0x4": "F_SETFL"
}
class MIPSimStub(object):
def __init__(self, app: "MIPSAccess", name: str) -> None:
self._app = app
self._name = name
@property
def app(self) -> "MIPSAccess":
return self._app
@property
def name(self) -> str:
return self._name
def get_arg_val(
self,
iaddr: str,
simstate: "MIPSimulationState",
arg: str) -> SV.SimValue:
"""Returns a SimValue; arg must be a MIPS register."""
return simstate.get_regval(iaddr, arg)
def get_arg_deref_val(
self,
iaddr: str,
simstate: "MIPSimulationState",
arg: str) -> SV.SimValue:
"""Returns a SimValue, pointed to by the arg-val."""
saddr = self.get_arg_val(iaddr, simstate, arg)
if saddr.is_address:
saddr = cast(SSV.SimAddress, saddr)
return simstate.get_memval(iaddr, saddr, 4)
else:
return SV.simUndefinedDW
def get_stack_arg_val(
self,
iaddr: str,
simstate: "MIPSimulationState",
argindex: int) -> SV.SimValue:
"""Returns a SimValue for an argument on the stack."""
sp = simstate.get_regval(iaddr, "sp")
if sp.is_address:
sp = cast(SSV.SimAddress, sp)
if sp.is_stack_address:
sp = cast(SSV.SimStackAddress, sp)
stackaddr = sp.add_offset(4 * argindex)
return simstate.get_memval(iaddr, stackaddr, 4)
return SV.simUndefinedDW
def get_arg_string(
self,
iaddr: str,
simstate: "MIPSimulationState",
arg: str) -> str:
"""Returns a string; arg must be a MIPS register."""
saddr = self.get_arg_val(iaddr, simstate, arg)
return self.get_string_at_address(iaddr, simstate, saddr)
def get_string_at_address(
self,
iaddr: str,
simstate: "MIPSimulationState",
saddr: SV.SimValue) -> str:
result = ''
offset = 0
if saddr.is_string_address:
saddr = cast(SSV.SimStringAddress, saddr)
return saddr.stringval
elif saddr.is_symbol:
saddr = cast(SSV.SimSymbol, saddr)
return 'symbol:' + saddr.name
elif saddr.is_literal and not saddr.is_defined:
return '*****address-not-defined*****'
elif saddr.is_literal and saddr.is_defined:
saddr = cast(SV.SimLiteralValue, saddr)
if (
simstate.instaticlib
and saddr.value > simstate.libimagebase.offsetvalue):
saddr = cast(SV.SimDoubleWordValue, saddr)
gaddr = SSV.SimGlobalAddress(saddr)
elif saddr.value > simstate.imagebase.offsetvalue:
saddr = cast(SV.SimDoubleWordValue, saddr)
gaddr = SSV.SimGlobalAddress(saddr)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"String argument is not a valid address: " + str(saddr))
else:
gaddr = cast(SSV.SimGlobalAddress, saddr)
while True:
srcaddr = gaddr.add_offset(offset)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
if srcval.is_literal and srcval.is_defined:
srcval = cast(SV.SimLiteralValue, srcval)
if srcval.value == 0:
break
result += chr(srcval.value)
offset += 1
else:
break
return result
def get_stack_arg_string(
self,
iaddr: str,
simstate: "MIPSimulationState",
argindex: int) -> str:
sp = simstate.get_regval(iaddr, "sp")
if sp.is_address:
sp = cast(SSV.SimAddress, sp)
if sp.is_stack_address:
sp = cast(SSV.SimStackAddress, sp)
stackaddr = sp.add_offset(4 * argindex)
return self.get_string_at_address(iaddr, simstate, stackaddr)
return "******stack-address-not-defined*******"
def get_arg_deref_string(
self,
iaddr: str,
simstate: "MIPSimulationState",
arg: str) -> str:
"""Returns a string; arg must be a MIPS register."""
saddrptr = self.get_arg_val(iaddr, simstate, arg)
if saddrptr.is_address:
saddrptr = cast(SSV.SimAddress, saddrptr)
saddr = simstate.get_memval(iaddr, saddrptr, 4)
if saddr.is_address:
saddr = cast(SSV.SimAddress, saddr)
result = ""
offset = 0
while True:
srcaddr = saddr.add_offset(offset)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
if srcval.is_literal and srcval.is_defined:
srcval = cast(SV.SimLiteralValue, srcval)
if srcval.value == 0:
break
result += chr(srcval.value)
offset += 1
else:
break
return result
else:
raise SU.CHBSimError(
simstate,
iaddr,
("Pointed to value in arg_deref_string "
+ " is not an address: "
+ str(saddr)))
else:
raise SU.CHBSimError(
simstate,
iaddr,
("Argument is not an address in arg_deref_string: "
+ str(saddrptr)))
def is_error_operation(self) -> bool:
return False
def is_io_operation(self) -> bool:
return False
def is_network_operation(self) -> bool:
return False
def is_string_operation(self) -> bool:
return False
def is_environment_operation(self) -> bool:
return False
def is_thread_operation(self) -> bool:
return False
def is_process_operation(self) -> bool:
return False
def is_memalloc_operation(self) -> bool:
return False
def is_sharedmem_operation(self) -> bool:
return False
def is_system_operation(self) -> bool:
return False
def is_domain_call(self) -> Optional[str]:
return None
def add_logmsg(
self,
iaddr: str,
simstate: "MIPSimulationState",
arguments: str,
returnval: str = "") -> str:
preturn = 'return value: ' + returnval if returnval else ''
msg = self.name + '(' + arguments + ') ' + preturn
simstate.add_logmsg('stub:' + self.name, msg)
if self.is_error_operation():
simstate.add_logmsg('error:', msg)
if self.is_io_operation():
simstate.add_logmsg('i/o:', msg)
if self.is_network_operation():
simstate.add_logmsg('network:', msg)
if self.is_string_operation():
simstate.add_logmsg('string:', msg)
if self.is_thread_operation():
simstate.add_logmsg('thread:', msg)
if self.is_process_operation():
simstate.add_logmsg('process:', msg)
if self.is_memalloc_operation():
simstate.add_logmsg('memory allocation:', msg)
if self.is_sharedmem_operation():
simstate.add_logmsg('shared memory:', msg)
if self.is_system_operation():
simstate.add_logmsg('system', msg)
if self.is_domain_call():
domain = cast(str, self.is_domain_call())
simstate.add_logmsg('domain:' + domain, msg)
return msg
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Dummy function."""
raise SU.CHBSimError(
simstate,
iaddr,
"Simulation not implemented for " + self.name)
def __str__(self) -> str:
return self.name
class MIPStub_accept(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, "accept")
def is_io_operation(self) -> bool:
return True
def is_network_operation(self) -> bool:
return True
# a new file descriptor shall be allocated for the socket
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2deref = self.get_arg_deref_val(iaddr, simstate, "a2")
pargs = (
','.join(str(a) for a in [a0, a1])
+ ','
+ str(a2)
+ ':'
+ str(a2deref))
simstate.set_register(iaddr, "v0", SV.mk_simvalue(114))
if a1.is_address:
a1 = cast(SSV.SimAddress, a1)
if a2deref.is_literal and a2deref.is_defined:
a2deref = cast(SV.SimLiteralValue, a2deref)
if a2deref.value == 16:
simstate.set_memval(
iaddr, a1, SV.mk_simvalue(0, size=2))
simstate.set_memval(
iaddr, a1.add_offset(2), SV.mk_simvalue(80, size=2))
simstate.set_memval(
iaddr, a1.add_offset(4), SV.mk_simvalue(444))
simstate.set_memval(
iaddr, a1.add_offset(8), SV.mk_simvalue(0))
simstate.set_memval(
iaddr, a1.add_offset(12), SV.mk_simvalue(0))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_access(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, "access")
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_atoi(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, "atoi")
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
try:
a0str = self.get_arg_string(iaddr, simstate, 'a0')
except Exception as e:
print("atoi: " + str(a0) + ' is not a string')
print(str(e))
exit(1)
pargs = str(a0) + ':' + a0str
try:
result = int(a0str)
except Exception as e:
print('String ' + a0str + ' cannot be converted to int: ' + str(e))
simstate.add_logmsg(
'error:',
'Conversion to int failed in atoi: ' + a0str)
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_basename(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'basename')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns (in v0) the basename set in simstate, expressed as SimString."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SSV.mk_string_address(simstate.basename))
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_bind(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'bind')
def is_io_operation(self) -> bool:
return True
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_calculate_checksum(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'calculate_checksum')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""No computation; returns -1 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(-1))
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs, returnval='-1')
class MIPStub_calloc(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'calloc')
def is_memalloc_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Initializes the memory to 0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
base = 'calloc_' + iaddr
if a0.is_literal and a0.is_defined and a1.is_literal and a1.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
a1 = cast(SV.SimLiteralValue, a1)
buffersize = a0.value * a1.value
address = SSV.mk_base_address(base, 0, buffersize=buffersize)
for i in range(0, buffersize):
tgtaddr = address.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, SV.SimByteValue(0))
simstate.set_register(iaddr, "v0", address)
returnval: str = str(address)
else:
simstate.set_register(iaddr, 'v0', SV.simZero)
returnval = "0"
pargs = str(a0) + ',' + str(a1)
return self.add_logmsg(iaddr, simstate, pargs, returnval=returnval)
class MIPStub_chdir(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'chdir')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + str(a0str)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_clock_gettime(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'clock_gettime')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
if a1.is_address:
a1 = cast(SSV.SimAddress, a1)
simstate.set_memval(iaddr, a1, SV.mk_simvalue(int(time.time())))
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_close(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'close')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_closelog(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'closelog')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o; no return value."""
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_connect(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'connect')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_daemon(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'daemon')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_dlopen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'dlopen')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
result = SSV.mk_symboltablehandle(a0str)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_dlsym(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'dlsym')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
if a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
result = SSV.mk_dynamic_link_symbol(a0.value, a1str)
if a0.is_symbol_table_handle:
a0 = cast(SSV.SimSymbolTableHandle, a0)
a0.set_value(a1str, result)
simstate.set_dlsym_stub(iaddr, a1str)
simstate.set_register(iaddr, 'v0', result)
else:
simstate.set_register(iaddr, "v0", SV.simNegOne)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_dprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'dprintf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_dup(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'dup')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(15))
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(a0))
class MIPStub_dup2(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'dup2')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', a1)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a1))
class MIPStub_epoll_create(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'epoll_create')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
result = SV.mk_simvalue(1)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result))
class MIPStub_epoll_ctl(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'epoll_ctl')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_epoll_wait(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'epoll_wait')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs, returnval='1')
class MIPStub___errno_location(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, '__errno_location')
def is_error_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
result = SSV.mk_string_address('error-string')
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, str(result))
class MIPStub_exit(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'exit')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
raise SU.CHBSimExitException(simstate, iaddr, str(a0))
class MIPStub_fclose(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fclose')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_symbol:
a0 = cast(SSV.SimSymbol, a0)
if a0.is_file_descriptor:
try:
a0 = cast(SSV.SimSymbolicFileDescriptor, a0)
a0.filedescriptor.close()
simstate.add_logmsg('i/o', 'Successfully closed ' + str(a0))
except Exception as e:
simstate.add_logmsg(
'i/o', 'Error in closing ' + str(a0) + ': ' + str(e))
elif a0.is_file_pointer:
try:
a0 = cast(SSV.SimSymbolicFilePointer, a0)
a0.fp.close()
simstate.add_logmsg('i/o', 'Successfully closed ' + str(a0))
except Exception as e:
simstate.add_logmsg(
'i/o', 'Error in closing ' + str(a0) + ': ' + str(e))
else:
simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')')
else:
pass
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_fcntl(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fcntl')
def is_io_operation(self) -> bool:
return True
def get_cmd_name(self, i: SV.SimLiteralValue) -> str:
if str(i) in fcntl_cmds:
return fcntl_cmds[str(i)]
else:
return str(i)
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a1.is_literal:
a1 = cast(SV.SimLiteralValue, a1)
a1cmd = self.get_cmd_name(a1)
if a1cmd == "F_SETFL":
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = str(a0) + ',' + a1cmd + ',' + str(a2)
else:
pargs = str(a0) + ',' + a1cmd
else:
pargs = str(a0) + "," + str(a1)
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(0))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fcntl64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fcntl64')
def is_io_operation(self) -> bool:
return True
def get_cmd_name(self, i: SV.SimLiteralValue) -> str:
if str(i) in fcntl_cmds:
return fcntl_cmds[str(i)]
else:
return str(i)
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a1.is_literal:
a1 = cast(SV.SimLiteralValue, a1)
a1cmd = self.get_cmd_name(a1)
if a1cmd == "F_SETFL":
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = str(a0) + ',' + a1cmd + ',' + str(a2)
else:
pargs = str(a0) + ',' + a1cmd
else:
pargs = str(a0) + str(a1)
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(0))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fdopen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fdopen')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs, returnval='0')
class MIPStub_feof(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'feof')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns false by default."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_symbol:
a0 = cast(SSV.SimSymbol, a0)
if a0.is_file_pointer:
a0 = cast(SSV.SimSymbolicFilePointer, a0)
try:
fp = a0.fp
s = fp.read()
if s == '':
result = 1
else:
result = 0
except Exception:
result = 0
else:
result = 0
else:
result = 0
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')')
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result))
class MIPStub___fgetc_unlocked(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, '__fgetc_unlocked')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Return a tainted value in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SSV.SimTaintedValue('fgetc', -1, 255))
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_fflush(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fflush')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_fgets(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fgets')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Inputs tainted characters."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = str(a0) + ',' + str(a1) + ',' + str(a2)
simstate.set_register(iaddr, 'v0', a0)
if not a0.is_address:
return self.add_logmsg(iaddr, simstate, pargs)
a0 = cast(SSV.SimAddress, a0)
if a2.is_symbolic:
a2 = cast(SSV.SimSymbol, a2)
if a2.is_file_pointer:
a2 = cast(SSV.SimSymbolicFilePointer, a2)
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
for i in range(0, a1.value - 1):
c = a2.fp.read(1)
if c == '':
if i == 0:
simstate.set_register(iaddr, 'v0', SV.simZero)
break
srcval = SV.SimByteValue(255)
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
break
else:
srcval = SV.SimByteValue(ord(c))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(a1.value - 1), SV.SimByteValue(0))
elif a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
for i in range(0, a1.value - 1):
srcval = SV.SimByteValue(ord('t'))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(a1.value - 1), SV.SimByteValue(0))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fputs(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fputs')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fileno(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fileno')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns a symbolic value in v0"""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_symbolic:
a0 = cast(SSV.SimSymbol, a0)
if a0.is_file_pointer:
a0 = cast(SSV.SimSymbolicFilePointer, a0)
fpresult = SSV.mk_filedescriptor(a0.filename, a0.fp)
simstate.set_register(iaddr, "v0", fpresult)
returnval = str(fpresult)
elif a0.is_symbol:
a0 = cast(SSV.SimSymbol, a0)
symresult = SSV.SimSymbol(a0.name + '_fildes')
simstate.set_register(iaddr, "v0", symresult)
returnval = str(symresult)
else:
simstate.set_register(iaddr, "v0", SV.SimDoubleWordValue(-1))
returnval = "-1"
else:
simstate.set_register(iaddr, "v0", SV.SimDoubleWordValue(-1))
returnval = "-1"
return self.add_logmsg(iaddr, simstate, str(a0), returnval=returnval)
class MIPStub_fopen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fopen')
def is_io_operation(self) -> bool:
return True
def simulate_success(
self,
iaddr: str,
simstate: "MIPSimulationState",
pargs: str,
filename: str,
filepointer: IO[Any],
comment: str = "") -> str:
returnval = SSV.mk_filepointer(filename, filepointer)
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
def simulate_failure(
self,
iaddr: str,
simstate: "MIPSimulationState",
pargs: str,
comment: str = "") -> str:
returnval = SV.simZero
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o; returns 0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = (
','.join(str(a) + ':' + str(s)
for (a, s) in [(a0, a0str), (a1, a1str)]))
if a0str == '/dev/console':
fp = open('sim_dev_console.txt', a1str)
return self.simulate_success(
iaddr,
simstate,
pargs,
'/dev/console',
fp,
'assume access to /dev/console is always enabled')
elif a0str in simstate.simsupport.diskfilenames:
filename = simstate.simsupport.diskfilenames[a0str]
fp = open(filename, a1str)
return self.simulate_success(
iaddr, simstate, pargs, a0str, fp, 'use diskfile: ' + filename)
else:
return self.simulate_failure(iaddr, simstate, pargs)
class MIPStub_fopen64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fopen64')
def is_io_operation(self) -> bool:
return True
def simulate_success(
self,
iaddr: str,
simstate: "MIPSimulationState",
pargs: str,
filename: str,
filepointer: IO[Any],
comment: str = "") -> str:
returnval = SSV.mk_filepointer(filename, filepointer)
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
def simulate_failure(
self,
iaddr: str,
simstate: "MIPSimulationState",
pargs: str,
comment: str = "") -> str:
returnval = SV.simZero
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o; returns 0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = (
','.join(str(a) + ':' + str(s)
for (a, s) in [(a0, a0str), (a1, a1str)]))
if a0str == '/dev/console':
fpconsole = open('devconsole', 'w')
return self.simulate_success(
iaddr,
simstate,
pargs,
'devconsole',
fpconsole,
comment='assume access to /dev/console is always enabled')
elif a0str in simstate.simsupport.diskfilenames:
filename = simstate.simsupport.diskfilenames[a0str]
fp = open(filename, a1str)
return self.simulate_success(
iaddr, simstate, pargs, a0str, fp, 'use diskfile: ' + filename)
else:
return self.simulate_failure(iaddr, simstate, pargs)
class MIPStub_freeaddrinfo(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'freeaddrinfo')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_fscanf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fscanf')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_fstat(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fstat')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fstat64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fstat64')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_fwrite(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fwrite')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o, returns 1 in v0 for now."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
simstate.set_register(iaddr, 'v0', SV.simOne)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
return self.add_logmsg(iaddr, simstate, pargs, returnval='1')
class MIPStub_fread(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fread')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a2))
class MIPStub_free(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'free')
def is_memalloc_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_fork(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fork')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
if iaddr in simstate.simsupport.forkchoices:
result = simstate.simsupport.forkchoices[iaddr]
else:
result = 0
simresult = SV.mk_simvalue(result)
simstate.set_register(iaddr, 'v0', simresult)
return self.add_logmsg(iaddr, simstate, '', returnval=str(result))
class MIPStub_fprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'fprintf')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
simstate.set_register(iaddr, 'v0', SV.simOne)
pargs = str(a0) + ',' + str(a1) + ':' + a1str
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_getaddrinfo(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getaddrinfo')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
# a0str = self.get_arg_string(iaddr, simstate,'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
simstate.set_register(iaddr, 'v0', SV.simZero)
if a3.is_address:
a3 = cast(SSV.SimAddress, a3)
simstate.set_memval(iaddr, a3, a2)
else:
simstate.add_logmsg(iaddr, "Not able to set side effect of getaddrinfo")
pargs = (
str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2) + ',' + str(a3))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_getcwd(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getcwd')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
cwd = simstate.simsupport.get_cwd()
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
i = 0
for c in cwd:
simstate.set_memval(
iaddr, a0.add_offset(i), SV.mk_simbytevalue(ord(c)))
i += 1
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a0))
class MIPStub_getenv(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getenv')
def is_environment_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs getenv request, returns environment variable from simstate."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
if simstate.has_environment_variable(a0str):
envvalue = simstate.get_environment_variable_value(a0str)
result: SV.SimValue = SSV.mk_string_address(envvalue)
envmsg = 'retrieved: ' + str(result) + ' for ' + a0str
else:
result = SV.simZero
envmsg = 'no environment value found for ' + a0str
simstate.set_register(iaddr, 'v0', result)
simstate.add_logmsg('getenv', envmsg)
pargs = str(a0) + ':' + a0str
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_gethostname(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'gethostname')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = ','.join(str(a) for a in [a0, a1])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_getline(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getline')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1deref = self.get_arg_deref_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = str(a0) + ',' + str(a1) + ':' + str(a1deref) + ',' + str(a2)
if a2.is_file_pointer and a0.is_address:
a0 = cast(SSV.SimAddress, a0)
a2 = cast(SSV.SimSymbolicFilePointer, a2)
line = a2.fp.readline()
result = len(line)
if result > 0:
sval = SSV.mk_string_address(line)
simstate.set_memval(iaddr, a0, sval)
simstate.add_logmsg('i/o', 'Read line: ' + line + ' from ' + str(a2))
else:
simstate.add_logmsg('i/o', 'Reached eof of ' + str(a2))
result = -1
else:
simstate.add_logmsg('i/o', 'No input read from ' + str(a2))
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_getopt(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getopt')
self.optarg = SV.simZero
self.optind = 1
self.optopt: SV.SimValue = SV.simZero
def is_io_operation(self) -> bool:
return True
def has_argument(self, cmdstr: str, c: str) -> bool:
cindex = cmdstr.find(c)
if cindex < 0:
return False
return cmdstr[cindex+1] == ':'
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
optoptaddr = simstate.simsupport.optoptaddr
optargaddr = simstate.simsupport.optargaddr
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1]) + ',' + str(a2) + ':' + a2str
if not (optoptaddr.is_address and optargaddr.is_address):
simstate.set_register(iaddr, "v0", SV.simNegOne)
return self.add_logmsg(iaddr, simstate, pargs, returnval="-1")
optoptaddr = cast(SSV.SimAddress, optoptaddr)
optargaddr = cast(SSV.SimAddress, optargaddr)
if a0.is_literal and a0.is_defined and a1.is_address:
a0 = cast(SV.SimLiteralValue, a0)
a1 = cast(SSV.SimAddress, a1)
if self.optind < a0.value:
argaddr = a1.add_offset(self.optind * 4)
self.optopt = simstate.get_memval(iaddr, argaddr, 4)
if self.optopt.is_string_address:
self.optopt = cast(SSV.SimStringAddress, self.optopt)
if self.optopt.stringval.startswith('-'):
cmdarg = self.optopt.stringval[1]
simstate.set_memval(
iaddr, optoptaddr, SV.mk_simvalue(ord(cmdarg) - 65))
if self.has_argument(a2str, cmdarg):
argvaladdr = a1.add_offset((self.optind + 1) * 4)
nextarg = simstate.get_memval(iaddr, argvaladdr, 4)
if nextarg.is_string_address:
nextarg = cast(SSV.SimStringAddress, nextarg)
if nextarg.stringval.startswith('-'):
emptyarg = SSV.mk_string_address(':')
simstate.set_memval(iaddr, optargaddr, emptyarg)
self.optind += 1
else:
simstate.set_memval(iaddr, optargaddr, nextarg)
self.optind += 2
else:
result = -1
else:
self.optind += 1
result = ord(cmdarg)
else:
result = -1
else:
result = -1
else:
result = -1
else:
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_getopt_long(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getopt_long')
self.optarg: SV.SimValue = SV.simZero
self.optind = 1
self.optopt: SV.SimValue = SV.simZero
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o, returns -1 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
if a0.is_literal and a0.is_defined and a1.is_address:
a0 = cast(SV.SimLiteralValue, a0)
a1 = cast(SSV.SimAddress, a1)
if self.optind < a0.value:
argaddr = a1.add_offset(self.optind * 4)
self.optopt = simstate.get_memval(iaddr, argaddr, 4)
if self.optopt.is_string_address:
self.optopt = cast(SSV.SimStringAddress, self.optopt)
if self.optopt.stringval.startswith('-'):
result = ord(self.optopt.stringval[1])
self.optind += 1
else:
result = -1
else:
result = -1
else:
result = -1
else:
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
pargs = ','.join(str(a) for a in [a0, a1]) + ',' + str(a0) + ':' + a2str
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_getpeername(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getpeername')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs, returnval='0')
class MIPStub_getpid(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getpid')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_getrlimit64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getrlimit64')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a1.is_address:
a1 = cast(SSV.SimAddress, a1)
simstate.set_memval(iaddr, a1, SV.simZero)
simstate.set_memval(iaddr, a1.add_offset(4), SV.simZero)
simstate.set_memval(iaddr, a1.add_offset(8), SV.simZero)
simstate.set_memval(iaddr, a1.add_offset(12), SV.simZero)
pargs = str(a0) + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_getsockname(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getsockname')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simNegOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_gettimeofday(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'gettimeofday')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
t = int(time.time())
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
simstate.set_memval(iaddr, a0, SV.mk_simvalue(t))
simstate.set_memval(iaddr, a0.add_offset(4), SV.simZero)
simstate.set_memval(iaddr, a0.add_offset(8), SV.simZero)
simstate.set_memval(iaddr, a0.add_offset(12), SV.simZero)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_getuid(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'getuid')
def get_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_index(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'index')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
a1value = str(chr(a1.value))
else:
a1value = "?"
pargs = str(a0) + ':' + a0str + ',' + str(a1) + ' {' + a1value + '}'
index = a0str.find(a1value)
if index >= 0 and a0.is_address:
a0 = cast(SSV.SimAddress, a0)
result: SV.SimValue = a0.add_offset(index)
else:
result = SV.simZero
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_inet_addr(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'inet_addr')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
result = int(ipaddress.IPv4Address(a0str))
xresult = SV.mk_simvalue(result)
pargs = str(a0) + ':' + a0str
simstate.set_register(iaddr, 'v0', xresult)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(xresult))
class MIPStub_inet_aton(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'inet_aton')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns 0 by default."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = str(a0) + ':' + a0str + ',' + str(a1)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_inet_ntoa(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'inet_ntoa')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SSV.mk_string_address('0.0.0'))
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_inet_pton(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'inet_pton')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Fails by default."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_ioctl(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'ioctl')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns 0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub___libc_current_sigrtmax(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, '__libc_current_sigrtmax')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub___libc_current_sigrtmin(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, '__libc_current_sigrtmin')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_listen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'listen')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_localtime(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'localtime')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
base = 'localtime_'
address = SSV.mk_base_address(base, 0, buffersize=36)
t = time.localtime()
print('time: ' + str(t))
def set_tm(off, tmval):
simstate.set_memval(
iaddr, address.add_offset(off), SV.mk_simvalue(tmval))
set_tm(0, t.tm_sec)
set_tm(4, t.tm_min)
set_tm(8, t.tm_hour)
set_tm(12, t.tm_mday)
set_tm(16, t.tm_mon)
set_tm(20, t.tm_year)
set_tm(24, t.tm_wday)
set_tm(28, t.tm_yday)
set_tm(32, t.tm_isdst)
simstate.set_register(iaddr, 'v0', address)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_lockf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'lockf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_longjmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'longjmp')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', a1)
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
newpc = simstate.get_memval(iaddr, a0, 4)
newsp = simstate.get_memval(iaddr, a0.add_offset(4), 4)
newra = simstate.get_memval(iaddr, a0.add_offset(8), 4)
context = simstate.get_memval(iaddr, a0.add_offset(12), 4)
if context.is_string_address:
context = cast(SSV.SimStringAddress, context)
contextstr = context.stringval
else:
contextstr = "?"
simstate.set_register(iaddr, 'sp', newsp)
simstate.set_register(iaddr, 'ra', newra)
simstate.restore_context(contextstr)
if newpc.is_address:
newpc = cast(SSV.SimAddress, newpc)
if newpc.is_global_address:
newpc = cast(SSV.SimGlobalAddress, newpc)
simstate.set_programcounter(newpc)
return self.add_logmsg(
iaddr,
simstate,
pargs,
returnval=(
str(a1) + ' (jmpaddr:' + str(newpc)
+ '; sp:' + str(newsp)
+ '; ra:' + str(newra) + ')'))
else:
return "newpc is not a global address: " + str(newpc)
else:
return "newpc is not an address: " + str(newpc)
else:
return "longjmp: argument is not an address: " + str(a0)
class MIPStub_malloc(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'malloc')
def is_memalloc_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns a symbolic address to a heap buffer in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
base = 'malloc_' + iaddr
if a0.is_literal:
a0 = cast(SV.SimLiteralValue, a0)
buffersize: Optional[int] = a0.value
else:
buffersize = None
address = SSV.mk_base_address(base, 0, buffersize=buffersize)
simstate.set_register(iaddr, 'v0', address)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_memcmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'memcmp')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
if a0.is_address:
dstaddr = a0
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
dstaddr = SSV.mk_global_address(a0.value)
else:
raise SU.CHBSimError(
simstate,
iaddr,
'memcmp: illegal destination address: ' + str(a0))
if a1.is_address:
srcaddr = cast(SSV.SimAddress, a1)
elif a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
if a1.value > simstate.imagebase.offsetvalue:
srcaddr = SSV.mk_global_address(a1.value)
else:
raise SU.CHBSimError(
simstate, iaddr, 'memcmp: illegal source address: ' + str(a0))
if a2.is_literal and a2.is_defined:
a2 = cast(SV.SimLiteralValue, a2)
src1addr = cast(SSV.SimAddress, dstaddr)
src2addr = srcaddr
count = 0
while count < a2.value:
src1val = simstate.get_memval(iaddr, src1addr, 1)
src2val = simstate.get_memval(iaddr, src2addr, 1)
if (
src1val.is_literal
and src1val.is_defined
and src2val.is_literal
and src2val.is_defined):
src1val = cast(SV.SimLiteralValue, src1val)
src2val = cast(SV.SimLiteralValue, src2val)
if not src1val.is_equal(src2val).is_true:
if src1val.value < src2val.value:
result = -1
else:
result = 1
break
else:
count += 1
src1addr = src1addr.add_offset(1)
src2addr = src2addr.add_offset(1)
else:
result = -1
break
else:
result = 0
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_memcpy(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'memcpy')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies count bytes from src to dst; returns a0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0') # dst
a1 = self.get_arg_val(iaddr, simstate, 'a1') # src
a2 = self.get_arg_val(iaddr, simstate, 'a2') # count
if a0.is_address:
dstaddr = cast(SSV.SimAddress, a0)
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
dstaddr = SSV.mk_global_address(a0.value)
else:
raise SU.CHBSimError(
simstate,
iaddr,
'memcpy: illegal destination address: ' + str(a0))
if a2.is_defined and a2.is_literal:
a2 = cast(SV.SimLiteralValue, a2)
if a1.is_string_address:
a1 = cast(SSV.SimStringAddress, a1)
srcstr = a1.stringval
if len(srcstr) >= a2.value:
for i in range(0, a2.value):
srcval: SV.SimValue = SV.mk_simvalue(ord(srcstr[i]), 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
pass
elif len(srcstr) + 1 == a2.value:
for i in range(0, a2.value - 1):
srcval = SV.mk_simvalue(ord(srcstr[i]), 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, dstaddr.add_offset(
a2.value - 1), SV.mk_simvalue(0, size=1))
else:
raise UF.CHBError(
'Memcpy with source string of length: '
+ str(len(srcstr))
+ ' and length argument: '
+ str(a2.value))
elif a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
if a1.value > simstate.imagebase.offsetvalue:
a1 = SSV.mk_global_address(a1.value)
for i in range(0, a2.value):
srcaddr: SSV.SimAddress = a1.add_offset(i)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
raise UF.CHBError(
"Illegal address in memcpy" + str(a1))
elif a1.is_address:
a1 = cast(SSV.SimAddress, a1)
for i in range(0, a2.value):
srcaddr = a1.add_offset(i)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
raise UF.CHBError("Illegal address in memcy: " + str(a1))
simstate.set_register(iaddr, 'v0', dstaddr)
pargs = ','.join(str(a) for a in [dstaddr, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_memmove(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'memmove')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies count bytes from src to dst; returns a0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0') # dst
a1 = self.get_arg_val(iaddr, simstate, 'a1') # src
a2 = self.get_arg_val(iaddr, simstate, 'a2') # count
if a0.is_address:
dstaddr = cast(SSV.SimAddress, a0)
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
dstaddr = SSV.mk_global_address(a0.value)
else:
raise SU.CHBSimError(
simstate,
iaddr,
'memmove: illegal destination address: ' + str(a0))
if a2.is_defined and a2.is_literal:
a2 = cast(SV.SimLiteralValue, a2)
if a1.is_string_address:
a1 = cast(SSV.SimStringAddress, a1)
srcstr = a1.stringval
for i in range(0, a2.value):
srcval: SV.SimValue = SV.mk_simvalue(ord(srcstr[i]), 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
pass
elif a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
if a1.value > simstate.imagebase.offsetvalue:
a1 = SSV.mk_global_address(a1.value)
for i in range(0, a2.value):
srcaddr: SSV.SimAddress = a1.add_offset(i)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
raise UF.CHBError("Illegal address in memmove: " + str(a1))
elif a1.is_address:
a1 = cast(SSV.SimAddress, a1)
for i in range(0, a2.value):
srcaddr = a1.add_offset(i)
srcval = simstate.get_memval(iaddr, srcaddr, 1)
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
else:
raise UF.CHBError("Illegal address in memmove: " + str(a1))
else:
raise UF.CHBError("Length not known in memmove: " + str(a2))
simstate.set_register(iaddr, 'v0', dstaddr)
pargs = ','.join(str(a) for a in [dstaddr, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_memset(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'memset')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Sets count bytes in dst to char. returns a0 in v0"""
a0 = self.get_arg_val(iaddr, simstate, 'a0') # dst
a1 = self.get_arg_val(iaddr, simstate, 'a1') # char
a2 = self.get_arg_val(iaddr, simstate, 'a2') # count
if (
a0.is_address
and a1.is_literal
and a1.is_defined
and a2.is_literal
and a2.is_defined):
a0 = cast(SSV.SimAddress, a0)
a1 = cast(SV.SimLiteralValue, a1)
a2 = cast(SV.SimLiteralValue, a2)
a1byte = SV.mk_simvalue(a1.value, size=1)
for i in range(0, a2.value):
address = a0.add_offset(i)
simstate.set_memval(iaddr, address, a1byte)
simstate.set_register(iaddr, 'v0', a0)
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_mkdir(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'mkdir')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_mktemp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'mktemp')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_msgget(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'msgget')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_mmap(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'mmap')
def is_process_operation(self) -> bool:
return True
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
a4 = self.get_stack_arg_val(iaddr, simstate, 4)
a5 = self.get_stack_arg_val(iaddr, simstate, 5)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_open(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'open')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(1))
simstate.add_logmsg('warning', 'File ' + a0str + ' was not opened')
return self.add_logmsg(iaddr, simstate, pargs, returnval='1')
class MIPStub_open64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'open64')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_openlog(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'openlog')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.add_logmsg('i/o', self.name + '(' + pargs + ')')
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pclose(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pclose')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simNegOne)
simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')')
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_perror(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'perror')
def is_error_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str
simstate.add_logmsg('error', self.name + '(' + pargs + ')')
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_popen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'popen')
def is_io_operation(self) -> bool:
return True
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_printf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'printf')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o; returns 1 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simOne)
pargs = str(a0) + ':' + a0str
if '%s' in a0str:
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs += ',' + str(a1) + ':' + a1str
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub__setjmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, '_setjmp')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
setval = SSV.mk_global_address(int(iaddr, 16) + 4)
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
simstate.set_memval(iaddr, a0, setval)
simstate.set_memval(iaddr, a0.add_offset(4), simstate.registers['sp'])
simstate.set_memval(iaddr, a0.add_offset(8), simstate.registers['ra'])
simstate.set_memval(
iaddr,
a0.add_offset(12),
SSV.SimStringAddress(simstate.context.peek()))
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Illegal address in setjmp: " + str(a0))
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_setlogmask(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'setlogmask')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_setrlimit(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'setrlimit')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_setrlimit64(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'setrlimit64')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_setsockopt(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'setsockopt')
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
a4 = self.get_stack_arg_val(iaddr, simstate, 4)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_shmat(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'shmat')
def is_sharedmem_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SSV.mk_global_address(0x700000))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_shmget(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'shmget')
def is_sharedmem_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sigaction(MIPSimStub):
def __init__(self, app: "MIPSAccess", name: str = 'sigaction') -> None:
MIPSimStub.__init__(self, app, name)
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sigaddset(MIPSimStub):
def __init__(self, app: "MIPSAccess", name: str = 'sigaddset'):
MIPSimStub.__init__(self, app, name)
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = '.'.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sigemptyset(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sigemptyset')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_signal(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'signal')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sigprocmask(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sigprocmask')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sleep(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sleep')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_snprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'snprintf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_socket(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'socket')
def is_network_operation(self) -> bool:
return True
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns a symbolic value in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
# returnval = SSV.mk_symbol('socket-fd',minval=0)
returnval = SV.mk_simvalue(113) # notable, recognizable value
simstate.set_register(iaddr, 'v0', returnval)
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_cond_init(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_cond_init')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_cond_signal(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_cond_signal')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_pthread_create(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_create')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_attr_init(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_attr_init')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_pthread_attr_setschedparam(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_attr_setschedparam')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_attr_setschedpolicy(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_attr_setschedpolicy')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_mutex_init(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_mutex_init')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_pthread_mutex_lock(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_mutex_lock')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_pthread_mutex_unlock(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_mutex_unlock')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_pthread_self(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'pthread_self')
def is_thread_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_puts(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'puts')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_rand(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'rand')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x4321))
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_random(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'random')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x87654321))
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_read(MIPSimStub):
"""ssize_t read(int fildes, void *buf, size_t nbyte)"""
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'read')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
if (
a0.is_literal
and a0.is_defined
and a1.is_address
and a2.is_literal
and a2.is_defined):
a1 = cast(SSV.SimAddress, a1)
a2 = cast(SV.SimLiteralValue, a2)
a0 = cast(SV.SimLiteralValue, a0)
inputbytes = simstate.simsupport.get_read_input(
iaddr, a0.value, a1, a2.value)
pargs = ','.join(str(a) for a in [a0, a1, a2])
if len(inputbytes) > 0:
for i in range(0, len(inputbytes)):
tgtaddr = a1.add_offset(i)
simstate.set_memval(
iaddr, tgtaddr, SV.mk_simbytevalue(inputbytes[i]))
result = SV.mk_simvalue(len(inputbytes))
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(
iaddr, simstate, pargs, returnval=str(result))
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Illegal address in read: " + str(a1))
class MIPStub_realloc(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'realloc')
def is_memalloc_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
base = 'realloc_' + iaddr
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
buffersize: Optional[int] = a1.value
else:
buffersize = None
address = SSV.mk_base_address(base, 0, buffersize=buffersize)
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
if a0.is_base_address:
a0 = cast(SSV.SimBaseAddress, a0)
if a0.has_buffer_size():
a0buffersize = cast(int, a0.buffersize)
a0 = cast(SSV.SimBaseAddress, a0)
for i in range(0, a0buffersize):
srcaddr = a0.add_offset(i)
tgtaddr = address.add_offset(i)
srcval = simstate.get_memval(iaddr, srcaddr, size=1)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_register(iaddr, 'v0', address)
pargs = str(a0) + ',' + str(a1)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(address))
class MIPStub_realpath(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'realpath')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_recv(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'recv')
self.buffer: Optional[str] = None
def is_io_operation(self) -> bool:
return True
def is_network_operation(self) -> bool:
return True
def get_network_input(
self, iaddr: str, simstate: "MIPSimulationState", size: int) -> str:
if self.buffer is None:
if simstate.simsupport.has_network_input(iaddr):
self.buffer = simstate.simsupport.get_network_input(
iaddr, simstate, size)
if self.buffer and len(self.buffer) > 0 and len(self.buffer) <= size:
recv = self.buffer[:]
self.buffer = ''
return recv
elif self.buffer and len(self.buffer) > 0:
recv = self.buffer[:size]
self.buffer = self.buffer[size:]
return recv
else:
return ''
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
if self.buffer and len(self.buffer) == 0:
simstate.set_register(iaddr, 'v0', SV.simOne)
simstate.add_logmsg('i/o', self.name + '(' + pargs + '):1')
return self.add_logmsg(iaddr, simstate, pargs, returnval='1')
elif simstate.simsupport.has_network_input(iaddr):
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
a1 = SSV.mk_global_address(a1.value)
elif a1.is_address:
a1 = cast(SSV.SimAddress, a1)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Argument a1 is not an address: " + str(a1))
if a2.is_literal and a2.is_defined:
a2 = cast(SV.SimLiteralValue, a2)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Lenght argument is not a literal: " + str(a0))
networkinput = self.get_network_input(iaddr, simstate, a2.value)
for i in range(0, len(networkinput)):
tgtaddr = a1.add_offset(i)
simstate.set_memval(
iaddr,
tgtaddr,
SV.mk_simvalue(ord(networkinput[i]), 1))
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(networkinput)))
return self.add_logmsg(
iaddr, simstate, pargs, returnval=str(len(networkinput)))
else:
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1))
return self.add_logmsg(iaddr, simstate, pargs, returnval='-1')
class MIPStub_recvfrom(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'recvfrom')
self.buffer: Optional[str] = None
def is_network_operation(self) -> bool:
return True
def is_io_operation(self) -> bool:
return True
def get_network_input(
self, iaddr: str, simstate: "MIPSimulationState", size: int) -> str:
if self.buffer is None:
if simstate.simsupport.has_network_input(iaddr):
self.buffer = simstate.simsupport.get_network_input(
iaddr, simstate, size)
self.buffer = cast(str, self.buffer)
if len(self.buffer) > 0 and len(self.buffer) <= size:
recv = self.buffer
self.buffer = ''
return recv
elif len(self.buffer) > 0:
recv = self.buffer[:size]
self.buffer = self.buffer[size:]
return recv
else:
return ''
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
a4 = self.get_stack_arg_val(iaddr, simstate, 4)
a5 = self.get_stack_arg_val(iaddr, simstate, 5)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5])
if self.buffer and len(self.buffer) == 0:
simstate.set_register(iaddr, 'v0', SV.simOne)
simstate.add_logmsg('i/o', self.name + '(' + pargs + '):1')
return self.add_logmsg(iaddr, simstate, pargs, returnval='1')
elif (simstate.simsupport.has_network_input(iaddr)
and a1.is_address
and a2.is_literal
and a2.is_defined):
a1 = cast(SSV.SimAddress, a1)
a2 = cast(SV.SimLiteralValue, a2)
networkinput = self.get_network_input(iaddr, simstate, a2.value)
for i in range(0, len(networkinput)):
tgtaddr = a1.add_offset(i)
simstate.set_memval(
iaddr, tgtaddr, SV.mk_simvalue(ord(networkinput[i]), 1))
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(networkinput)))
return self.add_logmsg(
iaddr, simstate, pargs, returnval=str(len(networkinput)))
else:
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1))
return self.add_logmsg(iaddr, simstate, pargs, returnval='-1')
class MIPStub_sched_get_priority_max(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sched_get_priority_max')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_sched_get_priority_min(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sched_get_priority_min')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_sched_yield(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sched_yield')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_select(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'select')
self.count = 0
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns the total number of bits set."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
a4 = self.get_stack_arg_val(iaddr, simstate, 4)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4])
if self.count == 0:
result = SV.simOne
self.count = 1
else:
result = SV.simZero
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_semget(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'semget')
def is_sharedmem_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_semop(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'semop')
def is_sharedmem_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_send(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'send')
def is_io_operation(self) -> bool:
return True
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
pargs = ','.join(str(a) for a in [a0, a1, a2, a3])
simstate.set_register(iaddr, 'v0', a2)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a2))
class MIPStub_sendto(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sendto')
def is_io_operation(self) -> bool:
return True
def is_network_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
a4 = self.get_stack_arg_val(iaddr, simstate, 4)
a5 = self.get_stack_arg_val(iaddr, simstate, 5)
pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5])
simstate.set_register(iaddr, 'v0', SV.simOne)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_setenv(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'setenv')
def is_environment_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o; returns 0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = (
str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str + ',' + str(a2))
simstate.set_environment_variable(a0str, a1str)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_sprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sprintf')
def write_string_to_buffer(
self, iaddr: str, simstate: "MIPSimulationState", s: str) -> None:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_symbol:
simstate.add_logmsg(
'free sprintf',
' to dst: ' + str(a0) + '; str: ' + str(s))
elif a0.is_address:
a0 = cast(SSV.SimAddress, a0)
for i in range(0, len(s)):
srcval = SV.SimByteValue(ord(s[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(iaddr, a0.add_offset(len(s)), SV.SimByteValue(0))
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
a0 = SSV.mk_global_address(a0.value)
for i in range(0, len(s)):
srcval = SV.SimByteValue(ord(s[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(len(s)), SV.SimByteValue(0))
else:
raise SU.CHBSimError(
simstate,
iaddr,
"sprintf: Address not recognized: " + str(a0))
else:
raise SU.CHBSimError(
simstate,
iaddr,
'Illegal destination address in sprintf: ' + str(a0))
def get_logmsg(
self,
iaddr: str,
simstate: "MIPSimulationState",
varargs: List[str],
s: str) -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str + ',' + ','.join(varargs)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(len(s)))
def set_returnval(
self, iaddr: str, simstate: "MIPSimulationState", s: str) -> None:
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(s)))
def substitute_formatstring(
self,
iaddr: str,
simstate: "MIPSimulationState",
a1str: str) -> Tuple[str, List[str]]:
"""Return substituted string and arguments used (as a string)."""
result = simstate.simsupport.substitute_formatstring(
self, iaddr, simstate, a1str)
if result is not None:
return result
if a1str == '%s':
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
printstring = a2str
varargs = [str(a2) + ':' + a2str]
return (printstring, varargs)
if a1str == '%d':
a2 = self.get_arg_val(iaddr, simstate, 'a2')
if a2.is_literal and a2.is_defined:
a2 = cast(SV.SimLiteralValue, a2)
printstring = str(a2.value)
varargs = [str(a2)]
return (printstring, varargs)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Argument a2 not recognized: " + str(a2))
else:
simstate.add_logmsg('warning', 'sprintf without substitution')
return (a1str, [])
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies the string of the second argument to the dst argument."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
(printstring, varargs) = self.substitute_formatstring(
iaddr, simstate, a1str)
self.write_string_to_buffer(iaddr, simstate, printstring)
self.set_returnval(iaddr, simstate, printstring)
pvarargs = ', '.join(varargs)
return self.add_logmsg(iaddr, simstate, pvarargs, printstring)
class MIPStub_srand(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'srand')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x12345678))
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_sscanf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'sscanf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
result = -1
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_stat(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'stat')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str + ',' + str(a1)
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strcasecmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strcasecmp')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
try:
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a0strlc = a0str.lower()
a1strlc = a1str.lower()
if a0strlc == a1strlc:
result = 0
elif a0strlc < a1strlc:
result = -1
else:
result = 1
except Exception as e:
result = 1
print('Error in strcasecmp')
a0str = '*** error ****'
if iaddr == '0x403948':
result = 0
resultval = SV.mk_simvalue(result)
simstate.set_register(iaddr, 'v0', resultval)
pargs = ','.join(str(a)
+ ':'
+ str(v) for (a, v) in [(a0, a0str), (a1, a1str)])
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(resultval))
class MIPStub_strchr(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strchr')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns pointer to the first character that matches the second argument."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = ','.join(str(a) for a in [a0, a1])
if a0.is_string_address and a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
a0str = self.get_arg_string(iaddr, simstate, 'a0')
if not (chr(a1.value) in a0str):
returnval: SV.SimValue = SV.simZero
else:
index = a0str.find(str(chr(a1.value)))
returnval = SSV.mk_string_address(a0str[index:])
elif a0.is_address and a1.is_literal and a1.is_defined:
a0 = cast(SSV.SimAddress, a0)
a1 = cast(SV.SimLiteralValue, a1)
i = 0
while True:
c = simstate.get_memval(iaddr, a0.add_offset(i), 1)
if c.is_literal and c.is_defined:
c = cast(SV.SimLiteralValue, c)
if c.value == a1.value:
returnval = a0.add_offset(i)
break
elif c.value == 0:
returnval = SV.simZero
break
else:
i += 1
else:
returnval = SV.simUndefinedDW
break
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
else:
returnval = SV.simZero
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
pa1 = "'" + chr(a1.value) + "'"
else:
pa1 = str(a1)
pargs = str(a0) + ',' + pa1
simstate.set_register(iaddr, 'v0', returnval)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
class MIPStub_strncasecmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strncasecmp')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Compares the two strings up to count, and returns the result in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a2.is_literal and a2.is_defined:
a2 = cast(SV.SimLiteralValue, a2)
count = a2.value
if a0str.lower()[:count] == a1str.lower()[:count]:
result = 0
elif a0str.lower()[:count] < a1str.lower()[:count]:
result = -1
else:
result = 1
resultval = SV.SimDoubleWordValue(result)
else:
resultval = SV.simUndefinedDW
simstate.set_register(iaddr, 'v0', resultval)
pargs = (
str(a0)
+ ': "'
+ a0str
+ '", '
+ str(a1)
+ ': "'
+ a1str
+ '", '
+ 'count:'
+ str(a2))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(resultval))
class MIPStub_strcmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strcmp')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Compares the two arguments and returns the result in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0') # str1
a1 = self.get_arg_val(iaddr, simstate, 'a1') # str2
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a0str == a1str:
result = 0
elif a0str < a1str:
result = -1
else:
result = 1
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(result))
pargs = ','.join(str(a) + ':' + str(v)
for (a, v) in [(a0, a0str), (a1, a1str)])
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_strncmp(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strncmp')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Compares the two strings up to count and returns the result in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a2.is_literal and a2.is_defined:
a2 = cast(SV.SimLiteralValue, a2)
count = a2.value
if a0str[:count] == a1str[:count]:
result = 0
elif a0str[:count] < a1str[:count]:
result = -1
else:
result = 1
resultval = SV.SimDoubleWordValue(result)
else:
resultval = SV.simUndefinedDW
simstate.set_register(iaddr, 'v0', resultval)
pargs = (
str(a0)
+ ': "'
+ a0str
+ '", '
+ str(a1)
+ ': "'
+ a1str
+ '", '
+ 'count:'
+ str(a2))
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(resultval))
class MIPStub_strcat(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strcat')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strcpy(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strcpy')
def get_dst_arg_index(self) -> int:
return 0
def get_src_arg_index(self) -> int:
return 1
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies characters from src to dst up to and including null terminator."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
dstaddr = a0
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
dstaddr = SSV.mk_global_address(a0.value)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"strcopy: illegal destination address: " + str(a0))
else:
raise SU.CHBSimError(
simstate, iaddr, 'strcpy: illegal destination address: ' + str(a0))
if a1.is_string_address:
a1str = self.get_arg_string(iaddr, simstate, 'a1')
for i in range(0, len(a1str)):
srcval = SV.SimByteValue(ord(a1str[i]))
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, dstaddr.add_offset(len(a1str)), SV.SimByteValue(0))
elif a1.is_symbol:
simstate.add_logmsg(
'free strcpy', 'src:' + str(a1) + ' to dst: ' + str(a0))
else:
a1str = self.get_arg_string(iaddr, simstate, 'a1')
for i in range(0, len(a1str)):
srcval = SV.SimByteValue(ord(a1str[i]))
tgtaddr = dstaddr.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, dstaddr.add_offset(len(a1str)), SV.SimByteValue(0))
simstate.set_register(iaddr, 'v0', a0)
pargs = str(dstaddr) + ',' + str(a1) + ':' + a1str
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strdup(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strdup')
def is_string_operation(self) -> bool:
return True
def is_memalloc_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns a pointer to a duplicated string in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_string_address:
a0 = cast(SSV.SimStringAddress, a0)
s = a0.stringval
base = 'strdup_' + iaddr
buffersize = len(s) + 1
address = SSV.mk_base_address(base, 0, buffersize=buffersize)
simstate.basemem[base] = MIPSimBaseMemory(
simstate, base, buffersize=buffersize)
for i in range(0, buffersize-1):
simstate.set_memval(
iaddr,
address.add_offset(i),
SV.mk_simvalue(ord(s[i]), size=1))
simstate.set_memval(iaddr, address.add_offset(buffersize - 1), SV.simZero)
result = address
elif a0.is_symbol:
a0 = cast(SSV.SimSymbol, a0)
base = 'strdup_' + iaddr
contents = a0.name + '_duplicate'
buffersize = len(contents) + 1
address = SSV.mk_base_address(base, 0, buffersize=buffersize)
simstate.basemem[base] = MIPSimBaseMemory(
simstate, base, buffersize=buffersize)
for i in range(0, buffersize-1):
simstate.set_memval(
iaddr,
address.add_offset(i),
SV.mk_simvalue(ord(contents[i]), size=1))
result = address
else:
a0str = self.get_arg_string(iaddr, simstate, 'a0')
base = 'strdup_' + iaddr
address = SSV.mk_base_address(base, 0, buffersize=len(a0str))
for i in range(0, len(a0str)):
simstate.set_memval(
iaddr,
address.add_offset(i),
SV.mk_simbytevalue(ord(a0str[i])))
simstate.set_memval(
iaddr, address.add_offset(len(a0str)), SV.mk_simbytevalue(0))
result = address
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result))
class MIPStub_strerror(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strerror')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
rval = SSV.mk_string_address('strerror-' + str(a0))
simstate.set_register(iaddr, 'v0', rval)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_stristr(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'stristr')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = ','.join(str(a) + ':' + s for (a, s) in [(a0, a0str), (a1, a1str)])
index = a0str.lower().find(a1str.lower())
if index >= 0 and a0.is_address:
a0 = cast(SSV.SimAddress, a0)
result: SV.SimValue = a0.add_offset(index)
else:
result = SV.simZero
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_strlen(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strlen')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns the length of the first argument in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
result = SV.SimDoubleWordValue(len(a0str))
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(
iaddr, simstate, str(a0) + ':' + a0str, returnval=str(result))
class MIPStub_strncat(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strncat')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strncpy(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strncpy')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
if (
a2.is_literal
and a2.is_defined
and a0.is_address
and a1.is_string_address):
a0 = cast(SSV.SimAddress, a0)
a1 = cast(SSV.SimStringAddress, a1)
a2 = cast(SV.SimLiteralValue, a2)
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if len(a1str) < a2.value:
for i in range(0, len(a1str)):
srcval = SV.SimByteValue(ord(a1str[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(len(a1str)), SV.mk_simbytevalue(0))
else:
for i in range(0, a2.value):
srcval = SV.SimByteValue(ord(a1str[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
elif (a2.is_literal
and a2.is_defined
and a0.is_address
and a1.is_address):
a0 = cast(SSV.SimAddress, a0)
a1 = cast(SSV.SimAddress, a1)
a2 = cast(SV.SimLiteralValue, a2)
for i in range(0, a2.value):
srcaddr = a1.add_offset(i)
srcval = cast(
SV.SimByteValue, simstate.get_memval(iaddr, srcaddr, 1))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_register(iaddr, 'v0', a0)
pargs = ','.join(str(a) for a in [a0, a1, a2])
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strrchr(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strrchr')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
if a0.is_string_address and a1.is_literal and a1.is_defined:
a0 = cast(SSV.SimStringAddress, a0)
a1 = cast(SV.SimLiteralValue, a1)
if not (chr(a1.value) in a0str):
returnval: SV.SimValue = SV.simZero
else:
index = a0str.rfind(str(chr(a1.value)))
returnval = SSV.mk_string_address(a0.stringval[index:])
elif a0.is_address and a1.is_literal and a1.is_defined:
a0 = cast(SSV.SimAddress, a0)
a1 = cast(SV.SimLiteralValue, a1)
i = len(a0str)
while i > 0:
c = simstate.get_memval(iaddr, a0.add_offset(i), 1)
if c.is_literal and c.is_defined:
c = cast(SV.SimLiteralValue, c)
if c.value == a1.value:
break
else:
i -= 1
else:
break
returnval = a0.add_offset(i)
else:
returnval = SV.simZero
simstate.set_register(iaddr, 'v0', returnval)
if a1.is_literal and a1.is_defined:
a1 = cast(SV.SimLiteralValue, a1)
pa1 = "'" + chr(a1.value) + "'"
else:
pa1 = str(a1)
pargs = str(a0) + ':' + a0str + ',' + pa1
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval))
class MIPStub_strsep(MIPSimStub):
"""extract token from string
char *strsep(char **stringp, const char *delim);
Description:
If *stringp is NULL, the strsep() function returns NULL and does
nothing else. Otherwise, this function finds the first token in
the string *stringp that is delimited by one of the bytes in the
string delim. This token is terminated by overwriting the
delimiter with a null byte ('\0'), and *stringp is updated to
point past the token. In case no delimiter was found, the token
is taken to be the entire string *stringp, and *stringp is made
NULL.
"""
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strsep')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
a0derefstr = 'NULL'
if a0.is_address:
a0 = cast(SSV.SimAddress, a0)
a0deref = self.get_arg_deref_val(iaddr, simstate, 'a0')
a0derefstr = self.get_arg_deref_string(iaddr, simstate, 'a0')
if a0deref.is_address:
a0deref = cast(SSV.SimAddress, a0deref)
for c in a1str:
index = a0derefstr.find(c)
if index >= 0:
tokenptr = a0deref.add_offset(index+1)
simstate.set_memval(
iaddr,
a0deref.add_offset(index),
SV.mk_simvalue(0, size=1))
simstate.set_memval(iaddr, a0, tokenptr)
break
else:
simstate.set_memval(iaddr, a0, SV.simZero)
else:
simstate.set_memval(iaddr, a0, SV.simZero)
a1ordstr = '{' + ','.join(str(ord(c)) for c in a1str) + '}'
pargs = str(a0) + ':&' + a0derefstr + ',' + str(a1) + ':' + a1str + a1ordstr
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strstr(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strstr')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = ','.join(str(a) + ':' + s for (a, s) in [(a0, a0str), (a1, a1str)])
index = a0str.find(a1str)
if index >= 0:
if a0.is_string_address:
result: SV.SimValue = SSV.mk_string_address(a0str[index:])
elif a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value > simstate.imagebase.offsetvalue:
a0 = SSV.mk_global_address(a0.value)
result = a0.add_offset(index)
else:
raise SU.CHBSimError(
simstate, iaddr, "Invalid address in strstr: " + str(a0))
else:
raise SU.CHBSimError(
simstate, iaddr, 'Invalid address in strstr: ' + str(a0))
else:
result = SV.simZero
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_strtof(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strtof')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
pargs = str(a0) + ':' + a0str + str(a1)
fstr = ''
for c in a0str:
if c.isdigit() or c == '.':
fstr += c
else:
break
result = SV.mk_floatvalue(float(fstr))
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_strtok(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strtok')
self.state: Optional[str] = None
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value == 0:
pargs = str(a0) + ',' + str(a1) + ':' + a1str
a0str = self.state
else:
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str
else:
raise SU.CHBSimError(
simstate, iaddr, "Undefined value in strtok: " + str(a0))
if a0str:
index = a0str.find(a1str)
if index > 0:
result: SV.SimValue = SSV.mk_string_address(a0str[index:])
self.state = a0str[index+1:]
else:
result = a0
self.state = None
else:
result = SV.simZero
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strtok_r(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strtok_r')
def is_string_operation(self) -> bool:
return True
def simulate_first_token(
self,
iaddr: str,
simstate: "MIPSimulationState",
srcaddr: SSV.SimAddress,
s: str,
sep: str,
stateaddr: SSV.SimAddress) -> str:
minpos = len(s)
for c in sep:
pos = s.find(c)
if pos == -1:
continue
if pos < minpos:
minpos = pos
if minpos == len(s):
result = srcaddr
simstate.set_memval(iaddr, stateaddr, SV.simZero)
pargs = str(srcaddr) + ':' + s + ',' + sep + ',' + str(stateaddr)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
else:
result = srcaddr
simstate.set_memval(
iaddr, srcaddr.add_offset(minpos), SV.SimByteValue(0))
simstate.set_memval(iaddr, stateaddr, srcaddr.add_offset(minpos + 1))
pargs = str(srcaddr) + ':' + s + ',' + sep + ',' + str(stateaddr)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
def simulate_next_token(
self,
iaddr: str,
simstate: "MIPSimulationState",
sep: str,
a2: SSV.SimAddress) -> str:
s = self.get_arg_deref_string(iaddr, simstate, 'a2')
minpos = len(s)
for c in sep:
pos = s.find(c)
if pos == -1:
continue
if pos < minpos:
minpos = pos
if minpos == len(s):
result = self.get_arg_deref_val(iaddr, simstate, 'a2')
simstate.set_memval(iaddr, a2, SV.SimByteValue(0))
pargs = '0, ' + sep + ',' + str(a2)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
else:
result = self.get_arg_deref_val(iaddr, simstate, 'a2')
if result.is_address:
result = cast(SSV.SimAddress, result)
simstate.set_memval(iaddr, result.add_offset(minpos), SV.SimByteValue(0))
simstate.set_memval(iaddr, a2, result.add_offset(minpos+1))
else:
simstate.add_logmsg(iaddr, "strtok: result is not an address")
pargs = '0, ' + sep + ', ' + str(a2)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Returns 0 in v0."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
if a0.is_literal and a0.is_defined and a2.is_address:
a0 = cast(SV.SimLiteralValue, a0)
a2 = cast(SSV.SimAddress, a2)
if a0.value == 0:
return self.simulate_next_token(iaddr, simstate, a1str, a2)
else:
raise SU.CHBSimError(
simstate,
iaddr,
"Unexpected literal value in strtok: " + str(a0))
elif a0.is_address and a2.is_address:
a0 = cast(SSV.SimAddress, a0)
a2 = cast(SSV.SimAddress, a2)
a0str = self.get_arg_string(iaddr, simstate, 'a0')
return self.simulate_first_token(iaddr, simstate, a0, a0str, a1str, a2)
else:
a0str = self.get_arg_string(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
pargs = (str(a0) + ': "' + a0str + '", '
+ str(a1) + ': "' + a1str + '", '
+ str('state:' + str(a2)))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_strtoul(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'strtoul')
def is_string_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = str(a0) + ':' + a0str + ',' + str(a1) + ',' + str(a2)
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, pargs, returnval='0')
class MIPStub_syslog(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'syslog')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
pargs = str(a0) + ',' + str(a1) + ':' + a1str
if a1str == '%s':
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
pargs += ',' + str(a2) + ':' + a2str
simstate.add_logmsg('i/o', self.name + '(' + pargs + ')')
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_system(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'system')
def is_system_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0') # cmdline string
if a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
if a0.value == 0:
pargs = 'NULL'
else:
pargs = self.get_arg_string(iaddr, simstate, 'a0')
else:
pargs = self.get_arg_string(iaddr, simstate, "a0")
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_time(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'time')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
result = int(time.time())
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result))
class MIPStub_tolower(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'tolower')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
if a0.is_literal and a0.is_defined:
a0 = cast(SV.SimLiteralValue, a0)
result = ord(str(chr(a0.value)).lower()[0])
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result))
return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result))
else:
return self.add_logmsg(iaddr, simstate, str(a0), returnval="?")
class MIPStub_umask(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'umask')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_unlink(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'unlink')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a0str = self.get_arg_string(iaddr, simstate, 'a0')
pargs = str(a0) + ':' + a0str
simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0))
return self.add_logmsg(iaddr, simstate, pargs)
class MIPStub_usleep(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'usleep')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_vsnprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'vsnprintf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies the string of the second argument to the dst argument."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
a2str = self.get_arg_string(iaddr, simstate, 'a2')
a3 = self.get_arg_val(iaddr, simstate, 'a3')
printstring = a2str
if a0.is_symbol:
simstate.add_logmsg(
'free vsprintf', ' to dst: ' + str(a0) + '; str: ' + printstring)
elif a0.is_address:
a0 = cast(SSV.SimAddress, a0)
for i in range(0, len(printstring)):
srcval = SV.SimByteValue(ord(printstring[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(len(printstring)), SV.mk_simvalue(0, size=1))
else:
simstate.add_logmsg(
iaddr,
"No address to write to in vsnprintf: " + str(a0))
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(len(printstring)))
pargs = (
str(a0) + ',' + str(a1) + ',' + str(a2) + ':' + a2str + ',' + str(a3))
return self.add_logmsg(
iaddr, simstate, pargs, returnval=str(len(printstring)))
class MIPStub_vsprintf(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'vsprintf')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Copies the string of the second argument to the dst argument."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a1str = self.get_arg_string(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
printstring = a1str
if a0.is_symbol:
simstate.add_logmsg(
'free vsprintf', ' to dst: ' + str(a0) + '; str: ' + printstring)
elif a0.is_address:
a0 = cast(SSV.SimAddress, a0)
for i in range(0, len(printstring)):
srcval = SV.SimByteValue(ord(printstring[i]))
tgtaddr = a0.add_offset(i)
simstate.set_memval(iaddr, tgtaddr, srcval)
simstate.set_memval(
iaddr, a0.add_offset(len(printstring)), SV.mk_simvalue(0, size=1))
simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(len(printstring)))
pargs = (str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2))
return self.add_logmsg(
iaddr, simstate, pargs, returnval=str(len(printstring)))
class MIPStub_waitpid(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'waitpid')
def is_process_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.set_register(iaddr, 'v0', a0)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a0))
class MIPStub_write(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'write')
def is_io_operation(self) -> bool:
return True
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
"""Logs i/o, returns a2 in v0 for now."""
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
if a0.is_literal:
simstate.add_logmsg('i/o', 'Not a valid file descriptor: ' + str(a0))
result: SV.SimValue = SV.mk_simvalue(-1)
else:
a0 = cast(SSV.SimSymbolicValue, a0)
if (
a0.is_file_descriptor
and a2.is_literal
and a2.is_defined
and a1.is_address):
a0 = cast(SSV.SimSymbolicFileDescriptor, a0)
a1 = cast(SSV.SimAddress, a1)
a2 = cast(SV.SimLiteralValue, a2)
for i in range(0, a2.value):
tgtaddr = a1.add_offset(i)
srcval = simstate.get_memval(iaddr, tgtaddr, 1)
if srcval.is_literal and srcval.is_defined:
srcval = cast(SV.SimLiteralValue, srcval)
a0.filedescriptor.write(chr(srcval.value))
else:
simstate.add_logmsg(iaddr, "No values written to file")
result = a2
simstate.add_logmsg(
'i/o',
'Successfully wrote ' + str(a2) + ' bytes to ' + str(a0))
else:
result = SV.mk_simvalue(-1)
simstate.set_register(iaddr, 'v0', result)
return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result))
class MIPStub_isLanSubnet(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'isLanSubnet')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, str(a0))
class MIPStub_uloop_init(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'uloop_init')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
simstate.set_register(iaddr, 'v0', SV.simZero)
return self.add_logmsg(iaddr, simstate, '')
class MIPStub_msglogd(MIPSimStub):
def __init__(self, app: "MIPSAccess") -> None:
MIPSimStub.__init__(self, app, 'msglogd')
def simulate(self, iaddr: str, simstate: "MIPSimulationState") -> str:
a0 = self.get_arg_val(iaddr, simstate, 'a0')
a1 = self.get_arg_val(iaddr, simstate, 'a1')
a2 = self.get_arg_val(iaddr, simstate, 'a2')
pargs = ','.join(str(a) for a in [a0, a1, a2])
simstate.add_logmsg('i/o', self.name + '(' + pargs + ')')
return self.add_logmsg(iaddr, simstate, pargs)
| 38.318141
| 89
| 0.588396
| 20,140
| 169,826
| 4.756902
| 0.036097
| 0.085216
| 0.044153
| 0.068619
| 0.804747
| 0.781658
| 0.768277
| 0.748685
| 0.728967
| 0.702852
| 0
| 0.02192
| 0.286258
| 169,826
| 4,431
| 90
| 38.326789
| 0.768464
| 0.024325
| 0
| 0.686455
| 0
| 0
| 0.070007
| 0.002135
| 0.000288
| 0
| 0.000345
| 0
| 0
| 1
| 0.141787
| false
| 0.000865
| 0.00317
| 0.039193
| 0.295389
| 0.015274
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
67e4d9a02c6653abd321ada0ee2db59690a8de28
| 102
|
py
|
Python
|
Lesson 03 - Time Complexity/ForgJmp/Solution.py
|
AbdeenM/codility-lessons-solutions
|
b58029d834e430d8c42c4468649aeff468195dd1
|
[
"MIT"
] | 1
|
2021-01-26T19:29:39.000Z
|
2021-01-26T19:29:39.000Z
|
Lesson 03 - Time Complexity/ForgJmp/Solution.py
|
AbdeenM/codility-lessons-solutions
|
b58029d834e430d8c42c4468649aeff468195dd1
|
[
"MIT"
] | null | null | null |
Lesson 03 - Time Complexity/ForgJmp/Solution.py
|
AbdeenM/codility-lessons-solutions
|
b58029d834e430d8c42c4468649aeff468195dd1
|
[
"MIT"
] | null | null | null |
import math
def solution(X, Y, D):
# Return the maxium distance
return math.ceil((Y - X) / D)
| 20.4
| 33
| 0.627451
| 17
| 102
| 3.764706
| 0.705882
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.245098
| 102
| 5
| 33
| 20.4
| 0.831169
| 0.254902
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
67e7aca8b827efe1d023ab71c9f18658ed34d4fd
| 5,727
|
py
|
Python
|
editor_api/fileio/exco.py
|
jphuart/swatplus-automatic-workflow
|
dd2eeb7f882eb2d4ab7e1e5265c10b9beb93ddc4
|
[
"MIT"
] | 8
|
2020-06-28T07:50:29.000Z
|
2022-01-05T16:29:48.000Z
|
editor_api/fileio/exco.py
|
jphuart/swatplus-automatic-workflow
|
dd2eeb7f882eb2d4ab7e1e5265c10b9beb93ddc4
|
[
"MIT"
] | null | null | null |
editor_api/fileio/exco.py
|
jphuart/swatplus-automatic-workflow
|
dd2eeb7f882eb2d4ab7e1e5265c10b9beb93ddc4
|
[
"MIT"
] | 5
|
2020-06-28T07:50:31.000Z
|
2021-08-16T07:09:59.000Z
|
from .base import BaseFileModel, FileColumn as col
from helpers import utils
from database.project.recall import Recall_dat, Recall_rec
import database.project.exco as db
class Exco_om_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
#self.write_default_table(db.Exco_om_exc, True)
table = db.Exco_om_exc
order_by = db.Exco_om_exc.id
recall_recs = Recall_rec.select().where(Recall_rec.rec_typ == 4)
if table.select().count() > 0 or recall_recs.count() > 0:
with open(self.file_name, 'w') as file:
file.write(self.get_meta_line())
cols = [col(table.name, direction="left"),
col(table.flo),
col(table.sed),
col(table.orgn),
col(table.sedp),
col(table.no3),
col(table.solp),
col(table.chla),
col(table.nh3),
col(table.no2),
col(table.cbod),
col(table.dox),
col(table.sand),
col(table.silt),
col(table.clay),
col(table.sag),
col(table.lag),
col(table.gravel),
col(table.tmp)]
self.write_headers(file, cols)
file.write("\n")
for row in table.select().order_by(order_by):
file.write(utils.string_pad(row.name, direction="left"))
file.write(utils.num_pad(row.flo))
file.write(utils.num_pad(row.sed))
file.write(utils.num_pad(row.orgn))
file.write(utils.num_pad(row.sedp))
file.write(utils.num_pad(row.no3))
file.write(utils.num_pad(row.solp))
file.write(utils.num_pad(row.chla))
file.write(utils.num_pad(row.nh3))
file.write(utils.num_pad(row.no2))
file.write(utils.num_pad(row.cbod))
file.write(utils.num_pad(row.dox))
file.write(utils.num_pad(row.sand))
file.write(utils.num_pad(row.silt))
file.write(utils.num_pad(row.clay))
file.write(utils.num_pad(row.sag))
file.write(utils.num_pad(row.lag))
file.write(utils.num_pad(row.gravel))
file.write(utils.num_pad(row.tmp))
file.write("\n")
for rec in recall_recs:
row = Recall_dat.get_or_none(Recall_dat.recall_rec_id == rec.id)
if row is not None:
file.write(utils.string_pad(rec.name, direction="left"))
file.write(utils.num_pad(row.flo))
file.write(utils.num_pad(row.sed))
file.write(utils.num_pad(row.ptl_n))
file.write(utils.num_pad(row.ptl_p))
file.write(utils.num_pad(row.no3_n))
file.write(utils.num_pad(row.sol_p))
file.write(utils.num_pad(row.chla))
file.write(utils.num_pad(row.nh3_n))
file.write(utils.num_pad(row.no2_n))
file.write(utils.num_pad(row.cbn_bod))
file.write(utils.num_pad(row.oxy))
file.write(utils.num_pad(row.sand))
file.write(utils.num_pad(row.silt))
file.write(utils.num_pad(row.clay))
file.write(utils.num_pad(row.sm_agg))
file.write(utils.num_pad(row.lg_agg))
file.write(utils.num_pad(row.gravel))
file.write(utils.num_pad(row.tmp))
file.write("\n")
class Exco_pest_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
self.write_default_table(db.Exco_pest_exc, True)
class Exco_path_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
self.write_default_table(db.Exco_path_exc, True)
class Exco_hmet_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
self.write_default_table(db.Exco_hmet_exc, True)
class Exco_salt_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
self.write_default_table(db.Exco_salt_exc, True)
class Exco_exc(BaseFileModel):
def __init__(self, file_name, version=None):
self.file_name = file_name
self.version = version
def read(self, database='project'):
raise NotImplementedError('Reading not implemented yet.')
def write(self):
table = db.Exco_exc
order_by = db.Exco_exc.id
recall_recs = Recall_rec.select().where(Recall_rec.rec_typ == 4)
if table.select().count() > 0 or recall_recs.count() > 0:
with open(self.file_name, 'w') as file:
file.write(self.get_meta_line())
cols = [col(table.name, direction="left"),
col(table.om),
col(table.pest),
col(table.path),
col(table.hmet),
col(table.salt)]
self.write_headers(file, cols)
file.write("\n")
for row in table.select().order_by(order_by):
file.write(utils.string_pad(row.name, direction="left"))
file.write(utils.key_name_pad(row.om))
file.write(utils.key_name_pad(row.pest))
file.write(utils.key_name_pad(row.path))
file.write(utils.key_name_pad(row.hmet))
file.write(utils.key_name_pad(row.salt))
file.write("\n")
for row in recall_recs:
file.write(utils.string_pad(row.name, direction="left"))
file.write(utils.string_pad(row.name))
file.write(utils.key_name_pad(None))
file.write(utils.key_name_pad(None))
file.write(utils.key_name_pad(None))
file.write(utils.key_name_pad(None))
file.write("\n")
| 31.295082
| 69
| 0.692858
| 893
| 5,727
| 4.240761
| 0.110862
| 0.13784
| 0.184843
| 0.161605
| 0.821231
| 0.801954
| 0.760761
| 0.668075
| 0.668075
| 0.668075
| 0
| 0.00313
| 0.163262
| 5,727
| 182
| 70
| 31.467033
| 0.787145
| 0.008032
| 0
| 0.523179
| 0
| 0
| 0.043662
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.119205
| false
| 0
| 0.02649
| 0
| 0.18543
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
c00c3187b34580671f449cd9aee80f5154a6597b
| 140
|
py
|
Python
|
domainconnectzone/__init__.py
|
vdyminskyy/DomainConnectApplyZone
|
70bfb3abc89adec6d2f8a3605e477f32c728063f
|
[
"MIT"
] | null | null | null |
domainconnectzone/__init__.py
|
vdyminskyy/DomainConnectApplyZone
|
70bfb3abc89adec6d2f8a3605e477f32c728063f
|
[
"MIT"
] | null | null | null |
domainconnectzone/__init__.py
|
vdyminskyy/DomainConnectApplyZone
|
70bfb3abc89adec6d2f8a3605e477f32c728063f
|
[
"MIT"
] | null | null | null |
from .DomainConnect import DomainConnect
from .qsutil import qs2dict, qsfilter
from .sigutil import verify_sig, generate_sig, get_publickey
| 35
| 60
| 0.85
| 18
| 140
| 6.444444
| 0.666667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.008
| 0.107143
| 140
| 3
| 61
| 46.666667
| 0.92
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
c04f51e1460fccbff7a6b38582793f5538922da5
| 43
|
py
|
Python
|
fastestrplidar/__init__.py
|
psomers3/FastestRplidar
|
de729ac04cc559941c4d2007a442d14b17ab8e67
|
[
"MIT"
] | null | null | null |
fastestrplidar/__init__.py
|
psomers3/FastestRplidar
|
de729ac04cc559941c4d2007a442d14b17ab8e67
|
[
"MIT"
] | null | null | null |
fastestrplidar/__init__.py
|
psomers3/FastestRplidar
|
de729ac04cc559941c4d2007a442d14b17ab8e67
|
[
"MIT"
] | null | null | null |
from .fastestrplidar import FastestRplidar
| 21.5
| 42
| 0.883721
| 4
| 43
| 9.5
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.093023
| 43
| 1
| 43
| 43
| 0.974359
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
fbeee4aa9fbd873d886930a721021ef77935f9dc
| 35
|
py
|
Python
|
ipclassifier/iambic_line_processors/__init__.py
|
Chad-Mowbray/iamb-classifier
|
9da3bbfa2cac4518dae5b01de7c62a100a785a82
|
[
"MIT"
] | 2
|
2021-09-11T13:12:38.000Z
|
2022-03-16T23:42:34.000Z
|
ipclassifier/iambic_line_processors/__init__.py
|
redova87/iamb-classifier
|
9da3bbfa2cac4518dae5b01de7c62a100a785a82
|
[
"MIT"
] | 2
|
2021-09-07T02:35:37.000Z
|
2022-02-06T08:29:18.000Z
|
ipclassifier/iambic_line_processors/__init__.py
|
redova87/iamb-classifier
|
9da3bbfa2cac4518dae5b01de7c62a100a785a82
|
[
"MIT"
] | 2
|
2022-02-06T08:27:47.000Z
|
2022-02-06T17:46:34.000Z
|
from .iambic_line import IambicLine
| 35
| 35
| 0.885714
| 5
| 35
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.085714
| 35
| 1
| 35
| 35
| 0.9375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
fbf2b5515da51d02d0c5cd1a25cf2cc1febb0bd8
| 71,066
|
py
|
Python
|
fundamental_analysis/accounting_ratios.py
|
olivier2311/Quantropy
|
539014df811b85742a8731ca347f0a224d82820b
|
[
"MIT"
] | 1
|
2021-11-16T19:06:56.000Z
|
2021-11-16T19:06:56.000Z
|
fundamental_analysis/accounting_ratios.py
|
webclinic017/Quantropy-1
|
539014df811b85742a8731ca347f0a224d82820b
|
[
"MIT"
] | null | null | null |
fundamental_analysis/accounting_ratios.py
|
webclinic017/Quantropy-1
|
539014df811b85742a8731ca347f0a224d82820b
|
[
"MIT"
] | 1
|
2021-11-16T19:06:53.000Z
|
2021-11-16T19:06:53.000Z
|
from datetime import datetime, timedelta
import fundamental_analysis.financial_statements_entries as fi
import fundamental_analysis.supporting_metrics as me
import historical_data_collection.data_preparation_helpers as excel
import fundamental_analysis.equity_valuation_models.equity_valuation_models as valuation
'''
Liquidity ratios are financial ratios that measure a company’s ability to repay both short- and long-term obligations.
'''
def current_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q') -> float:
"""
The **current ratio** measures a company’s ability to pay off short-term liabilities with current assets.
* *Category:* Liquidity Ratio
* *Healthy Range:* between 1.2 and 2
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Current Ratio} = \\frac{\\text{Current Assets}}{\\text{Current Liabilities}}
"""
return fi.current_total_assets(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.current_total_liabilities(stock=stock, date=date, lookback_period=lookback_period, period=period)
def acid_test_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q'):
"""
The acid-test ratio (or quick ratio) measures a company’s ability to pay off short-term liabilities with quick assets
* *Category:* Liquidity Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Acid-Test Ratio} = \\frac{\\text{Liquid Assets}}{\\text{Current Liabilities}}
"""
return me.liquid_assets(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.current_total_liabilities(stock=stock, date=date, lookback_period=lookback_period, period=period)
def cash_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q'):
"""
The cash ratio measures a company’s ability to pay off short-term liabilities with cash and cash equivalents
* *Category:* Liquidity Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Cash Ratio} = \\frac{\\text{Cash and Cash equivalents + Current Marketable Securities}}{\\text{Current Liabilities}}
"""
return (fi.cash_and_cash_equivalents(stock=stock, date=date, lookback_period=lookback_period, period=period)
+ fi.current_marketable_securities(stock=stock, date=date, lookback_period=lookback_period, period=period)) \
/ fi.current_total_liabilities(stock=stock, date=date, lookback_period=lookback_period, period=period)
def operating_cash_flow_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q'):
"""
The operating cash flow ratio is a measure of the number of times a company can pay off current liabilities with the cash generated in a given period
* *Category:* Liquidity Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Operating Cash Flow Ratio} = \\frac{\\text{Operating Cash Flow}}{\\text{Current Liabilities}}
"""
return fi.cash_flow_operating_activities(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.current_total_liabilities(stock=stock, date=date, lookback_period=lookback_period, period=period)
'''
Leverage ratios measure the amount of capital that comes from debt. In other words, leverage financial ratios are used to evaluate a company’s debt levels.
'''
def debt_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q'):
"""
The debt ratio measures the relative amount of a company’s assets that are provided from debt
* *Category:* Leverage Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Debt Ratio} = \\frac{\\text{Total Liabilities}}{\\text{Total Assets}}
"""
return fi.total_liabilities(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.total_assets(stock=stock, date=date, lookback_period=lookback_period, period=period)
def asset_to_equity(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q'):
'''
The asset/equity ratio indicates the relationship of the total assets of the firm to the part owned by shareholders (aka, owner's equity)
* *Category:* Leverage Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Asset to Equity Ratio} = \\frac{\\text{Total Assets}}{\\text{Shareholder’s equity}}
'''
total_assets = fi.total_assets(stock=stock, date=date, lookback_period=lookback_period, period=period)
total_equity = fi.total_shareholders_equity(stock=stock, date=date, lookback_period=lookback_period, period=period)
return total_assets / total_equity
def debt_to_equity(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q',
only_interest_expense=False, all_liabilities=False, only_long_term_debt=True,
exclude_current_portion_long_term_debt=False):
'''
The debt to equity ratio calculates the weight of total debt and financial liabilities against shareholders’ equity
* *Category:* Leverage Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param only_interest_expense:
:param all_liabilities:
:param only_long_term_debt:
:param exclude_current_portion_long_term_debt:
:return: .. math:: \\text{Debt to Equity Ratio} = \\frac{\\text{Total Liabilities}}{\\text{Shareholder’s equity}}
'''
return me.debt(stock=stock, date=date, lookback_period=lookback_period, period=period,
only_interest_expense=only_interest_expense, all_liabilities=all_liabilities,
long_term_debt=only_long_term_debt,
exclude_current_portion_long_term_debt=exclude_current_portion_long_term_debt) \
/ fi.total_shareholders_equity(stock=stock, date=date, lookback_period=lookback_period, period=period)
def debt_to_capital(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q',
interest_expense=False, all_liabilities=False, long_term_debt=True):
'''
A company's debt-to-capital ratio or D/C ratio is the ratio of its total debt to its total capital, its debt and equity combined. The ratio measures a company's capital structure, financial solvency, and degree of leverage, at a particular point in time.
* *Category:* Leverage Ratio
* *Healthy Range:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param interest_expense:
:param all_liabilities:
:param long_term_debt:
:return: .. math:: \\text{Debt to Capital Ratio} = \\frac{\\text{Debt}}{\\text{Debt + Shareholder’s equity}}
'''
total_debt = me.debt(stock=stock, date=date, lookback_period=lookback_period, period=period,
only_interest_expense=interest_expense, all_liabilities=all_liabilities,
long_term_debt=long_term_debt)
return total_debt / (total_debt + fi.total_shareholders_equity(stock=stock, date=date,
lookback_period=lookback_period, period=period))
def interest_coverage(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = ''):
'''
The interest coverage ratio shows how easily a company can pay its interest expenses
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Interest Coverage Ratio} = \\frac{\\text{Operating Income}}{\\text{Interest Expenses}}
'''
return me.earnings_before_interest_and_taxes(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.interest_expense(stock=stock, date=date, lookback_period=lookback_period, period=period)
def debt_service_coverage(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = '',
with_capex=False):
"""
The debt service coverage ratio reveals how easily a company can pay its debt obligations
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param with_capex: Some companies might prefer to subtract CAPEX because capital expenditure is not expensed on the income
statement but rather considered as an “investment”. Excluding CAPEX from EBITDA will give the company the actual
amount of operating income available for debt repayment.
:return: .. math:: \\text{Debt Service Coverage Ratio} = \\frac{\\text{Operating Income}}{\\text{Total Debt Service}}
"""
numerator = fi.operating_income(stock=stock, date=date, lookback_period=lookback_period, period=period)
numerator -= abs(me.capital_expenditures(stock=stock, date=date, lookback_period=lookback_period,
period=period)) if with_capex else 0
return numerator / me.debt_service(stock=stock, date=date, lookback_period=lookback_period, period=period)
'''
Efficiency ratios, also known as activity financial ratios, are used to measure how well a company is utilizing its assets and resources.
'''
def degree_of_operating_leverage(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Degree of Operating Leverage} = \\frac{\\text{}}{\\text{}}
"""
pass
def asset_turnover_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The asset turnover ratio measures a company’s ability to generate sales from assets.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Asset Turnover Ratio} = \\frac{\\text{Net Sales}}{\\text{Total Assets}}
"""
return fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.total_assets(stock=stock, date=date, lookback_period=lookback_period, period=period)
def accounts_payables_turnover_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'FY'):
"""
The accounts payables turnover ratio measures the number of times the company pays off all its creditors in one year.
* *Category*: Efficiency (Activity) Ratio
* *Subcategory*: Accounts Payable
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Accounts Payables Turnover Ratio} = \\frac{\\text{Cost of Goods Sold}}{\\text{Average Accounts Payable}}
"""
return fi.cost_of_goods_services(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.accounts_payable(stock=stock, date=date, lookback_period=lookback_period, period=period)
def payables_conversion_period(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY',
number_of_days=365):
"""
The payables conversion period, or Days Payable Outstanding (DPO), is the average number of days of payables.
For instance, a conversion period of 30 means that on average, the company takes 30 days to pay its creditors.
It is an element of the cash conversion cycle.
* *Category*: Efficiency (Activity) Ratio
* *Subcategory*: Accounts Payable
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param number_of_days: Number of days in period. By default the period is 365 days, but some analysts use 360.
:return: .. math:: \\text{Payables Conversion Period} = \\frac{\\text{365}}{\\text{Payables Turnover}}
"""
return number_of_days / accounts_payables_turnover_ratio(stock=stock, date=date, lookback_period=lookback_period,
period=period)
def inventory_turnover_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The inventory (or stock) turnover ratio measures how many times a company’s inventory is sold and replaced over a given period
* *Category*: Efficiency (Activity) Ratio
* *Subcategory*: Inventory
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Inventory Turnover Ratio} = \\frac{\\text{Cost of Goods Sold}}{\\text{Average Inventory}}
"""
return fi.cost_of_goods_services(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_inventory(stock=stock, date=date, lookback_period=lookback_period, period=period)
def inventory_conversion_period(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY',
number_of_days=365):
"""
The inventory conversion period, or days inventory outstanding (DIO), measures the average number of days that a
company holds on to inventory before selling it to customers. It is an element of the cash conversion cycle.
* *Category*: Efficiency (Activity) Ratio
* *Subcategory*: Inventory
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param number_of_days: Number of days in period. By default the period is 365 days, but some analysts use 360.
:return: .. math:: \\text{Inventory Conversion Period} = \\frac{\\text{365}}{\\text{Inventory Turnover}}
"""
return number_of_days / inventory_turnover_ratio(stock=stock, date=date, lookback_period=lookback_period,
period=period)
def accounts_receivables_turnover_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'FY'):
"""
The accounts receivable turnover ratio measures how many times a company can turn receivables into cash over a given period
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Accounts Receivables Turnover Ratio} = \\frac{\\text{Net Credit Sales}}{\\text{Accounts Receivables}}
"""
return me.net_credit_sales(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_accounts_receivable(stock=stock, date=date, lookback_period=lookback_period, period=period)
def average_collection_period(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY',
number_of_days=365):
"""
The average collection period, or Days Sales Outstanding (DSO), represents the average number of days between the date a credit sale is made and the date the purchaser pays for that sale.
It is an element of the cash conversion cycle.
* *Category*: Efficiency (Activity) Ratio
* *Subcategory*: Accounts Receivables
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param number_of_days: Number of days in period. By default the period is 365 days, but some analysts use 360.
:return: .. math:: \\text{Average Collection Period} = \\frac{\\text{365}}{\\text{Accounts Receivables Turnover Ratio}}
"""
return number_of_days / accounts_receivables_turnover_ratio(stock=stock, date=date, lookback_period=lookback_period,
period=period)
def cash_conversion_cycle(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The cash conversion cycle (CCC) is a metric that expresses the time (measured in days) it takes for a company to
convert its investments in inventory and other resources into cash flows from sales
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Cash Conversion Cycle} = \\text{Days Inventory Outstanding} + \\text{Days Sales Outstanding} + \\text{Days Payable Outstanding}
"""
return inventory_conversion_period(stock=stock, date=date, lookback_period=lookback_period, period=period) \
+ average_collection_period(stock=stock, date=date, lookback_period=lookback_period, period=period) \
- payables_conversion_period(stock=stock, date=date, lookback_period=lookback_period, period=period)
'''
Profitability ratios measure a company’s ability to generate income relative to revenue, balance sheet assets, operating costs, and equity.
'''
def net_profit_margin(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Net Profit Margin} = \\frac{\\text{Net Income}}{\\text{Net Sales}}
"""
return fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period)
def gross_profit_margin(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The gross margin ratio compares the gross profit of a company to its net sales to show how much profit a company makes after paying its cost of goods sold
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Gross Margin Ratio} = \\frac{\\text{Gross Profit}}{\\text{Net Sales}}
"""
return me.gross_profit(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period)
def operating_profit_margin(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The operating margin ratio compares the operating income of a company to its net sales to determine operating efficiency
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Operating Margin Ratio} = \\frac{\\text{Operating Income}}{\\text{Net Sales}}
"""
return fi.operating_income(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period)
def return_on_assets(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The return on assets ratio measures how efficiently a company is using its assets to generate profit
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Return on Assets} = \\frac{\\text{Net Income}}{\\text{Total Assets}}
"""
return fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.total_assets(stock=stock, date=date, lookback_period=lookback_period, period=period)
def return_on_equity(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
The return on equity ratio measures how efficiently a company is using its equity to generate profit
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Return on Equity} = \\frac{\\text{Net Income}}{\\text{Shareholder’s equity}}
"""
return fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.total_shareholders_equity(stock=stock, date=date, lookback_period=lookback_period, period=period)
def return_on_net_assets(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Return on Net Assets} = \\frac{\\text{Net Income}}{\\text{Fixed Assets + Working Capital}}
"""
return fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ (fi.net_property_plant_equipment(stock=stock, date=date, lookback_period=lookback_period, period=period)
+ me.net_working_capital(stock=stock, date=date, lookback_period=lookback_period, period=period))
def return_on_invested_capital(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY',
invested_capital_operating_approach=True):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param invested_capital_operating_approach:
:return: .. math:: \\text{Return on Invested Capital} = \\frac{\\text{NOPAT}}{\\text{Invested Capital}}
"""
return me.net_operating_profit_after_tax(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.invested_capital(stock=stock, date=date, lookback_period=lookback_period, period=period,
operating_approach=invested_capital_operating_approach)
def return_on_capital_employed(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Return on Capital Employed} = \\frac{\\text{EBIT}}{\\text{Capital Employed}}
"""
return me.earnings_before_interest_and_taxes(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.capital_employed(stock=stock, date=date, lookback_period=lookback_period, period=period)
def cash_flow_return_on_investment(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Cash Flow Return on Investment} = \\frac{\\text{Cash Flow}}{\\text{Market Recapitalisation}}
"""
pass
def efficiency_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Efficiency Ratio} = \\frac{\\text{Non-Interest Expense}}{\\text{Revenue}}
"""
pass
def net_gearing(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Net Gearing} = \\frac{\\text{Net Debt}}{\\text{Equity}}
"""
pass
def basic_earnings_power(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{} = \\frac{\\text{}}{\\text{}}
"""
pass
'''
Market value ratios are used to evaluate the share price of a company’s stock.
'''
def dividend_payout_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = '', deduct_preferred_dividends: bool = True, use_augmented_ratio: bool = False):
"""
The dividend payout ratio is the fraction of net income a firm pays to its stockholders in dividends.
The part of earnings not paid to investors is *retained* i.e. left for investment to provide for future earnings growth.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param deduct_preferred_dividends:
:param use_augmented_ratio: Some companies choose stock buybacks as an alternative to dividends; in such cases this ratio becomes less meaningful.
The augmented ratio adds *Buybacks* to the Dividends in the numerator.
:return: .. math:: \\text{Dividend Payout Ratio} = \\frac{\\text{Dividends}}{\\text{Net Income}}
"""
dividends = fi.payments_for_dividends(stock=stock, date=date, lookback_period=lookback_period, period=period)
dividends -= abs(fi.preferred_dividends(stock=stock, date=date, lookback_period=lookback_period,
period=period)) if deduct_preferred_dividends else 0
net_income = fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period)
return dividends / net_income
def retention_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY',
deduct_preferred_dividends: bool = True, use_augmented_ratio: bool = False):
"""
The **retention ratio** indicates the percentage of a company's earnings that are not paid out in dividends but
credited to retained earnings. It is the opposite of the dividend payout ratio
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param deduct_preferred_dividends:
:param use_augmented_ratio: Some companies choose stock buybacks as an alternative to dividends; in such cases this ratio becomes less meaningful.
The augmented ratio adds *Buybacks* to the Dividends in the numerator.
:return: .. math:: \\text{Retention Ratio} = 1 - \\text{Dividend Payout Ratio} = \\frac{\\text{Retained Earnings}}{\\text{Net Income}}
"""
return 1 - dividend_payout_ratio(stock=stock, date=date, lookback_period=lookback_period, period=period,
deduct_preferred_dividends=deduct_preferred_dividends,
use_augmented_ratio=use_augmented_ratio)
def dividend_coverage_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = '', deduct_preferred_dividends: bool = True,
use_augmented_ratio: bool = False):
"""
The **dividend coverage ratio** is the ratio of company's earnings (net income) over the dividend paid to shareholders, calculated as net profit or loss attributable to ordinary shareholders by total ordinary dividend.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param use_augmented_ratio:
:param deduct_preferred_dividends:
:return: .. math:: \\text{Dividend Coverage Ratio} = \\frac{\\text{Net Income}}{\\text{Dividends}}
"""
return 1 / dividend_payout_ratio(stock=stock, date=date, lookback_period=lookback_period, period=period,
deduct_preferred_dividends=deduct_preferred_dividends,
use_augmented_ratio=use_augmented_ratio)
def dividend_yield(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM',
diluted_shares: bool = False):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations. use diluted shares in the computations.
:return: .. math:: \\text{Dividend Yield} = \\frac{\\text{Dividend-per-share}}{\\text{Share Price}}
"""
return me.dividend_per_share(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares) \
/ me.market_price(stock=stock, date=date, lookback_period=lookback_period)
def earnings_per_share(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'TTM', diluted_shares: bool = False, use_income_from_operations: bool = False,
deduct_preferred_dividends: bool = True, weighted_average_shares: bool = True,
as_reported: bool = True):
'''
The earnings per share ratio measures the amount of net income earned for each share outstanding
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
*Notes:* Compared with Earnings per share, a company's cash flow is better indicator of the company's earnings power.
If a company's earnings per share is less than cash flow per share over long term, investors need to be cautious and find out why.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param as_reported: outputs the EPS as reported by the company in the 10-K or 10-Q filing.
:param diluted_shares: use diluted shares instead of basic in calculations.
:param use_income_from_operations: Use income from continuing operations instead of Net Income in the numerator.
:param deduct_preferred_dividends:
:param weighted_average_shares: It is more accurate to use a weighted average number of common shares over the reporting term because the number of shares can change over time.
:return: .. math:: \\text{Earnings Per Share} = \\frac{\\text{Net Income}}{\\text{Total Shares Outstanding}}
'''
numerator = fi.net_income(stock=stock, date=date, lookback_period=lookback_period, period=period)
numerator -= abs(fi.preferred_dividends(stock=stock, date=date, lookback_period=lookback_period,
period=period)) if deduct_preferred_dividends else 0
numerator += fi.non_operating_income(stock=stock, date=date, lookback_period=lookback_period,
period=period) if use_income_from_operations else 0
shares_outstanding_ = fi.total_shares_outstanding(stock=stock, date=date, lookback_period=lookback_period,
period=period, diluted_shares=diluted_shares)
return numerator / shares_outstanding_
def book_value_per_share(stock, date=datetime.now(), lookback_period=timedelta(days=0), period: str = 'Q',
diluted_shares: bool = False, tangible=False):
'''
The book value per share ratio calculates the per-share value of a company based on equity available to shareholders
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:param tangible:
:return: .. math:: \\text{Book Value Per Share} = \\frac{\\text{Shareholder's Equity}}{\\text{Total Shares Outstanding}}
'''
numerator = fi.total_shareholders_equity(stock=stock, date=date, lookback_period=lookback_period, period=period)
if tangible:
numerator = - fi.total_intangible_assets(stock=stock, date=date, lookback_period=lookback_period, period=period)
return numerator / fi.total_shares_outstanding(stock=stock, date=date, lookback_period=lookback_period,
period=period, diluted_shares=diluted_shares)
def price_to_cash_flow_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'TTM', diluted_shares: bool = False):
"""
The **price/cash flow ratio** (or P/CF) is used to compare a company's market value to its cash flow; or, equivalently,
divide the per-share stock price by the per-share operating cash flow.
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
*Notes:* A high P/CF ratio indicated that the specific firm is trading at a high price but is not generating enough
cash flows to support the multiple—sometimes this is OK, depending on the firm, industry, and its specific operations.
Smaller price ratios are generally preferred, as they may reveal a firm generating ample cash flows that are not yet
properly considered in the current share price. Holding all factors constant, from an investment perspective, a smaller P/CF is preferred over a larger multiple
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:return: .. math:: \\text{Price-to-Cash Flow Ratio} = \\frac{\\text{Market Capitalization}}{\\text{Operating Cash Flow}} =
\\frac{\\text{Share Price}}{\\text{Operating Cash Flow per Share}}
"""
return me.market_capitalization(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares) \
/ fi.cash_flow_operating_activities(stock=stock, date=date, lookback_period=lookback_period, period=period)
def price_to_book_ratio(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'Q',
diluted_shares: bool = False, tangible_book_value: bool = False):
"""
The price-to-book ratio (or P/B ratio) is used to compare a company's current market capitalization to its book value;
or, equivalently, divide the per-share stock price by the per-share book value.
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
*Notes:*
* A higher P/B ratio implies that investors expect management to create more value from a given set of
assets, all else equal (and/or that the market value of the firm's assets is significantly higher than their accounting
value). P/B ratios do not, however, directly provide any information on the ability of the firm to generate profits
or cash for shareholders.
* As with most ratios, it varies a fair amount by industry. Industries that require more infrastructure capital
(for each dollar of profit) will usually trade at P/B ratios much lower than, for example, consulting firms. P/B
ratios are commonly used to compare banks, because most assets and liabilities of banks are constantly valued at
market values.
* This ratio also gives some idea of whether an investor is paying too much for what would be left if the company
went bankrupt immediately. For companies in distress, the book value is usually calculated without the intangible
assets that would have no resale value. In such cases, P/B should also be calculated on a "diluted" basis, because
stock options may well vest on sale of the company or change of control or firing of management.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:param tangible_book_value: P/B can be calculated either including or excluding intangible assets and goodwill. When intangible assets and goodwill are excluded,
the ratio is often specified to be "price to tangible book value"
:return: .. math:: \\text{Price-to-Book Ratio} = \\frac{\\text{Market Capitalization}}{\\text{Book Value}} = \\frac{\\text{Share Price}}{\\text{Book Value per Share}}
"""
denominator = fi.total_shareholders_equity(stock=stock, date=date, lookback_period=lookback_period, period=period)
if tangible_book_value:
denominator -= fi.total_intangible_assets(stock=stock, date=date, lookback_period=lookback_period,
period=period)
return me.market_capitalization(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares) / denominator
def price_to_sales(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM',
diluted_shares: bool = False):
"""
Price–sales ratio (or P/S ratio, or PSR) is used to compare a company's current market capitalization and the revenue in
the most recent year; or, equivalently, divide the per-share stock price by the per-share revenue.
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
*Notes:*
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations. use diluted shares instead of basic in calculations.
:return: .. math:: \\text{Price-to-Sales Ratio} = \\frac{\\text{Market Capitalization}}{\\text{Revenue}} = \\frac{\\text{Share Price}}{\\text{Per-Share Revenue}}
"""
return me.market_capitalization(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares) \
/ fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period)
def justified_price_to_sales(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM',
diluted_shares: bool = False):
"""
The justified P/S ratio is calculated as the price-to-sales ratio based on the Gordon Growth Model.
Thus, it is the price-to-sales ratio based on the company's fundamentals rather than .
Here, *g* is the sustainable growth rate as defined below and *r* is the required rate of return.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:return: .. math:: \\text{Justified P/S} = \\text{Profit Margin} * \\text{Payout} * \\frac{1+g}{r-g} where .. math:: g = \\text{Retention Ratio} * \\text{Net Profit Margin} * \\frac{\\text{Sales}}{\\text{Assets}} * \\frac{\\text{Assets}}{\\text{Shareholders' Equity}}
"""
from fundamental_analysis.equity_valuation_models.cost_of_capital import weighted_average_cost_of_capital
g = valuation.growth_rate_PRAT_model(stock=stock, date=date, lookback_period=lookback_period, period=period)
r = weighted_average_cost_of_capital(stock=stock, date=date, lookback_period=lookback_period, period=period)
return net_profit_margin(stock=stock, date=date, lookback_period=lookback_period, period=period) \
* dividend_payout_ratio(stock=stock, date=date, lookback_period=lookback_period, period=period) \
* (1 + g) / (r - g)
def price_to_earnings(stock, date=datetime.now(), lookback_period: timedelta = timedelta(days=0),
period: str = 'TTM', diluted_shares: bool = False,
use_income_from_operations=False, deduct_preferred_dividends=True):
"""
The price-earnings ratio compares a company’s share price to its earnings per share
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:param use_income_from_operations:
:param deduct_preferred_dividends:
:return: .. math:: \\text{Price-earnings ratio} = \\frac{\\text{Share Price}}{\\text{Earnings Per Share}}
"""
market_price_ = me.market_price(stock=stock, date=date, lookback_period=lookback_period)
earnings_per_share_ = earnings_per_share(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares,
use_income_from_operations=use_income_from_operations,
deduct_preferred_dividends=deduct_preferred_dividends)
return market_price_ / earnings_per_share_
def earnings_yield(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = '', diluted_shares: bool = False,
use_income_from_operations=False, deduct_preferred_dividends=True):
"""
The **earnings yield** is the inverse of price to earnings.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param diluted_shares: use diluted shares instead of basic in calculations.
:param use_income_from_operations:
:param deduct_preferred_dividends:
:return: .. math:: \\text{Earnings Yield} = \\frac{\\text{Earnings Per Share}}{\\text{Share Price}}
"""
return 1 / price_to_earnings(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares, use_income_from_operations=use_income_from_operations,
deduct_preferred_dividends=deduct_preferred_dividends)
def greenblatt_earnings_yield(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'FY'):
"""
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return: .. math:: \\text{Greenblatt Earnings Yield} = \\frac{\\text{EBIT}}{\\text{Enterprise Value}}
"""
return me.earnings_before_interest_and_taxes(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period)
def price_to_earnings_to_growth(stock, date=datetime.now(), lookback_period=timedelta(days=0),
period: str = 'TTM', growth_periods: int = 5, diluted_shares: bool = False,
use_income_from_operations: bool = False, deduct_preferred_dividends: bool = True):
"""
The price/earnings to growth ratio (or PEG ratio) is a valuation metric for determining the relative trade-off
between the price of a stock, the earnings generated per share (EPS), and the company's expected growth.
*Category:* Market Value Ratios
*Subcategory:* Equity Value Ratios
*Notes:*
* In general, the P/E ratio is higher for a company with a higher growth rate. Thus, using just the P/E ratio
would make high-growth companies appear overvalued relative to others. It is assumed that by dividing the P/E
ratio by the earnings growth rate, the resulting ratio is better for comparing companies with different growth
rates. Therefore, a lower ratio is "better" (cheaper) and a higher ratio is "worse" (expensive).
* According to Peter Lynch in his book *One Up on Wall Street*, the P/E ratio of any company that's fairly
priced will equal its growth rate", i.e., a fairly valued company will have its PEG equal to 1.
* The P/E ratio used in the calculation may be projected or trailing. The (annual) growth rate is expressed as
a percent value, and should use real growth only, to correct for inflation. It may be the
expected growth rate for the next year or the next five years.
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:param growth_periods:
:param diluted_shares: use diluted shares instead of basic in calculations.
:param use_income_from_operations:
:param deduct_preferred_dividends:
:return: .. math:: \\text{} = \\frac{\\text{}}{\\text{}}
"""
lookbacks = [timedelta(days=365 * i if period != 'Q' else 90 * i) for i in range(growth_periods)]
eps_series = [earnings_per_share(stock=stock, date=date, lookback_period=lookback, period=period,
diluted_shares=diluted_shares,
use_income_from_operations=use_income_from_operations,
deduct_preferred_dividends=deduct_preferred_dividends) for lookback in lookbacks]
eps_growth = average_growth(eps_series[::-1])
output = price_to_earnings(stock=stock, date=date, lookback_period=lookback_period, period=period,
diluted_shares=diluted_shares,
use_income_from_operations=use_income_from_operations,
deduct_preferred_dividends=deduct_preferred_dividends) / eps_growth
return output
'''Enterprise Value Ratios'''
def enterprise_value_to_revenue(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM'):
"""
The enterprise value-to-revenue multiple is a measure of the value of a stock that compares a company's enterprise value to its revenue.
It is often used to determine a company's valuation in the case of a potential acquisition, and can be used for
companies that do not generate income or profits.
*Category:* Enterprise Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return:
"""
return me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ fi.net_sales(stock=stock, date=date, lookback_period=lookback_period, period=period)
def enterprise_value_to_ebitda(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM'):
"""
*Category:* Enterprise Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return:
"""
return me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.earnings_before_interest_and_taxes_and_depreciation_and_amortization(stock=stock, date=date,
lookback_period=lookback_period,
period=period)
def enterprise_value_to_ebit(stock, date=None, lookback_period: timedelta = timedelta(days=0), period: str = 'TTM'):
"""
*Category:* Enterprise Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return:
"""
return me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.earnings_before_interest_and_taxes(stock=stock, date=date, lookback_period=lookback_period,
period=period)
def enterprise_value_to_invested_capital(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'TTM'):
"""
*Category:* Enterprise Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return:
"""
return me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.invested_capital(stock=stock, date=date, lookback_period=lookback_period, period=period)
def enterprise_value_to_free_cash_flow(stock, date=None, lookback_period: timedelta = timedelta(days=0),
period: str = 'TTM'):
"""
*Category:* Enterprise Value Ratios
*Subcategory:* Equity Value Ratios
:param stock: ticker(s) in question. Can be a string (i.e. 'AAPL') or a list of strings (i.e. ['AAPL', 'BA']).
:param date: Can be a datetime (i.e. datetime(2019, 1, 1)) or list of datetimes. The most recent date of reporting from that date will be used. By default, date=datetime.now().
:param lookback_period: lookback from date (used to compare against previous year or quarter etc.) i.e. timedelta(days=90).
:param period: 'FY' for fiscal year, 'Q' for quarter, 'YTD' for calendar year to date, 'TTM' for trailing twelve months.
:return:
"""
return me.enterprise_value(stock=stock, date=date, lookback_period=lookback_period, period=period) \
/ me.free_cash_flow(stock=stock, date=date, lookback_period=lookback_period, period=period)
if __name__ == '__main__':
print(price_to_book_ratio(stock=['BA', 'AXP'], date=[datetime.now(), datetime(2019, 9, 1)], period='FY'))
print(me.market_price(stock=['BA', 'AXP'],
date=[datetime.now(), datetime(2019, 1, 1)]))
| 70.924152
| 271
| 0.695902
| 10,349
| 71,066
| 4.690888
| 0.053145
| 0.083632
| 0.065711
| 0.035224
| 0.796317
| 0.774173
| 0.751926
| 0.746508
| 0.739422
| 0.730194
| 0
| 0.009234
| 0.196916
| 71,066
| 1,001
| 272
| 70.995005
| 0.841341
| 0.632961
| 0
| 0.305785
| 0
| 0
| 0.00493
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.206612
| false
| 0.020661
| 0.024793
| 0
| 0.417355
| 0.008264
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
2222b7764e2de6fce05911a99adcbe3c22d40f38
| 5,054
|
py
|
Python
|
src/deepcolor/dataset.py
|
kojikoji/deepcolor
|
bf8fd441ea3cdb6e5b1879157640d85998b55041
|
[
"MIT"
] | null | null | null |
src/deepcolor/dataset.py
|
kojikoji/deepcolor
|
bf8fd441ea3cdb6e5b1879157640d85998b55041
|
[
"MIT"
] | null | null | null |
src/deepcolor/dataset.py
|
kojikoji/deepcolor
|
bf8fd441ea3cdb6e5b1879157640d85998b55041
|
[
"MIT"
] | null | null | null |
# evndyn
import torch
import numpy as np
class VaeSmDataSet(torch.utils.data.Dataset):
def __init__(self, x, xnorm_mat, transform=None, pre_transform=None):
self.x = x
self.xnorm_mat = xnorm_mat
def __len__(self):
return(self.x.shape[0])
def __getitem__(self, idx):
idx_x = self.x[idx]
idx_xnorm_mat = self.xnorm_mat[idx]
return(idx_x, idx_xnorm_mat)
class VaeSmDataSetMB(torch.utils.data.Dataset):
def __init__(self, x, xnorm_mat, batch_idx, transform=None, pre_transform=None):
self.x = x
self.xnorm_mat = xnorm_mat
self.batch_idx = batch_idx
def __len__(self):
return(self.x.shape[0])
def __getitem__(self, idx):
idx_x = self.x[idx]
idx_xnorm_mat = self.xnorm_mat[idx]
idx_batch_idx = self.batch_idx[idx]
return(idx_x, idx_xnorm_mat, idx_batch_idx)
class ConcatDataset(torch.utils.data.Dataset):
def __init__(self, *datasets):
self.datasets = datasets
def __getitem__(self, idx):
data_list = [
dataset[idx]
for dataset in self.datasets]
return(data_list)
def __len__(self):
min_length = min([
len(dataset)
for dataset in self.datasets])
return(min_length)
class VaeSmDataManager():
def __init__(self, x, test_ratio, batch_size, num_workers, validation_ratio=0.1):
x = x.float()
xnorm_mat = torch.mean(x, dim=1).view(-1, 1)
self.x = x
self.xnorm_mat = xnorm_mat
total_num = x.size()[0]
validation_num = int(total_num * validation_ratio)
test_num = int(total_num * test_ratio)
np.random.seed(42)
idx = np.random.permutation(np.arange(total_num))
validation_idx, test_idx, train_idx = idx[:validation_num], idx[validation_num:(validation_num + test_num)], idx[(validation_num + test_num):]
self.validation_idx, self.test_idx, self.train_idx = validation_idx, test_idx, train_idx
self.validation_x = x[validation_idx]
self.validation_xnorm_mat = xnorm_mat[validation_idx]
self.test_x = x[test_idx]
self.test_xnorm_mat = xnorm_mat[test_idx]
self.train_eds = VaeSmDataSet(x[train_idx], xnorm_mat[train_idx])
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True, pin_memory=True)
def initialize_loader(self, batch_size, num_workers=2):
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True, pin_memory=True)
class VaeSmDataManagerMB():
def __init__(self, x, batch_idx, test_ratio, batch_size, num_workers, validation_ratio=0.1):
x = x.float()
xnorm_mat = torch.mean(x, dim=1).view(-1, 1)
self.x = x
self.xnorm_mat = xnorm_mat
self.batch_idx = batch_idx
total_num = x.size()[0]
validation_num = int(total_num * validation_ratio)
test_num = int(total_num * test_ratio)
np.random.seed(42)
idx = np.random.permutation(np.arange(total_num))
validation_idx, test_idx, train_idx = idx[:validation_num], idx[validation_num:(validation_num + test_num)], idx[(validation_num + test_num):]
self.validation_idx, self.test_idx, self.train_idx = validation_idx, test_idx, train_idx
self.validation_x = x[validation_idx]
self.validation_xnorm_mat = xnorm_mat[validation_idx]
self.validation_batch_idx = batch_idx[validation_idx]
self.test_x = x[test_idx]
self.test_xnorm_mat = xnorm_mat[test_idx]
self.test_batch_idx = batch_idx[test_idx]
self.train_eds = VaeSmDataSet(x[train_idx], xnorm_mat[train_idx], batch_idx[train_idx])
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True, pin_memory=True)
def initialize_loader(self, batch_size, num_workers=2):
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True, pin_memory=True)
class VaeSmDataManagerDPP(VaeSmDataManager):
def __init__(self, gpu, gpu_num, *args, **kwargs):
super(VaeSmDataManagerDPP, self).__init__(*args, **kwargs)
self.train_sampler = torch.utils.data.distributed.DistributedSampler(
self.train_eds, num_replicas=gpu_num, rank=gpu)
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=args[2], shuffle=False, num_workers=0, drop_last=True, pin_memory=True, sampler=self.train_sampler)
def initialize_loader(self, batch_size):
self.train_loader = torch.utils.data.DataLoader(
self.train_eds, batch_size=batch_size, shuffle=False, num_workers=0, drop_last=True, pin_memory=True, sampler=self.train_sampler)
| 42.830508
| 152
| 0.682034
| 712
| 5,054
| 4.488764
| 0.109551
| 0.070088
| 0.043805
| 0.04005
| 0.821026
| 0.821026
| 0.79224
| 0.768148
| 0.768148
| 0.768148
| 0
| 0.005773
| 0.211713
| 5,054
| 117
| 153
| 43.196581
| 0.796436
| 0.001187
| 0
| 0.625
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.15625
| false
| 0
| 0.020833
| 0.020833
| 0.239583
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
2245794f829e43611ca6a39b731f0a0471740a06
| 21,060
|
py
|
Python
|
src/models/segnet.py
|
shendu-sw/TFR-HSS-Benchmark
|
3fbc93ff548d924050e2de5070007197f04be7f4
|
[
"MIT"
] | 7
|
2021-08-24T10:01:28.000Z
|
2021-12-29T07:13:17.000Z
|
src/models/segnet_istropy.py
|
idrl-lab/TFR-HSS-Benchmark
|
3fbc93ff548d924050e2de5070007197f04be7f4
|
[
"MIT"
] | null | null | null |
src/models/segnet_istropy.py
|
idrl-lab/TFR-HSS-Benchmark
|
3fbc93ff548d924050e2de5070007197f04be7f4
|
[
"MIT"
] | 1
|
2021-08-25T01:38:39.000Z
|
2021-08-25T01:38:39.000Z
|
# encoding: utf-8
from math import ceil
import torch
import torch.nn as nn
import torch.nn.functional as F
from .util.backbone import *
__all__ = [
"SegNet_VGG",
"SegNet_VGG_GN",
"SegNet_AlexNet",
"SegNet_ResNet18",
"SegNet_ResNet50",
"SegNet_ResNet101",
"SegNet_ResNet34",
"SegNet_ResNet152",
]
# required class for decoder of SegNet_ResNet
class DecoderBottleneck(nn.Module):
def __init__(self, in_channels):
super(DecoderBottleneck, self).__init__()
self.conv1 = nn.Conv2d(in_channels, in_channels // 4, kernel_size=1, bias=False)
self.bn1 = nn.BatchNorm2d(in_channels // 4)
self.conv2 = nn.ConvTranspose2d(
in_channels // 4, in_channels // 4, kernel_size=2, stride=2, bias=False
)
self.bn2 = nn.BatchNorm2d(in_channels // 4)
self.conv3 = nn.Conv2d(in_channels // 4, in_channels // 2, 1, bias=False)
self.bn3 = nn.BatchNorm2d(in_channels // 2)
self.relu = nn.ReLU(inplace=True)
self.downsample = nn.Sequential(
nn.ConvTranspose2d(
in_channels, in_channels // 2, kernel_size=2, stride=2, bias=False
),
nn.BatchNorm2d(in_channels // 2),
)
def forward(self, x):
out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)
out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)
out = self.conv3(out)
out = self.bn3(out)
identity = self.downsample(x)
out += identity
out = self.relu(out)
return out
# required class for decoder of SegNet_ResNet
class LastBottleneck(nn.Module):
def __init__(self, in_channels):
super(LastBottleneck, self).__init__()
self.conv1 = nn.Conv2d(in_channels, in_channels // 4, kernel_size=1, bias=False)
self.bn1 = nn.BatchNorm2d(in_channels // 4)
self.conv2 = nn.Conv2d(
in_channels // 4, in_channels // 4, kernel_size=3, padding=1, bias=False
)
self.bn2 = nn.BatchNorm2d(in_channels // 4)
self.conv3 = nn.Conv2d(in_channels // 4, in_channels // 4, 1, bias=False)
self.bn3 = nn.BatchNorm2d(in_channels // 4)
self.relu = nn.ReLU(inplace=True)
self.downsample = nn.Sequential(
nn.Conv2d(in_channels, in_channels // 4, kernel_size=1, bias=False),
nn.BatchNorm2d(in_channels // 4),
)
def forward(self, x):
out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)
out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)
out = self.conv3(out)
out = self.bn3(out)
identity = self.downsample(x)
out += identity
out = self.relu(out)
return out
# required class for decoder of SegNet_ResNet
class DecoderBasicBlock(nn.Module):
def __init__(self, in_channels):
super(DecoderBasicBlock, self).__init__()
self.conv1 = nn.Conv2d(
in_channels, in_channels // 2, kernel_size=3, padding=1, bias=False
)
self.bn1 = nn.BatchNorm2d(in_channels // 2)
self.conv2 = nn.ConvTranspose2d(
in_channels // 2, in_channels // 2, kernel_size=2, stride=2, bias=False
)
self.bn2 = nn.BatchNorm2d(in_channels // 2)
self.relu = nn.ReLU(inplace=True)
self.downsample = nn.Sequential(
nn.ConvTranspose2d(
in_channels, in_channels // 2, kernel_size=2, stride=2, bias=False
),
nn.BatchNorm2d(in_channels // 2),
)
def forward(self, x):
out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)
out = self.conv2(out)
out = self.bn2(out)
identity = self.downsample(x)
out += identity
out = self.relu(out)
return out
class LastBasicBlock(nn.Module):
def __init__(self, in_channels):
super(LastBasicBlock, self).__init__()
self.conv1 = nn.Conv2d(
in_channels, in_channels, kernel_size=3, padding=1, bias=False
)
self.bn1 = nn.BatchNorm2d(in_channels)
self.conv2 = nn.Conv2d(
in_channels, in_channels, kernel_size=3, padding=1, bias=False
)
self.bn2 = nn.BatchNorm2d(in_channels)
self.relu = nn.ReLU(inplace=True)
self.downsample = nn.Sequential(
nn.Conv2d(in_channels, in_channels, kernel_size=1, bias=False),
nn.BatchNorm2d(in_channels),
)
def forward(self, x):
out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)
out = self.conv2(out)
out = self.bn2(out)
identity = self.downsample(x)
out += identity
out = self.relu(out)
return out
class SegNet_VGG(nn.Module):
def __init__(self, out_channels=1, in_channels=1, pretrained=False):
super(SegNet_VGG, self).__init__()
vgg_bn = vgg16_bn(pretrained=pretrained)
encoder = list(vgg_bn.features.children())
# Adjust the input size
if in_channels != 3:
encoder[0] = nn.Conv2d(in_channels, 64, kernel_size=3, stride=1, padding=1)
# Encoder, VGG without any maxpooling
self.stage1_encoder = nn.Sequential(*encoder[:6])
self.stage2_encoder = nn.Sequential(*encoder[7:13])
self.stage3_encoder = nn.Sequential(*encoder[14:23])
self.stage4_encoder = nn.Sequential(*encoder[24:33])
self.stage5_encoder = nn.Sequential(*encoder[34:-1])
self.pool = nn.MaxPool2d(kernel_size=2, stride=2, return_indices=True)
# Decoder, same as the encoder but reversed, maxpool will not be used
decoder = encoder
decoder = [
i for i in list(reversed(decoder)) if not isinstance(i, nn.MaxPool2d)
]
# Replace the last conv layer
decoder[-1] = nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1)
# When reversing, we also reversed conv->batchN->relu, correct it
decoder = [
item for i in range(0, len(decoder), 3) for item in decoder[i : i + 3][::-1]
]
# Replace some conv layers & batchN after them
for i, module in enumerate(decoder):
if isinstance(module, nn.Conv2d):
if module.in_channels != module.out_channels:
decoder[i + 1] = nn.BatchNorm2d(module.in_channels)
decoder[i] = nn.Conv2d(
module.out_channels,
module.in_channels,
kernel_size=3,
stride=1,
padding=1,
)
self.stage1_decoder = nn.Sequential(*decoder[0:9])
self.stage2_decoder = nn.Sequential(*decoder[9:18])
self.stage3_decoder = nn.Sequential(*decoder[18:27])
self.stage4_decoder = nn.Sequential(*decoder[27:33])
self.stage5_decoder = nn.Sequential(
*decoder[33:],
nn.Conv2d(64, out_channels, kernel_size=3, stride=1, padding=1)
)
self.unpool = nn.MaxUnpool2d(kernel_size=2, stride=2)
self._initialize_weights(
self.stage1_decoder,
self.stage2_decoder,
self.stage3_decoder,
self.stage4_decoder,
self.stage5_decoder,
)
def _initialize_weights(self, *stages):
for modules in stages:
for module in modules.modules():
if isinstance(module, nn.Conv2d):
nn.init.kaiming_normal_(module.weight)
if module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.BatchNorm2d):
module.weight.data.fill_(1)
module.bias.data.zero_()
def forward(self, x):
# Encoder
x = self.stage1_encoder(x)
x1_size = x.size()
x, indices1 = self.pool(x)
x = self.stage2_encoder(x)
x2_size = x.size()
x, indices2 = self.pool(x)
x = self.stage3_encoder(x)
x3_size = x.size()
x, indices3 = self.pool(x)
x = self.stage4_encoder(x)
x4_size = x.size()
x, indices4 = self.pool(x)
x = self.stage5_encoder(x)
x5_size = x.size()
x, indices5 = self.pool(x)
# Decoder
x = self.unpool(x, indices=indices5, output_size=x5_size)
x = self.stage1_decoder(x)
x = self.unpool(x, indices=indices4, output_size=x4_size)
x = self.stage2_decoder(x)
x = self.unpool(x, indices=indices3, output_size=x3_size)
x = self.stage3_decoder(x)
x = self.unpool(x, indices=indices2, output_size=x2_size)
x = self.stage4_decoder(x)
x = self.unpool(x, indices=indices1, output_size=x1_size)
x = self.stage5_decoder(x)
return x
class SegNet_VGG_GN(nn.Module):
def __init__(self, out_channels=1, in_channels=3, pretrained=False):
super(SegNet_VGG_GN, self).__init__()
vgg_bn = vgg16_bn(pretrained=pretrained)
encoder = list(vgg_bn.features.children())
# Adjust the input size
if in_channels != 3:
encoder[0] = nn.Conv2d(in_channels, 64, kernel_size=3, stride=1, padding=1)
#
for i in range(len(encoder)):
if isinstance(encoder[i], nn.BatchNorm2d):
encoder[i] = nn.GroupNorm(32, encoder[i].num_features)
# Encoder, VGG without any maxpooling
self.stage1_encoder = nn.Sequential(*encoder[:6])
self.stage2_encoder = nn.Sequential(*encoder[7:13])
self.stage3_encoder = nn.Sequential(*encoder[14:23])
self.stage4_encoder = nn.Sequential(*encoder[24:33])
self.stage5_encoder = nn.Sequential(*encoder[34:-1])
self.pool = nn.MaxPool2d(kernel_size=2, stride=2, return_indices=True)
# Decoder, same as the encoder but reversed, maxpool will not be used
decoder = encoder
decoder = [
i for i in list(reversed(decoder)) if not isinstance(i, nn.MaxPool2d)
]
# Replace the last conv layer
decoder[-1] = nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1)
# When reversing, we also reversed conv->batchN->relu, correct it
decoder = [
item for i in range(0, len(decoder), 3) for item in decoder[i : i + 3][::-1]
]
# Replace some conv layers & batchN after them
for i, module in enumerate(decoder):
if isinstance(module, nn.Conv2d):
if module.in_channels != module.out_channels:
decoder[i + 1] = nn.GroupNorm(32, module.in_channels)
decoder[i] = nn.Conv2d(
module.out_channels,
module.in_channels,
kernel_size=3,
stride=1,
padding=1,
)
self.stage1_decoder = nn.Sequential(*decoder[0:9])
self.stage2_decoder = nn.Sequential(*decoder[9:18])
self.stage3_decoder = nn.Sequential(*decoder[18:27])
self.stage4_decoder = nn.Sequential(*decoder[27:33])
self.stage5_decoder = nn.Sequential(
*decoder[33:],
nn.Conv2d(64, out_channels, kernel_size=3, stride=1, padding=1)
)
self.unpool = nn.MaxUnpool2d(kernel_size=2, stride=2)
self._initialize_weights(
self.stage1_decoder,
self.stage2_decoder,
self.stage3_decoder,
self.stage4_decoder,
self.stage5_decoder,
)
def _initialize_weights(self, *stages):
for modules in stages:
for module in modules.modules():
if isinstance(module, nn.Conv2d):
nn.init.kaiming_normal_(module.weight)
if module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.BatchNorm2d):
module.weight.data.fill_(1)
module.bias.data.zero_()
def forward(self, x):
# Encoder
x = self.stage1_encoder(x)
x1_size = x.size()
x, indices1 = self.pool(x)
x = self.stage2_encoder(x)
x2_size = x.size()
x, indices2 = self.pool(x)
x = self.stage3_encoder(x)
x3_size = x.size()
x, indices3 = self.pool(x)
x = self.stage4_encoder(x)
x4_size = x.size()
x, indices4 = self.pool(x)
x = self.stage5_encoder(x)
x5_size = x.size()
x, indices5 = self.pool(x)
# Decoder
x = self.unpool(x, indices=indices5, output_size=x5_size)
x = self.stage1_decoder(x)
x = self.unpool(x, indices=indices4, output_size=x4_size)
x = self.stage2_decoder(x)
x = self.unpool(x, indices=indices3, output_size=x3_size)
x = self.stage3_decoder(x)
x = self.unpool(x, indices=indices2, output_size=x2_size)
x = self.stage4_decoder(x)
x = self.unpool(x, indices=indices1, output_size=x1_size)
x = self.stage5_decoder(x)
return x
class SegNet_AlexNet(nn.Module):
def __init__(self, out_channels=1, in_channels=1, bn=False):
super(SegNet_AlexNet, self).__init__()
self.stage3_encoder = nn.Sequential(
# kernel(11, 11) -> kernel(7, 7)
nn.Conv2d(in_channels, 64, kernel_size=7, stride=4, padding=3),
nn.BatchNorm2d(64) if bn else nn.GroupNorm(32, 64),
nn.ReLU(inplace=True),
# padding=0 -> padding=1
)
self.stage4_encoder = nn.Sequential(
nn.Conv2d(64, 192, kernel_size=5, padding=2),
nn.BatchNorm2d(192) if bn else nn.GroupNorm(32, 192),
nn.ReLU(inplace=True),
)
self.stage5_encoder = nn.Sequential(
nn.Conv2d(192, 384, kernel_size=3, padding=1),
nn.BatchNorm2d(384) if bn else nn.GroupNorm(32, 384),
nn.ReLU(inplace=True),
nn.Conv2d(384, 256, kernel_size=3, padding=1),
nn.BatchNorm2d(256) if bn else nn.GroupNorm(32, 256),
nn.ReLU(inplace=True),
nn.Conv2d(256, 256, kernel_size=3, padding=1),
nn.ReLU(inplace=True),
)
self.maxpool = nn.MaxPool2d(
kernel_size=2, stride=2, ceil_mode=False, return_indices=True
)
self.unpool = nn.MaxUnpool2d(kernel_size=2, stride=2)
self.stage5_decoder = nn.Sequential(
nn.Conv2d(256, 256, kernel_size=3, padding=1),
nn.BatchNorm2d(256) if bn else nn.GroupNorm(32, 256),
nn.ReLU(inplace=True),
nn.Conv2d(256, 384, kernel_size=3, padding=1),
nn.BatchNorm2d(384) if bn else nn.GroupNorm(32, 384),
nn.ReLU(inplace=True),
nn.Conv2d(384, 192, kernel_size=3, padding=1),
nn.BatchNorm2d(192) if bn else nn.GroupNorm(32, 192),
nn.ReLU(inplace=True),
)
self.stage4_decoder = nn.Sequential(
nn.Conv2d(192, 64, kernel_size=5, padding=2),
nn.BatchNorm2d(64) if bn else nn.GroupNorm(32, 64),
nn.ReLU(inplace=True),
)
self.stage3_decoder = nn.Sequential(
nn.ConvTranspose2d(64, 64, kernel_size=2, stride=2, bias=False),
nn.ConvTranspose2d(64, 64, kernel_size=2, stride=2, bias=False),
nn.Conv2d(64, out_channels, kernel_size=7, stride=1, padding=3),
nn.ReLU(inplace=True),
)
def forward(self, x):
x3 = self.stage3_encoder(x)
x3_size = x3.size()
x3, indices3 = self.maxpool(x3)
x4 = self.stage4_encoder(x3)
x4_size = x4.size()
x4, indices4 = self.maxpool(x4)
x5 = self.stage5_encoder(x4)
x5_size = x5.size()
x5, indices5 = self.maxpool(x5)
out = self.unpool(x5, indices=indices5, output_size=x5_size)
out = self.stage5_decoder(out)
out = self.unpool(out, indices=indices4, output_size=x4_size)
out = self.stage4_decoder(out)
out = self.unpool(out, indices=indices3, output_size=x3_size)
out = self.stage3_decoder(out)
return out
class SegNet_ResNet(nn.Module):
def __init__(self, backbone, out_channels=1, is_bottleneck=False, in_channels=1):
super(SegNet_ResNet, self).__init__()
resnet_backbone = backbone
encoder = list(resnet_backbone.children())
if in_channels != 3:
encoder[0] = nn.Conv2d(in_channels, 64, kernel_size=3, stride=1, padding=1)
encoder[3].return_indices = True
# Encoder
self.first_conv = nn.Sequential(*encoder[:4])
resnet_blocks = list(resnet_backbone.children())[4:]
self.encoder = nn.Sequential(*resnet_blocks)
# Decoder
resnet_r_blocks = list(resnet_backbone.children())[4:][::-1]
decoder = []
if is_bottleneck:
channels = (2048, 1024, 512)
else:
channels = (512, 256, 128)
for i, block in enumerate(resnet_r_blocks[:-1]):
new_block = list(block.children())[::-1][:-1]
decoder.append(
nn.Sequential(
*new_block,
DecoderBottleneck(channels[i])
if is_bottleneck
else DecoderBasicBlock(channels[i])
)
)
new_block = list(resnet_r_blocks[-1].children())[::-1][:-1]
decoder.append(
nn.Sequential(
*new_block, LastBottleneck(256) if is_bottleneck else LastBasicBlock(64)
)
)
self.decoder = nn.Sequential(*decoder)
self.last_conv = nn.Sequential(
nn.ConvTranspose2d(64, 64, kernel_size=2, stride=2, bias=False),
nn.Conv2d(64, out_channels, kernel_size=3, stride=1, padding=1),
)
def forward(self, x):
inputsize = x.size()
# Encoder
x, indices = self.first_conv(x)
x = self.encoder(x)
# Decoder
x = self.decoder(x)
h_diff = ceil((x.size()[2] - indices.size()[2]) / 2)
w_diff = ceil((x.size()[3] - indices.size()[3]) / 2)
if indices.size()[2] % 2 == 1:
x = x[
:,
:,
h_diff : x.size()[2] - (h_diff - 1),
w_diff : x.size()[3] - (w_diff - 1),
]
else:
x = x[:, :, h_diff : x.size()[2] - h_diff, w_diff : x.size()[3] - w_diff]
x = F.max_unpool2d(x, indices, kernel_size=2, stride=2)
x = self.last_conv(x)
if inputsize != x.size():
h_diff = (x.size()[2] - inputsize[2]) // 2
w_diff = (x.size()[3] - inputsize[3]) // 2
x = x[:, :, h_diff : x.size()[2] - h_diff, w_diff : x.size()[3] - w_diff]
if h_diff % 2 != 0:
x = x[:, :, :-1, :]
if w_diff % 2 != 0:
x = x[:, :, :, :-1]
return x
def SegNet_ResNet18(in_channels=1, out_channels=1, **kwargs):
"""
Construct SegNet based on ResNet18 model.
"""
backbone_net = resnet18()
model = SegNet_ResNet(
backbone_net,
out_channels=out_channels,
is_bottleneck=False,
in_channels=in_channels,
**kwargs
)
return model
def SegNet_ResNet34(in_channels=1, out_channels=1, **kwargs):
"""
Construct SegNet based on ResNet18 model.
"""
backbone_net = resnet34()
model = SegNet_ResNet(
backbone_net,
out_channels=out_channels,
is_bottleneck=False,
in_channels=in_channels,
**kwargs
)
return model
def SegNet_ResNet50(in_channels=1, out_channels=1, **kwargs):
"""
Construct SegNet based on ResNet50 model.
"""
backbone_net = resnet50()
model = SegNet_ResNet(
backbone_net,
out_channels=out_channels,
is_bottleneck=True,
in_channels=in_channels,
**kwargs
)
return model
def SegNet_ResNet101(in_channels=1, out_channels=1, **kwargs):
"""
Construct SegNet based on ResNet101 model.
"""
backbone_net = resnet101()
model = SegNet_ResNet(
backbone_net,
out_channels=out_channels,
is_bottleneck=True,
in_channels=in_channels,
**kwargs
)
return model
def SegNet_ResNet152(in_channels=1, out_channels=1, **kwargs):
"""
Construct SegNet based on ResNet101 model.
"""
backbone_net = resnet101()
model = SegNet_ResNet(
backbone_net,
out_channels=out_channels,
is_bottleneck=True,
in_channels=in_channels,
**kwargs
)
return model
if __name__ == "__main__":
model = SegNet_AlexNet(in_channels=1, out_channels=1)
print(model)
x = torch.randn(1, 1, 200, 200)
with torch.no_grad():
y = model(x)
print(y.shape)
| 33.75
| 88
| 0.57227
| 2,644
| 21,060
| 4.388805
| 0.076778
| 0.06808
| 0.017235
| 0.021717
| 0.842985
| 0.810841
| 0.787401
| 0.770252
| 0.750517
| 0.730955
| 0
| 0.051303
| 0.309544
| 21,060
| 623
| 89
| 33.804173
| 0.746716
| 0.047673
| 0
| 0.632653
| 0
| 0
| 0.006116
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.046939
| false
| 0
| 0.010204
| 0
| 0.1
| 0.004082
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
2274a2feaea502fa6c3f8a0c98c8155db599d409
| 96
|
py
|
Python
|
venv/lib/python3.8/site-packages/yapf/yapflib/format_token.py
|
Retraces/UkraineBot
|
3d5d7f8aaa58fa0cb8b98733b8808e5dfbdb8b71
|
[
"MIT"
] | 2
|
2022-03-13T01:58:52.000Z
|
2022-03-31T06:07:54.000Z
|
venv/lib/python3.8/site-packages/yapf/yapflib/format_token.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | 19
|
2021-11-20T04:09:18.000Z
|
2022-03-23T15:05:55.000Z
|
venv/lib/python3.8/site-packages/yapf/yapflib/format_token.py
|
DesmoSearch/Desmobot
|
b70b45df3485351f471080deb5c785c4bc5c4beb
|
[
"MIT"
] | null | null | null |
/home/runner/.cache/pip/pool/28/60/ae/0ed7ba935d630565e607df68d8384da6f83424ab9e7519647610e64102
| 96
| 96
| 0.895833
| 9
| 96
| 9.555556
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.479167
| 0
| 96
| 1
| 96
| 96
| 0.416667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
3f1621ba39df17f7cefc7e7a15e602361b856ab9
| 19,267
|
py
|
Python
|
django_cradmin/tests/test_sortable/test_sortable.py
|
appressoas/django_cradmin
|
0f8715afdfe1ad32e46033f442e622aecf6a4dec
|
[
"BSD-3-Clause"
] | 11
|
2015-07-05T16:57:58.000Z
|
2020-11-24T16:58:19.000Z
|
django_cradmin/tests/test_sortable/test_sortable.py
|
appressoas/django_cradmin
|
0f8715afdfe1ad32e46033f442e622aecf6a4dec
|
[
"BSD-3-Clause"
] | 91
|
2015-01-08T22:38:13.000Z
|
2022-02-10T10:25:27.000Z
|
django_cradmin/tests/test_sortable/test_sortable.py
|
appressoas/django_cradmin
|
0f8715afdfe1ad32e46033f442e622aecf6a4dec
|
[
"BSD-3-Clause"
] | 3
|
2016-12-07T12:19:24.000Z
|
2018-10-03T14:04:18.000Z
|
from builtins import range
from django import test
from django.core.exceptions import FieldDoesNotExist
from model_bakery import baker
from django_cradmin.tests.test_sortable.cradmin_sortable_testapp.models import SortableItem
from django_cradmin.tests.test_sortable.cradmin_sortable_testapp.models import ItemContainer
class TestSortableItem(test.TestCase):
"""
Test that classes inherit :class:`SortableBase` works as advertised!
"""
def setUp(self):
pass
def _create_container(self):
container = ItemContainer(name='test container')
container.save()
return container
def _create_items(self, num_items, container=None):
container = container or self._create_container()
items = []
for i in range(0, num_items, 1):
items.append(SortableItem(
container=container,
name='test{}'.format(i),
sort_index=i))
SortableItem.objects.bulk_create(items)
return SortableItem.objects.all()
def test_has_sort_index_field(self):
item = self._create_items(1)[0]
self.assertTrue(hasattr(item, 'sort_index'))
self.assertEqual(item.sort_index, 0)
def test_sort_item_last(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_last(i1)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i2.id, i3.id, i4.id, i5.id, i6.id, i1.id])
def test_sort_last_handles_none(self):
container = self._create_container()
other_item1 = baker.make(SortableItem,
container=container,
name='a',
sort_index=None)
other_item2 = baker.make(SortableItem,
container=container,
name='b',
sort_index=None)
moving_item = baker.make(SortableItem, container=container, sort_index=None)
SortableItem.objects.sort_last(moving_item)
other_item1.refresh_from_db()
other_item2.refresh_from_db()
moving_item.refresh_from_db()
self.assertEqual(other_item1.sort_index, 0)
self.assertEqual(other_item2.sort_index, 1)
self.assertEqual(moving_item.sort_index, 2)
def test_sort_before_handles_none(self):
container = self._create_container()
other_item1 = baker.make(SortableItem,
container=container,
name='a',
sort_index=None)
other_item2 = baker.make(SortableItem,
container=container,
name='b',
sort_index=None)
other_item3 = baker.make(SortableItem,
container=container,
name='c',
sort_index=None)
moving_item = baker.make(SortableItem, container=container, sort_index=None)
SortableItem.objects.sort_before(moving_item, other_item1.id)
other_item1.refresh_from_db()
other_item2.refresh_from_db()
other_item3.refresh_from_db()
moving_item.refresh_from_db()
self.assertEqual(moving_item.sort_index, 0)
self.assertEqual(other_item1.sort_index, 1)
self.assertEqual(other_item2.sort_index, 2)
self.assertEqual(other_item3.sort_index, 3)
def test_sort_item_3_last(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_last(i3)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i1.id, i2.id, i4.id, i5.id, i6.id, i3.id])
def test_sort_last_item_first(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_before(i6, i1.id)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i6.id, i1.id, i2.id, i3.id, i4.id, i5.id])
def test_sort_item_3_first(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_before(i3, i1.id)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i3.id, i1.id, i2.id, i4.id, i5.id, i6.id])
def test_sort_item_move_first_before_id_4(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_before(i1, i4.id)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i2.id, i3.id, i1.id, i4.id, i5.id, i6.id])
def test_sort_item_move_second_before_id_4(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_before(i2, i4.id)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i1.id, i3.id, i2.id, i4.id, i5.id, i6.id])
def test_sort_item_move_second_before_id_4_in_allready_reordered_list(self):
i1, i2, i3, i4, i5, i6 = self._create_items(6)
SortableItem.objects.sort_last(i1)
# now list is [i2,i3,i4,i5,i6,i1]
SortableItem.objects.sort_before(i2, i4.id)
reordered = [si.id for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(reordered, [i3.id, i2.id, i4.id, i5.id, i6.id, i1.id])
def test_set_sort_index_to_last_no_siblings(self):
container = self._create_container()
item = SortableItem(container=container, name='My test')
SortableItem.objects.set_newitem_sort_index_to_last(item)
self.assertEqual(item.sort_index, 0)
self.assertIsNone(item.pk) # The item was not saved
def test_set_sort_index_to_last_has_siblings(self):
container = self._create_container()
self._create_items(2, container=container)
item = SortableItem(container=container, name='My test')
SortableItem.objects.set_newitem_sort_index_to_last(item)
self.assertEqual(item.sort_index, 2)
self.assertIsNone(item.pk) # The item was not saved
def test_set_sort_index_to_last_refuse_with_sort_index(self):
container = self._create_container()
item = SortableItem(container=container, name='My test', sort_index=1)
with self.assertRaises(ValueError):
SortableItem.objects.set_newitem_sort_index_to_last(item)
def test_set_sort_index_to_last_refuse_existing(self):
container = self._create_container()
item = SortableItem(container=container, name='My test', sort_index=1)
item.save()
item.sort_index = None
with self.assertRaises(ValueError):
SortableItem.objects.set_newitem_sort_index_to_last(item)
#####
# Additional tests to locate bug where sort_before gives value of 0
#####
def test_sort_before_two_objects_last_to_first_not_lessthan_zero(self):
i1, i2 = self._create_items(2)
SortableItem.objects.sort_before(i2, i1.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_three_objects_last_to_first_not_lessthan_zero(self):
i1, i2, i3 = self._create_items(3)
SortableItem.objects.sort_before(i3, i1.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_four_objects_last_to_first_not_lessthan_zero(self):
i1, i2, i3, i4 = self._create_items(4)
SortableItem.objects.sort_before(i4, i1.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_two_objects_last_to_second_not_lessthan_zero(self):
i1, i2 = self._create_items(2)
SortableItem.objects.sort_before(i1, i1.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_three_objects_last_to_second_not_lessthan_zero(self):
i1, i2, i3 = self._create_items(3)
SortableItem.objects.sort_before(i3, i2.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_four_objects_last_to_second_not_lessthan_zero(self):
i1, i2, i3, i4 = self._create_items(4)
SortableItem.objects.sort_before(i4, i2.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_two_objects_first_to_last_not_lessthan_zero(self):
i1, i2 = self._create_items(2)
SortableItem.objects.sort_before(i1, i2.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_three_objects_first_to_last_not_lessthan_zero(self):
i1, i2, i3 = self._create_items(3)
SortableItem.objects.sort_before(i1, i3.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sort_before_four_objects_first_to_last_not_lessthan_zero(self):
i1, i2, i3, i4 = self._create_items(4)
SortableItem.objects.sort_before(i1, i4.id)
for object in SortableItem.objects.all():
self.assertTrue(object.sort_index >= 0)
def test_sortindex_is_none_sanity(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=None, container=container)
item2 = baker.make(SortableItem, sort_index=None, container=container)
item3 = baker.make(SortableItem, sort_index=None, container=container)
SortableItem.objects.sort_last(item1)
SortableItem.objects.sort_last(item2)
SortableItem.objects.sort_last(item3)
item1.refresh_from_db()
item2.refresh_from_db()
item3.refresh_from_db()
self.assertEqual(0, item1.sort_index)
self.assertEqual(1, item2.sort_index)
self.assertEqual(2, item3.sort_index)
def test_item_attrs_dict_sanity(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=None, name='SomeName', container=container)
SortableItem.objects.sort_last(item1, item_attrs_dict={'name': "OtherName"})
item1.refresh_from_db()
self.assertEqual(0, item1.sort_index)
self.assertEqual(item1.name, 'OtherName')
def test_item_attrs_dict_none_sanity(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=None, name='SomeName', container=container)
SortableItem.objects.sort_last(item1, item_attrs_dict=None)
item1.refresh_from_db()
self.assertEqual(0, item1.sort_index)
self.assertEqual(item1.name, 'SomeName')
def test_item_attrs_dict_has_invalid_values_crashes_sanity(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=None, name='SomeName', container=container)
with self.assertRaisesMessage(FieldDoesNotExist, 'SortableItem has no field named \'no_field\''):
SortableItem.objects.sort_last(item1, item_attrs_dict={'name': "OtherName", 'no_field': 'asd'})
def test_item_attrs_dict_set_only_on_items_that_updated_start_of_list(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=0, name='SomeName', container=container)
item2 = baker.make(SortableItem, sort_index=1, name='SomeName', container=container)
item3 = baker.make(SortableItem, sort_index=2, name='SomeName', container=container)
SortableItem.objects.sort_before(item2, item1.id, item_attrs_dict={'name': "OtherName"})
item1.refresh_from_db()
item2.refresh_from_db()
item3.refresh_from_db()
self.assertEqual(1, item1.sort_index)
self.assertEqual(0, item2.sort_index)
self.assertEqual(2, item3.sort_index)
self.assertEqual(item1.name, 'OtherName')
self.assertEqual(item2.name, 'OtherName')
self.assertEqual(item3.name, 'SomeName')
def test_item_attrs_dict_set_only_on_items_that_updated_end_of_list(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=0, name='SomeName', container=container)
item2 = baker.make(SortableItem, sort_index=1, name='SomeName', container=container)
item3 = baker.make(SortableItem, sort_index=2, name='SomeName', container=container)
SortableItem.objects.sort_before(item3, item2.id, item_attrs_dict={'name': "OtherName"})
item1.refresh_from_db()
item2.refresh_from_db()
item3.refresh_from_db()
self.assertEqual(0, item1.sort_index)
self.assertEqual(2, item2.sort_index)
self.assertEqual(1, item3.sort_index)
self.assertEqual(item1.name, 'SomeName')
self.assertEqual(item2.name, 'OtherName')
self.assertEqual(item3.name, 'OtherName')
def test_item_attrs_dict_all_items_updated_initially_no_sort_indexes(self):
container = baker.make(ItemContainer)
item1 = baker.make(SortableItem, sort_index=None, name='NameA', container=container)
item2 = baker.make(SortableItem, sort_index=None, name='NameB', container=container)
item3 = baker.make(SortableItem, sort_index=None, name='NameC', container=container)
SortableItem.objects.sort_before(item3, item2.id, item_attrs_dict={'name': "OtherName"})
item1.refresh_from_db()
item2.refresh_from_db()
item3.refresh_from_db()
self.assertEqual(0, item1.sort_index)
self.assertEqual(2, item2.sort_index)
self.assertEqual(1, item3.sort_index)
self.assertEqual(item1.name, 'OtherName')
self.assertEqual(item2.name, 'OtherName')
self.assertEqual(item3.name, 'OtherName')
class TestRepairSortable(test.TestCase):
def setUp(self):
pass
def _create_container(self):
container = ItemContainer(name='test container')
container.save()
return container
def _create_items(self, num_items, container=None, first_sort_index=0):
container = container or self._create_container()
items = []
for i in range(first_sort_index, num_items):
items.append(self._create_item(container, i))
return items
def _create_item(self, container, sort_index):
si = SortableItem.objects.create(
container=container,
name='test{}'.format(sort_index),
sort_index=sort_index)
return si
def test_repairs_empty_hole(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index + 2))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2])
def test_repairs_duplicate_index(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2])
def test_repair_multiple_duplicate_indexes(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index))
items.append(self._create_item(container, items[1].sort_index + 1))
items.append(self._create_item(container, items[1].sort_index + 2))
items.append(self._create_item(container, items[1].sort_index + 2))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2, 3, 4, 5])
def test_repair_multiple_holes_in_indexes(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index + 2))
items.append(self._create_item(container, items[1].sort_index + 3))
items.append(self._create_item(container, items[1].sort_index + 5))
items.append(self._create_item(container, items[1].sort_index + 7))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2, 3, 4, 5])
def test_repair_holes_and_duplicates_in_indexes(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index))
items.append(self._create_item(container, items[1].sort_index + 2))
items.append(self._create_item(container, items[1].sort_index + 3))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2, 3, 4])
def test_repair_several_indexes_hole(self):
container = self._create_container()
items = self._create_items(2, container)
items.append(self._create_item(container, items[1].sort_index + 3))
SortableItem.objects.sort_before(items[1], items[0].id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2])
def test_repair_hole_at_beginning(self):
container = self._create_container()
i1 = self._create_item(container, 1)
i2 = self._create_item(container, 2)
SortableItem.objects.sort_before(i2, i1.id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1])
def test_repair_duplicate_at_beginning(self):
container = self._create_container()
i1 = self._create_item(container, 0)
i2 = self._create_item(container, 0)
self._create_item(container, 1)
SortableItem.objects.sort_before(i2, i1.id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2])
def test_repair_duplicate_at_end(self):
container = self._create_container()
i1 = self._create_item(container, 0)
i2 = self._create_item(container, 1)
self._create_item(container, 1)
SortableItem.objects.sort_before(i2, i1.id)
indexes = [si.sort_index for si in SortableItem.objects.all().order_by('sort_index')]
self.assertEqual(indexes, [0, 1, 2])
| 45.016355
| 107
| 0.67286
| 2,499
| 19,267
| 4.916767
| 0.065226
| 0.084235
| 0.06926
| 0.058599
| 0.897615
| 0.875071
| 0.846423
| 0.833483
| 0.82746
| 0.801172
| 0
| 0.026283
| 0.217989
| 19,267
| 427
| 108
| 45.12178
| 0.789208
| 0.011055
| 0
| 0.643478
| 0
| 0
| 0.028121
| 0
| 0
| 0
| 0
| 0
| 0.191304
| 1
| 0.133333
| false
| 0.005797
| 0.017391
| 0
| 0.171014
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
3f40aa7fe4ae95244a009071351efccf6c656f20
| 45
|
py
|
Python
|
backend/users/serializers/__init__.py
|
orlantquijada/impact2050
|
1153a11c81477cd24689fad92f597621b7da84b9
|
[
"MIT"
] | null | null | null |
backend/users/serializers/__init__.py
|
orlantquijada/impact2050
|
1153a11c81477cd24689fad92f597621b7da84b9
|
[
"MIT"
] | 14
|
2020-06-06T00:08:34.000Z
|
2022-03-12T00:03:46.000Z
|
backend/users/serializers/__init__.py
|
orlantquijada/impact2050
|
1153a11c81477cd24689fad92f597621b7da84b9
|
[
"MIT"
] | null | null | null |
from . import base, request, extended, query
| 22.5
| 44
| 0.755556
| 6
| 45
| 5.666667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.155556
| 45
| 1
| 45
| 45
| 0.894737
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
58c2b2b0fe4b3508053ff98f42907b54995a9f80
| 149
|
py
|
Python
|
apps/sale/models/__init__.py
|
picsldev/pyerp
|
e998e3e99a4e45033d54a6b1df50697f7288f67f
|
[
"MIT"
] | null | null | null |
apps/sale/models/__init__.py
|
picsldev/pyerp
|
e998e3e99a4e45033d54a6b1df50697f7288f67f
|
[
"MIT"
] | null | null | null |
apps/sale/models/__init__.py
|
picsldev/pyerp
|
e998e3e99a4e45033d54a6b1df50697f7288f67f
|
[
"MIT"
] | null | null | null |
""" Centralización de los modelos del módulo de ventas
"""
# __init__.py
from .saleorder import PySaleOrder
from .saleorder import PySaleOrderDetail
| 24.833333
| 54
| 0.798658
| 18
| 149
| 6.388889
| 0.777778
| 0.226087
| 0.330435
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.134228
| 149
| 5
| 55
| 29.8
| 0.891473
| 0.422819
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 6
|
58e9a9174ed0d574bea61dfd4df2f8d8fa905e39
| 3,867
|
py
|
Python
|
project/Transparency/model/modules/Rationale_Generator.py
|
hancia/ToxicSpansDetection
|
4a10600292af90a936767aee09559b39380e3d5e
|
[
"Apache-2.0"
] | 3
|
2021-03-23T08:07:54.000Z
|
2021-11-13T07:13:32.000Z
|
project/Transparency/model/modules/Rationale_Generator.py
|
hancia/ToxicSpansDetection
|
4a10600292af90a936767aee09559b39380e3d5e
|
[
"Apache-2.0"
] | null | null | null |
project/Transparency/model/modules/Rationale_Generator.py
|
hancia/ToxicSpansDetection
|
4a10600292af90a936767aee09559b39380e3d5e
|
[
"Apache-2.0"
] | null | null | null |
import torch
import torch.nn as nn
from model.modelUtils import isTrue
from allennlp.common import Registrable
from allennlp.nn.activations import Activation
from torch.nn import LSTMCell
from collections import namedtuple
from model.modelUtils import isTrue, BatchHolder, BatchMultiHolder
from allennlp.common.from_params import FromParams
from typing import Dict
from allennlp.common import Params
class RGenerator(nn.Module) :
def __init__(self, vocab_size, embed_size, hidden_size, pre_embed=None) :
super().__init__()
self.vocab_size = vocab_size
self.embed_size = embed_size
if pre_embed is not None :
print("Setting Embedding")
weight = torch.Tensor(pre_embed)
weight[0, :].zero_()
self.embedding = nn.Embedding(vocab_size, embed_size, _weight=weight, padding_idx=0)
else :
self.embedding = nn.Embedding(vocab_size, embed_size, padding_idx=0)
self.rnn = nn.LSTM(input_size=embed_size, hidden_size=hidden_size, batch_first=True, bidirectional=True,dropout=0.3)
self.hidden_size = 2*hidden_size
self.linear_1 = nn.Linear(self.hidden_size, 1)#self.hidden_size // 2)
# self.linear_2 = nn.Linear(self.hidden_size//2, 1)
def forward(self, data) :
seq = data.seq
lengths = data.lengths
embedding = self.embedding(seq) #(B, L, E)
mask = data.masks.unsqueeze(-1).float() #(B, L, 1)
packseq = nn.utils.rnn.pack_padded_sequence(embedding, lengths, batch_first=True, enforce_sorted=False)
output, (h, c) = self.rnn(packseq)
output, lengths = nn.utils.rnn.pad_packed_sequence(output, batch_first=True, padding_value=0)
logits = (self.linear_1(output))
probs = torch.sigmoid(logits)
probs = probs * (1-mask) #(B, L, 1)
return probs
class RGenerator_QA(nn.Module) :
def __init__(self, vocab_size, embed_size, hidden_size, pre_embed=None) :
super().__init__()
self.vocab_size = vocab_size
self.embed_size = embed_size
if pre_embed is not None :
print("Setting Embedding")
weight = torch.Tensor(pre_embed)
weight[0, :].zero_()
self.embedding = nn.Embedding(vocab_size, embed_size, _weight=weight, padding_idx=0)
else :
self.embedding = nn.Embedding(vocab_size, embed_size, padding_idx=0)
self.rnn = nn.LSTM(input_size=embed_size, hidden_size=hidden_size, batch_first=True, bidirectional=True,dropout=0.3)
self.rnn_q = nn.LSTM(input_size=embed_size, hidden_size=hidden_size, batch_first=True, bidirectional=True,dropout=0.3)
self.hidden_size = 2*hidden_size
self.linear_1 = nn.Linear(self.hidden_size, 1)#self.hidden_size // 2)
# self.linear_2 = nn.Linear(self.hidden_size//2, 1)
def forward(self, Pdata, Qdata) :
seq = Qdata.seq
lengths = Qdata.lengths
embedding = self.embedding(seq) #(B, L, E)
mask = Qdata.masks.unsqueeze(-1).float() #(B, L, 1)
packseq = nn.utils.rnn.pack_padded_sequence(embedding, lengths, batch_first=True, enforce_sorted=False)
output, (h_n, c_n) = self.rnn_q(packseq)
######## Passage Encoder ###############
seq = Pdata.seq
lengths = Pdata.lengths
embedding = self.embedding(seq) #(B, L, E)
mask = Pdata.masks.unsqueeze(-1).float() #(B, L, 1)
packseq = nn.utils.rnn.pack_padded_sequence(embedding, lengths, batch_first=True, enforce_sorted=False)
output, (h, c) = self.rnn(packseq,(h_n,c_n))
output, lengths = nn.utils.rnn.pad_packed_sequence(output, batch_first=True, padding_value=0)
logits = (self.linear_1(output))
probs = torch.sigmoid(logits)
probs = probs * (1-mask) #(B, L, 1)
return probs
| 37.182692
| 126
| 0.656581
| 528
| 3,867
| 4.598485
| 0.181818
| 0.074135
| 0.058896
| 0.044481
| 0.815486
| 0.789951
| 0.789951
| 0.789951
| 0.789951
| 0.741763
| 0
| 0.01336
| 0.225756
| 3,867
| 103
| 127
| 37.543689
| 0.797595
| 0.061029
| 0
| 0.611111
| 0
| 0
| 0.00946
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.055556
| false
| 0
| 0.152778
| 0
| 0.263889
| 0.027778
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
58fd08bfe62746ab3de50421266da34393594f66
| 4,881
|
py
|
Python
|
mbzirc_ign/src/mbzirc_ign/test_model.py
|
osrf/mbzirc
|
53b8fddcd4fd99b669ba539a4439b07d711692f0
|
[
"Apache-2.0"
] | 13
|
2022-01-06T06:08:35.000Z
|
2022-03-31T14:56:45.000Z
|
mbzirc_ign/src/mbzirc_ign/test_model.py
|
osrf/mbzirc
|
53b8fddcd4fd99b669ba539a4439b07d711692f0
|
[
"Apache-2.0"
] | 28
|
2021-12-16T17:59:49.000Z
|
2022-03-31T18:40:09.000Z
|
mbzirc_ign/src/mbzirc_ign/test_model.py
|
osrf/mbzirc
|
53b8fddcd4fd99b669ba539a4439b07d711692f0
|
[
"Apache-2.0"
] | 9
|
2022-01-07T20:15:04.000Z
|
2022-03-30T07:41:06.000Z
|
import os
import unittest
from ament_index_python.packages import get_package_share_directory
from mbzirc_ign.model import Model
class TestModel(unittest.TestCase):
def test_single_uav_config(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'single_uav_config.yaml')
with open(config, 'r') as stream:
model = Model.FromConfig(stream)
self.assertTrue(model.isUAV())
model.generate()
args = model.spawn_args()
self.assertEqual(len(args), 18)
[bridges, nodes] = model.bridges('test_world_name')
self.assertEqual(len(bridges), 8)
self.assertEqual(len(nodes), 0)
[payload_bridges, payload_nodes, launch] = model.payload_bridges('test_world_name')
self.assertEqual(len(payload_bridges), 8)
self.assertEqual(len(payload_nodes), 4)
self.assertEqual(len(launch), 0)
def test_single_uav_with_gripper_config(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'single_uav_with_gripper_config.yaml')
with open(config, 'r') as stream:
model = Model.FromConfig(stream)
self.assertTrue(model.isUAV())
model.generate()
args = model.spawn_args()
self.assertEqual(len(args), 18)
[bridges, nodes] = model.bridges('test_world_name')
self.assertEqual(len(bridges), 13)
self.assertEqual(len(nodes), 0)
def test_single_fw_uav_config(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'single_fw_uav_config.yaml')
with open(config, 'r') as stream:
model = Model.FromConfig(stream)
self.assertTrue(model.isUAV())
model.generate()
args = model.spawn_args()
self.assertEqual(len(args), 18)
[bridges, nodes] = model.bridges('test_world_name')
self.assertEqual(len(bridges), 7)
self.assertEqual(len(nodes), 0)
[payload_bridges, payload_nodes, launch] = model.payload_bridges('test_world_name')
self.assertEqual(len(payload_bridges), 6)
self.assertEqual(len(payload_nodes), 1)
self.assertEqual(len(launch), 0)
def test_single_usv_config(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'single_usv_config.yaml')
with open(config, 'r') as stream:
model = Model.FromConfig(stream)
self.assertTrue(model.isUSV())
model.generate()
args = model.spawn_args()
self.assertEqual(len(args), 18)
[bridges, nodes] = model.bridges('test_world_name')
self.assertEqual(len(bridges), 9)
self.assertEqual(len(nodes), 0)
[payload_bridges, payload_nodes, launch] = model.payload_bridges('test_world_name')
self.assertEqual(len(payload_bridges), 14)
self.assertEqual(len(payload_nodes), 5)
self.assertEqual(len(launch), 0)
def test_single_usv_with_arm_gripper_config(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'single_usv_with_arm_gripper_config.yaml')
with open(config, 'r') as stream:
model = Model.FromConfig(stream)
self.assertTrue(model.isUSV())
model.generate()
args = model.spawn_args()
self.assertEqual(len(args), 18)
[bridges, nodes] = model.bridges('test_world_name')
self.assertEqual(len(bridges), 24)
self.assertEqual(len(nodes), 1)
def test_coast(self):
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'coast', 'hexrotor.yaml')
with open(config, 'r') as stream:
hexrotor = Model.FromConfig(stream)
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'coast', 'quadrotor.yaml')
with open(config, 'r') as stream:
quadrotor = Model.FromConfig(stream)
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'coast', 'usv.yaml')
with open(config, 'r') as stream:
usv = Model.FromConfig(stream)
config = os.path.join(get_package_share_directory('mbzirc_ign'),
'config', 'coast', 'config_team.yaml')
with open(config, 'r') as stream:
team = Model.FromConfig(stream)
self.assertIsInstance(hexrotor, Model)
self.assertIsInstance(quadrotor, Model)
self.assertIsInstance(usv, Model)
self.assertIsInstance(team, list)
self.assertEqual(len(team), 3)
self.assertIsInstance(team[0], Model)
| 35.369565
| 91
| 0.61975
| 562
| 4,881
| 5.174377
| 0.124555
| 0.128955
| 0.154746
| 0.082531
| 0.839065
| 0.795392
| 0.790578
| 0.753439
| 0.740371
| 0.712173
| 0
| 0.009426
| 0.261012
| 4,881
| 137
| 92
| 35.627737
| 0.796784
| 0
| 0
| 0.58
| 0
| 0
| 0.099775
| 0.029297
| 0
| 0
| 0
| 0
| 0.35
| 1
| 0.06
| false
| 0
| 0.04
| 0
| 0.11
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
453966259dfb7245873209ca8861317993e7d4c7
| 3,964
|
py
|
Python
|
december-measurements/config/network_metrics_config.py
|
dalton/socialsim
|
48b6acc2db423c0f4b14f4ff1c98e931660342fd
|
[
"BSD-2-Clause"
] | null | null | null |
december-measurements/config/network_metrics_config.py
|
dalton/socialsim
|
48b6acc2db423c0f4b14f4ff1c98e931660342fd
|
[
"BSD-2-Clause"
] | null | null | null |
december-measurements/config/network_metrics_config.py
|
dalton/socialsim
|
48b6acc2db423c0f4b14f4ff1c98e931660342fd
|
[
"BSD-2-Clause"
] | null | null | null |
import Metrics
from run_measurements_and_metrics import named_partial
network_measurement_params = {
### Github
"number_of_nodes": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": "number_of_nodes",
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"number_of_edges": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'number_of_edges',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"density": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'density',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
"absolute_difference": Metrics.absolute_difference,
}
},
"mean_shortest_path_length": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'mean_shortest_path_length',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"assortativity_coefficient": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'assortativity_coefficient',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
"absolute_difference": Metrics.absolute_difference,
}
},
"number_of_connected_components": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'number_of_connected_components',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"average_clustering_coefficient": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'average_clustering_coefficient',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
"absolute_difference": Metrics.absolute_difference,
}
},
"max_node_degree": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'max_node_degree',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"mean_node_degree": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'mean_node_degree',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
}
},
"degree_distribution": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'degree_distribution',
"metrics": {
"js_divergence": named_partial(Metrics.js_divergence, discrete=True),
}
},
"community_modularity": {
"question": '',
"scale": "population",
"scenario1":True,
"scenario2":False,
"sceanrio2":True,
"measurement": 'community_modularity',
"metrics": {
"absolute_percentage_error": Metrics.absolute_percentage_error,
"absolute_difference": Metrics.absolute_difference,
}
},
}
| 27.915493
| 81
| 0.562311
| 294
| 3,964
| 7.258503
| 0.163265
| 0.168697
| 0.234302
| 0.281162
| 0.797563
| 0.797563
| 0.797563
| 0.797563
| 0.685098
| 0.685098
| 0
| 0.011935
| 0.302472
| 3,964
| 141
| 82
| 28.113475
| 0.759855
| 0.001514
| 0
| 0.620155
| 0
| 0
| 0.384674
| 0.118867
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.015504
| 0
| 0.015504
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
453c4da07185e3d17286b9ebf96fcb00077cdc52
| 25
|
py
|
Python
|
electricityLoadForecasting/paths/__init__.py
|
BCD65/electricityLoadForecasting
|
07a6ed060afaf7cc2906c0389b5c9e9b0fede193
|
[
"MIT"
] | null | null | null |
electricityLoadForecasting/paths/__init__.py
|
BCD65/electricityLoadForecasting
|
07a6ed060afaf7cc2906c0389b5c9e9b0fede193
|
[
"MIT"
] | null | null | null |
electricityLoadForecasting/paths/__init__.py
|
BCD65/electricityLoadForecasting
|
07a6ed060afaf7cc2906c0389b5c9e9b0fede193
|
[
"MIT"
] | null | null | null |
from .paths import *
| 4.166667
| 20
| 0.6
| 3
| 25
| 5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.32
| 25
| 5
| 21
| 5
| 0.882353
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
188929f44e31ab820cb1ed2904ae6aad1015a3a7
| 25,673
|
py
|
Python
|
train/mix_net.py
|
thu-spmi/semi-EBM
|
393e3ea3566dd60c48872a5c573a335e8e802707
|
[
"Apache-2.0"
] | 2
|
2021-09-18T14:21:24.000Z
|
2021-12-20T03:39:13.000Z
|
train/mix_net.py
|
thu-spmi/semi-EBM
|
393e3ea3566dd60c48872a5c573a335e8e802707
|
[
"Apache-2.0"
] | null | null | null |
train/mix_net.py
|
thu-spmi/semi-EBM
|
393e3ea3566dd60c48872a5c573a335e8e802707
|
[
"Apache-2.0"
] | 1
|
2021-09-12T07:02:23.000Z
|
2021-09-12T07:02:23.000Z
|
# Copyright 2020 Tsinghua University, Author: Yunfu Song
# Apache 2.0.
# This script contrains net structures of CRF supervised training experiments.
import tensorflow as tf
from base import *
import alg
from hrf import alg as alg_np
class Config(wb.Config):
def __init__(self, word_vocab_size, char_vocab_size, output_size, beg_tag_token, end_tag_token):
self.vocab_size = word_vocab_size
self.char_vocab_size = char_vocab_size
self.output_size = output_size
self.init_weight = 0.1
self.embedding_size = 100
self.embedding_init_npy = None # the .npy file written by np.save and can be read by np.load
self.rnn_hidden_size = 200
self.rnn_hidden_layers = 1
self.c2w_type = 'rnn'
self.chr_embedding_size = 30
self.c2w_cnn_size = 30
self.c2w_cnn_width = [1, 2, 3, 4]
self.c2w_rnn_size = 30
self.c2w_rnn_layers = 1
self.dropout = 0
self.opt_method = 'adam'
self.max_grad_norm = 10
self.max_update_batch = 100
self.beg_token = beg_tag_token
self.end_token = end_tag_token
def __str__(self):
s = 'blstm_cnn_we{}_ce{}_c2w{}'.format(self.embedding_size, self.chr_embedding_size, self.c2w_type)
if self.dropout > 0:
s += '_dropout%.1f' % self.dropout
if self.embedding_init_npy is not None:
s += '_loadwd'
return s
# only the mix-connection between x and h, without the dependence in h
class self_Net(object):
def __init__(self, config, is_training, device='/gpu:0', name='uns-net', reuse=tf.AUTO_REUSE,
word_to_chars=None,uns_weight=0.1):
self.config = config
self.is_training = is_training
self.device = device
self.name = name
self.reuse = reuse
self.uns_weight=uns_weight
default_initializer = tf.random_uniform_initializer(-self.config.init_weight, self.config.init_weight)
with tf.device(device), tf.variable_scope(self.name, reuse=self.reuse, initializer=default_initializer):
#############################################
# inputs: of shape (batch_size, seq_len)
# labels: of shape (batch_size, seq_len)
# lengths: of shape (batch_size,)
#############################################
self._inputs = tf.placeholder(tf.int32, [None, None], name='inputs')
self._labels = tf.placeholder(tf.int32, [None, None], name='labels')
self._lengths = tf.placeholder(tf.int32, [None], name='lengths')
self.uns_inputs = tf.placeholder(tf.int32, [None, None], name='inputs')
self.uns_labels = tf.placeholder(tf.int32, [None, None], name='labels')
self.uns_lengths = tf.placeholder(tf.int32, [None], name='lengths')
self._dropout = tf.constant(0, dtype=tf.float32)
self._encoder_dropout=tf.constant(self.config.dropout, dtype=tf.float32)
self.phi, self.logz, self.logps = self.create_net(self._inputs, self._labels, self._lengths,
word_to_chars)
self.uns_phi, self.uns_logz, self.uns_logps = self.create_net(self.uns_inputs, self.uns_labels, self.uns_lengths,
word_to_chars)
# vars
self.vars = tf.get_collection(key=tf.GraphKeys.TRAINABLE_VARIABLES,
scope=tf.get_variable_scope().name)
self.var_size = tf.add_n([tf.size(v) for v in self.vars])
self.print_info()
self.saver = tf.train.Saver(self.vars)
if is_training:
# self.update_vars = self.vars
#
# self.grad_clean = []
# self.grad_bufs = []
# for v in self.update_vars:
# g = tf.get_variable(v.name.split(':')[0] + '_g', shape=v.shape, dtype=tf.float32, trainable=False)
# self.grad_bufs.append(g)
# clean_g = tf.assign(g, tf.zeros_like(g))
# self.grad_clean.append(clean_g)
#
# self._data_num = tf.placeholder(dtype=tf.int32, shape=None, name='data_num')
#
# data_phi = self.phi[0: self._data_num]
# samp_phi = self.phi[self._data_num:]
# grads = tf.gradients(self.outputs, self.update_vars, self._grad_outputs)
# self.grad_update = []
# for g, g_add in zip(self.grad_bufs, grads):
# self.grad_update.append(tf.assign_sub(g, g_add)) # to compute the -grad
# training operation
self.loss = - tf.reduce_mean(self.logps) - self.uns_weight * tf.reduce_mean(self.uns_logps)
self.train_op = layers.TrainOp(self.loss, self.vars, self.config.opt_method,
max_grad_norm=self.config.max_grad_norm,
name=name + '/train_op')
def print_info(self):
if self.reuse is None:
print('[%s.%s] variables in %s' % (__name__, self.__class__.__name__, self.name))
for v in self.vars:
print('\t' + v.name, v.shape, v.device)
def create_net(self, inputs, labels, lengths, word_to_chars):
# linear
outputs = self.create_emission(inputs, lengths, word_to_chars)
self.emission_output = outputs
# phi
phi, logz = self.create_values(outputs, labels, lengths)
# logps
logps = phi - logz
return phi, logz, logps
def create_emission(self, inputs, lengths, word_to_chars):
word_emb = self.create_word_emb(inputs) # [batch_size, max_len, word_emb]
if self.config.chr_embedding_size > 0:
char_emb = self.create_char_emb(inputs, word_to_chars, self.reuse)
char_emb = tf.nn.dropout(char_emb, keep_prob=1. - self._dropout)
emb = tf.concat([word_emb, char_emb], axis=-1)
else:
emb = word_emb
emb = tf.nn.dropout(emb, keep_prob=1. - self._dropout)
# bLSTM
rnn_outputs, _ = layers.rnn(emb, lengths,
self.config.rnn_hidden_size,
self.config.rnn_hidden_layers,
rnn_type='blstm',
reuse=self.reuse,
num_proj=self.config.rnn_proj_size)
rnn_outputs = tf.concat(rnn_outputs, axis=-1)
rnn_outputs = tf.nn.dropout(rnn_outputs, keep_prob=1. - self._dropout)
# linear
outputs = layers.linear(rnn_outputs, self.config.output_size,
activate=None, name='final_linear')
return outputs
def create_word_emb(self, inputs):
# embedding layers
initializer = None
if self.config.embedding_init_npy is not None:
print('[%s.%s] really load the initial word embedding in %s' %
(__name__, self.__class__.__name__, self.config.embedding_init_npy))
emb_arr = np.load(self.config.embedding_init_npy)
assert emb_arr.shape[0] == self.config.vocab_size
assert emb_arr.shape[1] == self.config.embedding_size
initializer = tf.constant_initializer(emb_arr)
word_embedding = tf.get_variable('word_embedding',
[self.config.vocab_size, self.config.embedding_size], dtype=tf.float32,
initializer=initializer)
emb = tf.nn.embedding_lookup(word_embedding, inputs) # (batch_size, seq_len, emb_dim)
return emb
def create_char_emb(self, inputs, word_to_chars, reuse=None):
if self.config.c2w_type == 'cnn':
return layers.char_emb_cnn(inputs, char_size=self.config.char_vocab_size,
embedding_size=self.config.chr_embedding_size,
cnn_kernel_size=self.config.c2w_cnn_size,
cnn_kernel_width=self.config.c2w_cnn_width,
word_to_chars=word_to_chars,
reuse=reuse)
else:
return layers.char_emb_rnn(inputs, char_size=self.config.char_vocab_size,
embedding_size=self.config.chr_embedding_size,
rnn_hidden_size=self.config.c2w_rnn_size,
rnn_hidden_layers=self.config.c2w_rnn_layers,
word_to_chars=word_to_chars,
reuse=reuse)
def create_values2(self, outputs, labels, lengths):
batch_size = tf.shape(outputs)[0]
max_length = tf.shape(outputs)[1]
output_dim = self.config.rnn_hidden_size * 2
# weight between adjacent h_i, h_i+1
self.labels_vecs = tf.get_variable('labels_vecs',
[self.config.output_size,
self.config.output_size,
output_dim], dtype=tf.float32)
self.labels_bias = tf.get_variable('labels_bias',
[self.config.output_size,
self.config.output_size], dtype=tf.float32)
idx1 = tf.reshape(labels[:, 0: -1], [-1])
idx2 = tf.reshape(labels[:, 1:], [-1])
idx = tf.stack([idx1, idx2], axis=1)
cur_vecs = tf.reshape(tf.gather_nd(self.labels_vecs, idx), [batch_size, -1, output_dim])
# [batch_size, len-1, rnn_hidden_size]
cur_bias = tf.reshape(tf.gather_nd(self.labels_bias, idx), [batch_size, -1])
# [batch_size, len-1]
values = tf.reduce_sum(cur_vecs * outputs[:, 1:], axis=-1) + cur_bias
len_mask = tf.sequence_mask(lengths - 1, maxlen=max_length - 1, dtype=tf.float32) # length-1
phi = tf.reduce_sum(values * len_mask, axis=-1) # [batch_size]
# logz
# [batch_size, len, tag_size, tag_size, dim]
trans_vecs = tf.reshape(self.labels_vecs,
[1, 1,
self.config.output_size, self.config.output_size, output_dim])
trans_bias = tf.reshape(self.labels_bias,
[1, 1, self.config.output_size, self.config.output_size])
trans_out = tf.reshape(outputs[:, 1:],
[batch_size, max_length-1, 1, 1, -1])
self.trans = tf.reduce_sum(trans_vecs * trans_out, axis=-1) + trans_bias
alphas = alg.forward_tf2(self.trans, lengths,
beg_ids=[self.config.beg_token],
end_ids=[self.config.end_token])
logz = alg.get_logsum(alphas, lengths)
return phi, logz
def create_values(self, outputs, labels, lengths):
# weight between x and h
edge_matrix = tf.get_variable('edge_mat', [self.config.output_size, self.config.output_size],
dtype=tf.float32)
log_likelihood, _ = tf.contrib.crf.crf_log_likelihood(
outputs[:, 1:-1], labels[:, 1:-1], lengths - 2, transition_params=edge_matrix)
pred_ids, _ = tf.contrib.crf.crf_decode(outputs[:, 1:-1], edge_matrix, lengths - 2)
self.preds = tf.concat([pred_ids[:, :1], pred_ids], 1)
return log_likelihood,0
def run_parameter_num(self, session):
return session.run(self.var_size)
def run_update(self, session, inputs, labels, lengths, uns_inputs, uns_labels, uns_lengths, learning_rate=1.0):
# update parameters
self.train_op.set_lr(session, learning_rate)
self.train_op.update(session, {self._inputs: inputs,
self._labels: labels,
self._lengths: lengths,
self.uns_inputs: uns_inputs,
self.uns_labels: uns_labels,
self.uns_lengths: uns_lengths,
self._dropout: self.config.dropout})
def run_outputs(self, session, inputs, lengths):
return session.run(self.emission_output, {self._inputs: inputs, self._lengths: lengths})
def run_phi(self, session, inputs, labels, lengths):
return session.run(self.phi, {self._inputs: inputs, self._lengths: lengths, self._labels: labels})
def run_logz(self, session, inputs, lengths):
return session.run(self.logz, {self._inputs: inputs, self._lengths: lengths})
def run_logp(self, session, inputs, labels, lengths):
return session.run(self.logps, {self._inputs: inputs, self._lengths: lengths, self._labels: labels})
def run_opt_labels(self, session, inputs, lengths):
preds = session.run(self.preds, {self.uns_inputs: inputs, self.uns_lengths: lengths, self._encoder_dropout: 0})
label_list = []
for pred, n in zip(preds, lengths):
label_list.append([0] + list(pred[1:n-1]) + [1])
return label_list
# trans_mat = session.run(self.trans, {self._inputs: inputs, self._lengths: lengths})
# label_list = []
# for trans, n in zip(trans_mat, lengths):
# label, _ = alg_np.decode(trans[0:n-1], [self.config.beg_token], [self.config.end_token])
# label_list.append(label)
#
# return label_list
def save(self, session, fname):
self.saver.save(session, fname + '.mix.ckpt')
def restore(self, session, fname):
self.saver.restore(session, fname + '.mix.ckpt')
class Net(object):
def __init__(self, config, is_training, device='/gpu:0', name='uns-net', reuse=None,
word_to_chars=None):
self.config = config
self.is_training = is_training
self.device = device
self.name = name
self.reuse = reuse
default_initializer = tf.random_uniform_initializer(-self.config.init_weight, self.config.init_weight)
with tf.device(device), tf.variable_scope(self.name, reuse=self.reuse, initializer=default_initializer):
#############################################
# inputs: of shape (batch_size, seq_len)
# labels: of shape (batch_size, seq_len)
# lengths: of shape (batch_size,)
#############################################
self._inputs = tf.placeholder(tf.int32, [None, None], name='inputs')
self._labels = tf.placeholder(tf.int32, [None, None], name='labels')
self._lengths = tf.placeholder(tf.int32, [None], name='lengths')
self._dropout = tf.constant(0, dtype=tf.float32)
self._encoder_dropout=tf.constant(self.config.dropout, dtype=tf.float32)
self.phi, self.logz, self.logps = self.create_net(self._inputs, self._labels, self._lengths,
word_to_chars)
# vars
self.vars = tf.get_collection(key=tf.GraphKeys.TRAINABLE_VARIABLES,
scope=tf.get_variable_scope().name)
self.var_size = tf.add_n([tf.size(v) for v in self.vars])
self.print_info()
self.saver = tf.train.Saver(self.vars)
if is_training:
# self.update_vars = self.vars
#
# self.grad_clean = []
# self.grad_bufs = []
# for v in self.update_vars:
# g = tf.get_variable(v.name.split(':')[0] + '_g', shape=v.shape, dtype=tf.float32, trainable=False)
# self.grad_bufs.append(g)
# clean_g = tf.assign(g, tf.zeros_like(g))
# self.grad_clean.append(clean_g)
#
# self._data_num = tf.placeholder(dtype=tf.int32, shape=None, name='data_num')
#
# data_phi = self.phi[0: self._data_num]
# samp_phi = self.phi[self._data_num:]
# grads = tf.gradients(self.outputs, self.update_vars, self._grad_outputs)
# self.grad_update = []
# for g, g_add in zip(self.grad_bufs, grads):
# self.grad_update.append(tf.assign_sub(g, g_add)) # to compute the -grad
# training operation
self.loss = -tf.reduce_mean(self.logps)
self.train_op = layers.TrainOp(self.loss, self.vars, self.config.opt_method,
max_grad_norm=self.config.max_grad_norm,
name=name + '/train_op')
def print_info(self):
if self.reuse is None:
print('[%s.%s] variables in %s' % (__name__, self.__class__.__name__, self.name))
for v in self.vars:
print('\t' + v.name, v.shape, v.device)
def create_net(self, inputs, labels, lengths, word_to_chars):
# linear
outputs = self.create_emission(inputs, lengths, word_to_chars)
self.emission_output = outputs
# phi
if self.config.std:
logps=self.create_values_std(outputs, labels, lengths)
phi,logz=0,0
else:
phi, logz = self.create_values(outputs, labels, lengths)
# logps
logps = phi - logz
return phi, logz, logps
def create_emission(self, inputs, lengths, word_to_chars):
word_emb = self.create_word_emb(inputs) # [batch_size, max_len, word_emb]
if self.config.chr_embedding_size > 0:
char_emb = self.create_char_emb(inputs, word_to_chars, self.reuse)
char_emb = tf.nn.dropout(char_emb, keep_prob=1. - self._dropout)
emb = tf.concat([word_emb, char_emb], axis=-1)
else:
emb = word_emb
emb = tf.nn.dropout(emb, keep_prob=1. - self._dropout)
# bLSTM
rnn_outputs, _ = layers.rnn(emb, lengths,
self.config.rnn_hidden_size,
self.config.rnn_hidden_layers,
rnn_type='blstm',
reuse=self.reuse,
num_proj=self.config.rnn_proj_size)
rnn_outputs = tf.concat(rnn_outputs, axis=-1)
rnn_outputs = tf.nn.dropout(rnn_outputs, keep_prob=1. - self._dropout)
# linear
outputs = layers.linear(rnn_outputs, self.config.output_size,
activate=None, name='final_linear')
return outputs
def create_word_emb(self, inputs):
# embedding layers
initializer = None
if self.config.embedding_init_npy is not None:
print('[%s.%s] load the initial word embedding in %s' %
(__name__, self.__class__.__name__, self.config.embedding_init_npy))
emb_arr = np.load(self.config.embedding_init_npy)
assert emb_arr.shape[0] == self.config.vocab_size
assert emb_arr.shape[1] == self.config.embedding_size
initializer = tf.constant_initializer(emb_arr)
word_embedding = tf.get_variable('word_embedding',
[self.config.vocab_size, self.config.embedding_size], dtype=tf.float32,
initializer=initializer)
emb = tf.nn.embedding_lookup(word_embedding, inputs) # (batch_size, seq_len, emb_dim)
return emb
def create_char_emb(self, inputs, word_to_chars, reuse=None):
if self.config.c2w_type == 'cnn':
return layers.char_emb_cnn(inputs, char_size=self.config.char_vocab_size,
embedding_size=self.config.chr_embedding_size,
cnn_kernel_size=self.config.c2w_cnn_size,
cnn_kernel_width=self.config.c2w_cnn_width,
word_to_chars=word_to_chars,
reuse=reuse)
else:
return layers.char_emb_rnn(inputs, char_size=self.config.char_vocab_size,
embedding_size=self.config.chr_embedding_size,
rnn_hidden_size=self.config.c2w_rnn_size,
rnn_hidden_layers=self.config.c2w_rnn_layers,
word_to_chars=word_to_chars,
reuse=reuse)
def create_values_std(self,outputs,labels,lengths):
edge_matrix = tf.get_variable('edge_mat', [self.config.output_size, self.config.output_size],
dtype=tf.float32)
log_likelihood, _ = tf.contrib.crf.crf_log_likelihood(
outputs[:, 1:-1], labels[:,1:-1], lengths - 2, transition_params=edge_matrix)
pred_ids, _ = tf.contrib.crf.crf_decode(outputs[:, 1:-1], edge_matrix, lengths - 2)
self.preds = tf.concat([pred_ids[:, :1], pred_ids], 1)
return log_likelihood
def create_values(self, outputs, labels, lengths):
# weight between x and h
batch_size = tf.shape(labels)[0]
max_length = tf.shape(labels)[1]
labels_flat = tf.reshape(labels, [-1])
outputs_flat = tf.reshape(outputs, [-1, tf.shape(outputs)[-1]])
idx = tf.stack([tf.range(tf.shape(labels_flat)[0]), labels_flat], axis=1)
loss = tf.gather_nd(outputs_flat, idx)
loss = tf.reshape(loss, [batch_size, -1])
len_mask = tf.sequence_mask(lengths, maxlen=max_length, dtype=tf.float32)
loss = tf.reduce_sum(loss * len_mask, axis=-1) # [batch_size]
# weight between adjacent h_i, h_i+1
self.edge_matrix = tf.get_variable('edge_mat', [self.config.output_size, self.config.output_size],
dtype=tf.float32)
edge_idx1 = tf.reshape(labels[:, 0:-1], [-1])
edge_idx2 = tf.reshape(labels[:, 1:], [-1])
idx = tf.stack([edge_idx1, edge_idx2], axis=1)
values = tf.gather_nd(self.edge_matrix, idx)
values = tf.reshape(values, [batch_size, -1])
len_mask = tf.sequence_mask(lengths - 1, maxlen=max_length - 1, dtype=tf.float32) # length-1
loss_bigram = tf.reduce_sum(values * len_mask, axis=-1) # [batch_size]
phi = loss + loss_bigram
# logz
alphas = alg.forward_tf(self.edge_matrix, self.emission_output, lengths,
beg_ids=[self.config.beg_token],
end_ids=[self.config.end_token])
logz = alg.get_logsum(alphas, lengths)
return phi, logz
def run_parameter_num(self, session):
return session.run(self.var_size)
def run_update(self, session, inputs, labels, lengths, learning_rate=1.0):
# update parameters
self.train_op.set_lr(session, learning_rate)
self.train_op.update(session, {self._inputs: inputs,
self._labels: labels,
self._lengths: lengths,
self._dropout: self.config.dropout})
def run_outputs(self, session, inputs, lengths):
return session.run(self.emission_output, {self._inputs: inputs, self._lengths: lengths})
def run_phi(self, session, inputs, labels, lengths):
return session.run(self.phi, {self._inputs: inputs, self._lengths: lengths, self._labels: labels})
def run_logz(self, session, inputs, lengths):
return session.run(self.logz, {self._inputs: inputs, self._lengths: lengths})
def run_logp(self, session, inputs, labels, lengths):
return session.run(self.logps, {self._inputs: inputs, self._lengths: lengths, self._labels: labels})
def run_opt_labels(self, session, inputs, lengths):
if self.config.std:
preds=session.run(self.preds,{self._inputs: inputs, self._lengths: lengths,self._encoder_dropout:0})
label_list=[]
for pred, n in zip(preds, lengths):
label_list.append([0]+list(pred[1:n]))
return label_list
trans_mat = session.run(self.edge_matrix)
emiss_mats = session.run(self.emission_output, {self._inputs: inputs, self._lengths: lengths,self._encoder_dropout:0})
label_list = []
for emat, n in zip(emiss_mats, lengths):
fb = alg_np.ForwardBackward(trans_mat, trans_mat, emat[0:n],
[self.config.beg_token],
[self.config.end_token])
label, _ = fb.decode()
label_list.append(label)
return label_list
# trans_mat = session.run(self.trans, {self._inputs: inputs, self._lengths: lengths})
# label_list = []
# for trans, n in zip(trans_mat, lengths):
# label, _ = alg_np.decode(trans[0:n-1], [self.config.beg_token], [self.config.end_token])
# label_list.append(label)
#
# return label_list
def save(self, session, fname):
self.saver.save(session, fname + '.mix.ckpt')
def restore(self, session, fname):
self.saver.restore(session, fname + '.mix.ckpt')
| 46.509058
| 126
| 0.566198
| 3,117
| 25,673
| 4.401989
| 0.081809
| 0.061949
| 0.018439
| 0.023322
| 0.83937
| 0.822389
| 0.815247
| 0.806355
| 0.803659
| 0.788281
| 0
| 0.013364
| 0.320882
| 25,673
| 552
| 127
| 46.509058
| 0.773616
| 0.116737
| 0
| 0.682584
| 0
| 0
| 0.020047
| 0.001116
| 0
| 0
| 0
| 0
| 0.011236
| 1
| 0.101124
| false
| 0
| 0.011236
| 0.02809
| 0.199438
| 0.02809
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
189e578e7e7852e62fa6ad4fef246a6bcb8af6aa
| 12,108
|
py
|
Python
|
tests/test_utils_iterverbose.py
|
dbajar/segno
|
f7d5669537b12d3ebb914ae6d0a0a1e14f8d25f5
|
[
"BSD-3-Clause"
] | 254
|
2016-09-25T21:32:00.000Z
|
2022-03-30T09:56:14.000Z
|
tests/test_utils_iterverbose.py
|
dbajar/segno
|
f7d5669537b12d3ebb914ae6d0a0a1e14f8d25f5
|
[
"BSD-3-Clause"
] | 102
|
2016-08-04T12:18:44.000Z
|
2022-03-23T09:09:51.000Z
|
tests/test_utils_iterverbose.py
|
dbajar/segno
|
f7d5669537b12d3ebb914ae6d0a0a1e14f8d25f5
|
[
"BSD-3-Clause"
] | 34
|
2016-09-25T21:34:42.000Z
|
2022-03-30T08:19:03.000Z
|
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2020 -- Lars Heuer
# All rights reserved.
#
# License: BSD License
#
"""\
Tests against the ``utils.matrix_iter_verboses`` function.
"""
from __future__ import absolute_import, unicode_literals, print_function
import io
import os
import pytest
from segno import encoder, utils, consts
def read_matrix(name):
"""\
Helper function to read a matrix from /ref_matrix. The file extension .txt
is added automatically.
:return: A tuple of bytearrays
"""
matrix = []
with io.open(os.path.join(os.path.dirname(__file__),
'feature_decompose/{0}.txt'.format(name)), 'rt') as f:
for row in f:
matrix.append(bytearray([int(i) for i in row if i != '\n']))
return matrix
def test_finder_pattern_dark_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_FINDER_PATTERN_DARK] for v in row]))
expected = read_matrix('v1-finder-dark')
assert expected == res
def test_finder_pattern_dark_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_FINDER_PATTERN_LIGHT] for v in row]))
expected = read_matrix('v1-finder-light')
assert expected == res
def test_finder_pattern_dark_and_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_FINDER_PATTERN_DARK,
consts.TYPE_FINDER_PATTERN_LIGHT)] for v in row])) # noqa: E501
expected = read_matrix('v1-finder-dark-and-light')
assert expected == res
def test_finder_pattern_dark_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_FINDER_PATTERN_DARK] for v in row]))
expected = read_matrix('m2-finder-dark')
assert expected == res
def test_finder_pattern_dark_light_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_FINDER_PATTERN_LIGHT] for v in row]))
expected = read_matrix('m2-finder-light')
assert expected == res
def test_finder_pattern_dark_and_light_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_FINDER_PATTERN_DARK,
consts.TYPE_FINDER_PATTERN_LIGHT)] for v in row])) # noqa: E501
expected = read_matrix('m2-finder-dark-and-light')
assert expected == res
def test_separator_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_SEPARATOR] for v in row]))
expected = read_matrix('v1-separator')
assert expected == res
def test_separator_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_SEPARATOR] for v in row]))
expected = read_matrix('m2-separator')
assert expected == res
def test_darkmodule_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_DARKMODULE] for v in row]))
expected = read_matrix('v1-darkmodule')
assert expected == res
def test_no_darkmodule_mqr():
# Micro QR Codes don't have a dark module.
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.extend([v == consts.TYPE_DARKMODULE for v in row])
assert True not in res
def test_timing_dark_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_TIMING_DARK] for v in row]))
expected = read_matrix('v1-timing-dark')
assert expected == res
def test_timing_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_TIMING_LIGHT] for v in row]))
expected = read_matrix('v1-timing-light')
assert expected == res
def test_timing_dark_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_TIMING_DARK] for v in row]))
expected = read_matrix('m2-timing-dark')
assert expected == res
def test_timing_light_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_TIMING_LIGHT] for v in row]))
expected = read_matrix('m2-timing-light')
assert expected == res
def test_timing_dark_and_light_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_TIMING_DARK,
consts.TYPE_TIMING_LIGHT)] for v in row]))
expected = read_matrix('m2-timing-dark-and-light')
assert expected == res
def test_alignment_dark():
qr = encoder.encode('A', version=12)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_ALIGNMENT_PATTERN_DARK] for v in row]))
expected = read_matrix('v12-alignment-dark')
assert expected == res
def test_alignment_light():
qr = encoder.encode('A', version=12)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_ALIGNMENT_PATTERN_LIGHT] for v in row]))
expected = read_matrix('v12-alignment-light')
assert expected == res
def test_alignment_dark_and_light():
qr = encoder.encode('A', version=12)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_ALIGNMENT_PATTERN_LIGHT,
consts.TYPE_ALIGNMENT_PATTERN_DARK)] for v in row])) # noqa: E501
expected = read_matrix('v12-alignment-dark-and-light')
assert expected == res
def test_version_dark():
qr = encoder.encode('A', version=7)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_VERSION_DARK] for v in row]))
expected = read_matrix('v7-version-dark')
assert expected == res
def test_version_light():
qr = encoder.encode('A', version=7)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_VERSION_LIGHT] for v in row]))
expected = read_matrix('v7-version-light')
assert expected == res
def test_version_dark_and_light():
qr = encoder.encode('A', version=7)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_VERSION_LIGHT,
consts.TYPE_VERSION_DARK)] for v in row])) # noqa: E501
expected = read_matrix('v7-version-dark-and-light')
assert expected == res
def test_version_no_version():
# The version information is not available in QR Codes < 7
qr = encoder.encode('A', version=6)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.extend([v in (consts.TYPE_VERSION_LIGHT, consts.TYPE_VERSION_DARK) for v in row])
assert True not in res
def test_format_dark_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_FORMAT_DARK] for v in row]))
expected = read_matrix('v1-format-dark')
assert expected == res
def test_format_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_FORMAT_LIGHT] for v in row]))
expected = read_matrix('v1-format-light')
assert expected == res
def test_format_dark_and_light_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
res.append(bytearray([(0x2, 0x1)[v in (consts.TYPE_FORMAT_DARK,
consts.TYPE_FORMAT_LIGHT)] for v in row]))
expected = read_matrix('v1-format-dark-and-light')
assert expected == res
def test_quietzone_default_qr():
qr = encoder.encode('A', micro=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_QUIET_ZONE] for v in row]))
expected = read_matrix('v1-quietzone-4')
assert expected == res
def test_quietzone_custom_qr():
qr = encoder.encode('A', micro=False)
border = 1
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=border):
res.append(bytearray([(0x2, 0x0)[v == consts.TYPE_QUIET_ZONE] for v in row]))
expected = read_matrix('v1-quietzone-1')
assert expected == res
def test_quietzone_default_mqr():
qr = encoder.encode('A', micro=True)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([(0x1, 0x0)[v == consts.TYPE_QUIET_ZONE] for v in row]))
expected = read_matrix('m2-quietzone-2')
assert expected == res
def test_quietzone_custom_mqr():
qr = encoder.encode('A', micro=True)
border = 5
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=border):
res.append(bytearray([(0x1, 0x0)[v == consts.TYPE_QUIET_ZONE] for v in row]))
expected = read_matrix('m2-quietzone-5')
assert expected == res
def test_convert_to_boolean_true():
qr = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
error='m', mask=4, boost_error=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([int(v >> 8 > 0) for v in row]))
expected = read_matrix('iso-fig-29')
assert expected == res
def test_convert_to_boolean_false():
qr = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
error='m', mask=4, boost_error=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([not int(v >> 8 == 0) for v in row]))
expected = read_matrix('iso-fig-29')
assert expected == res
def test_convert_to_boolean():
qr = encoder.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
error='m', mask=4, boost_error=False)
res = []
for row in utils.matrix_iter_verbose(qr.matrix, qr.version):
res.append(bytearray([bool(v >> 8) for v in row]))
expected = read_matrix('iso-fig-29')
assert expected == res
if __name__ == '__main__':
pytest.main([__file__])
| 36.251497
| 113
| 0.658077
| 1,727
| 12,108
| 4.431963
| 0.081065
| 0.015286
| 0.064672
| 0.045989
| 0.90763
| 0.893389
| 0.861249
| 0.836425
| 0.798798
| 0.726548
| 0
| 0.025665
| 0.208375
| 12,108
| 333
| 114
| 36.36036
| 0.772874
| 0.036009
| 0
| 0.611336
| 0
| 0
| 0.063645
| 0.030962
| 0
| 0
| 0.013933
| 0
| 0.129555
| 1
| 0.133603
| false
| 0
| 0.020243
| 0
| 0.157895
| 0.004049
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
18ab7d39eeaed42a3e079c910b0a49f3a0aeb3e8
| 227
|
py
|
Python
|
core_collection/sysinfo/code_axs.py
|
krai/axs
|
a8070ca41f4631793e0495a2495a01853c3b96de
|
[
"MIT"
] | 4
|
2021-12-22T10:48:28.000Z
|
2021-12-22T11:06:10.000Z
|
core_collection/sysinfo/code_axs.py
|
krai/axs
|
a8070ca41f4631793e0495a2495a01853c3b96de
|
[
"MIT"
] | null | null | null |
core_collection/sysinfo/code_axs.py
|
krai/axs
|
a8070ca41f4631793e0495a2495a01853c3b96de
|
[
"MIT"
] | null | null | null |
"""This entry can find out some properties of the host system,
lazily computed via parameters.
Usage examples :
axs byname sysinfo , get osname
axs byname sysinfo , get arch
"""
| 28.375
| 62
| 0.599119
| 27
| 227
| 5.037037
| 0.851852
| 0.132353
| 0.235294
| 0.279412
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.352423
| 227
| 7
| 63
| 32.428571
| 0.92517
| 0.964758
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
18d379ae2cd868db2af989b66da71ba30f75b7f4
| 220
|
py
|
Python
|
src/kotobo/exceptions.py
|
rmc8/kotobo-api
|
88e42286682f3e3a3c90906b504b7d87b901a808
|
[
"MIT"
] | null | null | null |
src/kotobo/exceptions.py
|
rmc8/kotobo-api
|
88e42286682f3e3a3c90906b504b7d87b901a808
|
[
"MIT"
] | null | null | null |
src/kotobo/exceptions.py
|
rmc8/kotobo-api
|
88e42286682f3e3a3c90906b504b7d87b901a808
|
[
"MIT"
] | null | null | null |
class KotoboConnectionError(Exception):
pass
class KotoboTooManyRequestsError(Exception):
pass
class KotoboNotLoginException(Exception):
pass
class KotoboUndefinedCategoryException(Exception):
pass
| 14.666667
| 50
| 0.790909
| 16
| 220
| 10.875
| 0.4375
| 0.298851
| 0.310345
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.154545
| 220
| 14
| 51
| 15.714286
| 0.935484
| 0
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 0
| 1
| 0
| 1
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 6
|
18e99212b43b090ce556541b0da3ad3e3276f9a5
| 458
|
py
|
Python
|
roomai/sevenking/__init__.py
|
yooyoo2004/RoomAI
|
7f4d655581a03ded801f6c6d7d18f9fff47aa6f5
|
[
"MIT"
] | null | null | null |
roomai/sevenking/__init__.py
|
yooyoo2004/RoomAI
|
7f4d655581a03ded801f6c6d7d18f9fff47aa6f5
|
[
"MIT"
] | null | null | null |
roomai/sevenking/__init__.py
|
yooyoo2004/RoomAI
|
7f4d655581a03ded801f6c6d7d18f9fff47aa6f5
|
[
"MIT"
] | 1
|
2021-08-15T16:19:01.000Z
|
2021-08-15T16:19:01.000Z
|
from roomai.sevenking.SevenKingUtils import SevenKingPokerCard
from roomai.sevenking.SevenKingUtils import AllSevenKingPokerCards
from roomai.sevenking.SevenKingInfo import SevenKingPublicState
from roomai.sevenking.SevenKingInfo import SevenKingPrivateState
from roomai.sevenking.SevenKingInfo import SevenKingPersonState
from roomai.sevenking.SevenKingAction import SevenKingAction
from roomai.sevenking.SevenKingEnv import SevenKingEnv
| 50.888889
| 68
| 0.866812
| 42
| 458
| 9.452381
| 0.309524
| 0.176322
| 0.335013
| 0.241814
| 0.483627
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.10262
| 458
| 8
| 69
| 57.25
| 0.965937
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
e186cd4c655e2a36ba4a952287dcfe2c6c0d20c8
| 134
|
py
|
Python
|
website/about/views.py
|
zckoh/ecommerce-fullstack
|
c4cecea3ebaec900da484954d01dcbc2cba325c9
|
[
"Apache-2.0"
] | 1
|
2021-12-14T22:24:20.000Z
|
2021-12-14T22:24:20.000Z
|
website/about/views.py
|
zckoh/ecommerce-fullstack
|
c4cecea3ebaec900da484954d01dcbc2cba325c9
|
[
"Apache-2.0"
] | 11
|
2021-03-30T13:59:29.000Z
|
2022-03-12T00:48:40.000Z
|
website/about/views.py
|
zckoh/ecommerce-fullstack
|
c4cecea3ebaec900da484954d01dcbc2cba325c9
|
[
"Apache-2.0"
] | null | null | null |
from django.shortcuts import render
# Create your views here.
def about_view(request):
return render(request, 'about/about.html')
| 26.8
| 46
| 0.768657
| 19
| 134
| 5.368421
| 0.789474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.134328
| 134
| 5
| 46
| 26.8
| 0.87931
| 0.171642
| 0
| 0
| 0
| 0
| 0.145455
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0.333333
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 6
|
e1c229a4d39784f95cb6afc0bca712010fe0ed7a
| 11,412
|
py
|
Python
|
tests/test_models_GAE.py
|
unit8co/vegans
|
46ceebe917c3a58fec7a87644c3945a148cfc7c9
|
[
"MIT"
] | 459
|
2019-01-30T17:04:40.000Z
|
2022-03-23T08:28:24.000Z
|
tests/test_models_GAE.py
|
unit8co/vegans
|
46ceebe917c3a58fec7a87644c3945a148cfc7c9
|
[
"MIT"
] | 7
|
2019-01-31T03:58:31.000Z
|
2021-12-14T15:30:28.000Z
|
tests/test_models_GAE.py
|
unit8co/vegans
|
46ceebe917c3a58fec7a87644c3945a148cfc7c9
|
[
"MIT"
] | 34
|
2019-01-30T18:20:33.000Z
|
2022-01-25T06:24:26.000Z
|
"""
Test for models with encoder, generator, adversary structure.
"""
import torch
import pytest
import numpy as np
from vegans.GAN import AAE, BicycleGAN, LRGAN, VAEGAN
from vegans.utils.layers import LayerReshape
# gan, adv_dim, enc_dim
networks_flat = [
(AAE, 10, 10),
(BicycleGAN, 16, 10+1),
(LRGAN, 16, 10),
(VAEGAN, 16, 10+1),
]
networks_image = [
(AAE, 10, 10),
(BicycleGAN, [3, 16, 16], 10+1),
(LRGAN, [3, 16, 16], 10),
(VAEGAN, [3, 16, 16], 10+1),
]
def generate_net(in_dim, last_layer, out_dim):
class MyNetwork(torch.nn.Module):
def __init__(self, in_dim, last_layer, out_dim):
super().__init__()
in_dim = np.prod(in_dim)
out_dim = [out_dim] if isinstance(out_dim, int) else out_dim
self.hidden_part = torch.nn.Sequential(
torch.nn.Flatten(),
torch.nn.Linear(in_dim, 16),
torch.nn.LeakyReLU(0.2),
torch.nn.Linear(16, np.prod(out_dim)),
LayerReshape(out_dim)
)
self.output = last_layer()
def forward(self, x):
x = self.hidden_part(x)
return self.output(x)
return MyNetwork(in_dim, last_layer, out_dim)
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_flat)
def test_init(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = 16
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
# TEST CRITIC
crit = generate_net(in_dim=adv_dim, last_layer=torch.nn.Identity, out_dim=1)
testgan = gan(generator=gen, adversary=crit, encoder=enc, x_dim=x_dim, z_dim=z_dim, adv_type="Critic", folder=None)
# TEST DISCRIMINATOR
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
testgan = gan(generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim, folder=None)
# TEST x_dim AND z_dim
with pytest.raises(TypeError):
gan(generator=gen, adversary=disc, encoder=enc, x_dim=17, z_dim=10, folder=None)
with pytest.raises(TypeError):
gan(generator=gen, adversary=disc, encoder=enc, x_dim=16, z_dim=11, folder=None)
# TEST GENERATOR OUTPUT DIMENSIONS
gen = generate_net(in_dim=10, last_layer=torch.nn.Sigmoid, out_dim=17)
with pytest.raises(AssertionError):
gan(generator=gen, adversary=disc, encoder=enc, x_dim=16, z_dim=10, folder=None)
# TEST ENCODER OUTPUT DIMENSIONS
if enc_dim == z_dim:
gen = generate_net(in_dim=10, last_layer=torch.nn.Sigmoid, out_dim=16)
enc = generate_net(in_dim=16, last_layer=torch.nn.Identity, out_dim=17)
with pytest.raises(AssertionError):
gan(generator=gen, adversary=disc, encoder=enc, x_dim=16, z_dim=10, folder=None)
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_flat)
def test_fit_vector(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = 16
X_train = np.zeros(shape=[100, x_dim])
X_test = np.zeros(shape=[100, x_dim])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
# TEST CRITIC
crit = generate_net(in_dim=adv_dim, last_layer=torch.nn.Identity, out_dim=1)
testgan = gan(generator=gen, adversary=crit, encoder=enc, x_dim=x_dim, z_dim=z_dim, adv_type="Critic", folder=None)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
# TEST DISCRIMINATOR
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
testgan = gan(generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim, folder=None)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_flat)
def test_fit_vector_feature_loss(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = 16
X_train = np.zeros(shape=[100, x_dim])
X_test = np.zeros(shape=[100, x_dim])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
# TEST CRITIC
crit = generate_net(in_dim=adv_dim, last_layer=torch.nn.Identity, out_dim=1)
testgan = gan(
generator=gen, adversary=crit, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, adv_type="Critic", feature_layer=crit.hidden_part
)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
# TEST DISCRIMINATOR
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, feature_layer=disc.hidden_part
)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_flat)
def test_fit_error_vector(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = 16
X_train = np.zeros(shape=[100, x_dim])
X_train_wrong_shape1 = np.zeros(shape=[100])
X_train_wrong_shape2 = np.zeros(shape=[100, x_dim+1])
X_train_wrong_shape3 = np.zeros(shape=[100, 17, 14])
X_train_wrong_shape4 = np.zeros(shape=[100, 17, 10, 10])
X_test_wrong_shape = np.zeros(shape=[100, 17])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, feature_layer=disc.hidden_part
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape1, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape2, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape3, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape4, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train, X_test=X_test_wrong_shape, **fit_kwargs
)
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_image)
def test_fit_image(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = [3, 16, 16]
X_train = np.zeros(shape=[100, *x_dim])
X_test = np.zeros(shape=[100, *x_dim])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None
)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_image)
def test_fit_image_feature_loss(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = [3, 16, 16]
X_train = np.zeros(shape=[100, *x_dim])
X_test = np.zeros(shape=[100, *x_dim])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, feature_layer=disc.hidden_part
)
testgan.fit(
X_train=X_train, X_test=X_test, **fit_kwargs
)
assert hasattr(testgan, "logged_losses")
@pytest.mark.parametrize("gan, adv_dim, enc_dim", networks_image)
def test_fit_image_error(gan, adv_dim, enc_dim):
z_dim = 10
x_dim = [3, 16, 16]
X_train = np.zeros(shape=[100, *x_dim])
X_train_wrong_shape1 = np.zeros(shape=[100])
X_train_wrong_shape2 = np.zeros(shape=[100, 17])
X_train_wrong_shape3 = np.zeros(shape=[100, 17, 14])
X_train_wrong_shape4 = np.zeros(shape=[100, 4, 16, 16])
X_test_wrong_shape = np.zeros(shape=[100, 3, 17, 17])
gen = generate_net(in_dim=z_dim, last_layer=torch.nn.Sigmoid, out_dim=x_dim)
enc = generate_net(in_dim=x_dim, last_layer=torch.nn.Identity, out_dim=enc_dim)
disc = generate_net(in_dim=adv_dim, last_layer=torch.nn.Sigmoid, out_dim=1)
fit_kwargs = {
"epochs": 1, "batch_size": 4, "steps": None, "print_every": None, "save_model_every": None,
"save_images_every": None, "save_losses_every": "1e", "enable_tensorboard": False
}
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, feature_layer=disc.hidden_part
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape1, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape2, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape3, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train_wrong_shape4, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan.fit(
X_train=X_train, X_test=X_test_wrong_shape, **fit_kwargs
)
with pytest.raises(AssertionError):
testgan = gan(
generator=gen, adversary=disc, encoder=enc, x_dim=x_dim, z_dim=z_dim,
folder=None, feature_layer="hidden_part"
)
@pytest.mark.parametrize("gan, optim", [
(AAE, torch.optim.Adam),
(BicycleGAN, torch.optim.Adam),
(LRGAN, torch.optim.Adam),
(VAEGAN, torch.optim.Adam),
]
)
def test_default_optimizers(gan, optim):
assert gan._default_optimizer(gan) == optim
| 36.228571
| 119
| 0.668332
| 1,744
| 11,412
| 4.072821
| 0.071674
| 0.033225
| 0.036463
| 0.063072
| 0.86921
| 0.861467
| 0.852034
| 0.840631
| 0.832184
| 0.832184
| 0
| 0.02739
| 0.203382
| 11,412
| 314
| 120
| 36.343949
| 0.753932
| 0.022958
| 0
| 0.62249
| 0
| 0
| 0.078685
| 0
| 0
| 0
| 0
| 0
| 0.080321
| 1
| 0.044177
| false
| 0
| 0.02008
| 0
| 0.076305
| 0.024096
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
835793b94346c0ddcb98979259b08b7de3d8301b
| 295
|
py
|
Python
|
examples/django/example/djfoursquare/auth.py
|
Code-in-the-House/foursquare_api
|
47f710802bad581d36c7e8ec28612bccf1f9fe41
|
[
"MIT"
] | null | null | null |
examples/django/example/djfoursquare/auth.py
|
Code-in-the-House/foursquare_api
|
47f710802bad581d36c7e8ec28612bccf1f9fe41
|
[
"MIT"
] | null | null | null |
examples/django/example/djfoursquare/auth.py
|
Code-in-the-House/foursquare_api
|
47f710802bad581d36c7e8ec28612bccf1f9fe41
|
[
"MIT"
] | null | null | null |
from django.conf import settings
def get_consumer_credentials():
'''
Return consumer OAuth credentials
'''
return getattr(settings, 'FOURSQUARE_CLIENT_ID', ''), \
getattr(settings, 'FOURSQUARE_CLIENT_SECRET', ''), \
getattr(settings, 'FOURSQUARE_CALLBACK', '')
| 26.818182
| 60
| 0.674576
| 28
| 295
| 6.857143
| 0.607143
| 0.234375
| 0.390625
| 0.322917
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.19661
| 295
| 10
| 61
| 29.5
| 0.810127
| 0.111864
| 0
| 0
| 0
| 0
| 0.256098
| 0.097561
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| true
| 0
| 0.2
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 6
|
55ef800ad9be85fe7cf92edcb76594b2fbef572a
| 12,169
|
py
|
Python
|
examples/account_examples.py
|
janezpodhostnik/flow-py-sdk
|
8b10f4ca2290f5d31920b86fd93a68a643cb1c75
|
[
"MIT"
] | 21
|
2020-11-25T16:30:53.000Z
|
2022-03-08T06:24:02.000Z
|
examples/account_examples.py
|
janezpodhostnik/flow-py-sdk
|
8b10f4ca2290f5d31920b86fd93a68a643cb1c75
|
[
"MIT"
] | 29
|
2021-03-06T19:04:33.000Z
|
2022-03-18T15:16:44.000Z
|
examples/account_examples.py
|
janezpodhostnik/flow-py-sdk
|
8b10f4ca2290f5d31920b86fd93a68a643cb1c75
|
[
"MIT"
] | 15
|
2021-03-06T18:36:40.000Z
|
2022-02-09T15:14:01.000Z
|
from flow_py_sdk import (
flow_client,
AccountKey,
ProposalKey,
create_account_template,
Tx,
TransactionTemplates,
cadence,
SignAlgo,
HashAlgo,
)
from examples.common import Example, Config
from examples.common.utils import random_account
# -------------------------------------------------------------------------
# Create an account
# -------------------------------------------------------------------------
class SignTransactionExample(Example):
def __init__(self) -> None:
super().__init__(
tag="AC.1.",
name="Create account transaction - using the template",
sort_order=901,
)
async def run(self, ctx: Config):
# First Step : Create a client to connect to the flow blockchain
# flow_client function creates a client using the host and port
async with flow_client(
host=ctx.access_node_host, port=ctx.access_node_port
) as client:
account_key, _ = AccountKey.from_seed(
seed="dfghj dfj kjhgf hgfd lkjhgf kjhgfd sdf45678l",
sign_algo=SignAlgo.ECDSA_P256,
hash_algo=HashAlgo.SHA3_256,
)
latest_block = await client.get_latest_block()
proposer = await client.get_account_at_latest_block(
address=ctx.service_account_address.bytes
)
transaction = (
create_account_template(
keys=[account_key],
reference_block_id=latest_block.id,
payer=ctx.service_account_address,
proposal_key=ProposalKey(
key_address=ctx.service_account_address,
key_id=ctx.service_account_key_id,
key_sequence_number=proposer.keys[
ctx.service_account_key_id
].sequence_number,
),
)
.add_authorizers(ctx.service_account_address)
.with_envelope_signature(
ctx.service_account_address, 0, ctx.service_account_signer
)
)
await client.execute_transaction(transaction)
# -------------------------------------------------------------------------
# Deploy a contract at an account
# -------------------------------------------------------------------------
class DeployContract(Example):
def __init__(self) -> None:
super().__init__(
tag="AC.2.",
name="Deploy Contract at the account - using the template",
sort_order=902,
)
async def run(self, ctx: Config):
# First Step : Create a client to connect to the flow blockchain
# flow_client function creates a client using the host and port
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
return a + b
}
}""",
}
contract_source_hex = bytes(contract["source"], "UTF-8").hex()
async with flow_client(
host=ctx.access_node_host, port=ctx.access_node_port
) as client:
account_address, _, new_signer = await random_account(
client=client, ctx=ctx
)
latest_block = await client.get_latest_block()
proposer = await client.get_account_at_latest_block(
address=account_address.bytes
)
contract_name = cadence.String(contract["Name"])
contract_code = cadence.String(contract_source_hex)
transaction = (
Tx(
code=TransactionTemplates.addAccountContractTemplate,
reference_block_id=latest_block.id,
payer=account_address,
proposal_key=ProposalKey(
key_address=account_address,
key_id=0,
key_sequence_number=proposer.keys[0].sequence_number,
),
)
.add_arguments(contract_name)
.add_arguments(contract_code)
.add_authorizers(account_address)
.with_envelope_signature(
account_address,
0,
new_signer,
)
)
await client.execute_transaction(transaction)
# -------------------------------------------------------------------------
# Update a contract at an account
# -------------------------------------------------------------------------
class UpdateContract(Example):
def __init__(self) -> None:
super().__init__(
tag="AC.3.",
name="Update a Contract of the account - using the template",
sort_order=903,
)
async def run(self, ctx: Config):
# First Step : Create a client to connect to the flow blockchain
# flow_client function creates a client using the host and port
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
return a + b
}
}""",
}
contract_source_hex = bytes(contract["source"], "UTF-8").hex()
async with flow_client(
host=ctx.access_node_host, port=ctx.access_node_port
) as client:
account_address, _, new_signer = await random_account(
client=client, ctx=ctx
)
latest_block = await client.get_latest_block()
proposer = await client.get_account_at_latest_block(
address=account_address.bytes
)
contract_name = cadence.String(contract["Name"])
contract_code = cadence.String(contract_source_hex)
transaction = (
Tx(
code=TransactionTemplates.addAccountContractTemplate,
reference_block_id=latest_block.id,
payer=account_address,
proposal_key=ProposalKey(
key_address=account_address,
key_id=0,
key_sequence_number=proposer.keys[0].sequence_number,
),
)
.add_arguments(contract_name)
.add_arguments(contract_code)
.add_authorizers(account_address)
.with_envelope_signature(
account_address,
0,
new_signer,
)
)
await client.execute_transaction(transaction)
proposer.keys[0].sequence_number = proposer.keys[0].sequence_number + 1
latest_block = await client.get_latest_block()
# Updated Contract
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
return a * b
}
}""",
}
contract_source_hex = bytes(contract["source"], "UTF-8").hex()
contract_name = cadence.String(contract["Name"])
contract_code = cadence.String(contract_source_hex)
# Update account contract with a transaction
transaction = (
Tx(
code=TransactionTemplates.updateAccountContractTemplate,
reference_block_id=latest_block.id,
payer=account_address,
proposal_key=ProposalKey(
key_address=account_address,
key_id=0,
key_sequence_number=proposer.keys[0].sequence_number,
),
)
.add_arguments(contract_name)
.add_arguments(contract_code)
.add_authorizers(account_address)
.with_envelope_signature(
account_address,
0,
new_signer,
)
)
await client.execute_transaction(transaction)
# -------------------------------------------------------------------------
# Remove a contract from an account
# -------------------------------------------------------------------------
class RemoveContract(Example):
def __init__(self) -> None:
super().__init__(
tag="AC.4.",
name="Remove a Contract from the account - using the template",
sort_order=904,
)
async def run(self, ctx: Config):
# First Step : Create a client to connect to the flow blockchain
# flow_client function creates a client using the host and port
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
return a + b
}
}""",
}
contract_source_hex = bytes(contract["source"], "UTF-8").hex()
async with flow_client(
host=ctx.access_node_host, port=ctx.access_node_port
) as client:
account_address, _, new_signer = await random_account(
client=client, ctx=ctx
)
latest_block = await client.get_latest_block()
proposer = await client.get_account_at_latest_block(
address=account_address.bytes
)
contract_name = cadence.String(contract["Name"])
contract_code = cadence.String(contract_source_hex)
transaction = (
Tx(
code=TransactionTemplates.addAccountContractTemplate,
reference_block_id=latest_block.id,
payer=account_address,
proposal_key=ProposalKey(
key_address=account_address,
key_id=0,
key_sequence_number=proposer.keys[0].sequence_number,
),
)
.add_arguments(contract_name)
.add_arguments(contract_code)
.add_authorizers(account_address)
.with_envelope_signature(
account_address,
0,
new_signer,
)
)
await client.execute_transaction(transaction)
proposer.keys[0].sequence_number = proposer.keys[0].sequence_number + 1
# Delete the added contract from the account
latest_block = await client.get_latest_block()
transaction = (
Tx(
code=TransactionTemplates.removeAccountContractTemplate,
reference_block_id=latest_block.id,
payer=account_address,
proposal_key=ProposalKey(
key_address=account_address,
key_id=0,
key_sequence_number=proposer.keys[0].sequence_number,
),
)
.add_arguments(contract_name)
.add_authorizers(account_address)
.with_envelope_signature(
account_address,
0,
new_signer,
)
)
await client.execute_transaction(transaction)
| 38.754777
| 83
| 0.49133
| 1,060
| 12,169
| 5.365094
| 0.133019
| 0.076314
| 0.024618
| 0.033234
| 0.840162
| 0.808335
| 0.791454
| 0.746263
| 0.746263
| 0.720943
| 0
| 0.00733
| 0.394609
| 12,169
| 313
| 84
| 38.878594
| 0.764626
| 0.125401
| 0
| 0.670543
| 0
| 0
| 0.115109
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.015504
| false
| 0
| 0.011628
| 0
| 0.05814
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
3621d1078b93ff9b3a2cb7946032d5f76ec6e466
| 9,444
|
py
|
Python
|
tests/separate_reference_test.py
|
thoppe/NLPre
|
4e7be5b9db2f3053dfb1af7f5312d95191c95f24
|
[
"CC0-1.0"
] | 186
|
2017-04-01T15:38:53.000Z
|
2022-03-04T18:59:58.000Z
|
tests/separate_reference_test.py
|
thoppe/NLPre
|
4e7be5b9db2f3053dfb1af7f5312d95191c95f24
|
[
"CC0-1.0"
] | 98
|
2017-04-03T18:34:22.000Z
|
2019-11-15T17:36:02.000Z
|
tests/separate_reference_test.py
|
thoppe/NLPre
|
4e7be5b9db2f3053dfb1af7f5312d95191c95f24
|
[
"CC0-1.0"
] | 28
|
2017-09-25T11:35:30.000Z
|
2021-07-15T13:54:05.000Z
|
from nose.tools import *
from nlpre.separate_reference import separate_reference
class References_Test:
@classmethod
def setup_class(cls):
cls.parser = separate_reference()
cls.parser_with_ref = separate_reference(reference_token=True)
def number_test(self):
doc = "How is the treatment4 going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def number_in_parenthesis_test(self):
doc = "How is (the treatment4) going. Pretty well"
doc_right = "How is (the treatment) going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def number_with_letter_test(self):
doc = "How is the treatment4a going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def number_with_multiple_letter_test(self):
doc = "How is the treatment4a,b going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def number_reference_token_test(self):
doc = "How is the treatment4 going. Pretty well"
doc_right = "How is the treatment REF_4 going. Pretty well"
doc_new = self.parser_with_ref(doc)
assert_equal(doc_right, doc_new)
def reference_in_parenthesis_test(self):
doc = "key feature in Drosophila3-5 and elegans(7)."
doc_right = "key feature in Drosophila and elegans."
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def parenthetical_reference_in_parenthesis_test(self):
doc = "key feature in (Drosophila3-5 and elegans(7))."
doc_right = "key feature in (Drosophila and elegans)."
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def parenthetical_reference_in_parenthesis_tokens_test(self):
# BROKEN
doc = "key feature in (Drosophila3-5 and elegans(7))."
doc_right = "key feature in (Drosophila REF_3-5 and elegans REF_7)."
doc_new = self.parser_with_ref(doc)
assert_equal(doc_right, doc_new)
def standard_word_in_reference_in_parenthesis_test(self):
doc = "key feature in Drosophila3-5 and trees(7)."
doc_right = "key feature in Drosophila and trees."
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def standard_word_in_reference_in_parenthesis_token_test(self):
doc = "key feature in Drosophila3-5 and trees(7)."
doc_right = "key feature in Drosophila REF_3-5 and trees REF_7."
doc_new = self.parser_with_ref(doc)
assert_equal(doc_right, doc_new)
def parenthesis_with_dashes_test(self):
doc = "key feature in Drosophila3-5 and trees(7-11)."
doc_right = "key feature in Drosophila and trees."
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def parenthesis_with_dashes_period_test(self):
doc = "key feature in Drosophila3-5 and trees.(7-11) its super helpful."
doc_right = "key feature in Drosophila and trees. its super helpful."
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def parenthesis_with_dashes_period_token_test(self):
doc = "key feature in Drosophila3-5 and trees.(7-11) its super helpful."
doc_right = "key feature in Drosophila REF_3-5 and trees REF_7-11. its super helpful."
doc_new = self.parser_with_ref(doc)
assert_equal(doc_right, doc_new)
def bracket_test(self):
doc = (
"There are at least eight distinct types of modifications found "
"on histones (see the legend box on the top left of the "
"figure). Enzymes have been identified for acetylation,[2] "
"methylation,[3] demethylation,[4] phosphorylation,[5] "
"ubiquitination,[6] sumoylation,[7] ADP-ribosylation,[8] "
"deimination,[9][10] and proline isomerization.[11]"
)
doc_right = (
"There are at least eight distinct types of "
"modifications found on histones (see the legend box on "
"the top left of the figure). Enzymes have been "
"identified for acetylation, methylation, "
"demethylation, phosphorylation, ubiquitination, "
"sumoylation, ADP-ribosylation, "
"deimination, and proline isomerization."
)
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def word_that_begins_with_number_parenthetical_reference_test(self):
doc = "How is the 4XasdL(5) going. Pretty well"
doc_right = "How is the 4XasdL going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def period_one_number_test(self):
doc = "How is the treatment.5 pretty well"
doc_right = "How is the treatment. pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def period_one_number_in_parens_test(self):
doc = "How is (the treatment.5) pretty well"
doc_right = "How is (the treatment.) pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def dashed_word_period_one_number_test(self):
doc = "How is the treat-ment.5 pretty well"
doc_right = "How is the treat-ment. pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def dash_with_letters_period_test(self):
doc = "How is the treatment.4a-5 Pretty well"
doc_right = "How is the treatment. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def period_dash_test(self):
doc = "How is the treatment.4-5 pretty well"
doc_right = "How is the treatment. pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def period_dash_reference_token_test(self):
doc = "How is the treatment going.4-5 Pretty well"
doc_right = "How is the treatment going. REF_4-5 Pretty well"
doc_new = self.parser_with_ref(doc)
assert_equal(doc_right, doc_new)
def comma_dash_test(self):
doc = "How is the treatment,4-5 my man"
doc_right = "How is the treatment, my man"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def dash_test(self):
doc = "How is the treatment4-5 going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def dash_with_letters_test(self):
doc = "How is the treatment4a-5 going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def comma_test(self):
doc = "How is the treatment4,5 going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def multiple_comma_test(self):
doc = "How is the treatment4,5,35,24 going. Pretty well"
doc_right = "How is the treatment going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def multiple_comma_in_parens_test(self):
doc = "How is (the treatment4,5,35,24) going. Pretty well"
doc_right = "How is (the treatment) going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def chemical_dash_test(self):
doc = "How is the interlukin-1 going. Pretty well"
doc_right = "How is the interlukin-1 going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def word_that_should_end_with_number_test(self):
doc = "How is the XasdL1 going. Pretty well"
doc_right = "How is the XasdL1 going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def word_that_begins_with_number_test(self):
doc = "How is the 4XasdL going. Pretty well"
doc_right = "How is the 4XasdL going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def pattern_in_middle_of_word_test(self):
doc = "How is the CAMK2-2-dependent going. Pretty well"
doc_right = "How is the CAMK2-2-dependent going. Pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def non_word_with_reference_test(self):
doc = "How is the CVD.70-73 pretty well"
doc_right = "How is the CVD. pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def number_in_word_with_reference_test(self):
doc = "How is the CV3D.70-73 pretty well"
doc_right = "How is the CV3D. pretty well"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
def single_letter_false_positive_test(self):
doc = "In section A.3 we see that apple's are healthy"
doc_right = "In section A.3 we see that apple's are healthy"
doc_new = self.parser(doc)
assert_equal(doc_right, doc_new)
| 34.593407
| 94
| 0.657666
| 1,361
| 9,444
| 4.326231
| 0.104335
| 0.092391
| 0.065217
| 0.092391
| 0.891644
| 0.88553
| 0.879076
| 0.852412
| 0.805367
| 0.764946
| 0
| 0.01644
| 0.259318
| 9,444
| 272
| 95
| 34.720588
| 0.825304
| 0.000635
| 0
| 0.473958
| 0
| 0
| 0.354811
| 0
| 0
| 0
| 0
| 0
| 0.177083
| 1
| 0.182292
| false
| 0
| 0.010417
| 0
| 0.197917
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
362d6acb565b4b3fe7d06ed62f810b010af90183
| 258,346
|
py
|
Python
|
instances/passenger_demand/pas-20210422-1717-int1/33.py
|
LHcau/scheduling-shared-passenger-and-freight-transport-on-a-fixed-infrastructure
|
bba1e6af5bc8d9deaa2dc3b83f6fe9ddf15d2a11
|
[
"BSD-3-Clause"
] | null | null | null |
instances/passenger_demand/pas-20210422-1717-int1/33.py
|
LHcau/scheduling-shared-passenger-and-freight-transport-on-a-fixed-infrastructure
|
bba1e6af5bc8d9deaa2dc3b83f6fe9ddf15d2a11
|
[
"BSD-3-Clause"
] | null | null | null |
instances/passenger_demand/pas-20210422-1717-int1/33.py
|
LHcau/scheduling-shared-passenger-and-freight-transport-on-a-fixed-infrastructure
|
bba1e6af5bc8d9deaa2dc3b83f6fe9ddf15d2a11
|
[
"BSD-3-Clause"
] | null | null | null |
"""
PASSENGERS
"""
numPassengers = 19150
passenger_arriving = (
(4, 4, 3, 5, 7, 3, 0, 1, 1, 0, 1, 0, 0, 5, 4, 4, 2, 5, 3, 1, 0, 2, 1, 0, 1, 0), # 0
(6, 3, 4, 3, 2, 1, 2, 2, 2, 1, 1, 1, 0, 6, 2, 3, 4, 8, 0, 1, 0, 0, 2, 3, 0, 0), # 1
(7, 4, 5, 7, 5, 0, 1, 3, 0, 3, 1, 0, 0, 9, 2, 2, 7, 7, 3, 3, 2, 1, 1, 0, 0, 0), # 2
(3, 5, 4, 4, 2, 1, 2, 4, 1, 3, 2, 0, 0, 3, 8, 8, 2, 5, 6, 5, 1, 1, 1, 1, 0, 0), # 3
(5, 3, 3, 10, 3, 1, 6, 1, 6, 2, 1, 0, 0, 6, 5, 3, 5, 4, 4, 2, 1, 3, 2, 1, 0, 0), # 4
(6, 4, 8, 7, 1, 1, 2, 0, 2, 1, 0, 2, 0, 14, 5, 5, 2, 7, 1, 3, 1, 1, 2, 0, 0, 0), # 5
(3, 10, 9, 9, 7, 4, 3, 1, 2, 2, 0, 1, 0, 7, 4, 3, 5, 4, 6, 4, 3, 6, 2, 0, 1, 0), # 6
(8, 6, 3, 8, 6, 2, 4, 1, 4, 1, 1, 0, 0, 7, 8, 10, 3, 7, 1, 2, 2, 2, 1, 0, 1, 0), # 7
(6, 8, 4, 6, 7, 2, 6, 2, 4, 2, 1, 0, 0, 10, 9, 3, 2, 3, 3, 2, 6, 4, 5, 1, 0, 0), # 8
(6, 9, 12, 4, 5, 5, 1, 0, 0, 2, 2, 1, 0, 7, 4, 5, 6, 7, 5, 6, 2, 4, 3, 0, 2, 0), # 9
(8, 8, 6, 9, 6, 2, 6, 4, 1, 1, 0, 1, 0, 9, 6, 8, 4, 2, 4, 4, 2, 0, 2, 2, 0, 0), # 10
(8, 6, 3, 4, 6, 3, 6, 1, 10, 0, 2, 0, 0, 10, 7, 1, 4, 6, 9, 6, 4, 3, 1, 0, 0, 0), # 11
(11, 9, 11, 6, 6, 2, 2, 2, 3, 2, 1, 0, 0, 15, 12, 5, 7, 7, 4, 1, 1, 3, 4, 2, 2, 0), # 12
(8, 13, 8, 6, 2, 2, 4, 1, 1, 1, 1, 2, 0, 12, 13, 5, 5, 7, 5, 1, 5, 5, 4, 7, 0, 0), # 13
(10, 18, 8, 6, 6, 5, 0, 6, 1, 3, 0, 1, 0, 11, 4, 5, 3, 10, 5, 1, 3, 4, 1, 0, 1, 0), # 14
(11, 8, 5, 5, 6, 0, 5, 5, 2, 0, 0, 0, 0, 13, 9, 9, 3, 6, 6, 3, 6, 3, 1, 2, 1, 0), # 15
(8, 16, 4, 6, 6, 2, 5, 2, 0, 1, 1, 0, 0, 10, 11, 5, 5, 10, 5, 6, 2, 0, 2, 2, 1, 0), # 16
(8, 11, 7, 5, 7, 3, 5, 5, 4, 1, 2, 0, 0, 6, 8, 4, 10, 7, 5, 6, 3, 1, 4, 0, 3, 0), # 17
(13, 7, 13, 8, 8, 2, 4, 3, 3, 4, 4, 1, 0, 9, 6, 3, 6, 10, 5, 2, 5, 4, 0, 2, 1, 0), # 18
(7, 13, 5, 4, 9, 3, 5, 4, 2, 2, 1, 0, 0, 8, 11, 8, 5, 10, 4, 1, 1, 2, 4, 7, 0, 0), # 19
(10, 7, 5, 10, 3, 2, 3, 8, 4, 3, 1, 1, 0, 10, 7, 5, 4, 6, 5, 4, 2, 2, 1, 0, 1, 0), # 20
(8, 9, 5, 10, 10, 2, 3, 8, 5, 4, 0, 0, 0, 8, 9, 7, 6, 5, 7, 1, 2, 5, 2, 3, 0, 0), # 21
(6, 8, 6, 6, 2, 3, 2, 3, 4, 2, 0, 0, 0, 7, 8, 5, 4, 5, 10, 2, 1, 4, 6, 1, 1, 0), # 22
(9, 7, 7, 8, 9, 7, 2, 1, 4, 1, 2, 1, 0, 7, 14, 7, 8, 10, 3, 2, 5, 2, 2, 1, 0, 0), # 23
(14, 9, 11, 8, 3, 2, 8, 4, 2, 2, 2, 1, 0, 9, 8, 8, 4, 7, 4, 8, 1, 4, 6, 1, 1, 0), # 24
(7, 11, 4, 5, 8, 1, 4, 4, 5, 2, 1, 0, 0, 11, 11, 13, 4, 7, 9, 4, 2, 5, 2, 2, 0, 0), # 25
(10, 9, 6, 13, 8, 4, 2, 1, 4, 4, 1, 0, 0, 8, 8, 8, 5, 8, 5, 5, 6, 4, 2, 2, 0, 0), # 26
(4, 7, 6, 10, 14, 4, 3, 3, 5, 3, 2, 1, 0, 10, 6, 6, 4, 16, 2, 6, 5, 5, 3, 4, 1, 0), # 27
(14, 16, 9, 15, 4, 1, 4, 2, 3, 1, 6, 2, 0, 11, 5, 9, 2, 4, 10, 5, 7, 2, 1, 2, 1, 0), # 28
(11, 12, 5, 11, 8, 1, 7, 4, 8, 2, 3, 0, 0, 8, 7, 7, 7, 8, 2, 5, 2, 4, 4, 1, 1, 0), # 29
(21, 13, 10, 15, 3, 3, 3, 1, 1, 3, 1, 1, 0, 6, 11, 12, 8, 7, 4, 1, 2, 4, 5, 1, 1, 0), # 30
(10, 12, 13, 9, 5, 2, 2, 5, 3, 0, 2, 0, 0, 7, 14, 9, 5, 5, 10, 5, 0, 3, 2, 1, 0, 0), # 31
(14, 7, 6, 6, 12, 4, 2, 5, 6, 5, 2, 0, 0, 8, 9, 6, 6, 8, 1, 6, 2, 6, 4, 1, 0, 0), # 32
(17, 18, 7, 6, 8, 5, 7, 1, 1, 4, 0, 1, 0, 7, 9, 6, 8, 3, 2, 6, 1, 2, 1, 3, 2, 0), # 33
(13, 14, 12, 13, 5, 4, 5, 5, 4, 2, 5, 1, 0, 11, 11, 6, 10, 7, 11, 4, 4, 5, 5, 2, 0, 0), # 34
(10, 8, 15, 11, 6, 1, 2, 4, 1, 1, 1, 1, 0, 5, 4, 8, 6, 7, 3, 2, 6, 2, 1, 3, 0, 0), # 35
(7, 9, 6, 10, 10, 2, 6, 7, 6, 0, 0, 1, 0, 15, 11, 9, 5, 9, 6, 8, 4, 6, 2, 0, 1, 0), # 36
(9, 13, 4, 4, 7, 2, 4, 0, 6, 1, 1, 1, 0, 7, 7, 12, 7, 10, 5, 3, 0, 3, 4, 4, 1, 0), # 37
(11, 10, 8, 9, 7, 5, 5, 4, 5, 3, 1, 1, 0, 17, 12, 7, 7, 9, 3, 7, 3, 0, 1, 2, 0, 0), # 38
(11, 12, 17, 6, 9, 6, 0, 3, 5, 0, 1, 0, 0, 8, 9, 8, 3, 12, 3, 4, 1, 4, 2, 3, 2, 0), # 39
(16, 11, 14, 6, 5, 2, 0, 4, 3, 0, 0, 2, 0, 11, 12, 8, 7, 12, 2, 5, 3, 4, 2, 2, 0, 0), # 40
(5, 10, 3, 12, 9, 1, 6, 2, 4, 1, 1, 2, 0, 15, 11, 12, 4, 6, 8, 3, 2, 3, 1, 0, 2, 0), # 41
(12, 9, 4, 9, 12, 6, 5, 3, 3, 2, 2, 0, 0, 11, 11, 3, 4, 6, 1, 1, 0, 0, 2, 1, 0, 0), # 42
(12, 12, 10, 8, 6, 4, 4, 4, 5, 3, 1, 1, 0, 8, 15, 4, 5, 8, 5, 3, 2, 1, 1, 0, 2, 0), # 43
(14, 11, 6, 7, 11, 6, 3, 6, 4, 0, 1, 1, 0, 10, 11, 5, 4, 4, 4, 3, 4, 3, 2, 1, 0, 0), # 44
(15, 13, 7, 9, 7, 1, 1, 4, 3, 2, 3, 1, 0, 7, 10, 5, 2, 2, 3, 3, 0, 3, 1, 1, 0, 0), # 45
(10, 6, 7, 7, 6, 2, 3, 5, 5, 1, 0, 1, 0, 17, 4, 7, 8, 7, 9, 2, 2, 5, 3, 3, 4, 0), # 46
(15, 14, 12, 7, 9, 2, 5, 5, 4, 3, 1, 0, 0, 10, 6, 6, 6, 7, 2, 6, 2, 9, 3, 1, 0, 0), # 47
(11, 8, 8, 4, 4, 5, 4, 8, 7, 2, 2, 3, 0, 9, 8, 9, 3, 6, 7, 1, 2, 4, 3, 1, 1, 0), # 48
(6, 6, 4, 9, 6, 3, 2, 3, 9, 5, 1, 1, 0, 6, 14, 6, 8, 11, 6, 5, 4, 5, 2, 4, 0, 0), # 49
(7, 16, 10, 12, 7, 0, 2, 3, 6, 6, 3, 2, 0, 10, 3, 6, 4, 9, 4, 5, 1, 8, 4, 1, 1, 0), # 50
(4, 10, 8, 10, 7, 1, 6, 4, 2, 5, 2, 2, 0, 20, 9, 5, 3, 8, 4, 6, 2, 3, 3, 1, 1, 0), # 51
(12, 8, 6, 5, 7, 4, 0, 4, 2, 2, 1, 0, 0, 11, 10, 14, 8, 10, 4, 6, 2, 5, 4, 3, 2, 0), # 52
(9, 9, 7, 6, 10, 3, 0, 6, 4, 2, 1, 1, 0, 8, 18, 3, 4, 14, 2, 6, 1, 6, 3, 1, 4, 0), # 53
(3, 8, 14, 10, 13, 0, 0, 5, 7, 2, 1, 1, 0, 9, 9, 15, 3, 10, 5, 1, 2, 4, 2, 3, 1, 0), # 54
(16, 9, 15, 3, 12, 7, 6, 4, 7, 3, 2, 0, 0, 5, 14, 7, 2, 10, 3, 4, 3, 3, 2, 2, 1, 0), # 55
(14, 8, 8, 8, 7, 1, 5, 2, 6, 3, 4, 2, 0, 16, 10, 7, 8, 7, 7, 7, 1, 2, 2, 2, 0, 0), # 56
(14, 7, 5, 12, 7, 5, 3, 2, 2, 2, 2, 1, 0, 10, 6, 6, 5, 6, 7, 2, 4, 1, 7, 0, 1, 0), # 57
(4, 12, 5, 10, 5, 3, 3, 4, 2, 2, 1, 0, 0, 6, 8, 7, 8, 10, 5, 5, 1, 2, 4, 1, 1, 0), # 58
(8, 11, 6, 7, 9, 0, 2, 2, 4, 3, 1, 2, 0, 9, 9, 7, 8, 6, 9, 5, 1, 5, 3, 2, 0, 0), # 59
(8, 4, 8, 17, 3, 3, 2, 4, 3, 4, 2, 1, 0, 8, 5, 4, 7, 6, 4, 2, 2, 2, 5, 2, 1, 0), # 60
(8, 9, 5, 14, 6, 1, 10, 7, 3, 3, 4, 1, 0, 12, 11, 5, 8, 10, 3, 2, 2, 6, 4, 1, 1, 0), # 61
(7, 9, 8, 7, 6, 7, 5, 2, 7, 1, 3, 0, 0, 13, 6, 8, 2, 6, 6, 5, 2, 2, 4, 4, 2, 0), # 62
(14, 16, 9, 7, 11, 3, 3, 2, 4, 1, 0, 1, 0, 12, 9, 7, 7, 8, 2, 2, 3, 6, 2, 2, 1, 0), # 63
(7, 10, 13, 9, 3, 9, 6, 4, 2, 0, 1, 2, 0, 15, 6, 9, 2, 5, 4, 4, 1, 5, 6, 0, 0, 0), # 64
(12, 4, 8, 11, 8, 2, 7, 5, 2, 2, 1, 0, 0, 14, 6, 6, 1, 8, 4, 0, 3, 2, 0, 0, 2, 0), # 65
(3, 14, 6, 5, 4, 4, 4, 2, 2, 2, 1, 0, 0, 15, 9, 7, 7, 8, 6, 4, 7, 8, 4, 0, 0, 0), # 66
(7, 15, 8, 12, 8, 6, 4, 2, 2, 3, 2, 1, 0, 19, 6, 10, 5, 15, 5, 1, 1, 4, 1, 2, 0, 0), # 67
(6, 5, 8, 5, 5, 5, 4, 1, 3, 2, 0, 1, 0, 8, 12, 3, 7, 6, 1, 1, 4, 5, 1, 2, 0, 0), # 68
(11, 13, 11, 11, 5, 2, 4, 3, 3, 0, 2, 0, 0, 6, 16, 9, 6, 7, 1, 3, 2, 1, 5, 1, 0, 0), # 69
(11, 4, 4, 12, 5, 5, 3, 4, 5, 0, 2, 0, 0, 8, 5, 8, 6, 5, 3, 7, 5, 1, 4, 3, 1, 0), # 70
(17, 15, 6, 6, 12, 2, 4, 1, 1, 0, 1, 1, 0, 5, 10, 3, 5, 7, 0, 2, 3, 3, 4, 2, 0, 0), # 71
(14, 10, 13, 6, 9, 3, 3, 0, 3, 1, 2, 1, 0, 10, 7, 7, 8, 6, 1, 3, 5, 2, 4, 2, 2, 0), # 72
(11, 11, 13, 7, 6, 5, 2, 2, 3, 3, 0, 0, 0, 17, 9, 4, 4, 8, 5, 4, 1, 1, 1, 2, 1, 0), # 73
(11, 7, 4, 11, 9, 4, 5, 1, 6, 0, 4, 1, 0, 14, 3, 4, 3, 9, 4, 5, 4, 13, 4, 4, 0, 0), # 74
(10, 5, 5, 10, 6, 4, 0, 5, 6, 2, 1, 2, 0, 15, 7, 7, 5, 8, 6, 6, 5, 2, 4, 1, 0, 0), # 75
(9, 9, 13, 9, 4, 7, 6, 3, 4, 4, 1, 2, 0, 10, 10, 4, 7, 10, 3, 3, 0, 3, 5, 4, 2, 0), # 76
(12, 6, 8, 10, 7, 3, 3, 10, 1, 1, 1, 0, 0, 12, 12, 6, 4, 9, 3, 6, 2, 3, 1, 2, 2, 0), # 77
(11, 8, 6, 7, 9, 4, 4, 0, 4, 1, 1, 0, 0, 11, 13, 2, 3, 5, 6, 3, 2, 2, 3, 0, 0, 0), # 78
(12, 6, 12, 18, 11, 6, 0, 4, 5, 1, 1, 2, 0, 8, 10, 7, 3, 9, 2, 7, 4, 4, 2, 0, 2, 0), # 79
(10, 10, 11, 6, 7, 4, 6, 2, 3, 1, 3, 3, 0, 10, 11, 8, 6, 2, 2, 6, 4, 0, 4, 3, 1, 0), # 80
(20, 9, 7, 8, 4, 4, 3, 6, 4, 5, 0, 0, 0, 9, 7, 7, 6, 11, 8, 5, 0, 2, 4, 0, 0, 0), # 81
(9, 9, 11, 6, 6, 5, 2, 3, 3, 2, 2, 2, 0, 10, 14, 8, 3, 12, 9, 2, 3, 2, 4, 1, 1, 0), # 82
(11, 4, 7, 11, 13, 8, 3, 1, 1, 0, 1, 2, 0, 8, 6, 4, 10, 7, 8, 8, 1, 4, 4, 1, 1, 0), # 83
(10, 9, 16, 9, 7, 6, 4, 2, 0, 2, 0, 1, 0, 9, 7, 5, 4, 5, 5, 3, 3, 5, 7, 2, 1, 0), # 84
(8, 5, 12, 10, 8, 3, 4, 3, 4, 0, 3, 0, 0, 13, 14, 3, 4, 5, 4, 2, 1, 3, 6, 2, 0, 0), # 85
(11, 12, 9, 12, 10, 1, 5, 4, 3, 0, 0, 0, 0, 12, 5, 6, 4, 3, 5, 3, 1, 4, 6, 1, 1, 0), # 86
(11, 7, 6, 10, 2, 3, 4, 6, 3, 7, 0, 0, 0, 5, 9, 6, 6, 13, 3, 4, 6, 4, 9, 4, 0, 0), # 87
(10, 11, 9, 8, 11, 6, 2, 0, 2, 1, 1, 0, 0, 9, 5, 3, 5, 9, 2, 6, 1, 5, 5, 0, 0, 0), # 88
(14, 8, 7, 8, 3, 2, 5, 2, 5, 3, 0, 0, 0, 9, 8, 8, 3, 9, 5, 0, 1, 2, 2, 1, 1, 0), # 89
(5, 12, 8, 2, 5, 1, 5, 2, 6, 1, 0, 0, 0, 9, 7, 2, 7, 9, 4, 4, 1, 3, 1, 0, 0, 0), # 90
(6, 8, 8, 10, 2, 4, 4, 4, 2, 3, 4, 0, 0, 5, 11, 9, 3, 6, 5, 2, 0, 3, 7, 1, 1, 0), # 91
(4, 4, 4, 9, 5, 0, 5, 8, 6, 2, 2, 1, 0, 3, 8, 4, 6, 7, 3, 6, 2, 4, 4, 0, 0, 0), # 92
(7, 14, 6, 17, 6, 6, 4, 5, 7, 0, 3, 0, 0, 17, 9, 6, 7, 6, 4, 2, 1, 5, 2, 2, 1, 0), # 93
(8, 7, 7, 10, 3, 4, 1, 4, 3, 2, 1, 1, 0, 9, 3, 7, 9, 8, 7, 3, 3, 4, 2, 5, 1, 0), # 94
(9, 7, 2, 6, 9, 2, 0, 2, 4, 1, 0, 0, 0, 10, 7, 13, 5, 7, 2, 4, 1, 3, 7, 2, 0, 0), # 95
(14, 6, 3, 16, 5, 3, 3, 3, 1, 0, 2, 1, 0, 8, 4, 8, 8, 12, 2, 3, 2, 2, 0, 1, 1, 0), # 96
(9, 9, 6, 9, 7, 4, 6, 3, 9, 2, 1, 1, 0, 8, 5, 5, 6, 9, 5, 2, 5, 3, 7, 3, 0, 0), # 97
(11, 9, 2, 8, 5, 4, 1, 2, 3, 1, 0, 3, 0, 11, 12, 8, 8, 3, 3, 5, 2, 4, 0, 2, 1, 0), # 98
(4, 11, 6, 10, 9, 1, 2, 0, 5, 2, 0, 0, 0, 12, 8, 8, 4, 6, 2, 5, 1, 0, 2, 1, 1, 0), # 99
(7, 6, 8, 13, 8, 4, 4, 2, 5, 3, 0, 1, 0, 13, 14, 10, 2, 9, 2, 3, 3, 6, 2, 2, 0, 0), # 100
(16, 7, 11, 12, 10, 4, 3, 2, 13, 0, 2, 0, 0, 8, 11, 5, 1, 8, 3, 4, 1, 3, 2, 0, 1, 0), # 101
(8, 7, 6, 10, 7, 4, 3, 1, 0, 3, 2, 0, 0, 12, 3, 6, 5, 8, 1, 4, 9, 1, 1, 0, 0, 0), # 102
(16, 3, 10, 8, 7, 0, 2, 3, 5, 3, 0, 0, 0, 12, 10, 4, 6, 5, 3, 0, 7, 4, 4, 6, 0, 0), # 103
(10, 11, 8, 4, 6, 4, 0, 2, 2, 1, 1, 2, 0, 9, 7, 7, 8, 3, 8, 3, 1, 1, 3, 0, 0, 0), # 104
(9, 9, 6, 10, 6, 3, 2, 1, 4, 1, 1, 2, 0, 12, 8, 5, 2, 7, 4, 2, 4, 1, 3, 2, 0, 0), # 105
(6, 8, 10, 11, 5, 2, 5, 2, 4, 2, 0, 0, 0, 8, 7, 7, 1, 7, 3, 7, 5, 6, 2, 0, 1, 0), # 106
(12, 10, 7, 9, 9, 3, 5, 2, 4, 3, 1, 1, 0, 7, 4, 6, 6, 8, 7, 4, 2, 4, 5, 1, 0, 0), # 107
(5, 10, 14, 11, 8, 3, 1, 3, 1, 3, 3, 0, 0, 13, 9, 2, 1, 12, 7, 4, 2, 5, 2, 1, 0, 0), # 108
(15, 5, 14, 12, 7, 2, 4, 2, 3, 2, 1, 0, 0, 10, 9, 12, 3, 5, 0, 1, 5, 3, 2, 1, 1, 0), # 109
(14, 13, 8, 6, 6, 7, 4, 0, 8, 1, 1, 0, 0, 6, 4, 8, 8, 6, 3, 3, 1, 4, 3, 2, 1, 0), # 110
(14, 3, 7, 9, 8, 2, 2, 2, 2, 1, 1, 0, 0, 9, 11, 7, 4, 4, 3, 0, 6, 3, 4, 3, 0, 0), # 111
(9, 6, 11, 10, 5, 0, 3, 1, 3, 1, 2, 1, 0, 10, 12, 4, 10, 4, 4, 4, 4, 4, 3, 0, 0, 0), # 112
(13, 14, 13, 4, 10, 4, 1, 1, 3, 1, 1, 0, 0, 12, 6, 6, 6, 9, 4, 4, 2, 5, 1, 0, 0, 0), # 113
(10, 8, 10, 9, 8, 4, 2, 4, 5, 0, 0, 1, 0, 10, 7, 5, 5, 6, 4, 4, 1, 3, 8, 1, 0, 0), # 114
(8, 13, 8, 12, 3, 3, 1, 0, 4, 2, 2, 1, 0, 16, 8, 4, 2, 6, 2, 1, 4, 2, 4, 2, 0, 0), # 115
(6, 7, 5, 13, 8, 4, 2, 3, 9, 0, 0, 0, 0, 10, 6, 7, 2, 11, 1, 2, 4, 4, 1, 1, 0, 0), # 116
(12, 13, 8, 4, 7, 7, 2, 3, 3, 1, 1, 2, 0, 3, 8, 4, 4, 8, 4, 4, 5, 2, 7, 3, 0, 0), # 117
(6, 7, 6, 6, 4, 1, 4, 1, 3, 1, 0, 1, 0, 11, 7, 8, 2, 10, 2, 2, 5, 4, 3, 1, 0, 0), # 118
(10, 7, 10, 6, 9, 6, 4, 1, 3, 1, 2, 2, 0, 9, 9, 5, 4, 10, 5, 2, 4, 5, 3, 0, 0, 0), # 119
(7, 8, 5, 10, 2, 2, 2, 3, 5, 0, 2, 1, 0, 10, 6, 3, 5, 8, 2, 5, 5, 5, 3, 3, 1, 0), # 120
(9, 10, 3, 9, 9, 2, 5, 3, 1, 2, 0, 1, 0, 4, 11, 6, 6, 3, 4, 2, 1, 2, 3, 2, 0, 0), # 121
(4, 9, 6, 9, 5, 4, 1, 6, 8, 2, 0, 1, 0, 12, 7, 8, 2, 7, 3, 4, 1, 4, 3, 1, 2, 0), # 122
(12, 3, 8, 8, 13, 1, 0, 3, 2, 0, 1, 0, 0, 12, 7, 6, 1, 7, 5, 2, 1, 3, 3, 1, 1, 0), # 123
(14, 6, 11, 7, 9, 3, 2, 2, 7, 0, 0, 0, 0, 13, 8, 4, 3, 8, 7, 2, 4, 2, 3, 1, 0, 0), # 124
(10, 3, 8, 10, 6, 4, 3, 2, 4, 3, 0, 0, 0, 14, 7, 7, 2, 5, 3, 3, 2, 3, 3, 1, 0, 0), # 125
(14, 9, 11, 8, 5, 5, 4, 0, 6, 0, 0, 0, 0, 6, 4, 10, 3, 4, 5, 4, 2, 3, 0, 1, 1, 0), # 126
(5, 9, 13, 7, 7, 2, 3, 3, 1, 2, 3, 1, 0, 11, 11, 8, 3, 9, 5, 4, 1, 3, 2, 2, 0, 0), # 127
(9, 8, 9, 6, 6, 8, 3, 1, 6, 2, 2, 0, 0, 9, 4, 6, 2, 11, 0, 4, 2, 4, 1, 2, 1, 0), # 128
(9, 6, 11, 6, 4, 6, 0, 2, 3, 1, 2, 2, 0, 9, 10, 7, 1, 4, 3, 4, 3, 5, 4, 1, 1, 0), # 129
(8, 14, 10, 5, 7, 3, 3, 3, 2, 0, 0, 3, 0, 4, 7, 6, 6, 6, 2, 5, 0, 1, 3, 0, 2, 0), # 130
(8, 5, 5, 5, 8, 5, 3, 3, 2, 1, 0, 1, 0, 9, 4, 7, 5, 6, 5, 4, 1, 3, 4, 2, 0, 0), # 131
(6, 7, 10, 7, 4, 0, 4, 4, 5, 2, 3, 0, 0, 11, 6, 4, 3, 7, 3, 4, 1, 4, 3, 3, 2, 0), # 132
(8, 8, 8, 5, 7, 5, 0, 0, 2, 3, 1, 2, 0, 9, 10, 3, 3, 3, 3, 7, 3, 2, 1, 0, 1, 0), # 133
(5, 3, 10, 7, 7, 5, 4, 2, 3, 2, 1, 1, 0, 8, 5, 7, 2, 7, 2, 5, 2, 2, 6, 2, 0, 0), # 134
(13, 3, 8, 11, 3, 3, 2, 1, 3, 0, 1, 0, 0, 15, 15, 4, 4, 9, 2, 7, 0, 2, 1, 6, 1, 0), # 135
(10, 8, 12, 10, 6, 3, 2, 2, 4, 2, 0, 0, 0, 8, 6, 8, 3, 3, 2, 4, 4, 1, 3, 2, 2, 0), # 136
(13, 6, 3, 11, 2, 3, 5, 4, 2, 0, 1, 1, 0, 9, 7, 4, 5, 6, 7, 2, 4, 6, 4, 3, 1, 0), # 137
(6, 14, 3, 5, 6, 2, 4, 3, 5, 5, 0, 0, 0, 12, 5, 4, 8, 4, 4, 3, 2, 2, 1, 1, 0, 0), # 138
(6, 11, 6, 10, 6, 6, 5, 3, 3, 1, 1, 0, 0, 7, 7, 2, 3, 5, 2, 4, 3, 6, 1, 0, 2, 0), # 139
(6, 10, 9, 4, 6, 2, 2, 1, 2, 2, 0, 2, 0, 14, 7, 6, 2, 3, 6, 1, 1, 4, 4, 4, 0, 0), # 140
(3, 10, 11, 7, 4, 0, 4, 1, 3, 0, 0, 1, 0, 6, 15, 7, 2, 8, 4, 2, 0, 2, 2, 2, 0, 0), # 141
(11, 10, 7, 7, 10, 2, 3, 5, 2, 2, 1, 3, 0, 14, 11, 6, 4, 6, 5, 1, 1, 4, 3, 3, 2, 0), # 142
(5, 10, 7, 7, 5, 4, 1, 1, 4, 1, 1, 0, 0, 3, 8, 6, 1, 3, 4, 4, 2, 5, 3, 1, 1, 0), # 143
(14, 7, 12, 10, 7, 4, 3, 1, 2, 1, 0, 0, 0, 14, 9, 8, 4, 6, 3, 2, 7, 4, 0, 1, 0, 0), # 144
(4, 2, 12, 10, 12, 3, 3, 0, 6, 2, 0, 0, 0, 8, 14, 4, 4, 5, 4, 4, 0, 3, 2, 0, 0, 0), # 145
(6, 10, 1, 5, 7, 3, 2, 2, 4, 1, 3, 0, 0, 11, 6, 3, 2, 6, 3, 1, 1, 6, 4, 3, 0, 0), # 146
(9, 3, 5, 7, 2, 5, 4, 2, 9, 2, 0, 0, 0, 9, 10, 2, 6, 9, 4, 2, 1, 4, 2, 2, 0, 0), # 147
(9, 0, 6, 1, 3, 1, 3, 1, 4, 2, 1, 0, 0, 8, 4, 2, 5, 7, 6, 3, 1, 3, 2, 1, 1, 0), # 148
(11, 9, 10, 11, 3, 3, 2, 2, 1, 1, 2, 0, 0, 11, 5, 2, 6, 10, 2, 4, 1, 0, 2, 1, 0, 0), # 149
(8, 6, 7, 8, 6, 2, 1, 2, 4, 1, 2, 0, 0, 10, 1, 7, 4, 6, 2, 2, 6, 6, 2, 3, 0, 0), # 150
(5, 9, 8, 5, 0, 2, 4, 2, 2, 1, 1, 1, 0, 7, 13, 2, 6, 7, 3, 2, 1, 2, 2, 2, 0, 0), # 151
(15, 7, 3, 9, 7, 4, 3, 0, 4, 0, 0, 0, 0, 3, 8, 6, 3, 10, 3, 2, 2, 2, 1, 3, 0, 0), # 152
(10, 8, 4, 6, 4, 2, 1, 2, 2, 2, 1, 0, 0, 6, 10, 2, 4, 3, 2, 2, 3, 1, 1, 1, 0, 0), # 153
(5, 4, 6, 5, 9, 0, 3, 3, 1, 0, 3, 0, 0, 8, 6, 7, 5, 10, 2, 3, 5, 2, 2, 2, 1, 0), # 154
(14, 4, 1, 6, 5, 1, 2, 1, 5, 3, 1, 1, 0, 6, 12, 3, 4, 10, 0, 1, 3, 5, 4, 1, 0, 0), # 155
(13, 7, 6, 7, 7, 7, 4, 1, 0, 2, 0, 1, 0, 10, 7, 3, 2, 4, 1, 1, 5, 3, 1, 2, 0, 0), # 156
(9, 4, 5, 6, 4, 8, 0, 1, 3, 5, 1, 1, 0, 11, 4, 13, 0, 8, 0, 3, 4, 4, 3, 1, 0, 0), # 157
(6, 2, 3, 10, 6, 3, 1, 2, 4, 3, 1, 0, 0, 12, 5, 5, 3, 5, 2, 3, 1, 3, 0, 2, 1, 0), # 158
(8, 4, 9, 7, 9, 0, 1, 1, 1, 2, 1, 1, 0, 8, 3, 8, 5, 6, 0, 0, 1, 1, 2, 0, 1, 0), # 159
(4, 5, 4, 8, 3, 5, 0, 2, 2, 0, 1, 0, 0, 8, 8, 7, 5, 5, 2, 6, 5, 1, 0, 1, 0, 0), # 160
(9, 4, 7, 10, 8, 5, 4, 6, 2, 0, 1, 0, 0, 5, 6, 3, 3, 2, 3, 1, 3, 1, 1, 0, 1, 0), # 161
(7, 4, 5, 4, 3, 2, 2, 5, 4, 2, 1, 0, 0, 12, 4, 3, 1, 5, 3, 1, 2, 5, 0, 1, 0, 0), # 162
(2, 4, 8, 5, 10, 4, 3, 1, 1, 0, 1, 1, 0, 8, 3, 2, 7, 6, 1, 2, 2, 2, 1, 0, 0, 0), # 163
(6, 7, 5, 4, 5, 3, 2, 1, 4, 3, 2, 1, 0, 8, 6, 9, 5, 9, 1, 4, 2, 3, 0, 1, 0, 0), # 164
(5, 4, 9, 8, 9, 2, 2, 0, 0, 2, 0, 0, 0, 11, 6, 4, 5, 5, 5, 2, 2, 3, 2, 1, 0, 0), # 165
(2, 2, 7, 8, 5, 2, 3, 1, 1, 0, 0, 0, 0, 11, 3, 4, 3, 5, 1, 3, 1, 2, 0, 3, 1, 0), # 166
(9, 2, 6, 6, 3, 1, 3, 0, 1, 0, 1, 0, 0, 6, 9, 5, 4, 3, 4, 2, 3, 3, 2, 1, 0, 0), # 167
(9, 1, 5, 7, 4, 4, 2, 1, 4, 1, 1, 0, 0, 4, 5, 2, 2, 4, 0, 2, 3, 2, 4, 3, 0, 0), # 168
(7, 3, 2, 10, 1, 2, 0, 3, 1, 0, 0, 1, 0, 10, 3, 2, 3, 5, 6, 1, 0, 3, 1, 2, 1, 0), # 169
(5, 4, 4, 5, 6, 3, 1, 0, 0, 2, 2, 1, 0, 6, 6, 6, 1, 6, 1, 2, 2, 1, 0, 2, 0, 0), # 170
(9, 2, 3, 7, 5, 3, 1, 4, 6, 0, 0, 0, 0, 4, 9, 2, 3, 7, 4, 1, 2, 3, 2, 0, 1, 0), # 171
(5, 3, 5, 7, 7, 1, 0, 3, 4, 1, 3, 3, 0, 10, 4, 1, 2, 6, 0, 1, 3, 2, 2, 0, 1, 0), # 172
(6, 1, 1, 6, 1, 1, 1, 1, 1, 0, 2, 1, 0, 7, 5, 2, 3, 4, 0, 2, 1, 2, 2, 1, 0, 0), # 173
(5, 4, 2, 5, 4, 2, 0, 2, 3, 0, 0, 0, 0, 14, 2, 5, 2, 2, 3, 2, 1, 1, 0, 1, 0, 0), # 174
(7, 5, 5, 2, 11, 3, 2, 3, 6, 1, 1, 0, 0, 5, 5, 4, 5, 2, 2, 0, 1, 4, 3, 0, 0, 0), # 175
(2, 2, 4, 2, 2, 1, 3, 3, 2, 0, 1, 0, 0, 7, 4, 2, 3, 3, 3, 1, 0, 3, 3, 0, 0, 0), # 176
(2, 4, 8, 3, 6, 0, 2, 3, 1, 3, 1, 0, 0, 2, 2, 6, 2, 2, 1, 3, 1, 2, 1, 1, 0, 0), # 177
(3, 7, 4, 3, 3, 2, 2, 3, 2, 0, 2, 0, 0, 3, 2, 0, 1, 4, 0, 3, 1, 3, 0, 1, 0, 0), # 178
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 179
)
station_arriving_intensity = (
(5.020865578371768, 5.525288559693166, 5.211283229612507, 6.214667773863432, 5.554685607609612, 3.1386549320373387, 4.146035615373915, 4.653176172979423, 6.090099062168007, 3.9580150155223697, 4.205265163885603, 4.897915078306173, 5.083880212578363), # 0
(5.354327152019974, 5.890060694144759, 5.555346591330152, 6.625144253276616, 5.922490337474237, 3.3459835840425556, 4.419468941263694, 4.959513722905708, 6.492245326332909, 4.21898069227715, 4.483096135956131, 5.221216660814354, 5.419791647439855), # 1
(5.686723008979731, 6.253385170890979, 5.8980422855474135, 7.033987704664794, 6.288962973749744, 3.5524851145124448, 4.691818507960704, 5.264625247904419, 6.892786806877549, 4.478913775020546, 4.759823148776313, 5.543232652053055, 5.75436482820969), # 2
(6.016757793146562, 6.613820501936447, 6.238010869319854, 7.439576407532074, 6.652661676001902, 3.757340622585113, 4.962003641647955, 5.567301157494507, 7.290135160921093, 4.736782698426181, 5.0343484118273825, 5.862685684930461, 6.086272806254225), # 3
(6.343136148415981, 6.9699251992857745, 6.573892899703036, 7.840288641382569, 7.012144603796492, 3.9597312073986677, 5.2289436685084585, 5.866331861194915, 7.682702045582707, 4.991555897167679, 5.305574134590575, 6.178298392354764, 6.414188632939817), # 4
(6.66456271868351, 7.320257774943588, 6.9043289337525175, 8.234502685720393, 7.36596991669928, 4.158837968091214, 5.491557914725224, 6.160507768524592, 8.068899117981559, 5.242201805918663, 5.572402526547132, 6.488793407234148, 6.736785359632827), # 5
(6.979742147844666, 7.663376740914501, 7.227959528523866, 8.620596820049652, 7.712695774276043, 4.353842003800864, 5.7487657064812625, 6.4486192890024885, 8.447138035236815, 5.487688859352758, 5.833735797178282, 6.792893362476808, 7.052736037699606), # 6
(7.2873790797949685, 7.997840609203132, 7.543425241072635, 8.996949323874462, 8.050880336092554, 4.543924413665721, 5.999486369959585, 6.729456832147552, 8.815830454467644, 5.726985492143586, 6.088476155965268, 7.089320890990929, 7.360713718506519), # 7
(7.586178158429934, 8.322207891814099, 7.849366628454396, 9.361938476698928, 8.379081761714586, 4.7282662968238895, 6.2426392313431975, 7.001810807478725, 9.173388032793206, 5.959060138964774, 6.335525812389321, 7.376798625684702, 7.659391453419917), # 8
(7.874844027645085, 8.635037100752022, 8.144424247724704, 9.713942558027169, 8.69585821070791, 4.906048752413484, 6.47714361681512, 7.264471624514963, 9.518222427332674, 6.182881234489941, 6.573786975931678, 7.654049199466313, 7.947442293806162), # 9
(8.152081331335932, 8.934886748021516, 8.427238655939124, 10.051339847363288, 8.9997678426383, 5.076452879572607, 6.701918852558355, 7.516229692775211, 9.848745295205214, 6.397417213392714, 6.802161856073574, 7.919795245243952, 8.22353929103161), # 10
(8.416594713398005, 9.220315345627206, 8.696450410153215, 10.372508624211397, 9.289368817071534, 5.238659777439368, 6.915884264755916, 7.7558754217784145, 10.163368293529993, 6.601636510346719, 7.019552662296249, 8.17275939592581, 8.486355496462611), # 11
(8.667088817726812, 9.489881405573698, 8.95070006742254, 10.675827168075612, 9.563219293573377, 5.391850545151869, 7.1179591795908115, 7.982199221043521, 10.460503079426179, 6.794507560025572, 7.224861604080934, 8.411664284420068, 8.734563961465534), # 12
(8.902268288217876, 9.74214343986562, 9.188628184802662, 10.959673758460044, 9.819877431709601, 5.5352062818482235, 7.307062923246056, 8.193991500089481, 10.738561310012932, 6.974998797102904, 7.416990890908869, 8.63523254363492, 8.966837737406735), # 13
(9.120837768766716, 9.975659960507588, 9.408875319349146, 11.222426674868792, 10.05790139104599, 5.667908086666534, 7.482114821904661, 8.390042668435246, 10.995954642409421, 7.142078656252334, 7.594842732261284, 8.84218680647856, 9.181849875652563), # 14
(9.321501903268855, 10.188989479504217, 9.610082028117542, 11.462464196805985, 10.275849331148308, 5.789137058744912, 7.642034201749626, 8.569143135599756, 11.23109473373482, 7.29471557214749, 7.757319337619419, 9.031249705859171, 9.37827342756938), # 15
(9.5029653356198, 10.380690508860132, 9.790888868163425, 11.678164603775716, 10.472279411582333, 5.898074297221459, 7.785740388963976, 8.73008331110196, 11.442393241108286, 7.431877979461996, 7.9033229164645125, 9.20114387468494, 9.554781444523545), # 16
(9.663932709715075, 10.549321560579946, 9.949936396542352, 11.867906175282112, 10.645749791913838, 5.993900901234285, 7.9121527097307105, 8.871653604460818, 11.628261821648984, 7.552534312869467, 8.031755678277799, 9.350591945864055, 9.710046977881415), # 17
(9.803108669450204, 10.693441146668274, 10.08586517030988, 12.030067190829278, 10.794818631708589, 6.075797969921503, 8.020190490232851, 8.99264442519526, 11.787112132476096, 7.6556530070435365, 8.141519832540508, 9.478316552304715, 9.842743079009345), # 18
(9.919197858720699, 10.811607779129744, 10.197315746521578, 12.163025929921314, 10.918044090532366, 6.142946602421208, 8.108773056653394, 9.091846182824245, 11.917355830708779, 7.740202496657828, 8.231517588733878, 9.583040326915096, 9.951542799273696), # 19
(10.010904921422082, 10.902379969968962, 10.282928682233003, 12.265160672062354, 11.013984327950944, 6.194527897871518, 8.176819735175362, 9.168049286866717, 12.017404573466198, 7.805151216385958, 8.30065115633915, 9.66348590260339, 10.035119190040824), # 20
(10.076934501449866, 10.964316231190558, 10.341344534499719, 12.334849696756486, 11.081197503530088, 6.229722955410535, 8.223249851981759, 9.220044146841623, 12.085670017867521, 7.849467600901555, 8.34782274483756, 9.718375912277793, 10.092145302677078), # 21
(10.115991242699579, 10.995975074799144, 10.371203860377285, 12.370471283507836, 11.118241776835575, 6.247712874176367, 8.2469827332556, 9.246621172267915, 12.120563821031915, 7.872120084878242, 8.37193456371034, 9.74643298884649, 10.121294188548827), # 22
(10.13039336334264, 10.999723593964335, 10.374923182441702, 12.374930812757203, 11.127732056032597, 6.25, 8.249804002259339, 9.249493827160494, 12.124926234567901, 7.874792272519433, 8.37495803716174, 9.749897576588934, 10.125), # 23
(10.141012413034153, 10.997537037037038, 10.374314814814815, 12.374381944444446, 11.133107613614852, 6.25, 8.248253812636166, 9.2455, 12.124341666666666, 7.87315061728395, 8.37462457912458, 9.749086419753086, 10.125), # 24
(10.15140723021158, 10.993227023319616, 10.373113854595337, 12.373296039094651, 11.138364945594503, 6.25, 8.24519890260631, 9.237654320987655, 12.123186728395062, 7.869918838591678, 8.373963399426362, 9.747485139460448, 10.125), # 25
(10.161577019048034, 10.986859396433472, 10.371336762688616, 12.37168544238683, 11.143503868421105, 6.25, 8.240686718308721, 9.226104938271606, 12.1214762345679, 7.865150708733425, 8.372980483850855, 9.745115683584821, 10.125), # 26
(10.171520983716636, 10.978499999999999, 10.369, 12.369562499999999, 11.148524198544214, 6.25, 8.234764705882354, 9.211, 12.119225, 7.858899999999999, 8.371681818181818, 9.742, 10.125), # 27
(10.181238328390501, 10.968214677640603, 10.366120027434842, 12.366939557613168, 11.153425752413401, 6.25, 8.22748031146615, 9.192487654320988, 12.116447839506172, 7.851220484682213, 8.370073388203018, 9.73816003657979, 10.125), # 28
(10.19072825724275, 10.95606927297668, 10.362713305898492, 12.36382896090535, 11.15820834647822, 6.25, 8.218880981199066, 9.170716049382715, 12.113159567901235, 7.842165935070874, 8.368161179698216, 9.733617741197987, 10.125), # 29
(10.199989974446497, 10.94212962962963, 10.358796296296296, 12.360243055555555, 11.162871797188236, 6.25, 8.209014161220043, 9.145833333333332, 12.109375, 7.83179012345679, 8.365951178451178, 9.728395061728394, 10.125), # 30
(10.209022684174858, 10.926461591220852, 10.354385459533608, 12.356194187242798, 11.167415920993008, 6.25, 8.19792729766804, 9.117987654320988, 12.105108950617284, 7.820146822130773, 8.363449370245666, 9.722513946044812, 10.125), # 31
(10.217825590600954, 10.909131001371742, 10.349497256515773, 12.35169470164609, 11.171840534342095, 6.25, 8.185667836681999, 9.087327160493828, 12.100376234567902, 7.807289803383631, 8.360661740865444, 9.715996342021034, 10.125), # 32
(10.226397897897897, 10.890203703703703, 10.344148148148149, 12.346756944444444, 11.176145453685063, 6.25, 8.172283224400871, 9.054, 12.095191666666667, 7.793272839506173, 8.357594276094275, 9.708864197530863, 10.125), # 33
(10.23473881023881, 10.869745541838133, 10.338354595336076, 12.341393261316872, 11.180330495471466, 6.25, 8.15782090696361, 9.018154320987653, 12.089570061728397, 7.778149702789209, 8.354252961715924, 9.701139460448102, 10.125), # 34
(10.242847531796807, 10.847822359396433, 10.332133058984912, 12.335615997942385, 11.18439547615087, 6.25, 8.142328330509159, 8.979938271604938, 12.083526234567902, 7.761974165523548, 8.350643783514153, 9.692844078646548, 10.125), # 35
(10.250723266745005, 10.824499999999999, 10.3255, 12.3294375, 11.188340212172836, 6.25, 8.12585294117647, 8.9395, 12.077074999999999, 7.7448, 8.346772727272727, 9.684000000000001, 10.125), # 36
(10.258365219256524, 10.799844307270233, 10.318471879286694, 12.322870113168724, 11.192164519986921, 6.25, 8.108442185104494, 8.896987654320988, 12.070231172839506, 7.726680978509374, 8.34264577877541, 9.674629172382259, 10.125), # 37
(10.265772593504476, 10.773921124828533, 10.311065157750342, 12.315926183127573, 11.19586821604269, 6.25, 8.09014350843218, 8.85254938271605, 12.063009567901235, 7.707670873342479, 8.33826892380596, 9.664753543667125, 10.125), # 38
(10.272944593661986, 10.746796296296296, 10.303296296296297, 12.308618055555556, 11.199451116789703, 6.25, 8.071004357298476, 8.806333333333333, 12.055425000000001, 7.687823456790124, 8.333648148148148, 9.654395061728394, 10.125), # 39
(10.279880423902163, 10.718535665294924, 10.295181755829903, 12.300958076131687, 11.202913038677519, 6.25, 8.05107217784233, 8.758487654320989, 12.047492283950618, 7.667192501143119, 8.328789437585733, 9.643575674439873, 10.125), # 40
(10.286579288398128, 10.689205075445816, 10.286737997256516, 12.29295859053498, 11.206253798155702, 6.25, 8.030394416202695, 8.709160493827161, 12.0392262345679, 7.645831778692272, 8.323698777902482, 9.632317329675354, 10.125), # 41
(10.293040391323, 10.658870370370371, 10.277981481481483, 12.284631944444445, 11.209473211673808, 6.25, 8.009018518518518, 8.6585, 12.030641666666668, 7.623795061728395, 8.318382154882155, 9.620641975308642, 10.125), # 42
(10.299262936849892, 10.627597393689987, 10.268928669410151, 12.275990483539095, 11.212571095681403, 6.25, 7.98699193092875, 8.606654320987655, 12.021753395061728, 7.601136122542296, 8.312845554308517, 9.608571559213535, 10.125), # 43
(10.305246129151927, 10.595451989026063, 10.259596021947875, 12.267046553497943, 11.215547266628045, 6.25, 7.964362099572339, 8.553771604938273, 12.0125762345679, 7.577908733424783, 8.307094961965332, 9.596128029263832, 10.125), # 44
(10.310989172402216, 10.5625, 10.25, 12.2578125, 11.218401540963296, 6.25, 7.9411764705882355, 8.5, 12.003124999999999, 7.554166666666667, 8.301136363636363, 9.583333333333332, 10.125), # 45
(10.31649127077388, 10.528807270233196, 10.240157064471878, 12.24830066872428, 11.221133735136716, 6.25, 7.917482490115388, 8.445487654320988, 11.993414506172838, 7.529963694558756, 8.294975745105374, 9.57020941929584, 10.125), # 46
(10.321751628440035, 10.49443964334705, 10.230083676268862, 12.238523405349794, 11.223743665597867, 6.25, 7.893327604292747, 8.390382716049382, 11.983459567901235, 7.505353589391861, 8.288619092156129, 9.55677823502515, 10.125), # 47
(10.326769449573796, 10.459462962962963, 10.219796296296296, 12.228493055555557, 11.22623114879631, 6.25, 7.868759259259259, 8.334833333333334, 11.973275000000001, 7.4803901234567896, 8.28207239057239, 9.543061728395061, 10.125), # 48
(10.331543938348286, 10.42394307270233, 10.209311385459534, 12.218221965020577, 11.228596001181607, 6.25, 7.8438249011538765, 8.278987654320987, 11.96287561728395, 7.455127069044353, 8.275341626137923, 9.529081847279379, 10.125), # 49
(10.336074298936616, 10.387945816186559, 10.198645404663925, 12.207722479423868, 11.230838039203315, 6.25, 7.81857197611555, 8.222993827160494, 11.9522762345679, 7.429618198445358, 8.268432784636488, 9.514860539551899, 10.125), # 50
(10.34035973551191, 10.351537037037037, 10.187814814814814, 12.197006944444444, 11.232957079310998, 6.25, 7.793047930283224, 8.167, 11.941491666666668, 7.403917283950617, 8.261351851851853, 9.50041975308642, 10.125), # 51
(10.344399452247279, 10.314782578875173, 10.176836076817558, 12.186087705761317, 11.234952937954214, 6.25, 7.767300209795852, 8.111154320987653, 11.930536728395062, 7.3780780978509375, 8.254104813567777, 9.485781435756746, 10.125), # 52
(10.348192653315843, 10.27774828532236, 10.165725651577505, 12.174977109053497, 11.23682543158253, 6.25, 7.741376260792383, 8.055604938271605, 11.919426234567903, 7.3521544124371285, 8.246697655568026, 9.470967535436671, 10.125), # 53
(10.351738542890716, 10.2405, 10.154499999999999, 12.1636875, 11.238574376645502, 6.25, 7.715323529411765, 8.000499999999999, 11.908175, 7.3262, 8.239136363636362, 9.456, 10.125), # 54
(10.355036325145022, 10.203103566529492, 10.143175582990398, 12.152231224279834, 11.24019958959269, 6.25, 7.689189461792948, 7.945987654320987, 11.896797839506172, 7.300268632830361, 8.231426923556553, 9.44090077732053, 10.125), # 55
(10.358085204251871, 10.165624828532236, 10.131768861454047, 12.140620627572016, 11.241700886873659, 6.25, 7.663021504074881, 7.892216049382716, 11.885309567901235, 7.274414083219022, 8.223575321112358, 9.425691815272062, 10.125), # 56
(10.360884384384383, 10.12812962962963, 10.120296296296297, 12.128868055555555, 11.243078084937967, 6.25, 7.636867102396514, 7.839333333333334, 11.873725, 7.24869012345679, 8.215587542087542, 9.410395061728394, 10.125), # 57
(10.36343306971568, 10.090683813443073, 10.108774348422497, 12.116985853909464, 11.244331000235174, 6.25, 7.610773702896797, 7.787487654320987, 11.862058950617284, 7.223150525834477, 8.20746957226587, 9.395032464563329, 10.125), # 58
(10.36573046441887, 10.053353223593964, 10.097219478737998, 12.104986368312757, 11.245459449214845, 6.25, 7.584788751714678, 7.736827160493827, 11.850326234567902, 7.197849062642891, 8.1992273974311, 9.379625971650663, 10.125), # 59
(10.367775772667077, 10.016203703703704, 10.085648148148147, 12.092881944444445, 11.246463248326537, 6.25, 7.558959694989106, 7.6875, 11.838541666666668, 7.172839506172839, 8.190867003367003, 9.364197530864198, 10.125), # 60
(10.369568198633415, 9.97930109739369, 10.0740768175583, 12.080684927983539, 11.247342214019811, 6.25, 7.533333978859033, 7.639654320987654, 11.826720061728395, 7.148175628715135, 8.182394375857339, 9.348769090077733, 10.125), # 61
(10.371106946491004, 9.942711248285322, 10.062521947873801, 12.068407664609055, 11.248096162744234, 6.25, 7.507959049463406, 7.5934382716049384, 11.814876234567901, 7.123911202560586, 8.17381550068587, 9.333362597165067, 10.125), # 62
(10.37239122041296, 9.9065, 10.051, 12.056062500000001, 11.248724910949356, 6.25, 7.482882352941176, 7.549, 11.803025, 7.100099999999999, 8.165136363636364, 9.318, 10.125), # 63
(10.373420224572397, 9.870733196159122, 10.039527434842249, 12.043661779835391, 11.249228275084748, 6.25, 7.458151335431292, 7.506487654320988, 11.791181172839506, 7.076795793324188, 8.156362950492579, 9.302703246456334, 10.125), # 64
(10.374193163142438, 9.835476680384087, 10.0281207133059, 12.031217849794238, 11.249606071599967, 6.25, 7.433813443072703, 7.466049382716049, 11.779359567901235, 7.054052354823959, 8.147501247038285, 9.287494284407863, 10.125), # 65
(10.374709240296196, 9.800796296296298, 10.016796296296297, 12.018743055555555, 11.249858116944573, 6.25, 7.409916122004357, 7.427833333333334, 11.767575, 7.031923456790123, 8.138557239057238, 9.272395061728396, 10.125), # 66
(10.374967660206792, 9.766757887517146, 10.005570644718793, 12.006249742798353, 11.24998422756813, 6.25, 7.386506818365206, 7.391987654320989, 11.755842283950617, 7.010462871513489, 8.12953691233321, 9.257427526291723, 10.125), # 67
(10.374791614480825, 9.733248639320323, 9.994405949931412, 11.993641740472357, 11.249877955297345, 6.2498840115836, 7.363515194829646, 7.358343850022862, 11.744087848651121, 6.989620441647166, 8.120285988540376, 9.242530021899743, 10.124875150034294), # 68
(10.373141706924315, 9.699245519713262, 9.982988425925925, 11.980283514492752, 11.248910675381262, 6.248967078189301, 7.340268181346613, 7.325098765432099, 11.731797839506173, 6.968806390704429, 8.10986283891547, 9.227218973359324, 10.12388599537037), # 69
(10.369885787558895, 9.664592459843355, 9.971268432784635, 11.966087124261943, 11.246999314128942, 6.247161255906112, 7.31666013456137, 7.291952446273434, 11.718902892089622, 6.947919524462734, 8.09814888652608, 9.211422761292809, 10.121932334533609), # 70
(10.365069660642929, 9.62931016859153, 9.959250085733881, 11.951073503757382, 11.244168078754136, 6.244495808565767, 7.292701659538988, 7.258915866483768, 11.705422210791038, 6.926960359342639, 8.085187370783862, 9.195152937212715, 10.119039887688615), # 71
(10.358739130434783, 9.593419354838709, 9.946937499999999, 11.935263586956522, 11.240441176470588, 6.2410000000000005, 7.268403361344538, 7.226, 11.691375, 6.905929411764705, 8.07102153110048, 9.17842105263158, 10.115234375), # 72
(10.35094000119282, 9.556940727465816, 9.934334790809327, 11.918678307836823, 11.23584281449205, 6.236703094040542, 7.243775845043092, 7.193215820759031, 11.676780464106082, 6.884827198149493, 8.055694606887588, 9.161238659061919, 10.110541516632374), # 73
(10.341718077175404, 9.519894995353777, 9.921446073388202, 11.901338600375738, 11.230397200032275, 6.231634354519128, 7.218829715699722, 7.160574302697759, 11.661657807498857, 6.863654234917561, 8.039249837556856, 9.143617308016267, 10.104987032750344), # 74
(10.331119162640901, 9.482302867383511, 9.908275462962962, 11.883265398550725, 11.224128540305012, 6.22582304526749, 7.1935755783795, 7.128086419753086, 11.6460262345679, 6.84241103848947, 8.021730462519935, 9.125568551007147, 10.098596643518519), # 75
(10.319189061847677, 9.44418505243595, 9.894827074759945, 11.864479636339238, 11.217061042524005, 6.219298430117361, 7.168024038147495, 7.095763145861912, 11.629904949702789, 6.821098125285779, 8.003179721188491, 9.107103939547082, 10.091396069101508), # 76
(10.305973579054093, 9.40556225939201, 9.881105024005485, 11.845002247718732, 11.209218913903008, 6.212089772900472, 7.142185700068779, 7.063615454961135, 11.613313157293096, 6.7997160117270505, 7.983640852974187, 9.088235025148606, 10.083411029663925), # 77
(10.291518518518519, 9.366455197132618, 9.867113425925925, 11.824854166666666, 11.200626361655774, 6.204226337448559, 7.116071169208425, 7.031654320987655, 11.596270061728394, 6.7782652142338415, 7.9631570972886765, 9.068973359324238, 10.074667245370371), # 78
(10.275869684499314, 9.326884574538697, 9.8528563957476, 11.804056327160493, 11.191307592996047, 6.195737387593354, 7.089691050631501, 6.9998907178783725, 11.578794867398262, 6.756746249226714, 7.941771693543622, 9.049330493586504, 10.065190436385459), # 79
(10.259072881254847, 9.286871100491172, 9.838338048696844, 11.782629663177671, 11.181286815137579, 6.18665218716659, 7.063055949403081, 6.968335619570188, 11.560906778692273, 6.7351596331262265, 7.919527881150688, 9.029317979447935, 10.0550063228738), # 80
(10.241173913043479, 9.246435483870968, 9.8235625, 11.760595108695654, 11.170588235294117, 6.177, 7.036176470588235, 6.937, 11.542625, 6.713505882352941, 7.8964688995215315, 9.008947368421053, 10.044140624999999), # 81
(10.222218584123576, 9.205598433559008, 9.808533864883403, 11.737973597691894, 11.159236060679415, 6.166810089925317, 7.009063219252036, 6.90589483310471, 11.52396873571102, 6.691785513327416, 7.872637988067813, 8.988230212018387, 10.03261906292867), # 82
(10.202252698753504, 9.164380658436214, 9.793256258573388, 11.714786064143853, 11.147254498507221, 6.156111720774272, 6.981726800459553, 6.875031092821216, 11.504957190214906, 6.669999042470211, 7.848078386201194, 8.967178061752461, 10.020467356824417), # 83
(10.181322061191626, 9.122802867383513, 9.777733796296296, 11.691053442028986, 11.134667755991286, 6.144934156378601, 6.954177819275858, 6.844419753086419, 11.485609567901234, 6.648146986201889, 7.822833333333333, 8.945802469135803, 10.007711226851852), # 84
(10.159472475696308, 9.080885769281826, 9.761970593278463, 11.666796665324746, 11.121500040345357, 6.133306660570035, 6.926426880766024, 6.814071787837221, 11.465945073159578, 6.626229860943005, 7.796946068875894, 8.924114985680937, 9.994376393175584), # 85
(10.136749746525913, 9.03865007301208, 9.745970764746229, 11.64203666800859, 11.107775558783183, 6.121258497180309, 6.89848458999512, 6.783998171010516, 11.445982910379517, 6.604248183114124, 7.770459832240534, 8.902127162900394, 9.98048857596022), # 86
(10.113199677938807, 8.996116487455197, 9.729738425925925, 11.61679438405797, 11.09351851851852, 6.108818930041152, 6.870361552028219, 6.75420987654321, 11.425742283950619, 6.582202469135802, 7.743417862838915, 8.879850552306692, 9.96607349537037), # 87
(10.088868074193357, 8.9533057214921, 9.713277692043896, 11.59109074745035, 11.07875312676511, 6.096017222984301, 6.842068371930391, 6.724717878372199, 11.40524239826246, 6.560093235428601, 7.715863400082698, 8.857296705412365, 9.951156871570646), # 88
(10.063800739547922, 8.910238484003717, 9.696592678326475, 11.564946692163177, 11.063503590736707, 6.082882639841488, 6.813615654766708, 6.695533150434385, 11.384502457704619, 6.537920998413083, 7.687839683383544, 8.834477173729935, 9.935764424725651), # 89
(10.03804347826087, 8.866935483870968, 9.6796875, 11.538383152173914, 11.04779411764706, 6.069444444444445, 6.785014005602241, 6.666666666666666, 11.363541666666668, 6.515686274509804, 7.65938995215311, 8.81140350877193, 9.919921875), # 90
(10.011642094590563, 8.823417429974777, 9.662566272290809, 11.511421061460013, 11.031648914709915, 6.055731900624904, 6.756274029502062, 6.638129401005944, 11.342379229538182, 6.4933895801393255, 7.63055744580306, 8.788087262050874, 9.903654942558298), # 91
(9.984642392795372, 8.779705031196071, 9.64523311042524, 11.484081353998926, 11.015092189139029, 6.041774272214601, 6.727406331531242, 6.609932327389118, 11.321034350708734, 6.471031431722209, 7.601385403745053, 8.764539985079297, 9.886989347565157), # 92
(9.957090177133654, 8.735818996415771, 9.62769212962963, 11.456384963768118, 10.998148148148148, 6.027600823045267, 6.69842151675485, 6.582086419753087, 11.299526234567901, 6.448612345679011, 7.57191706539075, 8.74077322936972, 9.869950810185184), # 93
(9.92903125186378, 8.691780034514801, 9.609947445130317, 11.428352824745035, 10.98084099895102, 6.0132408169486355, 6.669330190237961, 6.554602652034752, 11.277874085505259, 6.426132838430297, 7.54219567015181, 8.716798546434674, 9.85256505058299), # 94
(9.90051142124411, 8.647608854374088, 9.592003172153635, 11.400005870907139, 10.963194948761398, 5.9987235177564395, 6.640142957045644, 6.527491998171011, 11.25609710791038, 6.403593426396621, 7.512264457439896, 8.69262748778668, 9.834857788923182), # 95
(9.871576489533012, 8.603326164874554, 9.573863425925927, 11.371365036231884, 10.945234204793028, 5.984078189300411, 6.610870422242971, 6.500765432098766, 11.234214506172838, 6.3809946259985475, 7.482166666666667, 8.668271604938273, 9.816854745370371), # 96
(9.842272260988848, 8.558952674897121, 9.555532321673525, 11.342451254696725, 10.926982974259664, 5.969334095412284, 6.581523190895013, 6.474433927754916, 11.212245484682214, 6.358336953656634, 7.451945537243782, 8.64374244940197, 9.798581640089164), # 97
(9.812644539869984, 8.514509093322713, 9.53701397462277, 11.31328546027912, 10.908465464375052, 5.954520499923793, 6.552111868066842, 6.44850845907636, 11.190209247828074, 6.335620925791441, 7.421644308582906, 8.619051572690298, 9.78006419324417), # 98
(9.782739130434782, 8.470016129032258, 9.5183125, 11.283888586956522, 10.889705882352942, 5.939666666666667, 6.52264705882353, 6.423, 11.168125, 6.312847058823529, 7.391306220095694, 8.59421052631579, 9.761328125), # 99
(9.752601836941611, 8.425494490906676, 9.49943201303155, 11.254281568706388, 10.870728435407084, 5.924801859472641, 6.493139368230145, 6.3979195244627345, 11.146011945587563, 6.290015869173458, 7.36097451119381, 8.569230861790967, 9.742399155521262), # 100
(9.722278463648834, 8.380964887826895, 9.480376628943759, 11.224485339506174, 10.85155733075123, 5.909955342173449, 6.463599401351762, 6.3732780064014625, 11.123889288980338, 6.267127873261788, 7.330692421288912, 8.544124130628353, 9.723303004972564), # 101
(9.691814814814816, 8.336448028673836, 9.461150462962962, 11.194520833333334, 10.832216775599129, 5.895156378600824, 6.43403776325345, 6.349086419753086, 11.1017762345679, 6.244183587509078, 7.300503189792663, 8.518901884340481, 9.704065393518519), # 102
(9.661256694697919, 8.291964622328422, 9.4417576303155, 11.164408984165325, 10.812730977164529, 5.880434232586496, 6.40446505900028, 6.325355738454504, 11.079691986739826, 6.221183528335889, 7.270450056116723, 8.493575674439873, 9.68471204132373), # 103
(9.63064990755651, 8.247535377671579, 9.422202246227709, 11.134170725979603, 10.79312414266118, 5.865818167962201, 6.374891893657326, 6.302096936442616, 11.057655749885688, 6.19812821216278, 7.24057625967275, 8.468157052439054, 9.665268668552812), # 104
(9.600040257648953, 8.203181003584229, 9.402488425925926, 11.103826992753623, 10.773420479302832, 5.851337448559671, 6.345328872289658, 6.279320987654321, 11.035686728395062, 6.175018155410313, 7.210925039872408, 8.442657569850553, 9.64576099537037), # 105
(9.569473549233614, 8.158922208947299, 9.382620284636488, 11.073398718464842, 10.753644194303236, 5.837021338210638, 6.315786599962345, 6.25703886602652, 11.01380412665752, 6.151853874499045, 7.181539636127355, 8.417088778186894, 9.626214741941014), # 106
(9.538995586568856, 8.11477970264171, 9.362601937585735, 11.042906837090714, 10.733819494876139, 5.822899100746838, 6.286275681740461, 6.235261545496114, 10.992027149062643, 6.128635885849539, 7.152463287849252, 8.391462228960604, 9.606655628429355), # 107
(9.508652173913044, 8.070774193548388, 9.3424375, 11.012372282608696, 10.713970588235293, 5.809, 6.256806722689075, 6.214, 10.970375, 6.105364705882353, 7.1237392344497605, 8.365789473684211, 9.587109375), # 108
(9.478489115524543, 8.026926390548255, 9.322131087105625, 10.98181598899624, 10.69412168159445, 5.795353299801859, 6.227390327873262, 6.193265203475081, 10.948866883859168, 6.082040851018047, 7.09541071534054, 8.340082063870238, 9.567601701817559), # 109
(9.448552215661715, 7.983257002522237, 9.301686814128946, 10.951258890230811, 10.674296982167354, 5.7819882639841484, 6.198037102358089, 6.173068129858253, 10.92752200502972, 6.058664837677183, 7.06752096993325, 8.314351551031214, 9.54815832904664), # 110
(9.41888727858293, 7.9397867383512555, 9.281108796296298, 10.920721920289855, 10.654520697167756, 5.768934156378601, 6.168757651208631, 6.153419753086419, 10.906359567901236, 6.035237182280319, 7.040113237639553, 8.288609486679663, 9.528804976851852), # 111
(9.38954010854655, 7.896536306916234, 9.26040114883402, 10.890226013150832, 10.634817033809409, 5.756220240816949, 6.139562579489958, 6.134331047096479, 10.885398776863282, 6.011758401248016, 7.013230757871109, 8.26286742232811, 9.509567365397805), # 112
(9.360504223703044, 7.853598618785952, 9.239617828252069, 10.85983388249204, 10.615175680173705, 5.7438697692145135, 6.1105259636567695, 6.115852568780606, 10.86471281125862, 5.988304736612729, 6.9869239061528665, 8.237192936504428, 9.490443900843221), # 113
(9.331480897900065, 7.811397183525536, 9.219045675021619, 10.829789421277336, 10.595393354566326, 5.731854608529901, 6.082018208410579, 6.09821125950512, 10.84461903571306, 5.965315167912783, 6.961244337113197, 8.211912172112974, 9.471275414160035), # 114
(9.302384903003995, 7.769947198683046, 9.198696932707318, 10.800084505181779, 10.5754076778886, 5.7201435124987645, 6.054059650191562, 6.081402654278709, 10.82512497866879, 5.942825327988077, 6.936154511427094, 8.187037582558851, 9.452006631660376), # 115
(9.273179873237634, 7.729188281291702, 9.178532189983873, 10.770666150266404, 10.555188526383779, 5.708708877287098, 6.026604817527893, 6.065380312898993, 10.80618133922783, 5.920793358449547, 6.911605931271481, 8.162523197487346, 9.43260725975589), # 116
(9.243829442823772, 7.689060048384721, 9.158512035525986, 10.741481372592244, 10.53470577629511, 5.6975230990608905, 5.9996082389477525, 6.050097795163585, 10.787738816492203, 5.899177400908129, 6.887550098823283, 8.13832304654375, 9.413047004858225), # 117
(9.214297245985211, 7.649502116995324, 9.138597058008367, 10.712477188220333, 10.513929303865842, 5.686558573986138, 5.973024442979315, 6.0355086608700965, 10.769748109563935, 5.877935596974759, 6.863938516259424, 8.11439115937335, 9.393295573379024), # 118
(9.184546916944742, 7.610454104156729, 9.118747846105723, 10.683600613211706, 10.492828985339221, 5.675787698228833, 5.946807958150756, 6.021566469816145, 10.752159917545043, 5.857026088260372, 6.840722685756828, 8.090681565621434, 9.373322671729932), # 119
(9.154542089925162, 7.571855626902158, 9.098924988492762, 10.654798663627394, 10.471374696958497, 5.665182867954965, 5.920913312990253, 6.008224781799343, 10.734924939537558, 5.836407016375905, 6.817854109492416, 8.067148294933297, 9.353098006322597), # 120
(9.124246399149268, 7.533646302264829, 9.079089073844187, 10.626018355528434, 10.449536314966918, 5.6547164793305305, 5.89529503602598, 5.995437156617307, 10.717993874643499, 5.816036522932296, 6.795284289643116, 8.043745376954222, 9.33259128356866), # 121
(9.093623478839854, 7.495765747277961, 9.059200690834711, 10.597206704975855, 10.427283715607734, 5.644360928521519, 5.869907655786117, 5.983157154067649, 10.70131742196489, 5.795872749540477, 6.772964728385851, 8.0204268413295, 9.31177220987977), # 122
(9.062636963219719, 7.458153578974774, 9.039220428139036, 10.568310728030694, 10.40458677512419, 5.634088611693925, 5.844705700798839, 5.971338333947983, 10.684846280603754, 5.775873837811387, 6.750846927897544, 7.997146717704421, 9.290610491667572), # 123
(9.031250486511654, 7.420749414388487, 9.01910887443187, 10.539277440753986, 10.381415369759537, 5.623871925013739, 5.819643699592319, 5.959934256055926, 10.668531149662115, 5.755997929355961, 6.728882390355119, 7.973859035724275, 9.269075835343711), # 124
(8.999427682938459, 7.38349287055232, 8.998826618387923, 10.51005385920676, 10.357739375757022, 5.613683264646956, 5.794676180694739, 5.948898480189091, 10.652322728241993, 5.736203165785134, 6.707022617935501, 7.950517825034348, 9.247137947319828), # 125
(8.967132186722928, 7.346323564499494, 8.978334248681898, 10.480586999450054, 10.333528669359893, 5.603495026759568, 5.76975767263427, 5.938184566145092, 10.636171715445418, 5.7164476887098425, 6.685219112815613, 7.927077115279934, 9.224766534007578), # 126
(8.93432763208786, 7.309181113263224, 8.957592353988504, 10.450823877544899, 10.308753126811398, 5.593279607517565, 5.744842703939094, 5.927746073721545, 10.620028810374407, 5.696689639741024, 6.6634233771723785, 7.903490936106316, 9.201931301818599), # 127
(8.900977653256046, 7.272005133876735, 8.93656152298245, 10.420711509552332, 10.28338262435479, 5.583009403086944, 5.719885803137382, 5.917536562716062, 10.603844712130984, 5.6768871604896125, 6.641586913182724, 7.879713317158788, 9.178601957164537), # 128
(8.867045884450281, 7.234735243373241, 8.91520234433844, 10.390196911533382, 10.257387038233311, 5.572656809633695, 5.694841498757313, 5.90750959292626, 10.587570119817174, 5.656998392566545, 6.619661223023571, 7.855698288082636, 9.154748206457038), # 129
(8.832495959893366, 7.197311058785966, 8.893475406731179, 10.359227099549086, 10.230736244690213, 5.562194223323808, 5.669664319327063, 5.89761872414975, 10.571155732535, 5.636981477582757, 6.5975978088718445, 7.831399878523152, 9.130339756107748), # 130
(8.797291513808094, 7.159672197148127, 8.87134129883538, 10.327749089660475, 10.203400119968745, 5.55159404032328, 5.644308793374809, 5.88781751618415, 10.554552249386486, 5.616794557149185, 6.575348172904468, 7.806772118125624, 9.105346312528312), # 131
(8.76139618041726, 7.121758275492944, 8.848760609325746, 10.295709897928587, 10.175348540312154, 5.540828656798102, 5.618729449428725, 5.878059528827073, 10.537710369473654, 5.596395772876765, 6.552863817298364, 7.781769036535342, 9.079737582130376), # 132
(8.724773593943663, 7.083508910853635, 8.825693926876983, 10.263056540414452, 10.146551381963686, 5.529870468914266, 5.592880816016989, 5.868298321876132, 10.520580791898526, 5.575743266376432, 6.53009624423046, 7.756344663397592, 9.053483271325586), # 133
(8.687387388610095, 7.044863720263423, 8.802101840163804, 10.229736033179103, 10.116978521166592, 5.518691872837765, 5.566717421667779, 5.858487455128944, 10.503114215763128, 5.5547951792591235, 6.506996955877678, 7.730453028357666, 9.026553086525583), # 134
(8.649201198639354, 7.005762320755524, 8.777944937860909, 10.195695392283579, 10.08659983416412, 5.507265264734592, 5.540193794909268, 5.84858048838312, 10.48526134016948, 5.533509653135776, 6.483517454416942, 7.704048161060852, 8.99891673414202), # 135
(8.610178658254235, 6.966144329363159, 8.753183808643008, 10.160881633788906, 10.055385197199517, 5.495563040770739, 5.513264464269635, 5.838530981436277, 10.466972864219606, 5.511844829617322, 6.459609242025177, 7.677084091152441, 8.970543920586536), # 136
(8.570283401677534, 6.925949363119547, 8.72777904118481, 10.125241773756125, 10.023304486516034, 5.483557597112198, 5.485883958277055, 5.828292494086029, 10.448199487015533, 5.4897588503147015, 6.435223820879306, 7.649514848277719, 8.941404352270776), # 137
(8.529479063132047, 6.885117039057908, 8.701691224161017, 10.088722828246263, 9.990327578356919, 5.471221329924964, 5.458006805459704, 5.81781858612999, 10.428891907659281, 5.4672098568388465, 6.410312693156252, 7.621294462081978, 8.91146773560639), # 138
(8.487729276840568, 6.843586974211461, 8.67488094624634, 10.051271813320358, 9.956424348965415, 5.458526635375026, 5.429587534345759, 5.807062817365774, 10.409000825252871, 5.444155990800697, 6.38482736103294, 7.592376962210506, 8.880703777005019), # 139
(8.444997677025897, 6.801298785613425, 8.647308796115487, 10.012835745039444, 9.92156467458478, 5.445445909628379, 5.400580673463397, 5.795978747590996, 10.388476938898332, 5.420555393811186, 6.358719326686294, 7.562716378308592, 8.849082182878314), # 140
(8.40124789791083, 6.758192090297021, 8.61893536244316, 9.973361639464553, 9.885718431458253, 5.431951548851015, 5.370940751340795, 5.78451993660327, 10.36727094769768, 5.396366207481251, 6.331940092293238, 7.532266740021525, 8.816572659637913), # 141
(8.356443573718156, 6.714206505295466, 8.58972123390407, 9.93279651265672, 9.848855495829087, 5.418015949208927, 5.340622296506126, 5.772639944200211, 10.345333550752942, 5.371546573421828, 6.304441160030697, 7.500982076994594, 8.783144913695466), # 142
(8.310548338670674, 6.669281647641981, 8.559626999172925, 9.891087380676975, 9.810945743940529, 5.403611506868106, 5.3095798374875685, 5.760292330179432, 10.322615447166147, 5.3460546332438525, 6.276174032075593, 7.4688164188730894, 8.748768651462617), # 143
(8.263525826991184, 6.623357134369786, 8.528613246924428, 9.848181259586356, 9.771959052035829, 5.388710617994547, 5.277767902813299, 5.747430654338549, 10.29906733603931, 5.31984852855826, 6.247090210604851, 7.435723795302299, 8.713413579351014), # 144
(8.215339672902477, 6.576372582512099, 8.496640565833289, 9.804025165445895, 9.731865296358233, 5.3732856787542405, 5.245141021011493, 5.734008476475176, 10.274639916474454, 5.292886400975988, 6.217141197795395, 7.401658235927513, 8.6770494037723), # 145
(8.16595351062735, 6.528267609102142, 8.463669544574216, 9.758566114316626, 9.690634353150992, 5.35730908531318, 5.21165372061033, 5.719979356386927, 10.249283887573606, 5.2651263921079705, 6.186278495824149, 7.3665737703940195, 8.639645831138118), # 146
(8.1153309743886, 6.47898183117313, 8.42966077182191, 9.71175112225958, 9.648236098657351, 5.340753233837358, 5.177260530137981, 5.705296853871415, 10.22294994843879, 5.236526643565146, 6.154453606868036, 7.3304244283471105, 8.601172567860118), # 147
(8.063435698409021, 6.428454865758288, 8.394574836251083, 9.663527205335797, 9.604640409120561, 5.323590520492767, 5.1419159781226265, 5.689914528726257, 10.195588798172029, 5.207045296958447, 6.1216180331039824, 7.29316423943207, 8.561599320349941), # 148
(8.010231316911412, 6.37662632989083, 8.358372326536443, 9.613841379606303, 9.55981716078387, 5.3057933414453995, 5.105574593092441, 5.673785940749067, 10.167151135875338, 5.176640493898813, 6.08772327670891, 7.254747233294191, 8.520895795019237), # 149
(7.955681464118564, 6.323435840603979, 8.321013831352694, 9.562640661132138, 9.513736229890526, 5.287334092861249, 5.0681909035756005, 5.656864649737456, 10.137587660650752, 5.1452703759971765, 6.0527208398597425, 7.215127439578763, 8.479031698279647), # 150
(7.899749774253275, 6.268823014930954, 8.282459939374542, 9.50987206597433, 9.466367492683776, 5.268185170906305, 5.029719438100283, 5.639104215489043, 10.106849071600289, 5.112893084864478, 6.016562224733405, 7.174258887931072, 8.435976736542818), # 151
(7.842399881538343, 6.212727469904973, 8.242671239276701, 9.455482610193918, 9.417680825406869, 5.2483189717465635, 4.9901147251946645, 5.620458197801441, 10.07488606782597, 5.079466762111649, 5.979198933506821, 7.132095607996409, 8.391700616220398), # 152
(7.78359542019656, 6.155088822559256, 8.201608319733868, 9.399419309851933, 9.367646104303056, 5.2277078915480155, 4.949331293386919, 5.600880156472262, 10.041649348429823, 5.044949549349629, 5.940582468356916, 7.088591629420064, 8.346173043724027), # 153
(7.723300024450729, 6.095846689927024, 8.159231769420758, 9.34162918100941, 9.31623320561558, 5.206324326476654, 4.907323671205228, 5.580323651299123, 10.007089612513866, 5.009299588189353, 5.900664331460612, 7.043700981847325, 8.299363725465357), # 154
(7.6614773285236355, 6.034940689041495, 8.115502177012075, 9.282059239727378, 9.263412005587696, 5.184140672698471, 4.864046387177761, 5.558742242079636, 9.971157559180128, 4.972475020241754, 5.859396024994833, 6.997377694923482, 8.251242367856026), # 155
(7.598090966638081, 5.972310436935888, 8.070380131182526, 9.220656502066875, 9.209152380462648, 5.161129326379461, 4.8194539698327, 5.5360894886114185, 9.933803887530626, 4.934433987117773, 5.816729051136504, 6.949575798293822, 8.201778677307685), # 156
(7.533104573016862, 5.907895550643423, 8.023826220606818, 9.157367984088937, 9.153424206483685, 5.137262683685614, 4.773500947698219, 5.512318950692082, 9.894979296667389, 4.895134630428341, 5.772614912062549, 6.900249321603637, 8.150942360231976), # 157
(7.464680946405239, 5.840453120772258, 7.973591953902355, 9.089769581651243, 9.093681105870997, 5.11102447631711, 4.725106720927857, 5.485796952349372, 9.851662091599097, 4.8533659162911436, 5.7255957525389425, 6.847599564194339, 8.096485859415345), # 158
(7.382286766978402, 5.763065319599478, 7.906737818402988, 9.003977158788453, 9.015191309781628, 5.073689648007103, 4.668212763385716, 5.4472135327643825, 9.786427261222144, 4.802280994098745, 5.667416935618994, 6.781362523683108, 8.025427646920194), # 159
(7.284872094904309, 5.675096728540714, 7.821920957955888, 8.89857751040886, 8.916420131346795, 5.024341296047684, 4.602243748383784, 5.3955991895273465, 9.697425227228651, 4.741205651862893, 5.59725950860954, 6.700501948887847, 7.93642060889358), # 160
(7.17322205458596, 5.577120868080469, 7.720046971910309, 8.774572503756728, 8.798393124282113, 4.963577241570314, 4.527681446006876, 5.33160053310978, 9.585829766999018, 4.6706581931709374, 5.515741654599707, 6.605767468907571, 7.830374044819097), # 161
(7.048121770426357, 5.469711258703239, 7.602021459615496, 8.632964006076326, 8.662135842303204, 4.891995305706455, 4.445007626339809, 5.255864173983202, 9.452814657913637, 4.5911569216102315, 5.42348155667862, 6.497908712841293, 7.708197254180333), # 162
(6.9103563668284975, 5.353441420893524, 7.468750020420702, 8.474753884611934, 8.508673839125688, 4.810193309587572, 4.354704059467401, 5.169036722619125, 9.299553677352906, 4.503220140768125, 5.321097397935408, 6.3776753097880325, 7.570799536460879), # 163
(6.760710968195384, 5.228884875135821, 7.321138253675176, 8.300944006607818, 8.339032668465189, 4.718769074345129, 4.257252515474466, 5.071764789489069, 9.127220602697223, 4.407366154231968, 5.209207361459196, 6.245816888846803, 7.419090191144328), # 164
(6.599970698930017, 5.096615141914632, 7.160091758728169, 8.112536239308252, 8.154237884037324, 4.618320421110586, 4.153134764445822, 4.964694985064546, 8.93698921132698, 4.3041132655891134, 5.088429630339111, 6.10308307911662, 7.25397851771427), # 165
(6.428920683435397, 4.957205741714454, 6.9865161349289275, 7.910532449957501, 7.955315039557714, 4.509445171015408, 4.042832576466286, 4.848473919817077, 8.730033280622573, 4.193979778426912, 4.959382387664279, 5.950223509696501, 7.0763738156542955), # 166
(6.248346046114523, 4.811230195019787, 6.801316981626704, 7.695934505799843, 7.74328968874198, 4.392741145191058, 3.9268277216206746, 4.723748204218176, 8.5075265879644, 4.077483996332714, 4.822683816523827, 5.7879878096854585, 6.887185384447996), # 167
(6.059031911370395, 4.659262022315128, 6.605399898170748, 7.469744274079546, 7.519187385305742, 4.268806164768999, 3.805601969993804, 4.5911644487393595, 8.270642910732855, 3.955144222893872, 4.678952100006881, 5.617125608182511, 6.6873225235789615), # 168
(5.861763403606015, 4.501874744084979, 6.399670483910309, 7.232963622040883, 7.28403368296462, 4.138238050880695, 3.6796370916704917, 4.451369263852145, 8.020556026308338, 3.8274787616977366, 4.528805421202568, 5.438386534286672, 6.477694532530785), # 169
(5.657325647224384, 4.339641880813837, 6.185034338194635, 6.98659441692812, 7.038854135434233, 4.001634624657607, 3.549414856735553, 4.305009260028047, 7.7584397120712385, 3.6950059163316578, 4.372861963200016, 5.252520217096959, 6.259210710787055), # 170
(5.4465037666285, 4.173136952986201, 5.962397060372978, 6.731638525985535, 6.784674296430206, 3.8595937072311983, 3.4154170352738054, 4.152731047738583, 7.485467745401956, 3.5582439903829886, 4.211739909088348, 5.060276285712386, 6.032780357831365), # 171
(5.230082886221365, 4.002933481086569, 5.7326642497945866, 6.4690978164573965, 6.5225197196681535, 3.7127131197329337, 3.2781253973700655, 3.9951812374552707, 7.202813903680886, 3.41771128743908, 4.046057441956694, 4.862404369231971, 5.799312773147303), # 172
(5.00884813040598, 3.8296049855994423, 5.4967415058087115, 6.1999741555879755, 6.253415958863702, 3.5615906832942748, 3.1380217131091497, 3.8330064396496235, 6.911651964288422, 3.2739261110872815, 3.8764327448941778, 4.659654096754725, 5.5597172562184625), # 173
(4.783584623585344, 3.653724987009318, 5.2555344277646014, 5.9252694106215404, 5.978388567732466, 3.406824219046685, 2.9955877525758754, 3.6668532647931604, 6.613155704604964, 3.1274067649149466, 3.7034840009899277, 4.452775097379668, 5.314903106528433), # 174
(4.555077490162455, 3.4758670058006946, 5.009948615011508, 5.645985448802367, 5.698463099990069, 3.2490115481216284, 2.851305285855058, 3.497368323357396, 6.308498902010905, 2.9786715525094243, 3.5278293933330693, 4.242517000205814, 5.0657796235608075), # 175
(4.324111854540319, 3.296604562458073, 4.760889666898678, 5.363124137374725, 5.41466510935213, 3.0887504916505666, 2.705656083031515, 3.325198225813849, 5.998855333886642, 2.828238777458067, 3.35008710501273, 4.029629434332179, 4.813256106799174), # 176
(4.0914728411219325, 3.1165111774659513, 4.5092631827753635, 5.077687343582883, 5.128020149534273, 2.9266388707649633, 2.5591219141900625, 3.1509895826340326, 5.68539877761257, 2.6766267433482245, 3.1708753191180357, 3.8148620288577786, 4.5582418557271245), # 177
(3.8579455743102966, 2.9361603713088282, 4.255974761990814, 4.790676934671116, 4.8395537742521135, 2.7632745065962827, 2.4121845494155174, 2.9753890042894655, 5.3693030105690855, 2.52435375376725, 2.9908122187381125, 3.598964412881627, 4.301646169828252), # 178
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 179
)
passenger_arriving_acc = (
(4, 4, 3, 5, 7, 3, 0, 1, 1, 0, 1, 0, 0, 5, 4, 4, 2, 5, 3, 1, 0, 2, 1, 0, 1, 0), # 0
(10, 7, 7, 8, 9, 4, 2, 3, 3, 1, 2, 1, 0, 11, 6, 7, 6, 13, 3, 2, 0, 2, 3, 3, 1, 0), # 1
(17, 11, 12, 15, 14, 4, 3, 6, 3, 4, 3, 1, 0, 20, 8, 9, 13, 20, 6, 5, 2, 3, 4, 3, 1, 0), # 2
(20, 16, 16, 19, 16, 5, 5, 10, 4, 7, 5, 1, 0, 23, 16, 17, 15, 25, 12, 10, 3, 4, 5, 4, 1, 0), # 3
(25, 19, 19, 29, 19, 6, 11, 11, 10, 9, 6, 1, 0, 29, 21, 20, 20, 29, 16, 12, 4, 7, 7, 5, 1, 0), # 4
(31, 23, 27, 36, 20, 7, 13, 11, 12, 10, 6, 3, 0, 43, 26, 25, 22, 36, 17, 15, 5, 8, 9, 5, 1, 0), # 5
(34, 33, 36, 45, 27, 11, 16, 12, 14, 12, 6, 4, 0, 50, 30, 28, 27, 40, 23, 19, 8, 14, 11, 5, 2, 0), # 6
(42, 39, 39, 53, 33, 13, 20, 13, 18, 13, 7, 4, 0, 57, 38, 38, 30, 47, 24, 21, 10, 16, 12, 5, 3, 0), # 7
(48, 47, 43, 59, 40, 15, 26, 15, 22, 15, 8, 4, 0, 67, 47, 41, 32, 50, 27, 23, 16, 20, 17, 6, 3, 0), # 8
(54, 56, 55, 63, 45, 20, 27, 15, 22, 17, 10, 5, 0, 74, 51, 46, 38, 57, 32, 29, 18, 24, 20, 6, 5, 0), # 9
(62, 64, 61, 72, 51, 22, 33, 19, 23, 18, 10, 6, 0, 83, 57, 54, 42, 59, 36, 33, 20, 24, 22, 8, 5, 0), # 10
(70, 70, 64, 76, 57, 25, 39, 20, 33, 18, 12, 6, 0, 93, 64, 55, 46, 65, 45, 39, 24, 27, 23, 8, 5, 0), # 11
(81, 79, 75, 82, 63, 27, 41, 22, 36, 20, 13, 6, 0, 108, 76, 60, 53, 72, 49, 40, 25, 30, 27, 10, 7, 0), # 12
(89, 92, 83, 88, 65, 29, 45, 23, 37, 21, 14, 8, 0, 120, 89, 65, 58, 79, 54, 41, 30, 35, 31, 17, 7, 0), # 13
(99, 110, 91, 94, 71, 34, 45, 29, 38, 24, 14, 9, 0, 131, 93, 70, 61, 89, 59, 42, 33, 39, 32, 17, 8, 0), # 14
(110, 118, 96, 99, 77, 34, 50, 34, 40, 24, 14, 9, 0, 144, 102, 79, 64, 95, 65, 45, 39, 42, 33, 19, 9, 0), # 15
(118, 134, 100, 105, 83, 36, 55, 36, 40, 25, 15, 9, 0, 154, 113, 84, 69, 105, 70, 51, 41, 42, 35, 21, 10, 0), # 16
(126, 145, 107, 110, 90, 39, 60, 41, 44, 26, 17, 9, 0, 160, 121, 88, 79, 112, 75, 57, 44, 43, 39, 21, 13, 0), # 17
(139, 152, 120, 118, 98, 41, 64, 44, 47, 30, 21, 10, 0, 169, 127, 91, 85, 122, 80, 59, 49, 47, 39, 23, 14, 0), # 18
(146, 165, 125, 122, 107, 44, 69, 48, 49, 32, 22, 10, 0, 177, 138, 99, 90, 132, 84, 60, 50, 49, 43, 30, 14, 0), # 19
(156, 172, 130, 132, 110, 46, 72, 56, 53, 35, 23, 11, 0, 187, 145, 104, 94, 138, 89, 64, 52, 51, 44, 30, 15, 0), # 20
(164, 181, 135, 142, 120, 48, 75, 64, 58, 39, 23, 11, 0, 195, 154, 111, 100, 143, 96, 65, 54, 56, 46, 33, 15, 0), # 21
(170, 189, 141, 148, 122, 51, 77, 67, 62, 41, 23, 11, 0, 202, 162, 116, 104, 148, 106, 67, 55, 60, 52, 34, 16, 0), # 22
(179, 196, 148, 156, 131, 58, 79, 68, 66, 42, 25, 12, 0, 209, 176, 123, 112, 158, 109, 69, 60, 62, 54, 35, 16, 0), # 23
(193, 205, 159, 164, 134, 60, 87, 72, 68, 44, 27, 13, 0, 218, 184, 131, 116, 165, 113, 77, 61, 66, 60, 36, 17, 0), # 24
(200, 216, 163, 169, 142, 61, 91, 76, 73, 46, 28, 13, 0, 229, 195, 144, 120, 172, 122, 81, 63, 71, 62, 38, 17, 0), # 25
(210, 225, 169, 182, 150, 65, 93, 77, 77, 50, 29, 13, 0, 237, 203, 152, 125, 180, 127, 86, 69, 75, 64, 40, 17, 0), # 26
(214, 232, 175, 192, 164, 69, 96, 80, 82, 53, 31, 14, 0, 247, 209, 158, 129, 196, 129, 92, 74, 80, 67, 44, 18, 0), # 27
(228, 248, 184, 207, 168, 70, 100, 82, 85, 54, 37, 16, 0, 258, 214, 167, 131, 200, 139, 97, 81, 82, 68, 46, 19, 0), # 28
(239, 260, 189, 218, 176, 71, 107, 86, 93, 56, 40, 16, 0, 266, 221, 174, 138, 208, 141, 102, 83, 86, 72, 47, 20, 0), # 29
(260, 273, 199, 233, 179, 74, 110, 87, 94, 59, 41, 17, 0, 272, 232, 186, 146, 215, 145, 103, 85, 90, 77, 48, 21, 0), # 30
(270, 285, 212, 242, 184, 76, 112, 92, 97, 59, 43, 17, 0, 279, 246, 195, 151, 220, 155, 108, 85, 93, 79, 49, 21, 0), # 31
(284, 292, 218, 248, 196, 80, 114, 97, 103, 64, 45, 17, 0, 287, 255, 201, 157, 228, 156, 114, 87, 99, 83, 50, 21, 0), # 32
(301, 310, 225, 254, 204, 85, 121, 98, 104, 68, 45, 18, 0, 294, 264, 207, 165, 231, 158, 120, 88, 101, 84, 53, 23, 0), # 33
(314, 324, 237, 267, 209, 89, 126, 103, 108, 70, 50, 19, 0, 305, 275, 213, 175, 238, 169, 124, 92, 106, 89, 55, 23, 0), # 34
(324, 332, 252, 278, 215, 90, 128, 107, 109, 71, 51, 20, 0, 310, 279, 221, 181, 245, 172, 126, 98, 108, 90, 58, 23, 0), # 35
(331, 341, 258, 288, 225, 92, 134, 114, 115, 71, 51, 21, 0, 325, 290, 230, 186, 254, 178, 134, 102, 114, 92, 58, 24, 0), # 36
(340, 354, 262, 292, 232, 94, 138, 114, 121, 72, 52, 22, 0, 332, 297, 242, 193, 264, 183, 137, 102, 117, 96, 62, 25, 0), # 37
(351, 364, 270, 301, 239, 99, 143, 118, 126, 75, 53, 23, 0, 349, 309, 249, 200, 273, 186, 144, 105, 117, 97, 64, 25, 0), # 38
(362, 376, 287, 307, 248, 105, 143, 121, 131, 75, 54, 23, 0, 357, 318, 257, 203, 285, 189, 148, 106, 121, 99, 67, 27, 0), # 39
(378, 387, 301, 313, 253, 107, 143, 125, 134, 75, 54, 25, 0, 368, 330, 265, 210, 297, 191, 153, 109, 125, 101, 69, 27, 0), # 40
(383, 397, 304, 325, 262, 108, 149, 127, 138, 76, 55, 27, 0, 383, 341, 277, 214, 303, 199, 156, 111, 128, 102, 69, 29, 0), # 41
(395, 406, 308, 334, 274, 114, 154, 130, 141, 78, 57, 27, 0, 394, 352, 280, 218, 309, 200, 157, 111, 128, 104, 70, 29, 0), # 42
(407, 418, 318, 342, 280, 118, 158, 134, 146, 81, 58, 28, 0, 402, 367, 284, 223, 317, 205, 160, 113, 129, 105, 70, 31, 0), # 43
(421, 429, 324, 349, 291, 124, 161, 140, 150, 81, 59, 29, 0, 412, 378, 289, 227, 321, 209, 163, 117, 132, 107, 71, 31, 0), # 44
(436, 442, 331, 358, 298, 125, 162, 144, 153, 83, 62, 30, 0, 419, 388, 294, 229, 323, 212, 166, 117, 135, 108, 72, 31, 0), # 45
(446, 448, 338, 365, 304, 127, 165, 149, 158, 84, 62, 31, 0, 436, 392, 301, 237, 330, 221, 168, 119, 140, 111, 75, 35, 0), # 46
(461, 462, 350, 372, 313, 129, 170, 154, 162, 87, 63, 31, 0, 446, 398, 307, 243, 337, 223, 174, 121, 149, 114, 76, 35, 0), # 47
(472, 470, 358, 376, 317, 134, 174, 162, 169, 89, 65, 34, 0, 455, 406, 316, 246, 343, 230, 175, 123, 153, 117, 77, 36, 0), # 48
(478, 476, 362, 385, 323, 137, 176, 165, 178, 94, 66, 35, 0, 461, 420, 322, 254, 354, 236, 180, 127, 158, 119, 81, 36, 0), # 49
(485, 492, 372, 397, 330, 137, 178, 168, 184, 100, 69, 37, 0, 471, 423, 328, 258, 363, 240, 185, 128, 166, 123, 82, 37, 0), # 50
(489, 502, 380, 407, 337, 138, 184, 172, 186, 105, 71, 39, 0, 491, 432, 333, 261, 371, 244, 191, 130, 169, 126, 83, 38, 0), # 51
(501, 510, 386, 412, 344, 142, 184, 176, 188, 107, 72, 39, 0, 502, 442, 347, 269, 381, 248, 197, 132, 174, 130, 86, 40, 0), # 52
(510, 519, 393, 418, 354, 145, 184, 182, 192, 109, 73, 40, 0, 510, 460, 350, 273, 395, 250, 203, 133, 180, 133, 87, 44, 0), # 53
(513, 527, 407, 428, 367, 145, 184, 187, 199, 111, 74, 41, 0, 519, 469, 365, 276, 405, 255, 204, 135, 184, 135, 90, 45, 0), # 54
(529, 536, 422, 431, 379, 152, 190, 191, 206, 114, 76, 41, 0, 524, 483, 372, 278, 415, 258, 208, 138, 187, 137, 92, 46, 0), # 55
(543, 544, 430, 439, 386, 153, 195, 193, 212, 117, 80, 43, 0, 540, 493, 379, 286, 422, 265, 215, 139, 189, 139, 94, 46, 0), # 56
(557, 551, 435, 451, 393, 158, 198, 195, 214, 119, 82, 44, 0, 550, 499, 385, 291, 428, 272, 217, 143, 190, 146, 94, 47, 0), # 57
(561, 563, 440, 461, 398, 161, 201, 199, 216, 121, 83, 44, 0, 556, 507, 392, 299, 438, 277, 222, 144, 192, 150, 95, 48, 0), # 58
(569, 574, 446, 468, 407, 161, 203, 201, 220, 124, 84, 46, 0, 565, 516, 399, 307, 444, 286, 227, 145, 197, 153, 97, 48, 0), # 59
(577, 578, 454, 485, 410, 164, 205, 205, 223, 128, 86, 47, 0, 573, 521, 403, 314, 450, 290, 229, 147, 199, 158, 99, 49, 0), # 60
(585, 587, 459, 499, 416, 165, 215, 212, 226, 131, 90, 48, 0, 585, 532, 408, 322, 460, 293, 231, 149, 205, 162, 100, 50, 0), # 61
(592, 596, 467, 506, 422, 172, 220, 214, 233, 132, 93, 48, 0, 598, 538, 416, 324, 466, 299, 236, 151, 207, 166, 104, 52, 0), # 62
(606, 612, 476, 513, 433, 175, 223, 216, 237, 133, 93, 49, 0, 610, 547, 423, 331, 474, 301, 238, 154, 213, 168, 106, 53, 0), # 63
(613, 622, 489, 522, 436, 184, 229, 220, 239, 133, 94, 51, 0, 625, 553, 432, 333, 479, 305, 242, 155, 218, 174, 106, 53, 0), # 64
(625, 626, 497, 533, 444, 186, 236, 225, 241, 135, 95, 51, 0, 639, 559, 438, 334, 487, 309, 242, 158, 220, 174, 106, 55, 0), # 65
(628, 640, 503, 538, 448, 190, 240, 227, 243, 137, 96, 51, 0, 654, 568, 445, 341, 495, 315, 246, 165, 228, 178, 106, 55, 0), # 66
(635, 655, 511, 550, 456, 196, 244, 229, 245, 140, 98, 52, 0, 673, 574, 455, 346, 510, 320, 247, 166, 232, 179, 108, 55, 0), # 67
(641, 660, 519, 555, 461, 201, 248, 230, 248, 142, 98, 53, 0, 681, 586, 458, 353, 516, 321, 248, 170, 237, 180, 110, 55, 0), # 68
(652, 673, 530, 566, 466, 203, 252, 233, 251, 142, 100, 53, 0, 687, 602, 467, 359, 523, 322, 251, 172, 238, 185, 111, 55, 0), # 69
(663, 677, 534, 578, 471, 208, 255, 237, 256, 142, 102, 53, 0, 695, 607, 475, 365, 528, 325, 258, 177, 239, 189, 114, 56, 0), # 70
(680, 692, 540, 584, 483, 210, 259, 238, 257, 142, 103, 54, 0, 700, 617, 478, 370, 535, 325, 260, 180, 242, 193, 116, 56, 0), # 71
(694, 702, 553, 590, 492, 213, 262, 238, 260, 143, 105, 55, 0, 710, 624, 485, 378, 541, 326, 263, 185, 244, 197, 118, 58, 0), # 72
(705, 713, 566, 597, 498, 218, 264, 240, 263, 146, 105, 55, 0, 727, 633, 489, 382, 549, 331, 267, 186, 245, 198, 120, 59, 0), # 73
(716, 720, 570, 608, 507, 222, 269, 241, 269, 146, 109, 56, 0, 741, 636, 493, 385, 558, 335, 272, 190, 258, 202, 124, 59, 0), # 74
(726, 725, 575, 618, 513, 226, 269, 246, 275, 148, 110, 58, 0, 756, 643, 500, 390, 566, 341, 278, 195, 260, 206, 125, 59, 0), # 75
(735, 734, 588, 627, 517, 233, 275, 249, 279, 152, 111, 60, 0, 766, 653, 504, 397, 576, 344, 281, 195, 263, 211, 129, 61, 0), # 76
(747, 740, 596, 637, 524, 236, 278, 259, 280, 153, 112, 60, 0, 778, 665, 510, 401, 585, 347, 287, 197, 266, 212, 131, 63, 0), # 77
(758, 748, 602, 644, 533, 240, 282, 259, 284, 154, 113, 60, 0, 789, 678, 512, 404, 590, 353, 290, 199, 268, 215, 131, 63, 0), # 78
(770, 754, 614, 662, 544, 246, 282, 263, 289, 155, 114, 62, 0, 797, 688, 519, 407, 599, 355, 297, 203, 272, 217, 131, 65, 0), # 79
(780, 764, 625, 668, 551, 250, 288, 265, 292, 156, 117, 65, 0, 807, 699, 527, 413, 601, 357, 303, 207, 272, 221, 134, 66, 0), # 80
(800, 773, 632, 676, 555, 254, 291, 271, 296, 161, 117, 65, 0, 816, 706, 534, 419, 612, 365, 308, 207, 274, 225, 134, 66, 0), # 81
(809, 782, 643, 682, 561, 259, 293, 274, 299, 163, 119, 67, 0, 826, 720, 542, 422, 624, 374, 310, 210, 276, 229, 135, 67, 0), # 82
(820, 786, 650, 693, 574, 267, 296, 275, 300, 163, 120, 69, 0, 834, 726, 546, 432, 631, 382, 318, 211, 280, 233, 136, 68, 0), # 83
(830, 795, 666, 702, 581, 273, 300, 277, 300, 165, 120, 70, 0, 843, 733, 551, 436, 636, 387, 321, 214, 285, 240, 138, 69, 0), # 84
(838, 800, 678, 712, 589, 276, 304, 280, 304, 165, 123, 70, 0, 856, 747, 554, 440, 641, 391, 323, 215, 288, 246, 140, 69, 0), # 85
(849, 812, 687, 724, 599, 277, 309, 284, 307, 165, 123, 70, 0, 868, 752, 560, 444, 644, 396, 326, 216, 292, 252, 141, 70, 0), # 86
(860, 819, 693, 734, 601, 280, 313, 290, 310, 172, 123, 70, 0, 873, 761, 566, 450, 657, 399, 330, 222, 296, 261, 145, 70, 0), # 87
(870, 830, 702, 742, 612, 286, 315, 290, 312, 173, 124, 70, 0, 882, 766, 569, 455, 666, 401, 336, 223, 301, 266, 145, 70, 0), # 88
(884, 838, 709, 750, 615, 288, 320, 292, 317, 176, 124, 70, 0, 891, 774, 577, 458, 675, 406, 336, 224, 303, 268, 146, 71, 0), # 89
(889, 850, 717, 752, 620, 289, 325, 294, 323, 177, 124, 70, 0, 900, 781, 579, 465, 684, 410, 340, 225, 306, 269, 146, 71, 0), # 90
(895, 858, 725, 762, 622, 293, 329, 298, 325, 180, 128, 70, 0, 905, 792, 588, 468, 690, 415, 342, 225, 309, 276, 147, 72, 0), # 91
(899, 862, 729, 771, 627, 293, 334, 306, 331, 182, 130, 71, 0, 908, 800, 592, 474, 697, 418, 348, 227, 313, 280, 147, 72, 0), # 92
(906, 876, 735, 788, 633, 299, 338, 311, 338, 182, 133, 71, 0, 925, 809, 598, 481, 703, 422, 350, 228, 318, 282, 149, 73, 0), # 93
(914, 883, 742, 798, 636, 303, 339, 315, 341, 184, 134, 72, 0, 934, 812, 605, 490, 711, 429, 353, 231, 322, 284, 154, 74, 0), # 94
(923, 890, 744, 804, 645, 305, 339, 317, 345, 185, 134, 72, 0, 944, 819, 618, 495, 718, 431, 357, 232, 325, 291, 156, 74, 0), # 95
(937, 896, 747, 820, 650, 308, 342, 320, 346, 185, 136, 73, 0, 952, 823, 626, 503, 730, 433, 360, 234, 327, 291, 157, 75, 0), # 96
(946, 905, 753, 829, 657, 312, 348, 323, 355, 187, 137, 74, 0, 960, 828, 631, 509, 739, 438, 362, 239, 330, 298, 160, 75, 0), # 97
(957, 914, 755, 837, 662, 316, 349, 325, 358, 188, 137, 77, 0, 971, 840, 639, 517, 742, 441, 367, 241, 334, 298, 162, 76, 0), # 98
(961, 925, 761, 847, 671, 317, 351, 325, 363, 190, 137, 77, 0, 983, 848, 647, 521, 748, 443, 372, 242, 334, 300, 163, 77, 0), # 99
(968, 931, 769, 860, 679, 321, 355, 327, 368, 193, 137, 78, 0, 996, 862, 657, 523, 757, 445, 375, 245, 340, 302, 165, 77, 0), # 100
(984, 938, 780, 872, 689, 325, 358, 329, 381, 193, 139, 78, 0, 1004, 873, 662, 524, 765, 448, 379, 246, 343, 304, 165, 78, 0), # 101
(992, 945, 786, 882, 696, 329, 361, 330, 381, 196, 141, 78, 0, 1016, 876, 668, 529, 773, 449, 383, 255, 344, 305, 165, 78, 0), # 102
(1008, 948, 796, 890, 703, 329, 363, 333, 386, 199, 141, 78, 0, 1028, 886, 672, 535, 778, 452, 383, 262, 348, 309, 171, 78, 0), # 103
(1018, 959, 804, 894, 709, 333, 363, 335, 388, 200, 142, 80, 0, 1037, 893, 679, 543, 781, 460, 386, 263, 349, 312, 171, 78, 0), # 104
(1027, 968, 810, 904, 715, 336, 365, 336, 392, 201, 143, 82, 0, 1049, 901, 684, 545, 788, 464, 388, 267, 350, 315, 173, 78, 0), # 105
(1033, 976, 820, 915, 720, 338, 370, 338, 396, 203, 143, 82, 0, 1057, 908, 691, 546, 795, 467, 395, 272, 356, 317, 173, 79, 0), # 106
(1045, 986, 827, 924, 729, 341, 375, 340, 400, 206, 144, 83, 0, 1064, 912, 697, 552, 803, 474, 399, 274, 360, 322, 174, 79, 0), # 107
(1050, 996, 841, 935, 737, 344, 376, 343, 401, 209, 147, 83, 0, 1077, 921, 699, 553, 815, 481, 403, 276, 365, 324, 175, 79, 0), # 108
(1065, 1001, 855, 947, 744, 346, 380, 345, 404, 211, 148, 83, 0, 1087, 930, 711, 556, 820, 481, 404, 281, 368, 326, 176, 80, 0), # 109
(1079, 1014, 863, 953, 750, 353, 384, 345, 412, 212, 149, 83, 0, 1093, 934, 719, 564, 826, 484, 407, 282, 372, 329, 178, 81, 0), # 110
(1093, 1017, 870, 962, 758, 355, 386, 347, 414, 213, 150, 83, 0, 1102, 945, 726, 568, 830, 487, 407, 288, 375, 333, 181, 81, 0), # 111
(1102, 1023, 881, 972, 763, 355, 389, 348, 417, 214, 152, 84, 0, 1112, 957, 730, 578, 834, 491, 411, 292, 379, 336, 181, 81, 0), # 112
(1115, 1037, 894, 976, 773, 359, 390, 349, 420, 215, 153, 84, 0, 1124, 963, 736, 584, 843, 495, 415, 294, 384, 337, 181, 81, 0), # 113
(1125, 1045, 904, 985, 781, 363, 392, 353, 425, 215, 153, 85, 0, 1134, 970, 741, 589, 849, 499, 419, 295, 387, 345, 182, 81, 0), # 114
(1133, 1058, 912, 997, 784, 366, 393, 353, 429, 217, 155, 86, 0, 1150, 978, 745, 591, 855, 501, 420, 299, 389, 349, 184, 81, 0), # 115
(1139, 1065, 917, 1010, 792, 370, 395, 356, 438, 217, 155, 86, 0, 1160, 984, 752, 593, 866, 502, 422, 303, 393, 350, 185, 81, 0), # 116
(1151, 1078, 925, 1014, 799, 377, 397, 359, 441, 218, 156, 88, 0, 1163, 992, 756, 597, 874, 506, 426, 308, 395, 357, 188, 81, 0), # 117
(1157, 1085, 931, 1020, 803, 378, 401, 360, 444, 219, 156, 89, 0, 1174, 999, 764, 599, 884, 508, 428, 313, 399, 360, 189, 81, 0), # 118
(1167, 1092, 941, 1026, 812, 384, 405, 361, 447, 220, 158, 91, 0, 1183, 1008, 769, 603, 894, 513, 430, 317, 404, 363, 189, 81, 0), # 119
(1174, 1100, 946, 1036, 814, 386, 407, 364, 452, 220, 160, 92, 0, 1193, 1014, 772, 608, 902, 515, 435, 322, 409, 366, 192, 82, 0), # 120
(1183, 1110, 949, 1045, 823, 388, 412, 367, 453, 222, 160, 93, 0, 1197, 1025, 778, 614, 905, 519, 437, 323, 411, 369, 194, 82, 0), # 121
(1187, 1119, 955, 1054, 828, 392, 413, 373, 461, 224, 160, 94, 0, 1209, 1032, 786, 616, 912, 522, 441, 324, 415, 372, 195, 84, 0), # 122
(1199, 1122, 963, 1062, 841, 393, 413, 376, 463, 224, 161, 94, 0, 1221, 1039, 792, 617, 919, 527, 443, 325, 418, 375, 196, 85, 0), # 123
(1213, 1128, 974, 1069, 850, 396, 415, 378, 470, 224, 161, 94, 0, 1234, 1047, 796, 620, 927, 534, 445, 329, 420, 378, 197, 85, 0), # 124
(1223, 1131, 982, 1079, 856, 400, 418, 380, 474, 227, 161, 94, 0, 1248, 1054, 803, 622, 932, 537, 448, 331, 423, 381, 198, 85, 0), # 125
(1237, 1140, 993, 1087, 861, 405, 422, 380, 480, 227, 161, 94, 0, 1254, 1058, 813, 625, 936, 542, 452, 333, 426, 381, 199, 86, 0), # 126
(1242, 1149, 1006, 1094, 868, 407, 425, 383, 481, 229, 164, 95, 0, 1265, 1069, 821, 628, 945, 547, 456, 334, 429, 383, 201, 86, 0), # 127
(1251, 1157, 1015, 1100, 874, 415, 428, 384, 487, 231, 166, 95, 0, 1274, 1073, 827, 630, 956, 547, 460, 336, 433, 384, 203, 87, 0), # 128
(1260, 1163, 1026, 1106, 878, 421, 428, 386, 490, 232, 168, 97, 0, 1283, 1083, 834, 631, 960, 550, 464, 339, 438, 388, 204, 88, 0), # 129
(1268, 1177, 1036, 1111, 885, 424, 431, 389, 492, 232, 168, 100, 0, 1287, 1090, 840, 637, 966, 552, 469, 339, 439, 391, 204, 90, 0), # 130
(1276, 1182, 1041, 1116, 893, 429, 434, 392, 494, 233, 168, 101, 0, 1296, 1094, 847, 642, 972, 557, 473, 340, 442, 395, 206, 90, 0), # 131
(1282, 1189, 1051, 1123, 897, 429, 438, 396, 499, 235, 171, 101, 0, 1307, 1100, 851, 645, 979, 560, 477, 341, 446, 398, 209, 92, 0), # 132
(1290, 1197, 1059, 1128, 904, 434, 438, 396, 501, 238, 172, 103, 0, 1316, 1110, 854, 648, 982, 563, 484, 344, 448, 399, 209, 93, 0), # 133
(1295, 1200, 1069, 1135, 911, 439, 442, 398, 504, 240, 173, 104, 0, 1324, 1115, 861, 650, 989, 565, 489, 346, 450, 405, 211, 93, 0), # 134
(1308, 1203, 1077, 1146, 914, 442, 444, 399, 507, 240, 174, 104, 0, 1339, 1130, 865, 654, 998, 567, 496, 346, 452, 406, 217, 94, 0), # 135
(1318, 1211, 1089, 1156, 920, 445, 446, 401, 511, 242, 174, 104, 0, 1347, 1136, 873, 657, 1001, 569, 500, 350, 453, 409, 219, 96, 0), # 136
(1331, 1217, 1092, 1167, 922, 448, 451, 405, 513, 242, 175, 105, 0, 1356, 1143, 877, 662, 1007, 576, 502, 354, 459, 413, 222, 97, 0), # 137
(1337, 1231, 1095, 1172, 928, 450, 455, 408, 518, 247, 175, 105, 0, 1368, 1148, 881, 670, 1011, 580, 505, 356, 461, 414, 223, 97, 0), # 138
(1343, 1242, 1101, 1182, 934, 456, 460, 411, 521, 248, 176, 105, 0, 1375, 1155, 883, 673, 1016, 582, 509, 359, 467, 415, 223, 99, 0), # 139
(1349, 1252, 1110, 1186, 940, 458, 462, 412, 523, 250, 176, 107, 0, 1389, 1162, 889, 675, 1019, 588, 510, 360, 471, 419, 227, 99, 0), # 140
(1352, 1262, 1121, 1193, 944, 458, 466, 413, 526, 250, 176, 108, 0, 1395, 1177, 896, 677, 1027, 592, 512, 360, 473, 421, 229, 99, 0), # 141
(1363, 1272, 1128, 1200, 954, 460, 469, 418, 528, 252, 177, 111, 0, 1409, 1188, 902, 681, 1033, 597, 513, 361, 477, 424, 232, 101, 0), # 142
(1368, 1282, 1135, 1207, 959, 464, 470, 419, 532, 253, 178, 111, 0, 1412, 1196, 908, 682, 1036, 601, 517, 363, 482, 427, 233, 102, 0), # 143
(1382, 1289, 1147, 1217, 966, 468, 473, 420, 534, 254, 178, 111, 0, 1426, 1205, 916, 686, 1042, 604, 519, 370, 486, 427, 234, 102, 0), # 144
(1386, 1291, 1159, 1227, 978, 471, 476, 420, 540, 256, 178, 111, 0, 1434, 1219, 920, 690, 1047, 608, 523, 370, 489, 429, 234, 102, 0), # 145
(1392, 1301, 1160, 1232, 985, 474, 478, 422, 544, 257, 181, 111, 0, 1445, 1225, 923, 692, 1053, 611, 524, 371, 495, 433, 237, 102, 0), # 146
(1401, 1304, 1165, 1239, 987, 479, 482, 424, 553, 259, 181, 111, 0, 1454, 1235, 925, 698, 1062, 615, 526, 372, 499, 435, 239, 102, 0), # 147
(1410, 1304, 1171, 1240, 990, 480, 485, 425, 557, 261, 182, 111, 0, 1462, 1239, 927, 703, 1069, 621, 529, 373, 502, 437, 240, 103, 0), # 148
(1421, 1313, 1181, 1251, 993, 483, 487, 427, 558, 262, 184, 111, 0, 1473, 1244, 929, 709, 1079, 623, 533, 374, 502, 439, 241, 103, 0), # 149
(1429, 1319, 1188, 1259, 999, 485, 488, 429, 562, 263, 186, 111, 0, 1483, 1245, 936, 713, 1085, 625, 535, 380, 508, 441, 244, 103, 0), # 150
(1434, 1328, 1196, 1264, 999, 487, 492, 431, 564, 264, 187, 112, 0, 1490, 1258, 938, 719, 1092, 628, 537, 381, 510, 443, 246, 103, 0), # 151
(1449, 1335, 1199, 1273, 1006, 491, 495, 431, 568, 264, 187, 112, 0, 1493, 1266, 944, 722, 1102, 631, 539, 383, 512, 444, 249, 103, 0), # 152
(1459, 1343, 1203, 1279, 1010, 493, 496, 433, 570, 266, 188, 112, 0, 1499, 1276, 946, 726, 1105, 633, 541, 386, 513, 445, 250, 103, 0), # 153
(1464, 1347, 1209, 1284, 1019, 493, 499, 436, 571, 266, 191, 112, 0, 1507, 1282, 953, 731, 1115, 635, 544, 391, 515, 447, 252, 104, 0), # 154
(1478, 1351, 1210, 1290, 1024, 494, 501, 437, 576, 269, 192, 113, 0, 1513, 1294, 956, 735, 1125, 635, 545, 394, 520, 451, 253, 104, 0), # 155
(1491, 1358, 1216, 1297, 1031, 501, 505, 438, 576, 271, 192, 114, 0, 1523, 1301, 959, 737, 1129, 636, 546, 399, 523, 452, 255, 104, 0), # 156
(1500, 1362, 1221, 1303, 1035, 509, 505, 439, 579, 276, 193, 115, 0, 1534, 1305, 972, 737, 1137, 636, 549, 403, 527, 455, 256, 104, 0), # 157
(1506, 1364, 1224, 1313, 1041, 512, 506, 441, 583, 279, 194, 115, 0, 1546, 1310, 977, 740, 1142, 638, 552, 404, 530, 455, 258, 105, 0), # 158
(1514, 1368, 1233, 1320, 1050, 512, 507, 442, 584, 281, 195, 116, 0, 1554, 1313, 985, 745, 1148, 638, 552, 405, 531, 457, 258, 106, 0), # 159
(1518, 1373, 1237, 1328, 1053, 517, 507, 444, 586, 281, 196, 116, 0, 1562, 1321, 992, 750, 1153, 640, 558, 410, 532, 457, 259, 106, 0), # 160
(1527, 1377, 1244, 1338, 1061, 522, 511, 450, 588, 281, 197, 116, 0, 1567, 1327, 995, 753, 1155, 643, 559, 413, 533, 458, 259, 107, 0), # 161
(1534, 1381, 1249, 1342, 1064, 524, 513, 455, 592, 283, 198, 116, 0, 1579, 1331, 998, 754, 1160, 646, 560, 415, 538, 458, 260, 107, 0), # 162
(1536, 1385, 1257, 1347, 1074, 528, 516, 456, 593, 283, 199, 117, 0, 1587, 1334, 1000, 761, 1166, 647, 562, 417, 540, 459, 260, 107, 0), # 163
(1542, 1392, 1262, 1351, 1079, 531, 518, 457, 597, 286, 201, 118, 0, 1595, 1340, 1009, 766, 1175, 648, 566, 419, 543, 459, 261, 107, 0), # 164
(1547, 1396, 1271, 1359, 1088, 533, 520, 457, 597, 288, 201, 118, 0, 1606, 1346, 1013, 771, 1180, 653, 568, 421, 546, 461, 262, 107, 0), # 165
(1549, 1398, 1278, 1367, 1093, 535, 523, 458, 598, 288, 201, 118, 0, 1617, 1349, 1017, 774, 1185, 654, 571, 422, 548, 461, 265, 108, 0), # 166
(1558, 1400, 1284, 1373, 1096, 536, 526, 458, 599, 288, 202, 118, 0, 1623, 1358, 1022, 778, 1188, 658, 573, 425, 551, 463, 266, 108, 0), # 167
(1567, 1401, 1289, 1380, 1100, 540, 528, 459, 603, 289, 203, 118, 0, 1627, 1363, 1024, 780, 1192, 658, 575, 428, 553, 467, 269, 108, 0), # 168
(1574, 1404, 1291, 1390, 1101, 542, 528, 462, 604, 289, 203, 119, 0, 1637, 1366, 1026, 783, 1197, 664, 576, 428, 556, 468, 271, 109, 0), # 169
(1579, 1408, 1295, 1395, 1107, 545, 529, 462, 604, 291, 205, 120, 0, 1643, 1372, 1032, 784, 1203, 665, 578, 430, 557, 468, 273, 109, 0), # 170
(1588, 1410, 1298, 1402, 1112, 548, 530, 466, 610, 291, 205, 120, 0, 1647, 1381, 1034, 787, 1210, 669, 579, 432, 560, 470, 273, 110, 0), # 171
(1593, 1413, 1303, 1409, 1119, 549, 530, 469, 614, 292, 208, 123, 0, 1657, 1385, 1035, 789, 1216, 669, 580, 435, 562, 472, 273, 111, 0), # 172
(1599, 1414, 1304, 1415, 1120, 550, 531, 470, 615, 292, 210, 124, 0, 1664, 1390, 1037, 792, 1220, 669, 582, 436, 564, 474, 274, 111, 0), # 173
(1604, 1418, 1306, 1420, 1124, 552, 531, 472, 618, 292, 210, 124, 0, 1678, 1392, 1042, 794, 1222, 672, 584, 437, 565, 474, 275, 111, 0), # 174
(1611, 1423, 1311, 1422, 1135, 555, 533, 475, 624, 293, 211, 124, 0, 1683, 1397, 1046, 799, 1224, 674, 584, 438, 569, 477, 275, 111, 0), # 175
(1613, 1425, 1315, 1424, 1137, 556, 536, 478, 626, 293, 212, 124, 0, 1690, 1401, 1048, 802, 1227, 677, 585, 438, 572, 480, 275, 111, 0), # 176
(1615, 1429, 1323, 1427, 1143, 556, 538, 481, 627, 296, 213, 124, 0, 1692, 1403, 1054, 804, 1229, 678, 588, 439, 574, 481, 276, 111, 0), # 177
(1618, 1436, 1327, 1430, 1146, 558, 540, 484, 629, 296, 215, 124, 0, 1695, 1405, 1054, 805, 1233, 678, 591, 440, 577, 481, 277, 111, 0), # 178
(1618, 1436, 1327, 1430, 1146, 558, 540, 484, 629, 296, 215, 124, 0, 1695, 1405, 1054, 805, 1233, 678, 591, 440, 577, 481, 277, 111, 0), # 179
)
passenger_arriving_rate = (
(5.020865578371768, 5.064847846385402, 4.342736024677089, 4.661000830397574, 3.7031237384064077, 1.8308820436884476, 2.0730178076869574, 1.938823405408093, 2.030033020722669, 0.9895037538805926, 0.7008775273142672, 0.4081595898588478, 0.0, 5.083880212578363, 4.489755488447325, 3.5043876365713356, 2.968511261641777, 4.060066041445338, 2.7143527675713304, 2.0730178076869574, 1.3077728883488913, 1.8515618692032039, 1.5536669434658585, 0.8685472049354179, 0.4604407133077639, 0.0), # 0
(5.354327152019974, 5.399222302966028, 4.629455492775127, 4.968858189957462, 3.948326891649491, 1.9518237573581576, 2.209734470631847, 2.066464051210712, 2.164081775444303, 1.0547451730692876, 0.7471826893260219, 0.4351013884011963, 0.0, 5.419791647439855, 4.786115272413158, 3.73591344663011, 3.164235519207862, 4.328163550888606, 2.8930496716949965, 2.209734470631847, 1.3941598266843982, 1.9741634458247455, 1.6562860633191545, 0.9258910985550255, 0.49083839117872996, 0.0), # 1
(5.686723008979731, 5.732269739983398, 4.915035237956178, 5.275490778498595, 4.192641982499829, 2.072282983465593, 2.345909253980352, 2.193593853293508, 2.297595602292516, 1.1197284437551367, 0.7933038581293855, 0.46193605433775464, 0.0, 5.75436482820969, 5.0812965977153, 3.9665192906469278, 3.3591853312654094, 4.595191204585032, 3.0710313946109116, 2.345909253980352, 1.480202131046852, 2.0963209912499146, 1.758496926166199, 0.9830070475912357, 0.5211154309075817, 0.0), # 2
(6.016757793146562, 6.062668793441743, 5.198342391099879, 5.579682305649055, 4.435107784001268, 2.191782029841316, 2.4810018208239777, 2.3197088156227115, 2.430045053640364, 1.1841956746065454, 0.8390580686378972, 0.4885571404108718, 0.0, 6.086272806254225, 5.374128544519589, 4.195290343189486, 3.5525870238196355, 4.860090107280728, 3.247592341871796, 2.4810018208239777, 1.5655585927437972, 2.217553892000634, 1.8598941018830188, 1.0396684782199759, 0.551151708494704, 0.0), # 3
(6.343136148415981, 6.389098099345293, 5.478244083085864, 5.880216481036927, 4.674763069197661, 2.3098432043158894, 2.6144718342542292, 2.444304942164548, 2.560900681860902, 1.24788897429192, 0.8842623557650959, 0.514858199362897, 0.0, 6.414188632939817, 5.6634401929918665, 4.42131177882548, 3.743666922875759, 5.121801363721804, 3.422026919030367, 2.6144718342542292, 1.6498880030827783, 2.3373815345988307, 1.9600721603456428, 1.095648816617173, 0.5808270999404813, 0.0), # 4
(6.66456271868351, 6.710236293698289, 5.753607444793765, 6.175877014290295, 4.910646611132853, 2.4259888147198754, 2.745778957362612, 2.566878236885247, 2.689633039327186, 1.310550451479666, 0.9287337544245222, 0.5407327839361791, 0.0, 6.736785359632827, 5.948060623297969, 4.64366877212261, 3.9316513544389973, 5.379266078654372, 3.593629531639346, 2.745778957362612, 1.7328491533713395, 2.4553233055664263, 2.058625671430099, 1.1507214889587531, 0.6100214812452991, 0.0), # 5
(6.979742147844666, 7.024762012504959, 6.023299607103222, 6.465447615037239, 5.141797182850695, 2.5397411688838374, 2.8743828532406313, 2.686924703751037, 2.8157126784122717, 1.3719222148381898, 0.9722892995297139, 0.5660744468730674, 0.0, 7.052736037699606, 6.22681891560374, 4.8614464976485685, 4.115766644514569, 5.631425356824543, 3.761694585251452, 2.8743828532406313, 1.8141008349170267, 2.5708985914253475, 2.1551492050124135, 1.2046599214206444, 0.6386147284095418, 0.0), # 6
(7.2873790797949685, 7.331353891769537, 6.286187700893863, 6.747711992905847, 5.367253557395036, 2.650622574638337, 2.9997431849797924, 2.8039403467281465, 2.9386101514892147, 1.4317463730358968, 1.0147460259942116, 0.5907767409159108, 0.0, 7.360713718506519, 6.498544150075018, 5.073730129971057, 4.2952391191076895, 5.877220302978429, 3.9255164854194056, 2.9997431849797924, 1.8933018390273837, 2.683626778697518, 2.249237330968616, 1.2572375401787725, 0.6664867174335943, 0.0), # 7
(7.586178158429934, 7.628690567496257, 6.54113885704533, 7.021453857524196, 5.586054507809724, 2.7581553398139356, 3.1213196156715988, 2.917421169782802, 3.0577960109310682, 1.4897650347411937, 1.0559209687315536, 0.6147332188070586, 0.0, 7.659391453419917, 6.762065406877643, 5.279604843657768, 4.469295104223581, 6.1155920218621365, 4.084389637695923, 3.1213196156715988, 1.970110957009954, 2.793027253904862, 2.3404846191747324, 1.3082277714090662, 0.6935173243178416, 0.0), # 8
(7.874844027645085, 7.915450675689353, 6.787020206437253, 7.285456918520376, 5.797238807138606, 2.861861772241199, 3.23857180840756, 3.0268631768812346, 3.1727408091108913, 1.5457203086224858, 1.0956311626552797, 0.6378374332888596, 0.0, 7.947442293806162, 7.016211766177453, 5.478155813276398, 4.637160925867456, 6.345481618221783, 4.237608447633728, 3.23857180840756, 2.044186980172285, 2.898619403569303, 2.4284856395067926, 1.3574040412874508, 0.7195864250626686, 0.0), # 9
(8.152081331335932, 8.190312852353056, 7.022698879949271, 7.538504885522466, 5.999845228425533, 2.961264179750688, 3.3509594262791773, 3.1317623719896712, 3.282915098401738, 1.599354303348179, 1.133693642678929, 0.6599829371036627, 0.0, 8.22353929103161, 7.259812308140289, 5.668468213394645, 4.798062910044536, 6.565830196803476, 4.384467320785539, 3.3509594262791773, 2.11518869982192, 2.9999226142127666, 2.5128349618408223, 1.4045397759898541, 0.7445738956684597, 0.0), # 10
(8.416594713398005, 8.451955733491605, 7.247042008461013, 7.779381468158547, 6.192912544714355, 3.055884870172965, 3.457942132377958, 3.2316147590743394, 3.3877894311766643, 1.6504091275866801, 1.1699254437160416, 0.6810632829938176, 0.0, 8.486355496462611, 7.491696112931993, 5.849627218580208, 4.951227382760039, 6.775578862353329, 4.524260662704076, 3.457942132377958, 2.1827749072664036, 3.0964562723571776, 2.5931271560528497, 1.4494084016922026, 0.7683596121356006, 0.0), # 11
(8.667088817726812, 8.699057955109222, 7.458916722852117, 8.006870376056709, 6.375479529048918, 3.1452461513385908, 3.5589795897954057, 3.325916342101467, 3.486834359808726, 1.6986268900063934, 1.2041436006801558, 0.7009720237016724, 0.0, 8.734563961465534, 7.710692260718395, 6.020718003400779, 5.095880670019179, 6.973668719617452, 4.656282878942054, 3.5589795897954057, 2.246604393813279, 3.187739764524459, 2.6689567920189035, 1.4917833445704234, 0.7908234504644749, 0.0), # 12
(8.902268288217876, 8.93029815321015, 7.657190154002218, 8.219755318845033, 6.546584954473067, 3.2288703310781304, 3.653531461623028, 3.414163125037284, 3.579520436670977, 1.7437496992757264, 1.2361651484848115, 0.7196027119695768, 0.0, 8.966837737406735, 7.915629831665344, 6.180825742424058, 5.2312490978271775, 7.159040873341954, 4.7798283750521975, 3.653531461623028, 2.306335950770093, 3.2732924772365335, 2.7399184396150114, 1.5314380308004438, 0.8118452866554684, 0.0), # 13
(9.120837768766716, 9.144354963798623, 7.840729432790956, 8.416820006151594, 6.705267594030659, 3.306279717222145, 3.7410574109523305, 3.4958511118480193, 3.6653182141364735, 1.785519664063084, 1.2658071220435476, 0.7368489005398801, 0.0, 9.181849875652563, 8.10533790593868, 6.329035610217737, 5.3565589921892505, 7.330636428272947, 4.894191556587227, 3.7410574109523305, 2.3616283694443894, 3.3526337970153297, 2.8056066687171985, 1.5681458865581912, 0.8313049967089657, 0.0), # 14
(9.321501903268855, 9.339907022878865, 8.008401690097953, 8.59684814760449, 6.850566220765538, 3.376996617601199, 3.821017100874813, 3.5704763064998986, 3.743698244578273, 1.823678893036873, 1.2928865562699035, 0.752604142154931, 0.0, 9.37827342756938, 8.27864556370424, 6.464432781349516, 5.471036679110618, 7.487396489156546, 4.998666829099858, 3.821017100874813, 2.4121404411437135, 3.425283110382769, 2.865616049201497, 1.6016803380195905, 0.8490824566253515, 0.0), # 15
(9.5029653356198, 9.51563296645512, 8.159074056802854, 8.758623452831788, 6.981519607721555, 3.4405433400458514, 3.892870194481988, 3.6375347129591504, 3.8141310803694286, 1.8579694948654994, 1.3172204860774188, 0.7667619895570784, 0.0, 9.554781444523545, 8.434381885127861, 6.586102430387094, 5.5739084845964975, 7.628262160738857, 5.092548598142811, 3.892870194481988, 2.4575309571756083, 3.4907598038607777, 2.9195411509439295, 1.6318148113605708, 0.8650575424050111, 0.0), # 16
(9.663932709715075, 9.670211430531618, 8.291613663785293, 8.900929631461583, 7.097166527942559, 3.4964421923866666, 3.9560763548653552, 3.6965223351920073, 3.8760872738829946, 1.8881335782173672, 1.3386259463796333, 0.7792159954886714, 0.0, 9.710046977881415, 8.571375950375383, 6.693129731898166, 5.6644007346521, 7.752174547765989, 5.17513126926881, 3.9560763548653552, 2.4974587088476192, 3.5485832639712793, 2.9669765438205284, 1.6583227327570589, 0.8791101300483289, 0.0), # 17
(9.803108669450204, 9.802321051112584, 8.404887641924901, 9.022550393121959, 7.1965457544723925, 3.5442154824542103, 4.010095245116426, 3.746935177164692, 3.929037377492032, 1.9139132517608846, 1.3569199720900849, 0.7898597126920597, 0.0, 9.842743079009345, 8.688456839612655, 6.784599860450424, 5.741739755282652, 7.858074754984064, 5.245709248030569, 4.010095245116426, 2.531582487467293, 3.5982728772361963, 3.0075167977073205, 1.6809775283849802, 0.8911200955556896, 0.0), # 18
(9.919197858720699, 9.910640464202265, 8.497763122101317, 9.122269447440985, 7.2786960603549105, 3.5833855180790386, 4.054386528326697, 3.7882692428434357, 3.9724519435695926, 1.9350506241644574, 1.3719195981223131, 0.7985866939095915, 0.0, 9.951542799273696, 8.784453633005505, 6.859597990611565, 5.80515187249337, 7.944903887139185, 5.30357693998081, 4.054386528326697, 2.55956108434217, 3.6393480301774552, 3.0407564824803295, 1.6995526244202632, 0.9009673149274788, 0.0), # 19
(10.010904921422082, 9.993848305804882, 8.569107235194169, 9.198870504046766, 7.342656218633962, 3.613474607091719, 4.088409867587681, 3.8200205361944657, 4.005801524488732, 1.95128780409649, 1.3834418593898585, 0.805290491883616, 0.0, 10.035119190040824, 8.858195410719775, 6.9172092969492915, 5.853863412289469, 8.011603048977465, 5.348028750672252, 4.088409867587681, 2.5810532907797996, 3.671328109316981, 3.0662901680155894, 1.713821447038834, 0.9085316641640803, 0.0), # 20
(10.076934501449866, 10.050623211924679, 8.6177871120831, 9.251137272567364, 7.387465002353392, 3.6340050573228124, 4.1116249259908795, 3.84168506118401, 4.028556672622507, 1.9623669002253892, 1.39130379080626, 0.8098646593564828, 0.0, 10.092145302677078, 8.90851125292131, 6.9565189540313, 5.887100700676166, 8.057113345245014, 5.378359085657614, 4.1116249259908795, 2.5957178980877234, 3.693732501176696, 3.0837124241891223, 1.72355742241662, 0.91369301926588, 0.0), # 21
(10.115991242699579, 10.079643818565883, 8.642669883647738, 9.277853462630876, 7.41216118455705, 3.644499176602881, 4.1234913666278, 3.852758821778298, 4.040187940343971, 1.968030021219561, 1.3953224272850568, 0.8122027490705409, 0.0, 10.121294188548827, 8.934230239775948, 6.976612136425284, 5.904090063658682, 8.080375880687942, 5.393862350489617, 4.1234913666278, 2.6032136975734863, 3.706080592278525, 3.09261782087696, 1.7285339767295478, 0.9163312562332622, 0.0), # 22
(10.13039336334264, 10.083079961133974, 8.645769318701419, 9.281198109567903, 7.418488037355065, 3.6458333333333335, 4.124902001129669, 3.8539557613168727, 4.0416420781893, 1.9686980681298587, 1.3958263395269568, 0.8124914647157445, 0.0, 10.125, 8.93740611187319, 6.9791316976347835, 5.906094204389575, 8.0832841563786, 5.395538065843622, 4.124902001129669, 2.604166666666667, 3.7092440186775324, 3.0937327031893016, 1.729153863740284, 0.9166436328303613, 0.0), # 23
(10.141012413034153, 10.08107561728395, 8.645262345679013, 9.280786458333335, 7.422071742409901, 3.6458333333333335, 4.124126906318083, 3.852291666666667, 4.041447222222222, 1.968287654320988, 1.39577076318743, 0.8124238683127573, 0.0, 10.125, 8.936662551440328, 6.978853815937151, 5.904862962962962, 8.082894444444443, 5.393208333333334, 4.124126906318083, 2.604166666666667, 3.7110358712049507, 3.0935954861111123, 1.7290524691358027, 0.9164614197530866, 0.0), # 24
(10.15140723021158, 10.077124771376313, 8.644261545496114, 9.279972029320987, 7.4255766303963355, 3.6458333333333335, 4.122599451303155, 3.8490226337448563, 4.041062242798354, 1.96747970964792, 1.3956605665710604, 0.8122904282883707, 0.0, 10.125, 8.935194711172077, 6.978302832855302, 5.902439128943758, 8.082124485596708, 5.388631687242799, 4.122599451303155, 2.604166666666667, 3.7127883151981678, 3.0933240097736636, 1.728852309099223, 0.9161022519433014, 0.0), # 25
(10.161577019048034, 10.071287780064015, 8.642780635573846, 9.278764081790122, 7.429002578947403, 3.6458333333333335, 4.120343359154361, 3.8442103909465026, 4.0404920781893, 1.9662876771833566, 1.3954967473084758, 0.8120929736320684, 0.0, 10.125, 8.933022709952752, 6.977483736542379, 5.898863031550069, 8.0809841563786, 5.381894547325103, 4.120343359154361, 2.604166666666667, 3.7145012894737013, 3.0929213605967085, 1.7285561271147696, 0.915571616369456, 0.0), # 26
(10.171520983716636, 10.063624999999998, 8.640833333333333, 9.277171874999999, 7.432349465696142, 3.6458333333333335, 4.117382352941177, 3.837916666666667, 4.039741666666666, 1.9647250000000003, 1.3952803030303031, 0.8118333333333335, 0.0, 10.125, 8.930166666666667, 6.976401515151515, 5.894175, 8.079483333333332, 5.373083333333334, 4.117382352941177, 2.604166666666667, 3.716174732848071, 3.0923906250000006, 1.7281666666666669, 0.914875, 0.0), # 27
(10.181238328390501, 10.054196787837219, 8.638433356195703, 9.275204668209877, 7.4356171682756, 3.6458333333333335, 4.113740155733075, 3.830203189300412, 4.038815946502057, 1.9628051211705537, 1.3950122313671698, 0.8115133363816492, 0.0, 10.125, 8.926646700198141, 6.9750611568358485, 5.88841536351166, 8.077631893004114, 5.3622844650205765, 4.113740155733075, 2.604166666666667, 3.7178085841378, 3.091734889403293, 1.7276866712391405, 0.9140178898033837, 0.0), # 28
(10.19072825724275, 10.043063500228623, 8.635594421582077, 9.272871720679012, 7.438805564318813, 3.6458333333333335, 4.109440490599533, 3.821131687242798, 4.037719855967078, 1.9605414837677189, 1.3946935299497027, 0.811134811766499, 0.0, 10.125, 8.922482929431489, 6.973467649748514, 5.881624451303155, 8.075439711934155, 5.349584362139917, 4.109440490599533, 2.604166666666667, 3.7194027821594067, 3.0909572402263383, 1.7271188843164156, 0.9130057727480568, 0.0), # 29
(10.199989974446497, 10.03028549382716, 8.63233024691358, 9.270182291666666, 7.441914531458824, 3.6458333333333335, 4.104507080610022, 3.8107638888888884, 4.036458333333333, 1.957947530864198, 1.39432519640853, 0.8106995884773662, 0.0, 10.125, 8.917695473251028, 6.9716259820426485, 5.873842592592593, 8.072916666666666, 5.335069444444444, 4.104507080610022, 2.604166666666667, 3.720957265729412, 3.0900607638888897, 1.7264660493827162, 0.9118441358024693, 0.0), # 30
(10.209022684174858, 10.01592312528578, 8.62865454961134, 9.267145640432098, 7.444943947328672, 3.6458333333333335, 4.09896364883402, 3.799161522633745, 4.035036316872428, 1.9550367055326936, 1.3939082283742779, 0.8102094955037343, 0.0, 10.125, 8.912304450541077, 6.969541141871389, 5.865110116598079, 8.070072633744855, 5.318826131687243, 4.09896364883402, 2.604166666666667, 3.722471973664336, 3.0890485468107003, 1.7257309099222682, 0.910538465935071, 0.0), # 31
(10.217825590600954, 10.00003675125743, 8.624581047096479, 9.263771026234568, 7.447893689561397, 3.6458333333333335, 4.092833918340999, 3.7863863168724285, 4.033458744855967, 1.951822450845908, 1.3934436234775742, 0.8096663618350862, 0.0, 10.125, 8.906329980185948, 6.96721811738787, 5.8554673525377225, 8.066917489711933, 5.3009408436214, 4.092833918340999, 2.604166666666667, 3.7239468447806985, 3.0879236754115236, 1.7249162094192958, 0.909094250114312, 0.0), # 32
(10.226397897897897, 9.98268672839506, 8.620123456790123, 9.260067708333333, 7.450763635790041, 3.6458333333333335, 4.086141612200436, 3.7725000000000004, 4.031730555555555, 1.9483182098765437, 1.392932379349046, 0.8090720164609053, 0.0, 10.125, 8.899792181069957, 6.96466189674523, 5.84495462962963, 8.06346111111111, 5.2815, 4.086141612200436, 2.604166666666667, 3.7253818178950207, 3.086689236111112, 1.724024691358025, 0.9075169753086421, 0.0), # 33
(10.23473881023881, 9.963933413351622, 8.615295496113397, 9.256044945987654, 7.453553663647644, 3.6458333333333335, 4.078910453481805, 3.7575643004115222, 4.029856687242798, 1.9445374256973027, 1.3923754936193207, 0.8084282883706753, 0.0, 10.125, 8.892711172077426, 6.961877468096604, 5.833612277091907, 8.059713374485597, 5.260590020576132, 4.078910453481805, 2.604166666666667, 3.726776831823822, 3.085348315329219, 1.7230590992226795, 0.9058121284865113, 0.0), # 34
(10.242847531796807, 9.943837162780063, 8.610110882487428, 9.25171199845679, 7.456263650767246, 3.6458333333333335, 4.071164165254579, 3.741640946502058, 4.0278420781893, 1.9404935413808875, 1.3917739639190256, 0.807737006553879, 0.0, 10.125, 8.88510707209267, 6.958869819595128, 5.821480624142661, 8.0556841563786, 5.238297325102881, 4.071164165254579, 2.604166666666667, 3.728131825383623, 3.0839039994855972, 1.7220221764974855, 0.9039851966163696, 0.0), # 35
(10.250723266745005, 9.922458333333331, 8.604583333333334, 9.247078125, 7.45889347478189, 3.6458333333333335, 4.062926470588235, 3.724791666666667, 4.025691666666666, 1.9362000000000004, 1.391128787878788, 0.8070000000000002, 0.0, 10.125, 8.877, 6.95564393939394, 5.8086, 8.051383333333332, 5.214708333333334, 4.062926470588235, 2.604166666666667, 3.729446737390945, 3.0823593750000007, 1.7209166666666669, 0.9020416666666666, 0.0), # 36
(10.258365219256524, 9.89985728166438, 8.598726566072246, 9.242152584876543, 7.4614430133246135, 3.6458333333333335, 4.054221092552247, 3.707078189300412, 4.023410390946502, 1.931670244627344, 1.3904409631292352, 0.8062190976985216, 0.0, 10.125, 8.868410074683737, 6.952204815646175, 5.79501073388203, 8.046820781893004, 5.189909465020577, 4.054221092552247, 2.604166666666667, 3.7307215066623067, 3.080717528292182, 1.7197453132144491, 0.8999870256058529, 0.0), # 37
(10.265772593504476, 9.876094364426155, 8.592554298125286, 9.23694463734568, 7.46391214402846, 3.6458333333333335, 4.04507175421609, 3.6885622427983544, 4.021003189300411, 1.92691771833562, 1.3897114873009937, 0.8053961286389272, 0.0, 10.125, 8.859357415028198, 6.948557436504967, 5.780753155006859, 8.042006378600822, 5.163987139917697, 4.04507175421609, 2.604166666666667, 3.73195607201423, 3.078981545781894, 1.7185108596250571, 0.8978267604023779, 0.0), # 38
(10.272944593661986, 9.851229938271604, 8.586080246913582, 9.231463541666667, 7.466300744526468, 3.6458333333333335, 4.035502178649238, 3.6693055555555554, 4.0184750000000005, 1.9219558641975314, 1.3889413580246914, 0.8045329218106996, 0.0, 10.125, 8.849862139917693, 6.944706790123457, 5.765867592592593, 8.036950000000001, 5.137027777777778, 4.035502178649238, 2.604166666666667, 3.733150372263234, 3.07715451388889, 1.7172160493827164, 0.8955663580246914, 0.0), # 39
(10.279880423902163, 9.82532435985368, 8.579318129858253, 9.225718557098766, 7.468608692451679, 3.6458333333333335, 4.025536088921165, 3.649369855967079, 4.015830761316872, 1.9167981252857802, 1.3881315729309558, 0.8036313062033228, 0.0, 10.125, 8.83994436823655, 6.940657864654778, 5.750394375857339, 8.031661522633744, 5.1091177983539104, 4.025536088921165, 2.604166666666667, 3.7343043462258394, 3.0752395190329227, 1.7158636259716507, 0.8932113054412438, 0.0), # 40
(10.286579288398128, 9.79843798582533, 8.57228166438043, 9.219718942901235, 7.4708358654371345, 3.6458333333333335, 4.015197208101347, 3.628816872427984, 4.0130754115226335, 1.9114579446730684, 1.3872831296504138, 0.8026931108062796, 0.0, 10.125, 8.829624218869075, 6.936415648252069, 5.734373834019204, 8.026150823045267, 5.0803436213991775, 4.015197208101347, 2.604166666666667, 3.7354179327185673, 3.073239647633746, 1.7144563328760862, 0.8907670896204848, 0.0), # 41
(10.293040391323, 9.770631172839506, 8.564984567901236, 9.213473958333335, 7.472982141115872, 3.6458333333333335, 4.004509259259259, 3.6077083333333335, 4.010213888888889, 1.9059487654320992, 1.3863970258136926, 0.8017201646090536, 0.0, 10.125, 8.818921810699589, 6.931985129068463, 5.717846296296297, 8.020427777777778, 5.050791666666667, 4.004509259259259, 2.604166666666667, 3.736491070557936, 3.0711579861111122, 1.7129969135802474, 0.8882391975308643, 0.0), # 42
(10.299262936849892, 9.741964277549155, 8.557440557841794, 9.206992862654321, 7.475047397120935, 3.6458333333333335, 3.993495965464375, 3.58610596707819, 4.007251131687243, 1.9002840306355744, 1.3854742590514195, 0.800714296601128, 0.0, 10.125, 8.807857262612407, 6.927371295257098, 5.700852091906722, 8.014502263374485, 5.020548353909466, 3.993495965464375, 2.604166666666667, 3.7375236985604676, 3.0689976208847747, 1.7114881115683587, 0.8856331161408324, 0.0), # 43
(10.305246129151927, 9.712497656607225, 8.549663351623229, 9.200284915123458, 7.477031511085363, 3.6458333333333335, 3.9821810497861696, 3.564071502057614, 4.0041920781893, 1.8944771833561962, 1.3845158269942222, 0.7996773357719861, 0.0, 10.125, 8.796450693491845, 6.92257913497111, 5.683431550068587, 8.0083841563786, 4.98970010288066, 3.9821810497861696, 2.604166666666667, 3.7385157555426813, 3.0667616383744867, 1.709932670324646, 0.8829543324188387, 0.0), # 44
(10.310989172402216, 9.682291666666666, 8.541666666666668, 9.193359375, 7.478934360642197, 3.6458333333333335, 3.9705882352941178, 3.541666666666667, 4.001041666666666, 1.8885416666666672, 1.3835227272727273, 0.798611111111111, 0.0, 10.125, 8.784722222222221, 6.917613636363637, 5.665625, 8.002083333333331, 4.958333333333334, 3.9705882352941178, 2.604166666666667, 3.7394671803210984, 3.064453125000001, 1.7083333333333335, 0.8802083333333335, 0.0), # 45
(10.31649127077388, 9.65140666438043, 8.533464220393233, 9.186225501543209, 7.480755823424477, 3.6458333333333335, 3.958741245057694, 3.518953189300412, 3.997804835390946, 1.8824909236396894, 1.3824959575175624, 0.7975174516079867, 0.0, 10.125, 8.772691967687852, 6.912479787587812, 5.647472770919067, 7.995609670781892, 4.926534465020577, 3.958741245057694, 2.604166666666667, 3.7403779117122387, 3.062075167181071, 1.7066928440786466, 0.8774006058527665, 0.0), # 46
(10.321751628440035, 9.619903006401461, 8.525069730224052, 9.178892554012345, 7.482495777065244, 3.6458333333333335, 3.9466638021463734, 3.4959927983539094, 3.994486522633745, 1.8763383973479657, 1.3814365153593549, 0.7963981862520958, 0.0, 10.125, 8.760380048773053, 6.9071825767967745, 5.629015192043896, 7.98897304526749, 4.894389917695474, 3.9466638021463734, 2.604166666666667, 3.741247888532622, 3.0596308513374493, 1.7050139460448106, 0.8745366369455876, 0.0), # 47
(10.326769449573796, 9.587841049382716, 8.516496913580248, 9.171369791666667, 7.48415409919754, 3.6458333333333335, 3.9343796296296296, 3.4728472222222226, 3.9910916666666667, 1.8700975308641978, 1.3803453984287317, 0.7952551440329219, 0.0, 10.125, 8.74780658436214, 6.901726992143659, 5.610292592592592, 7.982183333333333, 4.861986111111112, 3.9343796296296296, 2.604166666666667, 3.74207704959877, 3.05712326388889, 1.7032993827160496, 0.871621913580247, 0.0), # 48
(10.331543938348286, 9.555281149977136, 8.507759487882945, 9.163666473765433, 7.485730667454405, 3.6458333333333335, 3.9219124505769383, 3.4495781893004116, 3.987625205761317, 1.8637817672610888, 1.3792236043563206, 0.7940901539399483, 0.0, 10.125, 8.73499169333943, 6.896118021781603, 5.5913453017832655, 7.975250411522634, 4.829409465020577, 3.9219124505769383, 2.604166666666667, 3.7428653337272024, 3.054555491255145, 1.7015518975765893, 0.8686619227251944, 0.0), # 49
(10.336074298936616, 9.522283664837678, 8.49887117055327, 9.155791859567902, 7.4872253594688765, 3.6458333333333335, 3.909285988057775, 3.4262474279835393, 3.9840920781893, 1.85740454961134, 1.3780721307727481, 0.7929050449626583, 0.0, 10.125, 8.72195549458924, 6.89036065386374, 5.572213648834019, 7.9681841563786, 4.796746399176955, 3.909285988057775, 2.604166666666667, 3.7436126797344382, 3.051930619855968, 1.6997742341106543, 0.86566215134888, 0.0), # 50
(10.34035973551191, 9.488908950617283, 8.489845679012346, 9.147755208333333, 7.488638052873998, 3.6458333333333335, 3.896523965141612, 3.4029166666666666, 3.9804972222222226, 1.8509793209876546, 1.3768919753086422, 0.7917016460905352, 0.0, 10.125, 8.708718106995885, 6.884459876543211, 5.552937962962963, 7.960994444444445, 4.764083333333334, 3.896523965141612, 2.604166666666667, 3.744319026436999, 3.049251736111112, 1.6979691358024693, 0.8626280864197532, 0.0), # 51
(10.344399452247279, 9.455217363968908, 8.480696730681299, 9.139565779320987, 7.489968625302809, 3.6458333333333335, 3.883650104897926, 3.3796476337448556, 3.976845576131687, 1.8445195244627348, 1.3756841355946297, 0.7904817863130622, 0.0, 10.125, 8.695299649443683, 6.878420677973147, 5.533558573388203, 7.953691152263374, 4.731506687242798, 3.883650104897926, 2.604166666666667, 3.7449843126514044, 3.04652192644033, 1.69613934613626, 0.8595652149062645, 0.0), # 52
(10.348192653315843, 9.421269261545497, 8.471438042981255, 9.131232831790122, 7.491216954388353, 3.6458333333333335, 3.8706881303961915, 3.3565020576131688, 3.9731420781893005, 1.8380386031092826, 1.3744496092613379, 0.7892472946197227, 0.0, 10.125, 8.681720240816947, 6.872248046306688, 5.514115809327846, 7.946284156378601, 4.699102880658437, 3.8706881303961915, 2.604166666666667, 3.7456084771941764, 3.043744277263375, 1.694287608596251, 0.8564790237768635, 0.0), # 53
(10.351738542890716, 9.387125000000001, 8.462083333333332, 9.122765625, 7.492382917763668, 3.6458333333333335, 3.8576617647058824, 3.333541666666666, 3.9693916666666667, 1.8315500000000005, 1.3731893939393938, 0.788, 0.0, 10.125, 8.668, 6.865946969696969, 5.49465, 7.938783333333333, 4.666958333333333, 3.8576617647058824, 2.604166666666667, 3.746191458881834, 3.040921875000001, 1.6924166666666667, 0.8533750000000002, 0.0), # 54
(10.355036325145022, 9.352844935985367, 8.452646319158665, 9.114173418209877, 7.493466393061793, 3.6458333333333335, 3.844594730896474, 3.3108281893004117, 3.9655992798353905, 1.8250671582075908, 1.3719044872594257, 0.7867417314433777, 0.0, 10.125, 8.654159045877153, 6.859522436297127, 5.4752014746227715, 7.931198559670781, 4.6351594650205765, 3.844594730896474, 2.604166666666667, 3.7467331965308963, 3.0380578060699595, 1.6905292638317333, 0.8502586305441244, 0.0), # 55
(10.358085204251871, 9.31848942615455, 8.443140717878373, 9.105465470679011, 7.4944672579157725, 3.6458333333333335, 3.8315107520374405, 3.288423353909465, 3.961769855967078, 1.818603520804756, 1.3705958868520598, 0.7854743179393385, 0.0, 10.125, 8.640217497332722, 6.852979434260299, 5.455810562414267, 7.923539711934156, 4.603792695473251, 3.8315107520374405, 2.604166666666667, 3.7472336289578863, 3.035155156893005, 1.6886281435756747, 0.8471354023776865, 0.0), # 56
(10.360884384384383, 9.284118827160494, 8.433580246913582, 9.096651041666666, 7.495385389958644, 3.6458333333333335, 3.818433551198257, 3.2663888888888892, 3.957908333333333, 1.812172530864198, 1.369264590347924, 0.7841995884773663, 0.0, 10.125, 8.626195473251027, 6.8463229517396185, 5.436517592592593, 7.915816666666666, 4.572944444444445, 3.818433551198257, 2.604166666666667, 3.747692694979322, 3.0322170138888898, 1.6867160493827165, 0.844010802469136, 0.0), # 57
(10.36343306971568, 9.24979349565615, 8.423978623685414, 9.087739390432098, 7.496220666823449, 3.6458333333333335, 3.8053868514483984, 3.2447865226337447, 3.954019650205761, 1.8057876314586196, 1.367911595377645, 0.7829193720469442, 0.0, 10.125, 8.612113092516385, 6.8395579768882255, 5.417362894375858, 7.908039300411522, 4.5427011316872425, 3.8053868514483984, 2.604166666666667, 3.7481103334117245, 3.029246463477367, 1.684795724737083, 0.8408903177869229, 0.0), # 58
(10.36573046441887, 9.215573788294467, 8.414349565614998, 9.078739776234567, 7.49697296614323, 3.6458333333333335, 3.792394375857339, 3.2236779835390945, 3.9501087448559673, 1.799462265660723, 1.3665378995718502, 0.7816354976375554, 0.0, 10.125, 8.597990474013107, 6.83268949785925, 5.398386796982168, 7.900217489711935, 4.513149176954733, 3.792394375857339, 2.604166666666667, 3.748486483071615, 3.02624659207819, 1.6828699131229998, 0.8377794352994972, 0.0), # 59
(10.367775772667077, 9.181520061728396, 8.404706790123456, 9.069661458333334, 7.497642165551024, 3.6458333333333335, 3.779479847494553, 3.203125, 3.946180555555556, 1.7932098765432103, 1.3651445005611673, 0.7803497942386832, 0.0, 10.125, 8.583847736625515, 6.825722502805837, 5.37962962962963, 7.892361111111112, 4.484375, 3.779479847494553, 2.604166666666667, 3.748821082775512, 3.023220486111112, 1.6809413580246915, 0.8346836419753088, 0.0), # 60
(10.369568198633415, 9.147692672610884, 8.395064014631917, 9.060513695987654, 7.498228142679874, 3.6458333333333335, 3.7666669894295164, 3.183189300411523, 3.9422400205761314, 1.7870439071787843, 1.3637323959762233, 0.7790640908398111, 0.0, 10.125, 8.56970499923792, 6.818661979881115, 5.361131721536351, 7.884480041152263, 4.456465020576132, 3.7666669894295164, 2.604166666666667, 3.749114071339937, 3.0201712319958856, 1.6790128029263836, 0.8316084247828076, 0.0), # 61
(10.371106946491004, 9.114151977594878, 8.385434956561502, 9.051305748456791, 7.498730775162823, 3.6458333333333335, 3.753979524731703, 3.1639326131687247, 3.9382920781893, 1.7809778006401469, 1.3623025834476452, 0.7777802164304223, 0.0, 10.125, 8.555582380734645, 6.811512917238226, 5.3429334019204395, 7.8765841563786, 4.429505658436215, 3.753979524731703, 2.604166666666667, 3.7493653875814115, 3.0171019161522645, 1.6770869913123003, 0.8285592706904436, 0.0), # 62
(10.37239122041296, 9.080958333333333, 8.375833333333334, 9.042046875, 7.499149940632904, 3.6458333333333335, 3.741441176470588, 3.1454166666666667, 3.9343416666666666, 1.7750250000000003, 1.360856060606061, 0.7765000000000001, 0.0, 10.125, 8.5415, 6.804280303030303, 5.325075, 7.868683333333333, 4.403583333333334, 3.741441176470588, 2.604166666666667, 3.749574970316452, 3.014015625000001, 1.675166666666667, 0.8255416666666667, 0.0), # 63
(10.373420224572397, 9.048172096479195, 8.366272862368541, 9.032746334876544, 7.4994855167231655, 3.6458333333333335, 3.729075667715646, 3.127703189300412, 3.9303937242798352, 1.7691989483310475, 1.3593938250820965, 0.7752252705380279, 0.0, 10.125, 8.527477975918305, 6.796969125410483, 5.307596844993141, 7.8607874485596705, 4.378784465020577, 3.729075667715646, 2.604166666666667, 3.7497427583615828, 3.0109154449588487, 1.6732545724737085, 0.822561099679927, 0.0), # 64
(10.374193163142438, 9.015853623685413, 8.35676726108825, 9.023413387345679, 7.499737381066645, 3.6458333333333335, 3.7169067215363514, 3.1108539094650207, 3.9264531893004113, 1.7635130887059902, 1.357916874506381, 0.7739578570339887, 0.0, 10.125, 8.513536427373873, 6.7895843725319045, 5.290539266117969, 7.852906378600823, 4.355195473251029, 3.7169067215363514, 2.604166666666667, 3.7498686905333223, 3.0078044624485605, 1.67135345221765, 0.819623056698674, 0.0), # 65
(10.374709240296196, 8.984063271604938, 8.34733024691358, 9.014057291666667, 7.499905411296382, 3.6458333333333335, 3.7049580610021784, 3.094930555555556, 3.9225250000000003, 1.7579808641975312, 1.3564262065095398, 0.7726995884773664, 0.0, 10.125, 8.499695473251029, 6.782131032547699, 5.273942592592592, 7.8450500000000005, 4.332902777777778, 3.7049580610021784, 2.604166666666667, 3.749952705648191, 3.0046857638888897, 1.6694660493827165, 0.8167330246913582, 0.0), # 66
(10.374967660206792, 8.952861396890716, 8.337975537265661, 9.004687307098765, 7.499989485045419, 3.6458333333333335, 3.693253409182603, 3.0799948559670787, 3.9186140946502057, 1.7526157178783728, 1.3549228187222018, 0.7714522938576437, 0.0, 10.125, 8.485975232434079, 6.774614093611008, 5.257847153635117, 7.837228189300411, 4.31199279835391, 3.693253409182603, 2.604166666666667, 3.7499947425227096, 3.001562435699589, 1.6675951074531323, 0.8138964906264289, 0.0), # 67
(10.374791614480825, 8.922144586043629, 8.328671624942844, 8.995231305354269, 7.499918636864896, 3.645765673423767, 3.681757597414823, 3.0659766041761927, 3.9146959495503735, 1.747405110411792, 1.3533809980900628, 0.770210835158312, 0.0, 10.124875150034294, 8.47231918674143, 6.766904990450313, 5.242215331235375, 7.829391899100747, 4.29236724584667, 3.681757597414823, 2.604118338159833, 3.749959318432448, 2.99841043511809, 1.6657343249885688, 0.8111040532766937, 0.0), # 68
(10.373141706924315, 8.890975059737157, 8.319157021604937, 8.985212635869564, 7.499273783587508, 3.6452307956104257, 3.6701340906733066, 3.052124485596708, 3.910599279835391, 1.7422015976761076, 1.3516438064859118, 0.7689349144466104, 0.0, 10.12388599537037, 8.458284058912714, 6.758219032429559, 5.226604793028321, 7.821198559670782, 4.272974279835391, 3.6701340906733066, 2.6037362825788755, 3.749636891793754, 2.9950708786231885, 1.6638314043209876, 0.8082704599761052, 0.0), # 69
(10.369885787558895, 8.859209754856408, 8.309390360653863, 8.974565343196456, 7.497999542752628, 3.6441773992785653, 3.658330067280685, 3.0383135192805977, 3.9063009640298736, 1.736979881115684, 1.3496914810876801, 0.7676185634410675, 0.0, 10.121932334533609, 8.44380419785174, 6.7484574054383994, 5.210939643347051, 7.812601928059747, 4.253638926992837, 3.658330067280685, 2.6029838566275467, 3.748999771376314, 2.991521781065486, 1.6618780721307727, 0.8053827049869463, 0.0), # 70
(10.365069660642929, 8.826867654542236, 8.299375071444901, 8.963305127818035, 7.496112052502757, 3.6426225549966977, 3.646350829769494, 3.0245482777015704, 3.9018074035970125, 1.7317400898356603, 1.347531228463977, 0.7662627447677263, 0.0, 10.119039887688615, 8.428890192444989, 6.737656142319885, 5.195220269506979, 7.803614807194025, 4.234367588782199, 3.646350829769494, 2.6018732535690696, 3.7480560262513785, 2.987768375939346, 1.6598750142889804, 0.8024425140492942, 0.0), # 71
(10.358739130434783, 8.793967741935482, 8.289114583333333, 8.95144769021739, 7.493627450980392, 3.6405833333333337, 3.634201680672269, 3.0108333333333333, 3.897125, 1.7264823529411768, 1.3451702551834133, 0.7648684210526316, 0.0, 10.115234375, 8.413552631578947, 6.7258512759170666, 5.179447058823529, 7.79425, 4.215166666666667, 3.634201680672269, 2.600416666666667, 3.746813725490196, 2.983815896739131, 1.6578229166666667, 0.7994516129032258, 0.0), # 72
(10.35094000119282, 8.760529000176998, 8.27861232567444, 8.939008730877617, 7.490561876328034, 3.638076804856983, 3.621887922521546, 2.9971732586495965, 3.8922601547020275, 1.7212067995373737, 1.3426157678145982, 0.7634365549218266, 0.0, 10.110541516632374, 8.397802104140093, 6.71307883907299, 5.163620398612119, 7.784520309404055, 4.196042562109435, 3.621887922521546, 2.598626289183559, 3.745280938164017, 2.979669576959206, 1.655722465134888, 0.7964117272888181, 0.0), # 73
(10.341718077175404, 8.726570412407629, 8.267871727823502, 8.926003950281803, 7.486931466688183, 3.6351200401361585, 3.609414857849861, 2.9835726261240665, 3.8872192691662857, 1.7159135587293908, 1.3398749729261428, 0.7619681090013557, 0.0, 10.104987032750344, 8.38164919901491, 6.699374864630713, 5.147740676188171, 7.774438538332571, 4.177001676573693, 3.609414857849861, 2.5965143143829703, 3.7434657333440917, 2.975334650093935, 1.6535743455647005, 0.7933245829461482, 0.0), # 74
(10.331119162640901, 8.692110961768218, 8.256896219135802, 8.912449048913043, 7.482752360203341, 3.6317301097393697, 3.59678778918975, 2.9700360082304527, 3.8820087448559666, 1.7106027596223679, 1.336955077086656, 0.7604640459172624, 0.0, 10.098596643518519, 8.365104505089885, 6.684775385433279, 5.131808278867102, 7.764017489711933, 4.158050411522634, 3.59678778918975, 2.594092935528121, 3.7413761801016703, 2.9708163496376816, 1.6513792438271604, 0.7901919056152927, 0.0), # 75
(10.319189061847677, 8.65716963139962, 8.245689228966622, 8.898359727254428, 7.478040695016003, 3.6279240842351275, 3.5840120190737474, 2.956567977442463, 3.876634983234263, 1.7052745313214452, 1.3338632868647486, 0.7589253282955902, 0.0, 10.091396069101508, 8.348178611251491, 6.669316434323743, 5.115823593964334, 7.753269966468526, 4.139195168419449, 3.5840120190737474, 2.5913743458822336, 3.7390203475080015, 2.96611990908481, 1.6491378457933243, 0.7870154210363293, 0.0), # 76
(10.305973579054093, 8.621765404442675, 8.234254186671238, 8.883751685789049, 7.472812609268672, 3.6237190341919425, 3.5710928500343897, 2.9431731062338065, 3.871104385764365, 1.699929002931763, 1.3306068088290313, 0.7573529187623839, 0.0, 10.083411029663925, 8.330882106386222, 6.653034044145156, 5.099787008795288, 7.74220877152873, 4.120442348727329, 3.5710928500343897, 2.58837073870853, 3.736406304634336, 2.9612505619296834, 1.6468508373342476, 0.7837968549493343, 0.0), # 77
(10.291518518518519, 8.585917264038233, 8.222594521604938, 8.868640625, 7.467084241103849, 3.6191320301783265, 3.5580355846042124, 2.9298559670781894, 3.8654233539094642, 1.6945663035584608, 1.327192849548113, 0.7557477799436866, 0.0, 10.074667245370371, 8.313225579380552, 6.635964247740564, 5.083698910675381, 7.7308467078189285, 4.101798353909466, 3.5580355846042124, 2.585094307270233, 3.7335421205519244, 2.956213541666667, 1.6445189043209878, 0.7805379330943849, 0.0), # 78
(10.275869684499314, 8.549644193327138, 8.210713663123, 8.85304224537037, 7.460871728664031, 3.61418014276279, 3.5448455253157505, 2.916621132449322, 3.859598289132754, 1.6891865623066789, 1.3236286155906039, 0.7541108744655421, 0.0, 10.065190436385459, 8.295219619120962, 6.618143077953018, 5.067559686920035, 7.719196578265508, 4.083269585429051, 3.5448455253157505, 2.5815572448305644, 3.7304358643320157, 2.951014081790124, 1.6421427326246, 0.7772403812115581, 0.0), # 79
(10.259072881254847, 8.51296517545024, 8.198615040580703, 8.836972247383253, 7.454191210091719, 3.6088804425138448, 3.5315279747015405, 2.9034731748209115, 3.853635592897424, 1.683789908281557, 1.3199213135251149, 0.7524431649539947, 0.0, 10.0550063228738, 8.27687481449394, 6.599606567625574, 5.05136972484467, 7.707271185794848, 4.064862444749276, 3.5315279747015405, 2.577771744652746, 3.7270956050458595, 2.945657415794418, 1.639723008116141, 0.7739059250409311, 0.0), # 80
(10.241173913043479, 8.475899193548386, 8.186302083333333, 8.82044633152174, 7.447058823529411, 3.60325, 3.5180882352941176, 2.890416666666667, 3.8475416666666664, 1.6783764705882358, 1.3160781499202554, 0.7507456140350878, 0.0, 10.044140624999999, 8.258201754385965, 6.580390749601277, 5.035129411764706, 7.695083333333333, 4.046583333333333, 3.5180882352941176, 2.57375, 3.7235294117647055, 2.940148777173914, 1.6372604166666667, 0.7705362903225808, 0.0), # 81
(10.222218584123576, 8.438465230762423, 8.17377822073617, 8.803480198268922, 7.43949070711961, 3.5973058857897686, 3.504531609626018, 2.8774561804602956, 3.841322911903673, 1.6729463783318543, 1.3121063313446355, 0.7490191843348656, 0.0, 10.03261906292867, 8.23921102768352, 6.560531656723177, 5.018839134995561, 7.682645823807346, 4.0284386526444145, 3.504531609626018, 2.5695042041355487, 3.719745353559805, 2.934493399422974, 1.634755644147234, 0.767133202796584, 0.0), # 82
(10.202252698753504, 8.400682270233196, 8.16104688214449, 8.78608954810789, 7.431502999004814, 3.591065170451659, 3.4908634002297765, 2.8645962886755068, 3.8349857300716352, 1.6674997606175532, 1.3080130643668657, 0.7472648384793719, 0.0, 10.020467356824417, 8.219913223273089, 6.540065321834328, 5.002499281852659, 7.6699714601432705, 4.01043480414571, 3.4908634002297765, 2.5650465503226134, 3.715751499502407, 2.9286965160359637, 1.632209376428898, 0.7636983882030178, 0.0), # 83
(10.181322061191626, 8.362569295101553, 8.14811149691358, 8.768290081521739, 7.423111837327523, 3.584544924554184, 3.477088909637929, 2.851841563786008, 3.8285365226337444, 1.6620367465504726, 1.3038055555555557, 0.7454835390946503, 0.0, 10.007711226851852, 8.200318930041153, 6.519027777777778, 4.986110239651417, 7.657073045267489, 3.9925781893004113, 3.477088909637929, 2.5603892318244172, 3.7115559186637617, 2.922763360507247, 1.629622299382716, 0.7602335722819594, 0.0), # 84
(10.159472475696308, 8.32414528850834, 8.13497549439872, 8.75009749899356, 7.414333360230238, 3.577762218665854, 3.463213440383012, 2.8391965782655086, 3.8219816910531925, 1.6565574652357518, 1.2994910114793157, 0.7436762488067449, 0.0, 9.994376393175584, 8.180438736874192, 6.497455057396579, 4.969672395707254, 7.643963382106385, 3.9748752095717124, 3.463213440383012, 2.5555444419041815, 3.707166680115119, 2.916699166331187, 1.626995098879744, 0.7567404807734855, 0.0), # 85
(10.136749746525913, 8.285429233594407, 8.121642303955191, 8.731527501006443, 7.405183705855455, 3.57073412335518, 3.44924229499756, 2.826665904587715, 3.815327636793172, 1.6510620457785314, 1.2950766387067558, 0.7418439302416996, 0.0, 9.98048857596022, 8.160283232658694, 6.475383193533778, 4.953186137335593, 7.630655273586344, 3.9573322664228017, 3.44924229499756, 2.550524373825129, 3.7025918529277275, 2.910509167002148, 1.6243284607910382, 0.7532208394176735, 0.0), # 86
(10.113199677938807, 8.246440113500597, 8.10811535493827, 8.712595788043478, 7.3956790123456795, 3.563477709190672, 3.4351807760141093, 2.8142541152263374, 3.8085807613168727, 1.645550617283951, 1.290569643806486, 0.7399875460255577, 0.0, 9.96607349537037, 8.139863006281134, 6.452848219032429, 4.936651851851852, 7.6171615226337455, 3.9399557613168725, 3.4351807760141093, 2.54534122085048, 3.6978395061728397, 2.904198596014493, 1.6216230709876542, 0.7496763739545999, 0.0), # 87
(10.088868074193357, 8.207196911367758, 8.094398076703246, 8.693318060587762, 7.385835417843406, 3.5560100467408424, 3.4210341859651954, 2.801965782655083, 3.8017474660874866, 1.6400233088571508, 1.2859772333471164, 0.7381080587843638, 0.0, 9.951156871570646, 8.119188646628, 6.429886166735582, 4.9200699265714505, 7.603494932174973, 3.9227520957171165, 3.4210341859651954, 2.540007176243459, 3.692917708921703, 2.897772686862588, 1.6188796153406495, 0.7461088101243417, 0.0), # 88
(10.063800739547922, 8.16771861033674, 8.080493898605397, 8.673710019122383, 7.375669060491138, 3.5483482065742016, 3.406807827383354, 2.7898054793476605, 3.794834152568206, 1.634480249603271, 1.2813066138972575, 0.7362064311441613, 0.0, 9.935764424725651, 8.098270742585774, 6.4065330694862865, 4.903440748809812, 7.589668305136412, 3.905727671086725, 3.406807827383354, 2.534534433267287, 3.687834530245569, 2.891236673040795, 1.6160987797210793, 0.7425198736669765, 0.0), # 89
(10.03804347826087, 8.128024193548386, 8.06640625, 8.653787364130435, 7.365196078431373, 3.5405092592592595, 3.3925070028011204, 2.7777777777777777, 3.7878472222222226, 1.6289215686274514, 1.2765649920255184, 0.7342836257309943, 0.0, 9.919921875, 8.077119883040936, 6.382824960127592, 4.886764705882353, 7.575694444444445, 3.888888888888889, 3.3925070028011204, 2.5289351851851856, 3.6825980392156863, 2.884595788043479, 1.6132812500000002, 0.7389112903225807, 0.0), # 90
(10.011642094590563, 8.088132644143545, 8.05213856024234, 8.63356579609501, 7.35443260980661, 3.532510275364528, 3.378137014751031, 2.7658872504191434, 3.780793076512727, 1.6233473950348318, 1.2717595743005101, 0.7323406051709063, 0.0, 9.903654942558298, 8.055746656879968, 6.35879787150255, 4.870042185104494, 7.561586153025454, 3.872242150586801, 3.378137014751031, 2.5232216252603767, 3.677216304903305, 2.8778552653650036, 1.6104277120484682, 0.7352847858312315, 0.0), # 91
(9.984642392795372, 8.048062945263066, 8.0376942586877, 8.613061015499195, 7.343394792759352, 3.524368325458518, 3.363703165765621, 2.754138469745466, 3.773678116902911, 1.6177578579305527, 1.2668975672908422, 0.7303783320899415, 0.0, 9.886989347565157, 8.034161652989356, 6.334487836454211, 4.853273573791657, 7.547356233805822, 3.8557938576436523, 3.363703165765621, 2.517405946756084, 3.671697396379676, 2.871020338499732, 1.6075388517375402, 0.7316420859330061, 0.0), # 92
(9.957090177133654, 8.00783408004779, 8.023076774691358, 8.592288722826089, 7.332098765432098, 3.5161004801097393, 3.349210758377425, 2.742536008230453, 3.766508744855967, 1.6121530864197533, 1.261986177565125, 0.7283977691141434, 0.0, 9.869950810185184, 8.012375460255576, 6.309930887825625, 4.836459259259259, 7.533017489711934, 3.839550411522634, 3.349210758377425, 2.5115003429355283, 3.666049382716049, 2.86409624094203, 1.6046153549382718, 0.727984916367981, 0.0), # 93
(9.92903125186378, 7.967465031638567, 8.008289537608597, 8.571264618558777, 7.320560665967347, 3.5077238098867043, 3.3346650951189805, 2.7310844383478132, 3.759291361835086, 1.6065332096075746, 1.2570326116919686, 0.7263998788695563, 0.0, 9.85256505058299, 7.990398667565118, 6.285163058459842, 4.819599628822722, 7.518582723670172, 3.823518213686939, 3.3346650951189805, 2.5055170070619317, 3.6602803329836733, 2.8570882061862592, 1.6016579075217197, 0.7243150028762335, 0.0), # 94
(9.90051142124411, 7.926974783176247, 7.993335976794697, 8.550004403180354, 7.308796632507598, 3.499255385357923, 3.320071478522822, 2.719788332571255, 3.7520323693034596, 1.6008983565991557, 1.2520440762399827, 0.7243856239822234, 0.0, 9.834857788923182, 7.968241863804456, 6.260220381199914, 4.8026950697974655, 7.504064738606919, 3.8077036655997567, 3.320071478522822, 2.4994681323985164, 3.654398316253799, 2.850001467726785, 1.5986671953589393, 0.7206340711978407, 0.0), # 95
(9.871576489533012, 7.886382317801674, 7.978219521604939, 8.528523777173913, 7.296822803195352, 3.4907122770919066, 3.3054352111214853, 2.708652263374486, 3.7447381687242793, 1.5952486564996373, 1.247027777777778, 0.7223559670781895, 0.0, 9.816854745370371, 7.945915637860083, 6.23513888888889, 4.785745969498911, 7.489476337448559, 3.7921131687242804, 3.3054352111214853, 2.4933659122085046, 3.648411401597676, 2.8428412590579715, 1.595643904320988, 0.7169438470728796, 0.0), # 96
(9.842272260988848, 7.845706618655694, 7.962943601394604, 8.506838441022543, 7.284655316173109, 3.482111555657166, 3.2907615954475067, 2.697680803231215, 3.7374151615607376, 1.589584238414159, 1.2419909228739638, 0.7203118707834976, 0.0, 9.798581640089164, 7.923430578618472, 6.209954614369819, 4.768752715242476, 7.474830323121475, 3.7767531245237014, 3.2907615954475067, 2.4872225397551184, 3.6423276580865545, 2.8356128136741816, 1.5925887202789208, 0.7132460562414268, 0.0), # 97
(9.812644539869984, 7.804966668879153, 7.947511645518976, 8.48496409520934, 7.272310309583368, 3.4734702916222124, 3.276055934033421, 2.68687852461515, 3.7300697492760246, 1.5839052314478608, 1.236940718097151, 0.7182542977241916, 0.0, 9.78006419324417, 7.900797274966106, 6.184703590485755, 4.751715694343581, 7.460139498552049, 3.7616299344612103, 3.276055934033421, 2.48105020830158, 3.636155154791684, 2.8283213650697805, 1.589502329103795, 0.7095424244435595, 0.0), # 98
(9.782739130434782, 7.764181451612902, 7.931927083333334, 8.462916440217391, 7.259803921568627, 3.464805555555556, 3.261323529411765, 2.67625, 3.7227083333333333, 1.5782117647058826, 1.2318843700159492, 0.7161842105263159, 0.0, 9.761328125, 7.878026315789473, 6.159421850079745, 4.734635294117647, 7.445416666666667, 3.7467500000000005, 3.261323529411765, 2.474861111111111, 3.6299019607843137, 2.820972146739131, 1.5863854166666669, 0.7058346774193549, 0.0), # 99
(9.752601836941611, 7.723369949997786, 7.916193344192958, 8.44071117652979, 7.247152290271389, 3.4561344180257074, 3.2465696841150726, 2.665799801859473, 3.715337315195854, 1.572503967293365, 1.2268290851989685, 0.714102571815914, 0.0, 9.742399155521262, 7.8551282899750525, 6.134145425994841, 4.717511901880093, 7.430674630391708, 3.732119722603262, 3.2465696841150726, 2.468667441446934, 3.6235761451356945, 2.8135703921765973, 1.5832386688385918, 0.7021245409088898, 0.0), # 100
(9.722278463648834, 7.682551147174654, 7.900313857453133, 8.41836400462963, 7.234371553834153, 3.4474739496011786, 3.231799700675881, 2.6555325026672763, 3.7079630963267793, 1.5667819683154474, 1.2217820702148188, 0.7120103442190294, 0.0, 9.723303004972564, 7.832113786409323, 6.108910351074094, 4.7003459049463405, 7.415926192653559, 3.7177455037341867, 3.231799700675881, 2.4624813925722706, 3.6171857769170765, 2.806121334876544, 1.5800627714906266, 0.6984137406522414, 0.0), # 101
(9.691814814814816, 7.641744026284349, 7.884292052469135, 8.395890625, 7.221477850399419, 3.4388412208504806, 3.217018881626725, 2.645452674897119, 3.7005920781893, 1.56104589687727, 1.2167505316321108, 0.7099084903617069, 0.0, 9.704065393518519, 7.808993393978774, 6.083752658160553, 4.683137690631809, 7.4011841563786, 3.703633744855967, 3.217018881626725, 2.4563151577503435, 3.6107389251997093, 2.798630208333334, 1.5768584104938272, 0.6947040023894864, 0.0), # 102
(9.661256694697919, 7.60096757046772, 7.8681313585962505, 8.373306738123993, 7.208487318109686, 3.430253302342123, 3.20223252950014, 2.63556489102271, 3.6932306622466085, 1.5552958820839726, 1.211741676019454, 0.7077979728699895, 0.0, 9.68471204132373, 7.785777701569883, 6.058708380097269, 4.6658876462519165, 7.386461324493217, 3.689790847431794, 3.20223252950014, 2.4501809302443736, 3.604243659054843, 2.7911022460413317, 1.5736262717192502, 0.6909970518607019, 0.0), # 103
(9.63064990755651, 7.560240762865614, 7.851835205189758, 8.350628044484703, 7.195416095107452, 3.421727264644617, 3.187445946828663, 2.6258737235177567, 3.685885249961896, 1.5495320530406955, 1.2067627099454585, 0.7056797543699213, 0.0, 9.665268668552812, 7.762477298069133, 6.033813549727292, 4.648596159122086, 7.371770499923792, 3.6762232129248593, 3.187445946828663, 2.4440909033175835, 3.597708047553726, 2.783542681494901, 1.5703670410379515, 0.687294614805965, 0.0), # 104
(9.600040257648953, 7.519582586618876, 7.835407021604938, 8.327870244565217, 7.182280319535221, 3.4132801783264752, 3.172664436144829, 2.6163837448559675, 3.6785622427983538, 1.5437545388525786, 1.201820839978735, 0.7035547974875461, 0.0, 9.64576099537037, 7.739102772363006, 6.009104199893674, 4.631263616557734, 7.3571244855967075, 3.662937242798354, 3.172664436144829, 2.4380572702331964, 3.5911401597676105, 2.775956748188406, 1.5670814043209877, 0.6835984169653525, 0.0), # 105
(9.569473549233614, 7.479012024868357, 7.818850237197074, 8.305049038848631, 7.1690961295354905, 3.404929113956206, 3.1578932999811724, 2.6070995275110502, 3.6712680422191735, 1.5379634686247616, 1.1969232726878927, 0.701424064848908, 0.0, 9.626214741941014, 7.715664713337986, 5.9846163634394625, 4.613890405874283, 7.342536084438347, 3.6499393385154706, 3.1578932999811724, 2.4320922242544327, 3.5845480647677452, 2.768349679616211, 1.5637700474394147, 0.6799101840789417, 0.0), # 106
(9.538995586568856, 7.438548060754901, 7.802168281321446, 8.282180127818036, 7.155879663250759, 3.3966911421023225, 3.1431378408702306, 2.5980256439567144, 3.6640090496875475, 1.532158971462385, 1.1920772146415421, 0.6992885190800504, 0.0, 9.606655628429355, 7.692173709880553, 5.96038607320771, 4.596476914387154, 7.328018099375095, 3.6372359015394005, 3.1431378408702306, 2.426207958644516, 3.5779398316253794, 2.760726709272679, 1.5604336562642893, 0.6762316418868093, 0.0), # 107
(9.508652173913044, 7.398209677419356, 7.785364583333334, 8.259279211956523, 7.1426470588235285, 3.3885833333333335, 3.1284033613445374, 2.589166666666667, 3.656791666666667, 1.5263411764705888, 1.1872898724082936, 0.6971491228070177, 0.0, 9.587109375, 7.668640350877193, 5.936449362041468, 4.579023529411765, 7.313583333333334, 3.624833333333334, 3.1284033613445374, 2.4204166666666667, 3.5713235294117642, 2.7530930706521746, 1.557072916666667, 0.6725645161290325, 0.0), # 108
(9.478489115524543, 7.358015858002567, 7.768442572588021, 8.23636199174718, 7.129414454396299, 3.3806227582177515, 3.113695163936631, 2.580527168114617, 3.6496222946197223, 1.5205102127545123, 1.1825684525567568, 0.6950068386558532, 0.0, 9.567601701817559, 7.645075225214384, 5.9128422627837836, 4.561530638263536, 7.299244589239445, 3.612738035360464, 3.113695163936631, 2.4147305415841083, 3.5647072271981495, 2.7454539972490606, 1.5536885145176043, 0.668910532545688, 0.0), # 109
(9.448552215661715, 7.317985585645383, 7.751405678440788, 8.213444167673108, 7.116197988111569, 3.3728264873240867, 3.0990185511790447, 2.5721117207742723, 3.6425073350099066, 1.5146662094192962, 1.177920161655542, 0.6928626292526012, 0.0, 9.54815832904664, 7.621488921778612, 5.8896008082777085, 4.543998628257887, 7.285014670019813, 3.600956409083981, 3.0990185511790447, 2.409161776660062, 3.5580989940557846, 2.737814722557703, 1.5502811356881578, 0.6652714168768531, 0.0), # 110
(9.41888727858293, 7.278137843488651, 7.7342573302469155, 8.190541440217391, 7.103013798111837, 3.365211591220851, 3.0843788256043156, 2.5639248971193416, 3.635453189300412, 1.5088092955700803, 1.173352206273259, 0.6907174572233054, 0.0, 9.528804976851852, 7.597892029456357, 5.866761031366295, 4.526427886710239, 7.270906378600824, 3.5894948559670783, 3.0843788256043156, 2.4037225651577505, 3.5515068990559184, 2.7301804800724643, 1.546851466049383, 0.6616488948626047, 0.0), # 111
(9.38954010854655, 7.238491614673214, 7.717000957361684, 8.167669509863124, 7.089878022539605, 3.357795140476554, 3.069781289744979, 2.5559712696235333, 3.628466258954427, 1.5029396003120044, 1.1688717929785184, 0.6885722851940093, 0.0, 9.509567365397805, 7.574295137134101, 5.844358964892591, 4.5088188009360115, 7.256932517908854, 3.5783597774729463, 3.069781289744979, 2.3984251003403956, 3.5449390112698027, 2.7225565032877084, 1.543400191472337, 0.6580446922430195, 0.0), # 112
(9.360504223703044, 7.1991320672204555, 7.699681523543391, 8.14487541186903, 7.076783786782469, 3.3505906987084666, 3.0552629818283847, 2.548271903658586, 3.6215709370862066, 1.4970761841531826, 1.1644873176921446, 0.6864327447087024, 0.0, 9.490443900843221, 7.550760191795725, 5.8224365884607225, 4.491228552459547, 7.243141874172413, 3.5675806651220205, 3.0552629818283847, 2.3932790705060474, 3.5383918933912346, 2.7149584706230105, 1.5399363047086783, 0.654466551565496, 0.0), # 113
(9.331480897900065, 7.16044741823174, 7.682538062518016, 8.122342065958001, 7.063595569710884, 3.343581854975776, 3.0410091042052896, 2.5409213581271333, 3.6148730119043533, 1.491328791978196, 1.1602073895188663, 0.684326014342748, 0.0, 9.471275414160035, 7.5275861577702265, 5.801036947594331, 4.473986375934587, 7.229746023808707, 3.557289901377987, 3.0410091042052896, 2.3882727535541255, 3.531797784855442, 2.7074473553193346, 1.5365076125036032, 0.6509497652937947, 0.0), # 114
(9.302384903003995, 7.122451598792792, 7.665580777256098, 8.100063378886334, 7.050271785259067, 3.3367503822909463, 3.027029825095781, 2.533917772616129, 3.6083749928895963, 1.4857063319970194, 1.1560257519045158, 0.6822531318799043, 0.0, 9.452006631660376, 7.5047844506789465, 5.7801287595225785, 4.457118995991058, 7.216749985779193, 3.5474848816625806, 3.027029825095781, 2.3833931302078186, 3.5251358926295335, 2.700021126295445, 1.5331161554512198, 0.647495599890254, 0.0), # 115
(9.273179873237634, 7.0850892578507265, 7.648776824986561, 8.077999612699802, 7.036792350922519, 3.330080178417474, 3.0133024087639466, 2.5272417970412473, 3.6020604464092765, 1.480198339612387, 1.1519343218785802, 0.6802102664572789, 0.0, 9.43260725975589, 7.482312931030067, 5.7596716093929015, 4.44059501883716, 7.204120892818553, 3.5381385158577463, 3.0133024087639466, 2.3786286988696244, 3.5183961754612594, 2.6926665375666015, 1.5297553649973124, 0.6440990234409752, 0.0), # 116
(9.243829442823772, 7.04830504435266, 7.632093362938321, 8.056111029444182, 7.02313718419674, 3.323555141118853, 2.9998041194738763, 2.5208740813181603, 3.5959129388307343, 1.4747943502270324, 1.1479250164705472, 0.6781935872119792, 0.0, 9.413047004858225, 7.46012945933177, 5.739625082352736, 4.424383050681096, 7.1918258776614685, 3.5292237138454245, 2.9998041194738763, 2.3739679579420376, 3.51156859209837, 2.6853703431480613, 1.5264186725876645, 0.6407550040320601, 0.0), # 117
(9.214297245985211, 7.0120436072457135, 7.615497548340306, 8.03435789116525, 7.009286202577227, 3.317159168158581, 2.9865122214896576, 2.51479527536254, 3.5899160365213114, 1.46948389924369, 1.143989752709904, 0.6761992632811126, 0.0, 9.393295573379024, 7.438191896092237, 5.71994876354952, 4.40845169773107, 7.179832073042623, 3.5207133855075567, 2.9865122214896576, 2.369399405827558, 3.5046431012886137, 2.678119297055084, 1.5230995096680613, 0.6374585097496104, 0.0), # 118
(9.184546916944742, 6.976249595477001, 7.598956538421437, 8.012700459908778, 6.99521932355948, 3.3108761573001524, 2.973403979075378, 2.5089860290900607, 3.5840533058483475, 1.4642565220650932, 1.1401204476261382, 0.6742234638017862, 0.0, 9.373322671729932, 7.416458101819647, 5.70060223813069, 4.392769566195279, 7.168106611696695, 3.5125804407260848, 2.973403979075378, 2.3649115409286803, 3.49760966177974, 2.670900153302927, 1.5197913076842873, 0.6342045086797276, 0.0), # 119
(9.154542089925162, 6.940867657993644, 7.582437490410635, 7.991098997720545, 6.980916464638998, 3.304690006307063, 2.9604566564951265, 2.5034269924163928, 3.578308313179186, 1.4591017540939766, 1.136309018248736, 0.6722623579111081, 0.0, 9.353098006322597, 7.394885937022188, 5.68154509124368, 4.377305262281929, 7.156616626358372, 3.50479778938295, 2.9604566564951265, 2.360492861647902, 3.490458232319499, 2.663699665906849, 1.516487498082127, 0.6309879689085133, 0.0), # 120
(9.124246399149268, 6.90584244374276, 7.565907561536823, 7.969513766646325, 6.966357543311279, 3.29858461294281, 2.94764751801299, 2.4980988152572112, 3.572664624881166, 1.4540091307330743, 1.1325473816071863, 0.6703121147461852, 0.0, 9.33259128356866, 7.373433262208036, 5.662736908035931, 4.362027392199222, 7.145329249762332, 3.497338341360096, 2.94764751801299, 2.356131866387721, 3.4831787716556395, 2.656504588882109, 1.5131815123073646, 0.6278038585220692, 0.0), # 121
(9.093623478839854, 6.871118601671464, 7.549333909028926, 7.947905028731892, 6.951522477071823, 3.292543874970886, 2.9349538278930587, 2.492982147528187, 3.5671058073216297, 1.4489681873851195, 1.1288274547309753, 0.6683689034441251, 0.0, 9.31177220987977, 7.352057937885375, 5.644137273654876, 4.346904562155357, 7.1342116146432595, 3.490175006539462, 2.9349538278930587, 2.351817053550633, 3.4757612385359113, 2.6493016762439643, 1.5098667818057854, 0.6246471456064968, 0.0), # 122
(9.062636963219719, 6.836640780726876, 7.532683690115864, 7.92623304602302, 6.936391183416127, 3.28655169015479, 2.9223528503994194, 2.4880576391449933, 3.5616154268679177, 1.443968459452847, 1.1251411546495909, 0.6664288931420351, 0.0, 9.290610491667572, 7.330717824562385, 5.625705773247954, 4.33190537835854, 7.123230853735835, 3.4832806948029904, 2.9223528503994194, 2.3475369215391355, 3.4681955917080636, 2.642077682007674, 1.5065367380231727, 0.621512798247898, 0.0), # 123
(9.031250486511654, 6.802353629856113, 7.515924062026559, 7.90445808056549, 6.920943579839691, 3.2805919562580144, 2.9098218497961597, 2.483305940023303, 3.5561770498873715, 1.4389994823389904, 1.1214803983925201, 0.664488252977023, 0.0, 9.269075835343711, 7.309370782747252, 5.6074019919625995, 4.316998447016971, 7.112354099774743, 3.476628316032624, 2.9098218497961597, 2.3432799687557244, 3.4604717899198456, 2.634819360188497, 1.5031848124053118, 0.618395784532374, 0.0), # 124
(8.999427682938459, 6.768201798006293, 7.499022181989936, 7.88254039440507, 6.905159583838015, 3.274648571044058, 2.8973380903473696, 2.478707700078788, 3.5507742427473308, 1.4340507914462837, 1.1178371029892504, 0.6625431520861957, 0.0, 9.247137947319828, 7.2879746729481525, 5.5891855149462515, 4.30215237433885, 7.1015484854946616, 3.470190780110303, 2.8973380903473696, 2.3390346936028985, 3.4525797919190073, 2.6275134648016905, 1.4998044363979874, 0.6152910725460268, 0.0), # 125
(8.967132186722928, 6.734129934124536, 7.481945207234916, 7.8604402495875405, 6.889019112906595, 3.2687054322764144, 2.884878836317135, 2.474243569227122, 3.545390571815139, 1.4291119221774609, 1.1142031854692689, 0.6605897596066612, 0.0, 9.224766534007578, 7.266487355673273, 5.571015927346345, 4.287335766532382, 7.090781143630278, 3.463940996917971, 2.884878836317135, 2.334789594483153, 3.4445095564532977, 2.620146749862514, 1.4963890414469831, 0.6121936303749579, 0.0), # 126
(8.93432763208786, 6.7000826871579555, 7.464660294990421, 7.838117908158674, 6.8725020845409315, 3.26274643771858, 2.872421351969547, 2.469894197383977, 3.5400096034581354, 1.4241724099352562, 1.1105705628620632, 0.6586242446755264, 0.0, 9.201931301818599, 7.244866691430789, 5.552852814310316, 4.272517229805768, 7.080019206916271, 3.457851876337568, 2.872421351969547, 2.3305331697989855, 3.4362510422704657, 2.612705969386225, 1.4929320589980841, 0.6090984261052688, 0.0), # 127
(8.900977653256046, 6.666004706053673, 7.447134602485375, 7.815533632164248, 6.855588416236526, 3.2567554851340508, 2.859942901568691, 2.465640234465026, 3.534614904043661, 1.4192217901224033, 1.1069311521971208, 0.6566427764298991, 0.0, 9.178601957164537, 7.223070540728888, 5.534655760985604, 4.257665370367209, 7.069229808087322, 3.4518963282510366, 2.859942901568691, 2.3262539179528936, 3.427794208118263, 2.6051778773880834, 1.4894269204970751, 0.6060004278230613, 0.0), # 128
(8.867045884450281, 6.631840639758805, 7.4293352869486995, 7.792647683650037, 6.838258025488874, 3.250716472286322, 2.8474207493786565, 2.4614623303859418, 3.529190039939058, 1.4142495981416365, 1.1032768705039286, 0.6546415240068865, 0.0, 9.154748206457038, 7.20105676407575, 5.516384352519642, 4.242748794424909, 7.058380079878116, 3.4460472625403185, 2.8474207493786565, 2.321940337347373, 3.419129012744437, 2.597549227883346, 1.4858670573897401, 0.6028946036144368, 0.0), # 129
(8.832495959893366, 6.5975351372204685, 7.411229505609316, 7.769420324661814, 6.820490829793475, 3.2446132969388883, 2.8348321596635313, 2.457341135062396, 3.5237185775116666, 1.4092453693956895, 1.0995996348119743, 0.6526166565435961, 0.0, 9.130339756107748, 7.178783221979556, 5.4979981740598705, 4.2277361081870675, 7.047437155023333, 3.4402775890873545, 2.8348321596635313, 2.3175809263849203, 3.4102454148967376, 2.589806774887272, 1.4822459011218634, 0.5997759215654973, 0.0), # 130
(8.797291513808094, 6.563032847385783, 7.392784415696151, 7.7458118172453565, 6.802266746645829, 3.238429856855247, 2.8221543966874045, 2.4532572984100627, 3.5181840831288285, 1.4041986392872965, 1.0958913621507447, 0.6505643431771354, 0.0, 9.105346312528312, 7.156207774948489, 5.479456810753724, 4.212595917861889, 7.036368166257657, 3.4345602177740875, 2.8221543966874045, 2.3131641834680337, 3.4011333733229145, 2.5819372724151193, 1.4785568831392302, 0.596639349762344, 0.0), # 131
(8.76139618041726, 6.528278419201865, 7.373967174438122, 7.72178242344644, 6.783565693541435, 3.2321500497988933, 2.8093647247143627, 2.449191470344614, 3.5125701231578845, 1.3990989432191914, 1.0921439695497275, 0.6484807530446118, 0.0, 9.079737582130376, 7.13328828349073, 5.460719847748638, 4.1972968296575734, 7.025140246315769, 3.4288680584824593, 2.8093647247143627, 2.3086786069992096, 3.3917828467707176, 2.573927474482147, 1.4747934348876244, 0.5934798562910787, 0.0), # 132
(8.724773593943663, 6.493216501615832, 7.354744939064153, 7.697292405310838, 6.764367587975791, 3.225757773533322, 2.7964404080084946, 2.445124300781722, 3.5068602639661752, 1.3939358165941083, 1.0883493740384103, 0.6463620552831327, 0.0, 9.053483271325586, 7.10998260811446, 5.44174687019205, 4.181807449782324, 7.0137205279323505, 3.4231740210944106, 2.7964404080084946, 2.3041126953809443, 3.3821837939878954, 2.5657641351036133, 1.4709489878128308, 0.590292409237803, 0.0), # 133
(8.687387388610095, 6.457791743574804, 7.33508486680317, 7.672302024884328, 6.7446523474443945, 3.2192369258220297, 2.7833587108338893, 2.44103643963706, 3.5010380719210428, 1.388698794814781, 1.0844994926462799, 0.6442044190298056, 0.0, 9.026553086525583, 7.0862486093278605, 5.422497463231399, 4.166096384444343, 7.0020761438420855, 3.417451015491884, 2.7833587108338893, 2.2994549470157355, 3.3723261737221972, 2.557434008294776, 1.4670169733606342, 0.5870719766886187, 0.0), # 134
(8.649201198639354, 6.421948794025897, 7.314954114884091, 7.646771544212684, 6.724399889442747, 3.212571404428512, 2.770096897454634, 2.4369085368263, 3.4950871133898262, 1.3833774132839443, 1.0805862424028239, 0.6420040134217377, 0.0, 8.99891673414202, 7.0620441476391145, 5.402931212014119, 4.150132239851832, 6.9901742267796525, 3.41167195155682, 2.770096897454634, 2.2946938603060802, 3.3621999447213735, 2.548923848070895, 1.4629908229768183, 0.583813526729627, 0.0), # 135
(8.610178658254235, 6.385632301916229, 7.294319840535841, 7.62066122534168, 6.703590131466344, 3.205745107116265, 2.7566322321348173, 2.4327212422651154, 3.4889909547398688, 1.3779612074043308, 1.0766015403375297, 0.6397570075960368, 0.0, 8.970543920586536, 7.037327083556404, 5.383007701687648, 4.133883622212991, 6.9779819094797375, 3.4058097391711617, 2.7566322321348173, 2.289817933654475, 3.351795065733172, 2.540220408447227, 1.4588639681071682, 0.58051202744693, 0.0), # 136
(8.570283401677534, 6.348786916192918, 7.273149200987342, 7.593931330317094, 6.682202991010689, 3.1987419316487826, 2.7429419791385277, 2.428455205869179, 3.4827331623385107, 1.3724397125786756, 1.0725373034798844, 0.63745957068981, 0.0, 8.941404352270776, 7.012055277587909, 5.362686517399421, 4.117319137736026, 6.965466324677021, 3.3998372882168506, 2.7429419791385277, 2.284815665463416, 3.3411014955053444, 2.5313104434390317, 1.4546298401974684, 0.577162446926629, 0.0), # 137
(8.529479063132047, 6.311357285803083, 7.251409353467515, 7.566542121184698, 6.660218385571278, 3.1915457757895624, 2.729003402729852, 2.4240910775541624, 3.4762973025530934, 1.3668024642097119, 1.0683854488593754, 0.6351078718401649, 0.0, 8.91146773560639, 6.986186590241813, 5.341927244296877, 4.100407392629135, 6.952594605106187, 3.3937275085758274, 2.729003402729852, 2.2796755541354017, 3.330109192785639, 2.5221807070615663, 1.450281870693503, 0.5737597532548258, 0.0), # 138
(8.487729276840568, 6.273288059693839, 7.229067455205284, 7.538453859990269, 6.63761623264361, 3.184140537302099, 2.7147937671728797, 2.4196095072357395, 3.469666941750957, 1.3610389977001744, 1.0641378935054902, 0.6326980801842089, 0.0, 8.880703777005019, 6.959678882026297, 5.32068946752745, 4.083116993100523, 6.939333883501914, 3.3874533101300353, 2.7147937671728797, 2.274386098072928, 3.318808116321805, 2.51281795333009, 1.4458134910410567, 0.5702989145176218, 0.0), # 139
(8.444997677025897, 6.234523886812306, 7.206090663429573, 7.509626808779583, 6.614376449723186, 3.176510113949888, 2.7002903367316984, 2.4149911448295818, 3.462825646299444, 1.3551388484527966, 1.0597865544477159, 0.6302263648590494, 0.0, 8.849082182878314, 6.932490013449542, 5.298932772238579, 4.0654165453583895, 6.925651292598888, 3.3809876027614147, 2.7002903367316984, 2.2689357956784915, 3.307188224861593, 2.5032089362598615, 1.4412181326859146, 0.5667748988011189, 0.0), # 140
(8.40124789791083, 6.195009416105602, 7.1824461353693, 7.480021229598415, 6.590478954305501, 3.1686384034964257, 2.6854703756703975, 2.4102166402513627, 3.455756982565893, 1.349091551870313, 1.0553233487155398, 0.6276888950017938, 0.0, 8.816572659637913, 6.904577845019731, 5.276616743577699, 4.047274655610939, 6.911513965131786, 3.3743032963519077, 2.6854703756703975, 2.26331314535459, 3.2952394771527507, 2.4933404098661387, 1.4364892270738603, 0.5631826741914184, 0.0), # 141
(8.356443573718156, 6.154689296520844, 7.158101028253392, 7.44959738449254, 6.565903663886058, 3.1605093037052074, 2.670311148253063, 2.4052666434167547, 3.448444516917647, 1.3428866433554572, 1.0507401933384497, 0.6250818397495496, 0.0, 8.783144913695466, 6.875900237245045, 5.253700966692247, 4.028659930066371, 6.896889033835294, 3.3673733007834565, 2.670311148253063, 2.2575066455037196, 3.282951831943029, 2.4831991281641805, 1.4316202056506786, 0.5595172087746222, 0.0), # 142
(8.310548338670674, 6.113508177005149, 7.133022499310772, 7.418315535507731, 6.540630495960352, 3.152106712339729, 2.6547899187437842, 2.4001218042414303, 3.4408718157220486, 1.3365136583109634, 1.0460290053459322, 0.6224013682394242, 0.0, 8.748768651462617, 6.846415050633665, 5.230145026729661, 4.009540974932889, 6.881743631444097, 3.360170525938002, 2.6547899187437842, 2.251504794528378, 3.270315247980176, 2.472771845169244, 1.4266044998621543, 0.5557734706368318, 0.0), # 143
(8.263525826991184, 6.071410706505636, 7.107177705770357, 7.386135944689768, 6.514639368023886, 3.1434145271634857, 2.6388839514066493, 2.3947627726410623, 3.4330224453464364, 1.3299621321395652, 1.0411817017674754, 0.619643649608525, 0.0, 8.713413579351014, 6.816080145693774, 5.205908508837376, 3.9898863964186946, 6.866044890692873, 3.3526678816974873, 2.6388839514066493, 2.245296090831061, 3.257319684011943, 2.4620453148965895, 1.4214355411540713, 0.5519464278641489, 0.0), # 144
(8.215339672902477, 6.0283415339694235, 7.080533804861075, 7.353018874084421, 6.487910197572155, 3.134416645939974, 2.6225705105057466, 2.3891701985313234, 3.424879972158151, 1.3232216002439972, 1.036190199632566, 0.6168048529939595, 0.0, 8.6770494037723, 6.784853382933553, 5.180950998162829, 3.969664800731991, 6.849759944316302, 3.344838277943853, 2.6225705105057466, 2.238869032814267, 3.2439550987860777, 2.451006291361474, 1.4161067609722149, 0.548031048542675, 0.0), # 145
(8.16595351062735, 5.984245308343629, 7.053057953811847, 7.318924585737469, 6.460422902100661, 3.1250969664326886, 2.605826860305165, 2.3833247318278863, 3.4164279625245353, 1.3162815980269928, 1.0310464159706916, 0.6138811475328351, 0.0, 8.639645831138118, 6.7526926228611845, 5.155232079853457, 3.948844794080978, 6.832855925049071, 3.3366546245590407, 2.605826860305165, 2.2322121188804918, 3.2302114510503306, 2.439641528579157, 1.4106115907623695, 0.5440223007585119, 0.0), # 146
(8.1153309743886, 5.93906667857537, 7.024717309851591, 7.283813341694685, 6.4321573991049, 3.1154393864051255, 2.5886302650689905, 2.3772070224464232, 3.40764998281293, 1.3091316608912866, 1.0257422678113395, 0.6108687023622593, 0.0, 8.601172567860118, 6.719555725984851, 5.1287113390566965, 3.9273949826738592, 6.81529996562586, 3.3280898314249923, 2.5886302650689905, 2.2253138474322327, 3.21607869955245, 2.4279377805648954, 1.4049434619703185, 0.5399151525977609, 0.0), # 147
(8.063435698409021, 5.892750293611764, 6.9954790302092364, 7.247645404001847, 6.403093606080374, 3.105427803620781, 2.5709579890613132, 2.3707977203026074, 3.398529599390676, 1.301761324239612, 1.0202696721839972, 0.6077636866193392, 0.0, 8.561599320349941, 6.68540055281273, 5.101348360919985, 3.905283972718835, 6.797059198781352, 3.3191168084236504, 2.5709579890613132, 2.2181627168719866, 3.201546803040187, 2.4158818013339496, 1.3990958060418472, 0.535704572146524, 0.0), # 148
(8.010231316911412, 5.845240802399927, 6.965310272113703, 7.210381034704727, 6.37321144052258, 3.0950461158431497, 2.5527872965462204, 2.3640774753121114, 3.3890503786251127, 1.2941601234747035, 1.0146205461181517, 0.6045622694411826, 0.0, 8.520895795019237, 6.650184963853008, 5.073102730590758, 3.88248037042411, 6.778100757250225, 3.3097084654369557, 2.5527872965462204, 2.21074722560225, 3.18660572026129, 2.403460344901576, 1.3930620544227408, 0.5313855274909026, 0.0), # 149
(7.955681464118564, 5.796482853886981, 6.934178192793912, 7.171980495849104, 6.342490819927017, 3.0842782208357287, 2.5340954517878003, 2.3570269373906068, 3.3791958868835836, 1.2863175939992944, 1.0087868066432906, 0.601260619964897, 0.0, 8.479031698279647, 6.6138668196138655, 5.043934033216452, 3.8589527819978824, 6.758391773767167, 3.2998377123468496, 2.5340954517878003, 2.2030558720255207, 3.1712454099635083, 2.390660165283035, 1.3868356385587826, 0.5269529867169983, 0.0), # 150
(7.899749774253275, 5.746421097020041, 6.902049949478785, 7.132404049480748, 6.310911661789184, 3.0731080163620113, 2.5148597190501416, 2.3496267564537683, 3.3689496905334293, 1.2782232712161197, 1.002760370788901, 0.5978549073275894, 0.0, 8.435976736542818, 6.576403980603482, 5.013801853944504, 3.8346698136483583, 6.737899381066859, 3.2894774590352753, 2.5148597190501416, 2.1950771545442938, 3.155455830894592, 2.377468016493583, 1.3804099898957571, 0.5224019179109128, 0.0), # 151
(7.842399881538343, 5.6950001807462245, 6.868892699397251, 7.091611957645439, 6.278453883604579, 3.0615194001854955, 2.4950573625973322, 2.3418575824172674, 3.3582953559419897, 1.2698666905279126, 0.9965331555844703, 0.5943413006663675, 0.0, 8.391700616220398, 6.537754307330042, 4.982665777922351, 3.809600071583737, 6.716590711883979, 3.2786006153841742, 2.4950573625973322, 2.1867995715610684, 3.1392269418022893, 2.36387065254848, 1.3737785398794504, 0.5177272891587478, 0.0), # 152
(7.78359542019656, 5.642164754012652, 6.834673599778224, 7.049564482388949, 6.245097402868703, 3.049496270069676, 2.4746656466934596, 2.333700065196776, 3.3472164494766075, 1.2612373873374074, 0.9900970780594861, 0.5907159691183387, 0.0, 8.346173043724027, 6.497875660301725, 4.95048539029743, 3.783712162012222, 6.694432898953215, 3.2671800912754865, 2.4746656466934596, 2.17821162147834, 3.1225487014343516, 2.3498548274629836, 1.3669347199556448, 0.5129240685466048, 0.0), # 153
(7.723300024450729, 5.587859465766439, 6.7993598078506325, 7.006221885757057, 6.210822137077053, 3.0370225237780484, 2.453661835602614, 2.325134854707968, 3.3356965375046217, 1.2523248970473384, 0.9834440552434354, 0.5869750818206104, 0.0, 8.299363725465357, 6.456725900026714, 4.917220276217177, 3.7569746911420143, 6.671393075009243, 3.2551887965911552, 2.453661835602614, 2.169301802698606, 3.1054110685385266, 2.335407295252353, 1.3598719615701265, 0.5079872241605854, 0.0), # 154
(7.6614773285236355, 5.532028964954703, 6.762918480843396, 6.961544429795533, 6.175608003725131, 3.0240820590741087, 2.4320231935888805, 2.316142600866515, 3.323719186393376, 1.2431187550604388, 0.9765660041658056, 0.5831148079102902, 0.0, 8.251242367856026, 6.414262887013191, 4.882830020829028, 3.7293562651813157, 6.647438372786752, 3.242599641213121, 2.4320231935888805, 2.160058613624363, 3.0878040018625654, 2.320514809931845, 1.3525836961686795, 0.5029117240867913, 0.0), # 155
(7.598090966638081, 5.474617900524564, 6.725316775985439, 6.915492376550157, 6.139434920308432, 3.0106587737213526, 2.40972698491635, 2.3067039535880913, 3.3112679625102084, 1.2336084967794434, 0.9694548418560842, 0.5791313165244852, 0.0, 8.201778677307685, 6.370444481769337, 4.84727420928042, 3.7008254903383295, 6.622535925020417, 3.2293855350233276, 2.40972698491635, 2.150470552658109, 3.069717460154216, 2.3051641255167192, 1.3450633551970879, 0.49769253641132405, 0.0), # 156
(7.533104573016862, 5.415570921423138, 6.686521850505682, 6.868025988066703, 6.102282804322456, 2.9967365654832747, 2.3867504738491094, 2.2967995627883675, 3.2983264322224626, 1.2237836576070855, 0.9621024853437583, 0.5750207768003032, 0.0, 8.150942360231976, 6.325228544803333, 4.810512426718791, 3.671350972821256, 6.596652864444925, 3.2155193879037145, 2.3867504738491094, 2.140526118202339, 3.051141402161228, 2.2893419960222348, 1.3373043701011365, 0.4923246292202853, 0.0), # 157
(7.464680946405239, 5.353748694041236, 6.644659961585297, 6.817327186238432, 6.062454070580665, 2.9814309445183143, 2.3625533604639286, 2.285748730145572, 3.2838873638663655, 1.213341479072786, 0.9542659587564906, 0.570633297016195, 0.0, 8.096485859415345, 6.276966267178143, 4.771329793782452, 3.640024437218358, 6.567774727732731, 3.200048222203801, 2.3625533604639286, 2.129593531798796, 3.0312270352903323, 2.2724423954128112, 1.3289319923170593, 0.48670442673102154, 0.0), # 158
(7.382286766978402, 5.282809876299521, 6.58894818200249, 6.7529828690913405, 6.010127539854418, 2.95965229467081, 2.334106381692858, 2.2696723053184926, 3.2621424204073812, 1.2005702485246865, 0.9445694892698324, 0.5651135436402591, 0.0, 8.025427646920194, 6.216248980042849, 4.722847446349162, 3.601710745574059, 6.5242848408147625, 3.17754122744589, 2.334106381692858, 2.114037353336293, 3.005063769927209, 2.250994289697114, 1.3177896364004982, 0.4802554432999565, 0.0), # 159
(7.284872094904309, 5.202172001162321, 6.51826746496324, 6.673933132806645, 5.94428008756453, 2.9308657560278157, 2.301121874191892, 2.248166328969728, 3.2324750757428835, 1.1853014129657236, 0.9328765847682567, 0.5583751624073207, 0.0, 7.93642060889358, 6.142126786480525, 4.664382923841283, 3.55590423889717, 6.464950151485767, 3.147432860557619, 2.301121874191892, 2.0934755400198686, 2.972140043782265, 2.2246443776022153, 1.3036534929926482, 0.47292472737839286, 0.0), # 160
(7.17322205458596, 5.11236079574043, 6.4333724765919245, 6.5809293778175455, 5.865595416188075, 2.895420057582683, 2.263840723003438, 2.2215002221290754, 3.1952765889996724, 1.1676645482927346, 0.9192902757666179, 0.5504806224089643, 0.0, 7.830374044819097, 6.055286846498606, 4.596451378833089, 3.5029936448782033, 6.390553177999345, 3.1101003109807053, 2.263840723003438, 2.0681571839876307, 2.9327977080940375, 2.1936431259391824, 1.2866744953183848, 0.46476007234003913, 0.0), # 161
(7.048121770426357, 5.013901987144635, 6.335017883012913, 6.474723004557244, 5.7747572282021356, 2.853663928328766, 2.2225038131699044, 2.1899434058263343, 3.150938219304545, 1.147789230402558, 0.9039135927797701, 0.5414923927367745, 0.0, 7.708197254180333, 5.956416320104519, 4.519567963898851, 3.4433676912076736, 6.30187643860909, 3.065920768156868, 2.2225038131699044, 2.03833137737769, 2.8873786141010678, 2.158241001519082, 1.2670035766025827, 0.4558092715586033, 0.0), # 162
(6.9103563668284975, 4.90732130248573, 6.223958350350585, 6.35606541345895, 5.672449226083792, 2.8059460972594175, 2.1773520297337003, 2.153765301091302, 3.0998512257843016, 1.1258050351920315, 0.8868495663225682, 0.5314729424823361, 0.0, 7.570799536460879, 5.846202367305696, 4.43424783161284, 3.3774151055760937, 6.199702451568603, 3.015271421527823, 2.1773520297337003, 2.0042472123281554, 2.836224613041896, 2.118688471152984, 1.2447916700701172, 0.4461201184077937, 0.0), # 163
(6.760710968195384, 4.793144468874502, 6.100948544729314, 6.225708004955863, 5.559355112310126, 2.752615293367992, 2.128626257737233, 2.113235328953779, 3.0424068675657407, 1.1018415385579923, 0.8682012269098661, 0.5204847407372336, 0.0, 7.419090191144328, 5.725332148109569, 4.34100613454933, 3.305524615673976, 6.0848137351314815, 2.9585294605352903, 2.128626257737233, 1.9661537809771372, 2.779677556155063, 2.075236001651955, 1.2201897089458629, 0.43574040626131844, 0.0), # 164
(6.599970698930017, 4.671897213421746, 5.966743132273474, 6.084402179481189, 5.436158589358215, 2.694020245647842, 2.076567382222911, 2.068622910443561, 2.9789964037756596, 1.0760283163972786, 0.8480716050565187, 0.5085902565930517, 0.0, 7.25397851771427, 5.594492822523568, 4.2403580252825925, 3.2280849491918353, 5.957992807551319, 2.8960720746209856, 2.076567382222911, 1.9243001754627442, 2.7180792946791077, 2.0281340598270634, 1.1933486264546949, 0.42471792849288603, 0.0), # 165
(6.428920683435397, 4.54410526323825, 5.82209677910744, 5.932899337468126, 5.3035433597051425, 2.630509683092322, 2.021416288233143, 2.020197466590449, 2.9100110935408576, 1.0484949446067282, 0.8265637312773799, 0.49585195914137514, 0.0, 7.0763738156542955, 5.454371550555126, 4.1328186563869, 3.145484833820184, 5.820022187081715, 2.8282764532266285, 2.021416288233143, 1.8789354879230868, 2.6517716798525712, 1.9776331124893758, 1.1644193558214881, 0.41310047847620457, 0.0), # 166
(6.248346046114523, 4.410294345434805, 5.667764151355587, 5.771950879349882, 5.1621931258279865, 2.562432334694784, 1.9634138608103373, 1.9682284184242402, 2.835842195988133, 1.0193709990831787, 0.8037806360873045, 0.48233231747378824, 0.0, 6.887185384447996, 5.30565549221167, 4.0189031804365225, 3.058112997249536, 5.671684391976266, 2.755519785793936, 1.9634138608103373, 1.8303088104962744, 2.5810965629139933, 1.9239836264499612, 1.1335528302711175, 0.4009358495849823, 0.0), # 167
(6.059031911370395, 4.270990187122201, 5.50449991514229, 5.60230820555966, 5.012791590203827, 2.490136929448583, 1.902800984996902, 1.9129851869747332, 2.7568809702442847, 0.9887860557234682, 0.7798253500011468, 0.468093800681876, 0.0, 6.6873225235789615, 5.149031807500635, 3.8991267500057343, 2.9663581671704042, 5.513761940488569, 2.6781792617646265, 1.902800984996902, 1.7786692353204163, 2.5063957951019136, 1.867436068519887, 1.100899983028458, 0.3882718351929274, 0.0), # 168
(5.861763403606015, 4.1267185154112305, 5.333058736591924, 5.4247227165306615, 4.856022455309747, 2.413972196347072, 1.8398185458352458, 1.8547371932717271, 2.6735186754361124, 0.9568696904244344, 0.7548009035337614, 0.45319887785722274, 0.0, 6.477694532530785, 4.985187656429449, 3.774004517668807, 2.8706090712733023, 5.347037350872225, 2.596632070580418, 1.8398185458352458, 1.724265854533623, 2.4280112276548733, 1.808240905510221, 1.066611747318385, 0.3751562286737483, 0.0), # 169
(5.657325647224384, 3.978005057412684, 5.154195281828863, 5.23994581269609, 4.692569423622822, 2.334286864383604, 1.7747074283677764, 1.7937538583450197, 2.5861465706904125, 0.9237514790829147, 0.7288103272000027, 0.4377100180914133, 0.0, 6.259210710787055, 4.814810199005545, 3.6440516360000137, 2.7712544372487433, 5.172293141380825, 2.5112554016830275, 1.7747074283677764, 1.6673477602740028, 2.346284711811411, 1.7466486042320304, 1.0308390563657726, 0.36163682340115316, 0.0), # 170
(5.4465037666285, 3.82537554023735, 4.968664216977482, 5.048728894489152, 4.523116197620137, 2.2514296625515327, 1.7077085176369027, 1.7303046032244096, 2.495155915133985, 0.8895609975957474, 0.7019566515147247, 0.4216896904760322, 0.0, 6.032780357831365, 4.638586595236354, 3.509783257573624, 2.6686829927872413, 4.99031183026797, 2.4224264445141737, 1.7077085176369027, 1.6081640446796661, 2.2615580988100685, 1.6829096314963843, 0.9937328433954964, 0.3477614127488501, 0.0), # 171
(5.230082886221365, 3.6693556909960217, 4.777220208162156, 4.851823362343048, 4.348346479778769, 2.1657493198442115, 1.6390626986850327, 1.664658848939696, 2.4009379678936282, 0.8544278218597702, 0.6743429069927823, 0.4052003641026643, 0.0, 5.799312773147303, 4.457204005129307, 3.3717145349639117, 2.56328346557931, 4.8018759357872565, 2.3305223885155746, 1.6390626986850327, 1.5469637998887225, 2.1741732398893845, 1.6172744541143496, 0.9554440416324312, 0.3335777900905475, 0.0), # 172
(5.00884813040598, 3.510471236799489, 4.58061792150726, 4.649980616690982, 4.168943972575801, 2.077594565254994, 1.5690108565545748, 1.5970860165206766, 2.303883988096141, 0.8184815277718206, 0.6460721241490297, 0.3883045080628938, 0.0, 5.5597172562184625, 4.271349588691831, 3.2303606207451483, 2.4554445833154612, 4.607767976192282, 2.235920423128947, 1.5690108565545748, 1.483996118039281, 2.0844719862879004, 1.5499935388969943, 0.916123584301452, 0.31913374879995354, 0.0), # 173
(4.783584623585344, 3.349247904758541, 4.3796120231371685, 4.443952057966156, 3.9855923784883105, 1.987314127777233, 1.4977938762879377, 1.5278555269971503, 2.204385234868321, 0.7818516912287369, 0.6172473334983214, 0.37106459144830567, 0.0, 5.314903106528433, 4.081710505931362, 3.0862366674916064, 2.34555507368621, 4.408770469736642, 2.1389977377960103, 1.4977938762879377, 1.4195100912694523, 1.9927961892441552, 1.4813173526553853, 0.8759224046274336, 0.3044770822507765, 0.0), # 174
(4.555077490162455, 3.18621142198397, 4.174957179176257, 4.2344890866017755, 3.7989753999933793, 1.8952567364042834, 1.425652642927529, 1.457236801398915, 2.102832967336968, 0.7446678881273562, 0.5879715655555117, 0.35354308335048457, 0.0, 5.0657796235608075, 3.8889739168553294, 2.939857827777558, 2.234003664382068, 4.205665934673936, 2.040131521958481, 1.425652642927529, 1.3537548117173452, 1.8994876999966896, 1.411496362200592, 0.8349914358352515, 0.28965558381672457, 0.0), # 175
(4.324111854540319, 3.0218875155865668, 3.9674080557488987, 4.0223431030310435, 3.609776739568087, 1.8017711201294973, 1.3528280415157574, 1.3854992607557703, 1.9996184446288805, 0.7070596943645169, 0.558347850835455, 0.33580245286101496, 0.0, 4.813256106799174, 3.693826981471164, 2.791739254177275, 2.1211790830935504, 3.999236889257761, 1.9396989650580787, 1.3528280415157574, 1.2869793715210696, 1.8048883697840434, 1.3407810343436815, 0.7934816111497798, 0.2747170468715061, 0.0), # 176
(4.0914728411219325, 2.856801912677122, 3.7577193189794698, 3.808265507687162, 3.4186800996895155, 1.7072060079462288, 1.2795609570950313, 1.3129123260975137, 1.8951329258708567, 0.6691566858370562, 0.528479219853006, 0.3179051690714816, 0.0, 4.5582418557271245, 3.496956859786297, 2.6423960992650297, 2.0074700575111684, 3.7902658517417134, 1.838077256536519, 1.2795609570950313, 1.2194328628187348, 1.7093400498447577, 1.269421835895721, 0.751543863795894, 0.25970926478882933, 0.0), # 177
(3.8579455743102966, 2.6914803403664256, 3.5466456349923448, 3.593007701003337, 3.226369182834742, 1.6119101288478317, 1.2060922747077587, 1.239745418453944, 1.7897676701896952, 0.6310884384418126, 0.49846870312301883, 0.299913701073469, 0.0, 4.301646169828252, 3.299050711808158, 2.4923435156150937, 1.8932653153254375, 3.5795353403793904, 1.7356435858355217, 1.2060922747077587, 1.1513643777484512, 1.613184591417371, 1.1976692336677792, 0.7093291269984691, 0.24468003094240237, 0.0), # 178
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 179
)
passenger_allighting_rate = (
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 0
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 1
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 2
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 3
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 4
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 5
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 6
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 7
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 8
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 9
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 10
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 11
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 12
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 13
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 14
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 15
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 16
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 17
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 18
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 19
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 20
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 21
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 22
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 23
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 24
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 25
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 26
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 27
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 28
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 29
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 30
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 31
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 32
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 33
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 34
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 35
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 36
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 37
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 38
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 39
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 40
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 41
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 42
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 43
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 44
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 45
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 46
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 47
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 48
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 49
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 50
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 51
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 52
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 53
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 54
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 55
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 56
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 57
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 58
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 59
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 60
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 61
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 62
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 63
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 64
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 65
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 66
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 67
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 68
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 69
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 70
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 71
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 72
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 73
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 74
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 75
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 76
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 77
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 78
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 79
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 80
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 81
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 82
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 83
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 84
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 85
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 86
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 87
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 88
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 89
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 90
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 91
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 92
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 93
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 94
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 95
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 96
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 97
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 98
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 99
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 100
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 101
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 102
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 103
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 104
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 105
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 106
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 107
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 108
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 109
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 110
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 111
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 112
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 113
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 114
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 115
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 116
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 117
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 118
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 119
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 120
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 121
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 122
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 123
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 124
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 125
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 126
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 127
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 128
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 129
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 130
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 131
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 132
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 133
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 134
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 135
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 136
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 137
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 138
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 139
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 140
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 141
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 142
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 143
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 144
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 145
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 146
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 147
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 148
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 149
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 150
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 151
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 152
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 153
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 154
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 155
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 156
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 157
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 158
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 159
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 160
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 161
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 162
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 163
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 164
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 165
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 166
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 167
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 168
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 169
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 170
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 171
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 172
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 173
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 174
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 175
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 176
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 177
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 178
(0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 179
)
"""
parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html
"""
#initial entropy
entropy = 8991598675325360468762009371570610170
#index for seed sequence child
child_seed_index = (
1, # 0
32, # 1
)
| 276.305882
| 494
| 0.769596
| 32,987
| 258,346
| 6.02695
| 0.217025
| 0.358531
| 0.344045
| 0.651875
| 0.375985
| 0.36753
| 0.364416
| 0.363994
| 0.363994
| 0.363994
| 0
| 0.849836
| 0.09574
| 258,346
| 934
| 495
| 276.601713
| 0.001194
| 0.015526
| 0
| 0.200873
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.005459
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 6
|
366a9ee730f7436b1948c3ca79a02b479f9aa5ee
| 19
|
py
|
Python
|
modules/unit_tests/core/formats/__init__.py
|
nursix/DRKCM
|
09328289ff721c416494398aa751ff99906327cb
|
[
"MIT"
] | 3
|
2022-01-26T08:07:54.000Z
|
2022-03-21T21:53:52.000Z
|
modules/unit_tests/core/formats/__init__.py
|
nursix/eden-asp
|
e49f46cb6488918f8d5a163dcd5a900cd686978c
|
[
"MIT"
] | null | null | null |
modules/unit_tests/core/formats/__init__.py
|
nursix/eden-asp
|
e49f46cb6488918f8d5a163dcd5a900cd686978c
|
[
"MIT"
] | 4
|
2018-07-09T12:56:09.000Z
|
2019-10-21T21:00:42.000Z
|
from .xml import *
| 9.5
| 18
| 0.684211
| 3
| 19
| 4.333333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.210526
| 19
| 1
| 19
| 19
| 0.866667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
366c335defd508c15d9e2b0da8d9a3838242bec5
| 25
|
py
|
Python
|
PC2/71755174-JorgeZuluaga/__init__.py
|
carloseorozco/PythonChallenges
|
78fd49e2acdf97e8e60b95b1009e3fdd2ada37ce
|
[
"MIT"
] | 2
|
2021-06-03T15:52:03.000Z
|
2021-06-07T15:52:10.000Z
|
PC2/71755174-JorgeZuluaga/__init__.py
|
carloseorozco/PythonChallenges
|
78fd49e2acdf97e8e60b95b1009e3fdd2ada37ce
|
[
"MIT"
] | null | null | null |
PC2/71755174-JorgeZuluaga/__init__.py
|
carloseorozco/PythonChallenges
|
78fd49e2acdf97e8e60b95b1009e3fdd2ada37ce
|
[
"MIT"
] | 3
|
2021-06-04T13:16:08.000Z
|
2021-06-10T19:22:32.000Z
|
import math
import numpy
| 8.333333
| 12
| 0.84
| 4
| 25
| 5.25
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16
| 25
| 2
| 13
| 12.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 6
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.