repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
SBRG/ssbio | ssbio/protein/structure/utils/foldx.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/utils/foldx.py#L107-L131 | def run_repair_pdb(self, silent=False, force_rerun=False):
"""Run FoldX RepairPDB on this PDB file.
Original command::
foldx --command=RepairPDB --pdb=4bxi.pdb
Args:
silent (bool): If FoldX output should be silenced from printing to the shell.
force_rerun (... | [
"def",
"run_repair_pdb",
"(",
"self",
",",
"silent",
"=",
"False",
",",
"force_rerun",
"=",
"False",
")",
":",
"# Create RepairPDB command",
"foldx_repair_pdb",
"=",
"'foldx --command=RepairPDB --pdb={}'",
".",
"format",
"(",
"self",
".",
"pdb_file",
")",
"# Repaire... | Run FoldX RepairPDB on this PDB file.
Original command::
foldx --command=RepairPDB --pdb=4bxi.pdb
Args:
silent (bool): If FoldX output should be silenced from printing to the shell.
force_rerun (bool): If FoldX RepairPDB should be rerun even if a repaired file exis... | [
"Run",
"FoldX",
"RepairPDB",
"on",
"this",
"PDB",
"file",
"."
] | python | train |
adafruit/Adafruit_Python_GPIO | Adafruit_GPIO/FT232H.py | https://github.com/adafruit/Adafruit_Python_GPIO/blob/a92a23d6b5869663b2bc1ccf78bb11585076a9c4/Adafruit_GPIO/FT232H.py#L700-L716 | def _i2c_read_bytes(self, length=1):
"""Read the specified number of bytes from the I2C bus. Length is the
number of bytes to read (must be 1 or more).
"""
for i in range(length-1):
# Read a byte and send ACK.
self._command.append('\x20\x00\x00\x13\x00\x00')
... | [
"def",
"_i2c_read_bytes",
"(",
"self",
",",
"length",
"=",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"length",
"-",
"1",
")",
":",
"# Read a byte and send ACK.",
"self",
".",
"_command",
".",
"append",
"(",
"'\\x20\\x00\\x00\\x13\\x00\\x00'",
")",
"# Ma... | Read the specified number of bytes from the I2C bus. Length is the
number of bytes to read (must be 1 or more). | [
"Read",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"I2C",
"bus",
".",
"Length",
"is",
"the",
"number",
"of",
"bytes",
"to",
"read",
"(",
"must",
"be",
"1",
"or",
"more",
")",
"."
] | python | valid |
SBRG/ssbio | ssbio/databases/swissmodel.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/databases/swissmodel.py#L168-L201 | def get_oligomeric_state(swiss_model_path):
"""Parse the oligomeric prediction in a SWISS-MODEL repository file
As of 2018-02-26, works on all E. coli models. Untested on other pre-made organism models.
Args:
swiss_model_path (str): Path to SWISS-MODEL PDB file
Returns:
dict: Informat... | [
"def",
"get_oligomeric_state",
"(",
"swiss_model_path",
")",
":",
"oligo_info",
"=",
"{",
"}",
"with",
"open",
"(",
"swiss_model_path",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"startswith",
"(",
"'REMARK 3 MODEL... | Parse the oligomeric prediction in a SWISS-MODEL repository file
As of 2018-02-26, works on all E. coli models. Untested on other pre-made organism models.
Args:
swiss_model_path (str): Path to SWISS-MODEL PDB file
Returns:
dict: Information parsed about the oligomeric state | [
"Parse",
"the",
"oligomeric",
"prediction",
"in",
"a",
"SWISS",
"-",
"MODEL",
"repository",
"file"
] | python | train |
ericmjl/nxviz | nxviz/plots.py | https://github.com/ericmjl/nxviz/blob/6ea5823a8030a686f165fbe37d7a04d0f037ecc9/nxviz/plots.py#L671-L714 | def store_node_label_meta(self, x, y, tx, ty, rot):
"""
This function stored coordinates-related metadate for a node
This function should not be called by the user
:param x: x location of node label or number
:type x: np.float64
:param y: y location of node label or num... | [
"def",
"store_node_label_meta",
"(",
"self",
",",
"x",
",",
"y",
",",
"tx",
",",
"ty",
",",
"rot",
")",
":",
"# Store computed values",
"self",
".",
"node_label_coords",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"x",
")",
"self",
".",
"node_label_coords",
"... | This function stored coordinates-related metadate for a node
This function should not be called by the user
:param x: x location of node label or number
:type x: np.float64
:param y: y location of node label or number
:type y: np.float64
:param tx: text location x of n... | [
"This",
"function",
"stored",
"coordinates",
"-",
"related",
"metadate",
"for",
"a",
"node",
"This",
"function",
"should",
"not",
"be",
"called",
"by",
"the",
"user"
] | python | train |
SUNCAT-Center/CatHub | cathub/reaction_networks.py | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/reaction_networks.py#L749-L848 | def reaction_scheme(self, df, temperature, pressure, pH, potential):
"""Returns a dataframe with Gibbs free reaction energies.
Parameters
----------
df : Pandas DataFrame generated by db_to_df
temperature : numeric
temperature in K
pressure : numeric
... | [
"def",
"reaction_scheme",
"(",
"self",
",",
"df",
",",
"temperature",
",",
"pressure",
",",
"pH",
",",
"potential",
")",
":",
"# set reaction scheme",
"reactions",
"=",
"self",
".",
"intermediates",
"df_param",
"=",
"self",
".",
"df_reaction_parameters",
".",
... | Returns a dataframe with Gibbs free reaction energies.
Parameters
----------
df : Pandas DataFrame generated by db_to_df
temperature : numeric
temperature in K
pressure : numeric
pressure in mbar
pH : PH in bulk solution
potential : Electri... | [
"Returns",
"a",
"dataframe",
"with",
"Gibbs",
"free",
"reaction",
"energies",
"."
] | python | train |
annoviko/pyclustering | pyclustering/cluster/fcm.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/fcm.py#L240-L256 | def __calculate_centers(self):
"""!
@brief Calculate center using membership of each cluster.
@return (list) Updated clusters as list of clusters. Each cluster contains indexes of objects from data.
@return (numpy.array) Updated centers.
"""
dimension = self._... | [
"def",
"__calculate_centers",
"(",
"self",
")",
":",
"dimension",
"=",
"self",
".",
"__data",
".",
"shape",
"[",
"1",
"]",
"centers",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"len",
"(",
"self",
".",
"__centers",
")",
",",
"dimension",
")",
")",
"for",
... | !
@brief Calculate center using membership of each cluster.
@return (list) Updated clusters as list of clusters. Each cluster contains indexes of objects from data.
@return (numpy.array) Updated centers. | [
"!"
] | python | valid |
DataDog/integrations-core | postgres/datadog_checks/postgres/postgres.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/postgres/datadog_checks/postgres/postgres.py#L759-L834 | def _collect_stats(
self,
key,
db,
instance_tags,
relations,
custom_metrics,
collect_function_metrics,
collect_count_metrics,
collect_activity_metrics,
collect_database_size_metrics,
collect_default_db,
interface_error,
... | [
"def",
"_collect_stats",
"(",
"self",
",",
"key",
",",
"db",
",",
"instance_tags",
",",
"relations",
",",
"custom_metrics",
",",
"collect_function_metrics",
",",
"collect_count_metrics",
",",
"collect_activity_metrics",
",",
"collect_database_size_metrics",
",",
"collec... | Query pg_stat_* for various metrics
If relations is not an empty list, gather per-relation metrics
on top of that.
If custom_metrics is not an empty list, gather custom metrics defined in postgres.yaml | [
"Query",
"pg_stat_",
"*",
"for",
"various",
"metrics",
"If",
"relations",
"is",
"not",
"an",
"empty",
"list",
"gather",
"per",
"-",
"relation",
"metrics",
"on",
"top",
"of",
"that",
".",
"If",
"custom_metrics",
"is",
"not",
"an",
"empty",
"list",
"gather",... | python | train |
consbio/gis-metadata-parser | gis_metadata/utils.py | https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L201-L208 | def get_xpath_branch(xroot, xpath):
""" :return: the relative part of an XPATH: that which extends past the root provided """
if xroot and xpath and xpath.startswith(xroot):
xpath = xpath[len(xroot):]
xpath = xpath.lstrip(XPATH_DELIM)
return xpath | [
"def",
"get_xpath_branch",
"(",
"xroot",
",",
"xpath",
")",
":",
"if",
"xroot",
"and",
"xpath",
"and",
"xpath",
".",
"startswith",
"(",
"xroot",
")",
":",
"xpath",
"=",
"xpath",
"[",
"len",
"(",
"xroot",
")",
":",
"]",
"xpath",
"=",
"xpath",
".",
"... | :return: the relative part of an XPATH: that which extends past the root provided | [
":",
"return",
":",
"the",
"relative",
"part",
"of",
"an",
"XPATH",
":",
"that",
"which",
"extends",
"past",
"the",
"root",
"provided"
] | python | train |
saltstack/salt | salt/cloud/clouds/virtualbox.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/virtualbox.py#L92-L113 | def map_clonemode(vm_info):
"""
Convert the virtualbox config file values for clone_mode into the integers the API requires
"""
mode_map = {
'state': 0,
'child': 1,
'all': 2
}
if not vm_info:
return DEFAULT_CLONE_MODE
if 'clonemode' not in vm_info:
retur... | [
"def",
"map_clonemode",
"(",
"vm_info",
")",
":",
"mode_map",
"=",
"{",
"'state'",
":",
"0",
",",
"'child'",
":",
"1",
",",
"'all'",
":",
"2",
"}",
"if",
"not",
"vm_info",
":",
"return",
"DEFAULT_CLONE_MODE",
"if",
"'clonemode'",
"not",
"in",
"vm_info",
... | Convert the virtualbox config file values for clone_mode into the integers the API requires | [
"Convert",
"the",
"virtualbox",
"config",
"file",
"values",
"for",
"clone_mode",
"into",
"the",
"integers",
"the",
"API",
"requires"
] | python | train |
what-studio/profiling | profiling/__main__.py | https://github.com/what-studio/profiling/blob/49666ba3ea295eb73782ae6c18a4ec7929d7d8b7/profiling/__main__.py#L235-L242 | def import_(module_name, name):
"""Imports an object by a relative module path::
Profiler = import_('profiling.profiler', 'Profiler')
"""
module = importlib.import_module(module_name, __package__)
return getattr(module, name) | [
"def",
"import_",
"(",
"module_name",
",",
"name",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
",",
"__package__",
")",
"return",
"getattr",
"(",
"module",
",",
"name",
")"
] | Imports an object by a relative module path::
Profiler = import_('profiling.profiler', 'Profiler') | [
"Imports",
"an",
"object",
"by",
"a",
"relative",
"module",
"path",
"::"
] | python | train |
ladybug-tools/ladybug | ladybug/skymodel.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/skymodel.py#L164-L224 | def zhang_huang_solar_split(altitudes, doys, cloud_cover, relative_humidity,
dry_bulb_present, dry_bulb_t3_hrs, wind_speed,
atm_pressure, use_disc=False):
"""Calculate direct and diffuse solar irradiance using the Zhang-Huang model.
By default, this funct... | [
"def",
"zhang_huang_solar_split",
"(",
"altitudes",
",",
"doys",
",",
"cloud_cover",
",",
"relative_humidity",
",",
"dry_bulb_present",
",",
"dry_bulb_t3_hrs",
",",
"wind_speed",
",",
"atm_pressure",
",",
"use_disc",
"=",
"False",
")",
":",
"# Calculate global horizon... | Calculate direct and diffuse solar irradiance using the Zhang-Huang model.
By default, this function uses the DIRINT method (aka. Perez split) to split global
irradiance into direct and diffuse. This is the same method used by EnergyPlus.
Args:
altitudes: A list of solar altitudes in degrees.
... | [
"Calculate",
"direct",
"and",
"diffuse",
"solar",
"irradiance",
"using",
"the",
"Zhang",
"-",
"Huang",
"model",
"."
] | python | train |
lepture/python-livereload | livereload/handlers.py | https://github.com/lepture/python-livereload/blob/f80cb3ae0f8f2cdf38203a712fe25ef7f1899c34/livereload/handlers.py#L116-L136 | def on_message(self, message):
"""Handshake with livereload.js
1. client send 'hello'
2. server reply 'hello'
3. client send 'info'
"""
message = ObjectDict(escape.json_decode(message))
if message.command == 'hello':
handshake = {
'com... | [
"def",
"on_message",
"(",
"self",
",",
"message",
")",
":",
"message",
"=",
"ObjectDict",
"(",
"escape",
".",
"json_decode",
"(",
"message",
")",
")",
"if",
"message",
".",
"command",
"==",
"'hello'",
":",
"handshake",
"=",
"{",
"'command'",
":",
"'hello... | Handshake with livereload.js
1. client send 'hello'
2. server reply 'hello'
3. client send 'info' | [
"Handshake",
"with",
"livereload",
".",
"js"
] | python | train |
chrisdev/django-pandas | django_pandas/managers.py | https://github.com/chrisdev/django-pandas/blob/8276d699f25dca7da58e6c3fcebbd46e1c3e35e9/django_pandas/managers.py#L84-L133 | def to_pivot_table(self, fieldnames=(), verbose=True,
values=None, rows=None, cols=None,
aggfunc='mean', fill_value=None, margins=False,
dropna=True, coerce_float=True):
"""
A convenience method for creating a spread sheet style pivot ... | [
"def",
"to_pivot_table",
"(",
"self",
",",
"fieldnames",
"=",
"(",
")",
",",
"verbose",
"=",
"True",
",",
"values",
"=",
"None",
",",
"rows",
"=",
"None",
",",
"cols",
"=",
"None",
",",
"aggfunc",
"=",
"'mean'",
",",
"fill_value",
"=",
"None",
",",
... | A convenience method for creating a spread sheet style pivot table
as a DataFrame
Parameters
----------
fieldnames: The model field names(columns) to utilise in creating
the DataFrame. You can span a relationships in the usual
Django ORM way by ... | [
"A",
"convenience",
"method",
"for",
"creating",
"a",
"spread",
"sheet",
"style",
"pivot",
"table",
"as",
"a",
"DataFrame",
"Parameters",
"----------",
"fieldnames",
":",
"The",
"model",
"field",
"names",
"(",
"columns",
")",
"to",
"utilise",
"in",
"creating",... | python | train |
senaite/senaite.core | bika/lims/content/analysisrequest.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/analysisrequest.py#L2215-L2224 | def getAncestors(self, all_ancestors=True):
"""Returns the ancestor(s) of this Analysis Request
param all_ancestors: include all ancestors, not only the parent
"""
parent = self.getParentAnalysisRequest()
if not parent:
return list()
if not all_ancestors:
... | [
"def",
"getAncestors",
"(",
"self",
",",
"all_ancestors",
"=",
"True",
")",
":",
"parent",
"=",
"self",
".",
"getParentAnalysisRequest",
"(",
")",
"if",
"not",
"parent",
":",
"return",
"list",
"(",
")",
"if",
"not",
"all_ancestors",
":",
"return",
"[",
"... | Returns the ancestor(s) of this Analysis Request
param all_ancestors: include all ancestors, not only the parent | [
"Returns",
"the",
"ancestor",
"(",
"s",
")",
"of",
"this",
"Analysis",
"Request",
"param",
"all_ancestors",
":",
"include",
"all",
"ancestors",
"not",
"only",
"the",
"parent"
] | python | train |
SpamScope/mail-parser | mailparser/mailparser.py | https://github.com/SpamScope/mail-parser/blob/814b56d0b803feab9dea04f054b802ce138097e2/mailparser/mailparser.py#L529-L536 | def headers(self):
"""
Return only the headers as Python object
"""
d = {}
for k, v in self.message.items():
d[k] = decode_header_part(v)
return d | [
"def",
"headers",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"message",
".",
"items",
"(",
")",
":",
"d",
"[",
"k",
"]",
"=",
"decode_header_part",
"(",
"v",
")",
"return",
"d"
] | Return only the headers as Python object | [
"Return",
"only",
"the",
"headers",
"as",
"Python",
"object"
] | python | train |
nicferrier/md | src/mdlib/cli.py | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L317-L355 | def do_storecheck(self, subcmd, opts):
"""${cmd_name}: checks the store for files that may not be in the maildirs.
"""
from os.path import basename
from os.path import dirname
from os.path import exists as existspath
from os.path import islink
from os.path import ... | [
"def",
"do_storecheck",
"(",
"self",
",",
"subcmd",
",",
"opts",
")",
":",
"from",
"os",
".",
"path",
"import",
"basename",
"from",
"os",
".",
"path",
"import",
"dirname",
"from",
"os",
".",
"path",
"import",
"exists",
"as",
"existspath",
"from",
"os",
... | ${cmd_name}: checks the store for files that may not be in the maildirs. | [
"$",
"{",
"cmd_name",
"}",
":",
"checks",
"the",
"store",
"for",
"files",
"that",
"may",
"not",
"be",
"in",
"the",
"maildirs",
"."
] | python | train |
rosenbrockc/fortpy | fortpy/elements.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/elements.py#L687-L698 | def search_dependencies(self):
"""Returns a list of modules that this executable needs in order to run
properly. This includes special kind declarations for precision or derived
types, but not dependency executable calls.
"""
#It is understood that this executable's module is obv... | [
"def",
"search_dependencies",
"(",
"self",
")",
":",
"#It is understood that this executable's module is obviously required. Just",
"#add any additional modules from the parameters.",
"result",
"=",
"[",
"p",
".",
"dependency",
"(",
")",
"for",
"p",
"in",
"self",
".",
"orde... | Returns a list of modules that this executable needs in order to run
properly. This includes special kind declarations for precision or derived
types, but not dependency executable calls. | [
"Returns",
"a",
"list",
"of",
"modules",
"that",
"this",
"executable",
"needs",
"in",
"order",
"to",
"run",
"properly",
".",
"This",
"includes",
"special",
"kind",
"declarations",
"for",
"precision",
"or",
"derived",
"types",
"but",
"not",
"dependency",
"execu... | python | train |
belbio/bel | bel/lang/completion.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/lang/completion.py#L369-L491 | def arg_completions(
completion_text: str,
parent_function: str,
args: list,
arg_idx: int,
bel_spec: BELSpec,
bel_fmt: str,
species_id: str,
namespace: str,
size: int,
):
"""Function argument completion
Only allow legal options for completion given function name, arguments a... | [
"def",
"arg_completions",
"(",
"completion_text",
":",
"str",
",",
"parent_function",
":",
"str",
",",
"args",
":",
"list",
",",
"arg_idx",
":",
"int",
",",
"bel_spec",
":",
"BELSpec",
",",
"bel_fmt",
":",
"str",
",",
"species_id",
":",
"str",
",",
"name... | Function argument completion
Only allow legal options for completion given function name, arguments and index of argument
to replace.
Args:
completion_text: text to use for completion - used for creating highlight
parent_function: BEL function containing these args
args: arguments ... | [
"Function",
"argument",
"completion"
] | python | train |
daler/metaseq | metaseq/results_table.py | https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L108-L129 | def features(self, ignore_unknown=False):
"""
Generator of features.
If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for
every feature in the dataframe's index.
Parameters
----------
ignore_unknown : bool
If True, silently ignores ... | [
"def",
"features",
"(",
"self",
",",
"ignore_unknown",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"db",
":",
"raise",
"ValueError",
"(",
"\"Please attach a gffutils.FeatureDB\"",
")",
"for",
"i",
"in",
"self",
".",
"data",
".",
"index",
":",
"try",
... | Generator of features.
If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for
every feature in the dataframe's index.
Parameters
----------
ignore_unknown : bool
If True, silently ignores features that are not found in the db. | [
"Generator",
"of",
"features",
"."
] | python | train |
mnick/scikit-tensor | sktensor/core.py | https://github.com/mnick/scikit-tensor/blob/fe517e9661a08164b8d30d2dddf7c96aeeabcf36/sktensor/core.py#L333-L378 | def khatrirao(A, reverse=False):
"""
Compute the columnwise Khatri-Rao product.
Parameters
----------
A : tuple of ndarrays
Matrices for which the columnwise Khatri-Rao product should be computed
reverse : boolean
Compute Khatri-Rao product in reverse order
Examples
--... | [
"def",
"khatrirao",
"(",
"A",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"A",
",",
"tuple",
")",
":",
"raise",
"ValueError",
"(",
"'A must be a tuple of array likes'",
")",
"N",
"=",
"A",
"[",
"0",
"]",
".",
"shape",
"[",
... | Compute the columnwise Khatri-Rao product.
Parameters
----------
A : tuple of ndarrays
Matrices for which the columnwise Khatri-Rao product should be computed
reverse : boolean
Compute Khatri-Rao product in reverse order
Examples
--------
>>> A = np.random.randn(5, 2)
... | [
"Compute",
"the",
"columnwise",
"Khatri",
"-",
"Rao",
"product",
"."
] | python | train |
cltrudeau/django-awl | awl/utils.py | https://github.com/cltrudeau/django-awl/blob/70d469ef9a161c1170b53aa017cf02d7c15eb90c/awl/utils.py#L46-L56 | def refetch_for_update(obj):
"""Queries the database for the same object that is passed in, refetching
its contents and runs ``select_for_update()`` to lock the corresponding
row until the next commit.
:param obj:
Object to refetch
:returns:
Refreshed version of the object
"""
... | [
"def",
"refetch_for_update",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"__class__",
".",
"objects",
".",
"select_for_update",
"(",
")",
".",
"get",
"(",
"id",
"=",
"obj",
".",
"id",
")"
] | Queries the database for the same object that is passed in, refetching
its contents and runs ``select_for_update()`` to lock the corresponding
row until the next commit.
:param obj:
Object to refetch
:returns:
Refreshed version of the object | [
"Queries",
"the",
"database",
"for",
"the",
"same",
"object",
"that",
"is",
"passed",
"in",
"refetching",
"its",
"contents",
"and",
"runs",
"select_for_update",
"()",
"to",
"lock",
"the",
"corresponding",
"row",
"until",
"the",
"next",
"commit",
"."
] | python | valid |
flask-restful/flask-restful | flask_restful/reqparse.py | https://github.com/flask-restful/flask-restful/blob/25544d697c1f82bafbd1320960df459f58a58e03/flask_restful/reqparse.py#L348-L356 | def replace_argument(self, name, *args, **kwargs):
""" Replace the argument matching the given name with a new version. """
new_arg = self.argument_class(name, *args, **kwargs)
for index, arg in enumerate(self.args[:]):
if new_arg.name == arg.name:
del self.args[index... | [
"def",
"replace_argument",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new_arg",
"=",
"self",
".",
"argument_class",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"index",
",",
"arg",
"in",
... | Replace the argument matching the given name with a new version. | [
"Replace",
"the",
"argument",
"matching",
"the",
"given",
"name",
"with",
"a",
"new",
"version",
"."
] | python | train |
cameronbwhite/Flask-CAS | flask_cas/cas_urls.py | https://github.com/cameronbwhite/Flask-CAS/blob/f85173938654cb9b9316a5c869000b74b008422e/flask_cas/cas_urls.py#L50-L74 | def create_cas_login_url(cas_url, cas_route, service, renew=None, gateway=None):
""" Create a CAS login URL .
Keyword arguments:
cas_url -- The url to the CAS (ex. http://sso.pdx.edu)
cas_route -- The route where the CAS lives on server (ex. /cas)
service -- (ex. http://localhost:5000/login)
r... | [
"def",
"create_cas_login_url",
"(",
"cas_url",
",",
"cas_route",
",",
"service",
",",
"renew",
"=",
"None",
",",
"gateway",
"=",
"None",
")",
":",
"return",
"create_url",
"(",
"cas_url",
",",
"cas_route",
",",
"(",
"'service'",
",",
"service",
")",
",",
... | Create a CAS login URL .
Keyword arguments:
cas_url -- The url to the CAS (ex. http://sso.pdx.edu)
cas_route -- The route where the CAS lives on server (ex. /cas)
service -- (ex. http://localhost:5000/login)
renew -- "true" or "false"
gateway -- "true" or "false"
Example usage:
>>> cr... | [
"Create",
"a",
"CAS",
"login",
"URL",
"."
] | python | train |
Contraz/demosys-py | demosys/effects/registry.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/effects/registry.py#L76-L94 | def add_package(self, name):
"""
Registers a single package
:param name: (str) The effect package to add
"""
name, cls_name = parse_package_string(name)
if name in self.package_map:
return
package = EffectPackage(name)
package.load()
... | [
"def",
"add_package",
"(",
"self",
",",
"name",
")",
":",
"name",
",",
"cls_name",
"=",
"parse_package_string",
"(",
"name",
")",
"if",
"name",
"in",
"self",
".",
"package_map",
":",
"return",
"package",
"=",
"EffectPackage",
"(",
"name",
")",
"package",
... | Registers a single package
:param name: (str) The effect package to add | [
"Registers",
"a",
"single",
"package"
] | python | valid |
PGower/PyCanvas | pycanvas/apis/base.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/base.py#L102-L152 | def generic_request(self, method, uri,
all_pages=False,
data_key=None,
no_data=False,
do_not_process=False,
force_urlencode_data=False,
data=None,
... | [
"def",
"generic_request",
"(",
"self",
",",
"method",
",",
"uri",
",",
"all_pages",
"=",
"False",
",",
"data_key",
"=",
"None",
",",
"no_data",
"=",
"False",
",",
"do_not_process",
"=",
"False",
",",
"force_urlencode_data",
"=",
"False",
",",
"data",
"=",
... | Generic Canvas Request Method. | [
"Generic",
"Canvas",
"Request",
"Method",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/distributions/half_normal.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/half_normal.py#L180-L196 | def _kl_half_normal_half_normal(a, b, name=None):
"""Calculate the batched KL divergence KL(a || b) with a and b `HalfNormal`.
Args:
a: Instance of a `HalfNormal` distribution object.
b: Instance of a `HalfNormal` distribution object.
name: (optional) Name to use for created operations.
default i... | [
"def",
"_kl_half_normal_half_normal",
"(",
"a",
",",
"b",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
"or",
"\"kl_half_normal_half_normal\"",
")",
":",
"# Consistent with",
"# http://www.mast.queensu.ca/~communications/Papers/gil-ms... | Calculate the batched KL divergence KL(a || b) with a and b `HalfNormal`.
Args:
a: Instance of a `HalfNormal` distribution object.
b: Instance of a `HalfNormal` distribution object.
name: (optional) Name to use for created operations.
default is "kl_half_normal_half_normal".
Returns:
Batchwi... | [
"Calculate",
"the",
"batched",
"KL",
"divergence",
"KL",
"(",
"a",
"||",
"b",
")",
"with",
"a",
"and",
"b",
"HalfNormal",
"."
] | python | test |
tanghaibao/jcvi | jcvi/formats/agp.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/agp.py#L887-L930 | def infer(args):
"""
%prog infer scaffolds.fasta genome.fasta
Infer where the components are in the genome. This function is rarely used,
but can be useful when distributor does not ship an AGP file.
"""
from jcvi.apps.grid import WriteJobs
from jcvi.formats.bed import sort
p = OptionP... | [
"def",
"infer",
"(",
"args",
")",
":",
"from",
"jcvi",
".",
"apps",
".",
"grid",
"import",
"WriteJobs",
"from",
"jcvi",
".",
"formats",
".",
"bed",
"import",
"sort",
"p",
"=",
"OptionParser",
"(",
"infer",
".",
"__doc__",
")",
"p",
".",
"set_cpus",
"... | %prog infer scaffolds.fasta genome.fasta
Infer where the components are in the genome. This function is rarely used,
but can be useful when distributor does not ship an AGP file. | [
"%prog",
"infer",
"scaffolds",
".",
"fasta",
"genome",
".",
"fasta"
] | python | train |
SurveyMonkey/pyramid_autodoc | pyramid_autodoc/__init__.py | https://github.com/SurveyMonkey/pyramid_autodoc/blob/8d669c7165de73cba5268bba97617c552d6b2185/pyramid_autodoc/__init__.py#L333-L338 | def setup(app):
"""Hook the directives when Sphinx ask for it."""
if 'http' not in app.domains:
httpdomain.setup(app)
app.add_directive('autopyramid', RouteDirective) | [
"def",
"setup",
"(",
"app",
")",
":",
"if",
"'http'",
"not",
"in",
"app",
".",
"domains",
":",
"httpdomain",
".",
"setup",
"(",
"app",
")",
"app",
".",
"add_directive",
"(",
"'autopyramid'",
",",
"RouteDirective",
")"
] | Hook the directives when Sphinx ask for it. | [
"Hook",
"the",
"directives",
"when",
"Sphinx",
"ask",
"for",
"it",
"."
] | python | valid |
MultipedRobotics/pyxl320 | bin/servo_ping.py | https://github.com/MultipedRobotics/pyxl320/blob/1a56540e208b028ee47d5fa0a7c7babcee0d9214/bin/servo_ping.py#L23-L42 | def packetToDict(pkt):
"""
Given a packet, this turns it into a dictionary ... is this useful?
in: packet, array of numbers
out: dictionary (key, value)
"""
d = {
'id': pkt[4],
# 'instruction': xl320.InstrToStr[pkt[7]],
# 'length': (pkt[6] << 8) + pkt[5],
# 'params': pkt[8:-2],
'Model Number': (pkt[10... | [
"def",
"packetToDict",
"(",
"pkt",
")",
":",
"d",
"=",
"{",
"'id'",
":",
"pkt",
"[",
"4",
"]",
",",
"# 'instruction': xl320.InstrToStr[pkt[7]],",
"# 'length': (pkt[6] << 8) + pkt[5],",
"# 'params': pkt[8:-2],",
"'Model Number'",
":",
"(",
"pkt",
"[",
"10",
"]",
"<... | Given a packet, this turns it into a dictionary ... is this useful?
in: packet, array of numbers
out: dictionary (key, value) | [
"Given",
"a",
"packet",
"this",
"turns",
"it",
"into",
"a",
"dictionary",
"...",
"is",
"this",
"useful?"
] | python | train |
BlackEarth/bl | bl/progress.py | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/progress.py#L19-L24 | def start(self, key=None, **params):
"""initialize process timing for the current stack"""
self.params.update(**params)
key = key or self.stack_key
if key is not None:
self.current_times[key] = time() | [
"def",
"start",
"(",
"self",
",",
"key",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"self",
".",
"params",
".",
"update",
"(",
"*",
"*",
"params",
")",
"key",
"=",
"key",
"or",
"self",
".",
"stack_key",
"if",
"key",
"is",
"not",
"None",
":... | initialize process timing for the current stack | [
"initialize",
"process",
"timing",
"for",
"the",
"current",
"stack"
] | python | train |
python-xlib/python-xlib | Xlib/display.py | https://github.com/python-xlib/python-xlib/blob/8901e831737e79fe5645f48089d70e1d1046d2f2/Xlib/display.py#L710-L713 | def list_extensions(self):
"""Return a list of all the extensions provided by the server."""
r = request.ListExtensions(display = self.display)
return r.names | [
"def",
"list_extensions",
"(",
"self",
")",
":",
"r",
"=",
"request",
".",
"ListExtensions",
"(",
"display",
"=",
"self",
".",
"display",
")",
"return",
"r",
".",
"names"
] | Return a list of all the extensions provided by the server. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"extensions",
"provided",
"by",
"the",
"server",
"."
] | python | train |
KelSolaar/Umbra | umbra/components/addons/trace_ui/trace_ui.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/addons/trace_ui/trace_ui.py#L407-L426 | def uninitialize_ui(self):
"""
Uninitializes the Component ui.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Uninitializing '{0}' Component ui.".format(self.__class__.__name__))
# Signals / Slots.
self.refresh_nodes.disconnect(self.__model__... | [
"def",
"uninitialize_ui",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Uninitializing '{0}' Component ui.\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
")",
"# Signals / Slots.",
"self",
".",
"refresh_nodes",
".",
"disconnect"... | Uninitializes the Component ui.
:return: Method success.
:rtype: bool | [
"Uninitializes",
"the",
"Component",
"ui",
"."
] | python | train |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/job.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/job.py#L427-L430 | def _job_statistics(self):
"""Helper for job-type specific statistics-based properties."""
statistics = self._properties.get("statistics", {})
return statistics.get(self._JOB_TYPE, {}) | [
"def",
"_job_statistics",
"(",
"self",
")",
":",
"statistics",
"=",
"self",
".",
"_properties",
".",
"get",
"(",
"\"statistics\"",
",",
"{",
"}",
")",
"return",
"statistics",
".",
"get",
"(",
"self",
".",
"_JOB_TYPE",
",",
"{",
"}",
")"
] | Helper for job-type specific statistics-based properties. | [
"Helper",
"for",
"job",
"-",
"type",
"specific",
"statistics",
"-",
"based",
"properties",
"."
] | python | train |
spotify/luigi | luigi/contrib/postgres.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L293-L349 | def run(self):
"""
Inserts data generated by rows() into target table.
If the target table doesn't exist, self.create_table will be called to attempt to create the table.
Normally you don't want to override this.
"""
if not (self.table and self.columns):
rai... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"table",
"and",
"self",
".",
"columns",
")",
":",
"raise",
"Exception",
"(",
"\"table and columns need to be specified\"",
")",
"connection",
"=",
"self",
".",
"output",
"(",
")",
".",
"... | Inserts data generated by rows() into target table.
If the target table doesn't exist, self.create_table will be called to attempt to create the table.
Normally you don't want to override this. | [
"Inserts",
"data",
"generated",
"by",
"rows",
"()",
"into",
"target",
"table",
"."
] | python | train |
oasis-open/cti-stix-validator | stix2validator/v21/shoulds.py | https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/v21/shoulds.py#L874-L893 | def pdf_doc_info(instance):
"""Ensure the keys of the 'document_info_dict' property of the pdf-ext
extension of file objects are only valid PDF Document Information
Dictionary Keys.
"""
for key, obj in instance['objects'].items():
if ('type' in obj and obj['type'] == 'file'):
try... | [
"def",
"pdf_doc_info",
"(",
"instance",
")",
":",
"for",
"key",
",",
"obj",
"in",
"instance",
"[",
"'objects'",
"]",
".",
"items",
"(",
")",
":",
"if",
"(",
"'type'",
"in",
"obj",
"and",
"obj",
"[",
"'type'",
"]",
"==",
"'file'",
")",
":",
"try",
... | Ensure the keys of the 'document_info_dict' property of the pdf-ext
extension of file objects are only valid PDF Document Information
Dictionary Keys. | [
"Ensure",
"the",
"keys",
"of",
"the",
"document_info_dict",
"property",
"of",
"the",
"pdf",
"-",
"ext",
"extension",
"of",
"file",
"objects",
"are",
"only",
"valid",
"PDF",
"Document",
"Information",
"Dictionary",
"Keys",
"."
] | python | train |
Erotemic/utool | utool/util_alg.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_alg.py#L514-L544 | def diagonalized_iter(size):
r"""
TODO: generalize to more than 2 dimensions to be more like
itertools.product.
CommandLine:
python -m utool.util_alg --exec-diagonalized_iter
python -m utool.util_alg --exec-diagonalized_iter --size=5
Example:
>>> # ENABLE_DOCTEST
>>... | [
"def",
"diagonalized_iter",
"(",
"size",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size",
"+",
"1",
")",
":",
"for",
"r",
",",
"c",
"in",
"zip",
"(",
"reversed",
"(",
"range",
"(",
"i",
")",
")",
",",
"(",
"range",
"(",
"i",
")",
... | r"""
TODO: generalize to more than 2 dimensions to be more like
itertools.product.
CommandLine:
python -m utool.util_alg --exec-diagonalized_iter
python -m utool.util_alg --exec-diagonalized_iter --size=5
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_alg import * #... | [
"r",
"TODO",
":",
"generalize",
"to",
"more",
"than",
"2",
"dimensions",
"to",
"be",
"more",
"like",
"itertools",
".",
"product",
"."
] | python | train |
lesscpy/lesscpy | lesscpy/lessc/lexer.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/lexer.py#L370-L373 | def t_css_string(self, t):
r'"[^"@]*"|\'[^\'@]*\''
t.lexer.lineno += t.value.count('\n')
return t | [
"def",
"t_css_string",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"lexer",
".",
"lineno",
"+=",
"t",
".",
"value",
".",
"count",
"(",
"'\\n'",
")",
"return",
"t"
] | r'"[^"@]*"|\'[^\'@]*\ | [
"r",
"[",
"^"
] | python | valid |
mottosso/be | be/vendor/click/core.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L790-L795 | def format_help_text(self, ctx, formatter):
"""Writes the help text to the formatter if it exists."""
if self.help:
formatter.write_paragraph()
with formatter.indentation():
formatter.write_text(self.help) | [
"def",
"format_help_text",
"(",
"self",
",",
"ctx",
",",
"formatter",
")",
":",
"if",
"self",
".",
"help",
":",
"formatter",
".",
"write_paragraph",
"(",
")",
"with",
"formatter",
".",
"indentation",
"(",
")",
":",
"formatter",
".",
"write_text",
"(",
"s... | Writes the help text to the formatter if it exists. | [
"Writes",
"the",
"help",
"text",
"to",
"the",
"formatter",
"if",
"it",
"exists",
"."
] | python | train |
saltstack/salt | salt/states/onyx.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/onyx.py#L153-L197 | def user_absent(name):
'''
Ensure a user is not present
name
username to remove if it exists
Examples:
.. code-block:: yaml
delete:
onyx.user_absent:
- name: daniel
'''
ret = {'name': name,
'result': False,
'changes': {},
... | [
"def",
"user_absent",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"old_user",
"=",
"__salt__",
"[",
"'onyx.cmd'",
"]",
"(",
"'get_use... | Ensure a user is not present
name
username to remove if it exists
Examples:
.. code-block:: yaml
delete:
onyx.user_absent:
- name: daniel | [
"Ensure",
"a",
"user",
"is",
"not",
"present"
] | python | train |
uber/doubles | doubles/expectation.py | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/expectation.py#L34-L47 | def satisfy_exact_match(self, args, kwargs):
"""
Returns a boolean indicating whether or not the mock will accept the provided arguments.
:return: Whether or not the mock accepts the provided arguments.
:rtype: bool
"""
is_match = super(Expectation, self).satisfy_exact_... | [
"def",
"satisfy_exact_match",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"is_match",
"=",
"super",
"(",
"Expectation",
",",
"self",
")",
".",
"satisfy_exact_match",
"(",
"args",
",",
"kwargs",
")",
"if",
"is_match",
":",
"self",
".",
"_satisfy",
... | Returns a boolean indicating whether or not the mock will accept the provided arguments.
:return: Whether or not the mock accepts the provided arguments.
:rtype: bool | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"or",
"not",
"the",
"mock",
"will",
"accept",
"the",
"provided",
"arguments",
"."
] | python | train |
skorch-dev/skorch | skorch/utils.py | https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/utils.py#L374-L381 | def is_skorch_dataset(ds):
"""Checks if the supplied dataset is an instance of
``skorch.dataset.Dataset`` even when it is nested inside
``torch.util.data.Subset``."""
from skorch.dataset import Dataset
if isinstance(ds, Subset):
return is_skorch_dataset(ds.dataset)
return isinstance(ds, ... | [
"def",
"is_skorch_dataset",
"(",
"ds",
")",
":",
"from",
"skorch",
".",
"dataset",
"import",
"Dataset",
"if",
"isinstance",
"(",
"ds",
",",
"Subset",
")",
":",
"return",
"is_skorch_dataset",
"(",
"ds",
".",
"dataset",
")",
"return",
"isinstance",
"(",
"ds"... | Checks if the supplied dataset is an instance of
``skorch.dataset.Dataset`` even when it is nested inside
``torch.util.data.Subset``. | [
"Checks",
"if",
"the",
"supplied",
"dataset",
"is",
"an",
"instance",
"of",
"skorch",
".",
"dataset",
".",
"Dataset",
"even",
"when",
"it",
"is",
"nested",
"inside",
"torch",
".",
"util",
".",
"data",
".",
"Subset",
"."
] | python | train |
vaexio/vaex | packages/vaex-core/vaex/dataframe.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L4202-L4226 | def select_circle(self, x, y, xc, yc, r, mode="replace", name="default", inclusive=True):
"""
Select a circular region centred on xc, yc, with a radius of r.
Example:
>>> df.select_circle('x','y',2,3,1)
:param x: expression for the x space
:param y: expression for the ... | [
"def",
"select_circle",
"(",
"self",
",",
"x",
",",
"y",
",",
"xc",
",",
"yc",
",",
"r",
",",
"mode",
"=",
"\"replace\"",
",",
"name",
"=",
"\"default\"",
",",
"inclusive",
"=",
"True",
")",
":",
"# expr = \"({x}-{xc})**2 + ({y}-{yc})**2 <={r}**2\".format(**lo... | Select a circular region centred on xc, yc, with a radius of r.
Example:
>>> df.select_circle('x','y',2,3,1)
:param x: expression for the x space
:param y: expression for the y space
:param xc: location of the centre of the circle in x
:param yc: location of the centre... | [
"Select",
"a",
"circular",
"region",
"centred",
"on",
"xc",
"yc",
"with",
"a",
"radius",
"of",
"r",
"."
] | python | test |
kontron/python-ipmi | pyipmi/sel.py | https://github.com/kontron/python-ipmi/blob/ce46da47a37dd683615f32d04a10eda069aa569a/pyipmi/sel.py#L49-L91 | def sel_entries(self):
"""Generator which returns all SEL entries."""
ENTIRE_RECORD = 0xff
rsp = self.send_message_with_name('GetSelInfo')
if rsp.entries == 0:
return
reservation_id = self.get_sel_reservation_id()
next_record_id = 0
while True:
... | [
"def",
"sel_entries",
"(",
"self",
")",
":",
"ENTIRE_RECORD",
"=",
"0xff",
"rsp",
"=",
"self",
".",
"send_message_with_name",
"(",
"'GetSelInfo'",
")",
"if",
"rsp",
".",
"entries",
"==",
"0",
":",
"return",
"reservation_id",
"=",
"self",
".",
"get_sel_reserv... | Generator which returns all SEL entries. | [
"Generator",
"which",
"returns",
"all",
"SEL",
"entries",
"."
] | python | train |
saltstack/salt | salt/modules/azurearm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L1326-L1356 | def load_balancer_delete(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Delete a load balancer.
:param name: The name of the load balancer to delete.
:param resource_group: The resource group name assigned to the
load balancer.
CLI Example:
.. code-block:: bash
... | [
"def",
"load_balancer_delete",
"(",
"name",
",",
"resource_group",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"False",
"netconn",
"=",
"__utils__",
"[",
"'azurearm.get_client'",
"]",
"(",
"'network'",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"load_... | .. versionadded:: 2019.2.0
Delete a load balancer.
:param name: The name of the load balancer to delete.
:param resource_group: The resource group name assigned to the
load balancer.
CLI Example:
.. code-block:: bash
salt-call azurearm_network.load_balancer_delete testlb testgr... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
pysathq/pysat | pysat/solvers.py | https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L3301-L3307 | def prop_budget(self, budget):
"""
Set limit on the number of propagations.
"""
if self.minisat:
pysolvers.minisatgh_pbudget(self.minisat, budget) | [
"def",
"prop_budget",
"(",
"self",
",",
"budget",
")",
":",
"if",
"self",
".",
"minisat",
":",
"pysolvers",
".",
"minisatgh_pbudget",
"(",
"self",
".",
"minisat",
",",
"budget",
")"
] | Set limit on the number of propagations. | [
"Set",
"limit",
"on",
"the",
"number",
"of",
"propagations",
"."
] | python | train |
inveniosoftware/invenio-records-files | invenio_records_files/utils.py | https://github.com/inveniosoftware/invenio-records-files/blob/c410eba986ea43be7e97082d5dcbbdc19ccec39c/invenio_records_files/utils.py#L34-L51 | def record_file_factory(pid, record, filename):
"""Get file from a record.
:param pid: Not used. It keeps the function signature.
:param record: Record which contains the files.
:param filename: Name of the file to be returned.
:returns: File object or ``None`` if not found.
"""
try:
... | [
"def",
"record_file_factory",
"(",
"pid",
",",
"record",
",",
"filename",
")",
":",
"try",
":",
"if",
"not",
"(",
"hasattr",
"(",
"record",
",",
"'files'",
")",
"and",
"record",
".",
"files",
")",
":",
"return",
"None",
"except",
"MissingModelError",
":"... | Get file from a record.
:param pid: Not used. It keeps the function signature.
:param record: Record which contains the files.
:param filename: Name of the file to be returned.
:returns: File object or ``None`` if not found. | [
"Get",
"file",
"from",
"a",
"record",
"."
] | python | train |
Caramel/treacle | treacle/treacle.py | https://github.com/Caramel/treacle/blob/70f85a505c0f345659850aec1715c46c687d0e48/treacle/treacle.py#L202-L230 | def in_hours(self, office=None, when=None):
"""
Finds if it is business hours in the given office.
:param office: Office ID to look up, or None to check if any office is in business hours.
:type office: str or None
:param datetime.datetime when: When to check the office is open, or None for now.
:returns... | [
"def",
"in_hours",
"(",
"self",
",",
"office",
"=",
"None",
",",
"when",
"=",
"None",
")",
":",
"if",
"when",
"==",
"None",
":",
"when",
"=",
"datetime",
".",
"now",
"(",
"tz",
"=",
"utc",
")",
"if",
"office",
"==",
"None",
":",
"for",
"office",
... | Finds if it is business hours in the given office.
:param office: Office ID to look up, or None to check if any office is in business hours.
:type office: str or None
:param datetime.datetime when: When to check the office is open, or None for now.
:returns: True if it is business hours, False otherwise.
:... | [
"Finds",
"if",
"it",
"is",
"business",
"hours",
"in",
"the",
"given",
"office",
"."
] | python | train |
annayqho/TheCannon | code/aaomega/aaomega_munge_data.py | https://github.com/annayqho/TheCannon/blob/8010a0a5dc9a3f9bb91efa79d7756f79b3c7ba9a/code/aaomega/aaomega_munge_data.py#L160-L183 | def make_full_ivar():
""" take the scatters and skylines and make final ivars """
# skylines come as an ivar
# don't use them for now, because I don't really trust them...
# skylines = np.load("%s/skylines.npz" %DATA_DIR)['arr_0']
ref_flux = np.load("%s/ref_flux_all.npz" %DATA_DIR)['arr_0']
re... | [
"def",
"make_full_ivar",
"(",
")",
":",
"# skylines come as an ivar",
"# don't use them for now, because I don't really trust them...",
"# skylines = np.load(\"%s/skylines.npz\" %DATA_DIR)['arr_0']",
"ref_flux",
"=",
"np",
".",
"load",
"(",
"\"%s/ref_flux_all.npz\"",
"%",
"DATA_DIR",... | take the scatters and skylines and make final ivars | [
"take",
"the",
"scatters",
"and",
"skylines",
"and",
"make",
"final",
"ivars"
] | python | train |
thisfred/val | val/tp.py | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/tp.py#L131-L148 | def _dict_to_teleport(dict_value):
"""Convert a val schema dictionary to teleport."""
if len(dict_value) == 1:
for key, value in dict_value.items():
if key is str:
return {"Map": from_val(value)}
optional = {}
required = {}
for key, value in dict_value.items():
... | [
"def",
"_dict_to_teleport",
"(",
"dict_value",
")",
":",
"if",
"len",
"(",
"dict_value",
")",
"==",
"1",
":",
"for",
"key",
",",
"value",
"in",
"dict_value",
".",
"items",
"(",
")",
":",
"if",
"key",
"is",
"str",
":",
"return",
"{",
"\"Map\"",
":",
... | Convert a val schema dictionary to teleport. | [
"Convert",
"a",
"val",
"schema",
"dictionary",
"to",
"teleport",
"."
] | python | train |
googleapis/google-cloud-python | dlp/google/cloud/dlp_v2/gapic/dlp_service_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dlp/google/cloud/dlp_v2/gapic/dlp_service_client.py#L128-L134 | def project_job_trigger_path(cls, project, job_trigger):
"""Return a fully-qualified project_job_trigger string."""
return google.api_core.path_template.expand(
"projects/{project}/jobTriggers/{job_trigger}",
project=project,
job_trigger=job_trigger,
) | [
"def",
"project_job_trigger_path",
"(",
"cls",
",",
"project",
",",
"job_trigger",
")",
":",
"return",
"google",
".",
"api_core",
".",
"path_template",
".",
"expand",
"(",
"\"projects/{project}/jobTriggers/{job_trigger}\"",
",",
"project",
"=",
"project",
",",
"job_... | Return a fully-qualified project_job_trigger string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"project_job_trigger",
"string",
"."
] | python | train |
jadolg/rocketchat_API | rocketchat_API/rocketchat.py | https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L324-L326 | def channels_close(self, room_id, **kwargs):
"""Removes the channel from the user’s list of channels."""
return self.__call_api_post('channels.close', roomId=room_id, kwargs=kwargs) | [
"def",
"channels_close",
"(",
"self",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__call_api_post",
"(",
"'channels.close'",
",",
"roomId",
"=",
"room_id",
",",
"kwargs",
"=",
"kwargs",
")"
] | Removes the channel from the user’s list of channels. | [
"Removes",
"the",
"channel",
"from",
"the",
"user’s",
"list",
"of",
"channels",
"."
] | python | train |
rootpy/rootpy | rootpy/plotting/hist.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L749-L775 | def uniform_binned(self, name=None):
"""
Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram.
"""
if self.GetDimension() == 1:
new_hist = Hist(
self.GetNbinsX(), 0, self.GetNbins... | [
"def",
"uniform_binned",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"GetDimension",
"(",
")",
"==",
"1",
":",
"new_hist",
"=",
"Hist",
"(",
"self",
".",
"GetNbinsX",
"(",
")",
",",
"0",
",",
"self",
".",
"GetNbinsX",
"(",
... | Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram. | [
"Return",
"a",
"new",
"histogram",
"with",
"constant",
"width",
"bins",
"along",
"all",
"axes",
"by",
"using",
"the",
"bin",
"indices",
"as",
"the",
"bin",
"edges",
"of",
"the",
"new",
"histogram",
"."
] | python | train |
sprockets/sprockets-influxdb | sprockets_influxdb.py | https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L858-L869 | def marshall(self):
"""Return the measurement in the line protocol format.
:rtype: str
"""
return '{},{} {} {}'.format(
self._escape(self.name),
','.join(['{}={}'.format(self._escape(k), self._escape(v))
for k, v in self.tags.items()]),
... | [
"def",
"marshall",
"(",
"self",
")",
":",
"return",
"'{},{} {} {}'",
".",
"format",
"(",
"self",
".",
"_escape",
"(",
"self",
".",
"name",
")",
",",
"','",
".",
"join",
"(",
"[",
"'{}={}'",
".",
"format",
"(",
"self",
".",
"_escape",
"(",
"k",
")",... | Return the measurement in the line protocol format.
:rtype: str | [
"Return",
"the",
"measurement",
"in",
"the",
"line",
"protocol",
"format",
"."
] | python | train |
limodou/uliweb | uliweb/utils/generic.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/generic.py#L1980-L2016 | def download(self, filename, timeout=3600, action=None, query=None,
fields_convert_map=None, type=None, domain=None,
template_filename='', sheet_name='', **kwargs):
"""
Default domain option is PARA/DOMAIN
:param template_filename: Excel template filename, ... | [
"def",
"download",
"(",
"self",
",",
"filename",
",",
"timeout",
"=",
"3600",
",",
"action",
"=",
"None",
",",
"query",
"=",
"None",
",",
"fields_convert_map",
"=",
"None",
",",
"type",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"template_filename",
... | Default domain option is PARA/DOMAIN
:param template_filename: Excel template filename, it'll xltools to writer it, only can be used
in xlsx | [
"Default",
"domain",
"option",
"is",
"PARA",
"/",
"DOMAIN",
":",
"param",
"template_filename",
":",
"Excel",
"template",
"filename",
"it",
"ll",
"xltools",
"to",
"writer",
"it",
"only",
"can",
"be",
"used",
"in",
"xlsx"
] | python | train |
vrtsystems/hszinc | hszinc/pintutil.py | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/pintutil.py#L171-L236 | def define_haystack_units():
"""
Missing units found in project-haystack
Added to the registry
"""
ureg = UnitRegistry()
ureg.define('% = [] = percent')
ureg.define('pixel = [] = px = dot = picture_element = pel')
ureg.define('decibel = [] = dB')
ureg.define('ppu = [] = parts_per_uni... | [
"def",
"define_haystack_units",
"(",
")",
":",
"ureg",
"=",
"UnitRegistry",
"(",
")",
"ureg",
".",
"define",
"(",
"'% = [] = percent'",
")",
"ureg",
".",
"define",
"(",
"'pixel = [] = px = dot = picture_element = pel'",
")",
"ureg",
".",
"define",
"(",
"'decibel =... | Missing units found in project-haystack
Added to the registry | [
"Missing",
"units",
"found",
"in",
"project",
"-",
"haystack",
"Added",
"to",
"the",
"registry"
] | python | valid |
google-research/batch-ppo | agents/tools/loop.py | https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/tools/loop.py#L189-L217 | def _define_step(self, done, score, summary):
"""Combine operations of a phase.
Keeps track of the mean score and when to report it.
Args:
done: Tensor indicating whether current score can be used.
score: Tensor holding the current, possibly intermediate, score.
summary: Tensor holding s... | [
"def",
"_define_step",
"(",
"self",
",",
"done",
",",
"score",
",",
"summary",
")",
":",
"if",
"done",
".",
"shape",
".",
"ndims",
"==",
"0",
":",
"done",
"=",
"done",
"[",
"None",
"]",
"if",
"score",
".",
"shape",
".",
"ndims",
"==",
"0",
":",
... | Combine operations of a phase.
Keeps track of the mean score and when to report it.
Args:
done: Tensor indicating whether current score can be used.
score: Tensor holding the current, possibly intermediate, score.
summary: Tensor holding summary string to write if not an empty string.
R... | [
"Combine",
"operations",
"of",
"a",
"phase",
"."
] | python | train |
erdc/RAPIDpy | RAPIDpy/helper_functions.py | https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/helper_functions.py#L21-L33 | def open_csv(csv_file, mode='r'):
"""
Get mode depending on Python version
Based on: http://stackoverflow.com/questions/29840849/writing-a-csv-file-in-python-that-works-for-both-python-2-7-and-python-3-3-in
""" # noqa
if version_info[0] == 2: # Not named on 2.6
access = '{0}b'.format(mode)... | [
"def",
"open_csv",
"(",
"csv_file",
",",
"mode",
"=",
"'r'",
")",
":",
"# noqa",
"if",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"# Not named on 2.6",
"access",
"=",
"'{0}b'",
".",
"format",
"(",
"mode",
")",
"kwargs",
"=",
"{",
"}",
"else",
":"... | Get mode depending on Python version
Based on: http://stackoverflow.com/questions/29840849/writing-a-csv-file-in-python-that-works-for-both-python-2-7-and-python-3-3-in | [
"Get",
"mode",
"depending",
"on",
"Python",
"version",
"Based",
"on",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"29840849",
"/",
"writing",
"-",
"a",
"-",
"csv",
"-",
"file",
"-",
"in",
"-",
"python",
"-",
"that",
"-... | python | train |
spookylukey/django-paypal | paypal/standard/models.py | https://github.com/spookylukey/django-paypal/blob/b07d0a3ad91b5c5fe7bb27be3e5d70aabcdef76f/paypal/standard/models.py#L385-L393 | def initialize(self, request):
"""Store the data we'll need to make the postback from the request object."""
if request.method == 'GET':
# PDT only - this data is currently unused
self.query = request.META.get('QUERY_STRING', '')
elif request.method == 'POST':
... | [
"def",
"initialize",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"# PDT only - this data is currently unused",
"self",
".",
"query",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'QUERY_STRING'",
",",
"''",
")"... | Store the data we'll need to make the postback from the request object. | [
"Store",
"the",
"data",
"we",
"ll",
"need",
"to",
"make",
"the",
"postback",
"from",
"the",
"request",
"object",
"."
] | python | train |
deepmind/sonnet | sonnet/python/modules/conv.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2631-L2677 | def _construct_w(self, inputs):
"""Connects the module into the graph, with input Tensor `inputs`.
Args:
inputs: A 4D Tensor of shape:
[batch_size, input_height, input_width, input_channels]
and of type `tf.float16`, `tf.bfloat16` or `tf.float32`.
Returns:
A tuple of two 4D... | [
"def",
"_construct_w",
"(",
"self",
",",
"inputs",
")",
":",
"depthwise_weight_shape",
"=",
"self",
".",
"_kernel_shape",
"+",
"(",
"self",
".",
"_input_channels",
",",
"self",
".",
"_channel_multiplier",
")",
"pointwise_input_size",
"=",
"self",
".",
"_channel_... | Connects the module into the graph, with input Tensor `inputs`.
Args:
inputs: A 4D Tensor of shape:
[batch_size, input_height, input_width, input_channels]
and of type `tf.float16`, `tf.bfloat16` or `tf.float32`.
Returns:
A tuple of two 4D Tensors, each with the same dtype as `... | [
"Connects",
"the",
"module",
"into",
"the",
"graph",
"with",
"input",
"Tensor",
"inputs",
"."
] | python | train |
inasafe/inasafe | safe/report/extractors/infographic_elements/svg_charts.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographic_elements/svg_charts.py#L52-L69 | def _convert_tuple_color_to_hex(cls, color):
"""Convert tuple of color element (r, g, b) to hexa.
:param color: A color tuple
:type color: (int, int, int) | str
:return: Hexa representation of the color
:rtype: str
"""
if isinstance(color, tuple):
re... | [
"def",
"_convert_tuple_color_to_hex",
"(",
"cls",
",",
"color",
")",
":",
"if",
"isinstance",
"(",
"color",
",",
"tuple",
")",
":",
"return",
"'#{:02x}{:02x}{:02x}'",
".",
"format",
"(",
"*",
"color",
")",
"elif",
"isinstance",
"(",
"color",
",",
"str",
")... | Convert tuple of color element (r, g, b) to hexa.
:param color: A color tuple
:type color: (int, int, int) | str
:return: Hexa representation of the color
:rtype: str | [
"Convert",
"tuple",
"of",
"color",
"element",
"(",
"r",
"g",
"b",
")",
"to",
"hexa",
"."
] | python | train |
QUANTAXIS/QUANTAXIS | QUANTAXIS/QAData/QABlockStruct.py | https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAData/QABlockStruct.py#L140-L153 | def get_block(self, block_name):
"""getblock 获取板块, block_name是list或者是单个str
Arguments:
block_name {[type]} -- [description]
Returns:
[type] -- [description]
"""
# block_name = [block_name] if isinstance(
# block_name, str) else block_name
... | [
"def",
"get_block",
"(",
"self",
",",
"block_name",
")",
":",
"# block_name = [block_name] if isinstance(",
"# block_name, str) else block_name",
"# return QA_DataStruct_Stock_block(self.data[self.data.blockname.apply(lambda x: x in block_name)])",
"return",
"self",
".",
"new",
"("... | getblock 获取板块, block_name是list或者是单个str
Arguments:
block_name {[type]} -- [description]
Returns:
[type] -- [description] | [
"getblock",
"获取板块",
"block_name是list或者是单个str"
] | python | train |
bcbio/bcbio-nextgen | bcbio/utils.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L351-L374 | def symlink_plus(orig, new):
"""Create relative symlinks and handle associated biological index files.
"""
orig = os.path.abspath(orig)
if not os.path.exists(orig):
raise RuntimeError("File not found: %s" % orig)
for ext in ["", ".idx", ".gbi", ".tbi", ".bai", ".fai"]:
if os.path.exi... | [
"def",
"symlink_plus",
"(",
"orig",
",",
"new",
")",
":",
"orig",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"orig",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"orig",
")",
":",
"raise",
"RuntimeError",
"(",
"\"File not found: %s\"",
... | Create relative symlinks and handle associated biological index files. | [
"Create",
"relative",
"symlinks",
"and",
"handle",
"associated",
"biological",
"index",
"files",
"."
] | python | train |
brandon-rhodes/python-adventure | adventure/game.py | https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L118-L132 | def start(self):
"""Start the game."""
# For old-fashioned players, accept five-letter truncations like
# "inven" instead of insisting on full words like "inventory".
for key, value in list(self.vocabulary.items()):
if isinstance(key, str) and len(key) > 5:
... | [
"def",
"start",
"(",
"self",
")",
":",
"# For old-fashioned players, accept five-letter truncations like",
"# \"inven\" instead of insisting on full words like \"inventory\".",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"self",
".",
"vocabulary",
".",
"items",
"(",
")",... | Start the game. | [
"Start",
"the",
"game",
"."
] | python | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/entomology.py | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/entomology.py#L197-L222 | def add(self, vector, InterventionAnophelesParams=None):
"""
Add a vector to entomology section.
vector is either ElementTree or xml snippet
InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention
already defined in the scenario.xml
... | [
"def",
"add",
"(",
"self",
",",
"vector",
",",
"InterventionAnophelesParams",
"=",
"None",
")",
":",
"# TODO",
"# 1. If there are GVI interventions, for every GVI, add anophelesParams section.",
"# (gvi_anophelesParams field in AnophelesSnippets models)",
"# 2. If there are ITN interve... | Add a vector to entomology section.
vector is either ElementTree or xml snippet
InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention
already defined in the scenario.xml | [
"Add",
"a",
"vector",
"to",
"entomology",
"section",
".",
"vector",
"is",
"either",
"ElementTree",
"or",
"xml",
"snippet"
] | python | train |
rackerlabs/rackspace-python-neutronclient | neutronclient/v2_0/client.py | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L621-L623 | def show_extension(self, ext_alias, **_params):
"""Fetches information of a certain extension."""
return self.get(self.extension_path % ext_alias, params=_params) | [
"def",
"show_extension",
"(",
"self",
",",
"ext_alias",
",",
"*",
"*",
"_params",
")",
":",
"return",
"self",
".",
"get",
"(",
"self",
".",
"extension_path",
"%",
"ext_alias",
",",
"params",
"=",
"_params",
")"
] | Fetches information of a certain extension. | [
"Fetches",
"information",
"of",
"a",
"certain",
"extension",
"."
] | python | train |
dancsalo/TensorBase | tensorbase/base.py | https://github.com/dancsalo/TensorBase/blob/3d42a326452bd03427034916ff2fb90730020204/tensorbase/base.py#L912-L919 | def const_variable(name, shape, value, trainable):
"""
:param name: string
:param shape: 1D array
:param value: float
:return: tf variable
"""
return tf.get_variable(name, shape, initializer=tf.constant_initializer(value), trainable=trainable) | [
"def",
"const_variable",
"(",
"name",
",",
"shape",
",",
"value",
",",
"trainable",
")",
":",
"return",
"tf",
".",
"get_variable",
"(",
"name",
",",
"shape",
",",
"initializer",
"=",
"tf",
".",
"constant_initializer",
"(",
"value",
")",
",",
"trainable",
... | :param name: string
:param shape: 1D array
:param value: float
:return: tf variable | [
":",
"param",
"name",
":",
"string",
":",
"param",
"shape",
":",
"1D",
"array",
":",
"param",
"value",
":",
"float",
":",
"return",
":",
"tf",
"variable"
] | python | train |
PyCQA/astroid | astroid/transforms.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/transforms.py#L83-L90 | def visit(self, module):
"""Walk the given astroid *tree* and transform each encountered node
Only the nodes which have transforms registered will actually
be replaced or changed.
"""
module.body = [self._visit(child) for child in module.body]
return self._transform(modu... | [
"def",
"visit",
"(",
"self",
",",
"module",
")",
":",
"module",
".",
"body",
"=",
"[",
"self",
".",
"_visit",
"(",
"child",
")",
"for",
"child",
"in",
"module",
".",
"body",
"]",
"return",
"self",
".",
"_transform",
"(",
"module",
")"
] | Walk the given astroid *tree* and transform each encountered node
Only the nodes which have transforms registered will actually
be replaced or changed. | [
"Walk",
"the",
"given",
"astroid",
"*",
"tree",
"*",
"and",
"transform",
"each",
"encountered",
"node"
] | python | train |
klahnakoski/pyLibrary | jx_python/meta.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L546-L615 | def _get_schema_from_list(frum, table_name, parent, nested_path, columns):
"""
:param frum: The list
:param table_name: Name of the table this list holds records for
:param parent: parent path
:param nested_path: each nested array, in reverse order
:param columns: map from full name to column de... | [
"def",
"_get_schema_from_list",
"(",
"frum",
",",
"table_name",
",",
"parent",
",",
"nested_path",
",",
"columns",
")",
":",
"for",
"d",
"in",
"frum",
":",
"row_type",
"=",
"python_type_to_json_type",
"[",
"d",
".",
"__class__",
"]",
"if",
"row_type",
"!=",
... | :param frum: The list
:param table_name: Name of the table this list holds records for
:param parent: parent path
:param nested_path: each nested array, in reverse order
:param columns: map from full name to column definition
:return: | [
":",
"param",
"frum",
":",
"The",
"list",
":",
"param",
"table_name",
":",
"Name",
"of",
"the",
"table",
"this",
"list",
"holds",
"records",
"for",
":",
"param",
"parent",
":",
"parent",
"path",
":",
"param",
"nested_path",
":",
"each",
"nested",
"array"... | python | train |
CivicSpleen/ambry | ambry/library/search_backends/base.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/base.py#L705-L832 | def parse(self, s, term_join=None):
""" Parses search term to
Args:
s (str): string with search term.
or_join (callable): function to join 'OR' terms.
Returns:
dict: all of the terms grouped by marker. Key is a marker, value is a term.
Example:
... | [
"def",
"parse",
"(",
"self",
",",
"s",
",",
"term_join",
"=",
"None",
")",
":",
"if",
"not",
"term_join",
":",
"term_join",
"=",
"lambda",
"x",
":",
"'('",
"+",
"' OR '",
".",
"join",
"(",
"x",
")",
"+",
"')'",
"toks",
"=",
"self",
".",
"scan",
... | Parses search term to
Args:
s (str): string with search term.
or_join (callable): function to join 'OR' terms.
Returns:
dict: all of the terms grouped by marker. Key is a marker, value is a term.
Example:
>>> SearchTermParser().parse('table2 fro... | [
"Parses",
"search",
"term",
"to"
] | python | train |
jmoiron/speedparser | speedparser/speedparser.py | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L255-L298 | def parse_entry(self, entry):
"""An attempt to parse pieces of an entry out w/o xpath, by looping
over the entry root's children and slotting them into the right places.
This is going to be way messier than SpeedParserEntries, and maybe
less cleanly usable, but it should be faster."""
... | [
"def",
"parse_entry",
"(",
"self",
",",
"entry",
")",
":",
"e",
"=",
"feedparser",
".",
"FeedParserDict",
"(",
")",
"tag_map",
"=",
"self",
".",
"tag_map",
"nslookup",
"=",
"self",
".",
"nslookup",
"for",
"child",
"in",
"entry",
".",
"getchildren",
"(",
... | An attempt to parse pieces of an entry out w/o xpath, by looping
over the entry root's children and slotting them into the right places.
This is going to be way messier than SpeedParserEntries, and maybe
less cleanly usable, but it should be faster. | [
"An",
"attempt",
"to",
"parse",
"pieces",
"of",
"an",
"entry",
"out",
"w",
"/",
"o",
"xpath",
"by",
"looping",
"over",
"the",
"entry",
"root",
"s",
"children",
"and",
"slotting",
"them",
"into",
"the",
"right",
"places",
".",
"This",
"is",
"going",
"to... | python | train |
pydsigner/pygu | pygu/pygw.py | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L550-L559 | def copy(self):
'''
Copy the text in the Entry() and place it on the clipboard.
'''
try:
pygame.scrap.put(SCRAP_TEXT, self.get())
return True
except:
# pygame.scrap is experimental, allow for changes
return False | [
"def",
"copy",
"(",
"self",
")",
":",
"try",
":",
"pygame",
".",
"scrap",
".",
"put",
"(",
"SCRAP_TEXT",
",",
"self",
".",
"get",
"(",
")",
")",
"return",
"True",
"except",
":",
"# pygame.scrap is experimental, allow for changes",
"return",
"False"
] | Copy the text in the Entry() and place it on the clipboard. | [
"Copy",
"the",
"text",
"in",
"the",
"Entry",
"()",
"and",
"place",
"it",
"on",
"the",
"clipboard",
"."
] | python | train |
rbuffat/pyepw | pyepw/epw.py | https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L5100-L5132 | def read(self, vals):
"""Read values.
Args:
vals (list): list of strings representing values
"""
i = 0
if len(vals[i]) == 0:
self.number_of_records_per_hour = None
else:
self.number_of_records_per_hour = vals[i]
i += 1
... | [
"def",
"read",
"(",
"self",
",",
"vals",
")",
":",
"i",
"=",
"0",
"if",
"len",
"(",
"vals",
"[",
"i",
"]",
")",
"==",
"0",
":",
"self",
".",
"number_of_records_per_hour",
"=",
"None",
"else",
":",
"self",
".",
"number_of_records_per_hour",
"=",
"vals... | Read values.
Args:
vals (list): list of strings representing values | [
"Read",
"values",
"."
] | python | train |
Roastero/freshroastsr700 | freshroastsr700/pid.py | https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/pid.py#L61-L65 | def setPoint(self, targetTemp):
"""Initilize the setpoint of PID."""
self.targetTemp = targetTemp
self.Integrator = 0
self.Derivator = 0 | [
"def",
"setPoint",
"(",
"self",
",",
"targetTemp",
")",
":",
"self",
".",
"targetTemp",
"=",
"targetTemp",
"self",
".",
"Integrator",
"=",
"0",
"self",
".",
"Derivator",
"=",
"0"
] | Initilize the setpoint of PID. | [
"Initilize",
"the",
"setpoint",
"of",
"PID",
"."
] | python | train |
openstack/proliantutils | proliantutils/hpssa/manager.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/hpssa/manager.py#L362-L402 | def erase_devices():
"""Erase all the drives on this server.
This method performs sanitize erase on all the supported physical drives
in this server. This erase cannot be performed on logical drives.
:returns: a dictionary of controllers with drives and the erase status.
:raises exception.HPSSAExc... | [
"def",
"erase_devices",
"(",
")",
":",
"server",
"=",
"objects",
".",
"Server",
"(",
")",
"for",
"controller",
"in",
"server",
".",
"controllers",
":",
"drives",
"=",
"[",
"x",
"for",
"x",
"in",
"controller",
".",
"unassigned_physical_drives",
"if",
"(",
... | Erase all the drives on this server.
This method performs sanitize erase on all the supported physical drives
in this server. This erase cannot be performed on logical drives.
:returns: a dictionary of controllers with drives and the erase status.
:raises exception.HPSSAException, if none of the drive... | [
"Erase",
"all",
"the",
"drives",
"on",
"this",
"server",
"."
] | python | train |
cherrypy/cheroot | cheroot/server.py | https://github.com/cherrypy/cheroot/blob/2af3b1798d66da697957480d3a8b4831a405770b/cheroot/server.py#L541-L582 | def readline(self, size=None):
"""Read a single line from rfile buffer and return it.
Args:
size (int): minimum amount of data to read
Returns:
bytes: One line from rfile.
"""
data = EMPTY
if size == 0:
return data
while Tr... | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"data",
"=",
"EMPTY",
"if",
"size",
"==",
"0",
":",
"return",
"data",
"while",
"True",
":",
"if",
"size",
"and",
"len",
"(",
"data",
")",
">=",
"size",
":",
"return",
"data",
"if... | Read a single line from rfile buffer and return it.
Args:
size (int): minimum amount of data to read
Returns:
bytes: One line from rfile. | [
"Read",
"a",
"single",
"line",
"from",
"rfile",
"buffer",
"and",
"return",
"it",
"."
] | python | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/gateway_agent.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/gateway_agent.py#L631-L655 | def _send_accum_trace(self, device_uuid):
"""Send whatever accumulated tracing data we have for the device."""
if device_uuid not in self._connections:
self._logger.debug("Dropping trace data for device without an active connection, uuid=0x%X", device_uuid)
return
conn_... | [
"def",
"_send_accum_trace",
"(",
"self",
",",
"device_uuid",
")",
":",
"if",
"device_uuid",
"not",
"in",
"self",
".",
"_connections",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Dropping trace data for device without an active connection, uuid=0x%X\"",
",",
"de... | Send whatever accumulated tracing data we have for the device. | [
"Send",
"whatever",
"accumulated",
"tracing",
"data",
"we",
"have",
"for",
"the",
"device",
"."
] | python | train |
fabioz/PyDev.Debugger | third_party/pep8/pycodestyle.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/pycodestyle.py#L1422-L1437 | def normalize_paths(value, parent=os.curdir):
"""Parse a comma-separated list of paths.
Return a list of absolute paths.
"""
if not value:
return []
if isinstance(value, list):
return value
paths = []
for path in value.split(','):
path = path.strip()
if '/' i... | [
"def",
"normalize_paths",
"(",
"value",
",",
"parent",
"=",
"os",
".",
"curdir",
")",
":",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"return",
"value",
"paths",
"=",
"[",
"]",
"for",
"pa... | Parse a comma-separated list of paths.
Return a list of absolute paths. | [
"Parse",
"a",
"comma",
"-",
"separated",
"list",
"of",
"paths",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/utils.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/utils.py#L150-L163 | def event_log_filter_between_date(start, end, utc):
"""betweenDate Query filter that SoftLayer_EventLog likes
:param string start: lower bound date in mm/dd/yyyy format
:param string end: upper bound date in mm/dd/yyyy format
:param string utc: utc offset. Defaults to '+0000'
"""
return {
... | [
"def",
"event_log_filter_between_date",
"(",
"start",
",",
"end",
",",
"utc",
")",
":",
"return",
"{",
"'operation'",
":",
"'betweenDate'",
",",
"'options'",
":",
"[",
"{",
"'name'",
":",
"'startDate'",
",",
"'value'",
":",
"[",
"format_event_log_date",
"(",
... | betweenDate Query filter that SoftLayer_EventLog likes
:param string start: lower bound date in mm/dd/yyyy format
:param string end: upper bound date in mm/dd/yyyy format
:param string utc: utc offset. Defaults to '+0000' | [
"betweenDate",
"Query",
"filter",
"that",
"SoftLayer_EventLog",
"likes"
] | python | train |
barryp/py-amqplib | amqplib/client_0_8/channel.py | https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L135-L195 | def close(self, reply_code=0, reply_text='', method_sig=(0, 0)):
"""
request a channel close
This method indicates that the sender wants to close the
channel. This may be due to internal conditions (e.g. a forced
shut-down) or due to an error handling a specific method, i.e.
... | [
"def",
"close",
"(",
"self",
",",
"reply_code",
"=",
"0",
",",
"reply_text",
"=",
"''",
",",
"method_sig",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"if",
"not",
"self",
".",
"is_open",
":",
"# already closed",
"return",
"args",
"=",
"AMQPWriter",
"(",... | request a channel close
This method indicates that the sender wants to close the
channel. This may be due to internal conditions (e.g. a forced
shut-down) or due to an error handling a specific method, i.e.
an exception. When a close is due to an exception, the sender
provides ... | [
"request",
"a",
"channel",
"close"
] | python | train |
gregreen/dustmaps | dustmaps/fetch_utils.py | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L94-L150 | def h5_file_exists(fname, size_guess=None, rtol=0.1, atol=1., dsets={}):
"""
Returns ``True`` if an HDF5 file exists, has the expected file size, and
contains (at least) the given datasets, with the correct shapes.
Args:
fname (str): Filename to check.
size_guess (Optional[int]): Expect... | [
"def",
"h5_file_exists",
"(",
"fname",
",",
"size_guess",
"=",
"None",
",",
"rtol",
"=",
"0.1",
",",
"atol",
"=",
"1.",
",",
"dsets",
"=",
"{",
"}",
")",
":",
"# Check if the file exists",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fname",
... | Returns ``True`` if an HDF5 file exists, has the expected file size, and
contains (at least) the given datasets, with the correct shapes.
Args:
fname (str): Filename to check.
size_guess (Optional[int]): Expected size (in Bytes) of the file. If
``None`` (the default), then filesize ... | [
"Returns",
"True",
"if",
"an",
"HDF5",
"file",
"exists",
"has",
"the",
"expected",
"file",
"size",
"and",
"contains",
"(",
"at",
"least",
")",
"the",
"given",
"datasets",
"with",
"the",
"correct",
"shapes",
"."
] | python | train |
gem/oq-engine | openquake/commands/purge.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/purge.py#L42-L56 | def purge_all(user=None, fast=False):
"""
Remove all calculations of the given user
"""
user = user or getpass.getuser()
if os.path.exists(datadir):
if fast:
shutil.rmtree(datadir)
print('Removed %s' % datadir)
else:
for fname in os.listdir(datadir... | [
"def",
"purge_all",
"(",
"user",
"=",
"None",
",",
"fast",
"=",
"False",
")",
":",
"user",
"=",
"user",
"or",
"getpass",
".",
"getuser",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"datadir",
")",
":",
"if",
"fast",
":",
"shutil",
".",... | Remove all calculations of the given user | [
"Remove",
"all",
"calculations",
"of",
"the",
"given",
"user"
] | python | train |
ic-labs/django-icekit | icekit/publishing/models.py | https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/publishing/models.py#L740-L768 | def handle_publishable_m2m_changed(
sender, instance, action, reverse, model, pk_set, **kwargs):
"""
Cache related published objects in `pre_clear` so they can be restored in
`post_clear`.
"""
# Do nothing if the target model is not publishable.
if not issubclass(model, PublishingModel):... | [
"def",
"handle_publishable_m2m_changed",
"(",
"sender",
",",
"instance",
",",
"action",
",",
"reverse",
",",
"model",
",",
"pk_set",
",",
"*",
"*",
"kwargs",
")",
":",
"# Do nothing if the target model is not publishable.",
"if",
"not",
"issubclass",
"(",
"model",
... | Cache related published objects in `pre_clear` so they can be restored in
`post_clear`. | [
"Cache",
"related",
"published",
"objects",
"in",
"pre_clear",
"so",
"they",
"can",
"be",
"restored",
"in",
"post_clear",
"."
] | python | train |
mila-iqia/fuel | fuel/utils/lock.py | https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L392-L403 | def release_readlock(lockdir_name):
"""Release a previously obtained readlock.
Parameters
----------
lockdir_name : str
Name of the previously obtained readlock
"""
# Make sure the lock still exists before deleting it
if os.path.exists(lockdir_name) and os.path.isdir(lockdir_name):... | [
"def",
"release_readlock",
"(",
"lockdir_name",
")",
":",
"# Make sure the lock still exists before deleting it",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"lockdir_name",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"lockdir_name",
")",
":",
"os",
".",
... | Release a previously obtained readlock.
Parameters
----------
lockdir_name : str
Name of the previously obtained readlock | [
"Release",
"a",
"previously",
"obtained",
"readlock",
"."
] | python | train |
saltstack/salt | salt/log/setup.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/setup.py#L1060-L1066 | def set_logger_level(logger_name, log_level='error'):
'''
Tweak a specific logger's logging level
'''
logging.getLogger(logger_name).setLevel(
LOG_LEVELS.get(log_level.lower(), logging.ERROR)
) | [
"def",
"set_logger_level",
"(",
"logger_name",
",",
"log_level",
"=",
"'error'",
")",
":",
"logging",
".",
"getLogger",
"(",
"logger_name",
")",
".",
"setLevel",
"(",
"LOG_LEVELS",
".",
"get",
"(",
"log_level",
".",
"lower",
"(",
")",
",",
"logging",
".",
... | Tweak a specific logger's logging level | [
"Tweak",
"a",
"specific",
"logger",
"s",
"logging",
"level"
] | python | train |
jantman/pypi-download-stats | pypi_download_stats/projectstats.py | https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/projectstats.py#L266-L287 | def per_implementation_data(self):
"""
Return download data by python impelementation name and version.
:return: dict of cache data; keys are datetime objects, values are
dict of implementation name/version (str) to count (int).
:rtype: dict
"""
ret = {}
... | [
"def",
"per_implementation_data",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"cache_date",
"in",
"self",
".",
"cache_dates",
":",
"data",
"=",
"self",
".",
"_cache_get",
"(",
"cache_date",
")",
"ret",
"[",
"cache_date",
"]",
"=",
"{",
"}",
"fo... | Return download data by python impelementation name and version.
:return: dict of cache data; keys are datetime objects, values are
dict of implementation name/version (str) to count (int).
:rtype: dict | [
"Return",
"download",
"data",
"by",
"python",
"impelementation",
"name",
"and",
"version",
"."
] | python | train |
CI-WATER/gsshapy | gsshapy/orm/prj.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/prj.py#L1642-L1669 | def _writeXput(self, session, directory, fileCards,
name=None, replaceParamFile=None):
"""
GSSHA Project Write Files to File Method
"""
for card in self.projectCards:
if (card.name in fileCards) and self._noneOrNumValue(card.value) \
and... | [
"def",
"_writeXput",
"(",
"self",
",",
"session",
",",
"directory",
",",
"fileCards",
",",
"name",
"=",
"None",
",",
"replaceParamFile",
"=",
"None",
")",
":",
"for",
"card",
"in",
"self",
".",
"projectCards",
":",
"if",
"(",
"card",
".",
"name",
"in",... | GSSHA Project Write Files to File Method | [
"GSSHA",
"Project",
"Write",
"Files",
"to",
"File",
"Method"
] | python | train |
LonamiWebs/Telethon | telethon/tl/custom/draft.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/draft.py#L117-L163 | async def set_message(
self, text=None, reply_to=0, parse_mode=(),
link_preview=None):
"""
Changes the draft message on the Telegram servers. The changes are
reflected in this object.
:param str text: New text of the draft.
Preserved if l... | [
"async",
"def",
"set_message",
"(",
"self",
",",
"text",
"=",
"None",
",",
"reply_to",
"=",
"0",
",",
"parse_mode",
"=",
"(",
")",
",",
"link_preview",
"=",
"None",
")",
":",
"if",
"text",
"is",
"None",
":",
"text",
"=",
"self",
".",
"_text",
"if",... | Changes the draft message on the Telegram servers. The changes are
reflected in this object.
:param str text: New text of the draft.
Preserved if left as None.
:param int reply_to: Message ID to reply to.
Preserved if left as 0, erased if s... | [
"Changes",
"the",
"draft",
"message",
"on",
"the",
"Telegram",
"servers",
".",
"The",
"changes",
"are",
"reflected",
"in",
"this",
"object",
"."
] | python | train |
kobinpy/kobin | kobin/routes.py | https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L137-L178 | def match(self, path, method):
""" Get callback and url_vars.
>>> from kobin import Response
>>> r = Router()
>>> def view(user_id: int) -> Response:
... return Response(f'You are {user_id}')
...
>>> r.add('/users/{user_id}', 'GET', 'user-detail', view)
... | [
"def",
"match",
"(",
"self",
",",
"path",
",",
"method",
")",
":",
"if",
"path",
"!=",
"'/'",
":",
"path",
"=",
"path",
".",
"rstrip",
"(",
"'/'",
")",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"status",
"=",
"404",
"for",
"p",
",",
"n",... | Get callback and url_vars.
>>> from kobin import Response
>>> r = Router()
>>> def view(user_id: int) -> Response:
... return Response(f'You are {user_id}')
...
>>> r.add('/users/{user_id}', 'GET', 'user-detail', view)
>>> callback, url_vars = r.match('/user... | [
"Get",
"callback",
"and",
"url_vars",
"."
] | python | train |
vberlier/nbtlib | nbtlib/literal/serializer.py | https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L83-L92 | def should_expand(self, tag):
"""Return whether the specified tag should be expanded."""
return self.indentation is not None and tag and (
not self.previous_indent or (
tag.serializer == 'list'
and tag.subtype.serializer in ('array', 'list', 'compound')
... | [
"def",
"should_expand",
"(",
"self",
",",
"tag",
")",
":",
"return",
"self",
".",
"indentation",
"is",
"not",
"None",
"and",
"tag",
"and",
"(",
"not",
"self",
".",
"previous_indent",
"or",
"(",
"tag",
".",
"serializer",
"==",
"'list'",
"and",
"tag",
".... | Return whether the specified tag should be expanded. | [
"Return",
"whether",
"the",
"specified",
"tag",
"should",
"be",
"expanded",
"."
] | python | train |
dylanaraps/pywal | pywal/theme.py | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L91-L124 | def file(input_file, light=False):
"""Import colorscheme from json file."""
util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))
theme_name = ".".join((input_file, "json"))
bri = "light" if light else "dark"
user_theme_fil... | [
"def",
"file",
"(",
"input_file",
",",
"light",
"=",
"False",
")",
":",
"util",
".",
"create_dir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CONF_DIR",
",",
"\"colorschemes/light/\"",
")",
")",
"util",
".",
"create_dir",
"(",
"os",
".",
"path",
".",
... | Import colorscheme from json file. | [
"Import",
"colorscheme",
"from",
"json",
"file",
"."
] | python | train |
galaxyproject/pulsar | pulsar/web/wsgi.py | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/web/wsgi.py#L14-L20 | def app_factory(global_conf, **local_conf):
"""
Returns the Pulsar WSGI application.
"""
configuration_file = global_conf.get("__file__", None)
webapp = init_webapp(ini_path=configuration_file, local_conf=local_conf)
return webapp | [
"def",
"app_factory",
"(",
"global_conf",
",",
"*",
"*",
"local_conf",
")",
":",
"configuration_file",
"=",
"global_conf",
".",
"get",
"(",
"\"__file__\"",
",",
"None",
")",
"webapp",
"=",
"init_webapp",
"(",
"ini_path",
"=",
"configuration_file",
",",
"local_... | Returns the Pulsar WSGI application. | [
"Returns",
"the",
"Pulsar",
"WSGI",
"application",
"."
] | python | train |
kibitzr/kibitzr | kibitzr/storage.py | https://github.com/kibitzr/kibitzr/blob/749da312488f1dda1ed1093cf4c95aaac0a604f7/kibitzr/storage.py#L167-L181 | def verbose(self):
"""Return changes in human-friendly format #14"""
try:
before = self.git.show('HEAD~1:content').strip()
except sh.ErrorReturnCode_128:
before = None
after = self.git.show('HEAD:content').strip()
if before is not None:
return ... | [
"def",
"verbose",
"(",
"self",
")",
":",
"try",
":",
"before",
"=",
"self",
".",
"git",
".",
"show",
"(",
"'HEAD~1:content'",
")",
".",
"strip",
"(",
")",
"except",
"sh",
".",
"ErrorReturnCode_128",
":",
"before",
"=",
"None",
"after",
"=",
"self",
"... | Return changes in human-friendly format #14 | [
"Return",
"changes",
"in",
"human",
"-",
"friendly",
"format",
"#14"
] | python | train |
mapnik/Cascadenik | cascadenik/compile.py | https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L587-L608 | def is_merc_projection(srs):
""" Return true if the map projection matches that used by VEarth, Google, OSM, etc.
Is currently necessary for zoom-level shorthand for scale-denominator.
"""
if srs.lower() == '+init=epsg:900913':
return True
# observed
srs = dict([p.split('=') fo... | [
"def",
"is_merc_projection",
"(",
"srs",
")",
":",
"if",
"srs",
".",
"lower",
"(",
")",
"==",
"'+init=epsg:900913'",
":",
"return",
"True",
"# observed",
"srs",
"=",
"dict",
"(",
"[",
"p",
".",
"split",
"(",
"'='",
")",
"for",
"p",
"in",
"srs",
".",
... | Return true if the map projection matches that used by VEarth, Google, OSM, etc.
Is currently necessary for zoom-level shorthand for scale-denominator. | [
"Return",
"true",
"if",
"the",
"map",
"projection",
"matches",
"that",
"used",
"by",
"VEarth",
"Google",
"OSM",
"etc",
".",
"Is",
"currently",
"necessary",
"for",
"zoom",
"-",
"level",
"shorthand",
"for",
"scale",
"-",
"denominator",
"."
] | python | train |
Alveo/pyalveo | pyalveo/pyalveo.py | https://github.com/Alveo/pyalveo/blob/1e9eec22bc031bc9a08066f9966565a546e6242e/pyalveo/pyalveo.py#L1395-L1412 | def get_speakers(self, collection_name):
"""Get a list of speaker URLs for this collection
:type collection_name: String
:param collection_name: the name of the collection to search
:rtype: List
:returns: a list of URLs for the speakers associated with
the given col... | [
"def",
"get_speakers",
"(",
"self",
",",
"collection_name",
")",
":",
"speakers_url",
"=",
"\"/speakers/\"",
"+",
"collection_name",
"resp",
"=",
"self",
".",
"api_request",
"(",
"speakers_url",
")",
"if",
"'speakers'",
"in",
"resp",
":",
"return",
"resp",
"["... | Get a list of speaker URLs for this collection
:type collection_name: String
:param collection_name: the name of the collection to search
:rtype: List
:returns: a list of URLs for the speakers associated with
the given collection | [
"Get",
"a",
"list",
"of",
"speaker",
"URLs",
"for",
"this",
"collection"
] | python | train |
Telefonica/toolium | toolium/config_driver.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/config_driver.py#L313-L332 | def _create_chrome_options(self):
"""Create and configure a chrome options object
:returns: chrome options object
"""
# Create Chrome options
options = webdriver.ChromeOptions()
if self.config.getboolean_optional('Driver', 'headless'):
self.logger.debug("Run... | [
"def",
"_create_chrome_options",
"(",
"self",
")",
":",
"# Create Chrome options",
"options",
"=",
"webdriver",
".",
"ChromeOptions",
"(",
")",
"if",
"self",
".",
"config",
".",
"getboolean_optional",
"(",
"'Driver'",
",",
"'headless'",
")",
":",
"self",
".",
... | Create and configure a chrome options object
:returns: chrome options object | [
"Create",
"and",
"configure",
"a",
"chrome",
"options",
"object"
] | python | train |
maas/python-libmaas | maas/client/utils/__init__.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/utils/__init__.py#L63-L79 | def urlencode(data):
"""A version of `urllib.urlencode` that isn't insane.
This only cares that `data` is an iterable of iterables. Each sub-iterable
must be of overall length 2, i.e. a name/value pair.
Unicode strings will be encoded to UTF-8. This is what Django expects; see
`smart_text` in the ... | [
"def",
"urlencode",
"(",
"data",
")",
":",
"def",
"dec",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"string",
"=",
"string",
".",
"decode",
"(",
"\"utf-8\"",
")",
"return",
"quote_plus",
"(",
"string",
")",
"r... | A version of `urllib.urlencode` that isn't insane.
This only cares that `data` is an iterable of iterables. Each sub-iterable
must be of overall length 2, i.e. a name/value pair.
Unicode strings will be encoded to UTF-8. This is what Django expects; see
`smart_text` in the Django documentation. | [
"A",
"version",
"of",
"urllib",
".",
"urlencode",
"that",
"isn",
"t",
"insane",
"."
] | python | train |
hellock/icrawler | icrawler/crawler.py | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/crawler.py#L154-L204 | def crawl(self,
feeder_kwargs=None,
parser_kwargs=None,
downloader_kwargs=None):
"""Start crawling
This method will start feeder, parser and download and wait
until all threads exit.
Args:
feeder_kwargs (dict, optional): Arguments t... | [
"def",
"crawl",
"(",
"self",
",",
"feeder_kwargs",
"=",
"None",
",",
"parser_kwargs",
"=",
"None",
",",
"downloader_kwargs",
"=",
"None",
")",
":",
"self",
".",
"signal",
".",
"reset",
"(",
")",
"self",
".",
"logger",
".",
"info",
"(",
"'start crawling..... | Start crawling
This method will start feeder, parser and download and wait
until all threads exit.
Args:
feeder_kwargs (dict, optional): Arguments to be passed to ``feeder.start()``
parser_kwargs (dict, optional): Arguments to be passed to ``parser.start()``
... | [
"Start",
"crawling"
] | python | train |
wummel/linkchecker | third_party/dnspython/dns/name.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/name.py#L104-L127 | def _validate_labels(labels):
"""Check for empty labels in the middle of a label sequence,
labels that are too long, and for too many labels.
@raises NameTooLong: the name as a whole is too long
@raises LabelTooLong: an individual label is too long
@raises EmptyLabel: a label is empty (i.e. the root... | [
"def",
"_validate_labels",
"(",
"labels",
")",
":",
"l",
"=",
"len",
"(",
"labels",
")",
"total",
"=",
"0",
"i",
"=",
"-",
"1",
"j",
"=",
"0",
"for",
"label",
"in",
"labels",
":",
"ll",
"=",
"len",
"(",
"label",
")",
"total",
"+=",
"ll",
"+",
... | Check for empty labels in the middle of a label sequence,
labels that are too long, and for too many labels.
@raises NameTooLong: the name as a whole is too long
@raises LabelTooLong: an individual label is too long
@raises EmptyLabel: a label is empty (i.e. the root label) and appears
in a position... | [
"Check",
"for",
"empty",
"labels",
"in",
"the",
"middle",
"of",
"a",
"label",
"sequence",
"labels",
"that",
"are",
"too",
"long",
"and",
"for",
"too",
"many",
"labels",
"."
] | python | train |
numenta/htmresearch | htmresearch/frameworks/layers/combined_sequence_experiment2.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/combined_sequence_experiment2.py#L194-L237 | def _updateInferenceStats(self, statistics, objectName=None):
"""
Updates the inference statistics.
Parameters:
----------------------------
@param statistics (dict)
Dictionary in which to write the statistics
@param objectName (str)
Name of the inferred object, if kn... | [
"def",
"_updateInferenceStats",
"(",
"self",
",",
"statistics",
",",
"objectName",
"=",
"None",
")",
":",
"L4Representations",
"=",
"self",
".",
"getL4Representations",
"(",
")",
"L4PredictedCells",
"=",
"self",
".",
"getL4PredictedCells",
"(",
")",
"L4PredictedAc... | Updates the inference statistics.
Parameters:
----------------------------
@param statistics (dict)
Dictionary in which to write the statistics
@param objectName (str)
Name of the inferred object, if known. Otherwise, set to None. | [
"Updates",
"the",
"inference",
"statistics",
"."
] | python | train |
casacore/python-casacore | casacore/tables/table.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/tables/table.py#L1873-L1950 | def view(self, wait=True, tempname="/tmp/seltable"):
""" View a table using casaviewer, casabrowser, or wxwidget
based browser.
The table is viewed depending on the type:
MeasurementSet
is viewed using casaviewer.
Image
is viewed using casaviewer.
ot... | [
"def",
"view",
"(",
"self",
",",
"wait",
"=",
"True",
",",
"tempname",
"=",
"\"/tmp/seltable\"",
")",
":",
"import",
"os",
"# Determine the table type.",
"# Test if casaviewer can be found.",
"# On OS-X 'which' always returns 0, so use test on top of it.",
"viewed",
"=",
"F... | View a table using casaviewer, casabrowser, or wxwidget
based browser.
The table is viewed depending on the type:
MeasurementSet
is viewed using casaviewer.
Image
is viewed using casaviewer.
other
are browsed using the :func:`browse` function.
... | [
"View",
"a",
"table",
"using",
"casaviewer",
"casabrowser",
"or",
"wxwidget",
"based",
"browser",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.