repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
pip-services3-python/pip-services3-components-python
pip_services3_components/log/CompositeLogger.py
CompositeLogger.set_references
def set_references(self, references): """ Sets references to dependent components. :param references: references to locate the component dependencies. """ super(CompositeLogger, self).set_references(references) # descriptor = Descriptor(None, "logger", None, None, None) ...
python
def set_references(self, references): """ Sets references to dependent components. :param references: references to locate the component dependencies. """ super(CompositeLogger, self).set_references(references) # descriptor = Descriptor(None, "logger", None, None, None) ...
[ "def", "set_references", "(", "self", ",", "references", ")", ":", "super", "(", "CompositeLogger", ",", "self", ")", ".", "set_references", "(", "references", ")", "# descriptor = Descriptor(None, \"logger\", None, None, None)", "loggers", "=", "references", ".", "ge...
Sets references to dependent components. :param references: references to locate the component dependencies.
[ "Sets", "references", "to", "dependent", "components", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/CompositeLogger.py#L54-L65
pip-services3-python/pip-services3-components-python
pip_services3_components/log/CompositeLogger.py
CompositeLogger._write
def _write(self, level, correlation_id, error, message): """ Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this me...
python
def _write(self, level, correlation_id, error, message): """ Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this me...
[ "def", "_write", "(", "self", ",", "level", ",", "correlation_id", ",", "error", ",", "message", ")", ":", "for", "logger", "in", "self", ".", "_loggers", ":", "logger", ".", "log", "(", "level", ",", "correlation_id", ",", "error", ",", "message", ")"...
Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to log.
[ "Writes", "a", "log", "message", "to", "the", "logger", "destination", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/CompositeLogger.py#L67-L80
etcher-be/emiz
emiz/avwx/remarks.py
_tdec
def _tdec(code: str, unit: str = 'C') -> str: """ Translates a 4-digit decimal temperature representation Ex: 1045 -> -4.5°C 0237 -> 23.7°C """ ret = f"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}" if unit: ret += f'°{unit}' return ret
python
def _tdec(code: str, unit: str = 'C') -> str: """ Translates a 4-digit decimal temperature representation Ex: 1045 -> -4.5°C 0237 -> 23.7°C """ ret = f"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}" if unit: ret += f'°{unit}' return ret
[ "def", "_tdec", "(", "code", ":", "str", ",", "unit", ":", "str", "=", "'C'", ")", "->", "str", ":", "ret", "=", "f\"{'-' if code[0] == '1' else ''}{int(code[1:3])}.{code[3]}\"", "if", "unit", ":", "ret", "+=", "f'°{unit}'", "return", "ret" ]
Translates a 4-digit decimal temperature representation Ex: 1045 -> -4.5°C 0237 -> 23.7°C
[ "Translates", "a", "4", "-", "digit", "decimal", "temperature", "representation" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L11-L20
etcher-be/emiz
emiz/avwx/remarks.py
pressure_tendency
def pressure_tendency(code: str, unit: str = 'mb') -> str: """ Translates a 5-digit pressure outlook code Ex: 50123 -> 12.3 mb: Increasing, then decreasing """ width, precision = int(code[2:4]), code[4] return ('3-hour pressure difference: +/- ' f'{width}.{precision} {unit} - {PRESS...
python
def pressure_tendency(code: str, unit: str = 'mb') -> str: """ Translates a 5-digit pressure outlook code Ex: 50123 -> 12.3 mb: Increasing, then decreasing """ width, precision = int(code[2:4]), code[4] return ('3-hour pressure difference: +/- ' f'{width}.{precision} {unit} - {PRESS...
[ "def", "pressure_tendency", "(", "code", ":", "str", ",", "unit", ":", "str", "=", "'mb'", ")", "->", "str", ":", "width", ",", "precision", "=", "int", "(", "code", "[", "2", ":", "4", "]", ")", ",", "code", "[", "4", "]", "return", "(", "'3-h...
Translates a 5-digit pressure outlook code Ex: 50123 -> 12.3 mb: Increasing, then decreasing
[ "Translates", "a", "5", "-", "digit", "pressure", "outlook", "code" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L31-L39
etcher-be/emiz
emiz/avwx/remarks.py
parse
def parse(rmk: str) -> RemarksData: """ Finds temperature and dewpoint decimal values from the remarks """ rmkdata = {} for item in rmk.split(' '): if len(item) in [5, 9] and item[0] == 'T' and item[1:].isdigit(): rmkdata['temperature_decimal'] = core.make_number(_tdec(item[1:5],...
python
def parse(rmk: str) -> RemarksData: """ Finds temperature and dewpoint decimal values from the remarks """ rmkdata = {} for item in rmk.split(' '): if len(item) in [5, 9] and item[0] == 'T' and item[1:].isdigit(): rmkdata['temperature_decimal'] = core.make_number(_tdec(item[1:5],...
[ "def", "parse", "(", "rmk", ":", "str", ")", "->", "RemarksData", ":", "rmkdata", "=", "{", "}", "for", "item", "in", "rmk", ".", "split", "(", "' '", ")", ":", "if", "len", "(", "item", ")", "in", "[", "5", ",", "9", "]", "and", "item", "[",...
Finds temperature and dewpoint decimal values from the remarks
[ "Finds", "temperature", "and", "dewpoint", "decimal", "values", "from", "the", "remarks" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L74-L83
etcher-be/emiz
emiz/avwx/remarks.py
translate
def translate(remarks: str) -> typing.Dict[str, str]: # noqa """ Translates elements in the remarks string """ ret = {} # Add and replace static multi-word elements for key in REMARKS_GROUPS: if key in remarks: ret[key.strip()] = REMARKS_GROUPS[key] remarks.repla...
python
def translate(remarks: str) -> typing.Dict[str, str]: # noqa """ Translates elements in the remarks string """ ret = {} # Add and replace static multi-word elements for key in REMARKS_GROUPS: if key in remarks: ret[key.strip()] = REMARKS_GROUPS[key] remarks.repla...
[ "def", "translate", "(", "remarks", ":", "str", ")", "->", "typing", ".", "Dict", "[", "str", ",", "str", "]", ":", "# noqa", "ret", "=", "{", "}", "# Add and replace static multi-word elements", "for", "key", "in", "REMARKS_GROUPS", ":", "if", "key", "in"...
Translates elements in the remarks string
[ "Translates", "elements", "in", "the", "remarks", "string" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/remarks.py#L86-L123
sahilchinoy/django-irs-filings
irs/management/commands/loadIRS.py
RowParser.clean_cell
def clean_cell(self, cell, cell_type): """ Uses the type of field (from the mapping) to determine how to clean and format the cell. """ try: # Get rid of non-ASCII characters cell = cell.encode('ascii', 'ignore').decode() if cell_type == 'D': ...
python
def clean_cell(self, cell, cell_type): """ Uses the type of field (from the mapping) to determine how to clean and format the cell. """ try: # Get rid of non-ASCII characters cell = cell.encode('ascii', 'ignore').decode() if cell_type == 'D': ...
[ "def", "clean_cell", "(", "self", ",", "cell", ",", "cell_type", ")", ":", "try", ":", "# Get rid of non-ASCII characters", "cell", "=", "cell", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", ")", "if", "cell_type", "==", "'D'", ...
Uses the type of field (from the mapping) to determine how to clean and format the cell.
[ "Uses", "the", "type", "of", "field", "(", "from", "the", "mapping", ")", "to", "determine", "how", "to", "clean", "and", "format", "the", "cell", "." ]
train
https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L50-L76
sahilchinoy/django-irs-filings
irs/management/commands/loadIRS.py
RowParser.parse_row
def parse_row(self): """ Parses a row, cell-by-cell, returning a dict of field names to the cleaned field values. """ fields = self.mapping for i, cell in enumerate(self.row[0:len(fields)]): field_name, field_type = fields[str(i)] parsed_cell = sel...
python
def parse_row(self): """ Parses a row, cell-by-cell, returning a dict of field names to the cleaned field values. """ fields = self.mapping for i, cell in enumerate(self.row[0:len(fields)]): field_name, field_type = fields[str(i)] parsed_cell = sel...
[ "def", "parse_row", "(", "self", ")", ":", "fields", "=", "self", ".", "mapping", "for", "i", ",", "cell", "in", "enumerate", "(", "self", ".", "row", "[", "0", ":", "len", "(", "fields", ")", "]", ")", ":", "field_name", ",", "field_type", "=", ...
Parses a row, cell-by-cell, returning a dict of field names to the cleaned field values.
[ "Parses", "a", "row", "cell", "-", "by", "-", "cell", "returning", "a", "dict", "of", "field", "names", "to", "the", "cleaned", "field", "values", "." ]
train
https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L78-L87
sahilchinoy/django-irs-filings
irs/management/commands/loadIRS.py
Command.build_mappings
def build_mappings(self): """ Uses CSV files of field names and positions for different filing types to load mappings into memory, for use in parsing different types of rows. """ self.mappings = {} for record_type in ('sa', 'sb', 'F8872'): path = os.pa...
python
def build_mappings(self): """ Uses CSV files of field names and positions for different filing types to load mappings into memory, for use in parsing different types of rows. """ self.mappings = {} for record_type in ('sa', 'sb', 'F8872'): path = os.pa...
[ "def", "build_mappings", "(", "self", ")", ":", "self", ".", "mappings", "=", "{", "}", "for", "record_type", "in", "(", "'sa'", ",", "'sb'", ",", "'F8872'", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dir...
Uses CSV files of field names and positions for different filing types to load mappings into memory, for use in parsing different types of rows.
[ "Uses", "CSV", "files", "of", "field", "names", "and", "positions", "for", "different", "filing", "types", "to", "load", "mappings", "into", "memory", "for", "use", "in", "parsing", "different", "types", "of", "rows", "." ]
train
https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/loadIRS.py#L244-L266
jic-dtool/dtool-info
dtool_info/dataset.py
diff
def diff(full, dataset_uri, reference_dataset_uri): """Report the difference between two datasets. 1. Checks that the identifiers are identicial 2. Checks that the sizes are identical 3. Checks that the hashes are identical, if the '--full' option is used If a differences is detected in step 1, st...
python
def diff(full, dataset_uri, reference_dataset_uri): """Report the difference between two datasets. 1. Checks that the identifiers are identicial 2. Checks that the sizes are identical 3. Checks that the hashes are identical, if the '--full' option is used If a differences is detected in step 1, st...
[ "def", "diff", "(", "full", ",", "dataset_uri", ",", "reference_dataset_uri", ")", ":", "def", "echo_header", "(", "desc", ",", "ds_name", ",", "ref_ds_name", ",", "prop", ")", ":", "click", ".", "secho", "(", "\"Different {}\"", ".", "format", "(", "desc"...
Report the difference between two datasets. 1. Checks that the identifiers are identicial 2. Checks that the sizes are identical 3. Checks that the hashes are identical, if the '--full' option is used If a differences is detected in step 1, steps 2 and 3 will not be carried out. Similarly if a dif...
[ "Report", "the", "difference", "between", "two", "datasets", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L38-L90
jic-dtool/dtool-info
dtool_info/dataset.py
ls
def ls(quiet, verbose, uri): """List datasets / items in a dataset. If the URI is a dataset the items in the dataset will be listed. It is not possible to list the items in a proto dataset. If the URI is a location containing datasets the datasets will be listed. Proto datasets are highlighted in ...
python
def ls(quiet, verbose, uri): """List datasets / items in a dataset. If the URI is a dataset the items in the dataset will be listed. It is not possible to list the items in a proto dataset. If the URI is a location containing datasets the datasets will be listed. Proto datasets are highlighted in ...
[ "def", "ls", "(", "quiet", ",", "verbose", ",", "uri", ")", ":", "if", "dtoolcore", ".", "_is_dataset", "(", "uri", ",", "CONFIG_PATH", ")", ":", "_list_dataset_items", "(", "uri", ",", "quiet", ",", "verbose", ")", "else", ":", "_list_datasets", "(", ...
List datasets / items in a dataset. If the URI is a dataset the items in the dataset will be listed. It is not possible to list the items in a proto dataset. If the URI is a location containing datasets the datasets will be listed. Proto datasets are highlighted in red.
[ "List", "datasets", "/", "items", "in", "a", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L161-L173
jic-dtool/dtool-info
dtool_info/dataset.py
identifiers
def identifiers(dataset_uri): """List the item identifiers in the dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) for i in dataset.identifiers: click.secho(i)
python
def identifiers(dataset_uri): """List the item identifiers in the dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) for i in dataset.identifiers: click.secho(i)
[ "def", "identifiers", "(", "dataset_uri", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "for", "i", "in", "dataset", ".", "identifiers", ":", "click", ".", "secho", "(", "i", ")" ]
List the item identifiers in the dataset.
[ "List", "the", "item", "identifiers", "in", "the", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L178-L182
jic-dtool/dtool-info
dtool_info/dataset.py
summary
def summary(dataset_uri, format): """Report summary information about a dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) creator_username = dataset._admin_metadata["creator_username"] frozen_at = dataset._admin_metadata["frozen_at"] num_items = len(dataset.identifiers) tot_size = su...
python
def summary(dataset_uri, format): """Report summary information about a dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) creator_username = dataset._admin_metadata["creator_username"] frozen_at = dataset._admin_metadata["frozen_at"] num_items = len(dataset.identifiers) tot_size = su...
[ "def", "summary", "(", "dataset_uri", ",", "format", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "creator_username", "=", "dataset", ".", "_admin_metadata", "[", "\"creator_username\"", "]", "frozen_at", "=", ...
Report summary information about a dataset.
[ "Report", "summary", "information", "about", "a", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L193-L231
jic-dtool/dtool-info
dtool_info/dataset.py
properties
def properties(dataset_uri, item_identifier): """Report item properties.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: props = dataset.item_properties(item_identifier) except KeyError: click.secho( "No such item in dataset: {}".format(item_identifier), ...
python
def properties(dataset_uri, item_identifier): """Report item properties.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: props = dataset.item_properties(item_identifier) except KeyError: click.secho( "No such item in dataset: {}".format(item_identifier), ...
[ "def", "properties", "(", "dataset_uri", ",", "item_identifier", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "try", ":", "props", "=", "dataset", ".", "item_properties", "(", "item_identifier", ")", "except"...
Report item properties.
[ "Report", "item", "properties", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L244-L270
jic-dtool/dtool-info
dtool_info/dataset.py
fetch
def fetch(dataset_uri, item_identifier): """Return abspath to file with item content. Fetches the file from remote storage if required. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) click.secho(dataset.item_content_abspath(item_identifier))
python
def fetch(dataset_uri, item_identifier): """Return abspath to file with item content. Fetches the file from remote storage if required. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) click.secho(dataset.item_content_abspath(item_identifier))
[ "def", "fetch", "(", "dataset_uri", ",", "item_identifier", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "click", ".", "secho", "(", "dataset", ".", "item_content_abspath", "(", "item_identifier", ")", ")" ]
Return abspath to file with item content. Fetches the file from remote storage if required.
[ "Return", "abspath", "to", "file", "with", "item", "content", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L276-L282
jic-dtool/dtool-info
dtool_info/dataset.py
overlay
def overlay(overlay_name, dataset_uri, item_identifier): """Return abspath to file with item content. Fetches the file from remote storage if required. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) if overlay_name not in dataset.list_overlay_names(): click.secho( "No suc...
python
def overlay(overlay_name, dataset_uri, item_identifier): """Return abspath to file with item content. Fetches the file from remote storage if required. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) if overlay_name not in dataset.list_overlay_names(): click.secho( "No suc...
[ "def", "overlay", "(", "overlay_name", ",", "dataset_uri", ",", "item_identifier", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "if", "overlay_name", "not", "in", "dataset", ".", "list_overlay_names", "(", ")...
Return abspath to file with item content. Fetches the file from remote storage if required.
[ "Return", "abspath", "to", "file", "with", "item", "content", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L289-L312
jic-dtool/dtool-info
dtool_info/dataset.py
relpath
def relpath(dataset_uri, item_identifier): """Return relpath associated with the item. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: props = dataset.item_properties(item_identifier) except KeyError: click.secho( "No such item in dataset: {}".format(item_ident...
python
def relpath(dataset_uri, item_identifier): """Return relpath associated with the item. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: props = dataset.item_properties(item_identifier) except KeyError: click.secho( "No such item in dataset: {}".format(item_ident...
[ "def", "relpath", "(", "dataset_uri", ",", "item_identifier", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "try", ":", "props", "=", "dataset", ".", "item_properties", "(", "item_identifier", ")", "except", ...
Return relpath associated with the item.
[ "Return", "relpath", "associated", "with", "the", "item", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L318-L331
jic-dtool/dtool-info
dtool_info/dataset.py
verify
def verify(full, dataset_uri): """Verify the integrity of a dataset. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) all_okay = True generated_manifest = dataset.generate_manifest() generated_identifiers = set(generated_manifest["items"].keys()) manifest_identifiers = set(dataset.iden...
python
def verify(full, dataset_uri): """Verify the integrity of a dataset. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) all_okay = True generated_manifest = dataset.generate_manifest() generated_identifiers = set(generated_manifest["items"].keys()) manifest_identifiers = set(dataset.iden...
[ "def", "verify", "(", "full", ",", "dataset_uri", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "all_okay", "=", "True", "generated_manifest", "=", "dataset", ".", "generate_manifest", "(", ")", "generated_ide...
Verify the integrity of a dataset.
[ "Verify", "the", "integrity", "of", "a", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L342-L394
jic-dtool/dtool-info
dtool_info/dataset.py
uuid
def uuid(dataset_uri): """Return the UUID of the dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) click.secho(dataset.uuid)
python
def uuid(dataset_uri): """Return the UUID of the dataset.""" dataset = dtoolcore.DataSet.from_uri(dataset_uri) click.secho(dataset.uuid)
[ "def", "uuid", "(", "dataset_uri", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "click", ".", "secho", "(", "dataset", ".", "uuid", ")" ]
Return the UUID of the dataset.
[ "Return", "the", "UUID", "of", "the", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/dataset.py#L399-L402
phoopy/phoopy-yaml
phoopy/yaml/yaml_parser.py
YamlParser.merge
def merge(self, destination, source): """ run me with nosetests --with-doctest file.py >>> a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } } >>> b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } } >>> merge(a, b) == { 'first' : { 'all_rows' ...
python
def merge(self, destination, source): """ run me with nosetests --with-doctest file.py >>> a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } } >>> b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } } >>> merge(a, b) == { 'first' : { 'all_rows' ...
[ "def", "merge", "(", "self", ",", "destination", ",", "source", ")", ":", "if", "isinstance", "(", "source", ",", "dict", ")", ":", "for", "key", ",", "value", "in", "source", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dic...
run me with nosetests --with-doctest file.py >>> a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } } >>> b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } } >>> merge(a, b) == { 'first' : { 'all_rows' : { 'pass' : 'dog', 'fail' : 'cat', 'number' : '5' } } }
[ "run", "me", "with", "nosetests", "--", "with", "-", "doctest", "file", ".", "py" ]
train
https://github.com/phoopy/phoopy-yaml/blob/573dc2041be8b5b23f4f46464cec595ac71ef5d1/phoopy/yaml/yaml_parser.py#L22-L40
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetBlock.split_data
def split_data(self): """Splits the list of SeqRecordExpanded objects into lists, which are kept into a bigger list. If the file_format is Nexus, then it is only partitioned by gene. If it is FASTA, then it needs partitioning by codon positions if required. Example: ...
python
def split_data(self): """Splits the list of SeqRecordExpanded objects into lists, which are kept into a bigger list. If the file_format is Nexus, then it is only partitioned by gene. If it is FASTA, then it needs partitioning by codon positions if required. Example: ...
[ "def", "split_data", "(", "self", ")", ":", "this_gene_code", "=", "None", "for", "seq_record", "in", "self", ".", "data", ".", "seq_records", ":", "if", "this_gene_code", "is", "None", "or", "this_gene_code", "!=", "seq_record", ".", "gene_code", ":", "this...
Splits the list of SeqRecordExpanded objects into lists, which are kept into a bigger list. If the file_format is Nexus, then it is only partitioned by gene. If it is FASTA, then it needs partitioning by codon positions if required. Example: >>> blocks = [ ... ...
[ "Splits", "the", "list", "of", "SeqRecordExpanded", "objects", "into", "lists", "which", "are", "kept", "into", "a", "bigger", "list", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L61-L84
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetBlock.convert_to_string
def convert_to_string(self, block): """Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code. Override this function if the dataset block needs to be different due to file format. This block will need to be split further if the dataset is FASTA or TNT an...
python
def convert_to_string(self, block): """Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code. Override this function if the dataset block needs to be different due to file format. This block will need to be split further if the dataset is FASTA or TNT an...
[ "def", "convert_to_string", "(", "self", ",", "block", ")", ":", "if", "self", ".", "partitioning", "!=", "'1st-2nd, 3rd'", ":", "return", "self", ".", "make_datablock_by_gene", "(", "block", ")", "else", ":", "if", "self", ".", "format", "==", "'FASTA'", ...
Makes gene_block as str from list of SeqRecordExpanded objects of a gene_code. Override this function if the dataset block needs to be different due to file format. This block will need to be split further if the dataset is FASTA or TNT and the partitioning scheme is 1st-2nd, 3rd. ...
[ "Makes", "gene_block", "as", "str", "from", "list", "of", "SeqRecordExpanded", "objects", "of", "a", "gene_code", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L86-L105
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetBlock.convert_block_dicts_to_string
def convert_block_dicts_to_string(self, block_1st2nd, block_1st, block_2nd, block_3rd): """Takes into account whether we need to output all codon positions.""" out = "" # We need 1st and 2nd positions if self.codon_positions in ['ALL', '1st-2nd']: for gene_code, seqs in block...
python
def convert_block_dicts_to_string(self, block_1st2nd, block_1st, block_2nd, block_3rd): """Takes into account whether we need to output all codon positions.""" out = "" # We need 1st and 2nd positions if self.codon_positions in ['ALL', '1st-2nd']: for gene_code, seqs in block...
[ "def", "convert_block_dicts_to_string", "(", "self", ",", "block_1st2nd", ",", "block_1st", ",", "block_2nd", ",", "block_3rd", ")", ":", "out", "=", "\"\"", "# We need 1st and 2nd positions", "if", "self", ".", "codon_positions", "in", "[", "'ALL'", ",", "'1st-2n...
Takes into account whether we need to output all codon positions.
[ "Takes", "into", "account", "whether", "we", "need", "to", "output", "all", "codon", "positions", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L139-L165
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetFooter.make_charsets
def make_charsets(self): """ Override this function for Phylip dataset as the content is different and goes into a separate file. """ count_start = 1 out = '' for gene_code, lengths in self.data.gene_codes_and_lengths.items(): count_end = lengths[0] + ...
python
def make_charsets(self): """ Override this function for Phylip dataset as the content is different and goes into a separate file. """ count_start = 1 out = '' for gene_code, lengths in self.data.gene_codes_and_lengths.items(): count_end = lengths[0] + ...
[ "def", "make_charsets", "(", "self", ")", ":", "count_start", "=", "1", "out", "=", "''", "for", "gene_code", ",", "lengths", "in", "self", ".", "data", ".", "gene_codes_and_lengths", ".", "items", "(", ")", ":", "count_end", "=", "lengths", "[", "0", ...
Override this function for Phylip dataset as the content is different and goes into a separate file.
[ "Override", "this", "function", "for", "Phylip", "dataset", "as", "the", "content", "is", "different", "and", "goes", "into", "a", "separate", "file", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L308-L319
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetFooter.make_slash_number
def make_slash_number(self): """ Charset lines have \2 or \3 depending on type of partitioning and codon positions requested for our dataset. :return: """ if self.partitioning == 'by codon position' and self.codon_positions == '1st-2nd': return '\\2' ...
python
def make_slash_number(self): """ Charset lines have \2 or \3 depending on type of partitioning and codon positions requested for our dataset. :return: """ if self.partitioning == 'by codon position' and self.codon_positions == '1st-2nd': return '\\2' ...
[ "def", "make_slash_number", "(", "self", ")", ":", "if", "self", ".", "partitioning", "==", "'by codon position'", "and", "self", ".", "codon_positions", "==", "'1st-2nd'", ":", "return", "'\\\\2'", "elif", "self", ".", "partitioning", "in", "[", "'by codon posi...
Charset lines have \2 or \3 depending on type of partitioning and codon positions requested for our dataset. :return:
[ "Charset", "lines", "have", "\\", "2", "or", "\\", "3", "depending", "on", "type", "of", "partitioning", "and", "codon", "positions", "requested", "for", "our", "dataset", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L332-L344
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetFooter.add_suffixes_to_gene_codes
def add_suffixes_to_gene_codes(self): """Appends pos1, pos2, etc to the gene_code if needed.""" out = [] for gene_code in self.data.gene_codes: for sufix in self.make_gene_code_suffixes(): out.append('{0}{1}'.format(gene_code, sufix)) return out
python
def add_suffixes_to_gene_codes(self): """Appends pos1, pos2, etc to the gene_code if needed.""" out = [] for gene_code in self.data.gene_codes: for sufix in self.make_gene_code_suffixes(): out.append('{0}{1}'.format(gene_code, sufix)) return out
[ "def", "add_suffixes_to_gene_codes", "(", "self", ")", ":", "out", "=", "[", "]", "for", "gene_code", "in", "self", ".", "data", ".", "gene_codes", ":", "for", "sufix", "in", "self", ".", "make_gene_code_suffixes", "(", ")", ":", "out", ".", "append", "(...
Appends pos1, pos2, etc to the gene_code if needed.
[ "Appends", "pos1", "pos2", "etc", "to", "the", "gene_code", "if", "needed", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L385-L391
carlosp420/dataset-creator
dataset_creator/base_dataset.py
DatasetFooter.get_outgroup
def get_outgroup(self): """Generates the outgroup line from the voucher code specified by the user. """ if self.outgroup is not None: outgroup_taxonomy = '' for i in self.data.seq_records: if self.outgroup == i.voucher_code: out...
python
def get_outgroup(self): """Generates the outgroup line from the voucher code specified by the user. """ if self.outgroup is not None: outgroup_taxonomy = '' for i in self.data.seq_records: if self.outgroup == i.voucher_code: out...
[ "def", "get_outgroup", "(", "self", ")", ":", "if", "self", ".", "outgroup", "is", "not", "None", ":", "outgroup_taxonomy", "=", "''", "for", "i", "in", "self", ".", "data", ".", "seq_records", ":", "if", "self", ".", "outgroup", "==", "i", ".", "vou...
Generates the outgroup line from the voucher code specified by the user.
[ "Generates", "the", "outgroup", "line", "from", "the", "voucher", "code", "specified", "by", "the", "user", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L413-L428
etcher-be/emiz
emiz/mission_time.py
MissionTime.apply_to_miz
def apply_to_miz(self, miz): """ Applies this datetime to a Miz object (it will be mutated in place) Args: miz: MIZ object to mutate Returns: True """ miz.mission.day = self.date.day miz.mission.month = self.date.month miz.mission.year = sel...
python
def apply_to_miz(self, miz): """ Applies this datetime to a Miz object (it will be mutated in place) Args: miz: MIZ object to mutate Returns: True """ miz.mission.day = self.date.day miz.mission.month = self.date.month miz.mission.year = sel...
[ "def", "apply_to_miz", "(", "self", ",", "miz", ")", ":", "miz", ".", "mission", ".", "day", "=", "self", ".", "date", ".", "day", "miz", ".", "mission", ".", "month", "=", "self", ".", "date", ".", "month", "miz", ".", "mission", ".", "year", "=...
Applies this datetime to a Miz object (it will be mutated in place) Args: miz: MIZ object to mutate Returns: True
[ "Applies", "this", "datetime", "to", "a", "Miz", "object", "(", "it", "will", "be", "mutated", "in", "place", ")" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/mission_time.py#L33-L48
etcher-be/emiz
emiz/mission_time.py
MissionTime.from_string
def from_string(input_str) -> 'MissionTime': # noinspection SpellCheckingInspection """ Creates a MissionTime instance from a string Format: YYYYMMDDHHMMSS Args: input_str: string to parse Returns: MissionTime instance """ match = RE_INPUT_...
python
def from_string(input_str) -> 'MissionTime': # noinspection SpellCheckingInspection """ Creates a MissionTime instance from a string Format: YYYYMMDDHHMMSS Args: input_str: string to parse Returns: MissionTime instance """ match = RE_INPUT_...
[ "def", "from_string", "(", "input_str", ")", "->", "'MissionTime'", ":", "# noinspection SpellCheckingInspection", "match", "=", "RE_INPUT_STRING", ".", "match", "(", "input_str", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "f'badly formatted date/time...
Creates a MissionTime instance from a string Format: YYYYMMDDHHMMSS Args: input_str: string to parse Returns: MissionTime instance
[ "Creates", "a", "MissionTime", "instance", "from", "a", "string" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/mission_time.py#L51-L77
dossier/dossier.models
dossier/models/report.py
ReportGenerator.run
def run(self, output): '''Generate the report to the given output. :param output: writable file-like object or file path ''' # Ensure folder exists. if self.folder_id not in self.folders.folders(self.user): print("E: folder not found: %s" % self.folder_name, ...
python
def run(self, output): '''Generate the report to the given output. :param output: writable file-like object or file path ''' # Ensure folder exists. if self.folder_id not in self.folders.folders(self.user): print("E: folder not found: %s" % self.folder_name, ...
[ "def", "run", "(", "self", ",", "output", ")", ":", "# Ensure folder exists.", "if", "self", ".", "folder_id", "not", "in", "self", ".", "folders", ".", "folders", "(", "self", ".", "user", ")", ":", "print", "(", "\"E: folder not found: %s\"", "%", "self"...
Generate the report to the given output. :param output: writable file-like object or file path
[ "Generate", "the", "report", "to", "the", "given", "output", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L84-L140
dossier/dossier.models
dossier/models/report.py
ReportGenerator._generate_report_all
def _generate_report_all(self): '''Generate report for all subfolders contained by self.folder_id.''' assert self.workbook is not None count = 0 # Do all subfolders for sid in self.folders.subfolders(self.folder_id, self.user): count += 1 self._generate_f...
python
def _generate_report_all(self): '''Generate report for all subfolders contained by self.folder_id.''' assert self.workbook is not None count = 0 # Do all subfolders for sid in self.folders.subfolders(self.folder_id, self.user): count += 1 self._generate_f...
[ "def", "_generate_report_all", "(", "self", ")", ":", "assert", "self", ".", "workbook", "is", "not", "None", "count", "=", "0", "# Do all subfolders", "for", "sid", "in", "self", ".", "folders", ".", "subfolders", "(", "self", ".", "folder_id", ",", "self...
Generate report for all subfolders contained by self.folder_id.
[ "Generate", "report", "for", "all", "subfolders", "contained", "by", "self", ".", "folder_id", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L142-L153
dossier/dossier.models
dossier/models/report.py
ReportGenerator._generate_report_single
def _generate_report_single(self, sid): '''Generate report for subfolder given by sid . The main purpose of this method is to make sure the subfolder given by sid does indeed exist. All real work is delegated to _generate_for_subfolder. :param sid: The subfolder id Pr...
python
def _generate_report_single(self, sid): '''Generate report for subfolder given by sid . The main purpose of this method is to make sure the subfolder given by sid does indeed exist. All real work is delegated to _generate_for_subfolder. :param sid: The subfolder id Pr...
[ "def", "_generate_report_single", "(", "self", ",", "sid", ")", ":", "assert", "self", ".", "workbook", "is", "not", "None", "assert", "sid", "is", "not", "None", "# Ensure subfolder exists", "if", "not", "sid", "in", "self", ".", "folders", ".", "subfolders...
Generate report for subfolder given by sid . The main purpose of this method is to make sure the subfolder given by sid does indeed exist. All real work is delegated to _generate_for_subfolder. :param sid: The subfolder id Private method.
[ "Generate", "report", "for", "subfolder", "given", "by", "sid", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L155-L175
dossier/dossier.models
dossier/models/report.py
ReportGenerator._generate_for_subfolder
def _generate_for_subfolder(self, sid): ''' Generate report for a subfolder. :param sid: The subfolder id; assumed valid ''' # TODO: the following assumes subfolder names can be constructed from a # subfolder id, which might not be the case in the future. name = self._sa...
python
def _generate_for_subfolder(self, sid): ''' Generate report for a subfolder. :param sid: The subfolder id; assumed valid ''' # TODO: the following assumes subfolder names can be constructed from a # subfolder id, which might not be the case in the future. name = self._sa...
[ "def", "_generate_for_subfolder", "(", "self", ",", "sid", ")", ":", "# TODO: the following assumes subfolder names can be constructed from a", "# subfolder id, which might not be the case in the future.", "name", "=", "self", ".", "_sanitise_sheetname", "(", "uni", "(", "Folders...
Generate report for a subfolder. :param sid: The subfolder id; assumed valid
[ "Generate", "report", "for", "a", "subfolder", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L177-L211
dossier/dossier.models
dossier/models/report.py
Item.construct
def construct(generator, subtopic): '''Method constructor of Item-derived classes. Given a subtopic tuple, this method attempts to construct an Item-derived class, currently either ItemText or ItemImage, from the subtopic's type, found in its 4th element. :param generator: Refe...
python
def construct(generator, subtopic): '''Method constructor of Item-derived classes. Given a subtopic tuple, this method attempts to construct an Item-derived class, currently either ItemText or ItemImage, from the subtopic's type, found in its 4th element. :param generator: Refe...
[ "def", "construct", "(", "generator", ",", "subtopic", ")", ":", "type", "=", "subtopic", "[", "3", "]", "if", "type", "not", "in", "Item", ".", "constructors", ":", "raise", "LookupError", "(", "type", ")", "# perhaps customise this exception?", "return", "...
Method constructor of Item-derived classes. Given a subtopic tuple, this method attempts to construct an Item-derived class, currently either ItemText or ItemImage, from the subtopic's type, found in its 4th element. :param generator: Reference to the owning ReportGenerator instance ...
[ "Method", "constructor", "of", "Item", "-", "derived", "classes", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L229-L247
dossier/dossier.models
dossier/models/report.py
ItemImage.generate_to
def generate_to(self, worksheet, row): '''Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :pa...
python
def generate_to(self, worksheet, row): '''Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :pa...
[ "def", "generate_to", "(", "self", ",", "worksheet", ",", "row", ")", ":", "super", "(", "ItemImage", ",", "self", ")", ".", "generate_to", "(", "worksheet", ",", "row", ")", "embedded", "=", "False", "fmt", "=", "self", ".", "generator", ".", "formats...
Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :param row: Row number.
[ "Generate", "row", "report", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L272-L314
dossier/dossier.models
dossier/models/report.py
ItemImage.resize_image
def resize_image(self, data): '''Resize image if height over 50 pixels and convert to JPEG. Given a ByteIO or StringIO data input, this method ensures that the image is not over 50 pixels high. If it is over 50 pixels high, the image is resized to precisely 50 pixels in height and the ...
python
def resize_image(self, data): '''Resize image if height over 50 pixels and convert to JPEG. Given a ByteIO or StringIO data input, this method ensures that the image is not over 50 pixels high. If it is over 50 pixels high, the image is resized to precisely 50 pixels in height and the ...
[ "def", "resize_image", "(", "self", ",", "data", ")", ":", "image", "=", "Image", ".", "open", "(", "data", ")", "stream_out", "=", "BytesIO", "(", ")", "width", ",", "height", "=", "image", ".", "size", "[", ":", "]", "if", "height", ">", "50", ...
Resize image if height over 50 pixels and convert to JPEG. Given a ByteIO or StringIO data input, this method ensures that the image is not over 50 pixels high. If it is over 50 pixels high, the image is resized to precisely 50 pixels in height and the width is adjusted accordingly in ...
[ "Resize", "image", "if", "height", "over", "50", "pixels", "and", "convert", "to", "JPEG", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L316-L341
dossier/dossier.models
dossier/models/report.py
ItemText.generate_to
def generate_to(self, worksheet, row): '''Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :pa...
python
def generate_to(self, worksheet, row): '''Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :pa...
[ "def", "generate_to", "(", "self", ",", "worksheet", ",", "row", ")", ":", "super", "(", "ItemText", ",", "self", ")", ".", "generate_to", "(", "worksheet", ",", "row", ")", "fmt", "=", "self", ".", "generator", ".", "formats", "worksheet", ".", "write...
Generate row report. Generates a row report of the item represented by this instance and inserts it into a given worksheet at a specified row number. :param worksheet: Reference to a worksheet in which to insert row report. :param row: Row number.
[ "Generate", "row", "report", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/report.py#L354-L370
bfontaine/p7magma
magma/courses.py
Course.desc
def desc(self): """ A textual description of this course """ if 'ects' in self: fmt = '%s (%s, S%d) [%s, %.2f ECTS]' fields = ('title', 'code', 'semester', 'status', 'ects') else: fmt = '%s' fields = ('title',) s = fmt % tu...
python
def desc(self): """ A textual description of this course """ if 'ects' in self: fmt = '%s (%s, S%d) [%s, %.2f ECTS]' fields = ('title', 'code', 'semester', 'status', 'ects') else: fmt = '%s' fields = ('title',) s = fmt % tu...
[ "def", "desc", "(", "self", ")", ":", "if", "'ects'", "in", "self", ":", "fmt", "=", "'%s (%s, S%d) [%s, %.2f ECTS]'", "fields", "=", "(", "'title'", ",", "'code'", ",", "'semester'", ",", "'status'", ",", "'ects'", ")", "else", ":", "fmt", "=", "'%s'", ...
A textual description of this course
[ "A", "textual", "description", "of", "this", "course" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L28-L48
bfontaine/p7magma
magma/courses.py
CoursesList._populate
def _populate(self, soup): """ Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object. """ tables = soup.select('table[rules=all]') if not tables: return trs = tables[0].select('tr')[1:] if len(trs[0]) == 5: # M1 se...
python
def _populate(self, soup): """ Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object. """ tables = soup.select('table[rules=all]') if not tables: return trs = tables[0].select('tr')[1:] if len(trs[0]) == 5: # M1 se...
[ "def", "_populate", "(", "self", ",", "soup", ")", ":", "tables", "=", "soup", ".", "select", "(", "'table[rules=all]'", ")", "if", "not", "tables", ":", "return", "trs", "=", "tables", "[", "0", "]", ".", "select", "(", "'tr'", ")", "[", "1", ":",...
Populate the list, assuming ``soup`` is a ``BeautifulSoup`` object.
[ "Populate", "the", "list", "assuming", "soup", "is", "a", "BeautifulSoup", "object", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L70-L84
bfontaine/p7magma
magma/courses.py
CoursesList._populate_small_table
def _populate_small_table(self, trs): """ Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (5 columns). """ for tr in trs: tds = tr.select('td') cs = Course( title=text(tds[0]), f...
python
def _populate_small_table(self, trs): """ Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (5 columns). """ for tr in trs: tds = tr.select('td') cs = Course( title=text(tds[0]), f...
[ "def", "_populate_small_table", "(", "self", ",", "trs", ")", ":", "for", "tr", "in", "trs", ":", "tds", "=", "tr", ".", "select", "(", "'td'", ")", "cs", "=", "Course", "(", "title", "=", "text", "(", "tds", "[", "0", "]", ")", ",", "followed", ...
Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (5 columns).
[ "Populate", "the", "list", "given", "that", "trs", "is", "a", "BeautifulSoup", "elements", "list", "from", "a", "large", "table", "(", "5", "columns", ")", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L86-L103
bfontaine/p7magma
magma/courses.py
CoursesList._populate_large_table
def _populate_large_table(self, trs): """ Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (8 columns). """ for tr in trs: tds = tr.select('td') cs = Course( code=coursecode(tds[0]), ...
python
def _populate_large_table(self, trs): """ Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (8 columns). """ for tr in trs: tds = tr.select('td') cs = Course( code=coursecode(tds[0]), ...
[ "def", "_populate_large_table", "(", "self", ",", "trs", ")", ":", "for", "tr", "in", "trs", ":", "tds", "=", "tr", ".", "select", "(", "'td'", ")", "cs", "=", "Course", "(", "code", "=", "coursecode", "(", "tds", "[", "0", "]", ")", ",", "title"...
Populate the list, given that ``trs`` is a ``BeautifulSoup`` elements list from a large table (8 columns).
[ "Populate", "the", "list", "given", "that", "trs", "is", "a", "BeautifulSoup", "elements", "list", "from", "a", "large", "table", "(", "8", "columns", ")", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L105-L125
bfontaine/p7magma
magma/courses.py
CoursesList.filter
def filter(self, criteria): """ Return a filtered version of this list following the given criteria, which can be a string (take only courses where this attribute is truthy) or a function which takes a course and return a boolean. """ if isinstance(criteria, str) or isins...
python
def filter(self, criteria): """ Return a filtered version of this list following the given criteria, which can be a string (take only courses where this attribute is truthy) or a function which takes a course and return a boolean. """ if isinstance(criteria, str) or isins...
[ "def", "filter", "(", "self", ",", "criteria", ")", ":", "if", "isinstance", "(", "criteria", ",", "str", ")", "or", "isinstance", "(", "criteria", ",", "unicode", ")", ":", "_criteria", "=", "criteria", "criteria", "=", "lambda", "x", ":", "x", ".", ...
Return a filtered version of this list following the given criteria, which can be a string (take only courses where this attribute is truthy) or a function which takes a course and return a boolean.
[ "Return", "a", "filtered", "version", "of", "this", "list", "following", "the", "given", "criteria", "which", "can", "be", "a", "string", "(", "take", "only", "courses", "where", "this", "attribute", "is", "truthy", ")", "or", "a", "function", "which", "ta...
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/courses.py#L135-L145
matthewdeanmartin/jiggle_version
jiggle_version/module_finder.py
ModuleFinder.setup_py_source
def setup_py_source(self): # type: () -> Optional[str] """ Read setup.py to string :return: """ if not self.setup_source: self.setup_source = self._read_file("setup.py") if not self.setup_source: self.setup_source = self._read_file("setup") # rar...
python
def setup_py_source(self): # type: () -> Optional[str] """ Read setup.py to string :return: """ if not self.setup_source: self.setup_source = self._read_file("setup.py") if not self.setup_source: self.setup_source = self._read_file("setup") # rar...
[ "def", "setup_py_source", "(", "self", ")", ":", "# type: () -> Optional[str]", "if", "not", "self", ".", "setup_source", ":", "self", ".", "setup_source", "=", "self", ".", "_read_file", "(", "\"setup.py\"", ")", "if", "not", "self", ".", "setup_source", ":",...
Read setup.py to string :return:
[ "Read", "setup", ".", "py", "to", "string", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L84-L93
matthewdeanmartin/jiggle_version
jiggle_version/module_finder.py
ModuleFinder.extract_package_dir
def extract_package_dir(self): # type: () -> Optional[str] """ Get the package_dir dictionary from source :return: """ # package_dir={'': 'lib'}, source = self.setup_py_source() if not source: # this happens when the setup.py file is missing ...
python
def extract_package_dir(self): # type: () -> Optional[str] """ Get the package_dir dictionary from source :return: """ # package_dir={'': 'lib'}, source = self.setup_py_source() if not source: # this happens when the setup.py file is missing ...
[ "def", "extract_package_dir", "(", "self", ")", ":", "# type: () -> Optional[str]", "# package_dir={'': 'lib'},", "source", "=", "self", ".", "setup_py_source", "(", ")", "if", "not", "source", ":", "# this happens when the setup.py file is missing", "return", "None", "# ...
Get the package_dir dictionary from source :return:
[ "Get", "the", "package_dir", "dictionary", "from", "source", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L95-L147
matthewdeanmartin/jiggle_version
jiggle_version/module_finder.py
ModuleFinder.via_find_packages
def via_find_packages(self): # type: () -> List[str] """ Use find_packages code to find modules. Can find LOTS of modules. :return: """ packages = [] # type: List[str] source = self.setup_py_source() if not source: return packages find_packag...
python
def via_find_packages(self): # type: () -> List[str] """ Use find_packages code to find modules. Can find LOTS of modules. :return: """ packages = [] # type: List[str] source = self.setup_py_source() if not source: return packages find_packag...
[ "def", "via_find_packages", "(", "self", ")", ":", "# type: () -> List[str]", "packages", "=", "[", "]", "# type: List[str]", "source", "=", "self", ".", "setup_py_source", "(", ")", "if", "not", "source", ":", "return", "packages", "find_package_args", "=", "\"...
Use find_packages code to find modules. Can find LOTS of modules. :return:
[ "Use", "find_packages", "code", "to", "find", "modules", ".", "Can", "find", "LOTS", "of", "modules", ".", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L163-L196
matthewdeanmartin/jiggle_version
jiggle_version/module_finder.py
ModuleFinder.find_top_level_modules_by_dunder_init
def find_top_level_modules_by_dunder_init(self): # type: () -> List[str] """ Find modules along side setup.py (or in current folder) Recreates what find_packages does. :return: """ # TODO: use package_dirs packaged_dirs = "" try: # Right now ...
python
def find_top_level_modules_by_dunder_init(self): # type: () -> List[str] """ Find modules along side setup.py (or in current folder) Recreates what find_packages does. :return: """ # TODO: use package_dirs packaged_dirs = "" try: # Right now ...
[ "def", "find_top_level_modules_by_dunder_init", "(", "self", ")", ":", "# type: () -> List[str]", "# TODO: use package_dirs", "packaged_dirs", "=", "\"\"", "try", ":", "# Right now only returns 1st.", "packaged_dirs", "=", "self", ".", "extract_package_dir", "(", ")", "exce...
Find modules along side setup.py (or in current folder) Recreates what find_packages does. :return:
[ "Find", "modules", "along", "side", "setup", ".", "py", "(", "or", "in", "current", "folder", ")" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L198-L231
matthewdeanmartin/jiggle_version
jiggle_version/module_finder.py
ModuleFinder.find_single_file_project
def find_single_file_project(self): # type: () -> List[str] """ Take first non-setup.py python file. What a mess. :return: """ # TODO: use package_dirs packaged_dirs = "" try: # Right now only returns 1st. packaged_dirs = self.extract_pack...
python
def find_single_file_project(self): # type: () -> List[str] """ Take first non-setup.py python file. What a mess. :return: """ # TODO: use package_dirs packaged_dirs = "" try: # Right now only returns 1st. packaged_dirs = self.extract_pack...
[ "def", "find_single_file_project", "(", "self", ")", ":", "# type: () -> List[str]", "# TODO: use package_dirs", "packaged_dirs", "=", "\"\"", "try", ":", "# Right now only returns 1st.", "packaged_dirs", "=", "self", ".", "extract_package_dir", "(", ")", "except", ":", ...
Take first non-setup.py python file. What a mess. :return:
[ "Take", "first", "non", "-", "setup", ".", "py", "python", "file", ".", "What", "a", "mess", ".", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L238-L271
pip-services3-python/pip-services3-components-python
pip_services3_components/connect/ConnectionParams.py
ConnectionParams.get_host
def get_host(self): """ Gets the host name or IP address. :return: the host name or IP address. """ host = self.get_as_nullable_string("host") host = host if host != None else self.get_as_nullable_string("ip") return host
python
def get_host(self): """ Gets the host name or IP address. :return: the host name or IP address. """ host = self.get_as_nullable_string("host") host = host if host != None else self.get_as_nullable_string("ip") return host
[ "def", "get_host", "(", "self", ")", ":", "host", "=", "self", ".", "get_as_nullable_string", "(", "\"host\"", ")", "host", "=", "host", "if", "host", "!=", "None", "else", "self", ".", "get_as_nullable_string", "(", "\"ip\"", ")", "return", "host" ]
Gets the host name or IP address. :return: the host name or IP address.
[ "Gets", "the", "host", "name", "or", "IP", "address", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionParams.py#L103-L111
etcher-be/emiz
emiz/weather/awc/awc.py
AWC.query_icao
def query_icao(icao: str): """ Queries AWC for the METAR of a given station Args: icao: station ID as a four letters-digits ICAO code Returns: AWC result for the station """ params = { 'dataSource': 'metars', 'requestType': 'retrieve...
python
def query_icao(icao: str): """ Queries AWC for the METAR of a given station Args: icao: station ID as a four letters-digits ICAO code Returns: AWC result for the station """ params = { 'dataSource': 'metars', 'requestType': 'retrieve...
[ "def", "query_icao", "(", "icao", ":", "str", ")", ":", "params", "=", "{", "'dataSource'", ":", "'metars'", ",", "'requestType'", ":", "'retrieve'", ",", "'format'", ":", "'csv'", ",", "'hoursBeforeNow'", ":", "24", ",", "}", "AWC", ".", "_validate_icao",...
Queries AWC for the METAR of a given station Args: icao: station ID as a four letters-digits ICAO code Returns: AWC result for the station
[ "Queries", "AWC", "for", "the", "METAR", "of", "a", "given", "station" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/awc/awc.py#L48-L69
canonical-web-and-design/asset-mapper
ubuntudesign/__init__.py
AssetMapper.create
def create(self, asset_content, friendly_name, tags='', optimize=False): """ Create an asset on the server You must provide the asset with a friendly name for the server to generate a path from. """ return self._create_asset({ 'asset': b64encode(asset_content...
python
def create(self, asset_content, friendly_name, tags='', optimize=False): """ Create an asset on the server You must provide the asset with a friendly name for the server to generate a path from. """ return self._create_asset({ 'asset': b64encode(asset_content...
[ "def", "create", "(", "self", ",", "asset_content", ",", "friendly_name", ",", "tags", "=", "''", ",", "optimize", "=", "False", ")", ":", "return", "self", ".", "_create_asset", "(", "{", "'asset'", ":", "b64encode", "(", "asset_content", ")", ",", "'fr...
Create an asset on the server You must provide the asset with a friendly name for the server to generate a path from.
[ "Create", "an", "asset", "on", "the", "server", "You", "must", "provide", "the", "asset", "with", "a", "friendly", "name", "for", "the", "server", "to", "generate", "a", "path", "from", "." ]
train
https://github.com/canonical-web-and-design/asset-mapper/blob/5dc438a9cb3290cf54c5607913be02ed9d58b02d/ubuntudesign/__init__.py#L64-L77
canonical-web-and-design/asset-mapper
ubuntudesign/__init__.py
AssetMapper.create_at_path
def create_at_path(self, asset_content, url_path, tags=''): """ Create asset at a specific URL path on the server """ return self._create_asset({ 'asset': b64encode(asset_content), 'url-path': url_path, 'tags': tags, 'type': 'base64' ...
python
def create_at_path(self, asset_content, url_path, tags=''): """ Create asset at a specific URL path on the server """ return self._create_asset({ 'asset': b64encode(asset_content), 'url-path': url_path, 'tags': tags, 'type': 'base64' ...
[ "def", "create_at_path", "(", "self", ",", "asset_content", ",", "url_path", ",", "tags", "=", "''", ")", ":", "return", "self", ".", "_create_asset", "(", "{", "'asset'", ":", "b64encode", "(", "asset_content", ")", ",", "'url-path'", ":", "url_path", ","...
Create asset at a specific URL path on the server
[ "Create", "asset", "at", "a", "specific", "URL", "path", "on", "the", "server" ]
train
https://github.com/canonical-web-and-design/asset-mapper/blob/5dc438a9cb3290cf54c5607913be02ed9d58b02d/ubuntudesign/__init__.py#L79-L89
lwcook/horsetail-matching
horsetailmatching/hm.py
_extalg
def _extalg(xarr, alpha=100, axis=None): '''Given an array xarr of values, smoothly return the max/min''' return (np.sum(xarr * np.exp(alpha*xarr), axis=axis, keepdims=True)/ np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True))
python
def _extalg(xarr, alpha=100, axis=None): '''Given an array xarr of values, smoothly return the max/min''' return (np.sum(xarr * np.exp(alpha*xarr), axis=axis, keepdims=True)/ np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True))
[ "def", "_extalg", "(", "xarr", ",", "alpha", "=", "100", ",", "axis", "=", "None", ")", ":", "return", "(", "np", ".", "sum", "(", "xarr", "*", "np", ".", "exp", "(", "alpha", "*", "xarr", ")", ",", "axis", "=", "axis", ",", "keepdims", "=", ...
Given an array xarr of values, smoothly return the max/min
[ "Given", "an", "array", "xarr", "of", "values", "smoothly", "return", "the", "max", "/", "min" ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L834-L837
lwcook/horsetail-matching
horsetailmatching/hm.py
_extgrad
def _extgrad(xarr, alpha=100, axis=None): '''Given an array xarr of values, return the gradient of the smooth min/max swith respect to each entry in the array''' term1 = (np.exp(alpha*xarr)/ np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True)) term2 = 1 + alpha*(xarr - _extalg(xarr, alp...
python
def _extgrad(xarr, alpha=100, axis=None): '''Given an array xarr of values, return the gradient of the smooth min/max swith respect to each entry in the array''' term1 = (np.exp(alpha*xarr)/ np.sum(np.exp(alpha*xarr), axis=axis, keepdims=True)) term2 = 1 + alpha*(xarr - _extalg(xarr, alp...
[ "def", "_extgrad", "(", "xarr", ",", "alpha", "=", "100", ",", "axis", "=", "None", ")", ":", "term1", "=", "(", "np", ".", "exp", "(", "alpha", "*", "xarr", ")", "/", "np", ".", "sum", "(", "np", ".", "exp", "(", "alpha", "*", "xarr", ")", ...
Given an array xarr of values, return the gradient of the smooth min/max swith respect to each entry in the array
[ "Given", "an", "array", "xarr", "of", "values", "return", "the", "gradient", "of", "the", "smooth", "min", "/", "max", "swith", "respect", "to", "each", "entry", "in", "the", "array" ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L839-L846
lwcook/horsetail-matching
horsetailmatching/hm.py
_matrix_integration
def _matrix_integration(q, h, t): ''' Returns the dp metric for a single horsetail curve at a given value of the epistemic uncertainties''' N = len(q) # correction if CDF has gone out of trapezium range if h[-1] < 0.9: h[-1] = 1.0 W = np.zeros([N, N]) for i in range(N): W[i, i] = ...
python
def _matrix_integration(q, h, t): ''' Returns the dp metric for a single horsetail curve at a given value of the epistemic uncertainties''' N = len(q) # correction if CDF has gone out of trapezium range if h[-1] < 0.9: h[-1] = 1.0 W = np.zeros([N, N]) for i in range(N): W[i, i] = ...
[ "def", "_matrix_integration", "(", "q", ",", "h", ",", "t", ")", ":", "N", "=", "len", "(", "q", ")", "# correction if CDF has gone out of trapezium range", "if", "h", "[", "-", "1", "]", "<", "0.9", ":", "h", "[", "-", "1", "]", "=", "1.0", "W", "...
Returns the dp metric for a single horsetail curve at a given value of the epistemic uncertainties
[ "Returns", "the", "dp", "metric", "for", "a", "single", "horsetail", "curve", "at", "a", "given", "value", "of", "the", "epistemic", "uncertainties" ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L921-L936
lwcook/horsetail-matching
horsetailmatching/hm.py
_matrix_grad
def _matrix_grad(q, h, h_dx, t, t_prime): ''' Returns the gradient with respect to a single variable''' N = len(q) W = np.zeros([N, N]) Wprime = np.zeros([N, N]) for i in range(N): W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)]) Wprime[i, i] = \ 0.5*(h_dx[min(i+1, N-1)...
python
def _matrix_grad(q, h, h_dx, t, t_prime): ''' Returns the gradient with respect to a single variable''' N = len(q) W = np.zeros([N, N]) Wprime = np.zeros([N, N]) for i in range(N): W[i, i] = 0.5*(h[min(i+1, N-1)] - h[max(i-1, 0)]) Wprime[i, i] = \ 0.5*(h_dx[min(i+1, N-1)...
[ "def", "_matrix_grad", "(", "q", ",", "h", ",", "h_dx", ",", "t", ",", "t_prime", ")", ":", "N", "=", "len", "(", "q", ")", "W", "=", "np", ".", "zeros", "(", "[", "N", ",", "N", "]", ")", "Wprime", "=", "np", ".", "zeros", "(", "[", "N",...
Returns the gradient with respect to a single variable
[ "Returns", "the", "gradient", "with", "respect", "to", "a", "single", "variable" ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L938-L954
lwcook/horsetail-matching
horsetailmatching/hm.py
HorsetailMatching.evalSamples
def evalSamples(self, x): '''Evalautes the samples of quantity of interest and its gradient (if supplied) at the given values of the design variables :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :return: (value...
python
def evalSamples(self, x): '''Evalautes the samples of quantity of interest and its gradient (if supplied) at the given values of the design variables :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :return: (value...
[ "def", "evalSamples", "(", "self", ",", "x", ")", ":", "# Make sure dimensions are correct", "# u_sample_dimensions = self._processDimensions()", "self", ".", "_N_dv", "=", "len", "(", "_makeIter", "(", "x", ")", ")", "if", "self", ".", "verbose", ":", "pri...
Evalautes the samples of quantity of interest and its gradient (if supplied) at the given values of the design variables :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :return: (values of the quantity of interest, values...
[ "Evalautes", "the", "samples", "of", "quantity", "of", "interest", "and", "its", "gradient", "(", "if", "supplied", ")", "at", "the", "given", "values", "of", "the", "design", "variables" ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L292-L326
lwcook/horsetail-matching
horsetailmatching/hm.py
HorsetailMatching.evalMetric
def evalMetric(self, x, method=None): '''Evaluates the horsetail matching metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param str method: method to use to evaluate...
python
def evalMetric(self, x, method=None): '''Evaluates the horsetail matching metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param str method: method to use to evaluate...
[ "def", "evalMetric", "(", "self", ",", "x", ",", "method", "=", "None", ")", ":", "# Make sure dimensions are correct", "# u_sample_dimensions = self._processDimensions()", "if", "self", ".", "verbose", ":", "print", "(", "'----------'", ")", "print", "(", "'...
Evaluates the horsetail matching metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param str method: method to use to evaluate the metric ('empirical' or 'kernel')...
[ "Evaluates", "the", "horsetail", "matching", "metric", "at", "given", "values", "of", "the", "design", "variables", "." ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L328-L363
lwcook/horsetail-matching
horsetailmatching/hm.py
HorsetailMatching.evalMetricFromSamples
def evalMetricFromSamples(self, q_samples, grad_samples=None, method=None): '''Evaluates the horsetail matching metric from given samples of the quantity of interest and gradient instead of evaluating them at a design. :param np.ndarray q_samples: samples of the quantity of interest, ...
python
def evalMetricFromSamples(self, q_samples, grad_samples=None, method=None): '''Evaluates the horsetail matching metric from given samples of the quantity of interest and gradient instead of evaluating them at a design. :param np.ndarray q_samples: samples of the quantity of interest, ...
[ "def", "evalMetricFromSamples", "(", "self", ",", "q_samples", ",", "grad_samples", "=", "None", ",", "method", "=", "None", ")", ":", "# Make sure dimensions are correct", "# u_sample_dimensions = self._processDimensions()", "q_samples", "=", "np", ".", "array", ...
Evaluates the horsetail matching metric from given samples of the quantity of interest and gradient instead of evaluating them at a design. :param np.ndarray q_samples: samples of the quantity of interest, size (M_int, M_prob) :param np.ndarray grad_samples: samples of the gradien, ...
[ "Evaluates", "the", "horsetail", "matching", "metric", "from", "given", "samples", "of", "the", "quantity", "of", "interest", "and", "gradient", "instead", "of", "evaluating", "them", "at", "a", "design", "." ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L365-L402
lwcook/horsetail-matching
horsetailmatching/hm.py
HorsetailMatching.getHorsetail
def getHorsetail(self): '''Function that gets vectors of the horsetail plot at the last design evaluated. :return: upper_curve, lower_curve, CDFs - returns three parameters, the first two are tuples containing pairs of x/y vectors of the upper and lower bounds on the CDF...
python
def getHorsetail(self): '''Function that gets vectors of the horsetail plot at the last design evaluated. :return: upper_curve, lower_curve, CDFs - returns three parameters, the first two are tuples containing pairs of x/y vectors of the upper and lower bounds on the CDF...
[ "def", "getHorsetail", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_ql'", ")", ":", "ql", ",", "qu", ",", "hl", ",", "hu", "=", "self", ".", "_ql", ",", "self", ".", "_qu", ",", "self", ".", "_hl", ",", "self", ".", "_hu", "qh...
Function that gets vectors of the horsetail plot at the last design evaluated. :return: upper_curve, lower_curve, CDFs - returns three parameters, the first two are tuples containing pairs of x/y vectors of the upper and lower bounds on the CDFs (the horsetail plot). The ...
[ "Function", "that", "gets", "vectors", "of", "the", "horsetail", "plot", "at", "the", "last", "design", "evaluated", "." ]
train
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/hm.py#L405-L450
goldhand/django-nupages
nupages/views.py
PageList.get_queryset
def get_queryset(self): ''' If MultiTenantMiddleware is used, filter queryset by request.site_id ''' queryset = super(PageList, self).get_queryset() if hasattr(self.request, 'site_id'): queryset = queryset.filter(site_id=self.request.site_id) return queryset
python
def get_queryset(self): ''' If MultiTenantMiddleware is used, filter queryset by request.site_id ''' queryset = super(PageList, self).get_queryset() if hasattr(self.request, 'site_id'): queryset = queryset.filter(site_id=self.request.site_id) return queryset
[ "def", "get_queryset", "(", "self", ")", ":", "queryset", "=", "super", "(", "PageList", ",", "self", ")", ".", "get_queryset", "(", ")", "if", "hasattr", "(", "self", ".", "request", ",", "'site_id'", ")", ":", "queryset", "=", "queryset", ".", "filte...
If MultiTenantMiddleware is used, filter queryset by request.site_id
[ "If", "MultiTenantMiddleware", "is", "used", "filter", "queryset", "by", "request", ".", "site_id" ]
train
https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/views.py#L54-L61
goldhand/django-nupages
nupages/views.py
PageList.get_context_data
def get_context_data(self, **kwargs): ''' Adds a 'base_template' attribute to context for the page_detail to extend from ''' context = super(PageList, self).get_context_data(**kwargs) page_base_template = "nupages/base.html" # if MultiTenantMiddleware is used, us...
python
def get_context_data(self, **kwargs): ''' Adds a 'base_template' attribute to context for the page_detail to extend from ''' context = super(PageList, self).get_context_data(**kwargs) page_base_template = "nupages/base.html" # if MultiTenantMiddleware is used, us...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "PageList", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "page_base_template", "=", "\"nupages/base.html\"", "# if MultiTenantM...
Adds a 'base_template' attribute to context for the page_detail to extend from
[ "Adds", "a", "base_template", "attribute", "to", "context", "for", "the", "page_detail", "to", "extend", "from" ]
train
https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/views.py#L63-L78
goldhand/django-nupages
nupages/views.py
PageDetail.get_template_names
def get_template_names(self): ''' Looks for a custom_template value and prepends it to template_names if it exists otherwise 'nupages/page_detail.html' is used ''' template_names = super(PageDetail, self).get_template_names() if self.get_object().custom_template: ...
python
def get_template_names(self): ''' Looks for a custom_template value and prepends it to template_names if it exists otherwise 'nupages/page_detail.html' is used ''' template_names = super(PageDetail, self).get_template_names() if self.get_object().custom_template: ...
[ "def", "get_template_names", "(", "self", ")", ":", "template_names", "=", "super", "(", "PageDetail", ",", "self", ")", ".", "get_template_names", "(", ")", "if", "self", ".", "get_object", "(", ")", ".", "custom_template", ":", "# there is a custom template, i...
Looks for a custom_template value and prepends it to template_names if it exists otherwise 'nupages/page_detail.html' is used
[ "Looks", "for", "a", "custom_template", "value", "and", "prepends", "it", "to", "template_names", "if", "it", "exists", "otherwise", "nupages", "/", "page_detail", ".", "html", "is", "used" ]
train
https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/views.py#L87-L96
goldhand/django-nupages
nupages/views.py
PageDetail.get_context_data
def get_context_data(self, **kwargs): ''' Adds a 'base_template' attribute to context for the page_detail to extend from ''' context = super(PageDetail, self).get_context_data(**kwargs) page_base_template = "nupages/base.html" # if MultiTenantMiddleware is used, ...
python
def get_context_data(self, **kwargs): ''' Adds a 'base_template' attribute to context for the page_detail to extend from ''' context = super(PageDetail, self).get_context_data(**kwargs) page_base_template = "nupages/base.html" # if MultiTenantMiddleware is used, ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "PageDetail", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "page_base_template", "=", "\"nupages/base.html\"", "# if MultiTenan...
Adds a 'base_template' attribute to context for the page_detail to extend from
[ "Adds", "a", "base_template", "attribute", "to", "context", "for", "the", "page_detail", "to", "extend", "from" ]
train
https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/views.py#L107-L121
etcher-be/emiz
emiz/weather/noaa/__init__.py
retrieve_taf
def retrieve_taf(station_icao) -> typing.Tuple[typing.Union[str, None], typing.Union[str, None]]: """ Retrieves a TAF string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str """ url = _BASE_TAF_URL.format(station=station_icao) ...
python
def retrieve_taf(station_icao) -> typing.Tuple[typing.Union[str, None], typing.Union[str, None]]: """ Retrieves a TAF string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str """ url = _BASE_TAF_URL.format(station=station_icao) ...
[ "def", "retrieve_taf", "(", "station_icao", ")", "->", "typing", ".", "Tuple", "[", "typing", ".", "Union", "[", "str", ",", "None", "]", ",", "typing", ".", "Union", "[", "str", ",", "None", "]", "]", ":", "url", "=", "_BASE_TAF_URL", ".", "format",...
Retrieves a TAF string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str
[ "Retrieves", "a", "TAF", "string", "from", "an", "online", "database" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/noaa/__init__.py#L13-L29
etcher-be/emiz
emiz/weather/noaa/__init__.py
retrieve_metar
def retrieve_metar(station_icao) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]: """ Retrieves a METAR string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str """ url = _BASE_METAR_URL.format(station=station_icao) ...
python
def retrieve_metar(station_icao) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]: """ Retrieves a METAR string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str """ url = _BASE_METAR_URL.format(station=station_icao) ...
[ "def", "retrieve_metar", "(", "station_icao", ")", "->", "typing", ".", "Tuple", "[", "typing", ".", "Optional", "[", "str", "]", ",", "typing", ".", "Optional", "[", "str", "]", "]", ":", "url", "=", "_BASE_METAR_URL", ".", "format", "(", "station", "...
Retrieves a METAR string from an online database Args: station_icao: ICAO of the station Returns: tuple of error, metar_str
[ "Retrieves", "a", "METAR", "string", "from", "an", "online", "database" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/noaa/__init__.py#L32-L48
etcher-be/emiz
emiz/weather/custom_metar/custom_metar_pressure.py
CustomPressure.value
def value(self, units=None): """Return the pressure in the specified units.""" if units is None: return self._value if not units.upper() in CustomPressure.legal_units: raise UnitsError("unrecognized pressure unit: '" + units + "'") units = units.upper() i...
python
def value(self, units=None): """Return the pressure in the specified units.""" if units is None: return self._value if not units.upper() in CustomPressure.legal_units: raise UnitsError("unrecognized pressure unit: '" + units + "'") units = units.upper() i...
[ "def", "value", "(", "self", ",", "units", "=", "None", ")", ":", "if", "units", "is", "None", ":", "return", "self", ".", "_value", "if", "not", "units", ".", "upper", "(", ")", "in", "CustomPressure", ".", "legal_units", ":", "raise", "UnitsError", ...
Return the pressure in the specified units.
[ "Return", "the", "pressure", "in", "the", "specified", "units", "." ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/custom_metar/custom_metar_pressure.py#L16-L39
etcher-be/emiz
emiz/weather/custom_metar/custom_metar_pressure.py
CustomPressure.string
def string(self, units: typing.Optional[str] = None) -> str: """Return a string representation of the pressure, using the given units.""" if not units: _units: str = self._units else: if not units.upper() in CustomPressure.legal_units: raise UnitsError("un...
python
def string(self, units: typing.Optional[str] = None) -> str: """Return a string representation of the pressure, using the given units.""" if not units: _units: str = self._units else: if not units.upper() in CustomPressure.legal_units: raise UnitsError("un...
[ "def", "string", "(", "self", ",", "units", ":", "typing", ".", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "if", "not", "units", ":", "_units", ":", "str", "=", "self", ".", "_units", "else", ":", "if", "not", "units", ".", ...
Return a string representation of the pressure, using the given units.
[ "Return", "a", "string", "representation", "of", "the", "pressure", "using", "the", "given", "units", "." ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/custom_metar/custom_metar_pressure.py#L41-L59
radjkarl/fancyTools
fancytools/math/vector3d.py
vectorAngle
def vectorAngle(vec1,vec2): ''' vector (x,y,z) or vector field of shape (3,x,y) ''' if vec1.ndim == 1: assert vec2.ndim == 3 vec1 = vectorToField(vec1, vec2.shape[:2]) if vec2.ndim == 1: assert vec1.ndim == 3 vec2 = vectorToField(vec2, vec1.shape[1:]) a = np.arcc...
python
def vectorAngle(vec1,vec2): ''' vector (x,y,z) or vector field of shape (3,x,y) ''' if vec1.ndim == 1: assert vec2.ndim == 3 vec1 = vectorToField(vec1, vec2.shape[:2]) if vec2.ndim == 1: assert vec1.ndim == 3 vec2 = vectorToField(vec2, vec1.shape[1:]) a = np.arcc...
[ "def", "vectorAngle", "(", "vec1", ",", "vec2", ")", ":", "if", "vec1", ".", "ndim", "==", "1", ":", "assert", "vec2", ".", "ndim", "==", "3", "vec1", "=", "vectorToField", "(", "vec1", ",", "vec2", ".", "shape", "[", ":", "2", "]", ")", "if", ...
vector (x,y,z) or vector field of shape (3,x,y)
[ "vector", "(", "x", "y", "z", ")", "or", "vector", "field", "of", "shape", "(", "3", "x", "y", ")" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/vector3d.py#L6-L25
toastdriven/alligator
alligator/utils.py
determine_name
def determine_name(func): """ Given a function, returns the name of the function. Ex:: from random import choice determine_name(choice) # Returns 'choice' :param func: The callable :type func: function :returns: Name string """ if hasattr(func, '__name__'): re...
python
def determine_name(func): """ Given a function, returns the name of the function. Ex:: from random import choice determine_name(choice) # Returns 'choice' :param func: The callable :type func: function :returns: Name string """ if hasattr(func, '__name__'): re...
[ "def", "determine_name", "(", "func", ")", ":", "if", "hasattr", "(", "func", ",", "'__name__'", ")", ":", "return", "func", ".", "__name__", "elif", "hasattr", "(", "func", ",", "'__class__'", ")", ":", "return", "func", ".", "__class__", ".", "__name__...
Given a function, returns the name of the function. Ex:: from random import choice determine_name(choice) # Returns 'choice' :param func: The callable :type func: function :returns: Name string
[ "Given", "a", "function", "returns", "the", "name", "of", "the", "function", "." ]
train
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L24-L46
toastdriven/alligator
alligator/utils.py
import_module
def import_module(module_name): """ Given a dotted Python path, imports & returns the module. If not found, raises ``UnknownModuleError``. Ex:: mod = import_module('random') :param module_name: The dotted Python path :type module_name: string :returns: module """ try: ...
python
def import_module(module_name): """ Given a dotted Python path, imports & returns the module. If not found, raises ``UnknownModuleError``. Ex:: mod = import_module('random') :param module_name: The dotted Python path :type module_name: string :returns: module """ try: ...
[ "def", "import_module", "(", "module_name", ")", ":", "try", ":", "return", "importlib", ".", "import_module", "(", "module_name", ")", "except", "ImportError", "as", "err", ":", "raise", "UnknownModuleError", "(", "str", "(", "err", ")", ")" ]
Given a dotted Python path, imports & returns the module. If not found, raises ``UnknownModuleError``. Ex:: mod = import_module('random') :param module_name: The dotted Python path :type module_name: string :returns: module
[ "Given", "a", "dotted", "Python", "path", "imports", "&", "returns", "the", "module", "." ]
train
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L49-L67
toastdriven/alligator
alligator/utils.py
import_attr
def import_attr(module_name, attr_name): """ Given a dotted Python path & an attribute name, imports the module & returns the attribute. If not found, raises ``UnknownCallableError``. Ex:: choice = import_attr('random', 'choice') :param module_name: The dotted Python path :type m...
python
def import_attr(module_name, attr_name): """ Given a dotted Python path & an attribute name, imports the module & returns the attribute. If not found, raises ``UnknownCallableError``. Ex:: choice = import_attr('random', 'choice') :param module_name: The dotted Python path :type m...
[ "def", "import_attr", "(", "module_name", ",", "attr_name", ")", ":", "module", "=", "import_module", "(", "module_name", ")", "try", ":", "return", "getattr", "(", "module", ",", "attr_name", ")", "except", "AttributeError", "as", "err", ":", "raise", "Unkn...
Given a dotted Python path & an attribute name, imports the module & returns the attribute. If not found, raises ``UnknownCallableError``. Ex:: choice = import_attr('random', 'choice') :param module_name: The dotted Python path :type module_name: string :param attr_name: The attribu...
[ "Given", "a", "dotted", "Python", "path", "&", "an", "attribute", "name", "imports", "the", "module", "&", "returns", "the", "attribute", "." ]
train
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/utils.py#L70-L94
nefarioustim/parker
parker/configloader.py
load_site_config
def load_site_config(name): """Load and return site configuration as a dict.""" return _load_config_json( os.path.join( CONFIG_PATH, CONFIG_SITES_PATH, name + CONFIG_EXT ) )
python
def load_site_config(name): """Load and return site configuration as a dict.""" return _load_config_json( os.path.join( CONFIG_PATH, CONFIG_SITES_PATH, name + CONFIG_EXT ) )
[ "def", "load_site_config", "(", "name", ")", ":", "return", "_load_config_json", "(", "os", ".", "path", ".", "join", "(", "CONFIG_PATH", ",", "CONFIG_SITES_PATH", ",", "name", "+", "CONFIG_EXT", ")", ")" ]
Load and return site configuration as a dict.
[ "Load", "and", "return", "site", "configuration", "as", "a", "dict", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/configloader.py#L37-L45
carlosp420/dataset-creator
dataset_creator/phylip.py
PhylipDatasetFooter.make_charsets
def make_charsets(self): """ Overridden function for Phylip dataset as the content is different and goes into a separate file. """ count_start = 1 out = '' for gene_code, lengths in self.data.gene_codes_and_lengths.items(): count_end = lengths[0] + cou...
python
def make_charsets(self): """ Overridden function for Phylip dataset as the content is different and goes into a separate file. """ count_start = 1 out = '' for gene_code, lengths in self.data.gene_codes_and_lengths.items(): count_end = lengths[0] + cou...
[ "def", "make_charsets", "(", "self", ")", ":", "count_start", "=", "1", "out", "=", "''", "for", "gene_code", ",", "lengths", "in", "self", ".", "data", ".", "gene_codes_and_lengths", ".", "items", "(", ")", ":", "count_end", "=", "lengths", "[", "0", ...
Overridden function for Phylip dataset as the content is different and goes into a separate file.
[ "Overridden", "function", "for", "Phylip", "dataset", "as", "the", "content", "is", "different", "and", "goes", "into", "a", "separate", "file", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/phylip.py#L13-L26
kstark/months
months/months.py
Month.from_date
def from_date(cls, date): """ Returns a Month instance from the given datetime.date or datetime.datetime object """ try: date = date.date() except AttributeError: pass return cls(date.year, date.month)
python
def from_date(cls, date): """ Returns a Month instance from the given datetime.date or datetime.datetime object """ try: date = date.date() except AttributeError: pass return cls(date.year, date.month)
[ "def", "from_date", "(", "cls", ",", "date", ")", ":", "try", ":", "date", "=", "date", ".", "date", "(", ")", "except", "AttributeError", ":", "pass", "return", "cls", "(", "date", ".", "year", ",", "date", ".", "month", ")" ]
Returns a Month instance from the given datetime.date or datetime.datetime object
[ "Returns", "a", "Month", "instance", "from", "the", "given", "datetime", ".", "date", "or", "datetime", ".", "datetime", "object" ]
train
https://github.com/kstark/months/blob/676910a7328c3204f7366558b038644057d34561/months/months.py#L66-L75
mbodenhamer/syn
syn/tree/b/tree.py
Tree.rebuild
def rebuild(self, **kwargs): '''Repopulate the node-tracking data structures. Shouldn't really ever be needed. ''' self.nodes = [] self.node_types = [] self.id_dict = {} self.type_dict = {} self.add_node(self.root)
python
def rebuild(self, **kwargs): '''Repopulate the node-tracking data structures. Shouldn't really ever be needed. ''' self.nodes = [] self.node_types = [] self.id_dict = {} self.type_dict = {} self.add_node(self.root)
[ "def", "rebuild", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "nodes", "=", "[", "]", "self", ".", "node_types", "=", "[", "]", "self", ".", "id_dict", "=", "{", "}", "self", ".", "type_dict", "=", "{", "}", "self", ".", "add_n...
Repopulate the node-tracking data structures. Shouldn't really ever be needed.
[ "Repopulate", "the", "node", "-", "tracking", "data", "structures", ".", "Shouldn", "t", "really", "ever", "be", "needed", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/tree/b/tree.py#L125-L134
mbodenhamer/syn
syn/tree/b/tree.py
Tree._check_search_kwarg_types
def _check_search_kwarg_types(self, kwargs): '''Checks that every element of kwargs is a valid type in this tree.''' for key in kwargs: if key not in self.node_types: raise TypeError("Invalid search type: {}".format(key))
python
def _check_search_kwarg_types(self, kwargs): '''Checks that every element of kwargs is a valid type in this tree.''' for key in kwargs: if key not in self.node_types: raise TypeError("Invalid search type: {}".format(key))
[ "def", "_check_search_kwarg_types", "(", "self", ",", "kwargs", ")", ":", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "self", ".", "node_types", ":", "raise", "TypeError", "(", "\"Invalid search type: {}\"", ".", "format", "(", "key", ")", ...
Checks that every element of kwargs is a valid type in this tree.
[ "Checks", "that", "every", "element", "of", "kwargs", "is", "a", "valid", "type", "in", "this", "tree", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/tree/b/tree.py#L147-L151
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
average
def average(x): """ Return a numpy array of column average. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column average Examples -------- ...
python
def average(x): """ Return a numpy array of column average. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column average Examples -------- ...
[ "def", "average", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "average", "(", "x", ",", "axis", "=", "1", ")", "return", "x" ]
Return a numpy array of column average. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column average Examples -------- >>> a = np.array([[1, 2, 3...
[ "Return", "a", "numpy", "array", "of", "column", "average", ".", "It", "does", "not", "affect", "if", "the", "array", "is", "one", "dimension" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L8-L35
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
mean
def mean(x): """ Return a numpy array of column mean. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column mean Examples -------- >>> a =...
python
def mean(x): """ Return a numpy array of column mean. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column mean Examples -------- >>> a =...
[ "def", "mean", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "mean", "(", "x", ",", "axis", "=", "1", ")", "return", "x" ]
Return a numpy array of column mean. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column mean Examples -------- >>> a = np.array([[1, 2, 3], [4,...
[ "Return", "a", "numpy", "array", "of", "column", "mean", ".", "It", "does", "not", "affect", "if", "the", "array", "is", "one", "dimension" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L37-L64
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
median
def median(x): """ Return a numpy array of column median. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column median Examples -------- >...
python
def median(x): """ Return a numpy array of column median. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column median Examples -------- >...
[ "def", "median", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "median", "(", "x", ",", "axis", "=", "1", ")", "return", "x" ]
Return a numpy array of column median. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column median Examples -------- >>> a = np.array([[1, 2, 3],...
[ "Return", "a", "numpy", "array", "of", "column", "median", ".", "It", "does", "not", "affect", "if", "the", "array", "is", "one", "dimension" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L66-L93
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
variance
def variance(x): """ Return a numpy array of column variance Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column variance Examples -------- >>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]...
python
def variance(x): """ Return a numpy array of column variance Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column variance Examples -------- >>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]...
[ "def", "variance", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "var", "(", "x", ",", "axis", "=", "1", ")", "return", "np", ".", "var", "(", "x", ...
Return a numpy array of column variance Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column variance Examples -------- >>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> np.testing.assert_...
[ "Return", "a", "numpy", "array", "of", "column", "variance" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L95-L123
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
standard_deviation
def standard_deviation(x): """ Return a numpy array of column standard deviation Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column standard deviation Examples -------- >>> a = np.array([[...
python
def standard_deviation(x): """ Return a numpy array of column standard deviation Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column standard deviation Examples -------- >>> a = np.array([[...
[ "def", "standard_deviation", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "std", "(", "x", ",", "axis", "=", "1", ")", "return", "np", ".", "std", "(",...
Return a numpy array of column standard deviation Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column standard deviation Examples -------- >>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>...
[ "Return", "a", "numpy", "array", "of", "column", "standard", "deviation" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L125-L153
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
confidential_interval
def confidential_interval(x, alpha=0.98): """ Return a numpy array of column confidential interval Parameters ---------- x : ndarray A numpy array instance alpha : float Alpha value of confidential interval Returns ------- ndarray A 1 x n numpy array which i...
python
def confidential_interval(x, alpha=0.98): """ Return a numpy array of column confidential interval Parameters ---------- x : ndarray A numpy array instance alpha : float Alpha value of confidential interval Returns ------- ndarray A 1 x n numpy array which i...
[ "def", "confidential_interval", "(", "x", ",", "alpha", "=", "0.98", ")", ":", "from", "scipy", ".", "stats", "import", "t", "if", "x", ".", "ndim", "==", "1", ":", "df", "=", "len", "(", "x", ")", "-", "1", "# calculate positive critical value of studen...
Return a numpy array of column confidential interval Parameters ---------- x : ndarray A numpy array instance alpha : float Alpha value of confidential interval Returns ------- ndarray A 1 x n numpy array which indicate the each difference from sample averag...
[ "Return", "a", "numpy", "array", "of", "column", "confidential", "interval" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L155-L188
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
simple_moving_matrix
def simple_moving_matrix(x, n=10): """ Create simple moving matrix. Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A n x n numpy array which will be useful for calculating ...
python
def simple_moving_matrix(x, n=10): """ Create simple moving matrix. Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A n x n numpy array which will be useful for calculating ...
[ "def", "simple_moving_matrix", "(", "x", ",", "n", "=", "10", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "x", "=", "np", ".", "average", "(", "x", ",", "axis", "=", "1", ")", "h"...
Create simple moving matrix. Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A n x n numpy array which will be useful for calculating confidentail interval of simple moving ...
[ "Create", "simple", "moving", "matrix", "." ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L190-L215
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
simple_moving_average
def simple_moving_average(x, n=10): """ Calculate simple moving average Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A 1 x n numpy array instance """ if x.ndim > ...
python
def simple_moving_average(x, n=10): """ Calculate simple moving average Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A 1 x n numpy array instance """ if x.ndim > ...
[ "def", "simple_moving_average", "(", "x", ",", "n", "=", "10", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "x", "=", "np", ".", "average", "(", "x", ",", "axis", "=", "1", ")", "a...
Calculate simple moving average Parameters ---------- x : ndarray A numpy array n : integer The number of sample points used to make average Returns ------- ndarray A 1 x n numpy array instance
[ "Calculate", "simple", "moving", "average" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L217-L236
rbarrois/volatildap
volatildap/server.py
find_available_port
def find_available_port(): """Find an available port. Simple trick: open a socket to localhost, see what port was allocated. Could fail in highly concurrent setups, though. """ s = socket.socket() s.bind(('localhost', 0)) _address, port = s.getsockname() s.close() return port
python
def find_available_port(): """Find an available port. Simple trick: open a socket to localhost, see what port was allocated. Could fail in highly concurrent setups, though. """ s = socket.socket() s.bind(('localhost', 0)) _address, port = s.getsockname() s.close() return port
[ "def", "find_available_port", "(", ")", ":", "s", "=", "socket", ".", "socket", "(", ")", "s", ".", "bind", "(", "(", "'localhost'", ",", "0", ")", ")", "_address", ",", "port", "=", "s", ".", "getsockname", "(", ")", "s", ".", "close", "(", ")",...
Find an available port. Simple trick: open a socket to localhost, see what port was allocated. Could fail in highly concurrent setups, though.
[ "Find", "an", "available", "port", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L378-L389
rbarrois/volatildap
volatildap/server.py
ldif_encode
def ldif_encode(attr, value): """Encode a attribute: value pair for the LDIF format. See RFC2849 for details. Rules are: - Text containing only chars <= 127 except control, ' ', '<', ':' is passed as-is - Other text is encoded through UTF-8 and base64-encoded - Binary data is simply base...
python
def ldif_encode(attr, value): """Encode a attribute: value pair for the LDIF format. See RFC2849 for details. Rules are: - Text containing only chars <= 127 except control, ' ', '<', ':' is passed as-is - Other text is encoded through UTF-8 and base64-encoded - Binary data is simply base...
[ "def", "ldif_encode", "(", "attr", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "return", "'%s:: %s'", "%", "(", "attr", ",", "base64", ".", "b64encode", "(", "value", ")", ".", "decode", "(", "'ascii'", ")", ")",...
Encode a attribute: value pair for the LDIF format. See RFC2849 for details. Rules are: - Text containing only chars <= 127 except control, ' ', '<', ':' is passed as-is - Other text is encoded through UTF-8 and base64-encoded - Binary data is simply base64-encoded Returns: A 'k...
[ "Encode", "a", "attribute", ":", "value", "pair", "for", "the", "LDIF", "format", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L399-L418
rbarrois/volatildap
volatildap/server.py
OpenLdapPaths._find_file
def _find_file(self, needle, candidates): """Find the first directory containing a given candidate file.""" for candidate in candidates: fullpath = os.path.join(candidate, needle) if os.path.isfile(fullpath): return fullpath raise PathError("Unable to loca...
python
def _find_file(self, needle, candidates): """Find the first directory containing a given candidate file.""" for candidate in candidates: fullpath = os.path.join(candidate, needle) if os.path.isfile(fullpath): return fullpath raise PathError("Unable to loca...
[ "def", "_find_file", "(", "self", ",", "needle", ",", "candidates", ")", ":", "for", "candidate", "in", "candidates", ":", "fullpath", "=", "os", ".", "path", ".", "join", "(", "candidate", ",", "needle", ")", "if", "os", ".", "path", ".", "isfile", ...
Find the first directory containing a given candidate file.
[ "Find", "the", "first", "directory", "containing", "a", "given", "candidate", "file", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L53-L59
rbarrois/volatildap
volatildap/server.py
LdapServer._locate_schemas
def _locate_schemas(self, schemas, skip_missing_schemas): """Locate all schemas (look in openldap store). If skip_missing_schemas is True, ignore missing schemas; otherwise, raise. """ for schema in schemas: if schema == os.path.abspath(schema): schem...
python
def _locate_schemas(self, schemas, skip_missing_schemas): """Locate all schemas (look in openldap store). If skip_missing_schemas is True, ignore missing schemas; otherwise, raise. """ for schema in schemas: if schema == os.path.abspath(schema): schem...
[ "def", "_locate_schemas", "(", "self", ",", "schemas", ",", "skip_missing_schemas", ")", ":", "for", "schema", "in", "schemas", ":", "if", "schema", "==", "os", ".", "path", ".", "abspath", "(", "schema", ")", ":", "schema_file", "=", "schema", "else", "...
Locate all schemas (look in openldap store). If skip_missing_schemas is True, ignore missing schemas; otherwise, raise.
[ "Locate", "all", "schemas", "(", "look", "in", "openldap", "store", ")", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L110-L128
rbarrois/volatildap
volatildap/server.py
LdapServer._start
def _start(self): """Start the server.""" assert self._tempdir is not None assert self._process is None self._process = subprocess.Popen( [ self.paths.slapd, '-f', self._slapd_conf, '-h', self.uri, '-d', str(self...
python
def _start(self): """Start the server.""" assert self._tempdir is not None assert self._process is None self._process = subprocess.Popen( [ self.paths.slapd, '-f', self._slapd_conf, '-h', self.uri, '-d', str(self...
[ "def", "_start", "(", "self", ")", ":", "assert", "self", ".", "_tempdir", "is", "not", "None", "assert", "self", ".", "_process", "is", "None", "self", ".", "_process", "=", "subprocess", ".", "Popen", "(", "[", "self", ".", "paths", ".", "slapd", "...
Start the server.
[ "Start", "the", "server", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L269-L283
rbarrois/volatildap
volatildap/server.py
LdapServer._populate
def _populate(self): """Populate a *running* server with initial data.""" self.add(self._core_data) if self.initial_data: self.add(self.initial_data)
python
def _populate(self): """Populate a *running* server with initial data.""" self.add(self._core_data) if self.initial_data: self.add(self.initial_data)
[ "def", "_populate", "(", "self", ")", ":", "self", ".", "add", "(", "self", ".", "_core_data", ")", "if", "self", ".", "initial_data", ":", "self", ".", "add", "(", "self", ".", "initial_data", ")" ]
Populate a *running* server with initial data.
[ "Populate", "a", "*", "running", "*", "server", "with", "initial", "data", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L285-L289
rbarrois/volatildap
volatildap/server.py
LdapServer._poll_slapd
def _poll_slapd(self, timeout=DEFAULT_STARTUP_DELAY): """Poll slapd port until available.""" begin = time.time() time.sleep(0.5) while time.time() < begin + timeout: if self._process.poll() is not None: raise RuntimeError("LDAP server has exited before starti...
python
def _poll_slapd(self, timeout=DEFAULT_STARTUP_DELAY): """Poll slapd port until available.""" begin = time.time() time.sleep(0.5) while time.time() < begin + timeout: if self._process.poll() is not None: raise RuntimeError("LDAP server has exited before starti...
[ "def", "_poll_slapd", "(", "self", ",", "timeout", "=", "DEFAULT_STARTUP_DELAY", ")", ":", "begin", "=", "time", ".", "time", "(", ")", "time", ".", "sleep", "(", "0.5", ")", "while", "time", ".", "time", "(", ")", "<", "begin", "+", "timeout", ":", ...
Poll slapd port until available.
[ "Poll", "slapd", "port", "until", "available", "." ]
train
https://github.com/rbarrois/volatildap/blob/08df9d5f2f65400e51eae7a50e64759bdbdce6f2/volatildap/server.py#L335-L355
carlosp420/dataset-creator
dataset_creator/genbank_fasta.py
GenBankFASTADatasetBlock.convert_to_string
def convert_to_string(self, block): """ Takes a list of SeqRecordExpanded objects corresponding to a gene_code and produces the gene_block as string. :param block: :return: str. """ out = "" for seq_record in block: taxon_id = ">{0}_{1}_{2} [o...
python
def convert_to_string(self, block): """ Takes a list of SeqRecordExpanded objects corresponding to a gene_code and produces the gene_block as string. :param block: :return: str. """ out = "" for seq_record in block: taxon_id = ">{0}_{1}_{2} [o...
[ "def", "convert_to_string", "(", "self", ",", "block", ")", ":", "out", "=", "\"\"", "for", "seq_record", "in", "block", ":", "taxon_id", "=", "\">{0}_{1}_{2} [org={0} {1}] [Specimen-voucher={2}] \"", "\"[note={3} gene, partial cds.] [Lineage={4}]\"", ".", "format", "(", ...
Takes a list of SeqRecordExpanded objects corresponding to a gene_code and produces the gene_block as string. :param block: :return: str.
[ "Takes", "a", "list", "of", "SeqRecordExpanded", "objects", "corresponding", "to", "a", "gene_code", "and", "produces", "the", "gene_block", "as", "string", "." ]
train
https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/genbank_fasta.py#L6-L33
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.create_view
def create_view(self, query_criteria=None, uid='_all_users'): ''' a method to add a view to a design document of a uid :param query_criteria: dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to update ...
python
def create_view(self, query_criteria=None, uid='_all_users'): ''' a method to add a view to a design document of a uid :param query_criteria: dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to update ...
[ "def", "create_view", "(", "self", ",", "query_criteria", "=", "None", ",", "uid", "=", "'_all_users'", ")", ":", "# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/query/put__db___design__ddoc_", "# https://developer.couchbas...
a method to add a view to a design document of a uid :param query_criteria: dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to update :return: integer with status of operation an example of how to construct the quer...
[ "a", "method", "to", "add", "a", "view", "to", "a", "design", "document", "of", "a", "uid", ":", "param", "query_criteria", ":", "dictionary", "with", "valid", "jsonmodel", "query", "criteria", ":", "param", "uid", ":", "[", "optional", "]", "string", "w...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L255-L364
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.delete_view
def delete_view(self, query_criteria=None, uid='_all_users'): ''' a method to delete a view associated with a user design doc :param query_criteria: [optional] dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to up...
python
def delete_view(self, query_criteria=None, uid='_all_users'): ''' a method to delete a view associated with a user design doc :param query_criteria: [optional] dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to up...
[ "def", "delete_view", "(", "self", ",", "query_criteria", "=", "None", ",", "uid", "=", "'_all_users'", ")", ":", "# https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/query/delete__db___design__ddoc_", "title", "=", "'%s.del...
a method to delete a view associated with a user design doc :param query_criteria: [optional] dictionary with valid jsonmodel query criteria :param uid: [optional] string with uid of design document to update :return: integer with status of operation an example ...
[ "a", "method", "to", "delete", "a", "view", "associated", "with", "a", "user", "design", "doc", ":", "param", "query_criteria", ":", "[", "optional", "]", "dictionary", "with", "valid", "jsonmodel", "query", "criteria", ":", "param", "uid", ":", "[", "opti...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L366-L454
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.list_users
def list_users(self): ''' a method to list all the user ids of all users in the bucket ''' # construct url url = self.bucket_url + '/_user/' # send request and unwrap response response = requests.get(url) response = response.json() return response
python
def list_users(self): ''' a method to list all the user ids of all users in the bucket ''' # construct url url = self.bucket_url + '/_user/' # send request and unwrap response response = requests.get(url) response = response.json() return response
[ "def", "list_users", "(", "self", ")", ":", "# construct url", "url", "=", "self", ".", "bucket_url", "+", "'/_user/'", "# send request and unwrap response", "response", "=", "requests", ".", "get", "(", "url", ")", "response", "=", "response", ".", "json", "(...
a method to list all the user ids of all users in the bucket
[ "a", "method", "to", "list", "all", "the", "user", "ids", "of", "all", "users", "in", "the", "bucket" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L456-L467
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.save_user
def save_user(self, uid, user_password, user_email='', user_channels=None, user_roles=None, user_views=None, disable_account=False): ''' a method to add or update an authorized user to the bucket :param uid: string with id to assign to user :param user_password: string ...
python
def save_user(self, uid, user_password, user_email='', user_channels=None, user_roles=None, user_views=None, disable_account=False): ''' a method to add or update an authorized user to the bucket :param uid: string with id to assign to user :param user_password: string ...
[ "def", "save_user", "(", "self", ",", "uid", ",", "user_password", ",", "user_email", "=", "''", ",", "user_channels", "=", "None", ",", "user_roles", "=", "None", ",", "user_views", "=", "None", ",", "disable_account", "=", "False", ")", ":", "# https://d...
a method to add or update an authorized user to the bucket :param uid: string with id to assign to user :param user_password: string with password to assign to user :param user_email: [optional] string with email of user for future lookup :param user_channels: [optional] lis...
[ "a", "method", "to", "add", "or", "update", "an", "authorized", "user", "to", "the", "bucket", ":", "param", "uid", ":", "string", "with", "id", "to", "assign", "to", "user", ":", "param", "user_password", ":", "string", "with", "password", "to", "assign...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L469-L535
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.load_user
def load_user(self, uid): ''' a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :return: dictionary with account fields for user ''' title = '%s.load_user' % self.__class__.__name__ ...
python
def load_user(self, uid): ''' a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :return: dictionary with account fields for user ''' title = '%s.load_user' % self.__class__.__name__ ...
[ "def", "load_user", "(", "self", ",", "uid", ")", ":", "title", "=", "'%s.load_user'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'uid'", ":", "uid", "}", "for", "key", ",", "value", "in", "input_fields"...
a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :return: dictionary with account fields for user
[ "a", "method", "to", "retrieve", "the", "account", "details", "of", "a", "user", "in", "the", "bucket", ":", "param", "uid", ":", "string", "with", "id", "of", "user", "in", "bucket", ":", "return", ":", "dictionary", "with", "account", "fields", "for", ...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L537-L564
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.delete_user
def delete_user(self, uid, delete_views=True): ''' a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :param delete_views: boolean to remove indices attached to user :return: integer with status ...
python
def delete_user(self, uid, delete_views=True): ''' a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :param delete_views: boolean to remove indices attached to user :return: integer with status ...
[ "def", "delete_user", "(", "self", ",", "uid", ",", "delete_views", "=", "True", ")", ":", "title", "=", "'%s.delete_user'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'uid'", ":", "uid", "}", "for", "ke...
a method to retrieve the account details of a user in the bucket :param uid: string with id of user in bucket :param delete_views: boolean to remove indices attached to user :return: integer with status of delete operation
[ "a", "method", "to", "retrieve", "the", "account", "details", "of", "a", "user", "in", "the", "bucket", ":", "param", "uid", ":", "string", "with", "id", "of", "user", "in", "bucket", ":", "param", "delete_views", ":", "boolean", "to", "remove", "indices...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L566-L603
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.create_session
def create_session(self, uid, duration=0): ''' a method to create a session token for the user :param uid: string with id of user in bucket :param duration: integer with number of seconds to last (default: 24hrs) :return: dictionary with account fields for user...
python
def create_session(self, uid, duration=0): ''' a method to create a session token for the user :param uid: string with id of user in bucket :param duration: integer with number of seconds to last (default: 24hrs) :return: dictionary with account fields for user...
[ "def", "create_session", "(", "self", ",", "uid", ",", "duration", "=", "0", ")", ":", "title", "=", "'%s.create_session'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'uid'", ":", "uid", ",", "'duration'",...
a method to create a session token for the user :param uid: string with id of user in bucket :param duration: integer with number of seconds to last (default: 24hrs) :return: dictionary with account fields for user
[ "a", "method", "to", "create", "a", "session", "token", "for", "the", "user", ":", "param", "uid", ":", "string", "with", "id", "of", "user", "in", "bucket", ":", "param", "duration", ":", "integer", "with", "number", "of", "seconds", "to", "last", "("...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L605-L639
collectiveacuity/labPack
labpack/databases/couchbase.py
syncGatewayClient.delete_sessions
def delete_sessions(self, uid): ''' a method to delete all session tokens associated with a user :param uid: string with id of user in bucket :return: integer with status code of delete operation ''' title = '%s.delete_session' % self.__clas...
python
def delete_sessions(self, uid): ''' a method to delete all session tokens associated with a user :param uid: string with id of user in bucket :return: integer with status code of delete operation ''' title = '%s.delete_session' % self.__clas...
[ "def", "delete_sessions", "(", "self", ",", "uid", ")", ":", "title", "=", "'%s.delete_session'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'uid'", ":", "uid", "}", "for", "key", ",", "value", "in", "in...
a method to delete all session tokens associated with a user :param uid: string with id of user in bucket :return: integer with status code of delete operation
[ "a", "method", "to", "delete", "all", "session", "tokens", "associated", "with", "a", "user", ":", "param", "uid", ":", "string", "with", "id", "of", "user", "in", "bucket", ":", "return", ":", "integer", "with", "status", "code", "of", "delete", "operat...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/couchbase.py#L668-L693