repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
shapiromatron/bmds | bmds/datasets.py | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/datasets.py#L494-L504 | def as_dfile(self):
"""
Return the dataset representation in BMDS .(d) file.
"""
rows = ["Dose Response"]
for dose, response in zip(self.individual_doses, self.responses):
dose_idx = self.doses.index(dose)
if dose_idx >= self.num_dose_groups:
... | [
"def",
"as_dfile",
"(",
"self",
")",
":",
"rows",
"=",
"[",
"\"Dose Response\"",
"]",
"for",
"dose",
",",
"response",
"in",
"zip",
"(",
"self",
".",
"individual_doses",
",",
"self",
".",
"responses",
")",
":",
"dose_idx",
"=",
"self",
".",
"doses",
"."... | Return the dataset representation in BMDS .(d) file. | [
"Return",
"the",
"dataset",
"representation",
"in",
"BMDS",
".",
"(",
"d",
")",
"file",
"."
] | python | train | 36.727273 |
horazont/aioxmpp | aioxmpp/entitycaps/caps390.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/entitycaps/caps390.py#L103-L121 | def _process_extensions(exts):
"""
Generate the `Extensions String` from an iterable of data forms.
:param exts: The data forms to generate the extensions string from.
:type exts: :class:`~collections.abc.Iterable` of
:class:`~.forms.xso.Data`
:return: The `Extensions String`
:rtype: :c... | [
"def",
"_process_extensions",
"(",
"exts",
")",
":",
"parts",
"=",
"[",
"_process_form",
"(",
"form",
")",
"for",
"form",
"in",
"exts",
"]",
"parts",
".",
"sort",
"(",
")",
"return",
"b\"\"",
".",
"join",
"(",
"parts",
")",
"+",
"b\"\\x1c\""
] | Generate the `Extensions String` from an iterable of data forms.
:param exts: The data forms to generate the extensions string from.
:type exts: :class:`~collections.abc.Iterable` of
:class:`~.forms.xso.Data`
:return: The `Extensions String`
:rtype: :class:`bytes`
Generate the `Extensions ... | [
"Generate",
"the",
"Extensions",
"String",
"from",
"an",
"iterable",
"of",
"data",
"forms",
"."
] | python | train | 28.368421 |
appknox/google-chartwrapper | GChartWrapper/GChart.py | https://github.com/appknox/google-chartwrapper/blob/3769aecbef6c83b6cd93ee72ece478ffe433ac57/GChartWrapper/GChart.py#L611-L628 | def image(self):
"""
Returns a PngImageFile instance of the chart
You must have PIL installed for this to work
"""
try:
try:
import Image
except ImportError:
from PIL import Image
except ImportError:
rai... | [
"def",
"image",
"(",
"self",
")",
":",
"try",
":",
"try",
":",
"import",
"Image",
"except",
"ImportError",
":",
"from",
"PIL",
"import",
"Image",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'You must install PIL to fetch image objects'",
")",
"tr... | Returns a PngImageFile instance of the chart
You must have PIL installed for this to work | [
"Returns",
"a",
"PngImageFile",
"instance",
"of",
"the",
"chart"
] | python | test | 30.5 |
cjdrake/pyeda | pyeda/parsing/dimacs.py | https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/parsing/dimacs.py#L96-L99 | def operator(self, text):
"""Push an operator onto the token queue."""
cls = self.OPERATORS[text]
self.push_token(cls(text, self.lineno, self.offset)) | [
"def",
"operator",
"(",
"self",
",",
"text",
")",
":",
"cls",
"=",
"self",
".",
"OPERATORS",
"[",
"text",
"]",
"self",
".",
"push_token",
"(",
"cls",
"(",
"text",
",",
"self",
".",
"lineno",
",",
"self",
".",
"offset",
")",
")"
] | Push an operator onto the token queue. | [
"Push",
"an",
"operator",
"onto",
"the",
"token",
"queue",
"."
] | python | train | 42.75 |
tensorflow/datasets | tensorflow_datasets/core/download/resource.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/resource.py#L273-L278 | def exists_locally(cls, path):
"""Returns whether the resource exists locally, at `resource.path`."""
# If INFO file doesn't exist, consider resource does NOT exist, as it would
# prevent guessing the `extract_method`.
return (tf.io.gfile.exists(path) and
tf.io.gfile.exists(_get_info_path(pa... | [
"def",
"exists_locally",
"(",
"cls",
",",
"path",
")",
":",
"# If INFO file doesn't exist, consider resource does NOT exist, as it would",
"# prevent guessing the `extract_method`.",
"return",
"(",
"tf",
".",
"io",
".",
"gfile",
".",
"exists",
"(",
"path",
")",
"and",
"... | Returns whether the resource exists locally, at `resource.path`. | [
"Returns",
"whether",
"the",
"resource",
"exists",
"locally",
"at",
"resource",
".",
"path",
"."
] | python | train | 53.333333 |
inasafe/inasafe | safe/gui/tools/batch/batch_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/batch/batch_dialog.py#L908-L942 | def validate_scenario(blocks, scenario_directory):
"""Function to validate input layer stored in scenario file.
Check whether the files that are used in scenario file need to be
updated or not.
:param blocks: dictionary from read_scenarios
:type blocks: dictionary
:param scenario_directory: d... | [
"def",
"validate_scenario",
"(",
"blocks",
",",
"scenario_directory",
")",
":",
"# dictionary to temporary contain status message",
"blocks_update",
"=",
"{",
"}",
"for",
"section",
",",
"section_item",
"in",
"list",
"(",
"blocks",
".",
"items",
"(",
")",
")",
":"... | Function to validate input layer stored in scenario file.
Check whether the files that are used in scenario file need to be
updated or not.
:param blocks: dictionary from read_scenarios
:type blocks: dictionary
:param scenario_directory: directory where scenario text file is saved
:type scena... | [
"Function",
"to",
"validate",
"input",
"layer",
"stored",
"in",
"scenario",
"file",
"."
] | python | train | 42.542857 |
crytic/slither | slither/detectors/attributes/const_functions.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/attributes/const_functions.py#L44-L84 | def _detect(self):
""" Detect the constant function changing the state
Recursively visit the calls
Returns:
list: {'vuln', 'filename,'contract','func','#varsWritten'}
"""
results = []
for c in self.contracts:
for f in c.functions:
... | [
"def",
"_detect",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"contracts",
":",
"for",
"f",
"in",
"c",
".",
"functions",
":",
"if",
"f",
".",
"contract",
"!=",
"c",
":",
"continue",
"if",
"f",
".",
"view",
"o... | Detect the constant function changing the state
Recursively visit the calls
Returns:
list: {'vuln', 'filename,'contract','func','#varsWritten'} | [
"Detect",
"the",
"constant",
"function",
"changing",
"the",
"state"
] | python | train | 48.146341 |
quasipedia/swaggery | swaggery/checker.py | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L135-L172 | def check_params_types(self, method):
'''Types in argument annotations must be instances, not classes.'''
mn = method.__name__
annos = dict(method.__annotations__)
errors = []
# Take a look at the syntax
msg_tuple = 'Parameter {} in method {} is not annotated with a tuple... | [
"def",
"check_params_types",
"(",
"self",
",",
"method",
")",
":",
"mn",
"=",
"method",
".",
"__name__",
"annos",
"=",
"dict",
"(",
"method",
".",
"__annotations__",
")",
"errors",
"=",
"[",
"]",
"# Take a look at the syntax",
"msg_tuple",
"=",
"'Parameter {} ... | Types in argument annotations must be instances, not classes. | [
"Types",
"in",
"argument",
"annotations",
"must",
"be",
"instances",
"not",
"classes",
"."
] | python | train | 49.342105 |
annayqho/TheCannon | code/lamost/mass_age/cn/calc_astroseismic_mass.py | https://github.com/annayqho/TheCannon/blob/8010a0a5dc9a3f9bb91efa79d7756f79b3c7ba9a/code/lamost/mass_age/cn/calc_astroseismic_mass.py#L3-L8 | def calc_mass(nu_max, delta_nu, teff):
""" asteroseismic scaling relations """
NU_MAX = 3140.0 # microHz
DELTA_NU = 135.03 # microHz
TEFF = 5777.0
return (nu_max/NU_MAX)**3 * (delta_nu/DELTA_NU)**(-4) * (teff/TEFF)**1.5 | [
"def",
"calc_mass",
"(",
"nu_max",
",",
"delta_nu",
",",
"teff",
")",
":",
"NU_MAX",
"=",
"3140.0",
"# microHz",
"DELTA_NU",
"=",
"135.03",
"# microHz",
"TEFF",
"=",
"5777.0",
"return",
"(",
"nu_max",
"/",
"NU_MAX",
")",
"**",
"3",
"*",
"(",
"delta_nu",
... | asteroseismic scaling relations | [
"asteroseismic",
"scaling",
"relations"
] | python | train | 39 |
sunt05/SuPy | docs/source/proc_var_info/gen_rst.py | https://github.com/sunt05/SuPy/blob/47178bd5aee50a059414e3e504940662fbfae0dc/docs/source/proc_var_info/gen_rst.py#L71-L92 | def gen_opt_str(ser_rec: pd.Series)->str:
'''generate rst option string
Parameters
----------
ser_rec : pd.Series
record for specifications
Returns
-------
str
rst string
'''
name = ser_rec.name
indent = r' '
str_opt = f'.. option:: {name}'+'\n\n'
fo... | [
"def",
"gen_opt_str",
"(",
"ser_rec",
":",
"pd",
".",
"Series",
")",
"->",
"str",
":",
"name",
"=",
"ser_rec",
".",
"name",
"indent",
"=",
"r' '",
"str_opt",
"=",
"f'.. option:: {name}'",
"+",
"'\\n\\n'",
"for",
"spec",
"in",
"ser_rec",
".",
"sort_index... | generate rst option string
Parameters
----------
ser_rec : pd.Series
record for specifications
Returns
-------
str
rst string | [
"generate",
"rst",
"option",
"string"
] | python | train | 22.318182 |
spotify/luigi | luigi/contrib/postgres.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L255-L264 | def map_column(self, value):
"""
Applied to each column of every row returned by `rows`.
Default behaviour is to escape special characters and identify any self.null_values.
"""
if value in self.null_values:
return r'\\N'
else:
return default_esca... | [
"def",
"map_column",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
".",
"null_values",
":",
"return",
"r'\\\\N'",
"else",
":",
"return",
"default_escape",
"(",
"six",
".",
"text_type",
"(",
"value",
")",
")"
] | Applied to each column of every row returned by `rows`.
Default behaviour is to escape special characters and identify any self.null_values. | [
"Applied",
"to",
"each",
"column",
"of",
"every",
"row",
"returned",
"by",
"rows",
"."
] | python | train | 33.5 |
newville/wxmplot | examples/tifffile.py | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L2475-L2656 | def imshow(data, title=None, vmin=0, vmax=None, cmap=None,
bitspersample=None, photometric='rgb', interpolation='nearest',
dpi=96, figure=None, subplot=111, maxdim=4096, **kwargs):
"""Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and plot axis.
Requires pyp... | [
"def",
"imshow",
"(",
"data",
",",
"title",
"=",
"None",
",",
"vmin",
"=",
"0",
",",
"vmax",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"bitspersample",
"=",
"None",
",",
"photometric",
"=",
"'rgb'",
",",
"interpolation",
"=",
"'nearest'",
",",
"dpi... | Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and plot axis.
Requires pyplot already imported ``from matplotlib import pyplot``.
Parameters
----------
bitspersample : int or None
Number of bits per channel in integer RGB images.
photometric : {'miniswhite', ... | [
"Plot",
"n",
"-",
"dimensional",
"images",
"using",
"matplotlib",
".",
"pyplot",
"."
] | python | train | 35.961538 |
rigetti/pyquil | pyquil/quil.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/quil.py#L941-L974 | def merge_programs(prog_list):
"""
Merges a list of pyQuil programs into a single one by appending them in sequence.
If multiple programs in the list contain the same gate and/or noisy gate definition
with identical name, this definition will only be applied once. If different definitions
with the s... | [
"def",
"merge_programs",
"(",
"prog_list",
")",
":",
"definitions",
"=",
"[",
"gate",
"for",
"prog",
"in",
"prog_list",
"for",
"gate",
"in",
"Program",
"(",
"prog",
")",
".",
"defined_gates",
"]",
"seen",
"=",
"{",
"}",
"# Collect definitions in reverse order ... | Merges a list of pyQuil programs into a single one by appending them in sequence.
If multiple programs in the list contain the same gate and/or noisy gate definition
with identical name, this definition will only be applied once. If different definitions
with the same name appear multiple times in the progr... | [
"Merges",
"a",
"list",
"of",
"pyQuil",
"programs",
"into",
"a",
"single",
"one",
"by",
"appending",
"them",
"in",
"sequence",
".",
"If",
"multiple",
"programs",
"in",
"the",
"list",
"contain",
"the",
"same",
"gate",
"and",
"/",
"or",
"noisy",
"gate",
"de... | python | train | 47.823529 |
rosenbrockc/fortpy | fortpy/isense/evaluator.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/isense/evaluator.py#L81-L110 | def _bracket_complete_sig(self, symbol, fullsymbol):
"""Returns the call signature and docstring for the executable
immediately preceding a bracket '(' that was typed."""
if symbol != fullsymbol:
#We have a sym%sym%... chain and the completion just needs to
#be the signat... | [
"def",
"_bracket_complete_sig",
"(",
"self",
",",
"symbol",
",",
"fullsymbol",
")",
":",
"if",
"symbol",
"!=",
"fullsymbol",
":",
"#We have a sym%sym%... chain and the completion just needs to",
"#be the signature of the member method.",
"target",
",",
"targmod",
"=",
"self... | Returns the call signature and docstring for the executable
immediately preceding a bracket '(' that was typed. | [
"Returns",
"the",
"call",
"signature",
"and",
"docstring",
"for",
"the",
"executable",
"immediately",
"preceding",
"a",
"bracket",
"(",
"that",
"was",
"typed",
"."
] | python | train | 49.966667 |
saltstack/salt | salt/returners/cassandra_cql_return.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/cassandra_cql_return.py#L246-L283 | def event_return(events):
'''
Return event to one of potentially many clustered cassandra nodes
Requires that configuration be enabled via 'event_return'
option in master config.
Cassandra does not support an auto-increment feature due to the
highly inefficient nature of creating a monotonical... | [
"def",
"event_return",
"(",
"events",
")",
":",
"for",
"event",
"in",
"events",
":",
"tag",
"=",
"event",
".",
"get",
"(",
"'tag'",
",",
"''",
")",
"data",
"=",
"event",
".",
"get",
"(",
"'data'",
",",
"''",
")",
"query",
"=",
"'''INSERT INTO {keyspa... | Return event to one of potentially many clustered cassandra nodes
Requires that configuration be enabled via 'event_return'
option in master config.
Cassandra does not support an auto-increment feature due to the
highly inefficient nature of creating a monotonically increasing
number across all no... | [
"Return",
"event",
"to",
"one",
"of",
"potentially",
"many",
"clustered",
"cassandra",
"nodes"
] | python | train | 43.236842 |
annayqho/TheCannon | TheCannon/helpers/corner/corner.py | https://github.com/annayqho/TheCannon/blob/8010a0a5dc9a3f9bb91efa79d7756f79b3c7ba9a/TheCannon/helpers/corner/corner.py#L43-L392 | def corner(xs, bins=20, range=None, weights=None, color="k",
smooth=None, smooth1d=None,
labels=None, label_kwargs=None,
show_titles=False, title_fmt=".2f", title_kwargs=None,
truths=None, truth_color="#4682b4",
scale_hist=False, quantiles=None, verbose=False, fig=... | [
"def",
"corner",
"(",
"xs",
",",
"bins",
"=",
"20",
",",
"range",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"color",
"=",
"\"k\"",
",",
"smooth",
"=",
"None",
",",
"smooth1d",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"label_kwargs",
"=",
... | Make a *sick* corner plot showing the projections of a data set in a
multi-dimensional space. kwargs are passed to hist2d() or used for
`matplotlib` styling.
Parameters
----------
xs : array_like (nsamples, ndim)
The samples. This should be a 1- or 2-dimensional array. For a 1-D
arr... | [
"Make",
"a",
"*",
"sick",
"*",
"corner",
"plot",
"showing",
"the",
"projections",
"of",
"a",
"data",
"set",
"in",
"a",
"multi",
"-",
"dimensional",
"space",
".",
"kwargs",
"are",
"passed",
"to",
"hist2d",
"()",
"or",
"used",
"for",
"matplotlib",
"styling... | python | train | 36.908571 |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L123-L144 | def _add_meta(xs, sample=None, config=None):
"""Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input).
"""
out = []
for x in xs:
if not isinstance(x["path"], six.string_types) or not os.path.exists(x["path... | [
"def",
"_add_meta",
"(",
"xs",
",",
"sample",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"x",
"in",
"xs",
":",
"if",
"not",
"isinstance",
"(",
"x",
"[",
"\"path\"",
"]",
",",
"six",
".",
"string_types",
")",
... | Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input). | [
"Add",
"top",
"level",
"information",
"about",
"the",
"sample",
"or",
"flowcell",
"to",
"output",
"."
] | python | train | 41.681818 |
numenta/nupic | src/nupic/frameworks/opf/common_models/cluster_params.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/common_models/cluster_params.py#L120-L129 | def _rangeGen(data, std=1):
"""
Return reasonable min/max values to use given the data.
"""
dataStd = np.std(data)
if dataStd == 0:
dataStd = 1
minval = np.min(data) - std * dataStd
maxval = np.max(data) + std * dataStd
return minval, maxval | [
"def",
"_rangeGen",
"(",
"data",
",",
"std",
"=",
"1",
")",
":",
"dataStd",
"=",
"np",
".",
"std",
"(",
"data",
")",
"if",
"dataStd",
"==",
"0",
":",
"dataStd",
"=",
"1",
"minval",
"=",
"np",
".",
"min",
"(",
"data",
")",
"-",
"std",
"*",
"da... | Return reasonable min/max values to use given the data. | [
"Return",
"reasonable",
"min",
"/",
"max",
"values",
"to",
"use",
"given",
"the",
"data",
"."
] | python | valid | 25.4 |
ToFuProject/tofu | tofu/pathfile.py | https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L278-L302 | def set_Name(self, Name, SaveName=None,
Include=defInclude,
ForceUpdate=False):
""" Set the Name of the instance, automatically updating the SaveName
The name should be a str without spaces or underscores (removed)
When the name is changed, if SaveName (i.e. th... | [
"def",
"set_Name",
"(",
"self",
",",
"Name",
",",
"SaveName",
"=",
"None",
",",
"Include",
"=",
"defInclude",
",",
"ForceUpdate",
"=",
"False",
")",
":",
"self",
".",
"_check_inputs",
"(",
"Name",
"=",
"Name",
",",
"SaveName",
"=",
"SaveName",
",",
"In... | Set the Name of the instance, automatically updating the SaveName
The name should be a str without spaces or underscores (removed)
When the name is changed, if SaveName (i.e. the name used for saving)
was not user-defined, it is automatically updated
Parameters
----------
... | [
"Set",
"the",
"Name",
"of",
"the",
"instance",
"automatically",
"updating",
"the",
"SaveName"
] | python | train | 42.56 |
saltstack/salt | salt/cloud/clouds/vmware.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vmware.py#L1550-L1566 | def list_datacenters(kwargs=None, call=None):
'''
List all the data centers for this VMware environment
CLI Example:
.. code-block:: bash
salt-cloud -f list_datacenters my-vmware-config
'''
if call != 'function':
raise SaltCloudSystemExit(
'The list_datacenters fun... | [
"def",
"list_datacenters",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_datacenters function must be called with '",
"'-f or --function.'",
")",
"return",
"{",
... | List all the data centers for this VMware environment
CLI Example:
.. code-block:: bash
salt-cloud -f list_datacenters my-vmware-config | [
"List",
"all",
"the",
"data",
"centers",
"for",
"this",
"VMware",
"environment"
] | python | train | 26.352941 |
LettError/MutatorMath | Lib/mutatorMath/ufo/document.py | https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L444-L455 | def readVersion(self):
""" Read the document version.
::
<designspace format="3">
"""
ds = self.root.findall("[@format]")[0]
raw_format = ds.attrib['format']
try:
self.documentFormatVersion = int(raw_format)
except ValueError:
#... | [
"def",
"readVersion",
"(",
"self",
")",
":",
"ds",
"=",
"self",
".",
"root",
".",
"findall",
"(",
"\"[@format]\"",
")",
"[",
"0",
"]",
"raw_format",
"=",
"ds",
".",
"attrib",
"[",
"'format'",
"]",
"try",
":",
"self",
".",
"documentFormatVersion",
"=",
... | Read the document version.
::
<designspace format="3"> | [
"Read",
"the",
"document",
"version",
".",
"::",
"<designspace",
"format",
"=",
"3",
">"
] | python | train | 35.916667 |
theonion/django-bulbs | bulbs/contributions/email.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/contributions/email.py#L149-L158 | def send_contributor_email(self, contributor):
"""Send an EmailMessage object for a given contributor."""
ContributorReport(
contributor,
month=self.month,
year=self.year,
deadline=self._deadline,
start=self._start,
end=self._end
... | [
"def",
"send_contributor_email",
"(",
"self",
",",
"contributor",
")",
":",
"ContributorReport",
"(",
"contributor",
",",
"month",
"=",
"self",
".",
"month",
",",
"year",
"=",
"self",
".",
"year",
",",
"deadline",
"=",
"self",
".",
"_deadline",
",",
"start... | Send an EmailMessage object for a given contributor. | [
"Send",
"an",
"EmailMessage",
"object",
"for",
"a",
"given",
"contributor",
"."
] | python | train | 32.5 |
globality-corp/microcosm-flask | microcosm_flask/errors.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/errors.py#L121-L147 | def make_json_error(error):
"""
Handle errors by logging and
"""
message = extract_error_message(error)
status_code = extract_status_code(error)
context = extract_context(error)
retryable = extract_retryable(error)
headers = extract_headers(error)
# Flask will not log user exception... | [
"def",
"make_json_error",
"(",
"error",
")",
":",
"message",
"=",
"extract_error_message",
"(",
"error",
")",
"status_code",
"=",
"extract_status_code",
"(",
"error",
")",
"context",
"=",
"extract_context",
"(",
"error",
")",
"retryable",
"=",
"extract_retryable",... | Handle errors by logging and | [
"Handle",
"errors",
"by",
"logging",
"and"
] | python | train | 32.555556 |
opennode/waldur-core | waldur_core/core/tasks.py | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/tasks.py#L402-L413 | def apply_async(self, args=None, kwargs=None, **options):
"""
Checks whether task must be skipped and decreases the counter in that case.
"""
key = self._get_cache_key(args, kwargs)
counter, penalty = cache.get(key, (0, 0))
if not counter:
return super(Penaliz... | [
"def",
"apply_async",
"(",
"self",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"key",
"=",
"self",
".",
"_get_cache_key",
"(",
"args",
",",
"kwargs",
")",
"counter",
",",
"penalty",
"=",
"cache",
".",
"... | Checks whether task must be skipped and decreases the counter in that case. | [
"Checks",
"whether",
"task",
"must",
"be",
"skipped",
"and",
"decreases",
"the",
"counter",
"in",
"that",
"case",
"."
] | python | train | 50.833333 |
SoftwareDefinedBuildings/XBOS | apps/hole_filling/pelican/backfill.py | https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/hole_filling/pelican/backfill.py#L73-L137 | def fillPelicanHole(site, username, password, tstat_name, start_time, end_time):
"""Fill a hole in a Pelican thermostat's data stream.
Arguments:
site -- The thermostat's Pelican site name
username -- The Pelican username for the site
password -- The Pelican password for the site
... | [
"def",
"fillPelicanHole",
"(",
"site",
",",
"username",
",",
"password",
",",
"tstat_name",
",",
"start_time",
",",
"end_time",
")",
":",
"start",
"=",
"datetime",
".",
"strptime",
"(",
"start_time",
",",
"_INPUT_TIME_FORMAT",
")",
".",
"replace",
"(",
"tzin... | Fill a hole in a Pelican thermostat's data stream.
Arguments:
site -- The thermostat's Pelican site name
username -- The Pelican username for the site
password -- The Pelican password for the site
tstat_name -- The name of the thermostat, as identified by Pelican
start_time ... | [
"Fill",
"a",
"hole",
"in",
"a",
"Pelican",
"thermostat",
"s",
"data",
"stream",
"."
] | python | train | 44.107692 |
pixelogik/NearPy | nearpy/storage/storage_memory.py | https://github.com/pixelogik/NearPy/blob/1b534b864d320d875508e95cd2b76b6d8c07a90b/nearpy/storage/storage_memory.py#L43-L53 | def store_vector(self, hash_name, bucket_key, v, data):
"""
Stores vector and JSON-serializable data in bucket with specified key.
"""
if not hash_name in self.buckets:
self.buckets[hash_name] = {}
if not bucket_key in self.buckets[hash_name]:
self.bucke... | [
"def",
"store_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
",",
"v",
",",
"data",
")",
":",
"if",
"not",
"hash_name",
"in",
"self",
".",
"buckets",
":",
"self",
".",
"buckets",
"[",
"hash_name",
"]",
"=",
"{",
"}",
"if",
"not",
"bucket_... | Stores vector and JSON-serializable data in bucket with specified key. | [
"Stores",
"vector",
"and",
"JSON",
"-",
"serializable",
"data",
"in",
"bucket",
"with",
"specified",
"key",
"."
] | python | train | 36.545455 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L249-L252 | def _list_available_hosts(self, *args):
''' returns a list of hosts that haven't failed and aren't dark '''
return [ h for h in self.inventory.list_hosts(*args) if (h not in self.stats.failures) and (h not in self.stats.dark)] | [
"def",
"_list_available_hosts",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"[",
"h",
"for",
"h",
"in",
"self",
".",
"inventory",
".",
"list_hosts",
"(",
"*",
"args",
")",
"if",
"(",
"h",
"not",
"in",
"self",
".",
"stats",
".",
"failures",
"... | returns a list of hosts that haven't failed and aren't dark | [
"returns",
"a",
"list",
"of",
"hosts",
"that",
"haven",
"t",
"failed",
"and",
"aren",
"t",
"dark"
] | python | train | 60 |
samfoo/vt102 | vt102/__init__.py | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L784-L800 | def _cursor_position(self, row=0, column=0):
"""
Set the cursor to a specific row and column.
Obnoxiously row/column is 1 based, instead of zero based, so we need
to compensate. I know I've created bugs in here somehow.
Confoundingly, inputs of 0 are still acceptable, and shou... | [
"def",
"_cursor_position",
"(",
"self",
",",
"row",
"=",
"0",
",",
"column",
"=",
"0",
")",
":",
"if",
"row",
"==",
"0",
":",
"row",
"=",
"1",
"if",
"column",
"==",
"0",
":",
"column",
"=",
"1",
"self",
".",
"y",
"=",
"min",
"(",
"row",
"-",
... | Set the cursor to a specific row and column.
Obnoxiously row/column is 1 based, instead of zero based, so we need
to compensate. I know I've created bugs in here somehow.
Confoundingly, inputs of 0 are still acceptable, and should move to
the beginning of the row/column as if they wer... | [
"Set",
"the",
"cursor",
"to",
"a",
"specific",
"row",
"and",
"column",
"."
] | python | train | 34.764706 |
inasafe/inasafe | extras/system_tools.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L112-L115 | def clean_line(str, delimiter):
"""Split string on given delimiter, remove whitespace from each field."""
return [x.strip() for x in str.strip().split(delimiter) if x != ''] | [
"def",
"clean_line",
"(",
"str",
",",
"delimiter",
")",
":",
"return",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"str",
".",
"strip",
"(",
")",
".",
"split",
"(",
"delimiter",
")",
"if",
"x",
"!=",
"''",
"]"
] | Split string on given delimiter, remove whitespace from each field. | [
"Split",
"string",
"on",
"given",
"delimiter",
"remove",
"whitespace",
"from",
"each",
"field",
"."
] | python | train | 44.75 |
Gandi/gandi.cli | gandi/cli/core/utils/__init__.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/utils/__init__.py#L239-L243 | def output_kernels(gandi, flavor, name_list, justify=14):
""" Helper to output kernel flavor versions."""
output_line(gandi, 'flavor', flavor, justify)
for name in name_list:
output_line(gandi, 'version', name, justify) | [
"def",
"output_kernels",
"(",
"gandi",
",",
"flavor",
",",
"name_list",
",",
"justify",
"=",
"14",
")",
":",
"output_line",
"(",
"gandi",
",",
"'flavor'",
",",
"flavor",
",",
"justify",
")",
"for",
"name",
"in",
"name_list",
":",
"output_line",
"(",
"gan... | Helper to output kernel flavor versions. | [
"Helper",
"to",
"output",
"kernel",
"flavor",
"versions",
"."
] | python | train | 47 |
hyperledger/indy-plenum | plenum/common/message_processor.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/message_processor.py#L32-L52 | def toDict(self, msg: Dict) -> Dict:
"""
Return a dictionary form of the message
:param msg: the message to be sent
:raises: ValueError if msg cannot be converted to an appropriate format
for transmission
"""
if isinstance(msg, Request):
tmsg = m... | [
"def",
"toDict",
"(",
"self",
",",
"msg",
":",
"Dict",
")",
"->",
"Dict",
":",
"if",
"isinstance",
"(",
"msg",
",",
"Request",
")",
":",
"tmsg",
"=",
"msg",
".",
"as_dict",
"elif",
"hasattr",
"(",
"msg",
",",
"\"_asdict\"",
")",
":",
"tmsg",
"=",
... | Return a dictionary form of the message
:param msg: the message to be sent
:raises: ValueError if msg cannot be converted to an appropriate format
for transmission | [
"Return",
"a",
"dictionary",
"form",
"of",
"the",
"message"
] | python | train | 32.761905 |
pyca/pynacl | src/nacl/bindings/utils.py | https://github.com/pyca/pynacl/blob/0df0c2c7693fa5d316846111ce510702756f5feb/src/nacl/bindings/utils.py#L74-L94 | def sodium_unpad(s, blocksize):
"""
Remove ISO/IEC 7816-4 padding from the input byte array ``s``
:param s: input bytes string
:type s: bytes
:param blocksize:
:type blocksize: int
:return: unpadded string
:rtype: bytes
"""
ensure(isinstance(s, bytes),
raising=exc.Typ... | [
"def",
"sodium_unpad",
"(",
"s",
",",
"blocksize",
")",
":",
"ensure",
"(",
"isinstance",
"(",
"s",
",",
"bytes",
")",
",",
"raising",
"=",
"exc",
".",
"TypeError",
")",
"ensure",
"(",
"isinstance",
"(",
"blocksize",
",",
"integer_types",
")",
",",
"ra... | Remove ISO/IEC 7816-4 padding from the input byte array ``s``
:param s: input bytes string
:type s: bytes
:param blocksize:
:type blocksize: int
:return: unpadded string
:rtype: bytes | [
"Remove",
"ISO",
"/",
"IEC",
"7816",
"-",
"4",
"padding",
"from",
"the",
"input",
"byte",
"array",
"s"
] | python | train | 28.095238 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/tfvc/tfvc_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/tfvc/tfvc_client.py#L214-L261 | def get_changesets(self, project=None, max_comment_length=None, skip=None, top=None, orderby=None, search_criteria=None):
"""GetChangesets.
Retrieve Tfvc Changesets
:param str project: Project ID or project name
:param int max_comment_length: Include details about associated work items i... | [
"def",
"get_changesets",
"(",
"self",
",",
"project",
"=",
"None",
",",
"max_comment_length",
"=",
"None",
",",
"skip",
"=",
"None",
",",
"top",
"=",
"None",
",",
"orderby",
"=",
"None",
",",
"search_criteria",
"=",
"None",
")",
":",
"route_values",
"=",... | GetChangesets.
Retrieve Tfvc Changesets
:param str project: Project ID or project name
:param int max_comment_length: Include details about associated work items in the response. Default: null
:param int skip: Number of results to skip. Default: null
:param int top: The maximum n... | [
"GetChangesets",
".",
"Retrieve",
"Tfvc",
"Changesets",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"int",
"max_comment_length",
":",
"Include",
"details",
"about",
"associated",
"work",
"items",
"in",
"the",
"r... | python | train | 68.25 |
justquick/django-native-tags | native_tags/contrib/pygmentize.py | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/pygmentize.py#L47-L68 | def highlight_block(context, nodelist, lexer, **kwargs):
"""
Code is nodelist ``rendered`` in ``context``
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight_block [lexer na... | [
"def",
"highlight_block",
"(",
"context",
",",
"nodelist",
",",
"lexer",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"highlighter",
"is",
"None",
":",
"return",
"'<pre>%s</pre>'",
"%",
"str",
"(",
"nodelist",
".",
"render",
"(",
"context",
")",
"or",
"''",
... | Code is nodelist ``rendered`` in ``context``
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight_block [lexer name] [formatter options] %}
... source code ..
... | [
"Code",
"is",
"nodelist",
"rendered",
"in",
"context",
"Returns",
"highlighted",
"code",
"div",
"tag",
"from",
"HtmlFormatter",
"Lexer",
"is",
"guessed",
"by",
"lexer",
"name",
"arguments",
"are",
"passed",
"into",
"the",
"formatter"
] | python | train | 34.636364 |
twilio/twilio-python | twilio/twiml/voice_response.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/twiml/voice_response.py#L584-L594 | def ssml_w(self, words, role=None, **kwargs):
"""
Create a <W> element
:param words: Words to speak
:param role: Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning
:param kwargs: additional attributes
:returns: <W> element
... | [
"def",
"ssml_w",
"(",
"self",
",",
"words",
",",
"role",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"nest",
"(",
"SsmlW",
"(",
"words",
",",
"role",
"=",
"role",
",",
"*",
"*",
"kwargs",
")",
")"
] | Create a <W> element
:param words: Words to speak
:param role: Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning
:param kwargs: additional attributes
:returns: <W> element | [
"Create",
"a",
"<W",
">",
"element"
] | python | train | 34.636364 |
OpenHydrology/lmoments3 | lmoments3/distr.py | https://github.com/OpenHydrology/lmoments3/blob/65934df58cd754f1a38e35dc5ee6c30717e5b94c/lmoments3/distr.py#L44-L65 | def lmom_fit(self, data=[], lmom_ratios=[]):
"""
Fit the distribution function to the given data or given L-moments.
:param data: Data to use in calculating the distribution parameters
:type data: array_like
:param lmom_ratios: L-moments (ratios) l1, l2, t3, t4, .. to use in cal... | [
"def",
"lmom_fit",
"(",
"self",
",",
"data",
"=",
"[",
"]",
",",
"lmom_ratios",
"=",
"[",
"]",
")",
":",
"n_min",
"=",
"self",
".",
"numargs",
"+",
"2",
"if",
"len",
"(",
"data",
")",
">",
"0",
":",
"if",
"len",
"(",
"data",
")",
"<=",
"n_min... | Fit the distribution function to the given data or given L-moments.
:param data: Data to use in calculating the distribution parameters
:type data: array_like
:param lmom_ratios: L-moments (ratios) l1, l2, t3, t4, .. to use in calculating the distribution parameters
:type lmom_ratios: a... | [
"Fit",
"the",
"distribution",
"function",
"to",
"the",
"given",
"data",
"or",
"given",
"L",
"-",
"moments",
"."
] | python | train | 47.227273 |
acutesoftware/virtual-AI-simulator | vais/worlds.py | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/worlds.py#L45-L63 | def refresh_stats(self):
"""
only need this when generating terrain (sea = 100 - perc_land at start).
This function forces a recount, otherwise just call the variables
"""
self.tot_pix = 0
self.tot_sea = 0
self.tot_land = 0
self.tot_blocked = 0
for... | [
"def",
"refresh_stats",
"(",
"self",
")",
":",
"self",
".",
"tot_pix",
"=",
"0",
"self",
".",
"tot_sea",
"=",
"0",
"self",
".",
"tot_land",
"=",
"0",
"self",
".",
"tot_blocked",
"=",
"0",
"for",
"row",
"in",
"range",
"(",
"self",
".",
"grd",
".",
... | only need this when generating terrain (sea = 100 - perc_land at start).
This function forces a recount, otherwise just call the variables | [
"only",
"need",
"this",
"when",
"generating",
"terrain",
"(",
"sea",
"=",
"100",
"-",
"perc_land",
"at",
"start",
")",
".",
"This",
"function",
"forces",
"a",
"recount",
"otherwise",
"just",
"call",
"the",
"variables"
] | python | train | 36.684211 |
dsoprea/PySecure | versioneer.py | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/versioneer.py#L1204-L1263 | def get_versions(default=DEFAULT, verbose=False):
"""This variation of get_versions() will be used in versioneer.py ."""
# returns dict with two keys: 'version' and 'full'
assert versionfile_source is not None, "please set versioneer.versionfile_source"
assert tag_prefix is not None, "please set versi... | [
"def",
"get_versions",
"(",
"default",
"=",
"DEFAULT",
",",
"verbose",
"=",
"False",
")",
":",
"# returns dict with two keys: 'version' and 'full'",
"assert",
"versionfile_source",
"is",
"not",
"None",
",",
"\"please set versioneer.versionfile_source\"",
"assert",
"tag_pref... | This variation of get_versions() will be used in versioneer.py . | [
"This",
"variation",
"of",
"get_versions",
"()",
"will",
"be",
"used",
"in",
"versioneer",
".",
"py",
"."
] | python | train | 43.133333 |
PyCQA/astroid | astroid/transforms.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/transforms.py#L28-L48 | def _transform(self, node):
"""Call matching transforms for the given node if any and return the
transformed node.
"""
cls = node.__class__
if cls not in self.transforms:
# no transform registered for this class of node
return node
transforms = se... | [
"def",
"_transform",
"(",
"self",
",",
"node",
")",
":",
"cls",
"=",
"node",
".",
"__class__",
"if",
"cls",
"not",
"in",
"self",
".",
"transforms",
":",
"# no transform registered for this class of node",
"return",
"node",
"transforms",
"=",
"self",
".",
"tran... | Call matching transforms for the given node if any and return the
transformed node. | [
"Call",
"matching",
"transforms",
"for",
"the",
"given",
"node",
"if",
"any",
"and",
"return",
"the",
"transformed",
"node",
"."
] | python | train | 39.238095 |
ponty/EasyProcess | easyprocess/__init__.py | https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L185-L199 | def call(self, timeout=None):
"""Run command with arguments. Wait for command to complete.
same as:
1. :meth:`start`
2. :meth:`wait`
3. :meth:`stop`
:rtype: self
"""
self.start().wait(timeout=timeout)
if self.is_alive():
self.stop... | [
"def",
"call",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"start",
"(",
")",
".",
"wait",
"(",
"timeout",
"=",
"timeout",
")",
"if",
"self",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"stop",
"(",
")",
"return",
"self"
] | Run command with arguments. Wait for command to complete.
same as:
1. :meth:`start`
2. :meth:`wait`
3. :meth:`stop`
:rtype: self | [
"Run",
"command",
"with",
"arguments",
".",
"Wait",
"for",
"command",
"to",
"complete",
"."
] | python | train | 21.866667 |
gholt/swiftly | swiftly/cli/ping.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/ping.py#L271-L364 | def cli_ping(context, prefix):
"""
Performs a ping test.
See :py:mod:`swiftly.cli.ping` for context usage information.
See :py:class:`CLIPing` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param prefix: The container name prefix to use. ... | [
"def",
"cli_ping",
"(",
"context",
",",
"prefix",
")",
":",
"if",
"not",
"prefix",
":",
"prefix",
"=",
"'swiftly-ping'",
"ping_ring_object_puts",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"[",
"]",
")",
"ping_ring_object_gets",
"=",
"collecti... | Performs a ping test.
See :py:mod:`swiftly.cli.ping` for context usage information.
See :py:class:`CLIPing` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param prefix: The container name prefix to use. Default:
swiftly-ping | [
"Performs",
"a",
"ping",
"test",
"."
] | python | test | 43.117021 |
NetEaseGame/ATX | atx/drivers/webdriver.py | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/webdriver.py#L53-L70 | def httpdo(method, url, data=None):
"""
Do HTTP Request
"""
if isinstance(data, dict):
data = json.dumps(data)
if DEBUG:
print "Shell: curl -X {method} -d '{data}' '{url}'".format(method=method, data=data or '', url=url)
fn = dict(GET=requests.get, POST=requests.post, D... | [
"def",
"httpdo",
"(",
"method",
",",
"url",
",",
"data",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"if",
"DEBUG",
":",
"print",
"\"Shell: curl -X {method} -d '{da... | Do HTTP Request | [
"Do",
"HTTP",
"Request"
] | python | train | 32.333333 |
Qiskit/qiskit-terra | qiskit/visualization/text.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L393-L406 | def fillup_layer(layer_length, arrow_char):
"""
Creates a layer with BreakWire elements.
Args:
layer_length (int): The length of the layer to create
arrow_char (char): The char used to create the BreakWire element.
Returns:
list: The new layer.
... | [
"def",
"fillup_layer",
"(",
"layer_length",
",",
"arrow_char",
")",
":",
"breakwire_layer",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"layer_length",
")",
":",
"breakwire_layer",
".",
"append",
"(",
"BreakWire",
"(",
"arrow_char",
")",
")",
"return",
... | Creates a layer with BreakWire elements.
Args:
layer_length (int): The length of the layer to create
arrow_char (char): The char used to create the BreakWire element.
Returns:
list: The new layer. | [
"Creates",
"a",
"layer",
"with",
"BreakWire",
"elements",
".",
"Args",
":",
"layer_length",
"(",
"int",
")",
":",
"The",
"length",
"of",
"the",
"layer",
"to",
"create",
"arrow_char",
"(",
"char",
")",
":",
"The",
"char",
"used",
"to",
"create",
"the",
... | python | test | 33.428571 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L622-L630 | def calibrate_pressure(self):
'''calibrate pressure'''
if self.mavlink10():
self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0,
0, 0, 1, 0, 0, 0, 0)
... | [
"def",
"calibrate_pressure",
"(",
"self",
")",
":",
"if",
"self",
".",
"mavlink10",
"(",
")",
":",
"self",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"target_system",
",",
"self",
".",
"target_component",
",",
"mavlink",
".",
"MAV_CMD_PREFLIGHT_... | calibrate pressure | [
"calibrate",
"pressure"
] | python | train | 52.666667 |
rmorshea/spectate | spectate/core.py | https://github.com/rmorshea/spectate/blob/79bd84dd8d00889015ce1d1e190db865a02cdb93/spectate/core.py#L151-L186 | def call(self, obj, name, method, args, kwargs):
"""Trigger a method along with its beforebacks and afterbacks.
Parameters
----------
name: str
The name of the method that will be called
args: tuple
The arguments that will be passed to the base method
... | [
"def",
"call",
"(",
"self",
",",
"obj",
",",
"name",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"name",
"in",
"self",
".",
"_callback_registry",
":",
"beforebacks",
",",
"afterbacks",
"=",
"zip",
"(",
"*",
"self",
".",
"_callback_regist... | Trigger a method along with its beforebacks and afterbacks.
Parameters
----------
name: str
The name of the method that will be called
args: tuple
The arguments that will be passed to the base method
kwargs: dict
The keyword args that will be ... | [
"Trigger",
"a",
"method",
"along",
"with",
"its",
"beforebacks",
"and",
"afterbacks",
"."
] | python | train | 34.833333 |
oseledets/ttpy | tt/ksl/ksl.py | https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/ksl/ksl.py#L7-L123 | def ksl(A, y0, tau, verb=1, scheme='symm', space=8, rmax=2000, use_normest=1):
""" Dynamical tensor-train approximation based on projector splitting
This function performs one step of dynamical tensor-train approximation
for the equation
.. math ::
\\frac{dy}{dt} = A y, \\quad y... | [
"def",
"ksl",
"(",
"A",
",",
"y0",
",",
"tau",
",",
"verb",
"=",
"1",
",",
"scheme",
"=",
"'symm'",
",",
"space",
"=",
"8",
",",
"rmax",
"=",
"2000",
",",
"use_normest",
"=",
"1",
")",
":",
"y0",
"=",
"y0",
".",
"round",
"(",
"1e-14",
")",
... | Dynamical tensor-train approximation based on projector splitting
This function performs one step of dynamical tensor-train approximation
for the equation
.. math ::
\\frac{dy}{dt} = A y, \\quad y(0) = y_0
and outputs approximation for :math:`y(\\tau)`
:References:
... | [
"Dynamical",
"tensor",
"-",
"train",
"approximation",
"based",
"on",
"projector",
"splitting",
"This",
"function",
"performs",
"one",
"step",
"of",
"dynamical",
"tensor",
"-",
"train",
"approximation",
"for",
"the",
"equation"
] | python | train | 28.940171 |
Netflix-Skunkworks/cloudaux | cloudaux/aws/iam.py | https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/aws/iam.py#L209-L224 | def get_managed_policy_document(policy_arn, policy_metadata=None, client=None, **kwargs):
"""Retrieve the currently active (i.e. 'default') policy version document for a policy.
:param policy_arn:
:param policy_metadata: This is a previously fetch managed policy response from boto/cloudaux.
... | [
"def",
"get_managed_policy_document",
"(",
"policy_arn",
",",
"policy_metadata",
"=",
"None",
",",
"client",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"policy_metadata",
":",
"policy_metadata",
"=",
"client",
".",
"get_policy",
"(",
"PolicyA... | Retrieve the currently active (i.e. 'default') policy version document for a policy.
:param policy_arn:
:param policy_metadata: This is a previously fetch managed policy response from boto/cloudaux.
This is used to prevent unnecessary API calls to get the initial policy default vers... | [
"Retrieve",
"the",
"currently",
"active",
"(",
"i",
".",
"e",
".",
"default",
")",
"policy",
"version",
"document",
"for",
"a",
"policy",
"."
] | python | valid | 49.625 |
alvarogzp/telegram-bot-framework | bot/action/util/format.py | https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L31-L43 | def default_format(self):
"""
Returns full name (first and last) if name is available.
If not, returns username if available.
If not available too, returns the user id as a string.
"""
user = self.user
if user.first_name is not None:
return self.full_n... | [
"def",
"default_format",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"user",
"if",
"user",
".",
"first_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"full_name",
"elif",
"user",
".",
"username",
"is",
"not",
"None",
":",
"return",
"user"... | Returns full name (first and last) if name is available.
If not, returns username if available.
If not available too, returns the user id as a string. | [
"Returns",
"full",
"name",
"(",
"first",
"and",
"last",
")",
"if",
"name",
"is",
"available",
".",
"If",
"not",
"returns",
"username",
"if",
"available",
".",
"If",
"not",
"available",
"too",
"returns",
"the",
"user",
"id",
"as",
"a",
"string",
"."
] | python | train | 33.076923 |
wakatime/wakatime | wakatime/stats.py | https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/stats.py#L228-L245 | def standardize_language(language, plugin):
"""Maps a string to the equivalent Pygments language.
Returns the standardized language string.
"""
if not language:
return None
# standardize language for this plugin
if plugin:
plugin = plugin.split(' ')[-1].split('/')[0].split('-'... | [
"def",
"standardize_language",
"(",
"language",
",",
"plugin",
")",
":",
"if",
"not",
"language",
":",
"return",
"None",
"# standardize language for this plugin",
"if",
"plugin",
":",
"plugin",
"=",
"plugin",
".",
"split",
"(",
"' '",
")",
"[",
"-",
"1",
"]"... | Maps a string to the equivalent Pygments language.
Returns the standardized language string. | [
"Maps",
"a",
"string",
"to",
"the",
"equivalent",
"Pygments",
"language",
"."
] | python | train | 30.5 |
newville/wxmplot | wxmplot/plotapp.py | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotapp.py#L21-L25 | def plot(self, x, y, **kw):
"""plot x, y values (erasing old plot),
for method options see PlotPanel.plot.
"""
return self.frame.plot(x,y,**kw) | [
"def",
"plot",
"(",
"self",
",",
"x",
",",
"y",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"frame",
".",
"plot",
"(",
"x",
",",
"y",
",",
"*",
"*",
"kw",
")"
] | plot x, y values (erasing old plot),
for method options see PlotPanel.plot. | [
"plot",
"x",
"y",
"values",
"(",
"erasing",
"old",
"plot",
")",
"for",
"method",
"options",
"see",
"PlotPanel",
".",
"plot",
"."
] | python | train | 34.4 |
VIVelev/PyDojoML | dojo/cluster/kmeans.py | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/cluster/kmeans.py#L58-L70 | def _closest_centroid(self, x):
"""Returns the index of the closest centroid to the sample
"""
closest_centroid = 0
distance = 10^9
for i in range(self.n_clusters):
current_distance = linalg.norm(x - self.centroids[i])
if current_distance < distance:
... | [
"def",
"_closest_centroid",
"(",
"self",
",",
"x",
")",
":",
"closest_centroid",
"=",
"0",
"distance",
"=",
"10",
"^",
"9",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n_clusters",
")",
":",
"current_distance",
"=",
"linalg",
".",
"norm",
"(",
"x",
... | Returns the index of the closest centroid to the sample | [
"Returns",
"the",
"index",
"of",
"the",
"closest",
"centroid",
"to",
"the",
"sample"
] | python | train | 32.076923 |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L281-L292 | def total_reads_from_grabix(in_file):
"""Retrieve total reads in a fastq file from grabix index.
"""
gbi_file = _get_grabix_index(in_file)
if gbi_file:
with open(gbi_file) as in_handle:
next(in_handle) # throw away
num_lines = int(next(in_handle).strip())
assert ... | [
"def",
"total_reads_from_grabix",
"(",
"in_file",
")",
":",
"gbi_file",
"=",
"_get_grabix_index",
"(",
"in_file",
")",
"if",
"gbi_file",
":",
"with",
"open",
"(",
"gbi_file",
")",
"as",
"in_handle",
":",
"next",
"(",
"in_handle",
")",
"# throw away",
"num_line... | Retrieve total reads in a fastq file from grabix index. | [
"Retrieve",
"total",
"reads",
"in",
"a",
"fastq",
"file",
"from",
"grabix",
"index",
"."
] | python | train | 35.166667 |
binarydud/pyres | pyres/__init__.py | https://github.com/binarydud/pyres/blob/4f4b28257afe5b7a08fd38a063fad7ce62c03ae2/pyres/__init__.py#L212-L222 | def enqueue(self, klass, *args):
"""Enqueue a job into a specific queue. Make sure the class you are
passing has **queue** attribute and a **perform** method on it.
"""
queue = getattr(klass,'queue', None)
if queue:
class_name = '%s.%s' % (klass.__module__, klass.__n... | [
"def",
"enqueue",
"(",
"self",
",",
"klass",
",",
"*",
"args",
")",
":",
"queue",
"=",
"getattr",
"(",
"klass",
",",
"'queue'",
",",
"None",
")",
"if",
"queue",
":",
"class_name",
"=",
"'%s.%s'",
"%",
"(",
"klass",
".",
"__module__",
",",
"klass",
... | Enqueue a job into a specific queue. Make sure the class you are
passing has **queue** attribute and a **perform** method on it. | [
"Enqueue",
"a",
"job",
"into",
"a",
"specific",
"queue",
".",
"Make",
"sure",
"the",
"class",
"you",
"are",
"passing",
"has",
"**",
"queue",
"**",
"attribute",
"and",
"a",
"**",
"perform",
"**",
"method",
"on",
"it",
"."
] | python | train | 42.909091 |
uw-it-aca/uw-restclients-trumba | uw_trumba/calendars.py | https://github.com/uw-it-aca/uw-restclients-trumba/blob/49e739924c332f08128a32b73fb798d580b9eafd/uw_trumba/calendars.py#L230-L245 | def _load_permissions(campus, calendarid, resp_fragment, permission_list):
"""
:return: a list of sorted trumba.Permission objects
None if error, [] if not exists
"""
for record in resp_fragment:
if not _is_valid_email(record['Email']):
# skip the non UW users
... | [
"def",
"_load_permissions",
"(",
"campus",
",",
"calendarid",
",",
"resp_fragment",
",",
"permission_list",
")",
":",
"for",
"record",
"in",
"resp_fragment",
":",
"if",
"not",
"_is_valid_email",
"(",
"record",
"[",
"'Email'",
"]",
")",
":",
"# skip the non UW us... | :return: a list of sorted trumba.Permission objects
None if error, [] if not exists | [
":",
"return",
":",
"a",
"list",
"of",
"sorted",
"trumba",
".",
"Permission",
"objects",
"None",
"if",
"error",
"[]",
"if",
"not",
"exists"
] | python | train | 36.25 |
estnltk/estnltk | estnltk/syntax/vislcg3_syntax.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/vislcg3_syntax.py#L213-L302 | def process_lines( self, input_lines, **kwargs ):
''' Executes the pipeline of subsequent VISL_CG3 commands. The first process
in pipeline gets input_lines as an input, and each subsequent process gets
the output of the previous process as an input.
The idea of h... | [
"def",
"process_lines",
"(",
"self",
",",
"input_lines",
",",
"*",
"*",
"kwargs",
")",
":",
"split_result_lines",
"=",
"False",
"remove_info",
"=",
"True",
"for",
"argName",
",",
"argVal",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"argName",
"in... | Executes the pipeline of subsequent VISL_CG3 commands. The first process
in pipeline gets input_lines as an input, and each subsequent process gets
the output of the previous process as an input.
The idea of how to construct the pipeline borrows from:
https... | [
"Executes",
"the",
"pipeline",
"of",
"subsequent",
"VISL_CG3",
"commands",
".",
"The",
"first",
"process",
"in",
"pipeline",
"gets",
"input_lines",
"as",
"an",
"input",
"and",
"each",
"subsequent",
"process",
"gets",
"the",
"output",
"of",
"the",
"previous",
"... | python | train | 46.866667 |
pytroll/satpy | satpy/writers/mitiff.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/writers/mitiff.py#L546-L615 | def _save_datasets_as_mitiff(self, datasets, image_description,
gen_filename, **kwargs):
"""Put all togehter and save as a tiff file with the special tag
making it a mitiff file.
"""
from libtiff import TIFF
tif = TIFF.open(gen_filename, mode=... | [
"def",
"_save_datasets_as_mitiff",
"(",
"self",
",",
"datasets",
",",
"image_description",
",",
"gen_filename",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"libtiff",
"import",
"TIFF",
"tif",
"=",
"TIFF",
".",
"open",
"(",
"gen_filename",
",",
"mode",
"=",
... | Put all togehter and save as a tiff file with the special tag
making it a mitiff file. | [
"Put",
"all",
"togehter",
"and",
"save",
"as",
"a",
"tiff",
"file",
"with",
"the",
"special",
"tag",
"making",
"it",
"a",
"mitiff",
"file",
"."
] | python | train | 50.771429 |
abseil/abseil-py | absl/flags/_flagvalues.py | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L811-L819 | def unparse_flags(self):
"""Unparses all flags to the point before any FLAGS(argv) was called."""
for f in self._flags().values():
f.unparse()
# We log this message before marking flags as unparsed to avoid a
# problem when the logging library causes flags access.
logging.info('unparse_flags()... | [
"def",
"unparse_flags",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"_flags",
"(",
")",
".",
"values",
"(",
")",
":",
"f",
".",
"unparse",
"(",
")",
"# We log this message before marking flags as unparsed to avoid a",
"# problem when the logging library ca... | Unparses all flags to the point before any FLAGS(argv) was called. | [
"Unparses",
"all",
"flags",
"to",
"the",
"point",
"before",
"any",
"FLAGS",
"(",
"argv",
")",
"was",
"called",
"."
] | python | train | 50.333333 |
happyleavesaoc/python-snapcast | snapcast/control/server.py | https://github.com/happyleavesaoc/python-snapcast/blob/9b3c483358677327c7fd6d0666bf474c19d87f19/snapcast/control/server.py#L132-L136 | def delete_client(self, identifier):
"""Delete client."""
params = {'id': identifier}
response = yield from self._transact(SERVER_DELETECLIENT, params)
self.synchronize(response) | [
"def",
"delete_client",
"(",
"self",
",",
"identifier",
")",
":",
"params",
"=",
"{",
"'id'",
":",
"identifier",
"}",
"response",
"=",
"yield",
"from",
"self",
".",
"_transact",
"(",
"SERVER_DELETECLIENT",
",",
"params",
")",
"self",
".",
"synchronize",
"(... | Delete client. | [
"Delete",
"client",
"."
] | python | train | 41.2 |
chaoss/grimoirelab-elk | utils/index_mapping.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L297-L347 | def export_items(elastic_url, in_index, out_index, elastic_url_out=None,
search_after=False, search_after_value=None, limit=None,
copy=False):
""" Export items from in_index to out_index using the correct mapping """
if not limit:
limit = DEFAULT_LIMIT
if search_a... | [
"def",
"export_items",
"(",
"elastic_url",
",",
"in_index",
",",
"out_index",
",",
"elastic_url_out",
"=",
"None",
",",
"search_after",
"=",
"False",
",",
"search_after_value",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"i... | Export items from in_index to out_index using the correct mapping | [
"Export",
"items",
"from",
"in_index",
"to",
"out_index",
"using",
"the",
"correct",
"mapping"
] | python | train | 40.862745 |
dslackw/slpkg | slpkg/binary/install.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/binary/install.py#L314-L325 | def top_view(self):
"""Print packages status bar
"""
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"New Version", " " * 8,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
... | [
"def",
"top_view",
"(",
"self",
")",
":",
"self",
".",
"msg",
".",
"template",
"(",
"78",
")",
"print",
"(",
"\"{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}\"",
".",
"format",
"(",
"\"| Package\"",
",",
"\" \"",
"*",
"17",
",",
"\"New Version\"",
",",
"\" \"",
"*",
... | Print packages status bar | [
"Print",
"packages",
"status",
"bar"
] | python | train | 29.833333 |
zeehio/parmap | parmap/parmap.py | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L386-L428 | def _map_or_starmap_async(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map_async and parmap.starmap_async.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"... | [
"def",
"_map_or_starmap_async",
"(",
"function",
",",
"iterable",
",",
"args",
",",
"kwargs",
",",
"map_or_starmap",
")",
":",
"arg_newarg",
"=",
"(",
"(",
"\"parallel\"",
",",
"\"pm_parallel\"",
")",
",",
"(",
"\"chunksize\"",
",",
"\"pm_chunksize\"",
")",
",... | Shared function between parmap.map_async and parmap.starmap_async.
Refer to those functions for details. | [
"Shared",
"function",
"between",
"parmap",
".",
"map_async",
"and",
"parmap",
".",
"starmap_async",
".",
"Refer",
"to",
"those",
"functions",
"for",
"details",
"."
] | python | train | 46.72093 |
gear11/pypelogs | pypein/wikip.py | https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypein/wikip.py#L132-L177 | def find_geo_coords(s):
"""Returns a list of lat/lons found by scanning the given text"""
coords = []
LOG.debug("Matching in text size %s", len(s))
for c in INFO_BOX_LAT_LON.findall(s):
try:
coord = (float(c[1]), float(c[2])) #, c[0])
coords.append(coord)
LOG... | [
"def",
"find_geo_coords",
"(",
"s",
")",
":",
"coords",
"=",
"[",
"]",
"LOG",
".",
"debug",
"(",
"\"Matching in text size %s\"",
",",
"len",
"(",
"s",
")",
")",
"for",
"c",
"in",
"INFO_BOX_LAT_LON",
".",
"findall",
"(",
"s",
")",
":",
"try",
":",
"co... | Returns a list of lat/lons found by scanning the given text | [
"Returns",
"a",
"list",
"of",
"lat",
"/",
"lons",
"found",
"by",
"scanning",
"the",
"given",
"text"
] | python | train | 44.847826 |
MLAB-project/pymlab | src/pymlab/sensors/__init__.py | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/__init__.py#L219-L223 | def write_byte_data(self, address, register, value):
"""Write a byte value to a device's register. """
LOGGER.debug("Writing byte data %s to register %s on device %s",
bin(value), hex(register), hex(address))
return self.driver.write_byte_data(address, register, value) | [
"def",
"write_byte_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Writing byte data %s to register %s on device %s\"",
",",
"bin",
"(",
"value",
")",
",",
"hex",
"(",
"register",
")",
",",
"hex",
... | Write a byte value to a device's register. | [
"Write",
"a",
"byte",
"value",
"to",
"a",
"device",
"s",
"register",
"."
] | python | train | 60.2 |
zetaops/zengine | zengine/views/channel_management.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L270-L287 | def return_selected_form_items(form_info):
"""
It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' name... | [
"def",
"return_selected_form_items",
"(",
"form_info",
")",
":",
"selected_keys",
"=",
"[",
"]",
"selected_names",
"=",
"[",
"]",
"for",
"chosen",
"in",
"form_info",
":",
"if",
"chosen",
"[",
"'choice'",
"]",
":",
"selected_keys",
".",
"append",
"(",
"chosen... | It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' names. | [
"It",
"returns",
"chosen",
"keys",
"list",
"from",
"a",
"given",
"form",
"."
] | python | train | 32.777778 |
python-gitlab/python-gitlab | gitlab/v4/objects.py | https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L221-L241 | def list(self, **kwargs):
"""Retrieve a list of objects.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): ... | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"'/users/%s/projects'",
"%",
"self",
".",
"_parent",
".",
"id",
"return",
"ListMixin",
".",
"list",
"(",
"self",
",",
"path",
"=",
"path",
",",
"*",
"*",
"kwargs",
")"
] | Retrieve a list of objects.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): If set to False and no pagination opt... | [
"Retrieve",
"a",
"list",
"of",
"objects",
"."
] | python | train | 40.571429 |
log2timeline/plaso | plaso/parsers/esedb_plugins/msie_webcache.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/esedb_plugins/msie_webcache.py#L260-L319 | def ParseContainersTable(
self, parser_mediator, database=None, table=None, **unused_kwargs):
"""Parses the Containers table.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
database (Optional[pyesedb.fil... | [
"def",
"ParseContainersTable",
"(",
"self",
",",
"parser_mediator",
",",
"database",
"=",
"None",
",",
"table",
"=",
"None",
",",
"*",
"*",
"unused_kwargs",
")",
":",
"if",
"database",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Missing database value.'",... | Parses the Containers table.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
database (Optional[pyesedb.file]): ESE database.
table (Optional[pyesedb.table]): table.
Raises:
ValueError: if the data... | [
"Parses",
"the",
"Containers",
"table",
"."
] | python | train | 37.683333 |
saltstack/salt | salt/modules/solr.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solr.py#L711-L800 | def match_index_versions(host=None, core_name=None):
'''
SLAVE CALL
Verifies that the master and the slave versions are in sync by
comparing the index version. If you are constantly pushing updates
the index the master and slave versions will seldom match. A solution
to this is pause indexing ev... | [
"def",
"match_index_versions",
"(",
"host",
"=",
"None",
",",
"core_name",
"=",
"None",
")",
":",
"# since only slaves can call this let's check the config:",
"ret",
"=",
"_get_return_dict",
"(",
")",
"success",
"=",
"True",
"if",
"_is_master",
"(",
")",
"and",
"_... | SLAVE CALL
Verifies that the master and the slave versions are in sync by
comparing the index version. If you are constantly pushing updates
the index the master and slave versions will seldom match. A solution
to this is pause indexing every so often to allow the slave to replicate
and then call th... | [
"SLAVE",
"CALL",
"Verifies",
"that",
"the",
"master",
"and",
"the",
"slave",
"versions",
"are",
"in",
"sync",
"by",
"comparing",
"the",
"index",
"version",
".",
"If",
"you",
"are",
"constantly",
"pushing",
"updates",
"the",
"index",
"the",
"master",
"and",
... | python | train | 39.988889 |
bambinos/bambi | bambi/models.py | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L83-L93 | def reset(self):
'''
Reset list of terms and y-variable.
'''
self.terms = OrderedDict()
self.y = None
self.backend = None
self.added_terms = []
self._added_priors = {}
self.completes = []
self.clean_data = None | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"terms",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"y",
"=",
"None",
"self",
".",
"backend",
"=",
"None",
"self",
".",
"added_terms",
"=",
"[",
"]",
"self",
".",
"_added_priors",
"=",
"{",
"}",
... | Reset list of terms and y-variable. | [
"Reset",
"list",
"of",
"terms",
"and",
"y",
"-",
"variable",
"."
] | python | train | 25.454545 |
pantsbuild/pants | src/python/pants/backend/jvm/tasks/resolve_shared.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/resolve_shared.py#L31-L67 | def add_directory_digests_for_jars(self, targets_and_jars):
"""For each target, get DirectoryDigests for its jars and return them zipped with the jars.
:param targets_and_jars: List of tuples of the form (Target, [pants.java.jar.jar_dependency_utils.ResolveJar])
:return: list[tuple[(Target, list[pants.java... | [
"def",
"add_directory_digests_for_jars",
"(",
"self",
",",
"targets_and_jars",
")",
":",
"targets_and_jars",
"=",
"list",
"(",
"targets_and_jars",
")",
"if",
"not",
"targets_and_jars",
"or",
"not",
"self",
".",
"get_options",
"(",
")",
".",
"capture_snapshots",
":... | For each target, get DirectoryDigests for its jars and return them zipped with the jars.
:param targets_and_jars: List of tuples of the form (Target, [pants.java.jar.jar_dependency_utils.ResolveJar])
:return: list[tuple[(Target, list[pants.java.jar.jar_dependency_utils.ResolveJar])] | [
"For",
"each",
"target",
"get",
"DirectoryDigests",
"for",
"its",
"jars",
"and",
"return",
"them",
"zipped",
"with",
"the",
"jars",
"."
] | python | train | 44.945946 |
pvlib/pvlib-python | pvlib/clearsky.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/clearsky.py#L377-L465 | def simplified_solis(apparent_elevation, aod700=0.1, precipitable_water=1.,
pressure=101325., dni_extra=1364.):
"""
Calculate the clear sky GHI, DNI, and DHI according to the
simplified Solis model [1]_.
Reference [1]_ describes the accuracy of the model as being 15, 20,
and 18... | [
"def",
"simplified_solis",
"(",
"apparent_elevation",
",",
"aod700",
"=",
"0.1",
",",
"precipitable_water",
"=",
"1.",
",",
"pressure",
"=",
"101325.",
",",
"dni_extra",
"=",
"1364.",
")",
":",
"p",
"=",
"pressure",
"w",
"=",
"precipitable_water",
"# algorithm... | Calculate the clear sky GHI, DNI, and DHI according to the
simplified Solis model [1]_.
Reference [1]_ describes the accuracy of the model as being 15, 20,
and 18 W/m^2 for the beam, global, and diffuse components. Reference
[2]_ provides comparisons with other clear sky models.
Parameters
---... | [
"Calculate",
"the",
"clear",
"sky",
"GHI",
"DNI",
"and",
"DHI",
"according",
"to",
"the",
"simplified",
"Solis",
"model",
"[",
"1",
"]",
"_",
"."
] | python | train | 31.674157 |
gbiggs/rtctree | rtctree/utils.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/utils.py#L87-L125 | def get_num_columns_and_rows(widths, gap_width, term_width):
'''Given a list of string widths, a width of the minimum gap to place
between them, and the maximum width of the output (such as a terminal
width), calculate the number of columns and rows, and the width of each
column, for the optimal lay... | [
"def",
"get_num_columns_and_rows",
"(",
"widths",
",",
"gap_width",
",",
"term_width",
")",
":",
"def",
"calc_longest_width",
"(",
"widths",
",",
"gap_width",
",",
"ncols",
")",
":",
"longest",
"=",
"0",
"rows",
"=",
"[",
"widths",
"[",
"s",
":",
"s",
"+... | Given a list of string widths, a width of the minimum gap to place
between them, and the maximum width of the output (such as a terminal
width), calculate the number of columns and rows, and the width of each
column, for the optimal layout. | [
"Given",
"a",
"list",
"of",
"string",
"widths",
"a",
"width",
"of",
"the",
"minimum",
"gap",
"to",
"place",
"between",
"them",
"and",
"the",
"maximum",
"width",
"of",
"the",
"output",
"(",
"such",
"as",
"a",
"terminal",
"width",
")",
"calculate",
"the",
... | python | train | 42 |
manahl/arctic | arctic/store/version_store.py | https://github.com/manahl/arctic/blob/57e110b6e182dbab00e7e214dc26f7d9ec47c120/arctic/store/version_store.py#L460-L483 | def read_metadata(self, symbol, as_of=None, allow_secondary=None):
"""
Return the metadata saved for a symbol. This method is fast as it doesn't
actually load the data.
Parameters
----------
symbol : `str`
symbol name for the item
as_of : `str` or in... | [
"def",
"read_metadata",
"(",
"self",
",",
"symbol",
",",
"as_of",
"=",
"None",
",",
"allow_secondary",
"=",
"None",
")",
":",
"_version",
"=",
"self",
".",
"_read_metadata",
"(",
"symbol",
",",
"as_of",
"=",
"as_of",
",",
"read_preference",
"=",
"self",
... | Return the metadata saved for a symbol. This method is fast as it doesn't
actually load the data.
Parameters
----------
symbol : `str`
symbol name for the item
as_of : `str` or int or `datetime.datetime`
Return the data as it was as_of the point in time.... | [
"Return",
"the",
"metadata",
"saved",
"for",
"a",
"symbol",
".",
"This",
"method",
"is",
"fast",
"as",
"it",
"doesn",
"t",
"actually",
"load",
"the",
"data",
"."
] | python | train | 56.125 |
materialsproject/pymatgen | pymatgen/io/abinit/nodes.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/nodes.py#L746-L751 | def deps_status(self):
"""Returns a list with the status of the dependencies."""
if not self.deps:
return [self.S_OK]
return [d.status for d in self.deps] | [
"def",
"deps_status",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"deps",
":",
"return",
"[",
"self",
".",
"S_OK",
"]",
"return",
"[",
"d",
".",
"status",
"for",
"d",
"in",
"self",
".",
"deps",
"]"
] | Returns a list with the status of the dependencies. | [
"Returns",
"a",
"list",
"with",
"the",
"status",
"of",
"the",
"dependencies",
"."
] | python | train | 31 |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2506-L2536 | def all_continuous_indexes_slices(ol,value):
'''
from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
all_continuous_indexes_slices(ol,"a")
'''
rslt = []
length = ol.__len__()
cursor = 0
begin = None
slice = []
while(cursor < length):
cond1 =... | [
"def",
"all_continuous_indexes_slices",
"(",
"ol",
",",
"value",
")",
":",
"rslt",
"=",
"[",
"]",
"length",
"=",
"ol",
".",
"__len__",
"(",
")",
"cursor",
"=",
"0",
"begin",
"=",
"None",
"slice",
"=",
"[",
"]",
"while",
"(",
"cursor",
"<",
"length",
... | from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
all_continuous_indexes_slices(ol,"a") | [
"from",
"elist",
".",
"elist",
"import",
"*",
"ol",
"=",
"[",
"1",
"a",
"a",
"2",
"3",
"a",
"4",
"a",
"a",
"a",
"5",
"]",
"all_continuous_indexes_slices",
"(",
"ol",
"a",
")"
] | python | valid | 24.612903 |
pandas-dev/pandas | pandas/core/internals/blocks.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L1229-L1257 | def shift(self, periods, axis=0, fill_value=None):
""" shift the block by periods, possibly upcast """
# convert integer to float if necessary. need to do a lot more than
# that, handle boolean etc also
new_values, fill_value = maybe_upcast(self.values, fill_value)
# make sure ... | [
"def",
"shift",
"(",
"self",
",",
"periods",
",",
"axis",
"=",
"0",
",",
"fill_value",
"=",
"None",
")",
":",
"# convert integer to float if necessary. need to do a lot more than",
"# that, handle boolean etc also",
"new_values",
",",
"fill_value",
"=",
"maybe_upcast",
... | shift the block by periods, possibly upcast | [
"shift",
"the",
"block",
"by",
"periods",
"possibly",
"upcast"
] | python | train | 35.586207 |
Datary/scrapbag | scrapbag/csvs.py | https://github.com/Datary/scrapbag/blob/3a4f9824ab6fe21121214ba9963690618da2c9de/scrapbag/csvs.py#L25-L40 | def get_csv_col_headers(rows, row_headers_count_value=0):
"""
Retrieve csv column headers
"""
count = 0
if rows:
for row in rows:
if exclude_empty_values(row[:row_headers_count_value]):
break
count += 1
if len(rows) == count:
count = 1 #... | [
"def",
"get_csv_col_headers",
"(",
"rows",
",",
"row_headers_count_value",
"=",
"0",
")",
":",
"count",
"=",
"0",
"if",
"rows",
":",
"for",
"row",
"in",
"rows",
":",
"if",
"exclude_empty_values",
"(",
"row",
"[",
":",
"row_headers_count_value",
"]",
")",
"... | Retrieve csv column headers | [
"Retrieve",
"csv",
"column",
"headers"
] | python | train | 23.75 |
tkhyn/dirsync | dirsync/syncer.py | https://github.com/tkhyn/dirsync/blob/a461a6c31a4cf521c1b6a8bcfcd8602e6288e8ce/dirsync/syncer.py#L453-L457 | def _dirdiffandupdate(self, dir1, dir2):
"""
Private function which does directory diff & update
"""
self._dowork(dir1, dir2, None, self._update) | [
"def",
"_dirdiffandupdate",
"(",
"self",
",",
"dir1",
",",
"dir2",
")",
":",
"self",
".",
"_dowork",
"(",
"dir1",
",",
"dir2",
",",
"None",
",",
"self",
".",
"_update",
")"
] | Private function which does directory diff & update | [
"Private",
"function",
"which",
"does",
"directory",
"diff",
"&",
"update"
] | python | train | 34.6 |
Opentrons/opentrons | api/src/opentrons/hardware_control/__init__.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/hardware_control/__init__.py#L135-L157 | def build_hardware_simulator(
cls,
attached_instruments: Dict[top_types.Mount, Dict[str, Optional[str]]] = None, # noqa E501
attached_modules: List[str] = None,
config: robot_configs.robot_config = None,
loop: asyncio.AbstractEventLoop = None,
str... | [
"def",
"build_hardware_simulator",
"(",
"cls",
",",
"attached_instruments",
":",
"Dict",
"[",
"top_types",
".",
"Mount",
",",
"Dict",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
"]",
"]",
"=",
"None",
",",
"# noqa E501",
"attached_modules",
":",
"List",
... | Build a simulating hardware controller.
This method may be used both on a real robot and on dev machines.
Multiple simulating hardware controllers may be active at one time. | [
"Build",
"a",
"simulating",
"hardware",
"controller",
"."
] | python | train | 41.652174 |
limix/limix-core | limix_core/mean/meanKronSum.py | https://github.com/limix/limix-core/blob/5c590b4d351409f83ca320844b4897ce92203814/limix_core/mean/meanKronSum.py#L169-L181 | def Y(self, value):
""" set phenotype """
self._N = value.shape[0]
self._P = value.shape[1]
self._Y = value
# missing data
self._Iok = ~sp.isnan(value)
self._veIok = vec(self._Iok)[:, 0]
self._miss = (~self._Iok).any()
# notify and clear_cached
... | [
"def",
"Y",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_N",
"=",
"value",
".",
"shape",
"[",
"0",
"]",
"self",
".",
"_P",
"=",
"value",
".",
"shape",
"[",
"1",
"]",
"self",
".",
"_Y",
"=",
"value",
"# missing data",
"self",
".",
"_Iok",... | set phenotype | [
"set",
"phenotype"
] | python | train | 30.076923 |
dragnet-org/dragnet | dragnet/features/__init__.py | https://github.com/dragnet-org/dragnet/blob/532c9d9f28e5b1b57f3cabc708218d3863a16322/dragnet/features/__init__.py#L8-L21 | def get_feature(name):
"""Get an instance of a ``Features`` class by ``name`` (str)."""
if name == 'css':
return CSSFeatures()
elif name == 'kohlschuetter':
return KohlschuetterFeatures()
elif name == 'readability':
return ReadabilityFeatures()
elif name == 'weninger':
... | [
"def",
"get_feature",
"(",
"name",
")",
":",
"if",
"name",
"==",
"'css'",
":",
"return",
"CSSFeatures",
"(",
")",
"elif",
"name",
"==",
"'kohlschuetter'",
":",
"return",
"KohlschuetterFeatures",
"(",
")",
"elif",
"name",
"==",
"'readability'",
":",
"return",... | Get an instance of a ``Features`` class by ``name`` (str). | [
"Get",
"an",
"instance",
"of",
"a",
"Features",
"class",
"by",
"name",
"(",
"str",
")",
"."
] | python | train | 35.285714 |
python-visualization/folium | folium/utilities.py | https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/utilities.py#L440-L446 | def normalize(rendered):
"""Return the input string without non-functional spaces or newlines."""
out = ''.join([line.strip()
for line in rendered.splitlines()
if line.strip()])
out = out.replace(', ', ',')
return out | [
"def",
"normalize",
"(",
"rendered",
")",
":",
"out",
"=",
"''",
".",
"join",
"(",
"[",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"rendered",
".",
"splitlines",
"(",
")",
"if",
"line",
".",
"strip",
"(",
")",
"]",
")",
"out",
"=",
"o... | Return the input string without non-functional spaces or newlines. | [
"Return",
"the",
"input",
"string",
"without",
"non",
"-",
"functional",
"spaces",
"or",
"newlines",
"."
] | python | train | 37.857143 |
jssimporter/python-jss | jss/jssobjects.py | https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobjects.py#L888-L901 | def set_category(self, category):
"""Set package category
Args:
category: String of an existing category's name, or a
Category object.
"""
# For some reason, packages only have the category name, not the
# ID.
if isinstance(category, Category)... | [
"def",
"set_category",
"(",
"self",
",",
"category",
")",
":",
"# For some reason, packages only have the category name, not the",
"# ID.",
"if",
"isinstance",
"(",
"category",
",",
"Category",
")",
":",
"name",
"=",
"category",
".",
"name",
"else",
":",
"name",
"... | Set package category
Args:
category: String of an existing category's name, or a
Category object. | [
"Set",
"package",
"category"
] | python | train | 30.357143 |
cytoscape/py2cytoscape | py2cytoscape/cyrest/network.py | https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/network.py#L636-L686 | def select(self, adjacentEdges=None, edgeList=None, extendEdges=None, firstNeighbors=None, \
invert=None, network=None, nodeList=None, verbose=False):
"""
Select nodes and/or edges in a network. This command provides options to
invert the selection, add first neighbors, add adjacent edge... | [
"def",
"select",
"(",
"self",
",",
"adjacentEdges",
"=",
"None",
",",
"edgeList",
"=",
"None",
",",
"extendEdges",
"=",
"None",
",",
"firstNeighbors",
"=",
"None",
",",
"invert",
"=",
"None",
",",
"network",
"=",
"None",
",",
"nodeList",
"=",
"None",
"... | Select nodes and/or edges in a network. This command provides options to
invert the selection, add first neighbors, add adjacent edges of selected
nodes, and add adjacent nodes of selected edges
:param adjacentEdges (string, optional): If 'true', then select any edges
adjacent to an... | [
"Select",
"nodes",
"and",
"/",
"or",
"edges",
"in",
"a",
"network",
".",
"This",
"command",
"provides",
"options",
"to",
"invert",
"the",
"selection",
"add",
"first",
"neighbors",
"add",
"adjacent",
"edges",
"of",
"selected",
"nodes",
"and",
"add",
"adjacent... | python | train | 66.019608 |
radujica/baloo | baloo/weld/weld_joins.py | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_joins.py#L110-L156 | def weld_merge_join(arrays_self, weld_types_self, arrays_other, weld_types_other,
how, is_on_sorted, is_on_unique, readable_text):
"""Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or W... | [
"def",
"weld_merge_join",
"(",
"arrays_self",
",",
"weld_types_self",
",",
"arrays_other",
",",
"weld_types_other",
",",
"how",
",",
"is_on_sorted",
",",
"is_on_unique",
",",
"readable_text",
")",
":",
"assert",
"is_on_unique",
"weld_obj_vec_of_struct_self",
"=",
"wel... | Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or WeldObject)
Columns from the self DataFrame on which to join.
weld_types_self : list of WeldType
Corresponding Weld types.
arrays_other... | [
"Applies",
"merge",
"-",
"join",
"on",
"the",
"arrays",
"returning",
"indices",
"from",
"each",
"to",
"keep",
"in",
"the",
"resulting"
] | python | train | 42.12766 |
sorgerlab/indra | indra/sources/biopax/processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/processor.py#L187-L259 | def get_regulate_activities(self):
"""Get Activation/Inhibition INDRA Statements from the BioPAX model.
This method extracts Activation/Inhibition Statements and reuses the
structure of BioPAX Pattern's
org.biopax.paxtools.pattern.PatternBox.constrolsStateChange pattern
with add... | [
"def",
"get_regulate_activities",
"(",
"self",
")",
":",
"mcc",
"=",
"_bpp",
"(",
"'constraint.ModificationChangeConstraint'",
")",
"mcct",
"=",
"_bpp",
"(",
"'constraint.ModificationChangeConstraint$Type'",
")",
"mod_filter",
"=",
"'residue modification, active'",
"# Start... | Get Activation/Inhibition INDRA Statements from the BioPAX model.
This method extracts Activation/Inhibition Statements and reuses the
structure of BioPAX Pattern's
org.biopax.paxtools.pattern.PatternBox.constrolsStateChange pattern
with additional constraints to specify the gain or los... | [
"Get",
"Activation",
"/",
"Inhibition",
"INDRA",
"Statements",
"from",
"the",
"BioPAX",
"model",
"."
] | python | train | 49.205479 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py#L403-L496 | def uninstall(self, auto_confirm=False):
"""
Uninstall the distribution currently satisfying this requirement.
Prompts before removing or modifying files unless
``auto_confirm`` is True.
Refuses to delete or modify files outside of ``sys.prefix`` -
thus uninstallation w... | [
"def",
"uninstall",
"(",
"self",
",",
"auto_confirm",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"check_if_exists",
"(",
")",
":",
"raise",
"UninstallationError",
"(",
"\"Cannot uninstall requirement %s, not installed\"",
"%",
"(",
"self",
".",
"name",
",... | Uninstall the distribution currently satisfying this requirement.
Prompts before removing or modifying files unless
``auto_confirm`` is True.
Refuses to delete or modify files outside of ``sys.prefix`` -
thus uninstallation within a virtual environment can only
modify that virt... | [
"Uninstall",
"the",
"distribution",
"currently",
"satisfying",
"this",
"requirement",
"."
] | python | test | 50.404255 |
sileht/cotyledon | cotyledon/_service_manager.py | https://github.com/sileht/cotyledon/blob/319faa2673a986733d9a7622bee29e187f2e7391/cotyledon/_service_manager.py#L138-L172 | def register_hooks(self, on_terminate=None, on_reload=None,
on_new_worker=None, on_dead_worker=None):
"""Register hook methods
This can be callable multiple times to add more hooks, hooks are
executed in added order. If a hook raised an exception, next hooks
will ... | [
"def",
"register_hooks",
"(",
"self",
",",
"on_terminate",
"=",
"None",
",",
"on_reload",
"=",
"None",
",",
"on_new_worker",
"=",
"None",
",",
"on_dead_worker",
"=",
"None",
")",
":",
"if",
"on_terminate",
"is",
"not",
"None",
":",
"_utils",
".",
"check_ca... | Register hook methods
This can be callable multiple times to add more hooks, hooks are
executed in added order. If a hook raised an exception, next hooks
will be not executed.
:param on_terminate: method called on SIGTERM
:type on_terminate: callable()
:param on_reload:... | [
"Register",
"hook",
"methods"
] | python | train | 46.542857 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py#L326-L357 | def print_stats(self, clsname=None, limit=1.0):
"""
Write tracked objects to stdout. The output can be filtered and
pruned. Only objects are printed whose classname contain the substring
supplied by the `clsname` argument. The output can be pruned by
passing a `limit` value.
... | [
"def",
"print_stats",
"(",
"self",
",",
"clsname",
"=",
"None",
",",
"limit",
"=",
"1.0",
")",
":",
"if",
"self",
".",
"tracker",
":",
"self",
".",
"tracker",
".",
"stop_periodic_snapshots",
"(",
")",
"if",
"not",
"self",
".",
"sorted",
":",
"self",
... | Write tracked objects to stdout. The output can be filtered and
pruned. Only objects are printed whose classname contain the substring
supplied by the `clsname` argument. The output can be pruned by
passing a `limit` value.
:param clsname: Only print objects whose classname contain t... | [
"Write",
"tracked",
"objects",
"to",
"stdout",
".",
"The",
"output",
"can",
"be",
"filtered",
"and",
"pruned",
".",
"Only",
"objects",
"are",
"printed",
"whose",
"classname",
"contain",
"the",
"substring",
"supplied",
"by",
"the",
"clsname",
"argument",
".",
... | python | train | 37.125 |
nickoala/telepot | telepot/__init__.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L945-L950 | def uploadStickerFile(self, user_id, png_sticker):
"""
See: https://core.telegram.org/bots/api#uploadstickerfile
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rectify(p), 'png_sticker', png_sticker) | [
"def",
"uploadStickerFile",
"(",
"self",
",",
"user_id",
",",
"png_sticker",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'png_sticker'",
"]",
")",
"return",
"self",
".",
"_api_request_with_file",
"(",
"'uploadStickerFile'",... | See: https://core.telegram.org/bots/api#uploadstickerfile | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#uploadstickerfile"
] | python | train | 48.5 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/node.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/node.py#L402-L416 | def parent_chain(self):
"""
Return the list of parents starting from this node. The chain ends
at the first node with no parents.
"""
chain = [self]
while True:
try:
parent = chain[-1].parent
except Exception:
break
... | [
"def",
"parent_chain",
"(",
"self",
")",
":",
"chain",
"=",
"[",
"self",
"]",
"while",
"True",
":",
"try",
":",
"parent",
"=",
"chain",
"[",
"-",
"1",
"]",
".",
"parent",
"except",
"Exception",
":",
"break",
"if",
"parent",
"is",
"None",
":",
"brea... | Return the list of parents starting from this node. The chain ends
at the first node with no parents. | [
"Return",
"the",
"list",
"of",
"parents",
"starting",
"from",
"this",
"node",
".",
"The",
"chain",
"ends",
"at",
"the",
"first",
"node",
"with",
"no",
"parents",
"."
] | python | train | 27.466667 |
Hackerfleet/hfos | modules/library/hfos/library/manager.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/library/hfos/library/manager.py#L141-L215 | def _augment_book(self, uuid, event):
"""
Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client
"""
try:
if not is... | [
"def",
"_augment_book",
"(",
"self",
",",
"uuid",
",",
"event",
")",
":",
"try",
":",
"if",
"not",
"isbnmeta",
":",
"self",
".",
"log",
"(",
"\"No isbntools found! Install it to get full \"",
"\"functionality!\"",
",",
"lvl",
"=",
"warn",
")",
"return",
"new_b... | Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client | [
"Checks",
"if",
"the",
"newly",
"created",
"object",
"is",
"a",
"book",
"and",
"only",
"has",
"an",
"ISBN",
".",
"If",
"so",
"tries",
"to",
"fetch",
"the",
"book",
"data",
"off",
"the",
"internet",
"."
] | python | train | 40.506667 |
SeabornGames/Meta | seaborn_meta/calling_function.py | https://github.com/SeabornGames/Meta/blob/f2a38ad8bcc5ac177e537645853593225895df46/seaborn_meta/calling_function.py#L81-L102 | def relevant_kwargs(function, exclude_keys='self', exclude_values=None,
extra_values=None):
"""
This will return a dictionary of local variables that are parameters to the
function provided in the arg.
Example:
function(**relevant_kwargs(function))
:param function: f... | [
"def",
"relevant_kwargs",
"(",
"function",
",",
"exclude_keys",
"=",
"'self'",
",",
"exclude_values",
"=",
"None",
",",
"extra_values",
"=",
"None",
")",
":",
"args",
"=",
"function_args",
"(",
"function",
")",
"locals_values",
"=",
"function_kwargs",
"(",
"fu... | This will return a dictionary of local variables that are parameters to the
function provided in the arg.
Example:
function(**relevant_kwargs(function))
:param function: function to select parameters for
:param exclude_keys: str,list,func if not a function it will be converted
... | [
"This",
"will",
"return",
"a",
"dictionary",
"of",
"local",
"variables",
"that",
"are",
"parameters",
"to",
"the",
"function",
"provided",
"in",
"the",
"arg",
"."
] | python | train | 46.363636 |
emc-openstack/storops | storops/unity/resource/lun.py | https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/unity/resource/lun.py#L195-L204 | def expand(self, new_size):
""" expand the LUN to a new size
:param new_size: new size in bytes.
:return: the old size
"""
ret = self.size_total
resp = self.modify(size=new_size)
resp.raise_if_err()
return ret | [
"def",
"expand",
"(",
"self",
",",
"new_size",
")",
":",
"ret",
"=",
"self",
".",
"size_total",
"resp",
"=",
"self",
".",
"modify",
"(",
"size",
"=",
"new_size",
")",
"resp",
".",
"raise_if_err",
"(",
")",
"return",
"ret"
] | expand the LUN to a new size
:param new_size: new size in bytes.
:return: the old size | [
"expand",
"the",
"LUN",
"to",
"a",
"new",
"size"
] | python | train | 26.5 |
pantsbuild/pants | src/python/pants/goal/run_tracker.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/run_tracker.py#L318-L348 | def new_workunit_under_parent(self, name, parent, labels=None, cmd='', log_config=None):
"""Creates a (hierarchical) subunit of work for the purpose of timing and reporting.
- name: A short name for this work. E.g., 'resolve', 'compile', 'scala', 'zinc'.
- parent: The new workunit is created under this par... | [
"def",
"new_workunit_under_parent",
"(",
"self",
",",
"name",
",",
"parent",
",",
"labels",
"=",
"None",
",",
"cmd",
"=",
"''",
",",
"log_config",
"=",
"None",
")",
":",
"workunit",
"=",
"WorkUnit",
"(",
"run_info_dir",
"=",
"self",
".",
"run_info_dir",
... | Creates a (hierarchical) subunit of work for the purpose of timing and reporting.
- name: A short name for this work. E.g., 'resolve', 'compile', 'scala', 'zinc'.
- parent: The new workunit is created under this parent.
- labels: An optional iterable of labels. The reporters can use this to decide how to
... | [
"Creates",
"a",
"(",
"hierarchical",
")",
"subunit",
"of",
"work",
"for",
"the",
"purpose",
"of",
"timing",
"and",
"reporting",
"."
] | python | train | 38.870968 |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L600-L637 | def _slice_weights(self, arr, li, lh):
"""slice fused rnn weights"""
args = {}
gate_names = self._gate_names
directions = self._directions
b = len(directions)
p = 0
for layer in range(self._num_layers):
for direction in directions:
for... | [
"def",
"_slice_weights",
"(",
"self",
",",
"arr",
",",
"li",
",",
"lh",
")",
":",
"args",
"=",
"{",
"}",
"gate_names",
"=",
"self",
".",
"_gate_names",
"directions",
"=",
"self",
".",
"_directions",
"b",
"=",
"len",
"(",
"directions",
")",
"p",
"=",
... | slice fused rnn weights | [
"slice",
"fused",
"rnn",
"weights"
] | python | train | 40.342105 |
kennethreitz/flask-sslify | flask_sslify.py | https://github.com/kennethreitz/flask-sslify/blob/425a1deb4a1a8f693319f4b97134196e0235848c/flask_sslify.py#L52-L59 | def hsts_header(self):
"""Returns the proper HSTS policy."""
hsts_policy = 'max-age={0}'.format(self.hsts_age)
if self.hsts_include_subdomains:
hsts_policy += '; includeSubDomains'
return hsts_policy | [
"def",
"hsts_header",
"(",
"self",
")",
":",
"hsts_policy",
"=",
"'max-age={0}'",
".",
"format",
"(",
"self",
".",
"hsts_age",
")",
"if",
"self",
".",
"hsts_include_subdomains",
":",
"hsts_policy",
"+=",
"'; includeSubDomains'",
"return",
"hsts_policy"
] | Returns the proper HSTS policy. | [
"Returns",
"the",
"proper",
"HSTS",
"policy",
"."
] | python | train | 29.75 |
jobovy/galpy | galpy/potential/KuzminKutuzovStaeckelPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/KuzminKutuzovStaeckelPotential.py#L276-L292 | def _n2deriv(self,l,n):
"""
NAME:
_n2deriv
PURPOSE:
evaluate the second derivative w.r.t. nu for this potential
INPUT:
l - prolate spheroidal coordinate lambda
n - prolate spheroidal coordinate nu
OUTPUT:
second derivati... | [
"def",
"_n2deriv",
"(",
"self",
",",
"l",
",",
"n",
")",
":",
"numer",
"=",
"-",
"nu",
".",
"sqrt",
"(",
"l",
")",
"-",
"3.",
"*",
"nu",
".",
"sqrt",
"(",
"n",
")",
"denom",
"=",
"4.",
"*",
"n",
"**",
"1.5",
"*",
"(",
"nu",
".",
"sqrt",
... | NAME:
_n2deriv
PURPOSE:
evaluate the second derivative w.r.t. nu for this potential
INPUT:
l - prolate spheroidal coordinate lambda
n - prolate spheroidal coordinate nu
OUTPUT:
second derivative w.r.t. nu
HISTORY:
20... | [
"NAME",
":",
"_n2deriv",
"PURPOSE",
":",
"evaluate",
"the",
"second",
"derivative",
"w",
".",
"r",
".",
"t",
".",
"nu",
"for",
"this",
"potential",
"INPUT",
":",
"l",
"-",
"prolate",
"spheroidal",
"coordinate",
"lambda",
"n",
"-",
"prolate",
"spheroidal",
... | python | train | 30.764706 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L117-L139 | def mutagen_call(action, path, func, *args, **kwargs):
"""Call a Mutagen function with appropriate error handling.
`action` is a string describing what the function is trying to do,
and `path` is the relevant filename. The rest of the arguments
describe the callable to invoke.
We require at least ... | [
"def",
"mutagen_call",
"(",
"action",
",",
"path",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"mutagen",
".",
"MutagenError",
"as",
"exc"... | Call a Mutagen function with appropriate error handling.
`action` is a string describing what the function is trying to do,
and `path` is the relevant filename. The rest of the arguments
describe the callable to invoke.
We require at least Mutagen 1.33, where `IOError` is *never* used,
neither for... | [
"Call",
"a",
"Mutagen",
"function",
"with",
"appropriate",
"error",
"handling",
"."
] | python | train | 46.565217 |
joestump/python-oauth2 | example/appengine_oauth.py | https://github.com/joestump/python-oauth2/blob/b94f69b1ad195513547924e380d9265133e995fa/example/appengine_oauth.py#L51-L64 | def get_oauth_request(self):
"""Return an OAuth Request object for the current request."""
try:
method = os.environ['REQUEST_METHOD']
except:
method = 'GET'
postdata = None
if method in ('POST', 'PUT'):
postdata = self.request.body
r... | [
"def",
"get_oauth_request",
"(",
"self",
")",
":",
"try",
":",
"method",
"=",
"os",
".",
"environ",
"[",
"'REQUEST_METHOD'",
"]",
"except",
":",
"method",
"=",
"'GET'",
"postdata",
"=",
"None",
"if",
"method",
"in",
"(",
"'POST'",
",",
"'PUT'",
")",
":... | Return an OAuth Request object for the current request. | [
"Return",
"an",
"OAuth",
"Request",
"object",
"for",
"the",
"current",
"request",
"."
] | python | train | 30.714286 |
lreis2415/PyGeoC | examples/ex04_watershed_delineation.py | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex04_watershed_delineation.py#L8-L14 | def main():
"""The simplest usage of watershed delineation based on TauDEM."""
dem = '../tests/data/Jamaica_dem.tif'
num_proc = 2
wp = '../tests/data/tmp_results/wtsd_delineation'
TauDEMWorkflow.watershed_delineation(num_proc, dem, workingdir=wp) | [
"def",
"main",
"(",
")",
":",
"dem",
"=",
"'../tests/data/Jamaica_dem.tif'",
"num_proc",
"=",
"2",
"wp",
"=",
"'../tests/data/tmp_results/wtsd_delineation'",
"TauDEMWorkflow",
".",
"watershed_delineation",
"(",
"num_proc",
",",
"dem",
",",
"workingdir",
"=",
"wp",
"... | The simplest usage of watershed delineation based on TauDEM. | [
"The",
"simplest",
"usage",
"of",
"watershed",
"delineation",
"based",
"on",
"TauDEM",
"."
] | python | train | 37.285714 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.