repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
unt-libraries/pyuntl
pyuntl/highwire_structure.py
CitationPublisher.get_publisher_name
def get_publisher_name(self, **kwargs): """Get the publisher name.""" children = kwargs.get('children', []) # Find the creator type in children. for child in children: if child.tag == 'name': return child.content return None
python
def get_publisher_name(self, **kwargs): """Get the publisher name.""" children = kwargs.get('children', []) # Find the creator type in children. for child in children: if child.tag == 'name': return child.content return None
[ "def", "get_publisher_name", "(", "self", ",", "*", "*", "kwargs", ")", ":", "children", "=", "kwargs", ".", "get", "(", "'children'", ",", "[", "]", ")", "# Find the creator type in children.", "for", "child", "in", "children", ":", "if", "child", ".", "t...
Get the publisher name.
[ "Get", "the", "publisher", "name", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L77-L84
train
Get the publisher name.
unt-libraries/pyuntl
pyuntl/highwire_structure.py
CitationPublicationDate.get_publication_date
def get_publication_date(self, **kwargs): """Determine the creation date for the publication date.""" date_string = kwargs.get('content', '') date_match = CREATION_DATE_REGEX.match(date_string) month_match = CREATION_MONTH_REGEX.match(date_string) year_match = CREATION_YEAR_REGEX...
python
def get_publication_date(self, **kwargs): """Determine the creation date for the publication date.""" date_string = kwargs.get('content', '') date_match = CREATION_DATE_REGEX.match(date_string) month_match = CREATION_MONTH_REGEX.match(date_string) year_match = CREATION_YEAR_REGEX...
[ "def", "get_publication_date", "(", "self", ",", "*", "*", "kwargs", ")", ":", "date_string", "=", "kwargs", ".", "get", "(", "'content'", ",", "''", ")", "date_match", "=", "CREATION_DATE_REGEX", ".", "match", "(", "date_string", ")", "month_match", "=", ...
Determine the creation date for the publication date.
[ "Determine", "the", "creation", "date", "for", "the", "publication", "date", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L93-L129
train
Determine the creation date for the publication date.
unt-libraries/pyuntl
pyuntl/highwire_structure.py
CitationOnlineDate.get_online_date
def get_online_date(self, **kwargs): """Get the online date from the meta creation date.""" qualifier = kwargs.get('qualifier', '') content = kwargs.get('content', '') # Handle meta-creation-date element. if qualifier == 'metadataCreationDate': date_match = META_CREAT...
python
def get_online_date(self, **kwargs): """Get the online date from the meta creation date.""" qualifier = kwargs.get('qualifier', '') content = kwargs.get('content', '') # Handle meta-creation-date element. if qualifier == 'metadataCreationDate': date_match = META_CREAT...
[ "def", "get_online_date", "(", "self", ",", "*", "*", "kwargs", ")", ":", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ",", "''", ")", "content", "=", "kwargs", ".", "get", "(", "'content'", ",", "''", ")", "# Handle meta-creation-date eleme...
Get the online date from the meta creation date.
[ "Get", "the", "online", "date", "from", "the", "meta", "creation", "date", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L138-L153
train
Get the online date from the meta creation date.
unt-libraries/pyuntl
pyuntl/highwire_structure.py
CitationDissertationInstitution.get_institution
def get_institution(self, **kwargs): """Get the dissertation institution.""" qualifier = kwargs.get('qualifier', '') content = kwargs.get('content', '') if qualifier == 'grantor': return content return None
python
def get_institution(self, **kwargs): """Get the dissertation institution.""" qualifier = kwargs.get('qualifier', '') content = kwargs.get('content', '') if qualifier == 'grantor': return content return None
[ "def", "get_institution", "(", "self", ",", "*", "*", "kwargs", ")", ":", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ",", "''", ")", "content", "=", "kwargs", ".", "get", "(", "'content'", ",", "''", ")", "if", "qualifier", "==", "'g...
Get the dissertation institution.
[ "Get", "the", "dissertation", "institution", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L216-L222
train
Get the dissertation institution.
usc-isi-i2/dig-sandpaper
digsandpaper/coarse/preprocess/constraint_remap_factory.py
ConstraintReMapSimilarity.call_doc_similarity
def call_doc_similarity(self, keywords, rerank_by_doc, start_date, end_date): """ :param keywords: a string, a query, A dark knight :return: similar docs as returned by the vector similarity service """ payload = {'query': keywords, 'k': self.constraint_remap_config['k'], 'rerank...
python
def call_doc_similarity(self, keywords, rerank_by_doc, start_date, end_date): """ :param keywords: a string, a query, A dark knight :return: similar docs as returned by the vector similarity service """ payload = {'query': keywords, 'k': self.constraint_remap_config['k'], 'rerank...
[ "def", "call_doc_similarity", "(", "self", ",", "keywords", ",", "rerank_by_doc", ",", "start_date", ",", "end_date", ")", ":", "payload", "=", "{", "'query'", ":", "keywords", ",", "'k'", ":", "self", ".", "constraint_remap_config", "[", "'k'", "]", ",", ...
:param keywords: a string, a query, A dark knight :return: similar docs as returned by the vector similarity service
[ ":", "param", "keywords", ":", "a", "string", "a", "query", "A", "dark", "knight", ":", "return", ":", "similar", "docs", "as", "returned", "by", "the", "vector", "similarity", "service" ]
c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6
https://github.com/usc-isi-i2/dig-sandpaper/blob/c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6/digsandpaper/coarse/preprocess/constraint_remap_factory.py#L32-L76
train
Calls the similarity service to get the similar docs for a given query.
rhayes777/PyAutoFit
autofit/aggregator.py
PhaseOutput.model_results
def model_results(self) -> str: """ Reads the model.results file """ with open(os.path.join(self.directory, "model.results")) as f: return f.read()
python
def model_results(self) -> str: """ Reads the model.results file """ with open(os.path.join(self.directory, "model.results")) as f: return f.read()
[ "def", "model_results", "(", "self", ")", "->", "str", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ",", "\"model.results\"", ")", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Reads the model.results file
[ "Reads", "the", "model", ".", "results", "file" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L44-L49
train
Reads the model. results file
rhayes777/PyAutoFit
autofit/aggregator.py
PhaseOutput.header
def header(self) -> str: """ A header created by joining the pipeline, phase and data names """ return "/".join((self.pipeline, self.phase, self.data))
python
def header(self) -> str: """ A header created by joining the pipeline, phase and data names """ return "/".join((self.pipeline, self.phase, self.data))
[ "def", "header", "(", "self", ")", "->", "str", ":", "return", "\"/\"", ".", "join", "(", "(", "self", ".", "pipeline", ",", "self", ".", "phase", ",", "self", ".", "data", ")", ")" ]
A header created by joining the pipeline, phase and data names
[ "A", "header", "created", "by", "joining", "the", "pipeline", "phase", "and", "data", "names" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L52-L56
train
A header created by joining the pipeline phase and data names
rhayes777/PyAutoFit
autofit/aggregator.py
PhaseOutput.optimizer
def optimizer(self) -> non_linear.NonLinearOptimizer: """ The optimizer object that was used in this phase """ if self.__optimizer is None: with open(os.path.join(self.directory, ".optimizer.pickle"), "r+b") as f: self.__optimizer = pickle.loads(f.read()) ...
python
def optimizer(self) -> non_linear.NonLinearOptimizer: """ The optimizer object that was used in this phase """ if self.__optimizer is None: with open(os.path.join(self.directory, ".optimizer.pickle"), "r+b") as f: self.__optimizer = pickle.loads(f.read()) ...
[ "def", "optimizer", "(", "self", ")", "->", "non_linear", ".", "NonLinearOptimizer", ":", "if", "self", ".", "__optimizer", "is", "None", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ",", "\".optimizer.pickle\"",...
The optimizer object that was used in this phase
[ "The", "optimizer", "object", "that", "was", "used", "in", "this", "phase" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L59-L66
train
Returns the optimizer object that was used in this phase.
rhayes777/PyAutoFit
autofit/aggregator.py
Aggregator.phases_with
def phases_with(self, **kwargs) -> [PhaseOutput]: """ Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with phase, data or pipeline as the key. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1...
python
def phases_with(self, **kwargs) -> [PhaseOutput]: """ Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with phase, data or pipeline as the key. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1...
[ "def", "phases_with", "(", "self", ",", "*", "*", "kwargs", ")", "->", "[", "PhaseOutput", "]", ":", "return", "[", "phase", "for", "phase", "in", "self", ".", "phases", "if", "all", "(", "[", "getattr", "(", "phase", ",", "key", ")", "==", "value"...
Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with phase, data or pipeline as the key. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1
[ "Filters", "phases", ".", "If", "no", "arguments", "are", "passed", "all", "phases", "are", "returned", ".", "Arguments", "must", "be", "key", "value", "pairs", "with", "phase", "data", "or", "pipeline", "as", "the", "key", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L94-L105
train
Returns a list of all phases that match the passed arguments.
rhayes777/PyAutoFit
autofit/aggregator.py
Aggregator.optimizers_with
def optimizers_with(self, **kwargs) -> [non_linear.NonLinearOptimizer]: """ Load a list of optimizers for phases in the directory with zero or more filters applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- ...
python
def optimizers_with(self, **kwargs) -> [non_linear.NonLinearOptimizer]: """ Load a list of optimizers for phases in the directory with zero or more filters applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- ...
[ "def", "optimizers_with", "(", "self", ",", "*", "*", "kwargs", ")", "->", "[", "non_linear", ".", "NonLinearOptimizer", "]", ":", "return", "[", "phase", ".", "optimizer", "for", "phase", "in", "self", ".", "phases_with", "(", "*", "*", "kwargs", ")", ...
Load a list of optimizers for phases in the directory with zero or more filters applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- optimizers A list of optimizers, one for each phase in the directory that match...
[ "Load", "a", "list", "of", "optimizers", "for", "phases", "in", "the", "directory", "with", "zero", "or", "more", "filters", "applied", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L107-L121
train
Load a list of optimizers for phases in the directory that match the given filters.
rhayes777/PyAutoFit
autofit/aggregator.py
Aggregator.model_results
def model_results(self, **kwargs) -> str: """ Collates model results from all phases in the directory or some subset if filters are applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- model_results ...
python
def model_results(self, **kwargs) -> str: """ Collates model results from all phases in the directory or some subset if filters are applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- model_results ...
[ "def", "model_results", "(", "self", ",", "*", "*", "kwargs", ")", "->", "str", ":", "return", "\"\\n\\n\"", ".", "join", "(", "\"{}\\n\\n{}\"", ".", "format", "(", "phase", ".", "header", ",", "phase", ".", "model_results", ")", "for", "phase", "in", ...
Collates model results from all phases in the directory or some subset if filters are applied. Parameters ---------- kwargs Filters, e.g. pipeline=pipeline1 Returns ------- model_results A string joining headers and results for all included phase...
[ "Collates", "model", "results", "from", "all", "phases", "in", "the", "directory", "or", "some", "subset", "if", "filters", "are", "applied", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L123-L138
train
Returns a string containing the model results for all phases in the directory.
peterbe/gg
gg/builtins/branches/gg_branches.py
branches
def branches(config, searchstring=""): """List all branches. And if exactly 1 found, offer to check it out.""" repo = config.repo branches_ = list(find(repo, searchstring)) if branches_: merged = get_merged_branches(repo) info_out("Found existing branches...") print_list(branche...
python
def branches(config, searchstring=""): """List all branches. And if exactly 1 found, offer to check it out.""" repo = config.repo branches_ = list(find(repo, searchstring)) if branches_: merged = get_merged_branches(repo) info_out("Found existing branches...") print_list(branche...
[ "def", "branches", "(", "config", ",", "searchstring", "=", "\"\"", ")", ":", "repo", "=", "config", ".", "repo", "branches_", "=", "list", "(", "find", "(", "repo", ",", "searchstring", ")", ")", "if", "branches_", ":", "merged", "=", "get_merged_branch...
List all branches. And if exactly 1 found, offer to check it out.
[ "List", "all", "branches", ".", "And", "if", "exactly", "1", "found", "offer", "to", "check", "it", "out", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/branches/gg_branches.py#L13-L39
train
List all branches. And if exactly 1 found offer to check it out.
Riminder/python-riminder-api
riminder/base64Wrapper.py
decodebytes
def decodebytes(input): """Decode base64 string to byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _decodebytes_py3(input) return _decodebytes_py2(input)
python
def decodebytes(input): """Decode base64 string to byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _decodebytes_py3(input) return _decodebytes_py2(input)
[ "def", "decodebytes", "(", "input", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "_decodebytes_py3", "(", "input", ")", "return", "_decodebytes_py2", "(", "input", ")" ]
Decode base64 string to byte array.
[ "Decode", "base64", "string", "to", "byte", "array", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/base64Wrapper.py#L14-L19
train
Decode base64 string to byte array.
gofed/gofedlib
gofedlib/snapshot/capturer.py
ProjectCapturer.capture
def capture(self, commit = ""): """Capture the current state of a project based on its provider Commit is relevant only for upstream providers. If empty, the latest commit from provider repository is taken. It is ignored for distribution providers. :param provider: project provider, e.g. upstream repository...
python
def capture(self, commit = ""): """Capture the current state of a project based on its provider Commit is relevant only for upstream providers. If empty, the latest commit from provider repository is taken. It is ignored for distribution providers. :param provider: project provider, e.g. upstream repository...
[ "def", "capture", "(", "self", ",", "commit", "=", "\"\"", ")", ":", "self", ".", "_validateProvider", "(", "self", ".", "_provider", ")", "# get client for repository", "# TODO(jchaloup): read config file to switch between local and remove clients", "# TODO(jchaloup): remote...
Capture the current state of a project based on its provider Commit is relevant only for upstream providers. If empty, the latest commit from provider repository is taken. It is ignored for distribution providers. :param provider: project provider, e.g. upstream repository, distribution builder :type provi...
[ "Capture", "the", "current", "state", "of", "a", "project", "based", "on", "its", "provider" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/snapshot/capturer.py#L25-L51
train
Capture the current state of a project based on its provider and the given commit.
pgxcentre/geneparse
geneparse/logging.py
found_duplicates
def found_duplicates(counts): """Log that duplicates were found. :param counts: A list of duplicate marker names along with their number of occurences. :type counts: list """ _logger.warning("Duplicated markers found") for marker, count in counts: _logger.warning(" -...
python
def found_duplicates(counts): """Log that duplicates were found. :param counts: A list of duplicate marker names along with their number of occurences. :type counts: list """ _logger.warning("Duplicated markers found") for marker, count in counts: _logger.warning(" -...
[ "def", "found_duplicates", "(", "counts", ")", ":", "_logger", ".", "warning", "(", "\"Duplicated markers found\"", ")", "for", "marker", ",", "count", "in", "counts", ":", "_logger", ".", "warning", "(", "\" - {}: {:,d} times\"", ".", "format", "(", "marker", ...
Log that duplicates were found. :param counts: A list of duplicate marker names along with their number of occurences. :type counts: list
[ "Log", "that", "duplicates", "were", "found", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/logging.py#L45-L57
train
Log that duplicates were found.
edx/edx-celeryutils
celery_utils/management/commands/cleanup_resolved_tasks.py
Command.add_arguments
def add_arguments(self, parser): """ Add arguments to the command parser. Uses argparse syntax. See documentation at https://docs.python.org/3/library/argparse.html. """ parser.add_argument( '--dry-run', action='store_true', default=F...
python
def add_arguments(self, parser): """ Add arguments to the command parser. Uses argparse syntax. See documentation at https://docs.python.org/3/library/argparse.html. """ parser.add_argument( '--dry-run', action='store_true', default=F...
[ "def", "add_arguments", "(", "self", ",", "parser", ")", ":", "parser", ".", "add_argument", "(", "'--dry-run'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "\"Output what we're going to do, but don't actually do it.\"", ")", ...
Add arguments to the command parser. Uses argparse syntax. See documentation at https://docs.python.org/3/library/argparse.html.
[ "Add", "arguments", "to", "the", "command", "parser", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/management/commands/cleanup_resolved_tasks.py#L25-L48
train
Add command line arguments to the parser.
lalinsky/mbdata
mbdata/utils/__init__.py
patch_model_schemas
def patch_model_schemas(mapping): """Update mbdata.models to use different schema names The function accepts a dictionary with schema name mapping and updates the schema for all MusicBrainz tables. If you want to use the default schema: >>> patch_model_schemas(NO_SCHEMAS) If you have just on...
python
def patch_model_schemas(mapping): """Update mbdata.models to use different schema names The function accepts a dictionary with schema name mapping and updates the schema for all MusicBrainz tables. If you want to use the default schema: >>> patch_model_schemas(NO_SCHEMAS) If you have just on...
[ "def", "patch_model_schemas", "(", "mapping", ")", ":", "from", "mbdata", ".", "models", "import", "Base", "for", "table", "in", "Base", ".", "metadata", ".", "sorted_tables", ":", "if", "table", ".", "schema", "is", "None", ":", "continue", "table", ".", ...
Update mbdata.models to use different schema names The function accepts a dictionary with schema name mapping and updates the schema for all MusicBrainz tables. If you want to use the default schema: >>> patch_model_schemas(NO_SCHEMAS) If you have just one 'musicbrainz' schema: >>> patch_mo...
[ "Update", "mbdata", ".", "models", "to", "use", "different", "schema", "names" ]
1ec788834047ced8614ad9763e430afe1d1e65e7
https://github.com/lalinsky/mbdata/blob/1ec788834047ced8614ad9763e430afe1d1e65e7/mbdata/utils/__init__.py#L21-L41
train
Update mbdata. models to use different schema names
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
detectRamPorts
def detectRamPorts(stm: IfContainer, current_en: RtlSignalBase): """ Detect RAM ports in If statement :param stm: statement to detect the ram ports in :param current_en: curent en/clk signal """ if stm.ifFalse or stm.elIfs: return for _stm in stm.ifTrue: if isinstance(_stm, ...
python
def detectRamPorts(stm: IfContainer, current_en: RtlSignalBase): """ Detect RAM ports in If statement :param stm: statement to detect the ram ports in :param current_en: curent en/clk signal """ if stm.ifFalse or stm.elIfs: return for _stm in stm.ifTrue: if isinstance(_stm, ...
[ "def", "detectRamPorts", "(", "stm", ":", "IfContainer", ",", "current_en", ":", "RtlSignalBase", ")", ":", "if", "stm", ".", "ifFalse", "or", "stm", ".", "elIfs", ":", "return", "for", "_stm", "in", "stm", ".", "ifTrue", ":", "if", "isinstance", "(", ...
Detect RAM ports in If statement :param stm: statement to detect the ram ports in :param current_en: curent en/clk signal
[ "Detect", "RAM", "ports", "in", "If", "statement" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L42-L67
train
Detect the RAM ports in a IfContainer.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
StatementRenderer.addInputPort
def addInputPort(self, node, name, i: Union[Value, RtlSignalBase], side=PortSide.WEST): """ Add and connect input port on subnode :param node: node where to add input port :param name: name of newly added port :param i: input value ...
python
def addInputPort(self, node, name, i: Union[Value, RtlSignalBase], side=PortSide.WEST): """ Add and connect input port on subnode :param node: node where to add input port :param name: name of newly added port :param i: input value ...
[ "def", "addInputPort", "(", "self", ",", "node", ",", "name", ",", "i", ":", "Union", "[", "Value", ",", "RtlSignalBase", "]", ",", "side", "=", "PortSide", ".", "WEST", ")", ":", "root", "=", "self", ".", "node", "port", "=", "node", ".", "addPort...
Add and connect input port on subnode :param node: node where to add input port :param name: name of newly added port :param i: input value :param side: side where input port should be added
[ "Add", "and", "connect", "input", "port", "on", "subnode" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L99-L149
train
Adds and connects input port on a node.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
StatementRenderer.addOutputPort
def addOutputPort(self, node: LNode, name: str, out: Optional[Union[RtlSignalBase, LPort]], side=PortSide.EAST): """ Add and connect output port on subnode """ oPort = node.addPort(name, PortType.OUTPUT, side) if out is not None: ...
python
def addOutputPort(self, node: LNode, name: str, out: Optional[Union[RtlSignalBase, LPort]], side=PortSide.EAST): """ Add and connect output port on subnode """ oPort = node.addPort(name, PortType.OUTPUT, side) if out is not None: ...
[ "def", "addOutputPort", "(", "self", ",", "node", ":", "LNode", ",", "name", ":", "str", ",", "out", ":", "Optional", "[", "Union", "[", "RtlSignalBase", ",", "LPort", "]", "]", ",", "side", "=", "PortSide", ".", "EAST", ")", ":", "oPort", "=", "no...
Add and connect output port on subnode
[ "Add", "and", "connect", "output", "port", "on", "subnode" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L151-L178
train
Add and connect an output port on a node.
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
StatementRenderer.lazyLoadNet
def lazyLoadNet(self, signal: RtlSignalBase): """ :param signal: top signal of hidden operator tree :note: operator tree is constrained by signals with hidden==False :note: statement nodes are not connected automatically """ d_cnt = len(signal.drivers) if d_cnt ==...
python
def lazyLoadNet(self, signal: RtlSignalBase): """ :param signal: top signal of hidden operator tree :note: operator tree is constrained by signals with hidden==False :note: statement nodes are not connected automatically """ d_cnt = len(signal.drivers) if d_cnt ==...
[ "def", "lazyLoadNet", "(", "self", ",", "signal", ":", "RtlSignalBase", ")", ":", "d_cnt", "=", "len", "(", "signal", ".", "drivers", ")", "if", "d_cnt", "==", "1", ":", "driver", "=", "signal", ".", "drivers", "[", "0", "]", "if", "isinstance", "(",...
:param signal: top signal of hidden operator tree :note: operator tree is constrained by signals with hidden==False :note: statement nodes are not connected automatically
[ ":", "param", "signal", ":", "top", "signal", "of", "hidden", "operator", "tree", ":", "note", ":", "operator", "tree", "is", "constrained", "by", "signals", "with", "hidden", "==", "False", ":", "note", ":", "statement", "nodes", "are", "not", "connected"...
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L340-L359
train
lazyLoadNet - lazy loads the network for the given signal
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
StatementRenderer.renderContent
def renderContent(self): """ Walk from outputs to inputs for each public signal register port of wrap node if required lazy load all operator and statement nodes for signals """ stm = self.stm portCtx = self.portCtx # for each inputs and outputs render exp...
python
def renderContent(self): """ Walk from outputs to inputs for each public signal register port of wrap node if required lazy load all operator and statement nodes for signals """ stm = self.stm portCtx = self.portCtx # for each inputs and outputs render exp...
[ "def", "renderContent", "(", "self", ")", ":", "stm", "=", "self", ".", "stm", "portCtx", "=", "self", ".", "portCtx", "# for each inputs and outputs render expression trees", "# walk statements and render muxs and memories", "for", "o", "in", "stm", ".", "_outputs", ...
Walk from outputs to inputs for each public signal register port of wrap node if required lazy load all operator and statement nodes for signals
[ "Walk", "from", "outputs", "to", "inputs", "for", "each", "public", "signal", "register", "port", "of", "wrap", "node", "if", "required", "lazy", "load", "all", "operator", "and", "statement", "nodes", "for", "signals" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L385-L425
train
Walk from outputs to inputs and render all operator and statement nodes for each public signal and signal that are not already in the tree
Nic30/hwtGraph
hwtGraph/elk/fromHwt/statementRenderer.py
StatementRenderer.renderForSignal
def renderForSignal(self, stm: Union[HdlStatement, List[HdlStatement]], s: RtlSignalBase, connectOut) -> Optional[Tuple[LNode, Union[RtlSignalBase, LPort]]]: """ Walk statement and render nodes which are representing hardware components (MUX, LATCH...
python
def renderForSignal(self, stm: Union[HdlStatement, List[HdlStatement]], s: RtlSignalBase, connectOut) -> Optional[Tuple[LNode, Union[RtlSignalBase, LPort]]]: """ Walk statement and render nodes which are representing hardware components (MUX, LATCH...
[ "def", "renderForSignal", "(", "self", ",", "stm", ":", "Union", "[", "HdlStatement", ",", "List", "[", "HdlStatement", "]", "]", ",", "s", ":", "RtlSignalBase", ",", "connectOut", ")", "->", "Optional", "[", "Tuple", "[", "LNode", ",", "Union", "[", "...
Walk statement and render nodes which are representing hardware components (MUX, LATCH, FF, ...) for specified signal
[ "Walk", "statement", "and", "render", "nodes", "which", "are", "representing", "hardware", "components", "(", "MUX", "LATCH", "FF", "...", ")", "for", "specified", "signal" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L473-L551
train
Render the given signal and return the corresponding LNode and LPort.
gofed/gofedlib
gofedlib/distribution/packagenamegenerator.py
PackageNameGenerator.generate
def generate(self, project): """ Package name construction is based on provider, not on prefix. Prefix does not have to equal provider_prefix. """ for assignment in self.s2n_mapping: if assignment["ipprefix"] == project: self._name = assignment["package"] return self # # github.com -> github ...
python
def generate(self, project): """ Package name construction is based on provider, not on prefix. Prefix does not have to equal provider_prefix. """ for assignment in self.s2n_mapping: if assignment["ipprefix"] == project: self._name = assignment["package"] return self # # github.com -> github ...
[ "def", "generate", "(", "self", ",", "project", ")", ":", "for", "assignment", "in", "self", ".", "s2n_mapping", ":", "if", "assignment", "[", "\"ipprefix\"", "]", "==", "project", ":", "self", ".", "_name", "=", "assignment", "[", "\"package\"", "]", "r...
Package name construction is based on provider, not on prefix. Prefix does not have to equal provider_prefix.
[ "Package", "name", "construction", "is", "based", "on", "provider", "not", "on", "prefix", ".", "Prefix", "does", "not", "have", "to", "equal", "provider_prefix", "." ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/packagenamegenerator.py#L9-L59
train
Generate a new name based on the project and the name of the project.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/hostkeys.py
HostKeys.hash_host
def hash_host(hostname, salt=None): """ Return a "hashed" form of the hostname, as used by OpenSSH when storing hashed hostnames in the known_hosts file. :param str hostname: the hostname to hash :param str salt: optional salt to use when hashing (must be 20 bytes long) ...
python
def hash_host(hostname, salt=None): """ Return a "hashed" form of the hostname, as used by OpenSSH when storing hashed hostnames in the known_hosts file. :param str hostname: the hostname to hash :param str salt: optional salt to use when hashing (must be 20 bytes long) ...
[ "def", "hash_host", "(", "hostname", ",", "salt", "=", "None", ")", ":", "if", "salt", "is", "None", ":", "salt", "=", "os", ".", "urandom", "(", "sha1", "(", ")", ".", "digest_size", ")", "else", ":", "if", "salt", ".", "startswith", "(", "'|1|'",...
Return a "hashed" form of the hostname, as used by OpenSSH when storing hashed hostnames in the known_hosts file. :param str hostname: the hostname to hash :param str salt: optional salt to use when hashing (must be 20 bytes long) :return: the hashed hostname as a `str`
[ "Return", "a", "hashed", "form", "of", "the", "hostname", "as", "used", "by", "OpenSSH", "when", "storing", "hashed", "hostnames", "in", "the", "known_hosts", "file", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/hostkeys.py#L258-L276
train
Return a hashed form of the hostname as used by OpenSSH when storing hashed hostnames in the known_hosts file.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/hostkeys.py
HostKeyEntry.from_line
def from_line(cls, line, lineno=None): """ Parses the given line of text to find the names for the host, the type of key, and the key data. The line is expected to be in the format used by the OpenSSH known_hosts file. Lines are expected to not have leading or trailing whitespac...
python
def from_line(cls, line, lineno=None): """ Parses the given line of text to find the names for the host, the type of key, and the key data. The line is expected to be in the format used by the OpenSSH known_hosts file. Lines are expected to not have leading or trailing whitespac...
[ "def", "from_line", "(", "cls", ",", "line", ",", "lineno", "=", "None", ")", ":", "log", "=", "get_logger", "(", "'paramiko.hostkeys'", ")", "fields", "=", "line", ".", "split", "(", "' '", ")", "if", "len", "(", "fields", ")", "<", "3", ":", "# B...
Parses the given line of text to find the names for the host, the type of key, and the key data. The line is expected to be in the format used by the OpenSSH known_hosts file. Lines are expected to not have leading or trailing whitespace. We don't bother to check for comments or empty l...
[ "Parses", "the", "given", "line", "of", "text", "to", "find", "the", "names", "for", "the", "host", "the", "type", "of", "key", "and", "the", "key", "data", ".", "The", "line", "is", "expected", "to", "be", "in", "the", "format", "used", "by", "the",...
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/hostkeys.py#L297-L338
train
Parses a line of text to find the names for the host the type of key and the key data.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.add_grid_data
def add_grid_data(self, data): """ Return id """ self.grid_data.append(data) return len(self.grid_data) - 1
python
def add_grid_data(self, data): """ Return id """ self.grid_data.append(data) return len(self.grid_data) - 1
[ "def", "add_grid_data", "(", "self", ",", "data", ")", ":", "self", ".", "grid_data", ".", "append", "(", "data", ")", "return", "len", "(", "self", ".", "grid_data", ")", "-", "1" ]
Return id
[ "Return", "id" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L132-L136
train
Adds data to the grid data list
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid._read_elem_nodes
def _read_elem_nodes(self, fid): """ Read the nodes from an opened elem.dat file. Correct for CutMcK transformations. We store three typed of nodes in the dict 'nodes': * "raw" : as read from the elem.dat file * "presort" : pre-sorted so we can directly read node number...
python
def _read_elem_nodes(self, fid): """ Read the nodes from an opened elem.dat file. Correct for CutMcK transformations. We store three typed of nodes in the dict 'nodes': * "raw" : as read from the elem.dat file * "presort" : pre-sorted so we can directly read node number...
[ "def", "_read_elem_nodes", "(", "self", ",", "fid", ")", ":", "nodes", "=", "{", "}", "# # prepare nodes", "# nodes_sorted = np.zeros((number_of_nodes, 3), dtype=float)", "# nodes = np.zeros((number_of_nodes, 3), dtype=float)", "# read in nodes", "nodes_raw", "=", "np", "...
Read the nodes from an opened elem.dat file. Correct for CutMcK transformations. We store three typed of nodes in the dict 'nodes': * "raw" : as read from the elem.dat file * "presort" : pre-sorted so we can directly read node numbers from a elec.dat file and use ...
[ "Read", "the", "nodes", "from", "an", "opened", "elem", ".", "dat", "file", ".", "Correct", "for", "CutMcK", "transformations", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L160-L229
train
Read the nodes from an elem. dat file and store them in the self. nodes dict.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid._read_elem_elements
def _read_elem_elements(self, fid): """Read all FE elements from the file stream. Elements are stored in the self.element_data dict. The keys refer to the element types: * 3: Triangular grid (three nodes) * 8: Quadrangular grid (four nodes) * 11: Mixed boundary element ...
python
def _read_elem_elements(self, fid): """Read all FE elements from the file stream. Elements are stored in the self.element_data dict. The keys refer to the element types: * 3: Triangular grid (three nodes) * 8: Quadrangular grid (four nodes) * 11: Mixed boundary element ...
[ "def", "_read_elem_elements", "(", "self", ",", "fid", ")", ":", "elements", "=", "{", "}", "# read elements", "for", "element_type", "in", "range", "(", "0", ",", "self", ".", "header", "[", "'nr_element_types'", "]", ")", ":", "element_list", "=", "[", ...
Read all FE elements from the file stream. Elements are stored in the self.element_data dict. The keys refer to the element types: * 3: Triangular grid (three nodes) * 8: Quadrangular grid (four nodes) * 11: Mixed boundary element * 12: Neumann (no-flow) boundary element
[ "Read", "all", "FE", "elements", "from", "the", "file", "stream", ".", "Elements", "are", "stored", "in", "the", "self", ".", "element_data", "dict", ".", "The", "keys", "refer", "to", "the", "element", "types", ":" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L231-L259
train
Read all FE elements from the file stream.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid._prepare_grids
def _prepare_grids(self): """ depending on the type of grid (rectangular or triangle), prepare grids or triangle lists TODO: We want some nice way of not needing to know in the future if we loaded triangles or quadratic elements. """ if(self.header['element...
python
def _prepare_grids(self): """ depending on the type of grid (rectangular or triangle), prepare grids or triangle lists TODO: We want some nice way of not needing to know in the future if we loaded triangles or quadratic elements. """ if(self.header['element...
[ "def", "_prepare_grids", "(", "self", ")", ":", "if", "(", "self", ".", "header", "[", "'element_infos'", "]", "[", "0", ",", "2", "]", "==", "3", ")", ":", "print", "(", "'Triangular grid found'", ")", "self", ".", "grid_is_rectangular", "=", "False", ...
depending on the type of grid (rectangular or triangle), prepare grids or triangle lists TODO: We want some nice way of not needing to know in the future if we loaded triangles or quadratic elements.
[ "depending", "on", "the", "type", "of", "grid", "(", "rectangular", "or", "triangle", ")", "prepare", "grids", "or", "triangle", "lists" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L261-L304
train
Prepare the grids for the we .
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.calculate_dimensions
def calculate_dimensions(self): """For a regular grid, calculate the element and node dimensions """ x_coordinates = np.sort(self.grid['x'][:, 0]) # first x node self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size self.nr_elements_x = self.elements.shape[0] / (...
python
def calculate_dimensions(self): """For a regular grid, calculate the element and node dimensions """ x_coordinates = np.sort(self.grid['x'][:, 0]) # first x node self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size self.nr_elements_x = self.elements.shape[0] / (...
[ "def", "calculate_dimensions", "(", "self", ")", ":", "x_coordinates", "=", "np", ".", "sort", "(", "self", ".", "grid", "[", "'x'", "]", "[", ":", ",", "0", "]", ")", "# first x node", "self", ".", "nr_nodes_z", "=", "np", ".", "where", "(", "x_coor...
For a regular grid, calculate the element and node dimensions
[ "For", "a", "regular", "grid", "calculate", "the", "element", "and", "node", "dimensions" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L306-L313
train
For a regular grid calculate the element and node dimensions
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.get_minmax
def get_minmax(self): """Return min/max x/z coordinates of grid Returns ------- x: [float, float] min, max values of grid dimensions in x direction (sideways) z: [float, float] min, max values of grid dimensions in z direction (downwards) """ ...
python
def get_minmax(self): """Return min/max x/z coordinates of grid Returns ------- x: [float, float] min, max values of grid dimensions in x direction (sideways) z: [float, float] min, max values of grid dimensions in z direction (downwards) """ ...
[ "def", "get_minmax", "(", "self", ")", ":", "x_minmax", "=", "[", "np", ".", "min", "(", "self", ".", "grid", "[", "'x'", "]", ")", ",", "np", ".", "max", "(", "self", ".", "grid", "[", "'x'", "]", ".", "max", "(", ")", ")", "]", "z_minmax", ...
Return min/max x/z coordinates of grid Returns ------- x: [float, float] min, max values of grid dimensions in x direction (sideways) z: [float, float] min, max values of grid dimensions in z direction (downwards)
[ "Return", "min", "/", "max", "x", "/", "z", "coordinates", "of", "grid" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L315-L328
train
Return min max x and z coordinates of grid
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid._read_elem_neighbors
def _read_elem_neighbors(self, fid): """Read the boundary-element-neighbors from the end of the file """ # get number of boundary elements # types 11 and 12 are boundary elements sizes = sum([len(self.element_data[key]) for key in (11, 12) if self.element_dat...
python
def _read_elem_neighbors(self, fid): """Read the boundary-element-neighbors from the end of the file """ # get number of boundary elements # types 11 and 12 are boundary elements sizes = sum([len(self.element_data[key]) for key in (11, 12) if self.element_dat...
[ "def", "_read_elem_neighbors", "(", "self", ",", "fid", ")", ":", "# get number of boundary elements", "# types 11 and 12 are boundary elements", "sizes", "=", "sum", "(", "[", "len", "(", "self", ".", "element_data", "[", "key", "]", ")", "for", "key", "in", "(...
Read the boundary-element-neighbors from the end of the file
[ "Read", "the", "boundary", "-", "element", "-", "neighbors", "from", "the", "end", "of", "the", "file" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L330-L343
train
Read the boundary - element - neighbors from the end of the file
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.save_elem_file
def save_elem_file(self, output): """Save elem.dat to file. The grid is saved as read in, i.e., with or without applied cutmck. If you want to change node coordinates, use self.nodes['raw'] Parameters ---------- filename: string output filename """ ...
python
def save_elem_file(self, output): """Save elem.dat to file. The grid is saved as read in, i.e., with or without applied cutmck. If you want to change node coordinates, use self.nodes['raw'] Parameters ---------- filename: string output filename """ ...
[ "def", "save_elem_file", "(", "self", ",", "output", ")", ":", "with", "open", "(", "output", ",", "'wb'", ")", "as", "fid", ":", "self", ".", "_write_elem_header", "(", "fid", ")", "self", ".", "_write_nodes", "(", "fid", ")", "self", ".", "_write_ele...
Save elem.dat to file. The grid is saved as read in, i.e., with or without applied cutmck. If you want to change node coordinates, use self.nodes['raw'] Parameters ---------- filename: string output filename
[ "Save", "elem", ".", "dat", "to", "file", ".", "The", "grid", "is", "saved", "as", "read", "in", "i", ".", "e", ".", "with", "or", "without", "applied", "cutmck", ".", "If", "you", "want", "to", "change", "node", "coordinates", "use", "self", ".", ...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L356-L370
train
Save elem. dat to file.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.load_grid
def load_grid(self, elem_file, elec_file): """Load elem.dat and elec.dat """ self.load_elem_file(elem_file) self.load_elec_file(elec_file)
python
def load_grid(self, elem_file, elec_file): """Load elem.dat and elec.dat """ self.load_elem_file(elem_file) self.load_elec_file(elec_file)
[ "def", "load_grid", "(", "self", ",", "elem_file", ",", "elec_file", ")", ":", "self", ".", "load_elem_file", "(", "elem_file", ")", "self", ".", "load_elec_file", "(", "elec_file", ")" ]
Load elem.dat and elec.dat
[ "Load", "elem", ".", "dat", "and", "elec", ".", "dat" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L411-L415
train
Load elem. dat and elec. dat
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.get_electrode_node
def get_electrode_node(self, electrode): """ For a given electrode (e.g. from a config.dat file), return the true node number as in self.nodes['sorted'] """ elec_node_raw = int(self.electrodes[electrode - 1][0]) if(self.header['cutmck']): elec_node = self.node...
python
def get_electrode_node(self, electrode): """ For a given electrode (e.g. from a config.dat file), return the true node number as in self.nodes['sorted'] """ elec_node_raw = int(self.electrodes[electrode - 1][0]) if(self.header['cutmck']): elec_node = self.node...
[ "def", "get_electrode_node", "(", "self", ",", "electrode", ")", ":", "elec_node_raw", "=", "int", "(", "self", ".", "electrodes", "[", "electrode", "-", "1", "]", "[", "0", "]", ")", "if", "(", "self", ".", "header", "[", "'cutmck'", "]", ")", ":", ...
For a given electrode (e.g. from a config.dat file), return the true node number as in self.nodes['sorted']
[ "For", "a", "given", "electrode", "(", "e", ".", "g", ".", "from", "a", "config", ".", "dat", "file", ")", "return", "the", "true", "node", "number", "as", "in", "self", ".", "nodes", "[", "sorted", "]" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L417-L427
train
Returns the node number for a given electrode.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.plot_grid_to_ax
def plot_grid_to_ax(self, ax, **kwargs): """ Other Parameters --------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False """ all_xz = [] for x, z in zip(self.grid['x'], self.grid['z']): tmp = n...
python
def plot_grid_to_ax(self, ax, **kwargs): """ Other Parameters --------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False """ all_xz = [] for x, z in zip(self.grid['x'], self.grid['z']): tmp = n...
[ "def", "plot_grid_to_ax", "(", "self", ",", "ax", ",", "*", "*", "kwargs", ")", ":", "all_xz", "=", "[", "]", "for", "x", ",", "z", "in", "zip", "(", "self", ".", "grid", "[", "'x'", "]", ",", "self", ".", "grid", "[", "'z'", "]", ")", ":", ...
Other Parameters --------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False
[ "Other", "Parameters", "---------------", "plot_electrode_numbers", ":", "bool", "optional", "Plot", "electrode", "numbers", "in", "the", "grid", "default", ":", "False" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L429-L465
train
Plots the electrodes in the grid.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.plot_grid
def plot_grid(self, **kwargs): """ Other Parameters ---------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False """ fig, ax = plt.subplots(1, 1) self.plot_grid_to_ax(ax, **kwargs) return fig, ax
python
def plot_grid(self, **kwargs): """ Other Parameters ---------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False """ fig, ax = plt.subplots(1, 1) self.plot_grid_to_ax(ax, **kwargs) return fig, ax
[ "def", "plot_grid", "(", "self", ",", "*", "*", "kwargs", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ")", "self", ".", "plot_grid_to_ax", "(", "ax", ",", "*", "*", "kwargs", ")", "return", "fig", ",", "ax" ]
Other Parameters ---------------- plot_electrode_numbers: bool, optional Plot electrode numbers in the grid, default: False
[ "Other", "Parameters", "----------------", "plot_electrode_numbers", ":", "bool", "optional", "Plot", "electrode", "numbers", "in", "the", "grid", "default", ":", "False" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L467-L476
train
Plot the electrode numbers in the grid.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.get_element_centroids
def get_element_centroids(self): """return the central points of all elements Returns ------- Nx2 array x/z coordinates for all (N) elements """ centroids = np.vstack(( np.mean(self.grid['x'], axis=1), np.mean(self.grid['z'], axis=1) )).T ...
python
def get_element_centroids(self): """return the central points of all elements Returns ------- Nx2 array x/z coordinates for all (N) elements """ centroids = np.vstack(( np.mean(self.grid['x'], axis=1), np.mean(self.grid['z'], axis=1) )).T ...
[ "def", "get_element_centroids", "(", "self", ")", ":", "centroids", "=", "np", ".", "vstack", "(", "(", "np", ".", "mean", "(", "self", ".", "grid", "[", "'x'", "]", ",", "axis", "=", "1", ")", ",", "np", ".", "mean", "(", "self", ".", "grid", ...
return the central points of all elements Returns ------- Nx2 array x/z coordinates for all (N) elements
[ "return", "the", "central", "points", "of", "all", "elements" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L494-L506
train
return the central points of all elements
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.get_internal_angles
def get_internal_angles(self): """Compute all internal angles of the grid Returns ------- numpy.ndarray NxK array with N the number of elements, and K the number of nodes, filled with the internal angles in degrees """ angles = [] for el...
python
def get_internal_angles(self): """Compute all internal angles of the grid Returns ------- numpy.ndarray NxK array with N the number of elements, and K the number of nodes, filled with the internal angles in degrees """ angles = [] for el...
[ "def", "get_internal_angles", "(", "self", ")", ":", "angles", "=", "[", "]", "for", "elx", ",", "elz", "in", "zip", "(", "self", ".", "grid", "[", "'x'", "]", ",", "self", ".", "grid", "[", "'z'", "]", ")", ":", "el_angles", "=", "[", "]", "xy...
Compute all internal angles of the grid Returns ------- numpy.ndarray NxK array with N the number of elements, and K the number of nodes, filled with the internal angles in degrees
[ "Compute", "all", "internal", "angles", "of", "the", "grid" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L519-L547
train
Compute all internal angles of the grid. Returns numpy. ndarray with N the number of elements and K the internal angles in degrees
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.analyze_internal_angles
def analyze_internal_angles(self, return_plot=False): """Analyze the internal angles of the grid. Angles shouldn't be too small because this can cause problems/uncertainties in the Finite-Element solution of the forward problem. This function prints the min/max values, as well as quantil...
python
def analyze_internal_angles(self, return_plot=False): """Analyze the internal angles of the grid. Angles shouldn't be too small because this can cause problems/uncertainties in the Finite-Element solution of the forward problem. This function prints the min/max values, as well as quantil...
[ "def", "analyze_internal_angles", "(", "self", ",", "return_plot", "=", "False", ")", ":", "angles", "=", "self", ".", "get_internal_angles", "(", ")", ".", "flatten", "(", ")", "print", "(", "'Minimal angle: {0} degrees'", ".", "format", "(", "np", ".", "mi...
Analyze the internal angles of the grid. Angles shouldn't be too small because this can cause problems/uncertainties in the Finite-Element solution of the forward problem. This function prints the min/max values, as well as quantiles, to the command line, and can also produce a histogram...
[ "Analyze", "the", "internal", "angles", "of", "the", "grid", ".", "Angles", "shouldn", "t", "be", "too", "small", "because", "this", "can", "cause", "problems", "/", "uncertainties", "in", "the", "Finite", "-", "Element", "solution", "of", "the", "forward", ...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L549-L612
train
Analyze the internal angles of the grid and produce a histogram of the internal angles.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.element_neighbors
def element_neighbors(self): """Return a list with element numbers (zero indexed) of neighboring elements. Note that the elements are not sorted. No spacial orientation can be inferred from the order of neighbors. WARNING: This function is slow due to a nested loop. This would be a ...
python
def element_neighbors(self): """Return a list with element numbers (zero indexed) of neighboring elements. Note that the elements are not sorted. No spacial orientation can be inferred from the order of neighbors. WARNING: This function is slow due to a nested loop. This would be a ...
[ "def", "element_neighbors", "(", "self", ")", ":", "if", "self", ".", "element_neighbors_data", "is", "not", "None", ":", "return", "self", ".", "element_neighbors_data", "max_nr_edges", "=", "self", ".", "header", "[", "'element_infos'", "]", "[", "0", ",", ...
Return a list with element numbers (zero indexed) of neighboring elements. Note that the elements are not sorted. No spacial orientation can be inferred from the order of neighbors. WARNING: This function is slow due to a nested loop. This would be a good starting point for further opti...
[ "Return", "a", "list", "with", "element", "numbers", "(", "zero", "indexed", ")", "of", "neighboring", "elements", ".", "Note", "that", "the", "elements", "are", "not", "sorted", ".", "No", "spacial", "orientation", "can", "be", "inferred", "from", "the", ...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L615-L670
train
Return a list of element numbers that are adjacent to each other.
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.Wm
def Wm(self): """Return the smoothing regularization matrix Wm of the grid """ centroids = self.get_element_centroids() Wm = scipy.sparse.csr_matrix( (self.nr_of_elements, self.nr_of_elements)) # Wm = np.zeros((self.nr_of_elements, self.nr_of_elements)) for ...
python
def Wm(self): """Return the smoothing regularization matrix Wm of the grid """ centroids = self.get_element_centroids() Wm = scipy.sparse.csr_matrix( (self.nr_of_elements, self.nr_of_elements)) # Wm = np.zeros((self.nr_of_elements, self.nr_of_elements)) for ...
[ "def", "Wm", "(", "self", ")", ":", "centroids", "=", "self", ".", "get_element_centroids", "(", ")", "Wm", "=", "scipy", ".", "sparse", ".", "csr_matrix", "(", "(", "self", ".", "nr_of_elements", ",", "self", ".", "nr_of_elements", ")", ")", "# Wm = np....
Return the smoothing regularization matrix Wm of the grid
[ "Return", "the", "smoothing", "regularization", "matrix", "Wm", "of", "the", "grid" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L672-L694
train
Return the smoothing regularization matrix Wm of the grid
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
crt_grid.create_surface_grid
def create_surface_grid(nr_electrodes=None, spacing=None, electrodes_x=None, depth=None, left=None, right=None, char_lengths=None, lines=None, ...
python
def create_surface_grid(nr_electrodes=None, spacing=None, electrodes_x=None, depth=None, left=None, right=None, char_lengths=None, lines=None, ...
[ "def", "create_surface_grid", "(", "nr_electrodes", "=", "None", ",", "spacing", "=", "None", ",", "electrodes_x", "=", "None", ",", "depth", "=", "None", ",", "left", "=", "None", ",", "right", "=", "None", ",", "char_lengths", "=", "None", ",", "lines"...
This is a simple wrapper for cr_trig_create to create simple surface grids. Automatically generated electrode positions are rounded to the third digit. Parameters ---------- nr_electrodes: int, optional the number of surface electrodes spacing: float...
[ "This", "is", "a", "simple", "wrapper", "for", "cr_trig_create", "to", "create", "simple", "surface", "grids", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L697-L906
train
This is a simple wrapper for cr_trig_create to create simple surface grids.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._initialize_components
def _initialize_components(self, kwargs): """initialize the various components using the supplied \*\*kwargs Parameters ---------- kwargs: dict \*\*kwargs dict as received by __init__() """ tomodir = None # load/assign grid if 'tomodir' in k...
python
def _initialize_components(self, kwargs): """initialize the various components using the supplied \*\*kwargs Parameters ---------- kwargs: dict \*\*kwargs dict as received by __init__() """ tomodir = None # load/assign grid if 'tomodir' in k...
[ "def", "_initialize_components", "(", "self", ",", "kwargs", ")", ":", "tomodir", "=", "None", "# load/assign grid", "if", "'tomodir'", "in", "kwargs", ":", "# load grid", "tomodir", "=", "kwargs", ".", "get", "(", "'tomodir'", ")", "print", "(", "'importing t...
initialize the various components using the supplied \*\*kwargs Parameters ---------- kwargs: dict \*\*kwargs dict as received by __init__()
[ "initialize", "the", "various", "components", "using", "the", "supplied", "\\", "*", "\\", "*", "kwargs" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L178-L258
train
initialize the various components using the supplied kwargs
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.create_tomodir
def create_tomodir(self, directory): """Create a tomodir subdirectory structure in the given directory """ pwd = os.getcwd() if not os.path.isdir(directory): os.makedirs(directory) os.chdir(directory) directories = ( 'config', 'exe', ...
python
def create_tomodir(self, directory): """Create a tomodir subdirectory structure in the given directory """ pwd = os.getcwd() if not os.path.isdir(directory): os.makedirs(directory) os.chdir(directory) directories = ( 'config', 'exe', ...
[ "def", "create_tomodir", "(", "self", ",", "directory", ")", ":", "pwd", "=", "os", ".", "getcwd", "(", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "os", ".", "makedirs", "(", "directory", ")", "os", ".", "chdir",...
Create a tomodir subdirectory structure in the given directory
[ "Create", "a", "tomodir", "subdirectory", "structure", "in", "the", "given", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L260-L281
train
Create a tomodir subdirectory structure in the given directory.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._check_state
def _check_state(self): """Check if this instance can model and/or can invert """ if(self.grid is not None and self.configs.configs is not None and self.assignments['forward_model'] is not None): self.can_model = True if(self.grid is not None and ...
python
def _check_state(self): """Check if this instance can model and/or can invert """ if(self.grid is not None and self.configs.configs is not None and self.assignments['forward_model'] is not None): self.can_model = True if(self.grid is not None and ...
[ "def", "_check_state", "(", "self", ")", ":", "if", "(", "self", ".", "grid", "is", "not", "None", "and", "self", ".", "configs", ".", "configs", "is", "not", "None", "and", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "not", "None", ...
Check if this instance can model and/or can invert
[ "Check", "if", "this", "instance", "can", "model", "and", "/", "or", "can", "invert" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L283-L293
train
Check if this instance can model and or invert the related resources.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.load_rho_file
def load_rho_file(self, filename): """Load a forward model from a rho.dat file Parameters ---------- filename: string filename to rho.dat file Returns ------- pid_mag: int parameter id for the magnitude model pid_pha: int ...
python
def load_rho_file(self, filename): """Load a forward model from a rho.dat file Parameters ---------- filename: string filename to rho.dat file Returns ------- pid_mag: int parameter id for the magnitude model pid_pha: int ...
[ "def", "load_rho_file", "(", "self", ",", "filename", ")", ":", "pids", "=", "self", ".", "parman", ".", "load_from_rho_file", "(", "filename", ")", "self", ".", "register_magnitude_model", "(", "pids", "[", "0", "]", ")", "self", ".", "register_phase_model"...
Load a forward model from a rho.dat file Parameters ---------- filename: string filename to rho.dat file Returns ------- pid_mag: int parameter id for the magnitude model pid_pha: int parameter id for the phase model
[ "Load", "a", "forward", "model", "from", "a", "rho", ".", "dat", "file" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L295-L314
train
Load a forward model from a rho. dat file.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.save_to_tomodir
def save_to_tomodir(self, directory): """Save the tomodir instance to a directory structure. Note ---- Test cases: * modeling only * inversion only * modeling and inversion """ self.create_tomodir(directory) self.grid.save_...
python
def save_to_tomodir(self, directory): """Save the tomodir instance to a directory structure. Note ---- Test cases: * modeling only * inversion only * modeling and inversion """ self.create_tomodir(directory) self.grid.save_...
[ "def", "save_to_tomodir", "(", "self", ",", "directory", ")", ":", "self", ".", "create_tomodir", "(", "directory", ")", "self", ".", "grid", ".", "save_elem_file", "(", "directory", "+", "os", ".", "sep", "+", "'grid/elem.dat'", ")", "self", ".", "grid", ...
Save the tomodir instance to a directory structure. Note ---- Test cases: * modeling only * inversion only * modeling and inversion
[ "Save", "the", "tomodir", "instance", "to", "a", "directory", "structure", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L316-L383
train
Save the tomodir instance to a directory structure.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._save_sensitivities
def _save_sensitivities(self, directory): """save sensitivities to a directory """ print('saving sensitivities') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): sens_data, meta_data = self.get_sensitivit...
python
def _save_sensitivities(self, directory): """save sensitivities to a directory """ print('saving sensitivities') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): sens_data, meta_data = self.get_sensitivit...
[ "def", "_save_sensitivities", "(", "self", ",", "directory", ")", ":", "print", "(", "'saving sensitivities'", ")", "digits", "=", "int", "(", "np", ".", "ceil", "(", "np", ".", "log10", "(", "self", ".", "configs", ".", "configs", ".", "shape", "[", "...
save sensitivities to a directory
[ "save", "sensitivities", "to", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L385-L407
train
save sensitivities to a directory
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._save_potentials
def _save_potentials(self, directory): """save potentials to a directory """ print('saving potentials') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): pot_data = self.get_potential(i) filena...
python
def _save_potentials(self, directory): """save potentials to a directory """ print('saving potentials') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): pot_data = self.get_potential(i) filena...
[ "def", "_save_potentials", "(", "self", ",", "directory", ")", ":", "print", "(", "'saving potentials'", ")", "digits", "=", "int", "(", "np", ".", "ceil", "(", "np", ".", "log10", "(", "self", ".", "configs", ".", "configs", ".", "shape", "[", "0", ...
save potentials to a directory
[ "save", "potentials", "to", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L409-L426
train
save potentials to a directory
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.clear_measurements
def clear_measurements(self): """Forget any previous measurements """ mid_list = self.assignments.get('measurements', None) if mid_list is not None: for mid in mid_list: self.configs.delete_measurements(mid=mid) self.assignments['measurements'] = N...
python
def clear_measurements(self): """Forget any previous measurements """ mid_list = self.assignments.get('measurements', None) if mid_list is not None: for mid in mid_list: self.configs.delete_measurements(mid=mid) self.assignments['measurements'] = N...
[ "def", "clear_measurements", "(", "self", ")", ":", "mid_list", "=", "self", ".", "assignments", ".", "get", "(", "'measurements'", ",", "None", ")", "if", "mid_list", "is", "not", "None", ":", "for", "mid", "in", "mid_list", ":", "self", ".", "configs",...
Forget any previous measurements
[ "Forget", "any", "previous", "measurements" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L428-L435
train
Forget any previous measurements
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.measurements
def measurements(self): """Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements. """ # check if we have measurements mid = self.assignments.get('measurements', None) ...
python
def measurements(self): """Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements. """ # check if we have measurements mid = self.assignments.get('measurements', None) ...
[ "def", "measurements", "(", "self", ")", ":", "# check if we have measurements", "mid", "=", "self", ".", "assignments", ".", "get", "(", "'measurements'", ",", "None", ")", "if", "mid", "is", "None", ":", "return_value", "=", "self", ".", "model", "(", "v...
Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements.
[ "Return", "the", "measurements", "associated", "with", "this", "instance", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L437-L461
train
Return the measurements associated with this instance.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_modeling_results
def _read_modeling_results(self, directory, silent=False): """Read modeling results from a given mod/ directory. Possible values to read in are: * voltages * potentials * sensitivities """ voltage_file = directory + os.sep + 'volt.dat' if os...
python
def _read_modeling_results(self, directory, silent=False): """Read modeling results from a given mod/ directory. Possible values to read in are: * voltages * potentials * sensitivities """ voltage_file = directory + os.sep + 'volt.dat' if os...
[ "def", "_read_modeling_results", "(", "self", ",", "directory", ",", "silent", "=", "False", ")", ":", "voltage_file", "=", "directory", "+", "os", ".", "sep", "+", "'volt.dat'", "if", "os", ".", "path", ".", "isfile", "(", "voltage_file", ")", ":", "if"...
Read modeling results from a given mod/ directory. Possible values to read in are: * voltages * potentials * sensitivities
[ "Read", "modeling", "results", "from", "a", "given", "mod", "/", "directory", ".", "Possible", "values", "to", "read", "in", "are", ":" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L463-L498
train
Read modeling results from a given mod / directory.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_sensitivities
def _read_sensitivities(self, sens_dir): """import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes """ if self.assignments['sensitivities'] is not None: print('Sensitivities alrea...
python
def _read_sensitivities(self, sens_dir): """import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes """ if self.assignments['sensitivities'] is not None: print('Sensitivities alrea...
[ "def", "_read_sensitivities", "(", "self", ",", "sens_dir", ")", ":", "if", "self", ".", "assignments", "[", "'sensitivities'", "]", "is", "not", "None", ":", "print", "(", "'Sensitivities already imported. Will not overwrite!'", ")", "return", "else", ":", "self"...
import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes
[ "import", "sensitivities", "from", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L500-L532
train
import sensitivities from a directory and store them in self. assignments
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_potentials
def _read_potentials(self, pot_dir): """import potentials from a directory """ if self.assignments['potentials'] is not None: print('Potentials already imported. Will not overwrite!') return else: self.assignments['potentials'] = {} pot_files ...
python
def _read_potentials(self, pot_dir): """import potentials from a directory """ if self.assignments['potentials'] is not None: print('Potentials already imported. Will not overwrite!') return else: self.assignments['potentials'] = {} pot_files ...
[ "def", "_read_potentials", "(", "self", ",", "pot_dir", ")", ":", "if", "self", ".", "assignments", "[", "'potentials'", "]", "is", "not", "None", ":", "print", "(", "'Potentials already imported. Will not overwrite!'", ")", "return", "else", ":", "self", ".", ...
import potentials from a directory
[ "import", "potentials", "from", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L534-L552
train
import potentials from a directory
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.get_potential
def get_potential(self, config_nr): """Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays Firs...
python
def get_potential(self, config_nr): """Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays Firs...
[ "def", "get_potential", "(", "self", ",", "config_nr", ")", ":", "if", "self", ".", "assignments", "[", "'potentials'", "]", "is", "None", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_model", ":", "self", ".", "model", "(", "pote...
Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays First array: magnitude potentials, second array: ph...
[ "Return", "potential", "data", "for", "a", "given", "measurement", "configuration", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L554-L575
train
Return the potential data for a given measurement configuration.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.get_sensitivity
def get_sensitivity(self, config_nr): """return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero. """ if self.assignments['sensitivities'] is None: self._check_state() if self.can_model: ...
python
def get_sensitivity(self, config_nr): """return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero. """ if self.assignments['sensitivities'] is None: self._check_state() if self.can_model: ...
[ "def", "get_sensitivity", "(", "self", ",", "config_nr", ")", ":", "if", "self", ".", "assignments", "[", "'sensitivities'", "]", "is", "None", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_model", ":", "self", ".", "model", "(", ...
return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero.
[ "return", "a", "sensitivity", "as", "well", "as", "corresponding", "metadata", "for", "a", "given", "measurement", "configuration", ".", "Indices", "start", "at", "zero", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L577-L589
train
return a sensitivity as well as corresponding metadata for a given taxonomy configuration. Indices start at zero.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.plot_sensitivity
def plot_sensitivity(self, config_nr=None, sens_data=None, mag_only=False, absv=False, **kwargs): """Create a nice looking plot of the sensitivity distribution for the given configuration nr. Configs start at 1! Parameters ---------- ...
python
def plot_sensitivity(self, config_nr=None, sens_data=None, mag_only=False, absv=False, **kwargs): """Create a nice looking plot of the sensitivity distribution for the given configuration nr. Configs start at 1! Parameters ---------- ...
[ "def", "plot_sensitivity", "(", "self", ",", "config_nr", "=", "None", ",", "sens_data", "=", "None", ",", "mag_only", "=", "False", ",", "absv", "=", "False", ",", "*", "*", "kwargs", ")", ":", "def", "_rescale_sensitivity", "(", "sens_data", ")", ":", ...
Create a nice looking plot of the sensitivity distribution for the given configuration nr. Configs start at 1! Parameters ---------- config_nr : int, optional The configuration number (starting with 0) to compute the sensitivity for. sens_data : Nx2 numpy...
[ "Create", "a", "nice", "looking", "plot", "of", "the", "sensitivity", "distribution", "for", "the", "given", "configuration", "nr", ".", "Configs", "start", "at", "1!" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L591-L767
train
Create a nice looking plot of the sensitivity distribution for the current locale.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.read_voltages
def read_voltages(self, voltage_file): """import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file """ measurements_raw = np.loadtxt( voltage_file, skiprows=1, ) measuremen...
python
def read_voltages(self, voltage_file): """import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file """ measurements_raw = np.loadtxt( voltage_file, skiprows=1, ) measuremen...
[ "def", "read_voltages", "(", "self", ",", "voltage_file", ")", ":", "measurements_raw", "=", "np", ".", "loadtxt", "(", "voltage_file", ",", "skiprows", "=", "1", ",", ")", "measurements", "=", "np", ".", "atleast_2d", "(", "measurements_raw", ")", "# extrac...
import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file
[ "import", "voltages", "from", "a", "volt", ".", "dat", "file" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L769-L834
train
import voltages from a volt. dat file
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.model
def model(self, voltages=True, sensitivities=False, potentials=False, output_directory=None, silent=False, ): """Forward model the tomodir and read in the results """ self._check_state() if self.can_model...
python
def model(self, voltages=True, sensitivities=False, potentials=False, output_directory=None, silent=False, ): """Forward model the tomodir and read in the results """ self._check_state() if self.can_model...
[ "def", "model", "(", "self", ",", "voltages", "=", "True", ",", "sensitivities", "=", "False", ",", "potentials", "=", "False", ",", "output_directory", "=", "None", ",", "silent", "=", "False", ",", ")", ":", "self", ".", "_check_state", "(", ")", "if...
Forward model the tomodir and read in the results
[ "Forward", "model", "the", "tomodir", "and", "read", "in", "the", "results" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L875-L910
train
Forward model the tomodir and read in the results
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._invert
def _invert(self, tempdir, catch_output=True, **kwargs): """Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the C...
python
def _invert(self, tempdir, catch_output=True, **kwargs): """Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the C...
[ "def", "_invert", "(", "self", ",", "tempdir", ",", "catch_output", "=", "True", ",", "*", "*", "kwargs", ")", ":", "nr_cores", "=", "kwargs", ".", "get", "(", "'cores'", ",", "2", ")", "print", "(", "'attempting inversion in directory: {0}'", ".", "format...
Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the CRTomo call (default: True) cores : int, optional ...
[ "Internal", "function", "than", "runs", "an", "inversion", "using", "CRTomo", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L912-L954
train
Internal function than runs an inversion using the CRTomo binary.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.invert
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
python
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
[ "def", "invert", "(", "self", ",", "output_directory", "=", "None", ",", "catch_output", "=", "True", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_invert", ":", "if", "output_directory", "is", "not", ...
Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional use this directory as output directory for the generated tomodir. ...
[ "Invert", "this", "instance", "and", "import", "the", "result", "files" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L956-L1001
train
Invert this instance and import the result files.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.read_inversion_results
def read_inversion_results(self, tomodir): """Import inversion results from a tomodir into this instance WARNING: Not finished! """ self._read_inversion_results(tomodir) self._read_inv_ctr(tomodir) self._read_resm_m(tomodir) self._read_eps_ctr(tomodir)
python
def read_inversion_results(self, tomodir): """Import inversion results from a tomodir into this instance WARNING: Not finished! """ self._read_inversion_results(tomodir) self._read_inv_ctr(tomodir) self._read_resm_m(tomodir) self._read_eps_ctr(tomodir)
[ "def", "read_inversion_results", "(", "self", ",", "tomodir", ")", ":", "self", ".", "_read_inversion_results", "(", "tomodir", ")", "self", ".", "_read_inv_ctr", "(", "tomodir", ")", "self", ".", "_read_resm_m", "(", "tomodir", ")", "self", ".", "_read_eps_ct...
Import inversion results from a tomodir into this instance WARNING: Not finished!
[ "Import", "inversion", "results", "from", "a", "tomodir", "into", "this", "instance" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1003-L1011
train
Import inversion results from a tomodir into this instance
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_inversion_results
def _read_inversion_results(self, tomodir): """Import resistivity magnitude/phase and real/imaginary part of conductivity for all iterations """ basedir = tomodir + os.sep + 'inv' + os.sep print(basedir) inv_mag = sorted(glob(basedir + 'rho*.mag')) inv_pha = sorte...
python
def _read_inversion_results(self, tomodir): """Import resistivity magnitude/phase and real/imaginary part of conductivity for all iterations """ basedir = tomodir + os.sep + 'inv' + os.sep print(basedir) inv_mag = sorted(glob(basedir + 'rho*.mag')) inv_pha = sorte...
[ "def", "_read_inversion_results", "(", "self", ",", "tomodir", ")", ":", "basedir", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "print", "(", "basedir", ")", "inv_mag", "=", "sorted", "(", "glob", "(", "basedir", "+", ...
Import resistivity magnitude/phase and real/imaginary part of conductivity for all iterations
[ "Import", "resistivity", "magnitude", "/", "phase", "and", "real", "/", "imaginary", "part", "of", "conductivity", "for", "all", "iterations" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1013-L1036
train
Read inversion results from the tomodir and store them in self. assignments.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.plot_eps_data_hist
def plot_eps_data_hist(self, dfs): """Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value """ # check if this is a DC inversion if 'datum' in dfs[0]: dc_inv = True else: d...
python
def plot_eps_data_hist(self, dfs): """Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value """ # check if this is a DC inversion if 'datum' in dfs[0]: dc_inv = True else: d...
[ "def", "plot_eps_data_hist", "(", "self", ",", "dfs", ")", ":", "# check if this is a DC inversion", "if", "'datum'", "in", "dfs", "[", "0", "]", ":", "dc_inv", "=", "True", "else", ":", "dc_inv", "=", "False", "nr_y", "=", "len", "(", "dfs", ")", "size_...
Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value
[ "Plot", "histograms", "of", "data", "residuals", "and", "data", "error", "weighting" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1038-L1140
train
Plot histograms of data residuals and data error weighting and weighting of the data.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_eps_ctr
def _read_eps_ctr(tomodir): """Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns ------- """ epsctr_file = tomodir + os.sep + 'inv...
python
def _read_eps_ctr(tomodir): """Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns ------- """ epsctr_file = tomodir + os.sep + 'inv...
[ "def", "_read_eps_ctr", "(", "tomodir", ")", ":", "epsctr_file", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "+", "'eps.ctr'", "if", "not", "os", ".", "path", ".", "isfile", "(", "epsctr_file", ")", ":", "print", "(", ...
Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns -------
[ "Parse", "a", "CRTomo", "eps", ".", "ctr", "file", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1218-L1258
train
Parse a CRTomo eps. ctr file and return a pandas DataFrame
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_inv_ctr
def _read_inv_ctr(self, tomodir): """Read in selected results of the inv.ctr file Parameters ---------- tomodir: string directory path to a tomodir Returns ------- inv_ctr: ? structure containing inv.ctr data """ invct...
python
def _read_inv_ctr(self, tomodir): """Read in selected results of the inv.ctr file Parameters ---------- tomodir: string directory path to a tomodir Returns ------- inv_ctr: ? structure containing inv.ctr data """ invct...
[ "def", "_read_inv_ctr", "(", "self", ",", "tomodir", ")", ":", "invctr_file", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "+", "'inv.ctr'", "if", "not", "os", ".", "path", ".", "isfile", "(", "invctr_file", ")", ":", ...
Read in selected results of the inv.ctr file Parameters ---------- tomodir: string directory path to a tomodir Returns ------- inv_ctr: ? structure containing inv.ctr data
[ "Read", "in", "selected", "results", "of", "the", "inv", ".", "ctr", "file" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1260-L1586
train
Read in selected results of the inv. ctr file and return a dictionary containing the result.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_resm_m
def _read_resm_m(self, tomodir): """Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir """ resm_file = tomodir + os.sep + 'inv' + os.sep + 'res_m.diag' if not os.path.isfile(resm_file): ...
python
def _read_resm_m(self, tomodir): """Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir """ resm_file = tomodir + os.sep + 'inv' + os.sep + 'res_m.diag' if not os.path.isfile(resm_file): ...
[ "def", "_read_resm_m", "(", "self", ",", "tomodir", ")", ":", "resm_file", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "+", "'res_m.diag'", "if", "not", "os", ".", "path", ".", "isfile", "(", "resm_file", ")", ":", "...
Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir
[ "Read", "in", "the", "resolution", "matrix", "of", "an", "inversion" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1622-L1648
train
Read in the resolution matrix of an inversion of a tomodir.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_measurements
def register_measurements(self, mag, pha=None): """Register measurements as magnitude/phase measurements used for the inversion Parameters ---------- mag: int|numpy.ndarray magnitude measurement id for the corresponding measurement data in self.configs.me...
python
def register_measurements(self, mag, pha=None): """Register measurements as magnitude/phase measurements used for the inversion Parameters ---------- mag: int|numpy.ndarray magnitude measurement id for the corresponding measurement data in self.configs.me...
[ "def", "register_measurements", "(", "self", ",", "mag", ",", "pha", "=", "None", ")", ":", "if", "isinstance", "(", "mag", ",", "np", ".", "ndarray", ")", ":", "# make sure that this array is 1D at the most", "# the 0 indicates only one measurement", "assert", "len...
Register measurements as magnitude/phase measurements used for the inversion Parameters ---------- mag: int|numpy.ndarray magnitude measurement id for the corresponding measurement data in self.configs.measurements. If mag is a numpy.ndarray, assume m...
[ "Register", "measurements", "as", "magnitude", "/", "phase", "measurements", "used", "for", "the", "inversion" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1650-L1684
train
Register measurements as magnitude and phase measurements used for the inversion of the current object.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_forward_model
def register_forward_model(self, pid_mag, pid_pha): """Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id correspondi...
python
def register_forward_model(self, pid_mag, pid_pha): """Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id correspondi...
[ "def", "register_forward_model", "(", "self", ",", "pid_mag", ",", "pid_pha", ")", ":", "self", ".", "register_magnitude_model", "(", "pid_mag", ")", "self", ".", "register_phase_model", "(", "pid_pha", ")" ]
Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id corresponding to the phase model
[ "Register", "parameter", "sets", "as", "the", "forward", "models", "for", "magnitude", "and", "phase" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1686-L1698
train
Register parameter sets as the forward models for magnitude and phase
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_magnitude_model
def register_magnitude_model(self, pid): """Set a given parameter model to the forward magnitude model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][0] = pid
python
def register_magnitude_model(self, pid): """Set a given parameter model to the forward magnitude model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][0] = pid
[ "def", "register_magnitude_model", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "None", ":", "self", ".", "assignments", "[", "'forward_model'", "]", "=", "[", "None", ",", "None", "]", "self", "...
Set a given parameter model to the forward magnitude model
[ "Set", "a", "given", "parameter", "model", "to", "the", "forward", "magnitude", "model" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1700-L1706
train
Register a given parameter model as the forward magnitude model.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_phase_model
def register_phase_model(self, pid): """Set a given parameter model to the forward phase model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][1] = pid
python
def register_phase_model(self, pid): """Set a given parameter model to the forward phase model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][1] = pid
[ "def", "register_phase_model", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "None", ":", "self", ".", "assignments", "[", "'forward_model'", "]", "=", "[", "None", ",", "None", "]", "self", ".", ...
Set a given parameter model to the forward phase model
[ "Set", "a", "given", "parameter", "model", "to", "the", "forward", "phase", "model" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1708-L1714
train
Register a given parameter model as the forward phase model.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.add_homogeneous_model
def add_homogeneous_model(self, magnitude, phase=0): """Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, opti...
python
def add_homogeneous_model(self, magnitude, phase=0): """Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, opti...
[ "def", "add_homogeneous_model", "(", "self", ",", "magnitude", ",", "phase", "=", "0", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "not", "None", ":", "print", "(", "'model already set, will overwrite'", ")", "# generate distri...
Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, optional phase [mrad] value of the homogeneous model ...
[ "Add", "a", "homogeneous", "resistivity", "model", "to", "the", "tomodir", ".", "This", "is", "useful", "for", "synthetic", "measurements", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1716-L1748
train
Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.check_measurements_against_sensitivities
def check_measurements_against_sensitivities( self, magnitude, phase=0, return_plot=False): """Check for all configurations if the sensitivities add up to a given homogeneous model Parameters ---------- magnitude : float magnitude used for the homogeneous...
python
def check_measurements_against_sensitivities( self, magnitude, phase=0, return_plot=False): """Check for all configurations if the sensitivities add up to a given homogeneous model Parameters ---------- magnitude : float magnitude used for the homogeneous...
[ "def", "check_measurements_against_sensitivities", "(", "self", ",", "magnitude", ",", "phase", "=", "0", ",", "return_plot", "=", "False", ")", ":", "# generate a temporary tdMan instance", "tdm", "=", "tdMan", "(", "grid", "=", "self", ".", "grid", ",", "confi...
Check for all configurations if the sensitivities add up to a given homogeneous model Parameters ---------- magnitude : float magnitude used for the homogeneous model phase : float, optional, default=0 phase value used for the homogeneous model re...
[ "Check", "for", "all", "configurations", "if", "the", "sensitivities", "add", "up", "to", "a", "given", "homogeneous", "model" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1750-L1880
train
Check for all configurations and return a list of results.
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.show_parset
def show_parset(self, pid): """Plot a given parameter set """ fig, ax = plt.subplots() self.plot.plot_elements_to_ax(pid, ax=ax) return fig, ax
python
def show_parset(self, pid): """Plot a given parameter set """ fig, ax = plt.subplots() self.plot.plot_elements_to_ax(pid, ax=ax) return fig, ax
[ "def", "show_parset", "(", "self", ",", "pid", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "self", ".", "plot", ".", "plot_elements_to_ax", "(", "pid", ",", "ax", "=", "ax", ")", "return", "fig", ",", "ax" ]
Plot a given parameter set
[ "Plot", "a", "given", "parameter", "set" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1882-L1887
train
Plot a given parameter set
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.plot_forward_models
def plot_forward_models(self): """Plot the forward models (requires the forward models to be loaded) """ pids_rho = self.assignments.get('forward_model', None) if pids_rho is None: raise Exception('you need to load the forward model first') fig, axes = plt.subplots(1,...
python
def plot_forward_models(self): """Plot the forward models (requires the forward models to be loaded) """ pids_rho = self.assignments.get('forward_model', None) if pids_rho is None: raise Exception('you need to load the forward model first') fig, axes = plt.subplots(1,...
[ "def", "plot_forward_models", "(", "self", ")", ":", "pids_rho", "=", "self", ".", "assignments", ".", "get", "(", "'forward_model'", ",", "None", ")", "if", "pids_rho", "is", "None", ":", "raise", "Exception", "(", "'you need to load the forward model first'", ...
Plot the forward models (requires the forward models to be loaded)
[ "Plot", "the", "forward", "models", "(", "requires", "the", "forward", "models", "to", "be", "loaded", ")" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1889-L1912
train
Plot the forward models
wdv4758h/python-everywhere
setup.py
cythonize
def cythonize(*args, **kwargs): ''' dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython. ''' global cythonize from Cython.Build import cythonize return cythonize(*args, **kwargs)
python
def cythonize(*args, **kwargs): ''' dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython. ''' global cythonize from Cython.Build import cythonize return cythonize(*args, **kwargs)
[ "def", "cythonize", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "cythonize", "from", "Cython", ".", "Build", "import", "cythonize", "return", "cythonize", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython.
[ "dirty", "hack", "only", "import", "cythonize", "at", "the", "time", "you", "use", "it", "." ]
1d1bafd9f908b08c7bdb0470c6e54181c928f32f
https://github.com/wdv4758h/python-everywhere/blob/1d1bafd9f908b08c7bdb0470c6e54181c928f32f/setup.py#L4-L13
train
dirty hack to import Cython. Build and cythonize
wdv4758h/python-everywhere
setup.py
mbcs_work_around
def mbcs_work_around(): ''' work around for mbcs codec to make "bdist_wininst" work https://mail.python.org/pipermail/python-list/2012-February/620326.html ''' import codecs try: codecs.lookup('mbcs') except LookupError: ascii = codecs.lookup('ascii') codecs.register(...
python
def mbcs_work_around(): ''' work around for mbcs codec to make "bdist_wininst" work https://mail.python.org/pipermail/python-list/2012-February/620326.html ''' import codecs try: codecs.lookup('mbcs') except LookupError: ascii = codecs.lookup('ascii') codecs.register(...
[ "def", "mbcs_work_around", "(", ")", ":", "import", "codecs", "try", ":", "codecs", ".", "lookup", "(", "'mbcs'", ")", "except", "LookupError", ":", "ascii", "=", "codecs", ".", "lookup", "(", "'ascii'", ")", "codecs", ".", "register", "(", "lambda", "na...
work around for mbcs codec to make "bdist_wininst" work https://mail.python.org/pipermail/python-list/2012-February/620326.html
[ "work", "around", "for", "mbcs", "codec", "to", "make", "bdist_wininst", "work", "https", ":", "//", "mail", ".", "python", ".", "org", "/", "pipermail", "/", "python", "-", "list", "/", "2012", "-", "February", "/", "620326", ".", "html" ]
1d1bafd9f908b08c7bdb0470c6e54181c928f32f
https://github.com/wdv4758h/python-everywhere/blob/1d1bafd9f908b08c7bdb0470c6e54181c928f32f/setup.py#L16-L26
train
work around for mbcs codec to make bdist_wininst work https://mail. python. org / pipermail - list / 2015 - February - 620326
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.endpoint
def endpoint(self, endpt, argdict=None): """ Construct API endpoint URLs using instance options in `self.args` and local arguments passed to the function as a dictionary `argdict`. >>> api = BustimeAPI("BOGUSAPIKEY") >>> api.endpoint('VEHICLES') 'http://realtim...
python
def endpoint(self, endpt, argdict=None): """ Construct API endpoint URLs using instance options in `self.args` and local arguments passed to the function as a dictionary `argdict`. >>> api = BustimeAPI("BOGUSAPIKEY") >>> api.endpoint('VEHICLES') 'http://realtim...
[ "def", "endpoint", "(", "self", ",", "endpt", ",", "argdict", "=", "None", ")", ":", "instanceargs", "=", "\"{}&{}\"", ".", "format", "(", "queryjoin", "(", "key", "=", "self", ".", "key", ")", ",", "queryjoin", "(", "self", ".", "args", ")", ")", ...
Construct API endpoint URLs using instance options in `self.args` and local arguments passed to the function as a dictionary `argdict`. >>> api = BustimeAPI("BOGUSAPIKEY") >>> api.endpoint('VEHICLES') 'http://realtime.portauthority.org/bustime/api/v1/getvehicles?key=BOGUSAPIKE...
[ "Construct", "API", "endpoint", "URLs", "using", "instance", "options", "in", "self", ".", "args", "and", "local", "arguments", "passed", "to", "the", "function", "as", "a", "dictionary", "argdict", ".", ">>>", "api", "=", "BustimeAPI", "(", "BOGUSAPIKEY", "...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L64-L82
train
Construct API endpoint URLs using instance options in self. args and local arguments passed to the function as a dictionary argdict.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.response
def response(self, url): """Grab an API response.""" resp = requests.get(url).content return self.parseresponse(resp)
python
def response(self, url): """Grab an API response.""" resp = requests.get(url).content return self.parseresponse(resp)
[ "def", "response", "(", "self", ",", "url", ")", ":", "resp", "=", "requests", ".", "get", "(", "url", ")", ".", "content", "return", "self", ".", "parseresponse", "(", "resp", ")" ]
Grab an API response.
[ "Grab", "an", "API", "response", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L84-L88
train
Grab an API response.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.errorhandle
def errorhandle(self, resp): """Parse API error responses and raise appropriate exceptions.""" if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] # Create list of errors if more than one error re...
python
def errorhandle(self, resp): """Parse API error responses and raise appropriate exceptions.""" if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] # Create list of errors if more than one error re...
[ "def", "errorhandle", "(", "self", ",", "resp", ")", ":", "if", "self", ".", "format", "==", "'json'", ":", "parsed", "=", "xmltodict", ".", "parse", "(", "resp", ")", "errors", "=", "parsed", "[", "self", ".", "RESPONSE_TOKEN", "]", "[", "self", "."...
Parse API error responses and raise appropriate exceptions.
[ "Parse", "API", "error", "responses", "and", "raise", "appropriate", "exceptions", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L90-L111
train
Parse API error responses and raise appropriate exceptions.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.parseresponse
def parseresponse(self, resp): """Parse an API response.""" # Support Python 3's bytes type from socket repsonses if sys.version_info.major > 2: resp = resp.decode('utf-8') if self.RESPONSE_TOKEN not in resp: raise BustimeError("The Bustime API returned an inval...
python
def parseresponse(self, resp): """Parse an API response.""" # Support Python 3's bytes type from socket repsonses if sys.version_info.major > 2: resp = resp.decode('utf-8') if self.RESPONSE_TOKEN not in resp: raise BustimeError("The Bustime API returned an inval...
[ "def", "parseresponse", "(", "self", ",", "resp", ")", ":", "# Support Python 3's bytes type from socket repsonses", "if", "sys", ".", "version_info", ".", "major", ">", "2", ":", "resp", "=", "resp", ".", "decode", "(", "'utf-8'", ")", "if", "self", ".", "R...
Parse an API response.
[ "Parse", "an", "API", "response", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L113-L127
train
Parse an API response.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.vehicles
def vehicles(self, vid=None, rt=None): """ Get busses by route or by vehicle ID. Arguments: either `vid`: "Set of one or more vehicle IDs whose location should be returned." Maximum of 10 `vid`s, either in a comma-separated list or an iterable. ...
python
def vehicles(self, vid=None, rt=None): """ Get busses by route or by vehicle ID. Arguments: either `vid`: "Set of one or more vehicle IDs whose location should be returned." Maximum of 10 `vid`s, either in a comma-separated list or an iterable. ...
[ "def", "vehicles", "(", "self", ",", "vid", "=", "None", ",", "rt", "=", "None", ")", ":", "if", "vid", "and", "rt", ":", "raise", "ValueError", "(", "\"The `vid` and `route` parameters cannot be specified simultaneously.\"", ")", "if", "not", "(", "vid", "or"...
Get busses by route or by vehicle ID. Arguments: either `vid`: "Set of one or more vehicle IDs whose location should be returned." Maximum of 10 `vid`s, either in a comma-separated list or an iterable. `rt`: "Set of one or more route designators for which ma...
[ "Get", "busses", "by", "route", "or", "by", "vehicle", "ID", ".", "Arguments", ":", "either", "vid", ":", "Set", "of", "one", "or", "more", "vehicle", "IDs", "whose", "location", "should", "be", "returned", ".", "Maximum", "of", "10", "vid", "s", "eith...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L144-L183
train
Returns a list of all vehicles in a given route or by vehicle ID.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.route_directions
def route_directions(self, rt): """ Return a list of directions for a route. The directions seem to always be INBOUND and OUTBOUND for the busses currently, where INBOUND is towards downtown and OUTBOUND is away from downtown. (No idea if this is going to change.) ...
python
def route_directions(self, rt): """ Return a list of directions for a route. The directions seem to always be INBOUND and OUTBOUND for the busses currently, where INBOUND is towards downtown and OUTBOUND is away from downtown. (No idea if this is going to change.) ...
[ "def", "route_directions", "(", "self", ",", "rt", ")", ":", "url", "=", "self", ".", "endpoint", "(", "'R_DIRECTIONS'", ",", "dict", "(", "rt", "=", "rt", ")", ")", "return", "self", ".", "response", "(", "url", ")" ]
Return a list of directions for a route. The directions seem to always be INBOUND and OUTBOUND for the busses currently, where INBOUND is towards downtown and OUTBOUND is away from downtown. (No idea if this is going to change.) Arguments: `rt`: route design...
[ "Return", "a", "list", "of", "directions", "for", "a", "route", ".", "The", "directions", "seem", "to", "always", "be", "INBOUND", "and", "OUTBOUND", "for", "the", "busses", "currently", "where", "INBOUND", "is", "towards", "downtown", "and", "OUTBOUND", "is...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L202-L219
train
Returns a list of directions for a route.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.stops
def stops(self, rt, direction): """ Return a list of stops for a particular route. Arguments: `rt`: route designator `dir`: route direction (INBOUND, OUTBOUND) Response: `stop`: (stop container) contains list of `stpi...
python
def stops(self, rt, direction): """ Return a list of stops for a particular route. Arguments: `rt`: route designator `dir`: route direction (INBOUND, OUTBOUND) Response: `stop`: (stop container) contains list of `stpi...
[ "def", "stops", "(", "self", ",", "rt", ",", "direction", ")", ":", "url", "=", "self", ".", "endpoint", "(", "'STOPS'", ",", "dict", "(", "rt", "=", "rt", ",", "dir", "=", "direction", ")", ")", "return", "self", ".", "response", "(", "url", ")"...
Return a list of stops for a particular route. Arguments: `rt`: route designator `dir`: route direction (INBOUND, OUTBOUND) Response: `stop`: (stop container) contains list of `stpid`: unique ID number for bus stop `s...
[ "Return", "a", "list", "of", "stops", "for", "a", "particular", "route", ".", "Arguments", ":", "rt", ":", "route", "designator", "dir", ":", "route", "direction", "(", "INBOUND", "OUTBOUND", ")", "Response", ":", "stop", ":", "(", "stop", "container", "...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L221-L239
train
Returns a list of stops for a particular route.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.geopatterns
def geopatterns(self, rt=None, pid=None): """ Returns a set of geographic points that make up a particular routing ('pattern', in API terminology) for a bus route. A bus route can have more than one routing. Arguments: either `rt`: route designator ...
python
def geopatterns(self, rt=None, pid=None): """ Returns a set of geographic points that make up a particular routing ('pattern', in API terminology) for a bus route. A bus route can have more than one routing. Arguments: either `rt`: route designator ...
[ "def", "geopatterns", "(", "self", ",", "rt", "=", "None", ",", "pid", "=", "None", ")", ":", "if", "rt", "and", "pid", ":", "raise", "ValueError", "(", "\"The `rt` and `pid` parameters cannot be specified simultaneously.\"", ")", "if", "not", "(", "rt", "or",...
Returns a set of geographic points that make up a particular routing ('pattern', in API terminology) for a bus route. A bus route can have more than one routing. Arguments: either `rt`: route designator or `pid`: comma-separated list or an iterable of...
[ "Returns", "a", "set", "of", "geographic", "points", "that", "make", "up", "a", "particular", "routing", "(", "pattern", "in", "API", "terminology", ")", "for", "a", "bus", "route", ".", "A", "bus", "route", "can", "have", "more", "than", "one", "routing...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L241-L278
train
Returns a list of geographic points that make up a particular routing.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.predictions
def predictions(self, stpid="", rt="", vid="", maxpredictions=""): """ Retrieve predictions for 1+ stops or 1+ vehicles. Arguments: `stpid`: unique ID number for bus stop (single or comma-seperated list or iterable) or `vid`: vehicle ID number (single...
python
def predictions(self, stpid="", rt="", vid="", maxpredictions=""): """ Retrieve predictions for 1+ stops or 1+ vehicles. Arguments: `stpid`: unique ID number for bus stop (single or comma-seperated list or iterable) or `vid`: vehicle ID number (single...
[ "def", "predictions", "(", "self", ",", "stpid", "=", "\"\"", ",", "rt", "=", "\"\"", ",", "vid", "=", "\"\"", ",", "maxpredictions", "=", "\"\"", ")", ":", "if", "(", "stpid", "and", "vid", ")", "or", "(", "rt", "and", "vid", ")", ":", "raise", ...
Retrieve predictions for 1+ stops or 1+ vehicles. Arguments: `stpid`: unique ID number for bus stop (single or comma-seperated list or iterable) or `vid`: vehicle ID number (single or comma-seperated list or iterable) or `stpid` and `rt` ...
[ "Retrieve", "predictions", "for", "1", "+", "stops", "or", "1", "+", "vehicles", ".", "Arguments", ":", "stpid", ":", "unique", "ID", "number", "for", "bus", "stop", "(", "single", "or", "comma", "-", "seperated", "list", "or", "iterable", ")", "or", "...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L284-L325
train
Retrieve predictions for 1 + stops or 1 + vehicles.
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.bulletins
def bulletins(self, rt="", rtdir="", stpid=""): """ Return list of service alerts ('bulletins') for a route or stop. Arguments: `rt`: route designator or `stpid`: bus stop number or (`rt` and `rtdir`) or (`rt` and `rtdir` and `stpid`) ...
python
def bulletins(self, rt="", rtdir="", stpid=""): """ Return list of service alerts ('bulletins') for a route or stop. Arguments: `rt`: route designator or `stpid`: bus stop number or (`rt` and `rtdir`) or (`rt` and `rtdir` and `stpid`) ...
[ "def", "bulletins", "(", "self", ",", "rt", "=", "\"\"", ",", "rtdir", "=", "\"\"", ",", "stpid", "=", "\"\"", ")", ":", "if", "not", "(", "rt", "or", "stpid", ")", "or", "(", "rtdir", "and", "not", "(", "rt", "or", "stpid", ")", ")", ":", "r...
Return list of service alerts ('bulletins') for a route or stop. Arguments: `rt`: route designator or `stpid`: bus stop number or (`rt` and `rtdir`) or (`rt` and `rtdir` and `stpid`) Response: `sb`: (bulletin container) conta...
[ "Return", "list", "of", "service", "alerts", "(", "bulletins", ")", "for", "a", "route", "or", "stop", ".", "Arguments", ":", "rt", ":", "route", "designator", "or", "stpid", ":", "bus", "stop", "number", "or", "(", "rt", "and", "rtdir", ")", "or", "...
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L327-L360
train
Returns a list of service alerts for a given route or stop.
zalando-stups/lizzy-client
lizzy_client/utils.py
get_stack_refs
def get_stack_refs(refs: list): # copy pasted from Senza """ Returns a list of stack references with name and version. """ refs = list(refs) refs.reverse() stack_refs = [] last_stack = None while refs: ref = refs.pop() if last_stack is not None and re.compile(r'v[0-9][a-...
python
def get_stack_refs(refs: list): # copy pasted from Senza """ Returns a list of stack references with name and version. """ refs = list(refs) refs.reverse() stack_refs = [] last_stack = None while refs: ref = refs.pop() if last_stack is not None and re.compile(r'v[0-9][a-...
[ "def", "get_stack_refs", "(", "refs", ":", "list", ")", ":", "# copy pasted from Senza", "refs", "=", "list", "(", "refs", ")", "refs", ".", "reverse", "(", ")", "stack_refs", "=", "[", "]", "last_stack", "=", "None", "while", "refs", ":", "ref", "=", ...
Returns a list of stack references with name and version.
[ "Returns", "a", "list", "of", "stack", "references", "with", "name", "and", "version", "." ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/utils.py#L35-L62
train
Returns a list of stack references with name and version.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_model_tuples
def prior_model_tuples(self): """ Returns ------- prior_model_tuples: [(String, PriorModel)] """ return list(filter(lambda t: isinstance(t[1], AbstractPriorModel), self.__dict__.items()))
python
def prior_model_tuples(self): """ Returns ------- prior_model_tuples: [(String, PriorModel)] """ return list(filter(lambda t: isinstance(t[1], AbstractPriorModel), self.__dict__.items()))
[ "def", "prior_model_tuples", "(", "self", ")", ":", "return", "list", "(", "filter", "(", "lambda", "t", ":", "isinstance", "(", "t", "[", "1", "]", ",", "AbstractPriorModel", ")", ",", "self", ".", "__dict__", ".", "items", "(", ")", ")", ")" ]
Returns ------- prior_model_tuples: [(String, PriorModel)]
[ "Returns", "-------", "prior_model_tuples", ":", "[", "(", "String", "PriorModel", ")", "]" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L88-L94
train
Returns a list of tuples containing the prior model names and their corresponding PriorModel instances.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.list_prior_model_tuples
def list_prior_model_tuples(self): """ Returns ------- list_prior_model_tuples: [(String, ListPriorModel)] """ return list(filter(lambda t: isinstance(t[1], CollectionPriorModel), self.__dict__.items()))
python
def list_prior_model_tuples(self): """ Returns ------- list_prior_model_tuples: [(String, ListPriorModel)] """ return list(filter(lambda t: isinstance(t[1], CollectionPriorModel), self.__dict__.items()))
[ "def", "list_prior_model_tuples", "(", "self", ")", ":", "return", "list", "(", "filter", "(", "lambda", "t", ":", "isinstance", "(", "t", "[", "1", "]", ",", "CollectionPriorModel", ")", ",", "self", ".", "__dict__", ".", "items", "(", ")", ")", ")" ]
Returns ------- list_prior_model_tuples: [(String, ListPriorModel)]
[ "Returns", "-------", "list_prior_model_tuples", ":", "[", "(", "String", "ListPriorModel", ")", "]" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L98-L104
train
Returns a list of tuples containing the names of the prior models for this object.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.flat_prior_model_tuples
def flat_prior_model_tuples(self): """ Returns ------- prior_model_tuples: [(String, PriorModel)] A list of tuples with the names of prior models and associated prior models. Names are fully qualified by all objects in which they are embedded. """ ...
python
def flat_prior_model_tuples(self): """ Returns ------- prior_model_tuples: [(String, PriorModel)] A list of tuples with the names of prior models and associated prior models. Names are fully qualified by all objects in which they are embedded. """ ...
[ "def", "flat_prior_model_tuples", "(", "self", ")", ":", "return", "[", "(", "\"{}\"", ".", "format", "(", "prior_model_name", ")", ",", "flat_prior_model", ")", "for", "prior_model_name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", "for", "flat...
Returns ------- prior_model_tuples: [(String, PriorModel)] A list of tuples with the names of prior models and associated prior models. Names are fully qualified by all objects in which they are embedded.
[ "Returns", "-------", "prior_model_tuples", ":", "[", "(", "String", "PriorModel", ")", "]", "A", "list", "of", "tuples", "with", "the", "names", "of", "prior", "models", "and", "associated", "prior", "models", ".", "Names", "are", "fully", "qualified", "by"...
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L108-L120
train
Returns a list of tuples with the names of prior models and associated prior models.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_tuples
def prior_tuples(self): """ Returns ------- prior_tuple_dict: [(Prior, PriorTuple)] The set of all priors associated with this mapper """ return {prior_tuple.prior: prior_tuple for name, prior_model in self.prior_model_tuples fo...
python
def prior_tuples(self): """ Returns ------- prior_tuple_dict: [(Prior, PriorTuple)] The set of all priors associated with this mapper """ return {prior_tuple.prior: prior_tuple for name, prior_model in self.prior_model_tuples fo...
[ "def", "prior_tuples", "(", "self", ")", ":", "return", "{", "prior_tuple", ".", "prior", ":", "prior_tuple", "for", "name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", "for", "prior_tuple", "in", "prior_model", ".", "prior_tuples", "}", ".", ...
Returns ------- prior_tuple_dict: [(Prior, PriorTuple)] The set of all priors associated with this mapper
[ "Returns", "-------", "prior_tuple_dict", ":", "[", "(", "Prior", "PriorTuple", ")", "]", "The", "set", "of", "all", "priors", "associated", "with", "this", "mapper" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L124-L133
train
Returns a dictionary of priors associated with this mapper.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.constant_tuple_dict
def constant_tuple_dict(self): """ Returns ------- constant_tuple_dict: {Constant: ConstantTuple} The set of all constants associated with this mapper """ return {constant_tuple.constant: constant_tuple for name, prior_model in self.prior_model...
python
def constant_tuple_dict(self): """ Returns ------- constant_tuple_dict: {Constant: ConstantTuple} The set of all constants associated with this mapper """ return {constant_tuple.constant: constant_tuple for name, prior_model in self.prior_model...
[ "def", "constant_tuple_dict", "(", "self", ")", ":", "return", "{", "constant_tuple", ".", "constant", ":", "constant_tuple", "for", "name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", "for", "constant_tuple", "in", "prior_model", ".", "constant_t...
Returns ------- constant_tuple_dict: {Constant: ConstantTuple} The set of all constants associated with this mapper
[ "Returns", "-------", "constant_tuple_dict", ":", "{", "Constant", ":", "ConstantTuple", "}", "The", "set", "of", "all", "constants", "associated", "with", "this", "mapper" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L145-L154
train
Returns a dictionary of all constants associated with this mapper.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_tuples_ordered_by_id
def prior_tuples_ordered_by_id(self): """ Returns ------- priors: [Prior] An ordered list of unique priors associated with this mapper """ return sorted(list(self.prior_tuples), key=lambda prior_tuple: prior_tuple.prior.id)
python
def prior_tuples_ordered_by_id(self): """ Returns ------- priors: [Prior] An ordered list of unique priors associated with this mapper """ return sorted(list(self.prior_tuples), key=lambda prior_tuple: prior_tuple.prior.id)
[ "def", "prior_tuples_ordered_by_id", "(", "self", ")", ":", "return", "sorted", "(", "list", "(", "self", ".", "prior_tuples", ")", ",", "key", "=", "lambda", "prior_tuple", ":", "prior_tuple", ".", "prior", ".", "id", ")" ]
Returns ------- priors: [Prior] An ordered list of unique priors associated with this mapper
[ "Returns", "-------", "priors", ":", "[", "Prior", "]", "An", "ordered", "list", "of", "unique", "priors", "associated", "with", "this", "mapper" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L158-L165
train
Returns an ordered list of priors associated with this mapper
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.constant_tuples_ordered_by_id
def constant_tuples_ordered_by_id(self): """ Returns ------- constants: [(str, Constant)] A list of tuples mapping strings to constants constants ordered by id """ return sorted(list(self.constant_tuple_dict), key=lambda constant_tuple: constant_tuple.constant...
python
def constant_tuples_ordered_by_id(self): """ Returns ------- constants: [(str, Constant)] A list of tuples mapping strings to constants constants ordered by id """ return sorted(list(self.constant_tuple_dict), key=lambda constant_tuple: constant_tuple.constant...
[ "def", "constant_tuples_ordered_by_id", "(", "self", ")", ":", "return", "sorted", "(", "list", "(", "self", ".", "constant_tuple_dict", ")", ",", "key", "=", "lambda", "constant_tuple", ":", "constant_tuple", ".", "constant", ".", "id", ")" ]
Returns ------- constants: [(str, Constant)] A list of tuples mapping strings to constants constants ordered by id
[ "Returns", "-------", "constants", ":", "[", "(", "str", "Constant", ")", "]", "A", "list", "of", "tuples", "mapping", "strings", "to", "constants", "constants", "ordered", "by", "id" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L169-L176
train
Returns a list of tuples mapping strings to Constant objects ordered by id
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_prior_model_dict
def prior_prior_model_dict(self): """ Returns ------- prior_prior_model_dict: {Prior: PriorModel} A dictionary mapping priors to associated prior models. Each prior will only have one prior model; if a prior is shared by two prior models then one of those prior mo...
python
def prior_prior_model_dict(self): """ Returns ------- prior_prior_model_dict: {Prior: PriorModel} A dictionary mapping priors to associated prior models. Each prior will only have one prior model; if a prior is shared by two prior models then one of those prior mo...
[ "def", "prior_prior_model_dict", "(", "self", ")", ":", "return", "{", "prior", ":", "prior_model", "[", "1", "]", "for", "prior_model", "in", "self", ".", "prior_model_tuples", "for", "_", ",", "prior", "in", "prior_model", "[", "1", "]", ".", "prior_tupl...
Returns ------- prior_prior_model_dict: {Prior: PriorModel} A dictionary mapping priors to associated prior models. Each prior will only have one prior model; if a prior is shared by two prior models then one of those prior models will be in this dictionary.
[ "Returns", "-------", "prior_prior_model_dict", ":", "{", "Prior", ":", "PriorModel", "}", "A", "dictionary", "mapping", "priors", "to", "associated", "prior", "models", ".", "Each", "prior", "will", "only", "have", "one", "prior", "model", ";", "if", "a", "...
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L193-L202
train
Returns a dictionary mapping priors to associated prior models.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_model_name_prior_tuples_dict
def prior_model_name_prior_tuples_dict(self): """ Returns ------- class_priors_dict: {String: [Prior]} A dictionary mapping_matrix the names of priors to lists of associated priors """ return {name: list(prior_model.prior_tuples) for name, prior_model in self....
python
def prior_model_name_prior_tuples_dict(self): """ Returns ------- class_priors_dict: {String: [Prior]} A dictionary mapping_matrix the names of priors to lists of associated priors """ return {name: list(prior_model.prior_tuples) for name, prior_model in self....
[ "def", "prior_model_name_prior_tuples_dict", "(", "self", ")", ":", "return", "{", "name", ":", "list", "(", "prior_model", ".", "prior_tuples", ")", "for", "name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", "}" ]
Returns ------- class_priors_dict: {String: [Prior]} A dictionary mapping_matrix the names of priors to lists of associated priors
[ "Returns", "-------", "class_priors_dict", ":", "{", "String", ":", "[", "Prior", "]", "}", "A", "dictionary", "mapping_matrix", "the", "names", "of", "priors", "to", "lists", "of", "associated", "priors" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L245-L252
train
Returns a dictionary mapping the names of priors to lists of associated priors.
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.prior_model_name_constant_tuples_dict
def prior_model_name_constant_tuples_dict(self): """ Returns ------- class_constants_dict: {String: [Constant]} A dictionary mapping_matrix the names of priors to lists of associated constants """ return {name: list(prior_model.constant_tuples) for name, prior...
python
def prior_model_name_constant_tuples_dict(self): """ Returns ------- class_constants_dict: {String: [Constant]} A dictionary mapping_matrix the names of priors to lists of associated constants """ return {name: list(prior_model.constant_tuples) for name, prior...
[ "def", "prior_model_name_constant_tuples_dict", "(", "self", ")", ":", "return", "{", "name", ":", "list", "(", "prior_model", ".", "constant_tuples", ")", "for", "name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", "}" ]
Returns ------- class_constants_dict: {String: [Constant]} A dictionary mapping_matrix the names of priors to lists of associated constants
[ "Returns", "-------", "class_constants_dict", ":", "{", "String", ":", "[", "Constant", "]", "}", "A", "dictionary", "mapping_matrix", "the", "names", "of", "priors", "to", "lists", "of", "associated", "constants" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L255-L262
train
Returns a dictionary mapping the names of priors to lists of associated constants.