repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
Genida/dependenpy | src/dependenpy/finder.py | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L45-L61 | def combine(specs):
"""
Combine package specifications' limitations.
Args:
specs (list of PackageSpec): the package specifications.
Returns:
list of PackageSpec: the new, merged list of PackageSpec.
"""
new_specs = {}
for spec in specs:
... | [
"def",
"combine",
"(",
"specs",
")",
":",
"new_specs",
"=",
"{",
"}",
"for",
"spec",
"in",
"specs",
":",
"if",
"new_specs",
".",
"get",
"(",
"spec",
",",
"None",
")",
"is",
"None",
":",
"new_specs",
"[",
"spec",
"]",
"=",
"spec",
"else",
":",
"ne... | Combine package specifications' limitations.
Args:
specs (list of PackageSpec): the package specifications.
Returns:
list of PackageSpec: the new, merged list of PackageSpec. | [
"Combine",
"package",
"specifications",
"limitations",
"."
] | python | train |
saltstack/salt | salt/modules/win_lgpo.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_lgpo.py#L4462-L4476 | def _dasd_conversion(cls, val, **kwargs):
'''
converts 0/1/2 for dasd reg key
'''
if val is not None:
if val == '0' or val == 0 or val == '':
return 'Administrators'
elif val == '1' or val == 1:
return 'Administrators and Power User... | [
"def",
"_dasd_conversion",
"(",
"cls",
",",
"val",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"val",
"is",
"not",
"None",
":",
"if",
"val",
"==",
"'0'",
"or",
"val",
"==",
"0",
"or",
"val",
"==",
"''",
":",
"return",
"'Administrators'",
"elif",
"val"... | converts 0/1/2 for dasd reg key | [
"converts",
"0",
"/",
"1",
"/",
"2",
"for",
"dasd",
"reg",
"key"
] | python | train |
thomasdelaet/python-velbus | velbus/controller.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/controller.py#L123-L130 | def send_binary(self, binary_message, callback=None):
"""
:return: None
"""
assert isinstance(binary_message, str)
message = self.parser.parse(binary_message)
if isinstance(message, velbus.Message):
self.send(message, callback) | [
"def",
"send_binary",
"(",
"self",
",",
"binary_message",
",",
"callback",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"binary_message",
",",
"str",
")",
"message",
"=",
"self",
".",
"parser",
".",
"parse",
"(",
"binary_message",
")",
"if",
"isinst... | :return: None | [
":",
"return",
":",
"None"
] | python | train |
saltstack/salt | salt/states/cmd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cmd.py#L561-L710 | def wait_script(name,
source=None,
template=None,
onlyif=None,
unless=None,
cwd=None,
runas=None,
shell=None,
env=None,
stateful=False,
umask=None,
... | [
"def",
"wait_script",
"(",
"name",
",",
"source",
"=",
"None",
",",
"template",
"=",
"None",
",",
"onlyif",
"=",
"None",
",",
"unless",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"runas",
"=",
"None",
",",
"shell",
"=",
"None",
",",
"env",
"=",
"... | Download a script from a remote source and execute it only if a watch
statement calls it.
source
The source script being downloaded to the minion, this source script is
hosted on the salt master server. If the file is located on the master
in the directory named spam, and is called egg... | [
"Download",
"a",
"script",
"from",
"a",
"remote",
"source",
"and",
"execute",
"it",
"only",
"if",
"a",
"watch",
"statement",
"calls",
"it",
"."
] | python | train |
widdowquinn/pyani | pyani/anib.py | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anib.py#L341-L360 | def construct_blastn_cmdline(
fname1, fname2, outdir, blastn_exe=pyani_config.BLASTN_DEFAULT
):
"""Returns a single blastn command.
- filename - input filename
- blastn_exe - path to BLASTN executable
"""
fstem1 = os.path.splitext(os.path.split(fname1)[-1])[0]
fstem2 = os.path.splitext(os.p... | [
"def",
"construct_blastn_cmdline",
"(",
"fname1",
",",
"fname2",
",",
"outdir",
",",
"blastn_exe",
"=",
"pyani_config",
".",
"BLASTN_DEFAULT",
")",
":",
"fstem1",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"fname1",... | Returns a single blastn command.
- filename - input filename
- blastn_exe - path to BLASTN executable | [
"Returns",
"a",
"single",
"blastn",
"command",
"."
] | python | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L240-L265 | def bear_rhumb(ra1, dec1, ra2, dec2):
"""
Calculate the bearing of point 2 from point 1 along a Rhumb line.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates... | [
"def",
"bear_rhumb",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"# verified against website to give correct results",
"phi1",
"=",
"np",
".",
"radians",
"(",
"dec1",
")",
"phi2",
"=",
"np",
".",
"radians",
"(",
"dec2",
")",
"lambda1",
"=",... | Calculate the bearing of point 2 from point 1 along a Rhumb line.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates (degrees) of the two points.
Returns
---... | [
"Calculate",
"the",
"bearing",
"of",
"point",
"2",
"from",
"point",
"1",
"along",
"a",
"Rhumb",
"line",
".",
"The",
"bearing",
"is",
"East",
"of",
"North",
"and",
"is",
"in",
"[",
"0",
"360",
")",
"whereas",
"position",
"angle",
"is",
"also",
"East",
... | python | train |
NerdWalletOSS/savage | src/savage/__init__.py | https://github.com/NerdWalletOSS/savage/blob/54f64ac1c912528710365107952967d31d56e60d/src/savage/__init__.py#L55-L71 | def _after_flush_handler(session, _flush_context):
"""Archive all new/updated/deleted data"""
dialect = get_dialect(session)
handlers = [
(_versioned_delete, session.deleted),
(_versioned_insert, session.new),
(_versioned_update, session.dirty),
]
for handler, rows in handler... | [
"def",
"_after_flush_handler",
"(",
"session",
",",
"_flush_context",
")",
":",
"dialect",
"=",
"get_dialect",
"(",
"session",
")",
"handlers",
"=",
"[",
"(",
"_versioned_delete",
",",
"session",
".",
"deleted",
")",
",",
"(",
"_versioned_insert",
",",
"sessio... | Archive all new/updated/deleted data | [
"Archive",
"all",
"new",
"/",
"updated",
"/",
"deleted",
"data"
] | python | train |
saltstack/salt | salt/modules/boto_ec2.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_ec2.py#L2079-L2107 | def attach_volume(volume_id, instance_id, device,
region=None, key=None, keyid=None, profile=None):
'''
Attach an EBS volume to an EC2 instance.
..
volume_id
(string) – The ID of the EBS volume to be attached.
instance_id
(string) – The ID of the EC2 instance to at... | [
"def",
"attach_volume",
"(",
"volume_id",
",",
"instance_id",
",",
"device",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
... | Attach an EBS volume to an EC2 instance.
..
volume_id
(string) – The ID of the EBS volume to be attached.
instance_id
(string) – The ID of the EC2 instance to attach the volume to.
device
(string) – The device on the instance through which the volume is exposed (e.g. /dev/sdh)
... | [
"Attach",
"an",
"EBS",
"volume",
"to",
"an",
"EC2",
"instance",
".",
".."
] | python | train |
taskcluster/taskcluster-client.py | taskcluster/queue.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/queue.py#L822-L835 | def quarantineWorker(self, *args, **kwargs):
"""
Quarantine a worker
Quarantine a worker
This method takes input: ``v1/quarantine-worker-request.json#``
This method gives output: ``v1/worker-response.json#``
This method is ``experimental``
"""
return ... | [
"def",
"quarantineWorker",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_makeApiCall",
"(",
"self",
".",
"funcinfo",
"[",
"\"quarantineWorker\"",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Quarantine a worker
Quarantine a worker
This method takes input: ``v1/quarantine-worker-request.json#``
This method gives output: ``v1/worker-response.json#``
This method is ``experimental`` | [
"Quarantine",
"a",
"worker"
] | python | train |
ManiacalLabs/BiblioPixel | bibliopixel/colors/tables.py | https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/colors/tables.py#L48-L55 | def contains(x):
"""Return true if this string or integer tuple appears in tables"""
if isinstance(x, str):
x = canonical_name(x)
return x in _TO_COLOR_USER or x in _TO_COLOR
else:
x = tuple(x)
return x in _TO_NAME_USER or x in _TO_NAME | [
"def",
"contains",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"str",
")",
":",
"x",
"=",
"canonical_name",
"(",
"x",
")",
"return",
"x",
"in",
"_TO_COLOR_USER",
"or",
"x",
"in",
"_TO_COLOR",
"else",
":",
"x",
"=",
"tuple",
"(",
"x",
"... | Return true if this string or integer tuple appears in tables | [
"Return",
"true",
"if",
"this",
"string",
"or",
"integer",
"tuple",
"appears",
"in",
"tables"
] | python | valid |
prompt-toolkit/pyvim | pyvim/editor.py | https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/editor.py#L262-L269 | def enter_command_mode(self):
"""
Go into command mode.
"""
self.application.layout.focus(self.command_buffer)
self.application.vi_state.input_mode = InputMode.INSERT
self.previewer.save() | [
"def",
"enter_command_mode",
"(",
"self",
")",
":",
"self",
".",
"application",
".",
"layout",
".",
"focus",
"(",
"self",
".",
"command_buffer",
")",
"self",
".",
"application",
".",
"vi_state",
".",
"input_mode",
"=",
"InputMode",
".",
"INSERT",
"self",
"... | Go into command mode. | [
"Go",
"into",
"command",
"mode",
"."
] | python | train |
nerox8664/pytorch2keras | pytorch2keras/reshape_layers.py | https://github.com/nerox8664/pytorch2keras/blob/750eaf747323580e6732d0c5ba9f2f39cb096764/pytorch2keras/reshape_layers.py#L124-L151 | def convert_unsqueeze(params, w_name, scope_name, inputs, layers, weights, names):
"""
Convert unsqueeze operation.
Args:
params: dictionary with layer parameters
w_name: name prefix in state_dict
scope_name: pytorch scope name
inputs: pytorch node inputs
layers: dic... | [
"def",
"convert_unsqueeze",
"(",
"params",
",",
"w_name",
",",
"scope_name",
",",
"inputs",
",",
"layers",
",",
"weights",
",",
"names",
")",
":",
"print",
"(",
"'Converting unsqueeze ...'",
")",
"if",
"names",
"==",
"'short'",
":",
"tf_name",
"=",
"'UNSQ'",... | Convert unsqueeze operation.
Args:
params: dictionary with layer parameters
w_name: name prefix in state_dict
scope_name: pytorch scope name
inputs: pytorch node inputs
layers: dictionary with keras tensors
weights: pytorch state_dict
names: use short names f... | [
"Convert",
"unsqueeze",
"operation",
"."
] | python | valid |
JasonKessler/scattertext | scattertext/termscoring/MannWhitneyU.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/termscoring/MannWhitneyU.py#L35-L87 | def get_score_df(self, correction_method=None):
'''
Computes Mann Whitney corrected p, z-values. Falls back to normal approximation when numerical limits are reached.
:param correction_method: str or None, correction method from statsmodels.stats.multitest.multipletests
'fdr_bh' is re... | [
"def",
"get_score_df",
"(",
"self",
",",
"correction_method",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_get_X",
"(",
")",
".",
"astype",
"(",
"np",
".",
"float64",
")",
"X",
"=",
"X",
"/",
"X",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"cat... | Computes Mann Whitney corrected p, z-values. Falls back to normal approximation when numerical limits are reached.
:param correction_method: str or None, correction method from statsmodels.stats.multitest.multipletests
'fdr_bh' is recommended.
:return: pd.DataFrame | [
"Computes",
"Mann",
"Whitney",
"corrected",
"p",
"z",
"-",
"values",
".",
"Falls",
"back",
"to",
"normal",
"approximation",
"when",
"numerical",
"limits",
"are",
"reached",
"."
] | python | train |
LionelAuroux/pyrser | pyrser/type_system/fun.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/fun.py#L57-L66 | def internal_name(self):
"""
Return the unique internal name
"""
unq = 'f_' + super().internal_name()
if self.tparams is not None:
unq += "_" + "_".join(self.tparams)
if self.tret is not None:
unq += "_" + self.tret
return unq | [
"def",
"internal_name",
"(",
"self",
")",
":",
"unq",
"=",
"'f_'",
"+",
"super",
"(",
")",
".",
"internal_name",
"(",
")",
"if",
"self",
".",
"tparams",
"is",
"not",
"None",
":",
"unq",
"+=",
"\"_\"",
"+",
"\"_\"",
".",
"join",
"(",
"self",
".",
... | Return the unique internal name | [
"Return",
"the",
"unique",
"internal",
"name"
] | python | test |
pyblish/pyblish-nuke | pyblish_nuke/vendor/Qt.py | https://github.com/pyblish/pyblish-nuke/blob/5fbd766774e999e5e3015201094a07a92d800c4f/pyblish_nuke/vendor/Qt.py#L299-L365 | def init():
"""Try loading each binding in turn
Please note: the entire Qt module is replaced with this code:
sys.modules["Qt"] = binding()
This means no functions or variables can be called after
this has executed.
For debugging and testing, this module may be accessed
through `Qt.__... | [
"def",
"init",
"(",
")",
":",
"preferred",
"=",
"os",
".",
"getenv",
"(",
"\"QT_PREFERRED_BINDING\"",
")",
"verbose",
"=",
"os",
".",
"getenv",
"(",
"\"QT_VERBOSE\"",
")",
"is",
"not",
"None",
"bindings",
"=",
"(",
"_pyside2",
",",
"_pyqt5",
",",
"_pysid... | Try loading each binding in turn
Please note: the entire Qt module is replaced with this code:
sys.modules["Qt"] = binding()
This means no functions or variables can be called after
this has executed.
For debugging and testing, this module may be accessed
through `Qt.__shim__`. | [
"Try",
"loading",
"each",
"binding",
"in",
"turn"
] | python | train |
exa-analytics/exa | exa/util/utility.py | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/utility.py#L55-L66 | def convert_bytes(value):
"""
Reduces bytes to more convenient units (i.e. KiB, GiB, TiB, etc.).
Args:
values (int): Value in Bytes
Returns:
tup (tuple): Tuple of value, unit (e.g. (10, 'MiB'))
"""
n = np.rint(len(str(value))/4).astype(int)
return value/(1024**n), sizes[n] | [
"def",
"convert_bytes",
"(",
"value",
")",
":",
"n",
"=",
"np",
".",
"rint",
"(",
"len",
"(",
"str",
"(",
"value",
")",
")",
"/",
"4",
")",
".",
"astype",
"(",
"int",
")",
"return",
"value",
"/",
"(",
"1024",
"**",
"n",
")",
",",
"sizes",
"["... | Reduces bytes to more convenient units (i.e. KiB, GiB, TiB, etc.).
Args:
values (int): Value in Bytes
Returns:
tup (tuple): Tuple of value, unit (e.g. (10, 'MiB')) | [
"Reduces",
"bytes",
"to",
"more",
"convenient",
"units",
"(",
"i",
".",
"e",
".",
"KiB",
"GiB",
"TiB",
"etc",
".",
")",
"."
] | python | train |
flo-compbio/genometools | genometools/expression/filter.py | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/filter.py#L74-L104 | def filter_mean(matrix, top):
"""Filter genes in an expression matrix by mean expression.
Parameters
----------
matrix: ExpMatrix
The expression matrix.
top: int
The number of genes to retain.
Returns
-------
ExpMatrix
The filtered expression matrix.
"""
... | [
"def",
"filter_mean",
"(",
"matrix",
",",
"top",
")",
":",
"assert",
"isinstance",
"(",
"matrix",
",",
"ExpMatrix",
")",
"assert",
"isinstance",
"(",
"top",
",",
"int",
")",
"if",
"top",
">=",
"matrix",
".",
"p",
":",
"logger",
".",
"warning",
"(",
"... | Filter genes in an expression matrix by mean expression.
Parameters
----------
matrix: ExpMatrix
The expression matrix.
top: int
The number of genes to retain.
Returns
-------
ExpMatrix
The filtered expression matrix. | [
"Filter",
"genes",
"in",
"an",
"expression",
"matrix",
"by",
"mean",
"expression",
"."
] | python | train |
radjkarl/imgProcessor | imgProcessor/interpolate/videoWrite.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/videoWrite.py#L14-L81 | def videoWrite(path, imgs, levels=None, shape=None, frames=15,
annotate_names=None,
lut=None, updateFn=None):
'''
TODO
'''
frames = int(frames)
if annotate_names is not None:
assert len(annotate_names) == len(imgs)
if levels is None:
if i... | [
"def",
"videoWrite",
"(",
"path",
",",
"imgs",
",",
"levels",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"frames",
"=",
"15",
",",
"annotate_names",
"=",
"None",
",",
"lut",
"=",
"None",
",",
"updateFn",
"=",
"None",
")",
":",
"frames",
"=",
"int... | TODO | [
"TODO"
] | python | train |
ToFuProject/tofu | tofu/geom/utils.py | https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/utils.py#L244-L347 | def _compute_VesPoly(R=2.4, r=1., elong=0., Dshape=0.,
divlow=True, divup=True, nP=200):
""" Utility to compute three 2D (R,Z) polygons
One represents a vacuum vessel, one an outer bumper, one a baffle
The vessel polygon is centered on (R,0.), with minor radius r
It can have a vert... | [
"def",
"_compute_VesPoly",
"(",
"R",
"=",
"2.4",
",",
"r",
"=",
"1.",
",",
"elong",
"=",
"0.",
",",
"Dshape",
"=",
"0.",
",",
"divlow",
"=",
"True",
",",
"divup",
"=",
"True",
",",
"nP",
"=",
"200",
")",
":",
"# Basics (center, theta, unit vectors)",
... | Utility to compute three 2D (R,Z) polygons
One represents a vacuum vessel, one an outer bumper, one a baffle
The vessel polygon is centered on (R,0.), with minor radius r
It can have a vertical (>0) or horizontal(<0) elongation in [-1;1]
It can be D-shaped (Dshape in [0.,1.], typically 0.2)
It can... | [
"Utility",
"to",
"compute",
"three",
"2D",
"(",
"R",
"Z",
")",
"polygons"
] | python | train |
rigetti/quantumflow | quantumflow/backend/numpybk.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/backend/numpybk.py#L150-L156 | def productdiag(tensor: BKTensor) -> BKTensor:
"""Returns the matrix diagonal of the product tensor""" # DOCME: Explain
N = rank(tensor)
tensor = reshape(tensor, [2**(N//2), 2**(N//2)])
tensor = np.diag(tensor)
tensor = reshape(tensor, [2]*(N//2))
return tensor | [
"def",
"productdiag",
"(",
"tensor",
":",
"BKTensor",
")",
"->",
"BKTensor",
":",
"# DOCME: Explain",
"N",
"=",
"rank",
"(",
"tensor",
")",
"tensor",
"=",
"reshape",
"(",
"tensor",
",",
"[",
"2",
"**",
"(",
"N",
"//",
"2",
")",
",",
"2",
"**",
"(",... | Returns the matrix diagonal of the product tensor | [
"Returns",
"the",
"matrix",
"diagonal",
"of",
"the",
"product",
"tensor"
] | python | train |
twilio/twilio-python | twilio/twiml/voice_response.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/twiml/voice_response.py#L474-L484 | def ssml_break(self, strength=None, time=None, **kwargs):
"""
Create a <Break> element
:param strength: Set a pause based on strength
:param time: Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms
:param kwargs: addition... | [
"def",
"ssml_break",
"(",
"self",
",",
"strength",
"=",
"None",
",",
"time",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"nest",
"(",
"SsmlBreak",
"(",
"strength",
"=",
"strength",
",",
"time",
"=",
"time",
",",
"*",
"*",... | Create a <Break> element
:param strength: Set a pause based on strength
:param time: Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms
:param kwargs: additional attributes
:returns: <Break> element | [
"Create",
"a",
"<Break",
">",
"element"
] | python | train |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/inventory/__init__.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/inventory/__init__.py#L145-L155 | def __get_hosts(self, pattern):
"""
finds hosts that postively match a particular pattern. Does not
take into account negative matches.
"""
(name, enumeration_details) = self._enumeration_info(pattern)
hpat = self._hosts_in_unenumerated_pattern(name)
hpat = sor... | [
"def",
"__get_hosts",
"(",
"self",
",",
"pattern",
")",
":",
"(",
"name",
",",
"enumeration_details",
")",
"=",
"self",
".",
"_enumeration_info",
"(",
"pattern",
")",
"hpat",
"=",
"self",
".",
"_hosts_in_unenumerated_pattern",
"(",
"name",
")",
"hpat",
"=",
... | finds hosts that postively match a particular pattern. Does not
take into account negative matches. | [
"finds",
"hosts",
"that",
"postively",
"match",
"a",
"particular",
"pattern",
".",
"Does",
"not",
"take",
"into",
"account",
"negative",
"matches",
"."
] | python | train |
synw/dataswim | dataswim/data/clean.py | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/clean.py#L140-L157 | def to_int(self, *cols, **kwargs):
"""
Convert some column values to integers
:param \*cols: names of the colums
:type \*cols: str, at least one
:param \*\*kwargs: keyword arguments for ``pd.to_numeric``
:type \*\*kwargs: optional
:example: ``ds.to_int("mycol1",... | [
"def",
"to_int",
"(",
"self",
",",
"*",
"cols",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"for",
"col",
"in",
"cols",
":",
"self",
".",
"df",
"[",
"col",
"]",
"=",
"pd",
".",
"to_numeric",
"(",
"self",
".",
"df",
"[",
"col",
"]",
",",
... | Convert some column values to integers
:param \*cols: names of the colums
:type \*cols: str, at least one
:param \*\*kwargs: keyword arguments for ``pd.to_numeric``
:type \*\*kwargs: optional
:example: ``ds.to_int("mycol1", "mycol2", errors="coerce")`` | [
"Convert",
"some",
"column",
"values",
"to",
"integers"
] | python | train |
joelcolucci/flask-registerblueprints | flask_registerblueprints/register.py | https://github.com/joelcolucci/flask-registerblueprints/blob/c117404691b66594f2cc84bff103ce893c633ecc/flask_registerblueprints/register.py#L24-L37 | def get_child_directories(path):
"""Return names of immediate child directories"""
if not _is_valid_directory(path):
raise exceptions.InvalidDirectory
entries = os.listdir(path)
directory_names = []
for entry in entries:
abs_entry_path = os.path.join(path, entry)
if _is_val... | [
"def",
"get_child_directories",
"(",
"path",
")",
":",
"if",
"not",
"_is_valid_directory",
"(",
"path",
")",
":",
"raise",
"exceptions",
".",
"InvalidDirectory",
"entries",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"directory_names",
"=",
"[",
"]",
"for",... | Return names of immediate child directories | [
"Return",
"names",
"of",
"immediate",
"child",
"directories"
] | python | train |
saltstack/salt | salt/cloud/clouds/xen.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/xen.py#L697-L718 | def _wait_for_ip(name, session):
'''
Wait for IP to be available during create()
'''
start_time = datetime.now()
status = None
while status is None:
status = get_vm_ip(name, session)
if status is not None:
# ignore APIPA address
if status.startswith('169'... | [
"def",
"_wait_for_ip",
"(",
"name",
",",
"session",
")",
":",
"start_time",
"=",
"datetime",
".",
"now",
"(",
")",
"status",
"=",
"None",
"while",
"status",
"is",
"None",
":",
"status",
"=",
"get_vm_ip",
"(",
"name",
",",
"session",
")",
"if",
"status"... | Wait for IP to be available during create() | [
"Wait",
"for",
"IP",
"to",
"be",
"available",
"during",
"create",
"()"
] | python | train |
fastai/fastai | docs_src/nbval/cover.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/docs_src/nbval/cover.py#L33-L73 | def setup_coverage(config, kernel, floc, output_loc=None):
"""Start coverage reporting in kernel.
Currently supported kernel languages are:
- Python
"""
language = kernel.language
if language.startswith('python'):
# Get the pytest-cov coverage object
cov = get_cov(config)
... | [
"def",
"setup_coverage",
"(",
"config",
",",
"kernel",
",",
"floc",
",",
"output_loc",
"=",
"None",
")",
":",
"language",
"=",
"kernel",
".",
"language",
"if",
"language",
".",
"startswith",
"(",
"'python'",
")",
":",
"# Get the pytest-cov coverage object",
"c... | Start coverage reporting in kernel.
Currently supported kernel languages are:
- Python | [
"Start",
"coverage",
"reporting",
"in",
"kernel",
"."
] | python | train |
data61/clkhash | clkhash/validate_data.py | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/validate_data.py#L30-L47 | def validate_row_lengths(fields, # type: Sequence[FieldSpec]
data # type: Sequence[Sequence[str]]
):
# type: (...) -> None
""" Validate the `data` row lengths according to the specification
in `fields`.
:param fields: The `FieldSpec` objects f... | [
"def",
"validate_row_lengths",
"(",
"fields",
",",
"# type: Sequence[FieldSpec]",
"data",
"# type: Sequence[Sequence[str]]",
")",
":",
"# type: (...) -> None",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"data",
")",
":",
"if",
"len",
"(",
"fields",
")",
"!=",... | Validate the `data` row lengths according to the specification
in `fields`.
:param fields: The `FieldSpec` objects forming the
specification.
:param data: The rows to check.
:raises FormatError: When the number of entries in a row does
not match expectation. | [
"Validate",
"the",
"data",
"row",
"lengths",
"according",
"to",
"the",
"specification",
"in",
"fields",
"."
] | python | train |
noxdafox/clipspy | clips/functions.py | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/functions.py#L341-L352 | def undefine(self):
"""Undefine the Method.
Python equivalent of the CLIPS undefmethod command.
The object becomes unusable after this method has been called.
"""
if lib.EnvUndefmethod(self._env, self._gnc, self._idx) != 1:
raise CLIPSError(self._env)
self... | [
"def",
"undefine",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvUndefmethod",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_gnc",
",",
"self",
".",
"_idx",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")",
"self",
".",
"_... | Undefine the Method.
Python equivalent of the CLIPS undefmethod command.
The object becomes unusable after this method has been called. | [
"Undefine",
"the",
"Method",
"."
] | python | train |
ccarocean/python-contours | contours/core.py | https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L108-L148 | def matlab_formatter(level, vertices, codes=None):
"""`MATLAB`_ style contour formatter.
Contours are returned as a single Nx2, `MATLAB`_ style, contour array.
There are two types of rows in this format:
* Header: The first element of a header row is the level of the contour
(the lower level for... | [
"def",
"matlab_formatter",
"(",
"level",
",",
"vertices",
",",
"codes",
"=",
"None",
")",
":",
"vertices",
"=",
"numpy_formatter",
"(",
"level",
",",
"vertices",
",",
"codes",
")",
"if",
"codes",
"is",
"not",
"None",
":",
"level",
"=",
"level",
"[",
"0... | `MATLAB`_ style contour formatter.
Contours are returned as a single Nx2, `MATLAB`_ style, contour array.
There are two types of rows in this format:
* Header: The first element of a header row is the level of the contour
(the lower level for filled contours) and the second element is the
numb... | [
"MATLAB",
"_",
"style",
"contour",
"formatter",
"."
] | python | valid |
thomasdelaet/python-velbus | velbus/messages/sensor_temperature.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/sensor_temperature.py#L25-L39 | def populate(self, priority, address, rtr, data):
"""
data bytes (high + low)
1 + 2 = current temp
3 + 4 = min temp
5 + 6 = max temp
:return: None
"""
assert isinstance(data, bytes)
self.needs_no_rtr(rtr)
self.needs_data(d... | [
"def",
"populate",
"(",
"self",
",",
"priority",
",",
"address",
",",
"rtr",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"self",
".",
"needs_no_rtr",
"(",
"rtr",
")",
"self",
".",
"needs_data",
"(",
"data",
",",
"6"... | data bytes (high + low)
1 + 2 = current temp
3 + 4 = min temp
5 + 6 = max temp
:return: None | [
"data",
"bytes",
"(",
"high",
"+",
"low",
")",
"1",
"+",
"2",
"=",
"current",
"temp",
"3",
"+",
"4",
"=",
"min",
"temp",
"5",
"+",
"6",
"=",
"max",
"temp",
":",
"return",
":",
"None"
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L1621-L1641 | def Emulation_setScriptExecutionDisabled(self, value):
"""
Function path: Emulation.setScriptExecutionDisabled
Domain: Emulation
Method name: setScriptExecutionDisabled
WARNING: This function is marked 'Experimental'!
Parameters:
Required arguments:
'value' (type: boolean) -> Whether scri... | [
"def",
"Emulation_setScriptExecutionDisabled",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"(",
"bool",
",",
")",
")",
",",
"\"Argument 'value' must be of type '['bool']'. Received type: '%s'\"",
"%",
"type",
"(",
"value",
")",
"s... | Function path: Emulation.setScriptExecutionDisabled
Domain: Emulation
Method name: setScriptExecutionDisabled
WARNING: This function is marked 'Experimental'!
Parameters:
Required arguments:
'value' (type: boolean) -> Whether script execution should be disabled in the page.
No return value... | [
"Function",
"path",
":",
"Emulation",
".",
"setScriptExecutionDisabled",
"Domain",
":",
"Emulation",
"Method",
"name",
":",
"setScriptExecutionDisabled",
"WARNING",
":",
"This",
"function",
"is",
"marked",
"Experimental",
"!",
"Parameters",
":",
"Required",
"arguments... | python | train |
aleju/imgaug | imgaug/multicore.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/multicore.py#L233-L238 | def terminate(self):
"""Terminate the pool immediately."""
if self._pool is not None:
self._pool.terminate()
self._pool.join()
self._pool = None | [
"def",
"terminate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pool",
"is",
"not",
"None",
":",
"self",
".",
"_pool",
".",
"terminate",
"(",
")",
"self",
".",
"_pool",
".",
"join",
"(",
")",
"self",
".",
"_pool",
"=",
"None"
] | Terminate the pool immediately. | [
"Terminate",
"the",
"pool",
"immediately",
"."
] | python | valid |
frc1418/tbapy | tbapy/main.py | https://github.com/frc1418/tbapy/blob/3866d5a9971fe3dfaf1a1d83638bd6be6070f0c4/tbapy/main.py#L251-L261 | def event(self, event, simple=False):
"""
Get basic information about an event.
More specific data (typically obtained with the detail_type URL parameter) can be obtained with event_alliances(), event_district_points(), event_insights(), event_oprs(), event_predictions(), and event_rankings().
... | [
"def",
"event",
"(",
"self",
",",
"event",
",",
"simple",
"=",
"False",
")",
":",
"return",
"Event",
"(",
"self",
".",
"_get",
"(",
"'event/%s%s'",
"%",
"(",
"event",
",",
"'/simple'",
"if",
"simple",
"else",
"''",
")",
")",
")"
] | Get basic information about an event.
More specific data (typically obtained with the detail_type URL parameter) can be obtained with event_alliances(), event_district_points(), event_insights(), event_oprs(), event_predictions(), and event_rankings().
:param event: Key of event for which you desire d... | [
"Get",
"basic",
"information",
"about",
"an",
"event",
"."
] | python | train |
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L908-L911 | def wxRect_to_Rect(self, wr):
""" Return a shrunk fitz.Rect for given wx.Rect."""
r = fitz.Rect(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height)
return r * self.shrink | [
"def",
"wxRect_to_Rect",
"(",
"self",
",",
"wr",
")",
":",
"r",
"=",
"fitz",
".",
"Rect",
"(",
"wr",
".",
"x",
",",
"wr",
".",
"y",
",",
"wr",
".",
"x",
"+",
"wr",
".",
"width",
",",
"wr",
".",
"y",
"+",
"wr",
".",
"height",
")",
"return",
... | Return a shrunk fitz.Rect for given wx.Rect. | [
"Return",
"a",
"shrunk",
"fitz",
".",
"Rect",
"for",
"given",
"wx",
".",
"Rect",
"."
] | python | train |
proycon/clam | clam/clamservice.py | https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/clamservice.py#L2099-L2120 | def uploader(project, credentials=None):
"""The Uploader is intended for the Fine Uploader used in the web application (or similar frontend), it is not intended for proper RESTful communication. Will return JSON compatible with Fine Uploader rather than CLAM Upload XML. Unfortunately, normal digest authentication d... | [
"def",
"uploader",
"(",
"project",
",",
"credentials",
"=",
"None",
")",
":",
"postdata",
"=",
"flask",
".",
"request",
".",
"values",
"if",
"'user'",
"in",
"postdata",
":",
"user",
"=",
"postdata",
"[",
"'user'",
"]",
"else",
":",
"user",
"=",
"'anony... | The Uploader is intended for the Fine Uploader used in the web application (or similar frontend), it is not intended for proper RESTful communication. Will return JSON compatible with Fine Uploader rather than CLAM Upload XML. Unfortunately, normal digest authentication does not work well with the uploader, so we imple... | [
"The",
"Uploader",
"is",
"intended",
"for",
"the",
"Fine",
"Uploader",
"used",
"in",
"the",
"web",
"application",
"(",
"or",
"similar",
"frontend",
")",
"it",
"is",
"not",
"intended",
"for",
"proper",
"RESTful",
"communication",
".",
"Will",
"return",
"JSON"... | python | train |
theonion/djes | djes/models.py | https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/models.py#L24-L38 | def mapping(self):
"""Get a mapping class for this model
This method will return a Mapping class for your model, generating it using settings from a
`Mapping` class on your model (if one exists). The generated class is cached on the manager.
"""
if not hasattr(self, "_mapping"):... | [
"def",
"mapping",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_mapping\"",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"model",
",",
"\"Mapping\"",
")",
":",
"mapping_klass",
"=",
"type",
"(",
"\"Mapping\"",
",",
"(",
"DjangoMa... | Get a mapping class for this model
This method will return a Mapping class for your model, generating it using settings from a
`Mapping` class on your model (if one exists). The generated class is cached on the manager. | [
"Get",
"a",
"mapping",
"class",
"for",
"this",
"model"
] | python | train |
Clinical-Genomics/scout | scout/parse/cytoband.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/parse/cytoband.py#L5-L35 | def parse_cytoband(lines):
"""Parse iterable with cytoband coordinates
Args:
lines(iterable): Strings on format "chr1\t2300000\t5400000\tp36.32\tgpos25"
Returns:
cytobands(dict): Dictionary with chromosome names as keys and
interval trees as values
... | [
"def",
"parse_cytoband",
"(",
"lines",
")",
":",
"cytobands",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"splitted_line",
"=",
"line",
".",
"split",
"(",
"'\\t'",
")",
"chrom",
"=",
"splitted_line",
... | Parse iterable with cytoband coordinates
Args:
lines(iterable): Strings on format "chr1\t2300000\t5400000\tp36.32\tgpos25"
Returns:
cytobands(dict): Dictionary with chromosome names as keys and
interval trees as values | [
"Parse",
"iterable",
"with",
"cytoband",
"coordinates",
"Args",
":",
"lines",
"(",
"iterable",
")",
":",
"Strings",
"on",
"format",
"chr1",
"\\",
"t2300000",
"\\",
"t5400000",
"\\",
"tp36",
".",
"32",
"\\",
"tgpos25",
"Returns",
":",
"cytobands",
"(",
"dic... | python | test |
StellarCN/py-stellar-base | stellar_base/builder.py | https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L804-L814 | def get_sequence(self):
"""Get the sequence number for a given account via Horizon.
:return: The current sequence number for a given account
:rtype: int
"""
if not self.address:
raise StellarAddressInvalidError('No address provided.')
address = self.horizon.... | [
"def",
"get_sequence",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"address",
":",
"raise",
"StellarAddressInvalidError",
"(",
"'No address provided.'",
")",
"address",
"=",
"self",
".",
"horizon",
".",
"account",
"(",
"self",
".",
"address",
")",
"retu... | Get the sequence number for a given account via Horizon.
:return: The current sequence number for a given account
:rtype: int | [
"Get",
"the",
"sequence",
"number",
"for",
"a",
"given",
"account",
"via",
"Horizon",
"."
] | python | train |
numenta/nupic | src/nupic/data/generators/data_generator.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/data_generator.py#L166-L171 | def generateRecords(self, records):
"""Generate multiple records. Refer to definition for generateRecord"""
if self.verbosity>0: print 'Generating', len(records), 'records...'
for record in records:
self.generateRecord(record) | [
"def",
"generateRecords",
"(",
"self",
",",
"records",
")",
":",
"if",
"self",
".",
"verbosity",
">",
"0",
":",
"print",
"'Generating'",
",",
"len",
"(",
"records",
")",
",",
"'records...'",
"for",
"record",
"in",
"records",
":",
"self",
".",
"generateRe... | Generate multiple records. Refer to definition for generateRecord | [
"Generate",
"multiple",
"records",
".",
"Refer",
"to",
"definition",
"for",
"generateRecord"
] | python | valid |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_api_provider.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L246-L270 | def _extract_apis_from_events(function_logical_id, serverless_function_events, collector):
"""
Given an AWS::Serverless::Function Event Dictionary, extract out all 'Api' events and store within the
collector
Parameters
----------
function_logical_id : str
Lo... | [
"def",
"_extract_apis_from_events",
"(",
"function_logical_id",
",",
"serverless_function_events",
",",
"collector",
")",
":",
"count",
"=",
"0",
"for",
"_",
",",
"event",
"in",
"serverless_function_events",
".",
"items",
"(",
")",
":",
"if",
"SamApiProvider",
"."... | Given an AWS::Serverless::Function Event Dictionary, extract out all 'Api' events and store within the
collector
Parameters
----------
function_logical_id : str
LogicalId of the AWS::Serverless::Function
serverless_function_events : dict
Event Dictionar... | [
"Given",
"an",
"AWS",
"::",
"Serverless",
"::",
"Function",
"Event",
"Dictionary",
"extract",
"out",
"all",
"Api",
"events",
"and",
"store",
"within",
"the",
"collector"
] | python | train |
xeroc/python-graphenelib | graphenecommon/memo.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/memo.py#L114-L150 | def decrypt(self, message):
""" Decrypt a message
:param dict message: encrypted memo message
:returns: decrypted message
:rtype: str
"""
if not message:
return None
# We first try to decode assuming we received the memo
try:
... | [
"def",
"decrypt",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"message",
":",
"return",
"None",
"# We first try to decode assuming we received the memo",
"try",
":",
"memo_wif",
"=",
"self",
".",
"blockchain",
".",
"wallet",
".",
"getPrivateKeyForPublicKey",... | Decrypt a message
:param dict message: encrypted memo message
:returns: decrypted message
:rtype: str | [
"Decrypt",
"a",
"message"
] | python | valid |
Chilipp/sphinx-nbexamples | sphinx_nbexamples/__init__.py | https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L317-L379 | def process_notebook(self, disable_warnings=True):
"""Process the notebook and create all the pictures and files
This method runs the notebook using the :mod:`nbconvert` and
:mod:`nbformat` modules. It creates the :attr:`outfile` notebook,
a python and a rst file"""
infile = sel... | [
"def",
"process_notebook",
"(",
"self",
",",
"disable_warnings",
"=",
"True",
")",
":",
"infile",
"=",
"self",
".",
"infile",
"outfile",
"=",
"self",
".",
"outfile",
"in_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"infile",
")",
"+",
"os",
".",
... | Process the notebook and create all the pictures and files
This method runs the notebook using the :mod:`nbconvert` and
:mod:`nbformat` modules. It creates the :attr:`outfile` notebook,
a python and a rst file | [
"Process",
"the",
"notebook",
"and",
"create",
"all",
"the",
"pictures",
"and",
"files"
] | python | test |
bitprophet/ssh | ssh/transport.py | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1094-L1119 | def auth_none(self, username):
"""
Try to authenticate to the server using no authentication at all.
This will almost always fail. It may be useful for determining the
list of authentication types supported by the server, by catching the
L{BadAuthenticationType} exception raised... | [
"def",
"auth_none",
"(",
"self",
",",
"username",
")",
":",
"if",
"(",
"not",
"self",
".",
"active",
")",
"or",
"(",
"not",
"self",
".",
"initial_kex_done",
")",
":",
"raise",
"SSHException",
"(",
"'No existing session'",
")",
"my_event",
"=",
"threading",... | Try to authenticate to the server using no authentication at all.
This will almost always fail. It may be useful for determining the
list of authentication types supported by the server, by catching the
L{BadAuthenticationType} exception raised.
@param username: the username to authent... | [
"Try",
"to",
"authenticate",
"to",
"the",
"server",
"using",
"no",
"authentication",
"at",
"all",
".",
"This",
"will",
"almost",
"always",
"fail",
".",
"It",
"may",
"be",
"useful",
"for",
"determining",
"the",
"list",
"of",
"authentication",
"types",
"suppor... | python | train |
NiklasRosenstein/myo-python | myo/math.py | https://github.com/NiklasRosenstein/myo-python/blob/89a7480f8058061da7a3dd98ccec57a6b134ddf3/myo/math.py#L102-L108 | def normalized(self):
"""
Returns a normalized copy of this vector.
"""
norm = self.magnitude()
return Vector(self.x / norm, self.y / norm, self.z / norm) | [
"def",
"normalized",
"(",
"self",
")",
":",
"norm",
"=",
"self",
".",
"magnitude",
"(",
")",
"return",
"Vector",
"(",
"self",
".",
"x",
"/",
"norm",
",",
"self",
".",
"y",
"/",
"norm",
",",
"self",
".",
"z",
"/",
"norm",
")"
] | Returns a normalized copy of this vector. | [
"Returns",
"a",
"normalized",
"copy",
"of",
"this",
"vector",
"."
] | python | train |
mhe/pynrrd | nrrd/reader.py | https://github.com/mhe/pynrrd/blob/96dd875b302031ea27e2d3aaa611dc6f2dfc7979/nrrd/reader.py#L469-L506 | def read(filename, custom_field_map=None, index_order='F'):
"""Read a NRRD file and return the header and data
See :ref:`user-guide:Reading NRRD files` for more information on reading NRRD files.
.. note::
Users should be aware that the `index_order` argument needs to be consistent between `nr... | [
"def",
"read",
"(",
"filename",
",",
"custom_field_map",
"=",
"None",
",",
"index_order",
"=",
"'F'",
")",
":",
"\"\"\"Read a NRRD file and return a tuple (data, header).\"\"\"",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"header",
"=",
... | Read a NRRD file and return the header and data
See :ref:`user-guide:Reading NRRD files` for more information on reading NRRD files.
.. note::
Users should be aware that the `index_order` argument needs to be consistent between `nrrd.read` and `nrrd.write`. I.e., reading an array with `index_order... | [
"Read",
"a",
"NRRD",
"file",
"and",
"return",
"the",
"header",
"and",
"data"
] | python | train |
tomprince/txgithub | txgithub/api.py | https://github.com/tomprince/txgithub/blob/3bd5eebb25db013e2193e6a102a91049f356710d/txgithub/api.py#L378-L396 | def createComment(self, repo_user, repo_name, pull_number,
body, commit_id, path, position):
"""
POST /repos/:owner/:repo/pulls/:number/comments
:param pull_number: The pull request's ID.
:param body: The text of the comment.
:param commit_id: The SHA of th... | [
"def",
"createComment",
"(",
"self",
",",
"repo_user",
",",
"repo_name",
",",
"pull_number",
",",
"body",
",",
"commit_id",
",",
"path",
",",
"position",
")",
":",
"return",
"self",
".",
"api",
".",
"makeRequest",
"(",
"[",
"\"repos\"",
",",
"repo_user",
... | POST /repos/:owner/:repo/pulls/:number/comments
:param pull_number: The pull request's ID.
:param body: The text of the comment.
:param commit_id: The SHA of the commit to comment on.
:param path: The relative path of the file to comment on.
:param position: The line index in th... | [
"POST",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"pulls",
"/",
":",
"number",
"/",
"comments"
] | python | train |
PolyJIT/benchbuild | benchbuild/projects/gentoo/gentoo.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/projects/gentoo/gentoo.py#L229-L250 | def write_wgetrc(_path):
"""
Write a valid gentoo wgetrc file to :path:.
Args:
path - The output path of the wgetrc
"""
http_proxy = str(CFG["gentoo"]["http_proxy"])
ftp_proxy = str(CFG["gentoo"]["ftp_proxy"])
path.mkfile_uchroot("/etc/wgetrc")
with open(_path, 'w') as wgetrc:
... | [
"def",
"write_wgetrc",
"(",
"_path",
")",
":",
"http_proxy",
"=",
"str",
"(",
"CFG",
"[",
"\"gentoo\"",
"]",
"[",
"\"http_proxy\"",
"]",
")",
"ftp_proxy",
"=",
"str",
"(",
"CFG",
"[",
"\"gentoo\"",
"]",
"[",
"\"ftp_proxy\"",
"]",
")",
"path",
".",
"mkf... | Write a valid gentoo wgetrc file to :path:.
Args:
path - The output path of the wgetrc | [
"Write",
"a",
"valid",
"gentoo",
"wgetrc",
"file",
"to",
":",
"path",
":",
"."
] | python | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L65-L94 | def qapplication(translate=True, test_time=3):
"""
Return QApplication instance
Creates it if it doesn't already exist
test_time: Time to maintain open the application when testing. It's given
in seconds
"""
if running_in_mac_app():
SpyderApplication = MacApplication
... | [
"def",
"qapplication",
"(",
"translate",
"=",
"True",
",",
"test_time",
"=",
"3",
")",
":",
"if",
"running_in_mac_app",
"(",
")",
":",
"SpyderApplication",
"=",
"MacApplication",
"else",
":",
"SpyderApplication",
"=",
"QApplication",
"app",
"=",
"SpyderApplicati... | Return QApplication instance
Creates it if it doesn't already exist
test_time: Time to maintain open the application when testing. It's given
in seconds | [
"Return",
"QApplication",
"instance",
"Creates",
"it",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"test_time",
":",
"Time",
"to",
"maintain",
"open",
"the",
"application",
"when",
"testing",
".",
"It",
"s",
"given",
"in",
"seconds"
] | python | train |
facebook/watchman | python/pywatchman/__init__.py | https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/python/pywatchman/__init__.py#L1145-L1158 | def capabilityCheck(self, optional=None, required=None):
""" Perform a server capability check """
res = self.query(
"version", {"optional": optional or [], "required": required or []}
)
if not self._hasprop(res, "capabilities"):
# Server doesn't support capabili... | [
"def",
"capabilityCheck",
"(",
"self",
",",
"optional",
"=",
"None",
",",
"required",
"=",
"None",
")",
":",
"res",
"=",
"self",
".",
"query",
"(",
"\"version\"",
",",
"{",
"\"optional\"",
":",
"optional",
"or",
"[",
"]",
",",
"\"required\"",
":",
"req... | Perform a server capability check | [
"Perform",
"a",
"server",
"capability",
"check"
] | python | train |
lepture/flask-oauthlib | flask_oauthlib/client.py | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L621-L650 | def handle_oauth1_response(self, args):
"""Handles an oauth1 authorization response."""
client = self.make_client()
client.verifier = args.get('oauth_verifier')
tup = session.get('%s_oauthtok' % self.name)
if not tup:
raise OAuthException(
'Token not f... | [
"def",
"handle_oauth1_response",
"(",
"self",
",",
"args",
")",
":",
"client",
"=",
"self",
".",
"make_client",
"(",
")",
"client",
".",
"verifier",
"=",
"args",
".",
"get",
"(",
"'oauth_verifier'",
")",
"tup",
"=",
"session",
".",
"get",
"(",
"'%s_oauth... | Handles an oauth1 authorization response. | [
"Handles",
"an",
"oauth1",
"authorization",
"response",
"."
] | python | test |
btimby/fulltext | fulltext/__init__.py | https://github.com/btimby/fulltext/blob/9234cc1e2099209430e20317649549026de283ce/fulltext/__init__.py#L329-L362 | def is_binary(f):
"""Return True if binary mode."""
# NOTE: order matters here. We don't bail on Python 2 just yet. Both
# codecs.open() and io.open() can open in text mode, both set the encoding
# attribute. We must do that check first.
# If it has a decoding attribute with a value, it is text mod... | [
"def",
"is_binary",
"(",
"f",
")",
":",
"# NOTE: order matters here. We don't bail on Python 2 just yet. Both",
"# codecs.open() and io.open() can open in text mode, both set the encoding",
"# attribute. We must do that check first.",
"# If it has a decoding attribute with a value, it is text mode... | Return True if binary mode. | [
"Return",
"True",
"if",
"binary",
"mode",
"."
] | python | train |
albert12132/templar | templar/markdown.py | https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L673-L685 | def unhash(text, hashes):
"""Unhashes all hashed entites in the hashes dictionary.
The pattern for hashes is defined by re_hash. After everything is
unhashed, <pre> blocks are "pulled out" of whatever indentation
level in which they used to be (e.g. in a list).
"""
def retrieve_match(match):
... | [
"def",
"unhash",
"(",
"text",
",",
"hashes",
")",
":",
"def",
"retrieve_match",
"(",
"match",
")",
":",
"return",
"hashes",
"[",
"match",
".",
"group",
"(",
"0",
")",
"]",
"while",
"re_hash",
".",
"search",
"(",
"text",
")",
":",
"text",
"=",
"re_h... | Unhashes all hashed entites in the hashes dictionary.
The pattern for hashes is defined by re_hash. After everything is
unhashed, <pre> blocks are "pulled out" of whatever indentation
level in which they used to be (e.g. in a list). | [
"Unhashes",
"all",
"hashed",
"entites",
"in",
"the",
"hashes",
"dictionary",
"."
] | python | train |
MartinThoma/hwrt | hwrt/create_ffiles.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/create_ffiles.py#L38-L59 | def _create_index_formula_lookup(formula_id2index,
feature_folder,
index2latex):
"""
Create a lookup file where the index is mapped to the formula id and the
LaTeX command.
Parameters
----------
formula_id2index : dict
featur... | [
"def",
"_create_index_formula_lookup",
"(",
"formula_id2index",
",",
"feature_folder",
",",
"index2latex",
")",
":",
"index2formula_id",
"=",
"sorted",
"(",
"formula_id2index",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"n",
":",
"n",
"[",
"1",
"]",
... | Create a lookup file where the index is mapped to the formula id and the
LaTeX command.
Parameters
----------
formula_id2index : dict
feature_folder : str
Path to a folder in which a feature file as well as an
index2formula_id.csv is.
index2latex : dict
Maps an integer i... | [
"Create",
"a",
"lookup",
"file",
"where",
"the",
"index",
"is",
"mapped",
"to",
"the",
"formula",
"id",
"and",
"the",
"LaTeX",
"command",
"."
] | python | train |
goose3/goose3 | goose3/extractors/images.py | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L303-L314 | def check_link_tag(self):
"""\
checks to see if we were able to
find open link_src on this page
"""
node = self.article.raw_doc
meta = self.parser.getElementsByTag(node, tag='link', attr='rel', value='image_src')
for item in meta:
src = self.parser.get... | [
"def",
"check_link_tag",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"article",
".",
"raw_doc",
"meta",
"=",
"self",
".",
"parser",
".",
"getElementsByTag",
"(",
"node",
",",
"tag",
"=",
"'link'",
",",
"attr",
"=",
"'rel'",
",",
"value",
"=",
"'... | \
checks to see if we were able to
find open link_src on this page | [
"\\",
"checks",
"to",
"see",
"if",
"we",
"were",
"able",
"to",
"find",
"open",
"link_src",
"on",
"this",
"page"
] | python | valid |
Apitax/Apitax | apitax/api/controllers/migrations/scriptax_controller.py | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/migrations/scriptax_controller.py#L20-L44 | def create_driver_script(name, create=None): # noqa: E501
"""Create a new script
Create a new script # noqa: E501
:param name: Get status of a driver with this name
:type name: str
:param create: The data needed to create this script
:type create: dict | bytes
:rtype: Response
"""
... | [
"def",
"create_driver_script",
"(",
"name",
",",
"create",
"=",
"None",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"create",
"=",
"Create1",
".",
"from_dict",
"(",
"connexion",
".",
"request",
".",
"get_json",
"(",
")... | Create a new script
Create a new script # noqa: E501
:param name: Get status of a driver with this name
:type name: str
:param create: The data needed to create this script
:type create: dict | bytes
:rtype: Response | [
"Create",
"a",
"new",
"script"
] | python | train |
pingali/dgit | dgitcore/helper.py | https://github.com/pingali/dgit/blob/ecde01f40b98f0719dbcfb54452270ed2f86686d/dgitcore/helper.py#L112-L128 | def compute_sha256(filename):
"""
Try the library. If it doesnt work, use the command line..
"""
try:
h = sha256()
fd = open(filename, 'rb')
while True:
buf = fd.read(0x1000000)
if buf in [None, ""]:
break
h.update(buf.encode('u... | [
"def",
"compute_sha256",
"(",
"filename",
")",
":",
"try",
":",
"h",
"=",
"sha256",
"(",
")",
"fd",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"while",
"True",
":",
"buf",
"=",
"fd",
".",
"read",
"(",
"0x1000000",
")",
"if",
"buf",
"in",
"["... | Try the library. If it doesnt work, use the command line.. | [
"Try",
"the",
"library",
".",
"If",
"it",
"doesnt",
"work",
"use",
"the",
"command",
"line",
".."
] | python | valid |
benhoff/pluginmanager | pluginmanager/file_filters/matching_regex.py | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_filters/matching_regex.py#L35-L43 | def plugin_valid(self, filename):
"""
Checks if the given filename is a valid plugin for this Strategy
"""
filename = os.path.basename(filename)
for regex in self.regex_expressions:
if regex.match(filename):
return True
return False | [
"def",
"plugin_valid",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"for",
"regex",
"in",
"self",
".",
"regex_expressions",
":",
"if",
"regex",
".",
"match",
"(",
"filename",
")",
":... | Checks if the given filename is a valid plugin for this Strategy | [
"Checks",
"if",
"the",
"given",
"filename",
"is",
"a",
"valid",
"plugin",
"for",
"this",
"Strategy"
] | python | train |
sixty-north/cosmic-ray | src/cosmic_ray/plugins.py | https://github.com/sixty-north/cosmic-ray/blob/c654e074afbb7b7fcbc23359083c1287c0d3e991/src/cosmic_ray/plugins.py#L27-L40 | def get_operator(name):
"""Get an operator class from a provider plugin.
Attrs:
name: The name of the operator class.
Returns: The operator *class object* (i.e. not an instance).
"""
sep = name.index('/')
provider_name = name[:sep]
operator_name = name[sep + 1:]
provider = OPE... | [
"def",
"get_operator",
"(",
"name",
")",
":",
"sep",
"=",
"name",
".",
"index",
"(",
"'/'",
")",
"provider_name",
"=",
"name",
"[",
":",
"sep",
"]",
"operator_name",
"=",
"name",
"[",
"sep",
"+",
"1",
":",
"]",
"provider",
"=",
"OPERATOR_PROVIDERS",
... | Get an operator class from a provider plugin.
Attrs:
name: The name of the operator class.
Returns: The operator *class object* (i.e. not an instance). | [
"Get",
"an",
"operator",
"class",
"from",
"a",
"provider",
"plugin",
"."
] | python | train |
TheHive-Project/Cortex-Analyzers | analyzers/MaxMind/ipaddr.py | https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/MaxMind/ipaddr.py#L315-L366 | def collapse_address_list(addresses):
"""Collapse a list of IP objects.
Example:
collapse_address_list([IPv4('1.1.0.0/24'), IPv4('1.1.1.0/24')]) ->
[IPv4('1.1.0.0/23')]
Args:
addresses: A list of IPv4Network or IPv6Network objects.
Returns:
A list of IPv4Network or I... | [
"def",
"collapse_address_list",
"(",
"addresses",
")",
":",
"i",
"=",
"0",
"addrs",
"=",
"[",
"]",
"ips",
"=",
"[",
"]",
"nets",
"=",
"[",
"]",
"# split IP addresses and networks",
"for",
"ip",
"in",
"addresses",
":",
"if",
"isinstance",
"(",
"ip",
",",
... | Collapse a list of IP objects.
Example:
collapse_address_list([IPv4('1.1.0.0/24'), IPv4('1.1.1.0/24')]) ->
[IPv4('1.1.0.0/23')]
Args:
addresses: A list of IPv4Network or IPv6Network objects.
Returns:
A list of IPv4Network or IPv6Network objects depending on what we
... | [
"Collapse",
"a",
"list",
"of",
"IP",
"objects",
"."
] | python | train |
BerkeleyAutomation/autolab_core | autolab_core/transformations.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L437-L496 | def projection_matrix(point, normal, direction=None,
perspective=None, pseudo=False):
"""Return matrix to project onto plane defined by point and normal.
Using either perspective point, projection direction, or none of both.
If pseudo is True, perspective projections will preserve re... | [
"def",
"projection_matrix",
"(",
"point",
",",
"normal",
",",
"direction",
"=",
"None",
",",
"perspective",
"=",
"None",
",",
"pseudo",
"=",
"False",
")",
":",
"M",
"=",
"numpy",
".",
"identity",
"(",
"4",
")",
"point",
"=",
"numpy",
".",
"array",
"(... | Return matrix to project onto plane defined by point and normal.
Using either perspective point, projection direction, or none of both.
If pseudo is True, perspective projections will preserve relative depth
such that Perspective = dot(Orthogonal, PseudoPerspective).
>>> P = projection_matrix((0, 0, ... | [
"Return",
"matrix",
"to",
"project",
"onto",
"plane",
"defined",
"by",
"point",
"and",
"normal",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L17808-L17822 | def get_max_port_count_for_storage_bus(self, bus):
"""Returns the maximum number of ports the given storage bus supports.
in bus of type :class:`StorageBus`
The storage bus type to get the value for.
return max_port_count of type int
The maximum number of ports for the ... | [
"def",
"get_max_port_count_for_storage_bus",
"(",
"self",
",",
"bus",
")",
":",
"if",
"not",
"isinstance",
"(",
"bus",
",",
"StorageBus",
")",
":",
"raise",
"TypeError",
"(",
"\"bus can only be an instance of type StorageBus\"",
")",
"max_port_count",
"=",
"self",
"... | Returns the maximum number of ports the given storage bus supports.
in bus of type :class:`StorageBus`
The storage bus type to get the value for.
return max_port_count of type int
The maximum number of ports for the given storage bus. | [
"Returns",
"the",
"maximum",
"number",
"of",
"ports",
"the",
"given",
"storage",
"bus",
"supports",
"."
] | python | train |
mardix/Mocha | mocha/utils.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/utils.py#L443-L450 | def how_old(dob):
"""
Calculate the age
:param dob: datetime object
:return: int
"""
today = datetime.date.today()
return today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) | [
"def",
"how_old",
"(",
"dob",
")",
":",
"today",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"return",
"today",
".",
"year",
"-",
"dob",
".",
"year",
"-",
"(",
"(",
"today",
".",
"month",
",",
"today",
".",
"day",
")",
"<",
"(",
"dob"... | Calculate the age
:param dob: datetime object
:return: int | [
"Calculate",
"the",
"age",
":",
"param",
"dob",
":",
"datetime",
"object",
":",
"return",
":",
"int"
] | python | train |
ergoithz/browsepy | browsepy/transform/__init__.py | https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/transform/__init__.py#L20-L55 | def nearest(self):
'''
Get the next state jump.
The next jump is calculated looking at :attr:`current` state
and its possible :attr:`jumps` to find the nearest and bigger
option in :attr:`pending` data.
If none is found, the returned next state label will be None.
... | [
"def",
"nearest",
"(",
"self",
")",
":",
"try",
":",
"options",
"=",
"self",
".",
"jumps",
"[",
"self",
".",
"current",
"]",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"'Current state %r not defined in %s.jumps.'",
"%",
"(",
"self",
".",
"current",... | Get the next state jump.
The next jump is calculated looking at :attr:`current` state
and its possible :attr:`jumps` to find the nearest and bigger
option in :attr:`pending` data.
If none is found, the returned next state label will be None.
:returns: tuple with index, substri... | [
"Get",
"the",
"next",
"state",
"jump",
"."
] | python | train |
tensorforce/tensorforce | tensorforce/models/memory_model.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L465-L491 | def tf_optimization(self, states, internals, actions, terminal, reward, next_states=None, next_internals=None):
"""
Creates the TensorFlow operations for performing an optimization update step based
on the given input states and actions batch.
Args:
states: Dict of state ten... | [
"def",
"tf_optimization",
"(",
"self",
",",
"states",
",",
"internals",
",",
"actions",
",",
"terminal",
",",
"reward",
",",
"next_states",
"=",
"None",
",",
"next_internals",
"=",
"None",
")",
":",
"arguments",
"=",
"self",
".",
"optimizer_arguments",
"(",
... | Creates the TensorFlow operations for performing an optimization update step based
on the given input states and actions batch.
Args:
states: Dict of state tensors.
internals: List of prior internal state tensors.
actions: Dict of action tensors.
terminal... | [
"Creates",
"the",
"TensorFlow",
"operations",
"for",
"performing",
"an",
"optimization",
"update",
"step",
"based",
"on",
"the",
"given",
"input",
"states",
"and",
"actions",
"batch",
"."
] | python | valid |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L315-L338 | def get_obj(self, content, vimtype, name):
"""
Return an object by name for a specific type, if name is None the
first found object is returned
:param content: pyvmomi content object
:param vimtype: the type of object too search
:param name: the object name t... | [
"def",
"get_obj",
"(",
"self",
",",
"content",
",",
"vimtype",
",",
"name",
")",
":",
"obj",
"=",
"None",
"container",
"=",
"self",
".",
"_get_all_objects_by_type",
"(",
"content",
",",
"vimtype",
")",
"# If no name was given will return the first object from list o... | Return an object by name for a specific type, if name is None the
first found object is returned
:param content: pyvmomi content object
:param vimtype: the type of object too search
:param name: the object name to return | [
"Return",
"an",
"object",
"by",
"name",
"for",
"a",
"specific",
"type",
"if",
"name",
"is",
"None",
"the",
"first",
"found",
"object",
"is",
"returned"
] | python | train |
dnanhkhoa/logone | logone/logone.py | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L147-L199 | def use_file(self, enabled=True,
file_name=None,
level=logging.WARNING,
when='d',
interval=1,
backup_count=30,
delay=False,
utc=False,
at_time=None,
log_format=None,
... | [
"def",
"use_file",
"(",
"self",
",",
"enabled",
"=",
"True",
",",
"file_name",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"WARNING",
",",
"when",
"=",
"'d'",
",",
"interval",
"=",
"1",
",",
"backup_count",
"=",
"30",
",",
"delay",
"=",
"False",
... | Handler for logging to a file, rotating the log file at certain timed intervals. | [
"Handler",
"for",
"logging",
"to",
"a",
"file",
"rotating",
"the",
"log",
"file",
"at",
"certain",
"timed",
"intervals",
"."
] | python | train |
Rackspace-DOT/flask_keystone | flask_keystone/__init__.py | https://github.com/Rackspace-DOT/flask_keystone/blob/6f6d630e9e66a3beca6607b0b786510ec2a79747/flask_keystone/__init__.py#L86-L123 | def init_app(self, app, config_group="flask_keystone"):
"""
Iniitialize the Flask_Keystone module in an application factory.
:param app: `flask.Flask` application to which to connect.
:type app: `flask.Flask`
:param str config_group: :class:`oslo_config.cfg.OptGroup` to which
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"config_group",
"=",
"\"flask_keystone\"",
")",
":",
"cfg",
".",
"CONF",
".",
"register_opts",
"(",
"RAX_OPTS",
",",
"group",
"=",
"config_group",
")",
"self",
".",
"logger",
"=",
"logging",
".",
"getLogger"... | Iniitialize the Flask_Keystone module in an application factory.
:param app: `flask.Flask` application to which to connect.
:type app: `flask.Flask`
:param str config_group: :class:`oslo_config.cfg.OptGroup` to which
to attach.
When initialized, the ext... | [
"Iniitialize",
"the",
"Flask_Keystone",
"module",
"in",
"an",
"application",
"factory",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L12904-L12945 | def spkw18(handle, subtyp, body, center, inframe, first, last, segid, degree, packts, epochs):
"""
Write a type 18 segment to an SPK file.
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkw18_c.html
:param handle: Handle of an SPK file open for writing.
:type handle: int
:param subt... | [
"def",
"spkw18",
"(",
"handle",
",",
"subtyp",
",",
"body",
",",
"center",
",",
"inframe",
",",
"first",
",",
"last",
",",
"segid",
",",
"degree",
",",
"packts",
",",
"epochs",
")",
":",
"handle",
"=",
"ctypes",
".",
"c_int",
"(",
"handle",
")",
"s... | Write a type 18 segment to an SPK file.
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkw18_c.html
:param handle: Handle of an SPK file open for writing.
:type handle: int
:param subtyp: SPK type 18 subtype code.
:type subtyp: int
:param body: Body code for ephemeris object.
:t... | [
"Write",
"a",
"type",
"18",
"segment",
"to",
"an",
"SPK",
"file",
"."
] | python | train |
ARMmbed/icetea | icetea_lib/tools/tools.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/tools.py#L538-L549 | def _create_combined_words(words, startindex):
"""
Helper for create_match_bool, used to combine words inside single quotes from a list into a
single string.
:param words: List of words.
:param startindex: Index where search is started.
:return: (str, int) or (None, 0) if no closing quote is fou... | [
"def",
"_create_combined_words",
"(",
"words",
",",
"startindex",
")",
":",
"for",
"i",
",",
"word",
"in",
"enumerate",
"(",
"words",
"[",
"startindex",
"+",
"1",
":",
"]",
")",
":",
"if",
"\"'\"",
"in",
"word",
":",
"return",
"\" \"",
".",
"join",
"... | Helper for create_match_bool, used to combine words inside single quotes from a list into a
single string.
:param words: List of words.
:param startindex: Index where search is started.
:return: (str, int) or (None, 0) if no closing quote is found. | [
"Helper",
"for",
"create_match_bool",
"used",
"to",
"combine",
"words",
"inside",
"single",
"quotes",
"from",
"a",
"list",
"into",
"a",
"single",
"string",
".",
":",
"param",
"words",
":",
"List",
"of",
"words",
".",
":",
"param",
"startindex",
":",
"Index... | python | train |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L58-L84 | def update_task(client, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None):
'''
Updates the task with the given ID
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter in... | [
"def",
"update_task",
"(",
"client",
",",
"task_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"assignee_id",
"=",
"None",
",",
"completed",
"=",
"None",
",",
"recurrence_type",
"=",
"None",
",",
"recurrence_count",
"=",
"None",
",",
"due_date",
"="... | Updates the task with the given ID
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information | [
"Updates",
"the",
"task",
"with",
"the",
"given",
"ID"
] | python | train |
saltstack/salt | salt/modules/virt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3437-L3448 | def _is_kvm_hyper():
'''
Returns a bool whether or not this node is a KVM hypervisor
'''
try:
with salt.utils.files.fopen('/proc/modules') as fp_:
if 'kvm_' not in salt.utils.stringutils.to_unicode(fp_.read()):
return False
except IOError:
# No /proc/modul... | [
"def",
"_is_kvm_hyper",
"(",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"'/proc/modules'",
")",
"as",
"fp_",
":",
"if",
"'kvm_'",
"not",
"in",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
... | Returns a bool whether or not this node is a KVM hypervisor | [
"Returns",
"a",
"bool",
"whether",
"or",
"not",
"this",
"node",
"is",
"a",
"KVM",
"hypervisor"
] | python | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/shadow/deviceShadow.py | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/shadow/deviceShadow.py#L367-L399 | def shadowRegisterDeltaCallback(self, srcCallback):
"""
**Description**
Listen on delta topics for this device shadow by subscribing to delta topics. Whenever there
is a difference between the desired and reported state, the registered callback will be called
and the delta pay... | [
"def",
"shadowRegisterDeltaCallback",
"(",
"self",
",",
"srcCallback",
")",
":",
"with",
"self",
".",
"_dataStructureLock",
":",
"# Update callback data structure",
"self",
".",
"_shadowSubscribeCallbackTable",
"[",
"\"delta\"",
"]",
"=",
"srcCallback",
"# One subscriptio... | **Description**
Listen on delta topics for this device shadow by subscribing to delta topics. Whenever there
is a difference between the desired and reported state, the registered callback will be called
and the delta payload will be available in the callback.
**Syntax**
.. ... | [
"**",
"Description",
"**"
] | python | train |
tensorpack/tensorpack | examples/FasterRCNN/model_fpn.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/model_fpn.py#L70-L100 | def fpn_map_rois_to_levels(boxes):
"""
Assign boxes to level 2~5.
Args:
boxes (nx4):
Returns:
[tf.Tensor]: 4 tensors for level 2-5. Each tensor is a vector of indices of boxes in its level.
[tf.Tensor]: 4 tensors, the gathered boxes in each level.
Be careful that the retur... | [
"def",
"fpn_map_rois_to_levels",
"(",
"boxes",
")",
":",
"sqrtarea",
"=",
"tf",
".",
"sqrt",
"(",
"tf_area",
"(",
"boxes",
")",
")",
"level",
"=",
"tf",
".",
"cast",
"(",
"tf",
".",
"floor",
"(",
"4",
"+",
"tf",
".",
"log",
"(",
"sqrtarea",
"*",
... | Assign boxes to level 2~5.
Args:
boxes (nx4):
Returns:
[tf.Tensor]: 4 tensors for level 2-5. Each tensor is a vector of indices of boxes in its level.
[tf.Tensor]: 4 tensors, the gathered boxes in each level.
Be careful that the returned tensor could be empty. | [
"Assign",
"boxes",
"to",
"level",
"2~5",
"."
] | python | train |
mryellow/maze_explorer | mazeexp/engine/world_rewards.py | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_rewards.py#L71-L84 | def reward_goal(self):
"""
Add an end goal reward
"""
if not 'goal' in self.mode:
return
mode = self.mode['goal']
if mode and mode['reward'] and self.__test_cond(mode):
if mode['reward'] > 0:
self.logger.info("Escaped!!")
... | [
"def",
"reward_goal",
"(",
"self",
")",
":",
"if",
"not",
"'goal'",
"in",
"self",
".",
"mode",
":",
"return",
"mode",
"=",
"self",
".",
"mode",
"[",
"'goal'",
"]",
"if",
"mode",
"and",
"mode",
"[",
"'reward'",
"]",
"and",
"self",
".",
"__test_cond",
... | Add an end goal reward | [
"Add",
"an",
"end",
"goal",
"reward"
] | python | train |
gabstopper/smc-python | smc/administration/scheduled_tasks.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/administration/scheduled_tasks.py#L592-L627 | def create(cls, name, servers, backup_log_data=False,
encrypt_password=None, comment=None):
"""
Create a new server backup task. This task provides the ability
to backup individual or all management and log servers under
SMC management.
:param str name: na... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"servers",
",",
"backup_log_data",
"=",
"False",
",",
"encrypt_password",
"=",
"None",
",",
"comment",
"=",
"None",
")",
":",
"if",
"not",
"servers",
":",
"servers",
"=",
"[",
"svr",
".",
"href",
"for",
... | Create a new server backup task. This task provides the ability
to backup individual or all management and log servers under
SMC management.
:param str name: name of task
:param servers: servers to back up. Servers must be instances of
management servers or log serve... | [
"Create",
"a",
"new",
"server",
"backup",
"task",
".",
"This",
"task",
"provides",
"the",
"ability",
"to",
"backup",
"individual",
"or",
"all",
"management",
"and",
"log",
"servers",
"under",
"SMC",
"management",
".",
":",
"param",
"str",
"name",
":",
"nam... | python | train |
materialsproject/pymatgen | pymatgen/analysis/molecule_matcher.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/molecule_matcher.py#L237-L259 | def _group_centroid(mol, ilabels, group_atoms):
"""
Calculate the centroids of a group atoms indexed by the labels of inchi
Args:
mol: The molecule. OpenBabel OBMol object
ilabel: inchi label map
Returns:
Centroid. Tuple (x, y, z)
"""
... | [
"def",
"_group_centroid",
"(",
"mol",
",",
"ilabels",
",",
"group_atoms",
")",
":",
"c1x",
",",
"c1y",
",",
"c1z",
"=",
"0.0",
",",
"0.0",
",",
"0.0",
"for",
"i",
"in",
"group_atoms",
":",
"orig_idx",
"=",
"ilabels",
"[",
"i",
"-",
"1",
"]",
"oa1",... | Calculate the centroids of a group atoms indexed by the labels of inchi
Args:
mol: The molecule. OpenBabel OBMol object
ilabel: inchi label map
Returns:
Centroid. Tuple (x, y, z) | [
"Calculate",
"the",
"centroids",
"of",
"a",
"group",
"atoms",
"indexed",
"by",
"the",
"labels",
"of",
"inchi"
] | python | train |
programa-stic/barf-project | barf/barf.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/barf.py#L216-L232 | def load_architecture(self, name, arch_info, disassembler, translator):
"""Translate to REIL instructions.
Args:
name (str): Architecture's name.
arch_info (ArchitectureInformation): Architecture information object.
disassembler (Disassembler): Disassembler for the a... | [
"def",
"load_architecture",
"(",
"self",
",",
"name",
",",
"arch_info",
",",
"disassembler",
",",
"translator",
")",
":",
"# Set up architecture information.",
"self",
".",
"name",
"=",
"name",
"self",
".",
"arch_info",
"=",
"arch_info",
"self",
".",
"disassembl... | Translate to REIL instructions.
Args:
name (str): Architecture's name.
arch_info (ArchitectureInformation): Architecture information object.
disassembler (Disassembler): Disassembler for the architecture.
translator (Translator): Translator for the architecture. | [
"Translate",
"to",
"REIL",
"instructions",
"."
] | python | train |
CalebBell/thermo | thermo/viscosity.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/viscosity.py#L764-L831 | def Lucas(T, P, Tc, Pc, omega, P_sat, mu_l):
r'''Adjustes for pressure the viscosity of a liquid using an emperical
formula developed in [1]_, but as discussed in [2]_ as the original source
is in German.
.. math::
\frac{\mu}{\mu_{sat}}=\frac{1+D(\Delta P_r/2.118)^A}{1+C\omega \Delta P_r}
... | [
"def",
"Lucas",
"(",
"T",
",",
"P",
",",
"Tc",
",",
"Pc",
",",
"omega",
",",
"P_sat",
",",
"mu_l",
")",
":",
"Tr",
"=",
"T",
"/",
"Tc",
"C",
"=",
"-",
"0.07921",
"+",
"2.1616",
"*",
"Tr",
"-",
"13.4040",
"*",
"Tr",
"**",
"2",
"+",
"44.1706"... | r'''Adjustes for pressure the viscosity of a liquid using an emperical
formula developed in [1]_, but as discussed in [2]_ as the original source
is in German.
.. math::
\frac{\mu}{\mu_{sat}}=\frac{1+D(\Delta P_r/2.118)^A}{1+C\omega \Delta P_r}
\Delta P_r = \frac{P-P^{sat}}{P_c}
A... | [
"r",
"Adjustes",
"for",
"pressure",
"the",
"viscosity",
"of",
"a",
"liquid",
"using",
"an",
"emperical",
"formula",
"developed",
"in",
"[",
"1",
"]",
"_",
"but",
"as",
"discussed",
"in",
"[",
"2",
"]",
"_",
"as",
"the",
"original",
"source",
"is",
"in"... | python | valid |
sdispater/orator | orator/orm/builder.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L532-L543 | def _is_nested(self, name, relation):
"""
Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool
"""
dots = name.find(".")
return dots and name.startswith(relation + ".") | [
"def",
"_is_nested",
"(",
"self",
",",
"name",
",",
"relation",
")",
":",
"dots",
"=",
"name",
".",
"find",
"(",
"\".\"",
")",
"return",
"dots",
"and",
"name",
".",
"startswith",
"(",
"relation",
"+",
"\".\"",
")"
] | Determine if the relationship is nested.
:type name: str
:type relation: str
:rtype: bool | [
"Determine",
"if",
"the",
"relationship",
"is",
"nested",
"."
] | python | train |
Unity-Technologies/ml-agents | ml-agents/mlagents/trainers/ppo/trainer.py | https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/ppo/trainer.py#L293-L305 | def end_episode(self):
"""
A signal that the Episode has ended. The buffer must be reset.
Get only called when the academy resets.
"""
self.training_buffer.reset_local_buffers()
for agent_id in self.cumulative_rewards:
self.cumulative_rewards[agent_id] = 0
... | [
"def",
"end_episode",
"(",
"self",
")",
":",
"self",
".",
"training_buffer",
".",
"reset_local_buffers",
"(",
")",
"for",
"agent_id",
"in",
"self",
".",
"cumulative_rewards",
":",
"self",
".",
"cumulative_rewards",
"[",
"agent_id",
"]",
"=",
"0",
"for",
"age... | A signal that the Episode has ended. The buffer must be reset.
Get only called when the academy resets. | [
"A",
"signal",
"that",
"the",
"Episode",
"has",
"ended",
".",
"The",
"buffer",
"must",
"be",
"reset",
".",
"Get",
"only",
"called",
"when",
"the",
"academy",
"resets",
"."
] | python | train |
maxpumperla/elephas | elephas/utils/functional_utils.py | https://github.com/maxpumperla/elephas/blob/84605acdc9564673c487637dcb27f5def128bcc7/elephas/utils/functional_utils.py#L33-L43 | def get_neutral(array_list):
"""Get list of zero-valued numpy arrays for
specified list of numpy arrays
:param array_list: list of numpy arrays
:return: list of zeros of same shape as input
"""
res = []
for x in array_list:
res.append(np.zeros_like(x))
return res | [
"def",
"get_neutral",
"(",
"array_list",
")",
":",
"res",
"=",
"[",
"]",
"for",
"x",
"in",
"array_list",
":",
"res",
".",
"append",
"(",
"np",
".",
"zeros_like",
"(",
"x",
")",
")",
"return",
"res"
] | Get list of zero-valued numpy arrays for
specified list of numpy arrays
:param array_list: list of numpy arrays
:return: list of zeros of same shape as input | [
"Get",
"list",
"of",
"zero",
"-",
"valued",
"numpy",
"arrays",
"for",
"specified",
"list",
"of",
"numpy",
"arrays"
] | python | train |
StanfordVL/robosuite | robosuite/environments/base.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/base.py#L115-L128 | def initialize_time(self, control_freq):
"""
Initializes the time constants used for simulation.
"""
self.cur_time = 0
self.model_timestep = self.sim.model.opt.timestep
if self.model_timestep <= 0:
raise XMLError("xml model defined non-positive time step")
... | [
"def",
"initialize_time",
"(",
"self",
",",
"control_freq",
")",
":",
"self",
".",
"cur_time",
"=",
"0",
"self",
".",
"model_timestep",
"=",
"self",
".",
"sim",
".",
"model",
".",
"opt",
".",
"timestep",
"if",
"self",
".",
"model_timestep",
"<=",
"0",
... | Initializes the time constants used for simulation. | [
"Initializes",
"the",
"time",
"constants",
"used",
"for",
"simulation",
"."
] | python | train |
rabitt/pysox | sox/transform.py | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L136-L253 | def set_input_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, ignore_length=False):
'''Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input ... | [
"def",
"set_input_format",
"(",
"self",
",",
"file_type",
"=",
"None",
",",
"rate",
"=",
"None",
",",
"bits",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"ignore_length",
"=",
"False",
")",
":",
"if",
"file_type",
"not... | Sets input file format arguments. This is primarily useful when
dealing with audio files without a file extension. Overwrites any
previously set input file arguments.
If this function is not explicity called the input format is inferred
from the file extension or the file's header.
... | [
"Sets",
"input",
"file",
"format",
"arguments",
".",
"This",
"is",
"primarily",
"useful",
"when",
"dealing",
"with",
"audio",
"files",
"without",
"a",
"file",
"extension",
".",
"Overwrites",
"any",
"previously",
"set",
"input",
"file",
"arguments",
"."
] | python | valid |
thebigmunch/gmusicapi-wrapper | gmusicapi_wrapper/musicmanager.py | https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/musicmanager.py#L35-L73 | def login(self, oauth_filename="oauth", uploader_id=None):
"""Authenticate the gmusicapi Musicmanager instance.
Parameters:
oauth_filename (str): The filename of the oauth credentials file to use/create for login.
Default: ``oauth``
uploader_id (str): A unique id as a MAC address (e.g. ``'00:11:22:33:AA... | [
"def",
"login",
"(",
"self",
",",
"oauth_filename",
"=",
"\"oauth\"",
",",
"uploader_id",
"=",
"None",
")",
":",
"cls_name",
"=",
"type",
"(",
"self",
")",
".",
"__name__",
"oauth_cred",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".... | Authenticate the gmusicapi Musicmanager instance.
Parameters:
oauth_filename (str): The filename of the oauth credentials file to use/create for login.
Default: ``oauth``
uploader_id (str): A unique id as a MAC address (e.g. ``'00:11:22:33:AA:BB'``).
This should only be provided in cases where the def... | [
"Authenticate",
"the",
"gmusicapi",
"Musicmanager",
"instance",
"."
] | python | valid |
askedrelic/libgreader | libgreader/auth.py | https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/auth.py#L303-L316 | def get(self, url, parameters=None):
"""
Convenience method for requesting to google with proper cookies/params.
"""
if not self.access_token:
raise IOError("No authorized client available.")
if parameters is None:
parameters = {}
parameters.update... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"parameters",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"access_token",
":",
"raise",
"IOError",
"(",
"\"No authorized client available.\"",
")",
"if",
"parameters",
"is",
"None",
":",
"parameters",
"=",
"... | Convenience method for requesting to google with proper cookies/params. | [
"Convenience",
"method",
"for",
"requesting",
"to",
"google",
"with",
"proper",
"cookies",
"/",
"params",
"."
] | python | train |
Microsoft/nni | src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L223-L229 | def add_noise(weights, other_weights):
'''add noise to the layer.
'''
w_range = np.ptp(other_weights.flatten())
noise_range = NOISE_RATIO * w_range
noise = np.random.uniform(-noise_range / 2.0, noise_range / 2.0, weights.shape)
return np.add(noise, weights) | [
"def",
"add_noise",
"(",
"weights",
",",
"other_weights",
")",
":",
"w_range",
"=",
"np",
".",
"ptp",
"(",
"other_weights",
".",
"flatten",
"(",
")",
")",
"noise_range",
"=",
"NOISE_RATIO",
"*",
"w_range",
"noise",
"=",
"np",
".",
"random",
".",
"uniform... | add noise to the layer. | [
"add",
"noise",
"to",
"the",
"layer",
"."
] | python | train |
klahnakoski/pyLibrary | jx_base/query.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/query.py#L200-L245 | def wrap(query, container, namespace):
"""
NORMALIZE QUERY SO IT CAN STILL BE JSON
"""
if is_op(query, QueryOp) or query == None:
return query
query = wrap(query)
table = container.get_table(query['from'])
schema = table.schema
output = QueryO... | [
"def",
"wrap",
"(",
"query",
",",
"container",
",",
"namespace",
")",
":",
"if",
"is_op",
"(",
"query",
",",
"QueryOp",
")",
"or",
"query",
"==",
"None",
":",
"return",
"query",
"query",
"=",
"wrap",
"(",
"query",
")",
"table",
"=",
"container",
".",... | NORMALIZE QUERY SO IT CAN STILL BE JSON | [
"NORMALIZE",
"QUERY",
"SO",
"IT",
"CAN",
"STILL",
"BE",
"JSON"
] | python | train |
googleapis/google-cloud-python | bigtable/google/cloud/bigtable_v2/gapic/bigtable_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable_v2/gapic/bigtable_client.py#L542-L652 | def check_and_mutate_row(
self,
table_name,
row_key,
app_profile_id=None,
predicate_filter=None,
true_mutations=None,
false_mutations=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
meta... | [
"def",
"check_and_mutate_row",
"(",
"self",
",",
"table_name",
",",
"row_key",
",",
"app_profile_id",
"=",
"None",
",",
"predicate_filter",
"=",
"None",
",",
"true_mutations",
"=",
"None",
",",
"false_mutations",
"=",
"None",
",",
"retry",
"=",
"google",
".",
... | Mutates a row atomically based on the output of a predicate Reader filter.
Example:
>>> from google.cloud import bigtable_v2
>>>
>>> client = bigtable_v2.BigtableClient()
>>>
>>> table_name = client.table_path('[PROJECT]', '[INSTANCE]', '[TABLE]')
... | [
"Mutates",
"a",
"row",
"atomically",
"based",
"on",
"the",
"output",
"of",
"a",
"predicate",
"Reader",
"filter",
"."
] | python | train |
craffel/mir_eval | mir_eval/pattern.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L306-L387 | def occurrence_FPR(reference_patterns, estimated_patterns, thres=.75,
similarity_metric="cardinality_score"):
"""Establishment F1 Score, Precision and Recall.
Examples
--------
>>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt")
>>> est_patterns = mir_eval.io.load_pa... | [
"def",
"occurrence_FPR",
"(",
"reference_patterns",
",",
"estimated_patterns",
",",
"thres",
"=",
".75",
",",
"similarity_metric",
"=",
"\"cardinality_score\"",
")",
":",
"validate",
"(",
"reference_patterns",
",",
"estimated_patterns",
")",
"# Number of elements in refer... | Establishment F1 Score, Precision and Recall.
Examples
--------
>>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt")
>>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt")
>>> F, P, R = mir_eval.pattern.occurrence_FPR(ref_patterns,
... ... | [
"Establishment",
"F1",
"Score",
"Precision",
"and",
"Recall",
"."
] | python | train |
vlukes/dicom2fem | dicom2fem/mesh.py | https://github.com/vlukes/dicom2fem/blob/3056c977ca7119e01984d3aa0c4448a1c6c2430f/dicom2fem/mesh.py#L67-L94 | def merge_mesh( x1, ngroups1, conns1, x2, ngroups2, conns2, cmap, eps = 1e-8 ):
"""Merge two meshes in common coordinates found in x1, x2."""
n1 = x1.shape[0]
n2 = x2.shape[0]
err = nm.sum( nm.sum( nm.abs( x1[cmap[:,0],:-1] - x2[cmap[:,1],:-1] ) ) )
if abs( err ) > (10.0 * eps):
print 'nonm... | [
"def",
"merge_mesh",
"(",
"x1",
",",
"ngroups1",
",",
"conns1",
",",
"x2",
",",
"ngroups2",
",",
"conns2",
",",
"cmap",
",",
"eps",
"=",
"1e-8",
")",
":",
"n1",
"=",
"x1",
".",
"shape",
"[",
"0",
"]",
"n2",
"=",
"x2",
".",
"shape",
"[",
"0",
... | Merge two meshes in common coordinates found in x1, x2. | [
"Merge",
"two",
"meshes",
"in",
"common",
"coordinates",
"found",
"in",
"x1",
"x2",
"."
] | python | train |
spyder-ide/conda-manager | conda_manager/api/conda_api.py | https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L727-L737 | def _setup_config_from_kwargs(kwargs):
"""Setup config commands for conda."""
cmd_list = ['--json', '--force']
if 'file' in kwargs:
cmd_list.extend(['--file', kwargs['file']])
if 'system' in kwargs:
cmd_list.append('--system')
return cmd_list | [
"def",
"_setup_config_from_kwargs",
"(",
"kwargs",
")",
":",
"cmd_list",
"=",
"[",
"'--json'",
",",
"'--force'",
"]",
"if",
"'file'",
"in",
"kwargs",
":",
"cmd_list",
".",
"extend",
"(",
"[",
"'--file'",
",",
"kwargs",
"[",
"'file'",
"]",
"]",
")",
"if",... | Setup config commands for conda. | [
"Setup",
"config",
"commands",
"for",
"conda",
"."
] | python | train |
trailofbits/protofuzz | protofuzz/values.py | https://github.com/trailofbits/protofuzz/blob/589492d34de9a0da6cc5554094e2588b893b2fd8/protofuzz/values.py#L94-L102 | def get_floats(bitwidth, limit=0):
'''
Return a number of interesting floating point values
'''
assert bitwidth in (32, 64, 80)
values = [0.0, -1.0, 1.0, -1231231231231.0123, 123123123123123.123]
for val in _limit_helper(values, limit):
yield val | [
"def",
"get_floats",
"(",
"bitwidth",
",",
"limit",
"=",
"0",
")",
":",
"assert",
"bitwidth",
"in",
"(",
"32",
",",
"64",
",",
"80",
")",
"values",
"=",
"[",
"0.0",
",",
"-",
"1.0",
",",
"1.0",
",",
"-",
"1231231231231.0123",
",",
"123123123123123.12... | Return a number of interesting floating point values | [
"Return",
"a",
"number",
"of",
"interesting",
"floating",
"point",
"values"
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/conventions/build_info.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/conventions/build_info.py#L63-L74 | def configure_build_info(graph):
"""
Configure the build info endpoint.
"""
ns = Namespace(
subject=BuildInfo,
)
convention = BuildInfoConvention(graph)
convention.configure(ns, retrieve=tuple())
return convention.build_info | [
"def",
"configure_build_info",
"(",
"graph",
")",
":",
"ns",
"=",
"Namespace",
"(",
"subject",
"=",
"BuildInfo",
",",
")",
"convention",
"=",
"BuildInfoConvention",
"(",
"graph",
")",
"convention",
".",
"configure",
"(",
"ns",
",",
"retrieve",
"=",
"tuple",
... | Configure the build info endpoint. | [
"Configure",
"the",
"build",
"info",
"endpoint",
"."
] | python | train |
newville/asteval | asteval/asteval.py | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/asteval.py#L528-L533 | def on_augassign(self, node): # ('target', 'op', 'value')
"""Augmented assign."""
return self.on_assign(ast.Assign(targets=[node.target],
value=ast.BinOp(left=node.target,
op=node.op,
... | [
"def",
"on_augassign",
"(",
"self",
",",
"node",
")",
":",
"# ('target', 'op', 'value')",
"return",
"self",
".",
"on_assign",
"(",
"ast",
".",
"Assign",
"(",
"targets",
"=",
"[",
"node",
".",
"target",
"]",
",",
"value",
"=",
"ast",
".",
"BinOp",
"(",
... | Augmented assign. | [
"Augmented",
"assign",
"."
] | python | train |
Yubico/python-yubico | yubico/yubikey_config.py | https://github.com/Yubico/python-yubico/blob/a72e8eddb90da6ee96e29f60912ca1f2872c9aea/yubico/yubikey_config.py#L362-L383 | def ticket_flag(self, which, new=None):
"""
Get or set a ticket flag.
'which' can be either a string ('APPEND_CR' etc.), or an integer.
You should ALWAYS use a string, unless you really know what you are doing.
"""
flag = _get_flag(which, TicketFlags)
if flag:
... | [
"def",
"ticket_flag",
"(",
"self",
",",
"which",
",",
"new",
"=",
"None",
")",
":",
"flag",
"=",
"_get_flag",
"(",
"which",
",",
"TicketFlags",
")",
"if",
"flag",
":",
"if",
"not",
"self",
".",
"capabilities",
".",
"have_ticket_flag",
"(",
"flag",
")",... | Get or set a ticket flag.
'which' can be either a string ('APPEND_CR' etc.), or an integer.
You should ALWAYS use a string, unless you really know what you are doing. | [
"Get",
"or",
"set",
"a",
"ticket",
"flag",
"."
] | python | train |
saltstack/salt | salt/states/postgres_cluster.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_cluster.py#L117-L151 | def absent(version,
name):
'''
Ensure that the named cluster is absent
version
Version of the postgresql server of the cluster to remove
name
The name of the cluster to remove
.. versionadded:: 2015.XX
'''
ret = {'name': name,
'changes': {},
... | [
"def",
"absent",
"(",
"version",
",",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"#check if cluster exists and remove it",
"if",
"__salt__",
"... | Ensure that the named cluster is absent
version
Version of the postgresql server of the cluster to remove
name
The name of the cluster to remove
.. versionadded:: 2015.XX | [
"Ensure",
"that",
"the",
"named",
"cluster",
"is",
"absent"
] | python | train |
secynic/ipwhois | ipwhois/scripts/ipwhois_cli.py | https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/scripts/ipwhois_cli.py#L489-L532 | def generate_output_entities(self, json_data=None, hr=True,
show_name=False, colorize=True):
"""
The function for generating CLI output RDAP entity results.
Args:
json_data (:obj:`dict`): The data to process. Defaults to None.
hr (:obj:`b... | [
"def",
"generate_output_entities",
"(",
"self",
",",
"json_data",
"=",
"None",
",",
"hr",
"=",
"True",
",",
"show_name",
"=",
"False",
",",
"colorize",
"=",
"True",
")",
":",
"output",
"=",
"''",
"short",
"=",
"HR_RDAP",
"[",
"'entities'",
"]",
"[",
"'... | The function for generating CLI output RDAP entity results.
Args:
json_data (:obj:`dict`): The data to process. Defaults to None.
hr (:obj:`bool`): Enable human readable key translations. Defaults
to True.
show_name (:obj:`bool`): Show human readable name (de... | [
"The",
"function",
"for",
"generating",
"CLI",
"output",
"RDAP",
"entity",
"results",
"."
] | python | train |
pytroll/satpy | satpy/readers/goes_imager_nc.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/goes_imager_nc.py#L926-L954 | def _update_metadata(self, data, ds_info):
"""Update metadata of the given DataArray"""
# Metadata from the dataset definition
data.attrs.update(ds_info)
# If the file_type attribute is a list and the data is xarray
# the concat of the dataset will not work. As the file_type is
... | [
"def",
"_update_metadata",
"(",
"self",
",",
"data",
",",
"ds_info",
")",
":",
"# Metadata from the dataset definition",
"data",
".",
"attrs",
".",
"update",
"(",
"ds_info",
")",
"# If the file_type attribute is a list and the data is xarray",
"# the concat of the dataset wil... | Update metadata of the given DataArray | [
"Update",
"metadata",
"of",
"the",
"given",
"DataArray"
] | python | train |
pyupio/changelogs | changelogs/finder.py | https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/finder.py#L62-L95 | def find_repo_urls(session, name, candidates):
"""
Visits the given URL candidates and searches the page for valid links to a repository.
:param session: requests Session instance
:param name: str, project name
:param candidates: list, list of URL candidates
:return: str, URL to a repo
"""
... | [
"def",
"find_repo_urls",
"(",
"session",
",",
"name",
",",
"candidates",
")",
":",
"for",
"_url",
"in",
"candidates",
":",
"if",
"validate_url",
"(",
"_url",
")",
":",
"try",
":",
"resp",
"=",
"session",
".",
"get",
"(",
"_url",
")",
"if",
"resp",
".... | Visits the given URL candidates and searches the page for valid links to a repository.
:param session: requests Session instance
:param name: str, project name
:param candidates: list, list of URL candidates
:return: str, URL to a repo | [
"Visits",
"the",
"given",
"URL",
"candidates",
"and",
"searches",
"the",
"page",
"for",
"valid",
"links",
"to",
"a",
"repository",
".",
":",
"param",
"session",
":",
"requests",
"Session",
"instance",
":",
"param",
"name",
":",
"str",
"project",
"name",
":... | python | train |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/random/RandomDateTime.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/random/RandomDateTime.py#L66-L79 | def next_datetime(min_year = None, max_year = None):
"""
Generates a random Date and time in the range ['minYear', 'maxYear'].
This method generate dates without time (or time set to 00:00:00)
:param min_year: (optional) minimum range value
:param max_year: max range value
... | [
"def",
"next_datetime",
"(",
"min_year",
"=",
"None",
",",
"max_year",
"=",
"None",
")",
":",
"date",
"=",
"RandomDateTime",
".",
"next_date",
"(",
"min_year",
",",
"max_year",
")",
".",
"date",
"(",
")",
"time",
"=",
"RandomDateTime",
".",
"next_time",
... | Generates a random Date and time in the range ['minYear', 'maxYear'].
This method generate dates without time (or time set to 00:00:00)
:param min_year: (optional) minimum range value
:param max_year: max range value
:return: a random Date and time value. | [
"Generates",
"a",
"random",
"Date",
"and",
"time",
"in",
"the",
"range",
"[",
"minYear",
"maxYear",
"]",
".",
"This",
"method",
"generate",
"dates",
"without",
"time",
"(",
"or",
"time",
"set",
"to",
"00",
":",
"00",
":",
"00",
")"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.