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 |
|---|---|---|---|---|---|---|---|---|---|---|
jepegit/cellpy | cellpy/readers/cellreader.py | just_load_srno | def just_load_srno(srno, prm_filename=None):
"""Simply load an dataset based on serial number (srno).
This convenience function reads a dataset based on a serial number. This
serial number (srno) must then be defined in your database. It is mainly
used to check that things are set up correctly.
Ar... | python | def just_load_srno(srno, prm_filename=None):
"""Simply load an dataset based on serial number (srno).
This convenience function reads a dataset based on a serial number. This
serial number (srno) must then be defined in your database. It is mainly
used to check that things are set up correctly.
Ar... | [
"def",
"just_load_srno",
"(",
"srno",
",",
"prm_filename",
"=",
"None",
")",
":",
"from",
"cellpy",
"import",
"dbreader",
",",
"filefinder",
"print",
"(",
"\"just_load_srno: srno: %i\"",
"%",
"srno",
")",
"# ------------reading parameters----------------------------------... | Simply load an dataset based on serial number (srno).
This convenience function reads a dataset based on a serial number. This
serial number (srno) must then be defined in your database. It is mainly
used to check that things are set up correctly.
Args:
prm_filename: name of parameter file (op... | [
"Simply",
"load",
"an",
"dataset",
"based",
"on",
"serial",
"number",
"(",
"srno",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4223-L4290 |
jepegit/cellpy | cellpy/readers/cellreader.py | load_and_save_resfile | def load_and_save_resfile(filename, outfile=None, outdir=None, mass=1.00):
"""Load a raw data file and save it as cellpy-file.
Args:
mass (float): active material mass [mg].
outdir (path): optional, path to directory for saving the hdf5-file.
outfile (str): optional, name of hdf5-file.
... | python | def load_and_save_resfile(filename, outfile=None, outdir=None, mass=1.00):
"""Load a raw data file and save it as cellpy-file.
Args:
mass (float): active material mass [mg].
outdir (path): optional, path to directory for saving the hdf5-file.
outfile (str): optional, name of hdf5-file.
... | [
"def",
"load_and_save_resfile",
"(",
"filename",
",",
"outfile",
"=",
"None",
",",
"outdir",
"=",
"None",
",",
"mass",
"=",
"1.00",
")",
":",
"d",
"=",
"CellpyData",
"(",
")",
"if",
"not",
"outdir",
":",
"outdir",
"=",
"prms",
".",
"Paths",
"[",
"\"c... | Load a raw data file and save it as cellpy-file.
Args:
mass (float): active material mass [mg].
outdir (path): optional, path to directory for saving the hdf5-file.
outfile (str): optional, name of hdf5-file.
filename (str): name of the resfile.
Returns:
out_file_name (... | [
"Load",
"a",
"raw",
"data",
"file",
"and",
"save",
"it",
"as",
"cellpy",
"-",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4293-L4325 |
jepegit/cellpy | cellpy/readers/cellreader.py | load_and_print_resfile | def load_and_print_resfile(filename, info_dict=None):
"""Load a raw data file and print information.
Args:
filename (str): name of the resfile.
info_dict (dict):
Returns:
info (str): string describing something.
"""
# self.test_no = None
# self.mass = 1.0 # mass of (a... | python | def load_and_print_resfile(filename, info_dict=None):
"""Load a raw data file and print information.
Args:
filename (str): name of the resfile.
info_dict (dict):
Returns:
info (str): string describing something.
"""
# self.test_no = None
# self.mass = 1.0 # mass of (a... | [
"def",
"load_and_print_resfile",
"(",
"filename",
",",
"info_dict",
"=",
"None",
")",
":",
"# self.test_no = None",
"# self.mass = 1.0 # mass of (active) material (in mg)",
"# self.no_cycles = 0.0",
"# self.charge_steps = None # not in use at the moment",
"# self.discharge_steps = None... | Load a raw data file and print information.
Args:
filename (str): name of the resfile.
info_dict (dict):
Returns:
info (str): string describing something. | [
"Load",
"a",
"raw",
"data",
"file",
"and",
"print",
"information",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L4328-L4392 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_instrument | def set_instrument(self, instrument=None):
"""Set the instrument (i.e. tell cellpy the file-type you use).
Args:
instrument: (str) in ["arbin", "bio-logic-csv", "bio-logic-bin",...]
Sets the instrument used for obtaining the data (i.e. sets fileformat)
"""
if instr... | python | def set_instrument(self, instrument=None):
"""Set the instrument (i.e. tell cellpy the file-type you use).
Args:
instrument: (str) in ["arbin", "bio-logic-csv", "bio-logic-bin",...]
Sets the instrument used for obtaining the data (i.e. sets fileformat)
"""
if instr... | [
"def",
"set_instrument",
"(",
"self",
",",
"instrument",
"=",
"None",
")",
":",
"if",
"instrument",
"is",
"None",
":",
"instrument",
"=",
"self",
".",
"tester",
"if",
"instrument",
"in",
"[",
"\"arbin\"",
",",
"\"arbin_res\"",
"]",
":",
"self",
".",
"_se... | Set the instrument (i.e. tell cellpy the file-type you use).
Args:
instrument: (str) in ["arbin", "bio-logic-csv", "bio-logic-bin",...]
Sets the instrument used for obtaining the data (i.e. sets fileformat) | [
"Set",
"the",
"instrument",
"(",
"i",
".",
"e",
".",
"tell",
"cellpy",
"the",
"file",
"-",
"type",
"you",
"use",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L213-L250 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_raw_datadir | def set_raw_datadir(self, directory=None):
"""Set the directory containing .res-files.
Used for setting directory for looking for res-files.@
A valid directory name is required.
Args:
directory (str): path to res-directory
Example:
>>> d = CellpyData()
... | python | def set_raw_datadir(self, directory=None):
"""Set the directory containing .res-files.
Used for setting directory for looking for res-files.@
A valid directory name is required.
Args:
directory (str): path to res-directory
Example:
>>> d = CellpyData()
... | [
"def",
"set_raw_datadir",
"(",
"self",
",",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"is",
"None",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"no directory name given\"",
")",
"return",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"("... | Set the directory containing .res-files.
Used for setting directory for looking for res-files.@
A valid directory name is required.
Args:
directory (str): path to res-directory
Example:
>>> d = CellpyData()
>>> directory = "MyData/Arbindata"
... | [
"Set",
"the",
"directory",
"containing",
".",
"res",
"-",
"files",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L342-L365 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_cellpy_datadir | def set_cellpy_datadir(self, directory=None):
"""Set the directory containing .hdf5-files.
Used for setting directory for looking for hdf5-files.
A valid directory name is required.
Args:
directory (str): path to hdf5-directory
Example:
>>> d = CellpyDa... | python | def set_cellpy_datadir(self, directory=None):
"""Set the directory containing .hdf5-files.
Used for setting directory for looking for hdf5-files.
A valid directory name is required.
Args:
directory (str): path to hdf5-directory
Example:
>>> d = CellpyDa... | [
"def",
"set_cellpy_datadir",
"(",
"self",
",",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"is",
"None",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"no directory name given\"",
")",
"return",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
... | Set the directory containing .hdf5-files.
Used for setting directory for looking for hdf5-files.
A valid directory name is required.
Args:
directory (str): path to hdf5-directory
Example:
>>> d = CellpyData()
>>> directory = "MyData/HDF5"
... | [
"Set",
"the",
"directory",
"containing",
".",
"hdf5",
"-",
"files",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L367-L389 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.check_file_ids | def check_file_ids(self, rawfiles, cellpyfile):
"""Check the stats for the files (raw-data and cellpy hdf5).
This function checks if the hdf5 file and the res-files have the same
timestamps etc to find out if we need to bother to load .res -files.
Args:
cellpyfile (str): fi... | python | def check_file_ids(self, rawfiles, cellpyfile):
"""Check the stats for the files (raw-data and cellpy hdf5).
This function checks if the hdf5 file and the res-files have the same
timestamps etc to find out if we need to bother to load .res -files.
Args:
cellpyfile (str): fi... | [
"def",
"check_file_ids",
"(",
"self",
",",
"rawfiles",
",",
"cellpyfile",
")",
":",
"txt",
"=",
"\"checking file ids - using '%s'\"",
"%",
"self",
".",
"filestatuschecker",
"self",
".",
"logger",
".",
"info",
"(",
"txt",
")",
"ids_cellpy_file",
"=",
"self",
".... | Check the stats for the files (raw-data and cellpy hdf5).
This function checks if the hdf5 file and the res-files have the same
timestamps etc to find out if we need to bother to load .res -files.
Args:
cellpyfile (str): filename of the cellpy hdf5-file.
rawfiles (list ... | [
"Check",
"the",
"stats",
"for",
"the",
"files",
"(",
"raw",
"-",
"data",
"and",
"cellpy",
"hdf5",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L391-L428 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData._check_raw | def _check_raw(self, file_names, abort_on_missing=False):
"""Get the file-ids for the res_files."""
strip_file_names = True
check_on = self.filestatuschecker
if not self._is_listtype(file_names):
file_names = [file_names, ]
ids = dict()
for f in file_names:
... | python | def _check_raw(self, file_names, abort_on_missing=False):
"""Get the file-ids for the res_files."""
strip_file_names = True
check_on = self.filestatuschecker
if not self._is_listtype(file_names):
file_names = [file_names, ]
ids = dict()
for f in file_names:
... | [
"def",
"_check_raw",
"(",
"self",
",",
"file_names",
",",
"abort_on_missing",
"=",
"False",
")",
":",
"strip_file_names",
"=",
"True",
"check_on",
"=",
"self",
".",
"filestatuschecker",
"if",
"not",
"self",
".",
"_is_listtype",
"(",
"file_names",
")",
":",
"... | Get the file-ids for the res_files. | [
"Get",
"the",
"file",
"-",
"ids",
"for",
"the",
"res_files",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L430-L458 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData._check_cellpy_file | def _check_cellpy_file(self, filename):
"""Get the file-ids for the cellpy_file."""
strip_filenames = True
check_on = self.filestatuschecker
self.logger.debug("checking cellpy-file")
self.logger.debug(filename)
if not os.path.isfile(filename):
self.logger.deb... | python | def _check_cellpy_file(self, filename):
"""Get the file-ids for the cellpy_file."""
strip_filenames = True
check_on = self.filestatuschecker
self.logger.debug("checking cellpy-file")
self.logger.debug(filename)
if not os.path.isfile(filename):
self.logger.deb... | [
"def",
"_check_cellpy_file",
"(",
"self",
",",
"filename",
")",
":",
"strip_filenames",
"=",
"True",
"check_on",
"=",
"self",
".",
"filestatuschecker",
"self",
".",
"logger",
".",
"debug",
"(",
"\"checking cellpy-file\"",
")",
"self",
".",
"logger",
".",
"debu... | Get the file-ids for the cellpy_file. | [
"Get",
"the",
"file",
"-",
"ids",
"for",
"the",
"cellpy_file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L460-L509 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.loadcell | def loadcell(self, raw_files, cellpy_file=None, mass=None,
summary_on_raw=False, summary_ir=True, summary_ocv=False,
summary_end_v=True, only_summary=False, only_first=False,
force_raw=False,
use_cellpy_stat_file=None):
"""Loads data for given... | python | def loadcell(self, raw_files, cellpy_file=None, mass=None,
summary_on_raw=False, summary_ir=True, summary_ocv=False,
summary_end_v=True, only_summary=False, only_first=False,
force_raw=False,
use_cellpy_stat_file=None):
"""Loads data for given... | [
"def",
"loadcell",
"(",
"self",
",",
"raw_files",
",",
"cellpy_file",
"=",
"None",
",",
"mass",
"=",
"None",
",",
"summary_on_raw",
"=",
"False",
",",
"summary_ir",
"=",
"True",
",",
"summary_ocv",
"=",
"False",
",",
"summary_end_v",
"=",
"True",
",",
"o... | Loads data for given cells.
Args:
raw_files (list): name of res-files
cellpy_file (path): name of cellpy-file
mass (float): mass of electrode or active material
summary_on_raw (bool): use raw-file for summary
summary_ir (bool): summarize ir
... | [
"Loads",
"data",
"for",
"given",
"cells",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L525-L602 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.from_raw | def from_raw(self, file_names=None, **kwargs):
"""Load a raw data-file.
Args:
file_names (list of raw-file names): uses CellpyData.file_names if
None. If the list contains more than one file name, then the
runs will be merged together.
"""
# T... | python | def from_raw(self, file_names=None, **kwargs):
"""Load a raw data-file.
Args:
file_names (list of raw-file names): uses CellpyData.file_names if
None. If the list contains more than one file name, then the
runs will be merged together.
"""
# T... | [
"def",
"from_raw",
"(",
"self",
",",
"file_names",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# This function only loads one test at a time (but could contain several",
"# files). The function from_res() also implements loading several",
"# datasets (using list of lists as inpu... | Load a raw data-file.
Args:
file_names (list of raw-file names): uses CellpyData.file_names if
None. If the list contains more than one file name, then the
runs will be merged together. | [
"Load",
"a",
"raw",
"data",
"-",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L604-L680 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.check | def check(self):
"""Returns False if no datasets exists or if one or more of the datasets
are empty"""
if len(self.status_datasets) == 0:
return False
if all(self.status_datasets):
return True
return False | python | def check(self):
"""Returns False if no datasets exists or if one or more of the datasets
are empty"""
if len(self.status_datasets) == 0:
return False
if all(self.status_datasets):
return True
return False | [
"def",
"check",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"status_datasets",
")",
"==",
"0",
":",
"return",
"False",
"if",
"all",
"(",
"self",
".",
"status_datasets",
")",
":",
"return",
"True",
"return",
"False"
] | Returns False if no datasets exists or if one or more of the datasets
are empty | [
"Returns",
"False",
"if",
"no",
"datasets",
"exists",
"or",
"if",
"one",
"or",
"more",
"of",
"the",
"datasets",
"are",
"empty"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L712-L720 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.load | def load(self, cellpy_file, parent_level="CellpyData"):
"""Loads a cellpy file.
Args:
cellpy_file (path, str): Full path to the cellpy file.
parent_level (str, optional): Parent level
"""
try:
self.logger.debug("loading cellpy-file (hdf5):")
... | python | def load(self, cellpy_file, parent_level="CellpyData"):
"""Loads a cellpy file.
Args:
cellpy_file (path, str): Full path to the cellpy file.
parent_level (str, optional): Parent level
"""
try:
self.logger.debug("loading cellpy-file (hdf5):")
... | [
"def",
"load",
"(",
"self",
",",
"cellpy_file",
",",
"parent_level",
"=",
"\"CellpyData\"",
")",
":",
"try",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"loading cellpy-file (hdf5):\"",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"cellpy_file",
")",
... | Loads a cellpy file.
Args:
cellpy_file (path, str): Full path to the cellpy file.
parent_level (str, optional): Parent level | [
"Loads",
"a",
"cellpy",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L749-L779 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData._load_hdf5 | def _load_hdf5(self, filename, parent_level="CellpyData"):
"""Load a cellpy-file.
Args:
filename (str): Name of the cellpy file.
parent_level (str) (optional): name of the parent level
(defaults to "CellpyData")
Returns:
loaded datasets (Data... | python | def _load_hdf5(self, filename, parent_level="CellpyData"):
"""Load a cellpy-file.
Args:
filename (str): Name of the cellpy file.
parent_level (str) (optional): name of the parent level
(defaults to "CellpyData")
Returns:
loaded datasets (Data... | [
"def",
"_load_hdf5",
"(",
"self",
",",
"filename",
",",
"parent_level",
"=",
"\"CellpyData\"",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"f\"file does not exist: {filename}\""... | Load a cellpy-file.
Args:
filename (str): Name of the cellpy file.
parent_level (str) (optional): name of the parent level
(defaults to "CellpyData")
Returns:
loaded datasets (DataSet-object) | [
"Load",
"a",
"cellpy",
"-",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L781-L872 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.merge | def merge(self, datasets=None, separate_datasets=False):
"""This function merges datasets into one set."""
self.logger.info("merging")
if separate_datasets:
warnings.warn("The option seperate_datasets=True is"
"not implemented yet. Performing merging, but"
... | python | def merge(self, datasets=None, separate_datasets=False):
"""This function merges datasets into one set."""
self.logger.info("merging")
if separate_datasets:
warnings.warn("The option seperate_datasets=True is"
"not implemented yet. Performing merging, but"
... | [
"def",
"merge",
"(",
"self",
",",
"datasets",
"=",
"None",
",",
"separate_datasets",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"merging\"",
")",
"if",
"separate_datasets",
":",
"warnings",
".",
"warn",
"(",
"\"The option seperate_dat... | This function merges datasets into one set. | [
"This",
"function",
"merges",
"datasets",
"into",
"one",
"set",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1018-L1041 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.print_step_table | def print_step_table(self, dataset_number=None):
"""Print the step table."""
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
return
st = self.datasets[dataset_number].step_table
print(s... | python | def print_step_table(self, dataset_number=None):
"""Print the step table."""
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
return
st = self.datasets[dataset_number].step_table
print(s... | [
"def",
"print_step_table",
"(",
"self",
",",
"dataset_number",
"=",
"None",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"None",
":",
"self",
".",
"_report_empty_dataset",
"(",
... | Print the step table. | [
"Print",
"the",
"step",
"table",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1248-L1255 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_step_numbers | def get_step_numbers(self, steptype='charge', allctypes=True, pdtype=False,
cycle_number=None, dataset_number=None,
steptable=None):
# TODO: @jepe - include sub_steps here
"""Get the step numbers of selected type.
Returns the selected step_numbe... | python | def get_step_numbers(self, steptype='charge', allctypes=True, pdtype=False,
cycle_number=None, dataset_number=None,
steptable=None):
# TODO: @jepe - include sub_steps here
"""Get the step numbers of selected type.
Returns the selected step_numbe... | [
"def",
"get_step_numbers",
"(",
"self",
",",
"steptype",
"=",
"'charge'",
",",
"allctypes",
"=",
"True",
",",
"pdtype",
"=",
"False",
",",
"cycle_number",
"=",
"None",
",",
"dataset_number",
"=",
"None",
",",
"steptable",
"=",
"None",
")",
":",
"# TODO: @j... | Get the step numbers of selected type.
Returns the selected step_numbers for the elected type of step(s).
Args:
steptype (string): string identifying type of step.
allctypes (bool): get all types of charge (or discharge).
pdtype (bool): return results as pandas.Dat... | [
"Get",
"the",
"step",
"numbers",
"of",
"selected",
"type",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1257-L1394 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.load_step_specifications | def load_step_specifications(self, file_name, short=False,
dataset_number=None):
""" Load a table that contains step-type definitions.
This function loads a file containing a specification for each step or
for each (cycle_number, step_number) combinations if sho... | python | def load_step_specifications(self, file_name, short=False,
dataset_number=None):
""" Load a table that contains step-type definitions.
This function loads a file containing a specification for each step or
for each (cycle_number, step_number) combinations if sho... | [
"def",
"load_step_specifications",
"(",
"self",
",",
"file_name",
",",
"short",
"=",
"False",
",",
"dataset_number",
"=",
"None",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
... | Load a table that contains step-type definitions.
This function loads a file containing a specification for each step or
for each (cycle_number, step_number) combinations if short==False. The
step_cycle specifications that are allowed are stored in the variable
cellreader.list_of_step_t... | [
"Load",
"a",
"table",
"that",
"contains",
"step",
"-",
"type",
"definitions",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1396-L1432 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.make_step_table | def make_step_table(self, custom_step_definition=False,
step_specifications=None,
short=False,
dataset_number=None):
""" Create a table (v.4) that contains summary information for each step.
This function creates a table containin... | python | def make_step_table(self, custom_step_definition=False,
step_specifications=None,
short=False,
dataset_number=None):
""" Create a table (v.4) that contains summary information for each step.
This function creates a table containin... | [
"def",
"make_step_table",
"(",
"self",
",",
"custom_step_definition",
"=",
"False",
",",
"step_specifications",
"=",
"None",
",",
"short",
"=",
"False",
",",
"dataset_number",
"=",
"None",
")",
":",
"time_00",
"=",
"time",
".",
"time",
"(",
")",
"dataset_num... | Create a table (v.4) that contains summary information for each step.
This function creates a table containing information about the
different steps for each cycle and, based on that, decides what type of
step it is (e.g. charge) for each cycle.
The format of the step_table is:
... | [
"Create",
"a",
"table",
"(",
"v",
".",
"4",
")",
"that",
"contains",
"summary",
"information",
"for",
"each",
"step",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1443-L1684 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.to_csv | def to_csv(self, datadir=None, sep=None, cycles=False, raw=True,
summary=True, shifted=False,
method=None, shift=0.0,
last_cycle=None):
"""Saves the data as .csv file(s).
Args:
datadir: folder where to save the data (uses current folder if not
... | python | def to_csv(self, datadir=None, sep=None, cycles=False, raw=True,
summary=True, shifted=False,
method=None, shift=0.0,
last_cycle=None):
"""Saves the data as .csv file(s).
Args:
datadir: folder where to save the data (uses current folder if not
... | [
"def",
"to_csv",
"(",
"self",
",",
"datadir",
"=",
"None",
",",
"sep",
"=",
"None",
",",
"cycles",
"=",
"False",
",",
"raw",
"=",
"True",
",",
"summary",
"=",
"True",
",",
"shifted",
"=",
"False",
",",
"method",
"=",
"None",
",",
"shift",
"=",
"0... | Saves the data as .csv file(s).
Args:
datadir: folder where to save the data (uses current folder if not
given).
sep: the separator to use in the csv file
(defaults to CellpyData.sep).
cycles: (bool) export voltage-capacity curves if True.
... | [
"Saves",
"the",
"data",
"as",
".",
"csv",
"file",
"(",
"s",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L1932-L2010 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.save | def save(self, filename, dataset_number=None, force=False, overwrite=True,
extension="h5", ensure_step_table=None):
"""Save the data structure to cellpy-format.
Args:
filename: (str) the name you want to give the file
dataset_number: (int) if you have several datase... | python | def save(self, filename, dataset_number=None, force=False, overwrite=True,
extension="h5", ensure_step_table=None):
"""Save the data structure to cellpy-format.
Args:
filename: (str) the name you want to give the file
dataset_number: (int) if you have several datase... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"dataset_number",
"=",
"None",
",",
"force",
"=",
"False",
",",
"overwrite",
"=",
"True",
",",
"extension",
"=",
"\"h5\"",
",",
"ensure_step_table",
"=",
"None",
")",
":",
"if",
"ensure_step_table",
"is",
... | Save the data structure to cellpy-format.
Args:
filename: (str) the name you want to give the file
dataset_number: (int) if you have several datasets, chose the one
you want (probably leave this untouched)
force: (bool) save a file even if the summary is not ... | [
"Save",
"the",
"data",
"structure",
"to",
"cellpy",
"-",
"format",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2012-L2156 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.sget_voltage | def sget_voltage(self, cycle, step, set_number=None):
"""Returns voltage for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][voltage_header]
Args:
cycle: cycle number
... | python | def sget_voltage(self, cycle, step, set_number=None):
"""Returns voltage for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][voltage_header]
Args:
cycle: cycle number
... | [
"def",
"sget_voltage",
"(",
"self",
",",
"cycle",
",",
"step",
",",
"set_number",
"=",
"None",
")",
":",
"time_00",
"=",
"time",
".",
"time",
"(",
")",
"set_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"set_number",
")",
"if",
"set_number",
... | Returns voltage for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][voltage_header]
Args:
cycle: cycle number
step: step number
set_number: the dataset... | [
"Returns",
"voltage",
"for",
"cycle",
"step",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2288-L2328 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_voltage | def get_voltage(self, cycle=None, dataset_number=None, full=True):
"""Returns voltage (in V).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
panda... | python | def get_voltage(self, cycle=None, dataset_number=None, full=True):
"""Returns voltage (in V).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
panda... | [
"def",
"get_voltage",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
",",
"full",
"=",
"True",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"N... | Returns voltage (in V).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
pandas.Series if True, else a list of pandas.Series
Returns:
p... | [
"Returns",
"voltage",
"(",
"in",
"V",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2330-L2373 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_current | def get_current(self, cycle=None, dataset_number=None, full=True):
"""Returns current (in mA).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
pand... | python | def get_current(self, cycle=None, dataset_number=None, full=True):
"""Returns current (in mA).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
pand... | [
"def",
"get_current",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
",",
"full",
"=",
"True",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"N... | Returns current (in mA).
Args:
cycle: cycle number (all cycles if None)
dataset_number: first dataset if None
full: valid only for cycle=None (i.e. all cycles), returns the full
pandas.Series if True, else a list of pandas.Series
Returns:
... | [
"Returns",
"current",
"(",
"in",
"mA",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2375-L2418 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.sget_steptime | def sget_steptime(self, cycle, step, dataset_number=None):
"""Returns step time for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][step_time_header]
Args:
cycle: cycl... | python | def sget_steptime(self, cycle, step, dataset_number=None):
"""Returns step time for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][step_time_header]
Args:
cycle: cycl... | [
"def",
"sget_steptime",
"(",
"self",
",",
"cycle",
",",
"step",
",",
"dataset_number",
"=",
"None",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"None",
":",
"self",
".",
... | Returns step time for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][step_time_header]
Args:
cycle: cycle number
step: step number
dataset_number: the... | [
"Returns",
"step",
"time",
"for",
"cycle",
"step",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2420-L2460 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.sget_timestamp | def sget_timestamp(self, cycle, step, dataset_number=None):
"""Returns timestamp for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][timestamp_header]
Args:
cycle: cyc... | python | def sget_timestamp(self, cycle, step, dataset_number=None):
"""Returns timestamp for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][timestamp_header]
Args:
cycle: cyc... | [
"def",
"sget_timestamp",
"(",
"self",
",",
"cycle",
",",
"step",
",",
"dataset_number",
"=",
"None",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"None",
":",
"self",
".",
... | Returns timestamp for cycle, step.
Convinience function; same as issuing
dfdata[(dfdata[cycle_index_header] == cycle) &
(dfdata[step_index_header] == step)][timestamp_header]
Args:
cycle: cycle number
step: step number
dataset_number: the... | [
"Returns",
"timestamp",
"for",
"cycle",
"step",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2462-L2499 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_timestamp | def get_timestamp(self, cycle=None, dataset_number=None,
in_minutes=False, full=True):
"""Returns timestamps (in sec or minutes (if in_minutes==True)).
Args:
cycle: cycle number (all if None)
dataset_number: first dataset if None
in_minutes: ret... | python | def get_timestamp(self, cycle=None, dataset_number=None,
in_minutes=False, full=True):
"""Returns timestamps (in sec or minutes (if in_minutes==True)).
Args:
cycle: cycle number (all if None)
dataset_number: first dataset if None
in_minutes: ret... | [
"def",
"get_timestamp",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
",",
"in_minutes",
"=",
"False",
",",
"full",
"=",
"True",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")... | Returns timestamps (in sec or minutes (if in_minutes==True)).
Args:
cycle: cycle number (all if None)
dataset_number: first dataset if None
in_minutes: return values in minutes instead of seconds if True
full: valid only for cycle=None (i.e. all cycles), returns ... | [
"Returns",
"timestamps",
"(",
"in",
"sec",
"or",
"minutes",
"(",
"if",
"in_minutes",
"==",
"True",
"))",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2501-L2547 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_dcap | def get_dcap(self, cycle=None, dataset_number=None):
"""Returns discharge_capacity (in mAh/g), and voltage."""
# TODO: should return a DataFrame as default
# but remark that we then have to update e.g. batch_helpers.py
dataset_number = self._validate_dataset_number(dataset_number)
... | python | def get_dcap(self, cycle=None, dataset_number=None):
"""Returns discharge_capacity (in mAh/g), and voltage."""
# TODO: should return a DataFrame as default
# but remark that we then have to update e.g. batch_helpers.py
dataset_number = self._validate_dataset_number(dataset_number)
... | [
"def",
"get_dcap",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
")",
":",
"# TODO: should return a DataFrame as default",
"# but remark that we then have to update e.g. batch_helpers.py",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_... | Returns discharge_capacity (in mAh/g), and voltage. | [
"Returns",
"discharge_capacity",
"(",
"in",
"mAh",
"/",
"g",
")",
"and",
"voltage",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2549-L2560 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_ccap | def get_ccap(self, cycle=None, dataset_number=None):
"""Returns charge_capacity (in mAh/g), and voltage."""
# TODO: should return a DataFrame as default
# but remark that we then have to update e.g. batch_helpers.py
dataset_number = self._validate_dataset_number(dataset_number)
... | python | def get_ccap(self, cycle=None, dataset_number=None):
"""Returns charge_capacity (in mAh/g), and voltage."""
# TODO: should return a DataFrame as default
# but remark that we then have to update e.g. batch_helpers.py
dataset_number = self._validate_dataset_number(dataset_number)
... | [
"def",
"get_ccap",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
")",
":",
"# TODO: should return a DataFrame as default",
"# but remark that we then have to update e.g. batch_helpers.py",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_... | Returns charge_capacity (in mAh/g), and voltage. | [
"Returns",
"charge_capacity",
"(",
"in",
"mAh",
"/",
"g",
")",
"and",
"voltage",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2562-L2573 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_cap | def get_cap(self, cycle=None, dataset_number=None,
method="back-and-forth",
shift=0.0,
categorical_column=False,
label_cycle_number=False,
split=False,
interpolated=False,
dx=0.1,
number_of_po... | python | def get_cap(self, cycle=None, dataset_number=None,
method="back-and-forth",
shift=0.0,
categorical_column=False,
label_cycle_number=False,
split=False,
interpolated=False,
dx=0.1,
number_of_po... | [
"def",
"get_cap",
"(",
"self",
",",
"cycle",
"=",
"None",
",",
"dataset_number",
"=",
"None",
",",
"method",
"=",
"\"back-and-forth\"",
",",
"shift",
"=",
"0.0",
",",
"categorical_column",
"=",
"False",
",",
"label_cycle_number",
"=",
"False",
",",
"split",
... | Gets the capacity for the run.
For cycle=None: not implemented yet, cycle set to 1.
Args:
cycle (int): cycle number.
method (string): how the curves are given
"back-and-forth" - standard back and forth; discharge
(or charge) reversed from wher... | [
"Gets",
"the",
"capacity",
"for",
"the",
"run",
".",
"For",
"cycle",
"=",
"None",
":",
"not",
"implemented",
"yet",
"cycle",
"set",
"to",
"1",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2575-L2790 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_ocv | def get_ocv(self, cycles=None, direction="up",
remove_first=False,
interpolated=False,
dx=None,
number_of_points=None):
"""get the open curcuit voltage relaxation curves.
Args:
cycles (list of ints or None): the cycles to extr... | python | def get_ocv(self, cycles=None, direction="up",
remove_first=False,
interpolated=False,
dx=None,
number_of_points=None):
"""get the open curcuit voltage relaxation curves.
Args:
cycles (list of ints or None): the cycles to extr... | [
"def",
"get_ocv",
"(",
"self",
",",
"cycles",
"=",
"None",
",",
"direction",
"=",
"\"up\"",
",",
"remove_first",
"=",
"False",
",",
"interpolated",
"=",
"False",
",",
"dx",
"=",
"None",
",",
"number_of_points",
"=",
"None",
")",
":",
"if",
"cycles",
"i... | get the open curcuit voltage relaxation curves.
Args:
cycles (list of ints or None): the cycles to extract from
(selects all if not given).
direction ("up", "down", or "both"): extract only relaxations that
is performed during discharge for "up" (because ... | [
"get",
"the",
"open",
"curcuit",
"voltage",
"relaxation",
"curves",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2837-L2928 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_ocv_old | def get_ocv_old(self, cycle_number=None, ocv_type='ocv', dataset_number=None):
"""Find ocv data in DataSet (voltage vs time).
Args:
cycle_number (int): find for all cycles if None.
ocv_type ("ocv", "ocvrlx_up", "ocvrlx_down"):
ocv - get up and down (default)... | python | def get_ocv_old(self, cycle_number=None, ocv_type='ocv', dataset_number=None):
"""Find ocv data in DataSet (voltage vs time).
Args:
cycle_number (int): find for all cycles if None.
ocv_type ("ocv", "ocvrlx_up", "ocvrlx_down"):
ocv - get up and down (default)... | [
"def",
"get_ocv_old",
"(",
"self",
",",
"cycle_number",
"=",
"None",
",",
"ocv_type",
"=",
"'ocv'",
",",
"dataset_number",
"=",
"None",
")",
":",
"# function for getting ocv curves",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_numbe... | Find ocv data in DataSet (voltage vs time).
Args:
cycle_number (int): find for all cycles if None.
ocv_type ("ocv", "ocvrlx_up", "ocvrlx_down"):
ocv - get up and down (default)
ocvrlx_up - get up
ocvrlx_down - get down
... | [
"Find",
"ocv",
"data",
"in",
"DataSet",
"(",
"voltage",
"vs",
"time",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L2930-L2980 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_number_of_cycles | def get_number_of_cycles(self, dataset_number=None, steptable=None):
"""Get the number of cycles in the test."""
if steptable is None:
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
... | python | def get_number_of_cycles(self, dataset_number=None, steptable=None):
"""Get the number of cycles in the test."""
if steptable is None:
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
... | [
"def",
"get_number_of_cycles",
"(",
"self",
",",
"dataset_number",
"=",
"None",
",",
"steptable",
"=",
"None",
")",
":",
"if",
"steptable",
"is",
"None",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"da... | Get the number of cycles in the test. | [
"Get",
"the",
"number",
"of",
"cycles",
"in",
"the",
"test",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3054-L3065 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_cycle_numbers | def get_cycle_numbers(self, dataset_number=None, steptable=None):
"""Get a list containing all the cycle numbers in the test."""
if steptable is None:
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_data... | python | def get_cycle_numbers(self, dataset_number=None, steptable=None):
"""Get a list containing all the cycle numbers in the test."""
if steptable is None:
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_data... | [
"def",
"get_cycle_numbers",
"(",
"self",
",",
"dataset_number",
"=",
"None",
",",
"steptable",
"=",
"None",
")",
":",
"if",
"steptable",
"is",
"None",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"datas... | Get a list containing all the cycle numbers in the test. | [
"Get",
"a",
"list",
"containing",
"all",
"the",
"cycle",
"numbers",
"in",
"the",
"test",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3067-L3078 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_converter_to_specific | def get_converter_to_specific(self, dataset=None, mass=None,
to_unit=None, from_unit=None):
"""get the convertion values
Args:
dataset: DataSet object
mass: mass of electrode (for example active material in mg)
to_unit: (float) unit ... | python | def get_converter_to_specific(self, dataset=None, mass=None,
to_unit=None, from_unit=None):
"""get the convertion values
Args:
dataset: DataSet object
mass: mass of electrode (for example active material in mg)
to_unit: (float) unit ... | [
"def",
"get_converter_to_specific",
"(",
"self",
",",
"dataset",
"=",
"None",
",",
"mass",
"=",
"None",
",",
"to_unit",
"=",
"None",
",",
"from_unit",
"=",
"None",
")",
":",
"if",
"not",
"dataset",
":",
"dataset_number",
"=",
"self",
".",
"_validate_datase... | get the convertion values
Args:
dataset: DataSet object
mass: mass of electrode (for example active material in mg)
to_unit: (float) unit of input, f.ex. if unit of charge
is mAh and unit of mass is g, then to_unit for charge/mass
will be 0.001 / ... | [
"get",
"the",
"convertion",
"values"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3084-L3122 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_mass | def set_mass(self, masses, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("mass", masses, dataset_number=dataset_number,
validated=validated) | python | def set_mass(self, masses, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("mass", masses, dataset_number=dataset_number,
validated=validated) | [
"def",
"set_mass",
"(",
"self",
",",
"masses",
",",
"dataset_number",
"=",
"None",
",",
"validated",
"=",
"None",
")",
":",
"self",
".",
"_set_run_attribute",
"(",
"\"mass\"",
",",
"masses",
",",
"dataset_number",
"=",
"dataset_number",
",",
"validated",
"="... | Sets the mass (masses) for the test (datasets). | [
"Sets",
"the",
"mass",
"(",
"masses",
")",
"for",
"the",
"test",
"(",
"datasets",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3186-L3190 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_tot_mass | def set_tot_mass(self, masses, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("tot_mass", masses,
dataset_number=dataset_number,
validated=validated) | python | def set_tot_mass(self, masses, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("tot_mass", masses,
dataset_number=dataset_number,
validated=validated) | [
"def",
"set_tot_mass",
"(",
"self",
",",
"masses",
",",
"dataset_number",
"=",
"None",
",",
"validated",
"=",
"None",
")",
":",
"self",
".",
"_set_run_attribute",
"(",
"\"tot_mass\"",
",",
"masses",
",",
"dataset_number",
"=",
"dataset_number",
",",
"validated... | Sets the mass (masses) for the test (datasets). | [
"Sets",
"the",
"mass",
"(",
"masses",
")",
"for",
"the",
"test",
"(",
"datasets",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3192-L3197 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_nom_cap | def set_nom_cap(self, nom_caps, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("nom_cap", nom_caps,
dataset_number=dataset_number,
validated=validated) | python | def set_nom_cap(self, nom_caps, dataset_number=None, validated=None):
"""Sets the mass (masses) for the test (datasets).
"""
self._set_run_attribute("nom_cap", nom_caps,
dataset_number=dataset_number,
validated=validated) | [
"def",
"set_nom_cap",
"(",
"self",
",",
"nom_caps",
",",
"dataset_number",
"=",
"None",
",",
"validated",
"=",
"None",
")",
":",
"self",
".",
"_set_run_attribute",
"(",
"\"nom_cap\"",
",",
"nom_caps",
",",
"dataset_number",
"=",
"dataset_number",
",",
"validat... | Sets the mass (masses) for the test (datasets). | [
"Sets",
"the",
"mass",
"(",
"masses",
")",
"for",
"the",
"test",
"(",
"datasets",
")",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3199-L3204 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.set_col_first | def set_col_first(df, col_names):
"""set selected columns first in a pandas.DataFrame.
This function sets cols with names given in col_names (a list) first in
the DataFrame. The last col in col_name will come first (processed last)
"""
column_headings = df.columns
colu... | python | def set_col_first(df, col_names):
"""set selected columns first in a pandas.DataFrame.
This function sets cols with names given in col_names (a list) first in
the DataFrame. The last col in col_name will come first (processed last)
"""
column_headings = df.columns
colu... | [
"def",
"set_col_first",
"(",
"df",
",",
"col_names",
")",
":",
"column_headings",
"=",
"df",
".",
"columns",
"column_headings",
"=",
"column_headings",
".",
"tolist",
"(",
")",
"try",
":",
"for",
"col_name",
"in",
"col_names",
":",
"i",
"=",
"column_headings... | set selected columns first in a pandas.DataFrame.
This function sets cols with names given in col_names (a list) first in
the DataFrame. The last col in col_name will come first (processed last) | [
"set",
"selected",
"columns",
"first",
"in",
"a",
"pandas",
".",
"DataFrame",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3207-L3224 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.get_summary | def get_summary(self, dataset_number=None, use_dfsummary_made=False):
"""Retrieve summary returned as a pandas DataFrame."""
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
return None
test = ... | python | def get_summary(self, dataset_number=None, use_dfsummary_made=False):
"""Retrieve summary returned as a pandas DataFrame."""
dataset_number = self._validate_dataset_number(dataset_number)
if dataset_number is None:
self._report_empty_dataset()
return None
test = ... | [
"def",
"get_summary",
"(",
"self",
",",
"dataset_number",
"=",
"None",
",",
"use_dfsummary_made",
"=",
"False",
")",
":",
"dataset_number",
"=",
"self",
".",
"_validate_dataset_number",
"(",
"dataset_number",
")",
"if",
"dataset_number",
"is",
"None",
":",
"self... | Retrieve summary returned as a pandas DataFrame. | [
"Retrieve",
"summary",
"returned",
"as",
"a",
"pandas",
"DataFrame",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3271-L3295 |
jepegit/cellpy | cellpy/readers/cellreader.py | CellpyData.make_summary | def make_summary(self, find_ocv=False, find_ir=False,
find_end_voltage=False,
use_cellpy_stat_file=None, all_tests=True,
dataset_number=0, ensure_step_table=True,
convert_date=False):
"""Convenience function that makes a summary... | python | def make_summary(self, find_ocv=False, find_ir=False,
find_end_voltage=False,
use_cellpy_stat_file=None, all_tests=True,
dataset_number=0, ensure_step_table=True,
convert_date=False):
"""Convenience function that makes a summary... | [
"def",
"make_summary",
"(",
"self",
",",
"find_ocv",
"=",
"False",
",",
"find_ir",
"=",
"False",
",",
"find_end_voltage",
"=",
"False",
",",
"use_cellpy_stat_file",
"=",
"None",
",",
"all_tests",
"=",
"True",
",",
"dataset_number",
"=",
"0",
",",
"ensure_ste... | Convenience function that makes a summary of the cycling data. | [
"Convenience",
"function",
"that",
"makes",
"a",
"summary",
"of",
"the",
"cycling",
"data",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L3421-L3485 |
openstax/cnx-epub | cnxepub/scripts/single_html/main.py | single_html | def single_html(epub_file_path, html_out=sys.stdout, mathjax_version=None,
numchapters=None, includes=None):
"""Generate complete book HTML."""
epub = cnxepub.EPUB.from_file(epub_file_path)
if len(epub) != 1:
raise Exception('Expecting an epub with one book')
package = epub[0]
... | python | def single_html(epub_file_path, html_out=sys.stdout, mathjax_version=None,
numchapters=None, includes=None):
"""Generate complete book HTML."""
epub = cnxepub.EPUB.from_file(epub_file_path)
if len(epub) != 1:
raise Exception('Expecting an epub with one book')
package = epub[0]
... | [
"def",
"single_html",
"(",
"epub_file_path",
",",
"html_out",
"=",
"sys",
".",
"stdout",
",",
"mathjax_version",
"=",
"None",
",",
"numchapters",
"=",
"None",
",",
"includes",
"=",
"None",
")",
":",
"epub",
"=",
"cnxepub",
".",
"EPUB",
".",
"from_file",
... | Generate complete book HTML. | [
"Generate",
"complete",
"book",
"HTML",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/scripts/single_html/main.py#L34-L65 |
jepegit/cellpy | cellpy/parameters/prmreader.py | _pack_prms | def _pack_prms():
"""if you introduce new 'save-able' parameter dictionaries, then you have
to include them here"""
config_dict = {
"Paths": prms.Paths.to_dict(),
"FileNames": prms.FileNames.to_dict(),
"Db": prms.Db.to_dict(),
"DbCols": prms.DbCols.to_dict(),
"DataSe... | python | def _pack_prms():
"""if you introduce new 'save-able' parameter dictionaries, then you have
to include them here"""
config_dict = {
"Paths": prms.Paths.to_dict(),
"FileNames": prms.FileNames.to_dict(),
"Db": prms.Db.to_dict(),
"DbCols": prms.DbCols.to_dict(),
"DataSe... | [
"def",
"_pack_prms",
"(",
")",
":",
"config_dict",
"=",
"{",
"\"Paths\"",
":",
"prms",
".",
"Paths",
".",
"to_dict",
"(",
")",
",",
"\"FileNames\"",
":",
"prms",
".",
"FileNames",
".",
"to_dict",
"(",
")",
",",
"\"Db\"",
":",
"prms",
".",
"Db",
".",
... | if you introduce new 'save-able' parameter dictionaries, then you have
to include them here | [
"if",
"you",
"introduce",
"new",
"save",
"-",
"able",
"parameter",
"dictionaries",
"then",
"you",
"have",
"to",
"include",
"them",
"here"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/parameters/prmreader.py#L56-L72 |
jepegit/cellpy | cellpy/parameters/prmreader.py | _read_prm_file | def _read_prm_file(prm_filename):
"""read the prm file"""
logger.debug("Reading config-file: %s" % prm_filename)
try:
with open(prm_filename, "r") as config_file:
prm_dict = yaml.load(config_file)
except yaml.YAMLError:
raise ConfigFileNotRead
else:
_update_prms(p... | python | def _read_prm_file(prm_filename):
"""read the prm file"""
logger.debug("Reading config-file: %s" % prm_filename)
try:
with open(prm_filename, "r") as config_file:
prm_dict = yaml.load(config_file)
except yaml.YAMLError:
raise ConfigFileNotRead
else:
_update_prms(p... | [
"def",
"_read_prm_file",
"(",
"prm_filename",
")",
":",
"logger",
".",
"debug",
"(",
"\"Reading config-file: %s\"",
"%",
"prm_filename",
")",
"try",
":",
"with",
"open",
"(",
"prm_filename",
",",
"\"r\"",
")",
"as",
"config_file",
":",
"prm_dict",
"=",
"yaml",... | read the prm file | [
"read",
"the",
"prm",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/parameters/prmreader.py#L75-L84 |
jepegit/cellpy | cellpy/parameters/prmreader.py | _get_prm_file | def _get_prm_file(file_name=None, search_order=None):
"""returns name of the prm file"""
if file_name is not None:
if os.path.isfile(file_name):
return file_name
else:
logger.info("Could not find the prm-file")
default_name = prms._prm_default_name
prm_globtxt = ... | python | def _get_prm_file(file_name=None, search_order=None):
"""returns name of the prm file"""
if file_name is not None:
if os.path.isfile(file_name):
return file_name
else:
logger.info("Could not find the prm-file")
default_name = prms._prm_default_name
prm_globtxt = ... | [
"def",
"_get_prm_file",
"(",
"file_name",
"=",
"None",
",",
"search_order",
"=",
"None",
")",
":",
"if",
"file_name",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"return",
"file_name",
"else",
":",
"log... | returns name of the prm file | [
"returns",
"name",
"of",
"the",
"prm",
"file"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/parameters/prmreader.py#L93-L156 |
jepegit/cellpy | cellpy/parameters/prmreader.py | info | def info():
"""this function will show only the 'box'-type
attributes and their content in the cellpy.prms module"""
print("convenience function for listing prms")
print(type(prms))
print(prms.__name__)
print(f"prm file: {_get_prm_file()}")
for key in prms.__dict__:
if isinstance(pr... | python | def info():
"""this function will show only the 'box'-type
attributes and their content in the cellpy.prms module"""
print("convenience function for listing prms")
print(type(prms))
print(prms.__name__)
print(f"prm file: {_get_prm_file()}")
for key in prms.__dict__:
if isinstance(pr... | [
"def",
"info",
"(",
")",
":",
"print",
"(",
"\"convenience function for listing prms\"",
")",
"print",
"(",
"type",
"(",
"prms",
")",
")",
"print",
"(",
"prms",
".",
"__name__",
")",
"print",
"(",
"f\"prm file: {_get_prm_file()}\"",
")",
"for",
"key",
"in",
... | this function will show only the 'box'-type
attributes and their content in the cellpy.prms module | [
"this",
"function",
"will",
"show",
"only",
"the",
"box",
"-",
"type",
"attributes",
"and",
"their",
"content",
"in",
"the",
"cellpy",
".",
"prms",
"module"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/parameters/prmreader.py#L165-L184 |
openstax/cnx-epub | cnxepub/formatters.py | _replace_tex_math | def _replace_tex_math(node, mml_url, mc_client=None, retry=0):
"""call mml-api service to replace TeX math in body of node with mathml"""
math = node.attrib['data-math'] or node.text
if math is None:
return None
eq = {}
if mc_client:
math_key = hashlib.md5(math.encode('utf-8')).hex... | python | def _replace_tex_math(node, mml_url, mc_client=None, retry=0):
"""call mml-api service to replace TeX math in body of node with mathml"""
math = node.attrib['data-math'] or node.text
if math is None:
return None
eq = {}
if mc_client:
math_key = hashlib.md5(math.encode('utf-8')).hex... | [
"def",
"_replace_tex_math",
"(",
"node",
",",
"mml_url",
",",
"mc_client",
"=",
"None",
",",
"retry",
"=",
"0",
")",
":",
"math",
"=",
"node",
".",
"attrib",
"[",
"'data-math'",
"]",
"or",
"node",
".",
"text",
"if",
"math",
"is",
"None",
":",
"return... | call mml-api service to replace TeX math in body of node with mathml | [
"call",
"mml",
"-",
"api",
"service",
"to",
"replace",
"TeX",
"math",
"in",
"body",
"of",
"node",
"with",
"mathml"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/formatters.py#L336-L374 |
openstax/cnx-epub | cnxepub/formatters.py | exercise_callback_factory | def exercise_callback_factory(match, url_template,
mc_client=None, token=None, mml_url=None):
"""Create a callback function to replace an exercise by fetching from
a server."""
def _replace_exercises(elem):
item_code = elem.get('href')[len(match):]
url = url_te... | python | def exercise_callback_factory(match, url_template,
mc_client=None, token=None, mml_url=None):
"""Create a callback function to replace an exercise by fetching from
a server."""
def _replace_exercises(elem):
item_code = elem.get('href')[len(match):]
url = url_te... | [
"def",
"exercise_callback_factory",
"(",
"match",
",",
"url_template",
",",
"mc_client",
"=",
"None",
",",
"token",
"=",
"None",
",",
"mml_url",
"=",
"None",
")",
":",
"def",
"_replace_exercises",
"(",
"elem",
")",
":",
"item_code",
"=",
"elem",
".",
"get"... | Create a callback function to replace an exercise by fetching from
a server. | [
"Create",
"a",
"callback",
"function",
"to",
"replace",
"an",
"exercise",
"by",
"fetching",
"from",
"a",
"server",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/formatters.py#L377-L440 |
openstax/cnx-epub | cnxepub/formatters.py | html_listify | def html_listify(tree, root_xl_element, extensions, list_type='ol'):
"""Convert a node tree into an xhtml nested list-of-lists.
This will create 'li' elements under the root_xl_element,
additional sublists of the type passed as list_type. The contents
of each li depends on the extensions dicto... | python | def html_listify(tree, root_xl_element, extensions, list_type='ol'):
"""Convert a node tree into an xhtml nested list-of-lists.
This will create 'li' elements under the root_xl_element,
additional sublists of the type passed as list_type. The contents
of each li depends on the extensions dicto... | [
"def",
"html_listify",
"(",
"tree",
",",
"root_xl_element",
",",
"extensions",
",",
"list_type",
"=",
"'ol'",
")",
":",
"for",
"node",
"in",
"tree",
":",
"li_elm",
"=",
"etree",
".",
"SubElement",
"(",
"root_xl_element",
",",
"'li'",
")",
"if",
"node",
"... | Convert a node tree into an xhtml nested list-of-lists.
This will create 'li' elements under the root_xl_element,
additional sublists of the type passed as list_type. The contents
of each li depends on the extensions dictonary: the keys of this
dictionary are the ids of tree elements that a... | [
"Convert",
"a",
"node",
"tree",
"into",
"an",
"xhtml",
"nested",
"list",
"-",
"of",
"-",
"lists",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/formatters.py#L806-L836 |
openstax/cnx-epub | cnxepub/formatters.py | HTMLFormatter._generate_ids | def _generate_ids(self, document, content):
"""Generate unique ids for html elements in page content so that it's
possible to link to them.
"""
existing_ids = content.xpath('//*/@id')
elements = [
'p', 'dl', 'dt', 'dd', 'table', 'div', 'section', 'figure',
... | python | def _generate_ids(self, document, content):
"""Generate unique ids for html elements in page content so that it's
possible to link to them.
"""
existing_ids = content.xpath('//*/@id')
elements = [
'p', 'dl', 'dt', 'dd', 'table', 'div', 'section', 'figure',
... | [
"def",
"_generate_ids",
"(",
"self",
",",
"document",
",",
"content",
")",
":",
"existing_ids",
"=",
"content",
".",
"xpath",
"(",
"'//*/@id'",
")",
"elements",
"=",
"[",
"'p'",
",",
"'dl'",
",",
"'dt'",
",",
"'dd'",
",",
"'table'",
",",
"'div'",
",",
... | Generate unique ids for html elements in page content so that it's
possible to link to them. | [
"Generate",
"unique",
"ids",
"for",
"html",
"elements",
"in",
"page",
"content",
"so",
"that",
"it",
"s",
"possible",
"to",
"link",
"to",
"them",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/formatters.py#L98-L143 |
openstax/cnx-epub | cnxepub/formatters.py | SingleHTMLFormatter.get_node_type | def get_node_type(self, node, parent=None):
"""If node is a document, the type is page.
If node is a binder with no parent, the type is book.
If node is a translucent binder, the type is either chapters (only
contain pages) or unit (contains at least one translucent binder).
"""
... | python | def get_node_type(self, node, parent=None):
"""If node is a document, the type is page.
If node is a binder with no parent, the type is book.
If node is a translucent binder, the type is either chapters (only
contain pages) or unit (contains at least one translucent binder).
"""
... | [
"def",
"get_node_type",
"(",
"self",
",",
"node",
",",
"parent",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"CompositeDocument",
")",
":",
"return",
"'composite-page'",
"elif",
"isinstance",
"(",
"node",
",",
"(",
"Document",
",",
"Docume... | If node is a document, the type is page.
If node is a binder with no parent, the type is book.
If node is a translucent binder, the type is either chapters (only
contain pages) or unit (contains at least one translucent binder). | [
"If",
"node",
"is",
"a",
"document",
"the",
"type",
"is",
"page",
".",
"If",
"node",
"is",
"a",
"binder",
"with",
"no",
"parent",
"the",
"type",
"is",
"book",
".",
"If",
"node",
"is",
"a",
"translucent",
"binder",
"the",
"type",
"is",
"either",
"chap... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/formatters.py#L218-L233 |
openstax/cnx-epub | cnxepub/epub.py | pack_epub | def pack_epub(directory, file):
"""Pack the given ``directory`` into an epub (i.e. zip) archive
given as ``file``, which can be a file-path or file-like object.
"""
with zipfile.ZipFile(file, 'w', zipfile.ZIP_DEFLATED) as zippy:
base_path = os.path.abspath(directory)
for root, dirs, file... | python | def pack_epub(directory, file):
"""Pack the given ``directory`` into an epub (i.e. zip) archive
given as ``file``, which can be a file-path or file-like object.
"""
with zipfile.ZipFile(file, 'w', zipfile.ZIP_DEFLATED) as zippy:
base_path = os.path.abspath(directory)
for root, dirs, file... | [
"def",
"pack_epub",
"(",
"directory",
",",
"file",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"file",
",",
"'w'",
",",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"as",
"zippy",
":",
"base_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"directory"... | Pack the given ``directory`` into an epub (i.e. zip) archive
given as ``file``, which can be a file-path or file-like object. | [
"Pack",
"the",
"given",
"directory",
"into",
"an",
"epub",
"(",
"i",
".",
"e",
".",
"zip",
")",
"archive",
"given",
"as",
"file",
"which",
"can",
"be",
"a",
"file",
"-",
"path",
"or",
"file",
"-",
"like",
"object",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L108-L120 |
openstax/cnx-epub | cnxepub/epub.py | unpack_epub | def unpack_epub(file, directory):
"""Unpack the given ``file`` (a file-path or file-like object)
to the given ``directory``.
"""
if zipfile.is_zipfile(file):
# Extract the epub to the current working directory.
with zipfile.ZipFile(file, 'r') as zf:
zf.extractall(path=directo... | python | def unpack_epub(file, directory):
"""Unpack the given ``file`` (a file-path or file-like object)
to the given ``directory``.
"""
if zipfile.is_zipfile(file):
# Extract the epub to the current working directory.
with zipfile.ZipFile(file, 'r') as zf:
zf.extractall(path=directo... | [
"def",
"unpack_epub",
"(",
"file",
",",
"directory",
")",
":",
"if",
"zipfile",
".",
"is_zipfile",
"(",
"file",
")",
":",
"# Extract the epub to the current working directory.",
"with",
"zipfile",
".",
"ZipFile",
"(",
"file",
",",
"'r'",
")",
"as",
"zf",
":",
... | Unpack the given ``file`` (a file-path or file-like object)
to the given ``directory``. | [
"Unpack",
"the",
"given",
"file",
"(",
"a",
"file",
"-",
"path",
"or",
"file",
"-",
"like",
"object",
")",
"to",
"the",
"given",
"directory",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L123-L130 |
openstax/cnx-epub | cnxepub/epub.py | EPUB.from_file | def from_file(cls, file):
"""Create the object from a *file* or *file-like object*.
The file can point to an ``.epub`` file or a directory
(the contents of which reflect
the internal struture of an ``.epub`` archive).
If given an non-archive file,
this structure will be u... | python | def from_file(cls, file):
"""Create the object from a *file* or *file-like object*.
The file can point to an ``.epub`` file or a directory
(the contents of which reflect
the internal struture of an ``.epub`` archive).
If given an non-archive file,
this structure will be u... | [
"def",
"from_file",
"(",
"cls",
",",
"file",
")",
":",
"root",
"=",
"None",
"if",
"zipfile",
".",
"is_zipfile",
"(",
"file",
")",
":",
"unpack_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"'-epub'",
")",
"# Extract the epub to the current working directory.",
"... | Create the object from a *file* or *file-like object*.
The file can point to an ``.epub`` file or a directory
(the contents of which reflect
the internal struture of an ``.epub`` archive).
If given an non-archive file,
this structure will be used when reading in and parsing the e... | [
"Create",
"the",
"object",
"from",
"a",
"*",
"file",
"*",
"or",
"*",
"file",
"-",
"like",
"object",
"*",
".",
"The",
"file",
"can",
"point",
"to",
"an",
".",
"epub",
"file",
"or",
"a",
"directory",
"(",
"the",
"contents",
"of",
"which",
"reflect",
... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L145-L182 |
openstax/cnx-epub | cnxepub/epub.py | EPUB.to_file | def to_file(epub, file):
"""Export to ``file``, which is a *file* or *file-like object*."""
directory = tempfile.mkdtemp('-epub')
# Write out the contents to the filesystem.
package_filenames = []
for package in epub:
opf_filepath = Package.to_file(package, directory)... | python | def to_file(epub, file):
"""Export to ``file``, which is a *file* or *file-like object*."""
directory = tempfile.mkdtemp('-epub')
# Write out the contents to the filesystem.
package_filenames = []
for package in epub:
opf_filepath = Package.to_file(package, directory)... | [
"def",
"to_file",
"(",
"epub",
",",
"file",
")",
":",
"directory",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"'-epub'",
")",
"# Write out the contents to the filesystem.",
"package_filenames",
"=",
"[",
"]",
"for",
"package",
"in",
"epub",
":",
"opf_filepath",
"=",
... | Export to ``file``, which is a *file* or *file-like object*. | [
"Export",
"to",
"file",
"which",
"is",
"a",
"*",
"file",
"*",
"or",
"*",
"file",
"-",
"like",
"object",
"*",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L185-L209 |
openstax/cnx-epub | cnxepub/epub.py | Package.from_file | def from_file(cls, file):
"""Create the object from a *file* or *file-like object*."""
opf_xml = etree.parse(file)
# Check if ``file`` is file-like.
if hasattr(file, 'read'):
name = os.path.basename(file.name)
root = os.path.abspath(os.path.dirname(file.name))
... | python | def from_file(cls, file):
"""Create the object from a *file* or *file-like object*."""
opf_xml = etree.parse(file)
# Check if ``file`` is file-like.
if hasattr(file, 'read'):
name = os.path.basename(file.name)
root = os.path.abspath(os.path.dirname(file.name))
... | [
"def",
"from_file",
"(",
"cls",
",",
"file",
")",
":",
"opf_xml",
"=",
"etree",
".",
"parse",
"(",
"file",
")",
"# Check if ``file`` is file-like.",
"if",
"hasattr",
"(",
"file",
",",
"'read'",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"basename",
... | Create the object from a *file* or *file-like object*. | [
"Create",
"the",
"object",
"from",
"a",
"*",
"file",
"*",
"or",
"*",
"file",
"-",
"like",
"object",
"*",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L349-L376 |
openstax/cnx-epub | cnxepub/epub.py | Package.to_file | def to_file(package, directory):
"""Write the package to the given ``directory``.
Returns the OPF filename.
"""
opf_filepath = os.path.join(directory, package.name)
# Create the directory structure
for name in ('contents', 'resources',):
path = os.path.join(d... | python | def to_file(package, directory):
"""Write the package to the given ``directory``.
Returns the OPF filename.
"""
opf_filepath = os.path.join(directory, package.name)
# Create the directory structure
for name in ('contents', 'resources',):
path = os.path.join(d... | [
"def",
"to_file",
"(",
"package",
",",
"directory",
")",
":",
"opf_filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"package",
".",
"name",
")",
"# Create the directory structure",
"for",
"name",
"in",
"(",
"'contents'",
",",
"'resource... | Write the package to the given ``directory``.
Returns the OPF filename. | [
"Write",
"the",
"package",
"to",
"the",
"given",
"directory",
".",
"Returns",
"the",
"OPF",
"filename",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/epub.py#L379-L413 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_journals.py | LabJournal.from_file | def from_file(self, file_name=None):
"""Loads a DataFrame with all the needed info about the experiment"""
file_name = self._check_file_name(file_name)
with open(file_name, 'r') as infile:
top_level_dict = json.load(infile)
pages_dict = top_level_dict['info_df']
pa... | python | def from_file(self, file_name=None):
"""Loads a DataFrame with all the needed info about the experiment"""
file_name = self._check_file_name(file_name)
with open(file_name, 'r') as infile:
top_level_dict = json.load(infile)
pages_dict = top_level_dict['info_df']
pa... | [
"def",
"from_file",
"(",
"self",
",",
"file_name",
"=",
"None",
")",
":",
"file_name",
"=",
"self",
".",
"_check_file_name",
"(",
"file_name",
")",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"infile",
":",
"top_level_dict",
"=",
"json",
"."... | Loads a DataFrame with all the needed info about the experiment | [
"Loads",
"a",
"DataFrame",
"with",
"all",
"the",
"needed",
"info",
"about",
"the",
"experiment"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_journals.py#L47-L61 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_journals.py | LabJournal.to_file | def to_file(self, file_name=None):
"""Saves a DataFrame with all the needed info about the experiment"""
file_name = self._check_file_name(file_name)
pages = self.pages
top_level_dict = {
'info_df': pages,
'metadata': self._prm_packer()
}
jason_... | python | def to_file(self, file_name=None):
"""Saves a DataFrame with all the needed info about the experiment"""
file_name = self._check_file_name(file_name)
pages = self.pages
top_level_dict = {
'info_df': pages,
'metadata': self._prm_packer()
}
jason_... | [
"def",
"to_file",
"(",
"self",
",",
"file_name",
"=",
"None",
")",
":",
"file_name",
"=",
"self",
".",
"_check_file_name",
"(",
"file_name",
")",
"pages",
"=",
"self",
".",
"pages",
"top_level_dict",
"=",
"{",
"'info_df'",
":",
"pages",
",",
"'metadata'",
... | Saves a DataFrame with all the needed info about the experiment | [
"Saves",
"a",
"DataFrame",
"with",
"all",
"the",
"needed",
"info",
"about",
"the",
"experiment"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_journals.py#L63-L87 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_journals.py | LabJournal.generate_folder_names | def generate_folder_names(self):
"""Set appropriate folder names."""
self.project_dir = os.path.join(prms.Paths.outdatadir, self.project)
self.batch_dir = os.path.join(self.project_dir, self.name)
self.raw_dir = os.path.join(self.batch_dir, "raw_data") | python | def generate_folder_names(self):
"""Set appropriate folder names."""
self.project_dir = os.path.join(prms.Paths.outdatadir, self.project)
self.batch_dir = os.path.join(self.project_dir, self.name)
self.raw_dir = os.path.join(self.batch_dir, "raw_data") | [
"def",
"generate_folder_names",
"(",
"self",
")",
":",
"self",
".",
"project_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"prms",
".",
"Paths",
".",
"outdatadir",
",",
"self",
".",
"project",
")",
"self",
".",
"batch_dir",
"=",
"os",
".",
"path",
... | Set appropriate folder names. | [
"Set",
"appropriate",
"folder",
"names",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_journals.py#L89-L93 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_journals.py | LabJournal.paginate | def paginate(self):
"""Make folders where we would like to put results etc."""
project_dir = self.project_dir
raw_dir = self.raw_dir
batch_dir = self.batch_dir
if project_dir is None:
raise UnderDefined("no project directory defined")
if raw_dir is None:
... | python | def paginate(self):
"""Make folders where we would like to put results etc."""
project_dir = self.project_dir
raw_dir = self.raw_dir
batch_dir = self.batch_dir
if project_dir is None:
raise UnderDefined("no project directory defined")
if raw_dir is None:
... | [
"def",
"paginate",
"(",
"self",
")",
":",
"project_dir",
"=",
"self",
".",
"project_dir",
"raw_dir",
"=",
"self",
".",
"raw_dir",
"batch_dir",
"=",
"self",
".",
"batch_dir",
"if",
"project_dir",
"is",
"None",
":",
"raise",
"UnderDefined",
"(",
"\"no project ... | Make folders where we would like to put results etc. | [
"Make",
"folders",
"where",
"we",
"would",
"like",
"to",
"put",
"results",
"etc",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_journals.py#L95-L120 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_journals.py | LabJournal.generate_file_name | def generate_file_name(self):
"""generate a suitable file name for the experiment"""
if not self.project:
raise UnderDefined("project name not given")
out_data_dir = prms.Paths.outdatadir
project_dir = os.path.join(out_data_dir, self.project)
file_name = "cellpy_batc... | python | def generate_file_name(self):
"""generate a suitable file name for the experiment"""
if not self.project:
raise UnderDefined("project name not given")
out_data_dir = prms.Paths.outdatadir
project_dir = os.path.join(out_data_dir, self.project)
file_name = "cellpy_batc... | [
"def",
"generate_file_name",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"project",
":",
"raise",
"UnderDefined",
"(",
"\"project name not given\"",
")",
"out_data_dir",
"=",
"prms",
".",
"Paths",
".",
"outdatadir",
"project_dir",
"=",
"os",
".",
"path",
... | generate a suitable file name for the experiment | [
"generate",
"a",
"suitable",
"file",
"name",
"for",
"the",
"experiment"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_journals.py#L122-L130 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_core.py | Doer.info | def info(self):
"""Delivers some info to you about the class."""
print("Sorry, but I don't have much to share.")
print("This is me:")
print(self)
print("And these are the experiments assigned to me:")
print(self.experiments) | python | def info(self):
"""Delivers some info to you about the class."""
print("Sorry, but I don't have much to share.")
print("This is me:")
print(self)
print("And these are the experiments assigned to me:")
print(self.experiments) | [
"def",
"info",
"(",
"self",
")",
":",
"print",
"(",
"\"Sorry, but I don't have much to share.\"",
")",
"print",
"(",
"\"This is me:\"",
")",
"print",
"(",
"self",
")",
"print",
"(",
"\"And these are the experiments assigned to me:\"",
")",
"print",
"(",
"self",
".",... | Delivers some info to you about the class. | [
"Delivers",
"some",
"info",
"to",
"you",
"about",
"the",
"class",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_core.py#L46-L53 |
jepegit/cellpy | cellpy/utils/batch_tools/batch_core.py | Doer.assign | def assign(self, experiment):
"""Assign an experiment."""
self.experiments.append(experiment)
self.farms.append(empty_farm) | python | def assign(self, experiment):
"""Assign an experiment."""
self.experiments.append(experiment)
self.farms.append(empty_farm) | [
"def",
"assign",
"(",
"self",
",",
"experiment",
")",
":",
"self",
".",
"experiments",
".",
"append",
"(",
"experiment",
")",
"self",
".",
"farms",
".",
"append",
"(",
"empty_farm",
")"
] | Assign an experiment. | [
"Assign",
"an",
"experiment",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/batch_tools/batch_core.py#L55-L59 |
openstax/cnx-epub | cnxepub/models.py | model_to_tree | def model_to_tree(model, title=None, lucent_id=TRANSLUCENT_BINDER_ID):
"""Given an model, build the tree::
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]}
"""
id = model.ident_hash
if id is None and isinstance(model, TranslucentBinder):
id = lucent_id
md = model.... | python | def model_to_tree(model, title=None, lucent_id=TRANSLUCENT_BINDER_ID):
"""Given an model, build the tree::
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]}
"""
id = model.ident_hash
if id is None and isinstance(model, TranslucentBinder):
id = lucent_id
md = model.... | [
"def",
"model_to_tree",
"(",
"model",
",",
"title",
"=",
"None",
",",
"lucent_id",
"=",
"TRANSLUCENT_BINDER_ID",
")",
":",
"id",
"=",
"model",
".",
"ident_hash",
"if",
"id",
"is",
"None",
"and",
"isinstance",
"(",
"model",
",",
"TranslucentBinder",
")",
":... | Given an model, build the tree::
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]} | [
"Given",
"an",
"model",
"build",
"the",
"tree",
"::"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L108-L127 |
openstax/cnx-epub | cnxepub/models.py | flatten_tree_to_ident_hashes | def flatten_tree_to_ident_hashes(item_or_tree,
lucent_id=TRANSLUCENT_BINDER_ID):
"""Flatten a tree to id and version values (ident_hash)."""
if 'contents' in item_or_tree:
tree = item_or_tree
if tree['id'] != lucent_id:
yield tree['id']
for i ... | python | def flatten_tree_to_ident_hashes(item_or_tree,
lucent_id=TRANSLUCENT_BINDER_ID):
"""Flatten a tree to id and version values (ident_hash)."""
if 'contents' in item_or_tree:
tree = item_or_tree
if tree['id'] != lucent_id:
yield tree['id']
for i ... | [
"def",
"flatten_tree_to_ident_hashes",
"(",
"item_or_tree",
",",
"lucent_id",
"=",
"TRANSLUCENT_BINDER_ID",
")",
":",
"if",
"'contents'",
"in",
"item_or_tree",
":",
"tree",
"=",
"item_or_tree",
"if",
"tree",
"[",
"'id'",
"]",
"!=",
"lucent_id",
":",
"yield",
"tr... | Flatten a tree to id and version values (ident_hash). | [
"Flatten",
"a",
"tree",
"to",
"id",
"and",
"version",
"values",
"(",
"ident_hash",
")",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L130-L143 |
openstax/cnx-epub | cnxepub/models.py | flatten_model | def flatten_model(model):
"""Flatten a model to a list of models.
This is used to flatten a ``Binder``'ish model down to a list
of contained models.
"""
yield model
if isinstance(model, (TranslucentBinder, Binder,)):
for m in model:
# yield from flatten_model(m)
f... | python | def flatten_model(model):
"""Flatten a model to a list of models.
This is used to flatten a ``Binder``'ish model down to a list
of contained models.
"""
yield model
if isinstance(model, (TranslucentBinder, Binder,)):
for m in model:
# yield from flatten_model(m)
f... | [
"def",
"flatten_model",
"(",
"model",
")",
":",
"yield",
"model",
"if",
"isinstance",
"(",
"model",
",",
"(",
"TranslucentBinder",
",",
"Binder",
",",
")",
")",
":",
"for",
"m",
"in",
"model",
":",
"# yield from flatten_model(m)",
"for",
"x",
"in",
"flatte... | Flatten a model to a list of models.
This is used to flatten a ``Binder``'ish model down to a list
of contained models. | [
"Flatten",
"a",
"model",
"to",
"a",
"list",
"of",
"models",
".",
"This",
"is",
"used",
"to",
"flatten",
"a",
"Binder",
"ish",
"model",
"down",
"to",
"a",
"list",
"of",
"contained",
"models",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L146-L156 |
openstax/cnx-epub | cnxepub/models.py | flatten_to_documents | def flatten_to_documents(model, include_pointers=False):
"""Flatten the model to a list of documents (aka ``Document`` objects).
This is to flatten a ``Binder``'ish model down to a list of documents.
If ``include_pointers`` has been set to ``True``, ``DocumentPointers``
will also be included in the resu... | python | def flatten_to_documents(model, include_pointers=False):
"""Flatten the model to a list of documents (aka ``Document`` objects).
This is to flatten a ``Binder``'ish model down to a list of documents.
If ``include_pointers`` has been set to ``True``, ``DocumentPointers``
will also be included in the resu... | [
"def",
"flatten_to_documents",
"(",
"model",
",",
"include_pointers",
"=",
"False",
")",
":",
"types",
"=",
"[",
"Document",
"]",
"if",
"include_pointers",
":",
"types",
".",
"append",
"(",
"DocumentPointer",
")",
"types",
"=",
"tuple",
"(",
"types",
")",
... | Flatten the model to a list of documents (aka ``Document`` objects).
This is to flatten a ``Binder``'ish model down to a list of documents.
If ``include_pointers`` has been set to ``True``, ``DocumentPointers``
will also be included in the results. | [
"Flatten",
"the",
"model",
"to",
"a",
"list",
"of",
"documents",
"(",
"aka",
"Document",
"objects",
")",
".",
"This",
"is",
"to",
"flatten",
"a",
"Binder",
"ish",
"model",
"down",
"to",
"a",
"list",
"of",
"documents",
".",
"If",
"include_pointers",
"has"... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L159-L174 |
openstax/cnx-epub | cnxepub/models.py | _discover_uri_type | def _discover_uri_type(uri):
"""Given a ``uri``, determine if it is internal or external."""
parsed_uri = urlparse(uri)
if not parsed_uri.netloc:
if parsed_uri.scheme == 'data':
type_ = INLINE_REFERENCE_TYPE
else:
type_ = INTERNAL_REFERENCE_TYPE
else:
type... | python | def _discover_uri_type(uri):
"""Given a ``uri``, determine if it is internal or external."""
parsed_uri = urlparse(uri)
if not parsed_uri.netloc:
if parsed_uri.scheme == 'data':
type_ = INLINE_REFERENCE_TYPE
else:
type_ = INTERNAL_REFERENCE_TYPE
else:
type... | [
"def",
"_discover_uri_type",
"(",
"uri",
")",
":",
"parsed_uri",
"=",
"urlparse",
"(",
"uri",
")",
"if",
"not",
"parsed_uri",
".",
"netloc",
":",
"if",
"parsed_uri",
".",
"scheme",
"==",
"'data'",
":",
"type_",
"=",
"INLINE_REFERENCE_TYPE",
"else",
":",
"t... | Given a ``uri``, determine if it is internal or external. | [
"Given",
"a",
"uri",
"determine",
"if",
"it",
"is",
"internal",
"or",
"external",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L191-L201 |
openstax/cnx-epub | cnxepub/models.py | _parse_references | def _parse_references(xml):
"""Parse the references to ``Reference`` instances."""
references = []
ref_finder = HTMLReferenceFinder(xml)
for elm, uri_attr in ref_finder:
type_ = _discover_uri_type(elm.get(uri_attr))
references.append(Reference(elm, type_, uri_attr))
return references | python | def _parse_references(xml):
"""Parse the references to ``Reference`` instances."""
references = []
ref_finder = HTMLReferenceFinder(xml)
for elm, uri_attr in ref_finder:
type_ = _discover_uri_type(elm.get(uri_attr))
references.append(Reference(elm, type_, uri_attr))
return references | [
"def",
"_parse_references",
"(",
"xml",
")",
":",
"references",
"=",
"[",
"]",
"ref_finder",
"=",
"HTMLReferenceFinder",
"(",
"xml",
")",
"for",
"elm",
",",
"uri_attr",
"in",
"ref_finder",
":",
"type_",
"=",
"_discover_uri_type",
"(",
"elm",
".",
"get",
"(... | Parse the references to ``Reference`` instances. | [
"Parse",
"the",
"references",
"to",
"Reference",
"instances",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L204-L211 |
openstax/cnx-epub | cnxepub/models.py | Reference._set_uri_from_bound_model | def _set_uri_from_bound_model(self):
"""Using the bound model, set the uri."""
value = self._uri_template.format(self._bound_model.id)
self.elm.set(self._uri_attr, value) | python | def _set_uri_from_bound_model(self):
"""Using the bound model, set the uri."""
value = self._uri_template.format(self._bound_model.id)
self.elm.set(self._uri_attr, value) | [
"def",
"_set_uri_from_bound_model",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_uri_template",
".",
"format",
"(",
"self",
".",
"_bound_model",
".",
"id",
")",
"self",
".",
"elm",
".",
"set",
"(",
"self",
".",
"_uri_attr",
",",
"value",
")"
] | Using the bound model, set the uri. | [
"Using",
"the",
"bound",
"model",
"set",
"the",
"uri",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L258-L261 |
openstax/cnx-epub | cnxepub/models.py | Reference.bind | def bind(self, model, template="{}"):
"""Bind the ``model`` to the reference. This uses the model's
``id`` attribute and the given ``template`` to
dynamically produce a uri when accessed.
"""
self._bound_model = model
self._uri_template = template
self._set_uri_fr... | python | def bind(self, model, template="{}"):
"""Bind the ``model`` to the reference. This uses the model's
``id`` attribute and the given ``template`` to
dynamically produce a uri when accessed.
"""
self._bound_model = model
self._uri_template = template
self._set_uri_fr... | [
"def",
"bind",
"(",
"self",
",",
"model",
",",
"template",
"=",
"\"{}\"",
")",
":",
"self",
".",
"_bound_model",
"=",
"model",
"self",
".",
"_uri_template",
"=",
"template",
"self",
".",
"_set_uri_from_bound_model",
"(",
")"
] | Bind the ``model`` to the reference. This uses the model's
``id`` attribute and the given ``template`` to
dynamically produce a uri when accessed. | [
"Bind",
"the",
"model",
"to",
"the",
"reference",
".",
"This",
"uses",
"the",
"model",
"s",
"id",
"attribute",
"and",
"the",
"given",
"template",
"to",
"dynamically",
"produce",
"a",
"uri",
"when",
"accessed",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L263-L270 |
jepegit/cellpy | cellpy/utils/ica.py | index_bounds | def index_bounds(x):
"""returns tuple with first and last item"""
if isinstance(x, (pd.DataFrame, pd.Series)):
return x.iloc[0], x.iloc[-1]
else:
return x[0], x[-1] | python | def index_bounds(x):
"""returns tuple with first and last item"""
if isinstance(x, (pd.DataFrame, pd.Series)):
return x.iloc[0], x.iloc[-1]
else:
return x[0], x[-1] | [
"def",
"index_bounds",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"(",
"pd",
".",
"DataFrame",
",",
"pd",
".",
"Series",
")",
")",
":",
"return",
"x",
".",
"iloc",
"[",
"0",
"]",
",",
"x",
".",
"iloc",
"[",
"-",
"1",
"]",
"else",
... | returns tuple with first and last item | [
"returns",
"tuple",
"with",
"first",
"and",
"last",
"item"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L367-L372 |
jepegit/cellpy | cellpy/utils/ica.py | dqdv_cycle | def dqdv_cycle(cycle, splitter=True, **kwargs):
"""Convenience functions for creating dq-dv data from given capacity and
voltage cycle.
Returns the a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycle (pandas.DataFrame): the cycle data ('voltage', 'capacity... | python | def dqdv_cycle(cycle, splitter=True, **kwargs):
"""Convenience functions for creating dq-dv data from given capacity and
voltage cycle.
Returns the a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycle (pandas.DataFrame): the cycle data ('voltage', 'capacity... | [
"def",
"dqdv_cycle",
"(",
"cycle",
",",
"splitter",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"c_first",
"=",
"cycle",
".",
"loc",
"[",
"cycle",
"[",
"\"direction\"",
"]",
"==",
"-",
"1",
"]",
"c_last",
"=",
"cycle",
".",
"loc",
"[",
"cycle",... | Convenience functions for creating dq-dv data from given capacity and
voltage cycle.
Returns the a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycle (pandas.DataFrame): the cycle data ('voltage', 'capacity',
'direction' (1 or -1)).
... | [
"Convenience",
"functions",
"for",
"creating",
"dq",
"-",
"dv",
"data",
"from",
"given",
"capacity",
"and",
"voltage",
"cycle",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L375-L432 |
jepegit/cellpy | cellpy/utils/ica.py | dqdv_cycles | def dqdv_cycles(cycles, **kwargs):
"""Convenience functions for creating dq-dv data from given capacity and
voltage cycles.
Returns a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycles (pandas.DataFrame): the cycle data ('cycle', 'voltage',
... | python | def dqdv_cycles(cycles, **kwargs):
"""Convenience functions for creating dq-dv data from given capacity and
voltage cycles.
Returns a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycles (pandas.DataFrame): the cycle data ('cycle', 'voltage',
... | [
"def",
"dqdv_cycles",
"(",
"cycles",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: should add option for normalising based on first cycle capacity",
"# this is e.g. done by first finding the first cycle capacity (nom_cap)",
"# (or use nominal capacity given as input) and then propagating this ... | Convenience functions for creating dq-dv data from given capacity and
voltage cycles.
Returns a DataFrame with a 'voltage' and a 'incremental_capacity'
column.
Args:
cycles (pandas.DataFrame): the cycle data ('cycle', 'voltage',
'capacity', 'direction' (1 or -1)).
... | [
"Convenience",
"functions",
"for",
"creating",
"dq",
"-",
"dv",
"data",
"from",
"given",
"capacity",
"and",
"voltage",
"cycles",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L435-L481 |
jepegit/cellpy | cellpy/utils/ica.py | dqdv | def dqdv(voltage, capacity, voltage_resolution=None, capacity_resolution=None,
voltage_fwhm=0.01, pre_smoothing=True, diff_smoothing=False,
post_smoothing=True, post_normalization=True,
interpolation_method=None, gaussian_order=None, gaussian_mode=None, gaussian_cval=None,
gaussian_t... | python | def dqdv(voltage, capacity, voltage_resolution=None, capacity_resolution=None,
voltage_fwhm=0.01, pre_smoothing=True, diff_smoothing=False,
post_smoothing=True, post_normalization=True,
interpolation_method=None, gaussian_order=None, gaussian_mode=None, gaussian_cval=None,
gaussian_t... | [
"def",
"dqdv",
"(",
"voltage",
",",
"capacity",
",",
"voltage_resolution",
"=",
"None",
",",
"capacity_resolution",
"=",
"None",
",",
"voltage_fwhm",
"=",
"0.01",
",",
"pre_smoothing",
"=",
"True",
",",
"diff_smoothing",
"=",
"False",
",",
"post_smoothing",
"=... | Convenience functions for creating dq-dv data from given capacity
and voltage data.
Args:
voltage: nd.array or pd.Series
capacity: nd.array or pd.Series
voltage_resolution: used for interpolating voltage data (e.g. 0.005)
capacity_resolution: used for interpolating capacity data... | [
"Convenience",
"functions",
"for",
"creating",
"dq",
"-",
"dv",
"data",
"from",
"given",
"capacity",
"and",
"voltage",
"data",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L484-L587 |
jepegit/cellpy | cellpy/utils/ica.py | _dqdv_combinded_frame | def _dqdv_combinded_frame(cell, **kwargs):
"""Returns full cycle dqdv data for all cycles as one pd.DataFrame.
Args:
cell: CellpyData-object
Returns:
pandas.DataFrame with the following columns:
cycle: cycle number
voltage: voltage
... | python | def _dqdv_combinded_frame(cell, **kwargs):
"""Returns full cycle dqdv data for all cycles as one pd.DataFrame.
Args:
cell: CellpyData-object
Returns:
pandas.DataFrame with the following columns:
cycle: cycle number
voltage: voltage
... | [
"def",
"_dqdv_combinded_frame",
"(",
"cell",
",",
"*",
"*",
"kwargs",
")",
":",
"cycles",
"=",
"cell",
".",
"get_cap",
"(",
"method",
"=",
"\"forth-and-forth\"",
",",
"categorical_column",
"=",
"True",
",",
"label_cycle_number",
"=",
"True",
",",
")",
"ica_d... | Returns full cycle dqdv data for all cycles as one pd.DataFrame.
Args:
cell: CellpyData-object
Returns:
pandas.DataFrame with the following columns:
cycle: cycle number
voltage: voltage
dq: the incremental capacity | [
"Returns",
"full",
"cycle",
"dqdv",
"data",
"for",
"all",
"cycles",
"as",
"one",
"pd",
".",
"DataFrame",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L629-L649 |
jepegit/cellpy | cellpy/utils/ica.py | dqdv_frames | def dqdv_frames(cell, split=False, **kwargs):
"""Returns dqdv data as pandas.DataFrame(s) for all cycles.
Args:
cell (CellpyData-object).
split (bool): return one frame for charge and one for
discharge if True (defaults to False).
Returns... | python | def dqdv_frames(cell, split=False, **kwargs):
"""Returns dqdv data as pandas.DataFrame(s) for all cycles.
Args:
cell (CellpyData-object).
split (bool): return one frame for charge and one for
discharge if True (defaults to False).
Returns... | [
"def",
"dqdv_frames",
"(",
"cell",
",",
"split",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: should add option for normalising based on first cycle capacity",
"# this is e.g. done by first finding the first cycle capacity (nom_cap)",
"# (or use nominal capacity given as... | Returns dqdv data as pandas.DataFrame(s) for all cycles.
Args:
cell (CellpyData-object).
split (bool): return one frame for charge and one for
discharge if True (defaults to False).
Returns:
pandas.DataFrame(s) with the follow... | [
"Returns",
"dqdv",
"data",
"as",
"pandas",
".",
"DataFrame",
"(",
"s",
")",
"for",
"all",
"cycles",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L652-L680 |
jepegit/cellpy | cellpy/utils/ica.py | _dqdv_split_frames | def _dqdv_split_frames(cell, tidy=False, **kwargs):
"""Returns dqdv data as pandas.DataFrames for all cycles.
Args:
cell (CellpyData-object).
tidy (bool): return in wide format if False (default),
long (tidy) format if True.
Returns:
(charge_ica_... | python | def _dqdv_split_frames(cell, tidy=False, **kwargs):
"""Returns dqdv data as pandas.DataFrames for all cycles.
Args:
cell (CellpyData-object).
tidy (bool): return in wide format if False (default),
long (tidy) format if True.
Returns:
(charge_ica_... | [
"def",
"_dqdv_split_frames",
"(",
"cell",
",",
"tidy",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"charge_dfs",
",",
"cycles",
",",
"minimum_v",
",",
"maximum_v",
"=",
"_collect_capacity_curves",
"(",
"cell",
",",
"direction",
"=",
"\"charge\"",
")",
... | Returns dqdv data as pandas.DataFrames for all cycles.
Args:
cell (CellpyData-object).
tidy (bool): return in wide format if False (default),
long (tidy) format if True.
Returns:
(charge_ica_frame, discharge_ica_frame) where the frames are
... | [
"Returns",
"dqdv",
"data",
"as",
"pandas",
".",
"DataFrames",
"for",
"all",
"cycles",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L683-L750 |
jepegit/cellpy | cellpy/utils/ica.py | Converter.set_data | def set_data(self, capacity, voltage=None,
capacity_label="q", voltage_label="v"
):
"""Set the data"""
logging.debug("setting data (capacity and voltage)")
if isinstance(capacity, pd.DataFrame):
logging.debug("recieved a pandas.DataFrame")
... | python | def set_data(self, capacity, voltage=None,
capacity_label="q", voltage_label="v"
):
"""Set the data"""
logging.debug("setting data (capacity and voltage)")
if isinstance(capacity, pd.DataFrame):
logging.debug("recieved a pandas.DataFrame")
... | [
"def",
"set_data",
"(",
"self",
",",
"capacity",
",",
"voltage",
"=",
"None",
",",
"capacity_label",
"=",
"\"q\"",
",",
"voltage_label",
"=",
"\"v\"",
")",
":",
"logging",
".",
"debug",
"(",
"\"setting data (capacity and voltage)\"",
")",
"if",
"isinstance",
"... | Set the data | [
"Set",
"the",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L113-L127 |
jepegit/cellpy | cellpy/utils/ica.py | Converter.inspect_data | def inspect_data(self, capacity=None, voltage=None,
err_est=False, diff_est=False):
"""check and inspect the data"""
logging.debug("inspecting the data")
if capacity is None:
capacity = self.capacity
if voltage is None:
voltage = self.voltag... | python | def inspect_data(self, capacity=None, voltage=None,
err_est=False, diff_est=False):
"""check and inspect the data"""
logging.debug("inspecting the data")
if capacity is None:
capacity = self.capacity
if voltage is None:
voltage = self.voltag... | [
"def",
"inspect_data",
"(",
"self",
",",
"capacity",
"=",
"None",
",",
"voltage",
"=",
"None",
",",
"err_est",
"=",
"False",
",",
"diff_est",
"=",
"False",
")",
":",
"logging",
".",
"debug",
"(",
"\"inspecting the data\"",
")",
"if",
"capacity",
"is",
"N... | check and inspect the data | [
"check",
"and",
"inspect",
"the",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L129-L205 |
jepegit/cellpy | cellpy/utils/ica.py | Converter.pre_process_data | def pre_process_data(self):
"""perform some pre-processing of the data (i.e. interpolation)"""
logging.debug("pre-processing the data")
capacity = self.capacity
voltage = self.voltage
# performing an interpolation in v(q) space
logging.debug(" - interpolating voltage(c... | python | def pre_process_data(self):
"""perform some pre-processing of the data (i.e. interpolation)"""
logging.debug("pre-processing the data")
capacity = self.capacity
voltage = self.voltage
# performing an interpolation in v(q) space
logging.debug(" - interpolating voltage(c... | [
"def",
"pre_process_data",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"pre-processing the data\"",
")",
"capacity",
"=",
"self",
".",
"capacity",
"voltage",
"=",
"self",
".",
"voltage",
"# performing an interpolation in v(q) space",
"logging",
".",
"debu... | perform some pre-processing of the data (i.e. interpolation) | [
"perform",
"some",
"pre",
"-",
"processing",
"of",
"the",
"data",
"(",
"i",
".",
"e",
".",
"interpolation",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L207-L250 |
jepegit/cellpy | cellpy/utils/ica.py | Converter.increment_data | def increment_data(self):
"""perform the dq-dv transform"""
# NOTE TO ASBJOERN: Probably insert method for "binning" instead of
# differentiating here
# (use self.increment_method as the variable for selecting method for)
logging.debug("incrementing data")
# ---- shift... | python | def increment_data(self):
"""perform the dq-dv transform"""
# NOTE TO ASBJOERN: Probably insert method for "binning" instead of
# differentiating here
# (use self.increment_method as the variable for selecting method for)
logging.debug("incrementing data")
# ---- shift... | [
"def",
"increment_data",
"(",
"self",
")",
":",
"# NOTE TO ASBJOERN: Probably insert method for \"binning\" instead of",
"# differentiating here",
"# (use self.increment_method as the variable for selecting method for)",
"logging",
".",
"debug",
"(",
"\"incrementing data\"",
")",
"# --... | perform the dq-dv transform | [
"perform",
"the",
"dq",
"-",
"dv",
"transform"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L252-L311 |
jepegit/cellpy | cellpy/utils/ica.py | Converter.post_process_data | def post_process_data(self, voltage=None, incremental_capacity=None,
voltage_step=None):
"""perform post-processing (smoothing, normalisation, interpolation) of
the data"""
logging.debug("post-processing data")
if voltage is None:
voltage = self.vo... | python | def post_process_data(self, voltage=None, incremental_capacity=None,
voltage_step=None):
"""perform post-processing (smoothing, normalisation, interpolation) of
the data"""
logging.debug("post-processing data")
if voltage is None:
voltage = self.vo... | [
"def",
"post_process_data",
"(",
"self",
",",
"voltage",
"=",
"None",
",",
"incremental_capacity",
"=",
"None",
",",
"voltage_step",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\"post-processing data\"",
")",
"if",
"voltage",
"is",
"None",
":",
"vo... | perform post-processing (smoothing, normalisation, interpolation) of
the data | [
"perform",
"post",
"-",
"processing",
"(",
"smoothing",
"normalisation",
"interpolation",
")",
"of",
"the",
"data"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ica.py#L313-L359 |
openstax/cnx-epub | cnxepub/collation.py | easybake | def easybake(ruleset, in_html, out_html):
"""This adheres to the same interface as
``cnxeasybake.scripts.main.easyback``.
``ruleset`` is a string containing the ruleset CSS
while ``in_html`` and ``out_html`` are file-like objects,
with respective read and write ability.
"""
html = etree.par... | python | def easybake(ruleset, in_html, out_html):
"""This adheres to the same interface as
``cnxeasybake.scripts.main.easyback``.
``ruleset`` is a string containing the ruleset CSS
while ``in_html`` and ``out_html`` are file-like objects,
with respective read and write ability.
"""
html = etree.par... | [
"def",
"easybake",
"(",
"ruleset",
",",
"in_html",
",",
"out_html",
")",
":",
"html",
"=",
"etree",
".",
"parse",
"(",
"in_html",
")",
"oven",
"=",
"Oven",
"(",
"ruleset",
")",
"oven",
".",
"bake",
"(",
"html",
")",
"out_html",
".",
"write",
"(",
"... | This adheres to the same interface as
``cnxeasybake.scripts.main.easyback``.
``ruleset`` is a string containing the ruleset CSS
while ``in_html`` and ``out_html`` are file-like objects,
with respective read and write ability. | [
"This",
"adheres",
"to",
"the",
"same",
"interface",
"as",
"cnxeasybake",
".",
"scripts",
".",
"main",
".",
"easyback",
".",
"ruleset",
"is",
"a",
"string",
"containing",
"the",
"ruleset",
"CSS",
"while",
"in_html",
"and",
"out_html",
"are",
"file",
"-",
"... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/collation.py#L28-L39 |
openstax/cnx-epub | cnxepub/collation.py | reconstitute | def reconstitute(html):
"""Given a file-like object as ``html``, reconstruct it into models."""
try:
htree = etree.parse(html)
except etree.XMLSyntaxError:
html.seek(0)
htree = etree.HTML(html.read())
xhtml = etree.tostring(htree, encoding='utf-8')
return adapt_single_html(x... | python | def reconstitute(html):
"""Given a file-like object as ``html``, reconstruct it into models."""
try:
htree = etree.parse(html)
except etree.XMLSyntaxError:
html.seek(0)
htree = etree.HTML(html.read())
xhtml = etree.tostring(htree, encoding='utf-8')
return adapt_single_html(x... | [
"def",
"reconstitute",
"(",
"html",
")",
":",
"try",
":",
"htree",
"=",
"etree",
".",
"parse",
"(",
"html",
")",
"except",
"etree",
".",
"XMLSyntaxError",
":",
"html",
".",
"seek",
"(",
"0",
")",
"htree",
"=",
"etree",
".",
"HTML",
"(",
"html",
"."... | Given a file-like object as ``html``, reconstruct it into models. | [
"Given",
"a",
"file",
"-",
"like",
"object",
"as",
"html",
"reconstruct",
"it",
"into",
"models",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/collation.py#L42-L51 |
openstax/cnx-epub | cnxepub/collation.py | collate | def collate(binder, ruleset=None, includes=None):
"""Given a ``Binder`` as ``binder``, collate the content into a new set
of models.
Returns the collated binder.
"""
html_formatter = SingleHTMLFormatter(binder, includes)
raw_html = io.BytesIO(bytes(html_formatter))
collated_html = io.BytesI... | python | def collate(binder, ruleset=None, includes=None):
"""Given a ``Binder`` as ``binder``, collate the content into a new set
of models.
Returns the collated binder.
"""
html_formatter = SingleHTMLFormatter(binder, includes)
raw_html = io.BytesIO(bytes(html_formatter))
collated_html = io.BytesI... | [
"def",
"collate",
"(",
"binder",
",",
"ruleset",
"=",
"None",
",",
"includes",
"=",
"None",
")",
":",
"html_formatter",
"=",
"SingleHTMLFormatter",
"(",
"binder",
",",
"includes",
")",
"raw_html",
"=",
"io",
".",
"BytesIO",
"(",
"bytes",
"(",
"html_formatt... | Given a ``Binder`` as ``binder``, collate the content into a new set
of models.
Returns the collated binder. | [
"Given",
"a",
"Binder",
"as",
"binder",
"collate",
"the",
"content",
"into",
"a",
"new",
"set",
"of",
"models",
".",
"Returns",
"the",
"collated",
"binder",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/collation.py#L54-L73 |
openstax/cnx-epub | cnxepub/adapters.py | adapt_package | def adapt_package(package):
"""Adapts ``.epub.Package`` to a ``BinderItem`` and cascades
the adaptation downward to ``DocumentItem``
and ``ResourceItem``.
The results of this process provide the same interface as
``.models.Binder``, ``.models.Document`` and ``.models.Resource``.
"""
navigati... | python | def adapt_package(package):
"""Adapts ``.epub.Package`` to a ``BinderItem`` and cascades
the adaptation downward to ``DocumentItem``
and ``ResourceItem``.
The results of this process provide the same interface as
``.models.Binder``, ``.models.Document`` and ``.models.Resource``.
"""
navigati... | [
"def",
"adapt_package",
"(",
"package",
")",
":",
"navigation_item",
"=",
"package",
".",
"navigation",
"html",
"=",
"etree",
".",
"parse",
"(",
"navigation_item",
".",
"data",
")",
"tree",
"=",
"parse_navigation_html_to_tree",
"(",
"html",
",",
"navigation_item... | Adapts ``.epub.Package`` to a ``BinderItem`` and cascades
the adaptation downward to ``DocumentItem``
and ``ResourceItem``.
The results of this process provide the same interface as
``.models.Binder``, ``.models.Document`` and ``.models.Resource``. | [
"Adapts",
".",
"epub",
".",
"Package",
"to",
"a",
"BinderItem",
"and",
"cascades",
"the",
"adaptation",
"downward",
"to",
"DocumentItem",
"and",
"ResourceItem",
".",
"The",
"results",
"of",
"this",
"process",
"provide",
"the",
"same",
"interface",
"as",
".",
... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L58-L68 |
openstax/cnx-epub | cnxepub/adapters.py | adapt_item | def adapt_item(item, package, filename=None):
"""Adapts ``.epub.Item`` to a ``DocumentItem``.
"""
if item.media_type == 'application/xhtml+xml':
try:
html = etree.parse(item.data)
except Exception as exc:
logger.error("failed parsing {}".format(item.name))
... | python | def adapt_item(item, package, filename=None):
"""Adapts ``.epub.Item`` to a ``DocumentItem``.
"""
if item.media_type == 'application/xhtml+xml':
try:
html = etree.parse(item.data)
except Exception as exc:
logger.error("failed parsing {}".format(item.name))
... | [
"def",
"adapt_item",
"(",
"item",
",",
"package",
",",
"filename",
"=",
"None",
")",
":",
"if",
"item",
".",
"media_type",
"==",
"'application/xhtml+xml'",
":",
"try",
":",
"html",
"=",
"etree",
".",
"parse",
"(",
"item",
".",
"data",
")",
"except",
"E... | Adapts ``.epub.Item`` to a ``DocumentItem``. | [
"Adapts",
".",
"epub",
".",
"Item",
"to",
"a",
"DocumentItem",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L71-L91 |
openstax/cnx-epub | cnxepub/adapters.py | make_epub | def make_epub(binders, file):
"""Creates an EPUB file from a binder(s)."""
if not isinstance(binders, (list, set, tuple,)):
binders = [binders]
epub = EPUB([_make_package(binder) for binder in binders])
epub.to_file(epub, file) | python | def make_epub(binders, file):
"""Creates an EPUB file from a binder(s)."""
if not isinstance(binders, (list, set, tuple,)):
binders = [binders]
epub = EPUB([_make_package(binder) for binder in binders])
epub.to_file(epub, file) | [
"def",
"make_epub",
"(",
"binders",
",",
"file",
")",
":",
"if",
"not",
"isinstance",
"(",
"binders",
",",
"(",
"list",
",",
"set",
",",
"tuple",
",",
")",
")",
":",
"binders",
"=",
"[",
"binders",
"]",
"epub",
"=",
"EPUB",
"(",
"[",
"_make_package... | Creates an EPUB file from a binder(s). | [
"Creates",
"an",
"EPUB",
"file",
"from",
"a",
"binder",
"(",
"s",
")",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L94-L99 |
openstax/cnx-epub | cnxepub/adapters.py | make_publication_epub | def make_publication_epub(binders, publisher, publication_message, file):
"""Creates an epub file from a binder(s). Also requires
publication information, meant to be used in a EPUB publication
request.
"""
if not isinstance(binders, (list, set, tuple,)):
binders = [binders]
packages = [... | python | def make_publication_epub(binders, publisher, publication_message, file):
"""Creates an epub file from a binder(s). Also requires
publication information, meant to be used in a EPUB publication
request.
"""
if not isinstance(binders, (list, set, tuple,)):
binders = [binders]
packages = [... | [
"def",
"make_publication_epub",
"(",
"binders",
",",
"publisher",
",",
"publication_message",
",",
"file",
")",
":",
"if",
"not",
"isinstance",
"(",
"binders",
",",
"(",
"list",
",",
"set",
",",
"tuple",
",",
")",
")",
":",
"binders",
"=",
"[",
"binders"... | Creates an epub file from a binder(s). Also requires
publication information, meant to be used in a EPUB publication
request. | [
"Creates",
"an",
"epub",
"file",
"from",
"a",
"binder",
"(",
"s",
")",
".",
"Also",
"requires",
"publication",
"information",
"meant",
"to",
"be",
"used",
"in",
"a",
"EPUB",
"publication",
"request",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L102-L118 |
openstax/cnx-epub | cnxepub/adapters.py | _make_package | def _make_package(binder):
"""Makes an ``.epub.Package`` from a Binder'ish instance."""
package_id = binder.id
if package_id is None:
package_id = hash(binder)
package_name = "{}.opf".format(package_id)
extensions = get_model_extensions(binder)
template_env = jinja2.Environment(trim_... | python | def _make_package(binder):
"""Makes an ``.epub.Package`` from a Binder'ish instance."""
package_id = binder.id
if package_id is None:
package_id = hash(binder)
package_name = "{}.opf".format(package_id)
extensions = get_model_extensions(binder)
template_env = jinja2.Environment(trim_... | [
"def",
"_make_package",
"(",
"binder",
")",
":",
"package_id",
"=",
"binder",
".",
"id",
"if",
"package_id",
"is",
"None",
":",
"package_id",
"=",
"hash",
"(",
"binder",
")",
"package_name",
"=",
"\"{}.opf\"",
".",
"format",
"(",
"package_id",
")",
"extens... | Makes an ``.epub.Package`` from a Binder'ish instance. | [
"Makes",
"an",
".",
"epub",
".",
"Package",
"from",
"a",
"Binder",
"ish",
"instance",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L136-L205 |
openstax/cnx-epub | cnxepub/adapters.py | _make_resource_from_inline | def _make_resource_from_inline(reference):
"""Makes an ``models.Resource`` from a ``models.Reference``
of type INLINE. That is, a data: uri"""
uri = DataURI(reference.uri)
data = io.BytesIO(uri.data)
mimetype = uri.mimetype
res = Resource('dummy', data, mimetype)
res.id = res.filename
... | python | def _make_resource_from_inline(reference):
"""Makes an ``models.Resource`` from a ``models.Reference``
of type INLINE. That is, a data: uri"""
uri = DataURI(reference.uri)
data = io.BytesIO(uri.data)
mimetype = uri.mimetype
res = Resource('dummy', data, mimetype)
res.id = res.filename
... | [
"def",
"_make_resource_from_inline",
"(",
"reference",
")",
":",
"uri",
"=",
"DataURI",
"(",
"reference",
".",
"uri",
")",
"data",
"=",
"io",
".",
"BytesIO",
"(",
"uri",
".",
"data",
")",
"mimetype",
"=",
"uri",
".",
"mimetype",
"res",
"=",
"Resource",
... | Makes an ``models.Resource`` from a ``models.Reference``
of type INLINE. That is, a data: uri | [
"Makes",
"an",
"models",
".",
"Resource",
"from",
"a",
"models",
".",
"Reference",
"of",
"type",
"INLINE",
".",
"That",
"is",
"a",
"data",
":",
"uri"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L208-L216 |
openstax/cnx-epub | cnxepub/adapters.py | _make_item | def _make_item(model):
"""Makes an ``.epub.Item`` from
a ``.models.Document`` or ``.models.Resource``
"""
item = Item(model.id, model.content, model.media_type)
return item | python | def _make_item(model):
"""Makes an ``.epub.Item`` from
a ``.models.Document`` or ``.models.Resource``
"""
item = Item(model.id, model.content, model.media_type)
return item | [
"def",
"_make_item",
"(",
"model",
")",
":",
"item",
"=",
"Item",
"(",
"model",
".",
"id",
",",
"model",
".",
"content",
",",
"model",
".",
"media_type",
")",
"return",
"item"
] | Makes an ``.epub.Item`` from
a ``.models.Document`` or ``.models.Resource`` | [
"Makes",
"an",
".",
"epub",
".",
"Item",
"from",
"a",
".",
"models",
".",
"Document",
"or",
".",
"models",
".",
"Resource"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L219-L224 |
openstax/cnx-epub | cnxepub/adapters.py | _node_to_model | def _node_to_model(tree_or_item, package, parent=None,
lucent_id=TRANSLUCENT_BINDER_ID):
"""Given a tree, parse to a set of models"""
if 'contents' in tree_or_item:
# It is a binder.
tree = tree_or_item
# Grab the package metadata, so we have required license info
... | python | def _node_to_model(tree_or_item, package, parent=None,
lucent_id=TRANSLUCENT_BINDER_ID):
"""Given a tree, parse to a set of models"""
if 'contents' in tree_or_item:
# It is a binder.
tree = tree_or_item
# Grab the package metadata, so we have required license info
... | [
"def",
"_node_to_model",
"(",
"tree_or_item",
",",
"package",
",",
"parent",
"=",
"None",
",",
"lucent_id",
"=",
"TRANSLUCENT_BINDER_ID",
")",
":",
"if",
"'contents'",
"in",
"tree_or_item",
":",
"# It is a binder.",
"tree",
"=",
"tree_or_item",
"# Grab the package m... | Given a tree, parse to a set of models | [
"Given",
"a",
"tree",
"parse",
"to",
"a",
"set",
"of",
"models"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L227-L261 |
openstax/cnx-epub | cnxepub/adapters.py | adapt_single_html | def adapt_single_html(html):
"""Adapts a single html document generated by
``.formatters.SingleHTMLFormatter`` to a ``models.Binder``
"""
html_root = etree.fromstring(html)
metadata = parse_metadata(html_root.xpath('//*[@data-type="metadata"]')[0])
id_ = metadata['cnx-archive-uri'] or 'book'
... | python | def adapt_single_html(html):
"""Adapts a single html document generated by
``.formatters.SingleHTMLFormatter`` to a ``models.Binder``
"""
html_root = etree.fromstring(html)
metadata = parse_metadata(html_root.xpath('//*[@data-type="metadata"]')[0])
id_ = metadata['cnx-archive-uri'] or 'book'
... | [
"def",
"adapt_single_html",
"(",
"html",
")",
":",
"html_root",
"=",
"etree",
".",
"fromstring",
"(",
"html",
")",
"metadata",
"=",
"parse_metadata",
"(",
"html_root",
".",
"xpath",
"(",
"'//*[@data-type=\"metadata\"]'",
")",
"[",
"0",
"]",
")",
"id_",
"=",
... | Adapts a single html document generated by
``.formatters.SingleHTMLFormatter`` to a ``models.Binder`` | [
"Adapts",
"a",
"single",
"html",
"document",
"generated",
"by",
".",
"formatters",
".",
"SingleHTMLFormatter",
"to",
"a",
"models",
".",
"Binder"
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L346-L361 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | select_ocv_points | def select_ocv_points(cellpydata, cycles=None, selection_method="martin",
number_of_points=5,
interval=10,
relative_voltage=False,
report_times=False,
direction=None):
"""Select points from the ocvrlx step... | python | def select_ocv_points(cellpydata, cycles=None, selection_method="martin",
number_of_points=5,
interval=10,
relative_voltage=False,
report_times=False,
direction=None):
"""Select points from the ocvrlx step... | [
"def",
"select_ocv_points",
"(",
"cellpydata",
",",
"cycles",
"=",
"None",
",",
"selection_method",
"=",
"\"martin\"",
",",
"number_of_points",
"=",
"5",
",",
"interval",
"=",
"10",
",",
"relative_voltage",
"=",
"False",
",",
"report_times",
"=",
"False",
",",... | Select points from the ocvrlx steps.
Args:
cellpydata: CellpyData-object
cycles: list of cycle numbers to process (optional)
selection_method: criteria for selecting points
martin: select first and last, and then last/2, last/2/2 etc.
unti... | [
"Select",
"points",
"from",
"the",
"ocvrlx",
"steps",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L17-L195 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | MultiCycleOcvFit.get_best_fit_parameters_grouped | def get_best_fit_parameters_grouped(self):
"""Returns a dictionary of the best fit."""
result_dict = dict()
result_dict['ocv'] = [parameters['ocv'] for parameters in
self.best_fit_parameters]
for i in range(self.circuits):
result_dict['t' + str(... | python | def get_best_fit_parameters_grouped(self):
"""Returns a dictionary of the best fit."""
result_dict = dict()
result_dict['ocv'] = [parameters['ocv'] for parameters in
self.best_fit_parameters]
for i in range(self.circuits):
result_dict['t' + str(... | [
"def",
"get_best_fit_parameters_grouped",
"(",
"self",
")",
":",
"result_dict",
"=",
"dict",
"(",
")",
"result_dict",
"[",
"'ocv'",
"]",
"=",
"[",
"parameters",
"[",
"'ocv'",
"]",
"for",
"parameters",
"in",
"self",
".",
"best_fit_parameters",
"]",
"for",
"i"... | Returns a dictionary of the best fit. | [
"Returns",
"a",
"dictionary",
"of",
"the",
"best",
"fit",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L312-L323 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | MultiCycleOcvFit.get_best_fit_parameters_translated_grouped | def get_best_fit_parameters_translated_grouped(self):
"""Returns the parameters as a dictionary of the 'real units' for the best fit."""
result_dict = dict()
result_dict['ocv'] = [parameters['ocv'] for parameters in
self.best_fit_parameters_translated]
resul... | python | def get_best_fit_parameters_translated_grouped(self):
"""Returns the parameters as a dictionary of the 'real units' for the best fit."""
result_dict = dict()
result_dict['ocv'] = [parameters['ocv'] for parameters in
self.best_fit_parameters_translated]
resul... | [
"def",
"get_best_fit_parameters_translated_grouped",
"(",
"self",
")",
":",
"result_dict",
"=",
"dict",
"(",
")",
"result_dict",
"[",
"'ocv'",
"]",
"=",
"[",
"parameters",
"[",
"'ocv'",
"]",
"for",
"parameters",
"in",
"self",
".",
"best_fit_parameters_translated",... | Returns the parameters as a dictionary of the 'real units' for the best fit. | [
"Returns",
"the",
"parameters",
"as",
"a",
"dictionary",
"of",
"the",
"real",
"units",
"for",
"the",
"best",
"fit",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L325-L338 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | MultiCycleOcvFit.plot_summary | def plot_summary(self, cycles=None):
"""Convenience function for plotting the summary of the fit"""
if cycles is None:
cycles = [0]
fig1 = plt.figure()
ax1 = fig1.add_subplot(221)
ax1.set_title('Fit')
ax2 = fig1.add_subplot(222)
ax2.set_title('OCV')
... | python | def plot_summary(self, cycles=None):
"""Convenience function for plotting the summary of the fit"""
if cycles is None:
cycles = [0]
fig1 = plt.figure()
ax1 = fig1.add_subplot(221)
ax1.set_title('Fit')
ax2 = fig1.add_subplot(222)
ax2.set_title('OCV')
... | [
"def",
"plot_summary",
"(",
"self",
",",
"cycles",
"=",
"None",
")",
":",
"if",
"cycles",
"is",
"None",
":",
"cycles",
"=",
"[",
"0",
"]",
"fig1",
"=",
"plt",
".",
"figure",
"(",
")",
"ax1",
"=",
"fig1",
".",
"add_subplot",
"(",
"221",
")",
"ax1"... | Convenience function for plotting the summary of the fit | [
"Convenience",
"function",
"for",
"plotting",
"the",
"summary",
"of",
"the",
"fit"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L344-L370 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.