Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def delete(self, id):
project = db.session.query(Project).filter_by(id=id).first()
if project is None:
response = jsonify({
'projects': None,
'message': 'No interface defined for URL.'
})
... | [
"delete."
] |
Please provide a description of the function:def serialize(self):
arguments = []
if isinstance(json.loads(self.data), dict):
for k, v in json.loads(self.data).items():
arguments.append({
'resultId': self.result_id,
'key': k,
... | [
"serialize."
] |
Please provide a description of the function:def collect_assets(result, force=False):
path_name = result.path_name
info_path = os.path.join(path_name, summary.CHAINERUI_ASSETS_METAFILE_NAME)
if not os.path.isfile(info_path):
return
start_idx = len(result.assets)
file_modified_at = datet... | [
"collect assets from meta file\n\n Collecting assets only when the metafile is updated. If number of assets\n are decreased, assets are reset and re-collect the assets.\n "
] |
Please provide a description of the function:def save_args(conditions, out_path):
if isinstance(conditions, argparse.Namespace):
args = vars(conditions)
else:
args = conditions
try:
os.makedirs(out_path)
except OSError:
pass
with tempdir(prefix='args', dir=out... | [
"A util function to save experiment condition for job table.\n\n Args:\n conditions (:class:`argparse.Namespace` or dict): Experiment conditions\n to show on a job table. Keys are show as table header and values\n are show at a job row.\n out_path (str): Output directory name ... |
Please provide a description of the function:def _list_result_paths(target_path, log_file_name='log'):
result_list = []
for root, _dirs, _files in os.walk(os.path.abspath(target_path)):
for name in _files:
if name == log_file_name:
result_list.append(root)
return ... | [
"list_result_paths."
] |
Please provide a description of the function:def collect_results(project, force=False):
if not project.crawlable:
return project
now = datetime.datetime.now()
if (now - project.updated_at).total_seconds() < 4 and (not force):
return project
result_paths = []
if os.path.isdir(... | [
"collect_results."
] |
Please provide a description of the function:def server_handler(args):
if not db.setup(url=args.db, echo=args.db_echo):
return
if not _check_db_revision():
return
app = create_app()
listener = '{:s}:{:d}'.format(args.host, args.port)
if args.debug:
logging.getLogger('we... | [
"server_handler."
] |
Please provide a description of the function:def db_handler(args):
if args.type == 'create':
if args.db is None:
db.init_db()
return
if not db.setup(url=args.db, echo=args.db_echo):
return
if args.type == 'status':
current_rev = db_revision.current_db_revi... | [
"db_handler."
] |
Please provide a description of the function:def project_create_handler(args):
if not db.setup(url=args.db, echo=args.db_echo):
return
if not _check_db_revision():
return
project_path = os.path.abspath(args.project_dir)
project_name = args.project_name
project = db.session.que... | [
"project_create_handler."
] |
Please provide a description of the function:def main():
parser = create_parser()
args = parser.parse_args()
if hasattr(args, 'handler'):
args.handler(args)
else:
parser.print_help() | [
"main."
] |
Please provide a description of the function:def get(self, id=None, project_id=None):
logs_limit = request.args.get('logs_limit', default=-1, type=int)
project = db.session.query(Project).filter_by(
id=project_id).first()
if project is None:
return jsonify({
... | [
"get."
] |
Please provide a description of the function:def put(self, id, project_id=None):
result = db.session.query(Result).filter_by(id=id).first()
if result is None:
response = jsonify({
'result': None, 'message': 'No interface defined for URL.'
})
r... | [
"put."
] |
Please provide a description of the function:def delete(self, id, project_id=None):
result = db.session.query(Result).filter_by(id=id).first()
if result is None:
response = jsonify({
'result': None, 'message': 'No interface defined for URL.'
})
... | [
"delete."
] |
Please provide a description of the function:def _path_insensitive(path):
path = str(path)
if path == '' or os.path.exists(path):
return path
base = os.path.basename(path) # may be a directory or a file
dirname = os.path.dirname(path)
suffix = ''
if not base: # dir ends with a s... | [
"\n Recursive part of path_insensitive to do the work.\n "
] |
Please provide a description of the function:def url_is_alive(url):
request = urllib.request.Request(url)
request.get_method = lambda: 'HEAD'
try:
urllib.request.urlopen(request)
return True
except urllib.request.HTTPError:
return False | [
"\n Checks that a given URL is reachable.\n :param url: A URL\n :rtype: bool\n "
] |
Please provide a description of the function:def form_option(str_opt):
'''generate option name based suffix for URL
:param str_opt: opt name
:type str_opt: str
:return: URL suffix for the specified option
:rtype: str
'''
str_base = '#cmdoption-arg-'
str_opt_x = str_base+str_opt.lower()... | [] |
Please provide a description of the function:def gen_url_option(
str_opt,
set_site=set_site,
set_runcontrol=set_runcontrol,
set_initcond=set_initcond,
source='docs'):
'''construct a URL for option based on source
:param str_opt: option name, defaults to ''
:param str_opt: str, opti... | [] |
Please provide a description of the function:def gen_df_forcing(
path_csv_in='SSss_YYYY_data_tt.csv',
url_base=url_repo_input,)->pd.DataFrame:
'''Generate description info of supy forcing data into a dataframe
Parameters
----------
path_csv_in : str, optional
path to the input c... | [] |
Please provide a description of the function:def gen_df_output(
list_csv_in=[
'SSss_YYYY_SUEWS_TT.csv',
'SSss_DailyState.csv',
'SSss_YYYY_snow_TT.csv',
],
url_base=url_repo_output)->Path:
'''Generate description info of supy output results into dataframe
... | [] |
Please provide a description of the function:def gen_opt_str(ser_rec: pd.Series)->str:
'''generate rst option string
Parameters
----------
ser_rec : pd.Series
record for specifications
Returns
-------
str
rst string
'''
name = ser_rec.name
indent = r' '
... | [] |
Please provide a description of the function:def plot_day_clm(df_var, fig=None, ax=None, **kwargs):
if fig is None and ax is None:
fig, ax = plt.subplots()
elif fig is None:
fig = ax.get_figure()
elif ax is None:
ax = fig.gca()
# plt.clf()
# group by hour and minute
... | [
"Short summary.\n\n Parameters\n ----------\n df_var : pd.DataFrame\n DataFrame containing variables to plot with datetime as index\n\n Returns\n -------\n MPL.figure\n figure showing median lines and IQR in shadings\n\n "
] |
Please provide a description of the function:def plot_comp(df_var, fig=None, ax=None, **kwargs):
if fig is None and ax is None:
fig, ax = plt.subplots()
elif fig is None:
fig = ax.get_figure()
elif ax is None:
ax = fig.gca()
# plt.clf()
# plt.cla()
# ax = sns.regplot... | [
"Short summary.\n\n Parameters\n ----------\n df_var : pd.DataFrame\n DataFrame containing variables to plot with datetime as index\n\n Returns\n -------\n MPL.figure\n figure showing 1:1 line plot\n\n "
] |
Please provide a description of the function:def init_supy(path_init: str)->pd.DataFrame:
'''Initialise supy by loading initial model states.
Parameters
----------
path_init : str
Path to a file that can initialise SuPy, which can be either of the follows:
* SUEWS :ref:`RunControl.n... | [] |
Please provide a description of the function:def load_forcing_grid(path_runcontrol: str, grid: int)->pd.DataFrame:
'''Load forcing data for a specific grid included in the index of `df_state_init </data-structure/supy-io.ipynb#df_state_init:-model-initial-states>`.
Parameters
----------
path_runcontrol... | [] |
Please provide a description of the function:def load_SampleData()->Tuple[pandas.DataFrame, pandas.DataFrame]:
'''Load sample data for quickly starting a demo run.
Returns
-------
df_state_init, df_forcing: Tuple[pandas.DataFrame, pandas.DataFrame]
- df_state_init: `initial model states <df_sta... | [] |
Please provide a description of the function:def run_supy(
df_forcing: pandas.DataFrame,
df_state_init: pandas.DataFrame,
save_state=False,
n_yr=10,
)->Tuple[pandas.DataFrame, pandas.DataFrame]:
'''Perform supy simulation.
Parameters
----------
df_forcing : pandas.DataFr... | [] |
Please provide a description of the function:def save_supy(
df_output: pandas.DataFrame,
df_state_final: pandas.DataFrame,
freq_s: int = 3600,
site: str = '',
path_dir_save: str = Path('.'),
path_runcontrol: str = None,)->list:
'''Save SuPy run results to files
P... | [] |
Please provide a description of the function:def load_SUEWS_Forcing_met_df_pattern(path_input, forcingfile_met_pattern):
# list of met forcing files
path_input = path_input.resolve()
# forcingfile_met_pattern = os.path.abspath(forcingfile_met_pattern)
list_file_MetForcing = sorted([
f for ... | [
"Short summary.\n\n Parameters\n ----------\n forcingfile_met_pattern : type\n Description of parameter `forcingfile_met_pattern`.\n\n Returns\n -------\n type\n Description of returned object.\n\n "
] |
Please provide a description of the function:def load_df_state(path_csv: Path)->pd.DataFrame:
'''load `df_state` from `path_csv`
Parameters
----------
path_csv : Path
path to the csv file that stores `df_state` produced by a supy run
Returns
-------
pd.DataFrame
`df_state` ... | [] |
Please provide a description of the function:def extract_var_suews(dict_var_full: dict, var_supy: str)->list:
'''extract related SUEWS variables for a supy variable `var_supy`
Parameters
----------
dict_var_full : dict
dict_var_full = sp.supy_load.exp_dict_full(sp.supy_load.dict_var2SiteSelect)... | [] |
Please provide a description of the function:def gen_df_site(
list_csv_in=list_table,
url_base=url_repo_input_site)->pd.DataFrame:
'''Generate description info of supy output results as a dataframe
Parameters
----------
path_csv_out : str, optional
path to the output csv file (t... | [] |
Please provide a description of the function:def gen_rst_url_split_opts(opts_str):
if opts_str is not 'None':
list_opts = opts_str.split(',')
# list_rst = [gen_rst_url_opt(opt.strip()) for opt in list_opts]
list_rst = [opt.strip() for opt in list_opts]
# list_rst = [f'`{opt}`' f... | [
"generate option list for RST docs\n\n Parameters\n ----------\n opts_str : str\n a string including all SUEWS related options/variables.\n e.g. 'SUEWS_a, SUEWS_b'\n\n\n Returns\n -------\n list\n a list of parsed RST `:ref:` roles.\n e.g. [':option:`SUEWS_a <suews:SUEW... |
Please provide a description of the function:def gen_df_state(
list_table: list,
set_initcond: set,
set_runcontrol: set,
set_input_runcontrol: set)->pd.DataFrame:
'''generate dataframe of all state variables used by supy
Parameters
----------
list_table : list
cs... | [] |
Please provide a description of the function:def gen_df_save(df_grid_group: pd.DataFrame)->pd.DataFrame:
'''generate a dataframe for saving
Parameters
----------
df_output_grid_group : pd.DataFrame
an output dataframe of a single group and grid
Returns
-------
pd.DataFrame
... | [] |
Please provide a description of the function:def save_df_output(
df_output: pd.DataFrame,
freq_s: int = 3600,
site: str = '',
path_dir_save: Path = Path('.'),)->list:
'''save supy output dataframe to txt files
Parameters
----------
df_output : pd.DataFrame
output... | [] |
Please provide a description of the function:def save_df_state(
df_state: pd.DataFrame,
site: str = '',
path_dir_save: Path = Path('.'),)->Path:
'''save `df_state` to a csv file
Parameters
----------
df_state : pd.DataFrame
a dataframe of model states produced by a supy ... | [] |
Please provide a description of the function:def get_save_info(path_runcontrol: str)->Tuple[int, Path, str]:
'''get necessary information for saving supy results, which are (freq_s, dir_save, site)
Parameters
----------
path_runcontrol : Path
Path to SUEWS :ref:`RunControl.nml <suews:RunControl... | [] |
Please provide a description of the function:def gen_FS_DF(df_output):
df_day = pd.pivot_table(
df_output,
values=['T2', 'U10', 'Kdown', 'RH2'],
index=['Year', 'Month', 'Day'],
aggfunc=[min, max, np.mean, ])
df_day_all_year = pd.pivot_table(
df_output,
values... | [
"generate DataFrame of scores.\n\n Parameters\n ----------\n df_WS_data : type\n Description of parameter `df_WS_data`.\n\n Returns\n -------\n type\n Description of returned object.\n\n "
] |
Please provide a description of the function:def gen_WS_DF(df_WS_data):
df_fs = gen_FS_DF(df_WS_data)
list_index = [('mean', 'T2'), ('max', 'T2'), ('min', 'T2'),
('mean', 'U10'), ('max', 'U10'), ('min', 'U10'),
('mean', 'RH2'), ('max', 'RH2'), ('min', 'RH2'),
... | [
"generate DataFrame of weighted sums.\n\n Parameters\n ----------\n df_WS_data : type\n Description of parameter `df_WS_data`.\n\n Returns\n -------\n type\n Description of returned object.\n\n "
] |
Please provide a description of the function:def gen_TMY(df_output):
'''generate TMY (typical meteorological year) from SuPy output.
Parameters
----------
df_output : pandas.DataFrame
Output from `run_supy`: longterm (e.g., >10 years) simulation results, otherwise not very useful.
'''
... | [] |
Please provide a description of the function:def _geoid_radius(latitude: float) -> float:
lat = deg2rad(latitude)
return sqrt(1/(cos(lat) ** 2 / Rmax_WGS84 ** 2 + sin(lat) ** 2 / Rmin_WGS84 ** 2)) | [
"Calculates the GEOID radius at a given latitude\n\n Parameters\n ----------\n latitude : float\n Latitude (degrees)\n\n Returns\n -------\n R : float\n GEOID Radius (meters)\n "
] |
Please provide a description of the function:def geometric2geopotential(z: float, latitude: float) -> float:
twolat = deg2rad(2 * latitude)
g = 9.80616 * (1 - 0.002637*cos(twolat) + 0.0000059*cos(twolat)**2)
re = _geoid_radius(latitude)
return z * g * re / (re + z) | [
"Converts geometric height to geopoential height\n\n Parameters\n ----------\n z : float\n Geometric height (meters)\n latitude : float\n Latitude (degrees)\n\n Returns\n -------\n h : float\n Geopotential Height (meters) above the reference ellipsoid\n "
] |
Please provide a description of the function:def geopotential2geometric(h: float, latitude: float) -> float:
twolat = deg2rad(2 * latitude)
g = 9.80616 * (1 - 0.002637*cos(twolat) + 0.0000059*cos(twolat)**2)
re = _geoid_radius(latitude)
return h * re / (g * re - h) | [
"Converts geopoential height to geometric height\n\n Parameters\n ----------\n h : float\n Geopotential height (meters)\n latitude : float\n Latitude (degrees)\n\n Returns\n -------\n z : float\n Geometric Height (meters) above the reference ellipsoid\n "
] |
Please provide a description of the function:def get_ser_val_alt(lat: float, lon: float,
da_alt_x: xr.DataArray,
da_alt: xr.DataArray, da_val: xr.DataArray)->pd.Series:
'''interpolate atmospheric variable to a specified altitude
Parameters
----------
lat : float
... | [] |
Please provide a description of the function:def get_df_val_alt(lat: float, lon: float, da_alt_meas: xr.DataArray, ds_val: xr.Dataset):
'''interpolate atmospheric variables to a specified altitude
Parameters
----------
lat : float
latitude of specified site
lon : float
longitude of ... | [] |
Please provide a description of the function:def gen_req_sfc(lat_x, lon_x, start, end, grid=[0.125, 0.125], scale=0):
'''generate a dict of reqs kwargs for (lat_x,lon_x) spanning [start, end]
Parameters
----------
lat_x : [type]
[description]
lon_x : [type]
[description]
start :... | [] |
Please provide a description of the function:def sel_list_pres(ds_sfc_x):
'''
select proper levels for model level data download
'''
p_min, p_max = ds_sfc_x.sp.min().values, ds_sfc_x.sp.max().values
list_pres_level = [
'1', '2', '3',
'5', '7', '10',
'20', '30', '50',
... | [] |
Please provide a description of the function:def load_world(filename):
import ecell4_base
vinfo = ecell4_base.core.load_version_information(filename)
if vinfo.startswith("ecell4-bd"):
return ecell4_base.bd.World(filename)
elif vinfo.startswith("ecell4-egfrd"):
return ecell4_base.eg... | [
"\n Load a world from the given HDF5 filename.\n The return type is determined by ``ecell4_base.core.load_version_information``.\n\n Parameters\n ----------\n filename : str\n A HDF5 filename.\n\n Returns\n -------\n w : World\n Return one from ``BDWorld``, ``EGFRDWorld``, ``Me... |
Please provide a description of the function:def run_simulation(
t, y0=None, volume=1.0, model=None, solver='ode',
is_netfree=False, species_list=None, without_reset=False,
return_type='matplotlib', opt_args=(), opt_kwargs=None,
structures=None, observers=(), progressbar=0, rndseed=None,... | [
"Run a simulation with the given model and plot the result on IPython\n notebook with matplotlib.\n\n Parameters\n ----------\n t : array or Real\n A sequence of time points for which to solve for 'm'.\n y0 : dict\n Initial condition.\n volume : Real or Real3, optional\n A siz... |
Please provide a description of the function:def number_observer(t=None, targets=None):
from ecell4_base.core import NumberObserver, FixedIntervalNumberObserver, TimingNumberObserver
if t is None:
return NumberObserver(targets)
elif isinstance(t, numbers.Number):
return FixedIntervalNu... | [
"\n Return a number observer. If t is None, return NumberObserver. If t is a number,\n return FixedIntervalNumberObserver. If t is an iterable (a list of numbers), return\n TimingNumberObserver.\n\n Parameters\n ----------\n t : float, list or tuple, optional. default None\n A timing of the... |
Please provide a description of the function:def show(target, *args, **kwargs):
if isinstance(target, (ecell4_base.core.FixedIntervalNumberObserver, ecell4_base.core.NumberObserver, ecell4_base.core.TimingNumberObserver, )):
plot_number_observer(target, *args, **kwargs)
elif isinstance(target, (ece... | [
"\n An utility function to display the given target object in the proper way.\n\n Paramters\n ---------\n target : NumberObserver, TrajectoryObserver, World, str\n When a NumberObserver object is given, show it with viz.plot_number_observer.\n When a TrajectoryObserver object is given, sho... |
Please provide a description of the function:def run(self, duration, obs):
from ecell4_base.core import TimeoutObserver
timeout = TimeoutObserver(self.__timeout)
if isinstance(obs, collections.Iterable):
obs = tuple(obs) + (timeout, )
else:
obs = (obs, t... | [
"Run the simulation.\n\n Parameters\n ----------\n duration : Real\n a duration for running a simulation.\n A simulation is expected to be stopped at t() + duration.\n observers : list of Obeservers, optional\n observers\n\n "
] |
Please provide a description of the function:def run(self, duration, obs=None):
from ecell4_base.core import TimeoutObserver
timeout = TimeoutObserver(self.__timeout)
if obs is None:
obs = (timeout, )
elif isinstance(obs, collections.Iterable):
obs = tup... | [
"Run the simulation.\n\n Parameters\n ----------\n duration : Real\n a duration for running a simulation.\n A simulation is expected to be stopped at t() + duration.\n obs : list of Obeservers, optional\n observers\n\n "
] |
Please provide a description of the function:def print_batch_exception(batch_exception):
_log.error('-------------------------------------------')
_log.error('Exception encountered:')
if batch_exception.error and \
batch_exception.error.message and \
batch_exception.error.messag... | [
"Prints the contents of the specified Batch exception.\n\n :param batch_exception:\n "
] |
Please provide a description of the function:def upload_file_to_container(block_blob_client, container_name, file_path):
blob_name = os.path.basename(file_path)
_log.info('Uploading file {} to container [{}]...'.format(file_path, container_name))
block_blob_client.create_blob_from_path(container_name... | [
"Uploads a local file to an Azure Blob storage container.\n\n :param block_blob_client: A blob service client.\n :type block_blob_client: `azure.storage.blob.BlockBlobService`\n :param str container_name: The name of the Azure Blob storage container.\n :param str file_path: The local path to the file.\n... |
Please provide a description of the function:def get_container_sas_token(block_blob_client,
container_name, blob_permissions):
# Obtain the SAS token for the container, setting the expiry time and
# permissions. In this case, no start time is specified, so the shared
# acces... | [
"Obtains a shared access signature granting the specified permissions to the\n container.\n\n :param block_blob_client: A blob service client.\n :type block_blob_client: `azure.storage.blob.BlockBlobService`\n :param str container_name: The name of the Azure Blob storage container.\n :param BlobPermi... |
Please provide a description of the function:def wrap_commands_in_shell(ostype, commands):
if ostype.lower() == 'linux':
return '/bin/bash -c \'set -e; set -o pipefail; {}; wait\''.format(
';'.join(commands))
elif ostype.lower() == 'windows':
return 'cmd.exe /c "{}"'.format('&'.... | [
"Wrap commands in a shell\n Originally in azure-batch-samples.Python.Batch.common.helpers\n\n :param list commands: list of commands to wrap\n :param str ostype: OS type, linux or windows\n :rtype: str\n :return: a shell wrapping commands\n "
] |
Please provide a description of the function:def create_pool(batch_service_client, pool_id,
resource_files, publisher, offer, sku,
task_file, vm_size, node_count):
_log.info('Creating pool [{}]...'.format(pool_id))
# Create a new pool of Linux compute nodes using an Azure V... | [
"Creates a pool of compute nodes with the specified OS settings.\n\n :param batch_service_client: A Batch service client.\n :type batch_service_client: `azure.batch.BatchServiceClient`\n :param str pool_id: An ID for the new pool.\n :param list resource_files: A collection of resource files for the pool... |
Please provide a description of the function:def create_job(batch_service_client, job_id, pool_id):
print('Creating job [{}]...'.format(job_id))
job = batch.models.JobAddParameter(
id=job_id,
pool_info=batch.models.PoolInformation(pool_id=pool_id))
try:
batch_service_client.jo... | [
"Creates a job with the specified ID, associated with the specified pool.\n\n :param batch_service_client: A Batch service client.\n :type batch_service_client: `azure.batch.BatchServiceClient`\n :param str job_id: The ID for the job.\n :param str pool_id: The ID for the pool.\n "
] |
Please provide a description of the function:def add_tasks(batch_service_client, job_id, loads,
output_container_name, output_container_sas_token,
task_file, acount_name):
_log.info('Adding {} tasks to job [{}]...'.format(len(loads), job_id))
# _log.info('Adding {} tasks to job... | [
"Adds a task for each input file in the collection to the specified job.\n\n :param batch_service_client: A Batch service client.\n :type batch_service_client: `azure.batch.BatchServiceClient`\n :param str job_id: The ID of the job to which to add the tasks.\n :param list input_files: A collection of in... |
Please provide a description of the function:def wait_for_tasks_to_complete(batch_service_client, job_ids, timeout):
timeout_expiration = datetime.datetime.now() + timeout
print("Monitoring all tasks for 'Completed' state, timeout in {}...".format(timeout), end='')
while datetime.datetime.now() < tim... | [
"Returns when all tasks in the specified job reach the Completed state.\n\n :param batch_service_client: A Batch service client.\n :type batch_service_client: `azure.batch.BatchServiceClient`\n :param str job_id: The id of the job whose tasks should be to monitored.\n :param timedelta timeout: The durat... |
Please provide a description of the function:def download_blobs_from_container(block_blob_client,
container_name, directory_path,
prefix=None):
_log.info('Downloading all files from container [{}]...'.format(container_name))
container_blo... | [
"Downloads all blobs from the specified Azure Blob storage container.\n\n :param block_blob_client: A blob service client.\n :type block_blob_client: `azure.storage.blob.BlockBlobService`\n :param container_name: The Azure Blob storage container from which to\n download files.\n :param directory_pat... |
Please provide a description of the function:def _read_stream_as_string(stream, encoding):
output = io.BytesIO()
try:
for data in stream:
output.write(data)
if encoding is None:
encoding = 'utf-8'
return output.getvalue().decode(encoding)
finally:
... | [
"Read stream as string\n Originally in azure-batch-samples.Python.Batch.common.helpers\n\n :param stream: input stream generator\n :param str encoding: The encoding of the file. The default is utf-8.\n :return: The file content.\n :rtype: str\n "
] |
Please provide a description of the function:def read_task_file_as_string(
batch_client, job_id, task_id, file_name, encoding=None):
stream = batch_client.file.get_from_task(job_id, task_id, file_name)
return _read_stream_as_string(stream, encoding) | [
"Reads the specified file as a string.\n Originally in azure-batch-samples.Python.Batch.common.helpers\n\n :param batch_client: The batch client to use.\n :type batch_client: `batchserviceclient.BatchServiceClient`\n :param str job_id: The id of the job.\n :param str task_id: The id of the task.\n ... |
Please provide a description of the function:def print_task_output(batch_client, job_id, task_ids, encoding=None):
for task_id in task_ids:
file_text = read_task_file_as_string(
batch_client,
job_id,
task_id,
_STANDARD_OUT_FILE_NAME,
encoding)... | [
"Prints the stdout and stderr for each task specified.\n Originally in azure-batch-samples.Python.Batch.common.helpers\n\n :param batch_client: The batch client to use.\n :type batch_client: `batchserviceclient.BatchServiceClient`\n :param str job_id: The id of the job to monitor.\n :param task_ids: ... |
Please provide a description of the function:def run_azure(target, jobs, n=1, path='.', delete=True, config=None):
if config is None:
raise ValueError('Argument \'config\' must be given.')
elif isinstance(config, str):
if not os.path.isfile(config):
raise FileNotFoundError('A f... | [
"Execute a function for multiple sets of arguments on Microsoft Azure,\n and return the results as a list.\n\n :param function target: A target function.\n :param list jobs: A list of sets of arguments given to the target.\n :param int n: The number of repeats running the target. 1 as default.\n :par... |
Please provide a description of the function:def singlerun(job, task_id=0, job_id=0):
import ecell4_base
import ecell4
import ecell4.util.simulation
import ecell4.util.decorator
print('ecell4_base.__version__ = {:s}'.format(ecell4_base.__version__))
print('ecell4.__version__ = {:s}'.format... | [
"This task is for an example."
] |
Please provide a description of the function:def plot_number_observer(*args, **kwargs):
interactive = kwargs.pop('interactive', False)
if interactive:
plot_number_observer_with_nya(*args, **kwargs)
# elif __on_ipython_notebook():
# kwargs['to_png'] = True
# plot_number_observer_... | [
"\n Generate a plot from NumberObservers and show it.\n See plot_number_observer_with_matplotlib and _with_nya for details.\n\n Parameters\n ----------\n obs : NumberObserver (e.g. FixedIntervalNumberObserver)\n interactive : bool, default False\n Choose a visualizer. If False, show the plo... |
Please provide a description of the function:def plot_world(*args, **kwargs):
interactive = kwargs.pop('interactive', True)
if interactive:
plot_world_with_elegans(*args, **kwargs)
else:
plot_world_with_matplotlib(*args, **kwargs) | [
"\n Generate a plot from received instance of World and show it.\n See also plot_world_with_elegans and plot_world_with_matplotlib.\n\n Parameters\n ----------\n world : World or str\n World or a HDF5 filename to render.\n interactive : bool, default True\n Choose a visualizer. If Fa... |
Please provide a description of the function:def plot_movie(*args, **kwargs):
interactive = kwargs.pop('interactive', False)
if interactive:
plot_movie_with_elegans(*args, **kwargs)
else:
plot_movie_with_matplotlib(*args, **kwargs) | [
"\n Generate a movie from received instances of World and show them.\n See also plot_movie_with_elegans and plot_movie_with_matplotlib.\n\n Parameters\n ----------\n worlds : list of World\n Worlds to render.\n interactive : bool, default True\n Choose a visualizer. If False, show th... |
Please provide a description of the function:def plot_trajectory(*args, **kwargs):
interactive = kwargs.pop('interactive', True)
if interactive:
plot_trajectory_with_elegans(*args, **kwargs)
else:
plot_trajectory_with_matplotlib(*args, **kwargs) | [
"\n Generate a plot from received instance of TrajectoryObserver and show it\n See also plot_trajectory_with_elegans and plot_trajectory_with_matplotlib.\n\n Parameters\n ----------\n obs : TrajectoryObserver\n TrajectoryObserver to render.\n interactive : bool, default True\n Choose... |
Please provide a description of the function:def plot_number_observer_with_matplotlib(*args, **kwargs):
import matplotlib.pylab as plt
import numpy
import collections
special_keys = ("xlim", "ylim", "xlabel", "ylabel", "legend", "x", "y", "filename")
plot_opts = {key: value for key, value in k... | [
"\n Generate a plot from NumberObservers and show it on IPython notebook\n with matplotlib.\n\n Parameters\n ----------\n obs : NumberObserver (e.g. FixedIntervalNumberObserver)\n fmt : str, optional\n opt : dict, optional\n matplotlib plot options.\n\n Examples\n --------\n >>>... |
Please provide a description of the function:def plot_number_observer_with_nya(obs, config=None, width=600, height=400, x=None, y=None, to_png=False):
config = config or {}
from IPython.core.display import display, HTML
import numpy
config = {}
color_scale = default_color_scale(config=config)... | [
"\n Generate a plot from NumberObservers and show it on IPython notebook\n with nyaplot.\n\n Parameters\n ----------\n obs : NumberObserver (e.g. FixedIntervalNumberObserver)\n config : dict, optional\n A config data for coloring. The dictionary will be updated during this plot.\n width ... |
Please provide a description of the function:def __parse_world(
world, radius=None, species_list=None, max_count=None,
predicator=None):
from ecell4_base.core import Species
if species_list is None:
species_list = [
p.species().serial() for pid, p in world.list_particle... | [
"\n Private function to parse world. Return infomation about particles\n (name, coordinates and particle size) for each species.\n\n "
] |
Please provide a description of the function:def plot_movie_with_elegans(
worlds, radius=None, width=500, height=500, config=None, grid=False,
species_list=None):
config = config or {}
from IPython.core.display import display, HTML
from jinja2 import Template
data = {}
sizes =... | [
"\n Generate a movie from received instances of World and show them\n on IPython notebook.\n\n Parameters\n ----------\n worlds : list of World\n Worlds to render.\n radius : float, default None\n If this value is set, all particles in the world will be rendered\n as if their ... |
Please provide a description of the function:def plot_world_with_elegans(
world, radius=None, width=350, height=350, config=None, grid=True,
wireframe=False, species_list=None, debug=None, max_count=1000,
camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6),
return_id=False, p... | [
"\n Generate a plot from received instance of World and show it on IPython notebook.\n This method returns the instance of dict that indicates color setting\n for each speices. You can use the dict as the parameter of plot_world,\n in order to use the same colors in another plot.\n\n Parameters\n ... |
Please provide a description of the function:def plot_dense_array(
arr, length=256, ranges=None, colors=("#a6cee3", "#fb9a99"), grid=False, camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6)):
import numpy
from PIL import Image
from base64 import b64encode
from tempfile import ... | [
"\n Volume renderer\n\n Parameters\n ----------\n arr : list of numpy.array\n i.e. [array([[1,2,3], [2,3,4]]), array([[1,2,3]])]\n ranges : list of tuple\n ranges for x, y, and z axis\n i.e. [(-100, 100), (-100, 100), (-100, 100)]\n colors : list of string\n colors for ... |
Please provide a description of the function:def generate_html(keywords, tmpl_path, package_name='ecell4.util'):
from jinja2 import Template
import pkgutil
template = Template(pkgutil.get_data(package_name, tmpl_path).decode())
# path = os.path.abspath(os.path.dirname(__file__)) + tmpl_path
# ... | [
"\n Generate static html file from JSON model and its own id.\n\n Parameters\n ----------\n model : dict\n JSON model from which ecell4.viz generates a plot.\n model_id : string\n Unique id for the plot.\n\n Returns\n -------\n html :\n A HTML object\n "
] |
Please provide a description of the function:def plot_trajectory_with_elegans(
obs, width=350, height=350, config=None, grid=True, wireframe=False,
max_count=10, camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6),
plot_range=None):
config = config or {}
from IPython.co... | [
"\n Generate a plot from received instance of TrajectoryObserver and show it\n on IPython notebook.\n\n Parameters\n ----------\n obs : TrajectoryObserver\n TrajectoryObserver to render.\n width : float, default 350\n Width of the plotting area.\n height : float, default 350\n ... |
Please provide a description of the function:def plot_world_with_matplotlib(
world, marker_size=3, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=1000, angle=None,
legend=True, noaxis=False, **kwargs):
import matplotlib.pyplot as plt
if species_list is None:
... | [
"\n Generate a plot from received instance of World and show it on IPython notebook.\n\n Parameters\n ----------\n world : World or str\n World to render. A HDF5 filename is also acceptable.\n marker_size : float, default 3\n Marker size for all species. Size is passed to scatter functi... |
Please provide a description of the function:def plot_trajectory_with_matplotlib(
obs, max_count=10, figsize=6, legend=True, angle=None,
wireframe=False, grid=True, noaxis=False, plot_range=None, **kwargs):
import matplotlib.pyplot as plt
data = obs.data()
if max_count is not None and ... | [
"\n Generate a plot from received instance of TrajectoryObserver and show it\n on IPython notebook.\n\n Parameters\n ----------\n obs : TrajectoryObserver\n TrajectoryObserver to render.\n max_count : Integer, default 10\n The maximum number of particles to show. If None, show all.\n... |
Please provide a description of the function:def plot_trajectory2d_with_matplotlib(
obs, plane='xy', max_count=10, figsize=6, legend=True,
wireframe=False, grid=True, noaxis=False, plot_range=None, **kwargs):
import matplotlib.pyplot as plt
plane = plane.lower()
if len(plane) != 2 or p... | [
"\n Make a 2D plot from received instance of TrajectoryObserver and show it\n on IPython notebook.\n\n Parameters\n ----------\n obs : TrajectoryObserver\n TrajectoryObserver to render.\n plane : str, default 'xy'\n 'xy', 'yz', 'zx'.\n max_count : Integer, default 10\n The ... |
Please provide a description of the function:def plot_movie_of_trajectory2d_with_matplotlib(
obs, plane='xy', figsize=6, grid=True,
wireframe=False, max_count=None, angle=None, noaxis=False,
interval=0.16, repeat_delay=3000, stride=1, rotate=None,
legend=True, output=None, crf=10, bitrat... | [
"\n Generate a move from the received list of instances of World,\n and show it on IPython notebook. This function may require ffmpeg.\n\n Parameters\n ----------\n worlds : list or FixedIntervalHDF5Observer\n A list of Worlds to render.\n plane : str, default 'xy'\n 'xy', 'yz', 'zx'... |
Please provide a description of the function:def plot_movie_of_trajectory_with_matplotlib(
obs, figsize=6, grid=True,
wireframe=False, max_count=None, angle=None, noaxis=False,
interval=0.16, repeat_delay=3000, stride=1, rotate=None,
legend=True, output=None, crf=10, bitrate='1M', plot_r... | [
"\n Generate a move from the received list of instances of World,\n and show it on IPython notebook. This function may require ffmpeg.\n\n Parameters\n ----------\n worlds : list or FixedIntervalHDF5Observer\n A list of Worlds to render.\n marker_size : float, default 3\n Marker size... |
Please provide a description of the function:def plot_world_with_attractive_mpl(
world, marker_size=6, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=1000, angle=None,
legend=True, noaxis=False, whratio=1.33, scale=1.0, **kwargs):
import matplotlib.pyplot as plt
... | [
"\n Generate a plot from received instance of World and show it on IPython notebook.\n\n Parameters\n ----------\n world : World or str\n World to render. A HDF5 filename is also acceptable.\n marker_size : float, default 3\n Marker size for all species. Size is passed to scatter functi... |
Please provide a description of the function:def plot_movie_with_attractive_mpl(
worlds, marker_size=6, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=None, angle=None, noaxis=False,
interval=0.16, repeat_delay=3000, stride=1, rotate=None,
legend=True, whratio=1.33, ... | [
"\n Generate a move from the received list of instances of World,\n and show it on IPython notebook. This function may require ffmpeg.\n\n Parameters\n ----------\n worlds : list or FixedIntervalHDF5Observer\n A list of Worlds to render.\n marker_size : float, default 3\n Marker size... |
Please provide a description of the function:def plot_world2d_with_matplotlib(
world, plane='xy', marker_size=3, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=1000, angle=None,
legend=True, noaxis=False, scale=1.0, **kwargs):
import matplotlib.pyplot as plt
pl... | [
"\n Make a 2D plot from received instance of World and show it on IPython notebook.\n\n Parameters\n ----------\n world : World or str\n World to render. A HDF5 filename is also acceptable.\n plane : str, default 'xy'\n 'xy', 'yz', 'zx'.\n marker_size : float, default 3\n Mark... |
Please provide a description of the function:def plot_movie2d_with_matplotlib(
worlds, plane='xy', marker_size=3, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=None, angle=None, noaxis=False,
interval=0.16, repeat_delay=3000, stride=1, rotate=None,
legend=True, scal... | [
"\n Generate a movie projected on the given plane from the received list\n of instances of World, and show it on IPython notebook.\n This function may require ffmpeg.\n\n Parameters\n ----------\n worlds : list or FixedIntervalHDF5Observer\n A list of Worlds to render.\n plane : str, def... |
Please provide a description of the function:def plot_world_with_plotly(world, species_list=None, max_count=1000):
if isinstance(world, str):
from .simulation import load_world
world = load_world(world)
if species_list is None:
species_list = [sp.serial() for sp in world.list_speci... | [
"\n Plot a World on IPython Notebook\n "
] |
Please provide a description of the function:def getUnitRegistry(length="meter", time="second", substance="item", volume=None, other=()):
ureg = pint.UnitRegistry()
ureg.define('item = mole / (avogadro_number * 1 mole)')
try:
pint.molar
# except UndefinedUnitError:
except AttributeErro... | [
"Return a pint.UnitRegistry made compatible with ecell4.\n\n Parameters\n ----------\n length : str, optional\n A default unit for '[length]'. 'meter' is its default.\n time : str, optional\n A default unit for '[time]'. 'second' is its default.\n substance : str, optional\n A de... |
Please provide a description of the function:def interactor(self, geneList=None, org=None):
geneList = geneList or []
organisms = organisms or []
querydata = self.interactions(geneList, org)
returnData = {}
for i in querydata:
if not returnData.get(i["symB"]... | [
"\n Supposing geneList returns an unique item.\n "
] |
Please provide a description of the function:def parse_psimitab(content, fmt='tab27'):
columns = [
'Unique identifier for interactor A',
'Unique identifier for interactor B',
'Alternative identifier for interactor A',
'Alternative identifier for interactor B',
'Aliases f... | [
"https://code.google.com/archive/p/psimi/wikis/PsimiTab27Format.wiki\n "
] |
Please provide a description of the function:def export_sbml(model, y0=None, volume=1.0, is_valid=True):
y0 = y0 or {}
import libsbml
document = libsbml.SBMLDocument(3, 1)
# ns = libsbml.XMLNamespaces()
# ns.add("http://www.ecell.org/ns/ecell4", "ecell4") #XXX: DUMMY URI
# document.setN... | [
"\n Export a model as a SBMLDocument.\n\n Parameters\n ----------\n model : NetworkModel\n y0 : dict\n Initial condition.\n volume : Real or Real3, optional\n A size of the simulation volume. 1 as a default.\n is_valid : bool, optional\n Check if the generated model is vali... |
Please provide a description of the function:def save_sbml(filename, model, y0=None, volume=1.0, is_valid=True):
y0 = y0 or {}
import libsbml
document = export_sbml(model, y0, volume, is_valid)
# with open(filename, 'w') as fout:
# fout.write(libsbml.writeSBMLToString(document))
# wr... | [
"\n Save a model in the SBML format.\n\n Parameters\n ----------\n model : NetworkModel\n y0 : dict\n Initial condition.\n volume : Real or Real3, optional\n A size of the simulation volume.\n is_valid : bool, optional\n Check if the generated model is valid. True as a defa... |
Please provide a description of the function:def import_sbml(document):
from ecell4.util.decorator import generate_ratelaw
m = document.getModel()
if m.getNumCompartments() == 0:
raise RuntimeError("No compartment was found.")
elif m.getNumCompartments() > 1:
warnings.warn(
... | [
"\n Import a model from a SBMLDocument.\n\n Parameters\n ----------\n document : SBMLDocument\n\n Returns\n -------\n model : NetworkModel\n y0 : dict\n Initial condition.\n volume : Real or Real3, optional\n A size of the simulation volume.\n\n "
] |
Please provide a description of the function:def load_sbml(filename):
import libsbml
document = libsbml.readSBML(filename)
document.validateSBML()
num_errors = (document.getNumErrors(libsbml.LIBSBML_SEV_ERROR)
+ document.getNumErrors(libsbml.LIBSBML_SEV_FATAL))
if num_errors ... | [
"\n Load a model from a SBML file.\n\n Parameters\n ----------\n filename : str\n The input SBML filename.\n\n Returns\n -------\n model : NetworkModel\n y0 : dict\n Initial condition.\n volume : Real or Real3, optional\n A size of the simulation volume.\n\n "
] |
Please provide a description of the function:def get_model(is_netfree=False, without_reset=False, seeds=None, effective=False):
try:
if seeds is not None or is_netfree:
m = ecell4_base.core.NetfreeModel()
else:
m = ecell4_base.core.NetworkModel()
for sp in SPECI... | [
"\n Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES``\n and ``REACTIONRULES``.\n\n Parameters\n ----------\n is_netfree : bool, optional\n Return ``NetfreeModel`` if True, and ``NetworkModel`` if else.\n Default is False.\n without_reset : bool, optional\n ... |
Please provide a description of the function:def run_serial(target, jobs, n=1, **kwargs):
return [[target(copy.copy(job), i + 1, j + 1) for j in range(n)] for i, job in enumerate(jobs)] | [
"\n Evaluate the given function with each set of arguments, and return a list of results.\n This function does in series.\n\n Parameters\n ----------\n target : function\n A function to be evaluated. The function must accepts three arguments,\n which are a list of arguments given as `jo... |
Please provide a description of the function:def run_multiprocessing(target, jobs, n=1, nproc=None, **kwargs):
def consumer(f, q_in, q_out):
while True:
val = q_in.get()
if val is None:
q_in.task_done()
break
i, x = val
res... | [
"\n Evaluate the given function with each set of arguments, and return a list of results.\n This function does in parallel by using `multiprocessing`.\n\n Parameters\n ----------\n target : function\n A function to be evaluated. The function must accepts three arguments,\n which are a l... |
Please provide a description of the function:def run_sge(target, jobs, n=1, nproc=None, path='.', delete=True, wait=True, environ=None, modules=(), **kwargs):
logging.basicConfig(level=logging.DEBUG)
if isinstance(target, types.LambdaType) and target.__name__ == "<lambda>":
raise RuntimeError("A l... | [
"\n Evaluate the given function with each set of arguments, and return a list of results.\n This function does in parallel on the Sun Grid Engine einvironment.\n\n Parameters\n ----------\n target : function\n A function to be evaluated. The function must accepts three arguments,\n whic... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.