def do_reload(self, c, target, cmdargs, msgtype): """The reloading magic. | First, reload handler.py. | Then make copies of all the handler data we want to keep. | Create a new handler and restore all the data. """ output = None if cmdargs == 'pull': output = misc.do_pull(dirname(__file__), c.real_nickname) c.privmsg(target, output) for x in modutils.get_enabled(dirname(__file__) + '/helpers'): name = 'helpers.%s' % x if name in sys.modules: importlib.reload(sys.modules[name]) importlib.reload(handler) self.config = ConfigParser() configfile = join(dirname(__file__), 'config.cfg') self.config.read_file(open(configfile)) # preserve data data = self.handler.get_data() self.do_shutdown(True) self.handler = handler.BotHandler(self.config) if self.config['feature'].getboolean('server'): self.server = server.init_server(self) self.handler.set_data(data) self.handler.connection = c self.handler.channels = self.channels self.handler.workers = workers.Workers(self.handler) if output: return output
def _spa_python_import(how): """Compile spa.py appropriately""" from pvlib import spa # check to see if the spa module was compiled with numba using_numba = spa.USE_NUMBA if how == 'numpy' and using_numba: # the spa module was compiled to numba code, so we need to # reload the module without compiling # the PVLIB_USE_NUMBA env variable is used to tell the module # to not compile with numba os.environ['PVLIB_USE_NUMBA'] = '0' pvl_logger.debug('Reloading spa module without compiling') spa = reload(spa) del os.environ['PVLIB_USE_NUMBA'] elif how == 'numba' and not using_numba: # The spa module was not compiled to numba code, so set # PVLIB_USE_NUMBA so it does compile to numba on reload. os.environ['PVLIB_USE_NUMBA'] = '1' pvl_logger.debug('Reloading spa module, compiling with numba') spa = reload(spa) del os.environ['PVLIB_USE_NUMBA'] elif how != 'numba' and how != 'numpy': raise ValueError("how must be either 'numba' or 'numpy'") return spa
def test_app(self): # capture output to test on with self._capture_output() as (out, err): importlib.reload(mqtt_app) mqtt_thread = Thread(target=mqtt_app.start_mqtt, args=(), daemon=True) mqtt_thread.start() publish = Thread(target=mqtt_app.publish_thread, args=(), daemon=True) publish.start() # Need a delay to allow some time for the threads to start time.sleep(4) # Pull info out of stdout since this app uses the cs.py log # function. This means the logs are converted to prints and # go to stdout output = err.getvalue().strip() # if the test passed, stdout should have captured output self.assertIn('MQTT connect reply to test.mosquitto.org, 1883: Connection Accepted.', output) self.assertIn('MQTT Client connection results: Connection Accepted.', output) self.assertIn('Published msg received. topic: /status/gps/lastpos', output) self.assertIn('Published msg received. topic: /status/wan/connection_state', output) self.assertIn('Published msg received. topic: /status/system/modem_temperature', output) self.assertIn('MQTT published file:', output) self.assertNotIn('Exception in publish_file().', output) self.assertNotIn('Exception in publish_thread().', output) self.assertNotIn('Exception in start_mqtt()!', output) self.assertNotIn('Exception during start_app()!', output)
def init_thread_vars(spec, info_space, unit): '''Initialize thread variables from lab units that do not get carried over properly from master''' if info_space.get(unit) is None: info_space.tick(unit) if logger.to_init(spec, info_space): os.environ['PREPATH'] = util.get_prepath(spec, info_space) reload(logger)
def reset_all(*, reload_scripts=False): """ Sets the addon state based on the user preferences. """ import sys # initializes addons_fake_modules modules_refresh() # RELEASE SCRIPTS: official scripts distributed in Blender releases paths_list = paths() for path in paths_list: _bpy.utils._sys_path_ensure(path) for mod_name, mod_path in _bpy.path.module_names(path): is_enabled, is_loaded = check(mod_name) # first check if reload is needed before changing state. if reload_scripts: import importlib mod = sys.modules.get(mod_name) if mod: importlib.reload(mod) if is_enabled == is_loaded: pass elif is_enabled: enable(mod_name) elif is_loaded: print("\taddon_utils.reset_all unloading", mod_name) disable(mod_name)
def test_importcheck_thread_safety(self, datapath): # see gh-16928 class ErrorThread(threading.Thread): def run(self): try: super(ErrorThread, self).run() except Exception as e: self.err = e else: self.err = None # force import check by reinitalising global vars in html.py reload(pandas.io.html) filename = datapath('io', 'data', 'valid_markup.html') helper_thread1 = ErrorThread(target=self.read_html, args=(filename,)) helper_thread2 = ErrorThread(target=self.read_html, args=(filename,)) helper_thread1.start() helper_thread2.start() while helper_thread1.is_alive() or helper_thread2.is_alive(): pass assert None is helper_thread1.err is helper_thread2.err
def import_module(self, modulename): """ If prefixed with "solfege:" user:collection/modulename collection is the directory name in ~/.solfege/exercises/collection/modulename and "user:"******""" if modulename.startswith("user:"******"user:"******"exercises", collection, "modules") sys.path.insert(0, module_dir) m = __import__(modulename.split("/")[1]) importlib.reload(m) del sys.path[0] else: try: m = __import__("solfege.exercises.%s" % modulename, fromlist=("solfege.exercises.%s" % modulename,), level=0) except ImportError as e: raise abstract.ExerciseModuleImportError(e) return m
def use_backend(backend): """ Specifies which backend to use. It is typically called before any other modules are imported. If it is called later it will reload the modules. However if any symbols was imported from the modules, they will have to be reimported. If it is not called, the default backend will be used. The *backend* parameter can either be an already imported module or a string which specifyes a module under *pyvx.backend* to load. That is the same string that was passed as the *name* argument of build_cbackend during `installation`_. The first form allows for backends that's not part of pyvx to be used. .. _`installation`: #installation Typical usage: .. code-block:: python from pyvx import use_backend use_backend("sample") from pyvx import vx """ """ :param backend: :return: """ import pyvx pyvx._default_backend_name = backend for n in ['backend', '_auto_vx', '_auto_vxu', 'types', 'vx', 'vxu', 'pythonic']: n = 'pyvx.' + n if n in sys.modules: reload(sys.modules[n])
def three_point_two_scaling_matrix(aloc1, aloc2, aloc3, bloc1, bloc2, bloc3): """Return the transformation to put points from a in b coordinate system, scaled uniformly such that the distance from a1 to a2 is that of b1 to b2.""" import scripts.ema_io.ema_gameserver.biteplate_headcorr as bh import importlib as imp imp.reload(bh) asset_cs = bh.ScalingPlane(aloc1, aloc2, aloc3) target_cs = bh.ScalingPlane(bloc1, bloc2, bloc3) print('Initial locations are:\n{} {}\n{} {}\n {} {}\n'.format(aloc1, bloc1, aloc2, bloc2, aloc3, bloc3)) # calculate a scaling factor target_dist = (bloc2 - bloc1).length current_dist = (aloc2 - aloc1).length sf = target_dist/current_dist #print('scaling by', sf) scaling_factor = mathutils.Matrix([[sf, 0, 0, 1], [0, sf, 0, 1], [0, 0, sf, 1], [0, 0, 0, 1], ]) # the transformation matrix used to align points by these three points, and size it such that the first two are the same distance from each other. tranf = target_cs.give_local_to_global_mat() * scaling_factor * asset_cs.give_global_to_local_mat() return tranf
def find_unknown(path): if not path or path == BOTS_FILE: try: reload(apache_log_filter.bots) except: return if not path or path == VALIDS_FILE: try: reload(apache_log_filter.tools.valids) except: return _found_one = False with open(SAMPLE_FILE, 'rt') as f: for line in f.readlines(): is_valid = apache_log_filter.tools.valids.valids.search(line) is_bot = apache_log_filter.bots.BOTS.search(line) if is_valid: if is_bot: print("This is recognized as non-bot's and as bot's user agents:\n{}".format(line)) _found_one = True break for token in ['bot', 'crawler', 'spider']: if token in line.lower(): print("This line contains the token '{}':\n{}".format(token, line)) _found_one = True break if not is_valid and not is_bot: print("Here's a new one:\n{}".format(line)) _found_one = True break if not _found_one: print("There's nothing new.") return time()
def load(): plugincount = 0 failcount = 0 blockcount = 0 modules = sorted(glob.glob(os.path.dirname(__file__)+"/*.py"), key=lambda x: (os.path.basename(x)[0]!="_", x)) blacklist = [m.strip() for m in _config.get("DEFAULT", "blacklist", fallback="").split(",")] blacklist += ["__init__"] # make sure we don't load ourselves for module in modules: module = os.path.basename(module)[:-3] if not module in blacklist: try: _ = importlib.import_module("."+module, "modules") importlib.reload(_) # in case of a reload plugincount += 1 except: traceback.print_exc() failcount += 1 elif not module == "__init__": blockcount += 1 loaded_modules = "Successfully (re)loaded {} modules".format(plugincount) if failcount > 0: loaded_modules += " | {} modules failed".format(failcount) if blockcount > 0: loaded_modules += " | {} modules blocked".format(blockcount) print(loaded_modules)
def reload_module(module): # reloading the imported module to update try: from importlib import reload except ImportError: pass # for python 2 reload(sys.modules[module])
def test_no_direct(self): """Ensure all connections are proxied""" import iview.config # Cannot use None to indicate module was absent realsocks = sys.modules.get("socks", "absent") class SocketProxied(Exception): pass class socks: def socksocket(*pos, **kw): raise SocketProxied() PROXY_TYPE_SOCKS5 = None def setdefaultproxy(*pos, **kw): pass sys.modules["socks"] = socks try: # Set dummy proxy values to enable proxy code with substattr(iview.config, "socks_proxy_host", True), \ substattr(iview.config, "socks_proxy_port", True): reload(iview.comm) return self.common(SocketProxied) finally: if realsocks == "absent": del sys.modules["socks"] else: sys.modules["socks"] = realsocks reload(iview.comm) # Reconfigure after resetting proxy settings
def load_project_migrations(project_dir): migration_file_paths = [ os.path.relpath(file_path, project_dir) for file_path in find_project_migrations(project_dir) ] migration_module_paths = [ file_path[:-3].replace(os.sep, '.') for file_path in migration_file_paths ] # we need to both invalidate_caches() migration_base_paths = set([ migration_module_path.rpartition('.')[0] for migration_module_path in migration_module_paths ]) for migration_base_path in migration_base_paths: reload(import_module(migration_base_path)) migration_modules = [ reload(import_module(module_path)) for module_path in migration_module_paths ] migration_classes = [ getattr(migration_module, 'Migration') for migration_module in migration_modules ] return migration_classes
def load_script(text): """ Will load the blender text file as a module in nodes.script """ #global _script_modules #global _name_lookup if text.endswith(".py"): name = text.rstrip(".py") else: name = text if not name.isidentifier() or keyword.iskeyword(name): print("bad text name: {}".format(text)) return name = make_valid_identifier(name) _name_lookup[name] = text if name in _script_modules: print("reloading") mod = _script_modules[name] importlib.reload(mod) else: mod = importlib.import_module("sverchok.nodes.script.{}".format(name)) _script_modules[name] = mod func = _func_lookup[name] setattr(mod, "_func", func) if func._sv_properties: cls = class_factory(func) setattr(mod, "_class", cls) else: setattr(mod, "_class", None)
def do_reload(self, c, target, cmdargs): """The reloading magic. | First, reload handler.py. | Then make copies of all the handler data we want to keep. | Create a new handler and restore all the data. """ self.reload_event.clear() output = None if cmdargs == 'pull': output = misc.do_pull(dirname(__file__), c.real_nickname) c.privmsg(target, output) for name in modutils.get_enabled('helpers', 'helpers')[0]: if name in sys.modules: importlib.reload(sys.modules[name]) importlib.reload(handler) self.config = ConfigParser() configfile = join(dirname(__file__), 'config.cfg') with open(configfile) as cfgfile: self.config.read_file(cfgfile) # preserve data data = self.handler.get_data() self.shutdown_server() self.shutdown_workers() self.handler = handler.BotHandler(self.config) self.handler.set_data(data) self.handler.connection = c self.handler.channels = self.channels if self.config['feature'].getboolean('server'): self.server = server.init_server(self) self.reload_event.set() if output: return output
def setUp(self): self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) # The test config.yaml references files in `xos-synchronizer-tests/` so make sure we're in the parent # directory of the test directory. os.chdir(os.path.join(test_path, "..")) import xossynchronizer.event_loop reload(xossynchronizer.event_loop) import xossynchronizer.backend reload(xossynchronizer.backend) from xossynchronizer.modelaccessor import model_accessor b = xossynchronizer.backend.Backend(model_accessor=model_accessor) steps_dir = Config.get("steps_dir") self.steps = b.load_sync_step_modules(steps_dir) self.synchronizer = xossynchronizer.event_loop.XOSObserver(self.steps, model_accessor)
def reload(cls, module): """ Reload the fake module """ real_module = sys.modules[module.__name__] reload(real_module) return module
def setUp(self): self._test_process = Mock() ui_client1 = UIClientStub() ui_client2 = UIClientStub() self._test_ui1 = Mock(wraps=ui_client1) self._test_ui2 = Mock(wraps=ui_client2) importlib.reload(bb.event)
def load(self, name, module_path): path, module_name = module_path.rsplit(".", 1) module = __import__(module_path, globals(), locals(), [module_name]) reload(module) self.plugins[name] = plugin = Plugin( name, module_path, [ obj for obj in module.__dict__.values() if getattr(obj, 'is_bot_event', False) is True ] ) cfg = self.config plugin_name = 'plugin:%s' % name if cfg.has_section(plugin_name): plugin.config.update(cfg.items(plugin_name)) initials_funcs = ( func for func in module.__dict__.values() if getattr(func, 'is_initial', False) is True ) for initial_func in initials_funcs: initial_func(plugin, self.protocol) future = plugin.future loops = [ func(self.protocol, plugin, future) for func in module.__dict__.values() if getattr(func, 'is_loop', False) is True ] for loop in loops: async(loop)
def test_reload(self): '''Test that reload didn't re-set the module's attributes''' with util.uncache(self.name): module = self.load_module() ex_class = module.Example importlib.reload(module) self.assertIs(ex_class, module.Example)
def test_llvm_version(self): # test the system its running on import llvm import numba self.assertTrue(numba.__version__) if sys.version_info >= (3, 4): from importlib import reload elif (sys.version_info[0], sys.version_info[1]) == (3, 3): from imp import reload else: from __builtin__ import reload # explicitly test all 4 cases of version string version_pass = '******' git_version_pass = '******' version_fail = '0.12.5' git_version_fail = '0.12.5-10-g92584ed' ver_pass = (version_pass, git_version_pass) ver_fail = (version_fail, git_version_fail) for v in ver_pass: llvm.__version = v reload(numba) self.assertTrue(numba.__version__) for v in ver_fail: with self.assertRaises(SystemExit): llvm.__version__ = v reload(numba)
def get_rig_type(rig_type): """ Fetches a rig module by name, and returns it. """ name = ".%s.%s" % (RIG_DIR, rig_type) submod = importlib.import_module(name, package=MODULE_NAME) importlib.reload(submod) return submod
def test_module_utils_basic_ansible_module_selinux_enabled(self): from ansible.module_utils import basic reload(basic) am = basic.AnsibleModule( argument_spec = dict(), ) # we first test the cases where the python selinux lib is # not installed, which has two paths: one in which the system # does have selinux installed (and the selinuxenabled command # is present and returns 0 when run), or selinux is not installed basic.HAVE_SELINUX = False am.get_bin_path = MagicMock() am.get_bin_path.return_value = '/path/to/selinuxenabled' am.run_command = MagicMock() am.run_command.return_value=(0, '', '') self.assertRaises(SystemExit, am.selinux_enabled) am.get_bin_path.return_value = None self.assertEqual(am.selinux_enabled(), False) # finally we test the case where the python selinux lib is installed, # and both possibilities there (enabled vs. disabled) basic.HAVE_SELINUX = True basic.selinux = Mock() with patch.dict('sys.modules', {'selinux': basic.selinux}): with patch('selinux.is_selinux_enabled', return_value=0): self.assertEqual(am.selinux_enabled(), False) with patch('selinux.is_selinux_enabled', return_value=1): self.assertEqual(am.selinux_enabled(), True) delattr(basic, 'selinux')
def test_module_utils_basic_ansible_module_selinux_default_context(self): from ansible.module_utils import basic reload(basic) am = basic.AnsibleModule( argument_spec = dict(), ) am.selinux_initial_context = MagicMock(return_value=[None, None, None, None]) am.selinux_enabled = MagicMock(return_value=True) # we first test the cases where the python selinux lib is not installed basic.HAVE_SELINUX = False self.assertEqual(am.selinux_default_context(path='/foo/bar'), [None, None, None, None]) # all following tests assume the python selinux bindings are installed basic.HAVE_SELINUX = True basic.selinux = Mock() with patch.dict('sys.modules', {'selinux': basic.selinux}): # next, we test with a mocked implementation of selinux.matchpathcon to simulate # an actual context being found with patch('selinux.matchpathcon', return_value=[0, 'unconfined_u:object_r:default_t:s0']): self.assertEqual(am.selinux_default_context(path='/foo/bar'), ['unconfined_u', 'object_r', 'default_t', 's0']) # we also test the case where matchpathcon returned a failure with patch('selinux.matchpathcon', return_value=[-1, '']): self.assertEqual(am.selinux_default_context(path='/foo/bar'), [None, None, None, None]) # finally, we test where an OSError occurred during matchpathcon's call with patch('selinux.matchpathcon', side_effect=OSError): self.assertEqual(am.selinux_default_context(path='/foo/bar'), [None, None, None, None]) delattr(basic, 'selinux')
def check_docker_fresh(): """ This is used for tests that have issues with cross test interaction :return: """ reload(cd) return cd
def reload(self): ''' Call reload on all loaded modules. ''' importlib.reload(self.ircformatter) self.listen()
def get_metarig_module(metarig_name): """ Fetches a rig module by name, and returns it. """ name = ".%s.%s" % (METARIG_DIR, metarig_name) submod = importlib.import_module(name, package=MODULE_NAME) importlib.reload(submod) return submod
def _post_install(): from importlib import reload import site reload(site) import nltk nltk.download('punkt')
def reload(self): import importlib import inspect modules = [inspect.getmodule(cls) for cls in self.registry] self.registry = [] for module in modules: importlib.reload(module)
# #################### # ヘッドレス化 # options = Options() # options.add_argument('--headless'); # クローム起動 # driver = webdriver.Chrome(es.driver_path, options=options) driver = webdriver.Chrome(es.driver_path) # インスタグラムにログイン ig.login(driver, account, account_pass) # In[19]: #################### # # フォロー解除 # #################### ig.al_release_follow(driver, profile_url, release_min, release_follow) # In[11]: import importlib importlib.reload(es) importlib.reload(ig) # In[ ]:
"author": "Andrés Botero", "version": (0, 1, 0), "blender": (2, 80, 0), "location": "File > Export > Datasmith (.udatasmith)", "description": "Export scene as Datasmith asset", "warning": "", "category": "Import-Export", "support": 'COMMUNITY', "wiki_url": "https://github.com/0xafbf/blender-datasmith-export", } if "bpy" in locals(): import importlib if "export_datasmith" in locals(): importlib.reload(export_datasmith) import bpy from bpy.props import ( StringProperty, BoolProperty, FloatProperty, EnumProperty, ) from bpy_extras.io_utils import ( ImportHelper, ExportHelper, path_reference_mode, axis_conversion, )
import sys import urllib.error import urllib.parse import urllib.request import xml.etree.cElementTree from importlib import reload Request = urllib.request.Request urlencode = urllib.parse.urlencode urlopen = urllib.request.urlopen HTTPError = urllib.error.HTTPError iteritems = dict.items try: reload(sys) sys.setdefaultencoding("utf8") except Exception: # Can't change default encoding usually... pass try: ssl.PROTOCOL_TLSv1_1 except AttributeError: raise Exception( "Using the Quip API requires an SSL library that supports TLS versions " ">= 1.1; your Python + OpenSSL installation must be upgraded." ) # After 2017-02, the Quip API HTTPS endpoint requires TLS version 1.1 or later; # TLS version 1.0 is disabled due to extensive security vulnerabilities. #
allData['f1Best_meta'] = np.zeros([mdlParams['numCV']]) allData['sensBest_meta'] = np.zeros([mdlParams['numCV'], num_classes]) allData['specBest_meta'] = np.zeros([mdlParams['numCV'], num_classes]) allData['accBest_meta'] = np.zeros([mdlParams['numCV']]) allData['waccBest_meta'] = np.zeros([mdlParams['numCV'], num_classes]) allData['aucBest_meta'] = np.zeros([mdlParams['numCV'], num_classes]) #allData['convergeTime'] = {} allData['bestPred_meta'] = {} allData['targets_meta'] = {} if not (len(sys.argv) > 8 and ('sevenpoint' in sys.argv[8] or 'ISIC_Rest' in sys.argv[8] or 'HAM' in sys.argv[8])): for cv in range(mdlParams['numCV']): # Reset model graph importlib.reload(models) #importlib.reload(torchvision) # Collect model variables modelVars = {} modelVars['device'] = torch.device( "cuda:0" if torch.cuda.is_available() else "cpu") print(modelVars['device']) # Def current CV set mdlParams['trainInd'] = mdlParams['trainIndCV'][cv] if 'valIndCV' in mdlParams: mdlParams['valInd'] = mdlParams['valIndCV'][cv] # Def current path for saving stuff if 'valIndCV' in mdlParams: mdlParams['saveDir'] = mdlParams['saveDirBase'] + '/CVSet' + str( cv) else:
def __init__(self, analysis_name, analysis_recipes, isderived=False, clobber=False, **query_kwargs): import popeos importlib.reload(popeos) #-- parse query: hardwired now for certain fields self.experiment = query_kwargs['experiment'] self.variable = query_kwargs.pop('variable') # get the analysis definition self.analysis_name = analysis_name with open(analysis_recipes) as f: analysis_defs = yaml.load(f) analysis = analysis_defs[analysis_name] if 'description' in analysis: self.analysis_description = analysis['description'] self.operators = analysis.pop('operators', [lambda ds: ds]) self.sel_kwargs = analysis.pop('sel_kwargs', {}) self.isel_kwargs = analysis.pop('isel_kwargs', {}) self.derived_var_def = analysis.pop('derived_var_def', None) self.file_format = analysis.pop('file_format', 'nc') if self.file_format not in ['nc', 'zarr']: raise ValueError(f'unknown file format: {self.file_format}') if isderived: with open('derived_variable_definitions.yml') as f: derived_var_defs = yaml.load(f) derived_var_def = derived_var_defs[self.variable] self.vars_dependent = derived_var_def['vars_dependent'] self.operators = derived_var_def['methods'] + self.operators #-- set some attrs self.dirout = os.path.join(dirout, 'processed_collections') #-- pull specified dataset from catalog self.catalog = data_catalog.get_catalog() ensembles = data_catalog.find_in_index( **query_kwargs).ensemble.unique() if len(ensembles) == 0: raise ValueError(f'catalog contains no data for this query:\n' f'{query_kwargs}') self.n_members = len(ensembles) self.cache_locations = [] self.input = [] # if the cached_locations are present, # then this list will be empty in the returned # object. Could be that the orig files are gone, # (off disk) but the cache remains. for ens_i in ensembles: file_out = '.'.join([ self.catalog, self.experiment, '%03d' % ens_i, self.analysis_name, self.variable, self.file_format ]) file_out = os.path.join(self.dirout, file_out) self.cache_locations.append(file_out) if os.path.exists(file_out) and clobber: check_call(['rm', '-fr', file_out]) # zarr files are directories if not os.path.exists(file_out): if not isderived: data_desc = data_catalog.get_entries( ensemble=ens_i, variable=self.variable, **query_kwargs) n_files = len(data_desc['files']) else: data_desc = [ data_catalog.get_entries(ensemble=ens_i, variable=v, **query_kwargs) for v in self.vars_dependent ] n_files = len(data_desc[0]['files']) if n_files > 0: self._process(file_out, data_desc) else: self.cache_locations.pop(-1) logging.warning(f'No data to generate {file_out}.') self.input.append(data_desc)
@author: Meva """ import numpy as np import pandas as pd import matplotlib as mpl import scipy import importlib import matplotlib.pyplot as plt from scipy.stats import skew, kurtosis, chi2, linregress from scipy.optimize import minimize from numpy import linalg as LA # import our own files and reload import stream_classes importlib.reload(stream_classes) def print_number(n=5): print(n) def load_timeseries(ric, file_extension='csv'): # get market data # remember to modify the path to match your own directory #ulmo path = 'C:\\Users\Meva\\.spyder-py3\\data\\' + ric + '.' + file_extension path = './data/' + ric + '.' + file_extension if file_extension == 'csv': table_raw = pd.read_csv(path) # default csv else: table_raw = pd.read_excel(path)
import os, sys, importlib # System packages import pandas as pd # Dataframes import numpy as np # Numeric tools import statsmodels as sm # Statistical models import statsmodels.formula.api as smf # Formulas from collections import namedtuple # High perf container # Plotting packages import matplotlib.pyplot as plt import seaborn as sns # Local packages sys.path.append(os.path.abspath('cqsampling')) # Executable path import cqsampling; importlib.reload(cqsampling) # Conditional Sampling from cqsampling import inv_transform # Warnings management # With many quantile regressions, the convergence warnings are overwhelming from warnings import simplefilter # Filter warnings from statsmodels.tools.sm_exceptions import (ConvergenceWarning, IterationLimitWarning) simplefilter("ignore", category=ConvergenceWarning) simplefilter("ignore", category=IterationLimitWarning) # Specific warnings in quantile regressions np.seterr(divide='ignore', invalid='ignore') ###############################################################################
# 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 bpy import os import importlib from bpy.props import * from bpy.app.handlers import persistent from . import one_mat, uv_fixer, uv_splitter, gen_tex from bpy.types import Panel, PropertyGroup, UIList, Operator, Scene, Material, Texture importlib.reload(one_mat) importlib.reload(uv_fixer) importlib.reload(uv_splitter) importlib.reload(gen_tex) bl_info = { 'name': 'Shotariya-don', 'category': '3D View', 'author': 'shotariya (shotariya#4269)', 'location': 'View 3D > Tool Shelf > Shotariya-don', 'description': 'Tool with some functions', 'version': [1, 1, 6, 3], 'blender': (2, 79, 0), 'wiki_url': 'https://github.com/Grim-es/material-combiner-addon/blob/master/README.md', 'tracker_url': 'https://discordapp.com/users/275608234595713024',
# [h] set width dialog import hTools2.dialogs.glyphs.width_set import importlib importlib.reload(hTools2.dialogs.glyphs.width_set) hTools2.dialogs.glyphs.width_set.setWidthDialog()
#!/usr/bin/python #coding=utf-8 from selenium.webdriver.common.by import By from appium import webdriver # from Base.Base import Base # import Page # from Page.login import Login import pytest import time import importlib import sys importlib.reload(sys) class Taptap: def setup_class(self): desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '7.0' desired_caps['deviceName'] = 'S9B7N17819001588' desired_caps['appPackage'] = 'com.taptap' desired_caps['appActivity'] = 'com.play.taptap.ui.MainAct' desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True desired_caps['noReset'] = True self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) print(">>>>>>>>>>>>>>>>>>>>>>>>>setup") # self.tap = Login(self.driver) def teardown_class(self):
"batch_size": 1024, "allowed_error": 0.3, }, "data_config": {"obs_n": 20, "pred_step_n": 7, "step_size": 3, "Note": "lat/long motion not considered jointly" # "Note": "jerk as target" }, "exp_id": "NA", "Note": "" } from models.core.tf_models import utils reload(utils) from models.core.tf_models import cae_model reload(cae_model) from models.core.tf_models.cae_model import Encoder, Decoder, CAE # config = loadConfig('series000exp001') config['exp_id'] = 'debug_experiment_2' def train_debugger(): model = CAE(config, model_use='training') data_objs = DataObj(config).loadData() t0 = time.time() for epoch in range(1):
import importlib import regretNet_pytorch_2 importlib.reload(regretNet_pytorch_2) from regretNet_pytorch_2 import * import torch import torch.nn as nn import matplotlib.pyplot as plt #importlib.reload(losses) #importlib.reload(utils) import numpy as np import distributions importlib.reload(distributions) n_epochs = 3 n_bidders = 1 n_objects = 2 distrib_list = [distributions.UniformDistrib(), distributions.UniformDistrib()] env = Auction_Environment(n_bidders, n_objects, distrib_list) net = Add_Network(env) #print(net.alloc_net) #print(net.pay_net) torch.cuda.set_device(0) trainer = Trainer(env, net, n_epochs) trainer.net.cuda() for q in range(n_epochs): print( '###################################################################################' ) print('\n') print('EPOCH NUMBER: ', q + 1)
## imports import tweepy from selenium import webdriver import time import pandas as pd from datetime import datetime, timedelta import configparser from dateutil.parser import parse import multiprocessing import sys import pytz import helpers import random import os from importlib import reload reload( helpers ) ## load the config file config = configparser.ConfigParser() config.read('config.py') ## parse the config variables DATE_IN_PAST = config['DEFAULT']['DATE_IN_PAST'] DAYS_IN_PAST = config['DEFAULT'].getint('DAYS_IN_PAST') NUM_TWEETS_TO_DOWNLOAD = config['DEFAULT'].getint('NUM_TWEETS_TO_DOWNLOAD') OUTPUT_FILE_NAME_SUFFIX = config['DEFAULT']['OUTPUT_FILE_NAME_SUFFIX'] TIME_SLEEP = config['DEFAULT'].getint('TIME_SLEEP') TIME_SLEEP_BROWSER_CLOSE = config['DEFAULT'].getint('TIME_SLEEP_BROWSER_CLOSE')
# [h] create anchors """Create `top` and `bottom` anchors in selected glyphs.""" import hTools2.modules.anchors import importlib importlib.reload(hTools2.modules.anchors) # import from mojo.roboFont import CurrentFont from vanilla import * from hTools2 import hDialog from hTools2.dialogs.misc import Spinner from hTools2.modules.fontutils import get_glyphs from hTools2.modules.anchors import create_anchors, clear_anchors from hTools2.modules.messages import no_glyph_selected, no_font_open # objects class createAnchorsDialog(hDialog): # _top = True # _bottom = True # _accent = False # _top_delta = 20 # _bottom_delta = 20 def __init__(self): self.title = "anchors"
from dateutil.parser import parse from datetime import datetime from datetime import timedelta # Python 2 and 3: easiest option from future.standard_library import install_aliases install_aliases() from urllib.parse import urlparse, urlencode from urllib.request import urlopen, Request from urllib.error import HTTPError import pytz from matplotlib.backends.backend_pdf import PdfPages import weather_data_tools as weather importlib.reload(weather) import spectra_fitting_tools as fitter importlib.reload(fitter) #--------------------------------------------------------------------------# # Process input data #--------------------------------------------------------------------------# def make_int(lst): ''' Makes all entries of a list an integer ''' y = [] for i in lst: y.append(int(i)) return y
return node_list for mods, base in mods_bases: import_modules(mods, base, imported_modules) node_list = make_node_list() reload_event = bool("bpy" in locals()) if reload_event: import nodeitems_utils # reload the base modules # then reload nodes after the node module as been reloaded for im in imported_modules: importlib.reload(im) node_list = make_node_list() for node in node_list: importlib.reload(node) old_nodes.reload_old() menu.reload_menu() import bpy from sverchok.utils import ascii_print def register(): for m in imported_modules + node_list: if hasattr(m, "register"): m.register() # this is used to access preferences, should/could be hidden
import torch.nn.functional as F from torch.nn.functional import mse_loss from torch.utils.data import Dataset, DataLoader from torch.nn.parallel import DistributedDataParallel from torch.distributed import all_reduce from torch.utils.data.distributed import DistributedSampler import h5py from utils import tqdm import numpy as np import random from matching import * from importlib import reload import lagomorph reload(lagomorph) import lagomorph as lm def MLP(widths, activation=None, last_layer_scale=1.0, dropout=None): if activation is None: activation = nn.ReLU() layers = [] prev_size = widths[0] for sz in widths[1:-1]: if dropout is not None: layers.append(nn.Dropout(p=dropout)) layers.append(nn.Linear(prev_size, sz)) layers.append(activation) prev_size = sz layers.append(nn.Linear(prev_size, widths[-1]))
# -*- coding: utf-8 -*- import sys, os import pandas as pd from importlib import reload from bs4 import BeautifulSoup import urllib.request from tqdm import tqdm import numpy as np import grimsel.auxiliary.timemap as timemap import grimsel.auxiliary.aux_sql_func as aql import PROFILE_READER.profile_reader as profile_reader reload(profile_reader) class FRHydroLevelReader(profile_reader.ProfileReader): ''' ''' dict_sql_default = dict(sc='profiles_raw', tb='hydro_level_rte_fr') data_dir = os.path.normpath('HYDRO_FILLING_LEVELS/RTE_FRANCE') tb_cols = [('nd_id', 'VARCHAR'), ('start_level_interp', 'DOUBLE PRECISION'), ('average_level', 'DOUBLE PRECISION'), ('start_level_diff', 'DOUBLE PRECISION'), ('wk_id', 'SMALLINT'), ('year', 'SMALLINT')] tb_pk = ['nd_id', 'year', 'wk_id']
def get_app(self): importlib.reload(server) return server.application
bl_info = { "name": "Sapling_4", "author": "Andrew Hale (TrumanBlending), modified by Aaron Buchler 2015-2020", "version": (0, 4, 0), "blender": (2, 80, 0), "location": "View3D > Add > Curve", "description": "Adds a parametric tree.", "category": "Add Curve" } ##"Originally based on the method presented by Jason Weber & Joseph Penn in their paper 'Creation and Rendering of Realistic Trees'."## if "bpy" in locals(): import importlib importlib.reload(utils) else: from sapling_4 import utils import bpy import time import os import ast #import cProfile from mathutils import * from math import pi, sin, degrees, radians, atan2, copysign, ceil from random import random, uniform, seed, choice, getstate, setstate from bpy.props import *
import numpy as np import matplotlib import matplotlib.pyplot as plt import matplotlib.cm as cm import matplotlib.colors as cl from matplotlib.ticker import MaxNLocator #from matplotlib.colors import Normalize import copy import pickle import importlib import rpmClassDev_Alex as rpm importlib.reload(rpm) Hc = 0.062 bar_length = 220e-9 vertex_gap = 1e-7 bar_thickness = 25e-9 bar_width = 80e-9 magnetisation = 800e3 angle = 45 squareLattice = rpm.ASI_RPM(25, 25, bar_length = bar_length,\ vertex_gap = vertex_gap, bar_thickness = bar_thickness,\ bar_width = bar_width, magnetisation = magnetisation) Hc_std = 0.05 squareLattice.load('RandomLattice1.npz')
"version": (2, 3, 6), "blender": (2, 78, 0), "location": "File > Import-Export", "description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures", "warning": "", "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Wavefront_OBJ", "support": 'OFFICIAL', "category": "Import-Export" } if "bpy" in locals(): import importlib if "import_obj" in locals(): importlib.reload(import_obj) if "export_obj" in locals(): importlib.reload(export_obj) import bpy from bpy.props import ( BoolProperty, FloatProperty, StringProperty, EnumProperty, ) from bpy_extras.io_utils import ( ImportHelper, ExportHelper, orientation_helper_factory, path_reference_mode,
def reload_base(): importlib.reload(izaber.plpython.base) from izaber.plpython.base import IPLPY return IPLPY
import board import neopixel # to control LEDs import datetime # for datetime management import time # for sleep/timing commands from importlib import reload import brightness from brightness import * # to load/reload variables from file # initialize system pixels = neopixel.NeoPixel(board.D18, 288) pixels.fill((0, 0, 0)) # Start actual infinite while loop to run script while True: # check brightness and color reload(brightness) from brightness import * r = int((r / 255) * a) g = int((g / 255) * a) b = int((b / 255) * a) # Fill all LEDs pixels.fill((r, g, b)) time.sleep(0.5)
"warning": "", "wiki_url": "https://github.com/rlguy/Blender-FLIP-Fluids/wiki", "tracker_url": "https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Guidelines-for-Reporting-Bugs-and-Issues", "category": "Animation" } if "bpy" in locals(): import importlib reloadable_modules = [ 'utils', 'objects', 'materials', 'properties', 'operators', 'ui', 'presets', 'export', 'bake', 'render', 'exit_handler' ] for module_name in reloadable_modules: if module_name in locals(): importlib.reload(locals()[module_name]) import bpy, atexit, shutil, os from bpy.props import (PointerProperty, StringProperty) from . import (utils, objects, materials, properties, operators, ui, presets, export, bake, render, exit_handler) from .utils import version_compatibility_utils as vcu @bpy.app.handlers.persistent def scene_update_post(scene): properties.scene_update_post(scene) render.scene_update_post(scene) materials.scene_update_post(scene)
"name": "BioVision Motion Capture (BVH) format", "author": "Campbell Barton", "version": (1, 0, 1), "blender": (2, 81, 6), "location": "File > Import-Export", "description": "Import-Export BVH from armature objects", "warning": "", "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/anim_bvh.html", "support": 'OFFICIAL', "category": "Import-Export", } if "bpy" in locals(): import importlib if "import_bvh" in locals(): importlib.reload(import_bvh) if "export_bvh" in locals(): importlib.reload(export_bvh) import bpy from bpy.props import ( StringProperty, FloatProperty, IntProperty, BoolProperty, EnumProperty, ) from bpy_extras.io_utils import ( ImportHelper, ExportHelper, orientation_helper,
def reload_lib(lib): lib = reload(lib)
# 1 qubit random density matrices # # Details: The script performs the following steps: # # Usage: python3 linear-test.py # ############################################################# # Include import importlib import numpy as np from scipy.stats import unitary_group as ug import scipy as sc import simulation importlib.reload(simulation) import estimation importlib.reload(estimation) import stats importlib.reload(stats) import estimation importlib.reload(estimation) import cProfile import pstats from progress import * pr = cProfile.Profile() pr.enable()
Spectroscopy class This file contains the Spectroscopy class that forms the basis analysis of all the spectroscopy measurement analyses. """ import pycqed.analysis_v2.base_analysis as ba import numpy as np import pandas as pd import matplotlib.pyplot as plt from pycqed.analysis import measurement_analysis as MA from pycqed.analysis import analysis_toolbox as a_tools from pycqed.analysis.tools import data_manipulation as dm_tools from pycqed.analysis import fitting_models as fit_mods import lmfit import importlib importlib.reload(ba) class Spectroscopy(ba.BaseDataAnalysis): def __init__(self, t_start: str, t_stop: str = None, options_dict: dict = None, label: str = None, extract_only: bool = False, auto: bool = True, do_fitting: bool = False): super(Spectroscopy, self).__init__(t_start=t_start, t_stop=t_stop, label=label, options_dict=options_dict,
import os from builtins import str from importlib import reload import openalea.vmango.preparation.doralice_mtg.mtg_manipulation as mm from openalea.mtg import * from openalea.tree_matching.mtgmatching import * from openalea.vmango.constants import * from openalea.vmango.utilities.util_tools import * from openalea.vmango.utilities.util_date import cycle_end, month_difference from openalea.vmango.utilities.util_path import (get_glm_mtg_repository, mtgfname, share_dir) from past.utils import old_div reload(mm) first_date = cycle_end(3) def get_burst_date(u, values): bdate = values.get(u) if bdate is None or bdate < first_date: return first_date return bdate class MtgNodeCost(NodeCost): def __init__(self, refburstdate, simburstdate, refmtg, simmtg): NodeCost.__init__(self) self.refburstdate = refburstdate self.simburstdate = simburstdate self.refmtg = refmtg self.simmtg = simmtg