repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
seznam/shelter | shelter/commands/startproject.py | substitute | def substitute(template, mapping=None):
"""
Render the template *template*. *mapping* is a :class:`dict` with
values to add to the template.
"""
if mapping is None:
mapping = {}
templ = Template(template)
return templ.substitute(mapping) | python | def substitute(template, mapping=None):
"""
Render the template *template*. *mapping* is a :class:`dict` with
values to add to the template.
"""
if mapping is None:
mapping = {}
templ = Template(template)
return templ.substitute(mapping) | [
"def",
"substitute",
"(",
"template",
",",
"mapping",
"=",
"None",
")",
":",
"if",
"mapping",
"is",
"None",
":",
"mapping",
"=",
"{",
"}",
"templ",
"=",
"Template",
"(",
"template",
")",
"return",
"templ",
".",
"substitute",
"(",
"mapping",
")"
] | Render the template *template*. *mapping* is a :class:`dict` with
values to add to the template. | [
"Render",
"the",
"template",
"*",
"template",
"*",
".",
"*",
"mapping",
"*",
"is",
"a",
":",
"class",
":",
"dict",
"with",
"values",
"to",
"add",
"to",
"the",
"template",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/commands/startproject.py#L17-L25 |
seznam/shelter | shelter/commands/startproject.py | dirtree | def dirtree(path):
"""
Find recursively and return all files and directories from
the path *path*.
"""
results = []
for name in glob.glob(os.path.join(path, '*')):
results.append(name)
if os.path.isdir(name):
results.extend(dirtree(name))
return results | python | def dirtree(path):
"""
Find recursively and return all files and directories from
the path *path*.
"""
results = []
for name in glob.glob(os.path.join(path, '*')):
results.append(name)
if os.path.isdir(name):
results.extend(dirtree(name))
return results | [
"def",
"dirtree",
"(",
"path",
")",
":",
"results",
"=",
"[",
"]",
"for",
"name",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'*'",
")",
")",
":",
"results",
".",
"append",
"(",
"name",
")",
"if",
"os",
... | Find recursively and return all files and directories from
the path *path*. | [
"Find",
"recursively",
"and",
"return",
"all",
"files",
"and",
"directories",
"from",
"the",
"path",
"*",
"path",
"*",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/commands/startproject.py#L28-L38 |
seznam/shelter | shelter/core/app.py | get_tornado_apps | def get_tornado_apps(context, debug=False):
"""
Create Tornado's application for all interfaces which are defined
in the configuration. *context* is instance of the
:class:`shelter.core.context.Context`. If *debug* is :const:`True`,
server will be run in **DEBUG** mode. Return :class:`list` of the
... | python | def get_tornado_apps(context, debug=False):
"""
Create Tornado's application for all interfaces which are defined
in the configuration. *context* is instance of the
:class:`shelter.core.context.Context`. If *debug* is :const:`True`,
server will be run in **DEBUG** mode. Return :class:`list` of the
... | [
"def",
"get_tornado_apps",
"(",
"context",
",",
"debug",
"=",
"False",
")",
":",
"if",
"context",
".",
"config",
".",
"app_settings_handler",
":",
"app_settings_handler",
"=",
"import_object",
"(",
"context",
".",
"config",
".",
"app_settings_handler",
")",
"set... | Create Tornado's application for all interfaces which are defined
in the configuration. *context* is instance of the
:class:`shelter.core.context.Context`. If *debug* is :const:`True`,
server will be run in **DEBUG** mode. Return :class:`list` of the
:class:`tornado.web.Application` instances. | [
"Create",
"Tornado",
"s",
"application",
"for",
"all",
"interfaces",
"which",
"are",
"defined",
"in",
"the",
"configuration",
".",
"*",
"context",
"*",
"is",
"instance",
"of",
"the",
":",
"class",
":",
"shelter",
".",
"core",
".",
"context",
".",
"Context"... | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/core/app.py#L14-L40 |
seznam/shelter | shelter/core/processes.py | BaseProcess.run | def run(self):
"""
Child process. Repeatedly call :meth:`loop` method every
:attribute:`interval` seconds.
"""
setproctitle.setproctitle("{:s}: {:s}".format(
self.context.config.name, self.__class__.__name__))
self.logger.info(
"Worker '%s' has bee... | python | def run(self):
"""
Child process. Repeatedly call :meth:`loop` method every
:attribute:`interval` seconds.
"""
setproctitle.setproctitle("{:s}: {:s}".format(
self.context.config.name, self.__class__.__name__))
self.logger.info(
"Worker '%s' has bee... | [
"def",
"run",
"(",
"self",
")",
":",
"setproctitle",
".",
"setproctitle",
"(",
"\"{:s}: {:s}\"",
".",
"format",
"(",
"self",
".",
"context",
".",
"config",
".",
"name",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
")",
"self",
".",
"logger",
".... | Child process. Repeatedly call :meth:`loop` method every
:attribute:`interval` seconds. | [
"Child",
"process",
".",
"Repeatedly",
"call",
":",
"meth",
":",
"loop",
"method",
"every",
":",
"attribute",
":",
"interval",
"seconds",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/core/processes.py#L68-L110 |
fhcrc/taxtastic | taxtastic/utils.py | get_new_nodes | def get_new_nodes(fname):
"""
Return an iterator of dicts given a .csv-format file.
"""
with open(fname, 'rU') as infile:
infile = (line for line in infile if not line.startswith('#'))
reader = list(csv.DictReader(infile))
rows = (d for d in reader if d['tax_id'])
# for now... | python | def get_new_nodes(fname):
"""
Return an iterator of dicts given a .csv-format file.
"""
with open(fname, 'rU') as infile:
infile = (line for line in infile if not line.startswith('#'))
reader = list(csv.DictReader(infile))
rows = (d for d in reader if d['tax_id'])
# for now... | [
"def",
"get_new_nodes",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'rU'",
")",
"as",
"infile",
":",
"infile",
"=",
"(",
"line",
"for",
"line",
"in",
"infile",
"if",
"not",
"line",
".",
"startswith",
"(",
"'#'",
")",
")",
"reader",
... | Return an iterator of dicts given a .csv-format file. | [
"Return",
"an",
"iterator",
"of",
"dicts",
"given",
"a",
".",
"csv",
"-",
"format",
"file",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L29-L48 |
fhcrc/taxtastic | taxtastic/utils.py | getlines | def getlines(fname):
"""
Returns iterator of whitespace-stripped lines in file, omitting
blank lines, lines beginning with '#', and line contents following
the first '#' character.
"""
with open(fname, 'rU') as f:
for line in f:
if line.strip() and not line.startswith('#'):
... | python | def getlines(fname):
"""
Returns iterator of whitespace-stripped lines in file, omitting
blank lines, lines beginning with '#', and line contents following
the first '#' character.
"""
with open(fname, 'rU') as f:
for line in f:
if line.strip() and not line.startswith('#'):
... | [
"def",
"getlines",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'rU'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"strip",
"(",
")",
"and",
"not",
"line",
".",
"startswith",
"(",
"'#'",
")",
":",
"yiel... | Returns iterator of whitespace-stripped lines in file, omitting
blank lines, lines beginning with '#', and line contents following
the first '#' character. | [
"Returns",
"iterator",
"of",
"whitespace",
"-",
"stripped",
"lines",
"in",
"file",
"omitting",
"blank",
"lines",
"lines",
"beginning",
"with",
"#",
"and",
"line",
"contents",
"following",
"the",
"first",
"#",
"character",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L51-L61 |
fhcrc/taxtastic | taxtastic/utils.py | parse_raxml | def parse_raxml(handle):
"""Parse RAxML's summary output.
*handle* should be an open file handle containing the RAxML
output. It is parsed and a dictionary returned.
"""
s = ''.join(handle.readlines())
result = {}
try_set_fields(result, r'(?P<program>RAxML version [0-9.]+)', s)
try_set... | python | def parse_raxml(handle):
"""Parse RAxML's summary output.
*handle* should be an open file handle containing the RAxML
output. It is parsed and a dictionary returned.
"""
s = ''.join(handle.readlines())
result = {}
try_set_fields(result, r'(?P<program>RAxML version [0-9.]+)', s)
try_set... | [
"def",
"parse_raxml",
"(",
"handle",
")",
":",
"s",
"=",
"''",
".",
"join",
"(",
"handle",
".",
"readlines",
"(",
")",
")",
"result",
"=",
"{",
"}",
"try_set_fields",
"(",
"result",
",",
"r'(?P<program>RAxML version [0-9.]+)'",
",",
"s",
")",
"try_set_fiel... | Parse RAxML's summary output.
*handle* should be an open file handle containing the RAxML
output. It is parsed and a dictionary returned. | [
"Parse",
"RAxML",
"s",
"summary",
"output",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L76-L109 |
fhcrc/taxtastic | taxtastic/utils.py | parse_stockholm | def parse_stockholm(fobj):
"""Return a list of names from an Stockholm-format sequence alignment
file. ``fobj`` is an open file or another object representing a
sequence of lines.
"""
names = OrderedDict()
found_eof = False
for line in fobj:
line = line.strip()
if line == ... | python | def parse_stockholm(fobj):
"""Return a list of names from an Stockholm-format sequence alignment
file. ``fobj`` is an open file or another object representing a
sequence of lines.
"""
names = OrderedDict()
found_eof = False
for line in fobj:
line = line.strip()
if line == ... | [
"def",
"parse_stockholm",
"(",
"fobj",
")",
":",
"names",
"=",
"OrderedDict",
"(",
")",
"found_eof",
"=",
"False",
"for",
"line",
"in",
"fobj",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
"==",
"'//'",
":",
"found_eof",
"=",
"True... | Return a list of names from an Stockholm-format sequence alignment
file. ``fobj`` is an open file or another object representing a
sequence of lines. | [
"Return",
"a",
"list",
"of",
"names",
"from",
"an",
"Stockholm",
"-",
"format",
"sequence",
"alignment",
"file",
".",
"fobj",
"is",
"an",
"open",
"file",
"or",
"another",
"object",
"representing",
"a",
"sequence",
"of",
"lines",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L208-L231 |
fhcrc/taxtastic | taxtastic/utils.py | has_rppr | def has_rppr(rppr_name='rppr'):
"""
Check for rppr binary in path
"""
with open(os.devnull) as dn:
try:
subprocess.check_call([rppr_name], stdout=dn, stderr=dn)
except OSError as e:
if e.errno == os.errno.ENOENT:
return False
else:
... | python | def has_rppr(rppr_name='rppr'):
"""
Check for rppr binary in path
"""
with open(os.devnull) as dn:
try:
subprocess.check_call([rppr_name], stdout=dn, stderr=dn)
except OSError as e:
if e.errno == os.errno.ENOENT:
return False
else:
... | [
"def",
"has_rppr",
"(",
"rppr_name",
"=",
"'rppr'",
")",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
")",
"as",
"dn",
":",
"try",
":",
"subprocess",
".",
"check_call",
"(",
"[",
"rppr_name",
"]",
",",
"stdout",
"=",
"dn",
",",
"stderr",
"=",
"d... | Check for rppr binary in path | [
"Check",
"for",
"rppr",
"binary",
"in",
"path"
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L234-L249 |
fhcrc/taxtastic | taxtastic/utils.py | add_database_args | def add_database_args(parser):
'''
Add a standard set of database arguments for argparse
'''
parser.add_argument(
'url',
nargs='?',
default='sqlite:///ncbi_taxonomy.db',
type=sqlite_default(),
help=('Database string URI or filename. If no database scheme '
... | python | def add_database_args(parser):
'''
Add a standard set of database arguments for argparse
'''
parser.add_argument(
'url',
nargs='?',
default='sqlite:///ncbi_taxonomy.db',
type=sqlite_default(),
help=('Database string URI or filename. If no database scheme '
... | [
"def",
"add_database_args",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'url'",
",",
"nargs",
"=",
"'?'",
",",
"default",
"=",
"'sqlite:///ncbi_taxonomy.db'",
",",
"type",
"=",
"sqlite_default",
"(",
")",
",",
"help",
"=",
"(",
"'Database s... | Add a standard set of database arguments for argparse | [
"Add",
"a",
"standard",
"set",
"of",
"database",
"arguments",
"for",
"argparse"
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L252-L271 |
fhcrc/taxtastic | taxtastic/utils.py | sqlite_default | def sqlite_default():
'''
Prepend default scheme if none is specified. This helps provides backwards
compatibility with old versions of taxtastic where sqlite was the automatic
default database.
'''
def parse_url(url):
# TODO: need separate option for a config file
if url.endswit... | python | def sqlite_default():
'''
Prepend default scheme if none is specified. This helps provides backwards
compatibility with old versions of taxtastic where sqlite was the automatic
default database.
'''
def parse_url(url):
# TODO: need separate option for a config file
if url.endswit... | [
"def",
"sqlite_default",
"(",
")",
":",
"def",
"parse_url",
"(",
"url",
")",
":",
"# TODO: need separate option for a config file",
"if",
"url",
".",
"endswith",
"(",
"'.db'",
")",
"or",
"url",
".",
"endswith",
"(",
"'.sqlite'",
")",
":",
"if",
"not",
"url",... | Prepend default scheme if none is specified. This helps provides backwards
compatibility with old versions of taxtastic where sqlite was the automatic
default database. | [
"Prepend",
"default",
"scheme",
"if",
"none",
"is",
"specified",
".",
"This",
"helps",
"provides",
"backwards",
"compatibility",
"with",
"old",
"versions",
"of",
"taxtastic",
"where",
"sqlite",
"was",
"the",
"automatic",
"default",
"database",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L274-L292 |
fhcrc/taxtastic | taxtastic/subcommands/strip.py | action | def action(args):
"""Strips non-current files and rollback information from a refpkg.
*args* should be an argparse object with fields refpkg (giving the
path to the refpkg to operate on).
"""
log.info('loading reference package')
refpkg.Refpkg(args.refpkg, create=False).strip() | python | def action(args):
"""Strips non-current files and rollback information from a refpkg.
*args* should be an argparse object with fields refpkg (giving the
path to the refpkg to operate on).
"""
log.info('loading reference package')
refpkg.Refpkg(args.refpkg, create=False).strip() | [
"def",
"action",
"(",
"args",
")",
":",
"log",
".",
"info",
"(",
"'loading reference package'",
")",
"refpkg",
".",
"Refpkg",
"(",
"args",
".",
"refpkg",
",",
"create",
"=",
"False",
")",
".",
"strip",
"(",
")"
] | Strips non-current files and rollback information from a refpkg.
*args* should be an argparse object with fields refpkg (giving the
path to the refpkg to operate on). | [
"Strips",
"non",
"-",
"current",
"files",
"and",
"rollback",
"information",
"from",
"a",
"refpkg",
"."
] | train | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/subcommands/strip.py#L37-L45 |
seznam/shelter | shelter/contrib/config/iniconfig.py | get_conf_d_files | def get_conf_d_files(path):
"""
Return alphabetical ordered :class:`list` of the *.conf* files
placed in the path. *path* is a directory path.
::
>>> get_conf_d_files('conf/conf.d/')
['conf/conf.d/10-base.conf', 'conf/conf.d/99-dev.conf']
"""
if not os.path.isdir(path):
... | python | def get_conf_d_files(path):
"""
Return alphabetical ordered :class:`list` of the *.conf* files
placed in the path. *path* is a directory path.
::
>>> get_conf_d_files('conf/conf.d/')
['conf/conf.d/10-base.conf', 'conf/conf.d/99-dev.conf']
"""
if not os.path.isdir(path):
... | [
"def",
"get_conf_d_files",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"\"'%s' is not a directory\"",
"%",
"path",
")",
"files_mask",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | Return alphabetical ordered :class:`list` of the *.conf* files
placed in the path. *path* is a directory path.
::
>>> get_conf_d_files('conf/conf.d/')
['conf/conf.d/10-base.conf', 'conf/conf.d/99-dev.conf'] | [
"Return",
"alphabetical",
"ordered",
":",
"class",
":",
"list",
"of",
"the",
"*",
".",
"conf",
"*",
"files",
"placed",
"in",
"the",
"path",
".",
"*",
"path",
"*",
"is",
"a",
"directory",
"path",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/contrib/config/iniconfig.py#L29-L42 |
seznam/shelter | shelter/contrib/config/iniconfig.py | get_conf_files | def get_conf_files(filename):
"""
Return :class:`list` of the all configuration files. *filename* is a
path of the main configuration file.
::
>>> get_conf_files('exampleapp.conf')
['exampleapp.conf', 'exampleapp.conf.d/10-database.conf']
"""
if not os.path.isfile(filename):
... | python | def get_conf_files(filename):
"""
Return :class:`list` of the all configuration files. *filename* is a
path of the main configuration file.
::
>>> get_conf_files('exampleapp.conf')
['exampleapp.conf', 'exampleapp.conf.d/10-database.conf']
"""
if not os.path.isfile(filename):
... | [
"def",
"get_conf_files",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"raise",
"ValueError",
"(",
"\"'%s' is not a file\"",
"%",
"filename",
")",
"conf_d_path",
"=",
"\"%s.d\"",
"%",
"filename",
"if",
... | Return :class:`list` of the all configuration files. *filename* is a
path of the main configuration file.
::
>>> get_conf_files('exampleapp.conf')
['exampleapp.conf', 'exampleapp.conf.d/10-database.conf'] | [
"Return",
":",
"class",
":",
"list",
"of",
"the",
"all",
"configuration",
"files",
".",
"*",
"filename",
"*",
"is",
"a",
"path",
"of",
"the",
"main",
"configuration",
"file",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/contrib/config/iniconfig.py#L45-L60 |
seznam/shelter | shelter/contrib/config/iniconfig.py | get_configparser | def get_configparser(filename=''):
"""
Read main configuration file and all files from *conf.d* subdirectory
and return parsed configuration as a **configparser.RawConfigParser**
instance.
"""
filename = filename or os.environ.get('SHELTER_CONFIG_FILENAME', '')
if not filename:
raise... | python | def get_configparser(filename=''):
"""
Read main configuration file and all files from *conf.d* subdirectory
and return parsed configuration as a **configparser.RawConfigParser**
instance.
"""
filename = filename or os.environ.get('SHELTER_CONFIG_FILENAME', '')
if not filename:
raise... | [
"def",
"get_configparser",
"(",
"filename",
"=",
"''",
")",
":",
"filename",
"=",
"filename",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'SHELTER_CONFIG_FILENAME'",
",",
"''",
")",
"if",
"not",
"filename",
":",
"raise",
"ImproperlyConfiguredError",
"(",
"... | Read main configuration file and all files from *conf.d* subdirectory
and return parsed configuration as a **configparser.RawConfigParser**
instance. | [
"Read",
"main",
"configuration",
"file",
"and",
"all",
"files",
"from",
"*",
"conf",
".",
"d",
"*",
"subdirectory",
"and",
"return",
"parsed",
"configuration",
"as",
"a",
"**",
"configparser",
".",
"RawConfigParser",
"**",
"instance",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/contrib/config/iniconfig.py#L63-L82 |
seznam/shelter | shelter/contrib/config/iniconfig.py | IniConfig.name | def name(self):
"""
Application name. It's used as a process name.
"""
try:
return self.config_parser.get('application', 'name')
except CONFIGPARSER_EXC:
return super(IniConfig, self).name | python | def name(self):
"""
Application name. It's used as a process name.
"""
try:
return self.config_parser.get('application', 'name')
except CONFIGPARSER_EXC:
return super(IniConfig, self).name | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"config_parser",
".",
"get",
"(",
"'application'",
",",
"'name'",
")",
"except",
"CONFIGPARSER_EXC",
":",
"return",
"super",
"(",
"IniConfig",
",",
"self",
")",
".",
"name"
] | Application name. It's used as a process name. | [
"Application",
"name",
".",
"It",
"s",
"used",
"as",
"a",
"process",
"name",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/contrib/config/iniconfig.py#L128-L135 |
seznam/shelter | shelter/contrib/config/iniconfig.py | IniConfig.interfaces | def interfaces(self):
"""
Interfaces as a :class:`list`of the
:class:`shelter.core.config.Config.Interface` instances.
"""
if 'interfaces' not in self._cached_values:
self._cached_values['interfaces'] = []
for name, interface in six.iteritems(self.settings... | python | def interfaces(self):
"""
Interfaces as a :class:`list`of the
:class:`shelter.core.config.Config.Interface` instances.
"""
if 'interfaces' not in self._cached_values:
self._cached_values['interfaces'] = []
for name, interface in six.iteritems(self.settings... | [
"def",
"interfaces",
"(",
"self",
")",
":",
"if",
"'interfaces'",
"not",
"in",
"self",
".",
"_cached_values",
":",
"self",
".",
"_cached_values",
"[",
"'interfaces'",
"]",
"=",
"[",
"]",
"for",
"name",
",",
"interface",
"in",
"six",
".",
"iteritems",
"("... | Interfaces as a :class:`list`of the
:class:`shelter.core.config.Config.Interface` instances. | [
"Interfaces",
"as",
"a",
":",
"class",
":",
"list",
"of",
"the",
":",
"class",
":",
"shelter",
".",
"core",
".",
"config",
".",
"Config",
".",
"Interface",
"instances",
"."
] | train | https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/contrib/config/iniconfig.py#L138-L183 |
sdispater/pytzdata | pytzdata/__init__.py | tz_file | def tz_file(name):
"""
Open a timezone file from the zoneinfo subdir for reading.
:param name: The name of the timezone.
:type name: str
:rtype: file
"""
try:
filepath = tz_path(name)
return open(filepath, 'rb')
except TimezoneNotFound:
# http://bugs.launchpad.... | python | def tz_file(name):
"""
Open a timezone file from the zoneinfo subdir for reading.
:param name: The name of the timezone.
:type name: str
:rtype: file
"""
try:
filepath = tz_path(name)
return open(filepath, 'rb')
except TimezoneNotFound:
# http://bugs.launchpad.... | [
"def",
"tz_file",
"(",
"name",
")",
":",
"try",
":",
"filepath",
"=",
"tz_path",
"(",
"name",
")",
"return",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"except",
"TimezoneNotFound",
":",
"# http://bugs.launchpad.net/bugs/383171 - we avoid using this",
"# unless abso... | Open a timezone file from the zoneinfo subdir for reading.
:param name: The name of the timezone.
:type name: str
:rtype: file | [
"Open",
"a",
"timezone",
"file",
"from",
"the",
"zoneinfo",
"subdir",
"for",
"reading",
"."
] | train | https://github.com/sdispater/pytzdata/blob/5707a44e425c0ab57cf9d1f6be83528accc31412/pytzdata/__init__.py#L22-L50 |
sdispater/pytzdata | pytzdata/__init__.py | tz_path | def tz_path(name):
"""
Return the path to a timezone file.
:param name: The name of the timezone.
:type name: str
:rtype: str
"""
if not name:
raise ValueError('Invalid timezone')
name_parts = name.lstrip('/').split('/')
for part in name_parts:
if part == os.path.... | python | def tz_path(name):
"""
Return the path to a timezone file.
:param name: The name of the timezone.
:type name: str
:rtype: str
"""
if not name:
raise ValueError('Invalid timezone')
name_parts = name.lstrip('/').split('/')
for part in name_parts:
if part == os.path.... | [
"def",
"tz_path",
"(",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"'Invalid timezone'",
")",
"name_parts",
"=",
"name",
".",
"lstrip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"for",
"part",
"in",
"name_parts",
":",
... | Return the path to a timezone file.
:param name: The name of the timezone.
:type name: str
:rtype: str | [
"Return",
"the",
"path",
"to",
"a",
"timezone",
"file",
"."
] | train | https://github.com/sdispater/pytzdata/blob/5707a44e425c0ab57cf9d1f6be83528accc31412/pytzdata/__init__.py#L53-L76 |
sdispater/pytzdata | pytzdata/__init__.py | get_timezones | def get_timezones():
"""
Get the supported timezones.
The list will be cached unless you set the "fresh" attribute to True.
:param fresh: Whether to get a fresh list or not
:type fresh: bool
:rtype: tuple
"""
base_dir = _DIRECTORY
zones = ()
for root, dirs, files in os.walk(b... | python | def get_timezones():
"""
Get the supported timezones.
The list will be cached unless you set the "fresh" attribute to True.
:param fresh: Whether to get a fresh list or not
:type fresh: bool
:rtype: tuple
"""
base_dir = _DIRECTORY
zones = ()
for root, dirs, files in os.walk(b... | [
"def",
"get_timezones",
"(",
")",
":",
"base_dir",
"=",
"_DIRECTORY",
"zones",
"=",
"(",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"base_dir",
")",
":",
"for",
"basename",
"in",
"files",
":",
"zone",
"=",
"os",
".... | Get the supported timezones.
The list will be cached unless you set the "fresh" attribute to True.
:param fresh: Whether to get a fresh list or not
:type fresh: bool
:rtype: tuple | [
"Get",
"the",
"supported",
"timezones",
"."
] | train | https://github.com/sdispater/pytzdata/blob/5707a44e425c0ab57cf9d1f6be83528accc31412/pytzdata/__init__.py#L88-L114 |
pinax/pinax-points | pinax/points/models.py | award_points | def award_points(target, key, reason="", source=None):
"""
Awards target the point value for key. If key is an integer then it's a
one off assignment and should be interpreted as the actual point value.
"""
point_value, points = get_points(key)
if not ALLOW_NEGATIVE_TOTALS:
total = poi... | python | def award_points(target, key, reason="", source=None):
"""
Awards target the point value for key. If key is an integer then it's a
one off assignment and should be interpreted as the actual point value.
"""
point_value, points = get_points(key)
if not ALLOW_NEGATIVE_TOTALS:
total = poi... | [
"def",
"award_points",
"(",
"target",
",",
"key",
",",
"reason",
"=",
"\"\"",
",",
"source",
"=",
"None",
")",
":",
"point_value",
",",
"points",
"=",
"get_points",
"(",
"key",
")",
"if",
"not",
"ALLOW_NEGATIVE_TOTALS",
":",
"total",
"=",
"points_awarded",... | Awards target the point value for key. If key is an integer then it's a
one off assignment and should be interpreted as the actual point value. | [
"Awards",
"target",
"the",
"point",
"value",
"for",
"key",
".",
"If",
"key",
"is",
"an",
"integer",
"then",
"it",
"s",
"a",
"one",
"off",
"assignment",
"and",
"should",
"be",
"interpreted",
"as",
"the",
"actual",
"point",
"value",
"."
] | train | https://github.com/pinax/pinax-points/blob/c8490f847d0572943029ff4718d67094c04fadc9/pinax/points/models.py#L167-L225 |
pinax/pinax-points | pinax/points/models.py | points_awarded | def points_awarded(target=None, source=None, since=None):
"""
Determine out how many points the given target has received.
"""
lookup_params = {}
if target is not None:
if isinstance(target, get_user_model()):
lookup_params["target_user"] = target
else:
look... | python | def points_awarded(target=None, source=None, since=None):
"""
Determine out how many points the given target has received.
"""
lookup_params = {}
if target is not None:
if isinstance(target, get_user_model()):
lookup_params["target_user"] = target
else:
look... | [
"def",
"points_awarded",
"(",
"target",
"=",
"None",
",",
"source",
"=",
"None",
",",
"since",
"=",
"None",
")",
":",
"lookup_params",
"=",
"{",
"}",
"if",
"target",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"target",
",",
"get_user_model",
"(... | Determine out how many points the given target has received. | [
"Determine",
"out",
"how",
"many",
"points",
"the",
"given",
"target",
"has",
"received",
"."
] | train | https://github.com/pinax/pinax-points/blob/c8490f847d0572943029ff4718d67094c04fadc9/pinax/points/models.py#L228-L262 |
condereis/realtime-stock | rtstock/utils.py | __validate_dates | def __validate_dates(start_date, end_date):
"""Validate if a date string.
Validate if a string is a date on yyyy-mm-dd format and it the
period between them is less than a year.
"""
try:
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.str... | python | def __validate_dates(start_date, end_date):
"""Validate if a date string.
Validate if a string is a date on yyyy-mm-dd format and it the
period between them is less than a year.
"""
try:
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.str... | [
"def",
"__validate_dates",
"(",
"start_date",
",",
"end_date",
")",
":",
"try",
":",
"start_date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"start_date",
",",
"'%Y-%m-%d'",
")",
"end_date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(... | Validate if a date string.
Validate if a string is a date on yyyy-mm-dd format and it the
period between them is less than a year. | [
"Validate",
"if",
"a",
"date",
"string",
"."
] | train | https://github.com/condereis/realtime-stock/blob/5b3110d0bc2fd3e8354ab2edb5cfe6cafd6f2a94/rtstock/utils.py#L33-L48 |
condereis/realtime-stock | rtstock/utils.py | __yahoo_request | def __yahoo_request(query):
"""Request Yahoo Finance information.
Request information from YQL.
`Check <http://goo.gl/8AROUD>`_ for more information on YQL.
"""
query = quote(query)
url = 'https://query.yahooapis.com/v1/public/yql?q=' + query + \
'&format=json&env=store://datatables.org... | python | def __yahoo_request(query):
"""Request Yahoo Finance information.
Request information from YQL.
`Check <http://goo.gl/8AROUD>`_ for more information on YQL.
"""
query = quote(query)
url = 'https://query.yahooapis.com/v1/public/yql?q=' + query + \
'&format=json&env=store://datatables.org... | [
"def",
"__yahoo_request",
"(",
"query",
")",
":",
"query",
"=",
"quote",
"(",
"query",
")",
"url",
"=",
"'https://query.yahooapis.com/v1/public/yql?q='",
"+",
"query",
"+",
"'&format=json&env=store://datatables.org/alltableswithkeys'",
"response",
"=",
"urlopen",
"(",
"... | Request Yahoo Finance information.
Request information from YQL.
`Check <http://goo.gl/8AROUD>`_ for more information on YQL. | [
"Request",
"Yahoo",
"Finance",
"information",
"."
] | train | https://github.com/condereis/realtime-stock/blob/5b3110d0bc2fd3e8354ab2edb5cfe6cafd6f2a94/rtstock/utils.py#L51-L63 |
condereis/realtime-stock | rtstock/utils.py | request_quotes | def request_quotes(tickers_list, selected_columns=['*']):
"""Request Yahoo Finance recent quotes.
Returns quotes information from YQL. The columns to be requested are
listed at selected_columns. Check `here <http://goo.gl/8AROUD>`_ for more
information on YQL.
>>> request_quotes(['AAPL'], ['Name',... | python | def request_quotes(tickers_list, selected_columns=['*']):
"""Request Yahoo Finance recent quotes.
Returns quotes information from YQL. The columns to be requested are
listed at selected_columns. Check `here <http://goo.gl/8AROUD>`_ for more
information on YQL.
>>> request_quotes(['AAPL'], ['Name',... | [
"def",
"request_quotes",
"(",
"tickers_list",
",",
"selected_columns",
"=",
"[",
"'*'",
"]",
")",
":",
"__validate_list",
"(",
"tickers_list",
")",
"__validate_list",
"(",
"selected_columns",
")",
"query",
"=",
"'select {cols} from yahoo.finance.quotes where symbol in ({v... | Request Yahoo Finance recent quotes.
Returns quotes information from YQL. The columns to be requested are
listed at selected_columns. Check `here <http://goo.gl/8AROUD>`_ for more
information on YQL.
>>> request_quotes(['AAPL'], ['Name', 'PreviousClose'])
{
'PreviousClose': '95.60',
... | [
"Request",
"Yahoo",
"Finance",
"recent",
"quotes",
"."
] | train | https://github.com/condereis/realtime-stock/blob/5b3110d0bc2fd3e8354ab2edb5cfe6cafd6f2a94/rtstock/utils.py#L66-L105 |
condereis/realtime-stock | rtstock/utils.py | request_historical | def request_historical(ticker, start_date, end_date):
"""Get stock's daily historical information.
Returns a dictionary with Adj Close, Close, High, Low, Open and
Volume, between the start_date and the end_date. Is start_date and
end_date were not provided all the available information will be
retr... | python | def request_historical(ticker, start_date, end_date):
"""Get stock's daily historical information.
Returns a dictionary with Adj Close, Close, High, Low, Open and
Volume, between the start_date and the end_date. Is start_date and
end_date were not provided all the available information will be
retr... | [
"def",
"request_historical",
"(",
"ticker",
",",
"start_date",
",",
"end_date",
")",
":",
"__validate_dates",
"(",
"start_date",
",",
"end_date",
")",
"cols",
"=",
"[",
"'Date'",
",",
"'Open'",
",",
"'High'",
",",
"'Low'",
",",
"'Close'",
",",
"'Volume'",
... | Get stock's daily historical information.
Returns a dictionary with Adj Close, Close, High, Low, Open and
Volume, between the start_date and the end_date. Is start_date and
end_date were not provided all the available information will be
retrieved. Information provided by YQL platform.
Check `here ... | [
"Get",
"stock",
"s",
"daily",
"historical",
"information",
"."
] | train | https://github.com/condereis/realtime-stock/blob/5b3110d0bc2fd3e8354ab2edb5cfe6cafd6f2a94/rtstock/utils.py#L108-L170 |
condereis/realtime-stock | rtstock/utils.py | download_historical | def download_historical(tickers_list, output_folder):
"""Download historical data from Yahoo Finance.
Downloads full historical data from Yahoo Finance as CSV. The following
fields are available: Adj Close, Close, High, Low, Open and Volume. Files
will be saved to output_folder as <ticker>.csv.
:p... | python | def download_historical(tickers_list, output_folder):
"""Download historical data from Yahoo Finance.
Downloads full historical data from Yahoo Finance as CSV. The following
fields are available: Adj Close, Close, High, Low, Open and Volume. Files
will be saved to output_folder as <ticker>.csv.
:p... | [
"def",
"download_historical",
"(",
"tickers_list",
",",
"output_folder",
")",
":",
"__validate_list",
"(",
"tickers_list",
")",
"for",
"ticker",
"in",
"tickers_list",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_folder",
",",
"ticker",
"... | Download historical data from Yahoo Finance.
Downloads full historical data from Yahoo Finance as CSV. The following
fields are available: Adj Close, Close, High, Low, Open and Volume. Files
will be saved to output_folder as <ticker>.csv.
:param tickers_list: List of tickers that will be returned.
... | [
"Download",
"historical",
"data",
"from",
"Yahoo",
"Finance",
"."
] | train | https://github.com/condereis/realtime-stock/blob/5b3110d0bc2fd3e8354ab2edb5cfe6cafd6f2a94/rtstock/utils.py#L173-L196 |
jepegit/cellpy | cellpy/log.py | setup_logging | def setup_logging(default_json_path=None, default_level=None, env_key='LOG_CFG',
custom_log_dir=None):
"""Setup logging configuration
"""
if not default_json_path:
default_json_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "logging.json")
path ... | python | def setup_logging(default_json_path=None, default_level=None, env_key='LOG_CFG',
custom_log_dir=None):
"""Setup logging configuration
"""
if not default_json_path:
default_json_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "logging.json")
path ... | [
"def",
"setup_logging",
"(",
"default_json_path",
"=",
"None",
",",
"default_level",
"=",
"None",
",",
"env_key",
"=",
"'LOG_CFG'",
",",
"custom_log_dir",
"=",
"None",
")",
":",
"if",
"not",
"default_json_path",
":",
"default_json_path",
"=",
"os",
".",
"path"... | Setup logging configuration | [
"Setup",
"logging",
"configuration"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/log.py#L11-L80 |
jepegit/cellpy | cellpy/readers/filefinder.py | search_for_files | def search_for_files(run_name, raw_extension=None, cellpy_file_extension=None,
raw_file_dir=None, cellpy_file_dir=None, prm_filename=None,
file_name_format=None, cache=None):
"""Searches for files (raw-data files and cellpy-files).
Args:
run_name(str): run-fil... | python | def search_for_files(run_name, raw_extension=None, cellpy_file_extension=None,
raw_file_dir=None, cellpy_file_dir=None, prm_filename=None,
file_name_format=None, cache=None):
"""Searches for files (raw-data files and cellpy-files).
Args:
run_name(str): run-fil... | [
"def",
"search_for_files",
"(",
"run_name",
",",
"raw_extension",
"=",
"None",
",",
"cellpy_file_extension",
"=",
"None",
",",
"raw_file_dir",
"=",
"None",
",",
"cellpy_file_dir",
"=",
"None",
",",
"prm_filename",
"=",
"None",
",",
"file_name_format",
"=",
"None... | Searches for files (raw-data files and cellpy-files).
Args:
run_name(str): run-file identification.
raw_extension(str): optional, extension of run-files (without the '.').
cellpy_file_extension(str): optional, extension for cellpy files
(without the '.').
raw_file_dir(p... | [
"Searches",
"for",
"files",
"(",
"raw",
"-",
"data",
"files",
"and",
"cellpy",
"-",
"files",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/filefinder.py#L37-L163 |
openstax/cnx-epub | cnxepub/utils.py | squash_xml_to_text | def squash_xml_to_text(elm, remove_namespaces=False):
"""Squash the given XML element (as `elm`) to a text containing XML.
The outer most element/tag will be removed, but inner elements will
remain. If `remove_namespaces` is specified, XML namespace declarations
will be removed from the text.
:para... | python | def squash_xml_to_text(elm, remove_namespaces=False):
"""Squash the given XML element (as `elm`) to a text containing XML.
The outer most element/tag will be removed, but inner elements will
remain. If `remove_namespaces` is specified, XML namespace declarations
will be removed from the text.
:para... | [
"def",
"squash_xml_to_text",
"(",
"elm",
",",
"remove_namespaces",
"=",
"False",
")",
":",
"leading_text",
"=",
"elm",
".",
"text",
"and",
"elm",
".",
"text",
"or",
"''",
"result",
"=",
"[",
"leading_text",
"]",
"for",
"child",
"in",
"elm",
".",
"getchil... | Squash the given XML element (as `elm`) to a text containing XML.
The outer most element/tag will be removed, but inner elements will
remain. If `remove_namespaces` is specified, XML namespace declarations
will be removed from the text.
:param elm: XML element
:type elm: :class:`xml.etree.ElementTr... | [
"Squash",
"the",
"given",
"XML",
"element",
"(",
"as",
"elm",
")",
"to",
"a",
"text",
"containing",
"XML",
".",
"The",
"outer",
"most",
"element",
"/",
"tag",
"will",
"be",
"removed",
"but",
"inner",
"elements",
"will",
"remain",
".",
"If",
"remove_names... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/utils.py#L19-L51 |
jepegit/cellpy | cellpy/readers/instruments/custom.py | CustomLoader.load | def load(self, file_name):
"""Load a raw data-file
Args:
file_name (path)
Returns:
loaded test
"""
new_rundata = self.loader(file_name)
new_rundata = self.inspect(new_rundata)
return new_rundata | python | def load(self, file_name):
"""Load a raw data-file
Args:
file_name (path)
Returns:
loaded test
"""
new_rundata = self.loader(file_name)
new_rundata = self.inspect(new_rundata)
return new_rundata | [
"def",
"load",
"(",
"self",
",",
"file_name",
")",
":",
"new_rundata",
"=",
"self",
".",
"loader",
"(",
"file_name",
")",
"new_rundata",
"=",
"self",
".",
"inspect",
"(",
"new_rundata",
")",
"return",
"new_rundata"
] | Load a raw data-file
Args:
file_name (path)
Returns:
loaded test | [
"Load",
"a",
"raw",
"data",
"-",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/custom.py#L344-L356 |
jepegit/cellpy | cellpy/readers/instruments/biologics_mpr.py | datetime2ole | def datetime2ole(dt):
"""converts from datetime object to ole datetime float"""
delta = dt - OLE_TIME_ZERO
delta_float = delta / datetime.timedelta(days=1) # trick from SO
return delta_float | python | def datetime2ole(dt):
"""converts from datetime object to ole datetime float"""
delta = dt - OLE_TIME_ZERO
delta_float = delta / datetime.timedelta(days=1) # trick from SO
return delta_float | [
"def",
"datetime2ole",
"(",
"dt",
")",
":",
"delta",
"=",
"dt",
"-",
"OLE_TIME_ZERO",
"delta_float",
"=",
"delta",
"/",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"# trick from SO",
"return",
"delta_float"
] | converts from datetime object to ole datetime float | [
"converts",
"from",
"datetime",
"object",
"to",
"ole",
"datetime",
"float"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/biologics_mpr.py#L33-L37 |
jepegit/cellpy | cellpy/readers/instruments/biologics_mpr.py | MprLoader.get_raw_limits | def get_raw_limits():
"""Include the settings for how to decide what kind of
step you are examining here.
The raw limits are 'epsilons' used to check if the current
and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current
is stable... | python | def get_raw_limits():
"""Include the settings for how to decide what kind of
step you are examining here.
The raw limits are 'epsilons' used to check if the current
and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current
is stable... | [
"def",
"get_raw_limits",
"(",
")",
":",
"raw_limits",
"=",
"dict",
"(",
")",
"raw_limits",
"[",
"\"current_hard\"",
"]",
"=",
"0.0000000000001",
"raw_limits",
"[",
"\"current_soft\"",
"]",
"=",
"0.00001",
"raw_limits",
"[",
"\"stable_current_hard\"",
"]",
"=",
"... | Include the settings for how to decide what kind of
step you are examining here.
The raw limits are 'epsilons' used to check if the current
and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current
is stable (constant) and non-zero).
... | [
"Include",
"the",
"settings",
"for",
"how",
"to",
"decide",
"what",
"kind",
"of",
"step",
"you",
"are",
"examining",
"here",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/biologics_mpr.py#L95-L120 |
jepegit/cellpy | cellpy/readers/instruments/biologics_mpr.py | MprLoader.loader | def loader(self, file_name, bad_steps=None, **kwargs):
"""Loads data from biologics .mpr files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s
(in cycle c) to skip loading.
Returns:
new_tests (list... | python | def loader(self, file_name, bad_steps=None, **kwargs):
"""Loads data from biologics .mpr files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s
(in cycle c) to skip loading.
Returns:
new_tests (list... | [
"def",
"loader",
"(",
"self",
",",
"file_name",
",",
"bad_steps",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"new_tests",
"=",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"self",
".",
"logger",
".",
"... | Loads data from biologics .mpr files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s
(in cycle c) to skip loading.
Returns:
new_tests (list of data objects) | [
"Loads",
"data",
"from",
"biologics",
".",
"mpr",
"files",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/biologics_mpr.py#L164-L240 |
jepegit/cellpy | cellpy/utils/batch_tools/dumpers.py | csv_dumper | def csv_dumper(**kwargs):
"""dump data to csv"""
logging.info("dumping to csv")
barn = kwargs["barn"]
farms = kwargs["farms"]
experiments = kwargs["experiments"]
for experiment, farm in zip(experiments, farms):
name = experiment.journal.name
project = experiment.journal.project
... | python | def csv_dumper(**kwargs):
"""dump data to csv"""
logging.info("dumping to csv")
barn = kwargs["barn"]
farms = kwargs["farms"]
experiments = kwargs["experiments"]
for experiment, farm in zip(experiments, farms):
name = experiment.journal.name
project = experiment.journal.project
... | [
"def",
"csv_dumper",
"(",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"dumping to csv\"",
")",
"barn",
"=",
"kwargs",
"[",
"\"barn\"",
"]",
"farms",
"=",
"kwargs",
"[",
"\"farms\"",
"]",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\""... | dump data to csv | [
"dump",
"data",
"to",
"csv"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/dumpers.py#L8-L41 |
jepegit/cellpy | cellpy/utils/batch_tools/dumpers.py | ram_dumper | def ram_dumper(**kwargs):
"""Dump data to 'memory' for later usage."""
logging.debug("trying to save stuff in memory")
farms = kwargs["farms"]
experiments = kwargs["experiments"]
engine = kwargs["engine"]
try:
engine_name = engine.__name__
except AttributeError:
engine_name ... | python | def ram_dumper(**kwargs):
"""Dump data to 'memory' for later usage."""
logging.debug("trying to save stuff in memory")
farms = kwargs["farms"]
experiments = kwargs["experiments"]
engine = kwargs["engine"]
try:
engine_name = engine.__name__
except AttributeError:
engine_name ... | [
"def",
"ram_dumper",
"(",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"debug",
"(",
"\"trying to save stuff in memory\"",
")",
"farms",
"=",
"kwargs",
"[",
"\"farms\"",
"]",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\"",
"]",
"engine",
"=",
"kwargs",
... | Dump data to 'memory' for later usage. | [
"Dump",
"data",
"to",
"memory",
"for",
"later",
"usage",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/dumpers.py#L54-L75 |
jepegit/cellpy | cellpy/utils/batch_tools/dumpers.py | screen_dumper | def screen_dumper(**kwargs):
"""Dump data to screen."""
farms = kwargs["farms"]
engine = kwargs["engine"]
logging.info("dumping to screen")
print(f"\n[Screen dumper] ({engine})")
try:
if len(farms) == 1:
print(f"You have one farm with little pandas.")
else:
... | python | def screen_dumper(**kwargs):
"""Dump data to screen."""
farms = kwargs["farms"]
engine = kwargs["engine"]
logging.info("dumping to screen")
print(f"\n[Screen dumper] ({engine})")
try:
if len(farms) == 1:
print(f"You have one farm with little pandas.")
else:
... | [
"def",
"screen_dumper",
"(",
"*",
"*",
"kwargs",
")",
":",
"farms",
"=",
"kwargs",
"[",
"\"farms\"",
"]",
"engine",
"=",
"kwargs",
"[",
"\"engine\"",
"]",
"logging",
".",
"info",
"(",
"\"dumping to screen\"",
")",
"print",
"(",
"f\"\\n[Screen dumper] ({engine}... | Dump data to screen. | [
"Dump",
"data",
"to",
"screen",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/dumpers.py#L78-L105 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_plotters.py | create_legend | def create_legend(info, c, option="clean", use_index=False):
"""creating more informative legends"""
logging.debug(" - creating legends")
mass, loading, label = info.loc[c, ["masses", "loadings", "labels"]]
if use_index or not label:
label = c.split("_")
label = "_".join(label[1:])
... | python | def create_legend(info, c, option="clean", use_index=False):
"""creating more informative legends"""
logging.debug(" - creating legends")
mass, loading, label = info.loc[c, ["masses", "loadings", "labels"]]
if use_index or not label:
label = c.split("_")
label = "_".join(label[1:])
... | [
"def",
"create_legend",
"(",
"info",
",",
"c",
",",
"option",
"=",
"\"clean\"",
",",
"use_index",
"=",
"False",
")",
":",
"logging",
".",
"debug",
"(",
"\" - creating legends\"",
")",
"mass",
",",
"loading",
",",
"label",
"=",
"info",
".",
"loc",
"[",... | creating more informative legends | [
"creating",
"more",
"informative",
"legends"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_plotters.py#L34-L54 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_plotters.py | create_plot_option_dicts | def create_plot_option_dicts(info, marker_types=None, colors=None,
line_dash=None, size=None):
"""Create two dictionaries with plot-options.
The first iterates colors (based on group-number), the second iterates
through marker types.
Returns: group_styles (dict), sub_group... | python | def create_plot_option_dicts(info, marker_types=None, colors=None,
line_dash=None, size=None):
"""Create two dictionaries with plot-options.
The first iterates colors (based on group-number), the second iterates
through marker types.
Returns: group_styles (dict), sub_group... | [
"def",
"create_plot_option_dicts",
"(",
"info",
",",
"marker_types",
"=",
"None",
",",
"colors",
"=",
"None",
",",
"line_dash",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\" - creating plot-options-dict (for bokeh)\"",
")"... | Create two dictionaries with plot-options.
The first iterates colors (based on group-number), the second iterates
through marker types.
Returns: group_styles (dict), sub_group_styles (dict) | [
"Create",
"two",
"dictionaries",
"with",
"plot",
"-",
"options",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_plotters.py#L63-L134 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_plotters.py | summary_plotting_engine | def summary_plotting_engine(**kwargs):
"""creates plots of summary data."""
logging.debug(f"Using {prms.Batch.backend} for plotting")
experiments = kwargs["experiments"]
farms = kwargs["farms"]
barn = None
logging.debug(" - summary_plot_engine")
farms = _preparing_data_and_plotting(
... | python | def summary_plotting_engine(**kwargs):
"""creates plots of summary data."""
logging.debug(f"Using {prms.Batch.backend} for plotting")
experiments = kwargs["experiments"]
farms = kwargs["farms"]
barn = None
logging.debug(" - summary_plot_engine")
farms = _preparing_data_and_plotting(
... | [
"def",
"summary_plotting_engine",
"(",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"debug",
"(",
"f\"Using {prms.Batch.backend} for plotting\"",
")",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\"",
"]",
"farms",
"=",
"kwargs",
"[",
"\"farms\"",
"]",
"barn"... | creates plots of summary data. | [
"creates",
"plots",
"of",
"summary",
"data",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_plotters.py#L316-L330 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_plotters.py | CyclingSummaryPlotter.run_dumper | def run_dumper(self, dumper):
"""run dumber (once pr. engine)
Args:
dumper: dumper to run (function or method).
The dumper takes the attributes experiments, farms, and barn as input.
It does not return anything. But can, if the dumper designer feels in
a bad and nas... | python | def run_dumper(self, dumper):
"""run dumber (once pr. engine)
Args:
dumper: dumper to run (function or method).
The dumper takes the attributes experiments, farms, and barn as input.
It does not return anything. But can, if the dumper designer feels in
a bad and nas... | [
"def",
"run_dumper",
"(",
"self",
",",
"dumper",
")",
":",
"logging",
".",
"debug",
"(",
"\"start dumper::\"",
")",
"dumper",
"(",
"experiments",
"=",
"self",
".",
"experiments",
",",
"farms",
"=",
"self",
".",
"farms",
",",
"barn",
"=",
"self",
".",
"... | run dumber (once pr. engine)
Args:
dumper: dumper to run (function or method).
The dumper takes the attributes experiments, farms, and barn as input.
It does not return anything. But can, if the dumper designer feels in
a bad and nasty mood, modify the input objects
... | [
"run",
"dumber",
"(",
"once",
"pr",
".",
"engine",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_plotters.py#L464-L483 |
sci-bots/serial-device | serial_device/__init__.py | _comports | def _comports():
'''
Returns
-------
pandas.DataFrame
Table containing descriptor, and hardware ID of each available COM
port, indexed by port (e.g., "COM4").
'''
return (pd.DataFrame(list(map(list, serial.tools.list_ports.comports())),
columns=['port', '... | python | def _comports():
'''
Returns
-------
pandas.DataFrame
Table containing descriptor, and hardware ID of each available COM
port, indexed by port (e.g., "COM4").
'''
return (pd.DataFrame(list(map(list, serial.tools.list_ports.comports())),
columns=['port', '... | [
"def",
"_comports",
"(",
")",
":",
"return",
"(",
"pd",
".",
"DataFrame",
"(",
"list",
"(",
"map",
"(",
"list",
",",
"serial",
".",
"tools",
".",
"list_ports",
".",
"comports",
"(",
")",
")",
")",
",",
"columns",
"=",
"[",
"'port'",
",",
"'descript... | Returns
-------
pandas.DataFrame
Table containing descriptor, and hardware ID of each available COM
port, indexed by port (e.g., "COM4"). | [
"Returns",
"-------",
"pandas",
".",
"DataFrame",
"Table",
"containing",
"descriptor",
"and",
"hardware",
"ID",
"of",
"each",
"available",
"COM",
"port",
"indexed",
"by",
"port",
"(",
"e",
".",
"g",
".",
"COM4",
")",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/__init__.py#L34-L44 |
sci-bots/serial-device | serial_device/__init__.py | comports | def comports(vid_pid=None, include_all=False, check_available=True,
only_available=False):
'''
.. versionchanged:: 0.9
Add :data:`check_available` keyword argument to optionally check if
each port is actually available by attempting to open a temporary
connection.
A... | python | def comports(vid_pid=None, include_all=False, check_available=True,
only_available=False):
'''
.. versionchanged:: 0.9
Add :data:`check_available` keyword argument to optionally check if
each port is actually available by attempting to open a temporary
connection.
A... | [
"def",
"comports",
"(",
"vid_pid",
"=",
"None",
",",
"include_all",
"=",
"False",
",",
"check_available",
"=",
"True",
",",
"only_available",
"=",
"False",
")",
":",
"df_comports",
"=",
"_comports",
"(",
")",
"# Extract USB product and vendor IDs from `hwid` entries... | .. versionchanged:: 0.9
Add :data:`check_available` keyword argument to optionally check if
each port is actually available by attempting to open a temporary
connection.
Add :data:`only_available` keyword argument to only include ports that
are actually available for connection.... | [
"..",
"versionchanged",
"::",
"0",
".",
"9",
"Add",
":",
"data",
":",
"check_available",
"keyword",
"argument",
"to",
"optionally",
"check",
"if",
"each",
"port",
"is",
"actually",
"available",
"by",
"attempting",
"to",
"open",
"a",
"temporary",
"connection",
... | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/__init__.py#L47-L143 |
sci-bots/serial-device | serial_device/__init__.py | _get_serial_ports_windows | def _get_serial_ports_windows():
'''
Uses the Win32 registry to return a iterator of serial (COM) ports existing
on this computer.
See http://stackoverflow.com/questions/1205383/listing-serial-com-ports-on-windows
'''
import six.moves.winreg as winreg
reg_path = 'HARDWARE\\DEVICEMAP\\SERIA... | python | def _get_serial_ports_windows():
'''
Uses the Win32 registry to return a iterator of serial (COM) ports existing
on this computer.
See http://stackoverflow.com/questions/1205383/listing-serial-com-ports-on-windows
'''
import six.moves.winreg as winreg
reg_path = 'HARDWARE\\DEVICEMAP\\SERIA... | [
"def",
"_get_serial_ports_windows",
"(",
")",
":",
"import",
"six",
".",
"moves",
".",
"winreg",
"as",
"winreg",
"reg_path",
"=",
"'HARDWARE\\\\DEVICEMAP\\\\SERIALCOMM'",
"try",
":",
"key",
"=",
"winreg",
".",
"OpenKey",
"(",
"winreg",
".",
"HKEY_LOCAL_MACHINE",
... | Uses the Win32 registry to return a iterator of serial (COM) ports existing
on this computer.
See http://stackoverflow.com/questions/1205383/listing-serial-com-ports-on-windows | [
"Uses",
"the",
"Win32",
"registry",
"to",
"return",
"a",
"iterator",
"of",
"serial",
"(",
"COM",
")",
"ports",
"existing",
"on",
"this",
"computer",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/__init__.py#L160-L181 |
sci-bots/serial-device | serial_device/__init__.py | SerialDevice.get_port | def get_port(self, baud_rate):
'''
Using the specified baud-rate, attempt to connect to each available
serial port. If the `test_connection()` method returns `True` for a
port, update the `port` attribute and return the port.
In the case where the `test_connection()` does not r... | python | def get_port(self, baud_rate):
'''
Using the specified baud-rate, attempt to connect to each available
serial port. If the `test_connection()` method returns `True` for a
port, update the `port` attribute and return the port.
In the case where the `test_connection()` does not r... | [
"def",
"get_port",
"(",
"self",
",",
"baud_rate",
")",
":",
"self",
".",
"port",
"=",
"None",
"for",
"test_port",
"in",
"get_serial_ports",
"(",
")",
":",
"if",
"self",
".",
"test_connection",
"(",
"test_port",
",",
"baud_rate",
")",
":",
"self",
".",
... | Using the specified baud-rate, attempt to connect to each available
serial port. If the `test_connection()` method returns `True` for a
port, update the `port` attribute and return the port.
In the case where the `test_connection()` does not return `True` for
any of the evaluated ports... | [
"Using",
"the",
"specified",
"baud",
"-",
"rate",
"attempt",
"to",
"connect",
"to",
"each",
"available",
"serial",
"port",
".",
"If",
"the",
"test_connection",
"()",
"method",
"returns",
"True",
"for",
"a",
"port",
"update",
"the",
"port",
"attribute",
"and"... | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/__init__.py#L206-L226 |
jepegit/cellpy | dev_utils/make_example_custom_file_configfile.py | _read | def _read(name):
"""read the yml file"""
logging.debug("Reading config-file: %s" % name)
try:
with open(name, "r") as config_file:
prm_dict = yaml.load(config_file)
except yaml.YAMLError:
raise yaml.YAMLErrorr
else:
return prm_dict | python | def _read(name):
"""read the yml file"""
logging.debug("Reading config-file: %s" % name)
try:
with open(name, "r") as config_file:
prm_dict = yaml.load(config_file)
except yaml.YAMLError:
raise yaml.YAMLErrorr
else:
return prm_dict | [
"def",
"_read",
"(",
"name",
")",
":",
"logging",
".",
"debug",
"(",
"\"Reading config-file: %s\"",
"%",
"name",
")",
"try",
":",
"with",
"open",
"(",
"name",
",",
"\"r\"",
")",
"as",
"config_file",
":",
"prm_dict",
"=",
"yaml",
".",
"load",
"(",
"conf... | read the yml file | [
"read",
"the",
"yml",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/make_example_custom_file_configfile.py#L16-L25 |
jepegit/cellpy | cellpy/utils/batch_tools/engines.py | cycles_engine | def cycles_engine(**kwargs):
"""engine to extract cycles"""
logging.info("cycles_engine:")
logging.info("Not ready for production")
# raise NotImplementedError
experiments = kwargs["experiments"]
farms = []
barn = "raw_dir" # Its a murder in the red barn - murder in the red barn
for ... | python | def cycles_engine(**kwargs):
"""engine to extract cycles"""
logging.info("cycles_engine:")
logging.info("Not ready for production")
# raise NotImplementedError
experiments = kwargs["experiments"]
farms = []
barn = "raw_dir" # Its a murder in the red barn - murder in the red barn
for ... | [
"def",
"cycles_engine",
"(",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"cycles_engine:\"",
")",
"logging",
".",
"info",
"(",
"\"Not ready for production\"",
")",
"# raise NotImplementedError",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\"",
... | engine to extract cycles | [
"engine",
"to",
"extract",
"cycles"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/engines.py#L11-L33 |
jepegit/cellpy | cellpy/utils/batch_tools/engines.py | raw_data_engine | def raw_data_engine(**kwargs):
"""engine to extract raw data"""
logger.debug("cycles_engine")
raise NotImplementedError
experiments = kwargs["experiments"]
farms = []
barn = "raw_dir"
for experiment in experiments:
farms.append([])
return farms, barn | python | def raw_data_engine(**kwargs):
"""engine to extract raw data"""
logger.debug("cycles_engine")
raise NotImplementedError
experiments = kwargs["experiments"]
farms = []
barn = "raw_dir"
for experiment in experiments:
farms.append([])
return farms, barn | [
"def",
"raw_data_engine",
"(",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"\"cycles_engine\"",
")",
"raise",
"NotImplementedError",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\"",
"]",
"farms",
"=",
"[",
"]",
"barn",
"=",
"\"raw_dir\"",
... | engine to extract raw data | [
"engine",
"to",
"extract",
"raw",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/engines.py#L36-L48 |
jepegit/cellpy | cellpy/utils/batch_tools/engines.py | summary_engine | def summary_engine(**kwargs):
"""engine to extract summary data"""
logger.debug("summary_engine")
# farms = kwargs["farms"]
farms = []
experiments = kwargs["experiments"]
for experiment in experiments:
if experiment.selected_summaries is None:
selected_summaries = [
... | python | def summary_engine(**kwargs):
"""engine to extract summary data"""
logger.debug("summary_engine")
# farms = kwargs["farms"]
farms = []
experiments = kwargs["experiments"]
for experiment in experiments:
if experiment.selected_summaries is None:
selected_summaries = [
... | [
"def",
"summary_engine",
"(",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"\"summary_engine\"",
")",
"# farms = kwargs[\"farms\"]",
"farms",
"=",
"[",
"]",
"experiments",
"=",
"kwargs",
"[",
"\"experiments\"",
"]",
"for",
"experiment",
"in",
"ex... | engine to extract summary data | [
"engine",
"to",
"extract",
"summary",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/engines.py#L51-L77 |
jepegit/cellpy | cellpy/utils/batch_tools/engines.py | simple_db_engine | def simple_db_engine(reader=None, srnos=None):
"""engine that gets values from the simple excel 'db'"""
if reader is None:
reader = dbreader.Reader()
logger.debug("No reader provided. Creating one myself.")
info_dict = dict()
info_dict["filenames"] = [reader.get_cell_name(srno) for srn... | python | def simple_db_engine(reader=None, srnos=None):
"""engine that gets values from the simple excel 'db'"""
if reader is None:
reader = dbreader.Reader()
logger.debug("No reader provided. Creating one myself.")
info_dict = dict()
info_dict["filenames"] = [reader.get_cell_name(srno) for srn... | [
"def",
"simple_db_engine",
"(",
"reader",
"=",
"None",
",",
"srnos",
"=",
"None",
")",
":",
"if",
"reader",
"is",
"None",
":",
"reader",
"=",
"dbreader",
".",
"Reader",
"(",
")",
"logger",
".",
"debug",
"(",
"\"No reader provided. Creating one myself.\"",
")... | engine that gets values from the simple excel 'db | [
"engine",
"that",
"gets",
"values",
"from",
"the",
"simple",
"excel",
"db"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/engines.py#L87-L131 |
sci-bots/serial-device | serial_device/or_event.py | orify | def orify(event, changed_callback):
'''
Override ``set`` and ``clear`` methods on event to call specified callback
function after performing default behaviour.
Parameters
----------
'''
event.changed = changed_callback
if not hasattr(event, '_set'):
# `set`/`clear` methods have... | python | def orify(event, changed_callback):
'''
Override ``set`` and ``clear`` methods on event to call specified callback
function after performing default behaviour.
Parameters
----------
'''
event.changed = changed_callback
if not hasattr(event, '_set'):
# `set`/`clear` methods have... | [
"def",
"orify",
"(",
"event",
",",
"changed_callback",
")",
":",
"event",
".",
"changed",
"=",
"changed_callback",
"if",
"not",
"hasattr",
"(",
"event",
",",
"'_set'",
")",
":",
"# `set`/`clear` methods have not been overridden on event yet.",
"# Override methods to cal... | Override ``set`` and ``clear`` methods on event to call specified callback
function after performing default behaviour.
Parameters
---------- | [
"Override",
"set",
"and",
"clear",
"methods",
"on",
"event",
"to",
"call",
"specified",
"callback",
"function",
"after",
"performing",
"default",
"behaviour",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/or_event.py#L19-L36 |
sci-bots/serial-device | serial_device/or_event.py | OrEvent | def OrEvent(*events):
'''
Parameters
----------
events : list(threading.Event)
List of events.
Returns
-------
threading.Event
Event that is set when **at least one** of the events in :data:`events`
is set.
'''
or_event = threading.Event()
def changed():... | python | def OrEvent(*events):
'''
Parameters
----------
events : list(threading.Event)
List of events.
Returns
-------
threading.Event
Event that is set when **at least one** of the events in :data:`events`
is set.
'''
or_event = threading.Event()
def changed():... | [
"def",
"OrEvent",
"(",
"*",
"events",
")",
":",
"or_event",
"=",
"threading",
".",
"Event",
"(",
")",
"def",
"changed",
"(",
")",
":",
"'''\n Set ``or_event`` if any of the specified events have been set.\n '''",
"bools",
"=",
"[",
"event_i",
".",
"is_... | Parameters
----------
events : list(threading.Event)
List of events.
Returns
-------
threading.Event
Event that is set when **at least one** of the events in :data:`events`
is set. | [
"Parameters",
"----------",
"events",
":",
"list",
"(",
"threading",
".",
"Event",
")",
"List",
"of",
"events",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/or_event.py#L39-L70 |
sci-bots/serial-device | serial_device/threaded.py | request | def request(device, response_queue, payload, timeout_s=None, poll=POLL_QUEUES):
'''
Send payload to serial device and wait for response.
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str or... | python | def request(device, response_queue, payload, timeout_s=None, poll=POLL_QUEUES):
'''
Send payload to serial device and wait for response.
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str or... | [
"def",
"request",
"(",
"device",
",",
"response_queue",
",",
"payload",
",",
"timeout_s",
"=",
"None",
",",
"poll",
"=",
"POLL_QUEUES",
")",
":",
"device",
".",
"write",
"(",
"payload",
")",
"if",
"poll",
":",
"# Polling enabled. Wait for response in busy loop.... | Send payload to serial device and wait for response.
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str or bytes
Payload to send.
timeout_s : float, optional
Maximum time to wait... | [
"Send",
"payload",
"to",
"serial",
"device",
"and",
"wait",
"for",
"response",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/threaded.py#L237-L272 |
sci-bots/serial-device | serial_device/threaded.py | EventProtocol.connection_made | def connection_made(self, transport):
"""Called when reader thread is started"""
self.port = transport.serial.port
logger.debug('connection_made: `%s` `%s`', self.port, transport)
self.transport = transport
self.connected.set()
self.disconnected.clear() | python | def connection_made(self, transport):
"""Called when reader thread is started"""
self.port = transport.serial.port
logger.debug('connection_made: `%s` `%s`', self.port, transport)
self.transport = transport
self.connected.set()
self.disconnected.clear() | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"port",
"=",
"transport",
".",
"serial",
".",
"port",
"logger",
".",
"debug",
"(",
"'connection_made: `%s` `%s`'",
",",
"self",
".",
"port",
",",
"transport",
")",
"self",
".",... | Called when reader thread is started | [
"Called",
"when",
"reader",
"thread",
"is",
"started"
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/threaded.py#L28-L34 |
sci-bots/serial-device | serial_device/threaded.py | EventProtocol.connection_lost | def connection_lost(self, exception):
"""\
Called when the serial port is closed or the reader loop terminated
otherwise.
"""
if isinstance(exception, Exception):
logger.debug('Connection to port `%s` lost: %s', self.port,
exception)
e... | python | def connection_lost(self, exception):
"""\
Called when the serial port is closed or the reader loop terminated
otherwise.
"""
if isinstance(exception, Exception):
logger.debug('Connection to port `%s` lost: %s', self.port,
exception)
e... | [
"def",
"connection_lost",
"(",
"self",
",",
"exception",
")",
":",
"if",
"isinstance",
"(",
"exception",
",",
"Exception",
")",
":",
"logger",
".",
"debug",
"(",
"'Connection to port `%s` lost: %s'",
",",
"self",
".",
"port",
",",
"exception",
")",
"else",
"... | \
Called when the serial port is closed or the reader loop terminated
otherwise. | [
"\\",
"Called",
"when",
"the",
"serial",
"port",
"is",
"closed",
"or",
"the",
"reader",
"loop",
"terminated",
"otherwise",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/threaded.py#L40-L51 |
sci-bots/serial-device | serial_device/threaded.py | KeepAliveReader.write | def write(self, data, timeout_s=None):
'''
Write to serial port.
Waits for serial connection to be established before writing.
Parameters
----------
data : str or bytes
Data to write to serial port.
timeout_s : float, optional
Maximum num... | python | def write(self, data, timeout_s=None):
'''
Write to serial port.
Waits for serial connection to be established before writing.
Parameters
----------
data : str or bytes
Data to write to serial port.
timeout_s : float, optional
Maximum num... | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"timeout_s",
"=",
"None",
")",
":",
"self",
".",
"connected",
".",
"wait",
"(",
"timeout_s",
")",
"self",
".",
"protocol",
".",
"transport",
".",
"write",
"(",
"data",
")"
] | Write to serial port.
Waits for serial connection to be established before writing.
Parameters
----------
data : str or bytes
Data to write to serial port.
timeout_s : float, optional
Maximum number of seconds to wait for serial connection to be
... | [
"Write",
"to",
"serial",
"port",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/threaded.py#L167-L184 |
sci-bots/serial-device | serial_device/threaded.py | KeepAliveReader.request | def request(self, response_queue, payload, timeout_s=None,
poll=POLL_QUEUES):
'''
Send
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str ... | python | def request(self, response_queue, payload, timeout_s=None,
poll=POLL_QUEUES):
'''
Send
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str ... | [
"def",
"request",
"(",
"self",
",",
"response_queue",
",",
"payload",
",",
"timeout_s",
"=",
"None",
",",
"poll",
"=",
"POLL_QUEUES",
")",
":",
"self",
".",
"connected",
".",
"wait",
"(",
"timeout_s",
")",
"return",
"request",
"(",
"self",
",",
"response... | Send
Parameters
----------
device : serial.Serial
Serial instance.
response_queue : Queue.Queue
Queue to wait for response on.
payload : str or bytes
Payload to send.
timeout_s : float, optional
Maximum time to wait (in sec... | [
"Send"
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/threaded.py#L186-L213 |
jepegit/cellpy | dev_utils/BioLogic_.py | fieldname_to_dtype | def fieldname_to_dtype(fieldname):
"""Converts a column header from the MPT file into a tuple of
canonical name and appropriate numpy dtype"""
if fieldname == 'mode':
return ('mode', np.uint8)
elif fieldname in ("ox/red", "error", "control changes", "Ns changes",
"counter... | python | def fieldname_to_dtype(fieldname):
"""Converts a column header from the MPT file into a tuple of
canonical name and appropriate numpy dtype"""
if fieldname == 'mode':
return ('mode', np.uint8)
elif fieldname in ("ox/red", "error", "control changes", "Ns changes",
"counter... | [
"def",
"fieldname_to_dtype",
"(",
"fieldname",
")",
":",
"if",
"fieldname",
"==",
"'mode'",
":",
"return",
"(",
"'mode'",
",",
"np",
".",
"uint8",
")",
"elif",
"fieldname",
"in",
"(",
"\"ox/red\"",
",",
"\"error\"",
",",
"\"control changes\"",
",",
"\"Ns cha... | Converts a column header from the MPT file into a tuple of
canonical name and appropriate numpy dtype | [
"Converts",
"a",
"column",
"header",
"from",
"the",
"MPT",
"file",
"into",
"a",
"tuple",
"of",
"canonical",
"name",
"and",
"appropriate",
"numpy",
"dtype"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/BioLogic_.py#L26-L49 |
jepegit/cellpy | dev_utils/BioLogic_.py | comma_converter | def comma_converter(float_string):
"""Convert numbers to floats whether the decimal point is '.' or ','"""
trans_table = maketrans(b',', b'.')
return float(float_string.translate(trans_table)) | python | def comma_converter(float_string):
"""Convert numbers to floats whether the decimal point is '.' or ','"""
trans_table = maketrans(b',', b'.')
return float(float_string.translate(trans_table)) | [
"def",
"comma_converter",
"(",
"float_string",
")",
":",
"trans_table",
"=",
"maketrans",
"(",
"b','",
",",
"b'.'",
")",
"return",
"float",
"(",
"float_string",
".",
"translate",
"(",
"trans_table",
")",
")"
] | Convert numbers to floats whether the decimal point is '.' or ', | [
"Convert",
"numbers",
"to",
"floats",
"whether",
"the",
"decimal",
"point",
"is",
".",
"or"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/BioLogic_.py#L52-L55 |
jepegit/cellpy | dev_utils/BioLogic_.py | MPTfile | def MPTfile(file_or_path):
"""Opens .mpt files as numpy record arrays
Checks for the correct headings, skips any comments and returns a
numpy record array object and a list of comments
"""
if isinstance(file_or_path, str):
mpt_file = open(file_or_path, 'rb')
else:
mpt_file = fi... | python | def MPTfile(file_or_path):
"""Opens .mpt files as numpy record arrays
Checks for the correct headings, skips any comments and returns a
numpy record array object and a list of comments
"""
if isinstance(file_or_path, str):
mpt_file = open(file_or_path, 'rb')
else:
mpt_file = fi... | [
"def",
"MPTfile",
"(",
"file_or_path",
")",
":",
"if",
"isinstance",
"(",
"file_or_path",
",",
"str",
")",
":",
"mpt_file",
"=",
"open",
"(",
"file_or_path",
",",
"'rb'",
")",
"else",
":",
"mpt_file",
"=",
"file_or_path",
"magic",
"=",
"next",
"(",
"mpt_... | Opens .mpt files as numpy record arrays
Checks for the correct headings, skips any comments and returns a
numpy record array object and a list of comments | [
"Opens",
".",
"mpt",
"files",
"as",
"numpy",
"record",
"arrays"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/BioLogic_.py#L58-L92 |
jepegit/cellpy | dev_utils/BioLogic_.py | MPTfileCSV | def MPTfileCSV(file_or_path):
"""Simple function to open MPT files as csv.DictReader objects
Checks for the correct headings, skips any comments and returns a
csv.DictReader object and a list of comments
"""
if isinstance(file_or_path, str):
mpt_file = open(file_or_path, 'r')
else:
... | python | def MPTfileCSV(file_or_path):
"""Simple function to open MPT files as csv.DictReader objects
Checks for the correct headings, skips any comments and returns a
csv.DictReader object and a list of comments
"""
if isinstance(file_or_path, str):
mpt_file = open(file_or_path, 'r')
else:
... | [
"def",
"MPTfileCSV",
"(",
"file_or_path",
")",
":",
"if",
"isinstance",
"(",
"file_or_path",
",",
"str",
")",
":",
"mpt_file",
"=",
"open",
"(",
"file_or_path",
",",
"'r'",
")",
"else",
":",
"mpt_file",
"=",
"file_or_path",
"magic",
"=",
"next",
"(",
"mp... | Simple function to open MPT files as csv.DictReader objects
Checks for the correct headings, skips any comments and returns a
csv.DictReader object and a list of comments | [
"Simple",
"function",
"to",
"open",
"MPT",
"files",
"as",
"csv",
".",
"DictReader",
"objects"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/BioLogic_.py#L95-L138 |
jepegit/cellpy | dev_utils/BioLogic_.py | read_VMP_modules | def read_VMP_modules(fileobj, read_module_data=True):
"""Reads in module headers in the VMPmodule_hdr format. Yields a dict with
the headers and offset for each module.
N.B. the offset yielded is the offset to the start of the data i.e. after
the end of the header. The data runs from (offset) to (offse... | python | def read_VMP_modules(fileobj, read_module_data=True):
"""Reads in module headers in the VMPmodule_hdr format. Yields a dict with
the headers and offset for each module.
N.B. the offset yielded is the offset to the start of the data i.e. after
the end of the header. The data runs from (offset) to (offse... | [
"def",
"read_VMP_modules",
"(",
"fileobj",
",",
"read_module_data",
"=",
"True",
")",
":",
"while",
"True",
":",
"module_magic",
"=",
"fileobj",
".",
"read",
"(",
"len",
"(",
"b'MODULE'",
")",
")",
"if",
"len",
"(",
"module_magic",
")",
"==",
"0",
":",
... | Reads in module headers in the VMPmodule_hdr format. Yields a dict with
the headers and offset for each module.
N.B. the offset yielded is the offset to the start of the data i.e. after
the end of the header. The data runs from (offset) to (offset+length) | [
"Reads",
"in",
"module",
"headers",
"in",
"the",
"VMPmodule_hdr",
"format",
".",
"Yields",
"a",
"dict",
"with",
"the",
"headers",
"and",
"offset",
"for",
"each",
"module",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/BioLogic_.py#L244-L279 |
jepegit/cellpy | cellpy/readers/instruments/arbin.py | ArbinLoader.get_headers_global | def get_headers_global():
"""Defines the so-called global column headings for Arbin .res-files"""
headers = dict()
# - global column headings (specific for Arbin)
headers["applications_path_txt"] = 'Applications_Path'
headers["channel_index_txt"] = 'Channel_Index'
headers... | python | def get_headers_global():
"""Defines the so-called global column headings for Arbin .res-files"""
headers = dict()
# - global column headings (specific for Arbin)
headers["applications_path_txt"] = 'Applications_Path'
headers["channel_index_txt"] = 'Channel_Index'
headers... | [
"def",
"get_headers_global",
"(",
")",
":",
"headers",
"=",
"dict",
"(",
")",
"# - global column headings (specific for Arbin)",
"headers",
"[",
"\"applications_path_txt\"",
"]",
"=",
"'Applications_Path'",
"headers",
"[",
"\"channel_index_txt\"",
"]",
"=",
"'Channel_Inde... | Defines the so-called global column headings for Arbin .res-files | [
"Defines",
"the",
"so",
"-",
"called",
"global",
"column",
"headings",
"for",
"Arbin",
".",
"res",
"-",
"files"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/arbin.py#L124-L152 |
jepegit/cellpy | cellpy/readers/instruments/arbin.py | ArbinLoader.inspect | def inspect(self, run_data):
"""Inspect the file -> reports to log (debug)"""
# TODO: type checking
if DEBUG_MODE:
checked_rundata = []
for data in run_data:
new_cols = data.dfdata.columns
for col in self.headers_normal:
... | python | def inspect(self, run_data):
"""Inspect the file -> reports to log (debug)"""
# TODO: type checking
if DEBUG_MODE:
checked_rundata = []
for data in run_data:
new_cols = data.dfdata.columns
for col in self.headers_normal:
... | [
"def",
"inspect",
"(",
"self",
",",
"run_data",
")",
":",
"# TODO: type checking",
"if",
"DEBUG_MODE",
":",
"checked_rundata",
"=",
"[",
"]",
"for",
"data",
"in",
"run_data",
":",
"new_cols",
"=",
"data",
".",
"dfdata",
".",
"columns",
"for",
"col",
"in",
... | Inspect the file -> reports to log (debug) | [
"Inspect",
"the",
"file",
"-",
">",
"reports",
"to",
"log",
"(",
"debug",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/arbin.py#L241-L257 |
jepegit/cellpy | cellpy/readers/instruments/arbin.py | ArbinLoader._iterdump | def _iterdump(self, file_name, headers=None):
"""
Function for dumping values from a file.
Should only be used by developers.
Args:
file_name: name of the file
headers: list of headers to pick
default:
["Discharge_Capacity", "Char... | python | def _iterdump(self, file_name, headers=None):
"""
Function for dumping values from a file.
Should only be used by developers.
Args:
file_name: name of the file
headers: list of headers to pick
default:
["Discharge_Capacity", "Char... | [
"def",
"_iterdump",
"(",
"self",
",",
"file_name",
",",
"headers",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"[",
"\"Discharge_Capacity\"",
",",
"\"Charge_Capacity\"",
"]",
"step_txt",
"=",
"self",
".",
"headers_normal",
"[",... | Function for dumping values from a file.
Should only be used by developers.
Args:
file_name: name of the file
headers: list of headers to pick
default:
["Discharge_Capacity", "Charge_Capacity"]
Returns: pandas.DataFrame | [
"Function",
"for",
"dumping",
"values",
"from",
"a",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/arbin.py#L259-L370 |
jepegit/cellpy | cellpy/readers/instruments/arbin.py | ArbinLoader.loader | def loader(self, file_name, bad_steps=None, **kwargs):
"""Loads data from arbin .res files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s (in cycle c) to skip loading.
Returns:
new_tests (list of data objects)... | python | def loader(self, file_name, bad_steps=None, **kwargs):
"""Loads data from arbin .res files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s (in cycle c) to skip loading.
Returns:
new_tests (list of data objects)... | [
"def",
"loader",
"(",
"self",
",",
"file_name",
",",
"bad_steps",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: @jepe - insert kwargs - current chunk, only normal data, etc",
"new_tests",
"=",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
... | Loads data from arbin .res files.
Args:
file_name (str): path to .res file.
bad_steps (list of tuples): (c, s) tuples of steps s (in cycle c) to skip loading.
Returns:
new_tests (list of data objects) | [
"Loads",
"data",
"from",
"arbin",
".",
"res",
"files",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/arbin.py#L506-L664 |
jepegit/cellpy | cellpy/utils/batch_old.py | _save_multi | def _save_multi(data, file_name, sep=";"):
"""convenience function for storing data column-wise in a csv-file."""
logger.debug("saving multi")
with open(file_name, "w", newline='') as f:
logger.debug(f"{file_name} opened")
writer = csv.writer(f, delimiter=sep)
try:
writer... | python | def _save_multi(data, file_name, sep=";"):
"""convenience function for storing data column-wise in a csv-file."""
logger.debug("saving multi")
with open(file_name, "w", newline='') as f:
logger.debug(f"{file_name} opened")
writer = csv.writer(f, delimiter=sep)
try:
writer... | [
"def",
"_save_multi",
"(",
"data",
",",
"file_name",
",",
"sep",
"=",
"\";\"",
")",
":",
"logger",
".",
"debug",
"(",
"\"saving multi\"",
")",
"with",
"open",
"(",
"file_name",
",",
"\"w\"",
",",
"newline",
"=",
"''",
")",
"as",
"f",
":",
"logger",
"... | convenience function for storing data column-wise in a csv-file. | [
"convenience",
"function",
"for",
"storing",
"data",
"column",
"-",
"wise",
"in",
"a",
"csv",
"-",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L152-L163 |
jepegit/cellpy | cellpy/utils/batch_old.py | _extract_dqdv | def _extract_dqdv(cell_data, extract_func, last_cycle):
"""Simple wrapper around the cellpy.utils.ica.dqdv function."""
from cellpy.utils.ica import dqdv
list_of_cycles = cell_data.get_cycle_numbers()
if last_cycle is not None:
list_of_cycles = [c for c in list_of_cycles if c <= int(last_cycle)... | python | def _extract_dqdv(cell_data, extract_func, last_cycle):
"""Simple wrapper around the cellpy.utils.ica.dqdv function."""
from cellpy.utils.ica import dqdv
list_of_cycles = cell_data.get_cycle_numbers()
if last_cycle is not None:
list_of_cycles = [c for c in list_of_cycles if c <= int(last_cycle)... | [
"def",
"_extract_dqdv",
"(",
"cell_data",
",",
"extract_func",
",",
"last_cycle",
")",
":",
"from",
"cellpy",
".",
"utils",
".",
"ica",
"import",
"dqdv",
"list_of_cycles",
"=",
"cell_data",
".",
"get_cycle_numbers",
"(",
")",
"if",
"last_cycle",
"is",
"not",
... | Simple wrapper around the cellpy.utils.ica.dqdv function. | [
"Simple",
"wrapper",
"around",
"the",
"cellpy",
".",
"utils",
".",
"ica",
".",
"dqdv",
"function",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L197-L226 |
jepegit/cellpy | cellpy/utils/batch_old.py | make_df_from_batch | def make_df_from_batch(batch_name, batch_col="b01", reader=None, reader_label=None):
"""Create a pandas DataFrame with the info needed for ``cellpy`` to load
the runs.
Args:
batch_name (str): Name of the batch.
batch_col (str): The column where the batch name is in the db.
reader (m... | python | def make_df_from_batch(batch_name, batch_col="b01", reader=None, reader_label=None):
"""Create a pandas DataFrame with the info needed for ``cellpy`` to load
the runs.
Args:
batch_name (str): Name of the batch.
batch_col (str): The column where the batch name is in the db.
reader (m... | [
"def",
"make_df_from_batch",
"(",
"batch_name",
",",
"batch_col",
"=",
"\"b01\"",
",",
"reader",
"=",
"None",
",",
"reader_label",
"=",
"None",
")",
":",
"batch_name",
"=",
"batch_name",
"batch_col",
"=",
"batch_col",
"logger",
".",
"debug",
"(",
"f\"batch_nam... | Create a pandas DataFrame with the info needed for ``cellpy`` to load
the runs.
Args:
batch_name (str): Name of the batch.
batch_col (str): The column where the batch name is in the db.
reader (method): the db-loader method.
reader_label (str): the label for the db-loader (if db... | [
"Create",
"a",
"pandas",
"DataFrame",
"with",
"the",
"info",
"needed",
"for",
"cellpy",
"to",
"load",
"the",
"runs",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L887-L917 |
jepegit/cellpy | cellpy/utils/batch_old.py | create_folder_structure | def create_folder_structure(project_name, batch_name):
"""This function creates a folder structure for the batch project.
The folder structure consists of main working folder ``project_name`
located in the ``outdatadir`` (as defined in the cellpy configuration file)
with a sub-folder named ``batch_name... | python | def create_folder_structure(project_name, batch_name):
"""This function creates a folder structure for the batch project.
The folder structure consists of main working folder ``project_name`
located in the ``outdatadir`` (as defined in the cellpy configuration file)
with a sub-folder named ``batch_name... | [
"def",
"create_folder_structure",
"(",
"project_name",
",",
"batch_name",
")",
":",
"out_data_dir",
"=",
"prms",
".",
"Paths",
"[",
"\"outdatadir\"",
"]",
"project_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_data_dir",
",",
"project_name",
")",
"batch... | This function creates a folder structure for the batch project.
The folder structure consists of main working folder ``project_name`
located in the ``outdatadir`` (as defined in the cellpy configuration file)
with a sub-folder named ``batch_name``. It also creates a folder
inside the ``batch_name`` fol... | [
"This",
"function",
"creates",
"a",
"folder",
"structure",
"for",
"the",
"batch",
"project",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L920-L953 |
jepegit/cellpy | cellpy/utils/batch_old.py | read_and_save_data | def read_and_save_data(info_df, raw_dir, sep=";", force_raw=False,
force_cellpy=False,
export_cycles=False, shifted_cycles=False,
export_raw=True,
export_ica=False, save=True, use_cellpy_stat_file=False,
p... | python | def read_and_save_data(info_df, raw_dir, sep=";", force_raw=False,
force_cellpy=False,
export_cycles=False, shifted_cycles=False,
export_raw=True,
export_ica=False, save=True, use_cellpy_stat_file=False,
p... | [
"def",
"read_and_save_data",
"(",
"info_df",
",",
"raw_dir",
",",
"sep",
"=",
"\";\"",
",",
"force_raw",
"=",
"False",
",",
"force_cellpy",
"=",
"False",
",",
"export_cycles",
"=",
"False",
",",
"shifted_cycles",
"=",
"False",
",",
"export_raw",
"=",
"True",... | Reads and saves cell data defined by the info-DataFrame.
The function iterates through the ``info_df`` and loads data from the runs.
It saves individual data for each run (if selected), as well as returns a
list of ``cellpy`` summary DataFrames, a list of the indexes (one for each
run; same as used as ... | [
"Reads",
"and",
"saves",
"cell",
"data",
"defined",
"by",
"the",
"info",
"-",
"DataFrame",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L956-L1107 |
jepegit/cellpy | cellpy/utils/batch_old.py | save_summaries | def save_summaries(frames, keys, selected_summaries, batch_dir, batch_name):
"""Writes the summaries to csv-files
Args:
frames: list of ``cellpy`` summary DataFrames
keys: list of indexes (typically run-names) for the different runs
selected_summaries: list defining which summary data t... | python | def save_summaries(frames, keys, selected_summaries, batch_dir, batch_name):
"""Writes the summaries to csv-files
Args:
frames: list of ``cellpy`` summary DataFrames
keys: list of indexes (typically run-names) for the different runs
selected_summaries: list defining which summary data t... | [
"def",
"save_summaries",
"(",
"frames",
",",
"keys",
",",
"selected_summaries",
",",
"batch_dir",
",",
"batch_name",
")",
":",
"if",
"not",
"frames",
":",
"logger",
".",
"info",
"(",
"\"Could save summaries - no summaries to save!\"",
")",
"logger",
".",
"info",
... | Writes the summaries to csv-files
Args:
frames: list of ``cellpy`` summary DataFrames
keys: list of indexes (typically run-names) for the different runs
selected_summaries: list defining which summary data to save
batch_dir: directory to save to
batch_name: the batch name (w... | [
"Writes",
"the",
"summaries",
"to",
"csv",
"-",
"files"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1110-L1146 |
jepegit/cellpy | cellpy/utils/batch_old.py | pick_summary_data | def pick_summary_data(key, summary_df, selected_summaries):
"""picks the selected pandas.DataFrame"""
selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
value = selected_summaries_dict[key]
return summary_df.iloc[:, summary_df.columns.get_level_values(1) == value] | python | def pick_summary_data(key, summary_df, selected_summaries):
"""picks the selected pandas.DataFrame"""
selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
value = selected_summaries_dict[key]
return summary_df.iloc[:, summary_df.columns.get_level_values(1) == value] | [
"def",
"pick_summary_data",
"(",
"key",
",",
"summary_df",
",",
"selected_summaries",
")",
":",
"selected_summaries_dict",
"=",
"create_selected_summaries_dict",
"(",
"selected_summaries",
")",
"value",
"=",
"selected_summaries_dict",
"[",
"key",
"]",
"return",
"summary... | picks the selected pandas.DataFrame | [
"picks",
"the",
"selected",
"pandas",
".",
"DataFrame"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1149-L1154 |
jepegit/cellpy | cellpy/utils/batch_old.py | plot_summary_data | def plot_summary_data(ax, df, info_df, color_list, symbol_list, is_charge=False,
plot_style=None):
"""creates a plot of the selected df-data in the given axes.
Typical usage:
standard_fig, (ce_ax, cap_ax, ir_ax) = plt.subplots(nrows=3, ncols=1,
... | python | def plot_summary_data(ax, df, info_df, color_list, symbol_list, is_charge=False,
plot_style=None):
"""creates a plot of the selected df-data in the given axes.
Typical usage:
standard_fig, (ce_ax, cap_ax, ir_ax) = plt.subplots(nrows=3, ncols=1,
... | [
"def",
"plot_summary_data",
"(",
"ax",
",",
"df",
",",
"info_df",
",",
"color_list",
",",
"symbol_list",
",",
"is_charge",
"=",
"False",
",",
"plot_style",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"trying to plot summary data\"",
")",
"if",
"plo... | creates a plot of the selected df-data in the given axes.
Typical usage:
standard_fig, (ce_ax, cap_ax, ir_ax) = plt.subplots(nrows=3, ncols=1,
sharex=True)
list_of_lines, plot_style = plot_summary_data(ce_ax, ce_df,
... | [
"creates",
"a",
"plot",
"of",
"the",
"selected",
"df",
"-",
"data",
"in",
"the",
"given",
"axes",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1157-L1215 |
jepegit/cellpy | cellpy/utils/batch_old.py | plot_summary_figure | def plot_summary_figure(info_df, summary_df, color_list, symbol_list,
selected_summaries,
batch_dir, batch_name, plot_style=None, show=False,
save=True,
figure_type=None):
"""Create a figure with summary graphs.
Args... | python | def plot_summary_figure(info_df, summary_df, color_list, symbol_list,
selected_summaries,
batch_dir, batch_name, plot_style=None, show=False,
save=True,
figure_type=None):
"""Create a figure with summary graphs.
Args... | [
"def",
"plot_summary_figure",
"(",
"info_df",
",",
"summary_df",
",",
"color_list",
",",
"symbol_list",
",",
"selected_summaries",
",",
"batch_dir",
",",
"batch_name",
",",
"plot_style",
"=",
"None",
",",
"show",
"=",
"False",
",",
"save",
"=",
"True",
",",
... | Create a figure with summary graphs.
Args:
info_df: the pandas DataFrame with info about the runs.
summary_df: a pandas DataFrame with the summary data.
color_list: a list of colors to use (one pr. group)
symbol_list: a list of symbols to use (one pr. cell in largest group)
s... | [
"Create",
"a",
"figure",
"with",
"summary",
"graphs",
".",
"Args",
":",
"info_df",
":",
"the",
"pandas",
"DataFrame",
"with",
"info",
"about",
"the",
"runs",
".",
"summary_df",
":",
"a",
"pandas",
"DataFrame",
"with",
"the",
"summary",
"data",
".",
"color_... | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1218-L1360 |
jepegit/cellpy | cellpy/utils/batch_old.py | export_dqdv | def export_dqdv(cell_data, savedir, sep, last_cycle=None):
"""Exports dQ/dV data from a CellpyData instance.
Args:
cell_data: CellpyData instance
savedir: path to the folder where the files should be saved
sep: separator for the .csv-files.
last_cycle: only export up to this cyc... | python | def export_dqdv(cell_data, savedir, sep, last_cycle=None):
"""Exports dQ/dV data from a CellpyData instance.
Args:
cell_data: CellpyData instance
savedir: path to the folder where the files should be saved
sep: separator for the .csv-files.
last_cycle: only export up to this cyc... | [
"def",
"export_dqdv",
"(",
"cell_data",
",",
"savedir",
",",
"sep",
",",
"last_cycle",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"exporting dqdv\"",
")",
"filename",
"=",
"cell_data",
".",
"dataset",
".",
"loaded_from",
"no_merged_sets",
"=",
"\"... | Exports dQ/dV data from a CellpyData instance.
Args:
cell_data: CellpyData instance
savedir: path to the folder where the files should be saved
sep: separator for the .csv-files.
last_cycle: only export up to this cycle (if not None) | [
"Exports",
"dQ",
"/",
"dV",
"data",
"from",
"a",
"CellpyData",
"instance",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1369-L1412 |
jepegit/cellpy | cellpy/utils/batch_old.py | init | def init(*args, **kwargs):
"""Returns an initialized instance of the Batch class"""
# set up cellpy logger
default_log_level = kwargs.pop("default_log_level", None)
import cellpy.log as log
log.setup_logging(custom_log_dir=prms.Paths["filelogdir"],
default_level=default_log_lev... | python | def init(*args, **kwargs):
"""Returns an initialized instance of the Batch class"""
# set up cellpy logger
default_log_level = kwargs.pop("default_log_level", None)
import cellpy.log as log
log.setup_logging(custom_log_dir=prms.Paths["filelogdir"],
default_level=default_log_lev... | [
"def",
"init",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# set up cellpy logger",
"default_log_level",
"=",
"kwargs",
".",
"pop",
"(",
"\"default_log_level\"",
",",
"None",
")",
"import",
"cellpy",
".",
"log",
"as",
"log",
"log",
".",
"setup_lo... | Returns an initialized instance of the Batch class | [
"Returns",
"an",
"initialized",
"instance",
"of",
"the",
"Batch",
"class"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1415-L1423 |
jepegit/cellpy | cellpy/utils/batch_old.py | debugging | def debugging():
"""This one I use for debugging..."""
print("In debugging")
json_file = r"C:\Scripting\Processing\Cell" \
r"data\outdata\SiBEC\cellpy_batch_bec_exp02.json"
b = init(default_log_level="DEBUG")
b.load_info_df(json_file)
print(b.info_df.head())
# setting some ... | python | def debugging():
"""This one I use for debugging..."""
print("In debugging")
json_file = r"C:\Scripting\Processing\Cell" \
r"data\outdata\SiBEC\cellpy_batch_bec_exp02.json"
b = init(default_log_level="DEBUG")
b.load_info_df(json_file)
print(b.info_df.head())
# setting some ... | [
"def",
"debugging",
"(",
")",
":",
"print",
"(",
"\"In debugging\"",
")",
"json_file",
"=",
"r\"C:\\Scripting\\Processing\\Cell\"",
"r\"data\\outdata\\SiBEC\\cellpy_batch_bec_exp02.json\"",
"b",
"=",
"init",
"(",
"default_log_level",
"=",
"\"DEBUG\"",
")",
"b",
".",
"lo... | This one I use for debugging... | [
"This",
"one",
"I",
"use",
"for",
"debugging",
"..."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L1437-L1455 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.create_info_df | def create_info_df(self):
"""Creates a DataFrame with info about the runs (loaded from the DB)"""
logger.debug("running create_info_df")
# initializing the reader
reader = self.reader()
self.info_df = make_df_from_batch(self.name, batch_col=self.batch_col,
... | python | def create_info_df(self):
"""Creates a DataFrame with info about the runs (loaded from the DB)"""
logger.debug("running create_info_df")
# initializing the reader
reader = self.reader()
self.info_df = make_df_from_batch(self.name, batch_col=self.batch_col,
... | [
"def",
"create_info_df",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"running create_info_df\"",
")",
"# initializing the reader",
"reader",
"=",
"self",
".",
"reader",
"(",
")",
"self",
".",
"info_df",
"=",
"make_df_from_batch",
"(",
"self",
".",
"n... | Creates a DataFrame with info about the runs (loaded from the DB) | [
"Creates",
"a",
"DataFrame",
"with",
"info",
"about",
"the",
"runs",
"(",
"loaded",
"from",
"the",
"DB",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L442-L449 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.save_info_df | def save_info_df(self):
"""Saves the DataFrame with info about the runs to a JSON file"""
logger.debug("running save_info_df")
info_df = self.info_df
top_level_dict = {'info_df': info_df, 'metadata': self._prm_packer()}
# packing prms
jason_string = json.dumps(top_leve... | python | def save_info_df(self):
"""Saves the DataFrame with info about the runs to a JSON file"""
logger.debug("running save_info_df")
info_df = self.info_df
top_level_dict = {'info_df': info_df, 'metadata': self._prm_packer()}
# packing prms
jason_string = json.dumps(top_leve... | [
"def",
"save_info_df",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"running save_info_df\"",
")",
"info_df",
"=",
"self",
".",
"info_df",
"top_level_dict",
"=",
"{",
"'info_df'",
":",
"info_df",
",",
"'metadata'",
":",
"self",
".",
"_prm_packer",
"... | Saves the DataFrame with info about the runs to a JSON file | [
"Saves",
"the",
"DataFrame",
"with",
"info",
"about",
"the",
"runs",
"to",
"a",
"JSON",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L451-L465 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.load_info_df | def load_info_df(self, file_name=None):
"""Loads a DataFrame with all the needed info about the run
(JSON file)"""
if file_name is None:
file_name = self.info_file
with open(file_name, 'r') as infile:
top_level_dict = json.load(infile)
new_info_df_dict ... | python | def load_info_df(self, file_name=None):
"""Loads a DataFrame with all the needed info about the run
(JSON file)"""
if file_name is None:
file_name = self.info_file
with open(file_name, 'r') as infile:
top_level_dict = json.load(infile)
new_info_df_dict ... | [
"def",
"load_info_df",
"(",
"self",
",",
"file_name",
"=",
"None",
")",
":",
"if",
"file_name",
"is",
"None",
":",
"file_name",
"=",
"self",
".",
"info_file",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"infile",
":",
"top_level_dict",
"=",
... | Loads a DataFrame with all the needed info about the run
(JSON file) | [
"Loads",
"a",
"DataFrame",
"with",
"all",
"the",
"needed",
"info",
"about",
"the",
"run",
"(",
"JSON",
"file",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L467-L484 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.create_folder_structure | def create_folder_structure(self):
"""Creates a folder structure based on the project and batch name.
Project - Batch-name - Raw-data-dir
The info_df JSON-file will be stored in the Project folder.
The summary-files will be saved in the Batch-name folder.
The raw data (includin... | python | def create_folder_structure(self):
"""Creates a folder structure based on the project and batch name.
Project - Batch-name - Raw-data-dir
The info_df JSON-file will be stored in the Project folder.
The summary-files will be saved in the Batch-name folder.
The raw data (includin... | [
"def",
"create_folder_structure",
"(",
"self",
")",
":",
"self",
".",
"info_file",
",",
"directories",
"=",
"create_folder_structure",
"(",
"self",
".",
"project",
",",
"self",
".",
"name",
")",
"self",
".",
"project_dir",
",",
"self",
".",
"batch_dir",
",",... | Creates a folder structure based on the project and batch name.
Project - Batch-name - Raw-data-dir
The info_df JSON-file will be stored in the Project folder.
The summary-files will be saved in the Batch-name folder.
The raw data (including exported cycles and ica-data) will be saved ... | [
"Creates",
"a",
"folder",
"structure",
"based",
"on",
"the",
"project",
"and",
"batch",
"name",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L486-L500 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.load_and_save_raw | def load_and_save_raw(self, parent_level="CellpyData"):
"""Loads the cellpy or raw-data file(s) and saves to csv"""
sep = prms.Reader["sep"]
if self.use_cellpy_stat_file is None:
use_cellpy_stat_file = prms.Reader.use_cellpy_stat_file
else:
use_cellpy_stat_file = ... | python | def load_and_save_raw(self, parent_level="CellpyData"):
"""Loads the cellpy or raw-data file(s) and saves to csv"""
sep = prms.Reader["sep"]
if self.use_cellpy_stat_file is None:
use_cellpy_stat_file = prms.Reader.use_cellpy_stat_file
else:
use_cellpy_stat_file = ... | [
"def",
"load_and_save_raw",
"(",
"self",
",",
"parent_level",
"=",
"\"CellpyData\"",
")",
":",
"sep",
"=",
"prms",
".",
"Reader",
"[",
"\"sep\"",
"]",
"if",
"self",
".",
"use_cellpy_stat_file",
"is",
"None",
":",
"use_cellpy_stat_file",
"=",
"prms",
".",
"Re... | Loads the cellpy or raw-data file(s) and saves to csv | [
"Loads",
"the",
"cellpy",
"or",
"raw",
"-",
"data",
"file",
"(",
"s",
")",
"and",
"saves",
"to",
"csv"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L502-L526 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.make_summaries | def make_summaries(self):
"""Make and save summary csv files,
each containing values from all cells"""
self.summary_df = save_summaries(self.frames, self.keys,
self.selected_summaries,
self.batch_dir, self.name)
... | python | def make_summaries(self):
"""Make and save summary csv files,
each containing values from all cells"""
self.summary_df = save_summaries(self.frames, self.keys,
self.selected_summaries,
self.batch_dir, self.name)
... | [
"def",
"make_summaries",
"(",
"self",
")",
":",
"self",
".",
"summary_df",
"=",
"save_summaries",
"(",
"self",
".",
"frames",
",",
"self",
".",
"keys",
",",
"self",
".",
"selected_summaries",
",",
"self",
".",
"batch_dir",
",",
"self",
".",
"name",
")",
... | Make and save summary csv files,
each containing values from all cells | [
"Make",
"and",
"save",
"summary",
"csv",
"files",
"each",
"containing",
"values",
"from",
"all",
"cells"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L528-L534 |
jepegit/cellpy | cellpy/utils/batch_old.py | Batch.plot_summaries | def plot_summaries(self, show=False, save=True, figure_type=None):
"""Plot summary graphs.
Args:
show: shows the figure if True.
save: saves the figure if True.
figure_type: optional, figure type to create.
"""
if not figure_type:
figure_... | python | def plot_summaries(self, show=False, save=True, figure_type=None):
"""Plot summary graphs.
Args:
show: shows the figure if True.
save: saves the figure if True.
figure_type: optional, figure type to create.
"""
if not figure_type:
figure_... | [
"def",
"plot_summaries",
"(",
"self",
",",
"show",
"=",
"False",
",",
"save",
"=",
"True",
",",
"figure_type",
"=",
"None",
")",
":",
"if",
"not",
"figure_type",
":",
"figure_type",
"=",
"self",
".",
"default_figure_type",
"if",
"not",
"figure_type",
"in",... | Plot summary graphs.
Args:
show: shows the figure if True.
save: saves the figure if True.
figure_type: optional, figure type to create. | [
"Plot",
"summary",
"graphs",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_old.py#L813-L839 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_experiments.py | CyclingExperiment.update | def update(self, all_in_memory=None):
"""Updates the selected datasets.
Args:
all_in_memory (bool): store the cellpydata in memory (default
False)
"""
logging.info("[update experiment]")
if all_in_memory is not None:
self.all_in_memory = all_... | python | def update(self, all_in_memory=None):
"""Updates the selected datasets.
Args:
all_in_memory (bool): store the cellpydata in memory (default
False)
"""
logging.info("[update experiment]")
if all_in_memory is not None:
self.all_in_memory = all_... | [
"def",
"update",
"(",
"self",
",",
"all_in_memory",
"=",
"None",
")",
":",
"logging",
".",
"info",
"(",
"\"[update experiment]\"",
")",
"if",
"all_in_memory",
"is",
"not",
"None",
":",
"self",
".",
"all_in_memory",
"=",
"all_in_memory",
"pages",
"=",
"self",... | Updates the selected datasets.
Args:
all_in_memory (bool): store the cellpydata in memory (default
False) | [
"Updates",
"the",
"selected",
"datasets",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_experiments.py#L68-L245 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_experiments.py | CyclingExperiment.link | def link(self):
"""Ensure that an appropriate link to the cellpy-files exists for
each cell.
The experiment will then contain a CellpyData object for each cell
(in the cell_data_frames attribute) with only the step-table stored.
Remark that running update persists the summary f... | python | def link(self):
"""Ensure that an appropriate link to the cellpy-files exists for
each cell.
The experiment will then contain a CellpyData object for each cell
(in the cell_data_frames attribute) with only the step-table stored.
Remark that running update persists the summary f... | [
"def",
"link",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"\"[estblishing links]\"",
")",
"logging",
".",
"debug",
"(",
"\"checking and establishing link to data\"",
")",
"cell_data_frames",
"=",
"dict",
"(",
")",
"counter",
"=",
"0",
"errors",
"=",
"... | Ensure that an appropriate link to the cellpy-files exists for
each cell.
The experiment will then contain a CellpyData object for each cell
(in the cell_data_frames attribute) with only the step-table stored.
Remark that running update persists the summary frames instead (or
e... | [
"Ensure",
"that",
"an",
"appropriate",
"link",
"to",
"the",
"cellpy",
"-",
"files",
"exists",
"for",
"each",
"cell",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_experiments.py#L268-L315 |
jepegit/cellpy | cellpy/cli.py | get_default_config_file_path | def get_default_config_file_path(init_filename=None):
"""gets the path to the default config-file"""
prm_dir = get_package_prm_dir()
if not init_filename:
init_filename = DEFAULT_FILENAME
src = os.path.join(prm_dir, init_filename)
return src | python | def get_default_config_file_path(init_filename=None):
"""gets the path to the default config-file"""
prm_dir = get_package_prm_dir()
if not init_filename:
init_filename = DEFAULT_FILENAME
src = os.path.join(prm_dir, init_filename)
return src | [
"def",
"get_default_config_file_path",
"(",
"init_filename",
"=",
"None",
")",
":",
"prm_dir",
"=",
"get_package_prm_dir",
"(",
")",
"if",
"not",
"init_filename",
":",
"init_filename",
"=",
"DEFAULT_FILENAME",
"src",
"=",
"os",
".",
"path",
".",
"join",
"(",
"... | gets the path to the default config-file | [
"gets",
"the",
"path",
"to",
"the",
"default",
"config",
"-",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/cli.py#L35-L41 |
jepegit/cellpy | cellpy/cli.py | get_user_dir_and_dst | def get_user_dir_and_dst(init_filename):
"""gets the name of the user directory and full prm filepath"""
user_dir = get_user_dir()
dst_file = os.path.join(user_dir, init_filename)
return user_dir, dst_file | python | def get_user_dir_and_dst(init_filename):
"""gets the name of the user directory and full prm filepath"""
user_dir = get_user_dir()
dst_file = os.path.join(user_dir, init_filename)
return user_dir, dst_file | [
"def",
"get_user_dir_and_dst",
"(",
"init_filename",
")",
":",
"user_dir",
"=",
"get_user_dir",
"(",
")",
"dst_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"user_dir",
",",
"init_filename",
")",
"return",
"user_dir",
",",
"dst_file"
] | gets the name of the user directory and full prm filepath | [
"gets",
"the",
"name",
"of",
"the",
"user",
"directory",
"and",
"full",
"prm",
"filepath"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/cli.py#L44-L48 |
jepegit/cellpy | cellpy/cli.py | setup | def setup(interactive, not_relative, dry_run, reset, root_dir, testuser):
"""This will help you to setup cellpy."""
click.echo("[cellpy] (setup)")
# generate variables
init_filename = create_custom_init_filename()
userdir, dst_file = get_user_dir_and_dst(init_filename)
if testuser:
if... | python | def setup(interactive, not_relative, dry_run, reset, root_dir, testuser):
"""This will help you to setup cellpy."""
click.echo("[cellpy] (setup)")
# generate variables
init_filename = create_custom_init_filename()
userdir, dst_file = get_user_dir_and_dst(init_filename)
if testuser:
if... | [
"def",
"setup",
"(",
"interactive",
",",
"not_relative",
",",
"dry_run",
",",
"reset",
",",
"root_dir",
",",
"testuser",
")",
":",
"click",
".",
"echo",
"(",
"\"[cellpy] (setup)\"",
")",
"# generate variables",
"init_filename",
"=",
"create_custom_init_filename",
... | This will help you to setup cellpy. | [
"This",
"will",
"help",
"you",
"to",
"setup",
"cellpy",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/cli.py#L131-L165 |
jepegit/cellpy | cellpy/cli.py | _parse_g_dir | def _parse_g_dir(repo, gdirpath):
"""parses a repo directory two-levels deep"""
for f in repo.get_contents(gdirpath):
if f.type == "dir":
for sf in repo.get_contents(f.path):
yield sf
else:
yield f | python | def _parse_g_dir(repo, gdirpath):
"""parses a repo directory two-levels deep"""
for f in repo.get_contents(gdirpath):
if f.type == "dir":
for sf in repo.get_contents(f.path):
yield sf
else:
yield f | [
"def",
"_parse_g_dir",
"(",
"repo",
",",
"gdirpath",
")",
":",
"for",
"f",
"in",
"repo",
".",
"get_contents",
"(",
"gdirpath",
")",
":",
"if",
"f",
".",
"type",
"==",
"\"dir\"",
":",
"for",
"sf",
"in",
"repo",
".",
"get_contents",
"(",
"f",
".",
"p... | parses a repo directory two-levels deep | [
"parses",
"a",
"repo",
"directory",
"two",
"-",
"levels",
"deep"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/cli.py#L716-L723 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_helpers.py | look_up_and_get | def look_up_and_get(cellpy_file_name, table_name):
"""Extracts table from cellpy hdf5-file."""
# infoname = '/CellpyData/info'
# dataname = '/CellpyData/dfdata'
# summaryname = '/CellpyData/dfsummary'
# fidname = '/CellpyData/fidtable'
# stepname = '/CellpyData/step_table'
root = '/CellpyD... | python | def look_up_and_get(cellpy_file_name, table_name):
"""Extracts table from cellpy hdf5-file."""
# infoname = '/CellpyData/info'
# dataname = '/CellpyData/dfdata'
# summaryname = '/CellpyData/dfsummary'
# fidname = '/CellpyData/fidtable'
# stepname = '/CellpyData/step_table'
root = '/CellpyD... | [
"def",
"look_up_and_get",
"(",
"cellpy_file_name",
",",
"table_name",
")",
":",
"# infoname = '/CellpyData/info'",
"# dataname = '/CellpyData/dfdata'",
"# summaryname = '/CellpyData/dfsummary'",
"# fidname = '/CellpyData/fidtable'",
"# stepname = '/CellpyData/step_table'",
"root",
"=",
... | Extracts table from cellpy hdf5-file. | [
"Extracts",
"table",
"from",
"cellpy",
"hdf5",
"-",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_helpers.py#L17-L33 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_helpers.py | fix_groups | def fix_groups(groups):
"""Takes care of strange group numbers."""
_groups = []
for g in groups:
try:
if not float(g) > 0:
_groups.append(1000)
else:
_groups.append(int(g))
except TypeError as e:
logging.info("Error in readi... | python | def fix_groups(groups):
"""Takes care of strange group numbers."""
_groups = []
for g in groups:
try:
if not float(g) > 0:
_groups.append(1000)
else:
_groups.append(int(g))
except TypeError as e:
logging.info("Error in readi... | [
"def",
"fix_groups",
"(",
"groups",
")",
":",
"_groups",
"=",
"[",
"]",
"for",
"g",
"in",
"groups",
":",
"try",
":",
"if",
"not",
"float",
"(",
"g",
")",
">",
"0",
":",
"_groups",
".",
"append",
"(",
"1000",
")",
"else",
":",
"_groups",
".",
"a... | Takes care of strange group numbers. | [
"Takes",
"care",
"of",
"strange",
"group",
"numbers",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_helpers.py#L88-L102 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_helpers.py | create_selected_summaries_dict | def create_selected_summaries_dict(summaries_list):
"""Creates a dictionary with summary column headers.
Examples:
>>> summaries_to_output = ["discharge_capacity", "charge_capacity"]
>>> summaries_to_output_dict = create_selected_summaries_dict(
>>> summaries_to_output
>>> )
... | python | def create_selected_summaries_dict(summaries_list):
"""Creates a dictionary with summary column headers.
Examples:
>>> summaries_to_output = ["discharge_capacity", "charge_capacity"]
>>> summaries_to_output_dict = create_selected_summaries_dict(
>>> summaries_to_output
>>> )
... | [
"def",
"create_selected_summaries_dict",
"(",
"summaries_list",
")",
":",
"headers_summary",
"=",
"cellpy",
".",
"parameters",
".",
"internal_settings",
".",
"get_headers_summary",
"(",
")",
"selected_summaries",
"=",
"dict",
"(",
")",
"for",
"h",
"in",
"summaries_l... | Creates a dictionary with summary column headers.
Examples:
>>> summaries_to_output = ["discharge_capacity", "charge_capacity"]
>>> summaries_to_output_dict = create_selected_summaries_dict(
>>> summaries_to_output
>>> )
>>> print(summaries_to_output_dict)
{'disch... | [
"Creates",
"a",
"dictionary",
"with",
"summary",
"column",
"headers",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_helpers.py#L148-L171 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_helpers.py | join_summaries | def join_summaries(summary_frames, selected_summaries, keep_old_header=False):
"""parse the summaries and combine based on column (selected_summaries)"""
selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
frames = []
keys = []
for key in summary_frames:
keys.append... | python | def join_summaries(summary_frames, selected_summaries, keep_old_header=False):
"""parse the summaries and combine based on column (selected_summaries)"""
selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
frames = []
keys = []
for key in summary_frames:
keys.append... | [
"def",
"join_summaries",
"(",
"summary_frames",
",",
"selected_summaries",
",",
"keep_old_header",
"=",
"False",
")",
":",
"selected_summaries_dict",
"=",
"create_selected_summaries_dict",
"(",
"selected_summaries",
")",
"frames",
"=",
"[",
"]",
"keys",
"=",
"[",
"]... | parse the summaries and combine based on column (selected_summaries) | [
"parse",
"the",
"summaries",
"and",
"combine",
"based",
"on",
"column",
"(",
"selected_summaries",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_helpers.py#L182-L212 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_helpers.py | generate_folder_names | def generate_folder_names(name, project):
"""Creates sensible folder names."""
out_data_dir = prms.Paths.outdatadir
project_dir = os.path.join(out_data_dir, project)
batch_dir = os.path.join(project_dir, name)
raw_dir = os.path.join(batch_dir, "raw_data")
return out_data_dir, project_dir, batch... | python | def generate_folder_names(name, project):
"""Creates sensible folder names."""
out_data_dir = prms.Paths.outdatadir
project_dir = os.path.join(out_data_dir, project)
batch_dir = os.path.join(project_dir, name)
raw_dir = os.path.join(batch_dir, "raw_data")
return out_data_dir, project_dir, batch... | [
"def",
"generate_folder_names",
"(",
"name",
",",
"project",
")",
":",
"out_data_dir",
"=",
"prms",
".",
"Paths",
".",
"outdatadir",
"project_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_data_dir",
",",
"project",
")",
"batch_dir",
"=",
"os",
".",
... | Creates sensible folder names. | [
"Creates",
"sensible",
"folder",
"names",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_helpers.py#L215-L222 |
jepegit/cellpy | cellpy/readers/cellreader.py | group_by_interpolate | def group_by_interpolate(df, x=None, y=None, group_by=None,
number_of_points=100, tidy=False,
individual_x_cols=False, header_name="Unit",
dx=10.0, generate_new_x=True):
"""Use this for generating wide format from long (tidy) data"""
ti... | python | def group_by_interpolate(df, x=None, y=None, group_by=None,
number_of_points=100, tidy=False,
individual_x_cols=False, header_name="Unit",
dx=10.0, generate_new_x=True):
"""Use this for generating wide format from long (tidy) data"""
ti... | [
"def",
"group_by_interpolate",
"(",
"df",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"group_by",
"=",
"None",
",",
"number_of_points",
"=",
"100",
",",
"tidy",
"=",
"False",
",",
"individual_x_cols",
"=",
"False",
",",
"header_name",
"=",
"\"Unit... | Use this for generating wide format from long (tidy) data | [
"Use",
"this",
"for",
"generating",
"wide",
"format",
"from",
"long",
"(",
"tidy",
")",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4004-L4067 |
jepegit/cellpy | cellpy/readers/cellreader.py | _interpolate_df_col | def _interpolate_df_col(df, x=None, y=None, new_x=None, dx=10.0,
number_of_points=None, direction=1, **kwargs):
"""Interpolate a column based on another column.
Args:
df: DataFrame with the (cycle) data.
x: Column name for the x-value (defaults to the ste... | python | def _interpolate_df_col(df, x=None, y=None, new_x=None, dx=10.0,
number_of_points=None, direction=1, **kwargs):
"""Interpolate a column based on another column.
Args:
df: DataFrame with the (cycle) data.
x: Column name for the x-value (defaults to the ste... | [
"def",
"_interpolate_df_col",
"(",
"df",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"new_x",
"=",
"None",
",",
"dx",
"=",
"10.0",
",",
"number_of_points",
"=",
"None",
",",
"direction",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"... | Interpolate a column based on another column.
Args:
df: DataFrame with the (cycle) data.
x: Column name for the x-value (defaults to the step-time column).
y: Column name for the y-value (defaults to the voltage column).
new_x (numpy array or None): Interpolate u... | [
"Interpolate",
"a",
"column",
"based",
"on",
"another",
"column",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4070-L4122 |
jepegit/cellpy | cellpy/readers/cellreader.py | _collect_capacity_curves | def _collect_capacity_curves(data, direction="charge"):
"""Create a list of pandas.DataFrames, one for each charge step.
The DataFrames are named by its cycle number.
Input: CellpyData
Returns: list of pandas.DataFrames
minimum voltage value,
maximum voltage value"""
minimum_v_val... | python | def _collect_capacity_curves(data, direction="charge"):
"""Create a list of pandas.DataFrames, one for each charge step.
The DataFrames are named by its cycle number.
Input: CellpyData
Returns: list of pandas.DataFrames
minimum voltage value,
maximum voltage value"""
minimum_v_val... | [
"def",
"_collect_capacity_curves",
"(",
"data",
",",
"direction",
"=",
"\"charge\"",
")",
":",
"minimum_v_value",
"=",
"np",
".",
"Inf",
"maximum_v_value",
"=",
"-",
"np",
".",
"Inf",
"charge_list",
"=",
"[",
"]",
"cycles",
"=",
"data",
".",
"get_cycle_numbe... | Create a list of pandas.DataFrames, one for each charge step.
The DataFrames are named by its cycle number.
Input: CellpyData
Returns: list of pandas.DataFrames
minimum voltage value,
maximum voltage value | [
"Create",
"a",
"list",
"of",
"pandas",
".",
"DataFrames",
"one",
"for",
"each",
"charge",
"step",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4125-L4161 |
jepegit/cellpy | cellpy/readers/cellreader.py | cell | def cell(filename=None, mass=None, instrument=None, logging_mode="INFO",
cycle_mode=None, auto_summary=True):
"""Create a CellpyData object"""
from cellpy import log
log.setup_logging(default_level=logging_mode)
cellpy_instance = setup_cellpy_instance()
if instrument is not None:
... | python | def cell(filename=None, mass=None, instrument=None, logging_mode="INFO",
cycle_mode=None, auto_summary=True):
"""Create a CellpyData object"""
from cellpy import log
log.setup_logging(default_level=logging_mode)
cellpy_instance = setup_cellpy_instance()
if instrument is not None:
... | [
"def",
"cell",
"(",
"filename",
"=",
"None",
",",
"mass",
"=",
"None",
",",
"instrument",
"=",
"None",
",",
"logging_mode",
"=",
"\"INFO\"",
",",
"cycle_mode",
"=",
"None",
",",
"auto_summary",
"=",
"True",
")",
":",
"from",
"cellpy",
"import",
"log",
... | Create a CellpyData object | [
"Create",
"a",
"CellpyData",
"object"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4164-L4198 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.