repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
OCA/openupgradelib
openupgradelib/openupgrade.py
update_workflow_workitems
def update_workflow_workitems(cr, pool, ref_spec_actions): """Find all the workflow items from the target state to set them to the wanted state. When a workflow action is removed, from model, the objects whose states are in these actions need to be set to another to be able to continue the workflow...
python
def update_workflow_workitems(cr, pool, ref_spec_actions): """Find all the workflow items from the target state to set them to the wanted state. When a workflow action is removed, from model, the objects whose states are in these actions need to be set to another to be able to continue the workflow...
[ "def", "update_workflow_workitems", "(", "cr", ",", "pool", ",", "ref_spec_actions", ")", ":", "workflow_workitems", "=", "pool", "[", "'workflow.workitem'", "]", "ir_model_data_model", "=", "pool", "[", "'ir.model.data'", "]", "for", "(", "target_external_id", ",",...
Find all the workflow items from the target state to set them to the wanted state. When a workflow action is removed, from model, the objects whose states are in these actions need to be set to another to be able to continue the workflow properly. Run in pre-migration :param ref_spec_actions:...
[ "Find", "all", "the", "workflow", "items", "from", "the", "target", "state", "to", "set", "them", "to", "the", "wanted", "state", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L726-L767
train
OCA/openupgradelib
openupgradelib/openupgrade.py
logged_query
def logged_query(cr, query, args=None, skip_no_result=False): """ Logs query and affected rows at level DEBUG. :param query: a query string suitable to pass to cursor.execute() :param args: a list, tuple or dictionary passed as substitution values to cursor.execute(). :param skip_no_result: I...
python
def logged_query(cr, query, args=None, skip_no_result=False): """ Logs query and affected rows at level DEBUG. :param query: a query string suitable to pass to cursor.execute() :param args: a list, tuple or dictionary passed as substitution values to cursor.execute(). :param skip_no_result: I...
[ "def", "logged_query", "(", "cr", ",", "query", ",", "args", "=", "None", ",", "skip_no_result", "=", "False", ")", ":", "if", "args", "is", "None", ":", "args", "=", "(", ")", "args", "=", "tuple", "(", "args", ")", "if", "type", "(", "args", ")...
Logs query and affected rows at level DEBUG. :param query: a query string suitable to pass to cursor.execute() :param args: a list, tuple or dictionary passed as substitution values to cursor.execute(). :param skip_no_result: If True, then logging details are only shown if there are affected re...
[ "Logs", "query", "and", "affected", "rows", "at", "level", "DEBUG", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L959-L980
train
OCA/openupgradelib
openupgradelib/openupgrade.py
update_module_names
def update_module_names(cr, namespec, merge_modules=False): """Deal with changed module names, making all the needed changes on the related tables, like XML-IDs, translations, and so on. :param namespec: list of tuples of (old name, new name) :param merge_modules: Specify if the operation should be a m...
python
def update_module_names(cr, namespec, merge_modules=False): """Deal with changed module names, making all the needed changes on the related tables, like XML-IDs, translations, and so on. :param namespec: list of tuples of (old name, new name) :param merge_modules: Specify if the operation should be a m...
[ "def", "update_module_names", "(", "cr", ",", "namespec", ",", "merge_modules", "=", "False", ")", ":", "for", "(", "old_name", ",", "new_name", ")", "in", "namespec", ":", "if", "merge_modules", ":", "query", "=", "\"SELECT id FROM ir_module_module WHERE name = %...
Deal with changed module names, making all the needed changes on the related tables, like XML-IDs, translations, and so on. :param namespec: list of tuples of (old name, new name) :param merge_modules: Specify if the operation should be a merge instead of just a renaming.
[ "Deal", "with", "changed", "module", "names", "making", "all", "the", "needed", "changes", "on", "the", "related", "tables", "like", "XML", "-", "IDs", "translations", "and", "so", "on", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L983-L1047
train
OCA/openupgradelib
openupgradelib/openupgrade.py
add_ir_model_fields
def add_ir_model_fields(cr, columnspec): """ Typically, new columns on ir_model_fields need to be added in a very early stage in the upgrade process of the base module, in raw sql as they need to be in place before any model gets initialized. Do not use for fields with additional SQL constraints, su...
python
def add_ir_model_fields(cr, columnspec): """ Typically, new columns on ir_model_fields need to be added in a very early stage in the upgrade process of the base module, in raw sql as they need to be in place before any model gets initialized. Do not use for fields with additional SQL constraints, su...
[ "def", "add_ir_model_fields", "(", "cr", ",", "columnspec", ")", ":", "for", "column", "in", "columnspec", ":", "query", "=", "'ALTER TABLE ir_model_fields ADD COLUMN %s %s'", "%", "(", "column", ")", "logged_query", "(", "cr", ",", "query", ",", "[", "]", ")"...
Typically, new columns on ir_model_fields need to be added in a very early stage in the upgrade process of the base module, in raw sql as they need to be in place before any model gets initialized. Do not use for fields with additional SQL constraints, such as a reference to another table or the cascade...
[ "Typically", "new", "columns", "on", "ir_model_fields", "need", "to", "be", "added", "in", "a", "very", "early", "stage", "in", "the", "upgrade", "process", "of", "the", "base", "module", "in", "raw", "sql", "as", "they", "need", "to", "be", "in", "place...
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1050-L1064
train
OCA/openupgradelib
openupgradelib/openupgrade.py
m2o_to_m2m
def m2o_to_m2m(cr, model, table, field, source_field): """ Recreate relations in many2many fields that were formerly many2one fields. Use rename_columns in your pre-migrate script to retain the column's old value, then call m2o_to_m2m in your post-migrate script. :param model: The target model ...
python
def m2o_to_m2m(cr, model, table, field, source_field): """ Recreate relations in many2many fields that were formerly many2one fields. Use rename_columns in your pre-migrate script to retain the column's old value, then call m2o_to_m2m in your post-migrate script. :param model: The target model ...
[ "def", "m2o_to_m2m", "(", "cr", ",", "model", ",", "table", ",", "field", ",", "source_field", ")", ":", "return", "m2o_to_x2m", "(", "cr", ",", "model", ",", "table", ",", "field", ",", "source_field", ")" ]
Recreate relations in many2many fields that were formerly many2one fields. Use rename_columns in your pre-migrate script to retain the column's old value, then call m2o_to_m2m in your post-migrate script. :param model: The target model registry object :param table: The source table :param field...
[ "Recreate", "relations", "in", "many2many", "fields", "that", "were", "formerly", "many2one", "fields", ".", "Use", "rename_columns", "in", "your", "pre", "-", "migrate", "script", "to", "retain", "the", "column", "s", "old", "value", "then", "call", "m2o_to_m...
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1154-L1170
train
OCA/openupgradelib
openupgradelib/openupgrade.py
message
def message(cr, module, table, column, message, *args, **kwargs): """ Log handler for non-critical notifications about the upgrade. To be extended with logging to a table for reporting purposes. :param module: the module name that the message concerns :param table: the model that this m...
python
def message(cr, module, table, column, message, *args, **kwargs): """ Log handler for non-critical notifications about the upgrade. To be extended with logging to a table for reporting purposes. :param module: the module name that the message concerns :param table: the model that this m...
[ "def", "message", "(", "cr", ",", "module", ",", "table", ",", "column", ",", "message", ",", "*", "args", ",", "**", "kwargs", ")", ":", "argslist", "=", "list", "(", "args", "or", "[", "]", ")", "prefix", "=", "': '", "if", "column", ":", "args...
Log handler for non-critical notifications about the upgrade. To be extended with logging to a table for reporting purposes. :param module: the module name that the message concerns :param table: the model that this message concerns (may be False, \ but preferably not if 'column' is defined) :param...
[ "Log", "handler", "for", "non", "-", "critical", "notifications", "about", "the", "upgrade", ".", "To", "be", "extended", "with", "logging", "to", "a", "table", "for", "reporting", "purposes", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1271-L1295
train
OCA/openupgradelib
openupgradelib/openupgrade.py
reactivate_workflow_transitions
def reactivate_workflow_transitions(cr, transition_conditions): """ Reactivate workflow transition previously deactivated by deactivate_workflow_transitions. :param transition_conditions: a dictionary returned by \ deactivate_workflow_transitions .. versionadded:: 7.0 .. deprecated:: 11.0 ...
python
def reactivate_workflow_transitions(cr, transition_conditions): """ Reactivate workflow transition previously deactivated by deactivate_workflow_transitions. :param transition_conditions: a dictionary returned by \ deactivate_workflow_transitions .. versionadded:: 7.0 .. deprecated:: 11.0 ...
[ "def", "reactivate_workflow_transitions", "(", "cr", ",", "transition_conditions", ")", ":", "for", "transition_id", ",", "condition", "in", "transition_conditions", ".", "iteritems", "(", ")", ":", "cr", ".", "execute", "(", "'update wkf_transition set condition = %s w...
Reactivate workflow transition previously deactivated by deactivate_workflow_transitions. :param transition_conditions: a dictionary returned by \ deactivate_workflow_transitions .. versionadded:: 7.0 .. deprecated:: 11.0 Workflows were removed from Odoo as of version 11.0
[ "Reactivate", "workflow", "transition", "previously", "deactivated", "by", "deactivate_workflow_transitions", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1342-L1357
train
OCA/openupgradelib
openupgradelib/openupgrade.py
convert_field_to_html
def convert_field_to_html(cr, table, field_name, html_field_name): """ Convert field value to HTML value. .. versionadded:: 7.0 """ if version_info[0] < 7: logger.error("You cannot use this method in an OpenUpgrade version " "prior to 7.0.") return cr.execut...
python
def convert_field_to_html(cr, table, field_name, html_field_name): """ Convert field value to HTML value. .. versionadded:: 7.0 """ if version_info[0] < 7: logger.error("You cannot use this method in an OpenUpgrade version " "prior to 7.0.") return cr.execut...
[ "def", "convert_field_to_html", "(", "cr", ",", "table", ",", "field_name", ",", "html_field_name", ")", ":", "if", "version_info", "[", "0", "]", "<", "7", ":", "logger", ".", "error", "(", "\"You cannot use this method in an OpenUpgrade version \"", "\"prior to 7....
Convert field value to HTML value. .. versionadded:: 7.0
[ "Convert", "field", "value", "to", "HTML", "value", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1623-L1645
train
OCA/openupgradelib
openupgradelib/openupgrade.py
lift_constraints
def lift_constraints(cr, table, column): """Lift all constraints on column in table. Typically, you use this in a pre-migrate script where you adapt references for many2one fields with changed target objects. If everything went right, the constraints will be recreated""" cr.execute( 'select ...
python
def lift_constraints(cr, table, column): """Lift all constraints on column in table. Typically, you use this in a pre-migrate script where you adapt references for many2one fields with changed target objects. If everything went right, the constraints will be recreated""" cr.execute( 'select ...
[ "def", "lift_constraints", "(", "cr", ",", "table", ",", "column", ")", ":", "cr", ".", "execute", "(", "'select relname, array_agg(conname) from '", "'(select t1.relname, c.conname '", "'from pg_constraint c '", "'join pg_attribute a '", "'on c.confrelid=a.attrelid and a.attnum=...
Lift all constraints on column in table. Typically, you use this in a pre-migrate script where you adapt references for many2one fields with changed target objects. If everything went right, the constraints will be recreated
[ "Lift", "all", "constraints", "on", "column", "in", "table", ".", "Typically", "you", "use", "this", "in", "a", "pre", "-", "migrate", "script", "where", "you", "adapt", "references", "for", "many2one", "fields", "with", "changed", "target", "objects", ".", ...
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1704-L1733
train
OCA/openupgradelib
openupgradelib/openupgrade.py
savepoint
def savepoint(cr): """return a context manager wrapping postgres savepoints""" if hasattr(cr, 'savepoint'): with cr.savepoint(): yield else: name = uuid.uuid1().hex cr.execute('SAVEPOINT "%s"' % name) try: yield cr.execute('RELEASE SAVEPOIN...
python
def savepoint(cr): """return a context manager wrapping postgres savepoints""" if hasattr(cr, 'savepoint'): with cr.savepoint(): yield else: name = uuid.uuid1().hex cr.execute('SAVEPOINT "%s"' % name) try: yield cr.execute('RELEASE SAVEPOIN...
[ "def", "savepoint", "(", "cr", ")", ":", "if", "hasattr", "(", "cr", ",", "'savepoint'", ")", ":", "with", "cr", ".", "savepoint", "(", ")", ":", "yield", "else", ":", "name", "=", "uuid", ".", "uuid1", "(", ")", ".", "hex", "cr", ".", "execute",...
return a context manager wrapping postgres savepoints
[ "return", "a", "context", "manager", "wrapping", "postgres", "savepoints" ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1737-L1749
train
OCA/openupgradelib
openupgradelib/openupgrade.py
rename_property
def rename_property(cr, model, old_name, new_name): """Rename property old_name owned by model to new_name. This should happen in a pre-migration script.""" cr.execute( "update ir_model_fields f set name=%s " "from ir_model m " "where m.id=f.model_id and m.model=%s and f.name=%s " ...
python
def rename_property(cr, model, old_name, new_name): """Rename property old_name owned by model to new_name. This should happen in a pre-migration script.""" cr.execute( "update ir_model_fields f set name=%s " "from ir_model m " "where m.id=f.model_id and m.model=%s and f.name=%s " ...
[ "def", "rename_property", "(", "cr", ",", "model", ",", "old_name", ",", "new_name", ")", ":", "cr", ".", "execute", "(", "\"update ir_model_fields f set name=%s \"", "\"from ir_model m \"", "\"where m.id=f.model_id and m.model=%s and f.name=%s \"", "\"returning f.id\"", ",",...
Rename property old_name owned by model to new_name. This should happen in a pre-migration script.
[ "Rename", "property", "old_name", "owned", "by", "model", "to", "new_name", ".", "This", "should", "happen", "in", "a", "pre", "-", "migration", "script", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L1752-L1768
train
OCA/openupgradelib
openupgradelib/openupgrade.py
delete_records_safely_by_xml_id
def delete_records_safely_by_xml_id(env, xml_ids): """This removes in the safest possible way the records whose XML-IDs are passed as argument. :param xml_ids: List of XML-ID string identifiers of the records to remove. """ for xml_id in xml_ids: logger.debug('Deleting record for XML-ID %s'...
python
def delete_records_safely_by_xml_id(env, xml_ids): """This removes in the safest possible way the records whose XML-IDs are passed as argument. :param xml_ids: List of XML-ID string identifiers of the records to remove. """ for xml_id in xml_ids: logger.debug('Deleting record for XML-ID %s'...
[ "def", "delete_records_safely_by_xml_id", "(", "env", ",", "xml_ids", ")", ":", "for", "xml_id", "in", "xml_ids", ":", "logger", ".", "debug", "(", "'Deleting record for XML-ID %s'", ",", "xml_id", ")", "try", ":", "with", "env", ".", "cr", ".", "savepoint", ...
This removes in the safest possible way the records whose XML-IDs are passed as argument. :param xml_ids: List of XML-ID string identifiers of the records to remove.
[ "This", "removes", "in", "the", "safest", "possible", "way", "the", "records", "whose", "XML", "-", "IDs", "are", "passed", "as", "argument", "." ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L2034-L2046
train
OCA/openupgradelib
openupgradelib/openupgrade.py
chunked
def chunked(records, single=True): """ Memory and performance friendly method to iterate over a potentially large number of records. Yields either a whole chunk or a single record at the time. Don't nest calls to this method. """ if version_info[0] > 10: invalidate = records.env.cache.invalidate...
python
def chunked(records, single=True): """ Memory and performance friendly method to iterate over a potentially large number of records. Yields either a whole chunk or a single record at the time. Don't nest calls to this method. """ if version_info[0] > 10: invalidate = records.env.cache.invalidate...
[ "def", "chunked", "(", "records", ",", "single", "=", "True", ")", ":", "if", "version_info", "[", "0", "]", ">", "10", ":", "invalidate", "=", "records", ".", "env", ".", "cache", ".", "invalidate", "elif", "version_info", "[", "0", "]", ">", "7", ...
Memory and performance friendly method to iterate over a potentially large number of records. Yields either a whole chunk or a single record at the time. Don't nest calls to this method.
[ "Memory", "and", "performance", "friendly", "method", "to", "iterate", "over", "a", "potentially", "large", "number", "of", "records", ".", "Yields", "either", "a", "whole", "chunk", "or", "a", "single", "record", "at", "the", "time", ".", "Don", "t", "nes...
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade.py#L2049-L2069
train
OCA/openupgradelib
openupgradelib/openupgrade_80.py
get_last_post_for_model
def get_last_post_for_model(cr, uid, ids, model_pool): """ Given a set of ids and a model pool, return a dict of each object ids with their latest message date as a value. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID ...
python
def get_last_post_for_model(cr, uid, ids, model_pool): """ Given a set of ids and a model pool, return a dict of each object ids with their latest message date as a value. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID ...
[ "def", "get_last_post_for_model", "(", "cr", ",", "uid", ",", "ids", ",", "model_pool", ")", ":", "if", "type", "(", "ids", ")", "is", "not", "list", ":", "ids", "=", "[", "ids", "]", "res", "=", "{", "}", "for", "obj", "in", "model_pool", ".", "...
Given a set of ids and a model pool, return a dict of each object ids with their latest message date as a value. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID :param ids: ids of the model in question to retrieve ids :pa...
[ "Given", "a", "set", "of", "ids", "and", "a", "model", "pool", "return", "a", "dict", "of", "each", "object", "ids", "with", "their", "latest", "message", "date", "as", "a", "value", ".", "To", "be", "called", "in", "post", "-", "migration", "scripts" ...
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_80.py#L34-L56
train
OCA/openupgradelib
openupgradelib/openupgrade_80.py
set_message_last_post
def set_message_last_post(cr, uid, pool, models): """ Given a list of models, set their 'message_last_post' fields to an estimated last post datetime. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID :param pool: orm p...
python
def set_message_last_post(cr, uid, pool, models): """ Given a list of models, set their 'message_last_post' fields to an estimated last post datetime. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID :param pool: orm p...
[ "def", "set_message_last_post", "(", "cr", ",", "uid", ",", "pool", ",", "models", ")", ":", "if", "type", "(", "models", ")", "is", "not", "list", ":", "models", "=", "[", "models", "]", "for", "model", "in", "models", ":", "model_pool", "=", "pool"...
Given a list of models, set their 'message_last_post' fields to an estimated last post datetime. To be called in post-migration scripts :param cr: database cursor :param uid: user id, assumed to be openerp.SUPERUSER_ID :param pool: orm pool, assumed to be openerp.pooler.get_pool(cr.dbname) :par...
[ "Given", "a", "list", "of", "models", "set", "their", "message_last_post", "fields", "to", "an", "estimated", "last", "post", "datetime", ".", "To", "be", "called", "in", "post", "-", "migration", "scripts" ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_80.py#L59-L84
train
OCA/openupgradelib
openupgradelib/openupgrade_tools.py
column_exists
def column_exists(cr, table, column): """ Check whether a certain column exists """ cr.execute( 'SELECT count(attname) FROM pg_attribute ' 'WHERE attrelid = ' '( SELECT oid FROM pg_class WHERE relname = %s ) ' 'AND attname = %s', (table, column)) return cr.fetchone()[...
python
def column_exists(cr, table, column): """ Check whether a certain column exists """ cr.execute( 'SELECT count(attname) FROM pg_attribute ' 'WHERE attrelid = ' '( SELECT oid FROM pg_class WHERE relname = %s ) ' 'AND attname = %s', (table, column)) return cr.fetchone()[...
[ "def", "column_exists", "(", "cr", ",", "table", ",", "column", ")", ":", "cr", ".", "execute", "(", "'SELECT count(attname) FROM pg_attribute '", "'WHERE attrelid = '", "'( SELECT oid FROM pg_class WHERE relname = %s ) '", "'AND attname = %s'", ",", "(", "table", ",", "c...
Check whether a certain column exists
[ "Check", "whether", "a", "certain", "column", "exists" ]
b220b6498075d62c1b64073cc934513a465cfd85
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_tools.py#L32-L40
train
crossbario/txaio
txaio/aio.py
start_logging
def start_logging(out=_stdout, level='info'): """ Begin logging. :param out: if provided, a file-like object to log to. By default, this is stdout. :param level: the maximum log-level to emit (a string) """ global _log_level, _loggers, _started_logging if level not in log_le...
python
def start_logging(out=_stdout, level='info'): """ Begin logging. :param out: if provided, a file-like object to log to. By default, this is stdout. :param level: the maximum log-level to emit (a string) """ global _log_level, _loggers, _started_logging if level not in log_le...
[ "def", "start_logging", "(", "out", "=", "_stdout", ",", "level", "=", "'info'", ")", ":", "global", "_log_level", ",", "_loggers", ",", "_started_logging", "if", "level", "not", "in", "log_levels", ":", "raise", "RuntimeError", "(", "\"Invalid log level '{0}'; ...
Begin logging. :param out: if provided, a file-like object to log to. By default, this is stdout. :param level: the maximum log-level to emit (a string)
[ "Begin", "logging", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/aio.py#L283-L322
train
crossbario/txaio
txaio/aio.py
_AsyncioApi.create_failure
def create_failure(self, exception=None): """ This returns an object implementing IFailedFuture. If exception is None (the default) we MUST be called within an "except" block (such that sys.exc_info() returns useful information). """ if exception: ret...
python
def create_failure(self, exception=None): """ This returns an object implementing IFailedFuture. If exception is None (the default) we MUST be called within an "except" block (such that sys.exc_info() returns useful information). """ if exception: ret...
[ "def", "create_failure", "(", "self", ",", "exception", "=", "None", ")", ":", "if", "exception", ":", "return", "FailedFuture", "(", "type", "(", "exception", ")", ",", "exception", ",", "None", ")", "return", "FailedFuture", "(", "*", "sys", ".", "exc_...
This returns an object implementing IFailedFuture. If exception is None (the default) we MUST be called within an "except" block (such that sys.exc_info() returns useful information).
[ "This", "returns", "an", "object", "implementing", "IFailedFuture", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/aio.py#L495-L505
train
crossbario/txaio
txaio/aio.py
_AsyncioApi.gather
def gather(self, futures, consume_exceptions=True): """ This returns a Future that waits for all the Futures in the list ``futures`` :param futures: a list of Futures (or coroutines?) :param consume_exceptions: if True, any errors are eaten and returned in the result li...
python
def gather(self, futures, consume_exceptions=True): """ This returns a Future that waits for all the Futures in the list ``futures`` :param futures: a list of Futures (or coroutines?) :param consume_exceptions: if True, any errors are eaten and returned in the result li...
[ "def", "gather", "(", "self", ",", "futures", ",", "consume_exceptions", "=", "True", ")", ":", "return", "asyncio", ".", "gather", "(", "*", "futures", ",", "return_exceptions", "=", "consume_exceptions", ")" ]
This returns a Future that waits for all the Futures in the list ``futures`` :param futures: a list of Futures (or coroutines?) :param consume_exceptions: if True, any errors are eaten and returned in the result list.
[ "This", "returns", "a", "Future", "that", "waits", "for", "all", "the", "Futures", "in", "the", "list", "futures" ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/aio.py#L522-L538
train
crossbario/txaio
txaio/__init__.py
_use_framework
def _use_framework(module): """ Internal helper, to set this modules methods to a specified framework helper-methods. """ import txaio for method_name in __all__: if method_name in ['use_twisted', 'use_asyncio']: continue setattr(txaio, method_name, ge...
python
def _use_framework(module): """ Internal helper, to set this modules methods to a specified framework helper-methods. """ import txaio for method_name in __all__: if method_name in ['use_twisted', 'use_asyncio']: continue setattr(txaio, method_name, ge...
[ "def", "_use_framework", "(", "module", ")", ":", "import", "txaio", "for", "method_name", "in", "__all__", ":", "if", "method_name", "in", "[", "'use_twisted'", ",", "'use_asyncio'", "]", ":", "continue", "setattr", "(", "txaio", ",", "method_name", ",", "g...
Internal helper, to set this modules methods to a specified framework helper-methods.
[ "Internal", "helper", "to", "set", "this", "modules", "methods", "to", "a", "specified", "framework", "helper", "-", "methods", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/__init__.py#L130-L140
train
crossbario/txaio
txaio/tx.py
start_logging
def start_logging(out=_stdout, level='info'): """ Start logging to the file-like object in ``out``. By default, this is stdout. """ global _loggers, _observer, _log_level, _started_logging if level not in log_levels: raise RuntimeError( "Invalid log level '{0}'; valid are: {...
python
def start_logging(out=_stdout, level='info'): """ Start logging to the file-like object in ``out``. By default, this is stdout. """ global _loggers, _observer, _log_level, _started_logging if level not in log_levels: raise RuntimeError( "Invalid log level '{0}'; valid are: {...
[ "def", "start_logging", "(", "out", "=", "_stdout", ",", "level", "=", "'info'", ")", ":", "global", "_loggers", ",", "_observer", ",", "_log_level", ",", "_started_logging", "if", "level", "not", "in", "log_levels", ":", "raise", "RuntimeError", "(", "\"Inv...
Start logging to the file-like object in ``out``. By default, this is stdout.
[ "Start", "logging", "to", "the", "file", "-", "like", "object", "in", "out", ".", "By", "default", "this", "is", "stdout", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/tx.py#L332-L365
train
crossbario/txaio
txaio/tx.py
Logger.set_log_level
def set_log_level(self, level, keep=True): """ Set the log level. If keep is True, then it will not change along with global log changes. """ self._set_log_level(level) self._log_level_set_explicitly = keep
python
def set_log_level(self, level, keep=True): """ Set the log level. If keep is True, then it will not change along with global log changes. """ self._set_log_level(level) self._log_level_set_explicitly = keep
[ "def", "set_log_level", "(", "self", ",", "level", ",", "keep", "=", "True", ")", ":", "self", ".", "_set_log_level", "(", "level", ")", "self", ".", "_log_level_set_explicitly", "=", "keep" ]
Set the log level. If keep is True, then it will not change along with global log changes.
[ "Set", "the", "log", "level", ".", "If", "keep", "is", "True", "then", "it", "will", "not", "change", "along", "with", "global", "log", "changes", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/tx.py#L203-L209
train
crossbario/txaio
txaio/tx.py
_TxApi.sleep
def sleep(self, delay): """ Inline sleep for use in co-routines. :param delay: Time to sleep in seconds. :type delay: float """ d = Deferred() self._get_loop().callLater(delay, d.callback, None) return d
python
def sleep(self, delay): """ Inline sleep for use in co-routines. :param delay: Time to sleep in seconds. :type delay: float """ d = Deferred() self._get_loop().callLater(delay, d.callback, None) return d
[ "def", "sleep", "(", "self", ",", "delay", ")", ":", "d", "=", "Deferred", "(", ")", "self", ".", "_get_loop", "(", ")", ".", "callLater", "(", "delay", ",", "d", ".", "callback", ",", "None", ")", "return", "d" ]
Inline sleep for use in co-routines. :param delay: Time to sleep in seconds. :type delay: float
[ "Inline", "sleep", "for", "use", "in", "co", "-", "routines", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/tx.py#L530-L539
train
crossbario/txaio
txaio/_common.py
_BatchedTimer._notify_bucket
def _notify_bucket(self, real_time): """ Internal helper. This 'does' the callbacks in a particular bucket. :param real_time: the bucket to do callbacks on """ (delayed_call, calls) = self._buckets[real_time] del self._buckets[real_time] errors = [] def ...
python
def _notify_bucket(self, real_time): """ Internal helper. This 'does' the callbacks in a particular bucket. :param real_time: the bucket to do callbacks on """ (delayed_call, calls) = self._buckets[real_time] del self._buckets[real_time] errors = [] def ...
[ "def", "_notify_bucket", "(", "self", ",", "real_time", ")", ":", "(", "delayed_call", ",", "calls", ")", "=", "self", ".", "_buckets", "[", "real_time", "]", "del", "self", ".", "_buckets", "[", "real_time", "]", "errors", "=", "[", "]", "def", "notif...
Internal helper. This 'does' the callbacks in a particular bucket. :param real_time: the bucket to do callbacks on
[ "Internal", "helper", ".", "This", "does", "the", "callbacks", "in", "a", "particular", "bucket", "." ]
29c77ff1210cabd4cc03f16f34672612e7eef704
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/_common.py#L77-L111
train
empymod/empymod
empymod/utils.py
check_ab
def check_ab(ab, verb): r"""Check source-receiver configuration. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver con...
python
def check_ab(ab, verb): r"""Check source-receiver configuration. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver con...
[ "def", "check_ab", "(", "ab", ",", "verb", ")", ":", "r", "try", ":", "ab", "=", "int", "(", "ab", ")", "except", "VariableCatch", ":", "print", "(", "'* ERROR :: <ab> must be an integer'", ")", "raise", "pab", "=", "[", "11", ",", "12", ",", "13", ...
r"""Check source-receiver configuration. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver configuration. verb : {0, ...
[ "r", "Check", "source", "-", "receiver", "configuration", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L142-L211
train
empymod/empymod
empymod/utils.py
check_dipole
def check_dipole(inp, name, verb): r"""Check dipole parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays ...
python
def check_dipole(inp, name, verb): r"""Check dipole parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays ...
[ "def", "check_dipole", "(", "inp", ",", "name", ",", "verb", ")", ":", "r", "_check_shape", "(", "np", ".", "squeeze", "(", "inp", ")", ",", "name", ",", "(", "3", ",", ")", ")", "inp", "[", "0", "]", "=", "_check_var", "(", "inp", "[", "0", ...
r"""Check dipole parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays Pole coordinates (m): [pole-x, pole-...
[ "r", "Check", "dipole", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L317-L365
train
empymod/empymod
empymod/utils.py
check_frequency
def check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb): r"""Calculate frequency-dependent parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Paramet...
python
def check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb): r"""Calculate frequency-dependent parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Paramet...
[ "def", "check_frequency", "(", "freq", ",", "res", ",", "aniso", ",", "epermH", ",", "epermV", ",", "mpermH", ",", "mpermV", ",", "verb", ")", ":", "r", "global", "_min_freq", "if", "isinstance", "(", "res", ",", "dict", ")", ":", "res", "=", "res", ...
r"""Calculate frequency-dependent parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- freq : array_like Frequencies f (Hz). res : a...
[ "r", "Calculate", "frequency", "-", "dependent", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L368-L436
train
empymod/empymod
empymod/utils.py
check_opt
def check_opt(opt, loop, ht, htarg, verb): r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel...
python
def check_opt(opt, loop, ht, htarg, verb): r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel...
[ "def", "check_opt", "(", "opt", ",", "loop", ",", "ht", ",", "htarg", ",", "verb", ")", ":", "r", "use_ne_eval", "=", "False", "if", "opt", "==", "'parallel'", ":", "if", "numexpr", ":", "use_ne_eval", "=", "numexpr", ".", "evaluate", "elif", "verb", ...
r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel'} Optimization flag; use ``numexpr`` o...
[ "r", "Check", "optimization", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L824-L897
train
empymod/empymod
empymod/utils.py
check_time_only
def check_time_only(time, signal, verb): r"""Check time and signal parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- time : array_like ...
python
def check_time_only(time, signal, verb): r"""Check time and signal parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- time : array_like ...
[ "def", "check_time_only", "(", "time", ",", "signal", ",", "verb", ")", ":", "r", "global", "_min_time", "if", "int", "(", "signal", ")", "not", "in", "[", "-", "1", ",", "0", ",", "1", "]", ":", "print", "(", "\"* ERROR :: <signal> must be one of: [No...
r"""Check time and signal parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- time : array_like Times t (s). signal : {None, 0, 1, ...
[ "r", "Check", "time", "and", "signal", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1221-L1267
train
empymod/empymod
empymod/utils.py
check_solution
def check_solution(solution, signal, ab, msrc, mrec): r"""Check required solution with parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- so...
python
def check_solution(solution, signal, ab, msrc, mrec): r"""Check required solution with parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- so...
[ "def", "check_solution", "(", "solution", ",", "signal", ",", "ab", ",", "msrc", ",", "mrec", ")", ":", "r", "if", "solution", "not", "in", "[", "'fs'", ",", "'dfs'", ",", "'dhs'", ",", "'dsplit'", ",", "'dtetm'", "]", ":", "print", "(", "\"* ERROR ...
r"""Check required solution with parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- solution : str String to define analytical solution....
[ "r", "Check", "required", "solution", "with", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1270-L1311
train
empymod/empymod
empymod/utils.py
get_abs
def get_abs(msrc, mrec, srcazm, srcdip, recazm, recdip, verb): r"""Get required ab's for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ...
python
def get_abs(msrc, mrec, srcazm, srcdip, recazm, recdip, verb): r"""Get required ab's for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ...
[ "def", "get_abs", "(", "msrc", ",", "mrec", ",", "srcazm", ",", "srcdip", ",", "recazm", ",", "recdip", ",", "verb", ")", ":", "r", "ab_calc", "=", "np", ".", "array", "(", "[", "[", "11", ",", "12", ",", "13", "]", ",", "[", "21", ",", "22",...
r"""Get required ab's for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- msrc, mrec : bool True if src/rec is magnetic, else Fals...
[ "r", "Get", "required", "ab", "s", "for", "given", "angles", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1316-L1402
train
empymod/empymod
empymod/utils.py
get_geo_fact
def get_geo_fact(ab, srcazm, srcdip, recazm, recdip, msrc, mrec): r"""Get required geometrical scaling factor for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Pa...
python
def get_geo_fact(ab, srcazm, srcdip, recazm, recdip, msrc, mrec): r"""Get required geometrical scaling factor for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Pa...
[ "def", "get_geo_fact", "(", "ab", ",", "srcazm", ",", "srcdip", ",", "recazm", ",", "recdip", ",", "msrc", ",", "mrec", ")", ":", "r", "global", "_min_angle", "fis", "=", "ab", "%", "10", "fir", "=", "ab", "//", "10", "if", "mrec", "and", "not", ...
r"""Get required geometrical scaling factor for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver configura...
[ "r", "Get", "required", "geometrical", "scaling", "factor", "for", "given", "angles", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1405-L1459
train
empymod/empymod
empymod/utils.py
get_layer_nr
def get_layer_nr(inp, depth): r"""Get number of layer in which inp resides. Note: If zinp is on a layer interface, the layer above the interface is chosen. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description...
python
def get_layer_nr(inp, depth): r"""Get number of layer in which inp resides. Note: If zinp is on a layer interface, the layer above the interface is chosen. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description...
[ "def", "get_layer_nr", "(", "inp", ",", "depth", ")", ":", "r", "zinp", "=", "inp", "[", "2", "]", "pdepth", "=", "np", ".", "concatenate", "(", "(", "depth", "[", "1", ":", "]", ",", "np", ".", "array", "(", "[", "np", ".", "infty", "]", ")"...
r"""Get number of layer in which inp resides. Note: If zinp is on a layer interface, the layer above the interface is chosen. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. ...
[ "r", "Get", "number", "of", "layer", "in", "which", "inp", "resides", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1462-L1503
train
empymod/empymod
empymod/utils.py
get_off_ang
def get_off_ang(src, rec, nsrc, nrec, verb): r"""Get depths, offsets, angles, hence spatial input parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters -----...
python
def get_off_ang(src, rec, nsrc, nrec, verb): r"""Get depths, offsets, angles, hence spatial input parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters -----...
[ "def", "get_off_ang", "(", "src", ",", "rec", ",", "nsrc", ",", "nrec", ",", "verb", ")", ":", "r", "global", "_min_off", "off", "=", "np", ".", "empty", "(", "(", "nrec", "*", "nsrc", ",", ")", ")", "angle", "=", "np", ".", "empty", "(", "(", ...
r"""Get depths, offsets, angles, hence spatial input parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- src, rec : list of floats or arrays ...
[ "r", "Get", "depths", "offsets", "angles", "hence", "spatial", "input", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1506-L1557
train
empymod/empymod
empymod/utils.py
printstartfinish
def printstartfinish(verb, inp=None, kcount=None): r"""Print start and finish with time measure and kernel count.""" if inp: if verb > 1: ttxt = str(timedelta(seconds=default_timer() - inp)) ktxt = ' ' if kcount: ktxt += str(kcount) + ' kernel call(s)'...
python
def printstartfinish(verb, inp=None, kcount=None): r"""Print start and finish with time measure and kernel count.""" if inp: if verb > 1: ttxt = str(timedelta(seconds=default_timer() - inp)) ktxt = ' ' if kcount: ktxt += str(kcount) + ' kernel call(s)'...
[ "def", "printstartfinish", "(", "verb", ",", "inp", "=", "None", ",", "kcount", "=", "None", ")", ":", "r", "if", "inp", ":", "if", "verb", ">", "1", ":", "ttxt", "=", "str", "(", "timedelta", "(", "seconds", "=", "default_timer", "(", ")", "-", ...
r"""Print start and finish with time measure and kernel count.
[ "r", "Print", "start", "and", "finish", "with", "time", "measure", "and", "kernel", "count", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1763-L1776
train
empymod/empymod
empymod/utils.py
set_minimum
def set_minimum(min_freq=None, min_time=None, min_off=None, min_res=None, min_angle=None): r""" Set minimum values of parameters. The given parameters are set to its minimum value if they are smaller. Parameters ---------- min_freq : float, optional Minimum frequency [H...
python
def set_minimum(min_freq=None, min_time=None, min_off=None, min_res=None, min_angle=None): r""" Set minimum values of parameters. The given parameters are set to its minimum value if they are smaller. Parameters ---------- min_freq : float, optional Minimum frequency [H...
[ "def", "set_minimum", "(", "min_freq", "=", "None", ",", "min_time", "=", "None", ",", "min_off", "=", "None", ",", "min_res", "=", "None", ",", "min_angle", "=", "None", ")", ":", "r", "global", "_min_freq", ",", "_min_time", ",", "_min_off", ",", "_m...
r""" Set minimum values of parameters. The given parameters are set to its minimum value if they are smaller. Parameters ---------- min_freq : float, optional Minimum frequency [Hz] (default 1e-20 Hz). min_time : float, optional Minimum time [s] (default 1e-20 s). min_off :...
[ "r", "Set", "minimum", "values", "of", "parameters", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1789-L1828
train
empymod/empymod
empymod/utils.py
get_minimum
def get_minimum(): r""" Return the current minimum values. Returns ------- min_vals : dict Dictionary of current minimum values with keys - min_freq : float - min_time : float - min_off : float - min_res : float - min_angle : float ...
python
def get_minimum(): r""" Return the current minimum values. Returns ------- min_vals : dict Dictionary of current minimum values with keys - min_freq : float - min_time : float - min_off : float - min_res : float - min_angle : float ...
[ "def", "get_minimum", "(", ")", ":", "r", "d", "=", "dict", "(", "min_freq", "=", "_min_freq", ",", "min_time", "=", "_min_time", ",", "min_off", "=", "_min_off", ",", "min_res", "=", "_min_res", ",", "min_angle", "=", "_min_angle", ")", "return", "d" ]
r""" Return the current minimum values. Returns ------- min_vals : dict Dictionary of current minimum values with keys - min_freq : float - min_time : float - min_off : float - min_res : float - min_angle : float For a full description...
[ "r", "Return", "the", "current", "minimum", "values", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1831-L1859
train
empymod/empymod
empymod/utils.py
_check_var
def _check_var(var, dtype, ndmin, name, shape=None, shape2=None): r"""Return variable as array of dtype, ndmin; shape-checked.""" if var is None: raise ValueError var = np.array(var, dtype=dtype, copy=True, ndmin=ndmin) if shape: _check_shape(var, name, shape, shape2) return var
python
def _check_var(var, dtype, ndmin, name, shape=None, shape2=None): r"""Return variable as array of dtype, ndmin; shape-checked.""" if var is None: raise ValueError var = np.array(var, dtype=dtype, copy=True, ndmin=ndmin) if shape: _check_shape(var, name, shape, shape2) return var
[ "def", "_check_var", "(", "var", ",", "dtype", ",", "ndmin", ",", "name", ",", "shape", "=", "None", ",", "shape2", "=", "None", ")", ":", "r", "if", "var", "is", "None", ":", "raise", "ValueError", "var", "=", "np", ".", "array", "(", "var", ","...
r"""Return variable as array of dtype, ndmin; shape-checked.
[ "r", "Return", "variable", "as", "array", "of", "dtype", "ndmin", ";", "shape", "-", "checked", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1880-L1887
train
empymod/empymod
empymod/utils.py
_strvar
def _strvar(a, prec='{:G}'): r"""Return variable as a string to print, with given precision.""" return ' '.join([prec.format(i) for i in np.atleast_1d(a)])
python
def _strvar(a, prec='{:G}'): r"""Return variable as a string to print, with given precision.""" return ' '.join([prec.format(i) for i in np.atleast_1d(a)])
[ "def", "_strvar", "(", "a", ",", "prec", "=", "'{:G}'", ")", ":", "r", "return", "' '", ".", "join", "(", "[", "prec", ".", "format", "(", "i", ")", "for", "i", "in", "np", ".", "atleast_1d", "(", "a", ")", "]", ")" ]
r"""Return variable as a string to print, with given precision.
[ "r", "Return", "variable", "as", "a", "string", "to", "print", "with", "given", "precision", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1890-L1892
train
empymod/empymod
empymod/utils.py
_check_min
def _check_min(par, minval, name, unit, verb): r"""Check minimum value of parameter.""" scalar = False if par.shape == (): scalar = True par = np.atleast_1d(par) if minval is not None: ipar = np.where(par < minval) par[ipar] = minval if verb > 0 and np.size(ipar) ...
python
def _check_min(par, minval, name, unit, verb): r"""Check minimum value of parameter.""" scalar = False if par.shape == (): scalar = True par = np.atleast_1d(par) if minval is not None: ipar = np.where(par < minval) par[ipar] = minval if verb > 0 and np.size(ipar) ...
[ "def", "_check_min", "(", "par", ",", "minval", ",", "name", ",", "unit", ",", "verb", ")", ":", "r", "scalar", "=", "False", "if", "par", ".", "shape", "==", "(", ")", ":", "scalar", "=", "True", "par", "=", "np", ".", "atleast_1d", "(", "par", ...
r"""Check minimum value of parameter.
[ "r", "Check", "minimum", "value", "of", "parameter", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1906-L1921
train
empymod/empymod
empymod/utils.py
spline_backwards_hankel
def spline_backwards_hankel(ht, htarg, opt): r"""Check opt if deprecated 'spline' is used. Returns corrected htarg, opt. r""" # Ensure ht is all lowercase ht = ht.lower() # Only relevant for 'fht' and 'hqwe', not for 'quad' if ht in ['fht', 'qwe', 'hqwe']: # Get corresponding htar...
python
def spline_backwards_hankel(ht, htarg, opt): r"""Check opt if deprecated 'spline' is used. Returns corrected htarg, opt. r""" # Ensure ht is all lowercase ht = ht.lower() # Only relevant for 'fht' and 'hqwe', not for 'quad' if ht in ['fht', 'qwe', 'hqwe']: # Get corresponding htar...
[ "def", "spline_backwards_hankel", "(", "ht", ",", "htarg", ",", "opt", ")", ":", "r", "ht", "=", "ht", ".", "lower", "(", ")", "if", "ht", "in", "[", "'fht'", ",", "'qwe'", ",", "'hqwe'", "]", ":", "if", "ht", "==", "'fht'", ":", "htarg", "=", ...
r"""Check opt if deprecated 'spline' is used. Returns corrected htarg, opt. r
[ "r", "Check", "opt", "if", "deprecated", "spline", "is", "used", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1937-L1975
train
empymod/empymod
empymod/model.py
gpr
def gpr(src, rec, depth, res, freqtime, cf, gain=None, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, xdirect=False, ht='quad', htarg=None, ft='fft', ftarg=None, opt=None, loop=None, verb=2): r"""Return the Ground-Penetrating Radar signal. THIS FUNCTION IS EXPERI...
python
def gpr(src, rec, depth, res, freqtime, cf, gain=None, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, xdirect=False, ht='quad', htarg=None, ft='fft', ftarg=None, opt=None, loop=None, verb=2): r"""Return the Ground-Penetrating Radar signal. THIS FUNCTION IS EXPERI...
[ "def", "gpr", "(", "src", ",", "rec", ",", "depth", ",", "res", ",", "freqtime", ",", "cf", ",", "gain", "=", "None", ",", "ab", "=", "11", ",", "aniso", "=", "None", ",", "epermH", "=", "None", ",", "epermV", "=", "None", ",", "mpermH", "=", ...
r"""Return the Ground-Penetrating Radar signal. THIS FUNCTION IS EXPERIMENTAL, USE WITH CAUTION. It is rather an example how you can calculate GPR responses; however, DO NOT RELY ON IT! It works only well with QUAD or QWE (``quad``, ``qwe``) for the Hankel transform, and with FFT (``fft``) for the Fou...
[ "r", "Return", "the", "Ground", "-", "Penetrating", "Radar", "signal", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/model.py#L1187-L1266
train
empymod/empymod
empymod/model.py
dipole_k
def dipole_k(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2): r"""Return the electromagnetic wavenumber-domain field. Calculate the electromagnetic wavenumber-domain field due to infinitesimal small electric or magnetic dip...
python
def dipole_k(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2): r"""Return the electromagnetic wavenumber-domain field. Calculate the electromagnetic wavenumber-domain field due to infinitesimal small electric or magnetic dip...
[ "def", "dipole_k", "(", "src", ",", "rec", ",", "depth", ",", "res", ",", "freq", ",", "wavenumber", ",", "ab", "=", "11", ",", "aniso", "=", "None", ",", "epermH", "=", "None", ",", "epermV", "=", "None", ",", "mpermH", "=", "None", ",", "mpermV...
r"""Return the electromagnetic wavenumber-domain field. Calculate the electromagnetic wavenumber-domain field due to infinitesimal small electric or magnetic dipole source(s), measured by infinitesimal small electric or magnetic dipole receiver(s); sources and receivers are directed along the principal...
[ "r", "Return", "the", "electromagnetic", "wavenumber", "-", "domain", "field", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/model.py#L1269-L1457
train
empymod/empymod
empymod/model.py
wavenumber
def wavenumber(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2): r"""Depreciated. Use `dipole_k` instead.""" # Issue warning mesg = ("\n The use of `model.wavenumber` is deprecated and will " + "be removed;\...
python
def wavenumber(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2): r"""Depreciated. Use `dipole_k` instead.""" # Issue warning mesg = ("\n The use of `model.wavenumber` is deprecated and will " + "be removed;\...
[ "def", "wavenumber", "(", "src", ",", "rec", ",", "depth", ",", "res", ",", "freq", ",", "wavenumber", ",", "ab", "=", "11", ",", "aniso", "=", "None", ",", "epermH", "=", "None", ",", "epermV", "=", "None", ",", "mpermH", "=", "None", ",", "mper...
r"""Depreciated. Use `dipole_k` instead.
[ "r", "Depreciated", ".", "Use", "dipole_k", "instead", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/model.py#L1460-L1470
train
empymod/empymod
empymod/model.py
tem
def tem(fEM, off, freq, time, signal, ft, ftarg, conv=True): r"""Return the time-domain response of the frequency-domain response fEM. This function is called from one of the above modelling routines. No input-check is carried out here. See the main description of :mod:`model` for information regarding...
python
def tem(fEM, off, freq, time, signal, ft, ftarg, conv=True): r"""Return the time-domain response of the frequency-domain response fEM. This function is called from one of the above modelling routines. No input-check is carried out here. See the main description of :mod:`model` for information regarding...
[ "def", "tem", "(", "fEM", ",", "off", ",", "freq", ",", "time", ",", "signal", ",", "ft", ",", "ftarg", ",", "conv", "=", "True", ")", ":", "r", "if", "signal", "in", "[", "-", "1", ",", "1", "]", ":", "fact", "=", "signal", "/", "(", "2j",...
r"""Return the time-domain response of the frequency-domain response fEM. This function is called from one of the above modelling routines. No input-check is carried out here. See the main description of :mod:`model` for information regarding input and output parameters. This function can be directly ...
[ "r", "Return", "the", "time", "-", "domain", "response", "of", "the", "frequency", "-", "domain", "response", "fEM", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/model.py#L1565-L1593
train
empymod/empymod
empymod/scripts/fdesign.py
save_filter
def save_filter(name, filt, full=None, path='filters'): r"""Save DLF-filter and inversion output to plain text files.""" # First we'll save the filter using its internal routine. # This will create the directory ./filters if it doesn't exist already. filt.tofile(path) # If full, we store the inver...
python
def save_filter(name, filt, full=None, path='filters'): r"""Save DLF-filter and inversion output to plain text files.""" # First we'll save the filter using its internal routine. # This will create the directory ./filters if it doesn't exist already. filt.tofile(path) # If full, we store the inver...
[ "def", "save_filter", "(", "name", ",", "filt", ",", "full", "=", "None", ",", "path", "=", "'filters'", ")", ":", "r", "filt", ".", "tofile", "(", "path", ")", "if", "full", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", ...
r"""Save DLF-filter and inversion output to plain text files.
[ "r", "Save", "DLF", "-", "filter", "and", "inversion", "output", "to", "plain", "text", "files", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L469-L523
train
empymod/empymod
empymod/scripts/fdesign.py
load_filter
def load_filter(name, full=False, path='filters'): r"""Load saved DLF-filter and inversion output from text files.""" # First we'll get the filter using its internal routine. filt = DigitalFilter(name.split('.')[0]) filt.fromfile(path) # If full, we get the inversion output if full: # ...
python
def load_filter(name, full=False, path='filters'): r"""Load saved DLF-filter and inversion output from text files.""" # First we'll get the filter using its internal routine. filt = DigitalFilter(name.split('.')[0]) filt.fromfile(path) # If full, we get the inversion output if full: # ...
[ "def", "load_filter", "(", "name", ",", "full", "=", "False", ",", "path", "=", "'filters'", ")", ":", "r", "filt", "=", "DigitalFilter", "(", "name", ".", "split", "(", "'.'", ")", "[", "0", "]", ")", "filt", ".", "fromfile", "(", "path", ")", "...
r"""Load saved DLF-filter and inversion output from text files.
[ "r", "Load", "saved", "DLF", "-", "filter", "and", "inversion", "output", "from", "text", "files", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L526-L566
train
empymod/empymod
empymod/scripts/fdesign.py
plot_result
def plot_result(filt, full, prntres=True): r"""QC the inversion result. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True - If prntres is True, it calls fdesign.print_result as well. r""" # Check matplotlib (soft dependency) if not plt: pr...
python
def plot_result(filt, full, prntres=True): r"""QC the inversion result. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True - If prntres is True, it calls fdesign.print_result as well. r""" # Check matplotlib (soft dependency) if not plt: pr...
[ "def", "plot_result", "(", "filt", ",", "full", ",", "prntres", "=", "True", ")", ":", "r", "if", "not", "plt", ":", "print", "(", "plt_msg", ")", "return", "if", "prntres", ":", "print_result", "(", "filt", ",", "full", ")", "spacing", "=", "full", ...
r"""QC the inversion result. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True - If prntres is True, it calls fdesign.print_result as well. r
[ "r", "QC", "the", "inversion", "result", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L573-L648
train
empymod/empymod
empymod/scripts/fdesign.py
print_result
def print_result(filt, full=None): r"""Print best filter information. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True """ print(' Filter length : %d' % filt.base.size) print(' Best filter') if full: # If full provided, we have more infor...
python
def print_result(filt, full=None): r"""Print best filter information. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True """ print(' Filter length : %d' % filt.base.size) print(' Best filter') if full: # If full provided, we have more infor...
[ "def", "print_result", "(", "filt", ",", "full", "=", "None", ")", ":", "r", "print", "(", "' Filter length : %d'", "%", "filt", ".", "base", ".", "size", ")", "print", "(", "' Best filter'", ")", "if", "full", ":", "if", "full", "[", "4", "]", ...
r"""Print best filter information. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True
[ "r", "Print", "best", "filter", "information", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L651-L678
train
empymod/empymod
empymod/scripts/fdesign.py
_call_qc_transform_pairs
def _call_qc_transform_pairs(n, ispacing, ishift, fI, fC, r, r_def, reim): r"""QC the input transform pairs.""" print('* QC: Input transform-pairs:') print(' fC: x-range defined through ``n``, ``spacing``, ``shift``, and ' + '``r``-parameters; b-range defined through ``r``-parameter.') print(...
python
def _call_qc_transform_pairs(n, ispacing, ishift, fI, fC, r, r_def, reim): r"""QC the input transform pairs.""" print('* QC: Input transform-pairs:') print(' fC: x-range defined through ``n``, ``spacing``, ``shift``, and ' + '``r``-parameters; b-range defined through ``r``-parameter.') print(...
[ "def", "_call_qc_transform_pairs", "(", "n", ",", "ispacing", ",", "ishift", ",", "fI", ",", "fC", ",", "r", ",", "r_def", ",", "reim", ")", ":", "r", "print", "(", "'* QC: Input transform-pairs:'", ")", "print", "(", "' fC: x-range defined through ``n``, ``spa...
r"""QC the input transform pairs.
[ "r", "QC", "the", "input", "transform", "pairs", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L683-L727
train
empymod/empymod
empymod/scripts/fdesign.py
_plot_transform_pairs
def _plot_transform_pairs(fCI, r, k, axes, tit): r"""Plot the input transform pairs.""" # Plot lhs plt.sca(axes[0]) plt.title('|' + tit + ' lhs|') for f in fCI: if f.name == 'j2': lhs = f.lhs(k) plt.loglog(k, np.abs(lhs[0]), lw=2, label='j0') plt.loglog(k...
python
def _plot_transform_pairs(fCI, r, k, axes, tit): r"""Plot the input transform pairs.""" # Plot lhs plt.sca(axes[0]) plt.title('|' + tit + ' lhs|') for f in fCI: if f.name == 'j2': lhs = f.lhs(k) plt.loglog(k, np.abs(lhs[0]), lw=2, label='j0') plt.loglog(k...
[ "def", "_plot_transform_pairs", "(", "fCI", ",", "r", ",", "k", ",", "axes", ",", "tit", ")", ":", "r", "plt", ".", "sca", "(", "axes", "[", "0", "]", ")", "plt", ".", "title", "(", "'|'", "+", "tit", "+", "' lhs|'", ")", "for", "f", "in", "f...
r"""Plot the input transform pairs.
[ "r", "Plot", "the", "input", "transform", "pairs", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L730-L778
train
empymod/empymod
empymod/scripts/fdesign.py
_plot_inversion
def _plot_inversion(f, rhs, r, k, imin, spacing, shift, cvar): r"""QC the resulting filter.""" # Check matplotlib (soft dependency) if not plt: print(plt_msg) return plt.figure("Inversion result "+f.name, figsize=(9.5, 4)) plt.subplots_adjust(wspace=.3, bottom=0.2) plt.clf() ...
python
def _plot_inversion(f, rhs, r, k, imin, spacing, shift, cvar): r"""QC the resulting filter.""" # Check matplotlib (soft dependency) if not plt: print(plt_msg) return plt.figure("Inversion result "+f.name, figsize=(9.5, 4)) plt.subplots_adjust(wspace=.3, bottom=0.2) plt.clf() ...
[ "def", "_plot_inversion", "(", "f", ",", "rhs", ",", "r", ",", "k", ",", "imin", ",", "spacing", ",", "shift", ",", "cvar", ")", ":", "r", "if", "not", "plt", ":", "print", "(", "plt_msg", ")", "return", "plt", ".", "figure", "(", "\"Inversion resu...
r"""QC the resulting filter.
[ "r", "QC", "the", "resulting", "filter", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L781-L829
train
empymod/empymod
empymod/scripts/fdesign.py
empy_hankel
def empy_hankel(ftype, zsrc, zrec, res, freqtime, depth=None, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, htarg=None, verblhs=0, verbrhs=0): r"""Numerical transform pair with empymod. All parameters except ``ftype``, ``verblhs``, and ``verbrhs`` correspond to...
python
def empy_hankel(ftype, zsrc, zrec, res, freqtime, depth=None, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, htarg=None, verblhs=0, verbrhs=0): r"""Numerical transform pair with empymod. All parameters except ``ftype``, ``verblhs``, and ``verbrhs`` correspond to...
[ "def", "empy_hankel", "(", "ftype", ",", "zsrc", ",", "zrec", ",", "res", ",", "freqtime", ",", "depth", "=", "None", ",", "aniso", "=", "None", ",", "epermH", "=", "None", ",", "epermV", "=", "None", ",", "mpermH", "=", "None", ",", "mpermV", "=",...
r"""Numerical transform pair with empymod. All parameters except ``ftype``, ``verblhs``, and ``verbrhs`` correspond to the input parameters to ``empymod.dipole``. See there for more information. Note that if depth=None or [], the analytical full-space solutions will be used (much faster). Paramet...
[ "r", "Numerical", "transform", "pair", "with", "empymod", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L1109-L1192
train
empymod/empymod
empymod/scripts/fdesign.py
_get_min_val
def _get_min_val(spaceshift, *params): r"""Calculate minimum resolved amplitude or maximum r.""" # Get parameters from tuples spacing, shift = spaceshift n, fI, fC, r, r_def, error, reim, cvar, verb, plot, log = params # Get filter for these parameters dlf = _calculate_filter(n, spacing, shift...
python
def _get_min_val(spaceshift, *params): r"""Calculate minimum resolved amplitude or maximum r.""" # Get parameters from tuples spacing, shift = spaceshift n, fI, fC, r, r_def, error, reim, cvar, verb, plot, log = params # Get filter for these parameters dlf = _calculate_filter(n, spacing, shift...
[ "def", "_get_min_val", "(", "spaceshift", ",", "*", "params", ")", ":", "r", "spacing", ",", "shift", "=", "spaceshift", "n", ",", "fI", ",", "fC", ",", "r", ",", "r_def", ",", "error", ",", "reim", ",", "cvar", ",", "verb", ",", "plot", ",", "lo...
r"""Calculate minimum resolved amplitude or maximum r.
[ "r", "Calculate", "minimum", "resolved", "amplitude", "or", "maximum", "r", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L1197-L1276
train
empymod/empymod
empymod/scripts/fdesign.py
_calculate_filter
def _calculate_filter(n, spacing, shift, fI, r_def, reim, name): r"""Calculate filter for this spacing, shift, n.""" # Base :: For this n/spacing/shift base = np.exp(spacing*(np.arange(n)-n//2) + shift) # r :: Start/end is defined by base AND r_def[0]/r_def[1] # Overdetermined system if r_def...
python
def _calculate_filter(n, spacing, shift, fI, r_def, reim, name): r"""Calculate filter for this spacing, shift, n.""" # Base :: For this n/spacing/shift base = np.exp(spacing*(np.arange(n)-n//2) + shift) # r :: Start/end is defined by base AND r_def[0]/r_def[1] # Overdetermined system if r_def...
[ "def", "_calculate_filter", "(", "n", ",", "spacing", ",", "shift", ",", "fI", ",", "r_def", ",", "reim", ",", "name", ")", ":", "r", "base", "=", "np", ".", "exp", "(", "spacing", "*", "(", "np", ".", "arange", "(", "n", ")", "-", "n", "//", ...
r"""Calculate filter for this spacing, shift, n.
[ "r", "Calculate", "filter", "for", "this", "spacing", "shift", "n", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L1279-L1316
train
empymod/empymod
empymod/scripts/fdesign.py
_print_count
def _print_count(log): r"""Print run-count information.""" log['cnt2'] += 1 # Current number cp = log['cnt2']/log['totnr']*100 # Percentage if log['cnt2'] == 0: # Not sure about this; brute seems to call the pass # function with the first arguments twice... ...
python
def _print_count(log): r"""Print run-count information.""" log['cnt2'] += 1 # Current number cp = log['cnt2']/log['totnr']*100 # Percentage if log['cnt2'] == 0: # Not sure about this; brute seems to call the pass # function with the first arguments twice... ...
[ "def", "_print_count", "(", "log", ")", ":", "r", "log", "[", "'cnt2'", "]", "+=", "1", "cp", "=", "log", "[", "'cnt2'", "]", "/", "log", "[", "'totnr'", "]", "*", "100", "if", "log", "[", "'cnt2'", "]", "==", "0", ":", "pass", "elif", "log", ...
r"""Print run-count information.
[ "r", "Print", "run", "-", "count", "information", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L1345-L1380
train
empymod/empymod
empymod/kernel.py
wavenumber
def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval): r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the f...
python
def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval): r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the f...
[ "def", "wavenumber", "(", "zsrc", ",", "zrec", ",", "lsrc", ",", "lrec", ",", "depth", ",", "etaH", ",", "etaV", ",", "zetaH", ",", "zetaV", ",", "lambd", ",", "ab", ",", "xdirect", ",", "msrc", ",", "mrec", ",", "use_ne_eval", ")", ":", "r", "PT...
r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:...
[ "r", "Calculate", "wavenumber", "domain", "solution", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/kernel.py#L47-L129
train
empymod/empymod
empymod/kernel.py
reflections
def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval): r"""Calculate Rp, Rm. .. math:: R^\pm_n, \bar{R}^\pm_n This function corresponds to equations 64/65 and A-11/A-12 in [HuTS15]_, and loosely to the corresponding files ``Rmin.F90`` and ``Rplus.F90``. This function is called from the f...
python
def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval): r"""Calculate Rp, Rm. .. math:: R^\pm_n, \bar{R}^\pm_n This function corresponds to equations 64/65 and A-11/A-12 in [HuTS15]_, and loosely to the corresponding files ``Rmin.F90`` and ``Rplus.F90``. This function is called from the f...
[ "def", "reflections", "(", "depth", ",", "e_zH", ",", "Gam", ",", "lrec", ",", "lsrc", ",", "use_ne_eval", ")", ":", "r", "for", "plus", "in", "[", "True", ",", "False", "]", ":", "if", "plus", ":", "pm", "=", "1", "layer_count", "=", "np", ".", ...
r"""Calculate Rp, Rm. .. math:: R^\pm_n, \bar{R}^\pm_n This function corresponds to equations 64/65 and A-11/A-12 in [HuTS15]_, and loosely to the corresponding files ``Rmin.F90`` and ``Rplus.F90``. This function is called from the function :mod:`kernel.greenfct`.
[ "r", "Calculate", "Rp", "Rm", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/kernel.py#L316-L402
train
empymod/empymod
empymod/kernel.py
angle_factor
def angle_factor(angle, ab, msrc, mrec): r"""Return the angle-dependent factor. The whole calculation in the wavenumber domain is only a function of the distance between the source and the receiver, it is independent of the angel. The angle-dependency is this factor, which can be applied to the cor...
python
def angle_factor(angle, ab, msrc, mrec): r"""Return the angle-dependent factor. The whole calculation in the wavenumber domain is only a function of the distance between the source and the receiver, it is independent of the angel. The angle-dependency is this factor, which can be applied to the cor...
[ "def", "angle_factor", "(", "angle", ",", "ab", ",", "msrc", ",", "mrec", ")", ":", "r", "if", "ab", "in", "[", "33", ",", "]", ":", "return", "np", ".", "ones", "(", "angle", ".", "size", ")", "eval_angle", "=", "angle", ".", "copy", "(", ")",...
r"""Return the angle-dependent factor. The whole calculation in the wavenumber domain is only a function of the distance between the source and the receiver, it is independent of the angel. The angle-dependency is this factor, which can be applied to the corresponding parts in the wavenumber or in the ...
[ "r", "Return", "the", "angle", "-", "dependent", "factor", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/kernel.py#L570-L620
train
empymod/empymod
empymod/scripts/printinfo.py
versions
def versions(mode=None, add_pckg=None, ncol=4): r"""Old func-way of class `Versions`, here for backwards compatibility. ``mode`` is not used any longer, dummy here. """ # Issue warning mesg = ("\n Func `versions` is deprecated and will " + "be removed; use Class `Versions` instead.")...
python
def versions(mode=None, add_pckg=None, ncol=4): r"""Old func-way of class `Versions`, here for backwards compatibility. ``mode`` is not used any longer, dummy here. """ # Issue warning mesg = ("\n Func `versions` is deprecated and will " + "be removed; use Class `Versions` instead.")...
[ "def", "versions", "(", "mode", "=", "None", ",", "add_pckg", "=", "None", ",", "ncol", "=", "4", ")", ":", "r", "mesg", "=", "(", "\"\\n Func `versions` is deprecated and will \"", "+", "\"be removed; use Class `Versions` instead.\"", ")", "warnings", ".", "wa...
r"""Old func-way of class `Versions`, here for backwards compatibility. ``mode`` is not used any longer, dummy here.
[ "r", "Old", "func", "-", "way", "of", "class", "Versions", "here", "for", "backwards", "compatibility", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/printinfo.py#L254-L264
train
empymod/empymod
empymod/scripts/printinfo.py
Versions._repr_html_
def _repr_html_(self): """HTML-rendered versions information.""" # Check ncol ncol = int(self.ncol) # Define html-styles border = "border: 2px solid #fff;'" def colspan(html, txt, ncol, nrow): r"""Print txt in a row spanning whole table.""" html ...
python
def _repr_html_(self): """HTML-rendered versions information.""" # Check ncol ncol = int(self.ncol) # Define html-styles border = "border: 2px solid #fff;'" def colspan(html, txt, ncol, nrow): r"""Print txt in a row spanning whole table.""" html ...
[ "def", "_repr_html_", "(", "self", ")", ":", "ncol", "=", "int", "(", "self", ".", "ncol", ")", "border", "=", "\"border: 2px solid #fff;'\"", "def", "colspan", "(", "html", ",", "txt", ",", "ncol", ",", "nrow", ")", ":", "r", "html", "+=", "\" <tr>\\...
HTML-rendered versions information.
[ "HTML", "-", "rendered", "versions", "information", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/printinfo.py#L155-L224
train
empymod/empymod
empymod/scripts/printinfo.py
Versions._get_packages
def _get_packages(add_pckg): r"""Create list of packages.""" # Mandatory packages pckgs = [numpy, scipy, empymod] # Optional packages for module in [IPython, numexpr, matplotlib]: if module: pckgs += [module] # Cast and add add_pckg ...
python
def _get_packages(add_pckg): r"""Create list of packages.""" # Mandatory packages pckgs = [numpy, scipy, empymod] # Optional packages for module in [IPython, numexpr, matplotlib]: if module: pckgs += [module] # Cast and add add_pckg ...
[ "def", "_get_packages", "(", "add_pckg", ")", ":", "r", "pckgs", "=", "[", "numpy", ",", "scipy", ",", "empymod", "]", "for", "module", "in", "[", "IPython", ",", "numexpr", ",", "matplotlib", "]", ":", "if", "module", ":", "pckgs", "+=", "[", "modul...
r"""Create list of packages.
[ "r", "Create", "list", "of", "packages", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/printinfo.py#L227-L251
train
empymod/empymod
empymod/filters.py
DigitalFilter.tofile
def tofile(self, path='filters'): r"""Save filter values to ascii-files. Store the filter base and the filter coefficients in separate files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Load a fil...
python
def tofile(self, path='filters'): r"""Save filter values to ascii-files. Store the filter base and the filter coefficients in separate files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Load a fil...
[ "def", "tofile", "(", "self", ",", "path", "=", "'filters'", ")", ":", "r", "name", "=", "self", ".", "savename", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "os", ".", "makedirs", "(", "path", ",", "exist_ok", "=", "True", ...
r"""Save filter values to ascii-files. Store the filter base and the filter coefficients in separate files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Load a filter >>> filt = empymod.filters.wer...
[ "r", "Save", "filter", "values", "to", "ascii", "-", "files", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/filters.py#L77-L114
train
empymod/empymod
empymod/filters.py
DigitalFilter.fromfile
def fromfile(self, path='filters'): r"""Load filter values from ascii-files. Load filter base and filter coefficients from ascii files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Create an empty ...
python
def fromfile(self, path='filters'): r"""Load filter values from ascii-files. Load filter base and filter coefficients from ascii files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Create an empty ...
[ "def", "fromfile", "(", "self", ",", "path", "=", "'filters'", ")", ":", "r", "name", "=", "self", ".", "savename", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "basefile", "=", "os", ".", "path", ".", "join", "(", "path", ",...
r"""Load filter values from ascii-files. Load filter base and filter coefficients from ascii files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Create an empty filter; >>> # Name has to be the bas...
[ "r", "Load", "filter", "values", "from", "ascii", "-", "files", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/filters.py#L116-L157
train
empymod/empymod
empymod/transform.py
fht
def fht(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH, zetaV, xdirect, fhtarg, use_ne_eval, msrc, mrec): r"""Hankel Transform using the Digital Linear Filter method. The *Digital Linear Filter* method was introduced to geophysics by [Ghos70]_, and made popular and wide-spread b...
python
def fht(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH, zetaV, xdirect, fhtarg, use_ne_eval, msrc, mrec): r"""Hankel Transform using the Digital Linear Filter method. The *Digital Linear Filter* method was introduced to geophysics by [Ghos70]_, and made popular and wide-spread b...
[ "def", "fht", "(", "zsrc", ",", "zrec", ",", "lsrc", ",", "lrec", ",", "off", ",", "factAng", ",", "depth", ",", "ab", ",", "etaH", ",", "etaV", ",", "zetaH", ",", "zetaV", ",", "xdirect", ",", "fhtarg", ",", "use_ne_eval", ",", "msrc", ",", "mre...
r"""Hankel Transform using the Digital Linear Filter method. The *Digital Linear Filter* method was introduced to geophysics by [Ghos70]_, and made popular and wide-spread by [Ande75]_, [Ande79]_, [Ande82]_. The DLF is sometimes referred to as the *Fast Hankel Transform* FHT, from which this routine ha...
[ "r", "Hankel", "Transform", "using", "the", "Digital", "Linear", "Filter", "method", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L47-L107
train
empymod/empymod
empymod/transform.py
hquad
def hquad(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH, zetaV, xdirect, quadargs, use_ne_eval, msrc, mrec): r"""Hankel Transform using the ``QUADPACK`` library. This routine uses the ``scipy.integrate.quad`` module, which in turn makes use of the Fortran library ``QUADPACK``...
python
def hquad(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH, zetaV, xdirect, quadargs, use_ne_eval, msrc, mrec): r"""Hankel Transform using the ``QUADPACK`` library. This routine uses the ``scipy.integrate.quad`` module, which in turn makes use of the Fortran library ``QUADPACK``...
[ "def", "hquad", "(", "zsrc", ",", "zrec", ",", "lsrc", ",", "lrec", ",", "off", ",", "factAng", ",", "depth", ",", "ab", ",", "etaH", ",", "etaV", ",", "zetaH", ",", "zetaV", ",", "xdirect", ",", "quadargs", ",", "use_ne_eval", ",", "msrc", ",", ...
r"""Hankel Transform using the ``QUADPACK`` library. This routine uses the ``scipy.integrate.quad`` module, which in turn makes use of the Fortran library ``QUADPACK`` (``qagse``). It is massively (orders of magnitudes) slower than either ``fht`` or ``hqwe``, and is mainly here for completeness and co...
[ "r", "Hankel", "Transform", "using", "the", "QUADPACK", "library", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L399-L482
train
empymod/empymod
empymod/transform.py
ffht
def ffht(fEM, time, freq, ftarg): r"""Fourier Transform using the Digital Linear Filter method. It follows the Filter methodology [Ande75]_, using Cosine- and Sine-filters; see ``fht`` for more information. The function is called from one of the modelling routines in :mod:`model`. Consult these m...
python
def ffht(fEM, time, freq, ftarg): r"""Fourier Transform using the Digital Linear Filter method. It follows the Filter methodology [Ande75]_, using Cosine- and Sine-filters; see ``fht`` for more information. The function is called from one of the modelling routines in :mod:`model`. Consult these m...
[ "def", "ffht", "(", "fEM", ",", "time", ",", "freq", ",", "ftarg", ")", ":", "r", "ffhtfilt", "=", "ftarg", "[", "0", "]", "pts_per_dec", "=", "ftarg", "[", "1", "]", "kind", "=", "ftarg", "[", "2", "]", "if", "pts_per_dec", "==", "0", ":", "fE...
r"""Fourier Transform using the Digital Linear Filter method. It follows the Filter methodology [Ande75]_, using Cosine- and Sine-filters; see ``fht`` for more information. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of...
[ "r", "Fourier", "Transform", "using", "the", "Digital", "Linear", "Filter", "method", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L487-L524
train
empymod/empymod
empymod/transform.py
fft
def fft(fEM, time, freq, ftarg): r"""Fourier Transform using the Fast Fourier Transform. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of the input and output parameters. Returns ------- tEM : array Ret...
python
def fft(fEM, time, freq, ftarg): r"""Fourier Transform using the Fast Fourier Transform. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of the input and output parameters. Returns ------- tEM : array Ret...
[ "def", "fft", "(", "fEM", ",", "time", ",", "freq", ",", "ftarg", ")", ":", "r", "dfreq", ",", "nfreq", ",", "ntot", ",", "pts_per_dec", "=", "ftarg", "if", "pts_per_dec", ":", "sfEMr", "=", "iuSpline", "(", "np", ".", "log", "(", "freq", ")", ",...
r"""Fourier Transform using the Fast Fourier Transform. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of the input and output parameters. Returns ------- tEM : array Returns time-domain EM response of ``fEM...
[ "r", "Fourier", "Transform", "using", "the", "Fast", "Fourier", "Transform", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L766-L806
train
empymod/empymod
empymod/transform.py
quad
def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp): r"""Quadrature for Hankel transform. This is the kernel of the QUAD method, used for the Hankel transforms ``hquad`` and ``hqwe`` (where the integral is not suited for QWE). """ # Define the quadrature kernels def q...
python
def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp): r"""Quadrature for Hankel transform. This is the kernel of the QUAD method, used for the Hankel transforms ``hquad`` and ``hqwe`` (where the integral is not suited for QWE). """ # Define the quadrature kernels def q...
[ "def", "quad", "(", "sPJ0r", ",", "sPJ0i", ",", "sPJ1r", ",", "sPJ1i", ",", "sPJ0br", ",", "sPJ0bi", ",", "ab", ",", "off", ",", "factAng", ",", "iinp", ")", ":", "r", "def", "quad_PJ0", "(", "klambd", ",", "sPJ0", ",", "koff", ")", ":", "r", "...
r"""Quadrature for Hankel transform. This is the kernel of the QUAD method, used for the Hankel transforms ``hquad`` and ``hqwe`` (where the integral is not suited for QWE).
[ "r", "Quadrature", "for", "Hankel", "transform", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L1097-L1156
train
empymod/empymod
empymod/transform.py
get_spline_values
def get_spline_values(filt, inp, nr_per_dec=None): r"""Return required calculation points.""" # Standard DLF if nr_per_dec == 0: return filt.base/inp[:, None], inp # Get min and max required out-values (depends on filter and inp-value) outmax = filt.base[-1]/inp.min() outmin = filt.bas...
python
def get_spline_values(filt, inp, nr_per_dec=None): r"""Return required calculation points.""" # Standard DLF if nr_per_dec == 0: return filt.base/inp[:, None], inp # Get min and max required out-values (depends on filter and inp-value) outmax = filt.base[-1]/inp.min() outmin = filt.bas...
[ "def", "get_spline_values", "(", "filt", ",", "inp", ",", "nr_per_dec", "=", "None", ")", ":", "r", "if", "nr_per_dec", "==", "0", ":", "return", "filt", ".", "base", "/", "inp", "[", ":", ",", "None", "]", ",", "inp", "outmax", "=", "filt", ".", ...
r"""Return required calculation points.
[ "r", "Return", "required", "calculation", "points", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L1159-L1216
train
empymod/empymod
empymod/transform.py
fhti
def fhti(rmin, rmax, n, q, mu): r"""Return parameters required for FFTLog.""" # Central point log10(r_c) of periodic interval logrc = (rmin + rmax)/2 # Central index (1/2 integral if n is even) nc = (n + 1)/2. # Log spacing of points dlogr = (rmax - rmin)/n dlnr = dlogr*np.log(10.) ...
python
def fhti(rmin, rmax, n, q, mu): r"""Return parameters required for FFTLog.""" # Central point log10(r_c) of periodic interval logrc = (rmin + rmax)/2 # Central index (1/2 integral if n is even) nc = (n + 1)/2. # Log spacing of points dlogr = (rmax - rmin)/n dlnr = dlogr*np.log(10.) ...
[ "def", "fhti", "(", "rmin", ",", "rmax", ",", "n", ",", "q", ",", "mu", ")", ":", "r", "logrc", "=", "(", "rmin", "+", "rmax", ")", "/", "2", "nc", "=", "(", "n", "+", "1", ")", "/", "2.", "dlogr", "=", "(", "rmax", "-", "rmin", ")", "/...
r"""Return parameters required for FFTLog.
[ "r", "Return", "parameters", "required", "for", "FFTLog", "." ]
4a78ca4191ed4b4d42d019ce715a9a3889dba1bc
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L1219-L1249
train
workhorsy/py-cpuinfo
cpuinfo/cpuinfo.py
_actual_get_cpu_info_from_cpuid
def _actual_get_cpu_info_from_cpuid(queue): ''' Warning! This function has the potential to crash the Python runtime. Do not call it directly. Use the _get_cpu_info_from_cpuid function instead. It will safely call this function in another process. ''' # Pipe all output to nothing sys.stdout = open(os.devnull, '...
python
def _actual_get_cpu_info_from_cpuid(queue): ''' Warning! This function has the potential to crash the Python runtime. Do not call it directly. Use the _get_cpu_info_from_cpuid function instead. It will safely call this function in another process. ''' # Pipe all output to nothing sys.stdout = open(os.devnull, '...
[ "def", "_actual_get_cpu_info_from_cpuid", "(", "queue", ")", ":", "sys", ".", "stdout", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "sys", ".", "stderr", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "arch", ",", "bits", "=", ...
Warning! This function has the potential to crash the Python runtime. Do not call it directly. Use the _get_cpu_info_from_cpuid function instead. It will safely call this function in another process.
[ "Warning!", "This", "function", "has", "the", "potential", "to", "crash", "the", "Python", "runtime", ".", "Do", "not", "call", "it", "directly", ".", "Use", "the", "_get_cpu_info_from_cpuid", "function", "instead", ".", "It", "will", "safely", "call", "this",...
c15afb770c1139bf76215852e17eb4f677ca3d2f
https://github.com/workhorsy/py-cpuinfo/blob/c15afb770c1139bf76215852e17eb4f677ca3d2f/cpuinfo/cpuinfo.py#L1294-L1356
train
workhorsy/py-cpuinfo
cpuinfo/cpuinfo.py
get_cpu_info_json
def get_cpu_info_json(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a json string ''' import json output = None # If running under pyinstaller, run normally if getattr(sys, 'frozen', False): info = _get_cpu_info_internal() output = json.dumps(info...
python
def get_cpu_info_json(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a json string ''' import json output = None # If running under pyinstaller, run normally if getattr(sys, 'frozen', False): info = _get_cpu_info_internal() output = json.dumps(info...
[ "def", "get_cpu_info_json", "(", ")", ":", "import", "json", "output", "=", "None", "if", "getattr", "(", "sys", ",", "'frozen'", ",", "False", ")", ":", "info", "=", "_get_cpu_info_internal", "(", ")", "output", "=", "json", ".", "dumps", "(", "info", ...
Returns the CPU info by using the best sources of information for your OS. Returns the result in a json string
[ "Returns", "the", "CPU", "info", "by", "using", "the", "best", "sources", "of", "information", "for", "your", "OS", ".", "Returns", "the", "result", "in", "a", "json", "string" ]
c15afb770c1139bf76215852e17eb4f677ca3d2f
https://github.com/workhorsy/py-cpuinfo/blob/c15afb770c1139bf76215852e17eb4f677ca3d2f/cpuinfo/cpuinfo.py#L2275-L2306
train
workhorsy/py-cpuinfo
cpuinfo/cpuinfo.py
get_cpu_info
def get_cpu_info(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a dict ''' import json output = get_cpu_info_json() # Convert JSON to Python with non unicode strings output = json.loads(output, object_hook = _utf_to_str) return output
python
def get_cpu_info(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a dict ''' import json output = get_cpu_info_json() # Convert JSON to Python with non unicode strings output = json.loads(output, object_hook = _utf_to_str) return output
[ "def", "get_cpu_info", "(", ")", ":", "import", "json", "output", "=", "get_cpu_info_json", "(", ")", "output", "=", "json", ".", "loads", "(", "output", ",", "object_hook", "=", "_utf_to_str", ")", "return", "output" ]
Returns the CPU info by using the best sources of information for your OS. Returns the result in a dict
[ "Returns", "the", "CPU", "info", "by", "using", "the", "best", "sources", "of", "information", "for", "your", "OS", ".", "Returns", "the", "result", "in", "a", "dict" ]
c15afb770c1139bf76215852e17eb4f677ca3d2f
https://github.com/workhorsy/py-cpuinfo/blob/c15afb770c1139bf76215852e17eb4f677ca3d2f/cpuinfo/cpuinfo.py#L2308-L2321
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qmangle/qmangle/__init__.py
_verbs_with_subjects
def _verbs_with_subjects(doc): """Given a spacy document return the verbs that have subjects""" # TODO: UNUSED verb_subj = [] for possible_subject in doc: if (possible_subject.dep_ == 'nsubj' and possible_subject.head.pos_ == 'VERB'): verb_subj.append([possible_subjec...
python
def _verbs_with_subjects(doc): """Given a spacy document return the verbs that have subjects""" # TODO: UNUSED verb_subj = [] for possible_subject in doc: if (possible_subject.dep_ == 'nsubj' and possible_subject.head.pos_ == 'VERB'): verb_subj.append([possible_subjec...
[ "def", "_verbs_with_subjects", "(", "doc", ")", ":", "verb_subj", "=", "[", "]", "for", "possible_subject", "in", "doc", ":", "if", "(", "possible_subject", ".", "dep_", "==", "'nsubj'", "and", "possible_subject", ".", "head", ".", "pos_", "==", "'VERB'", ...
Given a spacy document return the verbs that have subjects
[ "Given", "a", "spacy", "document", "return", "the", "verbs", "that", "have", "subjects" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qmangle/qmangle/__init__.py#L19-L27
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qmangle/qmangle/__init__.py
mangle_agreement
def mangle_agreement(correct_sentence): """Given a correct sentence, return a sentence or sentences with a subject verb agreement error""" # # Examples # # Back in the 1800s, people were much shorter and much stronger. # This sentence begins with the introductory phrase, 'back in the 1800s' ...
python
def mangle_agreement(correct_sentence): """Given a correct sentence, return a sentence or sentences with a subject verb agreement error""" # # Examples # # Back in the 1800s, people were much shorter and much stronger. # This sentence begins with the introductory phrase, 'back in the 1800s' ...
[ "def", "mangle_agreement", "(", "correct_sentence", ")", ":", "bad_sents", "=", "[", "]", "doc", "=", "nlp", "(", "correct_sentence", ")", "verbs", "=", "[", "(", "i", ",", "v", ")", "for", "(", "i", ",", "v", ")", "in", "enumerate", "(", "doc", ")...
Given a correct sentence, return a sentence or sentences with a subject verb agreement error
[ "Given", "a", "correct", "sentence", "return", "a", "sentence", "or", "sentences", "with", "a", "subject", "verb", "agreement", "error" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qmangle/qmangle/__init__.py#L83-L133
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/__init__.py
_build_trigram_indices
def _build_trigram_indices(trigram_index): """Build a dictionary of trigrams and their indices from a csv""" result = {} trigram_count = 0 for key, val in csv.reader(open(trigram_index)): result[key] = int(val) trigram_count += 1 return result, trigram_count
python
def _build_trigram_indices(trigram_index): """Build a dictionary of trigrams and their indices from a csv""" result = {} trigram_count = 0 for key, val in csv.reader(open(trigram_index)): result[key] = int(val) trigram_count += 1 return result, trigram_count
[ "def", "_build_trigram_indices", "(", "trigram_index", ")", ":", "result", "=", "{", "}", "trigram_count", "=", "0", "for", "key", ",", "val", "in", "csv", ".", "reader", "(", "open", "(", "trigram_index", ")", ")", ":", "result", "[", "key", "]", "=",...
Build a dictionary of trigrams and their indices from a csv
[ "Build", "a", "dictionary", "of", "trigrams", "and", "their", "indices", "from", "a", "csv" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/__init__.py#L48-L55
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/__init__.py
_begins_with_one_of
def _begins_with_one_of(sentence, parts_of_speech): """Return True if the sentence or fragment begins with one of the parts of speech in the list, else False""" doc = nlp(sentence) if doc[0].tag_ in parts_of_speech: return True return False
python
def _begins_with_one_of(sentence, parts_of_speech): """Return True if the sentence or fragment begins with one of the parts of speech in the list, else False""" doc = nlp(sentence) if doc[0].tag_ in parts_of_speech: return True return False
[ "def", "_begins_with_one_of", "(", "sentence", ",", "parts_of_speech", ")", ":", "doc", "=", "nlp", "(", "sentence", ")", "if", "doc", "[", "0", "]", ".", "tag_", "in", "parts_of_speech", ":", "return", "True", "return", "False" ]
Return True if the sentence or fragment begins with one of the parts of speech in the list, else False
[ "Return", "True", "if", "the", "sentence", "or", "fragment", "begins", "with", "one", "of", "the", "parts", "of", "speech", "in", "the", "list", "else", "False" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/__init__.py#L102-L108
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/__init__.py
get_language_tool_feedback
def get_language_tool_feedback(sentence): """Get matches from languagetool""" payload = {'language':'en-US', 'text':sentence} try: r = requests.post(LT_SERVER, data=payload) except requests.exceptions.ConnectionError as e: raise requests.exceptions.ConnectionError('''The languagetool ser...
python
def get_language_tool_feedback(sentence): """Get matches from languagetool""" payload = {'language':'en-US', 'text':sentence} try: r = requests.post(LT_SERVER, data=payload) except requests.exceptions.ConnectionError as e: raise requests.exceptions.ConnectionError('''The languagetool ser...
[ "def", "get_language_tool_feedback", "(", "sentence", ")", ":", "payload", "=", "{", "'language'", ":", "'en-US'", ",", "'text'", ":", "sentence", "}", "try", ":", "r", "=", "requests", ".", "post", "(", "LT_SERVER", ",", "data", "=", "payload", ")", "ex...
Get matches from languagetool
[ "Get", "matches", "from", "languagetool" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/__init__.py#L134-L144
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/__init__.py
is_participle_clause_fragment
def is_participle_clause_fragment(sentence): """Supply a sentence or fragment and recieve a confidence interval""" # short circuit if sentence or fragment doesn't start with a participle # past participles can sometimes look like adjectives -- ie, Tired if not _begins_with_one_of(sentence, ['VBG', 'VBN'...
python
def is_participle_clause_fragment(sentence): """Supply a sentence or fragment and recieve a confidence interval""" # short circuit if sentence or fragment doesn't start with a participle # past participles can sometimes look like adjectives -- ie, Tired if not _begins_with_one_of(sentence, ['VBG', 'VBN'...
[ "def", "is_participle_clause_fragment", "(", "sentence", ")", ":", "if", "not", "_begins_with_one_of", "(", "sentence", ",", "[", "'VBG'", ",", "'VBN'", ",", "'JJ'", "]", ")", ":", "return", "0.0", "if", "_begins_with_one_of", "(", "sentence", ",", "[", "'JJ...
Supply a sentence or fragment and recieve a confidence interval
[ "Supply", "a", "sentence", "or", "fragment", "and", "recieve", "a", "confidence", "interval" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/__init__.py#L147-L178
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/__init__.py
check
def check(sentence): """Supply a sentence or fragment and recieve feedback""" # How we decide what to put as the human readable feedback # # Our order of prefence is, # # 1. Spelling errors. # - A spelling error can change the sentence meaning # 2. Subject-verb agreement errors # ...
python
def check(sentence): """Supply a sentence or fragment and recieve feedback""" # How we decide what to put as the human readable feedback # # Our order of prefence is, # # 1. Spelling errors. # - A spelling error can change the sentence meaning # 2. Subject-verb agreement errors # ...
[ "def", "check", "(", "sentence", ")", ":", "result", "=", "Feedback", "(", ")", "is_missing_verb", "=", "detect_missing_verb", "(", "sentence", ")", "is_infinitive", "=", "detect_infinitive_phrase", "(", "sentence", ")", "is_participle", "=", "is_participle_clause_f...
Supply a sentence or fragment and recieve feedback
[ "Supply", "a", "sentence", "or", "fragment", "and", "recieve", "feedback" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/__init__.py#L181-L246
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/examples/porcupine/app.py
list_submissions
def list_submissions(): """List the past submissions with information about them""" submissions = [] try: submissions = session.query(Submission).all() except SQLAlchemyError as e: session.rollback() return render_template('list_submissions.html', submissions=submissions)
python
def list_submissions(): """List the past submissions with information about them""" submissions = [] try: submissions = session.query(Submission).all() except SQLAlchemyError as e: session.rollback() return render_template('list_submissions.html', submissions=submissions)
[ "def", "list_submissions", "(", ")", ":", "submissions", "=", "[", "]", "try", ":", "submissions", "=", "session", ".", "query", "(", "Submission", ")", ".", "all", "(", ")", "except", "SQLAlchemyError", "as", "e", ":", "session", ".", "rollback", "(", ...
List the past submissions with information about them
[ "List", "the", "past", "submissions", "with", "information", "about", "them" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/examples/porcupine/app.py#L49-L56
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/examples/porcupine/app.py
get_submissions
def get_submissions(): """API endpoint to get submissions in JSON format""" print(request.args.to_dict()) print(request.args.get('search[value]')) print(request.args.get('draw', 1)) # submissions = session.query(Submission).all() if request.args.get('correct_filter', 'all') == 'all': co...
python
def get_submissions(): """API endpoint to get submissions in JSON format""" print(request.args.to_dict()) print(request.args.get('search[value]')) print(request.args.get('draw', 1)) # submissions = session.query(Submission).all() if request.args.get('correct_filter', 'all') == 'all': co...
[ "def", "get_submissions", "(", ")", ":", "print", "(", "request", ".", "args", ".", "to_dict", "(", ")", ")", "print", "(", "request", ".", "args", ".", "get", "(", "'search[value]'", ")", ")", "print", "(", "request", ".", "args", ".", "get", "(", ...
API endpoint to get submissions in JSON format
[ "API", "endpoint", "to", "get", "submissions", "in", "JSON", "format" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/examples/porcupine/app.py#L59-L102
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/examples/porcupine/app.py
check_sentence
def check_sentence(): """Sole porcupine endpoint""" text = '' if request.method == 'POST': text = request.form['text'] if not text: error = 'No input' flash_message = error else: fb = check(request.form['text']) correct = False ...
python
def check_sentence(): """Sole porcupine endpoint""" text = '' if request.method == 'POST': text = request.form['text'] if not text: error = 'No input' flash_message = error else: fb = check(request.form['text']) correct = False ...
[ "def", "check_sentence", "(", ")", ":", "text", "=", "''", "if", "request", ".", "method", "==", "'POST'", ":", "text", "=", "request", ".", "form", "[", "'text'", "]", "if", "not", "text", ":", "error", "=", "'No input'", "flash_message", "=", "error"...
Sole porcupine endpoint
[ "Sole", "porcupine", "endpoint" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/examples/porcupine/app.py#L106-L131
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva_rb2.py
raise_double_modal_error
def raise_double_modal_error(verb_phrase_doc): """A modal auxilary verb should not follow another modal auxilary verb""" prev_word = None for word in verb_phrase: if word.tag_ == 'MD' and prev_word.tag == 'MD': raise('DoubleModalError') prev_word = word
python
def raise_double_modal_error(verb_phrase_doc): """A modal auxilary verb should not follow another modal auxilary verb""" prev_word = None for word in verb_phrase: if word.tag_ == 'MD' and prev_word.tag == 'MD': raise('DoubleModalError') prev_word = word
[ "def", "raise_double_modal_error", "(", "verb_phrase_doc", ")", ":", "prev_word", "=", "None", "for", "word", "in", "verb_phrase", ":", "if", "word", ".", "tag_", "==", "'MD'", "and", "prev_word", ".", "tag", "==", "'MD'", ":", "raise", "(", "'DoubleModalErr...
A modal auxilary verb should not follow another modal auxilary verb
[ "A", "modal", "auxilary", "verb", "should", "not", "follow", "another", "modal", "auxilary", "verb" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva_rb2.py#L97-L103
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva_rb2.py
raise_modal_error
def raise_modal_error(verb_phrase_doc): """Given a verb phrase, raise an error if the modal auxilary has an issue with it""" verb_phrase = verb_phrase_doc.text.lower() bad_strings = ['should had', 'should has', 'could had', 'could has', 'would ' 'had', 'would has'] ["should", "could", "would...
python
def raise_modal_error(verb_phrase_doc): """Given a verb phrase, raise an error if the modal auxilary has an issue with it""" verb_phrase = verb_phrase_doc.text.lower() bad_strings = ['should had', 'should has', 'could had', 'could has', 'would ' 'had', 'would has'] ["should", "could", "would...
[ "def", "raise_modal_error", "(", "verb_phrase_doc", ")", ":", "verb_phrase", "=", "verb_phrase_doc", ".", "text", ".", "lower", "(", ")", "bad_strings", "=", "[", "'should had'", ",", "'should has'", ",", "'could had'", ",", "'could has'", ",", "'would '", "'had...
Given a verb phrase, raise an error if the modal auxilary has an issue with it
[ "Given", "a", "verb", "phrase", "raise", "an", "error", "if", "the", "modal", "auxilary", "has", "an", "issue", "with", "it" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva_rb2.py#L106-L114
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva_rb2.py
split_infinitive_warning
def split_infinitive_warning(sentence_str): """Return a warning for a split infinitive, else, None""" sent_doc = textacy.Doc(sentence_str, lang='en_core_web_lg') inf_pattern = r'<PART><ADV><VERB>' # To aux/auxpass* csubj infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern) for inf ...
python
def split_infinitive_warning(sentence_str): """Return a warning for a split infinitive, else, None""" sent_doc = textacy.Doc(sentence_str, lang='en_core_web_lg') inf_pattern = r'<PART><ADV><VERB>' # To aux/auxpass* csubj infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern) for inf ...
[ "def", "split_infinitive_warning", "(", "sentence_str", ")", ":", "sent_doc", "=", "textacy", ".", "Doc", "(", "sentence_str", ",", "lang", "=", "'en_core_web_lg'", ")", "inf_pattern", "=", "r'<PART><ADV><VERB>'", "infinitives", "=", "textacy", ".", "extract", "."...
Return a warning for a split infinitive, else, None
[ "Return", "a", "warning", "for", "a", "split", "infinitive", "else", "None" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva_rb2.py#L234-L244
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva_rb2.py
raise_infinitive_error
def raise_infinitive_error(sentence_str): """Given a string, check that all infinitives are properly formatted""" sent_doc = textacy.Doc(sentence_str, lang='en_core_web_lg') inf_pattern = r'<PART|ADP><VERB>' # To aux/auxpass* csubj infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern) ...
python
def raise_infinitive_error(sentence_str): """Given a string, check that all infinitives are properly formatted""" sent_doc = textacy.Doc(sentence_str, lang='en_core_web_lg') inf_pattern = r'<PART|ADP><VERB>' # To aux/auxpass* csubj infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern) ...
[ "def", "raise_infinitive_error", "(", "sentence_str", ")", ":", "sent_doc", "=", "textacy", ".", "Doc", "(", "sentence_str", ",", "lang", "=", "'en_core_web_lg'", ")", "inf_pattern", "=", "r'<PART|ADP><VERB>'", "infinitives", "=", "textacy", ".", "extract", ".", ...
Given a string, check that all infinitives are properly formatted
[ "Given", "a", "string", "check", "that", "all", "infinitives", "are", "properly", "formatted" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva_rb2.py#L246-L255
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva_rb2.py
drop_modifiers
def drop_modifiers(sentence_str): """Given a string, drop the modifiers and return a string without them""" tdoc = textacy.Doc(sentence_str, lang='en_core_web_lg') new_sent = tdoc.text unusual_char = '形' for tag in tdoc: if tag.dep_.endswith('mod'): # Replace the tag ...
python
def drop_modifiers(sentence_str): """Given a string, drop the modifiers and return a string without them""" tdoc = textacy.Doc(sentence_str, lang='en_core_web_lg') new_sent = tdoc.text unusual_char = '形' for tag in tdoc: if tag.dep_.endswith('mod'): # Replace the tag ...
[ "def", "drop_modifiers", "(", "sentence_str", ")", ":", "tdoc", "=", "textacy", ".", "Doc", "(", "sentence_str", ",", "lang", "=", "'en_core_web_lg'", ")", "new_sent", "=", "tdoc", ".", "text", "unusual_char", "=", "'形'", "for", "tag", "in", "tdoc", ":", ...
Given a string, drop the modifiers and return a string without them
[ "Given", "a", "string", "drop", "the", "modifiers", "and", "return", "a", "string", "without", "them" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva_rb2.py#L258-L271
train
empirical-org/Quill-NLP-Tools-and-Datasets
quillnlp/cluster.py
cluster
def cluster(list_of_texts, num_clusters=3): """ Cluster a list of texts into a predefined number of clusters. :param list_of_texts: a list of untokenized texts :param num_clusters: the predefined number of clusters :return: a list with the cluster id for each text, e.g. [0,1,0,0,2,2,1] """ ...
python
def cluster(list_of_texts, num_clusters=3): """ Cluster a list of texts into a predefined number of clusters. :param list_of_texts: a list of untokenized texts :param num_clusters: the predefined number of clusters :return: a list with the cluster id for each text, e.g. [0,1,0,0,2,2,1] """ ...
[ "def", "cluster", "(", "list_of_texts", ",", "num_clusters", "=", "3", ")", ":", "pipeline", "=", "Pipeline", "(", "[", "(", "\"vect\"", ",", "CountVectorizer", "(", ")", ")", ",", "(", "\"tfidf\"", ",", "TfidfTransformer", "(", ")", ")", ",", "(", "\"...
Cluster a list of texts into a predefined number of clusters. :param list_of_texts: a list of untokenized texts :param num_clusters: the predefined number of clusters :return: a list with the cluster id for each text, e.g. [0,1,0,0,2,2,1]
[ "Cluster", "a", "list", "of", "texts", "into", "a", "predefined", "number", "of", "clusters", "." ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/quillnlp/cluster.py#L6-L25
train
empirical-org/Quill-NLP-Tools-and-Datasets
quillnlp/topics.py
find_topics
def find_topics(token_lists, num_topics=10): """ Find the topics in a list of texts with Latent Dirichlet Allocation. """ dictionary = Dictionary(token_lists) print('Number of unique words in original documents:', len(dictionary)) dictionary.filter_extremes(no_below=2, no_above=0.7) print('Number o...
python
def find_topics(token_lists, num_topics=10): """ Find the topics in a list of texts with Latent Dirichlet Allocation. """ dictionary = Dictionary(token_lists) print('Number of unique words in original documents:', len(dictionary)) dictionary.filter_extremes(no_below=2, no_above=0.7) print('Number o...
[ "def", "find_topics", "(", "token_lists", ",", "num_topics", "=", "10", ")", ":", "dictionary", "=", "Dictionary", "(", "token_lists", ")", "print", "(", "'Number of unique words in original documents:'", ",", "len", "(", "dictionary", ")", ")", "dictionary", ".",...
Find the topics in a list of texts with Latent Dirichlet Allocation.
[ "Find", "the", "topics", "in", "a", "list", "of", "texts", "with", "Latent", "Dirichlet", "Allocation", "." ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/quillnlp/topics.py#L14-L27
train
empirical-org/Quill-NLP-Tools-and-Datasets
scrapers/gutenfetch/gutenfetch/__init__.py
fetch_bookshelf
def fetch_bookshelf(start_url, output_dir): """Fetch all the books off of a gutenberg project bookshelf page example bookshelf page, http://www.gutenberg.org/wiki/Children%27s_Fiction_(Bookshelf) """ # make output directory try: os.mkdir(OUTPUT_DIR + output_dir) except OSError as e:...
python
def fetch_bookshelf(start_url, output_dir): """Fetch all the books off of a gutenberg project bookshelf page example bookshelf page, http://www.gutenberg.org/wiki/Children%27s_Fiction_(Bookshelf) """ # make output directory try: os.mkdir(OUTPUT_DIR + output_dir) except OSError as e:...
[ "def", "fetch_bookshelf", "(", "start_url", ",", "output_dir", ")", ":", "try", ":", "os", ".", "mkdir", "(", "OUTPUT_DIR", "+", "output_dir", ")", "except", "OSError", "as", "e", ":", "raise", "(", "e", ")", "r", "=", "requests", ".", "get", "(", "s...
Fetch all the books off of a gutenberg project bookshelf page example bookshelf page, http://www.gutenberg.org/wiki/Children%27s_Fiction_(Bookshelf)
[ "Fetch", "all", "the", "books", "off", "of", "a", "gutenberg", "project", "bookshelf", "page" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/scrapers/gutenfetch/gutenfetch/__init__.py#L23-L64
train
empirical-org/Quill-NLP-Tools-and-Datasets
quillnlp/preprocess.py
lemmatize
def lemmatize(text, lowercase=True, remove_stopwords=True): """ Return the lemmas of the tokens in a text. """ doc = nlp(text) if lowercase and remove_stopwords: lemmas = [t.lemma_.lower() for t in doc if not (t.is_stop or t.orth_.lower() in STOPWORDS)] elif lowercase: lemmas = [t.lemma_...
python
def lemmatize(text, lowercase=True, remove_stopwords=True): """ Return the lemmas of the tokens in a text. """ doc = nlp(text) if lowercase and remove_stopwords: lemmas = [t.lemma_.lower() for t in doc if not (t.is_stop or t.orth_.lower() in STOPWORDS)] elif lowercase: lemmas = [t.lemma_...
[ "def", "lemmatize", "(", "text", ",", "lowercase", "=", "True", ",", "remove_stopwords", "=", "True", ")", ":", "doc", "=", "nlp", "(", "text", ")", "if", "lowercase", "and", "remove_stopwords", ":", "lemmas", "=", "[", "t", ".", "lemma_", ".", "lower"...
Return the lemmas of the tokens in a text.
[ "Return", "the", "lemmas", "of", "the", "tokens", "in", "a", "text", "." ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/quillnlp/preprocess.py#L8-L20
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva.py
inflate
def inflate(deflated_vector): """Given a defalated vector, inflate it into a np array and return it""" dv = json.loads(deflated_vector) #result = np.zeros(dv['reductions']) # some claim vector length 5555, others #5530. this could have occurred doing remote computations? or something. # anyhow, we w...
python
def inflate(deflated_vector): """Given a defalated vector, inflate it into a np array and return it""" dv = json.loads(deflated_vector) #result = np.zeros(dv['reductions']) # some claim vector length 5555, others #5530. this could have occurred doing remote computations? or something. # anyhow, we w...
[ "def", "inflate", "(", "deflated_vector", ")", ":", "dv", "=", "json", ".", "loads", "(", "deflated_vector", ")", "result", "=", "np", ".", "zeros", "(", "5555", ")", "for", "n", "in", "dv", "[", "'indices'", "]", ":", "result", "[", "int", "(", "n...
Given a defalated vector, inflate it into a np array and return it
[ "Given", "a", "defalated", "vector", "inflate", "it", "into", "a", "np", "array", "and", "return", "it" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva.py#L25-L35
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/sva.py
text_to_vector
def text_to_vector(sent_str): """Given a string, get it's defalted vector, inflate it, then return the inflated vector""" r = requests.get("{}/sva/vector".format(VECTORIZE_API), params={'s':sent_str}) return inflate(r.text)
python
def text_to_vector(sent_str): """Given a string, get it's defalted vector, inflate it, then return the inflated vector""" r = requests.get("{}/sva/vector".format(VECTORIZE_API), params={'s':sent_str}) return inflate(r.text)
[ "def", "text_to_vector", "(", "sent_str", ")", ":", "r", "=", "requests", ".", "get", "(", "\"{}/sva/vector\"", ".", "format", "(", "VECTORIZE_API", ")", ",", "params", "=", "{", "'s'", ":", "sent_str", "}", ")", "return", "inflate", "(", "r", ".", "te...
Given a string, get it's defalted vector, inflate it, then return the inflated vector
[ "Given", "a", "string", "get", "it", "s", "defalted", "vector", "inflate", "it", "then", "return", "the", "inflated", "vector" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/sva.py#L37-L41
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/infinitive_phrase_detect.py
detect_missing_verb
def detect_missing_verb(sentence): """Return True if the sentence appears to be missing a main verb""" # TODO: should this be relocated? doc = nlp(sentence) for w in doc: if w.tag_.startswith('VB') and w.dep_ == 'ROOT': return False # looks like there is at least 1 main verb retu...
python
def detect_missing_verb(sentence): """Return True if the sentence appears to be missing a main verb""" # TODO: should this be relocated? doc = nlp(sentence) for w in doc: if w.tag_.startswith('VB') and w.dep_ == 'ROOT': return False # looks like there is at least 1 main verb retu...
[ "def", "detect_missing_verb", "(", "sentence", ")", ":", "doc", "=", "nlp", "(", "sentence", ")", "for", "w", "in", "doc", ":", "if", "w", ".", "tag_", ".", "startswith", "(", "'VB'", ")", "and", "w", ".", "dep_", "==", "'ROOT'", ":", "return", "Fa...
Return True if the sentence appears to be missing a main verb
[ "Return", "True", "if", "the", "sentence", "appears", "to", "be", "missing", "a", "main", "verb" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/infinitive_phrase_detect.py#L12-L19
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/qfragment/infinitive_phrase_detect.py
detect_infinitive_phrase
def detect_infinitive_phrase(sentence): """Given a string, return true if it is an infinitive phrase fragment""" # eliminate sentences without to if not 'to' in sentence.lower(): return False doc = nlp(sentence) prev_word = None for w in doc: # if statement will execute exactly...
python
def detect_infinitive_phrase(sentence): """Given a string, return true if it is an infinitive phrase fragment""" # eliminate sentences without to if not 'to' in sentence.lower(): return False doc = nlp(sentence) prev_word = None for w in doc: # if statement will execute exactly...
[ "def", "detect_infinitive_phrase", "(", "sentence", ")", ":", "if", "not", "'to'", "in", "sentence", ".", "lower", "(", ")", ":", "return", "False", "doc", "=", "nlp", "(", "sentence", ")", "prev_word", "=", "None", "for", "w", "in", "doc", ":", "if", ...
Given a string, return true if it is an infinitive phrase fragment
[ "Given", "a", "string", "return", "true", "if", "it", "is", "an", "infinitive", "phrase", "fragment" ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/qfragment/infinitive_phrase_detect.py#L21-L37
train
empirical-org/Quill-NLP-Tools-and-Datasets
quillnlp/srl.py
perform_srl
def perform_srl(responses, prompt): """ Perform semantic role labeling on a list of responses, given a prompt.""" predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2018.05.25.tar.gz") sentences = [{"sentence": prompt + " " + response} for response in responses] ...
python
def perform_srl(responses, prompt): """ Perform semantic role labeling on a list of responses, given a prompt.""" predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2018.05.25.tar.gz") sentences = [{"sentence": prompt + " " + response} for response in responses] ...
[ "def", "perform_srl", "(", "responses", ",", "prompt", ")", ":", "predictor", "=", "Predictor", ".", "from_path", "(", "\"https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2018.05.25.tar.gz\"", ")", "sentences", "=", "[", "{", "\"sentence\"", ":", "prompt", "...
Perform semantic role labeling on a list of responses, given a prompt.
[ "Perform", "semantic", "role", "labeling", "on", "a", "list", "of", "responses", "given", "a", "prompt", "." ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/quillnlp/srl.py#L4-L16
train
empirical-org/Quill-NLP-Tools-and-Datasets
quillnlp/utils.py
detokenize
def detokenize(s): """ Detokenize a string by removing spaces before punctuation.""" print(s) s = re.sub("\s+([;:,\.\?!])", "\\1", s) s = re.sub("\s+(n't)", "\\1", s) return s
python
def detokenize(s): """ Detokenize a string by removing spaces before punctuation.""" print(s) s = re.sub("\s+([;:,\.\?!])", "\\1", s) s = re.sub("\s+(n't)", "\\1", s) return s
[ "def", "detokenize", "(", "s", ")", ":", "print", "(", "s", ")", "s", "=", "re", ".", "sub", "(", "\"\\s+([;:,\\.\\?!])\"", ",", "\"\\\\1\"", ",", "s", ")", "s", "=", "re", ".", "sub", "(", "\"\\s+(n't)\"", ",", "\"\\\\1\"", ",", "s", ")", "return"...
Detokenize a string by removing spaces before punctuation.
[ "Detokenize", "a", "string", "by", "removing", "spaces", "before", "punctuation", "." ]
f2ff579ddf3a556d9cdc47c5f702422fa06863d9
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/quillnlp/utils.py#L4-L9
train
ejeschke/ginga
ginga/misc/Task.py
Task.start
def start(self): """This method starts a task executing and returns immediately. Subclass should override this method, if it has an asynchronous way to start the task and return immediately. """ if self.threadPool: self.threadPool.addTask(self) # Lets oth...
python
def start(self): """This method starts a task executing and returns immediately. Subclass should override this method, if it has an asynchronous way to start the task and return immediately. """ if self.threadPool: self.threadPool.addTask(self) # Lets oth...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "threadPool", ":", "self", ".", "threadPool", ".", "addTask", "(", "self", ")", "time", ".", "sleep", "(", "0", ")", "else", ":", "raise", "TaskError", "(", "\"start(): nothing to start for task %s\...
This method starts a task executing and returns immediately. Subclass should override this method, if it has an asynchronous way to start the task and return immediately.
[ "This", "method", "starts", "a", "task", "executing", "and", "returns", "immediately", ".", "Subclass", "should", "override", "this", "method", "if", "it", "has", "an", "asynchronous", "way", "to", "start", "the", "task", "and", "return", "immediately", "." ]
a78c893ec6f37a837de851947e9bb4625c597915
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/Task.py#L114-L125
train