hexsha
stringlengths
40
40
size
int64
1
1.03M
ext
stringclasses
10 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
239
max_stars_repo_name
stringlengths
5
130
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
sequencelengths
1
10
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
239
max_issues_repo_name
stringlengths
5
130
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
sequencelengths
1
10
max_issues_count
int64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
239
max_forks_repo_name
stringlengths
5
130
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
sequencelengths
1
10
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
1
1.03M
avg_line_length
float64
1
958k
max_line_length
int64
1
1.03M
alphanum_fraction
float64
0
1
4a2410a6907ec667eed452981eab3e772b943241
2,478
py
Python
src/lsi.py
lzakharov/lsi
227cdffc2b1d4187cc7e0e439b6e08fa4e76f01d
[ "MIT" ]
9
2018-10-10T20:17:03.000Z
2022-01-24T07:41:47.000Z
src/lsi.py
lzakharov/lsi
227cdffc2b1d4187cc7e0e439b6e08fa4e76f01d
[ "MIT" ]
null
null
null
src/lsi.py
lzakharov/lsi
227cdffc2b1d4187cc7e0e439b6e08fa4e76f01d
[ "MIT" ]
5
2019-09-19T18:37:59.000Z
2022-01-24T07:41:54.000Z
import string from typing import List, Type, Tuple, Union import numpy as np from .models import TermCountModel, AbstractModel class LSI: """Latent Semantic Indexing. """ def __init__(self, docs: List[str], query: str, model: Type[AbstractModel] = TermCountModel, rank_approximation: int = 2, stopwords: List[str] = None, ignore_chars=string.punctuation) -> None: if stopwords is None: stopwords = [] self.stopwords = stopwords self.ignore_chars = ignore_chars self.docs = list(map(self._parse, docs)) self.words = self._get_words() self.query = self._parse_query(query) self.model = model self.rank_approximation = rank_approximation self.term_doc_matrix = self._build_term_doc_matrix() def _parse(self, text: str) -> List[str]: translator = str.maketrans(self.ignore_chars, ' ' * len(self.ignore_chars)) return list(map(str.lower, filter(lambda w: w not in self.stopwords, text.translate(translator).split()))) def _parse_query(self, query: str) -> np.ndarray: result = np.zeros(len(self.words)) i = 0 for word in sorted(self._parse(query)): while word > self.words[i]: i += 1 if word == self.words[i]: result[i] += 1 return result def _get_words(self) -> List[str]: words = set() for doc in self.docs: words = words | set(doc) return sorted(words) def _build_term_doc_matrix(self) -> np.ndarray: model = self.model(self.words, self.docs) return model.build() def _svd_with_dimensionality_reduction(self) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: u, s, v = np.linalg.svd(self.term_doc_matrix) s = np.diag(s) k = self.rank_approximation return u[:, :k], s[:k, :k], v[:, :k] def process(self) -> np.ndarray: u_k, s_k, v_k = self._svd_with_dimensionality_reduction() q = self.query.T @ u_k @ np.linalg.pinv(s_k) d = self.term_doc_matrix.T @ u_k @ np.linalg.pinv(s_k) res = np.apply_along_axis(lambda row: self._sim(q, row), axis=1, arr=d) ranking = np.argsort(-res) + 1 return ranking @staticmethod def _sim(x: np.ndarray, y: np.ndarray): return (x @ y) / (np.linalg.norm(x) * np.linalg.norm(y))
32.605263
96
0.589992
4a24110cab388c12c8d47cf7dd42770baf915f1c
384
py
Python
TRANSFORM/Resources/Scripts/jModelica/Units/Conversions/Functions/Distance_m/Examples/check_cm.py
greenwoodms/TRANSFORM-Library
dc152d4f0298d3f18385f2ea33645d87d7812915
[ "Apache-2.0" ]
29
2018-04-24T17:06:19.000Z
2021-11-21T05:17:28.000Z
TRANSFORM/Resources/Scripts/jModelica/Units/Conversions/Functions/Distance_m/Examples/check_cm.py
greenwoodms/TRANSFORM-Library
dc152d4f0298d3f18385f2ea33645d87d7812915
[ "Apache-2.0" ]
13
2018-04-05T08:34:27.000Z
2021-10-04T14:24:41.000Z
TRANSFORM/Resources/Scripts/jModelica/Units/Conversions/Functions/Distance_m/Examples/check_cm.py
greenwoodms/TRANSFORM-Library
dc152d4f0298d3f18385f2ea33645d87d7812915
[ "Apache-2.0" ]
17
2018-08-06T22:18:01.000Z
2022-01-29T21:38:17.000Z
from pymodelica import compile_fmu from pyfmi import load_fmu libPath = r'C:\Users\vmg\Documents\Modelica\TRANSFORM-Library/TRANSFORM' modelName = 'TRANSFORM.Units.Conversions.Functions.Distance_m.Examples.check_cm' fmu = compile_fmu(modelName,libPath,target='cs') model = load_fmu(fmu) opts = model.simulate_options() opts['time_limit'] = 60 results=model.simulate(options=opts)
27.428571
80
0.802083
4a241165a17f63178ca79f5adba1ef7b37d3dba0
9,683
py
Python
apps/beeswax/src/beeswax/conf.py
landier/hue
5d8d2fb238772a26c28b17b0c0e559da8c27a419
[ "Apache-2.0" ]
null
null
null
apps/beeswax/src/beeswax/conf.py
landier/hue
5d8d2fb238772a26c28b17b0c0e559da8c27a419
[ "Apache-2.0" ]
null
null
null
apps/beeswax/src/beeswax/conf.py
landier/hue
5d8d2fb238772a26c28b17b0c0e559da8c27a419
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env python # Licensed to Cloudera, Inc. under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. Cloudera, Inc. licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import division from builtins import str from past.utils import old_div import logging import os.path from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.conf import default_ssl_cacerts, default_ssl_validate, AUTH_PASSWORD as DEFAULT_AUTH_PASSWORD,\ AUTH_USERNAME as DEFAULT_AUTH_USERNAME from desktop.lib.conf import ConfigSection, Config, coerce_bool, coerce_csv, coerce_password_from_script LOG = logging.getLogger(__name__) HIVE_DISCOVERY_LLAP = Config( key="hive_discovery_llap", help=_t("Have Hue determine Hive Server Interactive endpoint from zookeeper"), default="false", type=coerce_bool ) HIVE_DISCOVERY_HS2 = Config( key="hive_discovery_hs2", help=_t("Determines whether we pull a random HiveServer2 from the list in zookeeper. This HS2 instance is cached until hue is restarted."), default="false", type=coerce_bool ) HIVE_DISCOVERY_LLAP_HA = Config( key="hive_discovery_llap_ha", help=_t("If you have more than one HSI server, it has a different znode setup. This will trigger the code to check for the Active HSI Server"), default="false", type=coerce_bool ) HIVE_DISCOVERY_LLAP_ZNODE = Config( key="hive_discovery_llap_znode", help=_t("If LLAP is enabled, you should be using zookeeper service discovery mode, this is the znode of the LLAP Master(s)"), default="/hiveserver2-hive2" ) HIVE_DISCOVERY_HIVESERVER2_ZNODE = Config( key="hive_discovery_hiveserver2_znode", help=_t("If Hive is using zookeeper service discovery mode, this is the znode of the hiveserver2(s)"), default="/hiveserver2" ) CACHE_TIMEOUT = Config( key="cache_timeout", help=_t("How long to pause before reaching back out to zookeeper to get the current Active HSI endpoint"), default=60, type=int ) LLAP_SERVER_PORT = Config( key="llap_server_port", help=_t("Configure the base port the Hive Server Interactive runs on (10500 default)."), default=10500, type=int ) LLAP_SERVER_THRIFT_PORT = Config( key="llap_server_thrift_port", help=_t("Configure the thrift port the Hive Server Interactive runs on (10501 default)"), default=10501, type=int ) LLAP_SERVER_HOST = Config( key="llap_server_host", help=_t("Host where Hive Server Interactive is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost" ) HIVE_SERVER_HOST = Config( key="hive_server_host", help=_t("Host where HiveServer2 server is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost") HIVE_SERVER_PORT = Config( key="hive_server_port", help=_t("Configure the port the HiveServer2 server runs on."), default=10000, type=int) HIVE_METASTORE_HOST = Config( key="hive_metastore_host", help=_t("Host where Hive Metastore Server (HMS) is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost") HIVE_METASTORE_PORT = Config( key="hive_metastore_port", help=_t("Configure the port the Hive Metastore Server runs on."), default=9083, type=int) HIVE_CONF_DIR = Config( key='hive_conf_dir', help=_t('Hive configuration directory, where hive-site.xml is located.'), default=os.environ.get("HIVE_CONF_DIR", '/etc/hive/conf')) HIVE_SERVER_BIN = Config( key="hive_server_bin", help=_t("Path to HiveServer2 start script"), default='/usr/lib/hive/bin/hiveserver2', private=True) LOCAL_EXAMPLES_DATA_DIR = Config( key='local_examples_data_dir', default=os.path.join(os.path.dirname(__file__), "..", "..", "data"), help=_t('The local filesystem path containing the Hive examples.')) SERVER_CONN_TIMEOUT = Config( key='server_conn_timeout', default=120, type=int, help=_t('Timeout in seconds for Thrift calls.')) USE_GET_LOG_API = Config( # To remove in Hue 4 key='use_get_log_api', default=False, type=coerce_bool, help=_t('Choose whether to use the old GetLog() thrift call from before Hive 0.14 to retrieve the logs.' 'If false, use the FetchResults() thrift call from Hive 1.0 or more instead.') ) BROWSE_PARTITIONED_TABLE_LIMIT = Config( # Deprecated, to remove in Hue 4 key='browse_partitioned_table_limit', default=1000, type=int, help=_t('Limit the number of partitions to list on the partitions page. A positive value will be set as the LIMIT. If 0 or negative, do not set any limit.')) QUERY_PARTITIONS_LIMIT = Config( key='query_partitions_limit', default=10, type=int, help=_t('The maximum number of partitions that will be included in the SELECT * LIMIT sample query for partitioned tables.')) def get_browse_partitioned_table_limit(): """Get the old default""" return BROWSE_PARTITIONED_TABLE_LIMIT.get() LIST_PARTITIONS_LIMIT = Config( key='list_partitions_limit', dynamic_default=get_browse_partitioned_table_limit, type=int, help=_t('Limit the number of partitions that can be listed. A positive value will be set as the LIMIT.')) # Deprecated DOWNLOAD_CELL_LIMIT = Config( key='download_cell_limit', default=10000000, type=int, help=_t('A limit to the number of cells (rows * columns) that can be downloaded from a query ' '(e.g. - 10K rows * 1K columns = 10M cells.) ' 'A value of -1 means there will be no limit.')) def get_deprecated_download_cell_limit(): """Get the old default""" return old_div(DOWNLOAD_CELL_LIMIT.get(), 100) if DOWNLOAD_CELL_LIMIT.get() > 0 else DOWNLOAD_CELL_LIMIT.get() DOWNLOAD_ROW_LIMIT = Config( key='download_row_limit', dynamic_default=get_deprecated_download_cell_limit, type=int, help=_t('A limit to the number of rows that can be downloaded from a query before it is truncated. ' 'A value of -1 means there will be no limit.')) DOWNLOAD_BYTES_LIMIT = Config( key='download_bytes_limit', default=-1, type=int, help=_t('A limit to the number of bytes that can be downloaded from a query before it is truncated. ' 'A value of -1 means there will be no limit.')) APPLY_NATURAL_SORT_MAX = Config( key="apply_natural_sort_max", help=_t("The max number of records in the result set permitted to apply a natural sort to the database or tables list."), type=int, default=2000 ) CLOSE_QUERIES = Config( key="close_queries", help=_t("Hue will try to close the Hive query when the user leaves the editor page. " "This will free all the query resources in HiveServer2, but also make its results inaccessible."), type=coerce_bool, default=False ) MAX_NUMBER_OF_SESSIONS = Config( key="max_number_of_sessions", help=_t("Hue will use at most this many HiveServer2 sessions per user at a time"), type=int, default=1 ) THRIFT_VERSION = Config( key="thrift_version", help=_t("Thrift version to use when communicating with HiveServer2."), type=int, default=7 ) CONFIG_WHITELIST = Config( key='config_whitelist', default='hive.map.aggr,hive.exec.compress.output,hive.exec.parallel,hive.execution.engine,mapreduce.job.queuename', type=coerce_csv, help=_t('A comma-separated list of white-listed Hive configuration properties that users are authorized to set.') ) SSL = ConfigSection( key='ssl', help=_t('SSL configuration for the server.'), members=dict( CACERTS = Config( key="cacerts", help=_t("Path to Certificate Authority certificates."), type=str, dynamic_default=default_ssl_cacerts, ), KEY = Config( key="key", help=_t("Path to the private key file, e.g. /etc/hue/key.pem"), type=str, default=None ), CERT = Config( key="cert", help=_t("Path to the public certificate file, e.g. /etc/hue/cert.pem"), type=str, default=None ), VALIDATE = Config( key="validate", help=_t("Choose whether Hue should validate certificates received from the server."), type=coerce_bool, dynamic_default=default_ssl_validate, ) ) ) def get_auth_username(): """Get from top level default from desktop""" return DEFAULT_AUTH_USERNAME.get() AUTH_USERNAME = Config( key="auth_username", help=_t("Auth username of the hue user used for authentications."), dynamic_default=get_auth_username) def get_auth_password(): """Get from script or backward compatibility""" password = AUTH_PASSWORD_SCRIPT.get() if password: return password return DEFAULT_AUTH_PASSWORD.get() AUTH_PASSWORD = Config( key="auth_password", help=_t("LDAP/PAM/.. password of the hue user used for authentications."), private=True, dynamic_default=get_auth_password) AUTH_PASSWORD_SCRIPT = Config( key="auth_password_script", help=_t("Execute this script to produce the auth password. This will be used when `auth_password` is not set."), private=True, type=coerce_password_from_script, default=None)
32.712838
159
0.737891
4a2411b523f7130c7f471c509bab5841e8151e3c
1,850
py
Python
det3d/models/detectors/voxelnet.py
reinforcementdriving/CIA-SSD
f7b4a9ed4a2b852845303efc6c972125438817a6
[ "Apache-2.0" ]
382
2020-12-05T06:46:28.000Z
2022-03-29T17:40:58.000Z
det3d/models/detectors/voxelnet.py
reinforcementdriving/CIA-SSD
f7b4a9ed4a2b852845303efc6c972125438817a6
[ "Apache-2.0" ]
28
2020-12-08T07:50:57.000Z
2022-03-20T03:54:43.000Z
det3d/models/detectors/voxelnet.py
reinforcementdriving/CIA-SSD
f7b4a9ed4a2b852845303efc6c972125438817a6
[ "Apache-2.0" ]
57
2020-12-10T02:19:03.000Z
2022-03-19T09:49:38.000Z
from ..registry import DETECTORS from .single_stage import SingleStageDetector @DETECTORS.register_module class VoxelNet(SingleStageDetector): def __init__(self, reader, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None,): super(VoxelNet, self).__init__(reader, backbone, neck, bbox_head, train_cfg, test_cfg, pretrained) def extract_feat(self, data): input_features = self.reader(data["voxels"], data["num_points_per_voxel"]) # [69276, 5, 4], [69276] -> [69276, 4] x = self.backbone(input_features, data["coors"], data["batch_size"], data["input_shape"]) if self.with_neck: x = self.neck(x) return x def forward(self, example, return_loss=True, **kwargs): # todo: how the data change into torch datatype voxels = example["voxels"] # [69276, 5(points per voxel), 4(features per point)] coordinates = example["coordinates"] # [69276, 4] num_points_per_voxel = example["num_points"] # [69276], record num_points (non-zeros) in each voxel num_voxels = example["num_voxels"] # [18278, 18536, 16687, 15775] batch_size = len(num_voxels) # 4 input_shape = example["shape"][0] # [1408, 1600, 40] data = dict(voxels=voxels, num_points_per_voxel=num_points_per_voxel, coors=coordinates, batch_size=batch_size, input_shape=input_shape,) x = self.extract_feat(data) preds = self.bbox_head(x) # for debug, self.bbox_head.predict(example, preds, self.test_cfg) if return_loss: return self.bbox_head.loss(example, preds) else: return self.bbox_head.predict(example, preds, self.test_cfg)
45.121951
123
0.618378
4a2411fbc32cbeb1ebb91ede59b2290e07f9893b
214
py
Python
src/blib/__init__.py
Niklas-Seppala/blib
4364761ae5ce1cbb79ea6b800365a701b670bcd7
[ "MIT" ]
null
null
null
src/blib/__init__.py
Niklas-Seppala/blib
4364761ae5ce1cbb79ea6b800365a701b670bcd7
[ "MIT" ]
null
null
null
src/blib/__init__.py
Niklas-Seppala/blib
4364761ae5ce1cbb79ea6b800365a701b670bcd7
[ "MIT" ]
null
null
null
from .banner import Banner from .utils import Files from .index import index def blib_init(out='', src=''): if out: Files.set_out_path(out) if src: Files.set_in_path(src) index.load()
17.833333
31
0.64486
4a24120be95592f979c0339ed2e35251ee905347
2,520
py
Python
homeassistant/components/homematicip_cloud/__init__.py
TheDatNik/home-assistant
12b451adf5e5e894cb0707b61535218260411189
[ "Apache-2.0" ]
2
2019-02-04T15:05:30.000Z
2019-03-04T16:31:32.000Z
homeassistant/components/homematicip_cloud/__init__.py
TheDatNik/home-assistant
12b451adf5e5e894cb0707b61535218260411189
[ "Apache-2.0" ]
2
2022-01-13T04:00:03.000Z
2022-03-12T01:02:40.000Z
homeassistant/components/homematicip_cloud/__init__.py
TheDatNik/home-assistant
12b451adf5e5e894cb0707b61535218260411189
[ "Apache-2.0" ]
3
2016-08-26T12:32:49.000Z
2020-02-26T21:01:35.000Z
"""Support for HomematicIP Cloud devices.""" import logging import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_NAME from homeassistant.helpers import device_registry as dr import homeassistant.helpers.config_validation as cv from .config_flow import configured_haps from .const import ( CONF_ACCESSPOINT, CONF_AUTHTOKEN, DOMAIN, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME) from .device import HomematicipGenericDevice # noqa: F401 from .hap import HomematicipAuth, HomematicipHAP # noqa: F401 _LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema({ vol.Optional(DOMAIN, default=[]): vol.All(cv.ensure_list, [vol.Schema({ vol.Optional(CONF_NAME, default=''): vol.Any(cv.string), vol.Required(CONF_ACCESSPOINT): cv.string, vol.Required(CONF_AUTHTOKEN): cv.string, })]), }, extra=vol.ALLOW_EXTRA) async def async_setup(hass, config): """Set up the HomematicIP Cloud component.""" hass.data[DOMAIN] = {} accesspoints = config.get(DOMAIN, []) for conf in accesspoints: if conf[CONF_ACCESSPOINT] not in configured_haps(hass): hass.async_add_job(hass.config_entries.flow.async_init( DOMAIN, context={'source': config_entries.SOURCE_IMPORT}, data={ HMIPC_HAPID: conf[CONF_ACCESSPOINT], HMIPC_AUTHTOKEN: conf[CONF_AUTHTOKEN], HMIPC_NAME: conf[CONF_NAME], } )) return True async def async_setup_entry(hass, entry): """Set up an access point from a config entry.""" hap = HomematicipHAP(hass, entry) hapid = entry.data[HMIPC_HAPID].replace('-', '').upper() hass.data[DOMAIN][hapid] = hap if not await hap.async_setup(): return False # Register hap as device in registry. device_registry = await dr.async_get_registry(hass) home = hap.home # Add the HAP name from configuration if set. hapname = home.label \ if not home.name else "{} {}".format(home.label, home.name) device_registry.async_get_or_create( config_entry_id=home.id, identifiers={(DOMAIN, home.id)}, manufacturer='eQ-3', name=hapname, model=home.modelType, sw_version=home.currentAPVersion, ) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hap = hass.data[DOMAIN].pop(entry.data[HMIPC_HAPID]) return await hap.async_reset()
31.898734
75
0.674603
4a2412b6139195a714a1e6ea98557e835a9b3425
200
py
Python
Pacote Dawload/Projeto progamas Python/ex1113 Crescente e Decrescente For.py
wagnersistemalima/Exercicios-Python-URI-Online-Judge-Problems---Contests
d839a344b899c08f4199ff1ae22dd6ee931df6a2
[ "MIT" ]
1
2020-12-11T23:22:20.000Z
2020-12-11T23:22:20.000Z
Pacote Dawload/Projeto progamas Python/ex1113 Crescente e Decrescente For.py
wagnersistemalima/Exercicios-Python-URI-Online-Judge-Problems---Contests
d839a344b899c08f4199ff1ae22dd6ee931df6a2
[ "MIT" ]
null
null
null
Pacote Dawload/Projeto progamas Python/ex1113 Crescente e Decrescente For.py
wagnersistemalima/Exercicios-Python-URI-Online-Judge-Problems---Contests
d839a344b899c08f4199ff1ae22dd6ee931df6a2
[ "MIT" ]
null
null
null
# ex1113 Crescente e Decrescente For while True: x, y = map(int, input().split()) if x > y: print('Decrescente') elif x < y: print('Crescente') if x == y: break
22.222222
36
0.53
4a241364e55f8675908cfb2e3eda5c97a8be4673
7,430
py
Python
lingvo/core/early_stop_test.py
allenwang28/lingvo
26d3d6672d3f46d8f281c2aa9f57166ef6296738
[ "Apache-2.0" ]
2,611
2018-10-16T20:14:10.000Z
2022-03-31T14:48:41.000Z
lingvo/core/early_stop_test.py
allenwang28/lingvo
26d3d6672d3f46d8f281c2aa9f57166ef6296738
[ "Apache-2.0" ]
249
2018-10-27T06:02:29.000Z
2022-03-30T18:00:39.000Z
lingvo/core/early_stop_test.py
allenwang28/lingvo
26d3d6672d3f46d8f281c2aa9f57166ef6296738
[ "Apache-2.0" ]
436
2018-10-25T05:31:45.000Z
2022-03-31T07:26:03.000Z
# Lint as: python3 # Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for early_stop.""" import os import lingvo.compat as tf from lingvo.core import early_stop from lingvo.core import hyperparams from lingvo.core import test_helper from lingvo.core import test_utils class MetricHistoryTest(test_utils.TestCase): def setUp(self): super().setUp() early_stop.MetricHistory._metric_histories_map = {} def testSetLogdirInMetricHistories(self): p = hyperparams.Params() p.Define('name', 'testparams', 'test params') p.Define('logdir', None, 'dummy logdir') p.Define('mh1', early_stop.MetricHistory.Params(), 'history1') p2 = hyperparams.Params() p2.Define('mh2', early_stop.MetricHistory.Params(), 'history2') p.Define('subparams', p2, 'subparams') early_stop.MetricHistory.SetLogdirInMetricHistories(p, 'dir') self.assertEqual(p.mh1.logdir, 'dir') self.assertEqual(p.subparams.mh2.logdir, 'dir') self.assertNotEqual(p.logdir, 'dir') def testMetricHistoriesMapUniqueness(self): # pylint: disable=unused-variable p = early_stop.MetricHistory.Params() mh1 = early_stop.MetricHistory(p.Set(jobname='job1', metric='m1')) mh2 = early_stop.MetricHistory(p.Set(jobname='job2', metric='m2')) mh3 = early_stop.MetricHistory(p.Set(jobname='job1', metric='m1')) m = early_stop.MetricHistory._metric_histories_map self.assertEqual(len(m), 2) self.assertEqual(m[early_stop.MetricHistory._Key('job1', 'm1')], mh3) self.assertEqual(m[early_stop.MetricHistory._Key('job2', 'm2')], mh2) def testMetricHistoriesFiles(self): logdir = tf.test.get_temp_dir() tf.io.gfile.mkdir(os.path.join(logdir, 'job1')) tf.io.gfile.mkdir(os.path.join(logdir, 'job2')) p = early_stop.MetricHistory.Params().Set(logdir=logdir) mh1 = early_stop.MetricHistory( p.Set(jobname='job1', metric='m1', local_filesystem=True)) mh2 = early_stop.MetricHistory( p.Set(jobname='job2', metric='m2', local_filesystem=True)) early_stop.MetricHistory.ConditionalAppend('job1', 'm1', 1, 10.0) early_stop.MetricHistory.ConditionalAppend('job1', 'm2', 1, 10.0) early_stop.MetricHistory.ConditionalAppend('job2', 'm2', 1, 10.0) early_stop.MetricHistory.ConditionalAppend('job1', 'm1', 2, 5.0) self.assertTrue(tf.io.gfile.exists(mh1.hist_file)) self.assertTrue(tf.io.gfile.exists(mh2.hist_file)) with tf.io.gfile.GFile(mh1.hist_file) as f: lines = f.readlines() self.assertEqual(len(lines), 2) self.assertEqual(lines[0].rstrip(), '1 10.000000') self.assertEqual(lines[1].rstrip(), '2 5.000000') with tf.io.gfile.GFile(mh2.hist_file) as f: lines = f.readlines() self.assertEqual(len(lines), 1) self.assertEqual(lines[0].rstrip(), '1 10.000000') class EarlyStopTest(test_utils.TestCase): def setUp(self): super().setUp() early_stop.MetricHistory._metric_histories_map = {} def testEarlyStopDefaultIsNoOp(self): p = early_stop.EarlyStop.Params() es = p.Instantiate() mh = early_stop.MetricHistory a = mh.ConditionalAppend(es.params.metric_history.jobname, es.params.metric_history.metric, 1, 10.0) s = es.Stop(None) self.assertFalse(a) self.assertFalse(s) self.assertIsNone(es._node) self.assertEqual(len(early_stop.MetricHistory._metric_histories_map), 0) def testEarlyStopping(self): logdir = tf.test.get_temp_dir() tf.io.gfile.mkdir(os.path.join(logdir, 'eval_dev')) p = early_stop.EarlyStop.Params() p.window = 2 p.tolerance = 1.0 p.metric_history.local_filesystem = True early_stop.MetricHistory.SetLogdirInMetricHistories(p, logdir) es = p.Instantiate() with self.session() as sess: jobname = es.metric_history.params.jobname metric = es.metric_history.params.metric mh = early_stop.MetricHistory mh.ConditionalAppend(jobname, metric, 1, 10.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 1) self.assertEqual(es.last_step, 1) mh.ConditionalAppend(jobname, metric, 2, 5.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 2) self.assertEqual(es.last_step, 2) mh.ConditionalAppend(jobname, metric, 3, 4.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 2) self.assertEqual(es.last_step, 3) mh.ConditionalAppend(jobname, metric, 5, 4.0) self.assertTrue(es.Stop(sess)) self.assertEqual(es.best_step, 2) self.assertEqual(es.last_step, 5) def testEarlyStoppingAscendingMetric(self): logdir = tf.test.get_temp_dir() tf.io.gfile.mkdir(os.path.join(logdir, 'decoder_dev')) p = early_stop.EarlyStop.Params() p.window = 2 p.tolerance = 1.0 p.metric_history.local_filesystem = True p.metric_history.minimize = False p.metric_history.jobname = 'decoder_dev' p.metric_history.metric = 'canonical_bleu' early_stop.MetricHistory.SetLogdirInMetricHistories(p, logdir) es = p.Instantiate() with self.session() as sess: jobname = es.metric_history.params.jobname metric = es.metric_history.params.metric mh = early_stop.MetricHistory mh.ConditionalAppend(jobname, metric, 1, 0.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 1) self.assertEqual(es.last_step, 1) mh.ConditionalAppend(jobname, metric, 2, 1.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 1) self.assertEqual(es.last_step, 2) mh.ConditionalAppend(jobname, metric, 3, 2.5) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 3) self.assertEqual(es.last_step, 3) mh.ConditionalAppend(jobname, metric, 5, 2.0) self.assertFalse(es.Stop(sess)) self.assertEqual(es.best_step, 3) self.assertEqual(es.last_step, 5) mh.ConditionalAppend(jobname, metric, 6, 1.0) self.assertTrue(es.Stop(sess)) self.assertEqual(es.best_step, 3) self.assertEqual(es.last_step, 6) def testEarlyStoppingAscendingTfEvents(self): logdir = test_helper.test_src_dir_path('core/ops') p = early_stop.EarlyStop.Params() p.window = 1000 p.tolerance = 0.0 p.metric_history.local_filesystem = True p.metric_history.minimize = False p.metric_history.jobname = 'testdata' p.metric_history.metric = 'bleu/dev' p.metric_history.tfevent_file = True early_stop.MetricHistory.SetLogdirInMetricHistories(p, logdir) es = p.Instantiate() with self.session() as sess: self.assertTrue(es.Stop(sess)) self.assertEqual(es.best_step, 102600) self.assertEqual(es.last_step, 185200) if __name__ == '__main__': tf.test.main()
35.721154
80
0.693271
4a2414a04cb50d5ac13e24bdace34839948079f8
1,008
py
Python
wagtail/contrib/modeladmin/forms.py
kurtrwall/wagtail
fcea4ee30da388ebeb071c5b47285526928998e4
[ "BSD-3-Clause" ]
3
2016-08-17T13:56:36.000Z
2019-04-23T19:59:25.000Z
wagtail/contrib/modeladmin/forms.py
kurtrwall/wagtail
fcea4ee30da388ebeb071c5b47285526928998e4
[ "BSD-3-Clause" ]
11
2016-08-05T15:43:06.000Z
2016-12-16T13:32:23.000Z
wagtail/contrib/modeladmin/forms.py
potatolondon/wagtail-gae
79800b0439bffeb9eb840e70c32d62f5b3487f9c
[ "BSD-3-Clause" ]
null
null
null
from __future__ import absolute_import, unicode_literals from django import forms from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ from wagtail.wagtailcore.models import Page class PageChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): bits = [] for ancestor in obj.get_ancestors(inclusive=True).exclude(depth=1): bits.append(ancestor.title) return mark_safe('<span class="icon icon-arrow-right"></span>'.join(bits)) class ParentChooserForm(forms.Form): parent_page = PageChoiceField( label=_('Parent page'), required=True, empty_label=None, queryset=Page.objects.none(), widget=forms.RadioSelect(), ) def __init__(self, valid_parents_qs, *args, **kwargs): self.valid_parents_qs = valid_parents_qs super(ParentChooserForm, self).__init__(*args, **kwargs) self.fields['parent_page'].queryset = self.valid_parents_qs
32.516129
82
0.708333
4a2414a901d79c5d2a5bcdc6218370409f2f257c
909
py
Python
Day 9/day_9.py
yuhao-lin007/Advent-of-Code-2020
78f42be051bd6693d150048ae2e8c50c0298a127
[ "Unlicense" ]
3
2020-12-20T01:56:35.000Z
2020-12-31T11:29:19.000Z
Day 9/day_9.py
yuhao-lin007/Advent-of-Code-2020
78f42be051bd6693d150048ae2e8c50c0298a127
[ "Unlicense" ]
null
null
null
Day 9/day_9.py
yuhao-lin007/Advent-of-Code-2020
78f42be051bd6693d150048ae2e8c50c0298a127
[ "Unlicense" ]
2
2020-12-23T16:23:19.000Z
2021-03-03T05:26:09.000Z
def get_valid_contiguous_set(numbers, total): for length in range(2, len(numbers)+1): for offset in range(len(numbers)-length+1): contiguous_set = numbers[offset:offset+length] if sum(contiguous_set) == total: return contiguous_set with open("input.txt", "r") as file: numbers = list(map(int, file.read().split())) preamble_length = 25 for i in range(len(numbers) - preamble_length): previous_numbers = numbers[i:i+preamble_length] total = numbers[i+preamble_length] total_valid = False for num1 in previous_numbers: for num2 in previous_numbers: if num1 + num2 == total: total_valid = True if not total_valid: invalid_total = total # Part 1 print("Part 1") print(invalid_total, "is an invalid total!") print() # Part 2 print("Part 2") contiguous_set = get_valid_contiguous_set(numbers, invalid_total) print("Encryption Weakness:", min(contiguous_set) + max(contiguous_set))
28.40625
72
0.738174
4a2414d58a6797dbb1035dc9b6d2915610fd7e56
629
py
Python
nevergrad/functions/images/test_core.py
mehrdad-shokri/nevergrad
7b68b00c158bf60544bc45997560edf733fb5812
[ "MIT" ]
1
2021-01-15T01:55:39.000Z
2021-01-15T01:55:39.000Z
nevergrad/functions/images/test_core.py
OregonWebSells/nevergrad
c2b2a0efdca29830ccc9182d8a7ba4d8695f698d
[ "MIT" ]
null
null
null
nevergrad/functions/images/test_core.py
OregonWebSells/nevergrad
c2b2a0efdca29830ccc9182d8a7ba4d8695f698d
[ "MIT" ]
null
null
null
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import core def test_images() -> None: func = core.Image() x = 7 * np.fabs(np.random.normal(size=func.domain_shape)) #data = func.parametrization.spawn_child().set_standardized_data(x.flatten()).value value = func(x) # should not touch boundaries, so value should be < np.inf assert value < np.inf other_func = func.copy() value2 = other_func(x) assert value == value2
33.105263
87
0.704293
4a2415bbab4fa2ae57216c3146e2d11a81035d5b
3,479
py
Python
netsim/graphlib/algorithms/spf.py
networmix/NetSim
9a2804112895826c58399fbd47f496817916cd49
[ "MIT" ]
null
null
null
netsim/graphlib/algorithms/spf.py
networmix/NetSim
9a2804112895826c58399fbd47f496817916cd49
[ "MIT" ]
12
2021-11-20T22:50:46.000Z
2022-01-07T02:00:38.000Z
netsim/graphlib/algorithms/spf.py
networmix/NetSim
9a2804112895826c58399fbd47f496817916cd49
[ "MIT" ]
null
null
null
from heapq import heappop, heappush from typing import Tuple, List, Dict, Callable from netsim.graphlib.graph import MultiDiGraph DEFAULT_COST_ATTRIBUTE = "metric" def min_cost_edges_func_fabric(attr_to_use: str) -> Callable: """ Fabric producing a function to find the min-cost edges between a pair of adjacent nodes in a graph. Args: attr_to_use: name of the integer attribute that will be used to determine the cost. Returns: get_min_cost_edges_func: a callable function """ def get_min_cost_edges_func( graph: MultiDiGraph, src_node: str, dst_node: str ) -> Tuple[int, List[str]]: """ Returns the min-cost edges between a pair of adjacent nodes in a graph. Args: graph: MultiDiGraph object. src_node: node_id of the source node. dst_node: node_id of the destination node. Returns: min_cost: minimal cost of the edge between src_node and dst_node edge_list: list of all edge_ids with the min_cost """ edge_list = [] min_cost = None for edge_id, edge_attributes in graph.get_adj_out()[src_node][dst_node].items(): cost = edge_attributes[attr_to_use] if min_cost is None or cost < min_cost: min_cost = cost edge_list = [edge_id] elif cost == min_cost: edge_list.append(edge_id) return min_cost, edge_list return get_min_cost_edges_func def spf( graph: MultiDiGraph, src_node: str, min_cost_edges_func: Callable = min_cost_edges_func_fabric(DEFAULT_COST_ATTRIBUTE), ) -> Tuple[Dict, Dict]: """ Implementation of the Dijkstra's Shortest Path First algorithm for finding shortest paths in the graph. Implemented using a min-priority queue: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Using_a_priority_queue Args: src_node: source node identifier. Returns: costs: a dict with destination nodes mapped into the cost of the shortest path to that destination prev: a dict with nodes mapped into their previous (preceeding) nodes and edge list """ # Initialization min_pq = [] # min-priority queue costs = {src_node: 0} # source node has has zero cost to itself prev = {src_node: {}} # source node has no preceeding nodes heappush( min_pq, (0, src_node) ) # push source node onto the min-priority queue using cost as priority while min_pq: # pop the node with the minimal cost from the source node src_to_node_cost, node_id = heappop(min_pq) # iterate over all the neighbors of the node we're looking at for neighbor_id in graph.get_adj_out()[node_id]: min_edge_cost, edges_list = min_cost_edges_func(graph, node_id, neighbor_id) src_to_neigh_cost = src_to_node_cost + min_edge_cost if neighbor_id not in costs or src_to_neigh_cost < costs[neighbor_id]: # have not seen this neighbor yet or better path found costs[neighbor_id] = src_to_neigh_cost prev[neighbor_id] = {node_id: edges_list} heappush(min_pq, (src_to_neigh_cost, neighbor_id)) elif costs[neighbor_id] == src_to_neigh_cost: # have met this neighbor, but new equal cost path found prev[neighbor_id][node_id] = edges_list return costs, prev
37.010638
107
0.661972
4a241796f5fc6483411704dc8ffbed36257a96b5
444
py
Python
try/try2.py
laashub-sua/picker
1adae754a8dbd8b927ccce52a94dd5bf72d2909c
[ "Apache-2.0" ]
1
2020-07-25T15:03:16.000Z
2020-07-25T15:03:16.000Z
try/try2.py
laashub-sua/picker
1adae754a8dbd8b927ccce52a94dd5bf72d2909c
[ "Apache-2.0" ]
null
null
null
try/try2.py
laashub-sua/picker
1adae754a8dbd8b927ccce52a94dd5bf72d2909c
[ "Apache-2.0" ]
null
null
null
import ctypes import win32con def get_window(): '''Returns windows in z-order (top first)''' user32 = ctypes.windll.user32 lst = [] top = user32.GetTopWindow(None) if not top: return lst lst.append(top) while True: next = user32.GetWindow(lst[-1], win32con.GW_HWNDNEXT) if not next: break lst.append(next) return lst window_list = get_window() print(window_list)
18.5
62
0.617117
4a24181937d272d414bf4a02b45ca57357c12fa2
3,562
py
Python
src/programy/clients/polling/xmpp/client.py
motazsaad/fit-bot-fb-clt
580477aa1ec91855b621d9ae276f2705962f6a87
[ "MIT" ]
null
null
null
src/programy/clients/polling/xmpp/client.py
motazsaad/fit-bot-fb-clt
580477aa1ec91855b621d9ae276f2705962f6a87
[ "MIT" ]
null
null
null
src/programy/clients/polling/xmpp/client.py
motazsaad/fit-bot-fb-clt
580477aa1ec91855b621d9ae276f2705962f6a87
[ "MIT" ]
4
2019-04-01T15:42:23.000Z
2020-11-05T08:14:27.000Z
""" Copyright (c) 2016-2019 Keith Sterling http://www.keithsterling.com 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. """ import sleekxmpp from programy.utils.logging.ylogger import YLogger from programy.clients.polling.client import PollingBotClient from programy.clients.polling.xmpp.config import XmppConfiguration from programy.clients.polling.xmpp.xmpp import XmppClient class XmppBotClient(PollingBotClient): def __init__(self, argument_parser=None): self._xmpp_client = None self._server = None self._port = None self._username = None self._password = None PollingBotClient.__init__(self, "XMPP", argument_parser) def get_client_configuration(self): return XmppConfiguration() def parse_configuration(self): self._server = self.configuration.client_configuration.server self._port = self.configuration.client_configuration.port def get_license_keys(self): self._username = self.license_keys.get_key("XMPP_USERNAME") self._password = self.license_keys.get_key("XMPP_PASSWORD") def create_client(self, username, password): return XmppClient(self, username, password) def ask_question(self, userid, question): self._questions += 1 client_context = self.create_client_context(userid) response = client_context.bot.ask_question(client_context, question, responselogger=self) return response def connect(self): YLogger.debug(self, "XMPPBotClient Connecting as %s to %s %s", self._username, self._server, self._port) self._xmpp_client = self.create_client(self._username, self._password) if self._xmpp_client is not None: self._xmpp_client.connect((self._server, self._port)) self._xmpp_client.register_xep_plugins(self.configuration.client_configuration) return True return False def display_connected_message(self): print ("XMPP Bot connected and running...") def poll_and_answer(self): running = True try: self._xmpp_client.process(block=True) print("XMPP client exiting cleanly....") running = False except KeyboardInterrupt: print("XMPP client stopping via keyboard....") running = False except Exception as excep: YLogger.exception(self, "Failed to poll and answer", excep) return running if __name__ == '__main__': print("Initiating XMPP Client...") xmpp_app = XmppBotClient() xmpp_app.run()
38.717391
120
0.722347
4a2418e1b0dabc3c262aac125f1851f3fce02786
993
py
Python
tests_runner/__main__.py
RainingComputers/ShnooTalk
714f6648363a99e011e329ed1a3f800e6fe65f39
[ "MIT" ]
6
2021-07-17T16:02:07.000Z
2022-02-05T16:33:51.000Z
tests_runner/__main__.py
RainingComputers/ShnooTalk
714f6648363a99e011e329ed1a3f800e6fe65f39
[ "MIT" ]
1
2021-07-16T07:14:31.000Z
2021-07-16T07:22:10.000Z
tests_runner/__main__.py
RainingComputers/ShnooTalk
714f6648363a99e011e329ed1a3f800e6fe65f39
[ "MIT" ]
2
2021-07-16T02:54:27.000Z
2022-03-29T20:51:57.000Z
import sys from tests_runner.utils.config import CLI_ARG, BUILD_TYPE_MAP from tests_runner.utils.coverage import prepare_coverage_report from tests_runner.utils.result import ResultPrinter from tests_runner import compiler_tests, llc_tests, cli_tests, parser_tests, ir_tests def print_usage() -> None: print("🙁 Invalid CLI ARGS, available option are:") print(f" {' '.join(list(BUILD_TYPE_MAP.keys()))}") def run_all_tests() -> None: parser_tests.run() ir_tests.run() compiler_tests.run() llc_tests.run() cli_tests.run() def print_done() -> None: print("🏁 Done.") def main() -> int: if CLI_ARG == "--test": run_all_tests() print_done() return ResultPrinter.exit_code elif CLI_ARG == "--coverage": run_all_tests() prepare_coverage_report() print_done() return ResultPrinter.exit_code else: print_usage() return -1 if __name__ == "__main__": sys.exit(main())
21.586957
85
0.663646
4a24194725b788ea6d3137ad5779a89952168033
97
py
Python
tests/internal_bench/var-1-constant.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
13,648
2015-01-01T01:34:51.000Z
2022-03-31T16:19:53.000Z
tests/internal_bench/var-1-constant.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
7,092
2015-01-01T07:59:11.000Z
2022-03-31T23:52:18.000Z
tests/internal_bench/var-1-constant.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
4,942
2015-01-02T11:48:50.000Z
2022-03-31T19:57:10.000Z
import bench def test(num): i = 0 while i < 20000000: i += 1 bench.run(test)
8.818182
23
0.525773
4a241960aae06d33a36d3865af8f208dedeecfe2
1,838
py
Python
scipy/maxentropy/examples/bergerexample.py
lesserwhirls/scipy-cwt
ee673656d879d9356892621e23ed0ced3d358621
[ "BSD-3-Clause" ]
8
2015-10-07T00:37:32.000Z
2022-01-21T17:02:33.000Z
scipy/maxentropy/examples/bergerexample.py
lesserwhirls/scipy-cwt
ee673656d879d9356892621e23ed0ced3d358621
[ "BSD-3-Clause" ]
null
null
null
scipy/maxentropy/examples/bergerexample.py
lesserwhirls/scipy-cwt
ee673656d879d9356892621e23ed0ced3d358621
[ "BSD-3-Clause" ]
8
2015-05-09T14:23:57.000Z
2018-11-15T05:56:00.000Z
#!/usr/bin/env python """ Example use of the maximum entropy module: Machine translation example -- English to French -- from the paper 'A maximum entropy approach to natural language processing' by Berger et al., 1996. Consider the translation of the English word 'in' into French. We notice in a corpus of parallel texts the following facts: (1) p(dans) + p(en) + p(a) + p(au cours de) + p(pendant) = 1 (2) p(dans) + p(en) = 3/10 (3) p(dans) + p(a) = 1/2 This code finds the probability distribution with maximal entropy subject to these constraints. """ __author__ = 'Ed Schofield' __version__= '2.1' from scipy import maxentropy a_grave = u'\u00e0' samplespace = ['dans', 'en', a_grave, 'au cours de', 'pendant'] def f0(x): return x in samplespace def f1(x): return x=='dans' or x=='en' def f2(x): return x=='dans' or x==a_grave f = [f0, f1, f2] model = maxentropy.model(f, samplespace) # Now set the desired feature expectations K = [1.0, 0.3, 0.5] model.verbose = True # Fit the model model.fit(K) # Output the distribution print "\nFitted model parameters are:\n" + str(model.params) print "\nFitted distribution is:" p = model.probdist() for j in range(len(model.samplespace)): x = model.samplespace[j] print ("\tx = %-15s" %(x + ":",) + " p(x) = "+str(p[j])).encode('utf-8') # Now show how well the constraints are satisfied: print print "Desired constraints:" print "\tp['dans'] + p['en'] = 0.3" print ("\tp['dans'] + p['" + a_grave + "'] = 0.5").encode('utf-8') print print "Actual expectations under the fitted model:" print "\tp['dans'] + p['en'] =", p[0] + p[1] print ("\tp['dans'] + p['" + a_grave + "'] = " + str(p[0]+p[2])).encode('utf-8') # (Or substitute "x.encode('latin-1')" if you have a primitive terminal.)
26.637681
81
0.6284
4a241973ce7a049a5fbb70001eef91f44c2702d9
19,216
py
Python
nyangco.py
cauTheBattleCat/nyangco
82d97cd98e0e2a30937e94d88b2b0c8f6e76a96a
[ "MIT" ]
null
null
null
nyangco.py
cauTheBattleCat/nyangco
82d97cd98e0e2a30937e94d88b2b0c8f6e76a96a
[ "MIT" ]
null
null
null
nyangco.py
cauTheBattleCat/nyangco
82d97cd98e0e2a30937e94d88b2b0c8f6e76a96a
[ "MIT" ]
2
2020-12-06T12:57:22.000Z
2021-12-06T00:33:34.000Z
from bangtal import * import time import threading import random setGameOption(GameOption.ROOM_TITLE, False) setGameOption(GameOption.INVENTORY_BUTTON, False) setGameOption(GameOption.MESSAGE_BOX_BUTTON, False) mainScene = Scene("메인", "res/wallpaper/main.png") mapScene = Scene("지도", "res/wallpaper/ingame2.png") startScene = Scene("공격개시","res/wallpaper/ingame.png") stage1 = Scene("한국","res/wallpaper/stage1.png") stage2 = Scene("일본","res/wallpaper/stage2.png") stage3 = Scene("중국","res/wallpaper/stage3.png") stageNum = 1 # 현재 스테이지 번호 저장 prevScene = mainScene # 이전 Scene 저장 nowScene = mainScene # 현재 Scene 저장 stageObject = None # 현재 Stage 객체 저장 FRIEND = 0 ENEMY = 1 STAGE1 = 1 STAGE2 = 2 STAGE3 = 3 class Stage(): def __init__(self,stage): if(stage == STAGE1): self.friend = Friend(100,1000,stage) self.enemy = Enemy(1000,stage) catBtns[0].show() elif(stage == STAGE2): self.friend = Friend(500,2000,stage) self.enemy = Enemy(2000,stage) for i in range(0,3): catBtns[i].show() elif(stage == STAGE3): self.friend = Friend(1000,3000,stage) self.enemy = Enemy(3000,stage) for i in range(0,5): catBtns[i].show() class Enemy(): def createFriend(self): self.timer = threading.Timer(7,self.createFriend) isEmpty = False index = 0 for i in range(0,5): if self.friends[i] == None: isEmpty = True index = i break if isEmpty: if self.enemyOrder[self.i] == 0: self.friends[index] = DogSoldier(index) elif self.enemyOrder[self.i] == 1: self.friends[index] = SnakeSoldier(index) elif self.enemyOrder[self.i] == 2: self.friends[index] = SheepSoldier(index) elif self.enemyOrder[self.i] == 3: self.friends[index] = BearSoldier(index) elif self.enemyOrder[self.i] == 4: self.friends[index] = CySoldier(index) self.i = self.i + 1 self.timer.start() def endTimer(self): self.timer.cancel() def __init__(self,castleStat,stage): self.castle = EnemyCastle(ENEMY,castleStat) self.friends = [None for i in range(5)] self.i = 0 if stage == STAGE1: self.enemyOrder = [0 for i in range(20)] elif stage == STAGE2: self.enemyOrder = [0,1,0,2,0,0,0,2,0,0,0,1,0,0,0,2,0,1] elif stage == STAGE3: self.enemyOrder = [0,0,0,2,0,1,1,0,2,3,0,0,4,0,1,2,0,3] self.createFriend() class Friend(): def createFriend(self,type): isEmpty = False index = 0 for i in range(0,5): if self.friends[i] == None: # 아군이 5명이 넘지 않을 때 isEmpty = True index = i break if isEmpty: if self.moneyNow >= catBtns[type].price: # 돈이 병사 가격보다 많을 때 if type == 0 : self.friends[index] = CatSoldier(index) elif type == 1: self.friends[index] = TankCatSoldier(index) elif type == 2: self.friends[index] = AxeCatSoldier(index) elif type == 3: self.friends[index] = BirdCatSoldier(index) elif type == 4: self.friends[index] = TitanCatSoldier(index) self.moneyNow = self.moneyNow - catBtns[type].price catBtnsDisable[type].show() # 캐릭터 위에 작대기 2초동안 표시 def onTimeout(): catBtnsDisable[type].hide() timer = Timer(2) timer.start() timer.onTimeout = onTimeout def startTimer(self): # 돈 계산해서 화면에 표시하는 함수 self.timer = threading.Timer(1, self.startTimer) if self.moneyNow + 5*stageNum <= self.moneyMax: self.moneyNow = self.moneyNow + 5*stageNum rest = self.moneyNow self.moneyThou.setImage(f"res/etc/{int(self.moneyNow / 1000)}.png") rest = self.moneyNow - int(self.moneyNow / 1000)*1000 self.moneyThou.show() self.moneyHun.setImage(f"res/etc/{int(rest / 100)}.png") rest = self.moneyNow - int(self.moneyNow / 100)*100 self.moneyHun.show() self.moneyTens.setImage(f"res/etc/{int(rest/10)}.png") rest = self.moneyNow - int(self.moneyNow / 10)*10 self.moneyTens.show() self.moneyUnits.setImage(f"res/etc/{rest}.png") self.moneyUnits.show() self.timer.start() def endTimer(self): self.timer.cancel() def __init__(self,moneyMax,castleStat,stage): self.moneyMax = moneyMax self.moneyNow = 0 self.castle = FriendCastle(FRIEND,castleStat) self.friends = [None for i in range(5)] self.moneyTotImg = Object(f"res/etc/{stage}_money.png") self.moneyTotImg.locate(nowScene,1000,650) self.moneyTotImg.setScale(0.5) self.moneyTotImg.show() self.sliceImg = Object(f"res/etc/slice.png") self.sliceImg.locate(nowScene,960,650) self.sliceImg.setScale(0.5) self.sliceImg.show() self.moneyThou = Object(f"res/etc/0.png") self.moneyThou.locate(nowScene,840,650) self.moneyThou.setScale(0.5) self.moneyHun = Object(f"res/etc/0.png") self.moneyHun.locate(nowScene,870,650) self.moneyHun.setScale(0.5) self.moneyTens = Object(f"res/etc/0.png") self.moneyTens.locate(nowScene,900,650) self.moneyTens.setScale(0.5) self.moneyUnits = Object(f"res/etc/0.png") self.moneyUnits.locate(nowScene,930,650) self.moneyUnits.setScale(0.5) self.startTimer() class Soldier(Object): def __init__(self,file,move): super().__init__(file) self.move = move class EnemySoldier(Soldier): def endGame(self): self.hide() self.attackTimer.cancel() def receiveAttack(self,damage,index): self.power = self.power - damage if self.power < 0: stageObject.enemy.friends[index] = None self.hide() self.attack = 0 self.attackTimer.cancel() def attackOp(self): self.attackTimer = threading.Timer(self.interval,self.attackOp) attackCastle = True for i in range(0,5): if stageObject.friend.friends[i] != None: attackCastle = False if attackCastle: try: stageObject.friend.castle.receiveAttack(self.attack) except: self.attackTimer.cancel() else: while(True): attackIndex = random.randrange(0,5) if stageObject.friend.friends[attackIndex] != None: break stageObject.friend.friends[attackIndex].receiveAttack(self.attack,attackIndex) self.attackTimer.start() def movePos(self): self.moveTimer = threading.Timer(1, self.movePos) if (self.index == 0 and self.xPos + self.move <= 590) or (self.index == 1 and self.xPos + self.move <= 575) or (self.index == 2 and self.xPos + self.move <= 550) or (self.index == 3 and self.xPos + self.move <= 525) or (self.index == 4 and self.xPos + self.move <= 500): self.xPos = self.xPos + self.move self.locate(nowScene, self.xPos,self.yPos) else: self.moveTimer.cancel() self.attackOp() self.setImage(f"res/character/{self.name}_atk2.png") self.moveTimer.start() def __init__(self,file,name,index,move,attack,power,interval,xPos = 100,yPos = 180): super().__init__(file,move) self.name = name self.attack = attack self.power = power self.interval = interval self.index = index self.xPos = xPos self.yPos = yPos self.locate(nowScene,xPos,yPos) self.show() self.movePos() self.attackTimer = threading.Timer(self.interval,self.attackOp) class DogSoldier(EnemySoldier): def __init__(self,index): super().__init__(file="res/character/dog_move1.png",name="dog",index = index,move = 25,attack = 20,power = 100,interval = 1) class SnakeSoldier(EnemySoldier): def __init__(self,index): super().__init__(file="res/character/snake_move1.png",name="snake",index = index,move = 40,attack = 30,power = 500,interval = 1) class SheepSoldier(EnemySoldier): def __init__(self,index): super().__init__(file="res/character/baabaa_move1.png",name="baabaa",index = index,move = 20,attack = 100,power = 350,interval = 2) class BearSoldier(EnemySoldier): def __init__(self,index): super().__init__(file="res/character/bear_move1.png",name="bear",index = index,move = 50,attack = 200,power = 500,interval = 3) class CySoldier(EnemySoldier): def __init__(self,index): super().__init__(file="res/character/cy_move1.png",name="cy",index = index,move = 50,attack = 300,power = 2000,interval = 8) class FriendSoldier(Soldier): def endGame(self): self.hide() self.attackTimer.cancel() def receiveAttack(self,damage,index): self.power = self.power - damage if self.power < 0: stageObject.friend.friends[index] = None self.hide() self.attack = 0 self.attackTimer.cancel() def attackOp(self): if stageObject != None: self.attackTimer = threading.Timer(self.interval,self.attackOp) attackCastle = True for i in range(0,5): if stageObject.enemy.friends[i] != None: attackCastle = False if attackCastle: try: stageObject.enemy.castle.receiveAttack(self.attack) except: self.attackTimer.cancel() else: while(True): attackIndex = random.randrange(0,5) if stageObject.enemy.friends[attackIndex] != None: break stageObject.enemy.friends[attackIndex].receiveAttack(self.attack,attackIndex) self.attackTimer.start() def movePos(self): self.moveTimer = threading.Timer(1, self.movePos) if (self.index == 0 and self.xPos - self.move >= 610) or (self.index == 1 and self.xPos - self.move >= 625) or (self.index == 2 and self.xPos - self.move >= 650) or (self.index == 3 and self.xPos - self.move >= 675) or (self.index == 4 and self.xPos - self.move >= 700): self.xPos = self.xPos - self.move self.locate(nowScene, self.xPos,self.yPos) else: self.moveTimer.cancel() self.attackOp() self.setImage(f"res/character/{self.name}_atk2.png") self.moveTimer.start() def __init__(self,file,name,index,price,move,attack,power,interval,xPos = 1000,yPos = 180): super().__init__(file,move) self.name = name self.attack = attack self.power = power self.interval = interval self.index = index self.price = price self.xPos = xPos self.yPos = yPos self.locate(nowScene,xPos,yPos) self.show() self.movePos() self.attackTimer = threading.Timer(self.interval,self.attackOp) class CatSoldier(FriendSoldier): def __init__(self,index): super().__init__(file="res/character/cat1_move1.png",name="cat1",index = index,price = 50,move = 50,attack = 30,power = 130,interval = 1) class TankCatSoldier(FriendSoldier): def __init__(self,index): super().__init__(file="res/character/tankcat_move1.png",name="tankcat",index = index,price = 100,move = 40,attack = 10,power = 600,interval = 2) class AxeCatSoldier(FriendSoldier): def __init__(self,index): super().__init__(file="res/character/axecat_move1.png",name="axecat",index = index,price = 200,move = 60,attack = 60,power = 150,interval = 1) class BirdCatSoldier(FriendSoldier): def __init__(self,index): super().__init__(file="res/character/cat_bird_move1.png",name="cat_bird",index = index,price = 400,move = 50,attack = 250,power = 700,interval = 2) class TitanCatSoldier(FriendSoldier): def __init__(self,index): super().__init__(file="res/character/titan_move1.png",name="titan",index = index,price = 1000,move = 50,attack = 200,power = 800,interval = 4) class Castle(): def __init__(self,type,status): self.status = status self.type = type class FriendCastle(Castle): def displayStatus(self): self.timer = threading.Timer(1, self.displayStatus) rest = self.status self.statThou.setImage(f"res/etc/{int(self.status / 1000)}_mini.png") rest = self.status - int(self.status / 1000)*1000 self.statHun.setImage(f"res/etc/{int(rest / 100)}_mini.png") rest = rest - int(rest / 100)*100 self.statTens.setImage(f"res/etc/{int(rest / 10)}_mini.png") rest = rest - int(rest / 10)*10 self.statUnits.setImage(f"res/etc/{rest}_mini.png") self.timer.start() def receiveAttack(self,damage): if self.status - damage <= 0: victoryImg = Object("res/wallpaper/fail.png") victoryImg.locate(nowScene,200,300) victoryImg.show() stageObject.enemy.endTimer() stageObject.friend.endTimer() time.sleep(2) endGame() else: self.status = self.status - damage def __init__(self,type,status): super().__init__(type,status) self.statTotImg = Object(f"res/etc/{stageNum}_stat.png") self.statTotImg.locate(nowScene,930,450) self.statTotImg.show() self.sliceImg = Object(f"res/etc/slice_mini.png") self.sliceImg.locate(nowScene,900,450) self.sliceImg.setScale(0.5) self.sliceImg.show() self.statThou = Object(f"res/etc/{stageNum}_mini.png") self.statThou.locate(nowScene,795,450) self.statThou.setScale(0.5) self.statThou.show() self.statHun = Object(f"res/etc/0_mini.png") self.statHun.locate(nowScene,820,450) self.statHun.setScale(0.5) self.statHun.show() self.statTens = Object(f"res/etc/0_mini.png") self.statTens.locate(nowScene,845,450) self.statTens.setScale(0.5) self.statTens.show() self.statUnits = Object(f"res/etc/0_mini.png") self.statUnits.locate(nowScene,870,450) self.statUnits.setScale(0.5) self.statUnits.show() self.displayStatus() class EnemyCastle(Castle): def displayStatus(self): self.timer = threading.Timer(1, self.displayStatus) rest = self.status self.statThou.setImage(f"res/etc/{int(self.status / 1000)}_mini.png") rest = self.status - int(self.status / 1000)*1000 self.statHun.setImage(f"res/etc/{int(rest / 100)}_mini.png") rest = rest - int(rest / 100)*100 self.statTens.setImage(f"res/etc/{int(rest / 10)}_mini.png") rest = rest - int(rest / 10)*10 self.statUnits.setImage(f"res/etc/{rest}_mini.png") self.timer.start() def receiveAttack(self,damage): if self.status - damage <= 0: victoryImg = Object("res/wallpaper/victory.png") victoryImg.locate(nowScene,200,300) victoryImg.show() stageObject.enemy.endTimer() stageObject.friend.endTimer() time.sleep(2) endGame() else: self.status = self.status - damage def __init__(self,type,status): super().__init__(type,status) self.statTotImg = Object(f"res/etc/{stageNum}_stat.png") self.statTotImg.locate(nowScene,350,450) self.statTotImg.show() self.sliceImg = Object(f"res/etc/slice_mini.png") self.sliceImg.locate(nowScene,325,450) self.sliceImg.setScale(0.5) self.sliceImg.show() self.statThou = Object(f"res/etc/{stageNum}_mini.png") self.statThou.locate(nowScene,220,450) self.statThou.setScale(0.5) self.statThou.show() self.statHun = Object(f"res/etc/0_mini.png") self.statHun.locate(nowScene,245,450) self.statHun.setScale(0.5) self.statHun.show() self.statTens = Object(f"res/etc/0_mini.png") self.statTens.locate(nowScene,270,450) self.statTens.setScale(0.5) self.statTens.show() self.statUnits = Object(f"res/etc/0_mini.png") self.statUnits.locate(nowScene,295,450) self.statUnits.setScale(0.5) self.statUnits.show() self.displayStatus() class Point(Object): # 지도에서 각 지역별 표시 def __init__(self,file,type): super().__init__(file) self.type = type self.onMouseAction = self.point_onClick def point_onClick(self,x,y,action): global stageNum if self.type == STAGE1: koreaImg.show() japanImg.hide() chinaImg.hide() stageNum = STAGE1 elif self.type == STAGE2: koreaImg.hide() japanImg.show() chinaImg.hide() stageNum = STAGE2 elif self.type == STAGE3: koreaImg.hide() japanImg.hide() chinaImg.show() stageNum = STAGE3 gameBtn = Object("res/etc/game.png") gameBtn.locate(mainScene, 400,200) gameBtn.setScale(0.7) gameBtn.show() startBtn = Object("res/etc/start.png") startBtn.locate(mapScene, 1000,200) startBtn.setScale(0.5) startBtn.show() startImg = Object("res/wallpaper/start.png") startImg.locate(mapScene,0,0) backBtn = Object("res/etc/back.png") pauseBtn = Object("res/etc/pause.png") pauseBtn.locate(stage1, 0,600) pauseBtn.setScale(0.6) pauseBtn.show() pauseImg = Object("res/etc/pauseimg.png") pauseImg.locate(stage1, 400,200) continueBtn = Object("res/etc/continue.png") continueBtn.locate(stage1, 530,330) class CatBtn(Object): def onBtnClick(self,x,y,action): stageObject.friend.createFriend(self.type) def __init__(self,file,type,price): super().__init__(file) self.type = type self.price = price self.onMouseAction = self.onBtnClick catCastle = Object("res/castle/cat_castle.png") enCastle = Object("res/castle/en_castle.png") catBtns = [CatBtn("res/etc/cat.png",0,50),CatBtn("res/etc/tankcat.png",1,100),CatBtn("res/etc/axecat.png",2,200),CatBtn("res/etc/birdcat.png",3,400), CatBtn("res/etc/titan.png",4,1000)] catBtnsDisable = [Object("res/etc/none.png") for i in range(5)] point1 = Point("res/etc/point.png",STAGE1) #한국 point1.locate(mapScene, 580,335) point1.show() koreaImg = Object("res/etc/korea.png") koreaImg.locate(mapScene, 660,585) koreaImg.show() point2 = Point("res/etc/point.png",STAGE2) #일본 point2.locate(mapScene, 750,300) point2.show() japanImg = Object("res/etc/japan.png") japanImg.locate(mapScene, 660,585) point3 = Point("res/etc/point.png",STAGE3) #중국 point3.locate(mapScene, 360,200) point3.show() chinaImg = Object("res/etc/china.png") chinaImg.locate(mapScene, 660,585) def gameBtn_onClick(x,y,action): global prevScene prevScene = mainScene backBtn.locate(mapScene,3,40) backBtn.show() mapScene.enter() gameBtn.onMouseAction = gameBtn_onClick def startBtn_onClick(x,y,action): global prevScene startImg.show() timer = Timer(1) timer.start() def onTimeout(): global stageObject global nowScene startImg.hide() prevScene = mapScene if stageNum == STAGE1: nowScene = stage1 stageObject = Stage(STAGE1) elif stageNum == STAGE2: nowScene = stage2 stageObject = Stage(STAGE2) elif stageNum == STAGE3: nowScene = stage3 stageObject = Stage(STAGE3) catCastle.locate(nowScene,1000,200) catCastle.show() enCastle.locate(nowScene,0,150) enCastle.setScale(0.8) enCastle.show() xPos = 230 for i in range(0,5): catBtns[i].locate(nowScene,xPos,10) catBtnsDisable[i].locate(nowScene,xPos,10) xPos = xPos + 150 nowScene.enter() pauseBtn.locate(nowScene, 0,600) locatePauseBox(nowScene) timer.onTimeout = onTimeout startBtn.onMouseAction = startBtn_onClick def locatePauseBox(stage): pauseBtn.locate(stage, 0,600) pauseImg.locate(stage, 400,200) continueBtn.locate(stage, 530,330) def backBtn_onClick(x,y,action): prevScene.enter() backBtn.onMouseAction = backBtn_onClick def pauseBtn_onClick(x,y,action): pauseImg.show() continueBtn.show() pauseBtn.onMouseAction = pauseBtn_onClick def continueBtn_onClick(x,y,action): hidePauseBox() continueBtn.onMouseAction = continueBtn_onClick def hidePauseBox(): pauseImg.hide() continueBtn.hide() startGame(mainScene)
31.043619
274
0.670847
4a2419d84a45cfd2694fdb4d8de3a0dca18843f9
4,734
py
Python
daisy_workflows/image_import/freebsd/translate.py
collabora-gce/compute-image-tools
20a7f19be80b4920f8b369384beb161ed580550b
[ "Apache-2.0" ]
null
null
null
daisy_workflows/image_import/freebsd/translate.py
collabora-gce/compute-image-tools
20a7f19be80b4920f8b369384beb161ed580550b
[ "Apache-2.0" ]
2
2018-05-25T19:19:28.000Z
2018-06-21T02:31:47.000Z
daisy_workflows/image_import/freebsd/translate.py
collabora-gce/compute-image-tools
20a7f19be80b4920f8b369384beb161ed580550b
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env python # Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Translate the FreeBSD image on a GCE VM. Parameters (retrieved from instance metadata): install_gce_packages: True if GCE agent and SDK should be installed """ import glob import logging import os import subprocess import utils rc_conf = ''' ifconfig_re0="DHCP" sshd_enable="YES" ifconfig_DEFAULT="SYNCDHCP mtu 1460" ntpd_sync_on_start="YES" ''' ntp_conf = ''' server metadata.google.internal iburst ''' console_settings = ''' console="comconsole,vidconsole" comconsole_speed="38400" autoboot_delay="-1" loader_logo="none" ''' google_services = ''' google_startup_enable=YES google_accounts_daemon_enable=YES google_clock_skew_daemon_enable=YES google_instance_setup_enable=YES google_ip_forwarding_daemon_enable=YES google_network_setup_enable=YES ''' def DistroSpecific(c): install_gce = utils.GetMetadataAttribute('install_gce_packages') def UpdateConfigs(config, filename): """ Parses @config and removes left side of '=' char from @filename and then add the full @config to @filename """ # Removing, if it exists if os.path.isfile(filename): for t in config.split('\n'): if t: to_be_removed = t.split('=')[0] c.sh('sed -i -e "/%(pattern)s/d" %(filename)s' % { 'pattern': to_be_removed, 'filename': filename, }) else: # Indicate that a new one is being created throught a comment with open('/etc/resolv.conf', 'w') as f: f.write("# Created by daisy's image import\n") # Adding c.write_append(config, filename) UpdateConfigs(rc_conf, '/etc/rc.conf') if install_gce == 'true': c.sh('ASSUME_ALWAYS_YES=yes pkg update') logging.info('Installing GCE packages.') c.sh('pkg install --yes py27-google-compute-engine google-cloud-sdk') # Activate google services UpdateConfigs(google_services, '/etc/rc.conf') # Update console configuration on boot UpdateConfigs(console_settings, '/boot/loader.conf') # Update device names on fstab c.sh('sed -i -e "s#/dev/ada#/dev/da#" /etc/fstab') # Remove any hard coded DNS settings in resolvconf. logging.info('Resetting resolvconf base.') with open('/etc/resolv.conf', 'w') as f: f.write('\n') class Chroot(object): """ Simple alternative to guestfs lib, as it doesn't exist in FreeBSD """ def __init__(self, device): self.mount_point = '/translate' os.mkdir(self.mount_point) def FindAndMountRootPartition(): """ Try to mount partitions of @device onto @self.mount_point. The root partition should have a 'bin' folder. Return false if not found. """ for part in glob.glob(device + 'p*'): try: self.sh('mount %s %s' % (part, self.mount_point)) # check if a bin folder exists if os.path.isdir(os.path.join(self.mount_point, 'bin')): # Great! Found a desired partition with rootfs return True # No bin folder? Try the next partition self.sh('umount %s' % self.mount_point) except Exception as e: logging.info('Failed to mount %s. Reason: %s. Continuing...' % ( part, e)) # Too bad. Didn't find one return False if not FindAndMountRootPartition(): raise Exception("No root partition found on disk %s" % device) # copy resolv.conf for using internet connection before chroot self.sh('cp /etc/resolv.conf %s/etc/resolv.conf' % self.mount_point) # chroot to that environment os.chroot(self.mount_point) def sh(self, cmd): p = subprocess.Popen(cmd, shell=True) p.communicate() returncode = p.returncode if returncode != 0: raise subprocess.CalledProcessError(returncode, cmd) def write_append(self, content, filename): with open(filename, 'a') as dst: dst.write(content) def main(): # Class will mount appropriate partition on da1 disk c = Chroot('/dev/da1') DistroSpecific(c) # Remove SSH host keys. logging.info('Removing SSH host keys.') c.sh("rm -f /etc/ssh/ssh_host_*") if __name__ == '__main__': utils.RunTranslate(main)
27.523256
76
0.679341
4a241a606013e077c3c1e81c8d5bf13b399e8132
1,073
py
Python
django_extauth/urls.py
aiakos/aiakos
a591e7ef13ab9e8e14b4d3569d43fce694c4150a
[ "BSD-2-Clause", "MIT" ]
4
2017-04-28T19:09:17.000Z
2018-07-03T04:43:54.000Z
django_extauth/urls.py
aiakos/aiakos
a591e7ef13ab9e8e14b4d3569d43fce694c4150a
[ "BSD-2-Clause", "MIT" ]
2
2020-06-05T17:46:47.000Z
2021-06-10T17:22:58.000Z
django_extauth/urls.py
aiakos/aiakos
a591e7ef13ab9e8e14b4d3569d43fce694c4150a
[ "BSD-2-Clause", "MIT" ]
2
2017-08-14T07:15:14.000Z
2019-03-04T14:02:05.000Z
from django.conf.urls import url from django.contrib.auth import views as django_auth_views from . import user, views app_name = 'extauth' urlpatterns = [ url(r'^$', views.SelectAccountView.as_view(), name='select-account'), url(r'^u/(?P<account_id>[^/]+)/$', views.AccountHomeView.as_view(), name='account-home'), url(r'^u/(?P<account_id>[^/]+)/auth/settings/$', views.AccountSettingsView.as_view(), name='account-settings'), url(r'^u/(?P<account_id>[^/]+)/auth/settings/$', views.AccountSettingsView.as_view(), name='settings'), url(r'^auth/login/$', views.AuthView.as_view(), name='login'), url(r'^auth/oauth-done/$', views.OAuthDoneView.as_view(), name='oauth-done'), url(r'^auth/logout/$', django_auth_views.logout, name='logout'), url(r'^auth/login/(?P<auth_token>[^/]+)/$', views.LoginByEmail.as_view(), name='login-by-email'), url(r'^auth/confirm-email/(?P<auth_token>[^/]+)/$', views.FinishRegistrationByEmail.as_view(), name='finish-registration-by-email'), ] oauth_actions = { 'login': views.AuthView, 'associate': views.AccountSettingsView, }
39.740741
133
0.698043
4a241aee863f358e8285b974fc1413c9965210c0
15,101
py
Python
sdk/python/pulumi_aws/elb/listener_policy.py
jen20/pulumi-aws
172e00c642adc03238f89cc9c5a16b914a77c2b1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
sdk/python/pulumi_aws/elb/listener_policy.py
jen20/pulumi-aws
172e00c642adc03238f89cc9c5a16b914a77c2b1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
sdk/python/pulumi_aws/elb/listener_policy.py
jen20/pulumi-aws
172e00c642adc03238f89cc9c5a16b914a77c2b1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from .. import _utilities, _tables __all__ = ['ListenerPolicyArgs', 'ListenerPolicy'] @pulumi.input_type class ListenerPolicyArgs: def __init__(__self__, *, load_balancer_name: pulumi.Input[str], load_balancer_port: pulumi.Input[int], policy_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None): """ The set of arguments for constructing a ListenerPolicy resource. :param pulumi.Input[str] load_balancer_name: The load balancer to attach the policy to. :param pulumi.Input[int] load_balancer_port: The load balancer listener port to apply the policy to. :param pulumi.Input[Sequence[pulumi.Input[str]]] policy_names: List of Policy Names to apply to the backend server. """ pulumi.set(__self__, "load_balancer_name", load_balancer_name) pulumi.set(__self__, "load_balancer_port", load_balancer_port) if policy_names is not None: pulumi.set(__self__, "policy_names", policy_names) @property @pulumi.getter(name="loadBalancerName") def load_balancer_name(self) -> pulumi.Input[str]: """ The load balancer to attach the policy to. """ return pulumi.get(self, "load_balancer_name") @load_balancer_name.setter def load_balancer_name(self, value: pulumi.Input[str]): pulumi.set(self, "load_balancer_name", value) @property @pulumi.getter(name="loadBalancerPort") def load_balancer_port(self) -> pulumi.Input[int]: """ The load balancer listener port to apply the policy to. """ return pulumi.get(self, "load_balancer_port") @load_balancer_port.setter def load_balancer_port(self, value: pulumi.Input[int]): pulumi.set(self, "load_balancer_port", value) @property @pulumi.getter(name="policyNames") def policy_names(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]: """ List of Policy Names to apply to the backend server. """ return pulumi.get(self, "policy_names") @policy_names.setter def policy_names(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]): pulumi.set(self, "policy_names", value) class ListenerPolicy(pulumi.CustomResource): @overload def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, load_balancer_name: Optional[pulumi.Input[str]] = None, load_balancer_port: Optional[pulumi.Input[int]] = None, policy_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, __props__=None, __name__=None, __opts__=None): """ Attaches a load balancer policy to an ELB Listener. ## Example Usage ### Custom Policy ```python import pulumi import pulumi_aws as aws wu_tang = aws.elb.LoadBalancer("wu-tang", availability_zones=["us-east-1a"], listeners=[aws.elb.LoadBalancerListenerArgs( instance_port=443, instance_protocol="http", lb_port=443, lb_protocol="https", ssl_certificate_id="arn:aws:iam::000000000000:server-certificate/wu-tang.net", )], tags={ "Name": "wu-tang", }) wu_tang_ssl = aws.elb.LoadBalancerPolicy("wu-tang-ssl", load_balancer_name=wu_tang.name, policy_name="wu-tang-ssl", policy_type_name="SSLNegotiationPolicyType", policy_attributes=[ aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="ECDHE-ECDSA-AES128-GCM-SHA256", value="true", ), aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="Protocol-TLSv1.2", value="true", ), ]) wu_tang_listener_policies_443 = aws.elb.ListenerPolicy("wu-tang-listener-policies-443", load_balancer_name=wu_tang.name, load_balancer_port=443, policy_names=[wu_tang_ssl.policy_name]) ``` This example shows how to customize the TLS settings of an HTTPS listener. ### AWS Predefined Security Policy ```python import pulumi import pulumi_aws as aws wu_tang = aws.elb.LoadBalancer("wu-tang", availability_zones=["us-east-1a"], listeners=[aws.elb.LoadBalancerListenerArgs( instance_port=443, instance_protocol="http", lb_port=443, lb_protocol="https", ssl_certificate_id="arn:aws:iam::000000000000:server-certificate/wu-tang.net", )], tags={ "Name": "wu-tang", }) wu_tang_ssl_tls_1_1 = aws.elb.LoadBalancerPolicy("wu-tang-ssl-tls-1-1", load_balancer_name=wu_tang.name, policy_name="wu-tang-ssl", policy_type_name="SSLNegotiationPolicyType", policy_attributes=[aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="Reference-Security-Policy", value="ELBSecurityPolicy-TLS-1-1-2017-01", )]) wu_tang_listener_policies_443 = aws.elb.ListenerPolicy("wu-tang-listener-policies-443", load_balancer_name=wu_tang.name, load_balancer_port=443, policy_names=[wu_tang_ssl_tls_1_1.policy_name]) ``` This example shows how to add a [Predefined Security Policy for ELBs](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html) :param str resource_name: The name of the resource. :param pulumi.ResourceOptions opts: Options for the resource. :param pulumi.Input[str] load_balancer_name: The load balancer to attach the policy to. :param pulumi.Input[int] load_balancer_port: The load balancer listener port to apply the policy to. :param pulumi.Input[Sequence[pulumi.Input[str]]] policy_names: List of Policy Names to apply to the backend server. """ ... @overload def __init__(__self__, resource_name: str, args: ListenerPolicyArgs, opts: Optional[pulumi.ResourceOptions] = None): """ Attaches a load balancer policy to an ELB Listener. ## Example Usage ### Custom Policy ```python import pulumi import pulumi_aws as aws wu_tang = aws.elb.LoadBalancer("wu-tang", availability_zones=["us-east-1a"], listeners=[aws.elb.LoadBalancerListenerArgs( instance_port=443, instance_protocol="http", lb_port=443, lb_protocol="https", ssl_certificate_id="arn:aws:iam::000000000000:server-certificate/wu-tang.net", )], tags={ "Name": "wu-tang", }) wu_tang_ssl = aws.elb.LoadBalancerPolicy("wu-tang-ssl", load_balancer_name=wu_tang.name, policy_name="wu-tang-ssl", policy_type_name="SSLNegotiationPolicyType", policy_attributes=[ aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="ECDHE-ECDSA-AES128-GCM-SHA256", value="true", ), aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="Protocol-TLSv1.2", value="true", ), ]) wu_tang_listener_policies_443 = aws.elb.ListenerPolicy("wu-tang-listener-policies-443", load_balancer_name=wu_tang.name, load_balancer_port=443, policy_names=[wu_tang_ssl.policy_name]) ``` This example shows how to customize the TLS settings of an HTTPS listener. ### AWS Predefined Security Policy ```python import pulumi import pulumi_aws as aws wu_tang = aws.elb.LoadBalancer("wu-tang", availability_zones=["us-east-1a"], listeners=[aws.elb.LoadBalancerListenerArgs( instance_port=443, instance_protocol="http", lb_port=443, lb_protocol="https", ssl_certificate_id="arn:aws:iam::000000000000:server-certificate/wu-tang.net", )], tags={ "Name": "wu-tang", }) wu_tang_ssl_tls_1_1 = aws.elb.LoadBalancerPolicy("wu-tang-ssl-tls-1-1", load_balancer_name=wu_tang.name, policy_name="wu-tang-ssl", policy_type_name="SSLNegotiationPolicyType", policy_attributes=[aws.elb.LoadBalancerPolicyPolicyAttributeArgs( name="Reference-Security-Policy", value="ELBSecurityPolicy-TLS-1-1-2017-01", )]) wu_tang_listener_policies_443 = aws.elb.ListenerPolicy("wu-tang-listener-policies-443", load_balancer_name=wu_tang.name, load_balancer_port=443, policy_names=[wu_tang_ssl_tls_1_1.policy_name]) ``` This example shows how to add a [Predefined Security Policy for ELBs](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html) :param str resource_name: The name of the resource. :param ListenerPolicyArgs args: The arguments to use to populate this resource's properties. :param pulumi.ResourceOptions opts: Options for the resource. """ ... def __init__(__self__, resource_name: str, *args, **kwargs): resource_args, opts = _utilities.get_resource_args_opts(ListenerPolicyArgs, pulumi.ResourceOptions, *args, **kwargs) if resource_args is not None: __self__._internal_init(resource_name, opts, **resource_args.__dict__) else: __self__._internal_init(resource_name, *args, **kwargs) def _internal_init(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, load_balancer_name: Optional[pulumi.Input[str]] = None, load_balancer_port: Optional[pulumi.Input[int]] = None, policy_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, __props__=None, __name__=None, __opts__=None): if __name__ is not None: warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning) resource_name = __name__ if __opts__ is not None: warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning) opts = __opts__ if opts is None: opts = pulumi.ResourceOptions() if not isinstance(opts, pulumi.ResourceOptions): raise TypeError('Expected resource options to be a ResourceOptions instance') if opts.version is None: opts.version = _utilities.get_version() if opts.id is None: if __props__ is not None: raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource') __props__ = dict() if load_balancer_name is None and not opts.urn: raise TypeError("Missing required property 'load_balancer_name'") __props__['load_balancer_name'] = load_balancer_name if load_balancer_port is None and not opts.urn: raise TypeError("Missing required property 'load_balancer_port'") __props__['load_balancer_port'] = load_balancer_port __props__['policy_names'] = policy_names alias_opts = pulumi.ResourceOptions(aliases=[pulumi.Alias(type_="aws:elasticloadbalancing/listenerPolicy:ListenerPolicy")]) opts = pulumi.ResourceOptions.merge(opts, alias_opts) super(ListenerPolicy, __self__).__init__( 'aws:elb/listenerPolicy:ListenerPolicy', resource_name, __props__, opts) @staticmethod def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions] = None, load_balancer_name: Optional[pulumi.Input[str]] = None, load_balancer_port: Optional[pulumi.Input[int]] = None, policy_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None) -> 'ListenerPolicy': """ Get an existing ListenerPolicy resource's state with the given name, id, and optional extra properties used to qualify the lookup. :param str resource_name: The unique name of the resulting resource. :param pulumi.Input[str] id: The unique provider ID of the resource to lookup. :param pulumi.ResourceOptions opts: Options for the resource. :param pulumi.Input[str] load_balancer_name: The load balancer to attach the policy to. :param pulumi.Input[int] load_balancer_port: The load balancer listener port to apply the policy to. :param pulumi.Input[Sequence[pulumi.Input[str]]] policy_names: List of Policy Names to apply to the backend server. """ opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id)) __props__ = dict() __props__["load_balancer_name"] = load_balancer_name __props__["load_balancer_port"] = load_balancer_port __props__["policy_names"] = policy_names return ListenerPolicy(resource_name, opts=opts, __props__=__props__) @property @pulumi.getter(name="loadBalancerName") def load_balancer_name(self) -> pulumi.Output[str]: """ The load balancer to attach the policy to. """ return pulumi.get(self, "load_balancer_name") @property @pulumi.getter(name="loadBalancerPort") def load_balancer_port(self) -> pulumi.Output[int]: """ The load balancer listener port to apply the policy to. """ return pulumi.get(self, "load_balancer_port") @property @pulumi.getter(name="policyNames") def policy_names(self) -> pulumi.Output[Optional[Sequence[str]]]: """ List of Policy Names to apply to the backend server. """ return pulumi.get(self, "policy_names") def translate_output_property(self, prop): return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop def translate_input_property(self, prop): return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop
42.658192
173
0.623998
4a241b813cf573ce8fe4bb80e59a334ad129a353
8,857
py
Python
pylabnet/gui/pyqt/gui_windowbuilder.py
wi11dey/pylabnet
a6e3362f727c45aaa60e61496e858ae92e85574d
[ "MIT" ]
10
2020-01-07T23:28:49.000Z
2022-02-02T19:09:17.000Z
pylabnet/gui/pyqt/gui_windowbuilder.py
wi11dey/pylabnet
a6e3362f727c45aaa60e61496e858ae92e85574d
[ "MIT" ]
249
2019-12-28T19:38:49.000Z
2022-03-28T16:45:32.000Z
pylabnet/gui/pyqt/gui_windowbuilder.py
wi11dey/pylabnet
a6e3362f727c45aaa60e61496e858ae92e85574d
[ "MIT" ]
5
2020-11-17T19:45:10.000Z
2022-01-04T18:07:04.000Z
import sys from PyQt5 import QtCore, QtWidgets, QtGui import qdarkstyle from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget, QHBoxLayout from pylabnet.utils.helper_methods import load_script_config from pylabnet.network.core.client_base import ClientBase class GUIWindowFromConfig(QMainWindow): def __init__(self, config=None, host=None, port=None, staticlines=None): QMainWindow.__init__(self) self.config = load_script_config('staticline', config, logger=None) self.N_staticlines = len(self.config['lines']) self.widgets = dict() self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) #self.setMinimumSize(QSize(640, 480)) self.setWindowTitle("Staticline window") self.centralWidget = QWidget(self) self.setCentralWidget(self.centralWidget) self.gridLayout = QGridLayout(self) self.centralWidget.setLayout(self.gridLayout) self.blockgridLayout = [] # Add IP info self.host = host self.port = port self.blockgridLayout.append(QHBoxLayout(self)) self.gridLayout.addLayout(self.blockgridLayout[0], 0, 1) self.ip_label = QtWidgets.QLabel(f"IP Address: {host}") self.port_label = QtWidgets.QLabel(f"Port: {port}") self.blockgridLayout[0].addWidget(self.ip_label) self.blockgridLayout[0].addWidget(self.port_label) self.staticlines = staticlines self.unpack_config_file() def closeEvent(self, event): """ Occurs when window is closed. Overwrites parent class method""" try: close_client = ClientBase( host=self.host, port=self.port ) close_client.close_server() except: self.close() def unpack_config_file(self): block_num = 1 for device_name, device in self.config['lines'].items(): # Ignore non-device configs if type(device) != dict: continue #Device wasn't found, so don't add to GUI #Not a huge fan of this implementation, but its good enough for now if (self.staticlines != None and not device_name in self.staticlines): continue # Label for the device name label = QtWidgets.QLabel(" " + device_name + " ", self) label.setStyleSheet("color: white; background-color: #32414B; border-radius: 4px;") #label.setStyleSheet("border: 0.5px solid white; ") self.gridLayout.addWidget(label, block_num, 0) self.blockgridLayout.append(QGridLayout(self)) self.gridLayout.addLayout(self.blockgridLayout[block_num], block_num, 1) self.widgets[device_name] = dict() row_num = 0 # TODO: Check that staticline_types and staticline_names have same lengths # Iterate over all staticlines for the current device for staticline_idx, staticline_name in enumerate(device["staticline_names"]): staticline_type = device["staticline_configs"][staticline_idx]["type"] # Label for the staticline name label = QtWidgets.QLabel(staticline_name, self) label.setStyleSheet("color: white;") self.blockgridLayout[block_num].addWidget(label, row_num, 0) # Create the appropriate buttons for that device if staticline_type == "digital": self.widgets[device_name][staticline_name] = dict() self.make_digital_row(position=[block_num, row_num], device_name=device_name, staticline_name=staticline_name) elif staticline_type == "analog": self.widgets[device_name][staticline_name] = dict() self.make_analog_row(position=[block_num, row_num], device_name=device_name, staticline_name=staticline_name) elif staticline_type == "adjustable_digital": self.widgets[device_name][staticline_name + "_analog"] = dict() self.widgets[device_name][staticline_name + "_digital"] = dict() self.make_adjustable_digital_row(position=[block_num, row_num], device_name=device_name, staticline_name=staticline_name) row_num += 1 # Advance by 1 here so that overall it will advance by 2 else: continue # TODO: Print error message? row_num += 1 block_num += 1 def make_digital_row(self, position=[0, 0], device_name='', staticline_name=''): on_button = QtWidgets.QPushButton('I', self) on_button.setStyleSheet("color: black; background-color: #C1C1C1") on_button.setFont(QtGui.QFont("Arial", weight=QtGui.QFont.Bold)) self.widgets[device_name][staticline_name]["on"] = on_button self.blockgridLayout[position[0]].addWidget(on_button, position[1], 2) off_button = QtWidgets.QPushButton('O', self) off_button.setStyleSheet("color: white; background-color: #FF4040") off_button.setFont(QtGui.QFont("Arial", weight=QtGui.QFont.Bold)) self.widgets[device_name][staticline_name]["off"] = off_button self.blockgridLayout[position[0]].addWidget(off_button, position[1], 3) # enable/disable buttons depending on which one has last been clicked self.widgets[device_name][staticline_name]["on"].clicked.connect(lambda: self.enable_buttons(device_name=device_name, staticline_name=staticline_name, mode=True)) self.widgets[device_name][staticline_name]["off"].clicked.connect(lambda: self.enable_buttons(device_name=device_name, staticline_name=staticline_name, mode=False)) # Initially set the off button as disabled (since initially the staticline is off) self.widgets[device_name][staticline_name]["off"].setEnabled(False) def make_analog_row(self, position=[0, 0], device_name='', staticline_name=''): ain_field = QtWidgets.QLineEdit('0.000', self) ain_field.setStyleSheet("color: white; background-color: black") self.widgets[device_name][staticline_name]["AIN"] = ain_field self.blockgridLayout[position[0]].addWidget(ain_field, position[1], 1) apply_button = QtWidgets.QPushButton('Apply', self) apply_button.setStyleSheet("color: black; background-color: #AAD3E9") self.widgets[device_name][staticline_name]["apply"] = apply_button self.blockgridLayout[position[0]].addWidget(apply_button, position[1], 2) label = QtWidgets.QLabel("Current value: 0.00", self) label.setStyleSheet("color: white;") label.setMinimumSize(QtCore.QSize(200, 0)) self.widgets[device_name][staticline_name]["current_val"] = label self.blockgridLayout[position[0]].addWidget(label, position[1], 4) self.widgets[device_name][staticline_name]["apply"].clicked.connect(lambda: self.upd_cur_val(device_name=device_name, staticline_name=staticline_name)) def make_adjustable_digital_row(self, position=[0, 0], device_name='', staticline_name=''): block_num, row_num = position self.make_analog_row([block_num, row_num], device_name, staticline_name + "_analog") self.make_digital_row([block_num, row_num + 1], device_name, staticline_name + "_digital") def enable_buttons(self, device_name='', staticline_name='', mode=True): self.widgets[device_name][staticline_name]["off"].setEnabled(mode) self.widgets[device_name][staticline_name]["on"].setEnabled(not mode) if mode: self.widgets[device_name][staticline_name]["on"].setStyleSheet( "color: white; background-color: #3CD070") self.widgets[device_name][staticline_name]["off"].setStyleSheet( "color: black; background-color: #C1C1C1") else: self.widgets[device_name][staticline_name]["on"].setStyleSheet( "color: black; background-color: #C1C1C1") self.widgets[device_name][staticline_name]["off"].setStyleSheet( "color: white; background-color: #FF4040") def upd_cur_val(self, device_name='', staticline_name=''): self.widgets[device_name][staticline_name]["current_val"].setText( "Current value: " + self.widgets[device_name][staticline_name]["AIN"].text() ) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) mainWin = GUIWindowFromConfig(config='test_config_sl') mainWin.show() sys.exit(app.exec_())
47.363636
164
0.643446
4a241f279ad7c12fbea960db94bdfa55c229f948
3,772
py
Python
semanticmapping/networks/gridcells.py
nsdumont/SemanticMapping
af97a452b3de30a9670536c7fa92c28a70fae44d
[ "MIT" ]
null
null
null
semanticmapping/networks/gridcells.py
nsdumont/SemanticMapping
af97a452b3de30a9670536c7fa92c28a70fae44d
[ "MIT" ]
null
null
null
semanticmapping/networks/gridcells.py
nsdumont/SemanticMapping
af97a452b3de30a9670536c7fa92c28a70fae44d
[ "MIT" ]
null
null
null
import nengo import numpy as np def GridCellEncoders(n_G, ssp_space): def fractional_bind(basis, position): return np.fft.ifft(np.prod(np.fft.fft(basis, axis=0)**position, axis=1), axis=0) d = ssp_space.ssp_dim N = ssp_space.num_grids sub_dim=ssp_space.grid_basis_dim G_pos = np.random.uniform(low = ssp_space.domain_bounds[:,0], high = ssp_space.domain_bounds[:,1], size=(n_G,ssp_space.domain_dim)) # G_sorts records which 'sub-grid' each encoder is 'picking out' # We'll do at least one of each sub-grid. This can be changed if N < n_G: G_sorts = np.hstack([np.arange(N), np.random.randint(0, N - 1, size = n_G - N)]) else: G_sorts = np.arange(n_G) G_encoders = np.zeros((n_G,d)) for i in range(n_G): sub_mat = _get_sub_SSP(G_sorts[i],N,sublen=sub_dim) proj_mat = _proj_sub_SSP(G_sorts[i],N,sublen=sub_dim) basis_i = sub_mat @ ssp_space.axis_matrix G_encoders[i,:] = N * proj_mat @ fractional_bind(basis_i, G_pos[i,:]) return G_encoders, G_sorts class SSPNetwork(nengo.network.Network): def __init__(self, ssp_space, n_neurons, **kwargs): super().__init__() d = ssp_space.ssp_dim G_encoders, _ = GridCellEncoders(n_neurons, ssp_space) with self: self.input = nengo.Node(size_in=d) self.ssp = nengo.Ensemble(n_neurons, d, encoders=G_encoders,**kwargs) nengo.Connection(self.input, self.ssp) # Helper funstions def _get_sub_FourierSSP(n, N, sublen=3): # Return a matrix, \bar{A}_n # Consider the multi scale representation (S_{total}) and sub vectors (S_n) described in the paper # Then # \bar{A}_n F{S_{total}} = F{S_n} # i.e. pick out the sub vector in the Fourier domain tot_len = 2*sublen*N + 1 FA = np.zeros((2*sublen + 1, tot_len)) FA[0:sublen, sublen*n:sublen*(n+1)] = np.eye(sublen) FA[sublen, sublen*N] = 1 FA[sublen+1:, tot_len - np.arange(sublen*(n+1),sublen*n,-1)] = np.eye(sublen) return FA def _get_sub_SSP(n,N,sublen=3): # Return a matrix, A_n # Consider the multi scale representation (S_{total}) and sub vectors (S_n) described in the paper # Then # A_n S_{total} = S_n # i.e. pick out the sub vector in the time domain tot_len = 2*sublen*N + 1 FA = _get_sub_FourierSSP(n,N,sublen=sublen) W = np.fft.fft(np.eye(tot_len)) invW = np.fft.ifft(np.eye(2*sublen + 1)) A = invW @ np.fft.ifftshift(FA) @ W return A.real def _proj_sub_FourierSSP(n,N,sublen=3): # Return a matrix, \bar{B}_n # Consider the multi scale representation (S_{total}) and sub vectors (S_n) described in the paper # Then # \sum_n \bar{B}_n F{S_{n}} = F{S_{total}} # i.e. project the sub vector in the Fourier domain such that summing all such projections gives the full vector in Fourier domain tot_len = 2*sublen*N + 1 FB = np.zeros((2*sublen + 1, tot_len)) FB[0:sublen, sublen*n:sublen*(n+1)] = np.eye(sublen) FB[sublen, sublen*N] = 1/N # all sub vectors have a "1" zero freq term so scale it so full vector will have 1 FB[sublen+1:, tot_len - np.arange(sublen*(n+1),sublen*n,-1)] = np.eye(sublen) return FB.T def _proj_sub_SSP(n,N,sublen=3): # Return a matrix, B_n # Consider the multi scale representation (S_{total}) and sub vectors (S_n) described in the paper # Then # \sum_n B_n S_{n} = S_{total} # i.e. project the sub vector in the time domain such that summing all such projections gives the full vector tot_len = 2*sublen*N + 1 FB = _proj_sub_FourierSSP(n,N,sublen=sublen) invW = np.fft.ifft(np.eye(tot_len)) W = np.fft.fft(np.eye(2*sublen + 1)) B = invW @ np.fft.ifftshift(FB) @ W return B.real
42.382022
135
0.651909
4a241f3056882e0514d55dff241f6d58a3dfa212
335
py
Python
src/main/smarthooks/worker.py
eightnoteight/smarthooks
0496a2420f48f78a1ca3c0ab2f52d8c5551b4872
[ "MIT" ]
null
null
null
src/main/smarthooks/worker.py
eightnoteight/smarthooks
0496a2420f48f78a1ca3c0ab2f52d8c5551b4872
[ "MIT" ]
1
2021-06-01T21:53:08.000Z
2021-06-01T21:53:08.000Z
src/main/smarthooks/worker.py
eightnoteight/smarthooks
0496a2420f48f78a1ca3c0ab2f52d8c5551b4872
[ "MIT" ]
null
null
null
import celery import os app = celery.Celery('smarthooks', broker=os.environ['REDIS_URL'], include=['smarthooks.geeksforgeeksbot.worker']) # note: if results are to be stored # app.conf.update(BROKER_URL=os.environ['REDIS_URL'], # CELERY_RESULT_BACKEND=os.environ['REDIS_URL'])
30.454545
67
0.638806
4a24209a790e10703e22ef85a82e7cfe2185247b
395
py
Python
cogs/status_tracker.py
danya02/discord-logbot
a02cd660124319d3f7474fa90a8e4d0932555809
[ "MIT" ]
null
null
null
cogs/status_tracker.py
danya02/discord-logbot
a02cd660124319d3f7474fa90a8e4d0932555809
[ "MIT" ]
null
null
null
cogs/status_tracker.py
danya02/discord-logbot
a02cd660124319d3f7474fa90a8e4d0932555809
[ "MIT" ]
null
null
null
from database import BotReadyTimeSeries from discord.ext import commands, tasks from .common import * INTERVAL = 10 class StatusTracker(commands.Cog): def __init__(self, bot): self.bot = bot self.check_loop.start() @tasks.loop(seconds=INTERVAL) async def check_loop(self): await asyncify( BotReadyTimeSeries.record_status, self.bot.is_ready(), INTERVAL )
24.6875
89
0.718987
4a2420dd5e94122d4ab348b39d921b43570f7b69
8,282
py
Python
helper.py
blockchainhelppro/Neon-Core-Code-Update
459aeed16a833b53222a8a6d47e9ae8c2c4a3373
[ "MIT" ]
null
null
null
helper.py
blockchainhelppro/Neon-Core-Code-Update
459aeed16a833b53222a8a6d47e9ae8c2c4a3373
[ "MIT" ]
null
null
null
helper.py
blockchainhelppro/Neon-Core-Code-Update
459aeed16a833b53222a8a6d47e9ae8c2c4a3373
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- # # Copyright (C) 2011-2016 Red Hat, Inc. # # Authors: # Thomas Woerner <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # __all__ = [ "Helper", "helper_reader", "helper_writer" ] import xml.sax as sax import os import io import shutil from firewall import config from firewall.functions import u2b_if_py2 from firewall.core.io.io_object import PY2, IO_Object, \ IO_Object_ContentHandler, IO_Object_XMLGenerator, check_port, \ check_tcpudp from firewall.core.logger import log from firewall import errors from firewall.errors import FirewallError class Helper(IO_Object): IMPORT_EXPORT_STRUCTURE = ( ( "version", "" ), # s ( "short", "" ), # s ( "description", "" ), # s ( "family", "", ), # s ( "module", "", ), # s ( "ports", [ ( "", "" ), ], ), # a(ss) ) DBUS_SIGNATURE = '(sssssa(ss))' ADDITIONAL_ALNUM_CHARS = [ "-", "." ] PARSER_REQUIRED_ELEMENT_ATTRS = { "short": None, "description": None, "helper": [ "module" ], } PARSER_OPTIONAL_ELEMENT_ATTRS = { "helper": [ "name", "version", "family" ], "port": [ "port", "protocol" ], } def __init__(self): super(Helper, self).__init__() self.version = "" self.short = "" self.description = "" self.module = "" self.family = "" self.ports = [ ] def cleanup(self): self.version = "" self.short = "" self.description = "" self.module = "" self.family = "" del self.ports[:] def encode_strings(self): """ HACK. I haven't been able to make sax parser return strings encoded (because of python 2) instead of in unicode. Get rid of it once we throw out python 2 support.""" self.version = u2b_if_py2(self.version) self.short = u2b_if_py2(self.short) self.description = u2b_if_py2(self.description) self.module = u2b_if_py2(self.module) self.family = u2b_if_py2(self.family) self.ports = [(u2b_if_py2(po),u2b_if_py2(pr)) for (po,pr) in self.ports] def check_ipv(self, ipv): ipvs = [ 'ipv4', 'ipv6' ] if ipv not in ipvs: raise FirewallError(errors.INVALID_IPV, "'%s' not in '%s'" % (ipv, ipvs)) def _check_config(self, config, item): if item == "ports": for port in config: check_port(port[0]) check_tcpudp(port[1]) elif item == "module": if not config.startswith("nf_conntrack_"): raise FirewallError( errors.INVALID_MODULE, "'%s' does not start with 'nf_conntrack_'" % config) if len(config.replace("nf_conntrack_", "")) < 1: raise FirewallError(errors.INVALID_MODULE, "Module name '%s' too short" % config) # PARSER class helper_ContentHandler(IO_Object_ContentHandler): def startElement(self, name, attrs): IO_Object_ContentHandler.startElement(self, name, attrs) self.item.parser_check_element_attrs(name, attrs) if name == "helper": if "version" in attrs: self.item.version = attrs["version"] if "family" in attrs: self.item.check_ipv(attrs["family"]) self.item.family = attrs["family"] if "module" in attrs: if not attrs["module"].startswith("nf_conntrack_"): raise FirewallError( errors.INVALID_MODULE, "'%s' does not start with 'nf_conntrack_'" % \ attrs["module"]) if len(attrs["module"].replace("nf_conntrack_", "")) < 1: raise FirewallError( errors.INVALID_MODULE, "Module name '%s' too short" % attrs["module"]) self.item.module = attrs["module"] elif name == "short": pass elif name == "description": pass elif name == "port": check_port(attrs["port"]) check_tcpudp(attrs["protocol"]) entry = (attrs["port"], attrs["protocol"]) if entry not in self.item.ports: self.item.ports.append(entry) else: log.warning("Port '%s/%s' already set, ignoring.", attrs["port"], attrs["protocol"]) def helper_reader(filename, path): helper = Helper() if not filename.endswith(".xml"): raise FirewallError(errors.INVALID_NAME, "'%s' is missing .xml suffix" % filename) helper.name = filename[:-4] helper.check_name(helper.name) helper.filename = filename helper.path = path helper.builtin = False if path.startswith(config.ETC_FIREWALLD) else True helper.default = helper.builtin handler = helper_ContentHandler(helper) parser = sax.make_parser() parser.setContentHandler(handler) name = "%s/%s" % (path, filename) with open(name, "r") as f: try: parser.parse(f) except sax.SAXParseException as msg: raise FirewallError(errors.INVALID_HELPER, "not a valid helper file: %s" % \ msg.getException()) del handler del parser if PY2: helper.encode_strings() return helper def helper_writer(helper, path=None): _path = path if path else helper.path if helper.filename: name = "%s/%s" % (_path, helper.filename) else: name = "%s/%s.xml" % (_path, helper.name) if os.path.exists(name): try: shutil.copy2(name, "%s.old" % name) except Exception as msg: log.error("Backup of file '%s' failed: %s", name, msg) dirpath = os.path.dirname(name) if dirpath.startswith(config.ETC_FIREWALLD) and not os.path.exists(dirpath): if not os.path.exists(config.ETC_FIREWALLD): os.mkdir(config.ETC_FIREWALLD, 0o750) os.mkdir(dirpath, 0o750) f = io.open(name, mode='wt', encoding='UTF-8') handler = IO_Object_XMLGenerator(f) handler.startDocument() # start helper element attrs = {} attrs["module"] = helper.module if helper.version and helper.version != "": attrs["version"] = helper.version if helper.family and helper.family != "": attrs["family"] = helper.family handler.startElement("helper", attrs) handler.ignorableWhitespace("\n") # short if helper.short and helper.short != "": handler.ignorableWhitespace(" ") handler.startElement("short", { }) handler.characters(helper.short) handler.endElement("short") handler.ignorableWhitespace("\n") # description if helper.description and helper.description != "": handler.ignorableWhitespace(" ") handler.startElement("description", { }) handler.characters(helper.description) handler.endElement("description") handler.ignorableWhitespace("\n") # ports for port in helper.ports: handler.ignorableWhitespace(" ") handler.simpleElement("port", { "port": port[0], "protocol": port[1] }) handler.ignorableWhitespace("\n") # end helper element handler.endElement('helper') handler.ignorableWhitespace("\n") handler.endDocument() f.close() del handler
35.393162
80
0.575706
4a24210d36ebd26ac7195e218dc06191634a5aa2
3,571
py
Python
harvest-cloud/scripts/BW_PGS/calculate_GRS.py
PerinatalLab/metaGWAS
ba5de9bc8440685bb2bfa159d85a4beee3fe3ed3
[ "MIT" ]
1
2022-03-07T20:32:08.000Z
2022-03-07T20:32:08.000Z
harvest-cloud/scripts/MR_repr_phenos/calculate_GRS.py
PerinatalLab/metaGWAS
ba5de9bc8440685bb2bfa159d85a4beee3fe3ed3
[ "MIT" ]
null
null
null
harvest-cloud/scripts/MR_repr_phenos/calculate_GRS.py
PerinatalLab/metaGWAS
ba5de9bc8440685bb2bfa159d85a4beee3fe3ed3
[ "MIT" ]
null
null
null
import pandas as pd import numpy as np def remove_palindromic(d, REF, EFF): return(d.loc[~(((d[REF]== 'T') & (d[EFF]== 'A')) | ((d[REF]== 'A') & (d[EFF]== 'T')) | ((d[REF]== 'C') & (d[EFF]== 'G')) | ((d[REF]== 'G') & (d[EFF]== 'C'))), :]) def flip_alleles(x): x= x.str.upper() x= x.str.replace('C', 'g') x= x.str.replace('G', 'c') x= x.str.replace('T', 'a') x= x.str.replace('A', 't') return(x.str.upper()) def harmonize_alleles(d, REF_x, EFF_x, REF_y, EFF_y): # d= remove_palindromic(d, REF_x, EFF_x) # d= remove_palindromic(d, REF_y, EFF_y) d['beta']= np.where((d[EFF_y]== d[EFF_x]) & (d[REF_y] == d[REF_x]), d.beta, np.where((d[EFF_y]== d[REF_x]) & (d[REF_y]== d[EFF_x]), -1 * d.beta, np.where((flip_alleles(d[EFF_y])== d[EFF_x]) & (flip_alleles(d[REF_y])== d[REF_x]), d.beta, np.where((flip_alleles(d[EFF_y])== d[REF_x]) & (flip_alleles(d[REF_y]) == d[EFF_x]), -1 * d.beta, np.nan)))) d= d.loc[~(d.beta.isnull()), :] d[EFF_y]= np.where((d[EFF_y]== d[EFF_x]) & (d[REF_y]== d[REF_x]), d[EFF_x], np.where((d[EFF_y]== d[REF_x]) & (d[REF_y] == d[EFF_x]), d[REF_x], np.where((flip_alleles(d[EFF_y])== d[EFF_x]) & (flip_alleles(d[REF_y])== d[REF_x]), d[EFF_x], np.where((flip_alleles(d[EFF_y])== d[REF_x]) & (flip_alleles(d[REF_y]) == d[EFF_x]), d[REF_x], np.nan)))) d[REF_y]= np.where((d[EFF_y]== d[EFF_x]) & (d[REF_y]== d[REF_x]), d[REF_x], np.where((d[EFF_y]== d[REF_x]) & (d[REF_y]== d[EFF_x]), d[EFF_x], np.where((flip_alleles(d[EFF_y])== d[EFF_x]) & (flip_alleles(d[REF_y])== d[REF_x]), d[REF_x], np.where((flip_alleles(d[EFF_y])== d[REF_x]) & (flip_alleles(d[REF_y]) == d[EFF_x]), d[EFF_x], np.nan)))) return(d) def calculate_PGS(d, ID): d.drop_duplicates(['chr', 'pos'], keep=False, inplace= True) d['chr']= d.chr.apply(str) d= pd.merge(betas, d, on= ['chr', 'pos']) d= harmonize_alleles(d, 'ref', 'eff', 'REF', 'EFF') d.drop_duplicates(['chr', 'pos'], keep=False, inplace= True) betas_v= np.array(d.beta) d.drop(['ref', 'eff', 'pos', 'chr', 'EFF', 'REF', 'beta'], axis= 1, inplace= True) ids= d.columns d= pd.DataFrame(np.array(d) * betas_v.reshape(-1, 1), columns= ids) d= pd.DataFrame(d.sum(axis= 0)) d[ID]= d.index return d # Read data if 'haplotype' not in snakemake.input[0]: cols= ['chr','pos','ref','eff'] + [line.strip() for line in open(snakemake.input[0], 'r')] betas= pd.read_csv(snakemake.input[2], sep= '\t', header= 0) betas['chr']= betas['chr'].apply(str) df_list= list() for d in pd.read_csv(snakemake.input[1], header= None, names= cols, sep= '\t', chunksize= 600): d= calculate_PGS(d, 'IID') df_list.append(d) d= pd.concat(df_list) else: betas= pd.read_csv(snakemake.input[1], sep= '\t', header= 0) betas['chr']= betas['chr'].apply(str) df_list= list() for d in pd.read_csv(snakemake.input[0], header= 0, sep= '\t', chunksize= 600): d= calculate_PGS(d, 'PREG_ID') df_list.append(d) d= pd.concat(df_list) if 'haplotype' in snakemake.input[0]: d= d.groupby('PREG_ID').sum().reset_index() d.columns= ['PREG_ID', snakemake.wildcards.haplo] else: d= d.groupby('IID').sum().reset_index() d.columns.values[0]= snakemake.wildcards.sample + '_' + snakemake.wildcards.repr_trait + '_PGS' d.to_csv(snakemake.output[0], sep ='\t', header= True, index= False)
52.514706
353
0.557267
4a242172502e3e82267f6db9a3aabcf63826e93e
6,987
py
Python
src/quart/testing/utils.py
pgjones/quart
68a5bc4e98a07d903e7bfe148c1b7faa260f4334
[ "MIT" ]
1,085
2017-11-12T10:56:50.000Z
2022-03-31T15:14:26.000Z
src/quart/testing/utils.py
pgjones/quart
68a5bc4e98a07d903e7bfe148c1b7faa260f4334
[ "MIT" ]
139
2017-12-04T09:22:48.000Z
2022-03-26T08:34:07.000Z
src/quart/testing/utils.py
pgjones/quart
68a5bc4e98a07d903e7bfe148c1b7faa260f4334
[ "MIT" ]
92
2017-12-08T09:55:02.000Z
2022-03-29T20:45:44.000Z
from __future__ import annotations from typing import Any, AnyStr, cast, Dict, Optional, overload, Tuple, TYPE_CHECKING, Union from urllib.parse import unquote, urlencode from hypercorn.typing import HTTPScope, Scope, WebsocketScope from werkzeug.datastructures import Authorization, Headers from werkzeug.sansio.multipart import Data, Epilogue, Field, File, MultipartEncoder, Preamble from werkzeug.urls import iri_to_uri from ..datastructures import FileStorage from ..json import dumps from ..utils import encode_headers if TYPE_CHECKING: from ..app import Quart # noqa try: from typing import Literal except ImportError: from typing_extensions import Literal # type: ignore sentinel = object() def make_test_headers_path_and_query_string( app: "Quart", path: str, headers: Optional[Union[dict, Headers]] = None, query_string: Optional[dict] = None, auth: Optional[Union[Authorization, Tuple[str, str]]] = None, ) -> Tuple[Headers, str, bytes]: """Make the headers and path with defaults for testing. Arguments: app: The application to test against. path: The path to request. If the query_string argument is not defined this argument will be partitioned on a '?' with the following part being considered the query_string. headers: Initial headers to send. query_string: To send as a dictionary, alternatively the query_string can be determined from the path. """ if headers is None: headers = Headers() elif isinstance(headers, Headers): headers = headers elif headers is not None: headers = Headers(headers) if auth is not None: if isinstance(auth, tuple): auth = Authorization("basic", {"username": auth[0], "password": auth[1]}) headers.setdefault("Authorization", auth.to_header()) headers.setdefault("User-Agent", "Quart") headers.setdefault("host", app.config["SERVER_NAME"] or "localhost") if "?" in path and query_string is not None: raise ValueError("Query string is defined in the path and as an argument") if query_string is None: path, _, query_string_raw = path.partition("?") else: query_string_raw = urlencode(query_string, doseq=True) query_string_bytes = query_string_raw.encode("ascii") return headers, unquote(path), query_string_bytes def make_test_body_with_headers( *, data: Optional[AnyStr] = None, form: Optional[dict] = None, files: Optional[Dict[str, FileStorage]] = None, json: Any = sentinel, app: Optional["Quart"] = None, ) -> Tuple[bytes, Headers]: """Make the body bytes with associated headers. Arguments: data: Raw data to send in the request body. form: Key value paired data to send form encoded in the request body. files: Key FileStorage paired data to send as file encoded in the request body. json: Data to send json encoded in the request body. """ if [json is not sentinel, form is not None, data is not None].count(True) > 1: raise ValueError("Quart test args 'json', 'form', and 'data' are mutually exclusive") if [json is not sentinel, files is not None, data is not None].count(True) > 1: raise ValueError("Quart test args 'files', 'json', and 'data' are mutually exclusive") request_data = b"" headers = Headers() if isinstance(data, str): request_data = data.encode("utf-8") elif isinstance(data, bytes): request_data = data if json is not sentinel: request_data = dumps(json, app=app).encode("utf-8") headers["Content-Type"] = "application/json" elif files is not None: boundary = "----QuartBoundary" headers["Content-Type"] = f"multipart/form-data; boundary={boundary}" encoder = MultipartEncoder(boundary.encode()) request_data += encoder.send_event(Preamble(data=b"")) for key, file_storage in files.items(): request_data += encoder.send_event( File(name=key, filename=file_storage.filename, headers=file_storage.headers) ) chunk = file_storage.read(16384) while chunk != b"": request_data += encoder.send_event(Data(data=chunk, more_data=True)) chunk = file_storage.read(16384) request_data += encoder.send_event(Data(data=b"", more_data=False)) if form is not None: for key, value in form.items(): request_data += encoder.send_event(Field(name=key, headers=Headers())) request_data += encoder.send_event( Data(data=value.encode("utf-8"), more_data=False) ) request_data += encoder.send_event(Epilogue(data=b"")) elif form is not None: request_data = urlencode(form).encode("utf-8") headers["Content-Type"] = "application/x-www-form-urlencoded" return request_data, headers @overload def make_test_scope( type_: Literal["http"], path: str, method: str, headers: Headers, query_string: bytes, scheme: str, root_path: str, http_version: str, scope_base: Optional[dict], *, _preserve_context: bool = False, ) -> HTTPScope: ... @overload def make_test_scope( type_: Literal["websocket"], path: str, method: str, headers: Headers, query_string: bytes, scheme: str, root_path: str, http_version: str, scope_base: Optional[dict], *, _preserve_context: bool = False, ) -> WebsocketScope: ... def make_test_scope( type_: str, path: str, method: str, headers: Headers, query_string: bytes, scheme: str, root_path: str, http_version: str, scope_base: Optional[dict], *, _preserve_context: bool = False, ) -> Scope: scope = { "type": type_, "http_version": http_version, "asgi": {"spec_version": "2.1"}, "method": method, "scheme": scheme, "path": path, "raw_path": iri_to_uri(path).encode("ascii"), "query_string": query_string, "root_path": root_path, "headers": encode_headers(headers), "extensions": {}, "_quart._preserve_context": _preserve_context, } if scope_base is not None: scope.update(scope_base) if type_ == "http" and http_version in {"2", "3"}: scope["extensions"] = {"http.response.push": {}} elif type_ == "websocket": scope["extensions"] = {"websocket.http.response": {}} return cast(Scope, scope) async def no_op_push(path: str, headers: Headers) -> None: """A push promise sender that does nothing. This is best used when creating Request instances for testing outside of the QuartClient. The Request instance must know what to do with push promises, and this gives it the option of doing nothing. """ pass
33.113744
94
0.646629
4a2421cda7328b4f55ea24d020652e927f856f11
625
py
Python
examples/test_cmult.py
daniil-lyakhov/QArithmetic
7a5df9504e17c1979107c119bbaf0c5b2750a619
[ "Apache-2.0" ]
34
2019-03-01T02:45:45.000Z
2022-02-21T22:10:55.000Z
examples/test_cmult.py
supersimple33/QArithmetic
0925f87f8d86922e9cfc3826b98b1c64c95cbf5f
[ "Apache-2.0" ]
3
2019-12-22T09:34:00.000Z
2021-09-20T15:14:56.000Z
examples/test_cmult.py
supersimple33/QArithmetic
0925f87f8d86922e9cfc3826b98b1c64c95cbf5f
[ "Apache-2.0" ]
9
2019-04-02T14:30:54.000Z
2022-02-09T16:55:59.000Z
# Import the Qiskit SDK from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qiskit import execute, Aer from QArithmetic import cmult # Input N N = 3 c = QuantumRegister(1) a = QuantumRegister(N) b = QuantumRegister(N) m = QuantumRegister(2*N) cm = ClassicalRegister(2*N) qc = QuantumCircuit(c, a, b, m, cm) # Input # a = 010 = 2 qc.x(a[1]) # b = 011 = 3 qc.x(b[0]) qc.x(b[1]) qc.x(c)# turns operation on cmult(qc, c, a, b, m, N) qc.measure(m, cm) backend_sim = Aer.get_backend('qasm_simulator') job_sim = execute(qc, backend_sim) result_sim = job_sim.result() print(result_sim.get_counts(qc))
17.857143
69
0.7072
4a24225cbcb4b6f58a0db5912f5f67ec86df5fc2
21,953
py
Python
src/natcap/invest/carbon.py
hkotaro1215/invest
1ba08bd746977bfa8a4600ad8c821fc43598c421
[ "BSD-3-Clause" ]
null
null
null
src/natcap/invest/carbon.py
hkotaro1215/invest
1ba08bd746977bfa8a4600ad8c821fc43598c421
[ "BSD-3-Clause" ]
null
null
null
src/natcap/invest/carbon.py
hkotaro1215/invest
1ba08bd746977bfa8a4600ad8c821fc43598c421
[ "BSD-3-Clause" ]
null
null
null
"""Carbon Storage and Sequestration.""" from __future__ import absolute_import import collections import logging import os import time from osgeo import gdal from osgeo import ogr import numpy import natcap.invest.pygeoprocessing_0_3_3 from . import validation from . import utils LOGGER = logging.getLogger('natcap.invest.carbon') _OUTPUT_BASE_FILES = { 'tot_c_cur': 'tot_c_cur.tif', 'tot_c_fut': 'tot_c_fut.tif', 'tot_c_redd': 'tot_c_redd.tif', 'delta_cur_fut': 'delta_cur_fut.tif', 'delta_cur_redd': 'delta_cur_redd.tif', 'npv_fut': 'npv_fut.tif', 'npv_redd': 'npv_redd.tif', 'html_report': 'report.html', } _INTERMEDIATE_BASE_FILES = { 'c_above_cur': 'c_above_cur.tif', 'c_below_cur': 'c_below_cur.tif', 'c_soil_cur': 'c_soil_cur.tif', 'c_dead_cur': 'c_dead_cur.tif', 'c_above_fut': 'c_above_fut.tif', 'c_below_fut': 'c_below_fut.tif', 'c_soil_fut': 'c_soil_fut.tif', 'c_dead_fut': 'c_dead_fut.tif', 'c_above_redd': 'c_above_redd.tif', 'c_below_redd': 'c_below_redd.tif', 'c_soil_redd': 'c_soil_redd.tif', 'c_dead_redd': 'c_dead_redd.tif', } _TMP_BASE_FILES = { 'aligned_lulc_cur_path': 'aligned_lulc_cur.tif', 'aligned_lulc_fut_path': 'aligned_lulc_fut.tif', 'aligned_lulc_redd_path': 'aligned_lulc_redd.tif', } # -1.0 since carbon stocks are 0 or greater _CARBON_NODATA = -1.0 # use min float32 which is unlikely value to see in a NPV raster _VALUE_NODATA = numpy.finfo(numpy.float32).min def execute(args): """InVEST Carbon Model. Calculate the amount of carbon stocks given a landscape, or the difference due to a future change, and/or the tradeoffs between that and a REDD scenario, and calculate economic valuation on those scenarios. The model can operate on a single scenario, a combined present and future scenario, as well as an additional REDD scenario. Parameters: args['workspace_dir'] (string): a path to the directory that will write output and other temporary files during calculation. args['results_suffix'] (string): appended to any output file name. args['lulc_cur_path'] (string): a path to a raster representing the current carbon stocks. args['calc_sequestration'] (bool): if true, sequestration should be calculated and 'lulc_fut_path' and 'do_redd' should be defined. args['lulc_fut_path'] (string): a path to a raster representing future landcover scenario. Optional, but if present and well defined will trigger a sequestration calculation. args['do_redd'] ( bool): if true, REDD analysis should be calculated and 'lulc_redd_path' should be defined args['lulc_redd_path'] (string): a path to a raster representing the alternative REDD scenario which is only possible if the args['lulc_fut_path'] is present and well defined. args['carbon_pools_path'] (string): path to CSV or that indexes carbon storage density to lulc codes. (required if 'do_uncertainty' is false) args['lulc_cur_year'] (int/string): an integer representing the year of `args['lulc_cur_path']` used if `args['calc_sequestration']` is True. args['lulc_fut_year'](int/string): an integer representing the year of `args['lulc_fut_path']` used in valuation if it exists. Required if `args['do_valuation']` is True and `args['lulc_fut_path']` is present and well defined. args['do_valuation'] (bool): if true then run the valuation model on available outputs. At a minimum will run on carbon stocks, if sequestration with a future scenario is done and/or a REDD scenario calculate NPV for either and report in final HTML document. args['price_per_metric_ton_of_c'] (float): Is the present value of carbon per metric ton. Used if `args['do_valuation']` is present and True. args['discount_rate'] (float): Discount rate used if NPV calculations are required. Used if `args['do_valuation']` is present and True. args['rate_change'] (float): Annual rate of change in price of carbon as a percentage. Used if `args['do_valuation']` is present and True. Returns: None. """ file_suffix = utils.make_suffix_string(args, 'results_suffix') intermediate_output_dir = os.path.join( args['workspace_dir'], 'intermediate_outputs') output_dir = args['workspace_dir'] natcap.invest.pygeoprocessing_0_3_3.create_directories([intermediate_output_dir, output_dir]) LOGGER.info('Building file registry') file_registry = utils.build_file_registry( [(_OUTPUT_BASE_FILES, output_dir), (_INTERMEDIATE_BASE_FILES, intermediate_output_dir), (_TMP_BASE_FILES, output_dir)], file_suffix) carbon_pool_table = natcap.invest.pygeoprocessing_0_3_3.get_lookup_from_table( args['carbon_pools_path'], 'lucode') cell_sizes = [] valid_lulc_keys = [] valid_scenarios = [] for scenario_type in ['cur', 'fut', 'redd']: lulc_key = "lulc_%s_path" % (scenario_type) if lulc_key in args and len(args[lulc_key]) > 0: cell_sizes.append( natcap.invest.pygeoprocessing_0_3_3.geoprocessing.get_cell_size_from_uri( args[lulc_key])) valid_lulc_keys.append(lulc_key) valid_scenarios.append(scenario_type) pixel_size_out = min(cell_sizes) # align the input datasets natcap.invest.pygeoprocessing_0_3_3.align_dataset_list( [args[_] for _ in valid_lulc_keys], [file_registry['aligned_' + _] for _ in valid_lulc_keys], ['nearest'] * len(valid_lulc_keys), pixel_size_out, 'intersection', 0, assert_datasets_projected=True) LOGGER.info('Map all carbon pools to carbon storage rasters.') aligned_lulc_key = None pool_storage_path_lookup = collections.defaultdict(list) summary_stats = [] # use to aggregate storage, value, and more for pool_type in ['c_above', 'c_below', 'c_soil', 'c_dead']: carbon_pool_by_type = dict([ (lucode, float(carbon_pool_table[lucode][pool_type])) for lucode in carbon_pool_table]) for scenario_type in valid_scenarios: aligned_lulc_key = 'aligned_lulc_%s_path' % scenario_type storage_key = '%s_%s' % (pool_type, scenario_type) LOGGER.info( "Mapping carbon from '%s' to '%s' scenario.", aligned_lulc_key, storage_key) _generate_carbon_map( file_registry[aligned_lulc_key], carbon_pool_by_type, file_registry[storage_key]) # store the pool storage path so they can be easily added later pool_storage_path_lookup[scenario_type].append( file_registry[storage_key]) # Sum the individual carbon storage pool paths per scenario for scenario_type, storage_path_list in ( pool_storage_path_lookup.iteritems()): output_key = 'tot_c_' + scenario_type LOGGER.info( "Calculate carbon storage for '%s'", output_key) _sum_rasters(storage_path_list, file_registry[output_key]) # Tuple below is (sort_priority, description, value, unit, path) summary_stats.append(( 0, "Total %s" % scenario_type, _accumulate_totals(file_registry[output_key]), 'Mg of C', file_registry[output_key])) # calculate sequestration for fut_type in ['fut', 'redd']: if fut_type not in valid_scenarios: continue output_key = 'delta_cur_' + fut_type LOGGER.info("Calculate sequestration scenario '%s'", output_key) storage_path_list = [ file_registry['tot_c_cur'], file_registry['tot_c_' + fut_type]] _diff_rasters(storage_path_list, file_registry[output_key]) # Tuple below is (sort_priority, description, value, unit, path) summary_stats.append(( 1, "Change in C for %s" % fut_type, _accumulate_totals(file_registry[output_key]), 'Mg of C', file_registry[output_key])) if 'do_valuation' in args and args['do_valuation']: LOGGER.info('Constructing valuation formula.') valuation_constant = _calculate_valuation_constant( int(args['lulc_cur_year']), int(args['lulc_fut_year']), float(args['discount_rate']), float(args['rate_change']), float(args['price_per_metric_ton_of_c'])) for scenario_type in ['fut', 'redd']: if scenario_type not in valid_scenarios: continue output_key = 'npv_%s' % scenario_type LOGGER.info("Calculating NPV for scenario '%s'", output_key) _calculate_npv( file_registry['delta_cur_%s' % scenario_type], valuation_constant, file_registry[output_key]) # Tuple below is (sort_priority, description, value, unit, path) summary_stats.append(( 2, "Net present value from cur to %s" % scenario_type, _accumulate_totals(file_registry[output_key]), "currency units", file_registry[output_key])) _generate_report(summary_stats, args, file_registry['html_report']) for tmp_filename_key in _TMP_BASE_FILES: try: tmp_filename = file_registry[tmp_filename_key] if os.path.exists(tmp_filename): os.remove(tmp_filename) except OSError as os_error: LOGGER.warn( "Can't remove temporary file: %s\nOriginal Exception:\n%s", file_registry[tmp_filename_key], os_error) def _accumulate_totals(raster_path): """Sum all non-nodata pixels in `raster_path` and return result.""" nodata = natcap.invest.pygeoprocessing_0_3_3.get_nodata_from_uri(raster_path) raster_sum = 0.0 for _, block in natcap.invest.pygeoprocessing_0_3_3.iterblocks(raster_path): raster_sum += numpy.sum(block[block != nodata]) return raster_sum def _generate_carbon_map( lulc_path, carbon_pool_by_type, out_carbon_stock_path): """Generate carbon stock raster by mapping LULC values to carbon pools. Parameters: lulc_path (string): landcover raster with integer pixels. out_carbon_stock_path (string): path to output raster that will have pixels with carbon storage values in them with units of Mg*C carbon_pool_by_type (dict): a dictionary that maps landcover values to carbon storage densities per area (Mg C/Ha). Returns: None. """ nodata = natcap.invest.pygeoprocessing_0_3_3.get_nodata_from_uri(lulc_path) pixel_size_out = natcap.invest.pygeoprocessing_0_3_3.get_cell_size_from_uri(lulc_path) carbon_stock_by_type = dict([ (lulcid, stock * pixel_size_out ** 2 / 10**4) for lulcid, stock in carbon_pool_by_type.iteritems()]) carbon_stock_by_type[nodata] = _CARBON_NODATA natcap.invest.pygeoprocessing_0_3_3.reclassify_dataset_uri( lulc_path, carbon_stock_by_type, out_carbon_stock_path, gdal.GDT_Float32, _CARBON_NODATA, exception_flag='values_required', assert_dataset_projected=True) def _sum_rasters(storage_path_list, output_sum_path): """Sum all the rasters in `storage_path_list` to `output_sum_path`.""" def _sum_op(*storage_arrays): """Sum all the arrays or nodata a pixel stack if one exists.""" valid_mask = reduce( lambda x, y: x & y, [ _ != _CARBON_NODATA for _ in storage_arrays]) result = numpy.empty(storage_arrays[0].shape) result[:] = _CARBON_NODATA result[valid_mask] = numpy.sum([ _[valid_mask] for _ in storage_arrays], axis=0) return result pixel_size_out = natcap.invest.pygeoprocessing_0_3_3.get_cell_size_from_uri( storage_path_list[0]) natcap.invest.pygeoprocessing_0_3_3.vectorize_datasets( storage_path_list, _sum_op, output_sum_path, gdal.GDT_Float32, _CARBON_NODATA, pixel_size_out, "intersection", vectorize_op=False, datasets_are_pre_aligned=True) def _diff_rasters(storage_path_list, output_diff_path): """Subtract rasters in `storage_path_list` to `output_sum_path`.""" def _diff_op(base_array, future_array): """Subtract future_array from base_array and ignore nodata.""" result = numpy.empty(base_array.shape, dtype=numpy.float32) result[:] = _CARBON_NODATA valid_mask = ( (base_array != _CARBON_NODATA) & (future_array != _CARBON_NODATA)) result[valid_mask] = ( future_array[valid_mask] - base_array[valid_mask]) return result pixel_size_out = natcap.invest.pygeoprocessing_0_3_3.get_cell_size_from_uri( storage_path_list[0]) natcap.invest.pygeoprocessing_0_3_3.vectorize_datasets( storage_path_list, _diff_op, output_diff_path, gdal.GDT_Float32, _CARBON_NODATA, pixel_size_out, "intersection", vectorize_op=False, datasets_are_pre_aligned=True) def _calculate_valuation_constant( lulc_cur_year, lulc_fut_year, discount_rate, rate_change, price_per_metric_ton_of_c): """Calculate a net present valuation constant to multiply carbon storage. Parameters: lulc_cur_year (int): calendar year in present lulc_fut_year (int): calendar year in future discount_rate (float): annual discount rate as a percentage rate_change (float): annual change in price of carbon as a percentage price_per_metric_ton_of_c (float): currency amount of Mg of carbon Returns: a floating point number that can be used to multiply a delta carbon storage value by to calculate NPV. """ n_years = int(lulc_fut_year) - int(lulc_cur_year) - 1 ratio = ( 1.0 / ((1 + float(discount_rate) / 100.0) * (1 + float(rate_change) / 100.0))) valuation_constant = ( float(price_per_metric_ton_of_c) / (float(lulc_fut_year) - float(lulc_cur_year)) * (1.0 - ratio ** (n_years + 1)) / (1.0 - ratio)) return valuation_constant def _calculate_npv(delta_carbon_path, valuation_constant, npv_out_path): """Calculate net present value. Parameters: delta_carbon_path (string): path to change in carbon storage over time. valulation_constant (float): value to multiply each carbon storage value by to calculate NPV. npv_out_path (string): path to output net present value raster. Returns: None. """ def _npv_value_op(carbon_array): """Calculate the NPV given carbon storage or loss values.""" result = numpy.empty(carbon_array.shape, dtype=numpy.float32) result[:] = _VALUE_NODATA valid_mask = carbon_array != _CARBON_NODATA result[valid_mask] = carbon_array[valid_mask] * valuation_constant return result pixel_size_out = natcap.invest.pygeoprocessing_0_3_3.get_cell_size_from_uri(delta_carbon_path) natcap.invest.pygeoprocessing_0_3_3.geoprocessing.vectorize_datasets( [delta_carbon_path], _npv_value_op, npv_out_path, gdal.GDT_Float32, _VALUE_NODATA, pixel_size_out, "intersection", vectorize_op=False, datasets_are_pre_aligned=True) def _generate_report(summary_stats, model_args, html_report_path): """Generate a human readable HTML report of summary stats of model run. Paramters: summary_stats (list of tuple): a list of tuples of the form (display_sort_priority, description, value, unit, file_path) model_args (dict): InVEST argument dictionary. html_report_path (string): path to output report file. Returns: None. """ with open(html_report_path, 'w') as report_doc: # Boilerplate header that defines style and intro header. header = ( '<!DOCTYPE html><html><head><title>Carbon Results</title><style t' 'ype="text/css">body { background-color: #EFECCA; color: #002F2F ' '} h1 { text-align: center } h1, h2, h3, h4, strong, th { color: ' '#046380; } h2 { border-bottom: 1px solid #A7A37E; } table { bord' 'er: 5px solid #A7A37E; margin-bottom: 50px; background-color: #E' '6E2AF; } td, th { margin-left: 0px; margin-right: 0px; padding-l' 'eft: 8px; padding-right: 8px; padding-bottom: 2px; padding-top: ' '2px; text-align:left; } td { border-top: 5px solid #EFECCA; } .n' 'umber {text-align: right; font-family: monospace;} img { margin:' ' 20px; }</style></head><body><h1>InVEST Carbon Model Results</h1' '><p>This document summarizes the results from running the InVEST' ' carbon model with the following data.</p>') report_doc.write(header) report_doc.write('<p>Report generated at %s</p>' % ( time.strftime("%Y-%m-%d %H:%M"))) # Report input arguments report_doc.write('<table><tr><th>arg id</th><th>arg value</th></tr>') for key, value in model_args.iteritems(): report_doc.write('<tr><td>%s</td><td>%s</td></tr>' % (key, value)) report_doc.write('</table>') # Report aggregate results report_doc.write('<h3>Aggregate Results</h3>') report_doc.write( '<table><tr><th>Description</th><th>Value</th><th>Units</th><th>R' 'aw File</th></tr>') for _, result_description, units, value, raw_file_path in sorted( summary_stats): report_doc.write( '<tr><td>%s</td><td class="number">%.2f</td><td>%s</td>' '<td>%s</td></tr>' % ( result_description, units, value, raw_file_path)) report_doc.write('</body></html>') @validation.invest_validator def validate(args, limit_to=None): """Validate args to ensure they conform to `execute`'s contract. Parameters: args (dict): dictionary of key(str)/value pairs where keys and values are specified in `execute` docstring. limit_to (str): (optional) if not None indicates that validation should only occur on the args[limit_to] value. The intent that individual key validation could be significantly less expensive than validating the entire `args` dictionary. Returns: list of ([invalid key_a, invalid_keyb, ...], 'warning/error message') tuples. Where an entry indicates that the invalid keys caused the error message in the second part of the tuple. This should be an empty list if validation succeeds. """ missing_key_list = [] no_value_list = [] validation_error_list = [] required_keys = [ 'workspace_dir', 'lulc_cur_path', 'carbon_pools_path', 'calc_sequestration', 'do_valuation'] if 'calc_sequestration' in args and args['calc_sequestration']: required_keys.extend( ['lulc_cur_year', 'lulc_fut_path', 'lulc_fut_year', 'do_redd']) if 'do_redd' in args and args['do_redd']: required_keys.append('lulc_redd_path') if 'do_valuation' in args and args['do_valuation']: required_keys.extend( ['price_per_metric_ton_of_c', 'discount_rate', 'rate_change']) for key in required_keys: if limit_to is None or limit_to == key: if key not in args: missing_key_list.append(key) elif args[key] in ['', None]: no_value_list.append(key) if len(missing_key_list) > 0: # if there are missing keys, we have raise KeyError to stop hard raise KeyError( "The following keys were expected in `args` but were missing " + ', '.join(missing_key_list)) if len(no_value_list) > 0: validation_error_list.append( (no_value_list, 'parameter has no value')) file_type_list = [ ('lulc_cur_path', 'raster'), ('lulc_fut_path', 'raster'), ('lulc_redd_path', 'raster'), ('carbon_pools_path', 'table')] # check that existing/optional files are the correct types with utils.capture_gdal_logging(): for key, key_type in file_type_list: if ((limit_to is None or limit_to == key) and key in args and key in required_keys): if not os.path.exists(args[key]): validation_error_list.append( ([key], 'not found on disk')) continue if key_type == 'raster': raster = gdal.Open(args[key]) if raster is None: validation_error_list.append( ([key], 'not a raster')) del raster elif key_type == 'vector': vector = ogr.Open(args[key]) if vector is None: validation_error_list.append( ([key], 'not a vector')) del vector return validation_error_list
43.906
99
0.633945
4a242372b3fd27fd7c6756b4936f0173e794c91a
242
py
Python
tests/test_general.py
ArtellaPipe/artellapipe-libs-arnold
b807e37c245531e554b331d8462d93e36d130556
[ "MIT" ]
null
null
null
tests/test_general.py
ArtellaPipe/artellapipe-libs-arnold
b807e37c245531e554b331d8462d93e36d130556
[ "MIT" ]
null
null
null
tests/test_general.py
ArtellaPipe/artellapipe-libs-arnold
b807e37c245531e554b331d8462d93e36d130556
[ "MIT" ]
null
null
null
#! /usr/bin/env python # -*- coding: utf-8 -*- """ Module that contains general tests for artellapipe-libs-arnold """ import pytest from artellapipe.libs.arnold import __version__ def test_version(): assert __version__.get_version()
16.133333
62
0.727273
4a2423783d1180aac3412b74e5159e45505c5afd
419
py
Python
jcasts/podcasts/migrations/0094_podcast_websub_url.py
danjac/jcasts
04f5ef1f536d51962c0433d092817c0153acb6af
[ "MIT" ]
13
2021-09-17T07:41:00.000Z
2022-02-10T10:00:48.000Z
jcasts/podcasts/migrations/0094_podcast_websub_url.py
danjac/jcasts
04f5ef1f536d51962c0433d092817c0153acb6af
[ "MIT" ]
167
2021-07-17T09:41:38.000Z
2021-08-31T06:03:34.000Z
jcasts/podcasts/migrations/0094_podcast_websub_url.py
danjac/jcasts
04f5ef1f536d51962c0433d092817c0153acb6af
[ "MIT" ]
null
null
null
# Generated by Django 3.2.9 on 2021-11-17 06:27 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("podcasts", "0093_podcast_websub_exception"), ] operations = [ migrations.AddField( model_name="podcast", name="websub_url", field=models.URLField(blank=True, max_length=500, null=True), ), ]
22.052632
73
0.615752
4a24237e1a15128bcece004e7469caa941ad490e
1,104
py
Python
worker/messaging/fcm/external/fcm/legacy.py
pjongy/jraze
8c7c0abebcb973f87c8fc36b9c7bf7fa76f445f3
[ "MIT" ]
5
2020-07-31T02:18:29.000Z
2021-11-22T02:25:07.000Z
worker/messaging/fcm/external/fcm/legacy.py
pjongy/jraze
8c7c0abebcb973f87c8fc36b9c7bf7fa76f445f3
[ "MIT" ]
13
2020-08-03T07:36:19.000Z
2020-11-26T12:02:57.000Z
worker/messaging/fcm/external/fcm/legacy.py
pjongy/jraze
8c7c0abebcb973f87c8fc36b9c7bf7fa76f445f3
[ "MIT" ]
1
2020-08-19T07:48:30.000Z
2020-08-19T07:48:30.000Z
from typing import List, Tuple import httpx from common.logger.logger import get_logger from worker.messaging.fcm.external.fcm.abstract import AbstractFCM logger = get_logger(__name__) class FCMClientLegacy(AbstractFCM): FCM_API_HOST = 'https://fcm.googleapis.com' def __init__(self, server_key): self.server_key = server_key async def send_data( self, targets: List[str], data: dict ) -> Tuple[int, int]: PUSH_SEND_PATH = '/fcm/send' body = { **data, "registration_ids": targets } async with httpx.AsyncClient() as client: response = await client.post( url=f'{self.FCM_API_HOST}{PUSH_SEND_PATH}', json=body, headers={'Authorization': f'key={self.server_key}'} ) logger.debug(response) if not 200 <= response.status_code < 300: raise PermissionError(f'fcm data sent failed {response}') result = response.json() return result['success'], result['failure']
27.6
73
0.594203
4a2423dc88e10af5cbdd6313411828638800fbad
3,353
py
Python
utilities/test_backup_encryption.py
davemungo/various
ed7c17f8b75a27fc59b0a5cad6125d64d00cd3ce
[ "MIT" ]
1
2020-01-19T01:21:56.000Z
2020-01-19T01:21:56.000Z
utilities/test_backup_encryption.py
davemungo/various
ed7c17f8b75a27fc59b0a5cad6125d64d00cd3ce
[ "MIT" ]
null
null
null
utilities/test_backup_encryption.py
davemungo/various
ed7c17f8b75a27fc59b0a5cad6125d64d00cd3ce
[ "MIT" ]
1
2021-07-02T14:40:01.000Z
2021-07-02T14:40:01.000Z
import backup_encryption as be import base64 as b64 import os from datetime import datetime ### SETUP NOTES # Many tests require existence of 'development.key' file ### TESTS def test_create_key(): # Results should look like this # key: b'5jApZKjlxj4SjH5FU05tHx4abfUkzHxgYc3LxFmf4HM=' # keyfile: 'backup_file_encryption..2020-05-31-122543.key' (key, key_file) = be.create_key() assert len(key) == 44 assert type(key) is bytes assert len(key_file) == 45 def test_load_key(): (generated_key, key_file) = be.create_key() loaded_key = be.load_key(key=key_file) try: os.remove(key_file) assert loaded_key == generated_key except Exception as e: print(f"ERR: Unknown exception {e}") assert "Passed Test" == False def test_encrypt_file(): test_file_contents = '''A short test file''' test_file = 'TEST_FILE' with open(test_file, "w") as tf: tf.write(test_file_contents) try: key = be.load_key(key="development.key") encrypted_data = be.encrypt_file(test_file, key) except IOError as ioe: print(f"ERR: IO problem {ioe}") except EOFError: print(f"ERR: Unexpected EOF in {test_file}") except Exception as e: print(f"ERR: Unknown exception {e}") finally: os.remove(test_file) # Data format specified in https://cryptography.io/en/latest/fernet/ # Encrypted data is in bytes and URL-safe base64-encoded assert str(type(encrypted_data)) == "<class 'bytes'>" assert b64.urlsafe_b64encode(b64.urlsafe_b64decode(encrypted_data)) == encrypted_data def test_write_encrypted_file(): test_file_contents = '''A short test file''' test_file = 'TEST_FILE' with open(test_file, "w") as tf: tf.write(test_file_contents) try: key = be.load_key(key="development.key") encrypted_data = be.encrypt_file(test_file, key) file_name = be.write_encrypted_file(test_file, encrypted_data) file_size = os.path.getsize(file_name) except IOError as ioe: print(f"ERR: IO problem {ioe}") except EOFError: print(f"ERR: Unexpected EOF in {test_file}") except Exception as e: print(f"ERR: Unknown exception {e}") finally: os.remove(test_file) os.remove(test_file + '.enc') assert file_name == test_file + '.enc' assert file_size > 0 def test_decrypt_file(): test_file_contents = 'A short test file' test_file = 'TEST_FILE' with open(test_file, "w") as tf: tf.write(test_file_contents) try: key = be.load_key(key="development.key") encrypted_data = be.encrypt_file(test_file, key) encrypted_file = be.write_encrypted_file(test_file, encrypted_data) decrypted_data = be.decrypt_file(encrypted_file, key) except Exception as e: print(f"ERR: Unknown exception {e}") finally: os.remove(test_file) os.remove(test_file + '.enc') assert decrypted_data == test_file_contents ############################### # Testing the write encrypted file function
30.761468
90
0.612288
4a24265f19b851642fa69080d4864042d7e85b9e
6,331
py
Python
tacker/tests/unit/objects/test_vnf_deployment_flavour.py
takahashi-tsc/tacker
a0ae01a13dcc51bb374060adcbb4fd484ab37156
[ "Apache-2.0" ]
116
2015-10-18T02:57:08.000Z
2022-03-15T04:09:18.000Z
tacker/tests/unit/objects/test_vnf_deployment_flavour.py
takahashi-tsc/tacker
a0ae01a13dcc51bb374060adcbb4fd484ab37156
[ "Apache-2.0" ]
6
2016-11-07T22:15:54.000Z
2021-05-09T06:13:08.000Z
tacker/tests/unit/objects/test_vnf_deployment_flavour.py
takahashi-tsc/tacker
a0ae01a13dcc51bb374060adcbb4fd484ab37156
[ "Apache-2.0" ]
166
2015-10-20T15:31:52.000Z
2021-11-12T08:39:49.000Z
# Copyright (c) 2019 NTT DATA # # 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 unittest import mock from tacker.common import exceptions from tacker import context from tacker import objects from tacker.tests.unit.db.base import SqlTestCase from tacker.tests.unit.objects import fakes from tacker.tests import uuidsentinel class TestVnfDeploymentFlavour(SqlTestCase): def setUp(self): super(TestVnfDeploymentFlavour, self).setUp() self.context = context.get_admin_context() self.vnf_package = self._create_vnf_package() self.vnf_deployment_flavour = self._create_vnf_deployment_flavour() def _create_vnf_package(self): vnfpkgm = objects.VnfPackage(context=self.context, **fakes.vnf_package_data) vnfpkgm.create() return vnfpkgm def _create_vnf_deployment_flavour(self): flavour_data = fakes.vnf_deployment_flavour flavour_data.update({'package_uuid': self.vnf_package.id}) vnf_deployment_flavour = objects.VnfDeploymentFlavour( context=self.context, **flavour_data) vnf_deployment_flavour.create() return vnf_deployment_flavour def test_create(self): flavour_data = fakes.vnf_deployment_flavour flavour_data.update({'package_uuid': self.vnf_package.id}) vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour( context=self.context, **flavour_data) vnf_deployment_flavour_obj.create() self.assertTrue(vnf_deployment_flavour_obj.id) def test_create_with_software_images(self): software_images = objects.VnfSoftwareImage(**fakes.software_image) fake_software_images = objects.VnfSoftwareImagesList( objects=[software_images]) flavour_data = fakes.vnf_deployment_flavour flavour_data.update({'software_images': fake_software_images}) flavour_data.update({'package_uuid': self.vnf_package.id}) vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour( context=self.context, **flavour_data) vnf_deployment_flavour_obj.create() self.assertTrue(vnf_deployment_flavour_obj.id) def test_get_by_id(self): vnf_deployment_flavour = objects.VnfDeploymentFlavour.get_by_id( self.context, self.vnf_deployment_flavour.id, expected_attrs=None) self.compare_obj(self.vnf_deployment_flavour, vnf_deployment_flavour, allow_missing=['software_images', 'updated_at', 'deleted', 'deleted_at']) def test_get_by_id_with_no_existing_id(self): self.assertRaises( exceptions.VnfDeploymentFlavourNotFound, objects.VnfDeploymentFlavour.get_by_id, self.context, uuidsentinel.invalid_uuid) def test_create_with_id(self): vnf_deployment_flavour_obj = {'id': uuidsentinel.uuid} vnf_deployment_flavour = objects.VnfDeploymentFlavour( context=self.context, **vnf_deployment_flavour_obj) self.assertRaises(exceptions.ObjectActionError, vnf_deployment_flavour.create) @mock.patch('tacker.objects.vnf_deployment_flavour.' '_destroy_vnf_deployment_flavour') def test_destroy(self, mock_vnf_deployment_flavour_destroy): self.vnf_deployment_flavour.destroy(self.context) mock_vnf_deployment_flavour_destroy.assert_called_with( self.context, self.vnf_deployment_flavour.id) def test_destroy_without_id(self): vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour( context=self.context) self.assertRaises(exceptions.ObjectActionError, vnf_deployment_flavour_obj.destroy, self.context) def test_attribute_with_valid_data(self): data = {'id': self.vnf_deployment_flavour.id} vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour( context=self.context, **data) vnf_deployment_flavour_obj.obj_load_attr('flavour_id') self.assertEqual('simple', vnf_deployment_flavour_obj.flavour_id) def test_invalid_attribute(self): self.assertRaises( exceptions.ObjectActionError, self.vnf_deployment_flavour.obj_load_attr, 'invalid') def test_obj_load_attr_without_context(self): data = {'id': self.vnf_deployment_flavour.id} vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour(**data) self.assertRaises(exceptions.OrphanedObjectError, vnf_deployment_flavour_obj.obj_load_attr, 'flavour_id') def test_obj_load_attr_without_id_in_object(self): data = {'flavour_id': self.vnf_deployment_flavour.flavour_id} vnf_deployment_flavour_obj = objects.VnfDeploymentFlavour( context=self.context, **data) self.assertRaises(exceptions.ObjectActionError, vnf_deployment_flavour_obj.obj_load_attr, 'flavour_id') def test_get_by_id_with_software_images(self): software_image = fakes.software_image software_image.update( {'flavour_uuid': self.vnf_deployment_flavour.id}) vnf_soft_image_obj = objects.VnfSoftwareImage( context=self.context, **software_image) vnf_soft_image_obj.create() vnf_deployment_flavour = objects.VnfDeploymentFlavour.get_by_id( self.context, self.vnf_deployment_flavour.id, expected_attrs=['software_images']) self.assertEqual(1, len(vnf_deployment_flavour.software_images.objects)) self.compare_obj(vnf_soft_image_obj, vnf_deployment_flavour.software_images[0])
43.363014
78
0.6991
4a2427755dfc4c430e953c94ba135ba78c561978
1,323
py
Python
galaxy/common/survey.py
SamyCoenen/galaxy
7c17ef45e53b0fc2fe8a2c70a99f3947604e0b0e
[ "Apache-2.0" ]
null
null
null
galaxy/common/survey.py
SamyCoenen/galaxy
7c17ef45e53b0fc2fe8a2c70a99f3947604e0b0e
[ "Apache-2.0" ]
null
null
null
galaxy/common/survey.py
SamyCoenen/galaxy
7c17ef45e53b0fc2fe8a2c70a99f3947604e0b0e
[ "Apache-2.0" ]
null
null
null
# (c) 2012-2019, Ansible by Red Hat # # This file is part of Ansible Galaxy # # Ansible Galaxy is free software: you can redistribute it and/or modify # it under the terms of the Apache License as published by # the Apache Software Foundation, either version 2 of the License, or # (at your option) any later version. # # Ansible Galaxy is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # Apache License for more details. # # You should have received a copy of the Apache License # along with Galaxy. If not, see <http://www.apache.org/licenses/>. SURVEY_FIElDS = ( 'docs', 'ease_of_use', 'does_what_it_says', 'works_as_is', 'used_in_production', ) def calculate_survey_score(surveys): ''' :var surveys: queryset container all of the surveys for a collection or a repository ''' score = 0 answer_count = 0 survey_score = 0.0 for survey in surveys: for k in SURVEY_FIElDS: data = getattr(survey, k) if data is not None: answer_count += 1 survey_score += (data - 1) / 4 # Average and convert to 0-5 scale score = (survey_score / answer_count) * 5 return score
28.148936
77
0.671958
4a2427b6c26801774b60ecda22b9f031fbef9a8c
2,004
py
Python
test/lint/check-doc.py
mkscoin/mkscoin
a4436857087a727a5d1b03f8380764b04d954f04
[ "MIT" ]
null
null
null
test/lint/check-doc.py
mkscoin/mkscoin
a4436857087a727a5d1b03f8380764b04d954f04
[ "MIT" ]
null
null
null
test/lint/check-doc.py
mkscoin/mkscoin
a4436857087a727a5d1b03f8380764b04d954f04
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 # Copyright (c) 2015-2018 The mkscoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' This checks if all command line args are documented. Return value is 0 to indicate no error. Author: @MarcoFalke ''' from subprocess import check_output import re import sys FOLDER_GREP = 'src' FOLDER_TEST = 'src/test/' REGEX_ARG = '(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"' REGEX_DOC = 'AddArg\("(-[^"=]+?)(?:=|")' CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/{}'.format(FOLDER_GREP) CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST) CMD_GREP_DOCS = r"git grep --perl-regexp '{}' {}".format(REGEX_DOC, CMD_ROOT_DIR) # list unsupported, deprecated and duplicate args as they need no documentation SET_DOC_OPTIONAL = set(['-h', '-help', '-dbcrashratio', '-forcecompactdb']) def main(): if sys.version_info >= (3, 6): used = check_output(CMD_GREP_ARGS, shell=True, universal_newlines=True, encoding='utf8') docd = check_output(CMD_GREP_DOCS, shell=True, universal_newlines=True, encoding='utf8') else: used = check_output(CMD_GREP_ARGS, shell=True).decode('utf8').strip() docd = check_output(CMD_GREP_DOCS, shell=True).decode('utf8').strip() args_used = set(re.findall(re.compile(REGEX_ARG), used)) args_docd = set(re.findall(re.compile(REGEX_DOC), docd)).union(SET_DOC_OPTIONAL) args_need_doc = args_used.difference(args_docd) args_unknown = args_docd.difference(args_used) print("Args used : {}".format(len(args_used))) print("Args documented : {}".format(len(args_docd))) print("Args undocumented: {}".format(len(args_need_doc))) print(args_need_doc) print("Args unknown : {}".format(len(args_unknown))) print(args_unknown) sys.exit(len(args_need_doc)) if __name__ == "__main__": main()
37.811321
112
0.694112
4a2427bf4622071edd8b829f2e418142b40b1b7f
6,608
py
Python
robin_stocks/tda/authentication.py
qtcwt/robin_stocks
5672a2c3e16fb00ab46e03aa5894dce54adcb005
[ "MIT" ]
1,339
2018-08-29T03:10:09.000Z
2022-03-31T15:54:58.000Z
robin_stocks/tda/authentication.py
qtcwt/robin_stocks
5672a2c3e16fb00ab46e03aa5894dce54adcb005
[ "MIT" ]
290
2018-09-21T00:34:30.000Z
2022-03-25T02:30:51.000Z
robin_stocks/tda/authentication.py
qtcwt/robin_stocks
5672a2c3e16fb00ab46e03aa5894dce54adcb005
[ "MIT" ]
419
2018-11-03T17:32:19.000Z
2022-03-27T04:37:48.000Z
import pickle from datetime import datetime, timedelta from pathlib import Path from cryptography.fernet import Fernet from robin_stocks.tda.globals import DATA_DIR_NAME, PICKLE_NAME from robin_stocks.tda.helper import (request_data, set_login_state, update_session) from robin_stocks.tda.urls import URLS def login_first_time(encryption_passcode, client_id, authorization_token, refresh_token): """ Stores log in information in a pickle file on the computer. After being used once, user can call login() to automatically read in information from pickle file and refresh authorization tokens when needed. :param encryption_passcode: Encryption key created by generate_encryption_passcode(). :type encryption_passcode: str :param client_id: The Consumer Key for the API account. :type client_id: str :param authorization_token: The authorization code returned from post request to https://developer.tdameritrade.com/authentication/apis/post/token-0 :type authorization_token: str :param refresh_token: The refresh code returned from post request to https://developer.tdameritrade.com/authentication/apis/post/token-0 :type refresh_token: str """ if type(encryption_passcode) is str: encryption_passcode = encryption_passcode.encode() cipher_suite = Fernet(encryption_passcode) # Create necessary folders and paths for pickle file as defined in globals. data_dir = Path.home().joinpath(DATA_DIR_NAME) if not data_dir.exists(): data_dir.mkdir(parents=True) pickle_path = data_dir.joinpath(PICKLE_NAME) if not pickle_path.exists(): Path.touch(pickle_path) # Write information to the file. with pickle_path.open("wb") as pickle_file: pickle.dump( { 'authorization_token': cipher_suite.encrypt(authorization_token.encode()), 'refresh_token': cipher_suite.encrypt(refresh_token.encode()), 'client_id': cipher_suite.encrypt(client_id.encode()), 'authorization_timestamp': datetime.now(), 'refresh_timestamp': datetime.now() }, pickle_file) def login(encryption_passcode): """ Set the authorization token so the API can be used. Gets a new authorization token every 30 minutes using the refresh token. Gets a new refresh token every 60 days. :param encryption_passcode: Encryption key created by generate_encryption_passcode(). :type encryption_passcode: str """ if type(encryption_passcode) is str: encryption_passcode = encryption_passcode.encode() cipher_suite = Fernet(encryption_passcode) # Check that file exists before trying to read from it. data_dir = Path.home().joinpath(DATA_DIR_NAME) pickle_path = data_dir.joinpath(PICKLE_NAME) if not pickle_path.exists(): raise FileExistsError( "Please Call login_first_time() to create pickle file.") # Read the information from the pickle file. with pickle_path.open("rb") as pickle_file: pickle_data = pickle.load(pickle_file) access_token = cipher_suite.decrypt(pickle_data['authorization_token']).decode() refresh_token = cipher_suite.decrypt(pickle_data['refresh_token']).decode() client_id = cipher_suite.decrypt(pickle_data['client_id']).decode() authorization_timestamp = pickle_data['authorization_timestamp'] refresh_timestamp = pickle_data['refresh_timestamp'] # Authorization tokens expire after 30 mins. Refresh tokens expire after 90 days, # but you need to request a fresh authorization and refresh token before it expires. authorization_delta = timedelta(seconds=1800) refresh_delta = timedelta(days=60) url = URLS.oauth() # If it has been longer than 60 days. Get a new refresh and authorization token. # Else if it has been longer than 30 minutes, get only a new authorization token. if (datetime.now() - refresh_timestamp > refresh_delta): payload = { "grant_type": "refresh_token", "access_type": "offline", "refresh_token": refresh_token, "client_id": client_id } data, _ = request_data(url, payload, True) if "access_token" not in data and "refresh_token" not in data: raise ValueError( "Refresh token is no longer valid. Call login_first_time() to get a new refresh token.") access_token = data["access_token"] refresh_token = data["refresh_token"] with pickle_path.open("wb") as pickle_file: pickle.dump( { 'authorization_token': cipher_suite.encrypt(access_token.encode()), 'refresh_token': cipher_suite.encrypt(refresh_token.encode()), 'client_id': cipher_suite.encrypt(client_id.encode()), 'authorization_timestamp': datetime.now(), 'refresh_timestamp': datetime.now() }, pickle_file) elif (datetime.now() - authorization_timestamp > authorization_delta): payload = { "grant_type": "refresh_token", "refresh_token": refresh_token, "client_id": client_id } data, _ = request_data(url, payload, True) if "access_token" not in data: raise ValueError( "Refresh token is no longer valid. Call login_first_time() to get a new refresh token.") access_token = data["access_token"] # Write new data to file. Do not replace the refresh timestamp. with pickle_path.open("wb") as pickle_file: pickle.dump( { 'authorization_token': cipher_suite.encrypt(access_token.encode()), 'refresh_token': cipher_suite.encrypt(refresh_token.encode()), 'client_id': cipher_suite.encrypt(client_id.encode()), 'authorization_timestamp': datetime.now(), 'refresh_timestamp': refresh_timestamp }, pickle_file) # Store authorization token in session information to be used with API calls. auth_token = "Bearer {0}".format(access_token) update_session("Authorization", auth_token) update_session("apikey", client_id) set_login_state(True) return auth_token def generate_encryption_passcode(): """ Returns an encryption key to be used for logging in. :returns: Returns a byte object to be used with cryptography. """ return Fernet.generate_key().decode()
47.539568
152
0.677209
4a242ab3d53dc21308ecd6772159b5142f853617
4,554
py
Python
autots/tools/impute.py
mreismendes/AutoTS
a874b531ae1f06db69fdd1211ddc0ca908d033c9
[ "MIT" ]
null
null
null
autots/tools/impute.py
mreismendes/AutoTS
a874b531ae1f06db69fdd1211ddc0ca908d033c9
[ "MIT" ]
null
null
null
autots/tools/impute.py
mreismendes/AutoTS
a874b531ae1f06db69fdd1211ddc0ca908d033c9
[ "MIT" ]
null
null
null
"""Fill NA.""" # import numpy as np import pandas as pd def fill_zero(df): """Fill NaN with zero.""" df = df.fillna(0) return df def fill_forward(df): """Fill NaN with previous values.""" df = df.fillna(method='ffill') df = df.fillna(method='bfill') return df def fill_mean(df): """Fill NaN with mean.""" df = df.fillna(df.mean().to_dict()) return df def fill_median(df): """Fill NaN with median.""" df = df.fillna(df.median().to_dict()) return df def rolling_mean(df, window: int = 10): """Fill NaN with mean of last window values.""" df = df.fillna(df.rolling(window=window, min_periods=1).mean()).fillna( df.mean().to_dict() ) return df def biased_ffill(df, mean_weight: float = 1): """Fill NaN with average of last value and mean.""" df_mean = fill_mean(df) df_ffill = fill_forward(df) df = ((df_mean * mean_weight) + df_ffill) / (1 + mean_weight) return df def fake_date_fill(df, back_method: str = 'slice'): """ Return a dataframe where na values are removed and values shifted forward. Warnings: Thus, values will have incorrect timestamps! Args: back_method (str): how to deal with tails left by shifting NaN - 'bfill' -back fill the last value - 'slice' - drop any rows with any na - 'keepna' - keep the lagging na """ df_index = df.index.to_series().copy() df = df.sort_index(ascending=False) df = df.apply(lambda x: pd.Series(x.dropna().values)) df = df.sort_index(ascending=False) df.index = df_index.tail(len(df.index)) df = df.dropna(how='all', axis=0) if back_method == 'bfill': df = df.fillna(method='bfill') return df elif back_method == 'slice': df = df.dropna(how='any', axis=0) return df elif back_method == 'keepna': return df else: print('back_method not recognized in fake_date_fill') return df df_interpolate = [ 'linear', 'time', 'pad', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'spline', 'barycentric', 'polynomial', 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima', 'from_derivatives', ] # 'cubicspline' def FillNA(df, method: str = 'ffill', window: int = 10): """Fill NA values using different methods. Args: method (str): 'ffill' - fill most recent non-na value forward until another non-na value is reached 'zero' - fill with zero. Useful for sales and other data where NA does usually mean $0. 'mean' - fill all missing values with the series' overall average value 'median' - fill all missing values with the series' overall median value 'rolling mean' - fill with last n (window) values 'ffill mean biased' - simple avg of ffill and mean 'fake date' - shifts forward data over nan, thus values will have incorrect timestamps also most `method` values of pd.DataFrame.interpolate() window (int): length of rolling windows for filling na, for rolling methods """ method = str(method).replace(" ", "_") if method == 'zero': return fill_zero(df) elif method == 'ffill': return fill_forward(df) elif method == 'mean': return fill_mean(df) elif method == 'median': return fill_median(df) elif method == 'rolling_mean': return rolling_mean(df, window=window) elif method == 'rolling_mean_24': return rolling_mean(df, window=24) elif method == 'ffill_mean_biased': return biased_ffill(df) elif method == 'fake_date': return fake_date_fill(df, back_method='slice') elif method == 'IterativeImputer': cols = df.columns indx = df.index try: from sklearn.experimental import enable_iterative_imputer # noqa except Exception: pass from sklearn.impute import IterativeImputer df = IterativeImputer(random_state=0, max_iter=100).fit_transform(df) if not isinstance(df, pd.DataFrame): df = pd.DataFrame(df) df.index = indx df.columns = cols return df elif method in df_interpolate: return df.interpolate(method=method, order=5).fillna(method='bfill') elif method is None: return df else: print("FillNA method not known, returning original") return df
27.269461
99
0.608037
4a242ba538f60c5032ce44def55d98f342f10daa
4,265
py
Python
tasks/release.py
Enzime/pipenv
d4f710be4a39e09a82a5133b7b3a277ee9bfb13a
[ "MIT" ]
2
2018-11-06T04:53:13.000Z
2018-11-08T22:10:20.000Z
tasks/release.py
Enzime/pipenv
d4f710be4a39e09a82a5133b7b3a277ee9bfb13a
[ "MIT" ]
null
null
null
tasks/release.py
Enzime/pipenv
d4f710be4a39e09a82a5133b7b3a277ee9bfb13a
[ "MIT" ]
1
2018-07-17T07:39:47.000Z
2018-07-17T07:39:47.000Z
# -*- coding=utf-8 -*- import datetime import invoke import sys from pipenv.__version__ import __version__ from parver import Version from .vendoring import _get_git_root, drop_dir VERSION_FILE = 'pipenv/__version__.py' def log(msg): print('[release] %s' % msg) def get_version_file(ctx): return _get_git_root(ctx).joinpath(VERSION_FILE) def get_history_file(ctx): return _get_git_root(ctx).joinpath('HISTORY.txt') def get_dist_dir(ctx): return _get_git_root(ctx) / 'dist' def get_build_dir(ctx): return _get_git_root(ctx) / 'build' def drop_dist_dirs(ctx): log('Dropping Dist dir...') drop_dir(get_dist_dir(ctx)) log('Dropping build dir...') drop_dir(get_build_dir(ctx)) @invoke.task def build_dists(ctx): drop_dist_dirs(ctx) log('Building sdist using %s ....' % sys.executable) for py_version in ['2.7', '3.6', '3.7']: env = {'PIPENV_PYTHON': py_version} ctx.run('pipenv install --dev', env=env) if py_version == '3.6': ctx.run('pipenv run python setup.py sdist', env=env) log('Building wheel using python %s ....' % py_version) ctx.run('pipenv run python setup.py bdist_wheel', env=env) @invoke.task(build_dists) def upload_dists(ctx): log('Uploading distributions to pypi...') ctx.run('twine upload dist/*') @invoke.task def generate_markdown(ctx): log('Generating markdown from changelog...') ctx.run('pandoc CHANGELOG.rst -f rst -t markdown -o CHANGELOG.md') @invoke.task def generate_changelog(ctx, commit=False, draft=False): log('Generating changelog...') if draft: commit = False log('Writing draft to file...') ctx.run('towncrier --draft > CHANGELOG.draft.rst') if commit: ctx.run('towncrier') log('Committing...') ctx.run('git add CHANGELOG.rst') ctx.run('git rm CHANGELOG.draft.rst') ctx.run('git commit -m "Update changelog."') @invoke.task def tag_version(ctx, push=False): version = Version.parse(__version__) log('Tagging revision: v%s' % version) ctx.run('git tag v%s' % version) if push: log('Pushing tags...') ctx.run('git push --tags') @invoke.task def bump_version(ctx, dry_run=False, increment=True, release=False, dev=False, pre=False, tag=None, clear=False, commit=False,): current_version = Version.parse(__version__) today = datetime.date.today() next_month_number = today.month + 1 if today.month != 12 else 1 next_year_number = today.year if next_month_number != 1 else today.year+1 next_month = (next_year_number, next_month_number, 0) if pre and not tag: print('Using "pre" requires a corresponding tag.') return if release and not dev and not pre and increment: new_version = current_version.replace(release=today.timetuple()[:3]).clear(pre=True, dev=True) elif release and (dev or pre): if increment: new_version = current_version.replace(release=today.timetuple()[:3]) else: new_version = current_version if dev: new_version = new_version.bump_dev() elif pre: new_version = new_version.bump_pre(tag=tag) else: if not release: increment = False if increment: new_version = current_version.replace(release=next_month) else: new_version = current_version if dev: new_version = new_version.bump_dev() elif pre: new_version = new_version.bump_pre(tag=tag) if clear: new_version = new_version.clear(dev=True, pre=True, post=True) log('Updating version to %s' % new_version.normalize()) version_file = get_version_file(ctx) file_contents = version_file.read_text() log('Found current version: %s' % __version__) if dry_run: log('Would update to: %s' % new_version.normalize()) else: log('Updating to: %s' % new_version.normalize()) version_file.write_text(file_contents.replace(__version__, str(new_version.normalize()))) if commit: ctx.run('git add {0}'.format(version_file)) log('Committing...') ctx.run('git commit -s -m "Bumped version."')
31.131387
128
0.6483
4a242bd051c57a1e7f9cd1d9cb1118b4e0ec55d8
2,179
py
Python
code/tools/external/python/pygccxml/declarations/call_invocation.py
jgresula/jagpdf
6c36958b109e6522e6b57d04144dd83c024778eb
[ "MIT" ]
54
2015-02-16T14:25:16.000Z
2022-03-16T07:54:25.000Z
code/tools/external/python/pygccxml/declarations/call_invocation.py
jgresula/jagpdf
6c36958b109e6522e6b57d04144dd83c024778eb
[ "MIT" ]
null
null
null
code/tools/external/python/pygccxml/declarations/call_invocation.py
jgresula/jagpdf
6c36958b109e6522e6b57d04144dd83c024778eb
[ "MIT" ]
30
2015-03-05T08:52:25.000Z
2022-02-17T13:49:15.000Z
# Copyright 2004 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) """ free function call parser This module implements all functionality necessary to parse C++ free function invocation. In other words this module is able to extract next information from the string like this C{ print_message( message ) }. - name ( print_message ) - list of arguments ( message ) This module also defines few convenience function like L{split} and L{join}. """ import pattern_parser __THE_PARSER = pattern_parser.parser_t( '(', ')', ',' ) def is_call_invocation( decl_string ): """ returns True if decl_string is function invocation and False otherwise @param decl_string: string that should be checked for pattern presence @type decl_string: str @return: bool """ global __THE_PARSER return __THE_PARSER.has_pattern( decl_string ) def name( decl_string ): """ returns name of function @type decl_string: str @return: str """ global __THE_PARSER return __THE_PARSER.name( decl_string ) def args( decl_string ): """ returns list of function arguments @type decl_string: str @return: [str] """ global __THE_PARSER return __THE_PARSER.args( decl_string ) NOT_FOUND = __THE_PARSER.NOT_FOUND def find_args( text, start=None ): """ finds arguments within function invocation. @type text: str @return: [ arguments ] or L{NOT_FOUND} if arguments could not be found """ global __THE_PARSER return __THE_PARSER.find_args( text, start ) def split( decl_string ): """returns (name, [arguments] )""" global __THE_PARSER return __THE_PARSER.split( decl_string ) def split_recursive( decl_string ): """returns [(name, [arguments])]""" global __THE_PARSER return __THE_PARSER.split_recursive( decl_string ) def join( name, args, arg_separator=None ): """returns name( argument_1, argument_2, ..., argument_n )""" global __THE_PARSER return __THE_PARSER.join( name, args, arg_separator )
27.582278
80
0.69665
4a242cd26d5ed94f6bd3331a858fbb10da84919b
391
py
Python
auditlog/migrations/0004_logentry_detailed_object_repr.py
shawnrobb/django-auditlog
87aeba2bdb02a0e35994ea08a67261f5b1d0c3a9
[ "MIT" ]
252
2020-09-23T13:32:49.000Z
2022-03-29T18:38:59.000Z
auditlog/migrations/0004_logentry_detailed_object_repr.py
shawnrobb/django-auditlog
87aeba2bdb02a0e35994ea08a67261f5b1d0c3a9
[ "MIT" ]
121
2020-09-23T12:56:39.000Z
2022-03-31T06:59:09.000Z
auditlog/migrations/0004_logentry_detailed_object_repr.py
shawnrobb/django-auditlog
87aeba2bdb02a0e35994ea08a67261f5b1d0c3a9
[ "MIT" ]
89
2020-09-25T07:22:52.000Z
2022-03-29T07:59:35.000Z
import jsonfield.fields from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("auditlog", "0003_logentry_remote_addr"), ] operations = [ migrations.AddField( model_name="logentry", name="additional_data", field=jsonfield.fields.JSONField(null=True, blank=True), ), ]
21.722222
68
0.624041
4a242ecfbdd21a87fbf108aac4e3e78ea94c4e37
913
py
Python
__init__.py
nbons/baseclasses
25a7feef901f7bb73696a1b2860a1e83d467d883
[ "Apache-2.0" ]
null
null
null
__init__.py
nbons/baseclasses
25a7feef901f7bb73696a1b2860a1e83d467d883
[ "Apache-2.0" ]
null
null
null
__init__.py
nbons/baseclasses
25a7feef901f7bb73696a1b2860a1e83d467d883
[ "Apache-2.0" ]
null
null
null
from .python.pyAero_problem import AeroProblem from .python.pyTransi_problem import TransiProblem from .python.pyStruct_problem import StructProblem from .python.pyAeroStruct_problem import AeroStructProblem from .python.pyAero_solver import AeroSolver from .python.BaseSolver import BaseSolver from .python.pyMission_problem import MissionProblem from .python.pyMission_problem import MissionProfile from .python.pyMission_problem import MissionSegment from .python.pyWeight_problem import WeightProblem from .python.pyWeight_problem import FuelCase from .python.FluidProperties import FluidProperties from .python.ICAOAtmosphere import ICAOAtmosphere from .python.pyEngine_problem import EngineProblem from .python.pyFieldPerformance_problem import FieldPerformanceProblem from .python.pyLG_problem import LGProblem from .python.py3Util import getPy3SafeString from .python.BaseRegTest import BaseRegTest
36.52
70
0.875137
4a242f2d3fade073b50b80cc76923eaa76d4bef6
11,308
py
Python
v1.0.0.test/toontown/shtiker/HtmlView.py
TTOFFLINE-LEAK/ttoffline
bb0e91704a755d34983e94288d50288e46b68380
[ "MIT" ]
4
2019-07-01T15:46:43.000Z
2021-07-23T16:26:48.000Z
v1.0.0.test/toontown/shtiker/HtmlView.py
TTOFFLINE-LEAK/ttoffline
bb0e91704a755d34983e94288d50288e46b68380
[ "MIT" ]
1
2019-06-29T03:40:05.000Z
2021-06-13T01:15:16.000Z
v1.0.0.test/toontown/shtiker/HtmlView.py
TTOFFLINE-LEAK/ttoffline
bb0e91704a755d34983e94288d50288e46b68380
[ "MIT" ]
4
2019-07-28T21:18:46.000Z
2021-02-25T06:37:25.000Z
import array, sys from direct.showbase.DirectObject import DirectObject from direct.task.Task import Task from direct.directnotify import DirectNotifyGlobal from panda3d.core import Texture, CardMaker, NodePath, Point3, Vec3, Vec4, VBase4D, Point2, PNMImage, TextureStage, Texture, WindowProperties, AwWebView, AwWebCore from direct.interval.IntervalGlobal import * WEB_WIDTH_PIXELS = 784 WEB_HEIGHT_PIXELS = 451 WEB_WIDTH = 1024 WEB_HEIGHT = 512 WEB_HALF_WIDTH = WEB_WIDTH / 2 WIN_WIDTH = 800 WIN_HEIGHT = 600 GlobalWebcore = None class HtmlView(DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('HtmlView') useHalfTexture = base.config.GetBool('news-half-texture', 0) def __init__(self, parent=aspect2d): global GlobalWebcore self.parent = parent self.mx = 0 self.my = 0 self.htmlFile = 'index.html' self.transparency = False if GlobalWebcore: pass else: GlobalWebcore = AwWebCore(AwWebCore.LOGVERBOSE, True, AwWebCore.PFBGRA) GlobalWebcore.setBaseDirectory('.') for errResponse in xrange(400, 600): GlobalWebcore.setCustomResponsePage(errResponse, 'error.html') self.webView = GlobalWebcore.createWebView(WEB_WIDTH, WEB_HEIGHT, self.transparency, False, 70) frameName = '' inGameNewsUrl = self.getInGameNewsUrl() self.imgBuffer = array.array('B') for i in xrange(WEB_WIDTH * WEB_HEIGHT): self.imgBuffer.append(0) self.imgBuffer.append(0) self.imgBuffer.append(0) self.imgBuffer.append(255) if self.useHalfTexture: self.leftBuffer = array.array('B') for i in xrange(WEB_HALF_WIDTH * WEB_HEIGHT): self.leftBuffer.append(0) self.leftBuffer.append(0) self.leftBuffer.append(0) self.leftBuffer.append(255) self.rightBuffer = array.array('B') for i in xrange(WEB_HALF_WIDTH * WEB_HEIGHT): self.rightBuffer.append(0) self.rightBuffer.append(0) self.rightBuffer.append(0) self.rightBuffer.append(255) self.setupTexture() if self.useHalfTexture: self.setupHalfTextures() self.accept('mouse1', self.mouseDown, [AwWebView.LEFTMOUSEBTN]) self.accept('mouse3', self.mouseDown, [AwWebView.RIGHTMOUSEBTN]) self.accept('mouse1-up', self.mouseUp, [AwWebView.LEFTMOUSEBTN]) self.accept('mouse3-up', self.mouseUp, [AwWebView.RIGHTMOUSEBTN]) def getInGameNewsUrl(self): result = base.config.GetString('fallback-news-url', 'http://cdn.toontown.disney.go.com/toontown/en/gamenews/') override = base.config.GetString('in-game-news-url', '') if override: self.notify.info('got an override url, using %s for in a game news' % override) result = override else: try: launcherUrl = base.launcher.getValue('GAME_IN_GAME_NEWS_URL', '') if launcherUrl: result = launcherUrl self.notify.info('got GAME_IN_GAME_NEWS_URL from launcher using %s' % result) else: self.notify.info('blank GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) except: self.notify.warning('got exception getting GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) return result def setupTexture(self): cm = CardMaker('quadMaker') cm.setColor(1.0, 1.0, 1.0, 1.0) aspect = base.camLens.getAspectRatio() htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH) htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT) cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1) bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1) cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1)) card = cm.generate() self.quad = NodePath(card) self.quad.reparentTo(self.parent) self.guiTex = Texture('guiTex') self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) self.guiTex.setMinfilter(Texture.FTLinear) self.guiTex.setKeepRamImage(True) self.guiTex.makeRamImage() self.guiTex.setWrapU(Texture.WMRepeat) self.guiTex.setWrapV(Texture.WMRepeat) ts = TextureStage('webTS') self.quad.setTexture(ts, self.guiTex) self.quad.setTexScale(ts, 1.0, -1.0) self.quad.setTransparency(0) self.quad.setTwoSided(True) self.quad.setColor(1.0, 1.0, 1.0, 1.0) self.calcMouseLimits() def setupHalfTextures(self): self.setupLeftTexture() self.setupRightTexture() self.fullPnmImage = PNMImage(WEB_WIDTH, WEB_HEIGHT, 4) self.leftPnmImage = PNMImage(WEB_HALF_WIDTH, WEB_HEIGHT, 4) self.rightPnmImage = PNMImage(WEB_HALF_WIDTH, WEB_HEIGHT, 4) def setupLeftTexture(self): cm = CardMaker('quadMaker') cm.setColor(1.0, 1.0, 1.0, 1.0) aspect = base.camLens.getAspectRatio() htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH) htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT) cm.setFrame(-htmlWidth / 2.0, 0, -htmlHeight / 2.0, htmlHeight / 2.0) card = cm.generate() self.leftQuad = NodePath(card) self.leftQuad.reparentTo(self.parent) self.leftGuiTex = Texture('guiTex') self.leftGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) self.leftGuiTex.setKeepRamImage(True) self.leftGuiTex.makeRamImage() self.leftGuiTex.setWrapU(Texture.WMClamp) self.leftGuiTex.setWrapV(Texture.WMClamp) ts = TextureStage('leftWebTS') self.leftQuad.setTexture(ts, self.leftGuiTex) self.leftQuad.setTexScale(ts, 1.0, -1.0) self.leftQuad.setTransparency(0) self.leftQuad.setTwoSided(True) self.leftQuad.setColor(1.0, 1.0, 1.0, 1.0) def setupRightTexture(self): cm = CardMaker('quadMaker') cm.setColor(1.0, 1.0, 1.0, 1.0) aspect = base.camLens.getAspectRatio() htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH) htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT) cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) card = cm.generate() self.rightQuad = NodePath(card) self.rightQuad.reparentTo(self.parent) self.rightGuiTex = Texture('guiTex') self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) self.rightGuiTex.setKeepRamImage(True) self.rightGuiTex.makeRamImage() self.rightGuiTex.setWrapU(Texture.WMClamp) self.rightGuiTex.setWrapV(Texture.WMClamp) ts = TextureStage('rightWebTS') self.rightQuad.setTexture(ts, self.rightGuiTex) self.rightQuad.setTexScale(ts, 1.0, -1.0) self.rightQuad.setTransparency(0) self.rightQuad.setTwoSided(True) self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0) def calcMouseLimits(self): ll = Point3() ur = Point3() self.quad.calcTightBounds(ll, ur) self.notify.debug('ll=%s ur=%s' % (ll, ur)) offset = self.quad.getPos(aspect2d) self.notify.debug('offset = %s ' % offset) ll.setZ(ll.getZ() + offset.getZ()) ur.setZ(ur.getZ() + offset.getZ()) self.notify.debug('new LL=%s, UR=%s' % (ll, ur)) relPointll = self.quad.getRelativePoint(aspect2d, ll) self.notify.debug('relPoint = %s' % relPointll) self.mouseLL = (aspect2d.getScale()[0] * ll[0], aspect2d.getScale()[2] * ll[2]) self.mouseUR = (aspect2d.getScale()[0] * ur[0], aspect2d.getScale()[2] * ur[2]) self.notify.debug('original mouseLL=%s, mouseUR=%s' % (self.mouseLL, self.mouseUR)) def writeTex(self, filename='guiText.png'): self.notify.debug('writing texture') self.guiTex.generateRamMipmapImages() self.guiTex.write(filename) def toggleRotation(self): if self.interval.isPlaying(): self.interval.finish() else: self.interval.loop() def mouseDown(self, button): messenger.send('wakeup') self.webView.injectMouseDown(button) def mouseUp(self, button): self.webView.injectMouseUp(button) def reload(self): pass def zoomIn(self): self.webView.zoomIn() def zoomOut(self): self.webView.zoomOut() def toggleTransparency(self): self.transparency = not self.transparency self.webView.setTransparent(self.transparency) def update(self, task): if base.mouseWatcherNode.hasMouse(): x, y = self._translateRelativeCoordinates(base.mouseWatcherNode.getMouseX(), base.mouseWatcherNode.getMouseY()) if self.mx - x != 0 or self.my - y != 0: self.webView.injectMouseMove(x, y) self.mx, self.my = x, y if self.webView.isDirty(): self.webView.render(self.imgBuffer.buffer_info()[0], WEB_WIDTH * 4, 4) Texture.setTexturesPower2(2) textureBuffer = self.guiTex.modifyRamImage() textureBuffer.setData(self.imgBuffer.tostring()) if self.useHalfTexture: self.guiTex.store(self.fullPnmImage) self.leftPnmImage.copySubImage(self.fullPnmImage, 0, 0, 0, 0, WEB_HALF_WIDTH, WEB_HEIGHT) self.rightPnmImage.copySubImage(self.fullPnmImage, 0, 0, WEB_HALF_WIDTH, 0, WEB_HALF_WIDTH, WEB_HEIGHT) self.leftGuiTex.load(self.leftPnmImage) self.rightGuiTex.load(self.rightPnmImage) self.quad.hide() Texture.setTexturesPower2(1) GlobalWebcore.update() return Task.cont def _translateRelativeCoordinates(self, x, y): sx = int((x - self.mouseLL[0]) / (self.mouseUR[0] - self.mouseLL[0]) * WEB_WIDTH_PIXELS) sy = WEB_HEIGHT_PIXELS - int((y - self.mouseLL[1]) / (self.mouseUR[1] - self.mouseLL[1]) * WEB_HEIGHT_PIXELS) return ( sx, sy) def unload(self): self.ignoreAll() self.webView.destroy() self.webView = None return def onCallback(self, name, args): if name == 'requestFPS': pass def onBeginNavigation(self, url, frameName): pass def onBeginLoading(self, url, frameName, statusCode, mimeType): pass def onFinishLoading(self): self.notify.debug('finished loading') def onReceiveTitle(self, title, frameName): pass def onChangeTooltip(self, tooltip): pass def onChangeCursor(self, cursor): pass def onChangeKeyboardFocus(self, isFocused): pass def onChangeTargetURL(self, url): pass
41.12
163
0.628493
4a242f425e51fd7f35811a5211725736592140d9
29,113
py
Python
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
lucianogsilvestri/PlasmaPy
3e234246d9218208f20aaf5e83845049bc6f1584
[ "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-1-Clause", "BSD-3-Clause" ]
null
null
null
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
lucianogsilvestri/PlasmaPy
3e234246d9218208f20aaf5e83845049bc6f1584
[ "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-1-Clause", "BSD-3-Clause" ]
null
null
null
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
lucianogsilvestri/PlasmaPy
3e234246d9218208f20aaf5e83845049bc6f1584
[ "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-1-Clause", "BSD-3-Clause" ]
null
null
null
""" Tests for proton radiography functions """ import astropy.constants as const import astropy.units as u import numpy as np import os import pytest from scipy.special import erf from plasmapy.diagnostics import charged_particle_radiography as cpr from plasmapy.plasma.grids import CartesianGrid def _test_grid( name, L=1 * u.mm, num=100, B0=10 * u.T, E0=5e8 * u.V / u.m, phi0=1.4e5 * u.V, a=None, b=None, ): r""" Generates grids representing some common physical scenarios for testing and illustration. Valid example names are: * axially_magnetized_cylinder : A cylinder of radius L/4 magnetized in the Z-direction (like a solenoid, but without the fringe fields). * electrostatic_discontinuity : A discontinuity in the electric field at z=0 with a radial gaussian profile in the xy plane. * electrostatic_gaussian_sphere : An electric field created by a sphere of potential of radius L/2 with a radial Gaussian distribution. Parameters ---------- name : str Name of example to load (from list above) L : `~u.Quantity` (or array of three of the same) Length scale (or scales). -L and L are passed to the grid constructor as start and stop respectively. The default is 1 cm. num : int or list of three ints The number of points in each direction (or list of one for each dimension). Passed to the grid constructor as the num argument. The default is 100. E0, B0, phi0 : u.Quantities Scaling quantities used in the various examples a, b : u.Quantities Two length scales used in the various examples Returns ------- grid : CartesianGrid A CartesianGrid object containing quantity arrays representing the chosen example. """ grid = CartesianGrid(-L, L, num=num) # If an array was provided to the constructor, reduce to a single # length scale now. if L.size > 1: L = np.max(L) if name == "empty": pass elif name == "constant_bz": Bz = np.ones(grid.shape) * B0 grid.add_quantities(B_z=Bz) elif name == "constant_ex": Ex = np.ones(grid.shape) * E0 grid.add_quantities(E_x=Ex) elif name == "axially_magnetized_cylinder": if a is None: a = L / 4 radius = np.linalg.norm(grid.grid[..., 0:2] * grid.unit, axis=3) Bz = np.where(radius < a, B0, 0 * u.T) grid.add_quantities(B_z=Bz) elif name == "electrostatic_discontinuity": if a is None: a = L / 2 delta = a / 120 radius = np.linalg.norm(grid.grid[..., 0:2] * grid.unit, axis=3) z = grid.grids[2] potential = (1 - erf(z / delta)) * np.exp(-((radius / a) ** 2)) * u.V Ex, Ey, Ez = np.gradient(potential, grid.dax0, grid.dax1, grid.dax2) grid.add_quantities(E_x=Ex, E_y=Ey, E_z=Ez, phi=potential) elif name == "electrostatic_gaussian_sphere": if a is None: a = L / 3 if b is None: b = L / 2 radius = np.linalg.norm(grid.grid, axis=3) arg = (radius / a).to(u.dimensionless_unscaled) potential = phi0 * np.exp(-(arg ** 2)) Ex, Ey, Ez = np.gradient(potential, grid.dax0, grid.dax1, grid.dax2) Ex = np.where(radius < b, Ex, 0) Ey = np.where(radius < b, Ey, 0) Ez = np.where(radius < b, Ez, 0) grid.add_quantities(E_x=-Ex, E_y=-Ey, E_z=-Ez, phi=potential) else: raise ValueError( "No example corresponding to the provided name " f"({name}) exists." ) # If any of the following quantities are missing, add them as empty arrays req_quantities = ["E_x", "E_y", "E_z", "B_x", "B_y", "B_z"] for q in req_quantities: if q not in list(grid.ds.data_vars): unit = grid.recognized_quantities[q].unit arg = {q: np.zeros(grid.shape) * unit} grid.add_quantities(**arg) return grid def run_1D_example(name): """ Run a simulation through an example with parameters optimized to sum up to a lineout along x. The goal is to run a relatively fast sim with a quasi-1D field grid that can then be summed to get good enough statistics to use as a test. """ grid = _test_grid(name, L=1 * u.mm, num=50) # Cartesian source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) # Expect warnings because these fields aren't well-behaved at the edges with pytest.warns( RuntimeWarning, match="Fields should go to zero at edges of grid to avoid " ): sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e4, 3 * u.MeV, max_theta=0.1 * u.deg) sim.run() size = np.array([[-1, 1], [-1, 1]]) * 10 * u.cm bins = [200, 60] hax, vax, values = cpr.synthetic_radiograph(sim, size=size, bins=bins) values = np.mean(values[:, 20:40], axis=1) return hax, values def run_mesh_example( location=np.array([0, -2, 0]) * u.mm, extent=(2 * u.mm, 1.5 * u.mm), nwires=9, wire_diameter=20 * u.um, mesh_hdir=None, mesh_vdir=None, nparticles=1e4, problem="electrostatic_gaussian_sphere", ): """ Takes all of the add_wire_mesh parameters and runs a standard example problem simulation using them. Returns the sim object for use in additional tests """ grid = _test_grid(problem, num=100) source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) sim.add_wire_mesh( location, extent, nwires, wire_diameter, mesh_hdir=mesh_hdir, mesh_vdir=mesh_vdir, ) sim.create_particles(nparticles, 3 * u.MeV, max_theta=10 * u.deg) sim.run(field_weighting="nearest neighbor") return sim @pytest.mark.slow def test_1D_deflections(): # Check B-deflection hax, lineout = run_1D_example("constant_bz") loc = hax[np.argmax(lineout)] assert np.isclose(loc.si.value, 0.0165, 0.005) # Check E-deflection hax, lineout = run_1D_example("constant_ex") loc = hax[np.argmax(lineout)] assert np.isclose(loc.si.value, 0.0335, 0.005) @pytest.mark.slow def test_coordinate_systems(): """ Check that specifying the same point in different coordinate systems ends up with identical source and detector vectors. """ grid = _test_grid("empty") # Cartesian source = (-7.07 * u.mm, -7.07 * u.mm, 0 * u.mm) detector = (70.07 * u.mm, 70.07 * u.mm, 0 * u.mm) sim1 = cpr.Tracker(grid, source, detector, verbose=True) # Cylindrical source = (-1 * u.cm, 45 * u.deg, 0 * u.mm) detector = (10 * u.cm, 45 * u.deg, 0 * u.mm) sim2 = cpr.Tracker(grid, source, detector, verbose=False) # In spherical source = (-0.01 * u.m, 90 * u.deg, 45 * u.deg) detector = (0.1 * u.m, 90 * u.deg, 45 * u.deg) sim3 = cpr.Tracker(grid, source, detector, verbose=False) assert np.allclose(sim1.source, sim2.source, atol=1e-2) assert np.allclose(sim2.source, sim3.source, atol=1e-2) assert np.allclose(sim1.detector, sim2.detector, atol=1e-2) assert np.allclose(sim2.detector, sim3.detector, atol=1e-2) @pytest.mark.slow def test_input_validation(): """ Intentionally raise a number of errors. """ # ************************************************************************ # During initialization # ************************************************************************ grid = _test_grid("electrostatic_gaussian_sphere") source = (-10 * u.mm, 90 * u.deg, 45 * u.deg) detector = (100 * u.mm, 90 * u.deg, 45 * u.deg) # Check that an error is raised when an input grid has a nan or infty value # First check NaN Ex = grid["E_x"] Ex[0, 0, 0] = np.nan * u.V / u.m grid.add_quantities(E_x=Ex) with pytest.raises(ValueError): sim = cpr.Tracker(grid, source, detector, verbose=False) Ex[0, 0, 0] = 0 * u.V / u.m Ex[0, 0, 0] = np.inf * u.V / u.m # Reset element for the rest of the tests grid.add_quantities(E_x=Ex) with pytest.raises(ValueError): sim = cpr.Tracker(grid, source, detector, verbose=False) Ex[0, 0, 0] = 0 * u.V / u.m # Check what happens if a value is large relative to the rest of the array Ex[0, 0, 0] = 0.5 * np.max(Ex) grid.add_quantities(E_x=Ex) # with pytest.raises(ValueError): with pytest.warns(RuntimeWarning): sim = cpr.Tracker(grid, source, detector, verbose=False) Ex[0, 0, 0] = 0 * u.V / u.m # Raise error when source-to-detector vector doesn't pass through the # field grid source_bad = (10 * u.mm, -10 * u.mm, 0 * u.mm) detector_bad = (10 * u.mm, 100 * u.mm, 0 * u.mm) with pytest.raises(ValueError): sim = cpr.Tracker(grid, source_bad, detector_bad, verbose=False) # Test raises warning when one (or more) of the required fields is missing grid_bad = CartesianGrid(-1 * u.mm, 1 * u.mm, num=50) with pytest.warns(RuntimeWarning, match="is not specified for the provided grid."): sim = cpr.Tracker(grid_bad, source, detector, verbose=True) # ************************************************************************ # During create_particles # ************************************************************************ sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e3, 15 * u.MeV, max_theta=0.99 * np.pi / 2 * u.rad) # ************************************************************************ # During runtime # ************************************************************************ sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e3, 15 * u.MeV) # Test an invalid field weighting keyword with pytest.raises(ValueError): sim.run(field_weighting="not a valid field weighting") # ************************************************************************ # During runtime # ************************************************************************ # SYNTHETIC RADIOGRAPH ERRORS sim.run() # Choose a very small synthetic radiograph size that misses most of the # particles with pytest.warns( RuntimeWarning, match="of the particles are shown on this synthetic radiograph." ): size = np.array([[-1, 1], [-1, 1]]) * 1 * u.mm hax, vax, values = cpr.synthetic_radiograph(sim, size=size) def test_init(): grid = _test_grid("electrostatic_gaussian_sphere", num=50) # Cartesian source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) # Test manually setting hdir and vdir hdir = np.array([1, 0, 1]) sim = cpr.Tracker(grid, source, detector, verbose=False, detector_hdir=hdir) # Test special case hdir == [0,0,1] source = (0 * u.mm, 0 * u.mm, -10 * u.mm) detector = (0 * u.mm, 0 * u.mm, 200 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) assert all(sim.det_hdir == np.array([1, 0, 0])) # Test that hdir is calculated correctly if src-det axis is anti-parallel to z source = (0 * u.mm, 0 * u.mm, 10 * u.mm) detector = (0 * u.mm, 0 * u.mm, -200 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) assert all(sim.det_hdir == np.array([1, 0, 0])) def test_create_particles(): grid = _test_grid("electrostatic_gaussian_sphere", num=50) # Cartesian source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles( 1e3, 15 * u.MeV, max_theta=0.1 * u.rad, distribution="monte-carlo" ) sim.create_particles(1e3, 15 * u.MeV, max_theta=0.1 * u.rad, distribution="uniform") # Test specifying particle charge = 3 * const.e.si mass = const.m_e.si sim.create_particles(1e3, 15 * u.MeV, particle="e") @pytest.mark.slow def test_load_particles(): grid = _test_grid("electrostatic_gaussian_sphere", num=50) # Cartesian source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e3, 15 * u.MeV, max_theta=0.1 * u.rad, distribution="uniform") # Test adding unequal numbers of particles x = np.zeros([100, 3]) * u.m v = np.ones([150, 3]) * u.m / u.s with pytest.raises(ValueError): sim.load_particles(x, v) # Test creating particles with explicit keywords x = sim.x * u.m v = sim.v * u.m / u.s # Try setting particles going the wrong direction with pytest.warns(RuntimeWarning): sim.load_particles(x, -v) # Try specifying a larger ion (not a proton or electron) sim.load_particles(x, v, particle="C-12 +3") # Run the tracker to make sure everything works sim.run(field_weighting="nearest neighbor") @pytest.mark.slow def test_run_options(): grid = _test_grid("electrostatic_gaussian_sphere", num=50) # Cartesian source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=True) # Test that trying to call run() without creating particles # raises an exception with pytest.raises(ValueError): sim.run() sim = cpr.Tracker(grid, source, detector, verbose=True) sim.create_particles(1e4, 3 * u.MeV, max_theta=10 * u.deg) # Try running with nearest neighbor interpolator # Test manually setting a timestep sim.run(field_weighting="nearest neighbor", dt=1e-12 * u.s) # Test max_deflections sim.max_deflection # Test way too big of a max_theta sim = cpr.Tracker(grid, source, detector, verbose=True) sim.create_particles(1e4, 3 * u.MeV, max_theta=89 * u.deg) with pytest.warns(RuntimeWarning, match="of " "particles entered the field grid"): sim.run(field_weighting="nearest neighbor", dt=1e-12 * u.s) # Test extreme deflections -> warns user # This requires instantiating a whole new example field with a really # big B-field grid = _test_grid("constant_bz", num=50, B0=250 * u.T) source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) # Expect warnings because these fields aren't well-behaved at the edges with pytest.warns( RuntimeWarning, match="Fields should go to zero at edges of grid to avoid " ): sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e4, 3 * u.MeV, max_theta=0.1 * u.deg) with pytest.warns( RuntimeWarning, match="particles have been " "deflected away from the detector plane", ): sim.run(field_weighting="nearest neighbor", dt=1e-12 * u.s) # Calc max deflection: should be between 0 and pi/2 # Note: that's only true because max_theta is very small # More generally, max_deflection can be a bit bigger than pi/2 for # particles that begin at an angle then deflect all the way around. assert 0 < sim.max_deflection.to(u.rad).value < np.pi / 2 def create_tracker_obj(): # CREATE A RADIOGRAPH OBJECT grid = _test_grid("electrostatic_gaussian_sphere", num=50) source = (0 * u.mm, -10 * u.mm, 0 * u.mm) detector = (0 * u.mm, 200 * u.mm, 0 * u.mm) sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(int(1e4), 3 * u.MeV, max_theta=10 * u.deg) return sim tracker_obj_simulated = create_tracker_obj().run(field_weighting="nearest neighbor") @pytest.mark.slow class TestSyntheticRadiograph: """ Tests for `plasmapy.diagnostics.charged_particle_radiography.synthetic_radiograph`. """ tracker_obj_not_simulated = create_tracker_obj() tracker_obj_simulated = create_tracker_obj() tracker_obj_simulated.run(field_weighting="nearest neighbor") sim_results = tracker_obj_simulated.results_dict.copy() @pytest.mark.parametrize( "args, kwargs, _raises", [ # obj wrong type ((5,), {}, TypeError), # size wrong type ((tracker_obj_simulated,), {"size": "not a Quantity"}, TypeError), # size not convertible to meters ((sim_results,), {"size": 5 * u.ms}, ValueError), # size wrong shape ((sim_results,), {"size": [-1, 1] * u.cm}, ValueError), # simulation was never run ((tracker_obj_not_simulated,), {}, RuntimeError), ], ) def test_raises(self, args, kwargs, _raises): """Test scenarios the raise an Exception.""" with pytest.raises(_raises): cpr.synthetic_radiograph(*args, **kwargs) def test_warns(self): """ Test warning when less than half the particles reach the detector plane. """ sim_results = self.sim_results.copy() sim_results["nparticles"] *= 3 with pytest.warns(RuntimeWarning): cpr.synthetic_radiograph(sim_results) @pytest.mark.parametrize( "args, kwargs, expected", [ ( # From a Tracker object (tracker_obj_simulated,), {}, { "xrange": [-0.036934532101889815, 0.03702186098974771] * u.m, "yrange": [-0.03697401811598356, 0.037007901161403144] * u.m, "bins": (200, 200), }, ), ( # From a dict (sim_results,), {}, { "xrange": [-0.036934532101889815, 0.03702186098974771] * u.m, "yrange": [-0.03697401811598356, 0.037007901161403144] * u.m, "bins": (200, 200), }, ), ( # From a dict (sim_results,), {"size": np.array([[-1, 1], [-1, 1]]) * 30 * u.cm, "bins": (200, 60)}, { "xrange": [-0.3, 0.3] * u.m, "yrange": [-0.3, 0.3] * u.m, "bins": (200, 60), }, ), ], ) def test_intensity_histogram(self, args, kwargs, expected): """Test several valid use cases.""" results = cpr.synthetic_radiograph(*args, **kwargs) assert len(results) == 3 x = results[0] assert isinstance(x, u.Quantity) assert x.unit == u.m assert x.shape == (expected["bins"][0],) assert np.isclose(np.min(x), expected["xrange"][0], rtol=1e4) assert np.isclose(np.max(x), expected["xrange"][1], rtol=1e4) y = results[1] assert isinstance(y, u.Quantity) assert y.unit == u.m assert y.shape == (expected["bins"][1],) assert np.isclose(np.min(y), expected["yrange"][0], rtol=1e4) assert np.isclose(np.max(y), expected["yrange"][1], rtol=1e4) histogram = results[2] assert isinstance(histogram, np.ndarray) assert histogram.shape == expected["bins"] def test_optical_density_histogram(self): """ Test the optical density calculation is correct and stuffed with numpy.inf when the intensity is zero. """ bins = (200, 60) size = np.array([[-1, 1], [-1, 1]]) * 30 * u.cm intensity_results = cpr.synthetic_radiograph( self.sim_results, size=size, bins=bins ) od_results = cpr.synthetic_radiograph( self.sim_results, size=size, bins=bins, optical_density=True ) assert np.allclose(intensity_results[0], od_results[0]) assert np.allclose(intensity_results[1], od_results[1]) intensity = intensity_results[2] zero_mask = intensity == 0 i0 = np.mean(intensity[~zero_mask]) od = -np.log10(intensity / i0) assert np.allclose(od[~zero_mask], od_results[2][~zero_mask]) assert np.all(np.isposinf(od_results[2][zero_mask])) def test_saving_output(tmp_path): """Test behavior of Tracker.save_results.""" sim = create_tracker_obj() # Test that output cannot be saved prior to running with pytest.raises(RuntimeError): _ = sim.results_dict sim.run(field_weighting="nearest neighbor") results_1 = sim.results_dict # Save result path = os.path.join(tmp_path, "temp.npz") sim.save_results(path) # Load result results_2 = dict(np.load(path, "r", allow_pickle=True)) assert set(results_1.keys()) == set(results_2.keys()) for key in results_1.keys(): assert np.allclose(results_1[key], results_2[key]) @pytest.mark.parametrize( "case", ["creating particles", "loading particles", "adding a wire mesh"], ) def test_cannot_modify_simulation_after_running(case): """ Test that a Tracker objection can not be modified after it is run (Tracker.run). """ sim = create_tracker_obj() sim.run(field_weighting="nearest neighbor") # Error from creating particles with pytest.raises(RuntimeError): if case == "creating particles": sim.create_particles(1e4, 3 * u.MeV, max_theta=10 * u.deg) elif case == "loading particles": sim.load_particles(sim.x, sim.v) elif case == "adding a wire mesh": sim.add_wire_mesh( np.array([0, -2, 0]) * u.mm, (2 * u.mm, 1.5 * u.mm), 9, 20 * u.um, ) else: pytest.fail(f"Unrecognized test case '{case}'.") @pytest.mark.slow def test_gaussian_sphere_analytical_comparison(): """ This test runs a known example problem and compares to a theoretical model for small deflections. Still under construction (comparing the actual form of the radiograph is possible but tricky to implement). """ # The Gaussian sphere problem for small deflection potentials # is solved in Kugland2012relation, and the equations referenced # below are from that paper. # https://doi.org/10.1063/1.4750234 a = (1 * u.mm / 3).to(u.mm).value phi0 = 1.4e5 W = 15e6 l = 10 L = 200 # Define and run the problem # Setting b to be much larger than the problem so that the field is not # cut off at the edges. This is required to be directly # comparable to the theoretical result. grid = _test_grid( "electrostatic_gaussian_sphere", num=100, phi0=phi0 * u.V, a=a * u.mm, b=20 * u.mm, ) source = (0 * u.mm, -l * u.mm, 0 * u.mm) detector = (0 * u.mm, L * u.mm, 0 * u.mm) with pytest.warns( RuntimeWarning, match="Fields should go to zero at edges of grid to avoid " ): sim = cpr.Tracker(grid, source, detector, verbose=False) sim.create_particles(1e3, W * u.eV, max_theta=12 * u.deg) sim.run() size = np.array([[-1, 1], [-1, 1]]) * 4 * u.cm bins = [100, 100] h, v, i = cpr.synthetic_radiograph(sim, size=size, bins=bins) h = h.to(u.mm).value / sim.mag v = v.to(u.mm).value / sim.mag r0 = h # Calculate a lineout across the center of the plane (y=0) v0 = np.argmin(np.abs(v)) line = np.mean(i[:, v0 - 6 : v0 + 6], axis=1) # Zero the edge of the radiograph line += -np.mean(line) line *= 1 / np.max(np.abs(line)) # Calculate the theoretical deflection angles (Eq. 28) theory = phi0 / W * np.sqrt(np.pi) * (r0 / a) * np.exp(-((r0 / a) ** 2)) max_deflection = np.max(np.abs(theory)) mu = np.sqrt(np.pi) * (phi0 / W) * (l / a) # sim_mu = sim.max_deflection.to(u.rad).value*(l/a) # Calculate the theoretical inversion (Eq. 31 ) theory_deflect = -2 * mu * (1 - (r0 / a) ** 2) * np.exp(-((r0 / a) ** 2)) theory_deflect *= 1 / np.max(np.abs(theory_deflect)) # Uncomment for debug """ print(f"Theory max deflection: {max_deflection:.6f}") print(f"Theory mu: {mu:.3f}") print(f"Sim max deflection: {sim.max_deflection.to(u.rad).value:.6f}") print(f"Sim mu: {sim_mu:.3f}") import matplotlib.pyplot as plt print(f"Theory max deflection: {max_deflection:.6f}") print(f"Theory mu: {mu:.3f}") print(f"Sim max deflection: {sim.max_deflection.to(u.rad).value:.6f}") print(f"Sim mu: {sim_mu:.3f}") fig, ax = plt.subplots() ax.pcolormesh(h, v, i.T, shading='auto', cmap='Blues_r') ax.set_aspect('equal') fig, ax = plt.subplots() ax.plot(h, line ) ax.plot(h, theory_deflect) """ assert np.isclose(max_deflection, sim.max_deflection.to(u.rad).value, atol=1e-3) @pytest.mark.slow def test_add_wire_mesh(): # ************************************************************ # Test various input configurations # ************************************************************ # Test a circular mesh run_mesh_example(extent=1 * u.mm) # Test providing hdir run_mesh_example(mesh_hdir=np.array([0.5, 0, 0.5])) # Test providing hdir and vdir run_mesh_example(mesh_hdir=np.array([0.5, 0, 0.5]), mesh_vdir=np.array([0, 0.1, 1])) # ************************************************************ # Test invalid inputs # ************************************************************ # Test invalid extent (too many elements) with pytest.raises(ValueError): run_mesh_example(extent=(1 * u.mm, 2 * u.mm, 3 * u.mm)) # Test wire mesh completely blocks all particles (in this case because # the wire diameter is absurdly large) with pytest.raises(ValueError): run_mesh_example(wire_diameter=5 * u.mm) # Test if wire mesh is not between the source and object with pytest.raises(ValueError): run_mesh_example(location=np.array([0, 3, 0]) * u.mm) # ************************************************************ # Test that mesh is the right size in the detector plane, and that # the wire spacing images correctly. # This is actually a good overall test of the whole proton radiography # particle tracing algorithm. # ************************************************************ loc = np.array([0, -2, 0]) * u.mm extent = (1 * u.mm, 1 * u.mm) wire_diameter = 30 * u.um nwires = 9 sim = run_mesh_example( problem="empty", nparticles=1e5, location=loc, extent=extent, wire_diameter=wire_diameter, nwires=nwires, ) # Calculate the width that the grid SHOULD have on the image plane src_to_mesh = np.linalg.norm(loc.si.value - sim.source) mesh_to_det = np.linalg.norm(sim.detector - loc.si.value) mag = 1 + mesh_to_det / src_to_mesh true_width = mag * extent[0].to(u.mm).value true_spacing = true_width / (nwires - 1) # Create a synthetic radiograph size = np.array([[-1, 1], [-1, 1]]) * 2 * u.cm bins = [100, 50] # Expect a warning because many particles are off the radiograph # (Chose max_theta so corners are covered) with pytest.warns(RuntimeWarning): h, v, i = cpr.synthetic_radiograph(sim, size=size, bins=bins) # Sum up the vertical direction line = np.sum(i, axis=1) # Determine the points that are on gridlines: where 1/line is above the # median by a lot ind = np.argwhere(1 / line > 2 * np.median(1 / line)) hwhere = h.to(u.mm).value[ind] measured_width = np.max(hwhere) - np.min(hwhere) # Calculate the max spatial frequency (should be close to the grid spacing) dx = np.abs(size[0][1] - size[0][0]).to(u.mm).value / bins[0] fnyquist = int(bins[0] / 2) freqs = np.fft.fftfreq(h.size, d=dx) freqs = freqs[:fnyquist] # Calculate the positive frequency power spectrum pspect = np.abs(np.fft.fft(1 / line)) ** 2 pspect = pspect[:fnyquist] pspect = np.where(np.abs(freqs) < 0.1, 0, pspect) # Mask the low frequencies # Measured spacing is the inverse of the maximum spatial frequency measured_spacing = 1 / freqs[np.argmax(pspect)] # This test is somewhat tricky, so here's a matplotlib plot # that can be uncommented for debugging """ fig, ax = plt.subplots(nrows=3, figsize=(4,15)) ax[0].pcolormesh(h.to(u.mm).value, v.to(u.mm).value, i.T, cmap='Blues_r') ax[0].set_aspect('equal') ax[0].axvline(x=np.max(hwhere), color='red') ax[0].axvline(x=np.min(hwhere), color='red') ax[1].plot(h.to(u.mm).value, 1/line) ax[1].axhline(y=np.median(1/line)) ax[1].axvline(x=np.max(hwhere), color='red') ax[1].axvline(x=np.min(hwhere), color='red') ax[2].plot(freqs, pspect) """ # Verify that the edges of the mesh are imaged correctly assert np.isclose(measured_width, true_width, 1) # Verify that the spacing is correct by checking the FFT assert np.isclose(measured_spacing, true_spacing, 0.5)
33.734647
88
0.592828
4a242f59c45f3b57ad76aca9df5feeed19a826c8
14,902
py
Python
mmdet/models/detectors/two_stage_mask_assis.py
Gitgigabyte/mmd
02cf37884d3ac9a6018656d1871695669966dfb3
[ "Apache-2.0" ]
1
2020-03-13T08:37:35.000Z
2020-03-13T08:37:35.000Z
mmdet/models/detectors/two_stage_mask_assis.py
Gitgigabyte/mmd
02cf37884d3ac9a6018656d1871695669966dfb3
[ "Apache-2.0" ]
null
null
null
mmdet/models/detectors/two_stage_mask_assis.py
Gitgigabyte/mmd
02cf37884d3ac9a6018656d1871695669966dfb3
[ "Apache-2.0" ]
null
null
null
import torch import torch.nn as nn import torch.nn.functional as F from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler from .. import builder from ..registry import DETECTORS from .base import BaseDetector from .test_mixins import BBoxTestMixin, MaskTestMixin, RPNTestMixin @DETECTORS.register_module class TwoStageDetector_back(BaseDetector, RPNTestMixin, BBoxTestMixin, MaskTestMixin): def __init__(self, backbone, neck=None, shared_head=None, rpn_head=None, bbox_roi_extractor=None, bbox_head=None, # context_head=None, mask_roi_extractor=None, mask_head=None, train_cfg=None, test_cfg=None, pretrained=None): super(TwoStageDetector_back, self).__init__() self.backbone = builder.build_backbone(backbone) if neck is not None: self.neck = builder.build_neck(neck) if shared_head is not None: self.shared_head = builder.build_shared_head(shared_head) if rpn_head is not None: self.rpn_head = builder.build_head(rpn_head) if bbox_head is not None: self.bbox_roi_extractor = builder.build_roi_extractor( bbox_roi_extractor) self.bbox_head = builder.build_head(bbox_head) # if context_head is not None: # self.context_head = builder.build_head(context_head) if mask_head is not None: if mask_roi_extractor is not None: self.mask_roi_extractor = builder.build_roi_extractor( mask_roi_extractor) self.share_roi_extractor = False else: self.share_roi_extractor = True self.mask_roi_extractor = self.bbox_roi_extractor self.mask_head = builder.build_head(mask_head) self.train_cfg = train_cfg self.test_cfg = test_cfg self.init_weights(pretrained=pretrained) @property def with_rpn(self): return hasattr(self, 'rpn_head') and self.rpn_head is not None def init_weights(self, pretrained=None): super(TwoStageDetector_back, self).init_weights(pretrained) self.backbone.init_weights(pretrained=pretrained) if self.with_neck: if isinstance(self.neck, nn.Sequential): for m in self.neck: m.init_weights() else: self.neck.init_weights() if self.with_shared_head: self.shared_head.init_weights(pretrained=pretrained) if self.with_rpn: self.rpn_head.init_weights() if self.with_bbox: self.bbox_roi_extractor.init_weights() self.bbox_head.init_weights() if self.with_mask: self.mask_head.init_weights() if not self.share_roi_extractor: self.mask_roi_extractor.init_weights() def extract_feat(self, img): x = self.backbone(img) if self.with_neck: x = self.neck(x) return x def forward_dummy(self, img): outs = () # backbone x = self.extract_feat(img) # rpn if self.with_rpn: rpn_outs = self.rpn_head(x) outs = outs + (rpn_outs, ) proposals = torch.randn(1000, 4).cuda() # bbox head rois = bbox2roi([proposals]) if self.with_bbox: bbox_feats = self.bbox_roi_extractor( x[:self.bbox_roi_extractor.num_inputs], rois) if self.with_shared_head: bbox_feats = self.shared_head(bbox_feats) cls_score, bbox_pred = self.bbox_head(bbox_feats) outs = outs + (cls_score, bbox_pred) # mask head if self.with_mask: mask_rois = rois[:100] mask_feats = self.mask_roi_extractor( x[:self.mask_roi_extractor.num_inputs], mask_rois) if self.with_shared_head: mask_feats = self.shared_head(mask_feats) mask_pred = self.mask_head(mask_feats) outs = outs + (mask_pred, ) return outs def forward_train(self, img, img_meta, gt_bboxes, gt_labels, gt_bboxes_ignore=None, gt_masks=None, proposals=None): x = self.extract_feat(img) losses = dict() # RPN forward and loss if self.with_rpn: rpn_outs = self.rpn_head(x) rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, self.train_cfg.rpn) rpn_losses = self.rpn_head.loss( *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) losses.update(rpn_losses) proposal_cfg = self.train_cfg.get('rpn_proposal', self.test_cfg.rpn) proposal_inputs = rpn_outs + (img_meta, proposal_cfg) proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) else: proposal_list = proposals # assign gts and sample proposals if self.with_bbox or self.with_mask: bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) bbox_sampler = build_sampler( self.train_cfg.rcnn.sampler, context=self) num_imgs = img.size(0) if gt_bboxes_ignore is None: gt_bboxes_ignore = [None for _ in range(num_imgs)] sampling_results = [] for i in range(num_imgs): assign_result = bbox_assigner.assign(proposal_list[i], gt_bboxes[i], gt_bboxes_ignore[i], gt_labels[i]) sampling_result = bbox_sampler.sample( assign_result, proposal_list[i], gt_bboxes[i], gt_labels[i], feats=[lvl_feat[i][None] for lvl_feat in x]) sampling_results.append(sampling_result) # bbox head forward and loss if self.with_bbox: rois = bbox2roi([res.bboxes for res in sampling_results]) # TODO: a more flexible way to decide which feature maps to use bbox_feats = self.bbox_roi_extractor( x[:self.bbox_roi_extractor.num_inputs], rois) if self.with_mask: if not self.share_roi_extractor: mask_feats = self.mask_roi_extractor( x[:self.mask_roi_extractor.num_inputs], rois) if self.with_shared_head: mask_feats = self.shared_head(mask_feats) else: pos_inds = [] device = bbox_feats.device for res in sampling_results: pos_inds.append( torch.ones( res.pos_bboxes.shape[0], device=device, dtype=torch.uint8)) pos_inds.append( torch.zeros( res.neg_bboxes.shape[0], device=device, dtype=torch.uint8)) pos_inds = torch.cat(pos_inds) mask_feats = bbox_feats[pos_inds] mask_pred = self.mask_head(mask_feats) mask_targets = self.mask_head.get_target(sampling_results, gt_masks, self.train_cfg.rcnn) # fetched_mask = self.mask_head.fetch_mask(mask_pred.detach(), mask_cls_pred) # bbox_feats = F.adaptive_max_pool2d(mask_feats, (7, 7)) if self.with_shared_head: bbox_feats = self.shared_head(bbox_feats) cls_score, bbox_pred = self.bbox_head(bbox_feats, mask_pred.detach()) bbox_targets = self.bbox_head.get_target(sampling_results, gt_bboxes, gt_labels, self.train_cfg.rcnn) pos_labels = [res.pos_gt_labels for res in sampling_results] neg_labels = [torch.zeros_like(res.neg_inds) for res in sampling_results] labels = zip(pos_labels, neg_labels) labels = torch.cat([torch.cat(label) for label in labels]) loss_mask = self.mask_head.loss(mask_pred, mask_targets, labels) losses.update(loss_mask) # Modified by Pleaplusone # _,_,H,W = bbox_feats.size() # seg_feats = F.adaptive_max_pool2d(mask_pred, (H,W)) # bbox_feats = torch.cat([bbox_feats, seg_feats], dim=1) # bbox_feats = F.adaptive_max_pool2d(mask_feats, (7,7)) loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, *bbox_targets) losses.update(loss_bbox) return losses # def simple_test_mask(self, # x, # img_meta, # proposals, # rescale=False): # # scale_factor = img_meta[0]['scale_factor'] # # _bboxes = ( # # proposals[:,:4] * scale_factor if rescale else proposals # # ) # mask_rois = bbox2roi(proposals) # mask_feats = self.mask_roi_extractor(x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) # if self.with_shared_head: # mask_feats = self.shared_head(mask_feats) # mask_pred, mask_cls_pred = self.mask_head(mask_feats) # # return mask_pred, mask_cls_pred def simple_test_mask(self, x, img_meta, det_bboxes, det_labels, rescale=False): # image shape of the first image in the batch (only one) ori_shape = img_meta[0]['ori_shape'] scale_factor = img_meta[0]['scale_factor'] if det_bboxes.shape[0] == 0: segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] else: # if det_bboxes is rescaled to the original image size, we need to # rescale it back to the testing scale to obtain RoIs. _bboxes = ( det_bboxes[:, :4] * scale_factor if rescale else det_bboxes) mask_rois = bbox2roi([_bboxes]) mask_feats = self.mask_roi_extractor( x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) if self.with_shared_head: mask_feats = self.shared_head(mask_feats) mask_pred = self.mask_head(mask_feats) segm_result = self.mask_head.get_seg_masks(mask_pred, _bboxes, det_labels, self.test_cfg.rcnn, ori_shape, scale_factor, rescale) return segm_result def simple_test_bboxes(self, x, img_meta, mask_feats, proposals, rcnn_test_cfg, rescale=False): rois = bbox2roi(proposals) roi_feats = self.bbox_roi_extractor( x[:self.bbox_roi_extractor.num_inputs], rois) if self.with_shared_head: roi_feats = self.shared_head(roi_feats) # roi_feats = self.context_head(roi_feats, mask_feats) cls_score, bbox_pred = self.bbox_head(roi_feats, mask_feats) img_shape = img_meta[0]['img_shape'] scale_factor = img_meta[0]['scale_factor'] det_bboxes, det_labels = self.bbox_head.get_det_bboxes( rois, cls_score, bbox_pred, img_shape, scale_factor, rescale=rescale, cfg = rcnn_test_cfg ) return det_bboxes, det_labels def simple_test(self, img, img_meta, proposals=None, rescale=False): """Test without augmentation.""" assert self.with_bbox, "Bbox head must be implemented." x = self.extract_feat(img) proposal_list = self.simple_test_rpn( x, img_meta, self.test_cfg.rpn) if proposals is None else proposals mask_rois = bbox2roi(proposal_list) mask_feats = self.mask_roi_extractor(x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) if self.with_shared_head: mask_feats = self.shared_head(mask_feats) mask_pred = self.mask_head(mask_feats) # fetched_mask = self.mask_head.fetch_mask(mask_pred, mask_cls_pred) det_bboxes, det_labels = self.simple_test_bboxes( x, img_meta, mask_pred, proposal_list, self.test_cfg.rcnn, rescale=rescale) bbox_results = bbox2result(det_bboxes, det_labels, self.bbox_head.num_classes) if not self.with_mask: return bbox_results else: segm_results = self.simple_test_mask( x, img_meta, det_bboxes, det_labels, rescale=rescale) return bbox_results, segm_results def aug_test(self, imgs, img_metas, rescale=False): """Test with augmentations. If rescale is False, then returned bboxes and masks will fit the scale of imgs[0]. """ # recompute feats to save memory proposal_list = self.aug_test_rpn( self.extract_feats(imgs), img_metas, self.test_cfg.rpn) det_bboxes, det_labels = self.aug_test_bboxes( self.extract_feats(imgs), img_metas, proposal_list, self.test_cfg.rcnn) if rescale: _det_bboxes = det_bboxes else: _det_bboxes = det_bboxes.clone() _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor'] bbox_results = bbox2result(_det_bboxes, det_labels, self.bbox_head.num_classes) # det_bboxes always keep the original scale if self.with_mask: segm_results = self.aug_test_mask( self.extract_feats(imgs), img_metas, det_bboxes, det_labels) return bbox_results, segm_results else: return bbox_results
40.275676
107
0.549255
4a242f99cafd9dd2c7691cf6df7a3fd333fedba3
527
py
Python
trabalho-numerico/contorno.py
heissonwillen/tcm
71da46489f12e64b50436b17447721cb8f7eaf09
[ "MIT" ]
null
null
null
trabalho-numerico/contorno.py
heissonwillen/tcm
71da46489f12e64b50436b17447721cb8f7eaf09
[ "MIT" ]
null
null
null
trabalho-numerico/contorno.py
heissonwillen/tcm
71da46489f12e64b50436b17447721cb8f7eaf09
[ "MIT" ]
null
null
null
import numpy as np from constantes import INTERVALOS, DELTA_X '''Problema 0 ''' p_0 = np.zeros(INTERVALOS+1, float) p_0[-1] = 1 '''Problema 1 T(0, t) = 0 e T(1, t) = 0, t ≥ 0 T(x, 0) = 1, 0 < x < 1 ''' p_1 = np.linspace(1, 1, INTERVALOS+1) p_1[0] = 0 p_1[-1] = 0 '''Problema 2 T(0, t) = 0 e T(1, t) = 0, t ≥ 0 T(x, 0) = 1, 0 < x < 1 ''' p_2 = np.linspace(0, 0, INTERVALOS+1) p_2[0] = 1 '''Problema 3 T(0, t) = T(2, t) = 0 , t ≥ 0 T(x, 0) = sin(πx/2), 0 < x < 2 ''' p_3 = np.sin(np.linspace(0, 2, INTERVALOS+1)) p_3[-1] = 0
17.566667
45
0.529412
4a24305aac801a70470ffd33b06e1045d6d3a986
9,260
py
Python
bigbench/seqio/tasks_test.py
SafeRoboticsLab/BIG-bench
ba5569eb3579efaeaa3df1b93d71eceb2b542def
[ "Apache-2.0" ]
1
2021-10-07T20:52:41.000Z
2021-10-07T20:52:41.000Z
bigbench/seqio/tasks_test.py
SafeRoboticsLab/BIG-bench
ba5569eb3579efaeaa3df1b93d71eceb2b542def
[ "Apache-2.0" ]
null
null
null
bigbench/seqio/tasks_test.py
SafeRoboticsLab/BIG-bench
ba5569eb3579efaeaa3df1b93d71eceb2b542def
[ "Apache-2.0" ]
1
2021-09-24T17:27:41.000Z
2021-09-24T17:27:41.000Z
# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for tasks and mixtures.""" import itertools from absl.testing import absltest from absl.testing import parameterized from bigbench.seqio import vocabs from bigbench.seqio import bigbench_bridge as bb from bigbench.seqio import bigbench_json_paths from bigbench.seqio import task_api from bigbench.seqio import tasks from bigbench.seqio import utils from bigbench.benchmark_tasks import generate_task_summaries import seqio _SEQUENCE_LENGTH = {"inputs": 512, "targets": 256} _TASKS = [t for t in seqio.TaskRegistry.names() if "bigbench:" in t][:100] _MIXTURES = [t for t in seqio.MixtureRegistry.names() if "bigbench:" in t][:2] class MixturesTest(parameterized.TestCase): @classmethod def setUpClass(cls): super(MixturesTest, cls).setUpClass() # make sure metadata is up to date # import here to avoid ciruclar import error generate_task_summaries.update_task_metadata() @parameterized.named_parameters( [ ( f"{shots}_shot_{voc}_vocab_{max_examples}_max", shots, voc, max_examples, ) # pylint:disable=g-complex-comprehension for shots, voc, max_examples in itertools.product( tasks.GLOBAL_FEWSHOT_SETTINGS, tasks.GLOBAL_VOCABS.keys(), tasks.GLOBAL_MAX_EXAMPLES_PER_TASK, ) ] ) def test_task_names(self, shots, voc_name, max_examples): all_task_names = [] voc = vocabs.ALL_VOCABS[voc_name] bb_task_names = bigbench_json_paths.get_task_names() for task_name in bb_task_names: task_max_examples = None if max_examples: task_max_examples = min( max_examples, bigbench_json_paths.get_num_examples(task_name) ) formatted_task_name = utils.format_name_for_seqio(task_name) if bigbench_json_paths.has_subtasks(task_name): subtask_names = bigbench_json_paths.get_subtask_names(task_name) for subtask_name in subtask_names: subtask_max_examples = None if max_examples: subtask_max_examples = min( max_examples // len(subtask_names), bigbench_json_paths.get_num_examples(subtask_name), ) formatted_subtask_name = utils.format_name_for_seqio( subtask_name.split(":")[-1] ) task_types = bigbench_json_paths.get_task_types(subtask_name) for task_type in task_types: subtask_name = task_api.get_seqio_name( formatted_task_name, task_type, voc, shots, formatted_subtask_name, subtask_max_examples, ) all_task_names.append(subtask_name) else: task_types = bigbench_json_paths.get_task_types(task_name) for task_type in task_types: task_name = task_api.get_seqio_name( formatted_task_name, task_type, voc, shots, None, task_max_examples, ) all_task_names.append(task_name) registered_bb_task_names = [ t for t in seqio.TaskRegistry.names() if "bigbench:" in t and f".{shots}_shot." in t and f".{voc_name}_vocab." in t ] all_examples_prefix = ".all_examples" if max_examples: registered_bb_task_names = [ t for t in registered_bb_task_names if all_examples_prefix not in t ] else: registered_bb_task_names = [ t for t in registered_bb_task_names if all_examples_prefix in t ] self.assertListEqual(registered_bb_task_names, all_task_names) @parameterized.named_parameters( [ ( f"{shots}_shot_{voc}_vocab_{max_examples}_max", shots, voc, max_examples, ) # pylint:disable=g-complex-comprehension for shots, voc, max_examples in itertools.product( tasks.GLOBAL_FEWSHOT_SETTINGS, tasks.GLOBAL_VOCABS.keys(), tasks.GLOBAL_MAX_EXAMPLES_PER_TASK, ) ] ) def test_mixture_names(self, shots, voc_name, max_examples): all_mixture_names = [] voc = vocabs.ALL_VOCABS[voc_name] bb_task_names = bigbench_json_paths.get_task_names() for task_name in bb_task_names: task_max_examples = None task_types = bigbench_json_paths.get_task_types(task_name) if max_examples: task_max_examples = min( max_examples, bigbench_json_paths.get_num_examples(task_name) ) formatted_task_name = utils.format_name_for_seqio(task_name) if bigbench_json_paths.has_subtasks(task_name) or len(task_types) > 1: if bigbench_json_paths.has_subtasks(task_name): subtask_names = bigbench_json_paths.get_subtask_names(task_name) num_subtasks = len(subtask_names) def div_or_none(x, y): return x // y if x else x for subtask_name in subtask_names: max_examples_per_subtask = div_or_none( max_examples, num_subtasks ) subtask_types = bigbench_json_paths.get_task_types(subtask_name) if len(subtask_types) > 1: formatted_subtask_name = utils.format_name_for_seqio( subtask_name.split(":")[-1] ) def min_or_none(x, y): return min(x, y) if x else x examples = bigbench_json_paths.get_num_examples( subtask_name ) max_examples_per_subtask = min_or_none( max_examples_per_subtask, examples ) mixture_name = task_api.get_seqio_name( bigbench_task_name=formatted_task_name, bigbench_task_type=bb.BigBenchTaskType.MIX, vocab=voc, num_shots=shots, bigbench_subtask_name=formatted_subtask_name, max_examples=max_examples_per_subtask, ) all_mixture_names.append(mixture_name) mixture_name = task_api.get_seqio_name( formatted_task_name, bb.BigBenchTaskType.MIX, voc, shots, None, task_max_examples, ) all_mixture_names.append(mixture_name) all_mixture_name = task_api.get_seqio_name( "all_json", bb.BigBenchTaskType.MIX, voc, shots, None, max_examples ) all_mixture_names.append(all_mixture_name) bb_lite_v1_mixture_name = task_api.get_seqio_name( "bigbench_lite_v1", bb.BigBenchTaskType.MIX, voc, shots, None, max_examples ) all_mixture_names.append(bb_lite_v1_mixture_name) registered_bb_mixture_names = [ t for t in seqio.MixtureRegistry.names() if "bigbench:" in t and f".{shots}_shot." in t and f".{voc_name}_vocab." in t ] all_examples_prefix = ".all_examples" if max_examples: registered_bb_mixture_names = [ t for t in registered_bb_mixture_names if all_examples_prefix not in t ] else: registered_bb_mixture_names = [ t for t in registered_bb_mixture_names if all_examples_prefix in t ] self.assertListEqual(registered_bb_mixture_names, all_mixture_names) if __name__ == "__main__": absltest.main()
40.26087
88
0.558315
4a24335a2137933438ce5640a47cf8d7c1a859b7
8,111
py
Python
papers/cats/utility/get_online_results.py
Ark-kun/vowpal_wabbit
d811c93fa6adbb513729698202984e3662a3d8df
[ "BSD-3-Clause" ]
4,332
2015-01-01T10:26:51.000Z
2018-10-01T14:05:43.000Z
papers/cats/utility/get_online_results.py
chrinide/vowpal_wabbit
40e1fef676ca6a461d71cf0631ab5c63d1af5d8a
[ "BSD-3-Clause" ]
1,004
2015-01-01T12:00:54.000Z
2018-09-30T22:13:42.000Z
papers/cats/utility/get_online_results.py
chrinide/vowpal_wabbit
40e1fef676ca6a461d71cf0631ab5c63d1af5d8a
[ "BSD-3-Clause" ]
1,182
2015-01-02T20:38:55.000Z
2018-09-26T02:47:37.000Z
import sys import getopt from confidence_interval import ConfidenceInterval def nextword(target, source): for i, w in enumerate(source): if w == target: return source[i + 1] class LossStructOn: def __init__( self, model, n, h, loss, time, max_cost, nb_examples, ci_lower, ci_upper ): self.model = model self.n = n self.h = h self.loss = loss self.time = time self.max_cost = max_cost self.nb_examples = nb_examples self.ci_lower = ci_lower self.ci_upper = ci_upper class EvaluatorOnline: def __init__(self, file_name, alpha, quiet): self.file_name = file_name self.conf_alpha = alpha self.costs = [] self.best_cats = LossStructOn("cats", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0) self.best_disc_tree = LossStructOn( "disc_tree", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0 ) self.best_disc_linear = LossStructOn( "disc_linear", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0 ) self.max_time = 0.0 self.quiet = quiet def eval(self): data_file = open(self.file_name, "r") line = data_file.readline() while line: # Get data if line.find("CATS-online") != -1: self.costs.append( LossStructOn("cats", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0) ) elif line.find("Discretized-Tree-online") != -1: self.costs.append( LossStructOn("disc_tree", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0) ) elif line.find("Discretized-Linear-online") != -1: self.costs.append( LossStructOn("disc_linear", 0, 0, sys.float_info.max, 0, 0, 0, 0, 0) ) elif line.find("timeout") != -1: s1 = line.split() self.max_time = float(nextword("timeout", s1)) elif line.find("n = ") != -1: separator_position = len("n = ") separator_position_end = line.find("\n") self.costs[len(self.costs) - 1].n = float( line[separator_position:separator_position_end] ) elif line.find("h = ") != -1: separator_position = len("h = ") separator_position_end = line.find("\n") self.costs[len(self.costs) - 1].h = float( line[separator_position:separator_position_end] ) elif line.find("Max Cost=") != -1: separator_position = len("Max Cost=") self.costs[len(self.costs) - 1].max_cost = float( line[separator_position:] ) elif line.find("number of examples") != -1: s1 = line.split() self.costs[len(self.costs) - 1].nb_examples = int(nextword("=", s1)) elif line.find("average loss") != -1: s1 = line.split() self.costs[len(self.costs) - 1].loss = float(nextword("=", s1)) elif line.find("real") != -1: s1 = line.split() self.costs[len(self.costs) - 1].time = float(nextword("real", s1)) line = data_file.readline() self.get_best_loss() self.saveConfidenceIntervals(self.best_cats) self.saveConfidenceIntervals(self.best_disc_tree) self.saveConfidenceIntervals(self.best_disc_linear) if not self.quiet: self.printAllResults() print("max_time = ", self.max_time) self.printBestResults(self.best_cats) self.printBestResults(self.best_disc_tree) self.printBestResults(self.best_disc_linear) self.find_error() def return_loss(self, model): if model == "cats": return self.best_cats.loss, self.best_cats.ci_lower, self.best_cats.ci_upper elif model == "disc_tree": return ( self.best_disc_tree.loss, self.best_disc_tree.ci_lower, self.best_disc_tree.ci_upper, ) elif model == "disc_linear": return ( self.best_disc_linear.loss, self.best_disc_linear.ci_lower, self.best_disc_linear.ci_upper, ) def return_all(self, model): n_ = [] h_ = [] loss_ = [] time_ = [] for c in self.costs: if c.model == model: if c.loss < 1: loss_.append(c.loss) time_.append(c.time) n_.append(c.n) h_.append(c.h) return loss_, time_, n_, h_ def get_best_loss(self): for c in self.costs: if c.model == "cats": if c.loss < self.best_cats.loss: self.best_cats = c elif c.model == "disc_tree": if c.loss < self.best_disc_tree.loss: self.best_disc_tree = c elif c.model == "disc_linear": if c.loss < self.best_disc_linear.loss: self.best_disc_linear = c def saveConfidenceIntervals(self, cost): if cost.max_cost != 0: cost.ci_lower, cost.ci_upper = ConfidenceInterval.calculate( cost.nb_examples, cost.loss, cost.max_cost, self.conf_alpha ) def getTime(self, model, n, hp, h, mode): # assumes costs is soreted wrt hp and n times = [] if mode == "hp": n_ = [] for c in self.costs: if c.model == model: if c.h == hp: times.append(c.time) n_.append(c.n) return times, n_ elif mode == "h": n_ = [] for c in self.costs: if c.model == model: if (c.h / c.n) == h: times.append(c.time) n_.append(c.n) return times, n_ elif mode == "n": h_ = [] for c in self.costs: if c.model == model: if c.n == n: times.append(c.time) h_.append(c.h) return times, h_ def printAllResults(self): for cost in self.costs: print( "model, n, h, loss, time = {0}, {1}, {2}, {3}, {4}".format( cost.model, cost.n, cost.h, cost.loss, cost.time ) ) def printBestResults(self, cost): print( "model, n, h, loss, time = {0}, {1}, {2}, {3}, {4}".format( cost.model, cost.n, cost.h, cost.loss, cost.time ) ) print("C.I. = {0}, {1}".format(cost.ci_lower, cost.ci_upper)) def find_error(self): for c in self.costs: if c.loss == sys.float_info.max: if c.time < self.max_time: print("error in model={0}, n={1}, h={2}".format(c.model, c.n, c.h)) if __name__ == "__main__": namee = "BNG_cpu_act" data_file = "../../results/" + namee + "_online_validation.txt" alpha = 0.05 model = "cats" quiet = False # Parse options - get predict and data file names args = sys.argv[1:] opts, args = getopt.getopt( args, "d:a:r:q", ["data_file=", "alpha=", "return_model=", "quiet"] ) for opt, arg in opts: if opt in ("-d", "--data_file"): data_file = arg elif opt in ("-a", "--alpha"): alpha = float(arg) elif opt in ("-r", "--return_model"): model = arg elif opt in ("-q", "--quiet"): quiet = True # Print join lines to stdout fileJoiner = EvaluatorOnline(data_file, alpha, quiet) returnValue = fileJoiner.eval() print(fileJoiner.return_loss(model)) print(fileJoiner.getTime("disc_linear", 0, 0, 0, "hp"))
33.241803
88
0.496116
4a2433cb874833c3e46561d215afaed7b8e308fb
30,727
py
Python
MinkowskiEngine/MinkowskiSparseTensor.py
Geomni/MinkowskiEngine
0d06bd4ed183a28386464102e6b48acae80a99b3
[ "MIT" ]
null
null
null
MinkowskiEngine/MinkowskiSparseTensor.py
Geomni/MinkowskiEngine
0d06bd4ed183a28386464102e6b48acae80a99b3
[ "MIT" ]
null
null
null
MinkowskiEngine/MinkowskiSparseTensor.py
Geomni/MinkowskiEngine
0d06bd4ed183a28386464102e6b48acae80a99b3
[ "MIT" ]
null
null
null
# Copyright (c) 2020 NVIDIA CORPORATION. # Copyright (c) 2018-2020 Chris Choy ([email protected]). # # 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. # # Please cite "4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural # Networks", CVPR'19 (https://arxiv.org/abs/1904.08755) if you use any part # of the code. import os import torch import warnings from MinkowskiCommon import convert_to_int_list, StrideType from MinkowskiEngineBackend._C import ( CoordinateMapKey, CoordinateMapType, GPUMemoryAllocatorType, MinkowskiAlgorithm, ) from MinkowskiTensor import ( SparseTensorQuantizationMode, SparseTensorOperationMode, Tensor, sparse_tensor_operation_mode, global_coordinate_manager, set_global_coordinate_manager, ) from MinkowskiCoordinateManager import CoordinateManager from sparse_matrix_functions import MinkowskiSPMMFunction class SparseTensor(Tensor): r"""A sparse tensor class. Can be accessed via :attr:`MinkowskiEngine.SparseTensor`. The :attr:`SparseTensor` class is the basic tensor in MinkowskiEngine. For the definition of a sparse tensor, please visit `the terminology page <https://nvidia.github.io/MinkowskiEngine/terminology.html#sparse-tensor>`_. We use the COOrdinate (COO) format to save a sparse tensor `[1] <http://groups.csail.mit.edu/commit/papers/2016/parker-thesis.pdf>`_. This representation is simply a concatenation of coordinates in a matrix :math:`C` and associated features :math:`F`. .. math:: \mathbf{C} = \begin{bmatrix} b_1 & x_1^1 & x_1^2 & \cdots & x_1^D \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ b_N & x_N^1 & x_N^2 & \cdots & x_N^D \end{bmatrix}, \; \mathbf{F} = \begin{bmatrix} \mathbf{f}_1^T\\ \vdots\\ \mathbf{f}_N^T \end{bmatrix} where :math:`\mathbf{x}_i \in \mathcal{Z}^D` is a :math:`D`-dimensional coordinate and :math:`b_i \in \mathcal{Z}_+` denotes the corresponding batch index. :math:`N` is the number of non-zero elements in the sparse tensor, each with the coordinate :math:`(b_i, x_i^1, x_i^1, \cdots, x_i^D)`, and the associated feature :math:`\mathbf{f}_i`. Internally, we handle the batch index as an additional spatial dimension. Example:: >>> coords, feats = ME.utils.sparse_collate([coords_batch0, coords_batch1], [feats_batch0, feats_batch1]) >>> A = ME.SparseTensor(features=feats, coordinates=coords) >>> B = ME.SparseTensor(features=feats, coordinate_map_key=A.coordiante_map_key, coordinate_manager=A.coordinate_manager) >>> C = ME.SparseTensor(features=feats, coordinates=coords, quantization_mode=ME.SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE) >>> D = ME.SparseTensor(features=feats, coordinates=coords, quantization_mode=ME.SparseTensorQuantizationMode.RANDOM_SUBSAMPLE) >>> E = ME.SparseTensor(features=feats, coordinates=coords, tensor_stride=2) .. warning:: To use the GPU-backend for coordinate management, the :attr:`coordinates` must be a torch tensor on GPU. Applying `to(device)` after :attr:`MinkowskiEngine.SparseTensor` initialization with a CPU `coordinates` will waste time and computation on creating an unnecessary CPU CoordinateMap since the GPU CoordinateMap will be created from scratch as well. .. warning:: Before MinkowskiEngine version 0.4, we put the batch indices on the last column. Thus, direct manipulation of coordinates will be incompatible with the latest versions. Instead, please use :attr:`MinkowskiEngine.utils.batched_coordinates` or :attr:`MinkowskiEngine.utils.sparse_collate` to create batched coordinates. Also, to access coordinates or features batch-wise, use the functions :attr:`coordinates_at(batch_index : int)`, :attr:`features_at(batch_index : int)` of a sparse tensor. Or to access all batch-wise coordinates and features, `decomposed_coordinates`, `decomposed_features`, `decomposed_coordinates_and_features` of a sparse tensor. Example:: >>> coords, feats = ME.utils.sparse_collate([coords_batch0, coords_batch1], [feats_batch0, feats_batch1]) >>> A = ME.SparseTensor(feats=feats, coords=coords) >>> coords_batch0 = A.coordinates_at(batch_index=0) >>> feats_batch1 = A.features_at(batch_index=1) >>> list_of_coords, list_of_featurs = A.decomposed_coordinates_and_features """ def __init__( self, features: torch.Tensor, coordinates: torch.Tensor = None, # optional coordinate related arguments tensor_stride: StrideType = 1, coordinate_map_key: CoordinateMapKey = None, coordinate_manager: CoordinateManager = None, quantization_mode: SparseTensorQuantizationMode = SparseTensorQuantizationMode.RANDOM_SUBSAMPLE, # optional manager related arguments allocator_type: GPUMemoryAllocatorType = None, minkowski_algorithm: MinkowskiAlgorithm = None, requires_grad=None, device=None, ): r""" Args: :attr:`features` (:attr:`torch.FloatTensor`, :attr:`torch.DoubleTensor`, :attr:`torch.cuda.FloatTensor`, or :attr:`torch.cuda.DoubleTensor`): The features of a sparse tensor. :attr:`coordinates` (:attr:`torch.IntTensor`): The coordinates associated to the features. If not provided, :attr:`coordinate_map_key` must be provided. :attr:`tensor_stride` (:attr:`int`, :attr:`list`, :attr:`numpy.array`, or :attr:`tensor.Tensor`): The tensor stride of the current sparse tensor. By default, it is 1. :attr:`coordinate_map_key` (:attr:`MinkowskiEngine.CoordinateMapKey`): When the coordinates are already cached in the MinkowskiEngine, we could reuse the same coordinate map by simply providing the coordinate map key. In most case, this process is done automatically. When you provide a `coordinate_map_key`, `coordinates` will be be ignored. :attr:`coordinate_manager` (:attr:`MinkowskiEngine.CoordinateManager`): The MinkowskiEngine manages all coordinate maps using the `_C.CoordinateMapManager`. If not provided, the MinkowskiEngine will create a new computation graph. In most cases, this process is handled automatically and you do not need to use this. :attr:`quantization_mode` (:attr:`MinkowskiEngine.SparseTensorQuantizationMode`): Defines how continuous coordinates will be quantized to define a sparse tensor. Please refer to :attr:`SparseTensorQuantizationMode` for details. :attr:`allocator_type` (:attr:`MinkowskiEngine.GPUMemoryAllocatorType`): Defines the GPU memory allocator type. By default, it uses the c10 allocator. :attr:`minkowski_algorithm` (:attr:`MinkowskiEngine.MinkowskiAlgorithm`): Controls the mode the minkowski engine runs, Use :attr:`MinkowskiAlgorithm.MEMORY_EFFICIENT` if you want to reduce the memory footprint. Or use :attr:`MinkowskiAlgorithm.SPEED_OPTIMIZED` if you want to make it run fasterat the cost of more memory. :attr:`requires_grad` (:attr:`bool`): Set the requires_grad flag. :attr:`device` (:attr:`torch.device`): Set the device the sparse tensor is defined. """ # Type checks assert isinstance(features, torch.Tensor), "Features must be a torch.Tensor" assert ( features.ndim == 2 ), f"The feature should be a matrix, The input feature is an order-{features.ndim} tensor." assert isinstance(quantization_mode, SparseTensorQuantizationMode) self.quantization_mode = quantization_mode if coordinates is not None: assert isinstance(coordinates, torch.Tensor) if coordinate_map_key is not None: assert isinstance(coordinate_map_key, CoordinateMapKey) if coordinate_manager is not None: assert isinstance(coordinate_manager, CoordinateManager) if coordinates is None and ( coordinate_map_key is None or coordinate_manager is None ): raise ValueError( "Either coordinates or (coordinate_map_key, coordinate_manager) pair must be provided." ) Tensor.__init__(self) # To device if device is not None: features = features.to(device) if coordinates is not None: # assertion check for the map key done later coordinates = coordinates.to(device) self._D = ( coordinates.size(1) - 1 if coordinates is not None else coordinate_manager.D ) ########################## # Setup CoordsManager ########################## if coordinate_manager is None: # If set to share the coords man, use the global coords man if ( sparse_tensor_operation_mode() == SparseTensorOperationMode.SHARE_COORDINATE_MANAGER ): coordinate_manager = global_coordinate_manager() if coordinate_manager is None: coordinate_manager = CoordinateManager( D=self._D, coordinate_map_type=CoordinateMapType.CUDA if coordinates.is_cuda else CoordinateMapType.CPU, allocator_type=allocator_type, minkowski_algorithm=minkowski_algorithm, ) set_global_coordinate_manager(coordinate_manager) else: coordinate_manager = CoordinateManager( D=coordinates.size(1) - 1, coordinate_map_type=CoordinateMapType.CUDA if coordinates.is_cuda else CoordinateMapType.CPU, allocator_type=allocator_type, minkowski_algorithm=minkowski_algorithm, ) self._manager = coordinate_manager ########################## # Initialize coords ########################## if coordinates is not None: assert ( features.shape[0] == coordinates.shape[0] ), "The number of rows in features and coordinates must match." assert ( features.is_cuda == coordinates.is_cuda ), "Features and coordinates must have the same backend." coordinate_map_key = CoordinateMapKey( convert_to_int_list(tensor_stride, self._D), "" ) coordinates, features, coordinate_map_key = self.initialize_coordinates( coordinates, features, coordinate_map_key ) else: # coordinate_map_key is not None: assert coordinate_map_key.is_key_set(), "The coordinate key must be valid." if requires_grad is not None: features.requires_grad_(requires_grad) self._F = features self._C = coordinates self.coordinate_map_key = coordinate_map_key self._batch_rows = None def initialize_coordinates(self, coordinates, features, coordinate_map_key): if not isinstance(coordinates, (torch.IntTensor, torch.cuda.IntTensor)): warnings.warn( "coordinates implicitly converted to torch.IntTensor. " + "To remove this warning, use `.int()` to convert the " + "coords into an torch.IntTensor" ) coordinates = torch.floor(coordinates).int() ( coordinate_map_key, (unique_index, self.inverse_mapping), ) = self._manager.insert_and_map(coordinates, *coordinate_map_key.get_key()) self.unique_index = unique_index.long() coordinates = coordinates[self.unique_index] if self.quantization_mode in [ SparseTensorQuantizationMode.UNWEIGHTED_SUM, SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE, ]: spmm = MinkowskiSPMMFunction() N = len(features) cols = torch.arange( N, dtype=self.inverse_mapping.dtype, device=self.inverse_mapping.device, ) vals = torch.ones(N, dtype=features.dtype, device=features.device) size = torch.Size([len(self.unique_index), len(self.inverse_mapping)]) features = spmm.apply(self.inverse_mapping, cols, vals, size, features) if ( self.quantization_mode == SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE ): nums = spmm.apply( self.inverse_mapping, cols, vals, size, vals.reshape(N, 1), ) features /= nums elif self.quantization_mode == SparseTensorQuantizationMode.RANDOM_SUBSAMPLE: features = features[self.unique_index] else: # No quantization pass return coordinates, features, coordinate_map_key # Conversion functions def sparse(self, min_coords=None, max_coords=None, contract_coords=True): r"""Convert the :attr:`MinkowskiEngine.SparseTensor` to a torch sparse tensor. Args: :attr:`min_coords` (torch.IntTensor, optional): The min coordinates of the output sparse tensor. Must be divisible by the current :attr:`tensor_stride`. :attr:`max_coords` (torch.IntTensor, optional): The max coordinates of the output sparse tensor (inclusive). Must be divisible by the current :attr:`tensor_stride`. :attr:`contract_coords` (bool, optional): Given True, the output coordinates will be divided by the tensor stride to make features contiguous. Returns: :attr:`spare_tensor` (torch.sparse.Tensor): the torch sparse tensor representation of the self in `[Batch Dim, Spatial Dims..., Feature Dim]`. The coordinate of each feature can be accessed via `min_coord + tensor_stride * [the coordinate of the dense tensor]`. :attr:`min_coords` (torch.IntTensor): the D-dimensional vector defining the minimum coordinate of the output sparse tensor. If :attr:`contract_coords` is True, the :attr:`min_coords` will also be contracted. :attr:`tensor_stride` (torch.IntTensor): the D-dimensional vector defining the stride between tensor elements. """ if min_coords is not None: assert isinstance(min_coords, torch.IntTensor) assert min_coords.numel() == self._D if max_coords is not None: assert isinstance(max_coords, torch.IntTensor) assert min_coords.numel() == self._D def torch_sparse_Tensor(coords, feats, size=None): if size is None: if feats.dtype == torch.float64: return torch.sparse.DoubleTensor(coords, feats) elif feats.dtype == torch.float32: return torch.sparse.FloatTensor(coords, feats) else: raise ValueError("Feature type not supported.") else: if feats.dtype == torch.float64: return torch.sparse.DoubleTensor(coords, feats, size) elif feats.dtype == torch.float32: return torch.sparse.FloatTensor(coords, feats, size) else: raise ValueError("Feature type not supported.") # Use int tensor for all operations tensor_stride = torch.IntTensor(self.tensor_stride) # New coordinates coords = self.C coords, batch_indices = coords[:, 1:], coords[:, 0] # TODO, batch first if min_coords is None: min_coords, _ = coords.min(0, keepdim=True) elif min_coords.ndim == 1: min_coords = min_coords.unsqueeze(0) assert ( min_coords % tensor_stride ).sum() == 0, "The minimum coordinates must be divisible by the tensor stride." if max_coords is not None: if max_coords.ndim == 1: max_coords = max_coords.unsqueeze(0) assert ( max_coords % tensor_stride ).sum() == 0, ( "The maximum coordinates must be divisible by the tensor stride." ) coords -= min_coords if coords.ndim == 1: coords = coords.unsqueeze(1) if batch_indices.ndim == 1: batch_indices = batch_indices.unsqueeze(1) # return the contracted tensor if contract_coords: coords = coords // tensor_stride if max_coords is not None: max_coords = max_coords // tensor_stride min_coords = min_coords // tensor_stride new_coords = torch.cat((batch_indices, coords), dim=1).long() size = None if max_coords is not None: size = max_coords - min_coords + 1 # inclusive # Squeeze to make the size one-dimensional size = size.squeeze() max_batch = max(self._manager.get_batch_indices()) size = torch.Size([max_batch + 1, *size, self.F.size(1)]) sparse_tensor = torch_sparse_Tensor( new_coords.t().to(self.F.device), self.F, size ) tensor_stride = torch.IntTensor(self.tensor_stride) return sparse_tensor, min_coords, tensor_stride def dense(self, shape=None, min_coordinate=None, contract_stride=True): r"""Convert the :attr:`MinkowskiEngine.SparseTensor` to a torch dense tensor. Args: :attr:`shape` (torch.Size, optional): The size of the output tensor. :attr:`min_coordinate` (torch.IntTensor, optional): The min coordinates of the output sparse tensor. Must be divisible by the current :attr:`tensor_stride`. If 0 is given, it will use the origin for the min coordinate. :attr:`contract_stride` (bool, optional): The output coordinates will be divided by the tensor stride to make features spatially contiguous. True by default. Returns: :attr:`tensor` (torch.Tensor): the torch tensor with size `[Batch Dim, Feature Dim, Spatial Dim..., Spatial Dim]`. The coordinate of each feature can be accessed via `min_coordinate + tensor_stride * [the coordinate of the dense tensor]`. :attr:`min_coordinate` (torch.IntTensor): the D-dimensional vector defining the minimum coordinate of the output tensor. :attr:`tensor_stride` (torch.IntTensor): the D-dimensional vector defining the stride between tensor elements. """ if min_coordinate is not None: assert isinstance(min_coordinate, torch.IntTensor) assert min_coordinate.numel() == self._D if shape is not None: assert isinstance(shape, torch.Size) assert len(shape) == self._D + 2 # batch and channel if shape[1] != self._F.size(1): shape = torch.Size([shape[0], self._F.size(1), *[s for s in shape[2:]]]) # Use int tensor for all operations tensor_stride = torch.IntTensor(self.tensor_stride) # New coordinates batch_indices = self.C[:, 0] # TODO, batch first if min_coordinate is None: min_coordinate, _ = self.C.min(0, keepdim=True) min_coordinate = min_coordinate[:, 1:] coords = self.C[:, 1:] - min_coordinate elif isinstance(min_coordinate, int) and min_coordinate == 0: coords = self.C[:, 1:] else: if min_coordinate.ndim == 1: min_coordinate = min_coordinate.unsqueeze(0) coords = self.C[:, 1:] - min_coordinate assert ( min_coordinate % tensor_stride ).sum() == 0, "The minimum coordinates must be divisible by the tensor stride." if coords.ndim == 1: coords = coords.unsqueeze(1) # return the contracted tensor if contract_stride: coords = coords // tensor_stride nchannels = self.F.size(1) if shape is None: size = coords.max(0)[0] + 1 shape = torch.Size([batch_indices.max() + 1, nchannels, *size.numpy()]) dense_F = torch.zeros(shape, dtype=self.F.dtype, device=self.F.device) tcoords = coords.t().long() batch_indices = batch_indices.long() exec( "dense_F[batch_indices, :, " + ", ".join([f"tcoords[{i}]" for i in range(len(tcoords))]) + "] = self.F" ) tensor_stride = torch.IntTensor(self.tensor_stride) return dense_F, min_coordinate, tensor_stride def slice(self, X): r""" Args: :attr:`X` (:attr:`MinkowskiEngine.SparseTensor`): a sparse tensor that discretized the original input. Returns: :attr:`tensor_field` (:attr:`MinkowskiEngine.TensorField`): the resulting tensor field contains features on the continuous coordinates that generated the input X. Example:: >>> # coords, feats from a data loader >>> print(len(coords)) # 227742 >>> tfield = ME.TensorField(coordinates=coords, features=feats, quantization_mode=SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE) >>> print(len(tfield)) # 227742 >>> sinput = tfield.sparse() # 161890 quantization results in fewer voxels >>> soutput = MinkUNet(sinput) >>> print(len(soutput)) # 161890 Output with the same resolution >>> ofield = soutput.slice(tfield) >>> assert isinstance(ofield, ME.TensorField) >>> len(ofield) == len(coords) # recovers the original ordering and length >>> assert isinstance(ofield.F, torch.Tensor) # .F returns the features """ # Currently only supports unweighted slice. assert X.quantization_mode in [ SparseTensorQuantizationMode.RANDOM_SUBSAMPLE, SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE, ], "slice only available for sparse tensors with quantization RANDOM_SUBSAMPLE or UNWEIGHTED_AVERAGE" from MinkowskiTensorField import TensorField if isinstance(X, TensorField): return TensorField( self.F[X.inverse_mapping], coordinate_field_map_key=X.coordinate_field_map_key, coordinate_manager=X.coordinate_manager, quantization_mode=X.quantization_mode, ) elif isinstance(X, SparseTensor): assert ( X.coordinate_map_key == self.coordinate_map_key ), "Slice can only be applied on the same coordinates (coordinate_map_key)" return TensorField( self.F[X.inverse_mapping], coordinates=self.C[X.inverse_mapping], coordinate_manager=self.coordinate_manager, quantization_mode=self.quantization_mode, ) else: raise ValueError( "Invalid input. The input must be an instance of TensorField or SparseTensor." ) def cat_slice(self, X): r""" Args: :attr:`X` (:attr:`MinkowskiEngine.SparseTensor`): a sparse tensor that discretized the original input. Returns: :attr:`tensor_field` (:attr:`MinkowskiEngine.TensorField`): the resulting tensor field contains the concatenation of features on the original continuous coordinates that generated the input X and the self. Example:: >>> # coords, feats from a data loader >>> print(len(coords)) # 227742 >>> sinput = ME.SparseTensor(coordinates=coords, features=feats, quantization_mode=SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE) >>> print(len(sinput)) # 161890 quantization results in fewer voxels >>> soutput = network(sinput) >>> print(len(soutput)) # 161890 Output with the same resolution >>> ofield = soutput.cat_slice(sinput) >>> assert soutput.F.size(1) + sinput.F.size(1) == ofield.F.size(1) # concatenation of features """ # Currently only supports unweighted slice. assert X.quantization_mode in [ SparseTensorQuantizationMode.RANDOM_SUBSAMPLE, SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE, ], "slice only available for sparse tensors with quantization RANDOM_SUBSAMPLE or UNWEIGHTED_AVERAGE" from MinkowskiTensorField import TensorField features = torch.cat((self.F[X.inverse_mapping], X.F), dim=1) if isinstance(X, TensorField): return TensorField( features, coordinate_field_map_key=X.coordinate_field_map_key, coordinate_manager=X.coordinate_manager, quantization_mode=X.quantization_mode, ) elif isinstance(X, SparseTensor): assert ( X.coordinate_map_key == self.coordinate_map_key ), "Slice can only be applied on the same coordinates (coordinate_map_key)" return TensorField( features, coordinates=self.C[X.inverse_mapping], coordinate_manager=self.coordinate_manager, quantization_mode=self.quantization_mode, ) else: raise ValueError( "Invalid input. The input must be an instance of TensorField or SparseTensor." ) def features_at_coordinates(self, query_coordinates: torch.Tensor): r"""Extract features at the specified continuous coordinate matrix. Args: :attr:`query_coordinates` (:attr:`torch.FloatTensor`): a coordinate matrix of size :math:`N \times (D + 1)` where :math:`D` is the size of the spatial dimension. Returns: :attr:`queried_features` (:attr:`torch.Tensor`): a feature matrix of size :math:`N \times D_F` where :math:`D_F` is the number of channels in the feature. For coordinates not present in the current sparse tensor, corresponding feature rows will be zeros. """ from MinkowskiInterpolation import MinkowskiInterpolationFunction assert ( self.dtype == query_coordinates.dtype ), "Invalid query_coordinates dtype. use {self.dtype}" assert ( query_coordinates.device == self.device ), "query coordinates device ({query_coordinates.device}) does not match the sparse tensor device ({self.device})." return MinkowskiInterpolationFunction().apply( self._F, query_coordinates, self.coordinate_map_key, self.coordinate_manager, )[0] def __repr__(self): return ( self.__class__.__name__ + "(" + os.linesep + " coordinates=" + str(self.C) + os.linesep + " features=" + str(self.F) + os.linesep + " coordinate_map_key=" + str(self.coordinate_map_key) + os.linesep + " coordinate_manager=" + str(self._manager) + " spatial dimension=" + str(self._D) + ")" ) __slots__ = ( "_C", "_F", "_D", "coordinate_map_key", "_manager", "unique_index", "inverse_mapping", "quantization_mode", "_batch_rows", ) def _get_coordinate_map_key( input: SparseTensor, coordinates: torch.Tensor = None, tensor_stride: StrideType = 1, expand_coordinates: bool = False, ): r"""Returns the coordinates map key.""" if coordinates is not None and not expand_coordinates: assert isinstance(coordinates, (CoordinateMapKey, torch.Tensor, SparseTensor)) if isinstance(coordinates, torch.Tensor): assert coordinates.ndim == 2 coordinate_map_key = CoordinateMapKey( convert_to_int_list(tensor_stride, coordinates.size(1) - 1), "" ) ( coordinate_map_key, (unique_index, inverse_mapping), ) = input._manager.insert_and_map( coordinates, *coordinate_map_key.get_key() ) elif isinstance(coordinates, SparseTensor): coordinate_map_key = coordinates.coordinate_map_key else: # CoordinateMapKey type due to the previous assertion coordinate_map_key = coordinates else: # coordinates is None coordinate_map_key = CoordinateMapKey( input.coordinate_map_key.get_coordinate_size() ) return coordinate_map_key
41.748641
142
0.619227
4a2434dc1167710d7bdccd36174db529c93b8201
2,089
py
Python
EstruturaDeRepeticao/37.py
TheCarvalho/atividades-wikipython
9163d5de40dbed0d73917f6257e64a651a77e085
[ "Unlicense" ]
null
null
null
EstruturaDeRepeticao/37.py
TheCarvalho/atividades-wikipython
9163d5de40dbed0d73917f6257e64a651a77e085
[ "Unlicense" ]
null
null
null
EstruturaDeRepeticao/37.py
TheCarvalho/atividades-wikipython
9163d5de40dbed0d73917f6257e64a651a77e085
[ "Unlicense" ]
null
null
null
''' 37. Uma academia deseja fazer um senso entre seus clientes para descobrir o mais alto, o mais baixo, a mais gordo e o mais magro, para isto você deve fazer um programa que pergunte a cada um dos clientes da academia seu código, sua altura e seu peso. O final da digitação de dados deve ser dada quando o usuário digitar 0 (zero) no campo código. Ao encerrar o programa também deve ser informados os códigos e valores do cliente mais alto, do mais baixo, do mais gordo e do mais magro, além da média das alturas e dos pesos dos clientes ''' from os import system lista = list() dic = dict() maior = menor = gordo = magro = indmaior = indmenor = indgordo = indmagro = medaltura = medpeso = cont = 0 while True: system('cls') dic.clear() dic["codigo"] = int(input('Código: ')) if dic["codigo"] == 0: break dic["altura"] = (float(input('Altura: '))) medaltura += dic["altura"] dic["peso"] = (float(input('Peso: '))) medpeso += dic["peso"] lista.append(dic.copy()) cont += 1 for i in range(len(lista)): if i == 0: maior = menor = lista[i]['altura'] gordo = magro = lista[i]['peso'] if lista[i]['altura'] > maior: maior = lista[i]['altura'] indmaior = i if lista[i]['altura'] < menor: menor = lista[i]['altura'] indmenor = i if lista[i]['peso'] < magro: magro = lista[i]['peso'] indmagro = i if lista[i]['peso'] > gordo: gordo = lista[i]['peso'] indgordo system('cls') print( f'O mais magro é {lista[indmagro]["codigo"]:<20}| Altura: {lista[indmagro]["altura"]}\t| Peso: {magro}') print( f'O mais gordo é {lista[indgordo]["codigo"]:<20}| Altura: {lista[indgordo]["altura"]}\t| Peso: {gordo}') print( f'O mais alto é {lista[indmaior]["codigo"]:<21}| Altura: {maior}\t| Peso: {lista[indmaior]["peso"]}') print( f'O mais baixo é {lista[indmenor]["codigo"]:<20}| Altura: {menor}\t| Peso: {lista[indmenor]["peso"]}') print(f'\nA média de peso é {medpeso/cont:.1f} kg') print(f'A média de altura é {medaltura/cont:.1f} cm')
34.816667
122
0.622786
4a24355f74ac48eb59fed1ffd8cf07b934daaebd
468
py
Python
canvasapi/course_epub_export.py
eriktews/canvasapi
132146395ecf55227cae69dc4d5f6d94545172b9
[ "MIT" ]
null
null
null
canvasapi/course_epub_export.py
eriktews/canvasapi
132146395ecf55227cae69dc4d5f6d94545172b9
[ "MIT" ]
null
null
null
canvasapi/course_epub_export.py
eriktews/canvasapi
132146395ecf55227cae69dc4d5f6d94545172b9
[ "MIT" ]
null
null
null
from __future__ import absolute_import, division, print_function, unicode_literals from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject @python_2_unicode_compatible class CourseEpubExport(CanvasObject): def __str__(self): return "{} course_id:({}) epub_id:({}) {} ".format( self.name, self.id, self.epub_export["id"], self.epub_export["workflow_state"], )
27.529412
82
0.681624
4a24366ab3818325a847f3f11b61fc9e377ed009
53,980
py
Python
src/gui/main_widget.py
JARVIS-AI/The-Witcher-3-Mod-manager-1
fdc4763e29bc3cef6f7b4df51a1c4e286da0fe06
[ "BSD-2-Clause" ]
null
null
null
src/gui/main_widget.py
JARVIS-AI/The-Witcher-3-Mod-manager-1
fdc4763e29bc3cef6f7b4df51a1c4e286da0fe06
[ "BSD-2-Clause" ]
null
null
null
src/gui/main_widget.py
JARVIS-AI/The-Witcher-3-Mod-manager-1
fdc4763e29bc3cef6f7b4df51a1c4e286da0fe06
[ "BSD-2-Clause" ]
null
null
null
'''Main Widget''' # pylint: disable=invalid-name,superfluous-parens,wildcard-import,bare-except,broad-except,wildcard-import,unused-wildcard-import,missing-docstring,too-many-lines from sys import platform from os import path from PySide2.QtCore import QFileInfo, QMetaObject, QRect, QSize, QThread, Qt, Signal from PySide2.QtGui import QCursor, QResizeEvent from PySide2.QtWidgets import QAbstractItemView, QAction, QActionGroup, QFileIconProvider, QHBoxLayout, QHeaderView, QInputDialog, QLineEdit, QMenu, QMenuBar, QMessageBox, QProgressBar, QPushButton, QSizePolicy, QSplitter, QTextEdit, QToolBar, QTreeWidget, QVBoxLayout, QWidget from watchdog.observers import Observer from watchdog.events import PatternMatchingEventHandler from src.globals.constants import * from src.globals import data from src.util.util import * from src.util.syntax import * from src.core.model import Model from src.core.installer import Installer from src.gui.tree_widget import CustomTreeWidgetItem from src.gui.details_dialog import DetailsDialog from src.gui.alerts import MessageAlertScript, MessageUnsupportedOSAction class ModsSettingsWatcher(QThread): refresh = Signal(object) def __init__(self, *args, **kwargs): self.modsEventHandler = PatternMatchingEventHandler( patterns=["*mods.settings"], ignore_patterns=[], ignore_directories=True) self.modsEventHandler.on_modified = lambda e: self.refresh.emit(e) self.running = False self.observer = Observer() self.observer.schedule(self.modsEventHandler, path=data.config.settings, recursive=False) super().__init__(*args, **kwargs) self.observer.start() def __drop__(self): if self.observer: self.observer.stop() self.observer.join() self.observer = None class CustomMainWidget(QWidget): '''Main Widget''' def __init__(self, parent: QWidget, model: Model): super().__init__(parent) self.mainWindow = parent self.model = model self.searchString = "" self.modsSettingsWatcher = ModsSettingsWatcher() self.modsSettingsWatcher.refresh.connect( lambda e: self.refreshLoadOrder()) self.mainWindow.setObjectName("MainWindow") wini = int(data.config.get('WINDOW', 'width')) \ if data.config.get('WINDOW', 'width') else 1024 hini = int(data.config.get('WINDOW', 'height')) \ if data.config.get('WINDOW', 'height') else 720 self.mainWindow.resize(wini, hini) self.mainWindow.setCursor(QCursor(Qt.ArrowCursor)) self.mainWindow.setWindowOpacity(1.0) self.mainWindow.setStatusTip("") self.mainWindow.setAutoFillBackground(False) self.mainWindow.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.mainWindow.setAcceptDrops(True) self.centralwidget = QWidget(self.mainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_2 = QVBoxLayout(self.centralwidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.searchWidget = QLineEdit(self.centralwidget) self.searchWidget.setObjectName("searchWidget") self.searchWidget.setPlaceholderText(TRANSLATE("MainWindow", "Search")) self.verticalLayout_2.addWidget(self.searchWidget) self.treeWidget = QTreeWidget(self.centralwidget) self.treeWidget.setMinimumSize(QSize(600, 350)) self.treeWidget.setUniformRowHeights(True) self.treeWidget.setAnimated(True) self.treeWidget.setHeaderHidden(False) self.treeWidget.setColumnCount(8) self.treeWidget.setObjectName("treeWidget") self.treeWidget.header().setCascadingSectionResizes(True) self.treeWidget.header().setHighlightSections(False) self.treeWidget.header().setSortIndicatorShown(True) self.treeWidget.setSortingEnabled(True) self.horizontalSplitter_tree = QSplitter() self.horizontalSplitter_tree.setObjectName("horizontalSplitter_tree") self.horizontalSplitter_tree.addWidget(self.treeWidget) self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.loadOrder = QTreeWidget(self.centralwidget) self.loadOrder.setUniformRowHeights(True) self.loadOrder.setAnimated(True) self.loadOrder.setHeaderHidden(False) self.loadOrder.setColumnCount(2) self.loadOrder.setObjectName("loadOrder") self.loadOrder.setMinimumWidth(200) self.loadOrder.setSortingEnabled(False) self.horizontalSplitter_tree.addWidget(self.loadOrder) self.horizontalSplitter_tree.setCollapsible(0, False) self.horizontalSplitter_tree.setCollapsible(1, True) self.horizontalSplitter_tree.setStretchFactor(0, 3) self.horizontalSplitter_tree.setStretchFactor(1, 1) self.verticalLayout_2.addWidget(self.horizontalSplitter_tree) self.textEdit = QTextEdit(self.centralwidget) self.textEdit.setMaximumSize(QSize(16777215, 16777215)) self.textEdit.setReadOnly(True) self.textEdit.setObjectName("textEdit") self.horizontalLayout_2.addWidget(self.textEdit) self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.pushButton_4 = QPushButton(self.centralwidget) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.pushButton_4.sizePolicy().hasHeightForWidth()) self.pushButton_4.setSizePolicy(sizePolicy) self.pushButton_4.setMinimumSize(QSize(100, 50)) self.pushButton_4.setObjectName("pushButton_4") self.verticalLayout.addWidget(self.pushButton_4) self.pushButton_5 = QPushButton(self.centralwidget) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.pushButton_5.sizePolicy().hasHeightForWidth()) self.pushButton_5.setSizePolicy(sizePolicy) self.pushButton_5.setMinimumSize(QSize(100, 50)) self.pushButton_5.setObjectName("pushButton_5") self.verticalLayout.addWidget(self.pushButton_5) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.setStretch(0, 3) self.horizontalLayout_2.setStretch(1, 1) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.progressBar = QProgressBar(self.centralwidget) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName("progressBar") self.verticalLayout_2.addWidget(self.progressBar) self.verticalLayout_2.setStretch(0, 4) self.verticalLayout_2.setStretch(1, 1) self.mainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(self.mainWindow) self.menubar.setGeometry(QRect(0, 0, 583, 21)) self.menubar.setObjectName("menubar") self.menuFile = QMenu(self.menubar) self.menuFile.setObjectName("menuFile") self.menuEdit = QMenu(self.menubar) self.menuEdit.setObjectName("menuEdit") self.menuSettings = QMenu(self.menubar) self.menuSettings.setObjectName("menuSettings") self.menuSelect_Language = QMenu(self.menuSettings) self.menuSelect_Language.setObjectName("menuSelect_Language") self.menuConfigure_Settings = QMenu(self.menuSettings) self.menuConfigure_Settings.setObjectName("menuConfigure_Settings") self.menuHelp = QMenu(self.menubar) self.menuHelp.setObjectName("menuHelp") self.mainWindow.setMenuBar(self.menubar) self.toolBar = QToolBar(self.mainWindow) self.toolBar.setObjectName("toolBar") self.mainWindow.addToolBar(Qt.TopToolBarArea, self.toolBar) self.actionInstall_Mods = QAction(self.mainWindow) self.actionInstall_Mods.setIcon(getIcon('Add.ico')) self.actionInstall_Mods.setIconVisibleInMenu(False) self.actionInstall_Mods.setObjectName("actionInstall_Mods") self.actionInstall_Mods.setIconText( TRANSLATE('MainWindow', "Add")) self.actionRestoreColumns = QAction(self.mainWindow) self.actionRestoreColumns.setIconVisibleInMenu(False) self.actionRestoreColumns.setObjectName("actionRestoreColumns") self.actionUninstall_Mods = QAction(self.mainWindow) self.actionUninstall_Mods.setIcon(getIcon('rem.ico')) self.actionUninstall_Mods.setIconVisibleInMenu(False) self.actionUninstall_Mods.setObjectName("actionUninstall_Mods") self.actionUninstall_Mods.setIconText( TRANSLATE('MainWindow', "Remove")) self.actionEnable_Disable_Mods = QAction(self.mainWindow) self.actionEnable_Disable_Mods.setIcon(getIcon('check.ico')) self.actionEnable_Disable_Mods.setIconVisibleInMenu(False) self.actionEnable_Disable_Mods.setObjectName( "actionEnable_Disable_Mods") self.actionEnable_Disable_Mods.setIconText( TRANSLATE('MainWindow', "Toggle")) self.actionReinstall_Mods = QAction(self.mainWindow) self.actionReinstall_Mods.setObjectName("actionReinstall_Mods") self.actionRefresh_Mod_List = QAction(self.mainWindow) self.actionRefresh_Mod_List.setObjectName("actionRefresh_Mod_List") self.actionRefresh_Load_Order = QAction(self.mainWindow) self.actionRefresh_Load_Order.setObjectName("actionRefresh_Load_Order") self.actionSelect_All_Mods = QAction(self.mainWindow) self.actionSelect_All_Mods.setObjectName("actionSelect_All_Mods") self.actionSetPriority = QAction(self.mainWindow) self.actionSetPriority.setObjectName("actionSetPriority") self.actionUnsetPriority = QAction(self.mainWindow) self.actionUnsetPriority.setObjectName("actionUnsetPriority") self.actionRun_The_Game = QAction(self.mainWindow) self.actionRun_The_Game.setObjectName("actionRun_The_Game") self.actionRun_Script_Merger = QAction(self.mainWindow) self.actionRun_Script_Merger.setObjectName("actionRun_Script_Merger") self.actionAbout = QAction(self.mainWindow) self.actionAbout.setObjectName("actionAbout") self.actionRename = QAction(self.mainWindow) self.actionRename.setObjectName("actionRename") self.actionDetails = QAction(self.mainWindow) self.actionDetails.setObjectName("actionDetails") self.actionOpenFolder = QAction(self.mainWindow) self.actionOpenFolder.setObjectName("actionOpenFolder") self.actionIncreasePriority = QAction(self.mainWindow) self.actionIncreasePriority.setObjectName("actionIncreasePriority") self.actionDecreasePriority = QAction(self.mainWindow) self.actionDecreasePriority.setObjectName("actionDecreasePriority") self.actionMain_Web_Page = QAction(self.mainWindow) self.actionGitHub = QAction(self.mainWindow) self.actionMain_Web_Page.setObjectName("actionMain_Web_Page") self.actionGitHub.setObjectName("acitionGitHub") self.actionAlert_to_run_Script_Merger = QAction(self.mainWindow) self.actionAlert_to_run_Script_Merger.setCheckable(True) self.actionAlert_to_run_Script_Merger.setObjectName( "actionAlert_to_run_Script_Merger") self.languageActionGroup = QActionGroup(self.mainWindow) for lang in os.listdir(getProgramRootFolder() + '/translations/'): temp = self.makeLangAction(lang) self.languageActionGroup.addAction(temp) self.menuSelect_Language.addAction(temp) self.actionChange_Game_Path = QAction(self.mainWindow) self.actionChange_Game_Path.setObjectName("actionChange_Game_Path") self.actionChange_Script_Merger_Path = QAction(self.mainWindow) self.actionChange_Script_Merger_Path.setObjectName( "actionChange_Script_Merger_Path") self.actionClearOutput = QAction(self.mainWindow) self.actionClearOutput.setObjectName("actionClearOutput") self.menuFile.addAction(self.actionInstall_Mods) self.menuFile.addAction(self.actionUninstall_Mods) self.menuFile.addAction(self.actionEnable_Disable_Mods) self.menuFile.addSeparator() self.menuFile.addAction(self.actionOpenFolder) self.menuFile.addSeparator() self.menuFile.addAction(self.actionReinstall_Mods) self.menuFile.addAction(self.actionRefresh_Mod_List) self.menuFile.addAction(self.actionRefresh_Load_Order) self.menuFile.addAction(self.actionSelect_All_Mods) self.menuConfigure_Settings.addAction(self.actionChange_Game_Path) self.menuConfigure_Settings.addAction( self.actionChange_Script_Merger_Path) self.menuConfigure_Settings.addSeparator() self.menuConfigure_Settings.addAction(self.actionRestoreColumns) self.menuConfigure_Settings.addSeparator() self.menuConfigure_Settings.addAction( self.actionAlert_to_run_Script_Merger) self.menuConfigure_Settings.addSeparator() self.menuSettings.addAction(self.menuConfigure_Settings.menuAction()) self.menuSettings.addAction(self.menuSelect_Language.menuAction()) self.menuHelp.addAction(self.actionAbout) self.menuHelp.addAction(self.actionMain_Web_Page) self.menuHelp.addAction(self.actionGitHub) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuEdit.menuAction()) self.menubar.addAction(self.menuSettings.menuAction()) self.menubar.addAction(self.menuHelp.menuAction()) self.toolBar.addAction(self.actionInstall_Mods) self.toolBar.addAction(self.actionUninstall_Mods) self.toolBar.addAction(self.actionEnable_Disable_Mods) self.toolBar.setIconSize(QSize(32, 32)) self.toolBar.addSeparator() self.actionAddToToolbar = None self.translateUi() self.configureUi() self.configureToolbar() self.checkLanguage() self.refreshList() QMetaObject.connectSlotsByName(self.mainWindow) self.mainWindow.resizeEvent = lambda e: self.onResize() # type: ignore self.loadOrder.header().sectionResized.connect(lambda: self.onResize()) self.treeWidget.header().sectionResized.connect(lambda: self.onResize()) @throttle(200) def onResize(self): data.config.saveWindowSettings(self, self.mainWindow) def resizeEvent(self, event: QResizeEvent): self.onResize() def translateUi(self): self.mainWindow.setWindowTitle( TRANSLATE("MainWindow", TITLE)) self.treeWidget.headerItem().setText(0, TRANSLATE("MainWindow", "Enabled")) self.treeWidget.headerItem().setText(1, TRANSLATE("MainWindow", "Mod Name")) self.treeWidget.headerItem().setText(2, TRANSLATE("MainWindow", "Priority")) self.treeWidget.headerItem().setText(3, TRANSLATE("MainWindow", "Data")) self.treeWidget.headerItem().setText(4, TRANSLATE("MainWindow", "DLC")) self.treeWidget.headerItem().setText(5, TRANSLATE("MainWindow", "Menu")) self.treeWidget.headerItem().setText(6, TRANSLATE("MainWindow", "Var")) self.treeWidget.headerItem().setText(7, TRANSLATE("MainWindow", "Hidden")) self.treeWidget.headerItem().setText(8, TRANSLATE("MainWindow", "Key")) self.treeWidget.headerItem().setText(9, TRANSLATE("MainWindow", "Settings")) self.treeWidget.headerItem().setText(10, TRANSLATE("MainWindow", "Size")) self.treeWidget.headerItem().setText( 11, TRANSLATE("MainWindow", "Date Installed")) self.loadOrder.headerItem().setText(0, TRANSLATE("MainWindow", "Load Order")) self.loadOrder.headerItem().setText(1, TRANSLATE("MainWindow", "Priority")) self.textEdit.setPlaceholderText(TRANSLATE("MainWindow", "Output")) self.textEdit.setCursor(QCursor(Qt.ArrowCursor)) self.pushButton_4.setText(TRANSLATE("MainWindow", "Run Script Merger")) self.pushButton_5.setText(TRANSLATE("MainWindow", "Run the Game")) self.menuFile.setTitle(TRANSLATE("MainWindow", "Mods")) self.menuEdit.setTitle(TRANSLATE("MainWindow", "Edit")) self.menuSettings.setTitle(TRANSLATE("MainWindow", "Settings")) self.menuSelect_Language.setTitle( TRANSLATE("MainWindow", "Select Language")) self.menuConfigure_Settings.setTitle( TRANSLATE("MainWindow", "Configure Settings")) self.menuHelp.setTitle(TRANSLATE("MainWindow", "Help")) self.toolBar.setWindowTitle(TRANSLATE("MainWindow", "toolBar")) self.actionInstall_Mods.setText( TRANSLATE("MainWindow", "Install Mods")) self.actionInstall_Mods.setToolTip( TRANSLATE("MainWindow", "Install one or more Mods from folders or archives")) self.actionInstall_Mods.setShortcut("Ctrl+E") self.actionRestoreColumns.setText( TRANSLATE("MainWindow", "Restore default column widths")) self.actionRestoreColumns.setToolTip( TRANSLATE("MainWindow", "Restore default column widths")) self.actionUninstall_Mods.setText( TRANSLATE("MainWindow", "Uninstall")) self.actionUninstall_Mods.setToolTip( TRANSLATE("MainWindow", "Uninstall one or more selected Mods")) self.actionUninstall_Mods.setShortcut("Del") self.actionEnable_Disable_Mods.setText( TRANSLATE("MainWindow", "Enable/Disable")) self.actionEnable_Disable_Mods.setToolTip( TRANSLATE("MainWindow", "Enable or disable selected Mods")) self.actionEnable_Disable_Mods.setShortcut("Ctrl+Q") self.actionRefresh_Mod_List.setText( TRANSLATE("MainWindow", "Refresh Mod List")) self.actionRefresh_Mod_List.setShortcut("F5") self.actionReinstall_Mods.setText( TRANSLATE("MainWindow", "Reinstall")) self.actionRefresh_Load_Order.setText( TRANSLATE("MainWindow", "Refresh Load Order")) self.actionRefresh_Load_Order.setShortcut("F6") self.actionSelect_All_Mods.setText( TRANSLATE("MainWindow", "Select All Mods")) self.actionSelect_All_Mods.setShortcut("Ctrl+A") self.actionRun_The_Game.setText( TRANSLATE("MainWindow", "Run the Game")) self.actionRun_The_Game.setShortcut("Ctrl+R") self.actionRun_Script_Merger.setText( TRANSLATE("MainWindow", "Run Script Merger")) self.actionRun_Script_Merger.setShortcut("Ctrl+S") self.actionAbout.setText( TRANSLATE("MainWindow", "About")) self.actionAbout.setShortcut("F1") self.actionMain_Web_Page.setText( TRANSLATE("MainWindow", "Main Web Page")) self.actionGitHub.setText( TRANSLATE("MainWindow", "GitHub")) self.actionMain_Web_Page.setShortcut("Ctrl+F1") self.actionGitHub.setShortcut("Ctrl+F2") self.actionAlert_to_run_Script_Merger.setText( TRANSLATE("MainWindow", "Alert to run Script Merger")) self.actionChange_Game_Path.setText( TRANSLATE("MainWindow", "Change Game Path")) self.actionChange_Script_Merger_Path.setText( TRANSLATE("MainWindow", "Change Script Merger Path")) self.actionClearOutput.setText( TRANSLATE("MainWindow", "Clear Output")) self.actionRename.setText( TRANSLATE("MainWindow", "Rename")) self.actionRename.setShortcut("F2") self.actionDetails.setShortcut("F3") self.actionDetails.setText( TRANSLATE("MainWindow", "Details")) self.actionOpenFolder.setShortcut("Ctrl+L") self.actionOpenFolder.setText( TRANSLATE("MainWindow", "Open Folder")) self.actionIncreasePriority.setShortcut("Ctrl+Up") self.actionIncreasePriority.setText( TRANSLATE("MainWindow", "Increase Priority")) self.actionDecreasePriority.setShortcut("Ctrl+Down") self.actionDecreasePriority.setText( TRANSLATE("MainWindow", "Decrease Priority")) self.actionSetPriority.setShortcut("Ctrl+P") self.actionSetPriority.setText( TRANSLATE("MainWindow", "Set Priority")) self.actionUnsetPriority.setShortcut("Ctrl+U") self.actionUnsetPriority.setText( TRANSLATE("MainWindow", "Remove Priority")) self.menuEdit.addAction(self.actionDetails) self.menuEdit.addAction(self.actionRename) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionSetPriority) self.menuEdit.addAction(self.actionUnsetPriority) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionIncreasePriority) self.menuEdit.addAction(self.actionDecreasePriority) def configureUi(self): for i in range(0, self.treeWidget.header().count()): if not data.config.getWindowSection(i): data.config.setDefaultWindow() break self.treeWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.treeWidget.header().setDefaultAlignment(Qt.AlignCenter) self.treeWidget.sortByColumn(1, Qt.AscendingOrder) self.loadOrder.header().setDefaultAlignment(Qt.AlignCenter) self.loadOrder.header().setStretchLastSection(False) self.loadOrder.header().setSectionResizeMode(0, QHeaderView.Stretch) self.loadOrder.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) self.resizeColumns() self.actionInstall_Mods.triggered.connect(self.installMods) self.actionUninstall_Mods.triggered.connect(self.uninstallMods) self.actionReinstall_Mods.triggered.connect(self.reinstallMods) self.actionAbout.triggered.connect(showAboutWindow) self.actionEnable_Disable_Mods.triggered.connect( self.enableDisableMods) self.actionRefresh_Mod_List.triggered.connect( lambda e: self.refreshList()) self.actionRefresh_Load_Order.triggered.connect( lambda e: self.refreshLoadOrder()) self.actionSelect_All_Mods.triggered.connect(self.selectAllMods) self.actionRun_The_Game.triggered.connect(self.runTheGame) self.actionRun_Script_Merger.triggered.connect(self.runScriptMerger) self.actionMain_Web_Page.triggered.connect(lambda: openUrl(URL_WEB)) self.actionGitHub.triggered.connect(lambda: openUrl(URL_GIT)) self.actionAlert_to_run_Script_Merger.triggered.connect( self.alertPopupChanged) self.actionChange_Game_Path.triggered.connect(self.changeGamePath) self.actionChange_Script_Merger_Path.triggered.connect( self.changeScriptMergerPath) self.actionClearOutput.triggered.connect(self.clear) self.actionRename.triggered.connect(self.rename) self.actionDetails.triggered.connect(self.details) self.actionOpenFolder.triggered.connect(self.openFolder) self.actionIncreasePriority.triggered.connect(self.increasePriority) self.actionDecreasePriority.triggered.connect(self.decreasePriority) self.actionSetPriority.triggered.connect(self.setPriority) self.actionUnsetPriority.triggered.connect(self.unsetPriority) self.actionRestoreColumns.triggered.connect(self.restoreColumns) self.pushButton_4.clicked.connect(self.runScriptMerger) self.pushButton_5.clicked.connect(self.runTheGame) self.treeWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.treeWidget.customContextMenuRequested.connect(self.openMenu) self.toolBar.setContextMenuPolicy(Qt.CustomContextMenu) self.toolBar.customContextMenuRequested.connect(self.toolbarMenu) self.textEdit.setContextMenuPolicy(Qt.CustomContextMenu) self.textEdit.customContextMenuRequested.connect(self.openEditMenu) self.treeWidget.itemChanged.connect(self.modToggled) self.treeWidget.itemDoubleClicked.connect(self.modDoubleClicked) self.treeWidget.header().setStretchLastSection(False) self.loadOrder.itemDoubleClicked.connect(self.loadOrderDoubleClicked) self.actionAlert_to_run_Script_Merger.setChecked( data.config.allowpopups == '1') self.searchWidget.textChanged.connect(self.setSearchString) def openByConfigKey(self, option): '''Open or run any kind of folder/file or executable by configuration key''' openFile(getattr(data.config, option)) def configureToolbar(self): '''Creates and configures toolbar''' actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect(lambda: self.openByConfigKey('mods')) actionTemp.setText('M') actionTemp.setIconText(TRANSLATE('MainWindow', 'Mods')) actionTemp.setIcon(getIcon("mods.ico")) actionTemp.setToolTip(TRANSLATE("MainWindow", 'Open Mods folder')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect(lambda: self.openByConfigKey('dlc')) actionTemp.setText('D') actionTemp.setIconText(TRANSLATE('MainWindow', 'DLC')) actionTemp.setIcon(getIcon("dlc.ico")) actionTemp.setToolTip(TRANSLATE("MainWindow", 'Open DLC folder')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect(lambda: self.openByConfigKey('menu')) actionTemp.setText('I') actionTemp.setIconText(TRANSLATE('MainWindow', 'Menus')) actionTemp.setIcon(getIcon("menu.ico")) actionTemp.setToolTip(TRANSLATE("MainWindow", 'Open Menus folder')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect(lambda: self.openByConfigKey('settings')) actionTemp.setText('S') actionTemp.setIconText(TRANSLATE('MainWindow', 'Settings')) actionTemp.setIcon(getIcon("settings.ico")) actionTemp.setToolTip(TRANSLATE("MainWindow", 'Open Settings folder')) self.toolBar.addAction(actionTemp) self.toolBar.addSeparator() actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect( lambda: openFile(data.config.menu + '/input.xml')) actionTemp.setText('Input Xml') actionTemp.setIcon(getIcon("xml.ico")) actionTemp.setToolTip(TRANSLATE("MainWindow", 'Open input.xml file')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect( lambda: openFile(data.config.settings + '/input.settings')) actionTemp.setText('Input Settings') actionTemp.setIcon(getIcon("input.ico")) actionTemp.setToolTip( TRANSLATE("MainWindow", 'Open input.settings file')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect( lambda: openFile(data.config.settings + '/user.settings')) actionTemp.setText('User Settings') actionTemp.setIcon(getIcon("user.ico")) actionTemp.setToolTip( TRANSLATE("MainWindow", 'Open user.settings file')) self.toolBar.addAction(actionTemp) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect( lambda: openFile(data.config.settings + '/mods.settings')) actionTemp.setText('Mods Settings') actionTemp.setIcon(getIcon("modset.ico")) actionTemp.setToolTip( TRANSLATE("MainWindow", 'Open mods.settings file')) self.toolBar.addAction(actionTemp) self.toolBar.addSeparator() for custom in data.config.getOptions('TOOLBAR'): self.addToToolbar(custom) self.actionAddToToolbar = QAction(self.mainWindow) self.actionAddToToolbar.triggered.connect(self.addToToolbar) self.actionAddToToolbar.setText(TRANSLATE("MainWindow", 'Add New..')) def openMenu(self, position): '''Right click menu on mod list (Left panel)''' menu = QMenu() menu.addAction(self.actionDetails) menu.addSeparator() menu.addAction(self.actionSetPriority) menu.addAction(self.actionUnsetPriority) menu.addSeparator() menu.addAction(self.actionOpenFolder) menu.addSeparator() menu.addAction(self.actionRename) menu.addAction(self.actionReinstall_Mods) menu.addAction(self.actionUninstall_Mods) menu.addAction(self.actionEnable_Disable_Mods) menu.exec_(self.treeWidget.viewport().mapToGlobal(position)) def openEditMenu(self, position): '''Right click menu on output''' menu = QMenu() menu.addAction(self.actionClearOutput) menu.exec_(self.textEdit.viewport().mapToGlobal(position)) def toolbarMenu(self, position): '''Right click menu on toolbar''' menu = QMenu(self.mainWindow) menu.addAction(self.actionAddToToolbar) rem = QMenu(menu) rem.setTitle(TRANSLATE("MainWindow", "Remove..")) actions = self.toolBar.actions()[14:] for action in actions: temp = self.makeTempAction(action) rem.addAction(temp) del action menu.addAction(rem.menuAction()) menu.exec_(self.toolBar.mapToGlobal(position)) def removeFromToolbar(self, action): '''Creates menu for removing actions from toolbar''' self.toolBar.removeAction(action) data.config.removeOption('TOOLBAR', action.toolTip()) def addToToolbar(self, selected=""): '''Adds custom action to the toolbar selected by user''' try: if (not selected): temp = getFile() if (temp): selected = temp[0] if (selected): fileInfo = QFileInfo(selected) iconProvider = QFileIconProvider() icon = iconProvider.icon(fileInfo) _, file = path.split(selected) fl, _ = path.splitext(file) actionTemp = QAction(self.mainWindow) actionTemp.triggered.connect(lambda: openFile(selected)) actionTemp.setText(fl) actionTemp.setIcon(icon) actionTemp.setToolTip(selected) self.toolBar.addAction(actionTemp) data.config.setOption('TOOLBAR', selected) except Exception as err: self.output(formatUserError(err)) def restoreColumns(self): data.config.setDefaultWindow() self.resizeColumns() def resizeColumns(self): for i in range(0, self.treeWidget.header().count()): self.treeWidget.header().resizeSection(i, data.config.getWindowSection(i) or 60) for i in range(0, self.loadOrder.header().count() + 1): size = data.config.getWindowSection(i, 'lo') if size: self.loadOrder.header().resizeSection(i, size) try: hsplit0 = data.config.get('WINDOW', 'hsplit0') hsplit1 = data.config.get('WINDOW', 'hsplit1') if hsplit0 and hsplit1: self.horizontalSplitter_tree.setSizes( [int(hsplit0), int(hsplit1)]) except Exception as e: print(f"couldn't restore split: {e}") def output(self, appendation): '''Prints appendation to the output text field''' self.textEdit.append(appendation) def clear(self): '''Removes all text from output text field''' self.textEdit.setText("") def rename(self): '''Renames selected mod''' selected = self.getSelectedMods() if selected: try: renamed = 0 for oldname in selected: newname, ok = QInputDialog.getText( None, TRANSLATE("MainWindow", 'Rename') + " " + oldname, TRANSLATE("MainWindow", 'Enter new mod name') + ": ", QLineEdit.Normal, oldname) if ok: self.model.rename(oldname, newname) renamed += 1 if renamed: self.refreshList() except Exception as err: self.output(formatUserError(err)) def details(self): '''Shows details of the selected mods''' selected = self.getSelectedMods() if selected: try: for modname in selected: details = DetailsDialog(self, self.model.get(modname)) details.show() except Exception as err: self.output(formatUserError(err)) def openFolder(self): '''Open folders of the selected mods''' selected = self.getSelectedMods() if selected: try: for modname in selected: self.model.explore(modname) except Exception as err: self.output(formatUserError(err)) def modToggled(self, item, column): '''Triggered when the mod check state is changed. Enables or disables the mod based on the current check state''' try: if item.checkState(column) == Qt.Checked: self.model.get(item.text(1)).enable() elif item.checkState(column) == Qt.Unchecked: self.model.get(item.text(1)).disable() self.model.write() self.refreshLoadOrder() self.alertRunScriptMerger() except Exception as err: self.output(formatUserError(err)) def modDoubleClicked(self): '''Triggered when double clicked on the mod''' self.setPriority() def loadOrderDoubleClicked(self, item): '''Triggered when double clicked on the mod on the right panel. Sets priority''' try: selected = item.text(0) if (selected[0] == '~'): QMessageBox.critical( self, TRANSLATE("MainWindow", "Error"), TRANSLATE("MainWindow", "You cannot set priority to disabled mod") + " ") return selectedvalue = item.text(1) if (selectedvalue): value = int(selectedvalue) else: value = 0 priority, ok = QInputDialog.getInt( self, TRANSLATE("MainWindow", "Set Priority"), TRANSLATE("MainWindow", "Enter new priority") + ": ", value) if (ok): data.config.setPriority(str(selected), str(priority)) data.config.write() self.refreshList() except Exception as err: self.output(formatUserError(err)) def increaseLoadOrderPriority(self): '''Increases the priority of the selected mods in the load order list''' items = self.loadOrder.selectedItems() if items: item = items[0] selected = item.text(0) selectedvalue = item.text(1) if (selectedvalue): value = int(selectedvalue) else: value = 0 value = value + 1 data.config.setPriority(str(selected), str(value)) item.setText(1, str(value)) data.config.write() def decreaseLoadOrderPriority(self): '''Decreases the priority of the selected mods in the load order list''' items = self.loadOrder.selectedItems() if items: item = items[0] selected = item.text(0) selectedvalue = item.text(1) if (selectedvalue): value = max(-1, int(selectedvalue) - 1) if value < 0: data.config.removeSection(str(selected)) item.setText(1, "") else: data.config.setPriority(str(selected), str(value)) item.setText(0, str(value)) data.config.write() def alertPopupChanged(self): '''Triggered when option to alert popup is changed. Saves the change''' if (self.actionAlert_to_run_Script_Merger.isChecked()): data.config.allowpopups = '1' else: data.config.allowpopups = '0' def changeLanguage(self, language): '''Triggered when language is changed. Saves the change and restarts the program''' data.config.language = str(language) button = QMessageBox.question( self, TRANSLATE("MainWindow", "Change language"), TRANSLATE("MainWindow", "You need to restart the program to apply the changes.\n\ Do you want to restart it now?"), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if (button == QMessageBox.Yes): restartProgram() def checkLanguage(self): '''Checks which language is selected, and checks it''' language = data.config.language for lang in self.menuSelect_Language.actions(): if (language == lang.text() + ".qm"): lang.setChecked(True) break def setPriority(self): '''Sets the priority of the selected mods''' try: selected = self.getSelectedMods() if selected: old_priority = self.model.get(selected[0]).priority if not old_priority or not old_priority.isdecimal(): old_priority = 0 else: old_priority = int(old_priority) priority, ok = QInputDialog.getInt( self, TRANSLATE("MainWindow", "Set Priority"), TRANSLATE("MainWindow", "Enter new priority") + ": ", old_priority) if not ok: return for modname in selected: mod = self.model.get(modname) if mod.enabled: mod.priority = priority else: self.output(TRANSLATE( "MainWindow", "You cannot set priority to disabled mod") + " '" + modname + "'") data.config.write() self.refreshList() except Exception as err: self.output(formatUserError(err)) def unsetPriority(self): '''Removes priority of the selected mods''' selected = self.getSelectedMods() if selected: for modname in selected: self.model.get(modname).priority = None data.config.write() self.refreshList() def increasePriority(self): '''Increases the priority of the selected mods''' selected = self.getSelectedMods() if selected: for modname in selected: self.model.get(modname).increasePriority() data.config.write() self.refreshList() def decreasePriority(self): '''Decreases the priority of the selected mods''' selected = self.getSelectedMods() if selected: for modname in selected: self.model.get(modname).decreasePriority() data.config.write() self.refreshList() def changeGamePath(self): '''Changes game path''' if reconfigureGamePath(): self.refreshList() def changeScriptMergerPath(self): '''Changes script merger path''' reconfigureScriptMergerPath() def installMods(self): '''Installs selected mods''' self.clear() file = getFile(data.config.lastpath, "*.zip *.rar *.7z") self.installModFiles(file) def installModFiles(self, file): '''Installs passed list of mods''' try: successCount = 0 errorCount = 0 if file: progress = 0 progressMax = len(file) installer = Installer(self.model, output=self.output) for mod in file: progressStart = 100 * progress / progressMax progressEnd = 100 * (progress + 1) / progressMax progressCur = progressEnd - progressStart # pylint: disable=cell-var-from-loop installer.progress = lambda p: \ self.setProgress(progressStart + progressCur * p) result, count = installer.installMod(mod) if result: successCount += count else: errorCount += 1 progress += 1 self.setProgress(100 * progress / progressMax) lastpath, _ = path.split(file[0]) data.config.lastpath = lastpath self.refreshList() if successCount: self.alertRunScriptMerger() self.setProgress(0) else: self.output(TRANSLATE("MainWindow", "Installation canceled")) except Exception as err: self.setProgress(0) self.output(formatUserError(err)) errorCount += 1 self.output( f'> Installed {successCount} mods or dlcs ({errorCount} errors)') def uninstallMods(self): '''Uninstalls selected mods''' try: selected = self.getSelectedMods() if selected: clicked = QMessageBox.question( self, TRANSLATE("MainWindow", "Confirm"), TRANSLATE("MainWindow", "Are you sure you want to uninstall ") + str(len(selected)) + TRANSLATE("MainWindow", " selected mods") + "?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if clicked == QMessageBox.Yes: progress = 0 progressMax = len(selected) installer = Installer(self.model, output=self.output) for modname in selected: installer.uninstallMod(self.model.get(modname)) progress += 1 self.setProgress(100 * progress / progressMax) self.refreshList() self.setProgress(0) self.alertRunScriptMerger() except Exception as err: self.setProgress(0) self.output(formatUserError(err)) def reinstallMods(self): '''Reinstalls selected mods''' try: selected = self.getSelectedMods() if selected: clicked = QMessageBox.question( self, TRANSLATE("MainWindow", "Confirm"), TRANSLATE("MainWindow", "Are you sure you want to reinstall ") + str(len(selected)) + TRANSLATE("MainWindow", " selected mods") + "?\n\n" + TRANSLATE("MainWindow", "This will override the mods settings with " + "their defaults."), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if clicked == QMessageBox.Yes: self.setProgress(20) installer = Installer(self.model, output=self.output) for modname in selected: installer.reinstallMod(self.model.get(modname)) self.setProgress(100) self.refreshList() self.setProgress(0) self.alertRunScriptMerger() except Exception as err: self.setProgress(0) self.output(formatUserError(err)) def runTheGame(self): '''Runs the game''' try: gamepath = data.config.gameexe directory, _ = path.split(gamepath) if platform == "win32" or platform == "cygwin": subprocess.Popen([gamepath], cwd=directory) else: MessageUnsupportedOSAction( "Please run the game through Steam.") except Exception as err: self.output(formatUserError(err)) def runScriptMerger(self): '''Runs script merger''' try: scriptmergerpath = data.config.scriptmerger if not scriptmergerpath: self.changeScriptMergerPath() scriptmergerpath = data.config.scriptmerger directory, _ = path.split(scriptmergerpath) if platform == "win32" or platform == "cygwin": subprocess.Popen([scriptmergerpath], cwd=directory) elif platform == "linux" or platform == "darwin": subprocess.Popen(["wine", scriptmergerpath], cwd=directory) else: MessageUnsupportedOSAction("") except Exception as err: self.output(formatUserError(err)) def selectAllMods(self): '''Selects all mods in the list''' self.treeWidget.selectAll() def enableDisableMods(self): '''Changes checked state of the selected mods''' try: selected = self.treeWidget.selectedItems() if not selected: return self.setProgress(0) progress = 0 progressMax = len(selected) for item in selected: if (item.checkState(0) == Qt.Checked): item.setCheckState(0, Qt.Unchecked) else: item.setCheckState(0, Qt.Checked) progress += 1 self.setProgress(100 * progress / progressMax) self.refreshList() self.alertRunScriptMerger() self.setProgress(0) except Exception as err: self.setProgress(0) self.output(formatUserError(err)) def setSearchString(self, searchString): self.searchString = searchString self.refreshList() # Helpers @throttle(200) def refreshList(self): '''Refreshes mod list''' try: selected = self.getSelectedMods() self.treeWidget.clear() moddata = [] for mod in self.model.all(): if len(self.searchString) > 0: if self.searchString.lower() not in mod.name.lower(): continue moddata += mod.files modsize = 0 for modfile in mod.files: modsize += getSize(data.config.mods + "/" + modfile) modsize += getSize(data.config.mods + "/~" + modfile) userstr = TRANSLATE("MainWindow", 'No') if (mod.usersettings): userstr = TRANSLATE("MainWindow", 'Yes') self.addToList( mod.enabled, mod.name, mod.priority, len(mod.files), len(mod.dlcs), len(mod.menus), len(mod.xmlkeys), len(mod.hidden), len(mod.inputsettings), userstr, modsize, mod.date ) for item in selected: rows = self.treeWidget.findItems(item, Qt.MatchEndsWith, 1) if (rows): for row in rows: row.setSelected(True) self.refreshLoadOrder() self.model.write() except Exception as err: self.output(f"Couldn't refresh list: {formatUserError(err)}") return err return None def refreshLoadOrder(self): '''Refreshes right panel list - load order''' try: selected = self.getSelectedFiles() self.loadOrder.clear() data.config.readPriority() dirs = [] for data_ in os.listdir(data.config.mods): templist = [] templist.append(data_) prt = data.config.getPriority(data_) if (prt): temp = int(prt) else: temp = 16777215 templist.append(temp) dirs.append(templist) dirs = sorted(dirs, key=getKey) for directory in dirs: if (isData(directory[0])): if (directory[1] == 16777215): res = '' else: res = str(directory[1]) dirlist = [directory[0], res] item = CustomTreeWidgetItem(dirlist) item.setTextAlignment(1, Qt.AlignCenter) self.loadOrder.addTopLevelItem(item) for item in selected: rows = self.loadOrder.findItems( item.replace("~", ""), Qt.MatchEndsWith, 0) if (rows): for row in rows: row.setSelected(True) except Exception as err: self.output( f"Couldn't read or refresh load order: {formatUserError(err)}") return err return None def setProgress(self, currentProgress): '''Sets the progress to currentProgress''' self.progressBar.setProperty("value", currentProgress) def addToList( self, on, name, prio, data_, dlc, menu, keys, hidden, inputkeys, settings, size, date): '''Adds mod data to the list''' if (data_ == 0): datastr = '-' else: datastr = str(data_) if (dlc == 0): dlcstr = '-' else: dlcstr = str(dlc) if (menu == 0): menustr = '-' else: menustr = str(menu) if (keys == 0): keystr = '-' else: keystr = str(keys) if (inputkeys == 0): inkeystr = '-' else: inkeystr = str(inputkeys) if (hidden == 0): hiddenstr = '-' else: hiddenstr = str(hidden) size //= 1024 if (size // 1024 == 0): sizestr = str(size) + 'KB' else: size /= 1024 sizestr = f"{size:.1f}" + 'MB' proplist = [ '', str(name), str(prio), datastr, dlcstr, menustr, keystr, hiddenstr, inkeystr, str(settings), sizestr, str(date)] item = CustomTreeWidgetItem(proplist) item.setTextAlignment(2, Qt.AlignCenter) item.setTextAlignment(3, Qt.AlignCenter) item.setTextAlignment(4, Qt.AlignCenter) item.setTextAlignment(5, Qt.AlignCenter) item.setTextAlignment(6, Qt.AlignCenter) item.setTextAlignment(7, Qt.AlignCenter) item.setTextAlignment(8, Qt.AlignCenter) item.setTextAlignment(9, Qt.AlignCenter) item.setTextAlignment(10, Qt.AlignRight) item.setTextAlignment(11, Qt.AlignCenter) if (not '~' in name): if (on): item.setCheckState(0, Qt.Checked) else: item.setCheckState(0, Qt.Unchecked) self.treeWidget.addTopLevelItem(item) return item def getSelectedMods(self): '''Returns list of mod names of the selected mods''' array = [] getSelected = self.treeWidget.selectedItems() if getSelected: for selected in getSelected: baseNode = selected array.append(baseNode.text(1)) return array def getSelectedFiles(self): array = [] getSelected = self.loadOrder.selectedItems() if getSelected: for selected in getSelected: baseNode = selected array.append(baseNode.text(0)) return array def makeTempAction(self, action): '''Temp function for bypassing actions with same names problem''' temp = QAction(action) temp.setText(action.text()) temp.setIcon(action.icon()) temp.triggered.connect(lambda: self.removeFromToolbar(action)) return temp def makeLangAction(self, ts): name, _ = path.splitext(ts) action = QAction() action.setText(name) action.setToolTip(name) action.setCheckable(True) action.setChecked(False) action.triggered.connect(lambda: self.changeLanguage(ts)) return action @throttle(2000) def alertRunScriptMerger(self): '''Shows previous dialog based on settings''' if (data.config.allowpopups == "1"): res = MessageAlertScript() if (res == QMessageBox.Yes): self.runScriptMerger()
42.807296
277
0.620267
4a2436a8f2130642fbe3761141728de744cd5399
420
py
Python
model-optimizer/extensions/front/tf/select_ext.py
NikDemoShow/openvino
31907e51e96f1603753dc69811bdf738374ca5e6
[ "Apache-2.0" ]
3
2021-12-20T16:22:38.000Z
2022-01-11T09:46:37.000Z
model-optimizer/extensions/front/tf/select_ext.py
NikDemoShow/openvino
31907e51e96f1603753dc69811bdf738374ca5e6
[ "Apache-2.0" ]
105
2020-06-04T00:23:29.000Z
2022-02-21T13:04:33.000Z
model-optimizer/extensions/front/tf/select_ext.py
v-Golubev/openvino
26936d1fbb025c503ee43fe74593ee9d7862ab15
[ "Apache-2.0" ]
4
2021-04-02T08:48:38.000Z
2021-07-01T06:59:02.000Z
# Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from extensions.ops.select import Select from mo.front.extractor import FrontExtractorOp from mo.graph.graph import Node class SelectExtractor(FrontExtractorOp): op = 'Select' enabled = True @classmethod def extract(cls, node: Node): Select.update_node_stat(node, {'format': 'tf',}) return cls.enabled
24.705882
56
0.721429
4a24373a4e28877b52b323f588d5c3b78e11b74f
806
py
Python
bip_utils/bip/bip32/__init__.py
MIPPLTeam/bip_utils
c66446e7ac3879d2cf6308c5b8eb7f7705292660
[ "MIT" ]
149
2020-05-15T08:11:43.000Z
2022-03-29T16:34:42.000Z
bip_utils/bip/bip32/__init__.py
MIPPLTeam/bip_utils
c66446e7ac3879d2cf6308c5b8eb7f7705292660
[ "MIT" ]
41
2020-04-03T15:57:56.000Z
2022-03-31T08:25:11.000Z
bip_utils/bip/bip32/__init__.py
MIPPLTeam/bip_utils
c66446e7ac3879d2cf6308c5b8eb7f7705292660
[ "MIT" ]
55
2020-04-03T17:05:15.000Z
2022-03-24T12:43:42.000Z
from bip_utils.bip.bip32.bip32_base import Bip32Base from bip_utils.bip.bip32.bip32_const import Bip32Const from bip_utils.bip.bip32.bip32_ed25519_slip import Bip32Ed25519Slip from bip_utils.bip.bip32.bip32_ed25519_blake2b_slip import Bip32Ed25519Blake2bSlip from bip_utils.bip.bip32.bip32_nist256p1 import Bip32Nist256p1 from bip_utils.bip.bip32.bip32_secp256k1 import Bip32Secp256k1 from bip_utils.bip.bip32.bip32_ex import Bip32KeyError, Bip32PathError from bip_utils.bip.bip32.bip32_key_data import ( Bip32ChainCode, Bip32Depth, Bip32FingerPrint, Bip32KeyIndex, Bip32KeyNetVersions, Bip32KeyData ) from bip_utils.bip.bip32.bip32_keys import Bip32PublicKey, Bip32PrivateKey from bip_utils.bip.bip32.bip32_path import Bip32PathParser, Bip32Path from bip_utils.bip.bip32.bip32_utils import Bip32Utils
57.571429
98
0.87469
4a2437df996ef3ed713b8cb583c50c823a114268
4,171
py
Python
examples/switch/smm2_ninji.py
kinnay/NintendoClients
8d264ea4d5eccb9ef8f212b1ddb4d22634dc4e3f
[ "MIT" ]
144
2020-12-05T21:56:41.000Z
2022-03-27T20:25:48.000Z
examples/switch/smm2_ninji.py
kinnay/NintendoClients
8d264ea4d5eccb9ef8f212b1ddb4d22634dc4e3f
[ "MIT" ]
28
2020-12-03T17:48:06.000Z
2022-03-25T20:27:48.000Z
examples/switch/smm2_ninji.py
kinnay/NintendoClients
8d264ea4d5eccb9ef8f212b1ddb4d22634dc4e3f
[ "MIT" ]
22
2020-12-06T11:42:23.000Z
2022-03-22T06:17:00.000Z
from nintendo.baas import BAASClient from nintendo.dauth import DAuthClient from nintendo.aauth import AAuthClient from nintendo.switch import ProdInfo, KeySet from nintendo.nex import backend, authentication, \ datastore_smm2 as datastore, settings from nintendo.games import SMM2 from anynet import http import anyio import zlib import logging logging.basicConfig(level=logging.INFO) SYSTEM_VERSION = 1300 #13.0.0 # You can get your user id and password from # su/baas/<guid>.dat in save folder 8000000000000010. # Bytes 0x20 - 0x28 contain the user id in reversed # byte order, and bytes 0x28 - 0x50 contain the # password in plain text. # Alternatively, you can set up a mitm on your Switch # and extract them from the request to /1.0.0/login BAAS_USER_ID = 0x0123456789abcdef # 16 hex digits BAAS_PASSWORD = "..." # Should be 40 characters # You can dump prod.keys with Lockpick_RCM and # PRODINFO from hekate (decrypt it if necessary) PATH_KEYS = "/path/to/prod.keys" PATH_PRODINFO = "/path/to/PRODINFO" # Tickets can be dumped with nxdumptool. # You need the base ticket, not an update ticket. # Do not remove console specific data. PATH_TICKET = "/path/to/ticket" HOST = "g%08x-lp1.s.n.srv.nintendo.net" %SMM2.GAME_SERVER_ID PORT = 443 async def main(): keys = KeySet.load(PATH_KEYS) info = ProdInfo(keys, PATH_PRODINFO) with open(PATH_TICKET, "rb") as f: ticket = f.read() cert = info.get_tls_cert() pkey = info.get_tls_key() dauth = DAuthClient(keys) dauth.set_certificate(cert, pkey) dauth.set_system_version(SYSTEM_VERSION) response = await dauth.device_token(dauth.BAAS) device_token = response["device_auth_token"] aauth = AAuthClient() aauth.set_system_version(SYSTEM_VERSION) response = await aauth.auth_digital( SMM2.TITLE_ID, SMM2.LATEST_VERSION, device_token, ticket ) app_token = response["application_auth_token"] baas = BAASClient() baas.set_system_version(SYSTEM_VERSION) response = await baas.authenticate(device_token) access_token = response["accessToken"] response = await baas.login( BAAS_USER_ID, BAAS_PASSWORD, access_token, app_token ) user_id = int(response["user"]["id"], 16) id_token = response["idToken"] auth_info = authentication.AuthenticationInfo() auth_info.token = id_token auth_info.ngs_version = 4 #Switch auth_info.token_type = 2 s = settings.load("switch") s.configure(SMM2.ACCESS_KEY, SMM2.NEX_VERSION, SMM2.CLIENT_VERSION) async with backend.connect(s, HOST, PORT) as be: async with be.login(str(user_id), auth_info=auth_info) as client: # Search for ninji courses store = datastore.DataStoreClientSMM2(client) param = datastore.SearchCoursesEventParam() courses = await store.search_courses_event(param) print("Found %i ninji courses.\n" %len(courses)) # Print information about the oldest ninji course course = courses[-1] print("Name:", course.name) print("Description:", course.description) print("Start time:", course.upload_time) print("End time:", course.end_time) print() # Request ghost info param = datastore.GetEventCourseGhostParam() param.data_id = course.data_id param.time = 30000 # Request ghosts with a time around 30 seconds param.count = 1 # Only request a single ghost ghost = (await store.get_event_course_ghost(param))[0] # Request info about the ghost player param = datastore.GetUsersParam() param.pids = [ghost.pid] user = (await store.get_users(param)).users[0] print("Player:", user.name) print("Time: %i.%03i" %(ghost.time // 1000, ghost.time % 1000)) print() # Download replay file header_info = await store.get_req_get_info_headers_info(ghost.replay_file.data_type) headers = {h.key: h.value for h in header_info.headers} response = await http.get(ghost.replay_file.url, headers=headers) response.raise_if_error() # Decompress and save replay file data = zlib.decompress(response.body) with open("replay.bin", "wb") as f: f.write(data) anyio.run(main)
30.896296
88
0.714936
4a2437f2a581c5b9dc92f758babc0ca06eba66d7
4,107
py
Python
example/jclient/__init__.py
lega911/job_server
e65ff359d16217de7a67413aa1a295a551eaee99
[ "MIT" ]
16
2015-09-15T14:47:14.000Z
2017-08-10T07:41:25.000Z
example/jclient/__init__.py
lega911/job_server
e65ff359d16217de7a67413aa1a295a551eaee99
[ "MIT" ]
4
2015-09-07T17:15:42.000Z
2015-09-15T07:19:48.000Z
example/jclient/__init__.py
lega911/job_server
e65ff359d16217de7a67413aa1a295a551eaee99
[ "MIT" ]
null
null
null
import socket from .utils import int_to_b3, b3_to_int, UnknownMethod, Error, WorkerException, recvall, byte_to_int try: import queue except ImportError: import Queue as queue class WorkerHandler(object): """ Example: rpc = WorkerHandler('localhost', 8011) rpc.add('ping', ping) rpc.add('echo', echo) rpc.serve() rpc.close() """ def __init__(self, host, port): self.socket = None self.host = host self.port = port self.fn = {} def close(self): self.socket.close() self.socket = None def add(self, name, callback): self.fn[name.encode('utf8')] = callback def call(self, name, data): return self.fn[name](data) def recv_name_data(self, size): raw = recvall(self.socket, size) i = raw.find(b'\x00') if i < 0: raise Exception('Protocol error') return raw[:i], raw[i+1:] def serve(self): self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.connect((self.host, self.port)) # 11, size_3b, name, 0, data fn = list(self.fn.keys()) fn = sorted(fn) key = b','.join(fn) size = len(key) buf = b'\x0c' + int_to_b3(size) + key self.socket.sendall(buf) while self.socket: raw = recvall(self.socket, 4) flag = byte_to_int(raw[0]) size = b3_to_int(raw[1:]) if flag == 15: name, data = self.recv_name_data(size) result_code = b'\x10' try: result = self.call(name, data) assert isinstance(result, bytes), 'result is not bytes' except Exception as e: result = str(e).encode('utf8') result_code = b'\x13' assert len(result) < 0x1000000, 'Data is too big' raw = result_code + int_to_b3(len(result)) + result self.socket.sendall(raw) elif flag == 21: # async name, data = self.recv_name_data(size) try: self.call(name, data) except Exception as e: pass else: raise Exception('Protocol error') class ClientHandler(object): """ Example: rpc = ClientHandler('localhost', 8010) rpc.call('echo', b'data') rpc.close() """ def __init__(self, host, port): self.host = host self.port = port self.socks = queue.Queue() def _connect(self): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) return sock def close(self): while not self.socks.empty(): self.socks.get_nowait().close() def call(self, method, data, async=False): # 11, size_3b, name, 0, data method = method.encode('utf8') size = len(method) + len(data) + 1 assert size < 0x1000000, 'Data is too big' code = b'\x0d' if async else b'\x0b' buf = code + int_to_b3(size) + method + b'\x00' + data # get socket try: sock = self.socks.get_nowait() except queue.Empty: sock = self._connect() sock.sendall(buf) raw = recvall(sock, 4) code = byte_to_int(raw[0]) if code in {16, 17, 18, 19}: size = b3_to_int(raw[1:]) response = recvall(sock, size) self.socks.put_nowait(sock) if code == 16: return response elif code == 17: raise UnknownMethod(response.decode('utf8')) elif code == 18: raise Error(response.decode('utf8')) elif code == 19: raise WorkerException(response.decode('utf8')) elif code == 20: # async task was accepted self.socks.put_nowait(sock) else: sock.close() raise Exception('Protocol error')
29.335714
100
0.521305
4a2439079bf37857d229e0281efa9dcd7fdbafd4
7,640
py
Python
GAE/main.py
World4AI/reinforcement-learning
21267d12a19f9982baca003e4b976b19d3d8866c
[ "MIT" ]
null
null
null
GAE/main.py
World4AI/reinforcement-learning
21267d12a19f9982baca003e4b976b19d3d8866c
[ "MIT" ]
null
null
null
GAE/main.py
World4AI/reinforcement-learning
21267d12a19f9982baca003e4b976b19d3d8866c
[ "MIT" ]
null
null
null
import torch import torch.nn as nn from torch.distributions import Categorical import numpy as np import argparse import gym class ActorCritic(nn.Module): def __init__(self, num_features, num_actions, name): super(ActorCritic, self).__init__() self.path = name + '.pth' self.model = nn.Sequential( nn.Linear(in_features=num_features, out_features=512), nn.ReLU(), nn.Linear(in_features=512, out_features=256)) self.logits = nn.Linear(in_features=256, out_features=num_actions) self.value = nn.Linear(in_features=256, out_features=1) def forward(self, obs): model_output = self.model(obs) logits = self.logits(model_output) value = self.value(model_output) distribution = Categorical(logits=logits) action = distribution.sample() log_prob = distribution.log_prob(action) entropy = distribution.entropy() return action, log_prob, entropy, value def save_model(self): torch.save(self.state_dict(), self.path) def load_model(self): self.load_state_dict(torch.load(self.path)) class Agent: def __init__(self, name, env_id, num_envs, max_steps, num_steps, alpha, gamma, gae_lambda, value_factor, entropy_factor, device): self.device = device self.env = gym.make(env_id) self.envs = gym.vector.make(env_id, num_envs) self.num_features=self.env.observation_space.shape[0] self.num_actions=self.env.action_space.n self.gamma = gamma self.gae_lambda = gae_lambda self.max_steps = max_steps self.num_steps = num_steps self.AC = ActorCritic(self.num_features, self.num_actions, name) self.AC.to(self.device) self.optimizer = torch.optim.Adam(self.AC.parameters(), alpha) self.value_factor = value_factor self.entropy_factor = entropy_factor def reset(self): self.log_probs = [] self.rewards = [] self.values = [] self.entropies = [] self.dones = [] def optimize(self): # tensor values log_probs = torch.stack(self.log_probs) entropies = torch.stack(self.entropies) values = torch.stack(self.values) # numpy values dones = np.stack(self.dones) rewards = np.stack(self.rewards) # transform to tensors dones = torch.tensor(dones).to(self.device) rewards = torch.tensor(rewards).to(self.device) advantages = [] prev_gae = 0 for t in reversed(range(self.num_steps)): delta = rewards[t] + self.gamma * values[t+1].detach() * dones[t].logical_not() - values[t] delta += self.gamma * self.gae_lambda * prev_gae * dones[t].logical_not() prev_gae = delta advantages.append(prev_gae) advantages = torch.stack(advantages) # zero the gradients self.optimizer.zero_grad() # calculate actor loss pi_loss = -(advantages.detach() * log_probs).mean() # calculate entropy loss entropy_loss = -(entropies).mean() # calculate critic loss v_loss = advantages.pow(2).mul(0.5).mean() # calulate linearly weighted loss loss = pi_loss + self.entropy_factor * entropy_loss + self.value_factor * v_loss # run optimization step loss.backward() self.optimizer.step() def train(self): self.reset() obs = self.envs.reset() max_updates = self.max_steps // self.num_steps for i in range(max_updates): # use neural network to calculate the action, value and so on obs = torch.tensor(obs, dtype=torch.float32).to(self.device) action, log_prob, entropy, value = self.AC(obs) # take action action = action.cpu().detach().numpy() next_obs, reward, done, _ = self.envs.step(action) # save variables needed for optimization self.rewards.append(reward) self.dones.append(done) self.log_probs.append(log_prob) self.entropies.append(entropy) value = value.squeeze(dim=1) self.values.append(value) obs = next_obs if (i+1) % self.num_steps == 0: # we need one more value to calculate the bootsrapped target with torch.no_grad(): last_obs = torch.tensor(obs, dtype=torch.float32).to(self.device) _, _, _, value = self.AC(last_obs) value = value.squeeze(dim=1) self.values.append(value.detach()) self.optimize() self.reset() if (i+1) % 100 == 0: self.evaluate((i+1)*self.num_steps) def evaluate(self, step): returns = [] for _ in range(10): obs = self.env.reset() done = False eval_return = 0; while not done: with torch.no_grad(): obs = torch.tensor(obs, dtype=torch.float32).to(self.device) action, _, _, _ = self.AC(obs) action = action.cpu().detach().numpy() next_obs, reward, done, _ = self.env.step(action) obs = next_obs eval_return += reward returns.append(eval_return) avg_return = np.mean(returns) print('------------------------------------------------') print(f'Step: {step}') print(f'Average Return: {avg_return}') if __name__ == '__main__': # Algorithm inputs parser = argparse.ArgumentParser(description="GAE-A2C") parser.add_argument('--name', type=str, default="GAE_A2C_Cartpole-v1", help='The name of the experiment') parser.add_argument('--env-id', type=str, default="CartPole-v1", help='The id of the OpenAI gym environment') parser.add_argument('--num-envs', type=int, default=8, help='The number of environments that run in parallel') parser.add_argument('--max-steps', type=int, default=20000, help='The number of steps the algorithm is going to run for') parser.add_argument('--num-steps', type=int, default=5, help='The number of steps to calculate n-returns') parser.add_argument('--alpha', type=float, default=0.00025, help='The learning rate of the actor-critic used in gradient descent') parser.add_argument('--value-factor', type=float, default=0.5, help='The factor with which value function is taken into acount in the loss calculation') parser.add_argument('--entropy-factor', type=float, default=0.05, help='The factor with which the entropy is taken into account in the loss calculation') parser.add_argument('--gamma', type=float, default=0.99, help='The discount rate') parser.add_argument('--gae-lambda', type=float, default=0.95, help='The lambda used for the calculation of GAE') args = parser.parse_args() device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') print(f'Running on device: {device}') agent = Agent( name=args.name, env_id=args.env_id, num_envs=args.num_envs, max_steps=args.max_steps, num_steps=args.num_steps, alpha=args.alpha, gamma=args.gamma, gae_lambda=args.gae_lambda, value_factor=args.value_factor, entropy_factor=args.entropy_factor, device=device) # start the training loop agent.train()
38.781726
157
0.603141
4a243979a54311a8583844e7428741d8457499f2
6,794
py
Python
soba/agents/roomsOccupant.py
GGP00/soba
c193f323f26eccf579a454b8bb4bec4e80644444
[ "MIT" ]
1
2017-03-06T12:33:02.000Z
2017-03-06T12:33:02.000Z
soba/agents/roomsOccupant.py
GGP00/soba
c193f323f26eccf579a454b8bb4bec4e80644444
[ "MIT" ]
3
2017-04-26T08:57:35.000Z
2019-04-24T08:28:24.000Z
soba/agents/roomsOccupant.py
GGP00/soba
c193f323f26eccf579a454b8bb4bec4e80644444
[ "MIT" ]
1
2019-01-20T17:39:00.000Z
2019-01-20T17:39:00.000Z
import random import soba.agents.resources.aStar as aStar from soba.agents.occupant import Occupant class RoomsOccupant(Occupant): """ This class enables to create occupants that are modelled with a simplified models based on a discrete space associated with rooms. The occupants are agents with their activity defined by markov states. Attributes: Those inherited from the Occupant class. Methods: getPosState: Auxiliary method to distribute the occupants between the rooms shared by more than one occupant object. getWay: Invocation of the AStar resource to calculate the optimal path. occupantMovePos: Calculation of the control attributes that regulate the cost (steps) of the movement between rooms according to their size. getPlaceToGo: Obtaining the position associated with the current state. step: Method invoked by the Model scheduler in each step. """ def __init__(self, unique_id, model, json, speed = 0.7): super().__init__(unique_id, model, json, speed) """ Create a new RoomsOccupant object. Args: unique_id: Unique identifier corresponding to the Occupant. models: Associated Model object, by default RoomsModel. json: Json of definition of parameters of behavior speed: Movement speed in m/s Return: RoomsOccupant object """ self.model.schedule.add(self) #State machine for k, v in json['states'].items(): pos = self.getPosState(k, v) self.positionByState[k] = pos possible_rooms = [] roomsNames = self.positionByState[self.state] for room in self.model.rooms: if isinstance(roomsNames, dict): for roomName, v in roomsNames.items(): if room.name.split(r".")[0] == roomName: possible_rooms.append(room) else: if room.name.split(r".")[0] == self.positionByState[self.state]: possible_rooms.append(room) if len(possible_rooms) > 1: roomaux = random.choice(possible_rooms) else: roomaux = possible_rooms[0] self.model.grid.place_agent(self, roomaux.pos) self.model.pushAgentRoom(self, roomaux.pos) #control self.onMyWay1 = False self.onMyWay2 = False self.costMovementToNewRoom = 0 self.costMovementInNewRoom = 0 self.room1 = False self.room2 = False def getPosState(self, name, posAux): ''' Auxiliary method to distribute the occupants between the rooms shared by more than one occupant object. Args: name: State name. posAux: Name of the room associated with this state, string, or dictionary of room names with number of occupants. {'RoomName1': numberofOccupantsAssigned1, 'RoomName2': numberofOccupantsAssigned2... } Return: Position associated with this occupant ''' if isinstance(posAux, dict): for k, v in posAux.items(): if v > 0: self.positionByStateAux[name][k]= v - 1 return k return posAux #Movement def getWay(self, pos = None, pos_to_go = None): ''' Invocation of the AStar resource to calculate the optimal path. Args: pos: Initial position, by default the current position of the occupant. pos_to_go: Final position, by default the value of the 'pos_to_go' attribute of the occupant. Return: List of positions (x, y). ''' posSend = pos pos_to_goSend = pos_to_go if pos == None: posSend = self.pos if pos_to_go == None: pos_to_goSend = self.pos_to_go return aStar.getPathRooms(self.model, posSend, pos_to_goSend) def occupantMovePos(self, new_position): ''' Calculation of the control attributes that regulate the cost (steps) of the movement between rooms according to their size. Args: new_position: Room object to which it moves. ''' ux, uy = self.pos nx, ny = new_position for room in self.model.rooms: rx, ry = room.pos if room.pos == self.pos: #Cost as steps if (rx == nx): self.costMovemenToNewRoom = room.dy/2 * (1/self.speed) * (1/self.model.clock.timeByStep)# m * seg/m * step/seg if (ry == ny): self.costMovemenToNewRoom = room.dx/2 * (1/self.speed) * (1/self.model.clock.timeByStep) if room.pos == new_position: if (rx == ux): self.costMovementInNewRoom = room.dy/2 * (1/self.speed) * (1/self.model.clock.timeByStep) if (ry == uy): self.costMovementInNewRoom = room.dx/2 * (1/self.speed) * (1/self.model.clock.timeByStep) def getPlaceToGo(self): ''' Obtaining the position associated with the current state. It is invoked when you enter a new state. Return: Position as coordinate (x, y). ''' pos_to_go = self.pos roomsNames = self.positionByState[self.state] possible_rooms = [] for room in self.model.rooms: if isinstance(roomsNames, dict): for roomName, v in roomsNames.items(): if room.name.split(r".")[0] == roomName: possible_rooms.append(room.pos) else: if room.name.split(r".")[0] == self.positionByState[self.state]: possible_rooms.append(room.pos) if len(possible_rooms) > 1: pos_to_go = random.choice(possible_rooms) else: pos_to_go = possible_rooms[0] return pos_to_go def startActivity(self): super.startActivity() def step(self): """ Method invoked by the Model scheduler in each step. Evaluate if appropriate and, if so, perform: A change of state, a movement or advance in the cost of a movement, or an advance in the performance of an activity. """ if self.markov == True or self.changeSchedule(): self.markov_machine.runStep(self.markovActivity[self.getPeriod()]) elif self.onMyWay1 == True: if self.costMovemenToNewRoom > 0: self.costMovemenToNewRoom = self.costMovemenToNewRoom - 1 else: room1 = self.model.getRoom(self.pos) room2 = self.model.getRoom(self.movements[self.N]) self.room1 = room1 self.room2 = room2 if room1.name.split(r".")[0] != room2.name.split(r".")[0]: self.model.openDoor(self, room1, room2) self.model.popAgentRoom(self, self.pos) self.model.grid.move_agent(self, self.movements[self.N]) self.model.pushAgentRoom(self, self.pos) self.N = self.N + 1 self.onMyWay1 = False self.onMyWay2 = True elif self.onMyWay2 == True: if self.costMovementInNewRoom > 0: self.costMovementInNewRoom = self.costMovementInNewRoom - 1 else: room1 = self.room1 room2 = self.room2 if room1.name.split(r".")[0] != room2.name.split(r".")[0]: self.model.closeDoor(self, room1, room2) self.onMyWay2 = False self.step() elif self.pos != self.pos_to_go: self.occupantMovePos(self.movements[self.N]) self.onMyWay1 = True self.step() else: self.N = 0 if self.time_activity > 0: self.time_activity = self.time_activity - 1 else: self.markov = True
36.138298
143
0.686047
4a243985db34b35c9f3fc54456b857956b202c84
2,578
py
Python
lib/spack/spack/test/util/util_gpg.py
xiki-tempula/spack
9d66c05e93ab8a933fc59915040c0e0c86a4aac4
[ "ECL-2.0", "Apache-2.0", "MIT" ]
1
2020-05-24T15:23:12.000Z
2020-05-24T15:23:12.000Z
lib/spack/spack/test/util/util_gpg.py
xiki-tempula/spack
9d66c05e93ab8a933fc59915040c0e0c86a4aac4
[ "ECL-2.0", "Apache-2.0", "MIT" ]
6
2022-02-26T11:44:34.000Z
2022-03-12T12:14:50.000Z
lib/spack/spack/test/util/util_gpg.py
xiki-tempula/spack
9d66c05e93ab8a933fc59915040c0e0c86a4aac4
[ "ECL-2.0", "Apache-2.0", "MIT" ]
2
2020-09-15T02:37:59.000Z
2020-09-21T04:34:38.000Z
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import spack.util.gpg as gpg def test_parse_gpg_output_case_one(): # Two keys, fingerprint for primary keys, but not subkeys output = """sec::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:AAAAAAAAAA::::::::: fpr:::::::::XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: uid:::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::Joe (Test) <[email protected]>: ssb::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:::::::::: sec::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:AAAAAAAAAA::::::::: fpr:::::::::YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY: uid:::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::Joe (Test) <[email protected]>: ssb::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:::::::::: """ keys = gpg.parse_keys_output(output) assert len(keys) == 2 assert keys[0] == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' assert keys[1] == 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' def test_parse_gpg_output_case_two(): # One key, fingerprint for primary key as well as subkey output = """sec:-:2048:1:AAAAAAAAAA:AAAAAAAA:::-:::escaESCA:::+:::23::0: fpr:::::::::XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: grp:::::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA: uid:-::::AAAAAAAAA::AAAAAAAAA::Joe (Test) <[email protected]>::::::::::0: ssb:-:2048:1:AAAAAAAAA::::::esa:::+:::23: fpr:::::::::YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY: grp:::::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA: """ keys = gpg.parse_keys_output(output) assert len(keys) == 1 assert keys[0] == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' def test_parse_gpg_output_case_three(): # Two keys, fingerprint for primary keys as well as subkeys output = """sec::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:AAAAAAAAAA::::::::: fpr:::::::::WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW: uid:::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::Joe (Test) <[email protected]>: ssb::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:::::::::: fpr:::::::::XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: sec::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:AAAAAAAAAA::::::::: fpr:::::::::YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY: uid:::::::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::Joe (Test) <[email protected]>: ssb::2048:1:AAAAAAAAAAAAAAAA:AAAAAAAAAA:::::::::: fpr:::::::::ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:""" keys = gpg.parse_keys_output(output) assert len(keys) == 2 assert keys[0] == 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW' assert keys[1] == 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
42.262295
76
0.72886
4a2439b36006b8b5505bcacd9d9953c3010cad1a
176,433
py
Python
psx/_dump_/28/_dump_ida_/make_psx.py
maoa3/scalpel
2e7381b516cded28996d290438acc618d00b2aa7
[ "Unlicense" ]
15
2018-06-28T01:11:25.000Z
2021-09-27T15:57:18.000Z
psx/_dump_/28/_dump_ida_/make_psx.py
maoa3/scalpel
2e7381b516cded28996d290438acc618d00b2aa7
[ "Unlicense" ]
7
2018-06-29T04:08:23.000Z
2019-10-17T13:57:22.000Z
psx/_dump_/28/_dump_ida_/make_psx.py
maoa3/scalpel
2e7381b516cded28996d290438acc618d00b2aa7
[ "Unlicense" ]
7
2018-06-28T01:11:34.000Z
2020-05-23T09:21:48.000Z
set_name(0x8007B9B4, "GetTpY__FUs", SN_NOWARN) set_name(0x8007B9D0, "GetTpX__FUs", SN_NOWARN) set_name(0x8007B9DC, "Remove96__Fv", SN_NOWARN) set_name(0x8007BA14, "AppMain", SN_NOWARN) set_name(0x8007BB2C, "MAIN_RestartGameTask__Fv", SN_NOWARN) set_name(0x8007BB58, "GameTask__FP4TASK", SN_NOWARN) set_name(0x8007BC40, "MAIN_MainLoop__Fv", SN_NOWARN) set_name(0x8007BC88, "CheckMaxArgs__Fv", SN_NOWARN) set_name(0x8007BCBC, "GPUQ_InitModule__Fv", SN_NOWARN) set_name(0x8007BCC8, "GPUQ_FlushQ__Fv", SN_NOWARN) set_name(0x8007BE3C, "GPUQ_LoadImage__FP4RECTli", SN_NOWARN) set_name(0x8007BEF0, "GPUQ_DiscardHandle__Fl", SN_NOWARN) set_name(0x8007BF90, "GPUQ_LoadClutAddr__FiiiPv", SN_NOWARN) set_name(0x8007C02C, "GPUQ_MoveImage__FP4RECTii", SN_NOWARN) set_name(0x8007C0CC, "PRIM_Open__FiiiP10SCREEN_ENVUl", SN_NOWARN) set_name(0x8007C1E8, "InitPrimBuffer__FP11PRIM_BUFFERii", SN_NOWARN) set_name(0x8007C2C4, "PRIM_Clip__FP4RECTi", SN_NOWARN) set_name(0x8007C3EC, "PRIM_GetCurrentScreen__Fv", SN_NOWARN) set_name(0x8007C3F8, "PRIM_FullScreen__Fi", SN_NOWARN) set_name(0x8007C434, "PRIM_Flush__Fv", SN_NOWARN) set_name(0x8007C648, "PRIM_GetCurrentOtList__Fv", SN_NOWARN) set_name(0x8007C654, "ClearPbOnDrawSync", SN_NOWARN) set_name(0x8007C690, "ClearedYet__Fv", SN_NOWARN) set_name(0x8007C69C, "PrimDrawSycnCallBack", SN_NOWARN) set_name(0x8007C6BC, "SendDispEnv__Fv", SN_NOWARN) set_name(0x8007C6E0, "PRIM_GetNextPolyF4__Fv", SN_NOWARN) set_name(0x8007C6F8, "PRIM_GetNextPolyFt4__Fv", SN_NOWARN) set_name(0x8007C710, "PRIM_GetNextPolyGt4__Fv", SN_NOWARN) set_name(0x8007C728, "PRIM_GetNextPolyG4__Fv", SN_NOWARN) set_name(0x8007C740, "PRIM_GetNextPolyF3__Fv", SN_NOWARN) set_name(0x8007C758, "PRIM_GetNextDrArea__Fv", SN_NOWARN) set_name(0x8007C770, "ClipRect__FRC4RECTR4RECT", SN_NOWARN) set_name(0x8007C884, "IsColiding__FRC4RECTT0", SN_NOWARN) set_name(0x8007C8EC, "VID_AfterDisplay__Fv", SN_NOWARN) set_name(0x8007C90C, "VID_ScrOn__Fv", SN_NOWARN) set_name(0x8007C934, "VID_DoThisNextSync__FPFv_v", SN_NOWARN) set_name(0x8007C98C, "VID_NextSyncRoutHasExecuted__Fv", SN_NOWARN) set_name(0x8007C998, "VID_GetTick__Fv", SN_NOWARN) set_name(0x8007C9A4, "VID_DispEnvSend", SN_NOWARN) set_name(0x8007C9E0, "VID_SetXYOff__Fii", SN_NOWARN) set_name(0x8007C9F0, "VID_GetXOff__Fv", SN_NOWARN) set_name(0x8007C9FC, "VID_GetYOff__Fv", SN_NOWARN) set_name(0x8007CA08, "VID_SetDBuffer__Fb", SN_NOWARN) set_name(0x8007CB78, "MyFilter__FUlUlPCc", SN_NOWARN) set_name(0x8007CB80, "SlowMemMove__FPvT0Ul", SN_NOWARN) set_name(0x8007CBA0, "GetTpY__FUs_addr_8007CBA0", SN_NOWARN) set_name(0x8007CBBC, "GetTpX__FUs_addr_8007CBBC", SN_NOWARN) set_name(0x8007CBC8, "SYSI_GetFs__Fv", SN_NOWARN) set_name(0x8007CBD4, "SYSI_GetOverlayFs__Fv", SN_NOWARN) set_name(0x8007CBE0, "SortOutFileSystem__Fv", SN_NOWARN) set_name(0x8007CD1C, "MemCb__FlPvUlPCcii", SN_NOWARN) set_name(0x8007CD3C, "Spanker__Fv", SN_NOWARN) set_name(0x8007CD7C, "GaryLiddon__Fv", SN_NOWARN) set_name(0x8007CD84, "ReadPad__Fi", SN_NOWARN) set_name(0x8007CE48, "DummyPoll__Fv", SN_NOWARN) set_name(0x8007CE50, "DaveOwens__Fv", SN_NOWARN) set_name(0x8007CE78, "GetCur__C4CPad", SN_NOWARN) set_name(0x8007CEA0, "GetTpY__FUs_addr_8007CEA0", SN_NOWARN) set_name(0x8007CEBC, "GetTpX__FUs_addr_8007CEBC", SN_NOWARN) set_name(0x8007CEC8, "TimSwann__Fv", SN_NOWARN) set_name(0x8007CED0, "stub__FPcPv", SN_NOWARN) set_name(0x8007CED8, "eprint__FPcT0i", SN_NOWARN) set_name(0x8007CF0C, "leighbird__Fv", SN_NOWARN) set_name(0x8007CF34, "__6FileIOUl", SN_NOWARN) set_name(0x8007CF84, "___6FileIO", SN_NOWARN) set_name(0x8007CFD8, "Read__6FileIOPCcUl", SN_NOWARN) set_name(0x8007D140, "FileLen__6FileIOPCc", SN_NOWARN) set_name(0x8007D1A4, "FileNotFound__6FileIOPCc", SN_NOWARN) set_name(0x8007D1C4, "StreamFile__6FileIOPCciPFPUciib_bii", SN_NOWARN) set_name(0x8007D2A4, "ReadAtAddr__6FileIOPCcPUci", SN_NOWARN) set_name(0x8007D368, "DumpOldPath__6FileIO", SN_NOWARN) set_name(0x8007D3CC, "SetSearchPath__6FileIOPCc", SN_NOWARN) set_name(0x8007D4A8, "FindFile__6FileIOPCcPc", SN_NOWARN) set_name(0x8007D5BC, "CopyPathItem__6FileIOPcPCc", SN_NOWARN) set_name(0x8007D664, "LockSearchPath__6FileIO", SN_NOWARN) set_name(0x8007D6BC, "UnlockSearchPath__6FileIO", SN_NOWARN) set_name(0x8007D714, "SearchPathExists__6FileIO", SN_NOWARN) set_name(0x8007D728, "Save__6FileIOPCcPUci", SN_NOWARN) set_name(0x8007D764, "__4PCIOUl", SN_NOWARN) set_name(0x8007D7CC, "___4PCIO", SN_NOWARN) set_name(0x8007D824, "FileExists__4PCIOPCc", SN_NOWARN) set_name(0x8007D868, "LoReadFileAtAddr__4PCIOPCcPUci", SN_NOWARN) set_name(0x8007D92C, "GetFileLength__4PCIOPCc", SN_NOWARN) set_name(0x8007D9E4, "LoSave__4PCIOPCcPUci", SN_NOWARN) set_name(0x8007DAB8, "LoStreamFile__4PCIOPCciPFPUciib_bii", SN_NOWARN) set_name(0x8007DCC8, "__6SysObj", SN_NOWARN) set_name(0x8007DCE0, "__nw__6SysObji", SN_NOWARN) set_name(0x8007DD0C, "__nw__6SysObjiUl", SN_NOWARN) set_name(0x8007DD88, "__dl__6SysObjPv", SN_NOWARN) set_name(0x8007DDF4, "__5DatIOUl", SN_NOWARN) set_name(0x8007DE30, "___5DatIO", SN_NOWARN) set_name(0x8007DE88, "FileExists__5DatIOPCc", SN_NOWARN) set_name(0x8007DEC8, "LoReadFileAtAddr__5DatIOPCcPUci", SN_NOWARN) set_name(0x8007DF88, "GetFileLength__5DatIOPCc", SN_NOWARN) set_name(0x8007E03C, "LoSave__5DatIOPCcPUci", SN_NOWARN) set_name(0x8007E0E4, "LoStreamFile__5DatIOPCciPFPUciib_bii", SN_NOWARN) set_name(0x8007E2F0, "__7TextDat", SN_NOWARN) set_name(0x8007E330, "___7TextDat", SN_NOWARN) set_name(0x8007E378, "Use__7TextDat", SN_NOWARN) set_name(0x8007E56C, "TpLoadCallBack__FPUciib", SN_NOWARN) set_name(0x8007E63C, "StreamLoadTP__7TextDat", SN_NOWARN) set_name(0x8007E6F4, "FinishedUsing__7TextDat", SN_NOWARN) set_name(0x8007E750, "MakeBlockOffsetTab__7TextDat", SN_NOWARN) set_name(0x8007E7C0, "MakeOffsetTab__C9CBlockHdr", SN_NOWARN) set_name(0x8007E8EC, "SetUVTp__7TextDatP9FRAME_HDRP8POLY_FT4ii", SN_NOWARN) set_name(0x8007E9E8, "PrintMonster__7TextDatiiibi", SN_NOWARN) set_name(0x8007EDF0, "PrepareFt4__7TextDatP8POLY_FT4iiiii", SN_NOWARN) set_name(0x8007F05C, "GetDecompBufffer__7TextDati", SN_NOWARN) set_name(0x8007F1BC, "SetUVTpGT4__7TextDatP9FRAME_HDRP8POLY_GT4ii", SN_NOWARN) set_name(0x8007F2B8, "PrepareGt4__7TextDatP8POLY_GT4iiiii", SN_NOWARN) set_name(0x8007F514, "SetUVTpGT3__7TextDatP9FRAME_HDRP8POLY_GT3", SN_NOWARN) set_name(0x8007F594, "PrepareGt3__7TextDatP8POLY_GT3iii", SN_NOWARN) set_name(0x8007F758, "PrintFt4__7TextDatiiiiii", SN_NOWARN) set_name(0x8007F8AC, "PrintGt4__7TextDatiiiiii", SN_NOWARN) set_name(0x8007FA00, "PrintGt3__7TextDatiiii", SN_NOWARN) set_name(0x8007FAE4, "DecompFrame__7TextDatP9FRAME_HDR", SN_NOWARN) set_name(0x8007FC38, "MakeCreatureOffsetTab__7TextDat", SN_NOWARN) set_name(0x8007FD78, "MakePalOffsetTab__7TextDat", SN_NOWARN) set_name(0x8007FE74, "InitData__7TextDat", SN_NOWARN) set_name(0x8007FEA0, "DumpData__7TextDat", SN_NOWARN) set_name(0x8007FFE8, "GM_UseTexData__Fi", SN_NOWARN) set_name(0x80080108, "GM_FinishedUsing__FP7TextDat", SN_NOWARN) set_name(0x8008015C, "SetPal__7TextDatP9FRAME_HDRP8POLY_FT4", SN_NOWARN) set_name(0x80080224, "GetFrNum__7TextDatiiii", SN_NOWARN) set_name(0x80080278, "IsDirAliased__7TextDatiii", SN_NOWARN) set_name(0x800802D0, "DoDecompRequests__7TextDat", SN_NOWARN) set_name(0x800803F4, "FindDecompArea__7TextDatR4RECT", SN_NOWARN) set_name(0x800804C8, "GetFileInfo__7TextDati", SN_NOWARN) set_name(0x80080518, "GetSize__C15CCreatureAction", SN_NOWARN) set_name(0x80080540, "GetFrNum__C15CCreatureActionii", SN_NOWARN) set_name(0x800805E8, "InitDirRemap__15CCreatureAction", SN_NOWARN) set_name(0x800806A8, "GetFrNum__C12CCreatureHdriii", SN_NOWARN) set_name(0x800806EC, "GetAction__C12CCreatureHdri", SN_NOWARN) set_name(0x8008077C, "InitActionDirRemaps__12CCreatureHdr", SN_NOWARN) set_name(0x800807EC, "GetSize__C12CCreatureHdr", SN_NOWARN) set_name(0x80080858, "LoadDat__C13CTextFileInfo", SN_NOWARN) set_name(0x800808A8, "LoadHdr__C13CTextFileInfo", SN_NOWARN) set_name(0x800808D0, "GetFile__C13CTextFileInfoPc", SN_NOWARN) set_name(0x8008096C, "HasFile__C13CTextFileInfoPc", SN_NOWARN) set_name(0x800809D4, "Un64__FPUcT0l", SN_NOWARN) set_name(0x80080AA8, "__7CScreen", SN_NOWARN) set_name(0x80080ADC, "Load__7CScreeniii", SN_NOWARN) set_name(0x80080D58, "Unload__7CScreen", SN_NOWARN) set_name(0x80080D7C, "Display__7CScreeniiii", SN_NOWARN) set_name(0x8008105C, "SetRect__5CPartR7TextDatR4RECT", SN_NOWARN) set_name(0x800810D4, "GetBoundingBox__6CBlockR7TextDatR4RECT", SN_NOWARN) set_name(0x80081230, "_GLOBAL__D_DatPool", SN_NOWARN) set_name(0x80081288, "_GLOBAL__I_DatPool", SN_NOWARN) set_name(0x800812DC, "PRIM_GetPrim__FPP8POLY_GT3", SN_NOWARN) set_name(0x80081358, "PRIM_GetPrim__FPP8POLY_GT4", SN_NOWARN) set_name(0x800813D4, "PRIM_GetPrim__FPP8POLY_FT4", SN_NOWARN) set_name(0x80081450, "CanXferFrame__C7TextDat", SN_NOWARN) set_name(0x80081478, "CanXferPal__C7TextDat", SN_NOWARN) set_name(0x800814A0, "IsLoaded__C7TextDat", SN_NOWARN) set_name(0x800814AC, "GetTexNum__C7TextDat", SN_NOWARN) set_name(0x800814B8, "GetCreature__7TextDati", SN_NOWARN) set_name(0x80081530, "GetNumOfCreatures__7TextDat", SN_NOWARN) set_name(0x80081544, "SetFileInfo__7TextDatPC13CTextFileInfoi", SN_NOWARN) set_name(0x80081550, "GetNumOfFrames__7TextDat", SN_NOWARN) set_name(0x80081564, "GetPal__7TextDati", SN_NOWARN) set_name(0x80081580, "GetFr__7TextDati", SN_NOWARN) set_name(0x8008159C, "GetName__C13CTextFileInfo", SN_NOWARN) set_name(0x800815A8, "HasDat__C13CTextFileInfo", SN_NOWARN) set_name(0x800815D0, "HasTp__C13CTextFileInfo", SN_NOWARN) set_name(0x800815F8, "GetSize__C6CBlock", SN_NOWARN) set_name(0x8008160C, "__4CdIOUl", SN_NOWARN) set_name(0x80081650, "___4CdIO", SN_NOWARN) set_name(0x800816A8, "FileExists__4CdIOPCc", SN_NOWARN) set_name(0x800816CC, "LoReadFileAtAddr__4CdIOPCcPUci", SN_NOWARN) set_name(0x800816F4, "GetFileLength__4CdIOPCc", SN_NOWARN) set_name(0x80081718, "LoSave__4CdIOPCcPUci", SN_NOWARN) set_name(0x800817F8, "LoStreamCallBack__Fi", SN_NOWARN) set_name(0x80081808, "CD_GetCdlFILE__FPCcP7CdlFILE", SN_NOWARN) set_name(0x80081954, "LoStreamFile__4CdIOPCciPFPUciib_bii", SN_NOWARN) set_name(0x80081C0C, "LoAsyncStreamFile__4CdIOPCciPFPUciib_bii", SN_NOWARN) set_name(0x80081D48, "BL_InitEAC__Fv", SN_NOWARN) set_name(0x80081E34, "BL_ReadFile__FPcUl", SN_NOWARN) set_name(0x80081F60, "BL_AsyncReadFile__FPcUl", SN_NOWARN) set_name(0x800820D4, "BL_LoadDirectory__Fv", SN_NOWARN) set_name(0x80082240, "BL_LoadStreamDir__Fv", SN_NOWARN) set_name(0x80082520, "BL_MakeFilePosTab__FPUcUl", SN_NOWARN) set_name(0x80082620, "BL_FindStreamFile__FPcc", SN_NOWARN) set_name(0x800827BC, "BL_FileExists__FPcc", SN_NOWARN) set_name(0x800827E0, "BL_FileLength__FPcc", SN_NOWARN) set_name(0x80082814, "BL_LoadFileAtAddr__FPcPUcc", SN_NOWARN) set_name(0x800828FC, "BL_AsyncLoadDone__Fv", SN_NOWARN) set_name(0x80082908, "BL_AsyncLoadTASK__FP4TASK", SN_NOWARN) set_name(0x80082974, "BL_LoadFileAsync__FPcc", SN_NOWARN) set_name(0x80082B18, "BL_AsyncLoadFileAtAddr__FPcPUcc", SN_NOWARN) set_name(0x80082BE0, "BL_OpenStreamFile__FPcc", SN_NOWARN) set_name(0x80082C0C, "BL_CloseStreamFile__FP6STRHDR", SN_NOWARN) set_name(0x80082C44, "LZNP_Decode__FPUcT0", SN_NOWARN) set_name(0x80082D18, "Tmalloc__Fi", SN_NOWARN) set_name(0x80082E3C, "Tfree__FPv", SN_NOWARN) set_name(0x80082EEC, "InitTmalloc__Fv", SN_NOWARN) set_name(0x80082F14, "strupr__FPc", SN_NOWARN) set_name(0x80082F68, "PauseTask__FP4TASK", SN_NOWARN) set_name(0x80082FB4, "GetPausePad__Fv", SN_NOWARN) set_name(0x800830A0, "TryPadForPause__Fi", SN_NOWARN) set_name(0x800830CC, "DoPause__14CPauseMessagesi", SN_NOWARN) set_name(0x80083338, "DoPausedMessage__14CPauseMessages", SN_NOWARN) set_name(0x80083618, "DoQuitMessage__14CPauseMessages", SN_NOWARN) set_name(0x80083738, "AreYouSureMessage__14CPauseMessages", SN_NOWARN) set_name(0x8008383C, "PA_SetPauseOk__Fb", SN_NOWARN) set_name(0x8008384C, "PA_GetPauseOk__Fv", SN_NOWARN) set_name(0x80083858, "MY_PausePrint__17CTempPauseMessageiPci", SN_NOWARN) set_name(0x800839A4, "InitPrintQuitMessage__17CTempPauseMessage", SN_NOWARN) set_name(0x800839AC, "PrintQuitMessage__17CTempPauseMessagei", SN_NOWARN) set_name(0x80083AAC, "LeavePrintQuitMessage__17CTempPauseMessagei", SN_NOWARN) set_name(0x80083AB4, "InitPrintAreYouSure__17CTempPauseMessage", SN_NOWARN) set_name(0x80083ABC, "PrintAreYouSure__17CTempPauseMessagei", SN_NOWARN) set_name(0x80083BBC, "LeavePrintAreYouSure__17CTempPauseMessagei", SN_NOWARN) set_name(0x80083BC4, "InitPrintPaused__17CTempPauseMessage", SN_NOWARN) set_name(0x80083BCC, "PrintPaused__17CTempPauseMessage", SN_NOWARN) set_name(0x80083CF8, "LeavePrintPaused__17CTempPauseMessage", SN_NOWARN) set_name(0x80083D00, "___17CTempPauseMessage", SN_NOWARN) set_name(0x80083D28, "_GLOBAL__D_DoPause__14CPauseMessagesi", SN_NOWARN) set_name(0x80083D50, "_GLOBAL__I_DoPause__14CPauseMessagesi", SN_NOWARN) set_name(0x80083D78, "__17CTempPauseMessage", SN_NOWARN) set_name(0x80083DBC, "___14CPauseMessages", SN_NOWARN) set_name(0x80083DF0, "__14CPauseMessages", SN_NOWARN) set_name(0x80083E04, "SetRGB__6DialogUcUcUc", SN_NOWARN) set_name(0x80083E24, "SetBack__6Dialogi", SN_NOWARN) set_name(0x80083E2C, "SetBorder__6Dialogi", SN_NOWARN) set_name(0x80083E34, "___6Dialog", SN_NOWARN) set_name(0x80083E5C, "__6Dialog", SN_NOWARN) set_name(0x80083EB8, "GetDown__C4CPad", SN_NOWARN) set_name(0x80083EE0, "GetUp__C4CPad", SN_NOWARN) set_name(0x80083F08, "CheckActive__4CPad", SN_NOWARN) set_name(0x80083F14, "ReadPadStream__Fv", SN_NOWARN) set_name(0x8008402C, "PAD_Handler__Fv", SN_NOWARN) set_name(0x800841E4, "PAD_GetPad__FiUc", SN_NOWARN) set_name(0x80084280, "NewVal__4CPadUs", SN_NOWARN) set_name(0x800843B8, "BothNewVal__4CPadUsUs", SN_NOWARN) set_name(0x80084514, "Trans__4CPadUs", SN_NOWARN) set_name(0x80084638, "_GLOBAL__I_Pad0", SN_NOWARN) set_name(0x80084670, "SetPadType__4CPadUc", SN_NOWARN) set_name(0x80084678, "CheckActive__4CPad_addr_80084678", SN_NOWARN) set_name(0x80084684, "SetActive__4CPadUc", SN_NOWARN) set_name(0x8008468C, "SetBothFlag__4CPadUc", SN_NOWARN) set_name(0x80084694, "__4CPadi", SN_NOWARN) set_name(0x800846C8, "Flush__4CPad", SN_NOWARN) set_name(0x800846EC, "Set__7FontTab", SN_NOWARN) set_name(0x80084788, "InitPrinty__Fv", SN_NOWARN) set_name(0x80084810, "SetTextDat__5CFontP7TextDat", SN_NOWARN) set_name(0x80084818, "PrintChar__5CFontUsUscUcUcUc", SN_NOWARN) set_name(0x80084998, "Print__5CFontiiPc8TXT_JUSTP4RECTUcUcUc", SN_NOWARN) set_name(0x80084FB8, "GetStrWidth__5CFontPc", SN_NOWARN) set_name(0x8008506C, "SetChar__5CFontiUs", SN_NOWARN) set_name(0x800850D0, "SetOTpos__5CFonti", SN_NOWARN) set_name(0x800850DC, "ClearFont__5CFont", SN_NOWARN) set_name(0x80085100, "IsDefined__5CFontUc", SN_NOWARN) set_name(0x80085120, "GetCharFrameNum__5CFontc", SN_NOWARN) set_name(0x80085138, "GetCharWidth__5CFontc", SN_NOWARN) set_name(0x80085190, "Init__5CFont", SN_NOWARN) set_name(0x800851C4, "GetFr__7TextDati_addr_800851C4", SN_NOWARN) set_name(0x800851E0, "TrimCol__Fs", SN_NOWARN) set_name(0x80085218, "DialogPrint__Fiiiiiiiiii", SN_NOWARN) set_name(0x80085B90, "GetDropShadowG4__FUcUcUcUcUcUcUcUcUcUcUcUc", SN_NOWARN) set_name(0x80085CC8, "DropShadows__Fiiii", SN_NOWARN) set_name(0x80085F6C, "InitDialog__Fv", SN_NOWARN) set_name(0x800860A4, "GetSizes__6Dialog", SN_NOWARN) set_name(0x800862FC, "Back__6Dialogiiii", SN_NOWARN) set_name(0x800874BC, "Line__6Dialogiii", SN_NOWARN) set_name(0x800876D4, "GetPal__7TextDati_addr_800876D4", SN_NOWARN) set_name(0x800876F0, "GetFr__7TextDati_addr_800876F0", SN_NOWARN) set_name(0x8008770C, "ATT_DoAttract__Fv", SN_NOWARN) set_name(0x8008785C, "CreatePlayersFromFeData__FR9FE_CREATE", SN_NOWARN) set_name(0x800878F8, "UpdateSel__FPUsUsPUc", SN_NOWARN) set_name(0x80087938, "CycleSelCols__Fv", SN_NOWARN) set_name(0x80087AF0, "FindTownCreature__7CBlocksi", SN_NOWARN) set_name(0x80087B64, "FindCreature__7CBlocksi", SN_NOWARN) set_name(0x80087BB8, "__7CBlocksiiiii", SN_NOWARN) set_name(0x80087D0C, "SetTownersGraphics__7CBlocks", SN_NOWARN) set_name(0x80087D44, "SetMonsterGraphics__7CBlocksii", SN_NOWARN) set_name(0x80087E0C, "___7CBlocks", SN_NOWARN) set_name(0x80087E94, "DumpGt4s__7CBlocks", SN_NOWARN) set_name(0x80087EFC, "DumpRects__7CBlocks", SN_NOWARN) set_name(0x80087F64, "SetGraphics__7CBlocksPP7TextDatPii", SN_NOWARN) set_name(0x80087FC0, "DumpGraphics__7CBlocksPP7TextDatPi", SN_NOWARN) set_name(0x80088010, "PrintBlockOutline__7CBlocksiiiii", SN_NOWARN) set_name(0x8008835C, "Load__7CBlocksi", SN_NOWARN) set_name(0x80088408, "MakeRectTable__7CBlocks", SN_NOWARN) set_name(0x800884DC, "MakeGt4Table__7CBlocks", SN_NOWARN) set_name(0x800885E4, "MakeGt4__7CBlocksP8POLY_GT4P9FRAME_HDR", SN_NOWARN) set_name(0x80088720, "GetBlock__7CBlocksi", SN_NOWARN) set_name(0x80088798, "Print__7CBlocks", SN_NOWARN) set_name(0x800887C0, "SetXY__7CBlocksii", SN_NOWARN) set_name(0x800887E8, "GetXY__7CBlocksPiT1", SN_NOWARN) set_name(0x80088800, "PrintMap__7CBlocksii", SN_NOWARN) set_name(0x80089D24, "PrintGameSprites__7CBlocksiiiii", SN_NOWARN) set_name(0x80089E94, "PrintGameSprites__7CBlocksP8map_infoiiiiiii", SN_NOWARN) set_name(0x8008AC0C, "PrintSprites__7CBlocksP8map_infoiiiiiii", SN_NOWARN) set_name(0x8008B2D0, "PrintSprites__7CBlocksiiiii", SN_NOWARN) set_name(0x8008B440, "ScrToWorldX__7CBlocksii", SN_NOWARN) set_name(0x8008B454, "ScrToWorldY__7CBlocksii", SN_NOWARN) set_name(0x8008B468, "SetScrollTarget__7CBlocksii", SN_NOWARN) set_name(0x8008B52C, "DoScroll__7CBlocks", SN_NOWARN) set_name(0x8008B594, "SetPlayerPosBlocks__7CBlocksiii", SN_NOWARN) set_name(0x8008B634, "GetScrXY__7CBlocksR4RECTiiii", SN_NOWARN) set_name(0x8008B708, "ShadScaleSkew__7CBlocksP8POLY_FT4", SN_NOWARN) set_name(0x8008B788, "WorldToScrX__7CBlocksii", SN_NOWARN) set_name(0x8008B790, "WorldToScrY__7CBlocksii", SN_NOWARN) set_name(0x8008B7A4, "BL_GetCurrentBlocks__Fv", SN_NOWARN) set_name(0x8008B7B0, "PRIM_GetPrim__FPP8POLY_FT4_addr_8008B7B0", SN_NOWARN) set_name(0x8008B82C, "GetHighlightCol__FiPiUsUsUs", SN_NOWARN) set_name(0x8008B874, "PRIM_GetCopy__FP8POLY_FT4", SN_NOWARN) set_name(0x8008B8B0, "GetHighlightCol__FiPcUsUsUs", SN_NOWARN) set_name(0x8008B8F8, "PRIM_GetPrim__FPP8POLY_GT4_addr_8008B8F8", SN_NOWARN) set_name(0x8008B974, "PRIM_GetPrim__FPP7LINE_F2", SN_NOWARN) set_name(0x8008B9F0, "PRIM_CopyPrim__FP8POLY_FT4T0", SN_NOWARN) set_name(0x8008BA18, "GetCreature__14TownToCreaturei", SN_NOWARN) set_name(0x8008BA34, "SetItemGraphics__7CBlocksi", SN_NOWARN) set_name(0x8008BA5C, "SetObjGraphics__7CBlocksi", SN_NOWARN) set_name(0x8008BA84, "DumpItems__7CBlocks", SN_NOWARN) set_name(0x8008BAA8, "DumpObjs__7CBlocks", SN_NOWARN) set_name(0x8008BACC, "DumpMonsters__7CBlocks", SN_NOWARN) set_name(0x8008BAF4, "GetNumOfBlocks__7CBlocks", SN_NOWARN) set_name(0x8008BB00, "CopyToGt4__9LittleGt4P8POLY_GT4", SN_NOWARN) set_name(0x8008BB98, "InitFromGt4__9LittleGt4P8POLY_GT4ii", SN_NOWARN) set_name(0x8008BC28, "GetNumOfFrames__7TextDatii", SN_NOWARN) set_name(0x8008BC60, "GetCreature__7TextDati_addr_8008BC60", SN_NOWARN) set_name(0x8008BCD8, "GetNumOfCreatures__7TextDat_addr_8008BCD8", SN_NOWARN) set_name(0x8008BCEC, "SetFileInfo__7TextDatPC13CTextFileInfoi_addr_8008BCEC", SN_NOWARN) set_name(0x8008BCF8, "GetPal__7TextDati_addr_8008BCF8", SN_NOWARN) set_name(0x8008BD14, "GetFr__7TextDati_addr_8008BD14", SN_NOWARN) set_name(0x8008BD30, "OVR_IsMemcardOverlayBlank__Fv", SN_NOWARN) set_name(0x8008BD5C, "OVR_LoadPregame__Fv", SN_NOWARN) set_name(0x8008BD84, "OVR_LoadFrontend__Fv", SN_NOWARN) set_name(0x8008BDAC, "OVR_LoadGame__Fv", SN_NOWARN) set_name(0x8008BDD4, "OVR_LoadFmv__Fv", SN_NOWARN) set_name(0x8008BDFC, "OVR_LoadMemcard__Fv", SN_NOWARN) set_name(0x8008BE28, "ClearOutOverlays__Fv", SN_NOWARN) set_name(0x8008BE80, "ClearOut__7Overlay", SN_NOWARN) set_name(0x8008BF44, "Load__7Overlay", SN_NOWARN) set_name(0x8008BFB4, "OVR_GetCurrentOverlay__Fv", SN_NOWARN) set_name(0x8008BFC0, "LoadOver__FR7Overlay", SN_NOWARN) set_name(0x8008C014, "_GLOBAL__I_OVR_Open__Fv", SN_NOWARN) set_name(0x8008C184, "GetOverType__7Overlay", SN_NOWARN) set_name(0x8008C190, "StevesDummyPoll__Fv", SN_NOWARN) set_name(0x8008C198, "Lambo__Fv", SN_NOWARN) set_name(0x8008C1A0, "__7CPlayerbi", SN_NOWARN) set_name(0x8008C284, "___7CPlayer", SN_NOWARN) set_name(0x8008C2DC, "Load__7CPlayeri", SN_NOWARN) set_name(0x8008C338, "SetBlockXY__7CPlayerR7CBlocksR12PlayerStruct", SN_NOWARN) set_name(0x8008C484, "SetScrollTarget__7CPlayerR12PlayerStructR7CBlocks", SN_NOWARN) set_name(0x8008C8B0, "GetNumOfSpellAnims__FR12PlayerStruct", SN_NOWARN) set_name(0x8008C930, "Print__7CPlayerR12PlayerStructR7CBlocks", SN_NOWARN) set_name(0x8008CE24, "FindAction__7CPlayerR12PlayerStruct", SN_NOWARN) set_name(0x8008CEA0, "FindActionEnum__7CPlayerR12PlayerStruct", SN_NOWARN) set_name(0x8008CF1C, "Init__7CPlayer", SN_NOWARN) set_name(0x8008CF24, "Dump__7CPlayer", SN_NOWARN) set_name(0x8008CF2C, "PRIM_GetPrim__FPP8POLY_FT4_addr_8008CF2C", SN_NOWARN) set_name(0x8008CFA8, "PRIM_GetCopy__FP8POLY_FT4_addr_8008CFA8", SN_NOWARN) set_name(0x8008CFE4, "PRIM_CopyPrim__FP8POLY_FT4T0_addr_8008CFE4", SN_NOWARN) set_name(0x8008D00C, "GetPlrOt__7CBlocksi", SN_NOWARN) set_name(0x8008D020, "SetDecompArea__7TextDatiiii", SN_NOWARN) set_name(0x8008D038, "GetNumOfFrames__7TextDatii_addr_8008D038", SN_NOWARN) set_name(0x8008D070, "GetNumOfActions__7TextDati", SN_NOWARN) set_name(0x8008D094, "GetCreature__7TextDati_addr_8008D094", SN_NOWARN) set_name(0x8008D10C, "GetNumOfCreatures__7TextDat_addr_8008D10C", SN_NOWARN) set_name(0x8008D120, "SetFileInfo__7TextDatPC13CTextFileInfoi_addr_8008D120", SN_NOWARN) set_name(0x8008D12C, "PROF_Open__Fv", SN_NOWARN) set_name(0x8008D16C, "PROF_State__Fv", SN_NOWARN) set_name(0x8008D178, "PROF_On__Fv", SN_NOWARN) set_name(0x8008D188, "PROF_Off__Fv", SN_NOWARN) set_name(0x8008D194, "PROF_CpuEnd__Fv", SN_NOWARN) set_name(0x8008D1C4, "PROF_CpuStart__Fv", SN_NOWARN) set_name(0x8008D1E8, "PROF_DrawStart__Fv", SN_NOWARN) set_name(0x8008D20C, "PROF_DrawEnd__Fv", SN_NOWARN) set_name(0x8008D23C, "PROF_Draw__FPUl", SN_NOWARN) set_name(0x8008D430, "PROF_Restart__Fv", SN_NOWARN) set_name(0x8008D450, "PSX_WndProc__FUilUl", SN_NOWARN) set_name(0x8008D548, "PSX_PostWndProc__FUilUl", SN_NOWARN) set_name(0x8008D5F8, "GoBackLevel__Fv", SN_NOWARN) set_name(0x8008D670, "GoWarpLevel__Fv", SN_NOWARN) set_name(0x8008D6A8, "PostLoadGame__Fv", SN_NOWARN) set_name(0x8008D744, "GoLoadGame__Fv", SN_NOWARN) set_name(0x8008D7CC, "PostNewLevel__Fv", SN_NOWARN) set_name(0x8008D868, "GoNewLevel__Fv", SN_NOWARN) set_name(0x8008D8BC, "PostGoBackLevel__Fv", SN_NOWARN) set_name(0x8008D954, "GoForwardLevel__Fv", SN_NOWARN) set_name(0x8008D9AC, "PostGoForwardLevel__Fv", SN_NOWARN) set_name(0x8008DA44, "GoNewGame__Fv", SN_NOWARN) set_name(0x8008DA94, "PostNewGame__Fv", SN_NOWARN) set_name(0x8008DACC, "LevelToLevelInit__Fv", SN_NOWARN) set_name(0x8008DB24, "GetPal__6GPaneli", SN_NOWARN) set_name(0x8008DB68, "__6GPaneli", SN_NOWARN) set_name(0x8008DBC0, "DrawFlask__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008E040, "DrawSpeedBar__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008E4C4, "DrawSpell__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008E664, "DrawMsgWindow__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008E6B0, "DrawDurThingy__6GPaneliiP10ItemStructi", SN_NOWARN) set_name(0x8008EA6C, "DrawDurIcon__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008EB60, "Print__6GPanelP7PanelXYP12PlayerStruct", SN_NOWARN) set_name(0x8008EC64, "GetPal__7TextDati_addr_8008EC64", SN_NOWARN) set_name(0x8008EC80, "GetFr__7TextDati_addr_8008EC80", SN_NOWARN) set_name(0x8008EC9C, "PrintCDWaitTask__FP4TASK", SN_NOWARN) set_name(0x8008ED80, "InitCDWaitIcon__Fv", SN_NOWARN) set_name(0x8008EDB4, "STR_Debug__FP6SFXHDRPce", SN_NOWARN) set_name(0x8008EDC8, "STR_SystemTask__FP4TASK", SN_NOWARN) set_name(0x8008EE10, "STR_AllocBuffer__Fv", SN_NOWARN) set_name(0x8008EE64, "STR_Init__Fv", SN_NOWARN) set_name(0x8008EF30, "STR_InitStream__Fv", SN_NOWARN) set_name(0x8008F068, "STR_PlaySound__FUscic", SN_NOWARN) set_name(0x8008F1A4, "STR_setvolume__FP6SFXHDR", SN_NOWARN) set_name(0x8008F1FC, "STR_PlaySFX__FP6SFXHDR", SN_NOWARN) set_name(0x8008F308, "STR_pauseall__Fv", SN_NOWARN) set_name(0x8008F358, "STR_resumeall__Fv", SN_NOWARN) set_name(0x8008F3A8, "STR_CloseStream__FP6SFXHDR", SN_NOWARN) set_name(0x8008F414, "STR_SoundCommand__FP6SFXHDRi", SN_NOWARN) set_name(0x8008F520, "STR_Command__FP6SFXHDR", SN_NOWARN) set_name(0x8008F6CC, "STR_DMAControl__FP6SFXHDR", SN_NOWARN) set_name(0x8008F794, "STR_PlayStream__FP6SFXHDRPUci", SN_NOWARN) set_name(0x8008F970, "STR_AsyncWeeTASK__FP4TASK", SN_NOWARN) set_name(0x8008FC68, "STR_AsyncTASK__FP4TASK", SN_NOWARN) set_name(0x80090094, "STR_StreamMainTask__FP6SFXHDRc", SN_NOWARN) set_name(0x800901A4, "SPU_Init__Fv", SN_NOWARN) set_name(0x80090274, "SND_FindChannel__Fv", SN_NOWARN) set_name(0x800902E0, "SND_ClearBank__Fv", SN_NOWARN) set_name(0x80090358, "SndLoadCallBack__FPUciib", SN_NOWARN) set_name(0x800903D0, "SND_LoadBank__Fi", SN_NOWARN) set_name(0x80090504, "SND_FindSFX__FUs", SN_NOWARN) set_name(0x80090558, "SND_StopSnd__Fi", SN_NOWARN) set_name(0x8009057C, "SND_RemapSnd__Fi", SN_NOWARN) set_name(0x800905E0, "SND_PlaySnd__FUsiii", SN_NOWARN) set_name(0x80090794, "AS_CallBack0__Fi", SN_NOWARN) set_name(0x800907A8, "AS_CallBack1__Fi", SN_NOWARN) set_name(0x800907BC, "AS_WasLastBlock__FiP6STRHDRP6SFXHDR", SN_NOWARN) set_name(0x80090898, "AS_OpenStream__FP6STRHDRP6SFXHDR", SN_NOWARN) set_name(0x80090938, "AS_GetBlock__FP6SFXHDR", SN_NOWARN) set_name(0x80090944, "AS_CloseStream__FP6STRHDRP6SFXHDR", SN_NOWARN) set_name(0x80090970, "AS_LoopStream__FiP6STRHDRP6SFXHDR", SN_NOWARN) set_name(0x80090A90, "SCR_NeedHighlightPal__FUsUsi", SN_NOWARN) set_name(0x80090AC4, "Init__13PalCollectionPC7InitPos", SN_NOWARN) set_name(0x80090B54, "FindPal__13PalCollectionUsUsi", SN_NOWARN) set_name(0x80090C30, "NewPal__13PalCollectionUsUsi", SN_NOWARN) set_name(0x80090CB0, "MakePal__8PalEntryUsUsi", SN_NOWARN) set_name(0x80090D50, "GetHighlightPal__13PalCollectionUsUsi", SN_NOWARN) set_name(0x80090DE4, "UpdatePals__13PalCollection", SN_NOWARN) set_name(0x80090E58, "SCR_Handler__Fv", SN_NOWARN) set_name(0x80090E80, "GetNumOfObjs__t10Collection2Z8PalEntryi20", SN_NOWARN) set_name(0x80090E88, "GetObj__t10Collection2Z8PalEntryi20", SN_NOWARN) set_name(0x80090EC4, "Init__t10Collection2Z8PalEntryi20", SN_NOWARN) set_name(0x80090F28, "MoveFromUsedToUnused__t10Collection2Z8PalEntryi20P8PalEntry", SN_NOWARN) set_name(0x80090F80, "MoveFromUnusedToUsed__t10Collection2Z8PalEntryi20P8PalEntry", SN_NOWARN) set_name(0x80090FD8, "Set__8PalEntryUsUsi", SN_NOWARN) set_name(0x80090FEC, "Set__8PalEntryRC7InitPos", SN_NOWARN) set_name(0x80091018, "SetJustUsed__8PalEntryb", SN_NOWARN) set_name(0x80091020, "Init__8PalEntry", SN_NOWARN) set_name(0x80091028, "GetClut__C8PalEntry", SN_NOWARN) set_name(0x80091034, "IsEqual__C8PalEntryUsUsi", SN_NOWARN) set_name(0x8009106C, "GetNext__Ct11TLinkedList1Z8PalEntry", SN_NOWARN) set_name(0x80091078, "AddToList__t11TLinkedList1Z8PalEntryPP8PalEntry", SN_NOWARN) set_name(0x80091098, "DetachFromList__t11TLinkedList1Z8PalEntryPP8PalEntry", SN_NOWARN) set_name(0x800910E4, "stub__FPcPv_addr_800910E4", SN_NOWARN) set_name(0x800910EC, "new_eprint__FPcT0i", SN_NOWARN) set_name(0x80091120, "TonysGameTask__FP4TASK", SN_NOWARN) set_name(0x800911A8, "SetAmbientLight__Fv", SN_NOWARN) set_name(0x8009122C, "print_demo_task__FP4TASK", SN_NOWARN) set_name(0x80091430, "TonysDummyPoll__Fv", SN_NOWARN) set_name(0x80091454, "load_demo_pad_data__FUl", SN_NOWARN) set_name(0x800914B4, "save_demo_pad_data__FUl", SN_NOWARN) set_name(0x80091514, "set_pad_record_play__Fi", SN_NOWARN) set_name(0x80091588, "start_demo__Fv", SN_NOWARN) set_name(0x80091624, "tony__Fv", SN_NOWARN) set_name(0x8009165C, "GLUE_SetMonsterList__Fi", SN_NOWARN) set_name(0x80091668, "GLUE_GetMonsterList__Fv", SN_NOWARN) set_name(0x80091674, "GLUE_SuspendGame__Fv", SN_NOWARN) set_name(0x800916C8, "GLUE_ResumeGame__Fv", SN_NOWARN) set_name(0x8009171C, "GLUE_PreTown__Fv", SN_NOWARN) set_name(0x80091780, "GLUE_PreDun__Fv", SN_NOWARN) set_name(0x800917CC, "GLUE_Finished__Fv", SN_NOWARN) set_name(0x800917D8, "GLUE_SetFinished__Fb", SN_NOWARN) set_name(0x800917E4, "GLUE_StartBg__Fibi", SN_NOWARN) set_name(0x80091868, "GLUE_SetShowGameScreenFlag__Fb", SN_NOWARN) set_name(0x80091878, "GLUE_SetHomingScrollFlag__Fb", SN_NOWARN) set_name(0x80091888, "GLUE_SetShowPanelFlag__Fb", SN_NOWARN) set_name(0x80091898, "DoShowPanelGFX__FP6GPanelT0", SN_NOWARN) set_name(0x80091970, "BgTask__FP4TASK", SN_NOWARN) set_name(0x80091E34, "FindPlayerChar__FPc", SN_NOWARN) set_name(0x80091EBC, "FindPlayerChar__Fiii", SN_NOWARN) set_name(0x80091F18, "FindPlayerChar__FP12PlayerStruct", SN_NOWARN) set_name(0x80091F48, "FindPlayerChar__FP12PlayerStructb", SN_NOWARN) set_name(0x80091F88, "MakeSurePlayerDressedProperly__FR7CPlayerR12PlayerStructb", SN_NOWARN) set_name(0x80091FDC, "GLUE_GetCurrentList__Fi", SN_NOWARN) set_name(0x80092088, "GetTexId__7CPlayer", SN_NOWARN) set_name(0x80092094, "SetTown__7CBlocksb", SN_NOWARN) set_name(0x8009209C, "MoveToScrollTarget__7CBlocks", SN_NOWARN) set_name(0x800920B0, "SetDemoKeys__FPi", SN_NOWARN) set_name(0x80092188, "RestoreDemoKeys__FPi", SN_NOWARN) set_name(0x80092218, "get_action_str__Fii", SN_NOWARN) set_name(0x80092290, "get_key_pad__Fi", SN_NOWARN) set_name(0x800922C8, "RemoveCtrlScreen__Fv", SN_NOWARN) set_name(0x8009230C, "Init_ctrl_pos__Fv", SN_NOWARN) set_name(0x800923C4, "remove_padval__Fi", SN_NOWARN) set_name(0x80092404, "remove_comboval__Fi", SN_NOWARN) set_name(0x80092444, "set_buttons__Fii", SN_NOWARN) set_name(0x80092598, "restore_controller_settings__Fv", SN_NOWARN) set_name(0x800925E0, "main_ctrl_setup__Fv", SN_NOWARN) set_name(0x80092A78, "PrintCtrlString__FiiUcic", SN_NOWARN) set_name(0x80092FB4, "DrawCtrlSetup__Fv", SN_NOWARN) set_name(0x8009346C, "_GLOBAL__D_ctrlflag", SN_NOWARN) set_name(0x80093494, "_GLOBAL__I_ctrlflag", SN_NOWARN) set_name(0x800934BC, "GetTick__C4CPad", SN_NOWARN) set_name(0x800934E4, "GetDown__C4CPad_addr_800934E4", SN_NOWARN) set_name(0x8009350C, "GetUp__C4CPad_addr_8009350C", SN_NOWARN) set_name(0x80093534, "SetPadTickMask__4CPadUs", SN_NOWARN) set_name(0x8009353C, "SetPadTick__4CPadUs", SN_NOWARN) set_name(0x80093544, "SetRGB__6DialogUcUcUc_addr_80093544", SN_NOWARN) set_name(0x80093564, "SetBorder__6Dialogi_addr_80093564", SN_NOWARN) set_name(0x8009356C, "SetOTpos__6Dialogi", SN_NOWARN) set_name(0x80093578, "___6Dialog_addr_80093578", SN_NOWARN) set_name(0x800935A0, "__6Dialog_addr_800935A0", SN_NOWARN) set_name(0x800935FC, "switchnight__FP4TASK", SN_NOWARN) set_name(0x80093648, "city_lights__FP4TASK", SN_NOWARN) set_name(0x800937C8, "color_cycle__FP4TASK", SN_NOWARN) set_name(0x8009390C, "DrawFlameLogo__Fv", SN_NOWARN) set_name(0x80093B5C, "TitleScreen__FP7CScreen", SN_NOWARN) set_name(0x80093BB0, "TryCreaturePrint__Fiiiiiii", SN_NOWARN) set_name(0x80093E14, "TryWater__FiiP8POLY_GT4i", SN_NOWARN) set_name(0x80093FEC, "nightgfx__FibiP8POLY_GT4i", SN_NOWARN) set_name(0x80094078, "PRIM_GetCopy__FP8POLY_FT4_addr_80094078", SN_NOWARN) set_name(0x800940B4, "PRIM_CopyPrim__FP8POLY_FT4T0_addr_800940B4", SN_NOWARN) set_name(0x800940DC, "PRIM_GetPrim__FPP8POLY_FT4_addr_800940DC", SN_NOWARN) set_name(0x80094158, "GetNumOfActions__7TextDati_addr_80094158", SN_NOWARN) set_name(0x8009417C, "GetCreature__7TextDati_addr_8009417C", SN_NOWARN) set_name(0x800941F4, "GetNumOfCreatures__7TextDat_addr_800941F4", SN_NOWARN) set_name(0x80094208, "DaveLDummyPoll__Fv", SN_NOWARN) set_name(0x80094210, "DaveL__Fv", SN_NOWARN) set_name(0x80094238, "DoReflection__FP8POLY_FT4iii", SN_NOWARN) set_name(0x80094518, "mteleportfx__Fv", SN_NOWARN) set_name(0x800947F4, "invistimer__Fv", SN_NOWARN) set_name(0x800948C0, "setUVparams__FP8POLY_FT4P9FRAME_HDR", SN_NOWARN) set_name(0x80094948, "drawparticle__Fiiiiii", SN_NOWARN) set_name(0x80094B38, "drawpolyF4__Fiiiiii", SN_NOWARN) set_name(0x80094C6C, "drawpolyG4__Fiiiiiiii", SN_NOWARN) set_name(0x80094E3C, "particlejump__Fv", SN_NOWARN) set_name(0x80094FDC, "particleglow__Fv", SN_NOWARN) set_name(0x800950C0, "doparticlejump__Fv", SN_NOWARN) set_name(0x80095100, "StartPartJump__Fiiiiii", SN_NOWARN) set_name(0x80095268, "doparticlechain__Fiiiiiiiiiiii", SN_NOWARN) set_name(0x80095660, "ParticleMissile__FP13MissileStructiiii", SN_NOWARN) set_name(0x80095720, "Teleportfx__Fiiiiiii", SN_NOWARN) set_name(0x800959C8, "ResurrectFX__Fiiii", SN_NOWARN) set_name(0x80095BEC, "GetPlrPos__11SPELLFX_DATP12PlayerStruct", SN_NOWARN) set_name(0x80095D10, "healFX__Fv", SN_NOWARN) set_name(0x80095E28, "HealStart__Fi", SN_NOWARN) set_name(0x80095E5C, "HealotherStart__Fi", SN_NOWARN) set_name(0x80095E94, "TeleStart__Fi", SN_NOWARN) set_name(0x80095EF0, "PhaseStart__Fi", SN_NOWARN) set_name(0x80095F24, "InvisStart__Fi", SN_NOWARN) set_name(0x80095F58, "PhaseEnd__Fi", SN_NOWARN) set_name(0x80095F84, "ApocInit__11SPELLFX_DATP12PlayerStruct", SN_NOWARN) set_name(0x80096124, "ApocUpdate__11SPELLFX_DAT", SN_NOWARN) set_name(0x80096190, "ApocaStart__Fi", SN_NOWARN) set_name(0x800961E8, "doapocaFX__Fv", SN_NOWARN) set_name(0x80096300, "DaveLTask__FP4TASK", SN_NOWARN) set_name(0x80096364, "PRIM_GetPrim__FPP7POLY_G4", SN_NOWARN) set_name(0x800963E0, "PRIM_GetPrim__FPP7POLY_F4", SN_NOWARN) set_name(0x8009645C, "PRIM_GetPrim__FPP8POLY_FT4_addr_8009645C", SN_NOWARN) set_name(0x800964D8, "GetFr__7TextDati_addr_800964D8", SN_NOWARN) set_name(0x800964F4, "DrawArrow__Fii", SN_NOWARN) set_name(0x800966F8, "show_spell_dir__Fi", SN_NOWARN) set_name(0x80096B6C, "release_spell__Fi", SN_NOWARN) set_name(0x80096BE0, "select_belt_item__Fi", SN_NOWARN) set_name(0x80096BE8, "any_belt_items__Fv", SN_NOWARN) set_name(0x80096C50, "get_last_inv__Fv", SN_NOWARN) set_name(0x80096D80, "get_next_inv__Fv", SN_NOWARN) set_name(0x80096EB8, "pad_func_up__Fi", SN_NOWARN) set_name(0x80096EE4, "pad_func_down__Fi", SN_NOWARN) set_name(0x80096F10, "pad_func_left__Fi", SN_NOWARN) set_name(0x80096F18, "pad_func_right__Fi", SN_NOWARN) set_name(0x80096F20, "pad_func_select__Fi", SN_NOWARN) set_name(0x80096FDC, "pad_func_Attack__Fi", SN_NOWARN) set_name(0x800973F8, "pad_func_Action__Fi", SN_NOWARN) set_name(0x8009770C, "InitTargetCursor__Fi", SN_NOWARN) set_name(0x80097814, "RemoveTargetCursor__Fi", SN_NOWARN) set_name(0x800978A4, "pad_func_Cast_Spell__Fi", SN_NOWARN) set_name(0x80097E24, "pad_func_Use_Item__Fi", SN_NOWARN) set_name(0x80097EE4, "pad_func_Chr__Fi", SN_NOWARN) set_name(0x80097FEC, "pad_func_Inv__Fi", SN_NOWARN) set_name(0x800980D8, "pad_func_SplBook__Fi", SN_NOWARN) set_name(0x800981C4, "pad_func_QLog__Fi", SN_NOWARN) set_name(0x80098248, "pad_func_SpellBook__Fi", SN_NOWARN) set_name(0x800982E0, "pad_func_AutoMap__Fi", SN_NOWARN) set_name(0x8009839C, "pad_func_Quick_Spell__Fi", SN_NOWARN) set_name(0x80098418, "check_inv__FiPci", SN_NOWARN) set_name(0x800985E0, "pad_func_Quick_Use_Health__Fi", SN_NOWARN) set_name(0x80098608, "pad_func_Quick_Use_Mana__Fi", SN_NOWARN) set_name(0x80098630, "get_max_find_size__FPici", SN_NOWARN) set_name(0x80098770, "sort_gold__Fi", SN_NOWARN) set_name(0x8009887C, "DrawObjSelector__Fi", SN_NOWARN) set_name(0x80099140, "DrawObjTask__FP4TASK", SN_NOWARN) set_name(0x8009921C, "add_area_find_object__Fciii", SN_NOWARN) set_name(0x80099328, "CheckRangeObject__Fiici", SN_NOWARN) set_name(0x800996E8, "CheckArea__FiiicUci", SN_NOWARN) set_name(0x8009993C, "PlacePlayer__FiiiUc", SN_NOWARN) set_name(0x80099B60, "_GLOBAL__D_gplayer", SN_NOWARN) set_name(0x80099B88, "_GLOBAL__I_gplayer", SN_NOWARN) set_name(0x80099BB0, "SetRGB__6DialogUcUcUc_addr_80099BB0", SN_NOWARN) set_name(0x80099BD0, "SetBack__6Dialogi_addr_80099BD0", SN_NOWARN) set_name(0x80099BD8, "SetBorder__6Dialogi_addr_80099BD8", SN_NOWARN) set_name(0x80099BE0, "___6Dialog_addr_80099BE0", SN_NOWARN) set_name(0x80099C08, "__6Dialog_addr_80099C08", SN_NOWARN) set_name(0x80099C64, "MoveToScrollTarget__7CBlocks_addr_80099C64", SN_NOWARN) set_name(0x80099C78, "GetDown__C4CPad_addr_80099C78", SN_NOWARN) set_name(0x80099CA0, "GetCur__C4CPad_addr_80099CA0", SN_NOWARN) set_name(0x80099CC8, "DEC_AddAsDecRequestor__FP7TextDat", SN_NOWARN) set_name(0x80099D44, "DEC_RemoveAsDecRequestor__FP7TextDat", SN_NOWARN) set_name(0x80099D9C, "DEC_DoDecompRequests__Fv", SN_NOWARN) set_name(0x80099DF8, "FindThisTd__FP7TextDat", SN_NOWARN) set_name(0x80099E30, "FindEmptyIndex__Fv", SN_NOWARN) set_name(0x80099E68, "UPDATEPROGRESS__Fi", SN_NOWARN) set_name(0x80099EC8, "IsGameLoading__Fv", SN_NOWARN) set_name(0x80099ED4, "PutUpCutScreenTSK__FP4TASK", SN_NOWARN) set_name(0x8009A33C, "PutUpCutScreen__Fi", SN_NOWARN) set_name(0x8009A3EC, "TakeDownCutScreen__Fv", SN_NOWARN) set_name(0x8009A478, "FinishProgress__Fv", SN_NOWARN) set_name(0x8009A4C8, "PRIM_GetPrim__FPP7POLY_G4_addr_8009A4C8", SN_NOWARN) set_name(0x8009A544, "_GLOBAL__D_UPDATEPROGRESS__Fi", SN_NOWARN) set_name(0x8009A57C, "_GLOBAL__I_UPDATEPROGRESS__Fi", SN_NOWARN) set_name(0x8009A5B4, "SetRGB__6DialogUcUcUc_addr_8009A5B4", SN_NOWARN) set_name(0x8009A5D4, "SetBack__6Dialogi_addr_8009A5D4", SN_NOWARN) set_name(0x8009A5DC, "SetBorder__6Dialogi_addr_8009A5DC", SN_NOWARN) set_name(0x8009A5E4, "___6Dialog_addr_8009A5E4", SN_NOWARN) set_name(0x8009A60C, "__6Dialog_addr_8009A60C", SN_NOWARN) set_name(0x8009A668, "___7CScreen", SN_NOWARN) set_name(0x8009A688, "init_mem_card__FPFii_v", SN_NOWARN) set_name(0x8009A8A4, "memcard_event__Fii", SN_NOWARN) set_name(0x8009A8AC, "init_card__Fi", SN_NOWARN) set_name(0x8009A8E0, "ping_card__Fi", SN_NOWARN) set_name(0x8009A974, "CardUpdateTask__FP4TASK", SN_NOWARN) set_name(0x8009A9AC, "MemcardON__Fv", SN_NOWARN) set_name(0x8009AA1C, "MemcardOFF__Fv", SN_NOWARN) set_name(0x8009AA6C, "PrintSelectBack__FbT0", SN_NOWARN) set_name(0x8009ABC0, "DrawDialogBox__FiiP4RECTiiii", SN_NOWARN) set_name(0x8009ACA4, "DrawSpinner__FiiUcUcUciiibiT8", SN_NOWARN) set_name(0x8009B16C, "DrawMenu__Fi", SN_NOWARN) set_name(0x8009BC48, "who_pressed__Fi", SN_NOWARN) set_name(0x8009BCD0, "PAD_GetOptionsPad__Fi", SN_NOWARN) set_name(0x8009BD0C, "ShowCharacterFiles__Fv", SN_NOWARN) set_name(0x8009C388, "MemcardPad__Fv", SN_NOWARN) set_name(0x8009C994, "SoundPad__Fv", SN_NOWARN) set_name(0x8009D004, "CentrePad__Fv", SN_NOWARN) set_name(0x8009D428, "CalcVolumes__Fv", SN_NOWARN) set_name(0x8009D568, "GetVolumes__Fv", SN_NOWARN) set_name(0x8009D670, "PrintInfoMenu__Fv", SN_NOWARN) set_name(0x8009D818, "DrawOptions__FP4TASK", SN_NOWARN) set_name(0x8009DF60, "ToggleOptions__Fv", SN_NOWARN) set_name(0x8009E008, "FormatPad__Fv", SN_NOWARN) set_name(0x8009E314, "ActivateMemcard__Fv", SN_NOWARN) set_name(0x8009E398, "ShowGameFiles__FPc", SN_NOWARN) set_name(0x8009E4E4, "PRIM_GetPrim__FPP7POLY_G4_addr_8009E4E4", SN_NOWARN) set_name(0x8009E560, "GetTick__C4CPad_addr_8009E560", SN_NOWARN) set_name(0x8009E588, "GetDown__C4CPad_addr_8009E588", SN_NOWARN) set_name(0x8009E5B0, "GetUp__C4CPad_addr_8009E5B0", SN_NOWARN) set_name(0x8009E5D8, "SetPadTickMask__4CPadUs_addr_8009E5D8", SN_NOWARN) set_name(0x8009E5E0, "SetPadTick__4CPadUs_addr_8009E5E0", SN_NOWARN) set_name(0x8009E5E8, "SetRGB__6DialogUcUcUc_addr_8009E5E8", SN_NOWARN) set_name(0x8009E608, "SetBack__6Dialogi_addr_8009E608", SN_NOWARN) set_name(0x8009E610, "SetBorder__6Dialogi_addr_8009E610", SN_NOWARN) set_name(0x8009E618, "SetOTpos__6Dialogi_addr_8009E618", SN_NOWARN) set_name(0x8009E624, "___6Dialog_addr_8009E624", SN_NOWARN) set_name(0x8009E64C, "__6Dialog_addr_8009E64C", SN_NOWARN) set_name(0x8009E6A8, "GetFr__7TextDati_addr_8009E6A8", SN_NOWARN) set_name(0x8009E6C4, "BirdDistanceOK__Fiiii", SN_NOWARN) set_name(0x8009E71C, "AlterBirdPos__FP10BIRDSTRUCTUc", SN_NOWARN) set_name(0x8009E8F8, "BirdWorld__FP10BIRDSTRUCTii", SN_NOWARN) set_name(0x8009E974, "BirdScared__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EB00, "GetPerch__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EB54, "BIRD_StartHop__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009ECBC, "BIRD_DoHop__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EDC0, "BIRD_StartPerch__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EE2C, "BIRD_DoPerch__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EEB0, "BIRD_DoScatter__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009EF5C, "BIRD_StartScatter__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F000, "BIRD_StartFly__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F0A4, "BIRD_DoFly__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F350, "BIRD_StartLanding__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F3A8, "BIRD_DoLanding__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F3F8, "PlaceFlock__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F4E4, "ProcessFlock__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F614, "InitBird__Fv", SN_NOWARN) set_name(0x8009F6EC, "ProcessBird__Fv", SN_NOWARN) set_name(0x8009F844, "GetBirdFrame__FP10BIRDSTRUCT", SN_NOWARN) set_name(0x8009F8E0, "bscale__FP8POLY_FT4i", SN_NOWARN) set_name(0x8009FA10, "doshadow__FP10BIRDSTRUCTii", SN_NOWARN) set_name(0x8009FB1C, "DrawLBird__Fv", SN_NOWARN) set_name(0x8009FD28, "PRIM_GetPrim__FPP8POLY_FT4_addr_8009FD28", SN_NOWARN) set_name(0x8009FDA4, "PlayFMV__FPcii", SN_NOWARN) set_name(0x8009FE64, "play_movie", SN_NOWARN) set_name(0x8009FF20, "DisplayMonsterTypes__Fv", SN_NOWARN) set_name(0x800A03BC, "GetDown__C4CPad_addr_800A03BC", SN_NOWARN) set_name(0x800A03E4, "GetNumOfFrames__7TextDatii_addr_800A03E4", SN_NOWARN) set_name(0x800A041C, "GetCreature__7TextDati_addr_800A041C", SN_NOWARN) set_name(0x800A0494, "GetNumOfCreatures__7TextDat_addr_800A0494", SN_NOWARN) set_name(0x800A04A8, "GetFr__7TextDati_addr_800A04A8", SN_NOWARN) set_name(0x800A04C4, "LoadKanjiFont__FPc", SN_NOWARN) set_name(0x800A0558, "LoadKanjiIndex__FPc", SN_NOWARN) set_name(0x800A060C, "FreeKanji__Fv", SN_NOWARN) set_name(0x800A0694, "LoadKanji__F10LANG_DB_NO", SN_NOWARN) set_name(0x800A0768, "getb__FUs", SN_NOWARN) set_name(0x800A07D8, "_get_font__FPUsUsUs", SN_NOWARN) set_name(0x800A08A8, "KPrintChar__FUsUsUcUcUs", SN_NOWARN) set_name(0x800A0A1C, "PRIM_GetPrim__FPP8POLY_FT4_addr_800A0A1C", SN_NOWARN) set_name(0x800A0A98, "writeblock__FP5block", SN_NOWARN) set_name(0x800A0B80, "PAK_DoPak__FPUcT0i", SN_NOWARN) set_name(0x800A0DC0, "PAK_DoUnpak__FPUcT0", SN_NOWARN) set_name(0x800A0E60, "fputc__5blockUc", SN_NOWARN) set_name(0x8002E8A0, "TrimCol__Fs_addr_8002E8A0", SN_NOWARN) set_name(0x8002E8D8, "DrawSpellCel__FllUclUc", SN_NOWARN) set_name(0x8002F3F4, "SetSpellTrans__Fc", SN_NOWARN) set_name(0x8002F400, "DrawSpellBookTSK__FP4TASK", SN_NOWARN) set_name(0x8002F498, "DrawSpeedSpellTSK__FP4TASK", SN_NOWARN) set_name(0x8002F510, "ToggleSpell__Fi", SN_NOWARN) set_name(0x8002F5C4, "DrawSpellList__Fv", SN_NOWARN) set_name(0x8003014C, "SetSpell__Fi", SN_NOWARN) set_name(0x80030220, "AddPanelString__FPCci", SN_NOWARN) set_name(0x800302D0, "ClearPanel__Fv", SN_NOWARN) set_name(0x80030300, "InitPanelStr__Fv", SN_NOWARN) set_name(0x80030320, "InitControlPan__Fv", SN_NOWARN) set_name(0x80030584, "DrawCtrlPan__Fv", SN_NOWARN) set_name(0x800305B0, "DoAutoMap__Fv", SN_NOWARN) set_name(0x80030624, "CheckPanelInfo__Fv", SN_NOWARN) set_name(0x80030EE8, "FreeControlPan__Fv", SN_NOWARN) set_name(0x80030FF8, "CPrintString__FiPci", SN_NOWARN) set_name(0x80031114, "PrintInfo__Fv", SN_NOWARN) set_name(0x80031350, "DrawInfoBox__FP4RECT", SN_NOWARN) set_name(0x80031A04, "MY_PlrStringXY__Fv", SN_NOWARN) set_name(0x80031F50, "ADD_PlrStringXY__FPCcc", SN_NOWARN) set_name(0x80031FF8, "DrawPlus__Fii", SN_NOWARN) set_name(0x80032160, "ChrCheckValidButton__Fi", SN_NOWARN) set_name(0x8003223C, "DrawArrows__Fv", SN_NOWARN) set_name(0x80032334, "BuildChr__Fv", SN_NOWARN) set_name(0x8003360C, "DrawChr__Fv", SN_NOWARN) set_name(0x80033A64, "DrawChrTSK__FP4TASK", SN_NOWARN) set_name(0x80033B48, "DrawLevelUpIcon__Fi", SN_NOWARN) set_name(0x80033BDC, "CheckChrBtns__Fv", SN_NOWARN) set_name(0x80033F48, "DrawDurIcon4Item__FPC10ItemStructii", SN_NOWARN) set_name(0x80033FCC, "RedBack__Fv", SN_NOWARN) set_name(0x800340B4, "PrintSBookStr__FiiUcPCcUc", SN_NOWARN) set_name(0x8003414C, "GetSBookTrans__FiUc", SN_NOWARN) set_name(0x80034364, "DrawSpellBook__Fv", SN_NOWARN) set_name(0x80034CF0, "CheckSBook__Fv", SN_NOWARN) set_name(0x80034F54, "get_pieces_str__Fi", SN_NOWARN) set_name(0x80034F88, "_GLOBAL__D_fontkern", SN_NOWARN) set_name(0x80034FB0, "_GLOBAL__I_fontkern", SN_NOWARN) set_name(0x80034FEC, "GetTick__C4CPad_addr_80034FEC", SN_NOWARN) set_name(0x80035014, "GetDown__C4CPad_addr_80035014", SN_NOWARN) set_name(0x8003503C, "SetPadTickMask__4CPadUs_addr_8003503C", SN_NOWARN) set_name(0x80035044, "SetPadTick__4CPadUs_addr_80035044", SN_NOWARN) set_name(0x8003504C, "SetRGB__6DialogUcUcUc_addr_8003504C", SN_NOWARN) set_name(0x8003506C, "SetBack__6Dialogi_addr_8003506C", SN_NOWARN) set_name(0x80035074, "SetBorder__6Dialogi_addr_80035074", SN_NOWARN) set_name(0x8003507C, "___6Dialog_addr_8003507C", SN_NOWARN) set_name(0x800350A4, "__6Dialog_addr_800350A4", SN_NOWARN) set_name(0x80035100, "GetPal__7TextDati_addr_80035100", SN_NOWARN) set_name(0x8003511C, "GetFr__7TextDati_addr_8003511C", SN_NOWARN) set_name(0x80035138, "InitCursor__Fv", SN_NOWARN) set_name(0x80035140, "FreeCursor__Fv", SN_NOWARN) set_name(0x80035148, "SetICursor__Fi", SN_NOWARN) set_name(0x800351A4, "SetCursor__Fi", SN_NOWARN) set_name(0x80035208, "NewCursor__Fi", SN_NOWARN) set_name(0x80035228, "InitLevelCursor__Fv", SN_NOWARN) set_name(0x80035288, "CheckTown__Fv", SN_NOWARN) set_name(0x800354E0, "CheckRportal__Fv", SN_NOWARN) set_name(0x80035708, "CheckCursMove__Fv", SN_NOWARN) set_name(0x80035710, "InitDead__Fv", SN_NOWARN) set_name(0x8003590C, "AddDead__Fiici", SN_NOWARN) set_name(0x80035954, "FreeGameMem__Fv", SN_NOWARN) set_name(0x800359A4, "start_game__FUi", SN_NOWARN) set_name(0x80035A00, "free_game__Fv", SN_NOWARN) set_name(0x80035A74, "LittleStart__FUcUc", SN_NOWARN) set_name(0x80035B38, "StartGame__FUcUc", SN_NOWARN) set_name(0x80035D20, "run_game_loop__FUi", SN_NOWARN) set_name(0x80035E90, "TryIconCurs__Fv", SN_NOWARN) set_name(0x8003626C, "DisableInputWndProc__FUlUilUl", SN_NOWARN) set_name(0x80036274, "GM_Game__FUlUilUl", SN_NOWARN) set_name(0x80036324, "LoadLvlGFX__Fv", SN_NOWARN) set_name(0x800363C0, "LoadAllGFX__Fv", SN_NOWARN) set_name(0x800363E0, "CreateLevel__Fi", SN_NOWARN) set_name(0x800364D8, "LoCreateLevel__FPv", SN_NOWARN) set_name(0x80036660, "ClearOutDungeonMap__Fv", SN_NOWARN) set_name(0x8003673C, "LoadGameLevel__FUci", SN_NOWARN) set_name(0x800370C0, "game_logic__Fv", SN_NOWARN) set_name(0x800371CC, "timeout_cursor__FUc", SN_NOWARN) set_name(0x80037274, "game_loop__FUc", SN_NOWARN) set_name(0x800372AC, "alloc_plr__Fv", SN_NOWARN) set_name(0x800372B4, "plr_encrypt__FUc", SN_NOWARN) set_name(0x800372BC, "assert_fail__FiPCcT1", SN_NOWARN) set_name(0x800372DC, "assert_fail__FiPCc", SN_NOWARN) set_name(0x800372FC, "app_fatal", SN_NOWARN) set_name(0x8003732C, "DoMemCardFromFrontEnd__Fv", SN_NOWARN) set_name(0x80037354, "DoMemCardFromInGame__Fv", SN_NOWARN) set_name(0x8003737C, "GetActiveTowner__Fi", SN_NOWARN) set_name(0x800373D0, "SetTownerGPtrs__FPUcPPUc", SN_NOWARN) set_name(0x800373F0, "NewTownerAnim__FiPUcii", SN_NOWARN) set_name(0x80037438, "InitTownerInfo__FilUciiici", SN_NOWARN) set_name(0x80037598, "InitQstSnds__Fi", SN_NOWARN) set_name(0x80037650, "InitSmith__Fv", SN_NOWARN) set_name(0x8003777C, "InitBarOwner__Fv", SN_NOWARN) set_name(0x800378B0, "InitTownDead__Fv", SN_NOWARN) set_name(0x800379E0, "InitWitch__Fv", SN_NOWARN) set_name(0x80037B10, "InitBarmaid__Fv", SN_NOWARN) set_name(0x80037C40, "InitBoy__Fv", SN_NOWARN) set_name(0x80037D78, "InitHealer__Fv", SN_NOWARN) set_name(0x80037EA8, "InitTeller__Fv", SN_NOWARN) set_name(0x80037FD8, "InitDrunk__Fv", SN_NOWARN) set_name(0x80038108, "InitCows__Fv", SN_NOWARN) set_name(0x800383CC, "InitTowners__Fv", SN_NOWARN) set_name(0x80038458, "FreeTownerGFX__Fv", SN_NOWARN) set_name(0x800384FC, "TownCtrlMsg__Fi", SN_NOWARN) set_name(0x8003861C, "TownBlackSmith__Fv", SN_NOWARN) set_name(0x80038650, "TownBarOwner__Fv", SN_NOWARN) set_name(0x80038684, "TownDead__Fv", SN_NOWARN) set_name(0x8003876C, "TownHealer__Fv", SN_NOWARN) set_name(0x80038794, "TownStory__Fv", SN_NOWARN) set_name(0x800387BC, "TownDrunk__Fv", SN_NOWARN) set_name(0x800387E4, "TownBoy__Fv", SN_NOWARN) set_name(0x8003880C, "TownWitch__Fv", SN_NOWARN) set_name(0x80038834, "TownBarMaid__Fv", SN_NOWARN) set_name(0x8003885C, "TownCow__Fv", SN_NOWARN) set_name(0x80038884, "ProcessTowners__Fv", SN_NOWARN) set_name(0x80038AD4, "PlrHasItem__FiiRi", SN_NOWARN) set_name(0x80038BA8, "CowSFX__Fi", SN_NOWARN) set_name(0x80038CC4, "TownerTalk__Fii", SN_NOWARN) set_name(0x80038D04, "TalkToTowner__Fii", SN_NOWARN) set_name(0x8003A12C, "effect_is_playing__Fi", SN_NOWARN) set_name(0x8003A134, "stream_stop__Fv", SN_NOWARN) set_name(0x8003A17C, "stream_play__FP4TSFXll", SN_NOWARN) set_name(0x8003A240, "stream_update__Fv", SN_NOWARN) set_name(0x8003A248, "sfx_stop__Fv", SN_NOWARN) set_name(0x8003A264, "InitMonsterSND__Fi", SN_NOWARN) set_name(0x8003A2BC, "FreeMonsterSnd__Fv", SN_NOWARN) set_name(0x8003A2C4, "calc_snd_position__FiiPlT2", SN_NOWARN) set_name(0x8003A3C8, "PlaySFX_priv__FP4TSFXUcii", SN_NOWARN) set_name(0x8003A4D8, "PlayEffect__Fii", SN_NOWARN) set_name(0x8003A604, "RndSFX__Fi", SN_NOWARN) set_name(0x8003A69C, "PlaySFX__Fi", SN_NOWARN) set_name(0x8003A6DC, "PlaySfxLoc__Fiii", SN_NOWARN) set_name(0x8003A730, "sound_stop__Fv", SN_NOWARN) set_name(0x8003A7C8, "sound_update__Fv", SN_NOWARN) set_name(0x8003A7FC, "priv_sound_init__FUc", SN_NOWARN) set_name(0x8003A840, "sound_init__Fv", SN_NOWARN) set_name(0x8003A8E8, "GetDirection__Fiiii", SN_NOWARN) set_name(0x8003A98C, "SetRndSeed__Fl", SN_NOWARN) set_name(0x8003A99C, "GetRndSeed__Fv", SN_NOWARN) set_name(0x8003A9E4, "random__Fil", SN_NOWARN) set_name(0x8003AA50, "DiabloAllocPtr__FUl", SN_NOWARN) set_name(0x8003AA9C, "mem_free_dbg__FPv", SN_NOWARN) set_name(0x8003AAEC, "LoadFileInMem__FPCcPUl", SN_NOWARN) set_name(0x8003AAF4, "PlayInGameMovie__FPCc", SN_NOWARN) set_name(0x8003AB84, "Enter__9CCritSect", SN_NOWARN) set_name(0x8003AB8C, "InitDiabloMsg__Fc", SN_NOWARN) set_name(0x8003AC20, "ClrDiabloMsg__Fv", SN_NOWARN) set_name(0x8003AC4C, "DrawDiabloMsg__Fv", SN_NOWARN) set_name(0x8003AD58, "interface_msg_pump__Fv", SN_NOWARN) set_name(0x8003AD60, "ShowProgress__FUi", SN_NOWARN) set_name(0x8003B24C, "InitAllItemsUseable__Fv", SN_NOWARN) set_name(0x8003B284, "InitItemGFX__Fv", SN_NOWARN) set_name(0x8003B2B0, "ItemPlace__Fii", SN_NOWARN) set_name(0x8003B378, "AddInitItems__Fv", SN_NOWARN) set_name(0x8003B590, "InitItems__Fv", SN_NOWARN) set_name(0x8003B754, "CalcPlrItemVals__FiUc", SN_NOWARN) set_name(0x8003C204, "CalcPlrScrolls__Fi", SN_NOWARN) set_name(0x8003C584, "CalcPlrStaff__FP12PlayerStruct", SN_NOWARN) set_name(0x8003C620, "CalcSelfItems__Fi", SN_NOWARN) set_name(0x8003C780, "ItemMinStats__FPC12PlayerStructPC10ItemStruct", SN_NOWARN) set_name(0x8003C7CC, "CalcPlrItemMin__Fi", SN_NOWARN) set_name(0x8003C8AC, "CalcPlrBookVals__Fi", SN_NOWARN) set_name(0x8003CB40, "CalcPlrInv__FiUc", SN_NOWARN) set_name(0x8003CC04, "SetPlrHandItem__FP10ItemStructi", SN_NOWARN) set_name(0x8003CD1C, "GetPlrHandSeed__FP10ItemStruct", SN_NOWARN) set_name(0x8003CD48, "GetGoldSeed__FiP10ItemStruct", SN_NOWARN) set_name(0x8003CEC4, "SetPlrHandSeed__FP10ItemStructi", SN_NOWARN) set_name(0x8003CECC, "SetPlrHandGoldCurs__FP10ItemStruct", SN_NOWARN) set_name(0x8003CEFC, "CreatePlrItems__Fi", SN_NOWARN) set_name(0x8003D338, "ItemSpaceOk__Fii", SN_NOWARN) set_name(0x8003D610, "GetItemSpace__Fiic", SN_NOWARN) set_name(0x8003D83C, "GetSuperItemSpace__Fiic", SN_NOWARN) set_name(0x8003D9A4, "GetSuperItemLoc__FiiRiT2", SN_NOWARN) set_name(0x8003DA6C, "CalcItemValue__Fi", SN_NOWARN) set_name(0x8003DB24, "GetBookSpell__Fii", SN_NOWARN) set_name(0x8003DD8C, "GetStaffPower__FiiiUc", SN_NOWARN) set_name(0x8003DF7C, "GetStaffSpell__FiiUc", SN_NOWARN) set_name(0x8003E230, "GetItemAttrs__Fiii", SN_NOWARN) set_name(0x8003E77C, "RndPL__Fii", SN_NOWARN) set_name(0x8003E7B4, "PLVal__Fiiiii", SN_NOWARN) set_name(0x8003E828, "SaveItemPower__Fiiiiiii", SN_NOWARN) set_name(0x8003FF54, "GetItemPower__FiiilUc", SN_NOWARN) set_name(0x800403BC, "GetItemBonus__FiiiiUc", SN_NOWARN) set_name(0x800404B8, "SetupItem__Fi", SN_NOWARN) set_name(0x800405CC, "RndItem__Fi", SN_NOWARN) set_name(0x80040810, "RndUItem__Fi", SN_NOWARN) set_name(0x80040A50, "RndAllItems__Fv", SN_NOWARN) set_name(0x80040BC4, "RndTypeItems__Fii", SN_NOWARN) set_name(0x80040CC4, "CheckUnique__FiiiUc", SN_NOWARN) set_name(0x80040E74, "GetUniqueItem__Fii", SN_NOWARN) set_name(0x8004111C, "SpawnUnique__Fiii", SN_NOWARN) set_name(0x80041228, "ItemRndDur__Fi", SN_NOWARN) set_name(0x800412B8, "SetupAllItems__FiiiiiUcUcUc", SN_NOWARN) set_name(0x800415C4, "SpawnItem__FiiiUc", SN_NOWARN) set_name(0x8004180C, "CreateItem__Fiii", SN_NOWARN) set_name(0x8004193C, "CreateRndItem__FiiUcUcUc", SN_NOWARN) set_name(0x80041A84, "SetupAllUseful__Fiii", SN_NOWARN) set_name(0x80041B5C, "CreateRndUseful__FiiiUc", SN_NOWARN) set_name(0x80041C1C, "CreateTypeItem__FiiUciiUcUc", SN_NOWARN) set_name(0x80041D60, "RecreateEar__FiUsiUciiiiii", SN_NOWARN) set_name(0x80041F4C, "SpawnQuestItem__Fiiiii", SN_NOWARN) set_name(0x80042178, "SpawnRock__Fv", SN_NOWARN) set_name(0x80042338, "RespawnItem__FiUc", SN_NOWARN) set_name(0x800424FC, "DeleteItem__Fii", SN_NOWARN) set_name(0x80042550, "ItemDoppel__Fv", SN_NOWARN) set_name(0x80042618, "ProcessItems__Fv", SN_NOWARN) set_name(0x8004275C, "FreeItemGFX__Fv", SN_NOWARN) set_name(0x80042764, "GetItemStr__Fi", SN_NOWARN) set_name(0x800428F4, "CheckIdentify__Fii", SN_NOWARN) set_name(0x800429E4, "RepairItem__FP10ItemStructi", SN_NOWARN) set_name(0x80042AB4, "DoRepair__Fii", SN_NOWARN) set_name(0x80042B78, "RechargeItem__FP10ItemStructi", SN_NOWARN) set_name(0x80042BE8, "DoRecharge__Fii", SN_NOWARN) set_name(0x80042CE8, "PrintItemOil__Fc", SN_NOWARN) set_name(0x80042DDC, "PrintItemPower__FcPC10ItemStruct", SN_NOWARN) set_name(0x80043490, "PrintUString__FiiUcPcc", SN_NOWARN) set_name(0x80043498, "PrintItemMisc__FPC10ItemStruct", SN_NOWARN) set_name(0x80043724, "PrintItemDetails__FPC10ItemStruct", SN_NOWARN) set_name(0x80043A94, "PrintItemDur__FPC10ItemStruct", SN_NOWARN) set_name(0x80043DA4, "CastScroll__Fii", SN_NOWARN) set_name(0x80043DB4, "UseItem__Fiii", SN_NOWARN) set_name(0x800443CC, "StoreStatOk__FP10ItemStruct", SN_NOWARN) set_name(0x80044460, "PremiumItemOk__Fi", SN_NOWARN) set_name(0x800444DC, "RndPremiumItem__Fii", SN_NOWARN) set_name(0x800445E4, "SpawnOnePremium__Fii", SN_NOWARN) set_name(0x80044804, "SpawnPremium__Fi", SN_NOWARN) set_name(0x80044A48, "WitchBookLevel__Fi", SN_NOWARN) set_name(0x80044B98, "SpawnStoreGold__Fv", SN_NOWARN) set_name(0x80044C1C, "RecalcStoreStats__Fv", SN_NOWARN) set_name(0x80044DBC, "ItemNoFlippy__Fv", SN_NOWARN) set_name(0x80044E20, "CreateSpellBook__FiiiUcUc", SN_NOWARN) set_name(0x80044FB0, "CreateMagicArmor__FiiiiUcUc", SN_NOWARN) set_name(0x8004512C, "CreateMagicWeapon__FiiiiUcUc", SN_NOWARN) set_name(0x800452A8, "DrawUniqueInfo__Fv", SN_NOWARN) set_name(0x8004541C, "MakeItemStr__FP10ItemStructUsUs", SN_NOWARN) set_name(0x800455B4, "veclen2__Fii", SN_NOWARN) set_name(0x8004561C, "set_light_bands__Fv", SN_NOWARN) set_name(0x80045690, "SetLightFX__FiisssUcUcUc", SN_NOWARN) set_name(0x800456FC, "DoLighting__Fiiii", SN_NOWARN) set_name(0x800463AC, "DoUnLight__Fv", SN_NOWARN) set_name(0x800465F0, "DoUnVision__Fiii", SN_NOWARN) set_name(0x800466B4, "DoVision__FiiiUcUc", SN_NOWARN) set_name(0x80046BC4, "FreeLightTable__Fv", SN_NOWARN) set_name(0x80046BCC, "InitLightTable__Fv", SN_NOWARN) set_name(0x80046BD4, "MakeLightTable__Fv", SN_NOWARN) set_name(0x80046BDC, "InitLightMax__Fv", SN_NOWARN) set_name(0x80046C00, "InitLighting__Fv", SN_NOWARN) set_name(0x80046C44, "AddLight__Fiii", SN_NOWARN) set_name(0x80046CD8, "AddUnLight__Fi", SN_NOWARN) set_name(0x80046D08, "ChangeLightRadius__Fii", SN_NOWARN) set_name(0x80046D34, "ChangeLightXY__Fiii", SN_NOWARN) set_name(0x80046D6C, "light_fix__Fi", SN_NOWARN) set_name(0x80046D74, "ChangeLightOff__Fiii", SN_NOWARN) set_name(0x80046DAC, "ChangeLight__Fiiii", SN_NOWARN) set_name(0x80046DF0, "ChangeLightColour__Fii", SN_NOWARN) set_name(0x80046E20, "ProcessLightList__Fv", SN_NOWARN) set_name(0x80046F4C, "SavePreLighting__Fv", SN_NOWARN) set_name(0x80046F54, "InitVision__Fv", SN_NOWARN) set_name(0x80046FA4, "AddVision__FiiiUc", SN_NOWARN) set_name(0x800470A8, "ChangeVisionRadius__Fii", SN_NOWARN) set_name(0x8004715C, "ChangeVisionXY__Fiii", SN_NOWARN) set_name(0x80047214, "ProcessVisionList__Fv", SN_NOWARN) set_name(0x80047474, "FreeQuestText__Fv", SN_NOWARN) set_name(0x8004747C, "InitQuestText__Fv", SN_NOWARN) set_name(0x80047488, "CalcTextSpeed__FPCc", SN_NOWARN) set_name(0x800475C8, "InitQTextMsg__Fi", SN_NOWARN) set_name(0x800476DC, "DrawQTextBack__Fv", SN_NOWARN) set_name(0x8004774C, "DrawQTextTSK__FP4TASK", SN_NOWARN) set_name(0x8004781C, "DrawQText__Fv", SN_NOWARN) set_name(0x80047B64, "_GLOBAL__D_QBack", SN_NOWARN) set_name(0x80047B8C, "_GLOBAL__I_QBack", SN_NOWARN) set_name(0x80047BB4, "SetRGB__6DialogUcUcUc_addr_80047BB4", SN_NOWARN) set_name(0x80047BD4, "SetBorder__6Dialogi_addr_80047BD4", SN_NOWARN) set_name(0x80047BDC, "___6Dialog_addr_80047BDC", SN_NOWARN) set_name(0x80047C04, "__6Dialog_addr_80047C04", SN_NOWARN) set_name(0x80047C60, "GetCharWidth__5CFontc_addr_80047C60", SN_NOWARN) set_name(0x80047CB8, "GetFr__7TextDati_addr_80047CB8", SN_NOWARN) set_name(0x80047CD4, "nullmissile__Fiiiiiicii", SN_NOWARN) set_name(0x80047CDC, "FuncNULL__FP13MissileStructiii", SN_NOWARN) set_name(0x80047CE4, "delta_init__Fv", SN_NOWARN) set_name(0x80047D44, "delta_kill_monster__FiUcUcUc", SN_NOWARN) set_name(0x80047DE0, "delta_monster_hp__FilUc", SN_NOWARN) set_name(0x80047E64, "delta_sync_golem__FPC9TCmdGolemiUc", SN_NOWARN) set_name(0x80047EF4, "delta_leave_sync__FUc", SN_NOWARN) set_name(0x80048220, "delta_sync_object__FiUcUc", SN_NOWARN) set_name(0x80048280, "delta_get_item__FPC9TCmdGItemUc", SN_NOWARN) set_name(0x80048444, "delta_put_item__FPC9TCmdPItemiiUc", SN_NOWARN) set_name(0x800485CC, "delta_portal_inited__Fi", SN_NOWARN) set_name(0x800485F0, "delta_quest_inited__Fi", SN_NOWARN) set_name(0x80048614, "DeltaAddItem__Fi", SN_NOWARN) set_name(0x80048828, "DeltaExportData__FPc", SN_NOWARN) set_name(0x80048858, "DeltaImportData__FPc", SN_NOWARN) set_name(0x8004888C, "DeltaSaveLevel__Fv", SN_NOWARN) set_name(0x80048988, "NetSendCmd__FUcUc", SN_NOWARN) set_name(0x800489B0, "NetSendCmdGolem__FUcUcUcUclUc", SN_NOWARN) set_name(0x800489FC, "NetSendCmdLoc__FUcUcUcUc", SN_NOWARN) set_name(0x80048A2C, "NetSendCmdLocParam1__FUcUcUcUcUs", SN_NOWARN) set_name(0x80048A64, "NetSendCmdLocParam2__FUcUcUcUcUsUs", SN_NOWARN) set_name(0x80048AA4, "NetSendCmdLocParam3__FUcUcUcUcUsUsUs", SN_NOWARN) set_name(0x80048AEC, "NetSendCmdParam1__FUcUcUs", SN_NOWARN) set_name(0x80048B18, "NetSendCmdParam2__FUcUcUsUs", SN_NOWARN) set_name(0x80048B48, "NetSendCmdParam3__FUcUcUsUsUs", SN_NOWARN) set_name(0x80048B80, "NetSendCmdQuest__FUcUc", SN_NOWARN) set_name(0x80048BF4, "NetSendCmdGItem__FUcUcUcUcUc", SN_NOWARN) set_name(0x80048D28, "NetSendCmdGItem2__FUcUcUcUcPC9TCmdGItem", SN_NOWARN) set_name(0x80048DA4, "NetSendCmdReq2__FUcUcUcPC9TCmdGItem", SN_NOWARN) set_name(0x80048DFC, "NetSendCmdExtra__FPC9TCmdGItem", SN_NOWARN) set_name(0x80048E64, "NetSendCmdPItem__FUcUcUcUc", SN_NOWARN) set_name(0x80048F6C, "NetSendCmdChItem__FUcUc", SN_NOWARN) set_name(0x80049010, "NetSendCmdDelItem__FUcUc", SN_NOWARN) set_name(0x80049040, "NetSendCmdDItem__FUci", SN_NOWARN) set_name(0x80049154, "i_own_level__Fi", SN_NOWARN) set_name(0x8004915C, "NetSendCmdDamage__FUcUcUl", SN_NOWARN) set_name(0x80049190, "delta_open_portal__FiUcUcUcUcUc", SN_NOWARN) set_name(0x800491EC, "delta_close_portal__Fi", SN_NOWARN) set_name(0x8004922C, "check_update_plr__Fi", SN_NOWARN) set_name(0x80049234, "On_WALKXY__FPC4TCmdi", SN_NOWARN) set_name(0x800492D8, "On_ADDSTR__FPC4TCmdi", SN_NOWARN) set_name(0x80049308, "On_ADDMAG__FPC4TCmdi", SN_NOWARN) set_name(0x80049338, "On_ADDDEX__FPC4TCmdi", SN_NOWARN) set_name(0x80049368, "On_ADDVIT__FPC4TCmdi", SN_NOWARN) set_name(0x80049398, "On_SBSPELL__FPC4TCmdi", SN_NOWARN) set_name(0x8004940C, "On_GOTOGETITEM__FPC4TCmdi", SN_NOWARN) set_name(0x800494B0, "On_REQUESTGITEM__FPC4TCmdi", SN_NOWARN) set_name(0x800495F0, "On_GETITEM__FPC4TCmdi", SN_NOWARN) set_name(0x800497C0, "On_GOTOAGETITEM__FPC4TCmdi", SN_NOWARN) set_name(0x80049864, "On_REQUESTAGITEM__FPC4TCmdi", SN_NOWARN) set_name(0x80049998, "On_AGETITEM__FPC4TCmdi", SN_NOWARN) set_name(0x80049B60, "On_ITEMEXTRA__FPC4TCmdi", SN_NOWARN) set_name(0x80049BFC, "On_PUTITEM__FPC4TCmdi", SN_NOWARN) set_name(0x80049DAC, "On_SYNCPUTITEM__FPC4TCmdi", SN_NOWARN) set_name(0x80049EE8, "On_RESPAWNITEM__FPC4TCmdi", SN_NOWARN) set_name(0x8004A000, "On_SATTACKXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004A0AC, "On_SPELLXYD__FPC4TCmdi", SN_NOWARN) set_name(0x8004A1B4, "On_SPELLXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004A2AC, "On_TSPELLXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004A3A8, "On_OPOBJXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004A4D0, "On_DISARMXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004A5F8, "On_OPOBJT__FPC4TCmdi", SN_NOWARN) set_name(0x8004A660, "On_ATTACKID__FPC4TCmdi", SN_NOWARN) set_name(0x8004A7B4, "On_SPELLID__FPC4TCmdi", SN_NOWARN) set_name(0x8004A89C, "On_SPELLPID__FPC4TCmdi", SN_NOWARN) set_name(0x8004A97C, "On_TSPELLID__FPC4TCmdi", SN_NOWARN) set_name(0x8004AA60, "On_TSPELLPID__FPC4TCmdi", SN_NOWARN) set_name(0x8004AB44, "On_KNOCKBACK__FPC4TCmdi", SN_NOWARN) set_name(0x8004ABD0, "On_RESURRECT__FPC4TCmdi", SN_NOWARN) set_name(0x8004AC08, "On_HEALOTHER__FPC4TCmdi", SN_NOWARN) set_name(0x8004AC78, "On_TALKXY__FPC4TCmdi", SN_NOWARN) set_name(0x8004AD1C, "On_NEWLVL__FPC4TCmdi", SN_NOWARN) set_name(0x8004AD54, "On_WARP__FPC4TCmdi", SN_NOWARN) set_name(0x8004AE38, "On_MONSTDEATH__FPC4TCmdi", SN_NOWARN) set_name(0x8004AEA4, "On_KILLGOLEM__FPC4TCmdi", SN_NOWARN) set_name(0x8004AF10, "On_AWAKEGOLEM__FPC4TCmdi", SN_NOWARN) set_name(0x8004B080, "On_MONSTDAMAGE__FPC4TCmdi", SN_NOWARN) set_name(0x8004B184, "On_PLRDEAD__FPC4TCmdi", SN_NOWARN) set_name(0x8004B1CC, "On_PLRDAMAGE__FPC4TCmdi", SN_NOWARN) set_name(0x8004B388, "On_OPENDOOR__FPC4TCmdi", SN_NOWARN) set_name(0x8004B420, "On_CLOSEDOOR__FPC4TCmdi", SN_NOWARN) set_name(0x8004B4B8, "On_OPERATEOBJ__FPC4TCmdi", SN_NOWARN) set_name(0x8004B550, "On_PLROPOBJ__FPC4TCmdi", SN_NOWARN) set_name(0x8004B5E4, "On_BREAKOBJ__FPC4TCmdi", SN_NOWARN) set_name(0x8004B678, "On_CHANGEPLRITEMS__FPC4TCmdi", SN_NOWARN) set_name(0x8004B680, "On_DELPLRITEMS__FPC4TCmdi", SN_NOWARN) set_name(0x8004B688, "On_PLRLEVEL__FPC4TCmdi", SN_NOWARN) set_name(0x8004B690, "On_DROPITEM__FPC4TCmdi", SN_NOWARN) set_name(0x8004B6E8, "On_PLAYER_JOINLEVEL__FPC4TCmdi", SN_NOWARN) set_name(0x8004B97C, "On_ACTIVATEPORTAL__FPC4TCmdi", SN_NOWARN) set_name(0x8004BB0C, "On_DEACTIVATEPORTAL__FPC4TCmdi", SN_NOWARN) set_name(0x8004BB5C, "On_RETOWN__FPC4TCmdi", SN_NOWARN) set_name(0x8004BBA4, "On_SETSTR__FPC4TCmdi", SN_NOWARN) set_name(0x8004BBE4, "On_SETDEX__FPC4TCmdi", SN_NOWARN) set_name(0x8004BC24, "On_SETMAG__FPC4TCmdi", SN_NOWARN) set_name(0x8004BC64, "On_SETVIT__FPC4TCmdi", SN_NOWARN) set_name(0x8004BCA4, "On_SYNCQUEST__FPC4TCmdi", SN_NOWARN) set_name(0x8004BCEC, "On_ENDSHIELD__FPC4TCmdi", SN_NOWARN) set_name(0x8004BE08, "ParseCmd__FiPC4TCmd", SN_NOWARN) set_name(0x8004C228, "GetDLevel__Fib", SN_NOWARN) set_name(0x8004C2B8, "ReleaseDLevel__FP6DLevel", SN_NOWARN) set_name(0x8004C2F0, "NetSendLoPri__FPCUcUc", SN_NOWARN) set_name(0x8004C31C, "InitLevelType__Fi", SN_NOWARN) set_name(0x8004C368, "SetupLocalCoords__Fv", SN_NOWARN) set_name(0x8004C4F8, "InitNewSeed__Fl", SN_NOWARN) set_name(0x8004C56C, "NetInit__FUcPUc", SN_NOWARN) set_name(0x8004C794, "PostAddL1Door__Fiiii", SN_NOWARN) set_name(0x8004C8CC, "PostAddL2Door__Fiiii", SN_NOWARN) set_name(0x8004CA18, "PostAddArmorStand__Fi", SN_NOWARN) set_name(0x8004CAA0, "PostTorchLocOK__Fii", SN_NOWARN) set_name(0x8004CAE0, "PostAddObjLight__Fii", SN_NOWARN) set_name(0x8004CB84, "PostObjObjAddSwitch__Fiiii", SN_NOWARN) set_name(0x8004CC38, "InitObjectGFX__Fv", SN_NOWARN) set_name(0x8004CE54, "FreeObjectGFX__Fv", SN_NOWARN) set_name(0x8004CE60, "DeleteObject__Fii", SN_NOWARN) set_name(0x8004CF18, "SetupObject__Fiiii", SN_NOWARN) set_name(0x8004D19C, "SetObjMapRange__Fiiiiii", SN_NOWARN) set_name(0x8004D1FC, "SetBookMsg__Fii", SN_NOWARN) set_name(0x8004D224, "AddObject__Fiii", SN_NOWARN) set_name(0x8004D330, "PostAddObject__Fiii", SN_NOWARN) set_name(0x8004D43C, "Obj_Light__Fii", SN_NOWARN) set_name(0x8004D64C, "Obj_Circle__Fi", SN_NOWARN) set_name(0x8004D970, "Obj_StopAnim__Fi", SN_NOWARN) set_name(0x8004D9D4, "DrawExpl__Fiiiiiccc", SN_NOWARN) set_name(0x8004DCB0, "DrawObjExpl__FP12ObjectStructiii", SN_NOWARN) set_name(0x8004DD20, "Obj_Door__Fi", SN_NOWARN) set_name(0x8004DEB4, "Obj_Sarc__Fi", SN_NOWARN) set_name(0x8004DF00, "ActivateTrapLine__Fii", SN_NOWARN) set_name(0x8004E010, "Obj_FlameTrap__Fi", SN_NOWARN) set_name(0x8004E2E0, "Obj_Trap__Fi", SN_NOWARN) set_name(0x8004E630, "Obj_BCrossDamage__Fi", SN_NOWARN) set_name(0x8004E8C0, "ProcessObjects__Fv", SN_NOWARN) set_name(0x8004EB60, "ObjSetMicro__Fiii", SN_NOWARN) set_name(0x8004EB98, "ObjSetMini__Fiii", SN_NOWARN) set_name(0x8004EC6C, "ObjL1Special__Fiiii", SN_NOWARN) set_name(0x8004EC74, "ObjL2Special__Fiiii", SN_NOWARN) set_name(0x8004EC7C, "DoorSet__Fiii", SN_NOWARN) set_name(0x8004EEFC, "RedoPlayerVision__Fv", SN_NOWARN) set_name(0x8004EFA0, "OperateL1RDoor__FiiUc", SN_NOWARN) set_name(0x8004F344, "OperateL1LDoor__FiiUc", SN_NOWARN) set_name(0x8004F71C, "OperateL2RDoor__FiiUc", SN_NOWARN) set_name(0x8004FAB4, "OperateL2LDoor__FiiUc", SN_NOWARN) set_name(0x8004FE4C, "OperateL3RDoor__FiiUc", SN_NOWARN) set_name(0x80050154, "OperateL3LDoor__FiiUc", SN_NOWARN) set_name(0x8005045C, "MonstCheckDoors__Fi", SN_NOWARN) set_name(0x80050958, "PostAddL1Objs__Fiiii", SN_NOWARN) set_name(0x80050A90, "PostAddL2Objs__Fiiii", SN_NOWARN) set_name(0x80050BA4, "ObjChangeMap__Fiiii", SN_NOWARN) set_name(0x80050D5C, "DRLG_MRectTrans__Fiiii", SN_NOWARN) set_name(0x80050E08, "ObjChangeMapResync__Fiiii", SN_NOWARN) set_name(0x80050F78, "OperateL1Door__FiiUc", SN_NOWARN) set_name(0x800510D4, "OperateLever__Fii", SN_NOWARN) set_name(0x800512C0, "OperateBook__Fii", SN_NOWARN) set_name(0x800517B4, "OperateBookLever__Fii", SN_NOWARN) set_name(0x80051B5C, "OperateSChambBk__Fii", SN_NOWARN) set_name(0x80051D34, "OperateChest__FiiUc", SN_NOWARN) set_name(0x80052104, "OperateMushPatch__Fii", SN_NOWARN) set_name(0x800522C8, "OperateInnSignChest__Fii", SN_NOWARN) set_name(0x80052460, "OperateSlainHero__FiiUc", SN_NOWARN) set_name(0x800526B4, "OperateTrapLvr__Fi", SN_NOWARN) set_name(0x80052884, "OperateSarc__FiiUc", SN_NOWARN) set_name(0x80052A3C, "OperateL2Door__FiiUc", SN_NOWARN) set_name(0x80052B98, "OperateL3Door__FiiUc", SN_NOWARN) set_name(0x80052CF4, "LoadMapObjs__FPUcii", SN_NOWARN) set_name(0x80052DFC, "OperatePedistal__Fii", SN_NOWARN) set_name(0x800530B4, "TryDisarm__Fii", SN_NOWARN) set_name(0x80053278, "ItemMiscIdIdx__Fi", SN_NOWARN) set_name(0x800532E8, "OperateShrine__Fiii", SN_NOWARN) set_name(0x800558C4, "OperateSkelBook__FiiUc", SN_NOWARN) set_name(0x80055A40, "OperateBookCase__FiiUc", SN_NOWARN) set_name(0x80055C10, "OperateDecap__FiiUc", SN_NOWARN) set_name(0x80055CF8, "OperateArmorStand__FiiUc", SN_NOWARN) set_name(0x80055E68, "FindValidShrine__Fi", SN_NOWARN) set_name(0x80055F58, "OperateGoatShrine__Fiii", SN_NOWARN) set_name(0x80056000, "OperateCauldron__Fiii", SN_NOWARN) set_name(0x800560B4, "OperateFountains__Fii", SN_NOWARN) set_name(0x80056660, "OperateWeaponRack__FiiUc", SN_NOWARN) set_name(0x8005680C, "OperateStoryBook__Fii", SN_NOWARN) set_name(0x80056910, "OperateLazStand__Fii", SN_NOWARN) set_name(0x800569F0, "OperateObject__FiiUc", SN_NOWARN) set_name(0x80056E28, "SyncOpL1Door__Fiii", SN_NOWARN) set_name(0x80056F3C, "SyncOpL2Door__Fiii", SN_NOWARN) set_name(0x80057050, "SyncOpL3Door__Fiii", SN_NOWARN) set_name(0x80057164, "SyncOpObject__Fiii", SN_NOWARN) set_name(0x80057344, "BreakCrux__Fi", SN_NOWARN) set_name(0x80057534, "BreakBarrel__FiiiUcUc", SN_NOWARN) set_name(0x80057A88, "BreakObject__Fii", SN_NOWARN) set_name(0x80057BE8, "SyncBreakObj__Fii", SN_NOWARN) set_name(0x80057C44, "SyncL1Doors__Fi", SN_NOWARN) set_name(0x80057D5C, "SyncCrux__Fi", SN_NOWARN) set_name(0x80057E94, "SyncLever__Fi", SN_NOWARN) set_name(0x80057F10, "SyncQSTLever__Fi", SN_NOWARN) set_name(0x80058008, "SyncPedistal__Fi", SN_NOWARN) set_name(0x80058164, "SyncL2Doors__Fi", SN_NOWARN) set_name(0x800582CC, "SyncL3Doors__Fi", SN_NOWARN) set_name(0x800583F8, "SyncObjectAnim__Fi", SN_NOWARN) set_name(0x80058538, "GetObjectStr__Fi", SN_NOWARN) set_name(0x80058954, "RestoreObjectLight__Fv", SN_NOWARN) set_name(0x80058BA8, "GetNumOfFrames__7TextDatii_addr_80058BA8", SN_NOWARN) set_name(0x80058BE0, "GetCreature__7TextDati_addr_80058BE0", SN_NOWARN) set_name(0x80058C58, "GetNumOfCreatures__7TextDat_addr_80058C58", SN_NOWARN) set_name(0x80058C6C, "FindPath__FPFiii_UciiiiiPc", SN_NOWARN) set_name(0x80058C74, "game_2_ui_class__FPC12PlayerStruct", SN_NOWARN) set_name(0x80058CA0, "game_2_ui_player__FPC12PlayerStructP11_uiheroinfoUc", SN_NOWARN) set_name(0x80058D54, "SetupLocalPlayer__Fv", SN_NOWARN) set_name(0x80058D74, "ismyplr__FP12PlayerStruct", SN_NOWARN) set_name(0x80058DB8, "plrind__FP12PlayerStruct", SN_NOWARN) set_name(0x80058DCC, "InitPlayerGFX__FP12PlayerStruct", SN_NOWARN) set_name(0x80058DEC, "FreePlayerGFX__FP12PlayerStruct", SN_NOWARN) set_name(0x80058DF4, "NewPlrAnim__FP12PlayerStructiii", SN_NOWARN) set_name(0x80058E10, "ClearPlrPVars__FP12PlayerStruct", SN_NOWARN) set_name(0x80058E34, "SetPlrAnims__FP12PlayerStruct", SN_NOWARN) set_name(0x80059070, "CreatePlayer__FP12PlayerStructc", SN_NOWARN) set_name(0x8005948C, "CalcStatDiff__FP12PlayerStruct", SN_NOWARN) set_name(0x800594F4, "NextPlrLevel__FP12PlayerStruct", SN_NOWARN) set_name(0x80059664, "AddPlrExperience__FP12PlayerStructil", SN_NOWARN) set_name(0x80059870, "AddPlrMonstExper__Filc", SN_NOWARN) set_name(0x800598F4, "InitPlayer__FP12PlayerStructUc", SN_NOWARN) set_name(0x80059CC0, "InitMultiView__Fv", SN_NOWARN) set_name(0x80059CC8, "CheckLeighSolid__Fii", SN_NOWARN) set_name(0x80059D60, "SolidLoc__Fii", SN_NOWARN) set_name(0x80059DE8, "PlrClrTrans__Fii", SN_NOWARN) set_name(0x80059E7C, "PlrDoTrans__Fii", SN_NOWARN) set_name(0x80059F70, "SetPlayerOld__FP12PlayerStruct", SN_NOWARN) set_name(0x80059F84, "StartStand__FP12PlayerStructi", SN_NOWARN) set_name(0x8005A010, "StartWalkStand__FP12PlayerStruct", SN_NOWARN) set_name(0x8005A074, "PM_ChangeLightOff__FP12PlayerStruct", SN_NOWARN) set_name(0x8005A0B0, "PM_ChangeOffset__FP12PlayerStruct", SN_NOWARN) set_name(0x8005A0DC, "StartAttack__FP12PlayerStructi", SN_NOWARN) set_name(0x8005A214, "StartPlrBlock__FP12PlayerStructi", SN_NOWARN) set_name(0x8005A2AC, "StartSpell__FP12PlayerStructiii", SN_NOWARN) set_name(0x8005A448, "RemovePlrFromMap__FP12PlayerStruct", SN_NOWARN) set_name(0x8005A568, "StartPlrHit__FP12PlayerStructiUc", SN_NOWARN) set_name(0x8005A688, "RespawnDeadItem__FP10ItemStructii", SN_NOWARN) set_name(0x8005A824, "PlrDeadItem__FP12PlayerStructP10ItemStructii", SN_NOWARN) set_name(0x8005A9EC, "StartPlayerKill__FP12PlayerStructi", SN_NOWARN) set_name(0x8005AD04, "DropHalfPlayersGold__FP12PlayerStruct", SN_NOWARN) set_name(0x8005B14C, "StartPlrKill__FP12PlayerStructi", SN_NOWARN) set_name(0x8005B290, "SyncPlrKill__FP12PlayerStructi", SN_NOWARN) set_name(0x8005B2B0, "RemovePlrMissiles__FP12PlayerStruct", SN_NOWARN) set_name(0x8005B598, "InitLevelChange__FP12PlayerStruct", SN_NOWARN) set_name(0x8005B654, "StartNewLvl__FP12PlayerStructii", SN_NOWARN) set_name(0x8005B798, "RestartTownLvl__FP12PlayerStruct", SN_NOWARN) set_name(0x8005B828, "StartWarpLvl__FP12PlayerStructi", SN_NOWARN) set_name(0x8005B8E4, "PM_DoStand__FP12PlayerStruct", SN_NOWARN) set_name(0x8005B8EC, "ChkPlrOffsets__Fiiii", SN_NOWARN) set_name(0x8005B974, "PM_DoWalk__FP12PlayerStruct", SN_NOWARN) set_name(0x8005BCE0, "WeaponDur__FP12PlayerStructi", SN_NOWARN) set_name(0x8005BE80, "PlrHitMonst__FP12PlayerStructi", SN_NOWARN) set_name(0x8005C4B0, "PlrHitPlr__FP12PlayerStructc", SN_NOWARN) set_name(0x8005C860, "PlrHitObj__FP12PlayerStructii", SN_NOWARN) set_name(0x8005C8F0, "PM_DoAttack__FP12PlayerStruct", SN_NOWARN) set_name(0x8005CC7C, "PM_DoRangeAttack__FP12PlayerStruct", SN_NOWARN) set_name(0x8005CD7C, "ShieldDur__FP12PlayerStruct", SN_NOWARN) set_name(0x8005CE3C, "PM_DoBlock__FP12PlayerStruct", SN_NOWARN) set_name(0x8005CEDC, "do_spell_anim__FiiiP12PlayerStruct", SN_NOWARN) set_name(0x8005DEA0, "PM_DoSpell__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E210, "ArmorDur__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E30C, "PM_DoGotHit__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E388, "PM_DoDeath__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E4C8, "PM_DoNewLvl__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E4D0, "CheckNewPath__FP12PlayerStruct", SN_NOWARN) set_name(0x8005E910, "PlrDeathModeOK__Fi", SN_NOWARN) set_name(0x8005E978, "ValidatePlayer__Fv", SN_NOWARN) set_name(0x8005EE54, "CheckCheatStats__FP12PlayerStruct", SN_NOWARN) set_name(0x8005EEF0, "ProcessPlayers__Fv", SN_NOWARN) set_name(0x8005F224, "ClrPlrPath__FP12PlayerStruct", SN_NOWARN) set_name(0x8005F24C, "PosOkPlayer__FP12PlayerStructii", SN_NOWARN) set_name(0x8005F3F4, "MakePlrPath__FP12PlayerStructiiUc", SN_NOWARN) set_name(0x8005F3FC, "CheckPlrSpell__Fv", SN_NOWARN) set_name(0x8005F804, "SyncInitPlrPos__FP12PlayerStruct", SN_NOWARN) set_name(0x8005F940, "SyncInitPlr__FP12PlayerStruct", SN_NOWARN) set_name(0x8005F970, "CheckStats__Fi", SN_NOWARN) set_name(0x8005FB0C, "ModifyPlrStr__Fii", SN_NOWARN) set_name(0x8005FC28, "ModifyPlrMag__Fii", SN_NOWARN) set_name(0x8005FD14, "ModifyPlrDex__Fii", SN_NOWARN) set_name(0x8005FDF8, "ModifyPlrVit__Fii", SN_NOWARN) set_name(0x8005FED4, "SetPlayerHitPoints__FP12PlayerStructi", SN_NOWARN) set_name(0x8005FF18, "SetPlrStr__Fii", SN_NOWARN) set_name(0x8005FFF4, "SetPlrMag__Fii", SN_NOWARN) set_name(0x80060064, "SetPlrDex__Fii", SN_NOWARN) set_name(0x80060140, "SetPlrVit__Fii", SN_NOWARN) set_name(0x800601AC, "InitDungMsgs__FP12PlayerStruct", SN_NOWARN) set_name(0x800601B4, "PlayDungMsgs__Fv", SN_NOWARN) set_name(0x800604E4, "CreatePlrItems__FP12PlayerStruct", SN_NOWARN) set_name(0x8006050C, "WorldToOffset__FP12PlayerStructii", SN_NOWARN) set_name(0x80060550, "SetSpdbarGoldCurs__FP12PlayerStructi", SN_NOWARN) set_name(0x80060584, "GetSpellLevel__FP12PlayerStructi", SN_NOWARN) set_name(0x800605B8, "BreakObject__FP12PlayerStructi", SN_NOWARN) set_name(0x800605EC, "CalcPlrInv__FP12PlayerStructUc", SN_NOWARN) set_name(0x80060620, "RemoveSpdBarItem__FP12PlayerStructi", SN_NOWARN) set_name(0x80060654, "M_StartKill__FiP12PlayerStruct", SN_NOWARN) set_name(0x8006068C, "SetGoldCurs__FP12PlayerStructi", SN_NOWARN) set_name(0x800606C0, "HealStart__FP12PlayerStruct", SN_NOWARN) set_name(0x800606E8, "HealotherStart__FP12PlayerStruct", SN_NOWARN) set_name(0x80060710, "CalculateGold__FP12PlayerStruct", SN_NOWARN) set_name(0x80060738, "M_StartHit__FiP12PlayerStructi", SN_NOWARN) set_name(0x80060780, "TeleStart__FP12PlayerStruct", SN_NOWARN) set_name(0x800607A8, "PhaseStart__FP12PlayerStruct", SN_NOWARN) set_name(0x800607D0, "RemoveInvItem__FP12PlayerStructi", SN_NOWARN) set_name(0x80060804, "InvisStart__FP12PlayerStruct", SN_NOWARN) set_name(0x8006082C, "PhaseEnd__FP12PlayerStruct", SN_NOWARN) set_name(0x80060854, "OperateObject__FP12PlayerStructiUc", SN_NOWARN) set_name(0x80060898, "TryDisarm__FP12PlayerStructi", SN_NOWARN) set_name(0x800608CC, "TalkToTowner__FP12PlayerStructi", SN_NOWARN) set_name(0x80060900, "PosOkPlayer__Fiii", SN_NOWARN) set_name(0x8006094C, "CalcStatDiff__Fi", SN_NOWARN) set_name(0x80060998, "StartNewLvl__Fiii", SN_NOWARN) set_name(0x800609E4, "CreatePlayer__Fic", SN_NOWARN) set_name(0x80060A38, "StartStand__Fii", SN_NOWARN) set_name(0x80060A84, "SetPlayerHitPoints__Fii", SN_NOWARN) set_name(0x80060AD0, "MakePlrPath__FiiiUc", SN_NOWARN) set_name(0x80060B20, "StartWarpLvl__Fii", SN_NOWARN) set_name(0x80060B6C, "SyncPlrKill__Fii", SN_NOWARN) set_name(0x80060BB8, "StartPlrKill__Fii", SN_NOWARN) set_name(0x80060C04, "NewPlrAnim__Fiiii", SN_NOWARN) set_name(0x80060C50, "AddPlrExperience__Fiil", SN_NOWARN) set_name(0x80060C9C, "StartPlrBlock__Fii", SN_NOWARN) set_name(0x80060CE8, "StartPlrHit__FiiUc", SN_NOWARN) set_name(0x80060D38, "StartSpell__Fiiii", SN_NOWARN) set_name(0x80060D84, "InitPlayer__FiUc", SN_NOWARN) set_name(0x80060DD4, "PM_ChangeLightOff__Fi", SN_NOWARN) set_name(0x80060E20, "CheckNewPath__Fi", SN_NOWARN) set_name(0x80060E6C, "FreePlayerGFX__Fi", SN_NOWARN) set_name(0x80060EB8, "InitDungMsgs__Fi", SN_NOWARN) set_name(0x80060F04, "InitPlayerGFX__Fi", SN_NOWARN) set_name(0x80060F50, "SyncInitPlrPos__Fi", SN_NOWARN) set_name(0x80060F9C, "SetPlrAnims__Fi", SN_NOWARN) set_name(0x80060FE8, "ClrPlrPath__Fi", SN_NOWARN) set_name(0x80061034, "SyncInitPlr__Fi", SN_NOWARN) set_name(0x80061080, "RestartTownLvl__Fi", SN_NOWARN) set_name(0x800610CC, "SetPlayerOld__Fi", SN_NOWARN) set_name(0x80061118, "GetGoldSeed__FP12PlayerStructP10ItemStruct", SN_NOWARN) set_name(0x8006114C, "PRIM_GetPrim__FPP8POLY_FT4_addr_8006114C", SN_NOWARN) set_name(0x800611C8, "GetPlayer__7CPlayeri", SN_NOWARN) set_name(0x80061218, "GetLastOtPos__C7CPlayer", SN_NOWARN) set_name(0x80061224, "GetLastScrY__C7CPlayer", SN_NOWARN) set_name(0x80061230, "GetLastScrX__C7CPlayer", SN_NOWARN) set_name(0x8006123C, "TSK_Lava2Water__FP4TASK", SN_NOWARN) set_name(0x8006148C, "CheckQuests__Fv", SN_NOWARN) set_name(0x80061948, "ForceQuests__Fv", SN_NOWARN) set_name(0x80061AEC, "QuestStatus__Fi", SN_NOWARN) set_name(0x80061B80, "CheckQuestKill__FiUc", SN_NOWARN) set_name(0x80062160, "SetReturnLvlPos__Fv", SN_NOWARN) set_name(0x80062270, "GetReturnLvlPos__Fv", SN_NOWARN) set_name(0x800622C4, "ResyncMPQuests__Fv", SN_NOWARN) set_name(0x80062400, "ResyncQuests__Fv", SN_NOWARN) set_name(0x80062960, "PrintQLString__FiiUcPcc", SN_NOWARN) set_name(0x80062B8C, "DrawQuestLog__Fv", SN_NOWARN) set_name(0x80062D40, "DrawQuestLogTSK__FP4TASK", SN_NOWARN) set_name(0x80062DC0, "StartQuestlog__Fv", SN_NOWARN) set_name(0x80062ED0, "QuestlogUp__Fv", SN_NOWARN) set_name(0x80062F28, "QuestlogDown__Fv", SN_NOWARN) set_name(0x80062F90, "RemoveQLog__Fv", SN_NOWARN) set_name(0x80062FFC, "QuestlogEnter__Fv", SN_NOWARN) set_name(0x80063098, "QuestlogESC__Fv", SN_NOWARN) set_name(0x800630C0, "SetMultiQuest__FiiUci", SN_NOWARN) set_name(0x80063140, "_GLOBAL__D_questlog", SN_NOWARN) set_name(0x80063168, "_GLOBAL__I_questlog", SN_NOWARN) set_name(0x80063190, "GetBlockTexDat__7CBlocks", SN_NOWARN) set_name(0x8006319C, "SetRGB__6DialogUcUcUc_addr_8006319C", SN_NOWARN) set_name(0x800631BC, "SetBack__6Dialogi_addr_800631BC", SN_NOWARN) set_name(0x800631C4, "SetBorder__6Dialogi_addr_800631C4", SN_NOWARN) set_name(0x800631CC, "___6Dialog_addr_800631CC", SN_NOWARN) set_name(0x800631F4, "__6Dialog_addr_800631F4", SN_NOWARN) set_name(0x80063250, "GetPal__7TextDati_addr_80063250", SN_NOWARN) set_name(0x8006326C, "GetFr__7TextDati_addr_8006326C", SN_NOWARN) set_name(0x80063288, "DrawView__Fii", SN_NOWARN) set_name(0x80063450, "DrawAndBlit__Fv", SN_NOWARN) set_name(0x80063548, "FreeStoreMem__Fv", SN_NOWARN) set_name(0x80063550, "DrawSTextBack__Fv", SN_NOWARN) set_name(0x800635C0, "PrintSString__FiiUcPcci", SN_NOWARN) set_name(0x80063998, "DrawSLine__Fi", SN_NOWARN) set_name(0x80063A2C, "ClearSText__Fii", SN_NOWARN) set_name(0x80063AC4, "AddSLine__Fi", SN_NOWARN) set_name(0x80063B14, "AddSTextVal__Fii", SN_NOWARN) set_name(0x80063B3C, "AddSText__FiiUcPccUc", SN_NOWARN) set_name(0x80063BF0, "PrintStoreItem__FPC10ItemStructic", SN_NOWARN) set_name(0x80064078, "StoreAutoPlace__Fv", SN_NOWARN) set_name(0x80064698, "S_StartSmith__Fv", SN_NOWARN) set_name(0x80064820, "S_ScrollSBuy__Fi", SN_NOWARN) set_name(0x800649D8, "S_StartSBuy__Fv", SN_NOWARN) set_name(0x80064B08, "S_ScrollSPBuy__Fi", SN_NOWARN) set_name(0x80064D28, "S_StartSPBuy__Fv", SN_NOWARN) set_name(0x80064E78, "SmithSellOk__Fi", SN_NOWARN) set_name(0x80064F5C, "S_ScrollSSell__Fi", SN_NOWARN) set_name(0x80065184, "S_StartSSell__Fv", SN_NOWARN) set_name(0x800655B4, "SmithRepairOk__Fi", SN_NOWARN) set_name(0x80065658, "AddStoreHoldRepair__FP10ItemStructi", SN_NOWARN) set_name(0x80065838, "S_StartSRepair__Fv", SN_NOWARN) set_name(0x80065D08, "S_StartWitch__Fv", SN_NOWARN) set_name(0x80065E48, "S_ScrollWBuy__Fi", SN_NOWARN) set_name(0x80066020, "S_StartWBuy__Fv", SN_NOWARN) set_name(0x8006614C, "WitchSellOk__Fi", SN_NOWARN) set_name(0x80066270, "S_StartWSell__Fv", SN_NOWARN) set_name(0x800668C8, "WitchRechargeOk__Fi", SN_NOWARN) set_name(0x80066950, "AddStoreHoldRecharge__FG10ItemStructi", SN_NOWARN) set_name(0x80066AD0, "S_StartWRecharge__Fv", SN_NOWARN) set_name(0x80066EF0, "S_StartNoMoney__Fv", SN_NOWARN) set_name(0x80066F58, "S_StartNoRoom__Fv", SN_NOWARN) set_name(0x80066FB8, "S_StartConfirm__Fv", SN_NOWARN) set_name(0x80067308, "S_StartBoy__Fv", SN_NOWARN) set_name(0x80067498, "S_StartBBoy__Fv", SN_NOWARN) set_name(0x800675F4, "S_StartHealer__Fv", SN_NOWARN) set_name(0x800677C8, "S_ScrollHBuy__Fi", SN_NOWARN) set_name(0x80067934, "S_StartHBuy__Fv", SN_NOWARN) set_name(0x80067A54, "S_StartStory__Fv", SN_NOWARN) set_name(0x80067B44, "IdItemOk__FP10ItemStruct", SN_NOWARN) set_name(0x80067B78, "AddStoreHoldId__FG10ItemStructi", SN_NOWARN) set_name(0x80067C4C, "S_StartSIdentify__Fv", SN_NOWARN) set_name(0x800686AC, "S_StartIdShow__Fv", SN_NOWARN) set_name(0x80068880, "S_StartTalk__Fv", SN_NOWARN) set_name(0x80068AB0, "S_StartTavern__Fv", SN_NOWARN) set_name(0x80068BA8, "S_StartBarMaid__Fv", SN_NOWARN) set_name(0x80068C7C, "S_StartDrunk__Fv", SN_NOWARN) set_name(0x80068D50, "StartStore__Fc", SN_NOWARN) set_name(0x80069040, "DrawSText__Fv", SN_NOWARN) set_name(0x80069080, "DrawSTextTSK__FP4TASK", SN_NOWARN) set_name(0x80069148, "DoThatDrawSText__Fv", SN_NOWARN) set_name(0x800692F4, "STextESC__Fv", SN_NOWARN) set_name(0x80069470, "STextUp__Fv", SN_NOWARN) set_name(0x800695F8, "STextDown__Fv", SN_NOWARN) set_name(0x80069790, "S_SmithEnter__Fv", SN_NOWARN) set_name(0x80069864, "SetGoldCurs__Fii", SN_NOWARN) set_name(0x800698E0, "SetSpdbarGoldCurs__Fii", SN_NOWARN) set_name(0x8006995C, "TakePlrsMoney__Fl", SN_NOWARN) set_name(0x80069DA8, "SmithBuyItem__Fv", SN_NOWARN) set_name(0x80069F9C, "S_SBuyEnter__Fv", SN_NOWARN) set_name(0x8006A1C0, "SmithBuyPItem__Fv", SN_NOWARN) set_name(0x8006A348, "S_SPBuyEnter__Fv", SN_NOWARN) set_name(0x8006A578, "StoreGoldFit__Fi", SN_NOWARN) set_name(0x8006A830, "PlaceStoreGold__Fl", SN_NOWARN) set_name(0x8006AA94, "StoreSellItem__Fv", SN_NOWARN) set_name(0x8006AD88, "S_SSellEnter__Fv", SN_NOWARN) set_name(0x8006AE8C, "SmithRepairItem__Fv", SN_NOWARN) set_name(0x8006B0FC, "S_SRepairEnter__Fv", SN_NOWARN) set_name(0x8006B258, "S_WitchEnter__Fv", SN_NOWARN) set_name(0x8006B308, "WitchBuyItem__Fv", SN_NOWARN) set_name(0x8006B508, "S_WBuyEnter__Fv", SN_NOWARN) set_name(0x8006B6F4, "S_WSellEnter__Fv", SN_NOWARN) set_name(0x8006B7F8, "WitchRechargeItem__Fv", SN_NOWARN) set_name(0x8006B970, "S_WRechargeEnter__Fv", SN_NOWARN) set_name(0x8006BACC, "S_BoyEnter__Fv", SN_NOWARN) set_name(0x8006BC04, "BoyBuyItem__Fv", SN_NOWARN) set_name(0x8006BC88, "HealerBuyItem__Fv", SN_NOWARN) set_name(0x8006BF2C, "S_BBuyEnter__Fv", SN_NOWARN) set_name(0x8006C104, "StoryIdItem__Fv", SN_NOWARN) set_name(0x8006C450, "S_ConfirmEnter__Fv", SN_NOWARN) set_name(0x8006C56C, "S_HealerEnter__Fv", SN_NOWARN) set_name(0x8006C604, "S_HBuyEnter__Fv", SN_NOWARN) set_name(0x8006C810, "S_StoryEnter__Fv", SN_NOWARN) set_name(0x8006C8A8, "S_SIDEnter__Fv", SN_NOWARN) set_name(0x8006CA24, "S_TalkEnter__Fv", SN_NOWARN) set_name(0x8006CC1C, "S_TavernEnter__Fv", SN_NOWARN) set_name(0x8006CC8C, "S_BarmaidEnter__Fv", SN_NOWARN) set_name(0x8006CCFC, "S_DrunkEnter__Fv", SN_NOWARN) set_name(0x8006CD6C, "STextEnter__Fv", SN_NOWARN) set_name(0x8006CF6C, "CheckStoreBtn__Fv", SN_NOWARN) set_name(0x8006D088, "ReleaseStoreBtn__Fv", SN_NOWARN) set_name(0x8006D09C, "_GLOBAL__D_pSTextBoxCels", SN_NOWARN) set_name(0x8006D0C4, "_GLOBAL__I_pSTextBoxCels", SN_NOWARN) set_name(0x8006D0EC, "GetDown__C4CPad_addr_8006D0EC", SN_NOWARN) set_name(0x8006D114, "SetRGB__6DialogUcUcUc_addr_8006D114", SN_NOWARN) set_name(0x8006D134, "SetBorder__6Dialogi_addr_8006D134", SN_NOWARN) set_name(0x8006D13C, "___6Dialog_addr_8006D13C", SN_NOWARN) set_name(0x8006D164, "__6Dialog_addr_8006D164", SN_NOWARN) set_name(0x8006D1C0, "T_DrawView__Fii", SN_NOWARN) set_name(0x8006D334, "T_FillSector__FPUcT0iiiib", SN_NOWARN) set_name(0x8006D52C, "T_FillTile__FPUciii", SN_NOWARN) set_name(0x8006D61C, "T_Pass3__Fv", SN_NOWARN) set_name(0x8006D9DC, "CreateTown__Fi", SN_NOWARN) set_name(0x8006DB44, "GRL_LoadFileInMemSig__FPCcPUl", SN_NOWARN) set_name(0x8006DC28, "GRL_StripDir__FPcPCc", SN_NOWARN) set_name(0x8006DCC0, "ForceTownTrig__Fv", SN_NOWARN) set_name(0x8006DFD8, "ForceL1Trig__Fv", SN_NOWARN) set_name(0x8006E288, "ForceL2Trig__Fv", SN_NOWARN) set_name(0x8006E6E8, "ForceL3Trig__Fv", SN_NOWARN) set_name(0x8006EB64, "ForceL4Trig__Fv", SN_NOWARN) set_name(0x8006F070, "Freeupstairs__Fv", SN_NOWARN) set_name(0x8006F130, "ForceSKingTrig__Fv", SN_NOWARN) set_name(0x8006F224, "ForceSChambTrig__Fv", SN_NOWARN) set_name(0x8006F318, "ForcePWaterTrig__Fv", SN_NOWARN) set_name(0x8006F40C, "CheckTrigForce__Fv", SN_NOWARN) set_name(0x8006F728, "FadeGameOut__Fv", SN_NOWARN) set_name(0x8006F7C4, "IsTrigger__Fii", SN_NOWARN) set_name(0x8006F828, "CheckTriggers__Fi", SN_NOWARN) set_name(0x8006FD38, "GetManaAmount__Fii", SN_NOWARN) set_name(0x80070000, "UseMana__Fii", SN_NOWARN) set_name(0x80070144, "CheckSpell__FiicUc", SN_NOWARN) set_name(0x800701E4, "CastSpell__Fiiiiiiii", SN_NOWARN) set_name(0x80070490, "DoResurrect__Fii", SN_NOWARN) set_name(0x80070744, "DoHealOther__Fii", SN_NOWARN) set_name(0x800709A8, "snd_update__FUc", SN_NOWARN) set_name(0x800709B0, "snd_get_volume__FPCcPl", SN_NOWARN) set_name(0x80070A18, "snd_stop_snd__FP4TSnd", SN_NOWARN) set_name(0x80070A38, "snd_play_snd__FP4TSFXll", SN_NOWARN) set_name(0x80070AA8, "snd_play_msnd__FUsll", SN_NOWARN) set_name(0x80070B44, "snd_init__FUl", SN_NOWARN) set_name(0x80070BA0, "music_stop__Fv", SN_NOWARN) set_name(0x80070BE4, "music_fade__Fv", SN_NOWARN) set_name(0x80070C24, "music_start__Fi", SN_NOWARN) set_name(0x80070CB0, "music_hold__Fv", SN_NOWARN) set_name(0x80070D10, "music_release__Fv", SN_NOWARN) set_name(0x80070D60, "flyabout__7GamePad", SN_NOWARN) set_name(0x8007121C, "CloseInvChr__Fv", SN_NOWARN) set_name(0x80071264, "WorldToOffset__Fiii", SN_NOWARN) set_name(0x80071310, "pad_UpIsUp__Fi", SN_NOWARN) set_name(0x80071380, "pad_UpIsUpRight__Fi", SN_NOWARN) set_name(0x800713F0, "__7GamePadi", SN_NOWARN) set_name(0x80071520, "SetMoveStyle__7GamePadc", SN_NOWARN) set_name(0x80071560, "SetDownButton__7GamePadiPFi_v", SN_NOWARN) set_name(0x800715A4, "SetComboDownButton__7GamePadiPFi_v", SN_NOWARN) set_name(0x800715E8, "SetAllButtons__7GamePadP11KEY_ASSIGNS", SN_NOWARN) set_name(0x80071858, "GetAllButtons__7GamePadP11KEY_ASSIGNS", SN_NOWARN) set_name(0x80071A18, "GetActionButton__7GamePadPFi_v", SN_NOWARN) set_name(0x80071A74, "SetUpAction__7GamePadPFi_vT1", SN_NOWARN) set_name(0x80071AB0, "RunFunc__7GamePadi", SN_NOWARN) set_name(0x80071B50, "ButtonDown__7GamePadi", SN_NOWARN) set_name(0x80071F24, "TestButtons__7GamePad", SN_NOWARN) set_name(0x80071FF8, "CheckDirs__7GamePadi", SN_NOWARN) set_name(0x80072110, "CheckSide__7GamePadi", SN_NOWARN) set_name(0x80072154, "CheckBodge__7GamePadi", SN_NOWARN) set_name(0x80072458, "walk__7GamePadc", SN_NOWARN) set_name(0x80072764, "check_around_player__7GamePad", SN_NOWARN) set_name(0x80072ABC, "show_combos__7GamePad", SN_NOWARN) set_name(0x80072C70, "Handle__7GamePad", SN_NOWARN) set_name(0x800732D4, "GamePadTask__FP4TASK", SN_NOWARN) set_name(0x800734D8, "PostGamePad__Fiiii", SN_NOWARN) set_name(0x80073588, "Init_GamePad__Fv", SN_NOWARN) set_name(0x800735B8, "InitGamePadVars__Fv", SN_NOWARN) set_name(0x80073648, "SetWalkStyle__Fii", SN_NOWARN) set_name(0x800736B8, "MoveToScrollTarget__7CBlocks_addr_800736B8", SN_NOWARN) set_name(0x800736CC, "GetDown__C4CPad_addr_800736CC", SN_NOWARN) set_name(0x800736F4, "GetUp__C4CPad_addr_800736F4", SN_NOWARN) set_name(0x8007371C, "GetCur__C4CPad_addr_8007371C", SN_NOWARN) set_name(0x80073744, "DoGameTestStuff__Fv", SN_NOWARN) set_name(0x80073770, "DoInitGameStuff__Fv", SN_NOWARN) set_name(0x800737A4, "SMemAlloc", SN_NOWARN) set_name(0x800737C4, "SMemFree", SN_NOWARN) set_name(0x800737E4, "GRL_InitGwin__Fv", SN_NOWARN) set_name(0x800737F0, "GRL_SetWindowProc__FPFUlUilUl_Ul", SN_NOWARN) set_name(0x80073800, "GRL_CallWindowProc__FUlUilUl", SN_NOWARN) set_name(0x80073828, "GRL_PostMessage__FUlUilUl", SN_NOWARN) set_name(0x800738D4, "Msg2Txt__Fi", SN_NOWARN) set_name(0x8007391C, "LANG_GetLang__Fv", SN_NOWARN) set_name(0x80073928, "LANG_SetDb__F10LANG_DB_NO", SN_NOWARN) set_name(0x80073AA8, "GetStr__Fi", SN_NOWARN) set_name(0x80073B10, "LANG_SetLang__F9LANG_TYPE", SN_NOWARN) set_name(0x80073C88, "DumpCurrentText__Fv", SN_NOWARN) set_name(0x80073CE0, "CalcNumOfStrings__FPPc", SN_NOWARN) set_name(0x80073CEC, "GetLangFileName__F9LANG_TYPEPc", SN_NOWARN) set_name(0x80073E0C, "GetLangFileNameExt__F9LANG_TYPE", SN_NOWARN) set_name(0x80073E8C, "TempPrintMissile__FiiiiiiiiccUcUcUcc", SN_NOWARN) set_name(0x800743D0, "FuncTOWN__FP13MissileStructiii", SN_NOWARN) set_name(0x80074550, "FuncRPORTAL__FP13MissileStructiii", SN_NOWARN) set_name(0x800746B0, "FuncFIREBOLT__FP13MissileStructiii", SN_NOWARN) set_name(0x80074748, "FuncHBOLT__FP13MissileStructiii", SN_NOWARN) set_name(0x800747F8, "FuncLIGHTNING__FP13MissileStructiii", SN_NOWARN) set_name(0x8007485C, "FuncGUARDIAN__FP13MissileStructiii", SN_NOWARN) set_name(0x80074974, "FuncFIREWALL__FP13MissileStructiii", SN_NOWARN) set_name(0x80074A0C, "FuncFIREMOVE__FP13MissileStructiii", SN_NOWARN) set_name(0x80074AA4, "FuncFLAME__FP13MissileStructiii", SN_NOWARN) set_name(0x80074B0C, "FuncARROW__FP13MissileStructiii", SN_NOWARN) set_name(0x80074BAC, "FuncFARROW__FP13MissileStructiii", SN_NOWARN) set_name(0x80074C8C, "FuncLARROW__FP13MissileStructiii", SN_NOWARN) set_name(0x80074D64, "FuncMAGMABALL__FP13MissileStructiii", SN_NOWARN) set_name(0x80074DF4, "FuncBONESPIRIT__FP13MissileStructiii", SN_NOWARN) set_name(0x80074F10, "FuncACID__FP13MissileStructiii", SN_NOWARN) set_name(0x80074FAC, "FuncACIDSPLAT__FP13MissileStructiii", SN_NOWARN) set_name(0x80075014, "FuncACIDPUD__FP13MissileStructiii", SN_NOWARN) set_name(0x8007507C, "FuncFLARE__FP13MissileStructiii", SN_NOWARN) set_name(0x800751B0, "FuncFLAREXP__FP13MissileStructiii", SN_NOWARN) set_name(0x800752F4, "FuncCBOLT__FP13MissileStructiii", SN_NOWARN) set_name(0x8007535C, "FuncBOOM__FP13MissileStructiii", SN_NOWARN) set_name(0x800753B4, "FuncELEMENT__FP13MissileStructiii", SN_NOWARN) set_name(0x80075480, "FuncMISEXP__FP13MissileStructiii", SN_NOWARN) set_name(0x800754E4, "FuncRHINO__FP13MissileStructiii", SN_NOWARN) set_name(0x800754EC, "FuncFLASH__FP13MissileStructiii", SN_NOWARN) set_name(0x80075A14, "FuncMANASHIELD__FP13MissileStructiii", SN_NOWARN) set_name(0x80075ABC, "FuncFLASH2__FP13MissileStructiii", SN_NOWARN) set_name(0x80075AC4, "FuncRESURRECTBEAM__FP13MissileStructiii", SN_NOWARN) set_name(0x80075AF8, "PRIM_GetPrim__FPP8POLY_FT4_addr_80075AF8", SN_NOWARN) set_name(0x80075B74, "GetPlayer__7CPlayeri_addr_80075B74", SN_NOWARN) set_name(0x80075BC4, "GetLastOtPos__C7CPlayer_addr_80075BC4", SN_NOWARN) set_name(0x80075BD0, "GetLastScrY__C7CPlayer_addr_80075BD0", SN_NOWARN) set_name(0x80075BDC, "GetLastScrX__C7CPlayer_addr_80075BDC", SN_NOWARN) set_name(0x80075BE8, "GetNumOfFrames__7TextDat_addr_80075BE8", SN_NOWARN) set_name(0x80075BFC, "GetFr__7TextDati_addr_80075BFC", SN_NOWARN) set_name(0x80075C18, "ML_Init__Fv", SN_NOWARN) set_name(0x80075C50, "ML_GetList__Fi", SN_NOWARN) set_name(0x80075CD0, "ML_SetRandomList__Fi", SN_NOWARN) set_name(0x80075D68, "ML_SetList__Fii", SN_NOWARN) set_name(0x80075E18, "ML_GetPresetMonsters__FiPiUl", SN_NOWARN) set_name(0x80075FD4, "DefaultObjPrint__FP12ObjectStructiiP7TextDatiii", SN_NOWARN) set_name(0x80076168, "LightObjPrint__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076220, "DoorObjPrint__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800764B4, "DrawLightSpark__Fiii", SN_NOWARN) set_name(0x8007658C, "PrintOBJ_L1LIGHT__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076614, "PrintOBJ_SKFIRE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076640, "PrintOBJ_LEVER__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007666C, "PrintOBJ_CHEST1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076698, "PrintOBJ_CHEST2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800766C4, "PrintOBJ_CHEST3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800766F0, "PrintOBJ_CANDLE1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076714, "PrintOBJ_CANDLE2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076738, "PrintOBJ_CANDLEO__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076764, "PrintOBJ_BANNERL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076790, "PrintOBJ_BANNERM__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800767BC, "PrintOBJ_BANNERR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800767E8, "PrintOBJ_SKPILE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076814, "PrintOBJ_SKSTICK1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076840, "PrintOBJ_SKSTICK2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007686C, "PrintOBJ_SKSTICK3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076898, "PrintOBJ_SKSTICK4__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800768C4, "PrintOBJ_SKSTICK5__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800768F0, "PrintOBJ_CRUX1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007691C, "PrintOBJ_CRUX2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076948, "PrintOBJ_CRUX3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076974, "PrintOBJ_STAND__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800769A0, "PrintOBJ_ANGEL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800769CC, "PrintOBJ_BOOK2L__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800769F8, "PrintOBJ_BCROSS__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076A24, "PrintOBJ_NUDEW2R__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076A50, "PrintOBJ_SWITCHSKL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076A7C, "PrintOBJ_TNUDEM1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076AA8, "PrintOBJ_TNUDEM2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076AD4, "PrintOBJ_TNUDEM3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076B00, "PrintOBJ_TNUDEM4__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076B2C, "PrintOBJ_TNUDEW1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076B58, "PrintOBJ_TNUDEW2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076B84, "PrintOBJ_TNUDEW3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076BB0, "PrintOBJ_TORTURE1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076BDC, "PrintOBJ_TORTURE2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076C08, "PrintOBJ_TORTURE3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076C34, "PrintOBJ_TORTURE4__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076C60, "PrintOBJ_TORTURE5__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076C8C, "PrintOBJ_BOOK2R__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076CB8, "PrintTorchStick__Fiiii", SN_NOWARN) set_name(0x80076D4C, "PrintOBJ_TORCHL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076DDC, "PrintOBJ_TORCHR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076E6C, "PrintOBJ_TORCHL2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076EFC, "PrintOBJ_TORCHR2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076F8C, "PrintOBJ_SARC__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076FB8, "PrintOBJ_FLAMEHOLE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80076FE4, "PrintOBJ_FLAMELVR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077010, "PrintOBJ_WATER__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007703C, "PrintOBJ_BOOKLVR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077068, "PrintOBJ_TRAPL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077094, "PrintOBJ_TRAPR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800770C0, "PrintOBJ_BOOKSHELF__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800770EC, "PrintOBJ_WEAPRACK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077118, "PrintOBJ_BARREL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077144, "PrintOBJ_BARRELEX__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007729C, "PrintOBJ_SHRINEL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077368, "PrintOBJ_SHRINER__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077434, "PrintOBJ_SKELBOOK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077460, "PrintOBJ_BOOKCASEL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007748C, "PrintOBJ_BOOKCASER__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800774B8, "PrintOBJ_BOOKSTAND__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800774E4, "PrintOBJ_BOOKCANDLE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077508, "PrintOBJ_BLOODFTN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077534, "PrintOBJ_DECAP__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077560, "PrintOBJ_TCHEST1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007758C, "PrintOBJ_TCHEST2__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800775B8, "PrintOBJ_TCHEST3__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800775E4, "PrintOBJ_BLINDBOOK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077610, "PrintOBJ_BLOODBOOK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007763C, "PrintOBJ_PEDISTAL__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077668, "PrintOBJ_PURIFYINGFTN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077694, "PrintOBJ_ARMORSTAND__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800776C0, "PrintOBJ_ARMORSTANDN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800776EC, "PrintOBJ_GOATSHRINE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077718, "PrintOBJ_CAULDRON__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077744, "PrintOBJ_MURKYFTN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077770, "PrintOBJ_TEARFTN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007779C, "PrintOBJ_ALTBOY__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x800777C8, "PrintOBJ_MCIRCLE1__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x8007795C, "PrintOBJ_STORYBOOK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077AE4, "PrintOBJ_STORYCANDLE__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077B08, "PrintOBJ_STEELTOME__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077B34, "PrintOBJ_WARARMOR__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077B60, "PrintOBJ_WARWEAP__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077B8C, "PrintOBJ_TBCROSS__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077BB8, "PrintOBJ_WEAPONRACK__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077BE4, "PrintOBJ_WEAPONRACKN__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077C10, "PrintOBJ_MUSHPATCH__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077C3C, "PrintOBJ_LAZSTAND__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077C68, "PrintOBJ_SLAINHERO__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077C94, "PrintOBJ_SIGNCHEST__FP12ObjectStructiiP7TextDati", SN_NOWARN) set_name(0x80077CC0, "PRIM_GetCopy__FP8POLY_FT4_addr_80077CC0", SN_NOWARN) set_name(0x80077CFC, "PRIM_CopyPrim__FP8POLY_FT4T0_addr_80077CFC", SN_NOWARN) set_name(0x80077D24, "PRIM_GetPrim__FPP8POLY_FT4_addr_80077D24", SN_NOWARN) set_name(0x80077DA0, "GetBlockTexDat__7CBlocks_addr_80077DA0", SN_NOWARN) set_name(0x80077DAC, "GetNumOfFrames__7TextDatii_addr_80077DAC", SN_NOWARN) set_name(0x80077DE4, "GetCreature__7TextDati_addr_80077DE4", SN_NOWARN) set_name(0x80077E5C, "GetNumOfCreatures__7TextDat_addr_80077E5C", SN_NOWARN) set_name(0x80077E70, "GetFr__7TextDati_addr_80077E70", SN_NOWARN) set_name(0x80077E8C, "gamemenu_on__Fv", SN_NOWARN) set_name(0x80077E94, "gamemenu_off__Fv", SN_NOWARN) set_name(0x80077E9C, "LoadPalette__FPCc", SN_NOWARN) set_name(0x80077EA4, "LoadRndLvlPal__Fi", SN_NOWARN) set_name(0x80077EAC, "ResetPal__Fv", SN_NOWARN) set_name(0x80077EB4, "SetFadeLevel__Fi", SN_NOWARN) set_name(0x80077EE4, "GetFadeState__Fv", SN_NOWARN) set_name(0x80077EF0, "SetPolyXY__FP8POLY_GT4PUc", SN_NOWARN) set_name(0x80077FF4, "SmearScreen__Fv", SN_NOWARN) set_name(0x80077FFC, "DrawFadedScreen__Fv", SN_NOWARN) set_name(0x80078050, "BlackPalette__Fv", SN_NOWARN) set_name(0x8007810C, "PaletteFadeInTask__FP4TASK", SN_NOWARN) set_name(0x8007819C, "PaletteFadeIn__Fi", SN_NOWARN) set_name(0x800781F4, "PaletteFadeOutTask__FP4TASK", SN_NOWARN) set_name(0x800782A4, "PaletteFadeOut__Fi", SN_NOWARN) set_name(0x800782F8, "M_CheckEFlag__Fi", SN_NOWARN) set_name(0x80078318, "M_ClearSquares__Fi", SN_NOWARN) set_name(0x80078484, "IsSkel__Fi", SN_NOWARN) set_name(0x800784C0, "NewMonsterAnim__FiR10AnimStructii", SN_NOWARN) set_name(0x8007850C, "M_Ranged__Fi", SN_NOWARN) set_name(0x80078554, "M_Talker__Fi", SN_NOWARN) set_name(0x800785B4, "M_Enemy__Fi", SN_NOWARN) set_name(0x80078B48, "ClearMVars__Fi", SN_NOWARN) set_name(0x80078BBC, "InitMonster__Fiiiii", SN_NOWARN) set_name(0x80079008, "AddMonster__FiiiiUc", SN_NOWARN) set_name(0x800790B8, "M_StartStand__Fii", SN_NOWARN) set_name(0x800791FC, "M_UpdateLeader__Fi", SN_NOWARN) set_name(0x800792F4, "ActivateSpawn__Fiiii", SN_NOWARN) set_name(0x8007939C, "SpawnSkeleton__Fiii", SN_NOWARN) set_name(0x8007958C, "M_StartSpStand__Fii", SN_NOWARN) set_name(0x8007966C, "PosOkMonst__Fiii", SN_NOWARN) set_name(0x800798E8, "CanPut__Fii", SN_NOWARN) set_name(0x80079BF0, "GetAutomapType__FiiUc", SN_NOWARN) set_name(0x80079EEC, "SetAutomapView__Fii", SN_NOWARN) set_name(0x8007A33C, "lAddMissile__Fiiici", SN_NOWARN) set_name(0x8007A510, "AddWarpMissile__Fiii", SN_NOWARN) set_name(0x8007A658, "SyncPortals__Fv", SN_NOWARN) set_name(0x8007A760, "AddInTownPortal__Fi", SN_NOWARN) set_name(0x8007A798, "ActivatePortal__FiiiiiUc", SN_NOWARN) set_name(0x8007A808, "DeactivatePortal__Fi", SN_NOWARN) set_name(0x8007A828, "PortalOnLevel__Fi", SN_NOWARN) set_name(0x8007A860, "DelMis__Fii", SN_NOWARN) set_name(0x8007A8C0, "RemovePortalMissile__Fi", SN_NOWARN) set_name(0x8007AA3C, "SetCurrentPortal__Fi", SN_NOWARN) set_name(0x8007AA48, "GetPortalLevel__Fv", SN_NOWARN) set_name(0x8007ABEC, "GetPortalLvlPos__Fv", SN_NOWARN) set_name(0x8007AC9C, "__13CompLevelMaps", SN_NOWARN) set_name(0x8007ACC8, "___13CompLevelMaps", SN_NOWARN) set_name(0x8007ACF0, "Init__13CompLevelMaps", SN_NOWARN) set_name(0x8007AD20, "Dump__13CompLevelMaps", SN_NOWARN) set_name(0x8007ADC4, "DumpMap__13CompLevelMapsi", SN_NOWARN) set_name(0x8007AE2C, "UseMap__13CompLevelMapsi", SN_NOWARN) set_name(0x8007AF00, "ReleaseMap__13CompLevelMapsP6DLevel", SN_NOWARN) set_name(0x8007AF70, "IsMapCached__13CompLevelMapsi", SN_NOWARN) set_name(0x8007AFE4, "WriteBackCachedMap__13CompLevelMaps", SN_NOWARN) set_name(0x8007B1F8, "DecompToCached__13CompLevelMapsi", SN_NOWARN) set_name(0x8007B398, "BuildCompLevelImage__13CompLevelMapsP17CompLevelMemImage", SN_NOWARN) set_name(0x8007B4F8, "InitFromCompLevelImage__13CompLevelMapsP17CompLevelMemImage", SN_NOWARN) set_name(0x8007B638, "DoComp__13CompLevelMapsPUcT1i", SN_NOWARN) set_name(0x8007B670, "DoDecomp__13CompLevelMapsPUcT1ii", SN_NOWARN) set_name(0x8007B6A8, "GO_DoGameOver__Fv", SN_NOWARN) set_name(0x8007B6EC, "GameOverTask__FP4TASK", SN_NOWARN) set_name(0x8007B7A8, "PrintGameOver__Fv", SN_NOWARN) set_name(0x8007B884, "SetRGB__6DialogUcUcUc_addr_8007B884", SN_NOWARN) set_name(0x8007B8A4, "SetBack__6Dialogi_addr_8007B8A4", SN_NOWARN) set_name(0x8007B8AC, "SetBorder__6Dialogi_addr_8007B8AC", SN_NOWARN) set_name(0x8007B8B4, "___6Dialog_addr_8007B8B4", SN_NOWARN) set_name(0x8007B8DC, "__6Dialog_addr_8007B8DC", SN_NOWARN) set_name(0x8007B938, "VER_InitVersion__Fv", SN_NOWARN) set_name(0x8007B97C, "VER_GetVerString__Fv", SN_NOWARN) set_name(0x8007B98C, "CharPair2Num__FPc", SN_NOWARN) set_name(0x8001E698, "TICK_InitModule", SN_NOWARN) set_name(0x8001E6B8, "TICK_Set", SN_NOWARN) set_name(0x8001E6C8, "TICK_Get", SN_NOWARN) set_name(0x8001E6D8, "TICK_Update", SN_NOWARN) set_name(0x8001E6F8, "TICK_GetAge", SN_NOWARN) set_name(0x8001E724, "TICK_GetDateString", SN_NOWARN) set_name(0x8001E734, "TICK_GetTimeString", SN_NOWARN) set_name(0x8001E744, "GU_InitModule", SN_NOWARN) set_name(0x8001E770, "GU_SetRndSeed", SN_NOWARN) set_name(0x8001E7A0, "GU_GetRnd", SN_NOWARN) set_name(0x8001E830, "GU_GetSRnd", SN_NOWARN) set_name(0x8001E850, "GU_GetRndRange", SN_NOWARN) set_name(0x8001E88C, "GU_AlignVal", SN_NOWARN) set_name(0x8001E8B0, "main", SN_NOWARN) set_name(0x8001E900, "DBG_OpenModule", SN_NOWARN) set_name(0x8001E908, "DBG_PollHost", SN_NOWARN) set_name(0x8001E910, "DBG_Halt", SN_NOWARN) set_name(0x8001E918, "DBG_SendMessage", SN_NOWARN) set_name(0x8001E930, "DBG_SetMessageHandler", SN_NOWARN) set_name(0x8001E940, "DBG_Error", SN_NOWARN) set_name(0x8001E96C, "DBG_SetErrorFunc", SN_NOWARN) set_name(0x8001E97C, "SendPsyqString", SN_NOWARN) set_name(0x8001E984, "DBG_SetPollRoutine", SN_NOWARN) set_name(0x8001E994, "GTIMSYS_GetTimer", SN_NOWARN) set_name(0x8001E9B8, "GTIMSYS_ResetTimer", SN_NOWARN) set_name(0x8001E9DC, "GTIMSYS_InitTimer", SN_NOWARN) set_name(0x8001EC10, "DoEpi", SN_NOWARN) set_name(0x8001EC60, "DoPro", SN_NOWARN) set_name(0x8001ECB0, "TSK_OpenModule", SN_NOWARN) set_name(0x8001ED24, "TSK_AddTask", SN_NOWARN) set_name(0x8001EF0C, "TSK_DoTasks", SN_NOWARN) set_name(0x8001F0CC, "TSK_Sleep", SN_NOWARN) set_name(0x8001F1A8, "ReturnToSchedulerIfCurrentTask", SN_NOWARN) set_name(0x8001F230, "TSK_Die", SN_NOWARN) set_name(0x8001F25C, "TSK_Kill", SN_NOWARN) set_name(0x8001F2AC, "TSK_GetFirstActive", SN_NOWARN) set_name(0x8001F2BC, "TSK_IsStackCorrupted", SN_NOWARN) set_name(0x8001F338, "TSK_JumpAndResetStack", SN_NOWARN) set_name(0x8001F380, "TSK_RepointProc", SN_NOWARN) set_name(0x8001F3C4, "TSK_GetCurrentTask", SN_NOWARN) set_name(0x8001F3D4, "TSK_IsCurrentTask", SN_NOWARN) set_name(0x8001F3EC, "TSK_Exist", SN_NOWARN) set_name(0x8001F444, "TSK_SetExecFilter", SN_NOWARN) set_name(0x8001F45C, "TSK_ClearExecFilter", SN_NOWARN) set_name(0x8001F480, "TSK_KillTasks", SN_NOWARN) set_name(0x8001F580, "TSK_IterateTasks", SN_NOWARN) set_name(0x8001F5F8, "TSK_MakeTaskInactive", SN_NOWARN) set_name(0x8001F60C, "TSK_MakeTaskActive", SN_NOWARN) set_name(0x8001F620, "TSK_MakeTaskImmortal", SN_NOWARN) set_name(0x8001F634, "TSK_MakeTaskMortal", SN_NOWARN) set_name(0x8001F648, "TSK_IsTaskActive", SN_NOWARN) set_name(0x8001F65C, "TSK_IsTaskMortal", SN_NOWARN) set_name(0x8001F670, "DetachFromList", SN_NOWARN) set_name(0x8001F6BC, "AddToList", SN_NOWARN) set_name(0x8001F6DC, "LoTskKill", SN_NOWARN) set_name(0x8001F74C, "ExecuteTask", SN_NOWARN) set_name(0x8001F79C, "TSK_SetDoTasksPrologue", SN_NOWARN) set_name(0x8001F7B4, "TSK_SetDoTasksEpilogue", SN_NOWARN) set_name(0x8001F7CC, "TSK_SetTaskPrologue", SN_NOWARN) set_name(0x8001F7E4, "TSK_SetTaskEpilogue", SN_NOWARN) set_name(0x8001F7FC, "TSK_SetEpiProFilter", SN_NOWARN) set_name(0x8001F814, "TSK_ClearEpiProFilter", SN_NOWARN) set_name(0x8001F848, "TSK_SetExtraStackProtection", SN_NOWARN) set_name(0x8001F858, "TSK_SetStackFloodCallback", SN_NOWARN) set_name(0x8001F870, "TSK_SetExtraStackSize", SN_NOWARN) set_name(0x8001F898, "ExtraMarkStack", SN_NOWARN) set_name(0x8001F8C4, "CheckExtraStack", SN_NOWARN) set_name(0x8001F900, "GSYS_GetWorkMemInfo", SN_NOWARN) set_name(0x8001F910, "GSYS_SetStackAndJump", SN_NOWARN) set_name(0x8001F94C, "GSYS_MarkStack", SN_NOWARN) set_name(0x8001F95C, "GSYS_IsStackCorrupted", SN_NOWARN) set_name(0x8001F974, "GSYS_InitMachine", SN_NOWARN) set_name(0x8001F9C8, "GSYS_CheckPtr", SN_NOWARN) set_name(0x8001F9FC, "GSYS_IsStackOutOfBounds", SN_NOWARN) set_name(0x8001FA78, "GAL_SetErrorChecking", SN_NOWARN) set_name(0x8001FA88, "GAL_SplitBlock", SN_NOWARN) set_name(0x8001FBBC, "GAL_InitModule", SN_NOWARN) set_name(0x8001FC74, "GAL_AddMemType", SN_NOWARN) set_name(0x8001FD94, "GAL_Alloc", SN_NOWARN) set_name(0x8001FF2C, "GAL_Lock", SN_NOWARN) set_name(0x8001FF8C, "GAL_Unlock", SN_NOWARN) set_name(0x80020008, "GAL_Free", SN_NOWARN) set_name(0x800200A8, "GAL_GetFreeMem", SN_NOWARN) set_name(0x8002011C, "GAL_GetUsedMem", SN_NOWARN) set_name(0x80020190, "GAL_LargestFreeBlock", SN_NOWARN) set_name(0x8002020C, "AttachHdrToList", SN_NOWARN) set_name(0x8002022C, "DetachHdrFromList", SN_NOWARN) set_name(0x80020278, "IsActiveValidHandle", SN_NOWARN) set_name(0x800202A8, "AlignPtr", SN_NOWARN) set_name(0x800202D8, "AlignSize", SN_NOWARN) set_name(0x80020308, "FindClosestSizedBlock", SN_NOWARN) set_name(0x80020360, "FindHighestMemBlock", SN_NOWARN) set_name(0x800203C8, "FindLowestMemBlock", SN_NOWARN) set_name(0x80020430, "GetMemInitInfoBlockFromType", SN_NOWARN) set_name(0x8002046C, "MergeToEmptyList", SN_NOWARN) set_name(0x80020540, "GAL_AllocAt", SN_NOWARN) set_name(0x8002061C, "LoAlloc", SN_NOWARN) set_name(0x800207B4, "FindBlockInTheseBounds", SN_NOWARN) set_name(0x80020820, "GetFreeMemHdrBlock", SN_NOWARN) set_name(0x800208A8, "ReleaseMemHdrBlock", SN_NOWARN) set_name(0x800208E8, "GAL_IterateEmptyMem", SN_NOWARN) set_name(0x8002096C, "GAL_IterateUsedMem", SN_NOWARN) set_name(0x80020A08, "GAL_SetMemName", SN_NOWARN) set_name(0x80020A70, "GAL_TotalMem", SN_NOWARN) set_name(0x80020AC4, "GAL_MemBase", SN_NOWARN) set_name(0x80020B18, "GAL_DefragMem", SN_NOWARN) set_name(0x80020B9C, "GSetError", SN_NOWARN) set_name(0x80020BF8, "GAL_CheckMem", SN_NOWARN) set_name(0x80020CF4, "CheckCollisions", SN_NOWARN) set_name(0x80020DA0, "AreBlocksColliding", SN_NOWARN) set_name(0x80020DF8, "GAL_GetErrorText", SN_NOWARN) set_name(0x80020E28, "GAL_GetLastErrorCode", SN_NOWARN) set_name(0x80020E38, "GAL_GetLastErrorText", SN_NOWARN) set_name(0x80020E60, "GAL_HowManyEmptyRegions", SN_NOWARN) set_name(0x80020EC8, "GAL_HowManyUsedRegions", SN_NOWARN) set_name(0x80020F30, "GAL_SetTimeStamp", SN_NOWARN) set_name(0x80020F40, "GAL_IncTimeStamp", SN_NOWARN) set_name(0x80020F60, "GAL_GetTimeStamp", SN_NOWARN) set_name(0x80020F70, "GAL_AlignSizeToType", SN_NOWARN) set_name(0x80020FC0, "GAL_AllocMultiStruct", SN_NOWARN) set_name(0x80021010, "GAL_ProcessMultiStruct", SN_NOWARN) set_name(0x800210BC, "GAL_GetSize", SN_NOWARN) set_name(0x80021110, "GazDefragMem", SN_NOWARN) set_name(0x80021278, "PutBlocksInRegionIntoList", SN_NOWARN) set_name(0x8002131C, "CollideRegions", SN_NOWARN) set_name(0x80021350, "DeleteEmptyBlocks", SN_NOWARN) set_name(0x800213BC, "GetRegion", SN_NOWARN) set_name(0x800214B4, "FindNextBlock", SN_NOWARN) set_name(0x800214F0, "ShuffleBlocks", SN_NOWARN) set_name(0x80021580, "PutAllLockedBlocksOntoList", SN_NOWARN) set_name(0x800215FC, "SortMemHdrListByAddr", SN_NOWARN) set_name(0x800216B0, "GraftMemHdrList", SN_NOWARN) set_name(0x8002170C, "GAL_MemDump", SN_NOWARN) set_name(0x80021780, "GAL_SetVerbosity", SN_NOWARN) set_name(0x80021790, "CountFreeBlocks", SN_NOWARN) set_name(0x800217BC, "SetBlockName", SN_NOWARN) set_name(0x80021804, "GAL_GetNumFreeHeaders", SN_NOWARN) set_name(0x80021814, "GAL_GetLastTypeAlloced", SN_NOWARN) set_name(0x80021824, "GAL_SetAllocFilter", SN_NOWARN) set_name(0x8002183C, "GAL_SortUsedRegionsBySize", SN_NOWARN) set_name(0x80021890, "SortSize", SN_NOWARN) set_name(0x800218A0, "SortMemHdrList", SN_NOWARN) set_name(0x80023C5C, "vsprintf", SN_NOWARN) set_name(0x80023CA8, "_doprnt", SN_NOWARN) set_name(0x8012AC14, "NumOfMonsterListLevels", SN_NOWARN) set_name(0x800A7A78, "AllLevels", SN_NOWARN) set_name(0x8012A904, "NumsLEV1M1A", SN_NOWARN) set_name(0x8012A908, "NumsLEV1M1B", SN_NOWARN) set_name(0x8012A90C, "NumsLEV1M1C", SN_NOWARN) set_name(0x8012A914, "NumsLEV2M2A", SN_NOWARN) set_name(0x8012A918, "NumsLEV2M2B", SN_NOWARN) set_name(0x8012A91C, "NumsLEV2M2C", SN_NOWARN) set_name(0x8012A920, "NumsLEV2M2D", SN_NOWARN) set_name(0x8012A924, "NumsLEV2M2QA", SN_NOWARN) set_name(0x8012A928, "NumsLEV2M2QB", SN_NOWARN) set_name(0x8012A92C, "NumsLEV3M3A", SN_NOWARN) set_name(0x8012A930, "NumsLEV3M3QA", SN_NOWARN) set_name(0x8012A934, "NumsLEV3M3B", SN_NOWARN) set_name(0x8012A938, "NumsLEV3M3C", SN_NOWARN) set_name(0x8012A93C, "NumsLEV4M4A", SN_NOWARN) set_name(0x8012A940, "NumsLEV4M4QA", SN_NOWARN) set_name(0x8012A944, "NumsLEV4M4B", SN_NOWARN) set_name(0x8012A948, "NumsLEV4M4QB", SN_NOWARN) set_name(0x8012A950, "NumsLEV4M4C", SN_NOWARN) set_name(0x8012A954, "NumsLEV4M4QC", SN_NOWARN) set_name(0x8012A95C, "NumsLEV4M4D", SN_NOWARN) set_name(0x8012A960, "NumsLEV5M5A", SN_NOWARN) set_name(0x8012A964, "NumsLEV5M5B", SN_NOWARN) set_name(0x8012A968, "NumsLEV5M5C", SN_NOWARN) set_name(0x8012A96C, "NumsLEV5M5D", SN_NOWARN) set_name(0x8012A970, "NumsLEV5M5E", SN_NOWARN) set_name(0x8012A974, "NumsLEV5M5F", SN_NOWARN) set_name(0x8012A978, "NumsLEV5M5QA", SN_NOWARN) set_name(0x8012A97C, "NumsLEV6M6A", SN_NOWARN) set_name(0x8012A984, "NumsLEV6M6B", SN_NOWARN) set_name(0x8012A988, "NumsLEV6M6C", SN_NOWARN) set_name(0x8012A98C, "NumsLEV6M6D", SN_NOWARN) set_name(0x8012A990, "NumsLEV6M6E", SN_NOWARN) set_name(0x8012A994, "NumsLEV6M6QA", SN_NOWARN) set_name(0x8012A998, "NumsLEV7M7A", SN_NOWARN) set_name(0x8012A99C, "NumsLEV7M7B", SN_NOWARN) set_name(0x8012A9A0, "NumsLEV7M7C", SN_NOWARN) set_name(0x8012A9A4, "NumsLEV7M7D", SN_NOWARN) set_name(0x8012A9A8, "NumsLEV7M7E", SN_NOWARN) set_name(0x8012A9AC, "NumsLEV8M8QA", SN_NOWARN) set_name(0x8012A9B0, "NumsLEV8M8A", SN_NOWARN) set_name(0x8012A9B4, "NumsLEV8M8B", SN_NOWARN) set_name(0x8012A9B8, "NumsLEV8M8C", SN_NOWARN) set_name(0x8012A9BC, "NumsLEV8M8D", SN_NOWARN) set_name(0x8012A9C0, "NumsLEV8M8E", SN_NOWARN) set_name(0x8012A9C4, "NumsLEV9M9A", SN_NOWARN) set_name(0x8012A9C8, "NumsLEV9M9B", SN_NOWARN) set_name(0x8012A9CC, "NumsLEV9M9C", SN_NOWARN) set_name(0x8012A9D0, "NumsLEV9M9D", SN_NOWARN) set_name(0x8012A9D4, "NumsLEV10M10A", SN_NOWARN) set_name(0x8012A9D8, "NumsLEV10M10B", SN_NOWARN) set_name(0x8012A9DC, "NumsLEV10M10C", SN_NOWARN) set_name(0x8012A9E0, "NumsLEV10M10D", SN_NOWARN) set_name(0x8012A9E4, "NumsLEV10M10QA", SN_NOWARN) set_name(0x8012A9E8, "NumsLEV11M11A", SN_NOWARN) set_name(0x8012A9EC, "NumsLEV11M11B", SN_NOWARN) set_name(0x8012A9F0, "NumsLEV11M11C", SN_NOWARN) set_name(0x8012A9F4, "NumsLEV11M11D", SN_NOWARN) set_name(0x8012A9F8, "NumsLEV11M11E", SN_NOWARN) set_name(0x8012A9FC, "NumsLEV12M12A", SN_NOWARN) set_name(0x8012AA00, "NumsLEV12M12B", SN_NOWARN) set_name(0x8012AA04, "NumsLEV12M12C", SN_NOWARN) set_name(0x8012AA08, "NumsLEV12M12D", SN_NOWARN) set_name(0x8012AA0C, "NumsLEV13M13A", SN_NOWARN) set_name(0x8012AA10, "NumsLEV13M13B", SN_NOWARN) set_name(0x8012AA14, "NumsLEV13M13QB", SN_NOWARN) set_name(0x8012AA18, "NumsLEV13M13C", SN_NOWARN) set_name(0x8012AA1C, "NumsLEV13M13D", SN_NOWARN) set_name(0x8012AA20, "NumsLEV14M14A", SN_NOWARN) set_name(0x8012AA24, "NumsLEV14M14B", SN_NOWARN) set_name(0x8012AA28, "NumsLEV14M14QB", SN_NOWARN) set_name(0x8012AA2C, "NumsLEV14M14C", SN_NOWARN) set_name(0x8012AA30, "NumsLEV14M14D", SN_NOWARN) set_name(0x8012AA34, "NumsLEV14M14E", SN_NOWARN) set_name(0x8012AA38, "NumsLEV15M15A", SN_NOWARN) set_name(0x8012AA3C, "NumsLEV15M15B", SN_NOWARN) set_name(0x8012AA40, "NumsLEV15M15C", SN_NOWARN) set_name(0x8012AA44, "NumsLEV16M16D", SN_NOWARN) set_name(0x800A75A8, "ChoiceListLEV1", SN_NOWARN) set_name(0x800A75D8, "ChoiceListLEV2", SN_NOWARN) set_name(0x800A7638, "ChoiceListLEV3", SN_NOWARN) set_name(0x800A7678, "ChoiceListLEV4", SN_NOWARN) set_name(0x800A76E8, "ChoiceListLEV5", SN_NOWARN) set_name(0x800A7758, "ChoiceListLEV6", SN_NOWARN) set_name(0x800A77B8, "ChoiceListLEV7", SN_NOWARN) set_name(0x800A7808, "ChoiceListLEV8", SN_NOWARN) set_name(0x800A7868, "ChoiceListLEV9", SN_NOWARN) set_name(0x800A78A8, "ChoiceListLEV10", SN_NOWARN) set_name(0x800A78F8, "ChoiceListLEV11", SN_NOWARN) set_name(0x800A7948, "ChoiceListLEV12", SN_NOWARN) set_name(0x800A7988, "ChoiceListLEV13", SN_NOWARN) set_name(0x800A79D8, "ChoiceListLEV14", SN_NOWARN) set_name(0x800A7A38, "ChoiceListLEV15", SN_NOWARN) set_name(0x800A7A68, "ChoiceListLEV16", SN_NOWARN) set_name(0x8012C4E0, "GameTaskPtr", SN_NOWARN) set_name(0x800A7AF8, "AllArgs", SN_NOWARN) set_name(0x8012AC24, "ArgsSoFar", SN_NOWARN) set_name(0x8012AC34, "ThisOt", SN_NOWARN) set_name(0x8012AC38, "ThisPrimAddr", SN_NOWARN) set_name(0x8012C4E4, "hndPrimBuffers", SN_NOWARN) set_name(0x8012C4E8, "PrimBuffers", SN_NOWARN) set_name(0x8012C4EC, "BufferDepth", SN_NOWARN) set_name(0x8012C4ED, "WorkRamId", SN_NOWARN) set_name(0x8012C4EE, "ScrNum", SN_NOWARN) set_name(0x8012C4F0, "Screens", SN_NOWARN) set_name(0x8012C4F4, "PbToClear", SN_NOWARN) set_name(0x8012C4F8, "BufferNum", SN_NOWARN) set_name(0x8012AC3C, "AddrToAvoid", SN_NOWARN) set_name(0x8012C4F9, "LastBuffer", SN_NOWARN) set_name(0x8012C4FC, "DispEnvToPut", SN_NOWARN) set_name(0x8012C500, "ThisOtSize", SN_NOWARN) set_name(0x8012AC40, "ScrRect", SN_NOWARN) set_name(0x8012C504, "VidWait", SN_NOWARN) set_name(0x8012C960, "screen", SN_NOWARN) set_name(0x8012C508, "VbFunc", SN_NOWARN) set_name(0x8012C50C, "VidTick", SN_NOWARN) set_name(0x8012C510, "VXOff", SN_NOWARN) set_name(0x8012C514, "VYOff", SN_NOWARN) set_name(0x8012AC54, "Gaz", SN_NOWARN) set_name(0x8012AC58, "LastFmem", SN_NOWARN) set_name(0x8012AC48, "GSYS_MemStart", SN_NOWARN) set_name(0x8012AC4C, "GSYS_MemEnd", SN_NOWARN) set_name(0x800A7E40, "PsxMem", SN_NOWARN) set_name(0x800A7E68, "PsxFastMem", SN_NOWARN) set_name(0x8012AC50, "LowestFmem", SN_NOWARN) set_name(0x8012AC68, "FileSYS", SN_NOWARN) set_name(0x8012C518, "FileSystem", SN_NOWARN) set_name(0x8012C51C, "OverlayFileSystem", SN_NOWARN) set_name(0x8012AC82, "DavesPad", SN_NOWARN) set_name(0x8012AC84, "DavesPadDeb", SN_NOWARN) set_name(0x800A7E90, "_6FileIO_FileToLoad", SN_NOWARN) set_name(0x8012CA40, "MyFT4", SN_NOWARN) set_name(0x800A8734, "AllDats", SN_NOWARN) set_name(0x8012ACD4, "TpW", SN_NOWARN) set_name(0x8012ACD8, "TpH", SN_NOWARN) set_name(0x8012ACDC, "TpXDest", SN_NOWARN) set_name(0x8012ACE0, "TpYDest", SN_NOWARN) set_name(0x8012ACE4, "R", SN_NOWARN) set_name(0x800A8BAC, "MyGT4", SN_NOWARN) set_name(0x800A8BE0, "MyGT3", SN_NOWARN) set_name(0x800A7EC4, "DatPool", SN_NOWARN) set_name(0x8012ACF8, "ChunkGot", SN_NOWARN) set_name(0x800A8C08, "STREAM_DIR", SN_NOWARN) set_name(0x800A8C18, "STREAM_BIN", SN_NOWARN) set_name(0x800A8C28, "EAC_DirectoryCache", SN_NOWARN) set_name(0x8012AD0C, "BL_NoLumpFiles", SN_NOWARN) set_name(0x8012AD10, "BL_NoStreamFiles", SN_NOWARN) set_name(0x8012AD14, "LFileTab", SN_NOWARN) set_name(0x8012AD18, "SFileTab", SN_NOWARN) set_name(0x8012AD1C, "FileLoaded", SN_NOWARN) set_name(0x8012AD4C, "NoTAllocs", SN_NOWARN) set_name(0x800A8D54, "MemBlock", SN_NOWARN) set_name(0x8012C528, "CanPause", SN_NOWARN) set_name(0x8012C52C, "Paused", SN_NOWARN) set_name(0x8012CA68, "PBack", SN_NOWARN) set_name(0x800A8FBC, "RawPadData0", SN_NOWARN) set_name(0x800A8FE0, "RawPadData1", SN_NOWARN) set_name(0x800A9004, "demo_buffer", SN_NOWARN) set_name(0x8012AD78, "demo_pad_time", SN_NOWARN) set_name(0x8012AD7C, "demo_pad_count", SN_NOWARN) set_name(0x800A8EE4, "Pad0", SN_NOWARN) set_name(0x800A8F50, "Pad1", SN_NOWARN) set_name(0x8012AD80, "demo_finish", SN_NOWARN) set_name(0x8012AD84, "cac_pad", SN_NOWARN) set_name(0x8012ADA0, "CharFt4", SN_NOWARN) set_name(0x8012ADA4, "CharFrm", SN_NOWARN) set_name(0x8012AD91, "WHITER", SN_NOWARN) set_name(0x8012AD92, "WHITEG", SN_NOWARN) set_name(0x8012AD93, "WHITEB", SN_NOWARN) set_name(0x8012AD94, "BLUER", SN_NOWARN) set_name(0x8012AD95, "BLUEG", SN_NOWARN) set_name(0x8012AD96, "BLUEB", SN_NOWARN) set_name(0x8012AD97, "REDR", SN_NOWARN) set_name(0x8012AD98, "REDG", SN_NOWARN) set_name(0x8012AD99, "REDB", SN_NOWARN) set_name(0x8012AD9A, "GOLDR", SN_NOWARN) set_name(0x8012AD9B, "GOLDG", SN_NOWARN) set_name(0x8012AD9C, "GOLDB", SN_NOWARN) set_name(0x800A9388, "MediumFont", SN_NOWARN) set_name(0x800A95A0, "LargeFont", SN_NOWARN) set_name(0x800A97B8, "LFontTab", SN_NOWARN) set_name(0x800A986C, "LFont", SN_NOWARN) set_name(0x800A987C, "MFontTab", SN_NOWARN) set_name(0x800A99B4, "MFont", SN_NOWARN) set_name(0x8012ADB9, "DialogRed", SN_NOWARN) set_name(0x8012ADBA, "DialogGreen", SN_NOWARN) set_name(0x8012ADBB, "DialogBlue", SN_NOWARN) set_name(0x8012ADBC, "DialogTRed", SN_NOWARN) set_name(0x8012ADBD, "DialogTGreen", SN_NOWARN) set_name(0x8012ADBE, "DialogTBlue", SN_NOWARN) set_name(0x8012ADC0, "DialogTData", SN_NOWARN) set_name(0x8012ADC4, "DialogBackGfx", SN_NOWARN) set_name(0x8012ADC8, "DialogBackW", SN_NOWARN) set_name(0x8012ADCC, "DialogBackH", SN_NOWARN) set_name(0x8012ADD0, "DialogBorderGfx", SN_NOWARN) set_name(0x8012ADD4, "DialogBorderTLW", SN_NOWARN) set_name(0x8012ADD8, "DialogBorderTLH", SN_NOWARN) set_name(0x8012ADDC, "DialogBorderTRW", SN_NOWARN) set_name(0x8012ADE0, "DialogBorderTRH", SN_NOWARN) set_name(0x8012ADE4, "DialogBorderBLW", SN_NOWARN) set_name(0x8012ADE8, "DialogBorderBLH", SN_NOWARN) set_name(0x8012ADEC, "DialogBorderBRW", SN_NOWARN) set_name(0x8012ADF0, "DialogBorderBRH", SN_NOWARN) set_name(0x8012ADF4, "DialogBorderTW", SN_NOWARN) set_name(0x8012ADF8, "DialogBorderTH", SN_NOWARN) set_name(0x8012ADFC, "DialogBorderBW", SN_NOWARN) set_name(0x8012AE00, "DialogBorderBH", SN_NOWARN) set_name(0x8012AE04, "DialogBorderLW", SN_NOWARN) set_name(0x8012AE08, "DialogBorderLH", SN_NOWARN) set_name(0x8012AE0C, "DialogBorderRW", SN_NOWARN) set_name(0x8012AE10, "DialogBorderRH", SN_NOWARN) set_name(0x8012AE14, "DialogBevelGfx", SN_NOWARN) set_name(0x8012AE18, "DialogBevelCW", SN_NOWARN) set_name(0x8012AE1C, "DialogBevelCH", SN_NOWARN) set_name(0x8012AE20, "DialogBevelLRW", SN_NOWARN) set_name(0x8012AE24, "DialogBevelLRH", SN_NOWARN) set_name(0x8012AE28, "DialogBevelUDW", SN_NOWARN) set_name(0x8012AE2C, "DialogBevelUDH", SN_NOWARN) set_name(0x8012AE30, "MY_DialogOTpos", SN_NOWARN) set_name(0x8012C530, "DialogGBack", SN_NOWARN) set_name(0x8012C531, "GShadeX", SN_NOWARN) set_name(0x8012C532, "GShadeY", SN_NOWARN) set_name(0x8012C538, "RandBTab", SN_NOWARN) set_name(0x800A9A04, "Cxy", SN_NOWARN) set_name(0x8012ADB3, "BORDERR", SN_NOWARN) set_name(0x8012ADB4, "BORDERG", SN_NOWARN) set_name(0x8012ADB5, "BORDERB", SN_NOWARN) set_name(0x8012ADB6, "BACKR", SN_NOWARN) set_name(0x8012ADB7, "BACKG", SN_NOWARN) set_name(0x8012ADB8, "BACKB", SN_NOWARN) set_name(0x800A99C4, "GShadeTab", SN_NOWARN) set_name(0x8012ADB1, "GShadePX", SN_NOWARN) set_name(0x8012ADB2, "GShadePY", SN_NOWARN) set_name(0x8012AE3D, "PlayDemoFlag", SN_NOWARN) set_name(0x8012CA78, "rgbb", SN_NOWARN) set_name(0x8012CAA8, "rgbt", SN_NOWARN) set_name(0x8012C540, "blockr", SN_NOWARN) set_name(0x8012C544, "blockg", SN_NOWARN) set_name(0x8012C548, "blockb", SN_NOWARN) set_name(0x8012C54C, "InfraFlag", SN_NOWARN) set_name(0x8012C550, "blank_bit", SN_NOWARN) set_name(0x8012AE51, "P1ObjSelCount", SN_NOWARN) set_name(0x8012AE52, "P2ObjSelCount", SN_NOWARN) set_name(0x8012AE53, "P12ObjSelCount", SN_NOWARN) set_name(0x8012AE54, "P1ItemSelCount", SN_NOWARN) set_name(0x8012AE55, "P2ItemSelCount", SN_NOWARN) set_name(0x8012AE56, "P12ItemSelCount", SN_NOWARN) set_name(0x8012AE57, "P1MonstSelCount", SN_NOWARN) set_name(0x8012AE58, "P2MonstSelCount", SN_NOWARN) set_name(0x8012AE59, "P12MonstSelCount", SN_NOWARN) set_name(0x8012AE5A, "P1ObjSelCol", SN_NOWARN) set_name(0x8012AE5C, "P2ObjSelCol", SN_NOWARN) set_name(0x8012AE5E, "P12ObjSelCol", SN_NOWARN) set_name(0x8012AE60, "P1ItemSelCol", SN_NOWARN) set_name(0x8012AE62, "P2ItemSelCol", SN_NOWARN) set_name(0x8012AE64, "P12ItemSelCol", SN_NOWARN) set_name(0x8012AE66, "P1MonstSelCol", SN_NOWARN) set_name(0x8012AE68, "P2MonstSelCol", SN_NOWARN) set_name(0x8012AE6A, "P12MonstSelCol", SN_NOWARN) set_name(0x8012AE6C, "CurrentBlocks", SN_NOWARN) set_name(0x801206EC, "SinTab", SN_NOWARN) set_name(0x800A9A74, "TownConv", SN_NOWARN) set_name(0x8012AE88, "CurrentOverlay", SN_NOWARN) set_name(0x8012078C, "HaltTab", SN_NOWARN) set_name(0x8012CAD8, "FrontEndOver", SN_NOWARN) set_name(0x8012CAE8, "PregameOver", SN_NOWARN) set_name(0x8012CAF8, "GameOver", SN_NOWARN) set_name(0x8012CB08, "FmvOver", SN_NOWARN) set_name(0x8012C554, "OWorldX", SN_NOWARN) set_name(0x8012C558, "OWorldY", SN_NOWARN) set_name(0x8012C55C, "WWorldX", SN_NOWARN) set_name(0x8012C560, "WWorldY", SN_NOWARN) set_name(0x80120808, "TxyAdd", SN_NOWARN) set_name(0x8012AEAC, "GXAdj2", SN_NOWARN) set_name(0x8012C564, "TimePerFrame", SN_NOWARN) set_name(0x8012C568, "CpuStart", SN_NOWARN) set_name(0x8012C56C, "CpuTime", SN_NOWARN) set_name(0x8012C570, "DrawTime", SN_NOWARN) set_name(0x8012C574, "DrawStart", SN_NOWARN) set_name(0x8012C578, "LastCpuTime", SN_NOWARN) set_name(0x8012C57C, "LastDrawTime", SN_NOWARN) set_name(0x8012C580, "DrawArea", SN_NOWARN) set_name(0x8012AEB4, "ProfOn", SN_NOWARN) set_name(0x800A9A88, "LevPals", SN_NOWARN) set_name(0x80120970, "Level2Bgdata", SN_NOWARN) set_name(0x800A9A9C, "DefP1PanelXY", SN_NOWARN) set_name(0x800A9AF0, "DefP1PanelXY2", SN_NOWARN) set_name(0x800A9B44, "DefP2PanelXY", SN_NOWARN) set_name(0x800A9B98, "DefP2PanelXY2", SN_NOWARN) set_name(0x800A9BEC, "SpeedBarGfxTable", SN_NOWARN) set_name(0x8012AEDC, "hof", SN_NOWARN) set_name(0x8012AEE0, "mof", SN_NOWARN) set_name(0x800A9CB4, "SFXTab", SN_NOWARN) set_name(0x800A9DB4, "STR_Buffer", SN_NOWARN) set_name(0x8012AF10, "Time", SN_NOWARN) set_name(0x8012AF14, "CDWAIT", SN_NOWARN) set_name(0x800BBDB4, "voice_attr", SN_NOWARN) set_name(0x800BBDF4, "STRSave", SN_NOWARN) set_name(0x8012AEED, "NoActiveStreams", SN_NOWARN) set_name(0x8012AEF0, "STRInit", SN_NOWARN) set_name(0x8012AEF4, "CDAngle", SN_NOWARN) set_name(0x8012AF38, "SFXNotPlayed", SN_NOWARN) set_name(0x8012AF39, "SFXNotInBank", SN_NOWARN) set_name(0x8012CB18, "spu_management", SN_NOWARN) set_name(0x8012CC28, "rev_attr", SN_NOWARN) set_name(0x8012C588, "NoSfx", SN_NOWARN) set_name(0x8012AF24, "BankOffsets", SN_NOWARN) set_name(0x8012AF28, "OffsetHandle", SN_NOWARN) set_name(0x8012AF2C, "BankBase", SN_NOWARN) set_name(0x8012AF30, "SPU_Done", SN_NOWARN) set_name(0x80120D14, "SFXRemapTab", SN_NOWARN) set_name(0x8012AF34, "NoSNDRemaps", SN_NOWARN) set_name(0x800BBE74, "ThePals", SN_NOWARN) set_name(0x80120DB8, "InitialPositions", SN_NOWARN) set_name(0x8012AF80, "demo_level", SN_NOWARN) set_name(0x8012CC40, "buff", SN_NOWARN) set_name(0x8012AF84, "old_val", SN_NOWARN) set_name(0x8012AF88, "DemoTask", SN_NOWARN) set_name(0x8012AF8C, "DemoGameTask", SN_NOWARN) set_name(0x8012AF90, "tonys", SN_NOWARN) set_name(0x8012AF64, "demo_load", SN_NOWARN) set_name(0x8012AF68, "demo_record_load", SN_NOWARN) set_name(0x8012AF6C, "level_record", SN_NOWARN) set_name(0x8012AF70, "demo_fade_finished", SN_NOWARN) set_name(0x8012AF71, "demo_which", SN_NOWARN) set_name(0x800BC060, "demolevel", SN_NOWARN) set_name(0x8012AF60, "moo_moo", SN_NOWARN) set_name(0x8012AF72, "demo_flash", SN_NOWARN) set_name(0x8012AF74, "tonys_Task", SN_NOWARN) set_name(0x8012B0EC, "DoShowPanel", SN_NOWARN) set_name(0x8012B0F0, "DoDrawBg", SN_NOWARN) set_name(0x8012C58C, "GlueFinished", SN_NOWARN) set_name(0x8012C590, "DoHomingScroll", SN_NOWARN) set_name(0x8012C594, "TownerGfx", SN_NOWARN) set_name(0x8012C598, "CurrentMonsterList", SN_NOWARN) set_name(0x8012AF9D, "started_grtask", SN_NOWARN) set_name(0x800BC074, "PlayerInfo", SN_NOWARN) set_name(0x8012B0F4, "ArmourChar", SN_NOWARN) set_name(0x80120EAC, "WepChar", SN_NOWARN) set_name(0x8012B0F8, "CharChar", SN_NOWARN) set_name(0x8012C59C, "ctrl_select_line", SN_NOWARN) set_name(0x8012C59D, "ctrl_select_side", SN_NOWARN) set_name(0x8012C59E, "ckeyheld", SN_NOWARN) set_name(0x8012C5A4, "CtrlRect", SN_NOWARN) set_name(0x8012B10C, "ctrlflag", SN_NOWARN) set_name(0x800BC3A4, "txt_actions", SN_NOWARN) set_name(0x800BC2FC, "pad_txt", SN_NOWARN) set_name(0x8012B108, "toppos", SN_NOWARN) set_name(0x8012CC60, "CtrlBack", SN_NOWARN) set_name(0x800BC4D4, "controller_defaults", SN_NOWARN) set_name(0x8012B17C, "gr_scrxoff", SN_NOWARN) set_name(0x8012B180, "gr_scryoff", SN_NOWARN) set_name(0x8012B188, "water_clut", SN_NOWARN) set_name(0x8012B18C, "visible_level", SN_NOWARN) set_name(0x8012B179, "last_type", SN_NOWARN) set_name(0x8012B18E, "daylight", SN_NOWARN) set_name(0x8012B18A, "cow_in_sight", SN_NOWARN) set_name(0x8012B18B, "inn_in_sight", SN_NOWARN) set_name(0x8012B184, "water_count", SN_NOWARN) set_name(0x8012B18D, "lastrnd", SN_NOWARN) set_name(0x8012B190, "call_clock", SN_NOWARN) set_name(0x8012B1A0, "TitleAnimCount", SN_NOWARN) set_name(0x8012B1A4, "flametick", SN_NOWARN) set_name(0x800BC58C, "SpellFXDat", SN_NOWARN) set_name(0x8012CC70, "PartArray", SN_NOWARN) set_name(0x8012C5AC, "partOtPos", SN_NOWARN) set_name(0x8012B1C0, "SetParticle", SN_NOWARN) set_name(0x8012B1C4, "p1partexecnum", SN_NOWARN) set_name(0x8012B1C8, "p2partexecnum", SN_NOWARN) set_name(0x800BC56C, "JumpArray", SN_NOWARN) set_name(0x8012B1CC, "partjumpflag", SN_NOWARN) set_name(0x8012B1D0, "partglowflag", SN_NOWARN) set_name(0x8012B1D4, "partcolour", SN_NOWARN) set_name(0x800BC61C, "SplTarget", SN_NOWARN) set_name(0x8012B1F5, "select_flag", SN_NOWARN) set_name(0x8012C5B0, "SelectRect", SN_NOWARN) set_name(0x8012C5B8, "item_select", SN_NOWARN) set_name(0x8012B1F8, "QSpell", SN_NOWARN) set_name(0x8012B1FC, "_spltotype", SN_NOWARN) set_name(0x8012B200, "force_attack", SN_NOWARN) set_name(0x8012B1E8, "gplayer", SN_NOWARN) set_name(0x8012CEB0, "SelectBack", SN_NOWARN) set_name(0x8012B1EC, "mana_order", SN_NOWARN) set_name(0x8012B1F0, "health_order", SN_NOWARN) set_name(0x8012B1F4, "birdcheck", SN_NOWARN) set_name(0x8012CEC0, "DecRequestors", SN_NOWARN) set_name(0x8012C5BC, "progress", SN_NOWARN) set_name(0x80121030, "Level2CutScreen", SN_NOWARN) set_name(0x8012B220, "CutString", SN_NOWARN) set_name(0x8012CEE8, "Scr", SN_NOWARN) set_name(0x8012B224, "CutScreenTSK", SN_NOWARN) set_name(0x8012B228, "GameLoading", SN_NOWARN) set_name(0x8012CF68, "LBack", SN_NOWARN) set_name(0x8012B238, "card_ev0", SN_NOWARN) set_name(0x8012B23C, "card_ev1", SN_NOWARN) set_name(0x8012B240, "card_ev2", SN_NOWARN) set_name(0x8012B244, "card_ev3", SN_NOWARN) set_name(0x8012B248, "card_ev10", SN_NOWARN) set_name(0x8012B24C, "card_ev11", SN_NOWARN) set_name(0x8012B250, "card_ev12", SN_NOWARN) set_name(0x8012B254, "card_ev13", SN_NOWARN) set_name(0x8012B258, "card_dirty", SN_NOWARN) set_name(0x8012B260, "MemcardTask", SN_NOWARN) set_name(0x8012C5C0, "card_event", SN_NOWARN) set_name(0x8012B234, "mem_card_event_handler", SN_NOWARN) set_name(0x8012B22C, "MemCardActive", SN_NOWARN) set_name(0x8012B230, "never_hooked_events", SN_NOWARN) set_name(0x8012B2B4, "MasterVol", SN_NOWARN) set_name(0x8012B2B8, "MusicVol", SN_NOWARN) set_name(0x8012B2BC, "SoundVol", SN_NOWARN) set_name(0x8012B2C0, "VideoVol", SN_NOWARN) set_name(0x8012B2C4, "SpeechVol", SN_NOWARN) set_name(0x8012C5C4, "Slider", SN_NOWARN) set_name(0x8012C5C8, "sw", SN_NOWARN) set_name(0x8012C5CC, "sx", SN_NOWARN) set_name(0x8012C5D0, "sy", SN_NOWARN) set_name(0x8012C5D4, "Adjust", SN_NOWARN) set_name(0x8012C5D5, "qspin", SN_NOWARN) set_name(0x8012C5D6, "lqspin", SN_NOWARN) set_name(0x8012C5D8, "OrigLang", SN_NOWARN) set_name(0x8012C5DC, "OldLang", SN_NOWARN) set_name(0x8012C5E0, "NewLang", SN_NOWARN) set_name(0x8012B2C8, "card_blocks", SN_NOWARN) set_name(0x8012B2CC, "Savefilename", SN_NOWARN) set_name(0x8012B2D0, "ReturnMenu", SN_NOWARN) set_name(0x8012C5E4, "ORect", SN_NOWARN) set_name(0x8012C5EC, "McState", SN_NOWARN) set_name(0x8012B2D4, "they_pressed", SN_NOWARN) set_name(0x8012B28C, "optionsflag", SN_NOWARN) set_name(0x8012B280, "cmenu", SN_NOWARN) set_name(0x8012B298, "options_pad", SN_NOWARN) set_name(0x8012B288, "allspellsflag", SN_NOWARN) set_name(0x800BD054, "Circle", SN_NOWARN) set_name(0x8012B270, "goldcheat", SN_NOWARN) set_name(0x8012B274, "Spacing", SN_NOWARN) set_name(0x8012B278, "cs", SN_NOWARN) set_name(0x8012B27C, "lastcs", SN_NOWARN) set_name(0x8012B284, "MemcardOverlay", SN_NOWARN) set_name(0x8012B290, "saveflag", SN_NOWARN) set_name(0x8012B294, "loadflag", SN_NOWARN) set_name(0x8012B2A4, "PrevTxt", SN_NOWARN) set_name(0x8012B2A8, "SelTxt", SN_NOWARN) set_name(0x800BC664, "MainMenu", SN_NOWARN) set_name(0x800BC70C, "GameMenu", SN_NOWARN) set_name(0x800BC7FC, "SoundMenu", SN_NOWARN) set_name(0x800BC88C, "CentreMenu", SN_NOWARN) set_name(0x800BC934, "LangMenu", SN_NOWARN) set_name(0x800BC9DC, "QuitMenu", SN_NOWARN) set_name(0x800BCA3C, "MemcardMenu", SN_NOWARN) set_name(0x800BCAE4, "MemcardLoadGameMenu", SN_NOWARN) set_name(0x800BCB44, "MemcardSaveGameMenu", SN_NOWARN) set_name(0x800BCBA4, "MemcardSaveOptionsMenu", SN_NOWARN) set_name(0x800BCC04, "MemcardLoadOptionsMenu", SN_NOWARN) set_name(0x800BCC64, "MemcardCharacterMenu", SN_NOWARN) set_name(0x800BCCC4, "MemcardSelectCard1", SN_NOWARN) set_name(0x800BCD6C, "MemcardSelectCard2", SN_NOWARN) set_name(0x800BCE14, "MemcardFormatMenu", SN_NOWARN) set_name(0x800BCE74, "CheatMenu", SN_NOWARN) set_name(0x800BCF4C, "InfoMenu", SN_NOWARN) set_name(0x800BCF7C, "MonstViewMenu", SN_NOWARN) set_name(0x800BCFC4, "MenuList", SN_NOWARN) set_name(0x8012B2AC, "debounce", SN_NOWARN) set_name(0x8012B2B0, "Qfromoptions", SN_NOWARN) set_name(0x800BD0D4, "BirdList", SN_NOWARN) set_name(0x8012C5F4, "last_seenx", SN_NOWARN) set_name(0x8012C5FC, "last_seeny", SN_NOWARN) set_name(0x8012B2E1, "hop_height", SN_NOWARN) set_name(0x8012B2E4, "perches", SN_NOWARN) set_name(0x800BD254, "FmvTab", SN_NOWARN) set_name(0x8012B2F8, "CurMons", SN_NOWARN) set_name(0x8012B2FC, "Frame", SN_NOWARN) set_name(0x8012B300, "Action", SN_NOWARN) set_name(0x8012B304, "Dir", SN_NOWARN) set_name(0x8012B368, "indsize", SN_NOWARN) set_name(0x8012B348, "kanjbuff", SN_NOWARN) set_name(0x8012B34C, "kindex", SN_NOWARN) set_name(0x8012B350, "hndKanjBuff", SN_NOWARN) set_name(0x8012B354, "hndKanjIndex", SN_NOWARN) set_name(0x8012B3A8, "FeBackX", SN_NOWARN) set_name(0x8012B3AC, "FeBackY", SN_NOWARN) set_name(0x8012B3B0, "FeBackW", SN_NOWARN) set_name(0x8012B3B4, "FeBackH", SN_NOWARN) set_name(0x8012B3B8, "FeFlag", SN_NOWARN) set_name(0x800BDDE4, "FeBuffer", SN_NOWARN) set_name(0x8012B3BC, "FePlayerNo", SN_NOWARN) set_name(0x8012C604, "CStruct", SN_NOWARN) set_name(0x8012B3C0, "FeBufferCount", SN_NOWARN) set_name(0x8012B3C4, "FeNoOfPlayers", SN_NOWARN) set_name(0x8012B3C8, "FeChrClass", SN_NOWARN) set_name(0x800BE564, "FePlayerName", SN_NOWARN) set_name(0x8012B3D0, "FeCurMenu", SN_NOWARN) set_name(0x8012B3D4, "FePlayerNameFlag", SN_NOWARN) set_name(0x8012B3D8, "FeCount", SN_NOWARN) set_name(0x8012B3DC, "fileselect", SN_NOWARN) set_name(0x8012B3E0, "BookMenu", SN_NOWARN) set_name(0x8012B3E4, "FeAttractMode", SN_NOWARN) set_name(0x8012B3E8, "FMVPress", SN_NOWARN) set_name(0x8012B378, "FeTData", SN_NOWARN) set_name(0x8012B380, "LoadedChar", SN_NOWARN) set_name(0x8012B37C, "FlameTData", SN_NOWARN) set_name(0x8012B388, "FeIsAVirgin", SN_NOWARN) set_name(0x8012B38C, "FeMenuDelay", SN_NOWARN) set_name(0x800BD284, "DummyMenu", SN_NOWARN) set_name(0x800BD2A0, "FeMainMenu", SN_NOWARN) set_name(0x800BD2BC, "FeNewGameMenu", SN_NOWARN) set_name(0x800BD2D8, "FeNewP1ClassMenu", SN_NOWARN) set_name(0x800BD2F4, "FeNewP1NameMenu", SN_NOWARN) set_name(0x800BD310, "FeNewP2ClassMenu", SN_NOWARN) set_name(0x800BD32C, "FeNewP2NameMenu", SN_NOWARN) set_name(0x800BD348, "FeDifficultyMenu", SN_NOWARN) set_name(0x800BD364, "FeBackgroundMenu", SN_NOWARN) set_name(0x800BD380, "FeBook1Menu", SN_NOWARN) set_name(0x800BD39C, "FeBook2Menu", SN_NOWARN) set_name(0x800BD3B8, "FeLoadCharMenu", SN_NOWARN) set_name(0x800BD3D4, "FeLoadChar1Menu", SN_NOWARN) set_name(0x800BD3F0, "FeLoadChar2Menu", SN_NOWARN) set_name(0x8012B390, "fadeval", SN_NOWARN) set_name(0x800BD40C, "FeMainMenuTable", SN_NOWARN) set_name(0x800BD484, "FeNewGameMenuTable", SN_NOWARN) set_name(0x800BD4CC, "FePlayerClassMenuTable", SN_NOWARN) set_name(0x800BD544, "FeNameEngMenuTable", SN_NOWARN) set_name(0x800BDBEC, "FeMemcardMenuTable", SN_NOWARN) set_name(0x800BDC34, "FeDifficultyMenuTable", SN_NOWARN) set_name(0x800BDC94, "FeBackgroundMenuTable", SN_NOWARN) set_name(0x800BDCF4, "FeBook1MenuTable", SN_NOWARN) set_name(0x800BDD6C, "FeBook2MenuTable", SN_NOWARN) set_name(0x8012B39C, "AttractTitleDelay", SN_NOWARN) set_name(0x8012B3A0, "AttractMainDelay", SN_NOWARN) set_name(0x8012B3A4, "FMVEndPad", SN_NOWARN) set_name(0x8012B41C, "InCredits", SN_NOWARN) set_name(0x8012B420, "CreditTitleNo", SN_NOWARN) set_name(0x8012B424, "CreditSubTitleNo", SN_NOWARN) set_name(0x8012B438, "card_status", SN_NOWARN) set_name(0x8012B440, "card_usable", SN_NOWARN) set_name(0x8012B448, "card_files", SN_NOWARN) set_name(0x8012B450, "card_changed", SN_NOWARN) set_name(0x8012B494, "AlertTxt", SN_NOWARN) set_name(0x8012B498, "current_card", SN_NOWARN) set_name(0x8012B49C, "LoadType", SN_NOWARN) set_name(0x8012B4A0, "McMenuPos", SN_NOWARN) set_name(0x8012B4A4, "McCurMenu", SN_NOWARN) set_name(0x8012B490, "fileinfoflag", SN_NOWARN) set_name(0x8012B464, "DiabloGameFile", SN_NOWARN) set_name(0x8012B468, "DiabloOptionFile", SN_NOWARN) set_name(0x8012B488, "McState_addr_8012B488", SN_NOWARN) set_name(0x8012B578, "mdec_audio_buffer", SN_NOWARN) set_name(0x8012B580, "mdec_audio_sec", SN_NOWARN) set_name(0x8012B584, "mdec_audio_offs", SN_NOWARN) set_name(0x8012B588, "mdec_audio_playing", SN_NOWARN) set_name(0x8012B58C, "mdec_audio_rate_shift", SN_NOWARN) set_name(0x8012B590, "vlcbuf", SN_NOWARN) set_name(0x8012B598, "slice_size", SN_NOWARN) set_name(0x8012B59C, "slice", SN_NOWARN) set_name(0x8012B5A4, "slice_inc", SN_NOWARN) set_name(0x8012B5A8, "area_pw", SN_NOWARN) set_name(0x8012B5AC, "area_ph", SN_NOWARN) set_name(0x8012B5B0, "tmdc_pol_dirty", SN_NOWARN) set_name(0x8012B5B4, "num_pol", SN_NOWARN) set_name(0x8012B5BC, "mdec_cx", SN_NOWARN) set_name(0x8012B5C0, "mdec_cy", SN_NOWARN) set_name(0x8012B5C4, "mdec_w", SN_NOWARN) set_name(0x8012B5C8, "mdec_h", SN_NOWARN) set_name(0x8012B5CC, "mdec_pw", SN_NOWARN) set_name(0x8012B5D4, "mdec_ph", SN_NOWARN) set_name(0x8012B5DC, "move_x", SN_NOWARN) set_name(0x8012B5E0, "move_y", SN_NOWARN) set_name(0x8012B5E4, "move_scale", SN_NOWARN) set_name(0x8012B5E8, "stream_frames", SN_NOWARN) set_name(0x8012B5EC, "last_stream_frame", SN_NOWARN) set_name(0x8012B5F0, "mdec_framecount", SN_NOWARN) set_name(0x8012B5F4, "mdec_speed", SN_NOWARN) set_name(0x8012B5F8, "mdec_stream_starting", SN_NOWARN) set_name(0x8012B5FC, "mdec_last_frame", SN_NOWARN) set_name(0x8012B600, "mdec_sectors_per_frame", SN_NOWARN) set_name(0x8012B604, "vlctab", SN_NOWARN) set_name(0x8012B608, "mdc_buftop", SN_NOWARN) set_name(0x8012B60C, "mdc_bufstart", SN_NOWARN) set_name(0x8012B610, "mdc_bufleft", SN_NOWARN) set_name(0x8012B614, "mdc_buftotal", SN_NOWARN) set_name(0x8012B618, "ordertab_length", SN_NOWARN) set_name(0x8012B61C, "time_in_frames", SN_NOWARN) set_name(0x8012B620, "stream_chunksize", SN_NOWARN) set_name(0x8012B624, "stream_bufsize", SN_NOWARN) set_name(0x8012B628, "stream_subsec", SN_NOWARN) set_name(0x8012B62C, "stream_secnum", SN_NOWARN) set_name(0x8012B630, "stream_last_sector", SN_NOWARN) set_name(0x8012B634, "stream_startsec", SN_NOWARN) set_name(0x8012B638, "stream_opened", SN_NOWARN) set_name(0x8012B63C, "stream_last_chunk", SN_NOWARN) set_name(0x8012B640, "stream_got_chunks", SN_NOWARN) set_name(0x8012B644, "last_sector", SN_NOWARN) set_name(0x8012B648, "cdstream_resetsec", SN_NOWARN) set_name(0x8012B64C, "last_handler_event", SN_NOWARN) set_name(0x8012B51C, "user_start", SN_NOWARN) set_name(0x8012B4B4, "vlc_tab", SN_NOWARN) set_name(0x8012B4B8, "vlc_buf", SN_NOWARN) set_name(0x8012B4BC, "img_buf", SN_NOWARN) set_name(0x8012B4C0, "vbuf", SN_NOWARN) set_name(0x8012B4C4, "last_fn", SN_NOWARN) set_name(0x8012B4C8, "last_mdc", SN_NOWARN) set_name(0x8012B4CC, "slnum", SN_NOWARN) set_name(0x8012B4D0, "slices_to_do", SN_NOWARN) set_name(0x8012B4D4, "mbuf", SN_NOWARN) set_name(0x8012B4D8, "mfn", SN_NOWARN) set_name(0x8012B4DC, "last_move_mbuf", SN_NOWARN) set_name(0x8012B4E0, "move_request", SN_NOWARN) set_name(0x8012B4E4, "mdec_scale", SN_NOWARN) set_name(0x8012B4E8, "do_brightness", SN_NOWARN) set_name(0x8012B4EC, "frame_decoded", SN_NOWARN) set_name(0x8012B4F0, "mdec_streaming", SN_NOWARN) set_name(0x8012B4F4, "mdec_stream_size", SN_NOWARN) set_name(0x8012B4F8, "first_stream_frame", SN_NOWARN) set_name(0x8012B4FC, "stream_frames_played", SN_NOWARN) set_name(0x8012B500, "num_mdcs", SN_NOWARN) set_name(0x8012B504, "mdec_head", SN_NOWARN) set_name(0x8012B508, "mdec_tail", SN_NOWARN) set_name(0x8012B50C, "mdec_waiting_tail", SN_NOWARN) set_name(0x8012B510, "mdecs_queued", SN_NOWARN) set_name(0x8012B514, "mdecs_waiting", SN_NOWARN) set_name(0x8012B518, "sfx_volume", SN_NOWARN) set_name(0x8012B520, "stream_chunks_in", SN_NOWARN) set_name(0x8012B524, "stream_chunks_total", SN_NOWARN) set_name(0x8012B528, "stream_in", SN_NOWARN) set_name(0x8012B52C, "stream_out", SN_NOWARN) set_name(0x8012B530, "stream_stalled", SN_NOWARN) set_name(0x8012B534, "stream_ending", SN_NOWARN) set_name(0x8012B538, "stream_open", SN_NOWARN) set_name(0x8012B53C, "stream_handler_installed", SN_NOWARN) set_name(0x8012B540, "stream_chunks_borrowed", SN_NOWARN) set_name(0x8012B544, "_get_count", SN_NOWARN) set_name(0x8012B548, "_discard_count", SN_NOWARN) set_name(0x8012B54C, "CDTask", SN_NOWARN) set_name(0x8012B550, "CDStream", SN_NOWARN) set_name(0x8012B554, "cdready_calls", SN_NOWARN) set_name(0x8012B558, "cdready_errors", SN_NOWARN) set_name(0x8012B55C, "cdready_out_of_sync", SN_NOWARN) set_name(0x8012B560, "cdstream_resetting", SN_NOWARN) set_name(0x8012B564, "sector_dma", SN_NOWARN) set_name(0x8012B568, "sector_dma_in", SN_NOWARN) set_name(0x8012B56C, "chkaddr", SN_NOWARN) set_name(0x8012B570, "chunk", SN_NOWARN) set_name(0x8012B574, "first_handler_event", SN_NOWARN) set_name(0x8012B6EC, "pStatusPanel", SN_NOWARN) set_name(0x8012B6F0, "pGBoxBuff", SN_NOWARN) set_name(0x8012B6F4, "dropGoldFlag", SN_NOWARN) set_name(0x8012B6F8, "_pinfoflag", SN_NOWARN) set_name(0x800BEB5C, "_infostr", SN_NOWARN) set_name(0x8012B6FC, "_infoclr", SN_NOWARN) set_name(0x800BED5C, "tempstr", SN_NOWARN) set_name(0x8012B6FE, "drawhpflag", SN_NOWARN) set_name(0x8012B6FF, "drawmanaflag", SN_NOWARN) set_name(0x8012B700, "chrflag", SN_NOWARN) set_name(0x8012B701, "drawbtnflag", SN_NOWARN) set_name(0x8012B702, "panbtndown", SN_NOWARN) set_name(0x8012B703, "panelflag", SN_NOWARN) set_name(0x8012B704, "chrbtndown", SN_NOWARN) set_name(0x8012B705, "lvlbtndown", SN_NOWARN) set_name(0x8012B706, "sbookflag", SN_NOWARN) set_name(0x8012B707, "talkflag", SN_NOWARN) set_name(0x8012B708, "dropGoldValue", SN_NOWARN) set_name(0x8012B70C, "initialDropGoldValue", SN_NOWARN) set_name(0x8012B710, "initialDropGoldIndex", SN_NOWARN) set_name(0x8012B714, "pPanelButtons", SN_NOWARN) set_name(0x8012B718, "pPanelText", SN_NOWARN) set_name(0x8012B71C, "pManaBuff", SN_NOWARN) set_name(0x8012B720, "pLifeBuff", SN_NOWARN) set_name(0x8012B724, "pChrPanel", SN_NOWARN) set_name(0x8012B728, "pChrButtons", SN_NOWARN) set_name(0x8012B72C, "pSpellCels", SN_NOWARN) set_name(0x8012CFB8, "_panelstr", SN_NOWARN) set_name(0x8012D3B8, "_pstrjust", SN_NOWARN) set_name(0x8012C614, "_pnumlines", SN_NOWARN) set_name(0x8012B730, "InfoBoxRect", SN_NOWARN) set_name(0x8012B734, "CSRect", SN_NOWARN) set_name(0x8012C624, "_pSpell", SN_NOWARN) set_name(0x8012C62C, "_pSplType", SN_NOWARN) set_name(0x8012C634, "panbtn", SN_NOWARN) set_name(0x8012B73C, "numpanbtns", SN_NOWARN) set_name(0x8012B740, "pDurIcons", SN_NOWARN) set_name(0x8012B744, "drawdurflag", SN_NOWARN) set_name(0x8012C63C, "chrbtn", SN_NOWARN) set_name(0x8012B745, "chrbtnactive", SN_NOWARN) set_name(0x8012B748, "pSpellBkCel", SN_NOWARN) set_name(0x8012B74C, "pSBkBtnCel", SN_NOWARN) set_name(0x8012B750, "pSBkIconCels", SN_NOWARN) set_name(0x8012B754, "sbooktab", SN_NOWARN) set_name(0x8012B758, "cur_spel", SN_NOWARN) set_name(0x8012C644, "talkofs", SN_NOWARN) set_name(0x8012D408, "sgszTalkMsg", SN_NOWARN) set_name(0x8012C648, "sgbTalkSavePos", SN_NOWARN) set_name(0x8012C649, "sgbNextTalkSave", SN_NOWARN) set_name(0x8012C64A, "sgbPlrTalkTbl", SN_NOWARN) set_name(0x8012C64C, "pTalkPanel", SN_NOWARN) set_name(0x8012C650, "pMultiBtns", SN_NOWARN) set_name(0x8012C654, "pTalkBtns", SN_NOWARN) set_name(0x8012C658, "talkbtndown", SN_NOWARN) set_name(0x8012138C, "fontkern", SN_NOWARN) set_name(0x800BE590, "SpellITbl", SN_NOWARN) set_name(0x8012B659, "DrawLevelUpFlag", SN_NOWARN) set_name(0x8012B680, "_spselflag", SN_NOWARN) set_name(0x8012B67C, "spspelstate", SN_NOWARN) set_name(0x8012B6BC, "initchr", SN_NOWARN) set_name(0x8012B65C, "SPLICONNO", SN_NOWARN) set_name(0x8012B660, "SPLICONY", SN_NOWARN) set_name(0x8012C61C, "SPLICONRIGHT", SN_NOWARN) set_name(0x8012B664, "scx", SN_NOWARN) set_name(0x8012B668, "scy", SN_NOWARN) set_name(0x8012B66C, "scx1", SN_NOWARN) set_name(0x8012B670, "scy1", SN_NOWARN) set_name(0x8012B674, "scx2", SN_NOWARN) set_name(0x8012B678, "scy2", SN_NOWARN) set_name(0x8012B688, "SpellCol", SN_NOWARN) set_name(0x800BE57C, "SpellColors", SN_NOWARN) set_name(0x800BE5B8, "PanBtnPos", SN_NOWARN) set_name(0x800BE658, "PanBtnHotKey", SN_NOWARN) set_name(0x800BE678, "PanBtnStr", SN_NOWARN) set_name(0x800BE698, "SpellPages", SN_NOWARN) set_name(0x8012B6AC, "lus", SN_NOWARN) set_name(0x8012B6B0, "CsNo", SN_NOWARN) set_name(0x8012B6B4, "plusanim", SN_NOWARN) set_name(0x8012D3F8, "CSBack", SN_NOWARN) set_name(0x8012B6B8, "CS_XOFF", SN_NOWARN) set_name(0x800BE6FC, "CS_Tab", SN_NOWARN) set_name(0x8012B6C0, "NoCSEntries", SN_NOWARN) set_name(0x8012B6C4, "SPALOFF", SN_NOWARN) set_name(0x8012B6C8, "paloffset1", SN_NOWARN) set_name(0x8012B6CC, "paloffset2", SN_NOWARN) set_name(0x8012B6D0, "paloffset3", SN_NOWARN) set_name(0x8012B6D4, "paloffset4", SN_NOWARN) set_name(0x8012B6D8, "pinc1", SN_NOWARN) set_name(0x8012B6DC, "pinc2", SN_NOWARN) set_name(0x8012B6E0, "pinc3", SN_NOWARN) set_name(0x8012B6E4, "pinc4", SN_NOWARN) set_name(0x8012B76C, "_pcurs", SN_NOWARN) set_name(0x8012B774, "cursW", SN_NOWARN) set_name(0x8012B778, "cursH", SN_NOWARN) set_name(0x8012B77C, "icursW", SN_NOWARN) set_name(0x8012B780, "icursH", SN_NOWARN) set_name(0x8012B784, "icursW28", SN_NOWARN) set_name(0x8012B788, "icursH28", SN_NOWARN) set_name(0x8012B78C, "cursmx", SN_NOWARN) set_name(0x8012B790, "cursmy", SN_NOWARN) set_name(0x8012B794, "_pcursmonst", SN_NOWARN) set_name(0x8012B79C, "_pcursobj", SN_NOWARN) set_name(0x8012B7A0, "_pcursitem", SN_NOWARN) set_name(0x8012B7A4, "_pcursinvitem", SN_NOWARN) set_name(0x8012B7A8, "_pcursplr", SN_NOWARN) set_name(0x8012B768, "sel_data", SN_NOWARN) set_name(0x800BEE5C, "dead", SN_NOWARN) set_name(0x8012B7AC, "spurtndx", SN_NOWARN) set_name(0x8012B7B0, "stonendx", SN_NOWARN) set_name(0x8012B7B4, "pSquareCel", SN_NOWARN) set_name(0x8012B7F4, "ghInst", SN_NOWARN) set_name(0x8012B7F8, "svgamode", SN_NOWARN) set_name(0x8012B7FC, "MouseX", SN_NOWARN) set_name(0x8012B800, "MouseY", SN_NOWARN) set_name(0x8012B804, "gv1", SN_NOWARN) set_name(0x8012B808, "gv2", SN_NOWARN) set_name(0x8012B80C, "gv3", SN_NOWARN) set_name(0x8012B810, "gv4", SN_NOWARN) set_name(0x8012B814, "gv5", SN_NOWARN) set_name(0x8012B818, "gbProcessPlayers", SN_NOWARN) set_name(0x800BEFD0, "DebugMonsters", SN_NOWARN) set_name(0x800BEFF8, "glSeedTbl", SN_NOWARN) set_name(0x800BF03C, "gnLevelTypeTbl", SN_NOWARN) set_name(0x8012B819, "gbDoEnding", SN_NOWARN) set_name(0x8012B81A, "gbRunGame", SN_NOWARN) set_name(0x8012B81B, "gbRunGameResult", SN_NOWARN) set_name(0x8012B81C, "gbGameLoopStartup", SN_NOWARN) set_name(0x8012D458, "glEndSeed", SN_NOWARN) set_name(0x8012D4A8, "glMid1Seed", SN_NOWARN) set_name(0x8012D4F8, "glMid2Seed", SN_NOWARN) set_name(0x8012D548, "glMid3Seed", SN_NOWARN) set_name(0x8012C65C, "sg_previousFilter", SN_NOWARN) set_name(0x800BF080, "CreateEnv", SN_NOWARN) set_name(0x8012B820, "Passedlvldir", SN_NOWARN) set_name(0x8012B824, "TempStack", SN_NOWARN) set_name(0x8012B7C4, "ghMainWnd", SN_NOWARN) set_name(0x8012B7C8, "fullscreen", SN_NOWARN) set_name(0x8012B7CC, "force_redraw", SN_NOWARN) set_name(0x8012B7E0, "PauseMode", SN_NOWARN) set_name(0x8012B7E1, "FriendlyMode", SN_NOWARN) set_name(0x8012B7D1, "visiondebug", SN_NOWARN) set_name(0x8012B7D3, "light4flag", SN_NOWARN) set_name(0x8012B7D4, "leveldebug", SN_NOWARN) set_name(0x8012B7D5, "monstdebug", SN_NOWARN) set_name(0x8012B7DC, "debugmonsttypes", SN_NOWARN) set_name(0x8012B7D0, "cineflag", SN_NOWARN) set_name(0x8012B7D2, "scrollflag", SN_NOWARN) set_name(0x8012B7D6, "trigdebug", SN_NOWARN) set_name(0x8012B7D8, "setseed", SN_NOWARN) set_name(0x8012B7E4, "sgnTimeoutCurs", SN_NOWARN) set_name(0x8012B7E8, "sgbMouseDown", SN_NOWARN) set_name(0x800BF74C, "towner", SN_NOWARN) set_name(0x8012B83C, "numtowners", SN_NOWARN) set_name(0x8012B840, "storeflag", SN_NOWARN) set_name(0x8012B841, "boyloadflag", SN_NOWARN) set_name(0x8012B842, "bannerflag", SN_NOWARN) set_name(0x8012B844, "pCowCels", SN_NOWARN) set_name(0x8012C660, "sgdwCowClicks", SN_NOWARN) set_name(0x8012C664, "sgnCowMsg", SN_NOWARN) set_name(0x800BF48C, "Qtalklist", SN_NOWARN) set_name(0x8012B834, "CowPlaying", SN_NOWARN) set_name(0x800BF0B0, "AnimOrder", SN_NOWARN) set_name(0x800BF428, "TownCowX", SN_NOWARN) set_name(0x800BF434, "TownCowY", SN_NOWARN) set_name(0x800BF440, "TownCowDir", SN_NOWARN) set_name(0x800BF44C, "cowoffx", SN_NOWARN) set_name(0x800BF46C, "cowoffy", SN_NOWARN) set_name(0x8012B85C, "sfxdelay", SN_NOWARN) set_name(0x8012B860, "sfxdnum", SN_NOWARN) set_name(0x8012B854, "sghStream", SN_NOWARN) set_name(0x800C054C, "sgSFX", SN_NOWARN) set_name(0x8012B858, "sgpStreamSFX", SN_NOWARN) set_name(0x8012B864, "orgseed", SN_NOWARN) set_name(0x8012C668, "sglGameSeed", SN_NOWARN) set_name(0x8012B868, "SeedCount", SN_NOWARN) set_name(0x8012C66C, "sgMemCrit", SN_NOWARN) set_name(0x8012C670, "sgnWidth", SN_NOWARN) set_name(0x8012B876, "msgflag", SN_NOWARN) set_name(0x8012B877, "msgdelay", SN_NOWARN) set_name(0x800C154C, "msgtable", SN_NOWARN) set_name(0x800C149C, "MsgStrings", SN_NOWARN) set_name(0x8012B875, "msgcnt", SN_NOWARN) set_name(0x8012C674, "sgdwProgress", SN_NOWARN) set_name(0x8012C678, "sgdwXY", SN_NOWARN) set_name(0x800C159C, "AllItemsUseable", SN_NOWARN) set_name(0x80121784, "AllItemsList", SN_NOWARN) set_name(0x80122B24, "PL_Prefix", SN_NOWARN) set_name(0x80123844, "PL_Suffix", SN_NOWARN) set_name(0x80124744, "UniqueItemList", SN_NOWARN) set_name(0x800C17B0, "item", SN_NOWARN) set_name(0x800C63B0, "itemactive", SN_NOWARN) set_name(0x800C6430, "itemavail", SN_NOWARN) set_name(0x800C64B0, "UniqueItemFlag", SN_NOWARN) set_name(0x8012B8B0, "uitemflag", SN_NOWARN) set_name(0x8012C67C, "tem", SN_NOWARN) set_name(0x8012D590, "curruitem", SN_NOWARN) set_name(0x8012D630, "itemhold", SN_NOWARN) set_name(0x8012B8B4, "ScrollType", SN_NOWARN) set_name(0x800C6530, "ItemStr", SN_NOWARN) set_name(0x800C6570, "SufStr", SN_NOWARN) set_name(0x8012B890, "numitems", SN_NOWARN) set_name(0x8012B894, "gnNumGetRecords", SN_NOWARN) set_name(0x800C170C, "ItemInvSnds", SN_NOWARN) set_name(0x800C163C, "ItemCAnimTbl", SN_NOWARN) set_name(0x80126588, "Item2Frm", SN_NOWARN) set_name(0x800C16E8, "ItemAnimLs", SN_NOWARN) set_name(0x8012B898, "ItemAnimSnds", SN_NOWARN) set_name(0x8012B89C, "idoppely", SN_NOWARN) set_name(0x8012B8A0, "ScrollFlag", SN_NOWARN) set_name(0x800C1798, "premiumlvladd", SN_NOWARN) set_name(0x800C735C, "LightList", SN_NOWARN) set_name(0x800C749C, "lightactive", SN_NOWARN) set_name(0x8012B8C8, "numlights", SN_NOWARN) set_name(0x8012B8CC, "lightmax", SN_NOWARN) set_name(0x800C74C4, "VisionList", SN_NOWARN) set_name(0x8012B8D0, "numvision", SN_NOWARN) set_name(0x8012B8D4, "dovision", SN_NOWARN) set_name(0x8012B8D8, "visionid", SN_NOWARN) set_name(0x8012C680, "disp_mask", SN_NOWARN) set_name(0x8012C684, "weird", SN_NOWARN) set_name(0x8012C688, "disp_tab_r", SN_NOWARN) set_name(0x8012C68C, "dispy_r", SN_NOWARN) set_name(0x8012C690, "disp_tab_g", SN_NOWARN) set_name(0x8012C694, "dispy_g", SN_NOWARN) set_name(0x8012C698, "disp_tab_b", SN_NOWARN) set_name(0x8012C69C, "dispy_b", SN_NOWARN) set_name(0x8012C6A0, "radius", SN_NOWARN) set_name(0x8012C6A4, "bright", SN_NOWARN) set_name(0x8012D640, "mult_tab", SN_NOWARN) set_name(0x8012B8B8, "lightflag", SN_NOWARN) set_name(0x800C7070, "vCrawlTable", SN_NOWARN) set_name(0x800C7324, "RadiusAdj", SN_NOWARN) set_name(0x800C65B0, "CrawlTable", SN_NOWARN) set_name(0x8012B8BC, "restore_r", SN_NOWARN) set_name(0x8012B8C0, "restore_g", SN_NOWARN) set_name(0x8012B8C4, "restore_b", SN_NOWARN) set_name(0x800C733C, "radius_tab", SN_NOWARN) set_name(0x800C734C, "bright_tab", SN_NOWARN) set_name(0x8012B8F9, "qtextflag", SN_NOWARN) set_name(0x8012B8FC, "qtextSpd", SN_NOWARN) set_name(0x8012C6A8, "pMedTextCels", SN_NOWARN) set_name(0x8012C6AC, "pTextBoxCels", SN_NOWARN) set_name(0x8012C6B0, "qtextptr", SN_NOWARN) set_name(0x8012C6B4, "qtexty", SN_NOWARN) set_name(0x8012C6B8, "qtextDelay", SN_NOWARN) set_name(0x8012C6BC, "sgLastScroll", SN_NOWARN) set_name(0x8012C6C0, "scrolltexty", SN_NOWARN) set_name(0x8012C6C4, "sglMusicVolumeSave", SN_NOWARN) set_name(0x8012B8E8, "qtbodge", SN_NOWARN) set_name(0x800C7684, "QBack", SN_NOWARN) set_name(0x800C7694, "missiledata", SN_NOWARN) set_name(0x800C7E04, "misfiledata", SN_NOWARN) set_name(0x800C7CF4, "MissPrintRoutines", SN_NOWARN) set_name(0x800C7EF0, "sgLevels", SN_NOWARN) set_name(0x800DBC3C, "sgLocals", SN_NOWARN) set_name(0x8012D6C0, "sgJunk", SN_NOWARN) set_name(0x8012C6C9, "sgbRecvCmd", SN_NOWARN) set_name(0x8012C6CC, "sgdwRecvOffset", SN_NOWARN) set_name(0x8012C6D0, "sgbDeltaChunks", SN_NOWARN) set_name(0x8012C6D1, "sgbDeltaChanged", SN_NOWARN) set_name(0x8012C6D4, "sgdwOwnerWait", SN_NOWARN) set_name(0x8012C6D8, "sgpMegaPkt", SN_NOWARN) set_name(0x8012C6DC, "sgpCurrPkt", SN_NOWARN) set_name(0x8012C6E0, "sgnCurrMegaPlayer", SN_NOWARN) set_name(0x8012B915, "deltaload", SN_NOWARN) set_name(0x8012B916, "gbBufferMsgs", SN_NOWARN) set_name(0x8012B918, "dwRecCount", SN_NOWARN) set_name(0x8012B91C, "LevelOut", SN_NOWARN) set_name(0x8012B932, "gbMaxPlayers", SN_NOWARN) set_name(0x8012B933, "gbActivePlayers", SN_NOWARN) set_name(0x8012B934, "gbGameDestroyed", SN_NOWARN) set_name(0x8012B935, "gbDeltaSender", SN_NOWARN) set_name(0x8012B936, "gbSelectProvider", SN_NOWARN) set_name(0x8012B937, "gbSomebodyWonGameKludge", SN_NOWARN) set_name(0x8012C6E4, "sgbSentThisCycle", SN_NOWARN) set_name(0x8012C6E8, "sgdwGameLoops", SN_NOWARN) set_name(0x8012C6EC, "sgwPackPlrOffsetTbl", SN_NOWARN) set_name(0x8012C6F0, "sgbPlayerLeftGameTbl", SN_NOWARN) set_name(0x8012C6F4, "sgdwPlayerLeftReasonTbl", SN_NOWARN) set_name(0x8012C6FC, "sgbSendDeltaTbl", SN_NOWARN) set_name(0x8012C704, "sgGameInitInfo", SN_NOWARN) set_name(0x8012C70C, "sgbTimeout", SN_NOWARN) set_name(0x8012C710, "sglTimeoutStart", SN_NOWARN) set_name(0x8012B92C, "gszVersionNumber", SN_NOWARN) set_name(0x8012B931, "sgbNetInited", SN_NOWARN) set_name(0x800DCCA4, "ObjTypeConv", SN_NOWARN) set_name(0x800DCE68, "AllObjects", SN_NOWARN) set_name(0x80126C50, "ObjMasterLoadList", SN_NOWARN) set_name(0x800DD648, "object", SN_NOWARN) set_name(0x8012B958, "numobjects", SN_NOWARN) set_name(0x800DEC1C, "objectactive", SN_NOWARN) set_name(0x800DEC9C, "objectavail", SN_NOWARN) set_name(0x8012B95C, "InitObjFlag", SN_NOWARN) set_name(0x8012B960, "trapid", SN_NOWARN) set_name(0x800DED1C, "ObjFileList", SN_NOWARN) set_name(0x8012B964, "trapdir", SN_NOWARN) set_name(0x8012B968, "leverid", SN_NOWARN) set_name(0x8012B950, "numobjfiles", SN_NOWARN) set_name(0x800DD560, "bxadd", SN_NOWARN) set_name(0x800DD580, "byadd", SN_NOWARN) set_name(0x800DD608, "shrineavail", SN_NOWARN) set_name(0x800DD5A0, "shrinestrs", SN_NOWARN) set_name(0x800DD624, "StoryBookName", SN_NOWARN) set_name(0x8012B954, "myscale", SN_NOWARN) set_name(0x8012B97C, "gbValidSaveFile", SN_NOWARN) set_name(0x8012B978, "DoLoadedChar", SN_NOWARN) set_name(0x800DEF3C, "plr", SN_NOWARN) set_name(0x8012B99C, "myplr", SN_NOWARN) set_name(0x8012B9A0, "deathdelay", SN_NOWARN) set_name(0x8012B9A4, "deathflag", SN_NOWARN) set_name(0x8012B9A5, "light_rad", SN_NOWARN) set_name(0x8012B994, "light_level", SN_NOWARN) set_name(0x800DEE34, "MaxStats", SN_NOWARN) set_name(0x8012B98C, "PlrStructSize", SN_NOWARN) set_name(0x8012B990, "ItemStructSize", SN_NOWARN) set_name(0x800DED44, "plrxoff", SN_NOWARN) set_name(0x800DED68, "plryoff", SN_NOWARN) set_name(0x800DED8C, "plrxoff2", SN_NOWARN) set_name(0x800DEDB0, "plryoff2", SN_NOWARN) set_name(0x800DEDD4, "PlrGFXAnimLens", SN_NOWARN) set_name(0x800DEDF8, "StrengthTbl", SN_NOWARN) set_name(0x800DEE04, "MagicTbl", SN_NOWARN) set_name(0x800DEE10, "DexterityTbl", SN_NOWARN) set_name(0x800DEE1C, "VitalityTbl", SN_NOWARN) set_name(0x800DEE28, "ToBlkTbl", SN_NOWARN) set_name(0x800DEE64, "ExpLvlsTbl", SN_NOWARN) set_name(0x800E37C4, "quests", SN_NOWARN) set_name(0x8012B9E4, "pQLogCel", SN_NOWARN) set_name(0x8012B9E8, "ReturnLvlX", SN_NOWARN) set_name(0x8012B9EC, "ReturnLvlY", SN_NOWARN) set_name(0x8012B9F0, "ReturnLvl", SN_NOWARN) set_name(0x8012B9F4, "ReturnLvlT", SN_NOWARN) set_name(0x8012B9F8, "rporttest", SN_NOWARN) set_name(0x8012B9FC, "qline", SN_NOWARN) set_name(0x8012BA00, "numqlines", SN_NOWARN) set_name(0x8012BA04, "qtopline", SN_NOWARN) set_name(0x8012D6D8, "qlist", SN_NOWARN) set_name(0x8012C714, "QSRect", SN_NOWARN) set_name(0x8012B9B1, "questlog", SN_NOWARN) set_name(0x800E368C, "questlist", SN_NOWARN) set_name(0x8012B9B4, "ALLQUESTS", SN_NOWARN) set_name(0x800E37A0, "QuestGroup1", SN_NOWARN) set_name(0x800E37AC, "QuestGroup2", SN_NOWARN) set_name(0x800E37B8, "QuestGroup3", SN_NOWARN) set_name(0x8012B9C8, "QuestGroup4", SN_NOWARN) set_name(0x8012B9E0, "WaterDone", SN_NOWARN) set_name(0x8012B9B8, "questxoff", SN_NOWARN) set_name(0x8012B9C0, "questyoff", SN_NOWARN) set_name(0x800E378C, "questtrigstr", SN_NOWARN) set_name(0x8012B9D0, "QS_PX", SN_NOWARN) set_name(0x8012B9D4, "QS_PY", SN_NOWARN) set_name(0x8012B9D8, "QS_PW", SN_NOWARN) set_name(0x8012B9DC, "QS_PH", SN_NOWARN) set_name(0x8012D718, "QSBack", SN_NOWARN) set_name(0x800E3904, "spelldata", SN_NOWARN) set_name(0x8012BA3F, "stextflag", SN_NOWARN) set_name(0x800E41AC, "smithitem", SN_NOWARN) set_name(0x800E4D8C, "premiumitem", SN_NOWARN) set_name(0x8012BA40, "numpremium", SN_NOWARN) set_name(0x8012BA44, "premiumlevel", SN_NOWARN) set_name(0x800E511C, "witchitem", SN_NOWARN) set_name(0x800E5CFC, "boyitem", SN_NOWARN) set_name(0x8012BA48, "boylevel", SN_NOWARN) set_name(0x800E5D94, "golditem", SN_NOWARN) set_name(0x800E5E2C, "healitem", SN_NOWARN) set_name(0x8012BA4C, "stextsize", SN_NOWARN) set_name(0x8012BA4D, "stextscrl", SN_NOWARN) set_name(0x8012C71C, "stextsel", SN_NOWARN) set_name(0x8012C720, "stextlhold", SN_NOWARN) set_name(0x8012C724, "stextshold", SN_NOWARN) set_name(0x8012C728, "stextvhold", SN_NOWARN) set_name(0x8012C72C, "stextsval", SN_NOWARN) set_name(0x8012C730, "stextsmax", SN_NOWARN) set_name(0x8012C734, "stextup", SN_NOWARN) set_name(0x8012C738, "stextdown", SN_NOWARN) set_name(0x8012C73C, "stextscrlubtn", SN_NOWARN) set_name(0x8012C73D, "stextscrldbtn", SN_NOWARN) set_name(0x8012C73E, "SItemListFlag", SN_NOWARN) set_name(0x8012D728, "stext", SN_NOWARN) set_name(0x800E6A0C, "storehold", SN_NOWARN) set_name(0x800E868C, "storehidx", SN_NOWARN) set_name(0x8012C740, "storenumh", SN_NOWARN) set_name(0x8012C744, "gossipstart", SN_NOWARN) set_name(0x8012C748, "gossipend", SN_NOWARN) set_name(0x8012C74C, "StoreBackRect", SN_NOWARN) set_name(0x8012C754, "talker", SN_NOWARN) set_name(0x8012BA2C, "pSTextBoxCels", SN_NOWARN) set_name(0x8012BA30, "pSTextSlidCels", SN_NOWARN) set_name(0x8012BA34, "SStringY", SN_NOWARN) set_name(0x800E4088, "SBack", SN_NOWARN) set_name(0x800E4098, "SStringYNorm", SN_NOWARN) set_name(0x800E40E8, "SStringYBuy0", SN_NOWARN) set_name(0x800E4138, "SStringYBuy1", SN_NOWARN) set_name(0x800E4188, "talkname", SN_NOWARN) set_name(0x8012BA3E, "InStoreFlag", SN_NOWARN) set_name(0x80127EA4, "alltext", SN_NOWARN) set_name(0x8012BA5C, "gdwAllTextEntries", SN_NOWARN) set_name(0x8012C758, "P3Tiles", SN_NOWARN) set_name(0x8012BA6C, "tile", SN_NOWARN) set_name(0x8012BA7C, "_trigflag", SN_NOWARN) set_name(0x800E88F4, "trigs", SN_NOWARN) set_name(0x8012BA80, "numtrigs", SN_NOWARN) set_name(0x8012BA84, "townwarps", SN_NOWARN) set_name(0x8012BA88, "TWarpFrom", SN_NOWARN) set_name(0x800E86BC, "TownDownList", SN_NOWARN) set_name(0x800E86E8, "TownWarp1List", SN_NOWARN) set_name(0x800E871C, "L1UpList", SN_NOWARN) set_name(0x800E874C, "L1DownList", SN_NOWARN) set_name(0x800E8774, "L2UpList", SN_NOWARN) set_name(0x800E8780, "L2DownList", SN_NOWARN) set_name(0x800E8794, "L2TWarpUpList", SN_NOWARN) set_name(0x800E87A0, "L3UpList", SN_NOWARN) set_name(0x800E87DC, "L3DownList", SN_NOWARN) set_name(0x800E8800, "L3TWarpUpList", SN_NOWARN) set_name(0x800E8838, "L4UpList", SN_NOWARN) set_name(0x800E8848, "L4DownList", SN_NOWARN) set_name(0x800E8860, "L4TWarpUpList", SN_NOWARN) set_name(0x800E8870, "L4PentaList", SN_NOWARN) set_name(0x80128C34, "cursoff", SN_NOWARN) set_name(0x8012BAA2, "gbMusicOn", SN_NOWARN) set_name(0x8012BAA3, "gbSoundOn", SN_NOWARN) set_name(0x8012BAA1, "gbSndInited", SN_NOWARN) set_name(0x8012BAA8, "sglMasterVolume", SN_NOWARN) set_name(0x8012BAAC, "sglMusicVolume", SN_NOWARN) set_name(0x8012BAB0, "sglSoundVolume", SN_NOWARN) set_name(0x8012BAB4, "sglSpeechVolume", SN_NOWARN) set_name(0x8012BAB8, "sgnMusicTrack", SN_NOWARN) set_name(0x8012BAA4, "gbDupSounds", SN_NOWARN) set_name(0x8012BABC, "sghMusic", SN_NOWARN) set_name(0x80128CE0, "sgszMusicTracks", SN_NOWARN) set_name(0x8012BAE0, "_pcurr_inv", SN_NOWARN) set_name(0x800E8944, "_pfind_list", SN_NOWARN) set_name(0x8012BAE8, "_pfind_index", SN_NOWARN) set_name(0x8012BAEC, "_pfindx", SN_NOWARN) set_name(0x8012BAF0, "_pfindy", SN_NOWARN) set_name(0x8012BAF2, "automapmoved", SN_NOWARN) set_name(0x8012BAD4, "flyflag", SN_NOWARN) set_name(0x8012BACC, "pad_styles", SN_NOWARN) set_name(0x8012BAD5, "speed_type", SN_NOWARN) set_name(0x8012BAD6, "sel_speed", SN_NOWARN) set_name(0x8012C75C, "CurrentProc", SN_NOWARN) set_name(0x80128E7C, "AllMsgs", SN_NOWARN) set_name(0x8012BB2C, "NumOfStrings", SN_NOWARN) set_name(0x8012BB00, "LanguageType", SN_NOWARN) set_name(0x8012BB04, "hndText", SN_NOWARN) set_name(0x8012BB08, "TextPtr", SN_NOWARN) set_name(0x8012BB0C, "LangDbNo", SN_NOWARN) set_name(0x8012BB3C, "MissDat", SN_NOWARN) set_name(0x8012BB40, "CharFade", SN_NOWARN) set_name(0x8012BB44, "rotateness", SN_NOWARN) set_name(0x8012BB48, "spiralling_shape", SN_NOWARN) set_name(0x8012BB4C, "down", SN_NOWARN) set_name(0x800E8994, "MlTab", SN_NOWARN) set_name(0x800E89A4, "QlTab", SN_NOWARN) set_name(0x800E89B4, "ObjPrintFuncs", SN_NOWARN) set_name(0x8012BB68, "MyXoff1", SN_NOWARN) set_name(0x8012BB6C, "MyYoff1", SN_NOWARN) set_name(0x8012BB70, "MyXoff2", SN_NOWARN) set_name(0x8012BB74, "MyYoff2", SN_NOWARN) set_name(0x8012BB84, "iscflag", SN_NOWARN) set_name(0x8012BB91, "sgbFadedIn", SN_NOWARN) set_name(0x8012BB92, "screenbright", SN_NOWARN) set_name(0x8012BB94, "faderate", SN_NOWARN) set_name(0x8012BB98, "fading", SN_NOWARN) set_name(0x8012BBA4, "FadeCoords", SN_NOWARN) set_name(0x8012BB9C, "st", SN_NOWARN) set_name(0x8012BBA0, "mode", SN_NOWARN) set_name(0x800E8B3C, "portal", SN_NOWARN) set_name(0x8012BBD6, "portalindex", SN_NOWARN) set_name(0x8012BBD0, "WarpDropX", SN_NOWARN) set_name(0x8012BBD4, "WarpDropY", SN_NOWARN) set_name(0x800E8B54, "MyVerString", SN_NOWARN) set_name(0x8012BD48, "Year", SN_NOWARN) set_name(0x8012BD4C, "Day", SN_NOWARN) set_name(0x8012C760, "tbuff", SN_NOWARN) set_name(0x800E8BCC, "IconBuffer", SN_NOWARN) set_name(0x8012C764, "HR1", SN_NOWARN) set_name(0x8012C765, "HR2", SN_NOWARN) set_name(0x8012C766, "HR3", SN_NOWARN) set_name(0x8012C767, "VR1", SN_NOWARN) set_name(0x8012C768, "VR2", SN_NOWARN) set_name(0x8012C769, "VR3", SN_NOWARN) set_name(0x8012BDBC, "pHallList", SN_NOWARN) set_name(0x8012BDC0, "nRoomCnt", SN_NOWARN) set_name(0x8012BDC4, "nSx1", SN_NOWARN) set_name(0x8012BDC8, "nSy1", SN_NOWARN) set_name(0x8012BDCC, "nSx2", SN_NOWARN) set_name(0x8012BDD0, "nSy2", SN_NOWARN) set_name(0x8012BD74, "Area_Min", SN_NOWARN) set_name(0x8012BD78, "Room_Max", SN_NOWARN) set_name(0x8012BD7C, "Room_Min", SN_NOWARN) set_name(0x8012BD80, "BIG3", SN_NOWARN) set_name(0x8012BD88, "BIG4", SN_NOWARN) set_name(0x8012BD90, "BIG6", SN_NOWARN) set_name(0x8012BD98, "BIG7", SN_NOWARN) set_name(0x8012BDA0, "RUINS1", SN_NOWARN) set_name(0x8012BDA4, "RUINS2", SN_NOWARN) set_name(0x8012BDA8, "RUINS3", SN_NOWARN) set_name(0x8012BDAC, "RUINS4", SN_NOWARN) set_name(0x8012BDB0, "RUINS5", SN_NOWARN) set_name(0x8012BDB4, "RUINS6", SN_NOWARN) set_name(0x8012BDB8, "RUINS7", SN_NOWARN) set_name(0x8012C76C, "abyssx", SN_NOWARN) set_name(0x8012C770, "lavapool", SN_NOWARN) set_name(0x8012BE5C, "lockoutcnt", SN_NOWARN) set_name(0x8012BDE0, "L3TITE12", SN_NOWARN) set_name(0x8012BDE8, "L3TITE13", SN_NOWARN) set_name(0x8012BDF0, "L3CREV1", SN_NOWARN) set_name(0x8012BDF8, "L3CREV2", SN_NOWARN) set_name(0x8012BE00, "L3CREV3", SN_NOWARN) set_name(0x8012BE08, "L3CREV4", SN_NOWARN) set_name(0x8012BE10, "L3CREV5", SN_NOWARN) set_name(0x8012BE18, "L3CREV6", SN_NOWARN) set_name(0x8012BE20, "L3CREV7", SN_NOWARN) set_name(0x8012BE28, "L3CREV8", SN_NOWARN) set_name(0x8012BE30, "L3CREV9", SN_NOWARN) set_name(0x8012BE38, "L3CREV10", SN_NOWARN) set_name(0x8012BE40, "L3CREV11", SN_NOWARN) set_name(0x8012BE48, "L3XTRA1", SN_NOWARN) set_name(0x8012BE4C, "L3XTRA2", SN_NOWARN) set_name(0x8012BE50, "L3XTRA3", SN_NOWARN) set_name(0x8012BE54, "L3XTRA4", SN_NOWARN) set_name(0x8012BE58, "L3XTRA5", SN_NOWARN) set_name(0x8012BE60, "diabquad1x", SN_NOWARN) set_name(0x8012BE64, "diabquad2x", SN_NOWARN) set_name(0x8012BE68, "diabquad3x", SN_NOWARN) set_name(0x8012BE6C, "diabquad4x", SN_NOWARN) set_name(0x8012BE70, "diabquad1y", SN_NOWARN) set_name(0x8012BE74, "diabquad2y", SN_NOWARN) set_name(0x8012BE78, "diabquad3y", SN_NOWARN) set_name(0x8012BE7C, "diabquad4y", SN_NOWARN) set_name(0x8012BE80, "SP4x1", SN_NOWARN) set_name(0x8012BE84, "SP4y1", SN_NOWARN) set_name(0x8012BE88, "SP4x2", SN_NOWARN) set_name(0x8012BE8C, "SP4y2", SN_NOWARN) set_name(0x8012BE90, "l4holdx", SN_NOWARN) set_name(0x8012BE94, "l4holdy", SN_NOWARN) set_name(0x8012C774, "lpSetPiece1", SN_NOWARN) set_name(0x8012C778, "lpSetPiece2", SN_NOWARN) set_name(0x8012C77C, "lpSetPiece3", SN_NOWARN) set_name(0x8012C780, "lpSetPiece4", SN_NOWARN) set_name(0x8012BEA4, "SkelKingTrans1", SN_NOWARN) set_name(0x8012BEAC, "SkelKingTrans2", SN_NOWARN) set_name(0x800E8ECC, "SkelKingTrans3", SN_NOWARN) set_name(0x800E8EE0, "SkelKingTrans4", SN_NOWARN) set_name(0x800E8EFC, "SkelChamTrans1", SN_NOWARN) set_name(0x8012BEB4, "SkelChamTrans2", SN_NOWARN) set_name(0x800E8F10, "SkelChamTrans3", SN_NOWARN) set_name(0x8012BFA8, "DoUiForChooseMonster", SN_NOWARN) set_name(0x800E8F34, "MgToText", SN_NOWARN) set_name(0x800E8FBC, "StoryText", SN_NOWARN) set_name(0x800E8FE0, "dungeon", SN_NOWARN) set_name(0x800EA1E0, "pdungeon", SN_NOWARN) set_name(0x800EA820, "dflags", SN_NOWARN) set_name(0x8012BFCC, "setpc_x", SN_NOWARN) set_name(0x8012BFD0, "setpc_y", SN_NOWARN) set_name(0x8012BFD4, "setpc_w", SN_NOWARN) set_name(0x8012BFD8, "setpc_h", SN_NOWARN) set_name(0x8012BFDC, "setloadflag", SN_NOWARN) set_name(0x8012BFE0, "pMegaTiles", SN_NOWARN) set_name(0x800EAE60, "nBlockTable", SN_NOWARN) set_name(0x800EB664, "nSolidTable", SN_NOWARN) set_name(0x800EBE68, "nTransTable", SN_NOWARN) set_name(0x800EC66C, "nMissileTable", SN_NOWARN) set_name(0x800ECE70, "nTrapTable", SN_NOWARN) set_name(0x8012BFE4, "dminx", SN_NOWARN) set_name(0x8012BFE8, "dminy", SN_NOWARN) set_name(0x8012BFEC, "dmaxx", SN_NOWARN) set_name(0x8012BFF0, "dmaxy", SN_NOWARN) set_name(0x8012BFF4, "gnDifficulty", SN_NOWARN) set_name(0x8012BFF8, "currlevel", SN_NOWARN) set_name(0x8012BFF9, "leveltype", SN_NOWARN) set_name(0x8012BFFA, "setlevel", SN_NOWARN) set_name(0x8012BFFB, "setlvlnum", SN_NOWARN) set_name(0x8012BFFC, "setlvltype", SN_NOWARN) set_name(0x8012C000, "ViewX", SN_NOWARN) set_name(0x8012C004, "ViewY", SN_NOWARN) set_name(0x8012C008, "ViewDX", SN_NOWARN) set_name(0x8012C00C, "ViewDY", SN_NOWARN) set_name(0x8012C010, "ViewBX", SN_NOWARN) set_name(0x8012C014, "ViewBY", SN_NOWARN) set_name(0x800ED674, "ScrollInfo", SN_NOWARN) set_name(0x8012C018, "LvlViewX", SN_NOWARN) set_name(0x8012C01C, "LvlViewY", SN_NOWARN) set_name(0x8012C020, "btmbx", SN_NOWARN) set_name(0x8012C024, "btmby", SN_NOWARN) set_name(0x8012C028, "btmdx", SN_NOWARN) set_name(0x8012C02C, "btmdy", SN_NOWARN) set_name(0x8012C030, "MicroTileLen", SN_NOWARN) set_name(0x8012C034, "TransVal", SN_NOWARN) set_name(0x800ED688, "TransList", SN_NOWARN) set_name(0x8012C038, "themeCount", SN_NOWARN) set_name(0x800ED6A8, "dung_map", SN_NOWARN) set_name(0x8010F968, "dung_map_r", SN_NOWARN) set_name(0x801104CC, "dung_map_g", SN_NOWARN) set_name(0x80111030, "dung_map_b", SN_NOWARN) set_name(0x80111B94, "MinisetXY", SN_NOWARN) set_name(0x8012BFC4, "pSetPiece", SN_NOWARN) set_name(0x8012BFC8, "DungSize", SN_NOWARN) set_name(0x80111D60, "theme", SN_NOWARN) set_name(0x8012C078, "numthemes", SN_NOWARN) set_name(0x8012C07C, "zharlib", SN_NOWARN) set_name(0x8012C080, "armorFlag", SN_NOWARN) set_name(0x8012C081, "bCrossFlag", SN_NOWARN) set_name(0x8012C082, "weaponFlag", SN_NOWARN) set_name(0x8012C084, "themex", SN_NOWARN) set_name(0x8012C088, "themey", SN_NOWARN) set_name(0x8012C08C, "themeVar1", SN_NOWARN) set_name(0x8012C090, "bFountainFlag", SN_NOWARN) set_name(0x8012C091, "cauldronFlag", SN_NOWARN) set_name(0x8012C092, "mFountainFlag", SN_NOWARN) set_name(0x8012C093, "pFountainFlag", SN_NOWARN) set_name(0x8012C094, "tFountainFlag", SN_NOWARN) set_name(0x8012C095, "treasureFlag", SN_NOWARN) set_name(0x8012C098, "ThemeGoodIn", SN_NOWARN) set_name(0x80111C40, "ThemeGood", SN_NOWARN) set_name(0x80111C50, "trm5x", SN_NOWARN) set_name(0x80111CB4, "trm5y", SN_NOWARN) set_name(0x80111D18, "trm3x", SN_NOWARN) set_name(0x80111D3C, "trm3y", SN_NOWARN) set_name(0x8012C170, "nummissiles", SN_NOWARN) set_name(0x80111F78, "missileactive", SN_NOWARN) set_name(0x8011216C, "missileavail", SN_NOWARN) set_name(0x8012C174, "MissilePreFlag", SN_NOWARN) set_name(0x80112360, "missile", SN_NOWARN) set_name(0x8012C175, "ManashieldFlag", SN_NOWARN) set_name(0x8012C176, "ManashieldFlag2", SN_NOWARN) set_name(0x80111EF0, "XDirAdd", SN_NOWARN) set_name(0x80111F10, "YDirAdd", SN_NOWARN) set_name(0x8012C13D, "fadetor", SN_NOWARN) set_name(0x8012C13E, "fadetog", SN_NOWARN) set_name(0x8012C13F, "fadetob", SN_NOWARN) set_name(0x80111F30, "ValueTable", SN_NOWARN) set_name(0x80111F40, "StringTable", SN_NOWARN) set_name(0x80114C10, "monster", SN_NOWARN) set_name(0x8012C1D4, "nummonsters", SN_NOWARN) set_name(0x8011A390, "monstactive", SN_NOWARN) set_name(0x8011A520, "monstkills", SN_NOWARN) set_name(0x8011A6B0, "Monsters", SN_NOWARN) set_name(0x8012C1D8, "monstimgtot", SN_NOWARN) set_name(0x8012C1DC, "totalmonsters", SN_NOWARN) set_name(0x8012C1E0, "uniquetrans", SN_NOWARN) set_name(0x8012C784, "sgbSaveSoundOn", SN_NOWARN) set_name(0x8012C1A8, "offset_x", SN_NOWARN) set_name(0x8012C1B0, "offset_y", SN_NOWARN) set_name(0x8012C190, "left", SN_NOWARN) set_name(0x8012C198, "right", SN_NOWARN) set_name(0x8012C1A0, "opposite", SN_NOWARN) set_name(0x8012C184, "nummtypes", SN_NOWARN) set_name(0x8012C188, "animletter", SN_NOWARN) set_name(0x80114A70, "MWVel", SN_NOWARN) set_name(0x8012C1B8, "rnd5", SN_NOWARN) set_name(0x8012C1BC, "rnd10", SN_NOWARN) set_name(0x8012C1C0, "rnd20", SN_NOWARN) set_name(0x8012C1C4, "rnd60", SN_NOWARN) set_name(0x80114B90, "AiProc", SN_NOWARN) set_name(0x8011AB88, "monsterdata", SN_NOWARN) set_name(0x8011C5C8, "MonstConvTbl", SN_NOWARN) set_name(0x8011C648, "MonstAvailTbl", SN_NOWARN) set_name(0x8011C6B8, "UniqMonst", SN_NOWARN) set_name(0x8011A970, "TransPals", SN_NOWARN) set_name(0x8011A870, "StonePals", SN_NOWARN) set_name(0x8012C210, "invflag", SN_NOWARN) set_name(0x8012C211, "drawsbarflag", SN_NOWARN) set_name(0x8012C214, "InvBackY", SN_NOWARN) set_name(0x8012C218, "InvCursPos", SN_NOWARN) set_name(0x8011D660, "InvSlotTable", SN_NOWARN) set_name(0x8012C21C, "InvBackAY", SN_NOWARN) set_name(0x8012C220, "InvSel", SN_NOWARN) set_name(0x8012C224, "ItemW", SN_NOWARN) set_name(0x8012C228, "ItemH", SN_NOWARN) set_name(0x8012C22C, "ItemNo", SN_NOWARN) set_name(0x8012C230, "BRect", SN_NOWARN) set_name(0x8012C200, "InvPanelTData", SN_NOWARN) set_name(0x8012C204, "InvGfxTData", SN_NOWARN) set_name(0x8012C1FC, "InvPageNo", SN_NOWARN) set_name(0x8011CFE8, "AP2x2Tbl", SN_NOWARN) set_name(0x8011D010, "InvRect", SN_NOWARN) set_name(0x8011D258, "InvGfxTable", SN_NOWARN) set_name(0x8011D4F8, "InvItemWidth", SN_NOWARN) set_name(0x8011D5AC, "InvItemHeight", SN_NOWARN) set_name(0x8012C208, "InvOn", SN_NOWARN) set_name(0x8012C20C, "sgdwLastTime", SN_NOWARN) set_name(0x8012C25A, "automapflag", SN_NOWARN) set_name(0x8011D6AC, "automapview", SN_NOWARN) set_name(0x8011D774, "automaptype", SN_NOWARN) set_name(0x8012C25B, "AMLWallFlag", SN_NOWARN) set_name(0x8012C25C, "AMRWallFlag", SN_NOWARN) set_name(0x8012C25D, "AMLLWallFlag", SN_NOWARN) set_name(0x8012C25E, "AMLRWallFlag", SN_NOWARN) set_name(0x8012C25F, "AMDirtFlag", SN_NOWARN) set_name(0x8012C260, "AMColumnFlag", SN_NOWARN) set_name(0x8012C261, "AMStairFlag", SN_NOWARN) set_name(0x8012C262, "AMLDoorFlag", SN_NOWARN) set_name(0x8012C263, "AMLGrateFlag", SN_NOWARN) set_name(0x8012C264, "AMLArchFlag", SN_NOWARN) set_name(0x8012C265, "AMRDoorFlag", SN_NOWARN) set_name(0x8012C266, "AMRGrateFlag", SN_NOWARN) set_name(0x8012C267, "AMRArchFlag", SN_NOWARN) set_name(0x8012C268, "AutoMapX", SN_NOWARN) set_name(0x8012C26C, "AutoMapY", SN_NOWARN) set_name(0x8012C270, "AutoMapXOfs", SN_NOWARN) set_name(0x8012C274, "AutoMapYOfs", SN_NOWARN) set_name(0x8012C278, "AMPlayerX", SN_NOWARN) set_name(0x8012C27C, "AMPlayerY", SN_NOWARN) set_name(0x8012C244, "AutoMapScale", SN_NOWARN) set_name(0x8012C248, "AutoMapPlayerR", SN_NOWARN) set_name(0x8012C249, "AutoMapPlayerG", SN_NOWARN) set_name(0x8012C24A, "AutoMapPlayerB", SN_NOWARN) set_name(0x8012C24B, "AutoMapWallR", SN_NOWARN) set_name(0x8012C24C, "AutoMapWallG", SN_NOWARN) set_name(0x8012C24D, "AutoMapWallB", SN_NOWARN) set_name(0x8012C24E, "AutoMapDoorR", SN_NOWARN) set_name(0x8012C24F, "AutoMapDoorG", SN_NOWARN) set_name(0x8012C250, "AutoMapDoorB", SN_NOWARN) set_name(0x8012C251, "AutoMapColumnR", SN_NOWARN) set_name(0x8012C252, "AutoMapColumnG", SN_NOWARN) set_name(0x8012C253, "AutoMapColumnB", SN_NOWARN) set_name(0x8012C254, "AutoMapArchR", SN_NOWARN) set_name(0x8012C255, "AutoMapArchG", SN_NOWARN) set_name(0x8012C256, "AutoMapArchB", SN_NOWARN) set_name(0x8012C257, "AutoMapStairR", SN_NOWARN) set_name(0x8012C258, "AutoMapStairG", SN_NOWARN) set_name(0x8012C259, "AutoMapStairB", SN_NOWARN) set_name(0x8012C8E0, "GazTick", SN_NOWARN) set_name(0x80133218, "RndTabs", SN_NOWARN) set_name(0x800A687C, "DefaultRnd", SN_NOWARN) set_name(0x8012C908, "PollFunc", SN_NOWARN) set_name(0x8012C8EC, "MsgFunc", SN_NOWARN) set_name(0x8012C938, "ErrorFunc", SN_NOWARN) set_name(0x8012C80C, "ActiveTasks", SN_NOWARN) set_name(0x8012C810, "CurrentTask", SN_NOWARN) set_name(0x8012C814, "T", SN_NOWARN) set_name(0x8012C818, "MemTypeForTasker", SN_NOWARN) set_name(0x80130A48, "SchEnv", SN_NOWARN) set_name(0x8012C81C, "ExecId", SN_NOWARN) set_name(0x8012C820, "ExecMask", SN_NOWARN) set_name(0x8012C824, "TasksActive", SN_NOWARN) set_name(0x8012C828, "EpiFunc", SN_NOWARN) set_name(0x8012C82C, "ProFunc", SN_NOWARN) set_name(0x8012C830, "EpiProId", SN_NOWARN) set_name(0x8012C834, "EpiProMask", SN_NOWARN) set_name(0x8012C838, "DoTasksPrologue", SN_NOWARN) set_name(0x8012C83C, "DoTasksEpilogue", SN_NOWARN) set_name(0x8012C840, "StackFloodCallback", SN_NOWARN) set_name(0x8012C844, "ExtraStackProtection", SN_NOWARN) set_name(0x8012C848, "ExtraStackSizeLongs", SN_NOWARN) set_name(0x8012C8F4, "LastPtr", SN_NOWARN) set_name(0x800A68B4, "WorkMemInfo", SN_NOWARN) set_name(0x8012C84C, "MemInitBlocks", SN_NOWARN) set_name(0x80130A78, "MemHdrBlocks", SN_NOWARN) set_name(0x8012C850, "FreeBlocks", SN_NOWARN) set_name(0x8012C854, "LastError", SN_NOWARN) set_name(0x8012C858, "TimeStamp", SN_NOWARN) set_name(0x8012C85C, "FullErrorChecking", SN_NOWARN) set_name(0x8012C860, "LastAttemptedAlloc", SN_NOWARN) set_name(0x8012C864, "LastDeallocedBlock", SN_NOWARN) set_name(0x8012C868, "VerbLev", SN_NOWARN) set_name(0x8012C86C, "NumOfFreeHdrs", SN_NOWARN) set_name(0x8012C870, "LastTypeAlloced", SN_NOWARN) set_name(0x8012C874, "AllocFilter", SN_NOWARN) set_name(0x800A68BC, "GalErrors", SN_NOWARN) set_name(0x800A68E4, "PhantomMem", SN_NOWARN) set_name(0x80131BF8, "buf", SN_NOWARN) set_name(0x800A690C, "NULL_REP", SN_NOWARN)
53.351376
94
0.831358
4a243a0e5213c7d873bd91b7a8941e0f0f1300e8
1,778
py
Python
scripts/select_ref_by_ANI/parse_closest_ANI.py
nickp60/riboSeed
636eaf78a1bbe4517c43ddb120e5ca5bb2b97212
[ "MIT" ]
7
2017-02-04T14:33:36.000Z
2021-02-14T21:03:33.000Z
scripts/select_ref_by_ANI/parse_closest_ANI.py
nickp60/riboSeed
636eaf78a1bbe4517c43ddb120e5ca5bb2b97212
[ "MIT" ]
11
2017-03-13T15:23:20.000Z
2020-06-30T17:34:56.000Z
scripts/select_ref_by_ANI/parse_closest_ANI.py
nickp60/riboSeed
636eaf78a1bbe4517c43ddb120e5ca5bb2b97212
[ "MIT" ]
3
2017-08-10T12:14:22.000Z
2022-03-27T14:35:12.000Z
import sys counter = 0 matrix = [] with open(sys.argv[1], 'r') as inf: for line in inf: thisline = line.strip().split("\t") matrix.append(thisline) # for i,x in enumerate(thisline): # if x == "contigs" or x == "scaffolds": # print(i + 2) # unix indexes at 1, and line starts with a blak tab # sys.exit() # raise ValueError("contigs not found in header") # just start by getting the first forward comparison (ie, the vertical part of the matrix # we assume rthere is just one entry # lets transpose this tmatrix = list(map(list, zip(*matrix))) # print(tmatrix) # get the index of the row/column with id "contigs* contigs_idx = [i for i, x in enumerate(tmatrix) if x[0].startswith("contigs") or x[0].startswith("run")][0] # print(contigs_idx) # select our headers headers = matrix[0] # note here that we have to trim the first column from the row of interest, we have one less header column than the rest of the rows, cause the first one is empty line_of_interest = sorted(zip(headers, tmatrix[contigs_idx][1:]), key=lambda x: x[1], reverse=True) # print(line_of_interest) # bam # we need to do this stupid loop thing because if there is a score tie, the contigs # entry won't neccesdarily be first. So, we go through the line, printing the first entry that doesnt start with "contigs" and isn't identical (probably an artifact) for pair in line_of_interest: # the new version appends _## to the names if not (pair[0].startswith("contigs") or pair[0].startswith("run")) and pair[1] != "1": closest_id = "_".join(pair[0].split("_")[0:-1]) closest_id_perc = pair[1] print("{0}\t{1}".format(closest_id, closest_id_perc)) sys.exit(0) # print(line_of_interest[1][0])
42.333333
166
0.673228
4a243a51f1c3704674b477f2c65030fc5b33c2c9
563
py
Python
setup.py
gsgoncalves/K-NRM
b7bc8c44ddf6c8d0bc14a399beb05c9c1956fe2f
[ "BSD-3-Clause" ]
198
2017-11-02T18:11:44.000Z
2022-03-26T00:03:03.000Z
setup.py
gsgoncalves/K-NRM
b7bc8c44ddf6c8d0bc14a399beb05c9c1956fe2f
[ "BSD-3-Clause" ]
18
2017-11-14T08:04:21.000Z
2022-01-14T09:09:45.000Z
setup.py
gsgoncalves/K-NRM
b7bc8c44ddf6c8d0bc14a399beb05c9c1956fe2f
[ "BSD-3-Clause" ]
43
2017-11-02T16:43:35.000Z
2021-06-13T09:22:13.000Z
# Copyright (c) 2017, Carnegie Mellon University. All rights reserved. # # Use of the K-NRM package is subject to the terms of the software license set # forth in the LICENSE file included with this software, and also available at # https://github.com/AdeDZY/K-NRM/blob/master/LICENSE from setuptools import setup from setuptools import find_packages setup(name='knrm', version='0', description='knrm', author='Zhuyun Dai and Chenyan Xiong', install_requires=['numpy', 'traitlets', 'tensorflow'], packages=find_packages() )
31.277778
78
0.719361
4a243ac384738f4049463481ea23f2ed51c9119f
88,475
py
Python
modules/templates/RLPPTM/helpers.py
nursix/gims
6401aa82726bf79986c266a4f7a98a5de83e6c13
[ "MIT" ]
null
null
null
modules/templates/RLPPTM/helpers.py
nursix/gims
6401aa82726bf79986c266a4f7a98a5de83e6c13
[ "MIT" ]
null
null
null
modules/templates/RLPPTM/helpers.py
nursix/gims
6401aa82726bf79986c266a4f7a98a5de83e6c13
[ "MIT" ]
null
null
null
""" Helper functions and classes for RLPPTM License: MIT """ import json from dateutil import rrule from gluon import current, Field, \ CRYPT, IS_EMAIL, IS_IN_SET, IS_LOWER, IS_NOT_IN_DB, \ SQLFORM, A, DIV, H4, H5, I, INPUT, LI, P, SPAN, TABLE, TD, TH, TR, UL from core import ICON, IS_FLOAT_AMOUNT, JSONERRORS, S3DateTime, \ CRUDMethod, S3Represent, s3_fullname, s3_mark_required, s3_str from s3db.pr import pr_PersonRepresentContact # ============================================================================= def get_role_realms(role): """ Get all realms for which a role has been assigned Args: role: the role ID or role UUID Returns: list of pe_ids the current user has the role for, None if the role is assigned site-wide, or an empty list if the user does not have the role, or no realm for the role """ db = current.db auth = current.auth s3db = current.s3db if isinstance(role, str): gtable = auth.settings.table_group query = (gtable.uuid == role) & \ (gtable.deleted == False) row = db(query).select(gtable.id, cache = s3db.cache, limitby = (0, 1), ).first() role_id = row.id if row else None else: role_id = role role_realms = [] user = auth.user if user: role_realms = user.realms.get(role_id, role_realms) return role_realms # ============================================================================= def get_managed_facilities(role="ORG_ADMIN", public_only=True, cacheable=True): """ Get test stations managed by the current user Args: role: the user role to consider public_only: only include sites with PUBLIC=Y tag Returns: list of site_ids """ s3db = current.s3db ftable = s3db.org_facility query = (ftable.obsolete == False) & \ (ftable.deleted == False) realms = get_role_realms(role) if realms: query = (ftable.realm_entity.belongs(realms)) & query elif realms is not None: # User does not have the required role, or at least not for any realms return realms if public_only: ttable = s3db.org_site_tag join = ttable.on((ttable.site_id == ftable.site_id) & \ (ttable.tag == "PUBLIC") & \ (ttable.deleted == False)) query &= (ttable.value == "Y") else: join = None sites = current.db(query).select(ftable.site_id, cache = s3db.cache if cacheable else None, join = join, ) return [s.site_id for s in sites] # ============================================================================= def get_managed_orgs(group=None, cacheable=True): """ Get organisations managed by the current user Args: group: the organisation group cacheable: whether the result can be cached Returns: list of organisation_ids """ s3db = current.s3db otable = s3db.org_organisation query = (otable.deleted == False) realms = get_role_realms("ORG_ADMIN") if realms: query = (otable.realm_entity.belongs(realms)) & query elif realms is not None: # User does not have the required role, or at least not for any realms return [] if group: gtable = s3db.org_group mtable = s3db.org_group_membership join = [gtable.on((mtable.organisation_id == otable.id) & \ (mtable.deleted == False) & \ (gtable.id == mtable.group_id) & \ (gtable.name == group) )] else: join = None orgs = current.db(query).select(otable.id, cache = s3db.cache if cacheable else None, join = join, ) return [o.id for o in orgs] # ============================================================================= def get_org_accounts(organisation_id): """ Get all user accounts linked to an organisation Args: organisation_id: the organisation ID Returns: tuple (active, disabled, invited), each being a list of user accounts (auth_user Rows) """ auth = current.auth s3db = current.s3db utable = auth.settings.table_user oltable = s3db.org_organisation_user pltable = s3db.pr_person_user join = oltable.on((oltable.user_id == utable.id) & \ (oltable.deleted == False)) left = pltable.on((pltable.user_id == utable.id) & \ (pltable.deleted == False)) query = (oltable.organisation_id == organisation_id) rows = current.db(query).select(utable.id, utable.first_name, utable.last_name, utable.email, utable.registration_key, pltable.pe_id, join = join, left = left, ) active, disabled, invited = [], [], [] for row in rows: user = row[utable] person_link = row.pr_person_user if person_link.pe_id: if user.registration_key: disabled.append(user) else: active.append(user) else: invited.append(user) return active, disabled, invited # ----------------------------------------------------------------------------- def get_role_users(role_uid, pe_id=None, organisation_id=None): """ Look up users with a certain user role for a certain organisation Args: role_uid: the role UUID pe_id: the pe_id of the organisation, or organisation_id: the organisation_id Returns: a dict {user_id: pe_id} of all active users with this role for the organisation """ db = current.db auth = current.auth s3db = current.s3db if not pe_id and organisation_id: # Look up the realm pe_id from the organisation otable = s3db.org_organisation query = (otable.id == organisation_id) & \ (otable.deleted == False) organisation = db(query).select(otable.pe_id, limitby = (0, 1), ).first() pe_id = organisation.pe_id if organisation else None # Get all users with this realm as direct OU ancestor from s3db.pr import pr_realm_users users = pr_realm_users(pe_id) if pe_id else None if users: # Look up those among the realm users who have # the role for either pe_id or for their default realm gtable = auth.settings.table_group mtable = auth.settings.table_membership ltable = s3db.pr_person_user utable = auth.settings.table_user join = [mtable.on((mtable.user_id == ltable.user_id) & \ ((mtable.pe_id == None) | (mtable.pe_id == pe_id)) & \ (mtable.deleted == False)), gtable.on((gtable.id == mtable.group_id) & \ (gtable.uuid == role_uid)), # Only verified+active accounts: utable.on((utable.id == mtable.user_id) & \ ((utable.registration_key == None) | \ (utable.registration_key == ""))) ] query = (ltable.user_id.belongs(set(users.keys()))) & \ (ltable.deleted == False) rows = db(query).select(ltable.user_id, ltable.pe_id, join = join, ) users = {row.user_id: row.pe_id for row in rows} return users if users else None # ----------------------------------------------------------------------------- def get_role_emails(role_uid, pe_id=None, organisation_id=None): """ Look up the emails addresses of users with a certain user role for a certain organisation Args: role_uid: the role UUID pe_id: the pe_id of the organisation, or organisation_id: the organisation_id Returns: a list of email addresses """ contacts = None users = get_role_users(role_uid, pe_id = pe_id, organisation_id = organisation_id, ) if users: # Look up their email addresses ctable = current.s3db.pr_contact query = (ctable.pe_id.belongs(set(users.values()))) & \ (ctable.contact_method == "EMAIL") & \ (ctable.deleted == False) rows = current.db(query).select(ctable.value, orderby = ~ctable.priority, ) contacts = list(set(row.value for row in rows)) return contacts if contacts else None # ----------------------------------------------------------------------------- def get_role_hrs(role_uid, pe_id=None, organisation_id=None): """ Look up the HR records of users with a certain user role for a certain organisation Args: role_uid: the role UUID pe_id: the pe_id of the organisation, or organisation_id: the organisation_id Returns: a list of hrm_human_resource IDs """ hr_ids = None users = get_role_users(role_uid, pe_id = pe_id, organisation_id = organisation_id, ) if users: # Look up their HR records s3db = current.s3db ptable = s3db.pr_person htable = s3db.hrm_human_resource join = htable.on((htable.person_id == ptable.id) & \ (htable.deleted == False)) query = (ptable.pe_id.belongs(set(users.values()))) & \ (ptable.deleted == False) rows = current.db(query).select(htable.id, join = join, ) hr_ids = list(set(row.id for row in rows)) return hr_ids if hr_ids else None # ----------------------------------------------------------------------------- def is_org_group(organisation_id, group, cacheable=True): """ Check whether an organisation is member of an organisation group Args: organisation_id: the organisation ID group: the organisation group name Returns: boolean """ s3db = current.s3db gtable = s3db.org_group mtable = s3db.org_group_membership join = [gtable.on((gtable.id == mtable.group_id) & \ (gtable.name == group) )] query = (mtable.organisation_id == organisation_id) & \ (mtable.deleted == False) row = current.db(query).select(mtable.id, cache = s3db.cache, join = join, limitby = (0, 1), ).first() return bool(row) # ----------------------------------------------------------------------------- def is_org_type_tag(organisation_id, tag, value=None): """ Check if a type of an organisation has a certain tag Args: organisation_id: the organisation ID tag: the tag name value: the tag value (optional) Returns: boolean """ db = current.db s3db = current.s3db ltable = s3db.org_organisation_organisation_type ttable = s3db.org_organisation_type_tag joinq = (ttable.organisation_type_id == ltable.organisation_type_id) & \ (ttable.tag == tag) if value is not None: joinq &= (ttable.value == value) join = ttable.on(joinq & (ttable.deleted == False)) query = (ltable.organisation_id == organisation_id) & \ (ltable.deleted == False) row = db(query).select(ttable.id, join=join, limitby=(0, 1)).first() return bool(row) # ----------------------------------------------------------------------------- def restrict_data_formats(r): """ Restrict data exports (prevent S3XML/S3JSON of records) Args: r: the CRUDRequest """ settings = current.deployment_settings allowed = ("html", "iframe", "popup", "aadata", "plain", "geojson", "pdf", "xls") if r.record: allowed += ("card",) if r.method in ("report", "timeplot", "filter", "lookup", "info"): allowed += ("json",) elif r.method == "options": allowed += ("s3json",) settings.ui.export_formats = ("pdf", "xls") if r.representation not in allowed: r.error(403, current.ERROR.NOT_PERMITTED) # ----------------------------------------------------------------------------- def assign_pending_invoices(billing_id, organisation_id=None, invoice_id=None): """ Auto-assign pending invoices in a billing to accountants, taking into account their current workload Args: billing_id: the billing ID organisation_id: the ID of the accountant organisation invoice_id: assign only this invoice """ db = current.db s3db = current.s3db if not organisation_id: # Look up the accounting organisation for the billing btable = s3db.fin_voucher_billing query = (btable.id == billing_id) billing = db(query).select(btable.organisation_id, limitby = (0, 1), ).first() if not billing: return organisation_id = billing.organisation_id if organisation_id: # Look up the active accountants of the accountant org accountants = get_role_hrs("PROGRAM_ACCOUNTANT", organisation_id = organisation_id, ) else: accountants = None # Query for any pending invoices of this billing cycle itable = s3db.fin_voucher_invoice if invoice_id: query = (itable.id == invoice_id) else: query = (itable.billing_id == billing_id) query &= (itable.status != "PAID") & (itable.deleted == False) if accountants: # Limit to invoices that have not yet been assigned to any # of the accountants in charge: query &= ((itable.human_resource_id == None) | \ (~(itable.human_resource_id.belongs(accountants)))) # Get the invoices invoices = db(query).select(itable.id, itable.human_resource_id, ) if not invoices: return # Look up the number of pending invoices assigned to each # accountant, to get a measure for their current workload workload = {hr_id: 0 for hr_id in accountants} query = (itable.status != "PAID") & \ (itable.human_resource_id.belongs(accountants)) & \ (itable.deleted == False) num_assigned = itable.id.count() rows = db(query).select(itable.human_resource_id, num_assigned, groupby = itable.human_resource_id, ) for row in rows: workload[row[itable.human_resource_id]] = row[num_assigned] # Re-assign invoices # - try to distribute workload evenly among the accountants for invoice in invoices: hr_id, num = min(workload.items(), key=lambda item: item[1]) invoice.update_record(human_resource_id = hr_id) workload[hr_id] = num + 1 elif not invoice_id: # Unassign all pending invoices db(query).update(human_resource_id = None) # ----------------------------------------------------------------------------- def check_invoice_integrity(row): """ Rheader-helper to check and report invoice integrity Args: row: the invoice record Returns: integrity check result """ billing = current.s3db.fin_VoucherBilling(row.billing_id) try: checked = billing.check_invoice(row.id) except ValueError: checked = False T = current.T if checked: return SPAN(T("Ok"), I(_class="fa fa-check"), _class="record-integrity-ok", ) else: current.response.error = T("This invoice may be invalid - please contact the administrator") return SPAN(T("Failed"), I(_class="fa fa-exclamation-triangle"), _class="record-integrity-broken", ) # ----------------------------------------------------------------------------- def get_stats_projects(): """ Find all projects the current user can report test results, i.e. - projects marked as STATS=Y where - the current user has the VOUCHER_PROVIDER role for a partner organisation @status: obsolete, test results shall be reported for all projects """ permitted_realms = current.auth.permission.permitted_realms realms = permitted_realms("disease_case_diagnostics", method = "create", c = "disease", f = "case_diagnostics", ) if realms is not None and not realms: return [] s3db = current.s3db otable = s3db.org_organisation ltable = s3db.project_organisation ttable = s3db.project_project_tag oquery = otable.deleted == False if realms: oquery = otable.pe_id.belongs(realms) & oquery join = [ltable.on((ltable.project_id == ttable.project_id) & \ (ltable.deleted == False)), otable.on((otable.id == ltable.organisation_id) & oquery), ] query = (ttable.tag == "STATS") & \ (ttable.value == "Y") & \ (ttable.deleted == False) rows = current.db(query).select(ttable.project_id, cache = s3db.cache, join = join, groupby = ttable.project_id, ) return [row.project_id for row in rows] # ----------------------------------------------------------------------------- def can_cancel_debit(debit): """ Check whether the current user is entitled to cancel a certain voucher debit: * User must have the VOUCHER_PROVIDER role for the organisation that originally accepted the voucher (not even ADMIN-role can override this requirement) Args: debit: the debit (Row, must contain the debit pe_id) Returns: True|False """ auth = current.auth user = auth.user if user: # Look up the role ID gtable = auth.settings.table_group query = (gtable.uuid == "VOUCHER_PROVIDER") role = current.db(query).select(gtable.id, cache = current.s3db.cache, limitby = (0, 1), ).first() if not role: return False # Get the realms they have this role for realms = user.realms if role.id in realms: role_realms = realms.get(role.id) else: # They don't have the role at all return False if not role_realms: # User has a site-wide VOUCHER_PROVIDER role, however # for cancellation of debits they must be affiliated # with the debit owner organisation role_realms = current.s3db.pr_default_realms(user["pe_id"]) return debit.pe_id in role_realms else: # No user return False # ----------------------------------------------------------------------------- def configure_binary_tags(resource, tag_components): """ Configure representation of binary tags Args: resource: the CRUDResource tag_components: tuple|list of filtered tag component aliases """ T = current.T binary_tag_opts = {"Y": T("Yes"), "N": T("No")} for cname in tag_components: component = resource.components.get(cname) if component: ctable = component.table field = ctable.value field.default = "N" field.requires = IS_IN_SET(binary_tag_opts, zero=None) field.represent = lambda v, row=None: binary_tag_opts.get(v, "-") # ----------------------------------------------------------------------------- def workflow_tag_represent(options, none=None): """ Color-coded and icon-supported representation of facility approval workflow tags Args: options: the tag options as dict {value: label} none: treat None-values like this option (str) """ icons = {"REVISE": "fa fa-exclamation-triangle", "REJECT": "fa fa-exclamation-triangle", "REVIEW": "fa fa-hourglass", "APPROVED": "fa fa-check", "COMPLETE": "fa fa-check", "N/A": "fa fa-minus-circle", "N": "fa fa-minus-circle", "Y": "fa fa-check", } css_classes = {"REVISE": "workflow-red", "REJECT": "workflow-red", "REVIEW": "workflow-amber", "APPROVED": "workflow-green", "COMPLETE": "workflow-green", "N/A": "workflow-grey", "N": "workflow-red", "Y": "workflow-green", } def represent(value, row=None): if value is None and none: value = none label = DIV(_class="approve-workflow") color = css_classes.get(value) if color: label.add_class(color) icon = icons.get(value) if icon: label.append(I(_class=icon)) label.append(options.get(value, "-")) return label return represent # ----------------------------------------------------------------------------- def applicable_org_types(organisation_id, group=None, represent=False): """ Look up organisation types by OrgGroup-tag Args: organisation_id: the record ID of an existing organisation group: alternatively, the organisation group name represent: include type labels in the result Returns: a list of organisation type IDs, for filtering, or a dict {type_id: label}, for selecting """ db = current.db s3db = current.s3db ttable = s3db.org_organisation_type_tag if organisation_id: # Look up the org groups of this record gtable = s3db.org_group mtable = s3db.org_group_membership join = gtable.on(gtable.id == mtable.group_id) query = (mtable.organisation_id == organisation_id) & \ (mtable.deleted == False) rows = db(query).select(gtable.name, join=join) groups = {row.name for row in rows} q = (ttable.value.belongs(groups)) # Look up the org types the record is currently linked to ltable = s3db.org_organisation_organisation_type query = (ltable.organisation_id == organisation_id) & \ (ltable.deleted == False) rows = db(query).select(ltable.organisation_type_id) current_types = {row.organisation_type_id for row in rows} elif group: # Use group name as-is q = (ttable.value == group) # Look up all types tagged for this group query = (ttable.tag == "OrgGroup") & q & \ (ttable.deleted == False) rows = db(query).select(ttable.organisation_type_id, cache = s3db.cache, ) type_ids = {row.organisation_type_id for row in rows} if organisation_id: # Add the org types the record is currently linked to type_ids |= current_types if represent: labels = ttable.organisation_type_id.represent if hasattr(labels, "bulk"): labels.bulk(list(type_ids)) output = {str(t): labels(t) for t in type_ids} else: output = list(type_ids) return output # ============================================================================= def facility_map_popup(record): """ Custom map popup for facilities Args: record: the facility record (Row) Returns: the map popup contents as DIV """ db = current.db s3db = current.s3db T = current.T table = s3db.org_facility # Custom Map Popup title = H4(record.name, _class="map-popup-title") details = TABLE(_class="map-popup-details") append = details.append def formrow(label, value, represent=None): return TR(TD("%s:" % label, _class="map-popup-label"), TD(represent(value) if represent else value), ) # Address gtable = s3db.gis_location query = (gtable.id == record.location_id) location = db(query).select(gtable.addr_street, gtable.addr_postcode, gtable.L4, gtable.L3, limitby = (0, 1), ).first() if location.addr_street: append(formrow(gtable.addr_street.label, location.addr_street)) place = location.L4 or location.L3 or "?" if location.addr_postcode: place = "%s %s" % (location.addr_postcode, place) append(formrow(T("Place"), place)) # Phone number phone = record.phone1 if phone: append(formrow(T("Phone"), phone)) # Email address (as hyperlink) email = record.email if email: append(formrow(table.email.label, A(email, _href="mailto:%s" % email))) # Opening Times opening_times = record.opening_times if opening_times: append(formrow(table.opening_times.label, opening_times)) # Site services stable = s3db.org_service ltable = s3db.org_service_site join = stable.on(stable.id == ltable.service_id) query = (ltable.site_id == record.site_id) & \ (ltable.deleted == False) rows = db(query).select(stable.name, join=join) services = [row.name for row in rows] if services: append(formrow(T("Services"), ", ".join(services))) # Comments if record.comments: append(formrow(table.comments.label, record.comments, represent = table.comments.represent, )) return DIV(title, details, _class="map-popup") # ============================================================================= def update_daily_report(site_id, result_date, disease_id): """ Update daily testing activity report (without subtotals per demographic) - called when a new individual test result is registered Args: site_id: the test station site ID result_date: the result date of the test disease_id: the disease ID """ db = current.db s3db = current.s3db table = s3db.disease_case_diagnostics # Count records grouped by result query = (table.site_id == site_id) & \ (table.disease_id == disease_id) & \ (table.result_date == result_date) & \ (table.deleted == False) cnt = table.id.count() rows = db(query).select(table.result, cnt, groupby = table.result, ) total = positive = 0 for row in rows: num = row[cnt] total += num if row.disease_case_diagnostics.result == "POS": positive += num # Look up the daily report rtable = s3db.disease_testing_report query = (rtable.site_id == site_id) & \ (rtable.disease_id == disease_id) & \ (rtable.date == result_date) & \ (rtable.deleted == False) report = db(query).select(rtable.id, rtable.tests_total, rtable.tests_positive, limitby = (0, 1), ).first() if report: # Update report if actual numbers are greater if report.tests_total < total or report.tests_positive < positive: report.update_record(tests_total = total, tests_positive = positive, ) else: # Create report report = {"site_id": site_id, "disease_id": disease_id, "date": result_date, "tests_total": total, "tests_positive": positive, } report_id = rtable.insert(**report) if report_id: current.auth.s3_set_record_owner(rtable, report_id) report["id"] = report_id s3db.onaccept(rtable, report, method="create") # ----------------------------------------------------------------------------- def update_daily_report_by_demographic(site_id, result_date, disease_id): """ Update daily testing activity report (with subtotals per demographic) - called when a new individual test result is registered Args: site_id: the test station site ID result_date: the result date of the test disease_id: the disease ID """ db = current.db s3db = current.s3db set_record_owner = current.auth.s3_set_record_owner table = s3db.disease_case_diagnostics rtable = s3db.disease_testing_report dtable = s3db.disease_testing_demographic # Count individual results by demographic and result query = (table.site_id == site_id) & \ (table.disease_id == disease_id) & \ (table.result_date == result_date) & \ (table.deleted == False) cnt = table.id.count() rows = db(query).select(table.demographic_id, table.result, cnt, groupby = (table.demographic_id, table.result), ) # Generate recorded-subtotals matrix subtotals = {} total = positive = 0 for row in rows: record = row.disease_case_diagnostics demographic_id = record.demographic_id item = subtotals.get(demographic_id) if not item: item = subtotals[demographic_id] = {"tests_total": 0, "tests_positive": 0, } num = row[cnt] total += num item["tests_total"] += num if record.result == "POS": positive += num item["tests_positive"] += num # Look up the daily report query = (rtable.site_id == site_id) & \ (rtable.disease_id == disease_id) & \ (rtable.date == result_date) & \ (rtable.deleted == False) report = db(query).select(rtable.id, rtable.tests_total, rtable.tests_positive, limitby = (0, 1), ).first() if not report: # Create a report with the recorded totals report = {"site_id": site_id, "disease_id": disease_id, "date": result_date, "tests_total": total, "tests_positive": positive, } report["id"] = report_id = rtable.insert(**report) if report_id: set_record_owner(rtable, report_id) s3db.onaccept(rtable, report, method="create") # Add subtotals per demographic for demographic_id, item in subtotals.items(): subtotal = {"report_id": report_id, "demographic_id": demographic_id, "tests_total": item["tests_total"], "tests_positive": item["tests_positive"] } subtotal_id = subtotal["id"] = dtable.insert(**subtotal) set_record_owner(dtable, subtotal_id) # We've already set the correct totals in the report: #s3db.onaccept(dtable, subtotal, method="create") else: # Update the existing report with revised subtotals report_id = report.id # Get all current (reported) subtotals of this report query = (dtable.report_id == report_id) & \ (dtable.deleted == False) rows = db(query).select(dtable.id, dtable.demographic_id, dtable.tests_total, dtable.tests_positive, orderby = ~dtable.modified_on, ) # For each demographic, determine the recorded and reported subtotals for demographic_id, item in subtotals.items(): # Recorded totals recorded_total = item["tests_total"] recorded_positive = item["tests_positive"] # Reported totals last_report = None reported_total = reported_positive = 0 for row in rows: if row.demographic_id == demographic_id: reported_total += row.tests_total reported_positive += row.tests_positive if not last_report: last_report = row if not last_report: # No subtotal for this demographic yet => create one subtotal = {"report_id": report_id, "demographic_id": demographic_id, "tests_total": recorded_total, "tests_positive": recorded_positive, } subtotal_id = subtotal["id"] = dtable.insert(**subtotal) set_record_owner(dtable, subtotal_id) # We do this in-bulk at the end: #s3db.onaccept(dtable, subtotal, method="create") elif reported_total < recorded_total or \ reported_positive < recorded_positive: # Update the last subtotal with the differences last_report.update_record( tests_total = last_report.tests_total + \ max(recorded_total - reported_total, 1), tests_positive = last_report.tests_positive + \ max(recorded_positive - reported_positive, 0), ) # Get subtotals for all demographics under this report query = (dtable.report_id == report_id) & \ (dtable.deleted == False) total = dtable.tests_total.sum() positive = dtable.tests_positive.sum() row = db(query).select(total, positive).first() # Update the overall report query = (rtable.id == report_id) & \ (rtable.deleted == False) db(query).update(tests_total = row[total], tests_positive = row[positive], ) # ============================================================================= def rlp_holidays(start, end): """ Date rules set for holidays in RLP Args: start: the start date end: the end date Returns: a dateutil.rrule rule set for all holidays within the interval """ rules = rrule.rruleset() addrule = rules.rrule newrule = rrule.rrule # Fixed-date holidays addrule(newrule(rrule.YEARLY, dtstart=start, until=end, bymonth=1, bymonthday=1)) addrule(newrule(rrule.YEARLY, dtstart=start, until=end, bymonth=5, bymonthday=1)) addrule(newrule(rrule.YEARLY, dtstart=start, until=end, bymonth=10, bymonthday=3)) addrule(newrule(rrule.YEARLY, dtstart=start, until=end, bymonth=11, bymonthday=1)) addrule(newrule(rrule.YEARLY, dtstart=start, until=end, bymonth=12, bymonthday=(25, 26))) # Easter-related holidays: # (Karfreitag, Ostermontag, Christi Himmelfahrt, Pfingstmontag, Fronleichnam) addrule(newrule(rrule.YEARLY, dtstart=start, until=end, byeaster=(-2, 1, 39, 50, 60))) # Exclude holidays on weekends rules.exrule(newrule(rrule.WEEKLY, dtstart=start, until=end, byweekday=(rrule.SA,rrule.SU))) return rules # ============================================================================= class ServiceListRepresent(S3Represent): always_list = True def render_list(self, value, labels, show_link=True): """ Helper method to render list-type representations from bulk()-results. Args: value: the list labels: the labels as returned from bulk() show_link: render references as links, should be the same as used with bulk() """ show_link = show_link and self.show_link values = [v for v in value if v is not None] if not len(values): return "" if show_link: labels_ = (labels[v] if v in labels else self.default for v in values) else: labels_ = sorted(s3_str(labels[v]) if v in labels else self.default for v in values) html = UL(_class="service-list") for label in labels_: html.append(LI(label)) return html # ============================================================================= class OrganisationRepresent(S3Represent): """ Custom representation of organisations showing the organisation type - relevant for facility approval """ def __init__(self, show_type=True, show_link=True): super(OrganisationRepresent, self).__init__(lookup = "org_organisation", fields = ["name",], show_link = show_link, ) self.show_type = show_type self.org_types = {} self.type_names = {} # ------------------------------------------------------------------------- def lookup_rows(self, key, values, fields=None): """ Custom lookup method for organisation rows, does a left join with the parent organisation. Parameters key and fields are not used, but are kept for API compatibility reasons. Args: values: the organisation IDs """ db = current.db s3db = current.s3db otable = s3db.org_organisation count = len(values) if count == 1: query = (otable.id == values[0]) else: query = (otable.id.belongs(values)) rows = db(query).select(otable.id, otable.name, limitby = (0, count), ) if self.show_type: ltable = s3db.org_organisation_organisation_type if count == 1: query = (ltable.organisation_id == values[0]) else: query = (ltable.organisation_id.belongs(values)) query &= (ltable.deleted == False) types = db(query).select(ltable.organisation_id, ltable.organisation_type_id, ) all_types = set() org_types = self.org_types = {} for t in types: type_id = t.organisation_type_id all_types.add(type_id) organisation_id = t.organisation_id if organisation_id not in org_types: org_types[organisation_id] = {type_id} else: org_types[organisation_id].add(type_id) if all_types: ttable = s3db.org_organisation_type query = ttable.id.belongs(all_types) types = db(query).select(ttable.id, ttable.name, limitby = (0, len(all_types)), ) self.type_names = {t.id: t.name for t in types} return rows # ------------------------------------------------------------------------- def represent_row(self, row): """ Represent a single Row Args: row: the org_organisation Row """ name = s3_str(row.name) if self.show_type: T = current.T type_ids = self.org_types.get(row.id) if type_ids: type_names = self.type_names types = [s3_str(T(type_names[t])) for t in type_ids if t in type_names ] name = "%s (%s)" % (name, ", ".join(types)) return name # ============================================================================= class InviteUserOrg(CRUDMethod): """ Custom Method Handler to invite User Organisations """ # ------------------------------------------------------------------------- def apply_method(self, r, **attr): """ Page-render entry point for REST interface. Args: r: the CRUDRequest instance attr: controller attributes """ output = {} if r.http in ("GET", "POST"): if not r.record: r.error(400, current.ERROR.BAD_REQUEST) if r.interactive: output = self.invite(r, **attr) else: r.error(415, current.ERROR.BAD_FORMAT) else: r.error(405, current.ERROR.BAD_METHOD) return output # ------------------------------------------------------------------------- def invite(self, r, **attr): """ Prepare and process invitation form Args: r: the CRUDRequest instance attr: controller attributes """ T = current.T db = current.db s3db = current.s3db response = current.response request = current.request session = current.session settings = current.deployment_settings auth = current.auth auth_settings = auth.settings auth_messages = auth.messages output = {"title": T("Invite Organisation"), } # Check for existing accounts active, disabled, invited = get_org_accounts(r.record.id) if active or disabled: response.error = T("There are already user accounts registered for this organization") from core import s3_format_fullname fullname = lambda user: s3_format_fullname(fname = user.first_name, lname = user.last_name, truncate = False, ) account_list = DIV(_class="org-account-list") if active: account_list.append(H4(T("Active Accounts"))) accounts = UL() for user in active: accounts.append(LI("%s <%s>" % (fullname(user), user.email))) account_list.append(accounts) if disabled: account_list.append(H4(T("Disabled Accounts"))) accounts = UL() for user in disabled: accounts.append(LI("%s <%s>" % (fullname(user), user.email))) account_list.append(accounts) output["item"] = account_list response.view = self._view(r, "display.html") return output account = invited[0] if invited else None # Look up email to use for invitation email = None if account: email = account.email else: ctable = s3db.pr_contact query = (ctable.pe_id == r.record.pe_id) & \ (ctable.contact_method == "EMAIL") & \ (ctable.deleted == False) contact = db(query).select(ctable.value, orderby = ctable.priority, limitby = (0, 1), ).first() if contact: email = contact.value # Form Fields utable = auth_settings.table_user dbset = db(utable.id != account.id) if account else db formfields = [Field("email", default = email, requires = [IS_EMAIL(error_message = auth_messages.invalid_email), IS_LOWER(), IS_NOT_IN_DB(dbset, "%s.email" % utable._tablename, error_message = auth_messages.duplicate_email, ), ] ), ] # Generate labels (and mark required fields in the process) labels, has_required = s3_mark_required(formfields) response.s3.has_required = has_required # Form buttons SEND_INVITATION = T("Send New Invitation") if account else T("Send Invitation") buttons = [INPUT(_type = "submit", _value = SEND_INVITATION, ), # TODO cancel-button? ] # Construct the form response.form_label_separator = "" form = SQLFORM.factory(table_name = "invite", record = None, hidden = {"_next": request.vars._next}, labels = labels, separator = "", showid = False, submit_button = SEND_INVITATION, #delete_label = auth_messages.delete_label, formstyle = settings.get_ui_formstyle(), buttons = buttons, *formfields) # Identify form for CSS & JS Validation form.add_class("send_invitation") if form.accepts(request.vars, session, formname = "invite", #onvalidation = auth_settings.register_onvalidation, ): error = self.invite_account(r.record, form.vars.email, account=account) if error: response.error = T("Could not send invitation (%(reason)s)") % {"reason": error} else: response.confirmation = T("Invitation sent") else: if account: response.warning = T("This organisation has been invited before!") output["form"] = form response.view = self._view(r, "update.html") return output # ------------------------------------------------------------------------- @classmethod def invite_account(cls, organisation, email, account=None): request = current.request data = {"first_name": organisation.name, "email": email, # TODO language => use default language "link_user_to": ["staff"], "organisation_id": organisation.id, } # Generate registration key and activation code from uuid import uuid4 key = str(uuid4()) code = uuid4().hex[-6:].upper() # Add hash to data data["registration_key"] = cls.keyhash(key, code) if account: success = account.update_record(**data) if not success: return "could not update preliminary account" else: utable = current.auth.settings.table_user # Catch email addresses already used in existing accounts if current.db(utable.email == email).select(utable.id, limitby = (0, 1), ).first(): return "email address %s already in use" % email user_id = utable.insert(**data) if user_id: ltable = current.s3db.org_organisation_user ltable.insert(organisation_id = organisation.id, user_id = user_id, ) else: return "could not create preliminary account" # Compose and send invitation email # => must use public_url setting because URL() produces a # localhost address when called from CLI or script base_url = current.deployment_settings.get_base_public_url() appname = request.application registration_url = "%s/%s/default/index/register_invited/%s" data = {"url": registration_url % (base_url, appname, key), "code": code, } from .notifications import CMSNotifications return CMSNotifications.send(email, "InviteOrg", data, module = "auth", resource = "user", ) # ------------------------------------------------------------------------- @staticmethod def keyhash(key, code): """ Generate a hash of the activation code using the registration key Args: key: the registration key code: the activation code Returns: the hash as string """ crypt = CRYPT(key=key, digest_alg="sha512", salt=None) return str(crypt(code.upper())[0]) # ============================================================================= class InvoicePDF(CRUDMethod): """ REST Method to generate an invoice PDF - for external accounting archives """ # ------------------------------------------------------------------------- def apply_method(self, r, **attr): """ Generate a PDF of an Invoice Args: r: the CRUDRequest instance attr: controller attributes """ if r.representation != "pdf": r.error(415, current.ERROR.BAD_FORMAT) if not r.record or r.http != "GET": r.error(400, current.ERROR.BAD_REQUEST) T = current.T # Filename to include invoice number if available invoice_no = r.record.invoice_no from core import S3Exporter exporter = S3Exporter().pdf return exporter(r.resource, request = r, method = "read", pdf_title = T("Invoice"), pdf_filename = invoice_no if invoice_no else None, pdf_header = self.invoice_header, pdf_callback = self.invoice, pdf_footer = self.invoice_footer, pdf_hide_comments = True, pdf_header_padding = 12, pdf_orientation = "Portrait", pdf_table_autogrow = "B", **attr ) # ------------------------------------------------------------------------- @classmethod def invoice_header(cls, r): """ Generate the invoice header Args: r: the CRUDRequest """ T = current.T table = r.resource.table invoice = r.record pdata = cls.lookup_header_data(invoice) place = [pdata.get(k) for k in ("addr_postcode", "addr_place")] header = TABLE(TR(TD(DIV(H4(T("Invoice")), P(" ")), _colspan = 4, ), ), TR(TH(T("Invoicing Party")), TD(pdata.get("organisation", "-")), TH(T("Invoice No.")), TD(table.invoice_no.represent(invoice.invoice_no)), ), TR(TH(T("Address")), TD(pdata.get("addr_street", "-")), TH(table.date.label), TD(table.date.represent(invoice.date)), ), TR(TH(T("Place")), TD(" ".join(v for v in place if v)), TH(T("Payers")), TD(pdata.get("payers")), ), TR(TH(T("Email")), TD(pdata.get("email", "-")), TH(T("Billing Date")), TD(table.date.represent(pdata.get("billing_date"))), ), ) return header # ------------------------------------------------------------------------- @classmethod def invoice(cls, r): """ Generate the invoice body Args: r: the CRUDRequest """ T = current.T table = r.table invoice = r.record pdata = cls.lookup_body_data(invoice) # Lambda to format currency amounts amt = lambda v: IS_FLOAT_AMOUNT.represent(v, precision=2, fixed=True) currency = invoice.currency # Specification of costs costs = TABLE(TR(TH(T("No.")), TH(T("Description")), TH(T("Number##count")), TH(T("Unit")), TH(table.price_per_unit.label), TH(T("Total")), TH(table.currency.label), ), TR(TD("1"), # only one line item here TD(pdata.get("title", "-")), TD(str(invoice.quantity_total)), TD(pdata.get("unit", "-")), TD(amt(invoice.price_per_unit)), TD(amt(invoice.amount_receivable)), TD(currency), ), TR(TD(H5(T("Total")), _colspan=5), TD(H5(amt(invoice.amount_receivable))), TD(H5(currency)), ), ) # Payment Details an_field = table.account_number an = an_field.represent(invoice.account_number) payment_details = TABLE(TR(TH(table.account_holder.label), TD(invoice.account_holder), ), TR(TH(an_field.label), TD(an), ), TR(TH(table.bank_name.label), TD(invoice.bank_name), ), ) return DIV(H4(" "), H5(T("Specification of Costs")), costs, H4(" "), H4(" "), H5(T("Payable within %(num)s days to") % {"num": 30}), payment_details, ) # ------------------------------------------------------------------------- @staticmethod def invoice_footer(r): """ Generate the invoice footer Args: r: the CRUDRequest """ T = current.T invoice = r.record # Details about who generated the document and when user = current.auth.user if not user: username = T("anonymous user") else: username = s3_fullname(user) now = S3DateTime.datetime_represent(current.request.utcnow, utc=True) note = T("Document generated by %(user)s on %(date)s") % {"user": username, "date": now, } # Details about the data source vhash = invoice.vhash try: verification = vhash.split("$$")[1][:7] except (AttributeError, IndexError): verification = T("invalid") settings = current.deployment_settings source = TABLE(TR(TH(T("System Name")), TD(settings.get_system_name()), ), TR(TH(T("Web Address")), TD(settings.get_base_public_url()), ), TR(TH(T("Data Source")), TD("%s [%s]" % (invoice.uuid, verification)), ), ) return DIV(P(note), source) # ------------------------------------------------------------------------- @staticmethod def lookup_header_data(invoice): """ Look up data for the invoice header Args: invoice: the invoice record Returns: dict with header data """ db = current.db s3db = current.s3db data = {} btable = s3db.fin_voucher_billing ptable = s3db.fin_voucher_program otable = s3db.org_organisation ftable = s3db.org_facility ltable = s3db.gis_location ctable = s3db.pr_contact # Look up the billing date query = (btable.id == invoice.billing_id) billing = db(query).select(btable.date, limitby = (0, 1), ).first() if billing: data["billing_date"] = billing.date # Use the program admin org as "payers" query = (ptable.id == invoice.program_id) join = otable.on(otable.id == ptable.organisation_id) admin_org = db(query).select(otable.name, join = join, limitby = (0, 1), ).first() if admin_org: data["payers"] = admin_org.name # Look up details of the invoicing party query = (otable.pe_id == invoice.pe_id) & \ (otable.deleted == False) organisation = db(query).select(otable.id, otable.name, limitby = (0, 1), ).first() if organisation: data["organisation"] = organisation.name # Email address query = (ctable.pe_id == invoice.pe_id) & \ (ctable.contact_method == "EMAIL") & \ (ctable.deleted == False) email = db(query).select(ctable.value, limitby = (0, 1), ).first() if email: data["email"] = email.value # Facility address query = (ftable.organisation_id == organisation.id) & \ (ftable.obsolete == False) & \ (ftable.deleted == False) left = ltable.on(ltable.id == ftable.location_id) facility = db(query).select(ftable.email, ltable.addr_street, ltable.addr_postcode, ltable.L3, ltable.L4, left = left, limitby = (0, 1), orderby = ftable.created_on, ).first() if facility: if data.get("email"): # Fallback data["email"] = facility.org_facility.email location = facility.gis_location data["addr_street"] = location.addr_street or "-" data["addr_postcode"] = location.addr_postcode or "-" data["addr_place"] = location.L4 or location.L3 or "-" return data # ------------------------------------------------------------------------- @staticmethod def lookup_body_data(invoice): """ Look up additional data for invoice body Args: invoice: the invoice record Returns: dict with invoice data """ db = current.db s3db = current.s3db ptable = s3db.fin_voucher_program query = (ptable.id == invoice.program_id) & \ (ptable.deleted == False) program = db(query).select(ptable.id, ptable.name, ptable.unit, limitby = (0, 1), ).first() if program: data = {"title": program.name, "unit": program.unit, } else: data = {} return data # ============================================================================= class ClaimPDF(CRUDMethod): """ REST Method to generate a claim PDF - for external accounting archives """ # ------------------------------------------------------------------------- def apply_method(self, r, **attr): """ Generate a PDF of a Claim Args: r: the CRUDRequest instance attr: controller attributes """ if r.representation != "pdf": r.error(415, current.ERROR.BAD_FORMAT) if not r.record or r.http != "GET": r.error(400, current.ERROR.BAD_REQUEST) T = current.T # Filename to include invoice number if available invoice_no = self.invoice_number(r.record) from core import S3Exporter exporter = S3Exporter().pdf return exporter(r.resource, request = r, method = "read", pdf_title = T("Compensation Claim"), pdf_filename = invoice_no if invoice_no else None, pdf_header = self.claim_header, pdf_callback = self.claim, pdf_footer = self.claim_footer, pdf_hide_comments = True, pdf_header_padding = 12, pdf_orientation = "Portrait", pdf_table_autogrow = "B", **attr ) # ------------------------------------------------------------------------- @staticmethod def invoice_number(record): invoice_id = record.invoice_id if invoice_id: s3db = current.s3db itable = s3db.fin_voucher_invoice query = (itable.id == invoice_id) invoice = current.db(query).select(itable.invoice_no, cache = s3db.cache, limitby = (0, 1), ).first() else: invoice = None return invoice.invoice_no if invoice else None # ------------------------------------------------------------------------- @classmethod def claim_header(cls, r): """ Generate the claim header Args: r: the CRUDRequest """ T = current.T table = r.resource.table itable = current.s3db.fin_voucher_invoice claim = r.record pdata = cls.lookup_header_data(claim) place = [pdata.get(k) for k in ("addr_postcode", "addr_place")] status = " " if claim.invoice_id else "(%s)" % T("not invoiced yet") header = TABLE(TR(TD(DIV(H4(T("Compensation Claim")), P(status)), _colspan = 4, ), ), TR(TH(T("Invoicing Party")), TD(pdata.get("organisation", "-")), TH(T("Invoice No.")), TD(itable.invoice_no.represent(pdata.get("invoice_no"))), ), TR(TH(T("Address")), TD(pdata.get("addr_street", "-")), TH(itable.date.label), TD(itable.date.represent(pdata.get("invoice_date"))), ), TR(TH(T("Place")), TD(" ".join(v for v in place if v)), TH(T("Payers")), TD(pdata.get("payers")), ), TR(TH(T("Email")), TD(pdata.get("email", "-")), TH(T("Billing Date")), TD(table.date.represent(pdata.get("billing_date"))), ), ) return header # ------------------------------------------------------------------------- @classmethod def claim(cls, r): """ Generate the claim body Args: r: the CRUDRequest """ T = current.T table = r.table claim = r.record pdata = cls.lookup_body_data(claim) # Lambda to format currency amounts amt = lambda v: IS_FLOAT_AMOUNT.represent(v, precision=2, fixed=True) currency = claim.currency # Specification of costs costs = TABLE(TR(TH(T("No.")), TH(T("Description")), TH(T("Number##count")), TH(T("Unit")), TH(table.price_per_unit.label), TH(T("Total")), TH(table.currency.label), ), TR(TD("1"), # only one line item here TD(pdata.get("title", "-")), TD(str(claim.quantity_total)), TD(pdata.get("unit", "-")), TD(amt(claim.price_per_unit)), TD(amt(claim.amount_receivable)), TD(currency), ), TR(TD(H5(T("Total")), _colspan=5), TD(H5(amt(claim.amount_receivable))), TD(H5(currency)), ), ) # Payment Details an_field = table.account_number an = an_field.represent(claim.account_number) payment_details = TABLE(TR(TH(table.account_holder.label), TD(claim.account_holder), ), TR(TH(an_field.label), TD(an), ), TR(TH(table.bank_name.label), TD(claim.bank_name), ), ) return DIV(H4(" "), H5(T("Specification of Costs")), costs, H4(" "), H4(" "), H5(T("Payable within %(num)s days to") % {"num": 30}), payment_details, ) # ------------------------------------------------------------------------- @staticmethod def claim_footer(r): """ Generate the claim footer Args: r: the CRUDRequest """ T = current.T claim = r.record # Details about who generated the document and when user = current.auth.user if not user: username = T("anonymous user") else: username = s3_fullname(user) now = S3DateTime.datetime_represent(current.request.utcnow, utc=True) note = T("Document generated by %(user)s on %(date)s") % {"user": username, "date": now, } # Details about the data source vhash = claim.vhash try: verification = vhash.split("$$")[1][:7] except (AttributeError, IndexError): verification = T("invalid") settings = current.deployment_settings source = TABLE(TR(TH(T("System Name")), TD(settings.get_system_name()), ), TR(TH(T("Web Address")), TD(settings.get_base_public_url()), ), TR(TH(T("Data Source")), TD("%s [%s]" % (claim.uuid, verification)), ), ) return DIV(P(note), source) # ------------------------------------------------------------------------- @staticmethod def lookup_header_data(claim): """ Look up data for the claim header Args: claim: the claim record Returns: dict with header data """ db = current.db s3db = current.s3db data = {} btable = s3db.fin_voucher_billing itable = s3db.fin_voucher_invoice ptable = s3db.fin_voucher_program otable = s3db.org_organisation ftable = s3db.org_facility ltable = s3db.gis_location ctable = s3db.pr_contact # Look up the billing date query = (btable.id == claim.billing_id) billing = db(query).select(btable.date, limitby = (0, 1), ).first() if billing: data["billing_date"] = billing.date # Look up invoice details if claim.invoice_id: query = (itable.id == claim.invoice_id) invoice = db(query).select(itable.date, itable.invoice_no, limitby = (0, 1), ).first() if invoice: data["invoice_no"] = invoice.invoice_no data["invoice_date"] = invoice.date # Use the program admin org as "payers" query = (ptable.id == claim.program_id) join = otable.on(otable.id == ptable.organisation_id) admin_org = db(query).select(otable.name, join = join, limitby = (0, 1), ).first() if admin_org: data["payers"] = admin_org.name # Look up details of the invoicing party query = (otable.pe_id == claim.pe_id) & \ (otable.deleted == False) organisation = db(query).select(otable.id, otable.name, limitby = (0, 1), ).first() if organisation: data["organisation"] = organisation.name # Email address query = (ctable.pe_id == claim.pe_id) & \ (ctable.contact_method == "EMAIL") & \ (ctable.deleted == False) email = db(query).select(ctable.value, limitby = (0, 1), ).first() if email: data["email"] = email.value # Facility address query = (ftable.organisation_id == organisation.id) & \ (ftable.obsolete == False) & \ (ftable.deleted == False) left = ltable.on(ltable.id == ftable.location_id) facility = db(query).select(ftable.email, ltable.addr_street, ltable.addr_postcode, ltable.L3, ltable.L4, left = left, limitby = (0, 1), orderby = ftable.created_on, ).first() if facility: if data.get("email"): # Fallback data["email"] = facility.org_facility.email location = facility.gis_location data["addr_street"] = location.addr_street or "-" data["addr_postcode"] = location.addr_postcode or "-" data["addr_place"] = location.L4 or location.L3 or "-" return data # ------------------------------------------------------------------------- @staticmethod def lookup_body_data(claim): """ Look up additional data for claim body Args: claim: the claim record Returns: dict with claim data """ db = current.db s3db = current.s3db ptable = s3db.fin_voucher_program query = (ptable.id == claim.program_id) & \ (ptable.deleted == False) program = db(query).select(ptable.id, ptable.name, ptable.unit, limitby = (0, 1), ).first() if program: data = {"title": program.name, "unit": program.unit, } else: data = {} return data # ============================================================================= class TestFacilityInfo(CRUDMethod): """ REST Method to report details/activities of a test facility """ # ------------------------------------------------------------------------- def apply_method(self, r, **attr): """ Report test facility information Args: r: the CRUDRequest instance attr: controller attributes """ if r.http == "POST": if r.representation == "json": output = self.facility_info(r, **attr) else: r.error(415, current.ERROR.BAD_FORMAT) else: r.error(405, current.ERROR.BAD_METHOD) return output # ------------------------------------------------------------------------- @staticmethod def facility_info(r, **attr): """ Respond to a POST .json request, request body format: {"client": "CLIENT", - the client identity (ocert) "appkey": "APPKEY", - the client app key (ocert) "code": "FACILITY-CODE", - the facility code "report": ["start","end"], - the date interval to report activities for (optional) (ISO-format dates YYYY-MM-DD) } Output format: {"code": "FACILITY-CODE", - echoed from input "name": "FACILITY-NAME", - the facility name "phone": "phone #", - the facility phone number "email": "email", - the facility email address "public": True|False, - whether the facility is listed in the public registry "organisation": {"id": "ORG-ID", - the organisation ID tag "name": "ORG-NAME", - the organisation name "type": "ORG-TYPE", - the organisation type "website": "URL" - the organisation website URL }, "location": {"L1": "L1-NAME", - the L1 name (state) "L2": "L2-NAME", - the L2 name (district) "L3": "L3-NAME", - the L3 name (commune/city) "L4": "L4-NAME", - the L4 name (village/town) "address": "STREET", - the street address "postcode": "XXXXX" - the postcode }, "report": ["start","end"], - echoed from input, ISO-format dates YYYY-MM-DD "activity": {"tests": NN - the total number of tests reported for the period } } """ settings = current.deployment_settings # Get the configured, permitted clients ocert = settings.get_custom("ocert") if not ocert: r.error(501, current.ERROR.METHOD_DISABLED) # Read the body JSON of the request body = r.body body.seek(0) try: s = body.read().decode("utf-8") except (ValueError, AttributeError, UnicodeDecodeError): r.error(400, current.ERROR.BAD_REQUEST) try: ref = json.loads(s) except JSONERRORS: r.error(400, current.ERROR.BAD_REQUEST) # Verify the client client = ref.get("client") if not client or client not in ocert: r.error(403, current.ERROR.NOT_PERMITTED) key, _ = ocert.get(client) if key: appkey = ref.get("appkey") if not appkey or appkey.upper() != key.upper(): r.error(403, current.ERROR.NOT_PERMITTED) # Identify the facility db = current.db s3db = current.s3db table = s3db.org_facility record = r.record if record: query = (table.id == record.id) else: code = ref.get("code") if not code: r.error(400, current.ERROR.BAD_REQUEST) query = (table.code.upper() == code.upper()) ttable = s3db.org_site_tag left = ttable.on((ttable.site_id == table.site_id) & \ (ttable.tag == "PUBLIC") & \ (ttable.deleted == False)) query &= (table.deleted == False) row = db(query).select(table.code, table.name, table.phone1, table.email, table.website, table.organisation_id, table.location_id, table.site_id, ttable.id, ttable.value, left = left, limitby = (0, 1), ).first() if not row: r.error(404, current.ERROR.BAD_RECORD) else: facility = row.org_facility public = row.org_site_tag # Prepare facility info output = {"code": facility.code, "name": facility.name, "phone": facility.phone1, "email": facility.email, "public": True if public.value == "Y" else False, } # Look up organisation data otable = s3db.org_organisation ttable = s3db.org_organisation_type ltable = s3db.org_organisation_organisation_type ottable = s3db.org_organisation_tag left = [ttable.on((ltable.organisation_id == otable.id) & \ (ltable.deleted == False) & \ (ttable.id == ltable.organisation_type_id)), ottable.on((ottable.organisation_id == otable.id) & \ (ottable.tag == "OrgID") & \ (ottable.deleted == False)), ] query = (otable.id == facility.organisation_id) & \ (otable.deleted == False) row = db(query).select(otable.name, otable.website, ttable.name, ottable.value, left = left, limitby = (0, 1), ).first() if row: organisation = row.org_organisation orgtype = row.org_organisation_type orgid = row.org_organisation_tag orgdata = {"id": orgid.value, "name": organisation.name, "type": orgtype.name, "website": organisation.website, } output["organisation"] = orgdata # Look up location data ltable = s3db.gis_location query = (ltable.id == facility.location_id) & \ (ltable.deleted == False) row = db(query).select(ltable.L1, ltable.L2, ltable.L3, ltable.L4, ltable.addr_street, ltable.addr_postcode, limitby = (0, 1), ).first() if row: locdata = {"L1": row.L1, "L2": row.L2, "L3": row.L3, "L4": row.L4, "address": row.addr_street, "postcode": row.addr_postcode, } output["location"] = locdata # Look up activity data report = ref.get("report") if report: if isinstance(report, list) and len(report) == 2: start, end = report # Parse the dates, if any parse_date = current.calendar.parse_date start = parse_date(start) if start else False end = parse_date(end) if end else False if start is None or end is None: r.error(400, "Invalid date format in report parameter") if start and end and start > end: start, end = end, start # Extract the totals from the database table = s3db.disease_testing_report query = (table.site_id == facility.site_id) if start: query &= (table.date >= start) if end: query &= (table.date <= end) query &= (table.deleted == False) total = table.tests_total.sum() row = db(query).select(total).first() tests_total = row[total] if not tests_total: tests_total = 0 # Add to output output["report"] = [start.isoformat() if start else None, end.isoformat() if end else None, ] output["activity"] = {"tests": tests_total} else: r.error(400, "Invalid report parameter format") # Return as JSON response = current.response if response: response.headers["Content-Type"] = "application/json; charset=utf-8" return json.dumps(output, separators=(",", ":"), ensure_ascii=False) # ============================================================================= class PersonRepresentManager(pr_PersonRepresentContact): """ Custom representation of person_id in read-perspective on test station managers tab; include DoB """ # ------------------------------------------------------------------------- def represent_row_html(self, row): """ Represent a row with contact information, styleable HTML Args: row: the Row """ T = current.T output = DIV(SPAN(s3_fullname(row), _class = "manager-name", ), _class = "manager-repr", ) table = self.table try: dob = row.date_of_birth except AttributeError: dob = None dob = table.date_of_birth.represent(dob) if dob else "-" pe_id = row.pe_id email = self._email.get(pe_id) if self.show_email else None phone = self._phone.get(pe_id) if self.show_phone else None details = TABLE(TR(TH("%s:" % T("Date of Birth")), TD(dob), _class = "manager-dob" ), TR(TH(ICON("mail")), TD(A(email, _href="mailto:%s" % email) if email else "-"), _class = "manager-email" ), TR(TH(ICON("phone")), TD(phone if phone else "-"), _class = "manager-phone", ), _class="manager-details", ) output.append(details) return output # ------------------------------------------------------------------------- def lookup_rows(self, key, values, fields=None): """ Custom rows lookup Args: key: the key Field values: the values fields: unused (retained for API compatibility) """ rows = super(PersonRepresentManager, self).lookup_rows(key, values, fields=fields) # Lookup dates of birth table = self.table count = len(values) query = (key == values[0]) if count == 1 else key.belongs(values) dob = current.db(query).select(table.id, table.date_of_birth, limitby = (0, count), ).as_dict() for row in rows: date_of_birth = dob.get(row.id) if date_of_birth: row.date_of_birth = date_of_birth.get("date_of_birth") return rows # END =========================================================================
35.733037
100
0.462809
4a243b15325c39b2498d3d1e7b1745b0b83ec269
14,649
py
Python
wxpy/api/bot.py
bluedazzle/wxpy
c9e623c2fd2c16443227c2eaf19617c319c24936
[ "MIT" ]
3
2017-05-21T01:34:36.000Z
2021-02-18T03:08:16.000Z
wxpy/api/bot.py
bluedazzle/wxpy
c9e623c2fd2c16443227c2eaf19617c319c24936
[ "MIT" ]
2
2017-05-17T04:52:19.000Z
2017-05-29T07:39:19.000Z
wxpy/api/bot.py
bluedazzle/wxpy
c9e623c2fd2c16443227c2eaf19617c319c24936
[ "MIT" ]
1
2021-02-18T03:08:17.000Z
2021-02-18T03:08:17.000Z
# coding: utf-8 from __future__ import unicode_literals import atexit import functools import logging import os.path import queue import tempfile from pprint import pformat from threading import Thread import itchat from ..api.chats import Chat, Chats, Friend, Group, MP, User from ..api.consts import SYSTEM from ..api.messages import Message, MessageConfig, Messages, Registered from ..utils import PuidMap from ..utils import enhance_connection, enhance_webwx_request, ensure_list, get_user_name, handle_response, \ start_new_thread, wrap_user_name from ..compatible import PY2 from ..compatible.utils import force_encoded_string_output logger = logging.getLogger(__name__) class Bot(object): """ 机器人对象,用于登陆和操作微信账号,涵盖大部分 Web 微信的功能:: from wxpy import * bot = Bot() # 机器人账号自身 myself = bot.self # 向文件传输助手发送消息 bot.file_helper.send('Hello from wxpy!') """ def __init__( self, cache_path=None, console_qr=False, qr_path=None, qr_callback=None, login_callback=None, logout_callback=None ): """ :param cache_path: * 设置当前会话的缓存路径,并开启缓存功能;为 `None` (默认) 则不开启缓存功能。 * 开启缓存后可在短时间内避免重复扫码,缓存失效时会重新要求登陆。 * 设为 `True` 时,使用默认的缓存路径 'wxpy.pkl'。 :param console_qr: * 在终端中显示登陆二维码,需要安装 pillow 模块 (`pip3 install pillow`)。 * 可为整数(int),表示二维码单元格的宽度,通常为 2 (当被设为 `True` 时,也将在内部当作 2)。 * 也可为负数,表示以反色显示二维码,适用于浅底深字的命令行界面。 * 例如: 在大部分 Linux 系统中可设为 `True` 或 2,而在 macOS Terminal 的默认白底配色中,应设为 -2。 :param qr_path: 保存二维码的路径 :param qr_callback: 获得二维码后的回调,可以用来定义二维码的处理方式,接收参数: uuid, status, qrcode :param login_callback: 登陆成功后的回调,若不指定,将进行清屏操作,并删除二维码文件 :param logout_callback: 登出时的回调 """ self.core = itchat.Core() itchat.instanceList.append(self) enhance_connection(self.core.s) if cache_path is True: cache_path = 'wxpy.pkl' self.cache_path = cache_path if console_qr is True: console_qr = 2 self.core.auto_login( hotReload=bool(cache_path), statusStorageDir=cache_path, enableCmdQR=console_qr, picDir=qr_path, qrCallback=qr_callback, loginCallback=login_callback, exitCallback=logout_callback ) enhance_webwx_request(self) self.self = User(self.core.loginInfo['User'], self) self.file_helper = Chat(wrap_user_name('filehelper'), self) self.messages = Messages() self.registered = Registered(self) self.puid_map = None self.is_listening = False self.listening_thread = None if PY2: from wxpy.compatible.utils import TemporaryDirectory self.temp_dir = TemporaryDirectory(prefix='wxpy_') else: self.temp_dir = tempfile.TemporaryDirectory(prefix='wxpy_') self.start() atexit.register(self._cleanup) @force_encoded_string_output def __repr__(self): return '<{}: {}>'.format(self.__class__.__name__, self.self.name) def __unicode__(self): return '<{}: {}>'.format(self.__class__.__name__, self.self.name) @handle_response() def logout(self): """ 登出当前账号 """ logger.info('{}: logging out'.format(self)) return self.core.logout() @property def alive(self): """ 若为登陆状态,则为 True,否则为 False """ return self.core.alive @alive.setter def alive(self, value): self.core.alive = value def dump_login_status(self, cache_path=None): logger.debug('{}: dumping login status'.format(self)) return self.core.dump_login_status(cache_path or self.cache_path) # chats def enable_puid(self, path='wxpy_puid.pkl'): """ **可选操作:** 启用聊天对象的 :any:`puid <Chat.puid>` 属性:: # 启用 puid 属性,并指定 puid 所需的映射数据保存/载入路径 bot.enable_puid('wxpy_puid.pkl') # 指定一个好友 my_friend = bot.friends().search('游否')[0] # 查看他的 puid print(my_friend.puid) # 'edfe8468' .. tip:: | :any:`puid <Chat.puid>` 是 **wxpy 特有的聊天对象/用户ID** | 不同于其他 ID 属性,**puid** 可始终被获取到,且具有稳定的唯一性 :param path: puid 所需的映射数据保存/载入路径 """ self.puid_map = PuidMap(path) return self.puid_map def except_self(self, chats_or_dicts): """ 从聊天对象合集或用户字典列表中排除自身 :param chats_or_dicts: 聊天对象合集或用户字典列表 :return: 排除自身后的列表 :rtype: :class:`wxpy.Chats` """ return list(filter(lambda x: get_user_name(x) != self.self.user_name, chats_or_dicts)) def chats(self, update=False): """ 获取所有聊天对象 :param update: 是否更新 :return: 聊天对象合集 :rtype: :class:`wxpy.Chats` """ return Chats(self.friends(update) + self.groups(update) + self.mps(update), self) def _retrieve_itchat_storage(self, attr): with self.core.storageClass.updateLock: return getattr(self.core.storageClass, attr) @handle_response(Friend) def friends(self, update=False): """ 获取所有好友 :param update: 是否更新 :return: 聊天对象合集 :rtype: :class:`wxpy.Chats` """ if update: logger.info('{}: updating friends'.format(self)) return self.core.get_friends(update=update) else: return self._retrieve_itchat_storage('memberList') @handle_response(Group) def groups(self, update=False, contact_only=False): """ 获取所有群聊对象 一些不活跃的群可能无法被获取到,可通过在群内发言,或修改群名称的方式来激活 :param update: 是否更新 :param contact_only: 是否限于保存为联系人的群聊 :return: 群聊合集 :rtype: :class:`wxpy.Groups` """ # itchat 原代码有些难懂,似乎 itchat 中的 get_contact() 所获取的内容视其 update 参数而变化 # 如果 update=False 获取所有类型的本地聊天对象 # 反之如果 update=True,变为获取收藏的聊天室 if update or contact_only: logger.info('{}: updating groups'.format(self)) return self.core.get_chatrooms(update=update, contactOnly=contact_only) else: return self._retrieve_itchat_storage('chatroomList') @handle_response(MP) def mps(self, update=False): """ 获取所有公众号 :param update: 是否更新 :return: 聊天对象合集 :rtype: :class:`wxpy.Chats` """ if update: logger.info('{}: updating mps'.format(self)) return self.core.get_mps(update=update) else: return self._retrieve_itchat_storage('mpList') @handle_response(User) def user_details(self, user_or_users, chunk_size=50): """ 获取单个或批量获取多个用户的详细信息(地区、性别、签名等),但不可用于群聊成员 :param user_or_users: 单个或多个用户对象或 user_name :param chunk_size: 分配请求时的单批数量,目前为 50 :return: 单个或多个用户用户的详细信息 """ def chunks(): total = ensure_list(user_or_users) for i in range(0, len(total), chunk_size): yield total[i:i + chunk_size] @handle_response() def process_one_chunk(_chunk): return self.core.update_friend(userName=get_user_name(_chunk)) if isinstance(user_or_users, (list, tuple)): ret = list() for chunk in chunks(): chunk_ret = process_one_chunk(chunk) if isinstance(chunk_ret, list): ret += chunk_ret else: ret.append(chunk_ret) return ret else: return process_one_chunk(user_or_users) def search(self, keywords=None, **attributes): """ 在所有类型的聊天对象中进行搜索 .. note:: | 搜索结果为一个 :class:`Chats (列表) <Chats>` 对象 | 建议搭配 :any:`ensure_one()` 使用 :param keywords: 聊天对象的名称关键词 :param attributes: 属性键值对,键可以是 sex(性别), province(省份), city(城市) 等。例如可指定 province='广东' :return: 匹配的聊天对象合集 :rtype: :class:`wxpy.Chats` """ return self.chats().search(keywords, **attributes) # add / create @handle_response() def add_friend(self, user, verify_content=''): """ 添加用户为好友 :param user: 用户对象,或 user_name :param verify_content: 验证说明信息 """ logger.info('{}: adding {} (verify_content: {})'.format(self, user, verify_content)) user_name = get_user_name(user) return self.core.add_friend( userName=user_name, status=2, verifyContent=verify_content, autoUpdate=True ) @handle_response() def add_mp(self, user): """ 添加/关注 公众号 :param user: 公众号对象,或 user_name """ logger.info('{}: adding {}'.format(self, user)) user_name = get_user_name(user) return self.core.add_friend( userName=user_name, status=1, autoUpdate=True ) def accept_friend(self, user, verify_content=''): """ 接受用户为好友 :param user: 用户对象或 user_name :param verify_content: 验证说明信息 :return: 新的好友对象 :rtype: :class:`wxpy.Friend` """ logger.info('{}: accepting {} (verify_content: {})'.format(self, user, verify_content)) @handle_response() def do(): return self.core.add_friend( userName=get_user_name(user), status=3, verifyContent=verify_content, autoUpdate=True ) do() # 若上一步没有抛出异常,则返回该好友 for friend in self.friends(): if friend == user: return friend def create_group(self, users, topic=None): """ 创建一个新的群聊 :param users: 用户列表 :param topic: 群名称 :return: 若建群成功,返回一个新的群聊对象 :rtype: :class:`wxpy.Group` """ logger.info('{}: creating group (topic: {}), with users:\n{}'.format( self, topic, pformat(users))) @handle_response() def request(): return self.core.create_chatroom( memberList=dict_list, topic=topic or '' ) dict_list = wrap_user_name(self.except_self(ensure_list(users))) ret = request() user_name = ret.get('ChatRoomName') if user_name: return Group(self.core.update_chatroom(userName=user_name), self) else: raise Exception('Failed to create group:\n{}'.format(pformat(ret))) # upload def upload_file(self, path): """ | 上传文件,并获取 media_id | 可用于重复发送图片、表情、视频,和文件 :param path: 文件路径 :return: media_id :rtype: str """ logger.info('{}: uploading file: {}'.format(self, path)) @handle_response() def do(): upload = functools.partial(self.core.upload_file, fileDir=path) ext = os.path.splitext(path)[1].lower() if ext in ('.bmp', '.png', '.jpeg', '.jpg', '.gif'): return upload(isPicture=True) elif ext == '.mp4': return upload(isVideo=True) else: return upload() return do().get('MediaId') # messages / register def _process_message(self, msg): """ 处理接收到的消息 """ if not self.alive: return config = self.registered.get_config(msg) logger.debug('{}: new message (func: {}):\n{}'.format( self, config.func.__name__ if config else None, msg)) if not config: return def process(): # noinspection PyBroadException try: ret = config.func(msg) if ret is not None: msg.reply(ret) except: logger.exception('\nAn error occurred in {}.'.format(config.func)) if config.run_async: start_new_thread(process, use_caller_name=True) else: process() def register( self, chats=None, msg_types=None, except_self=True, run_async=True, enabled=True ): """ 装饰器:用于注册消息配置 :param chats: 消息所在的聊天对象:单个或列表形式的多个聊天对象或聊天类型,为空时匹配所有聊天对象 :param msg_types: 消息的类型:单个或列表形式的多个消息类型,为空时匹配所有消息类型 (SYSTEM 类消息除外) :param except_self: 排除由自己发送的消息 :param run_async: 是否异步执行所配置的函数:可提高响应速度 :param enabled: 当前配置的默认开启状态,可事后动态开启或关闭 """ def do_register(func): self.registered.append(MessageConfig( bot=self, func=func, chats=chats, msg_types=msg_types, except_self=except_self, run_async=run_async, enabled=enabled )) return func return do_register def _listen(self): try: logger.info('{}: started'.format(self)) self.is_listening = True while self.alive and self.is_listening: try: msg = Message(self.core.msgList.get(timeout=0.5), self) except queue.Empty: continue if msg.type is not SYSTEM: self.messages.append(msg) self._process_message(msg) finally: self.is_listening = False logger.info('{}: stopped'.format(self)) def start(self): """ 开始消息监听和处理 (登陆后会自动开始) """ if not self.alive: logger.warning('{} has been logged out!'.format(self)) elif self.is_listening: logger.warning('{} is already running, no need to start again.'.format(self)) else: self.listening_thread = start_new_thread(self._listen) def stop(self): """ 停止消息监听和处理 (登出后会自动停止) """ if self.is_listening: self.is_listening = False self.listening_thread.join() else: logger.warning('{} is not running.'.format(self)) def join(self): """ 堵塞进程,直到结束消息监听 (例如,机器人被登出时) """ if isinstance(self.listening_thread, Thread): try: logger.info('{}: joined'.format(self)) self.listening_thread.join() except KeyboardInterrupt: pass def _cleanup(self): if self.is_listening: self.stop() if self.alive and self.core.useHotReload: self.dump_login_status() self.temp_dir.cleanup()
27.902857
109
0.56468
4a243b58bf19dcff418dc05419da731d417457c7
2,428
py
Python
env/lib/python3.6/site-packages/openpyxl/utils/dataframe.py
anthowen/duplify
846d01c1b21230937fdf0281b0cf8c0b08a8c24e
[ "MIT" ]
6
2018-05-15T05:08:52.000Z
2021-12-23T12:31:28.000Z
env/lib/python3.6/site-packages/openpyxl/utils/dataframe.py
anthowen/duplify
846d01c1b21230937fdf0281b0cf8c0b08a8c24e
[ "MIT" ]
4
2021-03-11T04:02:00.000Z
2022-03-27T08:31:56.000Z
env/lib/python3.6/site-packages/openpyxl/utils/dataframe.py
anthowen/duplify
846d01c1b21230937fdf0281b0cf8c0b08a8c24e
[ "MIT" ]
5
2018-06-26T11:57:17.000Z
2021-03-28T06:52:15.000Z
from __future__ import absolute_import # Copyright (c) 2010-2018 openpyxl import operator from openpyxl.compat import accumulate, zip def dataframe_to_rows(df, index=True, header=True): """ Convert a Pandas dataframe into something suitable for passing into a worksheet. If index is True then the index will be included, starting one row below the header. If header is True then column headers will be included starting one column to the right. Formatting should be done by client code. """ import numpy from pandas import Timestamp blocks = df._data.blocks ncols = sum(b.shape[0] for b in blocks) data = [None] * ncols for b in blocks: values = b.values if b.dtype.type == numpy.datetime64: values = numpy.array([Timestamp(v) for v in values.ravel()]) values = values.reshape(b.shape) result = values.tolist() for col_loc, col in zip(b.mgr_locs, result): data[col_loc] = col if header: if df.columns.nlevels > 1: rows = expand_levels(df.columns.levels) else: rows = [list(df.columns.values)] for row in rows: n = [] for v in row: if isinstance(v, numpy.datetime64): v = Timestamp(v) n.append(v) row = n if index: row = [None]*df.index.nlevels + row yield row cols = None if df.index.nlevels > 1: cols = zip(*expand_levels(df.index.levels)) if index: yield df.index.names for idx, v in enumerate(df.index): row = [data[j][idx] for j in range(ncols)] if index: if cols: v = list(next(cols)) else: v = [v] row = v + row yield row def expand_levels(levels): """ Multiindexes need expanding so that subtitles repeat """ widths = (len(s) for s in levels) widths = list(accumulate(widths, operator.mul)) size = max(widths) for level, width in zip(levels, widths): padding = int(size/width) # how wide a title should be repeat = int(width/len(level)) # how often a title is repeated row = [] for v in level: title = [None]*padding title[0] = v row.extend(title) row = row*repeat yield row
28.564706
92
0.568369
4a243cc423712106ddcd73878c64d711ecf9130d
19,118
py
Python
localstack/services/generic_proxy.py
ap0/localstack
56fc6e0e606d1777d1982e91a9bb13d22da1a124
[ "Apache-2.0" ]
null
null
null
localstack/services/generic_proxy.py
ap0/localstack
56fc6e0e606d1777d1982e91a9bb13d22da1a124
[ "Apache-2.0" ]
null
null
null
localstack/services/generic_proxy.py
ap0/localstack
56fc6e0e606d1777d1982e91a9bb13d22da1a124
[ "Apache-2.0" ]
null
null
null
import re import os import sys import ssl import json import socket import inspect import logging import traceback import click import requests from ssl import SSLError from flask_cors import CORS from requests.structures import CaseInsensitiveDict from requests.models import Response, Request from six import iteritems from six.moves.socketserver import ThreadingMixIn from six.moves.urllib.parse import urlparse from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from localstack.config import TMP_FOLDER, USE_SSL, EXTRA_CORS_ALLOWED_HEADERS, EXTRA_CORS_EXPOSE_HEADERS from localstack.constants import ENV_INTERNAL_TEST_RUN, APPLICATION_JSON from localstack.utils.common import FuncThread, generate_ssl_cert, to_bytes QUIET = False # path for test certificate SERVER_CERT_PEM_FILE = '%s/server.test.pem' % (TMP_FOLDER) CORS_ALLOWED_HEADERS = ['authorization', 'content-type', 'content-md5', 'cache-control', 'x-amz-content-sha256', 'x-amz-date', 'x-amz-security-token', 'x-amz-user-agent', 'x-amz-target', 'x-amz-acl', 'x-amz-version-id', 'x-localstack-target', 'x-amz-tagging'] if EXTRA_CORS_ALLOWED_HEADERS: CORS_ALLOWED_HEADERS += EXTRA_CORS_ALLOWED_HEADERS.split(',') CORS_ALLOWED_METHODS = ('HEAD', 'GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'PATCH') CORS_EXPOSE_HEADERS = ('x-amz-version-id', ) if EXTRA_CORS_EXPOSE_HEADERS: CORS_EXPOSE_HEADERS += tuple(EXTRA_CORS_EXPOSE_HEADERS.split(',')) # set up logger LOG = logging.getLogger(__name__) class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): """Handle each request in a separate thread.""" daemon_threads = True class ProxyListener(object): def forward_request(self, method, path, data, headers): """ This interceptor method is called by the proxy when receiving a new request (*before* forwarding the request to the backend service). It receives details of the incoming request, and returns either of the following results: * True if the request should be forwarded to the backend service as-is (default). * An integer (e.g., 200) status code to return directly to the client without calling the backend service. * An instance of requests.models.Response to return directly to the client without calling the backend service. * An instance of requests.models.Request which represents a new/modified request that will be forwarded to the backend service. * Any other value, in which case a 503 Bad Gateway is returned to the client without calling the backend service. """ return True def return_response(self, method, path, data, headers, response, request_handler=None): """ This interceptor method is called by the proxy when returning a response (*after* having forwarded the request and received a response from the backend service). It receives details of the incoming request as well as the response from the backend service, and returns either of the following results: * An instance of requests.models.Response to return to the client instead of the actual response returned from the backend service. * Any other value, in which case the response from the backend service is returned to the client. """ return None def get_forward_url(self, method, path, data, headers): """ Return a custom URL to forward the given request to. If a falsy value is returned, then the default URL will be used. """ return None class GenericProxyHandler(BaseHTTPRequestHandler): # List of `ProxyListener` instances that are enabled by default for all requests DEFAULT_LISTENERS = [] def __init__(self, request, client_address, server): self.request = request self.client_address = client_address self.server = server self.proxy = server.my_object self.data_bytes = None self.protocol_version = self.proxy.protocol_version try: BaseHTTPRequestHandler.__init__(self, request, client_address, server) except SSLError as e: LOG.warning('SSL error when handling request: %s' % e) def parse_request(self): result = BaseHTTPRequestHandler.parse_request(self) if not result: return result if sys.version_info[0] >= 3: return result # Required fix for Python 2 (otherwise S3 uploads are hanging), based on the Python 3 code: # https://sourcecodebrowser.com/python3.2/3.2.3/http_2server_8py_source.html#l00332 expect = self.headers.get('Expect', '') if (expect.lower() == '100-continue' and self.protocol_version >= 'HTTP/1.1' and self.request_version >= 'HTTP/1.1'): if self.request_version != 'HTTP/0.9': self.wfile.write(('%s %d %s\r\n' % (self.protocol_version, 100, 'Continue')).encode('latin1', 'strict')) self.end_headers() return result def do_GET(self): self.method = requests.get self.read_content() self.forward('GET') def do_PUT(self): self.method = requests.put self.read_content() self.forward('PUT') def do_POST(self): self.method = requests.post self.read_content() self.forward('POST') def do_DELETE(self): self.data_bytes = None self.method = requests.delete self.forward('DELETE') def do_HEAD(self): self.data_bytes = None self.method = requests.head self.forward('HEAD') def do_PATCH(self): self.method = requests.patch self.read_content() self.forward('PATCH') def do_OPTIONS(self): self.data_bytes = None self.method = requests.options self.forward('OPTIONS') def do_CONNECT(self): self.method = None self.headers['Connection'] = self.headers.get('Connection') or 'keep-alive' self.forward('CONNECT') def read_content(self): content_length = self.headers.get('Content-Length') if content_length: self.data_bytes = self.rfile.read(int(content_length)) return self.data_bytes = None if self.method in (requests.post, requests.put): LOG.warning('Expected Content-Length header not found in POST/PUT request') # If the Content-Length header is missing, try to read # content from the socket using a socket timeout. socket_timeout_secs = 0.5 self.request.settimeout(socket_timeout_secs) block_length = 1 while True: try: # TODO find a more efficient way to do this! tmp = self.rfile.read(block_length) if self.data_bytes is None: self.data_bytes = tmp else: self.data_bytes += tmp except socket.timeout: break def build_x_forwarded_for(self, headers): x_forwarded_for = headers.get('X-Forwarded-For') client_address = self.client_address[0] server_address = ':'.join(map(str, self.server.server_address)) if x_forwarded_for: x_forwarded_for_list = (x_forwarded_for, client_address, server_address) else: x_forwarded_for_list = (client_address, server_address) return ', '.join(x_forwarded_for_list) def forward(self, method): data = self.data_bytes forward_headers = CaseInsensitiveDict(self.headers) # force close connection if forward_headers.get('Connection', '').lower() != 'keep-alive': self.close_connection = 1 def is_full_url(url): return re.match(r'[a-zA-Z]+://.+', url) path = self.path if is_full_url(path): path = path.split('://', 1)[1] path = '/%s' % (path.split('/', 1)[1] if '/' in path else '') forward_base_url = self.proxy.forward_base_url proxy_url = '%s%s' % (forward_base_url, path) for listener in self._listeners(): if listener: proxy_url = listener.get_forward_url(method, path, data, forward_headers) or proxy_url target_url = self.path if not is_full_url(target_url): target_url = '%s%s' % (forward_base_url, target_url) # update original "Host" header (moto s3 relies on this behavior) if not forward_headers.get('Host'): forward_headers['host'] = urlparse(target_url).netloc if 'localhost.atlassian.io' in forward_headers.get('Host'): forward_headers['host'] = 'localhost' forward_headers['X-Forwarded-For'] = self.build_x_forwarded_for(forward_headers) try: response = None modified_request = None # update listener (pre-invocation) for listener in self._listeners(): if not listener: continue listener_result = listener.forward_request(method=method, path=path, data=data, headers=forward_headers) if isinstance(listener_result, Response): response = listener_result break if isinstance(listener_result, dict): response = Response() response._content = json.dumps(listener_result) response.headers['Content-Type'] = APPLICATION_JSON response.status_code = 200 break elif isinstance(listener_result, Request): modified_request = listener_result data = modified_request.data forward_headers = modified_request.headers break elif listener_result is not True: # get status code from response, or use Bad Gateway status code code = listener_result if isinstance(listener_result, int) else 503 self.send_response(code) self.send_header('Content-Length', '0') # allow pre-flight CORS headers by default self._send_cors_headers() self.end_headers() return # perform the actual invocation of the backend service if response is None: forward_headers['Connection'] = forward_headers.get('Connection') or 'close' data_to_send = self.data_bytes request_url = proxy_url if modified_request: if modified_request.url: request_url = '%s%s' % (forward_base_url, modified_request.url) data_to_send = modified_request.data response = self.method(request_url, data=data_to_send, headers=forward_headers, stream=True) # prevent requests from processing response body if not response._content_consumed and response.raw: response._content = response.raw.read() # update listener (post-invocation) if self.proxy.update_listener: kwargs = { 'method': method, 'path': path, 'data': data, 'headers': forward_headers, 'response': response } if 'request_handler' in inspect.getargspec(self.proxy.update_listener.return_response)[0]: # some listeners (e.g., sqs_listener.py) require additional details like the original # request port, hence we pass in a reference to this request handler as well. kwargs['request_handler'] = self updated_response = self.proxy.update_listener.return_response(**kwargs) if isinstance(updated_response, Response): response = updated_response # copy headers and return response self.send_response(response.status_code) content_length_sent = False for header_key, header_value in iteritems(response.headers): # filter out certain headers that we don't want to transmit if header_key.lower() not in ('transfer-encoding', 'date', 'server'): self.send_header(header_key, header_value) content_length_sent = content_length_sent or header_key.lower() == 'content-length' if not content_length_sent: self.send_header('Content-Length', '%s' % len(response.content) if response.content else 0) # allow pre-flight CORS headers by default self._send_cors_headers(response) self.end_headers() if response.content and len(response.content): self.wfile.write(to_bytes(response.content)) except Exception as e: trace = str(traceback.format_exc()) conn_errors = ('ConnectionRefusedError', 'NewConnectionError', 'Connection aborted', 'Unexpected EOF', 'Connection reset by peer') conn_error = any(e in trace for e in conn_errors) error_msg = 'Error forwarding request: %s %s' % (e, trace) if 'Broken pipe' in trace: LOG.warn('Connection prematurely closed by client (broken pipe).') elif not self.proxy.quiet or not conn_error: LOG.error(error_msg) if os.environ.get(ENV_INTERNAL_TEST_RUN): # During a test run, we also want to print error messages, because # log messages are delayed until the entire test run is over, and # hence we are missing messages if the test hangs for some reason. print('ERROR: %s' % error_msg) self.send_response(502) # bad gateway self.end_headers() # force close connection self.close_connection = 1 finally: try: self.wfile.flush() except Exception as e: LOG.warning('Unable to flush write file: %s' % e) def _send_cors_headers(self, response=None): # Note: Use "response is not None" here instead of "not response"! headers = response is not None and response.headers or {} if 'Access-Control-Allow-Origin' not in headers: self.send_header('Access-Control-Allow-Origin', '*') if 'Access-Control-Allow-Methods' not in headers: self.send_header('Access-Control-Allow-Methods', ','.join(CORS_ALLOWED_METHODS)) if 'Access-Control-Allow-Headers' not in headers: requested_headers = self.headers.get('Access-Control-Request-Headers', '') requested_headers = re.split(r'[,\s]+', requested_headers) + CORS_ALLOWED_HEADERS self.send_header('Access-Control-Allow-Headers', ','.join([h for h in requested_headers if h])) if 'Access-Control-Expose-Headers' not in headers: self.send_header('Access-Control-Expose-Headers', ','.join(CORS_EXPOSE_HEADERS)) def _listeners(self): return self.DEFAULT_LISTENERS + [self.proxy.update_listener] def log_message(self, format, *args): return class DuplexSocket(ssl.SSLSocket): """ Simple duplex socket wrapper that allows serving HTTP/HTTPS over the same port. """ def accept(self): newsock, addr = socket.socket.accept(self) peek_bytes = 5 first_bytes = newsock.recv(peek_bytes, socket.MSG_PEEK) if len(first_bytes or '') == peek_bytes: first_byte = first_bytes[0] if first_byte < 32 or first_byte >= 127: newsock = self.context.wrap_socket(newsock, do_handshake_on_connect=self.do_handshake_on_connect, suppress_ragged_eofs=self.suppress_ragged_eofs, server_side=True) return newsock, addr # set globally defined SSL socket implementation class ssl.SSLContext.sslsocket_class = DuplexSocket class GenericProxy(FuncThread): def __init__(self, port, forward_url=None, ssl=False, host=None, update_listener=None, quiet=False, params={}): FuncThread.__init__(self, self.run_cmd, params, quiet=quiet) self.httpd = None self.port = port self.ssl = ssl self.quiet = quiet if forward_url: if '://' not in forward_url: forward_url = 'http://%s' % forward_url forward_url = forward_url.rstrip('/') self.forward_base_url = forward_url self.update_listener = update_listener self.server_stopped = False # Required to enable 'Connection: keep-alive' for S3 uploads self.protocol_version = params.get('protocol_version') or 'HTTP/1.1' self.listen_host = host or '' def run_cmd(self, params): try: self.httpd = ThreadedHTTPServer((self.listen_host, self.port), GenericProxyHandler) if self.ssl: # make sure we have a cert generated combined_file, cert_file_name, key_file_name = GenericProxy.create_ssl_cert(serial_number=self.port) self.httpd.socket = ssl.wrap_socket(self.httpd.socket, server_side=True, certfile=combined_file) self.httpd.my_object = self self.httpd.serve_forever() except Exception as e: if not self.quiet or not self.server_stopped: LOG.error('Exception running proxy on port %s: %s %s' % (self.port, e, traceback.format_exc())) def stop(self, quiet=False): self.quiet = quiet if self.httpd: self.httpd.server_close() self.server_stopped = True @classmethod def create_ssl_cert(cls, serial_number=None): return generate_ssl_cert(SERVER_CERT_PEM_FILE, serial_number=serial_number) @classmethod def get_flask_ssl_context(cls, serial_number=None): if USE_SSL: combined_file, cert_file_name, key_file_name = cls.create_ssl_cert(serial_number=serial_number) return (cert_file_name, key_file_name) return None def serve_flask_app(app, port, quiet=True, host=None, cors=True): if cors: CORS(app) if quiet: logging.getLogger('werkzeug').setLevel(logging.ERROR) if not host: host = '0.0.0.0' ssl_context = GenericProxy.get_flask_ssl_context(serial_number=port) app.config['ENV'] = 'development' def noecho(*args, **kwargs): pass click.echo = noecho app.run(port=int(port), threaded=True, host=host, ssl_context=ssl_context) return app
41.925439
116
0.619992
4a243cc6298393af428b5de5bebdd9a02cfc0b67
18,569
py
Python
scripts/pocketAnalysis/generateVoxels.py
demattox/lec_gly_binding
44a12445d3ed89029a21bed1c516a67bd86e0c68
[ "MIT" ]
null
null
null
scripts/pocketAnalysis/generateVoxels.py
demattox/lec_gly_binding
44a12445d3ed89029a21bed1c516a67bd86e0c68
[ "MIT" ]
null
null
null
scripts/pocketAnalysis/generateVoxels.py
demattox/lec_gly_binding
44a12445d3ed89029a21bed1c516a67bd86e0c68
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jul 17 10:44:57 2020 @author: dmattox """ import os import glob import dill import time # import itertools, collections import numpy as np import Bio.PDB # import pliptool.plip.modules.plipxml as plipxml from scipy.spatial import ConvexHull from sklearn.cluster import DBSCAN oWD = os.getcwd() oWD += '/' import lec_gly as LecGly import checkPLIPligands as LigCheck from bSiteResiFeatures import plipFile from pocketAnalysis.pdb2wrl_surface import wrlDir os.chdir(LecGly.homeDir) ############################################ mol2Dir = './data/structures/bsites/bsiteVoxels/' if not os.path.exists(mol2Dir): os.makedirs(mol2Dir) logFile = oWD + 'generateVoxels_logfile.txt' # Generates a log file in the directory from which the script is called (thoght to be the subdirectory containing a batch processing list of PDBs to run) ############################################ MIN_CUBE_EDGE = 20 # define the minimum length of the cube edge GRID_POINT_SPACING = (0.5)**(1/3) # how far apart to place the grid points PRO_ATM_THRESH = 2.5 # Threshold distance to a heavy protein atom to consider a point within the protein surface MAX_DIST_FROM_LIG = 10 # Threshold for maximum allowed distance for any grid point from a heavy ligand atom POCKET_THRESHOLDS = [4,6,8] # Distance values for binning points prior to clustering POCKET_THRESHOLDS.append(MAX_DIST_FROM_LIG) DBSCAN_EPS = np.sqrt(3/4) * GRID_POINT_SPACING * 2 + 0.01 # The maximum distance between two samples for one to be considered as in the neighborhood of the other. Setting to the max length between directly neighboring points, allowing for 26 possible nieghbors DBSCAN_MIN_SAMPS = 13 # The number of samples (or total weight) in a neighborhood for a point to be considered as a core point. CLUSTER_SIZE_THRESH = 15 # Prune clusters of pocket points with less than 15 Ang**3 of volume CLUSTER_SIZE_THRESH = CLUSTER_SIZE_THRESH/(GRID_POINT_SPACING**3) # convert from Ang**2 to number of points based on spacing PNTS_NEAR_LIG = 0.1 # Prune clusters with fewer than 10% of its points within 2 Ang of any heavy ligand atom ############################################ if __name__ == '__main__': pdbFiles = glob.glob(LigCheck.originalPDBsDir + '*.pdb') with open(plipFile, 'rb') as pickleFH: allPLIP = dill.load(pickleFH) ############################################ globalStart = time.time() plipCnt = 0 bsCnt = 0 runList = [] # List to hold subset of PDB ids to run in batch processing files = os.listdir(oWD) batchList = [f for f in files if f[:7] == 'pdbList'][0] with open(oWD + batchList, 'r') as inFH: for line in inFH: runList.append(line.strip()) # runList = list(allPLIP.keys()) with open(logFile, 'w') as logFH: for k,pdb in enumerate(runList): plipCnt +=1 if k % (round(len(runList)/10, 0)) == 0: print("Processing PBD file number " + str(k) + ' of ' + str(len(runList))) logFH.write('\n########\n'+pdb+'\n########\n') start = time.time() pdbIN = [f for f in pdbFiles if f[-8:-4] == pdb][0] parser = Bio.PDB.PDBParser(QUIET=True) model = parser.get_structure(pdb, pdbIN)[0] # grab the first model in PDB file searcher = Bio.PDB.NeighborSearch([a for a in model.get_atoms() if (a.get_parent().full_id[3][0][:2].strip() == '' and a.element != 'H')]) # Prepare bioPDB searcher to eliminate resiudes within the protein surface (<2.5 Ang from a heavy protein atom) for bs in allPLIP[pdb].bsites: bsCnt += 1 logFH.write('\n' + bs + '\n') # Identify ligand and binding site atoms ligAtms = LecGly.getLigAtoms(model, allPLIP[pdb].bsites[bs]) # bsResIDs = [res['aa'] + ':' + res['reschain'] + ':' + str(res['resnr']) for res in allPLIP[pdb].bsites[bs].bs_res] # if pdb in zeroResis.keys(): # Check for zero numbered resiudes and correct the res num to match the original number including the i_code # if bs in zeroResis[pdb]: # for i,resID in enumerate(bsResIDs): # resID = resID.split(':') # rID = resID[2]+resID[1] # resnum from PLIP with chain ID # if rID in zeroResis[pdb][bs].keys(): # resID[2] = zeroResis[pdb][bs][rID] # Replace PLIP resnum with true resnum with icode # bsResIDs[i] = ':'.join(resID) # proAtms = [] # Holds all heavy atoms in residues within the binding site # for res in model.get_residues(): # resID = res2plipID(res) # if res.full_id[3][2] != ' ': # If the residue has an i_code, append it to the resID to match the modified PLIP resIDs # resID = resID + res.full_id[3][2] # if resID in bsResIDs: # for a in res.get_atoms(): # if a.element != 'H': # proAtms.append(a) CL = LecGly.getCentroid(ligAtms) # Ligand centroid # CP = LecGly.getCentroid(proAtms) # Binding sites residues centroid # cDist = LecGly.eucDist(CL,CP) # Distance between ligand centroid and binding site residues centroid ligAtmDists = [LecGly.eucDist(CL, a.coord) for a in ligAtms] # Distance between ligand centroid and all atoms in the ligand cubeEdge = MIN_CUBE_EDGE if max(ligAtmDists) <= (MIN_CUBE_EDGE/2.5) else round(2.5*max(ligAtmDists)) # Set the size of the cube to be at least 20 Ang along each edge, or larger for larger ligands. Round to keep grid points even # apprxCL = [round(p) for p in CL] # rounded coordinates of ligand centroid cubeLimits = [[d + cubeEdge/2, d - cubeEdge/2] for d in CL] # cubeVerts = list(itertools.product(*cubeLimits)) # coords2Mol2('data/unilectin/structures/testcubeverts.mol2', cubeVerts) gridPnts = [] # hold the grid points within the cube defined above centered on the ligand centroid for x in np.arange(min(cubeLimits[0]),max(cubeLimits[0])+GRID_POINT_SPACING, step = GRID_POINT_SPACING): for y in np.arange(min(cubeLimits[1]),max(cubeLimits[1])+GRID_POINT_SPACING, step = GRID_POINT_SPACING): for z in np.arange(min(cubeLimits[2]),max(cubeLimits[2])+GRID_POINT_SPACING, step = GRID_POINT_SPACING): gridPnts.append([x,y,z]) # coords2Mol2('data/unilectin/structures/testgridInit.mol2', gridPnts) wrlFile = wrlDir + pdb + '_' + bs.replace(':','-') + '.wrl' proCoords = LecGly.getPntsFromWRL(wrlFile) # Points representing the van der Waals surface of the binding site residues # LecGly.coords2Mol2('data/unilectin/structures/' + bs+'surface.mol2', proCoords) ######################################################## # Begin excluding points # Exclude points within protein surface nonBuriedPnts = [] for p in gridPnts: closeProAtms = searcher.search(p,radius = PRO_ATM_THRESH, level = 'A') if len(closeProAtms) == 0: nonBuriedPnts.append(p) # coords2Mol2('data/unilectin/structures/testgridCloseInhullNotburied.mol2', nonBuriedPnts) logFH.write('From ' + str(len(gridPnts)) + ' points, ' + str(len(nonBuriedPnts)) + ' points found outside of the protein surface\n') # print('From ' + str(len(gridPnts)) + ' points, ' + str(len(nonBuriedPnts)) + ' points found outside of the protein surface\n') # Exclude points far from the ligand binPnts = [[] for b in POCKET_THRESHOLDS] # Holds points in each bin for each binning distance threshold lower than the max threshold for p in nonBuriedPnts: dists = [LecGly.eucDist(p,a.coord) for a in ligAtms] if min(dists) <= MAX_DIST_FROM_LIG: d = min(dists) for i,b in enumerate(POCKET_THRESHOLDS): if d <= b: binPnts[i].append(p) # coords2Mol2('data/unilectin/structures/testgridClose.mol2', binPnts[-1]) logFH.write('From ' + str(len(nonBuriedPnts)) + ' points, ' + str(len(binPnts[-1])) + ' points found within the max threshold distance of a ligand atom\n') # print('From ' + str(len(nonBuriedPnts)) + ' points, ' + str(len(binPnts[-1])) + ' points found within the threshold distance of a ligand atom\n') # Exclude points outside of convex hull initHull = ConvexHull(proCoords) hullVerts = initHull.points[initHull.vertices] hull = ConvexHull(points = hullVerts, incremental=True) inHullPnts = [] for p in binPnts[-1]: # Exclude points from largest cpocket threshold that are exterior to convex hull first, then check for those points prescence in the smaller pocket threshold point sets newVertInd = len(hull.points) # If a new vert shows up with this index, it is outside of the convex hull hull.add_points(np.array([p])) if newVertInd in hull.vertices: # if point is outside convex hull hull = ConvexHull(points = hullVerts, incremental=True) # reset convex hull else: inHullPnts.append(p) hull.close() # coords2Mol2('./data/unilectin/structures/bSites/pntsb4DBSCAN/' + pdb + '_' + bs.replace(':','-') + '.mol2', inHullPnts) logFH.write('From ' + str(len(binPnts[-1])) + ' points, ' + str(len(inHullPnts)) + ' points found within the convex hull\n\n') # print('From ' + str(len(binPnts[-1])) + ' points, ' + str(len(inHullPnts)) + ' points found within the convex hull\n') # Drop points outside of the convex hull from the binned points as well for i in range(len(binPnts)): binPnts[i] = [p for p in binPnts[i] if p in inHullPnts] # for b in binPnts: print(len(b)) # Cluster points together to identify individual pockets and eliminate pockets far from the ligand # prevHit = False prevNum_Vol = [0,0] # If a pocket from a lower threshold had 1+ clusters pass the size and ligand proximity threshold, store the number of clusters prevNum_Vol[0] and the total volume of the pocket prevNum_Vol[1] for i,pntSet in enumerate(binPnts): pntArr = np.array(pntSet) clusters = DBSCAN(eps = DBSCAN_EPS, min_samples= DBSCAN_MIN_SAMPS).fit(pntArr) #DBSCAN to cluster non-excluded points together into pockets # print(i, set(clusters.labels_)) # for ind in set(clusters.labels_): # print('Cluster ind',str(ind)) # print('\t',str(sum(clusters.labels_ == ind)), 'points') # coords2Mol2('data/unilectin/structures/testClust'+ '_' + str(i) + '_' +str(ind) +'.mol2', pntArr[clusters.labels_ == ind]) ### First pass method, take acceptable clusters as you go and if you get 0 clusters, take the next best one if you got any clusters at a smaller pocket threshold # goodClusts = [] # failed_bestInd = '' # failed_bestPercentage = 0 # If a pocket has clusters that pass the threshold initially but later fails to hit the 10% (PNTS_NEAR_LIG) threshold as the pocket expands, for each threshold that fails keep the cluster with the most points near the ligand atoms # for ind in set(clusters.labels_): # if ind != -1: # Don't consider the noise cluster # clusPnts = pntArr[clusters.labels_ == ind] # if len(clusPnts) > CLUSTER_SIZE_THRESH: # Filter out clusters with too few points # closePntCnt = 0 # for p in clusPnts: # dists = [LecGly.eucDist(p, a.coord) for a in ligAtms] # if min(dists) <= 2: # closePntCnt += 1 # if closePntCnt >= len(clusPnts)*PNTS_NEAR_LIG: # goodClusts.append(clusPnts) # prevHit = True # elif prevHit == True and len(goodClusts) == 0: # If one of the clusters from the tighter bin passed the percentage threshold, take the cluster with the most points within 2 Ang of a heavy ligand atom # if (closePntCnt/len(clusPnts)) > failed_bestPercentage: # failed_bestInd = ind # failed_bestPercentage = (closePntCnt/len(clusPnts)) # if failed_bestInd != '' and len(goodClusts) == 0: # No clusters pass the threshold but clusters from smaller bins did pass, & any clusters have any points within 2 Ang of a heavy ligand atom # goodClusts.append(pntArr[clusters.labels_ == failed_bestInd]) largeClusInds = [] largeClusPercents = [] goodClusts = [] for ind in set(clusters.labels_): if ind != -1: # Don't consider the noise cluster clusPnts = pntArr[clusters.labels_ == ind] if len(clusPnts) > CLUSTER_SIZE_THRESH: # Filter out clusters with too few points largeClusInds.append(ind) closePntCnt = 0 for p in clusPnts: dists = [LecGly.eucDist(p, a.coord) for a in ligAtms] if min(dists) <= 2: closePntCnt += 1 largeClusPercents.append(closePntCnt / len(clusPnts)) # Take the top clusters of acceptable size that pass the 10% PNTS_NEAR_LIG cutoff. Recovers clusters that drop below the 10% cutoff as the pocket threshold grows largeClusts = sorted(zip(largeClusInds,largeClusPercents), reverse = True, key = lambda pair: pair[1]) if prevNum_Vol[0] == 0: goodClusts = [pntArr[clusters.labels_ == ind] for ind,percent in largeClusts if percent >= PNTS_NEAR_LIG] prevNum_Vol = [len(goodClusts), sum(map(len, goodClusts))] # count the number of clusters and the number of points in all the clusters combined else: goodClusts = [pntArr[clusters.labels_ == ind] for ind,percent in largeClusts if percent >= PNTS_NEAR_LIG] newNum_Vol = [len(goodClusts), sum(map(len, goodClusts))] if newNum_Vol[0] < prevNum_Vol[0] and newNum_Vol[1] < prevNum_Vol[1]: # Catch cases where a cluster from a smaller threshold drops below the 10% cutoff while growing, take the next closest cluster in this case missedClustCnt = prevNum_Vol[0] - newNum_Vol[0] for j in range(newNum_Vol[0], newNum_Vol[0] + missedClustCnt): goodClusts.append(pntArr[clusters.labels_ == largeClusts[j][0]]) prevNum_Vol = [len(goodClusts), sum(map(len, goodClusts))] else: prevNum_Vol = newNum_Vol[:] allPocketPnts = [p for c in goodClusts for p in c] # Flatten separate pockets logFH.write(str(POCKET_THRESHOLDS[i]) + ' Ang binning threshold:\n') logFH.write('\t'+str(round(len(allPocketPnts) * GRID_POINT_SPACING**3,2)) + ' Ang^3 of binding pocket volume from ') if len(goodClusts) == 1: logFH.write('1 binding pocket\n') else: logFH.write(str(len(goodClusts)) + ' binding pockets\n') # Write thresholded points to a mol2 file LecGly.coords2Mol2(mol2Dir + pdb + '_' + bs.replace(':','-') + '_' + str(POCKET_THRESHOLDS[i]) + 'AngBin' + '.mol2', allPocketPnts) # Save out all remaining binding pockets points to a mol2 file, named by the PDB ID, the parent ligand PLIP ID with ":" swapped for "-", and the binning threshold used end = time.time() # print(end-start) logFH.write('\n\n' + str(round(end-start, 2)) + ' seconds to process ' + str(len(allPLIP[pdb].bsites)) + ' binding site(s) from pdb ' + pdb + '\n\n\n') logFH.flush() globalEnd = time.time() print(round((globalEnd-globalStart)/60, 2), 'minutes to process',bsCnt, 'binding sites from',plipCnt,'PDB files')
58.028125
320
0.540632
4a243ce0e588f5151b77f3129b17030782a65102
218
py
Python
ymir/command/mir/tools/settings.py
Zhang-SJ930104/ymir
dd6481be6f229ade4cf8fba64ef44a15357430c4
[ "Apache-2.0" ]
64
2021-11-15T03:48:00.000Z
2022-03-25T07:08:46.000Z
ymir/command/mir/tools/settings.py
Zhang-SJ930104/ymir
dd6481be6f229ade4cf8fba64ef44a15357430c4
[ "Apache-2.0" ]
35
2021-11-23T04:14:35.000Z
2022-03-26T09:03:43.000Z
ymir/command/mir/tools/settings.py
Aryalfrat/ymir
d4617ed00ef67a77ab4e1944763f608bface4be6
[ "Apache-2.0" ]
57
2021-11-11T10:15:40.000Z
2022-03-29T07:27:54.000Z
PRODUCER_KEY = 'producer' PRODUCER_NAME = 'ymir' EXECUTOR_CONFIG_KEY = 'executor_config' TASK_CONTEXT_KEY = 'task_context' TASK_CONTEXT_PARAMETERS_KEY = 'task_parameters' EXECUTOR_OUTLOG_NAME = 'ymir-executor-out.log'
31.142857
47
0.821101
4a243d31661e67e09041f4c9610293d0ad355158
6,927
py
Python
backend/suvfitness_31834/settings.py
crowdbotics-apps/suvfitness-31834
cb9a281a2d4da3a967a40143cd5a68a76d062c11
[ "FTL", "AML", "RSA-MD" ]
null
null
null
backend/suvfitness_31834/settings.py
crowdbotics-apps/suvfitness-31834
cb9a281a2d4da3a967a40143cd5a68a76d062c11
[ "FTL", "AML", "RSA-MD" ]
null
null
null
backend/suvfitness_31834/settings.py
crowdbotics-apps/suvfitness-31834
cb9a281a2d4da3a967a40143cd5a68a76d062c11
[ "FTL", "AML", "RSA-MD" ]
null
null
null
""" Django settings for suvfitness_31834 project. Generated by 'django-admin startproject' using Django 2.2.2. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os import environ import logging from modules.manifest import get_modules env = environ.Env() # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env.bool("DEBUG", default=False) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env.str("SECRET_KEY") ALLOWED_HOSTS = env.list("HOST", default=["*"]) SITE_ID = 1 SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_SSL_REDIRECT = env.bool("SECURE_REDIRECT", default=False) # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites' ] LOCAL_APPS = [ 'home', 'users.apps.UsersConfig', ] THIRD_PARTY_APPS = [ 'rest_framework', 'rest_framework.authtoken', 'rest_auth', 'rest_auth.registration', 'bootstrap4', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', 'django_extensions', 'drf_yasg', 'storages', ] MODULES_APPS = get_modules() INSTALLED_APPS += LOCAL_APPS + THIRD_PARTY_APPS + MODULES_APPS MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'suvfitness_31834.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'web_build')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'suvfitness_31834.wsgi.application' # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } if env.str("DATABASE_URL", default=None): DATABASES = { 'default': env.db() } # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' MIDDLEWARE += ['whitenoise.middleware.WhiteNoiseMiddleware'] AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend' ) STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'web_build/static')] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' # allauth / users ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_EMAIL_VERIFICATION = "optional" ACCOUNT_CONFIRM_EMAIL_ON_GET = True ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True ACCOUNT_UNIQUE_EMAIL = True LOGIN_REDIRECT_URL = "users:redirect" ACCOUNT_ADAPTER = "users.adapters.AccountAdapter" SOCIALACCOUNT_ADAPTER = "users.adapters.SocialAccountAdapter" ACCOUNT_ALLOW_REGISTRATION = env.bool("ACCOUNT_ALLOW_REGISTRATION", True) SOCIALACCOUNT_ALLOW_REGISTRATION = env.bool("SOCIALACCOUNT_ALLOW_REGISTRATION", True) REST_AUTH_SERIALIZERS = { # Replace password reset serializer to fix 500 error "PASSWORD_RESET_SERIALIZER": "home.api.v1.serializers.PasswordSerializer", } REST_AUTH_REGISTER_SERIALIZERS = { # Use custom serializer that has no username and matches web signup "REGISTER_SERIALIZER": "home.api.v1.serializers.SignupSerializer", } # Custom user model AUTH_USER_MODEL = "users.User" EMAIL_HOST = env.str("EMAIL_HOST", "smtp.sendgrid.net") EMAIL_HOST_USER = env.str("SENDGRID_USERNAME", "") EMAIL_HOST_PASSWORD = env.str("SENDGRID_PASSWORD", "") EMAIL_PORT = 587 EMAIL_USE_TLS = True # AWS S3 config AWS_ACCESS_KEY_ID = env.str("AWS_ACCESS_KEY_ID", "") AWS_SECRET_ACCESS_KEY = env.str("AWS_SECRET_ACCESS_KEY", "") AWS_STORAGE_BUCKET_NAME = env.str("AWS_STORAGE_BUCKET_NAME", "") AWS_STORAGE_REGION = env.str("AWS_STORAGE_REGION", "") USE_S3 = ( AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and AWS_STORAGE_BUCKET_NAME and AWS_STORAGE_REGION ) if USE_S3: AWS_S3_CUSTOM_DOMAIN = env.str("AWS_S3_CUSTOM_DOMAIN", "") AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"} AWS_DEFAULT_ACL = env.str("AWS_DEFAULT_ACL", "public-read") AWS_MEDIA_LOCATION = env.str("AWS_MEDIA_LOCATION", "media") AWS_AUTO_CREATE_BUCKET = env.bool("AWS_AUTO_CREATE_BUCKET", True) DEFAULT_FILE_STORAGE = env.str( "DEFAULT_FILE_STORAGE", "home.storage_backends.MediaStorage" ) MEDIA_URL = '/mediafiles/' MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles') # Swagger settings for api docs SWAGGER_SETTINGS = { "DEFAULT_INFO": f"{ROOT_URLCONF}.api_info", } if DEBUG or not (EMAIL_HOST_USER and EMAIL_HOST_PASSWORD): # output email to console instead of sending if not DEBUG: logging.warning("You should setup `SENDGRID_USERNAME` and `SENDGRID_PASSWORD` env vars to send emails.") EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
29.602564
112
0.730908
4a243da212ef1733b25871da62ebf7bea851b059
207
py
Python
crcsolver/__init__.py
lwerdna/crc_cracker
8fcf4d154866895d8c96cb856eee114ae8215bd0
[ "Unlicense" ]
2
2020-05-02T04:09:48.000Z
2020-05-08T13:53:56.000Z
crcsolver/__init__.py
lwerdna/crc_cracker
8fcf4d154866895d8c96cb856eee114ae8215bd0
[ "Unlicense" ]
null
null
null
crcsolver/__init__.py
lwerdna/crc_cracker
8fcf4d154866895d8c96cb856eee114ae8215bd0
[ "Unlicense" ]
1
2020-05-02T04:14:19.000Z
2020-05-02T04:14:19.000Z
name = "crcsolver" from . import main def solve(data, unknowns, desired, crc_func): return main.solve(data, unknowns, desired, crc_func) def compute(data, crc_name): return main.compute(data, crc_name)
20.7
53
0.748792
4a243fe2af2fbe44d02f53e675c2978288c6452b
1,609
py
Python
test/test_inline_response_200_18.py
scubawhere/scubawhere-api-python-client
9f8578e251492c7667f785df7b7c9d66e71f5c8e
[ "Apache-2.0" ]
null
null
null
test/test_inline_response_200_18.py
scubawhere/scubawhere-api-python-client
9f8578e251492c7667f785df7b7c9d66e71f5c8e
[ "Apache-2.0" ]
null
null
null
test/test_inline_response_200_18.py
scubawhere/scubawhere-api-python-client
9f8578e251492c7667f785df7b7c9d66e71f5c8e
[ "Apache-2.0" ]
null
null
null
# coding: utf-8 """ Scubawhere API Documentation This is the documentation for scubawhere's RMS API. This API is only to be used by authorized parties with valid auth tokens. [Learn about scubawhere](http://www.scubawhere.com) to become an authorized consumer of our API OpenAPI spec version: 1.0.0 Contact: [email protected] Generated by: https://github.com/swagger-api/swagger-codegen.git 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 __future__ import absolute_import import os import sys import unittest import swagger_client from swagger_client.rest import ApiException from swagger_client.models.inline_response_200_18 import InlineResponse20018 class TestInlineResponse20018(unittest.TestCase): """ InlineResponse20018 unit test stubs """ def setUp(self): pass def tearDown(self): pass def testInlineResponse20018(self): """ Test InlineResponse20018 """ model = swagger_client.models.inline_response_200_18.InlineResponse20018() if __name__ == '__main__': unittest.main()
29.796296
227
0.735861
4a24427a1d322bbd6f815b1d9c1ab6937a06e3f0
3,280
py
Python
scripts/parse_pants_targets_and_keywords.py
pantsbuild/vim-pants
6112addaeee02963aa1ed3cf180b5b3fea56c9d3
[ "MIT" ]
1
2015-04-27T13:14:40.000Z
2015-04-27T13:14:40.000Z
scripts/parse_pants_targets_and_keywords.py
pantsbuild/vim-pants
6112addaeee02963aa1ed3cf180b5b3fea56c9d3
[ "MIT" ]
null
null
null
scripts/parse_pants_targets_and_keywords.py
pantsbuild/vim-pants
6112addaeee02963aa1ed3cf180b5b3fea56c9d3
[ "MIT" ]
null
null
null
# Prints all targets and keywords used in Pants BUILD dsl. # $ cd commons/src/python/twitter/pants # $ cat __init__.py targets/*.py|python parse_pants_targets_and_keywords.py -t|sort|uniq|awk '{print " \\ "$1}' import sys import ast from optparse import OptionParser class ClassHierarchyResolver(ast.NodeVisitor): def __init__(self, node): self.class_hierarchy = dict() self.visit(node) def visit_ClassDef(self, node): base = node.bases[0] self.class_hierarchy[node.name] = base.id def resolve(self, name): if name in self.class_hierarchy: base = self.class_hierarchy[name] return self.resolve(base) else: return name class AssignResolver(ast.NodeVisitor): def __init__(self, node): self.assigns = dict() self.visit(node) def visit_Assign(self, node): if hasattr(node.value, "id"): for t in node.targets: if hasattr(t, "id"): self.assigns[t.id] = node.value.id def resolve(self, name): if name in self.assigns: assign = self.assigns[name] return self.resolve(assign) else: return name class TargetClassVisitor(ast.NodeVisitor): def __init__(self, class_hierarchy_resolver): self.targets = set() self.class_hierarchy_resolver = class_hierarchy_resolver def visit_ClassDef(self, node): base = self.class_hierarchy_resolver.resolve(node.name) if base == "Target" or base == "object": self.targets.add(node) class InitFunctionVisitor(ast.NodeVisitor): def __init__(self): self.keywords = set() def visit_FunctionDef(self, node): if node.name == "__init__": for a in node.args.args: if a.id != "self": self.keywords.add(a.id) class PantsParser: def parse_args(self): parser = OptionParser() parser.add_option("-t", "--targets", dest="print_targets", action="store_true", help="print all pants targets") parser.add_option("-k", "--keywords", dest="print_keywords", action="store_true", help="print all pants keywords") options, args = parser.parse_args() return options def run(self): options = self.parse_args() source = sys.stdin.read() root_node = ast.parse(source) class_hierarchy_resolver = ClassHierarchyResolver(root_node) assign_resolver = AssignResolver(root_node) target_class_visitor = TargetClassVisitor(class_hierarchy_resolver) target_class_visitor.visit(root_node) target_class_nodes = target_class_visitor.targets if options.print_targets: target_class_names = set([node.name for node in target_class_nodes]) # Print all pants Target class names for name in target_class_names: print name # Print all alias names to Target classes for assign in assign_resolver.assigns: name = assign_resolver.resolve(assign) if name in target_class_names: print assign if options.print_keywords: # Print all named arguments for Target classes __init__. for node in target_class_nodes: init_function_visitor = InitFunctionVisitor() init_function_visitor.visit(node) for keyword in init_function_visitor.keywords: print keyword def main(): PantsParser().run() main()
29.54955
112
0.685976
4a2443a01ac21f2354289338d3d83d25c62cd881
23,706
py
Python
DEEP LEARNING/segmentation/Kaggle TGS Salt Identification Challenge/v1/main.py
Diyago/ML-DL-scripts
40718a9d4318d6d6531bcea5998c0a18afcd9cb3
[ "Apache-2.0" ]
142
2018-09-02T08:59:45.000Z
2022-03-30T17:08:24.000Z
DEEP LEARNING/segmentation/Kaggle TGS Salt Identification Challenge/v1/main.py
jerinka/ML-DL-scripts
eeb5c3c7c5841eb4cdb272690e14d6718f3685b2
[ "Apache-2.0" ]
4
2019-09-08T07:27:11.000Z
2021-10-19T05:50:24.000Z
DEEP LEARNING/segmentation/Kaggle TGS Salt Identification Challenge/v1/main.py
jerinka/ML-DL-scripts
eeb5c3c7c5841eb4cdb272690e14d6718f3685b2
[ "Apache-2.0" ]
75
2018-10-04T17:08:40.000Z
2022-03-08T18:50:52.000Z
import argparse from data_loader import * from data_process.transform import * from loss.bce_losses import * from loss.cyclic_lr import * from loss.lovasz_losses import * from model.model import ( model34_DeepSupervion, model50A_DeepSupervion, model101A_DeepSupervion, ) from utils import create_submission from evaluate import do_kaggle_metric import time import datetime class SingleModelSolver(object): def __init__(self, config): self.model_name = config.model_name self.model = config.model self.dice_weight = config.dice_weight self.bce_weight = config.bce_weight # Model hyper-parameters self.image_size = config.image_size # Hyper-parameteres self.g_lr = config.lr self.cycle_num = config.cycle_num self.cycle_inter = config.cycle_inter self.dice_bce_pretrain_epochs = config.dice_bce_pretrain_epochs self.batch_size = config.batch_size self.pretrained_model = config.pretrained_model # Path self.log_path = os.path.join("./models", self.model_name, config.log_path) self.sample_path = os.path.join("./models", self.model_name, config.sample_path) self.model_save_path = os.path.join( "./models", self.model_name, config.model_save_path ) self.result_path = os.path.join("./models", self.model_name, config.result_path) # Create directories if not exist if not os.path.exists(self.log_path): os.makedirs(self.log_path) if not os.path.exists(self.model_save_path): os.makedirs(self.model_save_path) if not os.path.exists(self.sample_path): os.makedirs(self.sample_path) if not os.path.exists(self.result_path): os.makedirs(self.result_path) # Step size self.log_step = config.log_step self.sample_step = config.sample_step self.model_save_step = config.model_save_step # Build tensorboard if use self.build_model() self.load_pretrained_model(config.train_fold_index) def build_model(self): if self.model == "model_34": self.G = model34_DeepSupervion() elif self.model == "model_50A": self.G = model50A_DeepSupervion() elif self.model == "model_101A": self.G = model101A_DeepSupervion() self.g_optimizer = torch.optim.SGD( filter(lambda p: p.requires_grad, self.G.parameters()), self.g_lr, weight_decay=0.0002, momentum=0.9, ) self.print_network(self.G, "G") if torch.cuda.is_available(): self.G = torch.nn.DataParallel(self.G) self.G.cuda() def print_network(self, model, name): num_params = 0 for p in model.parameters(): num_params += p.numel() print(name) print(model) print("The number of parameters: {}".format(num_params)) def load_pretrained_model(self, fold_index, mode=None, Cycle=None): if mode == None: if os.path.exists( os.path.join( self.model_save_path, "fold_" + str(fold_index), "{}_G.pth".format(self.pretrained_model), ) ): self.G.load_state_dict( torch.load( os.path.join( self.model_save_path, "fold_" + str(fold_index), "{}_G.pth".format(self.pretrained_model), ) ) ) print( "loaded trained G models fold: {} (step: {})..!".format( fold_index, self.pretrained_model ) ) elif mode == "max_map": if Cycle is None: pth = os.path.join( self.model_save_path, "fold_" + str(fold_index), "Lsoftmax_maxMap_G.pth", ) else: pth = os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(Cycle) + "_Lsoftmax_maxMap_G.pth", ) if os.path.exists(pth): self.G.load_state_dict(torch.load(pth)) print( "loaded trained G models fold: {} (step: {})..!".format( fold_index, pth ) ) elif mode == "min_loss": if Cycle is None: pth = os.path.join( self.model_save_path, "fold_" + str(fold_index), "Lsoftmax_minValidLoss_G.pth", ) else: pth = os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(Cycle) + "_Lsoftmax_minValidLoss_G.pth", ) if os.path.exists(pth): self.G.load_state_dict(torch.load(pth)) print( "loaded trained G models fold: {} (step: {})..!".format( fold_index, pth ) ) def update_lr(self, g_lr): for param_group in self.g_optimizer.param_groups: param_group["lr"] = g_lr def to_var(self, x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Variable(x, volatile=volatile) def criterion(self, logits, label): logits = logits.squeeze(1) label = label.squeeze(1) loss = lovasz_hinge(logits, label, per_image=True, ignore=None) return loss def train_fold(self, fold_index, aug_list): CE = torch.nn.CrossEntropyLoss() if not os.path.exists( os.path.join(self.model_save_path, "fold_" + str(fold_index)) ): os.makedirs(os.path.join(self.model_save_path, "fold_" + str(fold_index))) print("train loader!!!") data_loader = get_foldloader( self.image_size, self.batch_size, fold_index, aug_list, mode="train" ) print("val loader!!!") val_loader = get_foldloader(self.image_size, 1, fold_index, mode="val") iters_per_epoch = len(data_loader) for init_index in range(self.dice_bce_pretrain_epochs): for i, (images, labels, is_empty) in enumerate(data_loader): inputs = self.to_var(images) labels = self.to_var(labels) class_lbls = self.to_var(torch.LongTensor(is_empty)) binary_logits, no_empty_logits, final_logits = self.G(inputs) bce_loss_final = mixed_dice_bce_loss( final_logits, labels, dice_weight=self.dice_weight, bce_weight=self.bce_weight, ) class_loss = CE(binary_logits, class_lbls) non_empty = [] for c in range(len(is_empty)): if is_empty[c] == 0: non_empty.append(c) has_empty_nonempty = False if len(non_empty) * len(is_empty) > 0: has_empty_nonempty = True all_loss = bce_loss_final + 0.05 * class_loss loss = {} loss["loss_seg"] = bce_loss_final.data[0] loss["loss_classifier"] = class_loss.data[0] if has_empty_nonempty: indices = self.to_var(torch.LongTensor(non_empty)) y_non_empty = torch.index_select(no_empty_logits, 0, indices) mask_non_empty = torch.index_select(labels, 0, indices) loss_no_empty = mixed_dice_bce_loss( y_non_empty, mask_non_empty, dice_weight=self.dice_weight, bce_weight=self.bce_weight, ) all_loss += 0.50 * loss_no_empty loss["loss_seg_noempty"] = loss_no_empty.data[0] self.g_optimizer.zero_grad() all_loss.backward() self.g_optimizer.step() # Print out log info if (i + 1) % 10 == 0: lr = self.g_optimizer.param_groups[0]["lr"] log = "{} FOLD: {}, BCE+DICE pretrain Epoch [{}/{}], lr {:.4f}".format( self.model_name, fold_index, init_index, 10, lr ) for tag, value in loss.items(): log += ", {}: {:.4f}".format(tag, value) print(log) sgdr = CosineAnnealingLR_with_Restart( self.g_optimizer, T_max=self.cycle_inter, T_mult=1, model=self.G, out_dir="../input/", take_snapshot=False, eta_min=1e-3, ) # Start training start_time = time.time() for cycle_index in range(self.cycle_num): print("cycle index: " + str(cycle_index)) valid_loss_plot = [] max_map_plot = [] for e in range(0, self.cycle_inter): sgdr.step() lr = self.g_optimizer.param_groups[0]["lr"] print("change learning rate into: {:.4f}".format(lr)) for i, (images, labels, is_empty) in enumerate(data_loader): # all images inputs = self.to_var(images) labels = self.to_var(labels) class_lbls = self.to_var(torch.LongTensor(is_empty)) binary_logits, no_empty_logits, no_empty, final_logits, final = self.G( inputs ) loss_final = self.criterion(final_logits, labels) class_loss = CE(binary_logits, class_lbls) non_empty = [] for c in range(len(is_empty)): if is_empty[c] == 0: non_empty.append(c) has_empty_nonempty = False if len(non_empty) * len(is_empty) > 0: has_empty_nonempty = True all_loss = loss_final + 0.05 * class_loss loss = {} loss["loss_seg"] = loss_final.data[0] loss["loss_classifier"] = class_loss.data[0] if has_empty_nonempty: indices = self.to_var(torch.LongTensor(non_empty)) y_non_empty = torch.index_select(no_empty_logits, 0, indices) mask_non_empty = torch.index_select(labels, 0, indices) loss_no_empty = self.criterion(y_non_empty, mask_non_empty) all_loss += 0.50 * loss_no_empty loss["loss_seg_noempty"] = loss_no_empty.data[0] self.g_optimizer.zero_grad() all_loss.backward() self.g_optimizer.step() # Print out log info if (i + 1) % self.log_step == 0: elapsed = time.time() - start_time elapsed = str(datetime.timedelta(seconds=elapsed)) lr = self.g_optimizer.param_groups[0]["lr"] log = "{} FOLD: {}, Cycle: {}, Elapsed [{}], Epoch [{}/{}], Iter [{}/{}], lr {:.4f}".format( self.model_name, fold_index, cycle_index, elapsed, e + 1, self.cycle_inter, i + 1, iters_per_epoch, lr, ) for tag, value in loss.items(): log += ", {}: {:.4f}".format(tag, value) print(log) if e + 1 >= 20 and (e + 1) % 5 == 0: valid_loss, max_map, max_thres = self.val_TTA( fold_index, val_loader, is_load=False ) if len(valid_loss_plot) == 0 or valid_loss < min(valid_loss_plot): print("save min valid loss model") torch.save( self.G.state_dict(), os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(cycle_index) + "_Lsoftmax_minValidLoss_G.pth", ), ) f = open( os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(cycle_index) + "_Lsoftmax_min_valid_loss.txt", ), "w", ) f.write( str(max_map) + " " + str(max_thres) + " " + str(valid_loss) + " epoch: " + str(e) ) f.close() if len(valid_loss_plot) == 0 or max_map > max(max_map_plot): print("save max map model") torch.save( self.G.state_dict(), os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(cycle_index) + "_Lsoftmax_maxMap_G.pth", ), ) f = open( os.path.join( self.model_save_path, "fold_" + str(fold_index), "Cycle_" + str(cycle_index) + "_Lsoftmax_max_map.txt", ), "w", ) f.write( str(max_map) + " " + str(max_thres) + " " + str(valid_loss) + " epoch: " + str(e) ) f.close() valid_loss_plot.append(valid_loss) max_map_plot.append(max_map) def val_TTA(self, fold_index, val_loader, is_load=False, mode=None, Cycle=None): if fold_index < 0: return if is_load: self.load_pretrained_model(fold_index, mode=mode, Cycle=Cycle) self.G.eval() loss = 0 t = 0 output_list = [] labels_list = [] for i, (images, labels, _) in enumerate(val_loader): img1 = images.numpy() img2 = img1[:, :, :, ::-1] batch_size = img1.shape[0] img_all = np.concatenate([img1, img2]) images = torch.FloatTensor(img_all) inputs = self.to_var(images) _, _, output = self.G(inputs) output = output.data.cpu().numpy() mask = output[0 : batch_size * 2] output = ( mask[0:batch_size] + mask[batch_size : batch_size * 2][:, :, :, ::-1] ) output = output / 2.0 labels = labels.numpy() output = output.transpose(2, 3, 0, 1).reshape( [self.image_size, self.image_size, -1] ) labels = labels.transpose(2, 3, 0, 1).reshape( [self.image_size, self.image_size, -1] ) if self.image_size == 128: output = center_corp(output, self.image_size, crop_size=101) labels = center_corp(labels, self.image_size, crop_size=101) elif self.image_size == 160: output = center_corp(output, self.image_size, crop_size=101) labels = center_corp(labels, self.image_size, crop_size=101) elif self.image_size == 256: output = center_corp(output, self.image_size, crop_size=202) labels = center_corp(labels, self.image_size, crop_size=202) output = cv2.resize(output, (101, 101)).reshape([101, 101, -1]) labels = cv2.resize(labels, (101, 101)).reshape([101, 101, -1]) output_list.append(output) labels_list.append(labels) output = output.transpose(2, 0, 1).reshape([batch_size, 1, 101, 101]) labels = labels.transpose(2, 0, 1).reshape([batch_size, 1, 101, 101]) output = torch.FloatTensor(output) labels = torch.FloatTensor(labels) labels = self.to_var(labels) output = self.to_var(output) bce_loss = self.criterion(output, labels) loss += bce_loss.data[0] t += 1.0 valid_loss = loss / t output = np.concatenate(output_list, axis=2) labels = np.concatenate(labels_list, axis=2) output = output.transpose(2, 0, 1) labels = labels.transpose(2, 0, 1) threshold = np.arange(-0.5, 0.5, 0.0125) def get_max_map(output_, labels_): precision_list = [] for thres in threshold: precision, result, _ = do_kaggle_metric( output_, labels_, threshold=thres ) precision = precision.mean() precision_list.append(precision) max_map = max(precision_list) max_index = np.argmax(np.asarray(precision_list)) print( "max map: {:.4f} at thres:{:.4f}".format(max_map, threshold[max_index]) ) return max_map, max_index max_map, max_index = get_max_map(output, labels) log = "{} FOLD: {} valid loss: {:.4f}".format( self.model_name, fold_index, valid_loss ) print(log) self.G.train() return valid_loss, max_map, threshold[max_index] def get_infer_TTA(self, fold_index, thres): self.G.eval() test_loader = get_foldloader( self.image_size, self.batch_size / 2, 0, mode="test" ) out = [] for i, (id, images) in enumerate(test_loader): img1 = images.numpy() img2 = img1[:, :, :, ::-1] batch_size = img1.shape[0] img_all = np.concatenate([img1, img2]) images = torch.FloatTensor(img_all) inputs = self.to_var(images) _, _, output = self.G(inputs) output = output.data.cpu().numpy() mask = output[0 : batch_size * 2] output = ( mask[0:batch_size] + mask[batch_size : batch_size * 2][:, :, :, ::-1] ) output = output / 2.0 output = output.transpose(2, 3, 0, 1).reshape( [self.image_size, self.image_size, batch_size] ) if self.image_size == 128: output = center_corp(output, self.image_size, crop_size=101) output = cv2.resize(output, (101, 101), cv2.INTER_CUBIC) output[output >= thres] = 1.0 output[output < thres] = 0.0 output = output.transpose(2, 0, 1) output = output.reshape([batch_size, 101, 101]).astype(np.uint8) for id_index in range(batch_size): out.append([id[id_index], output[id_index].reshape([101, 101])]) if i % 1000 == 0 and i > 0: print( self.model_name + " fold index: " + str(fold_index) + " " + str(i) ) return out def infer_fold_TTA(self, fold_index, mode="max_map", Cycle=None): print(mode) val_loader = get_foldloader( self.image_size, self.batch_size / 2, fold_index, mode="val" ) _, max_map, thres = self.val_TTA( fold_index, val_loader, is_load=True, mode=mode, Cycle=Cycle ) if fold_index < 0: return infer = self.get_infer_TTA(fold_index, thres) if Cycle is None: name_tmp = "fold_{}_TTA_{}{:.3f}at{:.3f}.csv".format( fold_index, mode, max_map, thres ) else: name_tmp = "fold_{}_Cycle_{}_TTA_{}{:.3f}at{:.3f}.csv".format( fold_index, Cycle, mode, max_map, thres ) output_name = os.path.join( self.model_save_path, "fold_" + str(fold_index), name_tmp ) submission = create_submission(infer) submission.to_csv(output_name, index=None) def infer_fold_all_Cycle(self, fold_index, mode="max_map"): for i in range(self.cycle_num): self.infer_fold_TTA(fold_index, mode, Cycle=i) def main(config, aug_list): # cudnn.benchmark = True if config.mode == "train": solver = SingleModelSolver(config) solver.train_fold(config.train_fold_index, aug_list) if config.mode == "test": solver = SingleModelSolver(config) solver.infer_fold_all_Cycle(config.train_fold_index) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--train_fold_index", type=int, default=0) parser.add_argument("--model", type=str, default="model_34") parser.add_argument("--model_name", type=str, default="model_34") parser.add_argument("--image_size", type=int, default=128) parser.add_argument("--batch_size", type=int, default=16) aug_list = ["flip_lr"] parser.add_argument("--mode", type=str, default="train", choices=["train", "test"]) parser.add_argument("--pretrained_model", type=str, default=None) parser.add_argument("--lr", type=float, default=0.01) parser.add_argument("--cycle_num", type=int, default=7) parser.add_argument("--cycle_inter", type=int, default=50) parser.add_argument("--dice_bce_pretrain_epochs", type=int, default=10) parser.add_argument("--dice_weight", type=float, default=0.5) parser.add_argument("--bce_weight", type=float, default=0.9) parser.add_argument("--num_workers", type=int, default=16) # Test settings parser.add_argument("--log_path", type=str, default="logs") parser.add_argument("--model_save_path", type=str, default="models") parser.add_argument("--sample_path", type=str, default="samples") parser.add_argument("--result_path", type=str, default="results") # Step size parser.add_argument("--log_step", type=int, default=10) parser.add_argument("--sample_step", type=int, default=10) parser.add_argument("--model_save_step", type=int, default=20000) config = parser.parse_args() print(config) main(config, aug_list)
37.450237
116
0.497216
4a244403a5d8e917f59000c35cf32c0f8b15ebb8
2,187
py
Python
src/classifier/classifier_training/classifier_utils.py
krangelie/bias-in-german-nlg
9fbaf50fde7d41d64692ae90c41beae61bc78d44
[ "MIT" ]
14
2021-08-24T12:36:37.000Z
2022-03-18T12:14:36.000Z
src/classifier/classifier_training/classifier_utils.py
krangelie/bias-in-german-nlg
9fbaf50fde7d41d64692ae90c41beae61bc78d44
[ "MIT" ]
null
null
null
src/classifier/classifier_training/classifier_utils.py
krangelie/bias-in-german-nlg
9fbaf50fde7d41d64692ae90c41beae61bc78d44
[ "MIT" ]
1
2021-10-21T20:22:55.000Z
2021-10-21T20:22:55.000Z
import torch import numpy as np import xgboost as xgb from sklearn.ensemble import RandomForestClassifier from src.classifier.lstm.lstm_classifier import RegardLSTM from src.classifier.sent_transformer.sbert_classifier import RegardBERT def get_classifier(model_params, model_type, n_embed, weight_vector=None, classes=None): if model_type == "rf": classifier = RandomForestClassifier( n_estimators=model_params.n_estimators, max_depth=model_params.max_depth, random_state=42, ) elif model_type == "xgb": classifier = xgb.XGBClassifier( n_estimators=model_params.n_estimators, learning_rate=model_params.learning_rate, max_depth=model_params.max_depth, random_state=42, ) elif model_type == "lstm": classifier = RegardLSTM( n_embed=n_embed, n_hidden=model_params.n_hidden, n_hidden_lin=model_params.n_hidden_lin, n_output=model_params.n_output, n_layers=model_params.n_layers, lr=model_params.lr, weight_vector=weight_vector, bidirectional=model_params.bidir, gru=model_params.unit, drop_p=model_params.dropout, drop_p_gru=model_params.dropout_gru, ) elif model_type == "transformer": classifier = RegardBERT( n_embed=n_embed, n_hidden_lin=model_params.n_hidden_lin, n_hidden_lin_2=model_params.n_hidden_lin_2, n_output=model_params.n_output, lr=model_params.lr, weight_vector=weight_vector, drop_p=model_params.dropout, ) else: print( "Please choose a classifier type that is implemented.\ So far only rf for RandomForest, xgb for XGBoost, or lstm." ) return classifier def compute_weight_vector(Y, use_torch=True): weight_vector = len(Y) / (len(set(Y)) * np.bincount(Y)) if use_torch: device = "cuda" if torch.cuda.is_available() else "cpu" weight_vector = torch.FloatTensor(weight_vector).to(device) return weight_vector
34.714286
88
0.652492
4a24446690a779077dd492cb8d3a91fd00b48c1b
1,548
py
Python
hard-gists/5167728/snippet.py
jjhenkel/dockerizeme
eaa4fe5366f6b9adf74399eab01c712cacaeb279
[ "Apache-2.0" ]
21
2019-07-08T08:26:45.000Z
2022-01-24T23:53:25.000Z
hard-gists/5167728/snippet.py
jjhenkel/dockerizeme
eaa4fe5366f6b9adf74399eab01c712cacaeb279
[ "Apache-2.0" ]
5
2019-06-15T14:47:47.000Z
2022-02-26T05:02:56.000Z
hard-gists/5167728/snippet.py
jjhenkel/dockerizeme
eaa4fe5366f6b9adf74399eab01c712cacaeb279
[ "Apache-2.0" ]
17
2019-05-16T03:50:34.000Z
2021-01-14T14:35:12.000Z
from PySide import QtGui, QtCore def findDagWidget(): stack = QtGui.QApplication.topLevelWidgets() while stack: widget = stack.pop() if widget.windowTitle() == 'Node Graph': # You should probably be a little safer with this return, but the actual DAG widget # seems to be here consistently... if not, it should be the only child of 'widget' # that's a QWidget instance. return widget.children()[-1] stack.extend(c for c in widget.children() if c.isWidgetType()) class PaintFilter(QtCore.QObject): def scribble(self, obj, event): qp = QtGui.QPainter() qp.begin(obj) qp.setPen(QtGui.QColor(168, 34, 3)) qp.setFont(QtGui.QFont('Decorative', 10)) qp.drawText(event.rect(), QtCore.Qt.AlignCenter, "Hurray") qp.end() def eventFilter(self, obj, event): if event.type() == QtCore.QEvent.Paint: # Call DAG paint event obj.paintEvent(event) # Do custom painting self.scribble(obj, event) return True return QtCore.QObject.eventFilter(obj, obj, event) dag = findDagWidget() """ # Render DAG widget into an image image = QtGui.QImage(dag.size(), QtGui.QImage.Format_RGB32) dag.repaint() dag.render(image) image.save("/tmp/test.png") """ # Remove old event filter # FIXME: Debug'y thing, for iteration in script editor try: dag.removeEventFilter(thing) except: pass # Install event filter thing=PaintFilter() dag.installEventFilter(thing)
28.666667
94
0.643411
4a2444a6382ff028cc19207870615e5e73417b21
631
py
Python
icefuzz/export.py
jaxnb/icestorm
0794aa3afa3776b5b0e7c408cfecc94823ca617e
[ "ISC" ]
612
2015-07-18T12:15:58.000Z
2020-06-23T13:01:53.000Z
icefuzz/export.py
jaxnb/icestorm
0794aa3afa3776b5b0e7c408cfecc94823ca617e
[ "ISC" ]
154
2015-07-29T14:06:23.000Z
2020-06-22T12:41:25.000Z
icefuzz/export.py
jaxnb/icestorm
0794aa3afa3776b5b0e7c408cfecc94823ca617e
[ "ISC" ]
170
2015-07-20T01:45:20.000Z
2020-06-23T07:36:54.000Z
#!/usr/bin/env python3 import os device_class = os.getenv("ICEDEVICE") with open("../icebox/iceboxdb.py", "w") as f: files = [ "database_io", "database_logic", "database_ramb", "database_ramt", "database_ipcon_5k"] for device_class in ["8k"]: files.append("database_ramb_" + device_class) files.append("database_ramt_" + device_class) for i in range(4): files.append("database_dsp%d_5k" % i) for i in files: print('%s_txt = """' % i, file=f) with open("%s.txt" % i, "r") as fi: for line in fi: print(line, end="", file=f) print('"""', file=f)
33.210526
101
0.586371
4a2444c37838587b50a2ad44d0e8c3a91c7ae6e4
16,141
py
Python
myprojectenv/lib/python3.5/site-packages/ansible/modules/files/lineinfile.py
lancerenteria/doFlask
2d4e242469b108c6c8316ee18a540307497bfb53
[ "MIT" ]
null
null
null
myprojectenv/lib/python3.5/site-packages/ansible/modules/files/lineinfile.py
lancerenteria/doFlask
2d4e242469b108c6c8316ee18a540307497bfb53
[ "MIT" ]
null
null
null
myprojectenv/lib/python3.5/site-packages/ansible/modules/files/lineinfile.py
lancerenteria/doFlask
2d4e242469b108c6c8316ee18a540307497bfb53
[ "MIT" ]
null
null
null
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Daniel Hokka Zakrisson <[email protected]> # (c) 2014, Ahti Kitsik <[email protected]> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'core'} DOCUMENTATION = """ --- module: lineinfile author: - "Daniel Hokka Zakrissoni (@dhozac)" - "Ahti Kitsik (@ahtik)" extends_documentation_fragment: - files - validate short_description: Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression. description: - This module will search a file for a line, and ensure that it is present or absent. - This is primarily useful when you want to change a single line in a file only. See the M(replace) module if you want to change multiple, similar lines or check M(blockinfile) if you want to insert/update/remove a block of lines in a file. For other cases, see the M(copy) or M(template) modules. version_added: "0.7" options: path: required: true aliases: [ 'dest', 'destfile', 'name' ] description: - The file to modify. - Before 2.3 this option was only usable as I(dest), I(destfile) and I(name). regexp: required: false version_added: 1.7 description: - The regular expression to look for in every line of the file. For C(state=present), the pattern to replace if found; only the last line found will be replaced. For C(state=absent), the pattern of the line(s) to remove. Uses Python regular expressions; see U(http://docs.python.org/2/library/re.html). state: required: false choices: [ present, absent ] default: "present" aliases: [] description: - Whether the line should be there or not. line: required: false description: - Required for C(state=present). The line to insert/replace into the file. If C(backrefs) is set, may contain backreferences that will get expanded with the C(regexp) capture groups if the regexp matches. backrefs: required: false default: "no" choices: [ "yes", "no" ] version_added: "1.1" description: - Used with C(state=present). If set, line can contain backreferences (both positional and named) that will get populated if the C(regexp) matches. This flag changes the operation of the module slightly; C(insertbefore) and C(insertafter) will be ignored, and if the C(regexp) doesn't match anywhere in the file, the file will be left unchanged. If the C(regexp) does match, the last matching line will be replaced by the expanded line parameter. insertafter: required: false default: EOF description: - Used with C(state=present). If specified, the line will be inserted after the last match of specified regular expression. A special value is available; C(EOF) for inserting the line at the end of the file. If specified regular expression has no matches, EOF will be used instead. May not be used with C(backrefs). choices: [ 'EOF', '*regex*' ] insertbefore: required: false version_added: "1.1" description: - Used with C(state=present). If specified, the line will be inserted before the last match of specified regular expression. A value is available; C(BOF) for inserting the line at the beginning of the file. If specified regular expression has no matches, the line will be inserted at the end of the file. May not be used with C(backrefs). choices: [ 'BOF', '*regex*' ] create: required: false choices: [ "yes", "no" ] default: "no" description: - Used with C(state=present). If specified, the file will be created if it does not already exist. By default it will fail if the file is missing. backup: required: false default: "no" choices: [ "yes", "no" ] description: - Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. others: description: - All arguments accepted by the M(file) module also work here. required: false notes: - As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well. """ EXAMPLES = r""" # Before 2.3, option 'dest', 'destfile' or 'name' was used instead of 'path' - lineinfile: path: /etc/selinux/config regexp: '^SELINUX=' line: 'SELINUX=enforcing' - lineinfile: path: /etc/sudoers state: absent regexp: '^%wheel' - lineinfile: path: /etc/hosts regexp: '^127\.0\.0\.1' line: '127.0.0.1 localhost' owner: root group: root mode: 0644 - lineinfile: path: /etc/httpd/conf/httpd.conf regexp: '^Listen ' insertafter: '^#Listen ' line: 'Listen 8080' - lineinfile: path: /etc/services regexp: '^# port for http' insertbefore: '^www.*80/tcp' line: '# port for http by default' # Add a line to a file if it does not exist, without passing regexp - lineinfile: path: /tmp/testfile line: '192.168.1.99 foo.lab.net foo' # Fully quoted because of the ': ' on the line. See the Gotchas in the YAML docs. - lineinfile: path: /etc/sudoers state: present regexp: '^%wheel\s' line: '%wheel ALL=(ALL) NOPASSWD: ALL' # Yaml requires escaping backslashes in double quotes but not in single quotes - lineinfile: path: /opt/jboss-as/bin/standalone.conf regexp: '^(.*)Xms(\\d+)m(.*)$' line: '\1Xms${xms}m\3' backrefs: yes # Validate the sudoers file before saving - lineinfile: path: /etc/sudoers state: present regexp: '^%ADMIN ALL=' line: '%ADMIN ALL=(ALL) NOPASSWD: ALL' validate: 'visudo -cf %s' """ import re import os import tempfile # import module snippets from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six import b from ansible.module_utils._text import to_bytes, to_native def write_changes(module, b_lines, dest): tmpfd, tmpfile = tempfile.mkstemp() f = os.fdopen(tmpfd, 'wb') f.writelines(b_lines) f.close() validate = module.params.get('validate', None) valid = not validate if validate: if "%s" not in validate: module.fail_json(msg="validate must contain %%s: %s" % (validate)) (rc, out, err) = module.run_command(to_bytes(validate % tmpfile, errors='surrogate_or_strict')) valid = rc == 0 if rc != 0: module.fail_json(msg='failed to validate: ' 'rc:%s error:%s' % (rc, err)) if valid: module.atomic_move(tmpfile, to_native(os.path.realpath(to_bytes(dest, errors='surrogate_or_strict')), errors='surrogate_or_strict'), unsafe_writes=module.params['unsafe_writes']) def check_file_attrs(module, changed, message, diff): file_args = module.load_file_common_arguments(module.params) if module.set_fs_attributes_if_different(file_args, False, diff=diff): if changed: message += " and " changed = True message += "ownership, perms or SE linux context changed" return message, changed def present(module, dest, regexp, line, insertafter, insertbefore, create, backup, backrefs): diff = {'before': '', 'after': '', 'before_header': '%s (content)' % dest, 'after_header': '%s (content)' % dest} b_dest = to_bytes(dest, errors='surrogate_or_strict') if not os.path.exists(b_dest): if not create: module.fail_json(rc=257, msg='Destination %s does not exist !' % dest) b_destpath = os.path.dirname(b_dest) if not os.path.exists(b_destpath) and not module.check_mode: os.makedirs(b_destpath) b_lines = [] else: f = open(b_dest, 'rb') b_lines = f.readlines() f.close() if module._diff: diff['before'] = to_native(b('').join(b_lines)) if regexp is not None: bre_m = re.compile(to_bytes(regexp, errors='surrogate_or_strict')) if insertafter not in (None, 'BOF', 'EOF'): bre_ins = re.compile(to_bytes(insertafter, errors='surrogate_or_strict')) elif insertbefore not in (None, 'BOF'): bre_ins = re.compile(to_bytes(insertbefore, errors='surrogate_or_strict')) else: bre_ins = None # index[0] is the line num where regexp has been found # index[1] is the line num where insertafter/inserbefore has been found index = [-1, -1] m = None b_line = to_bytes(line, errors='surrogate_or_strict') for lineno, b_cur_line in enumerate(b_lines): if regexp is not None: match_found = bre_m.search(b_cur_line) else: match_found = b_line == b_cur_line.rstrip(b('\r\n')) if match_found: index[0] = lineno m = match_found elif bre_ins is not None and bre_ins.search(b_cur_line): if insertafter: # + 1 for the next line index[1] = lineno + 1 if insertbefore: # + 1 for the previous line index[1] = lineno msg = '' changed = False # Regexp matched a line in the file b_linesep = to_bytes(os.linesep, errors='surrogate_or_strict') if index[0] != -1: if backrefs: b_new_line = m.expand(b_line) else: # Don't do backref expansion if not asked. b_new_line = b_line if not b_new_line.endswith(b_linesep): b_new_line += b_linesep if b_lines[index[0]] != b_new_line: b_lines[index[0]] = b_new_line msg = 'line replaced' changed = True elif backrefs: # Do absolutely nothing, since it's not safe generating the line # without the regexp matching to populate the backrefs. pass # Add it to the beginning of the file elif insertbefore == 'BOF' or insertafter == 'BOF': b_lines.insert(0, b_line + b_linesep) msg = 'line added' changed = True # Add it to the end of the file if requested or # if insertafter/insertbefore didn't match anything # (so default behaviour is to add at the end) elif insertafter == 'EOF' or index[1] == -1: # If the file is not empty then ensure there's a newline before the added line if len(b_lines) > 0 and not b_lines[-1][-1:] in (b('\n'), b('\r')): b_lines.append(b_linesep) b_lines.append(b_line + b_linesep) msg = 'line added' changed = True # insert* matched, but not the regexp else: b_lines.insert(index[1], b_line + b_linesep) msg = 'line added' changed = True if module._diff: diff['after'] = to_native(b('').join(b_lines)) backupdest = "" if changed and not module.check_mode: if backup and os.path.exists(b_dest): backupdest = module.backup_local(dest) write_changes(module, b_lines, dest) if module.check_mode and not os.path.exists(b_dest): module.exit_json(changed=changed, msg=msg, backup=backupdest, diff=diff) attr_diff = {} msg, changed = check_file_attrs(module, changed, msg, attr_diff) attr_diff['before_header'] = '%s (file attributes)' % dest attr_diff['after_header'] = '%s (file attributes)' % dest difflist = [diff, attr_diff] module.exit_json(changed=changed, msg=msg, backup=backupdest, diff=difflist) def absent(module, dest, regexp, line, backup): b_dest = to_bytes(dest, errors='surrogate_or_strict') if not os.path.exists(b_dest): module.exit_json(changed=False, msg="file not present") msg = '' diff = {'before': '', 'after': '', 'before_header': '%s (content)' % dest, 'after_header': '%s (content)' % dest} f = open(b_dest, 'rb') b_lines = f.readlines() f.close() if module._diff: diff['before'] = to_native(b('').join(b_lines)) if regexp is not None: bre_c = re.compile(to_bytes(regexp, errors='surrogate_or_strict')) found = [] b_line = to_bytes(line, errors='surrogate_or_strict') def matcher(b_cur_line): if regexp is not None: match_found = bre_c.search(b_cur_line) else: match_found = b_line == b_cur_line.rstrip(b('\r\n')) if match_found: found.append(b_cur_line) return not match_found b_lines = [l for l in b_lines if matcher(l)] changed = len(found) > 0 if module._diff: diff['after'] = to_native(b('').join(b_lines)) backupdest = "" if changed and not module.check_mode: if backup: backupdest = module.backup_local(dest) write_changes(module, b_lines, dest) if changed: msg = "%s line(s) removed" % len(found) attr_diff = {} msg, changed = check_file_attrs(module, changed, msg, attr_diff) attr_diff['before_header'] = '%s (file attributes)' % dest attr_diff['after_header'] = '%s (file attributes)' % dest difflist = [diff, attr_diff] module.exit_json(changed=changed, found=len(found), msg=msg, backup=backupdest, diff=difflist) def main(): module = AnsibleModule( argument_spec=dict( path=dict(required=True, aliases=['dest', 'destfile', 'name'], type='path'), state=dict(default='present', choices=['absent', 'present']), regexp=dict(default=None), line=dict(aliases=['value']), insertafter=dict(default=None), insertbefore=dict(default=None), backrefs=dict(default=False, type='bool'), create=dict(default=False, type='bool'), backup=dict(default=False, type='bool'), validate=dict(default=None, type='str'), ), mutually_exclusive=[['insertbefore', 'insertafter']], add_file_common_args=True, supports_check_mode=True ) params = module.params create = params['create'] backup = params['backup'] backrefs = params['backrefs'] path = params['path'] b_path = to_bytes(path, errors='surrogate_or_strict') if os.path.isdir(b_path): module.fail_json(rc=256, msg='Path %s is a directory !' % path) if params['state'] == 'present': if backrefs and params['regexp'] is None: module.fail_json(msg='regexp= is required with backrefs=true') if params.get('line', None) is None: module.fail_json(msg='line= is required with state=present') # Deal with the insertafter default value manually, to avoid errors # because of the mutually_exclusive mechanism. ins_bef, ins_aft = params['insertbefore'], params['insertafter'] if ins_bef is None and ins_aft is None: ins_aft = 'EOF' line = params['line'] present(module, path, params['regexp'], line, ins_aft, ins_bef, create, backup, backrefs) else: if params['regexp'] is None and params.get('line', None) is None: module.fail_json(msg='one of line= or regexp= is required with state=absent') absent(module, path, params['regexp'], params.get('line', None), backup) if __name__ == '__main__': main()
34.197034
131
0.631621
4a2445ef1fb580ebee59da97c581bc90275fd5dd
20,113
py
Python
Adafruit_CharLCD/Adafruit_CharLCD.py
jfabi/infomini
bddfc52d0068bccf4e7827cc7730c5ecd6cc7806
[ "MIT" ]
null
null
null
Adafruit_CharLCD/Adafruit_CharLCD.py
jfabi/infomini
bddfc52d0068bccf4e7827cc7730c5ecd6cc7806
[ "MIT" ]
1
2017-10-13T00:25:50.000Z
2017-11-10T01:53:14.000Z
Adafruit_CharLCD/Adafruit_CharLCD.py
jfabi/infomini
bddfc52d0068bccf4e7827cc7730c5ecd6cc7806
[ "MIT" ]
null
null
null
# Copyright (c) 2014 Adafruit Industries # Author: Tony DiCola # # 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. import time import Adafruit_GPIO as GPIO import Adafruit_GPIO.I2C as I2C import Adafruit_GPIO.MCP230xx as MCP import Adafruit_GPIO.PWM as PWM # Commands LCD_CLEARDISPLAY = 0x01 LCD_RETURNHOME = 0x02 LCD_ENTRYMODESET = 0x04 LCD_DISPLAYCONTROL = 0x08 LCD_CURSORSHIFT = 0x10 LCD_FUNCTIONSET = 0x20 LCD_SETCGRAMADDR = 0x40 LCD_SETDDRAMADDR = 0x80 # Entry flags LCD_ENTRYRIGHT = 0x00 LCD_ENTRYLEFT = 0x02 LCD_ENTRYSHIFTINCREMENT = 0x01 LCD_ENTRYSHIFTDECREMENT = 0x00 # Control flags LCD_DISPLAYON = 0x04 LCD_DISPLAYOFF = 0x00 LCD_CURSORON = 0x02 LCD_CURSOROFF = 0x00 LCD_BLINKON = 0x01 LCD_BLINKOFF = 0x00 # Move flags LCD_DISPLAYMOVE = 0x08 LCD_CURSORMOVE = 0x00 LCD_MOVERIGHT = 0x04 LCD_MOVELEFT = 0x00 # Function set flags LCD_8BITMODE = 0x10 LCD_4BITMODE = 0x00 LCD_2LINE = 0x08 LCD_1LINE = 0x00 LCD_5x10DOTS = 0x04 LCD_5x8DOTS = 0x00 # Offset for up to 4 rows. LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54) # Char LCD plate GPIO numbers. LCD_PLATE_RS = 15 LCD_PLATE_RW = 14 LCD_PLATE_EN = 13 LCD_PLATE_D4 = 12 LCD_PLATE_D5 = 11 LCD_PLATE_D6 = 10 LCD_PLATE_D7 = 9 LCD_PLATE_RED = 6 LCD_PLATE_GREEN = 7 LCD_PLATE_BLUE = 8 # Char LCD plate button names. SELECT = 0 RIGHT = 1 DOWN = 2 UP = 3 LEFT = 4 class Adafruit_CharLCD(object): """Class to represent and interact with an HD44780 character LCD display.""" def __init__(self, rs, en, d4, d5, d6, d7, cols, lines, backlight=None, invert_polarity=True, enable_pwm=False, gpio=GPIO.get_platform_gpio(), pwm=PWM.get_platform_pwm(), initial_backlight=1.0): """Initialize the LCD. RS, EN, and D4...D7 parameters should be the pins connected to the LCD RS, clock enable, and data line 4 through 7 connections. The LCD will be used in its 4-bit mode so these 6 lines are the only ones required to use the LCD. You must also pass in the number of columns and lines on the LCD. If you would like to control the backlight, pass in the pin connected to the backlight with the backlight parameter. The invert_polarity boolean controls if the backlight is one with a LOW signal or HIGH signal. The default invert_polarity value is True, i.e. the backlight is on with a LOW signal. You can enable PWM of the backlight pin to have finer control on the brightness. To enable PWM make sure your hardware supports PWM on the provided backlight pin and set enable_pwm to True (the default is False). The appropriate PWM library will be used depending on the platform, but you can provide an explicit one with the pwm parameter. The initial state of the backlight is ON, but you can set it to an explicit initial state with the initial_backlight parameter (0 is off, 1 is on/full bright). You can optionally pass in an explicit GPIO class, for example if you want to use an MCP230xx GPIO extender. If you don't pass in an GPIO instance, the default GPIO for the running platform will be used. """ # Save column and line state. self._cols = cols self._lines = lines # Save GPIO state and pin numbers. self._gpio = gpio self._rs = rs self._en = en self._d4 = d4 self._d5 = d5 self._d6 = d6 self._d7 = d7 # Save backlight state. self._backlight = backlight self._pwm_enabled = enable_pwm self._pwm = pwm self._blpol = not invert_polarity # Setup all pins as outputs. for pin in (rs, en, d4, d5, d6, d7): gpio.setup(pin, GPIO.OUT) # Setup backlight. if backlight is not None: if enable_pwm: pwm.start(backlight, self._pwm_duty_cycle(initial_backlight)) else: gpio.setup(backlight, GPIO.OUT) gpio.output(backlight, self._blpol if initial_backlight else not self._blpol) # Initialize the display. self.write8(0x33) self.write8(0x32) # Initialize display control, function, and mode registers. self.displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF self.displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_2LINE | LCD_5x8DOTS self.displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT # Write registers. self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) self.write8(LCD_FUNCTIONSET | self.displayfunction) self.write8(LCD_ENTRYMODESET | self.displaymode) # set the entry mode self.clear() def home(self): """Move the cursor back to its home (first line and first column).""" self.write8(LCD_RETURNHOME) # set cursor position to zero self._delay_microseconds(3000) # this command takes a long time! def clear(self): """Clear the LCD.""" self.write8(LCD_CLEARDISPLAY) # command to clear display self._delay_microseconds(3000) # 3000 microsecond sleep, clearing the display takes a long time def set_cursor(self, col, row): """Move the cursor to an explicit column and row position.""" # Clamp row to the last row of the display. if row > self._lines: row = self._lines - 1 # Set location. self.write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row])) def enable_display(self, enable): """Enable or disable the display. Set enable to True to enable.""" if enable: self.displaycontrol |= LCD_DISPLAYON else: self.displaycontrol &= ~LCD_DISPLAYON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) def show_cursor(self, show): """Show or hide the cursor. Cursor is shown if show is True.""" if show: self.displaycontrol |= LCD_CURSORON else: self.displaycontrol &= ~LCD_CURSORON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) def blink(self, blink): """Turn on or off cursor blinking. Set blink to True to enable blinking.""" if blink: self.displaycontrol |= LCD_BLINKON else: self.displaycontrol &= ~LCD_BLINKON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) def move_left(self): """Move display left one position.""" self.write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT) def move_right(self): """Move display right one position.""" self.write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT) def set_left_to_right(self): """Set text direction left to right.""" self.displaymode |= LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode) def set_right_to_left(self): """Set text direction right to left.""" self.displaymode &= ~LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode) def autoscroll(self, autoscroll): """Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text. """ if autoscroll: self.displaymode |= LCD_ENTRYSHIFTINCREMENT else: self.displaymode &= ~LCD_ENTRYSHIFTINCREMENT self.write8(LCD_ENTRYMODESET | self.displaymode) def message(self, text): """Write text to display. Note that text can include newlines.""" line = 0 # Iterate through each character. for char in text: # Advance to next line if character is a new line. if char == '\n': line += 1 # Move to left or right side depending on text direction. col = 0 if self.displaymode & LCD_ENTRYLEFT > 0 else self._cols-1 self.set_cursor(col, line) # Write the character to the display. else: self.write8(ord(char), True) def set_backlight(self, backlight): """Enable or disable the backlight. If PWM is not enabled (default), a non-zero backlight value will turn on the backlight and a zero value will turn it off. If PWM is enabled, backlight can be any value from 0.0 to 1.0, with 1.0 being full intensity backlight. """ if self._backlight is not None: if self._pwm_enabled: self._pwm.set_duty_cycle(self._backlight, self._pwm_duty_cycle(backlight)) else: self._gpio.output(self._backlight, self._blpol if backlight else not self._blpol) def write8(self, value, char_mode=False): """Write 8-bit value in character or data mode. Value should be an int value from 0-255, and char_mode is True if character data or False if non-character data (default). """ # One millisecond delay to prevent writing too quickly. self._delay_microseconds(1000) # Set character / data bit. self._gpio.output(self._rs, char_mode) # Write upper 4 bits. self._gpio.output_pins({ self._d4: ((value >> 4) & 1) > 0, self._d5: ((value >> 5) & 1) > 0, self._d6: ((value >> 6) & 1) > 0, self._d7: ((value >> 7) & 1) > 0 }) self._pulse_enable() # Write lower 4 bits. self._gpio.output_pins({ self._d4: (value & 1) > 0, self._d5: ((value >> 1) & 1) > 0, self._d6: ((value >> 2) & 1) > 0, self._d7: ((value >> 3) & 1) > 0 }) self._pulse_enable() def _delay_microseconds(self, microseconds): # Busy wait in loop because delays are generally very short (few microseconds). end = time.time() + (microseconds/1000000.0) while time.time() < end: pass def _pulse_enable(self): # Pulse the clock enable line off, on, off to send command. self._gpio.output(self._en, False) self._delay_microseconds(1) # 1 microsecond pause - enable pulse must be > 450ns self._gpio.output(self._en, True) self._delay_microseconds(1) # 1 microsecond pause - enable pulse must be > 450ns self._gpio.output(self._en, False) self._delay_microseconds(1) # commands need > 37us to settle def _pwm_duty_cycle(self, intensity): # Convert intensity value of 0.0 to 1.0 to a duty cycle of 0.0 to 100.0 intensity = 100.0*intensity # Invert polarity if required. if not self._blpol: intensity = 100.0-intensity return intensity class Adafruit_RGBCharLCD(Adafruit_CharLCD): """Class to represent and interact with an HD44780 character LCD display with an RGB backlight.""" def __init__(self, rs, en, d4, d5, d6, d7, cols, lines, red, green, blue, gpio=GPIO.get_platform_gpio(), invert_polarity=True, enable_pwm=False, pwm=PWM.get_platform_pwm(), initial_color=(1.0, 1.0, 1.0)): """Initialize the LCD with RGB backlight. RS, EN, and D4...D7 parameters should be the pins connected to the LCD RS, clock enable, and data line 4 through 7 connections. The LCD will be used in its 4-bit mode so these 6 lines are the only ones required to use the LCD. You must also pass in the number of columns and lines on the LCD. The red, green, and blue parameters define the pins which are connected to the appropriate backlight LEDs. The invert_polarity parameter is a boolean that controls if the LEDs are on with a LOW or HIGH signal. By default invert_polarity is True, i.e. the backlight LEDs are on with a low signal. If you want to enable PWM on the backlight LEDs (for finer control of colors) and the hardware supports PWM on the provided pins, set enable_pwm to True. Finally you can set an explicit initial backlight color with the initial_color parameter. The default initial color is white (all LEDs lit). You can optionally pass in an explicit GPIO class, for example if you want to use an MCP230xx GPIO extender. If you don't pass in an GPIO instance, the default GPIO for the running platform will be used. """ super(Adafruit_RGBCharLCD, self).__init__(rs, en, d4, d5, d6, d7, cols, lines, enable_pwm=enable_pwm, backlight=None, invert_polarity=invert_polarity, gpio=gpio, pwm=pwm) self._red = red self._green = green self._blue = blue # Setup backlight pins. if enable_pwm: # Determine initial backlight duty cycles. rdc, gdc, bdc = self._rgb_to_duty_cycle(initial_color) pwm.start(red, rdc) pwm.start(green, gdc) pwm.start(blue, bdc) else: gpio.setup(red, GPIO.OUT) gpio.setup(green, GPIO.OUT) gpio.setup(blue, GPIO.OUT) self._gpio.output_pins(self._rgb_to_pins(initial_color)) def _rgb_to_duty_cycle(self, rgb): # Convert tuple of RGB 0-1 values to tuple of duty cycles (0-100). red, green, blue = rgb # Clamp colors between 0.0 and 1.0 red = max(0.0, min(1.0, red)) green = max(0.0, min(1.0, green)) blue = max(0.0, min(1.0, blue)) return (self._pwm_duty_cycle(red), self._pwm_duty_cycle(green), self._pwm_duty_cycle(blue)) def _rgb_to_pins(self, rgb): # Convert tuple of RGB 0-1 values to dict of pin values. red, green, blue = rgb return { self._red: self._blpol if red else not self._blpol, self._green: self._blpol if green else not self._blpol, self._blue: self._blpol if blue else not self._blpol } def set_color(self, red, green, blue): """Set backlight color to provided red, green, and blue values. If PWM is enabled then color components can be values from 0.0 to 1.0, otherwise components should be zero for off and non-zero for on. """ if self._pwm_enabled: # Set duty cycle of PWM pins. rdc, gdc, bdc = self._rgb_to_duty_cycle((red, green, blue)) self._pwm.set_duty_cycle(self._red, rdc) self._pwm.set_duty_cycle(self._green, gdc) self._pwm.set_duty_cycle(self._blue, bdc) else: # Set appropriate backlight pins based on polarity and enabled colors. self._gpio.output_pins({self._red: self._blpol if red else not self._blpol, self._green: self._blpol if green else not self._blpol, self._blue: self._blpol if blue else not self._blpol }) def set_backlight(self, backlight): """Enable or disable the backlight. If PWM is not enabled (default), a non-zero backlight value will turn on the backlight and a zero value will turn it off. If PWM is enabled, backlight can be any value from 0.0 to 1.0, with 1.0 being full intensity backlight. On an RGB display this function will set the backlight to all white. """ self.set_color(backlight, backlight, backlight) def create_char(self, location, pattern): """Fill one of the first 8 CGRAM locations with custom characters. The location parameter should be between 0 and 7 and pattern should provide an array of 8 bytes containing the pattern. E.g. you can easyly design your custom character at http://www.quinapalus.com/hd44780udg.html To show your custom character use eg. lcd.message('\x01') """ # only position 0..7 are allowed location &= 0x7 self.write8(LCD_SETCGRAMADDR | (location << 3)) for i in range(8): self.write8(pattern[i], char_mode=True) class Adafruit_CharLCDPlate(Adafruit_RGBCharLCD): """Class to represent and interact with an Adafruit Raspberry Pi character LCD plate.""" def __init__(self, address=0x20, busnum=I2C.get_default_bus(), cols=16, lines=2): """Initialize the character LCD plate. Can optionally specify a separate I2C address or bus number, but the defaults should suffice for most needs. Can also optionally specify the number of columns and lines on the LCD (default is 16x2). """ # Configure MCP23017 device. self._mcp = MCP.MCP23017(address=address, busnum=busnum) # Set LCD R/W pin to low for writing only. self._mcp.setup(LCD_PLATE_RW, GPIO.OUT) self._mcp.output(LCD_PLATE_RW, GPIO.LOW) # Set buttons as inputs with pull-ups enabled. for button in (SELECT, RIGHT, DOWN, UP, LEFT): self._mcp.setup(button, GPIO.IN) self._mcp.pullup(button, True) # Initialize LCD (with no PWM support). super(Adafruit_CharLCDPlate, self).__init__(LCD_PLATE_RS, LCD_PLATE_EN, LCD_PLATE_D4, LCD_PLATE_D5, LCD_PLATE_D6, LCD_PLATE_D7, cols, lines, LCD_PLATE_RED, LCD_PLATE_GREEN, LCD_PLATE_BLUE, enable_pwm=False, gpio=self._mcp) def is_pressed(self, button): """Return True if the provided button is pressed, False otherwise.""" if button not in set((SELECT, RIGHT, DOWN, UP, LEFT)): raise ValueError('Unknown button, must be SELECT, RIGHT, DOWN, UP, or LEFT.') return self._mcp.input(button) == GPIO.LOW
44.399558
105
0.600855
4a2446bb9234625f2c07ed3cfa35889ba9ca2347
5,902
py
Python
Chapter06/02_dqn_pong.py
feiwang20/DRLHandsOn-Playground
b940c4959993d3ad7c6a2b0429b155d21cafe845
[ "MIT" ]
2,497
2018-05-25T09:45:54.000Z
2022-03-31T14:30:28.000Z
Chapter06/02_dqn_pong.py
feiwang20/DRLHandsOn-Playground
b940c4959993d3ad7c6a2b0429b155d21cafe845
[ "MIT" ]
94
2018-09-02T11:53:00.000Z
2022-03-02T07:36:31.000Z
Chapter06/02_dqn_pong.py
feiwang20/DRLHandsOn-Playground
b940c4959993d3ad7c6a2b0429b155d21cafe845
[ "MIT" ]
1,254
2018-05-23T11:21:24.000Z
2022-03-30T16:56:13.000Z
#!/usr/bin/env python3 from lib import wrappers from lib import dqn_model import argparse import time import numpy as np import collections import torch import torch.nn as nn import torch.optim as optim from tensorboardX import SummaryWriter DEFAULT_ENV_NAME = "PongNoFrameskip-v4" MEAN_REWARD_BOUND = 19.5 GAMMA = 0.99 BATCH_SIZE = 32 REPLAY_SIZE = 10000 LEARNING_RATE = 1e-4 SYNC_TARGET_FRAMES = 1000 REPLAY_START_SIZE = 10000 EPSILON_DECAY_LAST_FRAME = 10**5 EPSILON_START = 1.0 EPSILON_FINAL = 0.02 Experience = collections.namedtuple('Experience', field_names=['state', 'action', 'reward', 'done', 'new_state']) class ExperienceBuffer: def __init__(self, capacity): self.buffer = collections.deque(maxlen=capacity) def __len__(self): return len(self.buffer) def append(self, experience): self.buffer.append(experience) def sample(self, batch_size): indices = np.random.choice(len(self.buffer), batch_size, replace=False) states, actions, rewards, dones, next_states = zip(*[self.buffer[idx] for idx in indices]) return np.array(states), np.array(actions), np.array(rewards, dtype=np.float32), \ np.array(dones, dtype=np.uint8), np.array(next_states) class Agent: def __init__(self, env, exp_buffer): self.env = env self.exp_buffer = exp_buffer self._reset() def _reset(self): self.state = env.reset() self.total_reward = 0.0 def play_step(self, net, epsilon=0.0, device="cpu"): done_reward = None if np.random.random() < epsilon: action = env.action_space.sample() else: state_a = np.array([self.state], copy=False) state_v = torch.tensor(state_a).to(device) q_vals_v = net(state_v) _, act_v = torch.max(q_vals_v, dim=1) action = int(act_v.item()) # do step in the environment new_state, reward, is_done, _ = self.env.step(action) self.total_reward += reward exp = Experience(self.state, action, reward, is_done, new_state) self.exp_buffer.append(exp) self.state = new_state if is_done: done_reward = self.total_reward self._reset() return done_reward def calc_loss(batch, net, tgt_net, device="cpu"): states, actions, rewards, dones, next_states = batch states_v = torch.tensor(states).to(device) next_states_v = torch.tensor(next_states).to(device) actions_v = torch.tensor(actions).to(device) rewards_v = torch.tensor(rewards).to(device) done_mask = torch.ByteTensor(dones).to(device) state_action_values = net(states_v).gather(1, actions_v.unsqueeze(-1)).squeeze(-1) next_state_values = tgt_net(next_states_v).max(1)[0] next_state_values[done_mask] = 0.0 next_state_values = next_state_values.detach() expected_state_action_values = next_state_values * GAMMA + rewards_v return nn.MSELoss()(state_action_values, expected_state_action_values) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--cuda", default=False, action="store_true", help="Enable cuda") parser.add_argument("--env", default=DEFAULT_ENV_NAME, help="Name of the environment, default=" + DEFAULT_ENV_NAME) parser.add_argument("--reward", type=float, default=MEAN_REWARD_BOUND, help="Mean reward boundary for stop of training, default=%.2f" % MEAN_REWARD_BOUND) args = parser.parse_args() device = torch.device("cuda" if args.cuda else "cpu") env = wrappers.make_env(args.env) net = dqn_model.DQN(env.observation_space.shape, env.action_space.n).to(device) tgt_net = dqn_model.DQN(env.observation_space.shape, env.action_space.n).to(device) writer = SummaryWriter(comment="-" + args.env) print(net) buffer = ExperienceBuffer(REPLAY_SIZE) agent = Agent(env, buffer) epsilon = EPSILON_START optimizer = optim.Adam(net.parameters(), lr=LEARNING_RATE) total_rewards = [] frame_idx = 0 ts_frame = 0 ts = time.time() best_mean_reward = None while True: frame_idx += 1 epsilon = max(EPSILON_FINAL, EPSILON_START - frame_idx / EPSILON_DECAY_LAST_FRAME) reward = agent.play_step(net, epsilon, device=device) if reward is not None: total_rewards.append(reward) speed = (frame_idx - ts_frame) / (time.time() - ts) ts_frame = frame_idx ts = time.time() mean_reward = np.mean(total_rewards[-100:]) print("%d: done %d games, mean reward %.3f, eps %.2f, speed %.2f f/s" % ( frame_idx, len(total_rewards), mean_reward, epsilon, speed )) writer.add_scalar("epsilon", epsilon, frame_idx) writer.add_scalar("speed", speed, frame_idx) writer.add_scalar("reward_100", mean_reward, frame_idx) writer.add_scalar("reward", reward, frame_idx) if best_mean_reward is None or best_mean_reward < mean_reward: torch.save(net.state_dict(), args.env + "-best.dat") if best_mean_reward is not None: print("Best mean reward updated %.3f -> %.3f, model saved" % (best_mean_reward, mean_reward)) best_mean_reward = mean_reward if mean_reward > args.reward: print("Solved in %d frames!" % frame_idx) break if len(buffer) < REPLAY_START_SIZE: continue if frame_idx % SYNC_TARGET_FRAMES == 0: tgt_net.load_state_dict(net.state_dict()) optimizer.zero_grad() batch = buffer.sample(BATCH_SIZE) loss_t = calc_loss(batch, net, tgt_net, device=device) loss_t.backward() optimizer.step() writer.close()
34.115607
113
0.648085
4a2446e4cc733549054fe6fb812377fd1ce310bf
4,727
py
Python
site-packages/pskf/tools/plot/pa/iterative.py
jjokella/pyshemkf
61a6329f7aa5739a38a68504fd6a44568fcd833b
[ "MIT" ]
5
2019-02-06T10:52:52.000Z
2021-05-21T09:32:45.000Z
site-packages/pskf/tools/plot/pa/iterative.py
jjokella/pyshemkf
61a6329f7aa5739a38a68504fd6a44568fcd833b
[ "MIT" ]
null
null
null
site-packages/pskf/tools/plot/pa/iterative.py
jjokella/pyshemkf
61a6329f7aa5739a38a68504fd6a44568fcd833b
[ "MIT" ]
1
2018-12-04T11:39:10.000Z
2018-12-04T11:39:10.000Z
# Iterative wavewell_dats = {50: '2018_03_21', 70: '2018_03_21', 100: '2018_03_21', 250: '2018_03_21', 500: '2018_03_21', 1000: '2018_03_21', 2000: '2018_03_21'} wavewell_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} wavewell_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} wavewell_obss = {50: 1830, 70: 1830, 100: 1830, 250: 1830, 500: 1830, 1000: 1830, 2000: 1830} wavewell2_dats = {50: '2019_03_07', 70: '2019_03_07', 100: '2019_03_07', 250: '2019_03_07', 500: '2019_03_07', 1000: '2019_03_07', 2000: '2019_03_07'} wavewell2_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} wavewell2_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} wavewell2_obss = {50: 1830, 70: 1830, 100: 1830, 250: 1830, 500: 1830, 1000: 1830, 2000: 1830} wavereal_dats = {50: '2018_02_15', 70: '2018_02_15', 100: '2018_02_15', 250: '2018_02_15', 500: '2018_02_15', 1000: '2018_02_15', 2000: '2018_02_15'} wavereal_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} wavereal_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} wavereal_obss = {50: 5050, 70: 5050, 100: 5050, 250: 5050, 500: 5050, 1000: 5050, 2000: 5050} wavereal2_dats = {50: '2019_03_07', 70: '2019_03_07', 100: '2019_03_07', 250: '2019_03_07', 500: '2019_03_07', 1000: '2019_03_07', 2000: '2019_03_07'} wavereal2_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} wavereal2_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} wavereal2_obss = {50: 5050, 70: 5050, 100: 5050, 250: 5050, 500: 5050, 1000: 5050, 2000: 5050} corrsmall_wavereal_dats = {50: '2018_09_07', 70: '2018_09_07', 100: '2018_09_07', 250: '2018_09_07', 500: '2018_09_07', 1000: '2018_09_07', 2000: '2018_09_07'} corrsmall_wavereal_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} corrsmall_wavereal_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} corrsmall_wavereal_obss = {50: 5050, 70: 5050, 100: 5050, 250: 5050, 500: 5050, 1000: 5050, 2000: 5050} corrlarge_wavereal_dats = {50: '2018_09_18', 70: '2018_09_18', 100: '2018_09_18', 250: '2018_09_18', 500: '2018_09_18', 1000: '2018_09_18', 2000: '2018_09_18'} corrlarge_wavereal_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} corrlarge_wavereal_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} corrlarge_wavereal_obss = {50: 5050, 70: 5050, 100: 5050, 250: 5050, 500: 5050, 1000: 5050, 2000: 5050} corrsmall_wavewell_dats = {50: '2018_09_07', 70: '2018_09_07', 100: '2018_09_07', 250: '2018_09_07', 500: '2018_09_07', 1000: '2018_09_07', 2000: '2018_09_07'} corrsmall_wavewell_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} corrsmall_wavewell_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} corrsmall_wavewell_obss = {50: 1830, 70: 1830, 100: 1830, 250: 1830, 500: 1830, 1000: 1830, 2000: 1830} corrlarge_wavewell_dats = {50: '2018_09_18', 70: '2018_09_18', 100: '2018_09_18', 250: '2018_09_18', 500: '2018_09_18', 1000: '2018_09_18', 2000: '2018_09_18'} corrlarge_wavewell_lets = {50: 'b', 70: 'aln', 100: 'bxz', 250: 'dkl', 500: 'ewx', 1000: 'gjj', 2000: 'hvv'} corrlarge_wavewell_nums = {50: 1000, 70: 1000, 100: 1000, 250: 1000, 500: 100, 1000: 100, 2000: 100} corrlarge_wavewell_obss = {50: 1830, 70: 1830, 100: 1830, 250: 1830, 500: 1830, 1000: 1830, 2000: 1830}
53.11236
70
0.507933
4a244732363134901b2b46efd4e2bfaa9bb190c0
7,378
py
Python
Leak #5 - Lost In Translation/windows/fuzzbunch/figlet.py
bidhata/EquationGroupLeaks
1ff4bc115cb2bd5bf2ed6bf769af44392926830c
[ "Unlicense" ]
9
2019-11-22T04:58:40.000Z
2022-02-26T16:47:28.000Z
Python.Fuzzbunch/fuzzbunch/figlet.py
010001111/Vx-Suites
6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79
[ "MIT" ]
null
null
null
Python.Fuzzbunch/fuzzbunch/figlet.py
010001111/Vx-Suites
6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79
[ "MIT" ]
8
2017-09-27T10:31:18.000Z
2022-01-08T10:30:46.000Z
""" Port of the C figlet driver to Python. Ugly, gross, not fully working, but does what I need to display a simple banner with a hand selected set of fonts. """ import sys import os import random __all__ = ['newbanner'] def newbanner(fontdir, msg): """ Returns msg converted to a random ascii art font from the given fontdir. """ try: font = get_randfont(fontdir) if not font: return "", "" f = Fig(font) f.addline(msg) except: return "", "" return f.getline(),font def get_randfont(fontdir): fonts = get_fontdirlist(fontdir) if not fonts: return None index = random.randint(0, len(fonts) - 1) return fonts[index] def get_fontdirlist(fontdir='fonts'): fonts = [fontdir + os.path.sep + item for item in os.listdir(fontdir) if item.endswith(".flf")] return fonts class Fig: hdr = {} def __init__(self, fontfile=None): if fontfile: self.init_fonts(fontfile) self.clearline() """ Font File parsing """ def init_fonts(self, fontfile=None): if fontfile: self.fontfile = fontfile file = open(self.fontfile) self.parse_header(file.readline().split()) self.parse_comments(file) self.parse_chars(file) file.close() def parse_header(self, header): self.hdr['signature'] = header[0][:-1] self.hdr['hardblank'] = header[0][-1] self.hdr['height'] = int(header[1]) self.hdr['baseline'] = header[2] self.hdr['maxlength'] = int(header[3]) self.hdr['oldlayout'] = header[4] self.hdr['commentlines'] = int(header[5]) try: self.hdr['printdir'] = header[6] self.hdr['fulllayout'] = header[7] self.hdr['codetagcount'] = header[8] except: self.hdr['printdir'] = "" self.hdr['fulllayout'] = "" self.hdr['codetagcount'] = "" if self.hdr['signature'] != "flf2a": self.hdr = {} return False return True def parse_comments(self, file): for i in range(0, self.hdr['commentlines']): line = file.readline() del line def parse_chars(self, file): self.chars = {} for c in range(32,127): self.chars[chr(c)] = [] for i in range(0, self.hdr['height']): self.chars[chr(c)].append(list(file.readline().rstrip("@#\r\n"))) def getletter(self, c): self.previouscharwidth = self.currcharwidth self.currcharwidth = len(self.chars[c][0]) return self.chars[c] def len_letter(self, letter): return len(letter[0]) """ Input Handling """ def smushmem(self, ch1, ch2): special = "|/\\[]{}()<>" if ch1 == ' ': return ch2 if ch2 == ' ': return ch1 if self.previouscharwidth < 2 or self.currcharwidth < 2: return '\0' if ch1 == self.hdr['hardblank'] or ch2 == self.hdr['hardblank']: return '\0' if ch1 == ch2: return ch1 if ch1 == '_' and ch2 in special: return ch2 if ch2 == '_' and ch1 in special: return ch1 if ch1 == "|" and ch2 in special[1:]: return ch2 if ch2 == "|" and ch1 in special[1:]: return ch1 if ch1 in "/\\" and ch2 in special[3:]: return ch2 if ch2 in "/\\" and ch1 in special[3:]: return ch1 if ch1 in "[]" and ch2 in special[5:]: return ch2 if ch2 in "[]" and ch1 in special[5:]: return ch1 if ch1 in "{}" and ch2 in special[7:]: return ch2 if ch2 in "{}" and ch1 in special[7:]: return ch1 if ch1 in "()" and ch2 in special[9:]: return ch2 if ch2 in "()" and ch1 in special[9:]: return ch1 if ch1 == '[' and ch2 == ']': return '|' if ch1 == ']' and ch2 == '[': return '|' if ch1 == '{' and ch2 == '}': return '|' if ch1 == '}' and ch2 == '{': return '|' if ch1 == '(' and ch2 == ')': return '|' if ch1 == ')' and ch2 == '(': return '|' return '\0' def get_smushamount(self, l): max_smush = self.currcharwidth for row in range(0, self.hdr['height']): linebd = len(self.line[row]) ch1 = ' ' while linebd > 0 and ch1 == ' ': try: ch1 = self.line[row][linebd] except IndexError: ch1 = ' ' if ch1 != ' ': break linebd = linebd - 1 try: charbd = 0 ch2 = ' ' while ch2 == ' ': ch2 = l[row][charbd] if ch2 != ' ': break charbd = charbd + 1 except IndexError: ch2 = None amt = charbd + self.outlinelen - 1 - linebd if ch1 == None or ch1 == ' ': amt = amt + 1 elif ch2 != None: if self.smushmem(ch1, ch2) != '\0': amt = amt + 1 if amt < max_smush: max_smush = amt return max_smush def addchar(self, c): letter = self.getletter(c) smush_amount = self.get_smushamount(letter) for row in range(0, self.hdr['height']): for k in range(0, smush_amount): if self.outlinelen - smush_amount + k >= 0: ch1 = self.line[row][self.outlinelen-smush_amount+k] ch2 = letter[row][k] self.line[row][self.outlinelen-smush_amount+k] = self.smushmem(ch1, ch2) self.line[row] += letter[row][smush_amount:] self.outlinelen = len(self.line[0]) def addline(self, line): for c in line: self.addchar(c) """ Output handling """ def clearline(self): self.line = [] for i in range(0,self.hdr['height']): self.line.append([]) self.previouscharwidth = 0 self.currcharwidth = 0 self.outlinelen = 0 def getstring(self, i): return ''.join(self.line[i]).replace(self.hdr['hardblank'], ' ') def getline(self): lines = [] for i in range(0, self.hdr['height']): lines.append(self.getstring(i)) self.clearline() return '\n'.join(lines) def putstring(self, i): print ''.join(self.line[i]).replace(self.hdr['hardblank'], ' ') def printline(self): for i in range(0, self.hdr['height']): self.putstring(i) self.clearline() if __name__ == "__main__": if len(sys.argv) < 3: print "usage: %s [phrase] [fontdir]" % sys.argv[0] sys.exit(-1) fontdir = sys.argv[2] fonts = get_fontdirlist(fontdir) index = random.randint(0, len(fonts) - 1) for font in fonts: print "FONT: ", font f = Fig(font) f.addline(sys.argv[1]) f.printline()
29.394422
92
0.485904
4a24474fbc565803357accfc254952e1dc6364bf
84
py
Python
project/settings.py
Divye02/cse599G1_HW
7357d9f79fda887e2ce0ba58601fbc432d2b53fd
[ "Apache-2.0" ]
null
null
null
project/settings.py
Divye02/cse599G1_HW
7357d9f79fda887e2ce0ba58601fbc432d2b53fd
[ "Apache-2.0" ]
null
null
null
project/settings.py
Divye02/cse599G1_HW
7357d9f79fda887e2ce0ba58601fbc432d2b53fd
[ "Apache-2.0" ]
null
null
null
from local_settings import * import os RES_DIR = os.path.join(MAIN_DIR, 'results')
16.8
43
0.761905
4a2447acde75859fb7635e5971e432791a07f80d
3,398
py
Python
src/pyams_zmi/interfaces/viewlet.py
Py-AMS/pyams-zmi
0073d12062728efad3dc2b5cb40b0f75eacaaa1d
[ "ZPL-2.1" ]
null
null
null
src/pyams_zmi/interfaces/viewlet.py
Py-AMS/pyams-zmi
0073d12062728efad3dc2b5cb40b0f75eacaaa1d
[ "ZPL-2.1" ]
null
null
null
src/pyams_zmi/interfaces/viewlet.py
Py-AMS/pyams-zmi
0073d12062728efad3dc2b5cb40b0f75eacaaa1d
[ "ZPL-2.1" ]
null
null
null
# # Copyright (c) 2015-2020 Thierry Florac <tflorac AT ulthar.net> # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # """PyAMS_zmi.interfaces.viewlet module This module defines public interfaces of several content providers which are used in PyAMS management interface. """ __docformat__ = 'restructuredtext' from zope.interface import Interface from zope.schema import Bool, Choice, TextLine from pyams_skin.interfaces import BOOTSTRAP_STATUS from pyams_skin.interfaces.viewlet import IDropdownMenu from pyams_viewlet.interfaces import IViewletManager class IPageHeaderViewletManager(IViewletManager): """Header viewlet marker interface""" class ITopLinksViewletManager(IViewletManager): """Top links viewlet marker interface""" class IUserLinksViewletManager(IViewletManager): """User links viewlet marker interface""" class IUserMenuViewletManager(IViewletManager): """User menu viewlet marker interface""" class ILeftAsideViewletManager(IViewletManager): """Left aside viewlet marker interface""" class INavigationViewletManager(IViewletManager): """Navigation viewlet marker interface""" class IMenuHeader(Interface): """Menu header""" class INavigationMenu(IViewletManager): """Navigation menu viewlet interface""" header = TextLine(title="Menu header label", description="Can be customized using an IMenuHeader multi-adapter") class IContentManagementMenu(INavigationMenu): """Content management menu marker interface""" class IPropertiesMenu(INavigationMenu): """Content properties menu""" class ISiteManagementMenu(INavigationMenu): """Site management menu marker interface""" class IControlPanelMenu(INavigationMenu): """Control panel menu marker interface""" class IUtilitiesMenu(INavigationMenu): """Local utilities menu""" class INavigationMenuItem(IViewletManager): """Navigation menu item viewlet interface""" label = TextLine(title="Main menu item label") css_class = TextLine(title="Main CSS class") icon_class = TextLine(title="FontAwesome class of menu item icon, including prefix " "('fa', 'fab'...)") badge = TextLine(title="Optional badge text") badge_status = Choice(title="Badge status", values=BOOTSTRAP_STATUS, default='info') href = TextLine(title="Link target URL", default='#') def get_href(self): """Complete HREF attribute getter""" click_handler = TextLine(title="Optional Javascript click handler name") target = TextLine(title="Menu link target name") modal_target = Bool(title="Link to modal dialog?", default=False) class IToolbarViewletManager(IViewletManager): """Toolbar viewlet manager""" class IContextAddingsViewletManager(IDropdownMenu): """Context addings viewlet manager""" class IActionsViewletManager(IViewletManager): """Custom actions menu viewlet manager"""
27.403226
89
0.723955
4a2447da11d183836fb555d74770ee3439a2b2a9
1,437
py
Python
pipeline_web/drawing_new/constants.py
springborland/bk-sops
a9057672c10efb5f2414a805a30ead4092429c76
[ "Apache-2.0" ]
1
2021-05-19T04:31:34.000Z
2021-05-19T04:31:34.000Z
pipeline_web/drawing_new/constants.py
ZhuoZhuoCrayon/bk-sops
d1475d53c19729915727ce7adc24e3226f15e332
[ "Apache-2.0" ]
null
null
null
pipeline_web/drawing_new/constants.py
ZhuoZhuoCrayon/bk-sops
d1475d53c19729915727ce7adc24e3226f15e332
[ "Apache-2.0" ]
null
null
null
# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available. Copyright (C) 2017-2020 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://opensource.org/licenses/MIT 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 pipeline_web.constants import PWE MIN_LEN = 1 DUMMY_NODE_TYPE = 'DummyNode' DUMMY_FLOW_TYPE = 'DummyFlow' CANVAS_WIDTH = 1300 POSITION = { 'activity_size': (150, 54), 'event_size': (44, 44), 'gateway_size': (34, 34), 'start': (60, 100) } PIPELINE_ELEMENT_TO_WEB = { DUMMY_NODE_TYPE: DUMMY_NODE_TYPE, PWE.ServiceActivity: PWE.tasknode, PWE.SubProcess: PWE.subflow, PWE.EmptyStartEvent: PWE.startpoint, PWE.EmptyEndEvent: PWE.endpoint, PWE.ExclusiveGateway: PWE.branchgateway, PWE.ParallelGateway: PWE.parallelgateway, PWE.ConvergeGateway: PWE.convergegateway } PIPELINE_WEB_TO_ELEMENT = {value: key for key, value in PIPELINE_ELEMENT_TO_WEB.items()}
37.815789
115
0.759221
4a24493380aa30a02108219e98ce85c1f1ae9e7f
1,871
py
Python
kubernetes/test/test_scheduling_v1alpha1_api.py
iamneha/python
5b208a1a49a8d6f8bbab28bcc226b9ef793bcbd0
[ "Apache-2.0" ]
1
2019-02-17T15:28:39.000Z
2019-02-17T15:28:39.000Z
kubernetes/test/test_scheduling_v1alpha1_api.py
iamneha/python
5b208a1a49a8d6f8bbab28bcc226b9ef793bcbd0
[ "Apache-2.0" ]
null
null
null
kubernetes/test/test_scheduling_v1alpha1_api.py
iamneha/python
5b208a1a49a8d6f8bbab28bcc226b9ef793bcbd0
[ "Apache-2.0" ]
null
null
null
# coding: utf-8 """ Kubernetes No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: v1.13.4 Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import absolute_import import os import sys import unittest import kubernetes.client from kubernetes.client.rest import ApiException from kubernetes.client.apis.scheduling_v1alpha1_api import SchedulingV1alpha1Api class TestSchedulingV1alpha1Api(unittest.TestCase): """ SchedulingV1alpha1Api unit test stubs """ def setUp(self): self.api = kubernetes.client.apis.scheduling_v1alpha1_api.SchedulingV1alpha1Api() def tearDown(self): pass def test_create_priority_class(self): """ Test case for create_priority_class """ pass def test_delete_collection_priority_class(self): """ Test case for delete_collection_priority_class """ pass def test_delete_priority_class(self): """ Test case for delete_priority_class """ pass def test_get_api_resources(self): """ Test case for get_api_resources """ pass def test_list_priority_class(self): """ Test case for list_priority_class """ pass def test_patch_priority_class(self): """ Test case for patch_priority_class """ pass def test_read_priority_class(self): """ Test case for read_priority_class """ pass def test_replace_priority_class(self): """ Test case for replace_priority_class """ pass if __name__ == '__main__': unittest.main()
18.524752
105
0.616248
4a24497e2b4d133283e35fd56e7a3f5fa915e87c
4,416
py
Python
minio_storage/files.py
brianhelba/django-minio-storage
7ebc10be0cf07c9c5709bb976a8df40d231f0433
[ "Apache-2.0", "MIT" ]
null
null
null
minio_storage/files.py
brianhelba/django-minio-storage
7ebc10be0cf07c9c5709bb976a8df40d231f0433
[ "Apache-2.0", "MIT" ]
null
null
null
minio_storage/files.py
brianhelba/django-minio-storage
7ebc10be0cf07c9c5709bb976a8df40d231f0433
[ "Apache-2.0", "MIT" ]
null
null
null
import tempfile import typing as T from logging import getLogger from django.core.files.base import File from minio import error as merr from minio_storage.errors import minio_error if T.TYPE_CHECKING: from minio_storage.storage import Storage logger = getLogger("minio_storage") class ReadOnlyMixin: """File class mixin which disallows .write() calls""" def writable(self) -> bool: return False def write(*args, **kwargs): raise NotImplementedError("this is a read only file") class NonSeekableMixin: """File class mixin which disallows .seek() calls""" def seekable(self) -> bool: return False def seek(self, *args, **kwargs) -> bool: # TODO: maybe exception is better # raise NotImplementedError('seek is not supported') return False class MinioStorageFile(File): def __init__(self, name: str, mode: str, storage: "Storage", **kwargs): self._storage: "Storage" = storage self.name: str = name self._mode: str = mode self._file = None class ReadOnlyMinioObjectFile(MinioStorageFile, ReadOnlyMixin, NonSeekableMixin): """A django File class which directly exposes the underlying minio object. This means the the instance doesnt support functions like .seek() and is required to be closed to be able to reuse minio connections. Note: This file class is not tested yet""" def __init__( self, name: str, mode: str, storage: "Storage", max_memory_size: T.Optional[int] = None, **kwargs, ): if mode.find("w") > -1: raise NotImplementedError( "ReadOnlyMinioObjectFile storage only support read modes" ) if max_memory_size is not None: self.max_memory_size = max_memory_size super().__init__(name, mode, storage) def _get_file(self): if self._file is None: try: obj = self._storage.client.get_object( self._storage.bucket_name, self.name ) self._file = obj return self._file except merr.ResponseError as error: logger.warn(error) raise OSError(f"File {self.name} does not exist") finally: try: obj.release_conn() except Exception as e: logger.error(str(e)) return self._file def _set_file(self, value): self._file = value file = property(_get_file, _set_file) def close(self): try: self.file.close() finally: self.file.release_conn() class ReadOnlySpooledTemporaryFile(MinioStorageFile, ReadOnlyMixin): """A django File class which buffers the minio object into a local SpooledTemporaryFile. """ max_memory_size: int = 1024 * 1024 * 10 def __init__( self, name: str, mode: str, storage: "Storage", max_memory_size: T.Optional[int] = None, **kwargs, ): if mode.find("w") > -1: raise NotImplementedError( "ReadOnlySpooledTemporaryFile storage only support read modes" ) if max_memory_size is not None: self.max_memory_size = max_memory_size super().__init__(name, mode, storage) def _get_file(self): if self._file is None: try: obj = self._storage.client.get_object( self._storage.bucket_name, self.name ) self._file = tempfile.SpooledTemporaryFile( max_size=self.max_memory_size ) for d in obj.stream(amt=1024 * 1024): self._file.write(d) self._file.seek(0) return self._file except merr.ResponseError as error: raise minio_error(f"File {self.name} does not exist", error) finally: try: obj.release_conn() except Exception as e: logger.error(str(e)) return self._file def _set_file(self, value): self._file = value file = property(_get_file, _set_file) def close(self): if self._file is not None: self._file.close() self._file = None
29.245033
83
0.581748
4a244a264ccd8efbff6eaac69d084b59c9cdcd0e
3,797
py
Python
native/pca/GPU/base_pca.py
PokhodenkoSA/dpbench
b22970237a7d550f7b0514481797247edcb4f190
[ "BSD-2-Clause" ]
null
null
null
native/pca/GPU/base_pca.py
PokhodenkoSA/dpbench
b22970237a7d550f7b0514481797247edcb4f190
[ "BSD-2-Clause" ]
null
null
null
native/pca/GPU/base_pca.py
PokhodenkoSA/dpbench
b22970237a7d550f7b0514481797247edcb4f190
[ "BSD-2-Clause" ]
null
null
null
# ***************************************************************************** # Copyright (c) 2020, Intel Corporation All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ***************************************************************************** import os import numpy as np from sklearn.datasets import make_classification, make_regression import pandas as pd import utils ###################################################### # GLOBAL DECLARATIONS THAT WILL BE USED IN ALL FILES # ###################################################### # make xrange available in python 3 try: xrange except NameError: xrange = range ################################################# def gen_c_data(nopt, dims): return make_classification(n_samples=nopt, n_features=dims, random_state=0) def gen_r_data(nopt, dims): return make_regression(n_samples=nopt, n_features=dims, random_state=0) ################################################# def run(name, sizes=10, step=2, nopt=2**10): import argparse parser = argparse.ArgumentParser() parser.add_argument('--steps', type=int, default=sizes, help='Number of steps') parser.add_argument('--step', type=int, default=step, help='Factor for each step') parser.add_argument('--size', type=int, default=nopt, help='Initial data size') parser.add_argument('--repeat', type=int, default=1, help='Iterations inside measured region') parser.add_argument('--text', default='', help='Print with each result') parser.add_argument('--dims', type=int, default=2**7, help='Dimensions') args = parser.parse_args() repeat = args.repeat # delete perf_output csv and runtimes csv if os.path.isfile('runtimes.csv'): os.remove('runtimes.csv') if os.path.isfile('perf_output.csv'): os.remove('perf_output.csv') clean_string = ['make', 'clean'] utils.run_command(clean_string, verbose=True) build_string = ['make'] utils.run_command(build_string, verbose=True) nopt = int(args.size) for i in xrange(args.steps): r_data, _ = gen_r_data(nopt, args.dims) # write data to csv file pd.DataFrame(r_data).to_csv('pca_normalized.csv', header=None, index=None) # run the C program run_cmd = ['./pca', str(nopt), str(args.dims), str(repeat)] utils.run_command(run_cmd, verbose=True) nopt *= args.step repeat -= args.step if repeat < 1: repeat = 1 if __name__ == '__main__': run('PCA native')
37.22549
98
0.643666
4a244aedf8bf66f0aeb54e8378f8348808b4ad54
1,331
py
Python
mqtt_wrapper.py
alpsayin/keyboard-interceptor-esp
e3b25f03d2a541f002f068a3a49b5c7603ffd51e
[ "MIT" ]
null
null
null
mqtt_wrapper.py
alpsayin/keyboard-interceptor-esp
e3b25f03d2a541f002f068a3a49b5c7603ffd51e
[ "MIT" ]
null
null
null
mqtt_wrapper.py
alpsayin/keyboard-interceptor-esp
e3b25f03d2a541f002f068a3a49b5c7603ffd51e
[ "MIT" ]
2
2020-12-21T13:04:59.000Z
2021-06-13T02:04:16.000Z
import time from umqtt.simple import MQTTClient # Publish test messages e.g. with: # mosquitto_pub -t foo_topic -m hello blocking_wait = False mqtt_client = None # Received messages from subscriptions will be delivered to this callback def simple_sub_cb(topic, msg): print((topic, msg)) def init(client_id, hostname='alpcer0.local', sub_topic='kybIntcpt', callback=simple_sub_cb): global mqtt_client mqtt_client = MQTTClient(client_id, hostname) mqtt_client.set_callback(callback) mqtt_client.connect() mqtt_client.subscribe(sub_topic) mqtt_client.ping() mqtt_client.wait_msg() def main(server="alpcer0.local"): global blocking_wait c = MQTTClient("umqtt_client", server) c.set_callback(simple_sub_cb) c.connect() c.subscribe(b"foo_topic") while True: if blocking_wait: # Blocking wait for message c.wait_msg() c.publish(b'bar_topic', b'received a message') else: c.publish(b'bar_topic', b'checking for messages') # Non-blocking wait for message c.check_msg() # Then need to sleep to avoid 100% CPU usage (in a real # app other useful actions would be performed instead) time.sleep(1) c.disconnect() if __name__ == "__main__": main()
27.729167
93
0.66867
4a244b915a4e8e59fb7724430734e5b842e91d02
4,699
py
Python
sdk/recoveryservices/azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/aio/operations/_job_cancellations_operations.py
JianpingChen/azure-sdk-for-python
3072fc8c0366287fbaea1b02493a50259c3248a2
[ "MIT" ]
3
2020-06-23T02:25:27.000Z
2021-09-07T18:48:11.000Z
sdk/recoveryservices/azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/aio/operations/_job_cancellations_operations.py
JianpingChen/azure-sdk-for-python
3072fc8c0366287fbaea1b02493a50259c3248a2
[ "MIT" ]
510
2019-07-17T16:11:19.000Z
2021-08-02T08:38:32.000Z
sdk/recoveryservices/azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/aio/operations/_job_cancellations_operations.py
JianpingChen/azure-sdk-for-python
3072fc8c0366287fbaea1b02493a50259c3248a2
[ "MIT" ]
5
2019-09-04T12:51:37.000Z
2020-09-16T07:28:40.000Z
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class JobCancellationsOperations: """JobCancellationsOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.mgmt.recoveryservicesbackup.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config async def trigger( self, vault_name: str, resource_group_name: str, job_name: str, **kwargs: Any ) -> None: """Cancels a job. This is an asynchronous operation. To know the status of the cancellation, call GetCancelOperationResult API. :param vault_name: The name of the recovery services vault. :type vault_name: str :param resource_group_name: The name of the resource group where the recovery services vault is present. :type resource_group_name: str :param job_name: Name of the job to cancel. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2021-01-01" accept = "application/json" # Construct URL url = self.trigger.metadata['url'] # type: ignore path_format_arguments = { 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'jobName': self._serialize.url("job_name", job_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) trigger.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobs/{jobName}/cancel'} # type: ignore
45.621359
200
0.676314
4a244b9bb63e706df8c4ff57367dfaa23cd39310
9,668
py
Python
parser/team28/main.py
Lenin201/tytus
cace7587b0274ceb26327b583201493bd1048b96
[ "MIT" ]
null
null
null
parser/team28/main.py
Lenin201/tytus
cace7587b0274ceb26327b583201493bd1048b96
[ "MIT" ]
null
null
null
parser/team28/main.py
Lenin201/tytus
cace7587b0274ceb26327b583201493bd1048b96
[ "MIT" ]
null
null
null
from tkinter import * from tkinter import ttk from tkinter.filedialog import askopenfilename from tkinter.filedialog import asksaveasfilename from tkinter import messagebox from tkinter import scrolledtext from tkinter.font import Font import os import json from utils.analyzers.syntactic import * from controllers.error_controller import ErrorController from utils.reports.generate_ast import GraficarAST from utils.reports.report_error import ReportError from controllers.ast_construction import * report_error = None report_ast = None class GUI: archivo = "" def __init__(self, window): self.ventana = window # Defino un titulo para el GUI self.ventana.title("Query Tool") # Defino un fondo para usar, pueden cambiarlo por otro color mas bonito self.ventana.configure(background='#3c3f41') self.ventana.columnconfigure(0, weight=1) self.ventana.rowconfigure(0, weight=1) # Creo un frame para que contenga la intefaz, es como en java se hace con swing frame = LabelFrame(self.ventana) # Posiciono el frame frame.grid(row=0, column=0, columnspan=10, pady=10) # Defino un fondo para usar, pueden cambiarlo por otro color mas bonito frame.configure(background='#3c3f41', borderwidth=0) #############################################_MENU_############################################# # Creo un menu, es decir una lista desplegable barraMenu = Menu(self.ventana) self.ventana.config(menu=barraMenu) archivoMenu = Menu(barraMenu, tearoff=0) #############################################SUB MENU EJECUTAR############################################# # Creo un menu, es decir una lista desplegable archivoEjecutar = Menu(archivoMenu, tearoff=0) # Este menu va a ser para ejecutar archivos y ser analizados por el parser # command es para anadir metodos creados archivoEjecutar.add_command( label="Analizar Entrada", command=self.analizar_entrada) #############################################MENU Abrir############################################# archivoOpen = Menu(archivoMenu, tearoff=0) archivoOpen.add_command(label="Abrir Archivo", command=self.open_file_editor) #############################################MENU Archivo############################################# archivoMenu.add_command(label="Nuevo", command=self.nuevo) archivoMenu.add_separator() archivoMenu.add_cascade(label="Abrir", menu=archivoOpen) archivoMenu.add_separator() archivoMenu.add_command(label="Guardar", command=self.guardar) archivoMenu.add_command(label="Guardar como...", command=self.guardar_como) archivoMenu.add_separator() archivoMenu.add_cascade(label="Ejecutar", menu=archivoEjecutar) archivoMenu.add_separator() archivoMenu.add_command(label="Salir", command=self.terminar) #############################################MENU WINDOWS############################################## windows_menu = Menu(barraMenu, tearoff=0) windows_menu.add_command(label='Report AST', command=self.report_ast_windows) windows_menu.add_command(label='Report Errors', command=self.report_errors_windows) #############################################MENU LINUX################################################ ubuntu_menu = Menu(barraMenu, tearoff=0) ubuntu_menu.add_command(label='Report AST', command=self.report_ast_ubuntu) ubuntu_menu.add_command(label='Report Errors', command=self.report_errors_ubuntu) #############################################MENU REPORTES############################################# archivoReportes = Menu(barraMenu, tearoff=0) archivoReportes.add_cascade(label="Windows", menu=windows_menu) archivoReportes.add_separator() archivoReportes.add_cascade(label="Linux", menu=ubuntu_menu) #############################################MENU PRINCIPAL############################################# barraMenu.add_cascade(label="Archivo", menu=archivoMenu) # anade submenu barraMenu.add_cascade(label="Reportes", menu=archivoReportes) barraMenu.configure(background='SpringGreen') ############################################_ENTRADA_############################################ Label(frame, text='Archivo de Entrada', borderwidth=0, font='Arial 15 bold', width=52, bg='#3c3f41', foreground='#fff').grid(row=3, column=0) # Crea un scroll por si el texto es muy largo self.entrada = scrolledtext.ScrolledText(frame, borderwidth=0, height=35, width=70, bg='#2e2e31', foreground='#fff') self.entrada.grid(row=4, column=0, padx=30) # Para este editor aun hay que ver si lo usamos como consola para errores, si no lo quitamos Label(frame, text='Consola', borderwidth=0, font='Arial 15 bold', width=52, bg='#3c3f41', foreground='#fff').grid(row=3, column=1) self.salida = scrolledtext.ScrolledText(frame, state=DISABLED, borderwidth=0, height=35, width=70, bg='#1c1c1e', foreground='#9efb01') self.salida.grid(row=4, column=1, padx=30) # END # Metodo para abrir archivo y colocarlo en el editor def open_file_editor(self): filename = askopenfilename(title="Abrir Archivo") archivo = open(filename, "r") texto = archivo.read() self.entrada.insert(INSERT, texto) archivo.close() messagebox.showinfo("CARGA", "SE CARGO CORRECTAMENTE EL ARCHIVO SQL") return # Crea una nueva pestana def nuevo(self): self.entrada.delete(1.0, END) self.salida.delete(1.0, END) self.archivo = "" # Guarda el archivo def guardar(self): if self.archivo == "": self.guardar_como() else: guardar_info = open(self.archivo, "w") guardar_info.write(self.entrada.get("1.0", END)) guardar_info.close() # Opcion para guardar como def guardar_como(self): guardar_info = asksaveasfilename(title="Guardar Archivo") write_file = open(guardar_info, "w+") write_file.write(self.entrada.get("1.0", END)) write_file.close() self.archivo = guardar_info # Opcion para ejecutar el texto de entrada del editor def analizar_entrada(self): global report_error global report_ast texto = self.entrada.get("1.0", END) result = parse(texto) #jsonStr = json.dumps(result, default=lambda o: o.__dict__) #Convierte el AST a formato JSON para poder saber como se esta formando print(result) # Imprime el AST if len(ErrorController().getList()) > 0: report_error = ReportError() messagebox.showerror('ERRORES', 'Se encontraron errores') else: result2 = parse2(texto) report_ast = result2 messagebox.showinfo("EXITO", "SE FINALIZO EL ANALISIS CON EXITO") # ---------- TEST --------- for inst in result: # print(inst) print(inst.process(0)) #report_errors = ReportError() #report = open('dot.txt', 'w') # report.write(report_errors.get_report( # ErrorController().getExeErrList())) # report.close() #os.system('dot -Tpdf dot.txt -o error.pdf') # os.startfile('error.pdf') # ---------- TEST --------- # Para mostrar el editor def report_ast_ubuntu(self): global report_ast graficadora = GraficarAST() report = open('./team28/dot.txt', 'w') report.write(graficadora.generate_string(report_ast)) report.close() os.system('dot -Tpdf ./team28/dot.txt -o ./team28/ast.pdf') # Si estan en ubuntu dejan esta linea si no la comentan y descomentan la otra para windows os.system('xdg-open ./team28/ast.pdf') # os.open('ast.pdf') # os.startfile('ast.pdf') def report_errors_ubuntu(self): global report_error report = open('./team28/dot.txt', 'w') report.write(report_error.get_report(ErrorController().getList())) report.close() os.system('dot -Tpdf ./team28/dot.txt -o ./team28/error.pdf') os.system('xdg-open ./team28/error.pdf') def report_errors_windows(self): global report_error report = open('dot.txt', 'w') report.write(report_error.get_report(ErrorController().getList())) report.close() os.system('dot -Tpdf dot.txt -o error.pdf') os.startfile('error.pdf') def report_ast_windows(self): global report_ast graficadora = GraficarAST() report = open('dot.txt', 'w') report.write(graficadora.generate_string(report_ast)) report.close() os.system('dot -Tpdf dot.txt -o ast.pdf') os.startfile('ast.pdf') # Para salir de la aplicacion def terminar(self): salir = messagebox.askokcancel("Salir", "Está seguro que desea salir?") if salir: self.ventana.destroy() return if __name__ == '__main__': root = Tk() app = GUI(root) root.mainloop()
44.146119
139
0.571473
4a244bc85448579584e18926043ee1fbf60fdeb0
1,394
py
Python
src/utils/image.py
paulwarkentin/pytorch-neural-doodle
4b0c8da17351ef1662a0ce0bf5979027bafb130e
[ "MIT" ]
15
2018-10-07T14:54:33.000Z
2021-10-09T11:22:14.000Z
src/utils/image.py
paulwarkentin/pytorch-neural-doodle
4b0c8da17351ef1662a0ce0bf5979027bafb130e
[ "MIT" ]
null
null
null
src/utils/image.py
paulwarkentin/pytorch-neural-doodle
4b0c8da17351ef1662a0ce0bf5979027bafb130e
[ "MIT" ]
2
2019-05-31T19:27:38.000Z
2020-01-08T15:02:12.000Z
## ## pytorch-neural-doodle/src/utils/image.py ## ## Created by Bastian Boll <[email protected]> on 29/08/2018. ## Updated by Bastian Boll <[email protected]> on 06/10/2018. import os.path import numpy as np import sys import torch from skimage import io __exec_dir = sys.path[0] while os.path.basename(__exec_dir) != "src": __exec_dir = os.path.dirname(__exec_dir) sys.path.insert(0, __exec_dir) from utils.common.logging import logging_error def load(filepath, device=torch.device("cpu")): """Load image from filepath as tensor. Arguments: filepath (string): Path to image. device (torch device): Device on which to allocate the image tensor. Returns: Tensor of image content with shape (1, channels, height, width). """ if not os.path.isfile(filepath): logging_error("File {} does not exist.".format(filepath), should_exit = True) image = io.imread(filepath).transpose((2, 0, 1)) / (256.0 / 2.0) - 1.0 return torch.from_numpy(image).double().unsqueeze(0).to(device) def save(filepath, image): """Save a given tensor to a filepath. Arguments: filepath (string): Path to save to. image (tensor): Image to be saved. """ image = image.detach().cpu().numpy() _, channels, height, width = image.shape image = image.reshape((channels, height, width)).transpose((1, 2, 0)) image = (image + 1.0) * (256.0 / 2.0) io.imsave(filepath, image.astype("uint8"))
27.88
79
0.699426
4a244c075211f46d8a2f7dfb71c69fcd811f42c5
12,855
py
Python
utils/smiles_similarity_new_weighted.py
BioSysLab/TF-platform
358bf8846d32bc3b69e86332f476a8211364546b
[ "MIT" ]
null
null
null
utils/smiles_similarity_new_weighted.py
BioSysLab/TF-platform
358bf8846d32bc3b69e86332f476a8211364546b
[ "MIT" ]
null
null
null
utils/smiles_similarity_new_weighted.py
BioSysLab/TF-platform
358bf8846d32bc3b69e86332f476a8211364546b
[ "MIT" ]
1
2020-06-09T13:59:25.000Z
2020-06-09T13:59:25.000Z
import urllib import os import numpy as np import pandas as pd import sys from sys import getsizeof import scipy from scipy import stats import csv #import rdkit from rdkit import Chem from rdkit import DataStructs from rdkit.Chem import Draw from rdkit.Chem.rdmolfiles import SDMolSupplier from rdkit.Chem.Fingerprints import FingerprintMols # -*- coding: utf-8 -*- """ Created on Thu May 16 11:32:13 2019 @author: sofia """ def sim_two_serial(): #Load Data----------------------------------------------------------------------- path1 = input("Path for list 1: ") path2= input("Path for list 2: ") smis1=pd.read_csv(path1) smis1=smis1["smiles"] smis2=pd.read_csv(path2) smis2=smis2["smiles"] l1=len(smis1) l2=len(smis2) l=l1*l2 lp=round(l/20) #Get molecules from smiles----------------------------------------------------------------------- bad1=[] molecules1=[] for i,smi in enumerate(smis1): m=Chem.MolFromSmiles(smi) if m is None: print('smile with number:',i,'in list 1 could not be converted to molecule') bad1.append(i) continue molecules1.append(m) bad2=[] molecules2=[] for i,smi in enumerate(smis2): m = Chem.MolFromSmiles(smi) if m is None: print('smile with number:',i,'in list 2 could not be converted to molecule') bad2.append(i) continue molecules2.append(m) #can1=[Chem.MolToSmiles(x) for x in molecules1] #can2=[Chem.MolToSmiles(x) for x in molecules2] #for j in bad1: #can1.insert(j,"bad1") #for j in bad2: #can2.insert(j,"bad2") smis1=[] smis2=[] #Final output matrix----------------------------------------------------------------------- similarity=np.zeros(shape=(l1,l2),dtype=np.float32) from rdkit.Chem import MACCSkeys from rdkit.Chem.AtomPairs import Pairs from rdkit.Chem.AtomPairs import Torsions from rdkit.Chem import AllChem print('Begining fingerprint calculation...wait') fps_topol1=[FingerprintMols.FingerprintMol(x) for x in molecules1] fps_maccs1=[MACCSkeys.GenMACCSKeys(x) for x in molecules1] fps_pairs1 = [Pairs.GetAtomPairFingerprint(x) for x in molecules1] fps_tts1 = [Torsions.GetTopologicalTorsionFingerprintAsIntVect(x) for x in molecules1] fps_ecfp4_1 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024) for x in molecules1] fps_ecfp6_1 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024) for x in molecules1] fps_fcfp4_1 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024,useFeatures=True) for x in molecules1] fps_fcfp6_1 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024,useFeatures=True) for x in molecules1] print('Begining fingerprint calculation...50%') fps_topol2=[FingerprintMols.FingerprintMol(x) for x in molecules2] fps_maccs2=[MACCSkeys.GenMACCSKeys(x) for x in molecules2] fps_pairs2 = [Pairs.GetAtomPairFingerprint(x) for x in molecules2] fps_tts2 = [Torsions.GetTopologicalTorsionFingerprintAsIntVect(x) for x in molecules2] fps_ecfp4_2 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024) for x in molecules2] fps_ecfp6_2 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024) for x in molecules2] fps_fcfp4_2 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024,useFeatures=True) for x in molecules2] fps_fcfp6_2 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024,useFeatures=True) for x in molecules2] print('Begining fingerprint calculation...done\n') for j in bad1: fps_topol1.insert(j,1) fps_maccs1.insert(j,1) fps_pairs1.insert(j,1) fps_tts1.insert(j,1) fps_ecfp4_1.insert(j,1) fps_ecfp6_1.insert(j,1) fps_fcfp4_1.insert(j,1) fps_fcfp6_1.insert(j,1) for j in bad2: fps_topol2.insert(j,1) fps_maccs2.insert(j,1) fps_pairs2.insert(j,1) fps_tts2.insert(j,1) fps_ecfp4_2.insert(j,1) fps_ecfp6_2.insert(j,1) fps_fcfp4_2.insert(j,1) fps_fcfp6_2.insert(j,1) print('Begining of fingerprints similarity calculation\n') molecules1=[] molecules2=[] k=0 maxs=2/(0.65*10)+2/(0.6*10)+2/(0.7*10)+1/(0.75*5)+1/(0.85*5) for i in range(l1): for j in range(l2): if not((i in bad1) or (j in bad2)): similarities_topol=DataStructs.FingerprintSimilarity(fps_topol1[i],fps_topol2[j]) similarities_maccs=DataStructs.FingerprintSimilarity(fps_maccs1[i],fps_maccs2[j]) similarities_pairs=DataStructs.DiceSimilarity(fps_pairs1[i],fps_pairs2[j]) similarities_tts=DataStructs.DiceSimilarity(fps_tts1[i],fps_tts2[j]) similarities_ecfp4=DataStructs.FingerprintSimilarity(fps_ecfp4_1[i],fps_ecfp4_2[j]) similarities_ecfp6=DataStructs.FingerprintSimilarity(fps_ecfp6_1[i],fps_ecfp6_2[j]) similarities_fcfp4=DataStructs.FingerprintSimilarity(fps_fcfp4_1[i],fps_fcfp4_2[j]) similarities_fcfp6=DataStructs.FingerprintSimilarity(fps_fcfp6_1[i],fps_fcfp6_2[j]) similarity[i][j]=(0.5*(similarities_ecfp4/0.65+similarities_ecfp6/0.6)+0.5*(similarities_fcfp4/0.65+similarities_fcfp6/0.6)+0.5*(similarities_tts/0.7+similarities_pairs/0.7)+similarities_maccs/0.85+similarities_topol/0.75)/5 k=k+1 if k%lp==0: print('running:',(k/l)*100,'%') #for other similarity metrics use for example DataStructs.FingerprintSimilarity(fps[0],fps[1], metric=DataStructs.DiceSimilarity) similarity=similarity/maxs similarity[bad1,:]=10 similarity[:,bad2]=10 print('End of fingerprints similarity calculation') bad1=[] bad2=[] df_similarity = pd.DataFrame(similarity) similarity=[] return df_similarity def sim_one_serial(): #Load Data----------------------------------------------------------------------- path=input("Path for list : ") smis=pd.read_csv(path) smis=smis["smiles"] l=len(smis) lp=round(l*l/20) #Get molecules from smiles----------------------------------------------------------------------- bad=[] molecules=[] for i,smi in enumerate(smis): m = Chem.MolFromSmiles(smi) if m is None: print('smile with number:',i,'in list could not be converted to molecule') bad.append(i) continue molecules.append(m) #can=[Chem.MolToSmiles(x) for x in molecules] #for j in bad: #can.insert(j,"bad") smis=[] #Final output matrix----------------------------------------------------------------------- similarity=np.zeros(shape=(l,l),dtype=np.float32) from rdkit.Chem import MACCSkeys from rdkit.Chem.AtomPairs import Pairs from rdkit.Chem.AtomPairs import Torsions from rdkit.Chem import AllChem print('Begining fingerprint calculation...wait') fps_topol=[FingerprintMols.FingerprintMol(x) for x in molecules] fps_maccs=[MACCSkeys.GenMACCSKeys(x) for x in molecules] fps_pairs = [Pairs.GetAtomPairFingerprint(x) for x in molecules] fps_tts = [Torsions.GetTopologicalTorsionFingerprintAsIntVect(x) for x in molecules] fps_ecfp4 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024) for x in molecules] fps_ecfp6 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024) for x in molecules] fps_fcfp4 = [AllChem.GetMorganFingerprintAsBitVect(x,2,nBits=1024,useFeatures=True) for x in molecules] fps_fcfp6 = [AllChem.GetMorganFingerprintAsBitVect(x,3,nBits=1024,useFeatures=True) for x in molecules] print('Begining fingerprint calculation...done\n') for j in bad: fps_topol.insert(j,1) fps_maccs.insert(j,1) fps_pairs.insert(j,1) fps_tts.insert(j,1) fps_ecfp4.insert(j,1) fps_ecfp6.insert(j,1) fps_fcfp4.insert(j,1) fps_fcfp6.insert(j,1) #molecules=[] print('Begining of fingerprints similarity calculation\n') k=0 maxs=2/(0.65*10)+2/(0.6*10)+2/(0.7*10)+1/(0.75*5)+1/(0.85*5) for i in range(l): for j in range(l): if i>=j: if not((i in bad) or (j in bad)): similarities_topol=DataStructs.FingerprintSimilarity(fps_topol[i],fps_topol[j]) similarities_maccs=DataStructs.FingerprintSimilarity(fps_maccs[i],fps_maccs[j]) similarities_pairs=DataStructs.DiceSimilarity(fps_pairs[i],fps_pairs[j]) similarities_tts=DataStructs.DiceSimilarity(fps_tts[i],fps_tts[j]) similarities_ecfp4=DataStructs.FingerprintSimilarity(fps_ecfp4[i],fps_ecfp4[j]) similarities_ecfp6=DataStructs.FingerprintSimilarity(fps_ecfp6[i],fps_ecfp6[j]) similarities_fcfp4=DataStructs.FingerprintSimilarity(fps_fcfp4[i],fps_fcfp4[j]) similarities_fcfp6=DataStructs.FingerprintSimilarity(fps_fcfp6[i],fps_fcfp6[j]) similarity[i][j]=(0.5*(similarities_ecfp4/0.65+similarities_ecfp6/0.6)+0.5*(similarities_fcfp4/0.65+similarities_fcfp6/0.6)+0.5*(similarities_tts/0.7+similarities_pairs/0.7)+similarities_maccs/0.85+similarities_topol/0.75)/5 similarity[j][i]=similarity[i][j] k=k+1 if k%lp==0: print('running:',(k/(l*l/2))*100,'%') #for other similarity metrics use for example DataStructs.FingerprintSimilarity(fps[0],fps[1], metric=DataStructs.DiceSimilarity) similarity=similarity/maxs similarity[bad,:]=10 similarity[:,bad]=10 print('End of fingerprints similarity calculation') bad=[] df_similarity = pd.DataFrame(similarity) similarity=[] return df_similarity print('Welcome to NTUA BIOSYS LAB compound similarity script') user="wrong" print('Enter user customization: Advanced or Default\n') while ((user!='A') and (user!='D')): user=input("Enter A or D: ") if ((user!='A') and (user!='D')): print('Fatal error input,enter again') nol=3 print('Choose to compare:') print('[1].All compounds in one list') print('[2].Two lists of compounds') while ((nol!=1) and (nol!=2)): nol=int(input("Enter 1 or 2: "),10) if ((nol!=1) and (nol!=2)): print('Fatal error input,enter again') out=input("Enter path/filename for outpout file [name.csv]: ") if (user=='A'): print('Choose running setup:') run=int(input("Enter 1 for Serial or 2 for Parallel :"),10) if (nol==1): df_similarity=sim_one_serial() #Write in csv-------------------------------------- print('Saving results in csv...') df_similarity.to_csv(out) print('END') else: if (run==1): df_similarity=sim_two_serial() #Write in csv-------------------------------------- print('Saving results in csv...') df_similarity.to_csv(out) print('END') elif (run==2): import multiprocessing as mp from rdkit.Chem import MACCSkeys from rdkit.Chem.AtomPairs import Pairs from rdkit.Chem.AtomPairs import Torsions from rdkit.Chem import AllChem ncpu=mp.cpu_count() print('Number of CPUs core: ',ncpu) ncpu=int(input('Choose number of CPUs-workers: '),10) # Step 1: Init multiprocessing.Pool()---------------------- #pool = mp.Pool(ncpu) while (ncpu>mp.cpu_count()): print('Too many workers!! The max is: ',mp.cpu_count()) ncpu=int(input('Choose number of CPUs-workers: '),10) #if (ncpu!=8): #sys.exit('sorry for know it works only with 8 cores!!') # Step 2: `pool.apply` the `howmany_within_range()` #results = [pool.apply(sim_two_parallel, args=(sim_ind)) for sim_ind in range(1,9)] # Step 3: Don't forget to close #pool.close() print('No parallel section yet!Sorry coming soon!') print('END') else: run=1 if (nol==1): df_similarity=sim_one_serial() #Write in csv-------------------------------------- print('Saving results in csv...') df_similarity.to_csv(out) print('END') else: if (run==1): df_similarity=sim_two_serial() #Write in csv-------------------------------------- print('Saving results in csv...') df_similarity.to_csv(out) print('END') elif (run==2): import multiprocessing as mp ncpu=mp.cpu_count() print('Number of CPUs core: ',ncpu) ncpu=int(input('Choose number of CPUs-workers: '),10) print('No parallel section yet!Sorry coming soon!') print('END')
40.297806
244
0.620848
4a244c7b006e588ac9cf717b8459619195de02f0
216
py
Python
core/cart/__init__.py
yezz123/Apollo
f27a655a6a5ee9186867b380840411feca21290f
[ "MIT" ]
18
2021-07-28T22:01:48.000Z
2022-02-07T10:57:21.000Z
core/cart/__init__.py
yezz123/Apollo
f27a655a6a5ee9186867b380840411feca21290f
[ "MIT" ]
null
null
null
core/cart/__init__.py
yezz123/Apollo
f27a655a6a5ee9186867b380840411feca21290f
[ "MIT" ]
5
2021-07-29T01:47:28.000Z
2022-01-05T02:04:54.000Z
#!/usr/bin/python3 from sqlalchemy.orm import Session from fastapi import APIRouter, Depends, HTTPException from data import database from schemas import schemas from api import crud from data.database import get_db
27
53
0.833333
4a244e27d6565925596281b8723ef145ef127aa6
2,614
py
Python
telegram_gcloner/handlers/contact.py
winkxx/telegram_gcloner
ab0c0e28fb09fc475bd4dd69677c0a4b29b24e56
[ "MIT" ]
213
2020-06-25T08:58:06.000Z
2022-03-24T12:44:18.000Z
telegram_gcloner/handlers/contact.py
winkxx/telegram_gcloner
ab0c0e28fb09fc475bd4dd69677c0a4b29b24e56
[ "MIT" ]
4
2020-06-26T22:52:28.000Z
2020-09-29T20:22:44.000Z
telegram_gcloner/handlers/contact.py
winkxx/telegram_gcloner
ab0c0e28fb09fc475bd4dd69677c0a4b29b24e56
[ "MIT" ]
101
2020-06-25T10:42:34.000Z
2022-01-16T13:22:36.000Z
#!/usr/bin/python3 # -*- coding: utf-8 -*- import html import logging from telegram import ParseMode from telegram.ext import Dispatcher, CommandHandler from telegram.utils.helpers import mention_html from utils.callback import callback_delete_message from utils.config_loader import config from utils.restricted import restricted_private logger = logging.getLogger(__name__) def init(dispatcher: Dispatcher): """Provide handlers initialization.""" dispatcher.add_handler(CommandHandler('4999baoyue', contact, pass_args=True)) @restricted_private def contact(update, context): text = update.message.text.strip('/4999baoyue') if text: context.bot.send_message(chat_id=config.USER_IDS[0], text='Received message from {} ({}):'.format( mention_html(update.effective_user.id, html.escape(update.effective_user.name)), update.effective_user.id), parse_mode=ParseMode.HTML) context.bot.forward_message(chat_id=config.USER_IDS[0], from_chat_id=update.message.chat_id, message_id=update.message.message_id) logger.info('{} ({}) left a message: {}'.format(update.effective_user.name, update.effective_user.id, text)) rsp = update.message.reply_text('收到。') rsp.done.wait(timeout=60) message_id = rsp.result().message_id if update.message.chat_id < 0: context.job_queue.run_once(callback_delete_message, config.TIMER_TO_DELETE_MESSAGE, context=(update.message.chat_id, message_id)) context.job_queue.run_once(callback_delete_message, config.TIMER_TO_DELETE_MESSAGE, context=(update.message.chat_id, update.message.message_id)) else: rsp = update.message.reply_text('这么害羞,不说点啥?\n' + config.AD_STRING.format(context.bot.username), ParseMode.HTML) rsp.done.wait(timeout=60) message_id = rsp.result().message_id if update.message.chat_id < 0: context.job_queue.run_once(callback_delete_message, config.TIMER_TO_DELETE_MESSAGE, context=(update.message.chat_id, message_id)) context.job_queue.run_once(callback_delete_message, config.TIMER_TO_DELETE_MESSAGE, context=(update.message.chat_id, update.message.message_id))
48.407407
117
0.625096
4a244edf6966017a575d46b9c42d92c7e0f53396
7,282
py
Python
jni-build/jni/include/tensorflow/contrib/metrics/__init__.py
rcelebi/android-elfali
4ea14a58a18356ef9e16aba2e7dae84c02afba12
[ "Apache-2.0" ]
680
2016-12-03T14:38:28.000Z
2022-02-16T04:06:45.000Z
jni-build/jni/include/tensorflow/contrib/metrics/__init__.py
rcelebi/android-elfali
4ea14a58a18356ef9e16aba2e7dae84c02afba12
[ "Apache-2.0" ]
38
2016-11-17T08:43:51.000Z
2019-11-12T12:27:04.000Z
jni-build/jni/include/tensorflow/contrib/metrics/__init__.py
rcelebi/android-elfali
4ea14a58a18356ef9e16aba2e7dae84c02afba12
[ "Apache-2.0" ]
250
2016-12-05T10:37:17.000Z
2022-03-18T21:26:55.000Z
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """##Ops for evaluation metrics and summary statistics. ### API This module provides functions for computing streaming metrics: metrics computed on dynamically valued `Tensors`. Each metric declaration returns a "value_tensor", an idempotent operation that returns the current value of the metric, and an "update_op", an operation that accumulates the information from the current value of the `Tensors` being measured as well as returns the value of the "value_tensor". To use any of these metrics, one need only declare the metric, call `update_op` repeatedly to accumulate data over the desired number of `Tensor` values (often each one is a single batch) and finally evaluate the value_tensor. For example, to use the `streaming_mean`: ```python value = ... mean_value, update_op = tf.contrib.metrics.streaming_mean(values) sess.run(tf.initialize_local_variables()) for i in range(number_of_batches): print('Mean after batch %d: %f' % (i, update_op.eval()) print('Final Mean: %f' % mean_value.eval()) ``` Each metric function adds nodes to the graph that hold the state necessary to compute the value of the metric as well as a set of operations that actually perform the computation. Every metric evaluation is composed of three steps * Initialization: initializing the metric state. * Aggregation: updating the values of the metric state. * Finalization: computing the final metric value. In the above example, calling streaming_mean creates a pair of state variables that will contain (1) the running sum and (2) the count of the number of samples in the sum. Because the streaming metrics use local variables, the Initialization stage is performed by running the op returned by `tf.initialize_local_variables()`. It sets the sum and count variables to zero. Next, Aggregation is performed by examining the current state of `values` and incrementing the state variables appropriately. This step is executed by running the `update_op` returned by the metric. Finally, finalization is performed by evaluating the "value_tensor" In practice, we commonly want to evaluate across many batches and multiple metrics. To do so, we need only run the metric computation operations multiple times: ```python labels = ... predictions = ... accuracy, update_op_acc = tf.contrib.metrics.streaming_accuracy( labels, predictions) error, update_op_error = tf.contrib.metrics.streaming_mean_absolute_error( labels, predictions) sess.run(tf.initialize_local_variables()) for batch in range(num_batches): sess.run([update_op_acc, update_op_error]) accuracy, mean_absolute_error = sess.run([accuracy, mean_absolute_error]) ``` Note that when evaluating the same metric multiple times on different inputs, one must specify the scope of each metric to avoid accumulating the results together: ```python labels = ... predictions0 = ... predictions1 = ... accuracy0 = tf.contrib.metrics.accuracy(labels, predictions0, name='preds0') accuracy1 = tf.contrib.metrics.accuracy(labels, predictions1, name='preds1') ``` Certain metrics, such as streaming_mean or streaming_accuracy, can be weighted via a `weights` argument. The `weights` tensor must be the same size as the labels and predictions tensors and results in a weighted average of the metric. Other metrics, such as streaming_recall, streaming_precision, and streaming_auc, are not well defined with regard to weighted samples. However, a binary `ignore_mask` argument can be used to ignore certain values at graph executation time. ## Metric `Ops` @@streaming_accuracy @@streaming_mean @@streaming_recall @@streaming_precision @@streaming_auc @@streaming_recall_at_k @@streaming_mean_absolute_error @@streaming_mean_iou @@streaming_mean_relative_error @@streaming_mean_squared_error @@streaming_root_mean_squared_error @@streaming_mean_cosine_distance @@streaming_percentage_less @@streaming_sparse_precision_at_k @@streaming_sparse_recall_at_k @@auc_using_histogram @@accuracy @@confusion_matrix @@aggregate_metrics @@aggregate_metric_map ## Set `Ops` @@set_difference @@set_intersection @@set_size @@set_union """ from __future__ import absolute_import from __future__ import division from __future__ import print_function # pylint: disable=unused-import,line-too-long,g-importing-member,wildcard-import from tensorflow.contrib.metrics.python.metrics import * from tensorflow.contrib.metrics.python.ops.confusion_matrix_ops import confusion_matrix from tensorflow.contrib.metrics.python.ops.histogram_ops import auc_using_histogram from tensorflow.contrib.metrics.python.ops.metric_ops import aggregate_metric_map from tensorflow.contrib.metrics.python.ops.metric_ops import aggregate_metrics from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_accuracy from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_auc from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_absolute_error from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_cosine_distance from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_iou from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_relative_error from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_squared_error from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_mean_tensor from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_percentage_less from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_precision from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_precision_at_thresholds from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_recall from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_recall_at_k from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_recall_at_thresholds from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_root_mean_squared_error from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_sparse_precision_at_k from tensorflow.contrib.metrics.python.ops.metric_ops import streaming_sparse_recall_at_k from tensorflow.contrib.metrics.python.ops.set_ops import set_difference from tensorflow.contrib.metrics.python.ops.set_ops import set_intersection from tensorflow.contrib.metrics.python.ops.set_ops import set_size from tensorflow.contrib.metrics.python.ops.set_ops import set_union from tensorflow.python.util.all_util import make_all __all__ = make_all(__name__)
42.337209
94
0.815298
4a2450ee7d2b0696e758438da41654d8a76519f4
2,116
py
Python
index_data.py
tonystratum/FashionShopApp
34d34fc5855ab7b593855c2f07a4808689365e09
[ "MIT" ]
30
2020-06-22T11:46:41.000Z
2021-12-17T11:29:35.000Z
index_data.py
tonystratum/FashionShopApp
34d34fc5855ab7b593855c2f07a4808689365e09
[ "MIT" ]
3
2020-07-15T12:51:42.000Z
2021-06-10T18:25:47.000Z
index_data.py
tonystratum/FashionShopApp
34d34fc5855ab7b593855c2f07a4808689365e09
[ "MIT" ]
16
2020-06-22T13:01:25.000Z
2021-06-15T10:18:31.000Z
# Test for search function import csv # data_list = [["id","title","description","price","image_file","type"], # [1,"Shirt 1", "Shirt for men",11, 'img-1.jpg',"Women"], # [2,"Shirt 2", "Shirt for men",12, 'img-1.jpg',"Women"], # [3,"Shirt 3", "Shirt for men",13, 'img-1.jpg',"Women"], # [4,"Shirt 4", "Shirt for men",14, 'img-1.jpg',"Women"], # [5,"Shirt 5", "Shirt for men",15, 'img-1.jpg',"Women"], # [6,"Shirt 6", "Shirt for men",16, 'img-1.jpg',"Women"], # [7,"Shirt 7", "Shirt for men",17, 'img-1.jpg',"Women"], # [8,"Shirt 8", "Shirt for men",18, 'img-1.jpg',"Women"], # [9,"Shirt 9", "Shirt for men",19, 'img-1.jpg',"Women"], # [10,"Shirt 10", "Shirt for men",110, 'img-1.jpg',"Women"], # [11,"Shirt 11 ", "Shirt for men",111, 'img-1.jpg',"Women"], # [12,"Shirt 12", "Shirt for men",112, 'img-1.jpg',"Women"], # [13,"Shirt 13", "Shirt for men",113, 'img-1.jpg',"Women"], # [14,"Shirt 14", "Shirt for men",114, 'img-1.jpg',"Women"], # [15,"Shirt 15", "Shirt for men",115, 'img-1.jpg',"Women"], # ] # with open('index_data.csv','w', newline='') as file: # writer = csv.writer(file) # writer.writerows(data_list) import os import pandas as pd from fashionshop import es # from fashionshop import es import requests csv_file = pd.read_csv('products_data.csv') search_file = pd.concat([csv_file['title'], csv_file['description']], axis = 1) print(search_file) # r = requests.get('http://localhost:9200') # print(r.content) index_name = 'fashionshop' doc_type = 'product' for i, t in enumerate(search_file['title']): # print(i,t) s = es.index(index = index_name, doc_type = doc_type, id = i, body = {'title': t}) print(s) product = es.get(index= index_name, doc_type = doc_type, id = 10) print(product) query = es.search(index = index_name, body={'query':{'match': {'title':'1'}}}) print(query['hits']['total']) print(query['hits']['hits'])
48.090909
87
0.548677
4a2454c44f1143fdf77f448f7aea9d2d18a0bc79
50,213
py
Python
scripts/compute_tides_ICESat2_ATL03.py
mcuttler/pyTMD
40ec2ec4c170c821a2558f52c1aeac6c5f9dfeff
[ "MIT" ]
null
null
null
scripts/compute_tides_ICESat2_ATL03.py
mcuttler/pyTMD
40ec2ec4c170c821a2558f52c1aeac6c5f9dfeff
[ "MIT" ]
null
null
null
scripts/compute_tides_ICESat2_ATL03.py
mcuttler/pyTMD
40ec2ec4c170c821a2558f52c1aeac6c5f9dfeff
[ "MIT" ]
null
null
null
#!/usr/bin/env python u""" compute_tides_ICESat2_ATL03.py Written by Tyler Sutterley (06/2021) Calculates tidal elevations for correcting ICESat-2 photon height data Calculated at ATL03 segment level using reference photon geolocation and time Segment level corrections can be applied to the individual photon events (PEs) Uses OTIS format tidal solutions provided by Ohio State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ Global Tide Model (GOT) solutions provided by Richard Ray at GSFC or Finite Element Solution (FES) models provided by AVISO COMMAND LINE OPTIONS: -D X, --directory X: Working data directory -T X, --tide X: Tide model to use in correction CATS0201 CATS2008 CATS2008_load TPXO9-atlas TPXO9-atlas-v2 TPXO9-atlas-v3 TPXO9-atlas-v4 TPXO9.1 TPXO8-atlas TPXO7.2 TPXO7.2_load AODTM-5 AOTIM-5 AOTIM-5-2018 Gr1km-v2 GOT4.7 GOT4.7_load GOT4.8 GOT4.8_load GOT4.10 GOT4.10_load FES2014 FES2014_load -I X, --interpolate X: Interpolation method spline linear nearest bilinear -E X, --extrapolate X: Extrapolate with nearest-neighbors -c X, --cutoff X: Extrapolation cutoff in kilometers set to inf to extrapolate for all points -M X, --mode X: Permission mode of directories and files created -V, --verbose: Output information about each created file PYTHON DEPENDENCIES: numpy: Scientific Computing Tools For Python https://numpy.org https://numpy.org/doc/stable/user/numpy-for-matlab-users.html scipy: Scientific Tools for Python https://docs.scipy.org/doc/ h5py: Python interface for Hierarchal Data Format 5 (HDF5) https://www.h5py.org/ pyproj: Python interface to PROJ library https://pypi.org/project/pyproj/ PROGRAM DEPENDENCIES: read_ICESat2_ATL03.py: reads ICESat-2 global geolocated photon data files time.py: utilities for calculating time operations utilities.py: download and management utilities for syncing files calc_astrol_longitudes.py: computes the basic astronomical mean longitudes calc_delta_time.py: calculates difference between universal and dynamic time convert_ll_xy.py: convert lat/lon points to and from projected coordinates infer_minor_corrections.py: return corrections for minor constituents load_constituent.py: loads parameters for a given tidal constituent load_nodal_corrections.py: load the nodal corrections for tidal constituents read_tide_model.py: extract tidal harmonic constants from OTIS tide models read_netcdf_model.py: extract tidal harmonic constants from netcdf models read_GOT_model.py: extract tidal harmonic constants from GSFC GOT models read_FES_model.py: extract tidal harmonic constants from FES tide models bilinear_interp.py: bilinear interpolation of data to coordinates nearest_extrap.py: nearest-neighbor extrapolation of data to coordinates predict_tide_drift.py: predict tidal elevations using harmonic constants UPDATE HISTORY: Updated 06/2021: added new Gr1km-v2 1km Greenland model from ESR Updated 05/2021: added option for extrapolation cutoff in kilometers Updated 04/2021: can use a generically named ATL03 file as input Updated 03/2021: added TPXO9-atlas-v4 in binary OTIS format simplified netcdf inputs to be similar to binary OTIS read program replaced numpy bool/int to prevent deprecation warnings Updated 12/2020: H5py deprecation warning change to use make_scale added valid data extrapolation with nearest_extrap merged time conversion routines into module Updated 11/2020: added model constituents from TPXO9-atlas-v3 Updated 10/2020: using argparse to set command line parameters Updated 08/2020: using builtin time operations. python3 regular expressions Updated 07/2020: added FES2014 and FES2014_load. use merged delta times Updated 06/2020: added version 2 of TPXO9-atlas (TPXO9-atlas-v2) Updated 03/2020: use read_ICESat2_ATL03.py from read-ICESat-2 repository Updated 02/2020: changed CATS2008 grid to match version on U.S. Antarctic Program Data Center http://www.usap-dc.org/view/dataset/601235 Updated 11/2019: calculate minor constituents as separate variable added AOTIM-5-2018 tide model (2018 update to 2004 model) Updated 10/2019: external read functions. adjust regex for processed files changing Y/N flags to True/False Updated 09/2019: using date functions paralleling public repository add option for TPXO9-atlas. add OTIS netcdf tide option Written 04/2019 """ from __future__ import print_function import sys import os import re import h5py import argparse import datetime import numpy as np import pyTMD.time import pyTMD.utilities from pyTMD.calc_delta_time import calc_delta_time from pyTMD.read_tide_model import extract_tidal_constants from pyTMD.read_netcdf_model import extract_netcdf_constants from pyTMD.read_GOT_model import extract_GOT_constants from pyTMD.read_FES_model import extract_FES_constants from pyTMD.infer_minor_corrections import infer_minor_corrections from pyTMD.predict_tide_drift import predict_tide_drift from icesat2_toolkit.read_ICESat2_ATL03 import read_HDF5_ATL03_main, \ read_HDF5_ATL03_beam #-- PURPOSE: read ICESat-2 geolocated photon data (ATL03) from NSIDC #-- compute tides at points and times using tidal model driver algorithms def compute_tides_ICESat2(tide_dir, INPUT_FILE, TIDE_MODEL=None, METHOD='spline', EXTRAPOLATE=False, CUTOFF=None, VERBOSE=False, MODE=0o775): #-- select between tide models if (TIDE_MODEL == 'CATS0201'): grid_file = os.path.join(tide_dir,'cats0201_tmd','grid_CATS') model_file = os.path.join(tide_dir,'cats0201_tmd','h0_CATS02_01') reference = 'https://mail.esr.org/polar_tide_models/Model_CATS0201.html' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'CATS2008'): grid_file = os.path.join(tide_dir,'CATS2008','grid_CATS2008') model_file = os.path.join(tide_dir,'CATS2008','hf.CATS2008.out') reference = ('https://www.esr.org/research/polar-tide-models/' 'list-of-polar-tide-models/cats2008/') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = 'CATS2008' TYPE = 'z' elif (TIDE_MODEL == 'CATS2008_load'): grid_file = os.path.join(tide_dir,'CATS2008a_SPOTL_Load','grid_CATS2008a_opt') model_file = os.path.join(tide_dir,'CATS2008a_SPOTL_Load','h_CATS2008a_SPOTL_load') reference = ('https://www.esr.org/research/polar-tide-models/' 'list-of-polar-tide-models/cats2008/') variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'OTIS' EPSG = 'CATS2008' TYPE = 'z' elif (TIDE_MODEL == 'TPXO9-atlas'): model_directory = os.path.join(tide_dir,'TPXO9_atlas') grid_file = os.path.join(model_directory,'grid_tpxo9_atlas.nc.gz') model_files = ['h_q1_tpxo9_atlas_30.nc.gz','h_o1_tpxo9_atlas_30.nc.gz', 'h_p1_tpxo9_atlas_30.nc.gz','h_k1_tpxo9_atlas_30.nc.gz', 'h_n2_tpxo9_atlas_30.nc.gz','h_m2_tpxo9_atlas_30.nc.gz', 'h_s2_tpxo9_atlas_30.nc.gz','h_k2_tpxo9_atlas_30.nc.gz', 'h_m4_tpxo9_atlas_30.nc.gz','h_ms4_tpxo9_atlas_30.nc.gz', 'h_mn4_tpxo9_atlas_30.nc.gz','h_2n2_tpxo9_atlas_30.nc.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] reference = 'http://volkov.oce.orst.edu/tides/tpxo9_atlas.html' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'netcdf' TYPE = 'z' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'TPXO9-atlas-v2'): model_directory = os.path.join(tide_dir,'TPXO9_atlas_v2') grid_file = os.path.join(model_directory,'grid_tpxo9_atlas_30_v2.nc.gz') model_files = ['h_q1_tpxo9_atlas_30_v2.nc.gz','h_o1_tpxo9_atlas_30_v2.nc.gz', 'h_p1_tpxo9_atlas_30_v2.nc.gz','h_k1_tpxo9_atlas_30_v2.nc.gz', 'h_n2_tpxo9_atlas_30_v2.nc.gz','h_m2_tpxo9_atlas_30_v2.nc.gz', 'h_s2_tpxo9_atlas_30_v2.nc.gz','h_k2_tpxo9_atlas_30_v2.nc.gz', 'h_m4_tpxo9_atlas_30_v2.nc.gz','h_ms4_tpxo9_atlas_30_v2.nc.gz', 'h_mn4_tpxo9_atlas_30_v2.nc.gz','h_2n2_tpxo9_atlas_30_v2.nc.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] reference = 'https://www.tpxo.net/global/tpxo9-atlas' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'netcdf' TYPE = 'z' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'TPXO9-atlas-v3'): model_directory = os.path.join(tide_dir,'TPXO9_atlas_v3') grid_file = os.path.join(model_directory,'grid_tpxo9_atlas_30_v3.nc.gz') model_files = ['h_q1_tpxo9_atlas_30_v3.nc.gz','h_o1_tpxo9_atlas_30_v3.nc.gz', 'h_p1_tpxo9_atlas_30_v3.nc.gz','h_k1_tpxo9_atlas_30_v3.nc.gz', 'h_n2_tpxo9_atlas_30_v3.nc.gz','h_m2_tpxo9_atlas_30_v3.nc.gz', 'h_s2_tpxo9_atlas_30_v3.nc.gz','h_k2_tpxo9_atlas_30_v3.nc.gz', 'h_m4_tpxo9_atlas_30_v3.nc.gz','h_ms4_tpxo9_atlas_30_v3.nc.gz', 'h_mn4_tpxo9_atlas_30_v3.nc.gz','h_2n2_tpxo9_atlas_30_v3.nc.gz', 'h_mf_tpxo9_atlas_30_v3.nc.gz','h_mm_tpxo9_atlas_30_v3.nc.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] reference = 'https://www.tpxo.net/global/tpxo9-atlas' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'netcdf' TYPE = 'z' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'TPXO9-atlas-v4'): model_directory = os.path.join(tide_dir,'TPXO9_atlas_v4') grid_file = os.path.join(model_directory,'grid_tpxo9_atlas_30_v4') model_files = ['h_q1_tpxo9_atlas_30_v4','h_o1_tpxo9_atlas_30_v4', 'h_p1_tpxo9_atlas_30_v4','h_k1_tpxo9_atlas_30_v4', 'h_n2_tpxo9_atlas_30_v4','h_m2_tpxo9_atlas_30_v4', 'h_s2_tpxo9_atlas_30_v4','h_k2_tpxo9_atlas_30_v4', 'h_m4_tpxo9_atlas_30_v4','h_ms4_tpxo9_atlas_30_v4', 'h_mn4_tpxo9_atlas_30_v4','h_2n2_tpxo9_atlas_30_v4', 'h_mf_tpxo9_atlas_30_v4','h_mm_tpxo9_atlas_30_v4'] model_file = [os.path.join(model_directory,m) for m in model_files] reference = 'https://www.tpxo.net/global/tpxo9-atlas' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'TPXO9.1'): grid_file = os.path.join(tide_dir,'TPXO9.1','DATA','grid_tpxo9') model_file = os.path.join(tide_dir,'TPXO9.1','DATA','h_tpxo9.v1') reference = 'http://volkov.oce.orst.edu/tides/global.html' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'TPXO8-atlas'): grid_file = os.path.join(tide_dir,'tpxo8_atlas','grid_tpxo8atlas_30_v1') model_file = os.path.join(tide_dir,'tpxo8_atlas','hf.tpxo8_atlas_30_v1') reference = 'http://volkov.oce.orst.edu/tides/tpxo8_atlas.html' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'ATLAS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'TPXO7.2'): grid_file = os.path.join(tide_dir,'TPXO7.2_tmd','grid_tpxo7.2') model_file = os.path.join(tide_dir,'TPXO7.2_tmd','h_tpxo7.2') reference = 'http://volkov.oce.orst.edu/tides/global.html' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'TPXO7.2_load'): grid_file = os.path.join(tide_dir,'TPXO7.2_load','grid_tpxo6.2') model_file = os.path.join(tide_dir,'TPXO7.2_load','h_tpxo7.2_load') reference = 'http://volkov.oce.orst.edu/tides/global.html' variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'OTIS' EPSG = '4326' TYPE = 'z' elif (TIDE_MODEL == 'AODTM-5'): grid_file = os.path.join(tide_dir,'aodtm5_tmd','grid_Arc5km') model_file = os.path.join(tide_dir,'aodtm5_tmd','h0_Arc5km.oce') reference = ('https://www.esr.org/research/polar-tide-models/' 'list-of-polar-tide-models/aodtm-5/') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = 'PSNorth' TYPE = 'z' elif (TIDE_MODEL == 'AOTIM-5'): grid_file = os.path.join(tide_dir,'aotim5_tmd','grid_Arc5km') model_file = os.path.join(tide_dir,'aotim5_tmd','h_Arc5km.oce') reference = ('https://www.esr.org/research/polar-tide-models/' 'list-of-polar-tide-models/aotim-5/') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = 'PSNorth' TYPE = 'z' elif (TIDE_MODEL == 'AOTIM-5-2018'): grid_file = os.path.join(tide_dir,'Arc5km2018','grid_Arc5km2018') model_file = os.path.join(tide_dir,'Arc5km2018','h_Arc5km2018') reference = ('https://www.esr.org/research/polar-tide-models/' 'list-of-polar-tide-models/aotim-5/') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = 'PSNorth' TYPE = 'z' elif (TIDE_MODEL == 'Gr1km-v2'): grid_file = os.path.join(tide_dir,'greenlandTMD_v2','grid_Greenland8.v2') model_file = os.path.join(tide_dir,'greenlandTMD_v2','h_Greenland8.v2') reference = 'https://www.esr.org/research/polar-tide-models/' variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'OTIS' EPSG = '3413' TYPE = 'z' elif (TIDE_MODEL == 'GOT4.7'): model_directory = os.path.join(tide_dir,'GOT4.7','grids_oceantide') model_files = ['q1.d.gz','o1.d.gz','p1.d.gz','k1.d.gz','n2.d.gz', 'm2.d.gz','s2.d.gz','k2.d.gz','s1.d.gz','m4.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'GOT' SCALE = 1.0/100.0 GZIP = True elif (TIDE_MODEL == 'GOT4.7_load'): model_directory = os.path.join(tide_dir,'GOT4.7','grids_loadtide') model_files = ['q1load.d.gz','o1load.d.gz','p1load.d.gz','k1load.d.gz', 'n2load.d.gz','m2load.d.gz','s2load.d.gz','k2load.d.gz', 's1load.d.gz','m4load.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'GOT' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'GOT4.8'): model_directory = os.path.join(tide_dir,'got4.8','grids_oceantide') model_files = ['q1.d.gz','o1.d.gz','p1.d.gz','k1.d.gz','n2.d.gz', 'm2.d.gz','s2.d.gz','k2.d.gz','s1.d.gz','m4.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'GOT' SCALE = 1.0/100.0 GZIP = True elif (TIDE_MODEL == 'GOT4.8_load'): model_directory = os.path.join(tide_dir,'got4.8','grids_loadtide') model_files = ['q1load.d.gz','o1load.d.gz','p1load.d.gz','k1load.d.gz', 'n2load.d.gz','m2load.d.gz','s2load.d.gz','k2load.d.gz', 's1load.d.gz','m4load.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'GOT' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'GOT4.10'): model_directory = os.path.join(tide_dir,'GOT4.10c','grids_oceantide') model_files = ['q1.d.gz','o1.d.gz','p1.d.gz','k1.d.gz','n2.d.gz', 'm2.d.gz','s2.d.gz','k2.d.gz','s1.d.gz','m4.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'GOT' SCALE = 1.0/100.0 GZIP = True elif (TIDE_MODEL == 'GOT4.10_load'): model_directory = os.path.join(tide_dir,'GOT4.10c','grids_loadtide') model_files = ['q1load.d.gz','o1load.d.gz','p1load.d.gz','k1load.d.gz', 'n2load.d.gz','m2load.d.gz','s2load.d.gz','k2load.d.gz', 's1load.d.gz','m4load.d.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['q1','o1','p1','k1','n2','m2','s2','k2','s1','m4'] reference = ('https://denali.gsfc.nasa.gov/personal_pages/ray/' 'MiscPubs/19990089548_1999150788.pdf') variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'GOT' SCALE = 1.0/1000.0 GZIP = True elif (TIDE_MODEL == 'FES2014'): model_directory = os.path.join(tide_dir,'fes2014','ocean_tide') model_files = ['2n2.nc.gz','eps2.nc.gz','j1.nc.gz','k1.nc.gz', 'k2.nc.gz','l2.nc.gz','la2.nc.gz','m2.nc.gz','m3.nc.gz','m4.nc.gz', 'm6.nc.gz','m8.nc.gz','mf.nc.gz','mks2.nc.gz','mm.nc.gz', 'mn4.nc.gz','ms4.nc.gz','msf.nc.gz','msqm.nc.gz','mtm.nc.gz', 'mu2.nc.gz','n2.nc.gz','n4.nc.gz','nu2.nc.gz','o1.nc.gz','p1.nc.gz', 'q1.nc.gz','r2.nc.gz','s1.nc.gz','s2.nc.gz','s4.nc.gz','sa.nc.gz', 'ssa.nc.gz','t2.nc.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['2n2','eps2','j1','k1','k2','l2','lambda2','m2','m3','m4','m6', 'm8','mf','mks2','mm','mn4','ms4','msf','msqm','mtm','mu2','n2', 'n4','nu2','o1','p1','q1','r2','s1','s2','s4','sa','ssa','t2'] reference = ('https://www.aviso.altimetry.fr/en/data/products' 'auxiliary-products/global-tide-fes.html') variable = 'tide_ocean' long_name = "Ocean Tide" description = ("Ocean Tides including diurnal and semi-diurnal " "(harmonic analysis), and longer period tides (dynamic and " "self-consistent equilibrium).") model_format = 'FES' TYPE = 'z' SCALE = 1.0/100.0 GZIP = True elif (TIDE_MODEL == 'FES2014_load'): model_directory = os.path.join(tide_dir,'fes2014','load_tide') model_files = ['2n2.nc.gz','eps2.nc.gz','j1.nc.gz','k1.nc.gz', 'k2.nc.gz','l2.nc.gz','la2.nc.gz','m2.nc.gz','m3.nc.gz','m4.nc.gz', 'm6.nc.gz','m8.nc.gz','mf.nc.gz','mks2.nc.gz','mm.nc.gz', 'mn4.nc.gz','ms4.nc.gz','msf.nc.gz','msqm.nc.gz','mtm.nc.gz', 'mu2.nc.gz','n2.nc.gz','n4.nc.gz','nu2.nc.gz','o1.nc.gz','p1.nc.gz', 'q1.nc.gz','r2.nc.gz','s1.nc.gz','s2.nc.gz','s4.nc.gz','sa.nc.gz', 'ssa.nc.gz','t2.nc.gz'] model_file = [os.path.join(model_directory,m) for m in model_files] c = ['2n2','eps2','j1','k1','k2','l2','lambda2','m2','m3','m4','m6', 'm8','mf','mks2','mm','mn4','ms4','msf','msqm','mtm','mu2','n2', 'n4','nu2','o1','p1','q1','r2','s1','s2','s4','sa','ssa','t2'] reference = ('https://www.aviso.altimetry.fr/en/data/products' 'auxiliary-products/global-tide-fes.html') variable = 'tide_load' long_name = "Load Tide" description = "Local displacement due to Ocean Loading (-6 to 0 cm)" model_format = 'FES' TYPE = 'z' SCALE = 1.0/100.0 GZIP = True #-- read data from input file print('{0} -->'.format(os.path.basename(INPUT_FILE))) if VERBOSE else None IS2_atl03_mds,IS2_atl03_attrs,IS2_atl03_beams = read_HDF5_ATL03_main(INPUT_FILE, ATTRIBUTES=True) DIRECTORY = os.path.dirname(INPUT_FILE) #-- extract parameters from ICESat-2 ATLAS HDF5 file name rx = re.compile(r'(processed_)?(ATL\d{2})_(\d{4})(\d{2})(\d{2})(\d{2})' r'(\d{2})(\d{2})_(\d{4})(\d{2})(\d{2})_(\d{3})_(\d{2})(.*?).h5$') try: SUB,PRD,YY,MM,DD,HH,MN,SS,TRK,CYCL,GRAN,RL,VERS,AUX = rx.findall(INPUT_FILE).pop() except: #-- output tide HDF5 file (generic) fileBasename,fileExtension = os.path.splitext(INPUT_FILE) args = (fileBasename,TIDE_MODEL,fileExtension) OUTPUT_FILE = '{0}_{1}_TIDES{2}'.format(*args) else: #-- output tide HDF5 file for ASAS/NSIDC granules args = (PRD,TIDE_MODEL,YY,MM,DD,HH,MN,SS,TRK,CYCL,GRAN,RL,VERS,AUX) file_format = '{0}_{1}_TIDES_{2}{3}{4}{5}{6}{7}_{8}{9}{10}_{11}_{12}{13}.h5' OUTPUT_FILE = file_format.format(*args) #-- number of GPS seconds between the GPS epoch #-- and ATLAS Standard Data Product (SDP) epoch atlas_sdp_gps_epoch = IS2_atl03_mds['ancillary_data']['atlas_sdp_gps_epoch'] #-- delta time (TT - UT1) file delta_file = pyTMD.utilities.get_data_path(['data','merged_deltat.data']) #-- copy variables for outputting to HDF5 file IS2_atl03_tide = {} IS2_atl03_fill = {} IS2_atl03_dims = {} IS2_atl03_tide_attrs = {} #-- number of GPS seconds between the GPS epoch (1980-01-06T00:00:00Z UTC) #-- and ATLAS Standard Data Product (SDP) epoch (2018-01-01T00:00:00Z UTC) #-- Add this value to delta time parameters to compute full gps_seconds IS2_atl03_tide['ancillary_data'] = {} IS2_atl03_tide_attrs['ancillary_data'] = {} for key in ['atlas_sdp_gps_epoch']: #-- get each HDF5 variable IS2_atl03_tide['ancillary_data'][key] = IS2_atl03_mds['ancillary_data'][key] #-- Getting attributes of group and included variables IS2_atl03_tide_attrs['ancillary_data'][key] = {} for att_name,att_val in IS2_atl03_attrs['ancillary_data'][key].items(): IS2_atl03_tide_attrs['ancillary_data'][key][att_name] = att_val #-- for each input beam within the file for gtx in sorted(IS2_atl03_beams): #-- output data dictionaries for beam IS2_atl03_tide[gtx] = dict(geolocation={}, geophys_corr={}) IS2_atl03_fill[gtx] = dict(geolocation={}, geophys_corr={}) IS2_atl03_dims[gtx] = dict(geolocation={}, geophys_corr={}) IS2_atl03_tide_attrs[gtx] = dict(geolocation={}, geophys_corr={}) #-- read data and attributes for beam val,attrs = read_HDF5_ATL03_beam(INPUT_FILE,gtx,ATTRIBUTES=True) #-- number of segments n_seg = len(val['geolocation']['segment_id']) #-- extract variables for computing tides segment_id = val['geolocation']['segment_id'].copy() delta_time = val['geolocation']['delta_time'].copy() lon = val['geolocation']['reference_photon_lon'].copy() lat = val['geolocation']['reference_photon_lat'].copy() #-- invalid value fv = attrs['geolocation']['sigma_h']['_FillValue'] #-- convert time from ATLAS SDP to days relative to Jan 1, 1992 gps_seconds = atlas_sdp_gps_epoch + delta_time leap_seconds = pyTMD.time.count_leap_seconds(gps_seconds) tide_time = pyTMD.time.convert_delta_time(gps_seconds-leap_seconds, epoch1=(1980,1,6,0,0,0), epoch2=(1992,1,1,0,0,0), scale=1.0/86400.0) #-- read tidal constants and interpolate to grid points if model_format in ('OTIS','ATLAS'): amp,ph,D,c = extract_tidal_constants(lon, lat, grid_file, model_file, EPSG, TYPE=TYPE, METHOD=METHOD, EXTRAPOLATE=EXTRAPOLATE, CUTOFF=CUTOFF, GRID=model_format) deltat = np.zeros_like(tide_time) elif (model_format == 'netcdf'): amp,ph,D,c = extract_netcdf_constants(lon, lat, grid_file, model_file, TYPE=TYPE, METHOD=METHOD, EXTRAPOLATE=EXTRAPOLATE, CUTOFF=CUTOFF, SCALE=SCALE, GZIP=GZIP) deltat = np.zeros_like(tide_time) elif (model_format == 'GOT'): amp,ph,c = extract_GOT_constants(lon, lat, model_file, METHOD=METHOD, EXTRAPOLATE=EXTRAPOLATE, CUTOFF=CUTOFF, SCALE=SCALE, GZIP=GZIP) #-- interpolate delta times from calendar dates to tide time deltat = calc_delta_time(delta_file, tide_time) elif (model_format == 'FES'): amp,ph = extract_FES_constants(lon, lat, model_file, TYPE=TYPE, VERSION=TIDE_MODEL, METHOD=METHOD, EXTRAPOLATE=EXTRAPOLATE, CUTOFF=CUTOFF, SCALE=SCALE, GZIP=GZIP) #-- interpolate delta times from calendar dates to tide time deltat = calc_delta_time(delta_file, tide_time) #-- calculate complex phase in radians for Euler's cph = -1j*ph*np.pi/180.0 #-- calculate constituent oscillation hc = amp*np.exp(cph) #-- predict tidal elevations at time and infer minor corrections tide = np.ma.empty((n_seg),fill_value=fv) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = predict_tide_drift(tide_time, hc, c, DELTAT=deltat, CORRECTIONS=model_format) minor = infer_minor_corrections(tide_time, hc, c, DELTAT=deltat, CORRECTIONS=model_format) tide.data[:] += minor.data[:] #-- replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) tide.data[invalid] = tide.fill_value tide.mask[invalid] = True #-- group attributes for beam IS2_atl03_tide_attrs[gtx]['Description'] = attrs['Description'] IS2_atl03_tide_attrs[gtx]['atlas_pce'] = attrs['atlas_pce'] IS2_atl03_tide_attrs[gtx]['atlas_beam_type'] = attrs['atlas_beam_type'] IS2_atl03_tide_attrs[gtx]['groundtrack_id'] = attrs['groundtrack_id'] IS2_atl03_tide_attrs[gtx]['atmosphere_profile'] = attrs['atmosphere_profile'] IS2_atl03_tide_attrs[gtx]['atlas_spot_number'] = attrs['atlas_spot_number'] IS2_atl03_tide_attrs[gtx]['sc_orientation'] = attrs['sc_orientation'] #-- group attributes for geolocation IS2_atl03_tide_attrs[gtx]['geolocation']['Description'] = ("Contains parameters related to " "geolocation. The rate of all of these parameters is at the rate corresponding to the " "ICESat-2 Geolocation Along Track Segment interval (nominally 20 m along-track).") IS2_atl03_tide_attrs[gtx]['geolocation']['data_rate'] = ("Data within this group are " "stored at the ICESat-2 20m segment rate.") #-- group attributes for geophys_corr IS2_atl03_tide_attrs[gtx]['geophys_corr']['Description'] = ("Contains parameters used to " "correct photon heights for geophysical effects, such as tides. These parameters are " "posted at the same interval as the ICESat-2 Geolocation Along-Track Segment interval " "(nominally 20m along-track).") IS2_atl03_tide_attrs[gtx]['geophys_corr']['data_rate'] = ("These parameters are stored at " "the ICESat-2 Geolocation Along Track Segment rate (nominally every 20 m along-track).") #-- geolocation, time and segment ID #-- delta time in geolocation group IS2_atl03_tide[gtx]['geolocation']['delta_time'] = delta_time IS2_atl03_fill[gtx]['geolocation']['delta_time'] = None IS2_atl03_dims[gtx]['geolocation']['delta_time'] = None IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time'] = {} IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['units'] = "seconds since 2018-01-01" IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['long_name'] = "Elapsed GPS seconds" IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['standard_name'] = "time" IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['calendar'] = "standard" IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['description'] = ("Elapsed seconds " "from the ATLAS SDP GPS Epoch, corresponding to the transmit time of the reference " "photon. The ATLAS Standard Data Products (SDP) epoch offset is defined within " "/ancillary_data/atlas_sdp_gps_epoch as the number of GPS seconds between the GPS epoch " "(1980-01-06T00:00:00.000000Z UTC) and the ATLAS SDP epoch. By adding the offset " "contained within atlas_sdp_gps_epoch to delta time parameters, the time in gps_seconds " "relative to the GPS epoch can be computed.") IS2_atl03_tide_attrs[gtx]['geolocation']['delta_time']['coordinates'] = \ "segment_id reference_photon_lat reference_photon_lon" #-- delta time in geophys_corr group IS2_atl03_tide[gtx]['geophys_corr']['delta_time'] = delta_time IS2_atl03_fill[gtx]['geophys_corr']['delta_time'] = None IS2_atl03_dims[gtx]['geophys_corr']['delta_time'] = None IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time'] = {} IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['units'] = "seconds since 2018-01-01" IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['long_name'] = "Elapsed GPS seconds" IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['standard_name'] = "time" IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['calendar'] = "standard" IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['description'] = ("Elapsed seconds " "from the ATLAS SDP GPS Epoch, corresponding to the transmit time of the reference " "photon. The ATLAS Standard Data Products (SDP) epoch offset is defined within " "/ancillary_data/atlas_sdp_gps_epoch as the number of GPS seconds between the GPS epoch " "(1980-01-06T00:00:00.000000Z UTC) and the ATLAS SDP epoch. By adding the offset " "contained within atlas_sdp_gps_epoch to delta time parameters, the time in gps_seconds " "relative to the GPS epoch can be computed.") IS2_atl03_tide_attrs[gtx]['geophys_corr']['delta_time']['coordinates'] = ("../geolocation/segment_id " "../geolocation/reference_photon_lat ../geolocation/reference_photon_lon") #-- latitude IS2_atl03_tide[gtx]['geolocation']['reference_photon_lat'] = lat IS2_atl03_fill[gtx]['geolocation']['reference_photon_lat'] = None IS2_atl03_dims[gtx]['geolocation']['reference_photon_lat'] = ['delta_time'] IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat'] = {} IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['units'] = "degrees_north" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['contentType'] = "physicalMeasurement" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['long_name'] = "Latitude" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['standard_name'] = "latitude" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['description'] = ("Latitude of each " "reference photon. Computed from the ECF Cartesian coordinates of the bounce point.") IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['valid_min'] = -90.0 IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['valid_max'] = 90.0 IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lat']['coordinates'] = \ "segment_id delta_time reference_photon_lon" #-- longitude IS2_atl03_tide[gtx]['geolocation']['reference_photon_lon'] = lon IS2_atl03_fill[gtx]['geolocation']['reference_photon_lon'] = None IS2_atl03_dims[gtx]['geolocation']['reference_photon_lon'] = ['delta_time'] IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon'] = {} IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['units'] = "degrees_east" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['contentType'] = "physicalMeasurement" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['long_name'] = "Longitude" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['standard_name'] = "longitude" IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['description'] = ("Longitude of each " "reference photon. Computed from the ECF Cartesian coordinates of the bounce point.") IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['valid_min'] = -180.0 IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['valid_max'] = 180.0 IS2_atl03_tide_attrs[gtx]['geolocation']['reference_photon_lon']['coordinates'] = \ "segment_id delta_time reference_photon_lat" #-- segment ID IS2_atl03_tide[gtx]['geolocation']['segment_id'] = segment_id IS2_atl03_fill[gtx]['geolocation']['segment_id'] = None IS2_atl03_dims[gtx]['geolocation']['segment_id'] = ['delta_time'] IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id'] = {} IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id']['units'] = "1" IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id']['contentType'] = "referenceInformation" IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id']['long_name'] = "Along-track segment ID number" IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id']['description'] = ("A 7 digit number " "identifying the along-track geolocation segment number. These are sequential, starting with " "1 for the first segment after an ascending equatorial crossing node. Equal to the segment_id for " "the second of the two 20m ATL03 segments included in the 40m ATL03 segment") IS2_atl03_tide_attrs[gtx]['geolocation']['segment_id']['coordinates'] = \ "delta_time reference_photon_lat reference_photon_lon" #-- computed tide IS2_atl03_tide[gtx]['geophys_corr'][variable] = tide IS2_atl03_fill[gtx]['geophys_corr'][variable] = tide.fill_value IS2_atl03_dims[gtx]['geophys_corr'][variable] = ['delta_time'] IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable] = {} IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['units'] = "meters" IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['contentType'] = "referenceInformation" IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['long_name'] = long_name IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['description'] = description IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['source'] = TIDE_MODEL IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['reference'] = reference IS2_atl03_tide_attrs[gtx]['geophys_corr'][variable]['coordinates'] = \ ("../geolocation/segment_id ../geolocation/delta_time " "../geolocation/reference_photon_lat ../geolocation/reference_photon_lon") #-- print file information print('\t{0}'.format(OUTPUT_FILE)) if VERBOSE else None HDF5_ATL03_tide_write(IS2_atl03_tide, IS2_atl03_tide_attrs, CLOBBER=True, INPUT=os.path.basename(INPUT_FILE), FILL_VALUE=IS2_atl03_fill, DIMENSIONS=IS2_atl03_dims, FILENAME=os.path.join(DIRECTORY,OUTPUT_FILE)) #-- change the permissions mode os.chmod(os.path.join(DIRECTORY,OUTPUT_FILE), MODE) #-- PURPOSE: outputting the tide values for ICESat-2 data to HDF5 def HDF5_ATL03_tide_write(IS2_atl03_tide, IS2_atl03_attrs, INPUT=None, FILENAME='', FILL_VALUE=None, DIMENSIONS=None, CLOBBER=False): #-- setting HDF5 clobber attribute if CLOBBER: clobber = 'w' else: clobber = 'w-' #-- open output HDF5 file fileID = h5py.File(os.path.expanduser(FILENAME), clobber) #-- create HDF5 records h5 = {} #-- number of GPS seconds between the GPS epoch (1980-01-06T00:00:00Z UTC) #-- and ATLAS Standard Data Product (SDP) epoch (2018-01-01T00:00:00Z UTC) h5['ancillary_data'] = {} for k,v in IS2_atl03_tide['ancillary_data'].items(): #-- Defining the HDF5 dataset variables val = 'ancillary_data/{0}'.format(k) h5['ancillary_data'][k] = fileID.create_dataset(val, np.shape(v), data=v, dtype=v.dtype, compression='gzip') #-- add HDF5 variable attributes for att_name,att_val in IS2_atl03_attrs['ancillary_data'][k].items(): h5['ancillary_data'][k].attrs[att_name] = att_val #-- write each output beam beams = [k for k in IS2_atl03_tide.keys() if bool(re.match(r'gt\d[lr]',k))] for gtx in beams: fileID.create_group(gtx) h5[gtx] = {} #-- add HDF5 group attributes for beam for att_name in ['Description','atlas_pce','atlas_beam_type', 'groundtrack_id','atmosphere_profile','atlas_spot_number', 'sc_orientation']: fileID[gtx].attrs[att_name] = IS2_atl03_attrs[gtx][att_name] #-- create geolocation and geophys_corr groups for key in ['geolocation','geophys_corr']: fileID[gtx].create_group(key) h5[gtx][key] = {} for att_name in ['Description','data_rate']: att_val = IS2_atl03_attrs[gtx][key][att_name] fileID[gtx][key].attrs[att_name] = att_val #-- all variables for group groupkeys = set(IS2_atl03_tide[gtx][key].keys())-set(['delta_time']) for k in ['delta_time',*sorted(groupkeys)]: #-- values and attributes v = IS2_atl03_tide[gtx][key][k] attrs = IS2_atl03_attrs[gtx][key][k] fillvalue = FILL_VALUE[gtx][key][k] #-- Defining the HDF5 dataset variables val = '{0}/{1}/{2}'.format(gtx,key,k) if fillvalue: h5[gtx][key][k] = fileID.create_dataset(val, np.shape(v), data=v, dtype=v.dtype, fillvalue=fillvalue, compression='gzip') else: h5[gtx][key][k] = fileID.create_dataset(val, np.shape(v), data=v, dtype=v.dtype, compression='gzip') #-- create or attach dimensions for HDF5 variable if DIMENSIONS[gtx][key][k]: #-- attach dimensions for i,dim in enumerate(DIMENSIONS[gtx][key][k]): h5[gtx][key][k].dims[i].attach_scale(h5[gtx][key][dim]) else: #-- make dimension h5[gtx][key][k].make_scale(k) #-- add HDF5 variable attributes for att_name,att_val in attrs.items(): h5[gtx][key][k].attrs[att_name] = att_val #-- HDF5 file title fileID.attrs['featureType'] = 'trajectory' fileID.attrs['title'] = 'ATLAS/ICESat-2 L2A Global Geolocated Photon Data' fileID.attrs['summary'] = ('The purpose of ATL03 is to provide along-track ' 'photon data for all 6 ATLAS beams and associated statistics') fileID.attrs['description'] = ('Photon heights determined by ATBD ' 'Algorithm using POD and PPD. All photon events per transmit pulse ' 'per beam. Includes POD and PPD vectors. Classification of each ' 'photon by several ATBD Algorithms.') date_created = datetime.datetime.today() fileID.attrs['date_created'] = date_created.isoformat() project = 'ICESat-2 > Ice, Cloud, and land Elevation Satellite-2' fileID.attrs['project'] = project platform = 'ICESat-2 > Ice, Cloud, and land Elevation Satellite-2' fileID.attrs['project'] = platform #-- add attribute for elevation instrument and designated processing level instrument = 'ATLAS > Advanced Topographic Laser Altimeter System' fileID.attrs['instrument'] = instrument fileID.attrs['source'] = 'Spacecraft' fileID.attrs['references'] = 'https://nsidc.org/data/icesat-2' fileID.attrs['processing_level'] = '4' #-- add attributes for input ATL03 file fileID.attrs['input_files'] = os.path.basename(INPUT) #-- find geospatial and temporal ranges lnmn,lnmx,ltmn,ltmx,tmn,tmx = (np.inf,-np.inf,np.inf,-np.inf,np.inf,-np.inf) for gtx in beams: lon = IS2_atl03_tide[gtx]['geolocation']['reference_photon_lon'] lat = IS2_atl03_tide[gtx]['geolocation']['reference_photon_lat'] delta_time = IS2_atl03_tide[gtx]['geolocation']['delta_time'] #-- setting the geospatial and temporal ranges lnmn = lon.min() if (lon.min() < lnmn) else lnmn lnmx = lon.max() if (lon.max() > lnmx) else lnmx ltmn = lat.min() if (lat.min() < ltmn) else ltmn ltmx = lat.max() if (lat.max() > ltmx) else ltmx tmn = delta_time.min() if (delta_time.min() < tmn) else tmn tmx = delta_time.max() if (delta_time.max() > tmx) else tmx #-- add geospatial and temporal attributes fileID.attrs['geospatial_lat_min'] = ltmn fileID.attrs['geospatial_lat_max'] = ltmx fileID.attrs['geospatial_lon_min'] = lnmn fileID.attrs['geospatial_lon_max'] = lnmx fileID.attrs['geospatial_lat_units'] = "degrees_north" fileID.attrs['geospatial_lon_units'] = "degrees_east" fileID.attrs['geospatial_ellipsoid'] = "WGS84" fileID.attrs['date_type'] = 'UTC' fileID.attrs['time_type'] = 'CCSDS UTC-A' #-- convert start and end time from ATLAS SDP seconds into GPS seconds atlas_sdp_gps_epoch=IS2_atl03_tide['ancillary_data']['atlas_sdp_gps_epoch'] gps_seconds = atlas_sdp_gps_epoch + np.array([tmn,tmx]) #-- calculate leap seconds leaps = pyTMD.time.count_leap_seconds(gps_seconds) #-- convert from seconds since 1980-01-06T00:00:00 to Julian days time_julian = 2400000.5 + pyTMD.time.convert_delta_time(gps_seconds - leaps, epoch1=(1980,1,6,0,0,0), epoch2=(1858,11,17,0,0,0), scale=1.0/86400.0) #-- convert to calendar date YY,MM,DD,HH,MN,SS = pyTMD.time.convert_julian(time_julian,FORMAT='tuple') #-- add attributes with measurement date start, end and duration tcs = datetime.datetime(int(YY[0]), int(MM[0]), int(DD[0]), int(HH[0]), int(MN[0]), int(SS[0]), int(1e6*(SS[0] % 1))) fileID.attrs['time_coverage_start'] = tcs.isoformat() tce = datetime.datetime(int(YY[1]), int(MM[1]), int(DD[1]), int(HH[1]), int(MN[1]), int(SS[1]), int(1e6*(SS[1] % 1))) fileID.attrs['time_coverage_end'] = tce.isoformat() fileID.attrs['time_coverage_duration'] = '{0:0.0f}'.format(tmx-tmn) #-- Closing the HDF5 file fileID.close() #-- Main program that calls compute_tides_ICESat2() def main(): #-- Read the system arguments listed after the program parser = argparse.ArgumentParser( description="""Calculates tidal elevations for correcting ICESat-2 ATL03 geolocated photon height data """ ) #-- command line parameters parser.add_argument('infile', type=lambda p: os.path.abspath(os.path.expanduser(p)), nargs='+', help='ICESat-2 ATL03 file to run') #-- directory with tide data parser.add_argument('--directory','-D', type=lambda p: os.path.abspath(os.path.expanduser(p)), default=os.getcwd(), help='Working data directory') #-- tide model to use model_choices = ('CATS0201','CATS2008','CATS2008_load', 'TPXO9-atlas','TPXO9-atlas-v2','TPXO9-atlas-v3','TPXO9-atlas-v4', 'TPXO9.1','TPXO8-atlas','TPXO7.2','TPXO7.2_load', 'AODTM-5','AOTIM-5','AOTIM-5-2018','Gr1km-v2', 'GOT4.7','GOT4.7_load','GOT4.8','GOT4.8_load','GOT4.10','GOT4.10_load', 'FES2014','FES2014_load') parser.add_argument('--tide','-T', metavar='TIDE', type=str, default='CATS2008', choices=model_choices, help='Tide model to use in correction') #-- interpolation method parser.add_argument('--interpolate','-I', metavar='METHOD', type=str, default='spline', choices=('spline','linear','nearest','bilinear'), help='Spatial interpolation method') #-- extrapolate with nearest-neighbors parser.add_argument('--extrapolate','-E', default=False, action='store_true', help='Extrapolate with nearest-neighbors') #-- extrapolation cutoff in kilometers #-- set to inf to extrapolate over all points parser.add_argument('--cutoff','-c', type=np.float64, default=10.0, help='Extrapolation cutoff in kilometers') #-- verbosity settings #-- verbose will output information about each output file parser.add_argument('--verbose','-V', default=False, action='store_true', help='Output information about each created file') #-- permissions mode of the local files (number in octal) parser.add_argument('--mode','-M', type=lambda x: int(x,base=8), default=0o775, help='Permission mode of directories and files created') args = parser.parse_args() #-- run for each input ATL03 file for FILE in args.infile: compute_tides_ICESat2(args.directory, FILE, TIDE_MODEL=args.tide, METHOD=args.interpolate, EXTRAPOLATE=args.extrapolate, CUTOFF=args.cutoff, VERBOSE=args.verbose, MODE=args.mode) #-- run main program if __name__ == '__main__': main()
53.876609
111
0.646247
4a2457632fc33589a39c9bb9defa5606260590bc
1,786
py
Python
plugins/dbnd-docker/src/dbnd_docker/docker/docker_task_run_ctrl.py
ipattarapong/dbnd
7bd65621c46c73e078eb628f994127ad4c7dbd1a
[ "Apache-2.0" ]
224
2020-01-02T10:46:37.000Z
2022-03-02T13:54:08.000Z
plugins/dbnd-docker/src/dbnd_docker/docker/docker_task_run_ctrl.py
ipattarapong/dbnd
7bd65621c46c73e078eb628f994127ad4c7dbd1a
[ "Apache-2.0" ]
16
2020-03-11T09:37:58.000Z
2022-01-26T10:22:08.000Z
plugins/dbnd-docker/src/dbnd_docker/docker/docker_task_run_ctrl.py
ipattarapong/dbnd
7bd65621c46c73e078eb628f994127ad4c7dbd1a
[ "Apache-2.0" ]
24
2020-03-24T13:53:50.000Z
2022-03-22T11:55:18.000Z
from dbnd_docker.docker_ctrl import DockerRunCtrl class LocalDockerRunCtrl(DockerRunCtrl): def __init__(self, **kwargs): super(LocalDockerRunCtrl, self).__init__(**kwargs) self.runner_op = None @property def docker_config(self): # type: (LocalDockerRunCtrl) -> DockerEngineConfig return self.task.docker_engine def docker_run(self): from dbnd_airflow_contrib.docker_operator import DockerOperator t = self.task dc = self.docker_config environment = dc.environment.copy() environment.update(self.task_run.run.get_context_spawn_env()) self.runner_op = DockerOperator( task_id=self.task.task_id, image=t.image, command=t.command, docker_conn_id=dc.docker_conn_id, cpus=dc.cpus, environment=environment, api_version=dc.api_version, docker_url="unix://var/run/docker.sock", force_pull=dc.force_pull, mem_limit=dc.mem_limit, network_mode=dc.network_mode, tls_ca_cert=dc.tls_ca_cert, tls_client_cert=dc.tls_client_cert, tls_client_key=dc.tls_client_key, tls_hostname=dc.tls_hostname, tls_ssl_version=dc.tls_ssl_version, tmp_dir=dc.tmp_dir, user=dc.user, volumes=dc.volumes, working_dir=dc.working_dir, xcom_push=False, xcom_all=False, dns=dc.dns, dns_search=dc.dns_search, auto_remove=dc.auto_remove, shm_size=dc.shm_size, ) self.runner_op.execute(context=None) def on_kill(self): if self.runner_op is not None: self.runner_op.on_kill()
31.892857
71
0.614222
4a2457b9db06e896d8f76449cd46184604a6cc81
2,682
py
Python
meerkat/tools/lazy_loader.py
HazyResearch/meerkat
e3b437d47809ef8e856a5f732ac1e11a1176ba1f
[ "Apache-2.0" ]
65
2021-06-25T06:51:15.000Z
2022-02-08T22:25:27.000Z
meerkat/tools/lazy_loader.py
HazyResearch/meerkat
e3b437d47809ef8e856a5f732ac1e11a1176ba1f
[ "Apache-2.0" ]
111
2021-06-24T01:16:36.000Z
2022-03-07T17:54:58.000Z
terra/tools/lazy.py
seyuboglu/terra
7d5f8d8cdfbf819b52fb997b5b9746746d86b295
[ "Apache-2.0" ]
4
2021-08-03T18:24:22.000Z
2022-03-09T21:06:07.000Z
# coding=utf-8 # Copyright 2020 The TF-Agents Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Lazy loader class.""" from __future__ import absolute_import, division, print_function import importlib import logging import types logger = logging.getLogger(__name__) class LazyLoader(types.ModuleType): """Lazily import a module, mainly to avoid pulling in large dependencies. `contrib`, and `ffmpeg` are examples of modules that are large and not always needed, and this allows them to only be loaded when they are used. """ # The lint error here is incorrect. def __init__( self, local_name, parent_module_globals=None, name=None, warning=None, error=None, ): # pylint: disable=super-on-old-class if parent_module_globals is None: parent_module_globals = globals() self._local_name = local_name self._parent_module_globals = parent_module_globals self._warning = warning self._error = error if name is None: name = local_name super(LazyLoader, self).__init__(name) def _load(self): """Load the module and insert it into the parent's globals.""" # Import the target module and insert it into the parent's namespace try: module = importlib.import_module(self.__name__) except ImportError as e: raise ImportError(self._error) if self._error else e self._parent_module_globals[self._local_name] = module # Emit a warning if one was specified if self._warning: logger.warning(self._warning) # Make sure to only warn once. self._warning = None # Update this object's dict so that if someone keeps a reference to the # LazyLoader, lookups are efficient (__getattr__ is only called on lookups # that fail). self.__dict__.update(module.__dict__) return module def __getattr__(self, item): module = self._load() return getattr(module, item) def __dir__(self): module = self._load() return dir(module)
31.186047
84
0.66965