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 |
|---|---|---|---|---|---|---|---|---|
mongodb/mongo-python-driver | bson/codec_options.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/bson/codec_options.py#L294-L314 | def with_options(self, **kwargs):
"""Make a copy of this CodecOptions, overriding some options::
>>> from bson.codec_options import DEFAULT_CODEC_OPTIONS
>>> DEFAULT_CODEC_OPTIONS.tz_aware
False
>>> options = DEFAULT_CODEC_OPTIONS.with_options(tz_aware=True)
... | [
"def",
"with_options",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"CodecOptions",
"(",
"kwargs",
".",
"get",
"(",
"'document_class'",
",",
"self",
".",
"document_class",
")",
",",
"kwargs",
".",
"get",
"(",
"'tz_aware'",
",",
"self",
".",
... | Make a copy of this CodecOptions, overriding some options::
>>> from bson.codec_options import DEFAULT_CODEC_OPTIONS
>>> DEFAULT_CODEC_OPTIONS.tz_aware
False
>>> options = DEFAULT_CODEC_OPTIONS.with_options(tz_aware=True)
>>> options.tz_aware
True... | [
"Make",
"a",
"copy",
"of",
"this",
"CodecOptions",
"overriding",
"some",
"options",
"::"
] | python | train |
juju/charm-helpers | charmhelpers/contrib/database/mysql.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L160-L166 | def execute(self, sql):
"""Execute arbitary SQL against the database."""
cursor = self.connection.cursor()
try:
cursor.execute(sql)
finally:
cursor.close() | [
"def",
"execute",
"(",
"self",
",",
"sql",
")",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"try",
":",
"cursor",
".",
"execute",
"(",
"sql",
")",
"finally",
":",
"cursor",
".",
"close",
"(",
")"
] | Execute arbitary SQL against the database. | [
"Execute",
"arbitary",
"SQL",
"against",
"the",
"database",
"."
] | python | train |
nutechsoftware/alarmdecoder | examples/rf_device.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/rf_device.py#L10-L33 | def main():
"""
Example application that watches for an event from a specific RF device.
This feature allows you to watch for events from RF devices if you have
an RF receiver. This is useful in the case of internal sensors, which
don't emit a FAULT if the sensor is tripped and the panel is armed ... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve the first USB device",
"device",
"=",
"AlarmDecoder",
"(",
"SerialDevice",
"(",
"interface",
"=",
"SERIAL_DEVICE",
")",
")",
"# Set up an event handler and open the device",
"device",
".",
"on_rfx_message",
"+=",
"... | Example application that watches for an event from a specific RF device.
This feature allows you to watch for events from RF devices if you have
an RF receiver. This is useful in the case of internal sensors, which
don't emit a FAULT if the sensor is tripped and the panel is armed STAY.
It also will m... | [
"Example",
"application",
"that",
"watches",
"for",
"an",
"event",
"from",
"a",
"specific",
"RF",
"device",
"."
] | python | train |
BlueBrain/NeuroM | examples/synthesis_json.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/synthesis_json.py#L92-L100 | def transform_header(mtype_name):
'''Add header to json output to wrap around distribution data.
'''
head_dict = OrderedDict()
head_dict["m-type"] = mtype_name
head_dict["components"] = defaultdict(OrderedDict)
return head_dict | [
"def",
"transform_header",
"(",
"mtype_name",
")",
":",
"head_dict",
"=",
"OrderedDict",
"(",
")",
"head_dict",
"[",
"\"m-type\"",
"]",
"=",
"mtype_name",
"head_dict",
"[",
"\"components\"",
"]",
"=",
"defaultdict",
"(",
"OrderedDict",
")",
"return",
"head_dict"... | Add header to json output to wrap around distribution data. | [
"Add",
"header",
"to",
"json",
"output",
"to",
"wrap",
"around",
"distribution",
"data",
"."
] | python | train |
mixcloud/django-experiments | experiments/utils.py | https://github.com/mixcloud/django-experiments/blob/1f45e9f8a108b51e44918daa647269b2b8d43f1d/experiments/utils.py#L192-L200 | def is_enrolled(self, experiment_name, alternative):
"""Enroll this user in the experiment if they are not already part of it. Returns the selected alternative"""
"""Test if the user is enrolled in the supplied alternative for the given experiment.
The supplied alternative will be added to the ... | [
"def",
"is_enrolled",
"(",
"self",
",",
"experiment_name",
",",
"alternative",
")",
":",
"\"\"\"Test if the user is enrolled in the supplied alternative for the given experiment.\n\n The supplied alternative will be added to the list of possible alternatives for the\n experiment if... | Enroll this user in the experiment if they are not already part of it. Returns the selected alternative | [
"Enroll",
"this",
"user",
"in",
"the",
"experiment",
"if",
"they",
"are",
"not",
"already",
"part",
"of",
"it",
".",
"Returns",
"the",
"selected",
"alternative"
] | python | train |
dcwatson/django-pgcrypto | pgcrypto/base.py | https://github.com/dcwatson/django-pgcrypto/blob/02108795ec97f80af92ff6800a1c55eb958c3496/pgcrypto/base.py#L33-L46 | def armor(data, versioned=True):
"""
Returns a string in ASCII Armor format, for the given binary data. The
output of this is compatiple with pgcrypto's armor/dearmor functions.
"""
template = '-----BEGIN PGP MESSAGE-----\n%(headers)s%(body)s\n=%(crc)s\n-----END PGP MESSAGE-----'
body = base64.b... | [
"def",
"armor",
"(",
"data",
",",
"versioned",
"=",
"True",
")",
":",
"template",
"=",
"'-----BEGIN PGP MESSAGE-----\\n%(headers)s%(body)s\\n=%(crc)s\\n-----END PGP MESSAGE-----'",
"body",
"=",
"base64",
".",
"b64encode",
"(",
"data",
")",
"# The 24-bit CRC should be in big... | Returns a string in ASCII Armor format, for the given binary data. The
output of this is compatiple with pgcrypto's armor/dearmor functions. | [
"Returns",
"a",
"string",
"in",
"ASCII",
"Armor",
"format",
"for",
"the",
"given",
"binary",
"data",
".",
"The",
"output",
"of",
"this",
"is",
"compatiple",
"with",
"pgcrypto",
"s",
"armor",
"/",
"dearmor",
"functions",
"."
] | python | train |
evhub/coconut | coconut/command/util.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/command/util.py#L263-L295 | def run_cmd(cmd, show_output=True, raise_errs=True, **kwargs):
"""Run a console command.
When show_output=True, prints output and returns exit code, otherwise returns output.
When raise_errs=True, raises a subprocess.CalledProcessError if the command fails.
"""
internal_assert(cmd and isinstance(cm... | [
"def",
"run_cmd",
"(",
"cmd",
",",
"show_output",
"=",
"True",
",",
"raise_errs",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"internal_assert",
"(",
"cmd",
"and",
"isinstance",
"(",
"cmd",
",",
"list",
")",
",",
"\"console commands must be passed as non... | Run a console command.
When show_output=True, prints output and returns exit code, otherwise returns output.
When raise_errs=True, raises a subprocess.CalledProcessError if the command fails. | [
"Run",
"a",
"console",
"command",
"."
] | python | train |
rikrd/inspire | inspirespeech/__init__.py | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L481-L494 | def load(fileobj):
"""Load the submission from a file-like object
:param fileobj: File-like object
:return: the loaded submission
"""
with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
submission = Submission(metadata=json.loads(z.readline()))
for line ... | [
"def",
"load",
"(",
"fileobj",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"fileobj",
",",
"mode",
"=",
"'r'",
")",
"as",
"z",
":",
"submission",
"=",
"Submission",
"(",
"metadata",
"=",
"json",
".",
"loads",
"(",
"z",
".",
"rea... | Load the submission from a file-like object
:param fileobj: File-like object
:return: the loaded submission | [
"Load",
"the",
"submission",
"from",
"a",
"file",
"-",
"like",
"object"
] | python | train |
toumorokoshi/sprinter | sprinter/environment.py | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L573-L578 | def _copy_source_to_target(self):
""" copy source user configuration to target """
if self.source and self.target:
for k, v in self.source.items('config'):
# always have source override target.
self.target.set_input(k, v) | [
"def",
"_copy_source_to_target",
"(",
"self",
")",
":",
"if",
"self",
".",
"source",
"and",
"self",
".",
"target",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"source",
".",
"items",
"(",
"'config'",
")",
":",
"# always have source override target.",
"se... | copy source user configuration to target | [
"copy",
"source",
"user",
"configuration",
"to",
"target"
] | python | train |
SheffieldML/GPy | GPy/models/warped_gp.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/models/warped_gp.py#L118-L132 | def predict_quantiles(self, X, quantiles=(2.5, 97.5), Y_metadata=None, likelihood=None, kern=None):
"""
Get the predictive quantiles around the prediction at X
:param X: The points at which to make a prediction
:type X: np.ndarray (Xnew x self.input_dim)
:param quantiles: tuple ... | [
"def",
"predict_quantiles",
"(",
"self",
",",
"X",
",",
"quantiles",
"=",
"(",
"2.5",
",",
"97.5",
")",
",",
"Y_metadata",
"=",
"None",
",",
"likelihood",
"=",
"None",
",",
"kern",
"=",
"None",
")",
":",
"qs",
"=",
"super",
"(",
"WarpedGP",
",",
"s... | Get the predictive quantiles around the prediction at X
:param X: The points at which to make a prediction
:type X: np.ndarray (Xnew x self.input_dim)
:param quantiles: tuple of quantiles, default is (2.5, 97.5) which is the 95% interval
:type quantiles: tuple
:returns: list of ... | [
"Get",
"the",
"predictive",
"quantiles",
"around",
"the",
"prediction",
"at",
"X"
] | python | train |
atlassian-api/atlassian-python-api | atlassian/bitbucket.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/bitbucket.py#L20-L27 | def project(self, key):
"""
Provide project info
:param key:
:return:
"""
url = 'rest/api/1.0/projects/{0}'.format(key)
return (self.get(url) or {}).get('values') | [
"def",
"project",
"(",
"self",
",",
"key",
")",
":",
"url",
"=",
"'rest/api/1.0/projects/{0}'",
".",
"format",
"(",
"key",
")",
"return",
"(",
"self",
".",
"get",
"(",
"url",
")",
"or",
"{",
"}",
")",
".",
"get",
"(",
"'values'",
")"
] | Provide project info
:param key:
:return: | [
"Provide",
"project",
"info",
":",
"param",
"key",
":",
":",
"return",
":"
] | python | train |
cisco-sas/kitty | kitty/fuzzers/base.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/fuzzers/base.py#L246-L257 | def set_model(self, model):
'''
Set the model to fuzz
:type model: :class:`~kitty.model.high_level.base.BaseModel` or a subclass
:param model: Model object to fuzz
'''
self.model = model
if self.model:
self.model.set_notification_handler(self)
... | [
"def",
"set_model",
"(",
"self",
",",
"model",
")",
":",
"self",
".",
"model",
"=",
"model",
"if",
"self",
".",
"model",
":",
"self",
".",
"model",
".",
"set_notification_handler",
"(",
"self",
")",
"self",
".",
"handle_stage_changed",
"(",
"model",
")",... | Set the model to fuzz
:type model: :class:`~kitty.model.high_level.base.BaseModel` or a subclass
:param model: Model object to fuzz | [
"Set",
"the",
"model",
"to",
"fuzz"
] | python | train |
glomex/gcdt | gcdt/kumo_core.py | https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_core.py#L608-L629 | def describe_change_set(awsclient, change_set_name, stack_name):
"""Print out the change_set to console.
This needs to run create_change_set first.
:param awsclient:
:param change_set_name:
:param stack_name:
"""
client = awsclient.get_client('cloudformation')
status = None
while s... | [
"def",
"describe_change_set",
"(",
"awsclient",
",",
"change_set_name",
",",
"stack_name",
")",
":",
"client",
"=",
"awsclient",
".",
"get_client",
"(",
"'cloudformation'",
")",
"status",
"=",
"None",
"while",
"status",
"not",
"in",
"[",
"'CREATE_COMPLETE'",
","... | Print out the change_set to console.
This needs to run create_change_set first.
:param awsclient:
:param change_set_name:
:param stack_name: | [
"Print",
"out",
"the",
"change_set",
"to",
"console",
".",
"This",
"needs",
"to",
"run",
"create_change_set",
"first",
"."
] | python | train |
kennknowles/python-rightarrow | rightarrow/parser.py | https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/parser.py#L169-L174 | def p_obj_fields(self, p):
"""
obj_fields : obj_fields ',' obj_field
| obj_field
"""
p[0] = dict([p[1]] if len(p) == 2 else p[1] + [p[3]]) | [
"def",
"p_obj_fields",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"dict",
"(",
"[",
"p",
"[",
"1",
"]",
"]",
"if",
"len",
"(",
"p",
")",
"==",
"2",
"else",
"p",
"[",
"1",
"]",
"+",
"[",
"p",
"[",
"3",
"]",
"]",
")"
] | obj_fields : obj_fields ',' obj_field
| obj_field | [
"obj_fields",
":",
"obj_fields",
"obj_field",
"|",
"obj_field"
] | python | train |
portfors-lab/sparkle | sparkle/gui/stim/stimulusview.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulusview.py#L205-L208 | def rowsAboutToBeRemoved(self, parent, start, end):
"""Marks view for repaint. :qtdoc:`Re-implemented<QAbstractItemView.rowsAboutToBeRemoved>`"""
self._viewIsDirty = True
super(StimulusView, self).rowsAboutToBeRemoved(parent, start, end) | [
"def",
"rowsAboutToBeRemoved",
"(",
"self",
",",
"parent",
",",
"start",
",",
"end",
")",
":",
"self",
".",
"_viewIsDirty",
"=",
"True",
"super",
"(",
"StimulusView",
",",
"self",
")",
".",
"rowsAboutToBeRemoved",
"(",
"parent",
",",
"start",
",",
"end",
... | Marks view for repaint. :qtdoc:`Re-implemented<QAbstractItemView.rowsAboutToBeRemoved>` | [
"Marks",
"view",
"for",
"repaint",
".",
":",
"qtdoc",
":",
"Re",
"-",
"implemented<QAbstractItemView",
".",
"rowsAboutToBeRemoved",
">"
] | python | train |
bcbio/bcbio-nextgen | bcbio/structural/cnvkit.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/cnvkit.py#L125-L139 | def _match_batches(tumor, normal):
"""Fix batch names for shared tumor/normals to ensure matching
"""
def _get_batch(x):
b = dd.get_batch(x)
return [b] if not isinstance(b, (list, tuple)) else b
if normal:
tumor = copy.deepcopy(tumor)
normal = copy.deepcopy(normal)
... | [
"def",
"_match_batches",
"(",
"tumor",
",",
"normal",
")",
":",
"def",
"_get_batch",
"(",
"x",
")",
":",
"b",
"=",
"dd",
".",
"get_batch",
"(",
"x",
")",
"return",
"[",
"b",
"]",
"if",
"not",
"isinstance",
"(",
"b",
",",
"(",
"list",
",",
"tuple"... | Fix batch names for shared tumor/normals to ensure matching | [
"Fix",
"batch",
"names",
"for",
"shared",
"tumor",
"/",
"normals",
"to",
"ensure",
"matching"
] | python | train |
tcpcloud/python-aptly | aptly/publisher/__init__.py | https://github.com/tcpcloud/python-aptly/blob/7eb4ce1c508666bad0e6a0d4c5c561b1485ed558/aptly/publisher/__init__.py#L594-L601 | def add(self, snapshot, component='main'):
"""
Add snapshot of component to publish
"""
try:
self.components[component].append(snapshot)
except KeyError:
self.components[component] = [snapshot] | [
"def",
"add",
"(",
"self",
",",
"snapshot",
",",
"component",
"=",
"'main'",
")",
":",
"try",
":",
"self",
".",
"components",
"[",
"component",
"]",
".",
"append",
"(",
"snapshot",
")",
"except",
"KeyError",
":",
"self",
".",
"components",
"[",
"compon... | Add snapshot of component to publish | [
"Add",
"snapshot",
"of",
"component",
"to",
"publish"
] | python | train |
saltstack/salt | salt/modules/netscaler.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netscaler.py#L484-L510 | def service_disable(s_name, s_delay=None, **connection_args):
'''
Disable a service
CLI Example:
.. code-block:: bash
salt '*' netscaler.service_disable 'serviceName'
salt '*' netscaler.service_disable 'serviceName' 'delayInSeconds'
'''
ret = True
service = _service_get(s_... | [
"def",
"service_disable",
"(",
"s_name",
",",
"s_delay",
"=",
"None",
",",
"*",
"*",
"connection_args",
")",
":",
"ret",
"=",
"True",
"service",
"=",
"_service_get",
"(",
"s_name",
",",
"*",
"*",
"connection_args",
")",
"if",
"service",
"is",
"None",
":"... | Disable a service
CLI Example:
.. code-block:: bash
salt '*' netscaler.service_disable 'serviceName'
salt '*' netscaler.service_disable 'serviceName' 'delayInSeconds' | [
"Disable",
"a",
"service"
] | python | train |
nephila/djangocms-blog | djangocms_blog/admin.py | https://github.com/nephila/djangocms-blog/blob/3fdfbd4ba48947df0ee4c6d42e3a1c812b6dd95d/djangocms_blog/admin.py#L302-L342 | def get_fieldsets(self, request, obj=None):
"""
Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration
"""
app_config_default = self._app_config_select(request, obj)
if app_config_de... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"app_config_default",
"=",
"self",
".",
"_app_config_select",
"(",
"request",
",",
"obj",
")",
"if",
"app_config_default",
"is",
"None",
"and",
"request",
".",
"method",
... | Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration | [
"Customize",
"the",
"fieldsets",
"according",
"to",
"the",
"app",
"settings"
] | python | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L19-L44 | def compute_nutation(t):
"""Generate the nutation rotations for Time `t`.
If the Julian date is scalar, a simple ``(3, 3)`` matrix is
returned; if the date is an array of length ``n``, then an array of
matrices is returned with dimensions ``(3, 3, n)``.
"""
oblm, oblt, eqeq, psi, eps = t._eart... | [
"def",
"compute_nutation",
"(",
"t",
")",
":",
"oblm",
",",
"oblt",
",",
"eqeq",
",",
"psi",
",",
"eps",
"=",
"t",
".",
"_earth_tilt",
"cobm",
"=",
"cos",
"(",
"oblm",
"*",
"DEG2RAD",
")",
"sobm",
"=",
"sin",
"(",
"oblm",
"*",
"DEG2RAD",
")",
"co... | Generate the nutation rotations for Time `t`.
If the Julian date is scalar, a simple ``(3, 3)`` matrix is
returned; if the date is an array of length ``n``, then an array of
matrices is returned with dimensions ``(3, 3, n)``. | [
"Generate",
"the",
"nutation",
"rotations",
"for",
"Time",
"t",
"."
] | python | train |
mmcauliffe/Conch-sounds | conch/analysis/mfcc/rastamat.py | https://github.com/mmcauliffe/Conch-sounds/blob/e05535fd08e4b0e47e37a77ef521d05eff1d6bc5/conch/analysis/mfcc/rastamat.py#L35-L66 | def construct_filterbank(num_filters, nfft, sr, min_freq, max_freq):
"""Constructs a mel-frequency filter bank.
Parameters
----------
nfft : int
Number of points in the FFT.
Returns
-------
array
Filter bank to... | [
"def",
"construct_filterbank",
"(",
"num_filters",
",",
"nfft",
",",
"sr",
",",
"min_freq",
",",
"max_freq",
")",
":",
"min_mel",
"=",
"freq_to_mel",
"(",
"min_freq",
")",
"max_mel",
"=",
"freq_to_mel",
"(",
"max_freq",
")",
"mel_points",
"=",
"np",
".",
"... | Constructs a mel-frequency filter bank.
Parameters
----------
nfft : int
Number of points in the FFT.
Returns
-------
array
Filter bank to multiply an FFT spectrum to create a mel-frequency
spectrum... | [
"Constructs",
"a",
"mel",
"-",
"frequency",
"filter",
"bank",
"."
] | python | train |
numenta/htmresearch | htmresearch/support/column_pooler_mixin.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/column_pooler_mixin.py#L201-L227 | def mmGetCellActivityPlot(self, title="", showReset=False,
resetShading=0.25, activityType="activeCells"):
"""
Returns plot of the cell activity.
@param title (string) an optional title for the figure
@param showReset (bool) if true, the first set of cell acti... | [
"def",
"mmGetCellActivityPlot",
"(",
"self",
",",
"title",
"=",
"\"\"",
",",
"showReset",
"=",
"False",
",",
"resetShading",
"=",
"0.25",
",",
"activityType",
"=",
"\"activeCells\"",
")",
":",
"cellTrace",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_... | Returns plot of the cell activity.
@param title (string) an optional title for the figure
@param showReset (bool) if true, the first set of cell activities
after a reset will have a gray background
@param resetShading (float) if showReset is true, this fl... | [
"Returns",
"plot",
"of",
"the",
"cell",
"activity",
"."
] | python | train |
coopie/ttv | ttv.py | https://github.com/coopie/ttv/blob/43e2bcddf58945f27665d4db1362473842eb26f3/ttv.py#L140-L167 | def get_dataset(corpora):
"""
Return a dictionary of subjectID -> [path_to_resource].
"""
# TODO: make filter methods for the files
def make_posix_path(dirpath, filename):
dirpath = posixpath.sep.join(dirpath.split(os.sep))
return posixpath.join(dirpath, filename)
wav_files_in_... | [
"def",
"get_dataset",
"(",
"corpora",
")",
":",
"# TODO: make filter methods for the files",
"def",
"make_posix_path",
"(",
"dirpath",
",",
"filename",
")",
":",
"dirpath",
"=",
"posixpath",
".",
"sep",
".",
"join",
"(",
"dirpath",
".",
"split",
"(",
"os",
"."... | Return a dictionary of subjectID -> [path_to_resource]. | [
"Return",
"a",
"dictionary",
"of",
"subjectID",
"-",
">",
"[",
"path_to_resource",
"]",
"."
] | python | train |
axialmarket/fsq | fsq/internal.py | https://github.com/axialmarket/fsq/blob/43b84c292cb8a187599d86753b947cf73248f989/fsq/internal.py#L167-L176 | def check_ttl_max_tries(tries, enqueued_at, max_tries, ttl):
'''Check that the ttl for an item has not expired, and that the item has
not exceeded it's maximum allotted tries'''
if max_tries > 0 and tries >= max_tries:
raise FSQMaxTriesError(errno.EINTR, u'Max tries exceded:'\
... | [
"def",
"check_ttl_max_tries",
"(",
"tries",
",",
"enqueued_at",
",",
"max_tries",
",",
"ttl",
")",
":",
"if",
"max_tries",
">",
"0",
"and",
"tries",
">=",
"max_tries",
":",
"raise",
"FSQMaxTriesError",
"(",
"errno",
".",
"EINTR",
",",
"u'Max tries exceded:'",
... | Check that the ttl for an item has not expired, and that the item has
not exceeded it's maximum allotted tries | [
"Check",
"that",
"the",
"ttl",
"for",
"an",
"item",
"has",
"not",
"expired",
"and",
"that",
"the",
"item",
"has",
"not",
"exceeded",
"it",
"s",
"maximum",
"allotted",
"tries"
] | python | train |
mitsei/dlkit | dlkit/json_/repository/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L5623-L5639 | def get_child_repository_ids(self, repository_id):
"""Gets the ``Ids`` of the children of the given repository.
arg: repository_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the repository
raise: NotFound - ``repository_id`` not found
raise:... | [
"def",
"get_child_repository_ids",
"(",
"self",
",",
"repository_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bin_ids",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_sess... | Gets the ``Ids`` of the children of the given repository.
arg: repository_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the repository
raise: NotFound - ``repository_id`` not found
raise: NullArgument - ``repository_id`` is ``null``
raise: ... | [
"Gets",
"the",
"Ids",
"of",
"the",
"children",
"of",
"the",
"given",
"repository",
"."
] | python | train |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/_package.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/_package.py#L67-L84 | def _assert_gcs_files(files):
"""Check files starts wtih gs://.
Args:
files: string to file path, or list of file paths.
"""
if sys.version_info.major > 2:
string_type = (str, bytes) # for python 3 compatibility
else:
string_type = basestring # noqa
if isinstance(files, string_type):
fi... | [
"def",
"_assert_gcs_files",
"(",
"files",
")",
":",
"if",
"sys",
".",
"version_info",
".",
"major",
">",
"2",
":",
"string_type",
"=",
"(",
"str",
",",
"bytes",
")",
"# for python 3 compatibility",
"else",
":",
"string_type",
"=",
"basestring",
"# noqa",
"if... | Check files starts wtih gs://.
Args:
files: string to file path, or list of file paths. | [
"Check",
"files",
"starts",
"wtih",
"gs",
":",
"//",
"."
] | python | train |
sosreport/sos | sos/__init__.py | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L272-L285 | def merge(self, src, skip_default=True):
"""Merge another set of ``SoSOptions`` into this object.
Merge two ``SoSOptions`` objects by setting unset or default
values to their value in the ``src`` object.
:param src: the ``SoSOptions`` object to copy from
:param ... | [
"def",
"merge",
"(",
"self",
",",
"src",
",",
"skip_default",
"=",
"True",
")",
":",
"for",
"arg",
"in",
"_arg_names",
":",
"if",
"not",
"hasattr",
"(",
"src",
",",
"arg",
")",
":",
"continue",
"if",
"getattr",
"(",
"src",
",",
"arg",
")",
"is",
... | Merge another set of ``SoSOptions`` into this object.
Merge two ``SoSOptions`` objects by setting unset or default
values to their value in the ``src`` object.
:param src: the ``SoSOptions`` object to copy from
:param is_default: ``True`` if new default values are to be... | [
"Merge",
"another",
"set",
"of",
"SoSOptions",
"into",
"this",
"object",
"."
] | python | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L108-L123 | def print_model(self, pretty=True, encoding='utf8'):
"""Return the assembled SBGN model as an XML string.
Parameters
----------
pretty : Optional[bool]
If True, the SBGN string is formatted with indentation (for human
viewing) otherwise no indentation is used. De... | [
"def",
"print_model",
"(",
"self",
",",
"pretty",
"=",
"True",
",",
"encoding",
"=",
"'utf8'",
")",
":",
"return",
"lxml",
".",
"etree",
".",
"tostring",
"(",
"self",
".",
"sbgn",
",",
"pretty_print",
"=",
"pretty",
",",
"encoding",
"=",
"encoding",
",... | Return the assembled SBGN model as an XML string.
Parameters
----------
pretty : Optional[bool]
If True, the SBGN string is formatted with indentation (for human
viewing) otherwise no indentation is used. Default: True
Returns
-------
sbgn_str : ... | [
"Return",
"the",
"assembled",
"SBGN",
"model",
"as",
"an",
"XML",
"string",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L2658-L2668 | def computeDistortion(self, eEye, fU, fV):
"""
Gets the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport.
Returns true for success. Otherwise, returns false, ... | [
"def",
"computeDistortion",
"(",
"self",
",",
"eEye",
",",
"fU",
",",
"fV",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"computeDistortion",
"pDistortionCoordinates",
"=",
"DistortionCoordinates_t",
"(",
")",
"result",
"=",
"fn",
"(",
"eEye",
",... | Gets the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport.
Returns true for success. Otherwise, returns false, and distortion coordinates are not suitable. | [
"Gets",
"the",
"result",
"of",
"the",
"distortion",
"function",
"for",
"the",
"specified",
"eye",
"and",
"input",
"UVs",
".",
"UVs",
"go",
"from",
"0",
"0",
"in",
"the",
"upper",
"left",
"of",
"that",
"eye",
"s",
"viewport",
"and",
"1",
"1",
"in",
"t... | python | train |
pypa/pipenv | pipenv/vendor/distlib/_backport/tarfile.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L752-L778 | def read(self, size=None):
"""Read data from the file.
"""
if size is None:
size = self.size - self.position
else:
size = min(size, self.size - self.position)
buf = b""
while size > 0:
while True:
data, start, stop, off... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"self",
".",
"size",
"-",
"self",
".",
"position",
"else",
":",
"size",
"=",
"min",
"(",
"size",
",",
"self",
".",
"size",
"-",
"self"... | Read data from the file. | [
"Read",
"data",
"from",
"the",
"file",
"."
] | python | train |
acutesoftware/AIKIF | aikif/agents/explore/agent_explore_grid.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/explore/agent_explore_grid.py#L24-L41 | def set_world(self, grd, start_y_x, y_x):
"""
tell the agent to move to location y,x
Why is there another grd object in the agent? Because
this is NOT the main grid, rather a copy for the agent
to overwrite with planning routes, etc.
The real grid is initialised in Worl... | [
"def",
"set_world",
"(",
"self",
",",
"grd",
",",
"start_y_x",
",",
"y_x",
")",
":",
"self",
".",
"grd",
"=",
"grd",
"self",
".",
"start_y",
"=",
"start_y_x",
"[",
"0",
"]",
"self",
".",
"start_x",
"=",
"start_y_x",
"[",
"1",
"]",
"self",
".",
"c... | tell the agent to move to location y,x
Why is there another grd object in the agent? Because
this is NOT the main grid, rather a copy for the agent
to overwrite with planning routes, etc.
The real grid is initialised in World.__init__() class | [
"tell",
"the",
"agent",
"to",
"move",
"to",
"location",
"y",
"x",
"Why",
"is",
"there",
"another",
"grd",
"object",
"in",
"the",
"agent?",
"Because",
"this",
"is",
"NOT",
"the",
"main",
"grid",
"rather",
"a",
"copy",
"for",
"the",
"agent",
"to",
"overw... | python | train |
HazyResearch/metal | metal/multitask/mt_end_model.py | https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/multitask/mt_end_model.py#L281-L294 | def _preprocess_Y(self, Y, k=None):
"""Convert Y to t-length list of probabilistic labels if necessary"""
# If not a list, convert to a singleton list
if not isinstance(Y, list):
if self.t != 1:
msg = "For t > 1, Y must be a list of n-dim or [n, K_t] tensors"
... | [
"def",
"_preprocess_Y",
"(",
"self",
",",
"Y",
",",
"k",
"=",
"None",
")",
":",
"# If not a list, convert to a singleton list",
"if",
"not",
"isinstance",
"(",
"Y",
",",
"list",
")",
":",
"if",
"self",
".",
"t",
"!=",
"1",
":",
"msg",
"=",
"\"For t > 1, ... | Convert Y to t-length list of probabilistic labels if necessary | [
"Convert",
"Y",
"to",
"t",
"-",
"length",
"list",
"of",
"probabilistic",
"labels",
"if",
"necessary"
] | python | train |
tempodb/tempodb-python | tempodb/protocol/objects.py | https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/protocol/objects.py#L438-L448 | def to_dictionary(self):
"""Serialize an object into dictionary form. Useful if you have to
serialize an array of objects into JSON. Otherwise, if you call the
:meth:`to_json` method on each object in the list and then try to
dump the array, you end up with an array with one string."""... | [
"def",
"to_dictionary",
"(",
"self",
")",
":",
"j",
"=",
"{",
"}",
"j",
"[",
"'interval'",
"]",
"=",
"{",
"'start'",
":",
"self",
".",
"start",
".",
"isoformat",
"(",
")",
",",
"'end'",
":",
"self",
".",
"end",
".",
"isoformat",
"(",
")",
"}",
... | Serialize an object into dictionary form. Useful if you have to
serialize an array of objects into JSON. Otherwise, if you call the
:meth:`to_json` method on each object in the list and then try to
dump the array, you end up with an array with one string. | [
"Serialize",
"an",
"object",
"into",
"dictionary",
"form",
".",
"Useful",
"if",
"you",
"have",
"to",
"serialize",
"an",
"array",
"of",
"objects",
"into",
"JSON",
".",
"Otherwise",
"if",
"you",
"call",
"the",
":",
"meth",
":",
"to_json",
"method",
"on",
"... | python | train |
gem/oq-engine | openquake/engine/engine.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/engine.py#L294-L373 | def run_calc(job_id, oqparam, exports, hazard_calculation_id=None, **kw):
"""
Run a calculation.
:param job_id:
ID of the current job
:param oqparam:
:class:`openquake.commonlib.oqvalidation.OqParam` instance
:param exports:
A comma-separated string of export types.
"""
... | [
"def",
"run_calc",
"(",
"job_id",
",",
"oqparam",
",",
"exports",
",",
"hazard_calculation_id",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"setproctitle",
"(",
"'oq-job-%d'",
"%",
"job_id",
")",
"calc",
"=",
"base",
".",
"calculators",
"(",
"oqparam",
"... | Run a calculation.
:param job_id:
ID of the current job
:param oqparam:
:class:`openquake.commonlib.oqvalidation.OqParam` instance
:param exports:
A comma-separated string of export types. | [
"Run",
"a",
"calculation",
"."
] | python | train |
nutechsoftware/alarmdecoder | alarmdecoder/event/event.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/event/event.py#L37-L45 | def _getfunctionlist(self):
"""(internal use) """
try:
eventhandler = self.obj.__eventhandler__
except AttributeError:
eventhandler = self.obj.__eventhandler__ = {}
return eventhandler.setdefault(self.event, []) | [
"def",
"_getfunctionlist",
"(",
"self",
")",
":",
"try",
":",
"eventhandler",
"=",
"self",
".",
"obj",
".",
"__eventhandler__",
"except",
"AttributeError",
":",
"eventhandler",
"=",
"self",
".",
"obj",
".",
"__eventhandler__",
"=",
"{",
"}",
"return",
"event... | (internal use) | [
"(",
"internal",
"use",
")"
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavextra.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavextra.py#L520-L526 | def rate_of_turn(speed, bank):
'''return expected rate of turn in degrees/s for given speed in m/s and
bank angle in degrees'''
if abs(speed) < 2 or abs(bank) > 80:
return 0
ret = degrees(9.81*tan(radians(bank))/speed)
return ret | [
"def",
"rate_of_turn",
"(",
"speed",
",",
"bank",
")",
":",
"if",
"abs",
"(",
"speed",
")",
"<",
"2",
"or",
"abs",
"(",
"bank",
")",
">",
"80",
":",
"return",
"0",
"ret",
"=",
"degrees",
"(",
"9.81",
"*",
"tan",
"(",
"radians",
"(",
"bank",
")"... | return expected rate of turn in degrees/s for given speed in m/s and
bank angle in degrees | [
"return",
"expected",
"rate",
"of",
"turn",
"in",
"degrees",
"/",
"s",
"for",
"given",
"speed",
"in",
"m",
"/",
"s",
"and",
"bank",
"angle",
"in",
"degrees"
] | python | train |
jedie/DragonPy | PyDC/PyDC/utils.py | https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L654-L670 | def get_word(byte_iterator):
"""
return a uint16 value
>>> g=iter([0x1e, 0x12])
>>> v=get_word(g)
>>> v
7698
>>> hex(v)
'0x1e12'
"""
byte_values = list(itertools.islice(byte_iterator, 2))
try:
word = (byte_values[0] << 8) | byte_values[1]
except TypeError, err:
... | [
"def",
"get_word",
"(",
"byte_iterator",
")",
":",
"byte_values",
"=",
"list",
"(",
"itertools",
".",
"islice",
"(",
"byte_iterator",
",",
"2",
")",
")",
"try",
":",
"word",
"=",
"(",
"byte_values",
"[",
"0",
"]",
"<<",
"8",
")",
"|",
"byte_values",
... | return a uint16 value
>>> g=iter([0x1e, 0x12])
>>> v=get_word(g)
>>> v
7698
>>> hex(v)
'0x1e12' | [
"return",
"a",
"uint16",
"value"
] | python | train |
tableau/document-api-python | tableaudocumentapi/connection.py | https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L71-L83 | def server(self, value):
"""
Set the connection's server property.
Args:
value: New server. String.
Returns:
Nothing.
"""
self._server = value
self._connectionXML.set('server', value) | [
"def",
"server",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_server",
"=",
"value",
"self",
".",
"_connectionXML",
".",
"set",
"(",
"'server'",
",",
"value",
")"
] | Set the connection's server property.
Args:
value: New server. String.
Returns:
Nothing. | [
"Set",
"the",
"connection",
"s",
"server",
"property",
"."
] | python | train |
bpannier/simpletr64 | simpletr64/devicetr64.py | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L270-L297 | def getSCDPURL(self, serviceType, default=None):
"""Returns the SCDP (Service Control Protocol Document) URL for a given service type.
When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this
method returns for a given service type/namespace th... | [
"def",
"getSCDPURL",
"(",
"self",
",",
"serviceType",
",",
"default",
"=",
"None",
")",
":",
"if",
"serviceType",
"in",
"self",
".",
"__deviceServiceDefinitions",
".",
"keys",
"(",
")",
":",
"return",
"self",
".",
"__deviceServiceDefinitions",
"[",
"serviceTyp... | Returns the SCDP (Service Control Protocol Document) URL for a given service type.
When the device definitions have been loaded with :meth:`~simpletr64.DeviceTR64.loadDeviceDefinitions` this
method returns for a given service type/namespace the associated URL to the SCDP. If the device definitions
... | [
"Returns",
"the",
"SCDP",
"(",
"Service",
"Control",
"Protocol",
"Document",
")",
"URL",
"for",
"a",
"given",
"service",
"type",
"."
] | python | train |
opennode/waldur-core | waldur_core/core/monkeypatch.py | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/monkeypatch.py#L14-L21 | def subfield_get(self, obj, type=None):
"""
Verbatim copy from:
https://github.com/django/django/blob/1.9.13/django/db/models/fields/subclassing.py#L38
"""
if obj is None:
return self
return obj.__dict__[self.field.name] | [
"def",
"subfield_get",
"(",
"self",
",",
"obj",
",",
"type",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"self",
"return",
"obj",
".",
"__dict__",
"[",
"self",
".",
"field",
".",
"name",
"]"
] | Verbatim copy from:
https://github.com/django/django/blob/1.9.13/django/db/models/fields/subclassing.py#L38 | [
"Verbatim",
"copy",
"from",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"django",
"/",
"django",
"/",
"blob",
"/",
"1",
".",
"9",
".",
"13",
"/",
"django",
"/",
"db",
"/",
"models",
"/",
"fields",
"/",
"subclassing",
".",
"py#L38"
] | python | train |
molmod/molmod | molmod/ic.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L747-L751 | def _opbend_angle_low(a, b, c, deriv=0):
"""Similar to opbend_angle, but with relative vectors"""
result = _opbend_cos_low(a, b, c, deriv)
sign = np.sign(np.linalg.det([a, b, c]))
return _cos_to_angle(result, deriv, sign) | [
"def",
"_opbend_angle_low",
"(",
"a",
",",
"b",
",",
"c",
",",
"deriv",
"=",
"0",
")",
":",
"result",
"=",
"_opbend_cos_low",
"(",
"a",
",",
"b",
",",
"c",
",",
"deriv",
")",
"sign",
"=",
"np",
".",
"sign",
"(",
"np",
".",
"linalg",
".",
"det",... | Similar to opbend_angle, but with relative vectors | [
"Similar",
"to",
"opbend_angle",
"but",
"with",
"relative",
"vectors"
] | python | train |
aws/sagemaker-python-sdk | src/sagemaker/estimator.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/estimator.py#L523-L531 | def get_vpc_config(self, vpc_config_override=vpc_utils.VPC_CONFIG_DEFAULT):
"""
Returns VpcConfig dict either from this Estimator's subnets and security groups,
or else validate and return an optional override value.
"""
if vpc_config_override is vpc_utils.VPC_CONFIG_DEFAULT:
... | [
"def",
"get_vpc_config",
"(",
"self",
",",
"vpc_config_override",
"=",
"vpc_utils",
".",
"VPC_CONFIG_DEFAULT",
")",
":",
"if",
"vpc_config_override",
"is",
"vpc_utils",
".",
"VPC_CONFIG_DEFAULT",
":",
"return",
"vpc_utils",
".",
"to_dict",
"(",
"self",
".",
"subne... | Returns VpcConfig dict either from this Estimator's subnets and security groups,
or else validate and return an optional override value. | [
"Returns",
"VpcConfig",
"dict",
"either",
"from",
"this",
"Estimator",
"s",
"subnets",
"and",
"security",
"groups",
"or",
"else",
"validate",
"and",
"return",
"an",
"optional",
"override",
"value",
"."
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/rietbrock_2013.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L122-L139 | def _get_distance_segment_coefficients(self, rval):
"""
Returns the coefficients describing the distance attenuation shape
for three different distance bins, equations 12a - 12c
"""
# Get distance segment ends
nsites = len(rval)
# Equation 12a
f_0 = np.log... | [
"def",
"_get_distance_segment_coefficients",
"(",
"self",
",",
"rval",
")",
":",
"# Get distance segment ends",
"nsites",
"=",
"len",
"(",
"rval",
")",
"# Equation 12a",
"f_0",
"=",
"np",
".",
"log10",
"(",
"self",
".",
"CONSTS",
"[",
"\"r0\"",
"]",
"/",
"rv... | Returns the coefficients describing the distance attenuation shape
for three different distance bins, equations 12a - 12c | [
"Returns",
"the",
"coefficients",
"describing",
"the",
"distance",
"attenuation",
"shape",
"for",
"three",
"different",
"distance",
"bins",
"equations",
"12a",
"-",
"12c"
] | python | train |
FactoryBoy/factory_boy | factory/declarations.py | https://github.com/FactoryBoy/factory_boy/blob/edaa7c7f5a14065b229927903bd7989cc93cd069/factory/declarations.py#L100-L126 | def deepgetattr(obj, name, default=_UNSPECIFIED):
"""Try to retrieve the given attribute of an object, digging on '.'.
This is an extended getattr, digging deeper if '.' is found.
Args:
obj (object): the object of which an attribute should be read
name (str): the name of an attribute to lo... | [
"def",
"deepgetattr",
"(",
"obj",
",",
"name",
",",
"default",
"=",
"_UNSPECIFIED",
")",
":",
"try",
":",
"if",
"'.'",
"in",
"name",
":",
"attr",
",",
"subname",
"=",
"name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"return",
"deepgetattr",
"(",
"g... | Try to retrieve the given attribute of an object, digging on '.'.
This is an extended getattr, digging deeper if '.' is found.
Args:
obj (object): the object of which an attribute should be read
name (str): the name of an attribute to look up.
default (object): the default value to use... | [
"Try",
"to",
"retrieve",
"the",
"given",
"attribute",
"of",
"an",
"object",
"digging",
"on",
".",
"."
] | python | train |
pymoca/pymoca | src/pymoca/backends/xml/sim_scipy.py | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/sim_scipy.py#L16-L188 | def sim(model: HybridOde, options: Dict = None, # noqa: too-complex
user_callback=None) -> Dict[str, np.array]:
"""
Simulates a Dae model.
:model: The model to simulate
:options: See opt dict below
:user_callback: A routine to call after each integration step,
f(t, x, y, m, p, c) -> ... | [
"def",
"sim",
"(",
"model",
":",
"HybridOde",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"# noqa: too-complex",
"user_callback",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"np",
".",
"array",
"]",
":",
"if",
"model",
".",
"f_x_rhs",
".",
"s... | Simulates a Dae model.
:model: The model to simulate
:options: See opt dict below
:user_callback: A routine to call after each integration step,
f(t, x, y, m, p, c) -> ret (ret < 0 means abort) | [
"Simulates",
"a",
"Dae",
"model",
"."
] | python | train |
Opentrons/opentrons | api/src/opentrons/deck_calibration/endpoints.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/deck_calibration/endpoints.py#L470-L504 | async def save_transform(data):
"""
Calculate the transormation matrix that calibrates the gantry to the deck
:param data: Information obtained from a POST request.
The content type is application/json.
The correct packet form should be as follows:
{
'token': UUID token from current sessio... | [
"async",
"def",
"save_transform",
"(",
"data",
")",
":",
"if",
"any",
"(",
"[",
"v",
"is",
"None",
"for",
"v",
"in",
"session",
".",
"points",
".",
"values",
"(",
")",
"]",
")",
":",
"message",
"=",
"\"Not all points have been saved\"",
"status",
"=",
... | Calculate the transormation matrix that calibrates the gantry to the deck
:param data: Information obtained from a POST request.
The content type is application/json.
The correct packet form should be as follows:
{
'token': UUID token from current session start
'command': 'save transform'
... | [
"Calculate",
"the",
"transormation",
"matrix",
"that",
"calibrates",
"the",
"gantry",
"to",
"the",
"deck",
":",
"param",
"data",
":",
"Information",
"obtained",
"from",
"a",
"POST",
"request",
".",
"The",
"content",
"type",
"is",
"application",
"/",
"json",
... | python | train |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L1049-L1075 | def com_google_fonts_check_has_ttfautohint_params(ttFont):
""" Font has ttfautohint params? """
from fontbakery.utils import get_name_entry_strings
def ttfautohint_version(value):
# example string:
#'Version 1.000; ttfautohint (v0.93) -l 8 -r 50 -G 200 -x 14 -w "G"
import re
results = re.search(r... | [
"def",
"com_google_fonts_check_has_ttfautohint_params",
"(",
"ttFont",
")",
":",
"from",
"fontbakery",
".",
"utils",
"import",
"get_name_entry_strings",
"def",
"ttfautohint_version",
"(",
"value",
")",
":",
"# example string:",
"#'Version 1.000; ttfautohint (v0.93) -l 8 -r 50 -... | Font has ttfautohint params? | [
"Font",
"has",
"ttfautohint",
"params?"
] | python | train |
pyrapt/rapt | rapt/treebrd/grammars/core_grammar.py | https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/grammars/core_grammar.py#L143-L148 | def statement(self):
"""
A terminated relational algebra statement.
"""
return (self.assignment ^ self.expression) + Suppress(
self.syntax.terminator) | [
"def",
"statement",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"assignment",
"^",
"self",
".",
"expression",
")",
"+",
"Suppress",
"(",
"self",
".",
"syntax",
".",
"terminator",
")"
] | A terminated relational algebra statement. | [
"A",
"terminated",
"relational",
"algebra",
"statement",
"."
] | python | train |
aacanakin/glim | glim/core.py | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/core.py#L56-L68 | def set(self, key, value):
"""
Function deeply sets the key with "." notation
Args
----
key (string): A key with the "." notation.
value (unknown type): A dict or a primitive type.
"""
target = self.registrar
for element in key.split('.')[:-1]... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"target",
"=",
"self",
".",
"registrar",
"for",
"element",
"in",
"key",
".",
"split",
"(",
"'.'",
")",
"[",
":",
"-",
"1",
"]",
":",
"target",
"=",
"target",
".",
"setdefault",
"(",
... | Function deeply sets the key with "." notation
Args
----
key (string): A key with the "." notation.
value (unknown type): A dict or a primitive type. | [
"Function",
"deeply",
"sets",
"the",
"key",
"with",
".",
"notation"
] | python | train |
bimbar/pykwb | pykwb/kwb.py | https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L412-L416 | def run_thread(self):
"""Run the main thread."""
self._run_thread = True
self._thread.setDaemon(True)
self._thread.start() | [
"def",
"run_thread",
"(",
"self",
")",
":",
"self",
".",
"_run_thread",
"=",
"True",
"self",
".",
"_thread",
".",
"setDaemon",
"(",
"True",
")",
"self",
".",
"_thread",
".",
"start",
"(",
")"
] | Run the main thread. | [
"Run",
"the",
"main",
"thread",
"."
] | python | train |
joferkington/mplstereonet | examples/fault_slip_plot.py | https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/examples/fault_slip_plot.py#L35-L52 | def fault_and_striae_plot(ax, strikes, dips, rakes):
"""Makes a fault-and-striae plot (a.k.a. "Ball of String") for normal faults
with the given strikes, dips, and rakes."""
# Plot the planes
lines = ax.plane(strikes, dips, 'k-', lw=0.5)
# Calculate the position of the rake of the lineations, but d... | [
"def",
"fault_and_striae_plot",
"(",
"ax",
",",
"strikes",
",",
"dips",
",",
"rakes",
")",
":",
"# Plot the planes",
"lines",
"=",
"ax",
".",
"plane",
"(",
"strikes",
",",
"dips",
",",
"'k-'",
",",
"lw",
"=",
"0.5",
")",
"# Calculate the position of the rake... | Makes a fault-and-striae plot (a.k.a. "Ball of String") for normal faults
with the given strikes, dips, and rakes. | [
"Makes",
"a",
"fault",
"-",
"and",
"-",
"striae",
"plot",
"(",
"a",
".",
"k",
".",
"a",
".",
"Ball",
"of",
"String",
")",
"for",
"normal",
"faults",
"with",
"the",
"given",
"strikes",
"dips",
"and",
"rakes",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L1036-L1048 | def get_vmpolicy_macaddr_output_vmpolicy_macaddr_dvpg_nn(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr")
config = get_vmpolicy_macaddr
output = ET.SubElement(get_vmpolicy_macaddr, "output"... | [
"def",
"get_vmpolicy_macaddr_output_vmpolicy_macaddr_dvpg_nn",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_vmpolicy_macaddr",
"=",
"ET",
".",
"Element",
"(",
"\"get_vmpolicy_macaddr\"",
")",
"co... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
brainiak/brainiak | brainiak/reprsimil/brsa.py | https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/reprsimil/brsa.py#L584-L794 | def fit(self, X, design, nuisance=None, scan_onsets=None, coords=None,
inten=None):
"""Compute the Bayesian RSA
Parameters
----------
X: numpy array, shape=[time_points, voxels]
If you have multiple scans of the same participants that you
want to anal... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"design",
",",
"nuisance",
"=",
"None",
",",
"scan_onsets",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"inten",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"'Running Bayesian RSA'",
")",
"self",
"."... | Compute the Bayesian RSA
Parameters
----------
X: numpy array, shape=[time_points, voxels]
If you have multiple scans of the same participants that you
want to analyze together, you should concatenate them along
the time dimension after proper preprocessing (... | [
"Compute",
"the",
"Bayesian",
"RSA"
] | python | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L186-L192 | def find_actions(namespace, action_prefix):
"""Find all the actions in the namespace."""
actions = {}
for key, value in iteritems(namespace):
if key.startswith(action_prefix):
actions[key[len(action_prefix):]] = analyse_action(value)
return actions | [
"def",
"find_actions",
"(",
"namespace",
",",
"action_prefix",
")",
":",
"actions",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"namespace",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"action_prefix",
")",
":",
"actions",
"[",
... | Find all the actions in the namespace. | [
"Find",
"all",
"the",
"actions",
"in",
"the",
"namespace",
"."
] | python | train |
biocore/burrito-fillings | bfillings/mafft_v7.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/mafft_v7.py#L204-L225 | def _input_as_seqs(self, data):
"""Format a list of seq as input.
Parameters
----------
data: list of strings
Each string is a sequence to be aligned.
Returns
-------
A temp file name that contains the sequences.
See Also
--------
... | [
"def",
"_input_as_seqs",
"(",
"self",
",",
"data",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"i",
",",
"s",
"in",
"enumerate",
"(",
"data",
")",
":",
"# will number the sequences 1,2,3,etc.",
"lines",
".",
"append",
"(",
"''",
".",
"join",
"(",
"[",
"'>... | Format a list of seq as input.
Parameters
----------
data: list of strings
Each string is a sequence to be aligned.
Returns
-------
A temp file name that contains the sequences.
See Also
--------
burrito.util.CommandLineApplication | [
"Format",
"a",
"list",
"of",
"seq",
"as",
"input",
"."
] | python | train |
spyder-ide/spyder | spyder/preferences/configdialog.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L749-L791 | def create_fontgroup(self, option=None, text=None, title=None,
tip=None, fontfilters=None, without_group=False):
"""Option=None -> setting plugin font"""
if title:
fontlabel = QLabel(title)
else:
fontlabel = QLabel(_("Font"))
font... | [
"def",
"create_fontgroup",
"(",
"self",
",",
"option",
"=",
"None",
",",
"text",
"=",
"None",
",",
"title",
"=",
"None",
",",
"tip",
"=",
"None",
",",
"fontfilters",
"=",
"None",
",",
"without_group",
"=",
"False",
")",
":",
"if",
"title",
":",
"font... | Option=None -> setting plugin font | [
"Option",
"=",
"None",
"-",
">",
"setting",
"plugin",
"font"
] | python | train |
MakerReduxCorp/PLOD | PLOD/__init__.py | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/__init__.py#L251-L278 | def insert(self, new_entry):
'''Insert a new entry to the end of the list of dictionaries.
This entry retains the original index tracking but adds this
entry incrementally at the end.
>>> test = [
... {"name": "Jim", "age": 18, "income": 93000, "wigs": 68 },
... | [
"def",
"insert",
"(",
"self",
",",
"new_entry",
")",
":",
"self",
".",
"index_track",
".",
"append",
"(",
"len",
"(",
"self",
".",
"table",
")",
")",
"self",
".",
"table",
".",
"append",
"(",
"new_entry",
")",
"return",
"self"
] | Insert a new entry to the end of the list of dictionaries.
This entry retains the original index tracking but adds this
entry incrementally at the end.
>>> test = [
... {"name": "Jim", "age": 18, "income": 93000, "wigs": 68 },
... {"name": "Larry", "age": 18, ... | [
"Insert",
"a",
"new",
"entry",
"to",
"the",
"end",
"of",
"the",
"list",
"of",
"dictionaries",
"."
] | python | train |
Robpol86/sphinxcontrib-versioning | sphinxcontrib/versioning/sphinx_.py | https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/sphinx_.py#L172-L204 | def _build(argv, config, versions, current_name, is_root):
"""Build Sphinx docs via multiprocessing for isolation.
:param tuple argv: Arguments to pass to Sphinx.
:param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
:param sphinxcontrib.versioning.versions.Versions versions: Versio... | [
"def",
"_build",
"(",
"argv",
",",
"config",
",",
"versions",
",",
"current_name",
",",
"is_root",
")",
":",
"# Patch.",
"application",
".",
"Config",
"=",
"ConfigInject",
"if",
"config",
".",
"show_banner",
":",
"EventHandlers",
".",
"BANNER_GREATEST_TAG",
"=... | Build Sphinx docs via multiprocessing for isolation.
:param tuple argv: Arguments to pass to Sphinx.
:param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
:param sphinxcontrib.versioning.versions.Versions versions: Versions class instance.
:param str current_name: The ref name of th... | [
"Build",
"Sphinx",
"docs",
"via",
"multiprocessing",
"for",
"isolation",
"."
] | python | train |
lexibank/pylexibank | src/pylexibank/cldf.py | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/cldf.py#L106-L147 | def add_lexemes(self, **kw):
"""
:return: list of dicts corresponding to newly created Lexemes
"""
lexemes = []
# Do we have morpheme segmentation on top of phonemes?
with_morphemes = '+' in self['FormTable', 'Segments'].separator
for i, form in enumerate(self.d... | [
"def",
"add_lexemes",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"lexemes",
"=",
"[",
"]",
"# Do we have morpheme segmentation on top of phonemes?",
"with_morphemes",
"=",
"'+'",
"in",
"self",
"[",
"'FormTable'",
",",
"'Segments'",
"]",
".",
"separator",
"for",... | :return: list of dicts corresponding to newly created Lexemes | [
":",
"return",
":",
"list",
"of",
"dicts",
"corresponding",
"to",
"newly",
"created",
"Lexemes"
] | python | train |
ToFuProject/tofu | tofu/data/_core.py | https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1431-L1543 | def select_ch(self, val=None, key=None, log='any', touch=None, out=bool):
""" Return a channels index array
Return a boolean or integer index array, hereafter called 'ind'
The array refers to the reference channel/'X' vector self.ddataRef['X']
There are 3 different ways of selecting ch... | [
"def",
"select_ch",
"(",
"self",
",",
"val",
"=",
"None",
",",
"key",
"=",
"None",
",",
"log",
"=",
"'any'",
",",
"touch",
"=",
"None",
",",
"out",
"=",
"bool",
")",
":",
"assert",
"out",
"in",
"[",
"int",
",",
"bool",
"]",
"assert",
"log",
"in... | Return a channels index array
Return a boolean or integer index array, hereafter called 'ind'
The array refers to the reference channel/'X' vector self.ddataRef['X']
There are 3 different ways of selecting channels, by refering to:
- The 'X' vector/array values in self.dataRef['X']... | [
"Return",
"a",
"channels",
"index",
"array"
] | python | train |
tensorpack/tensorpack | tensorpack/utils/concurrency.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/utils/concurrency.py#L68-L74 | def queue_get_stoppable(self, q):
""" Take obj from queue, but will give up when the thread is stopped"""
while not self.stopped():
try:
return q.get(timeout=5)
except queue.Empty:
pass | [
"def",
"queue_get_stoppable",
"(",
"self",
",",
"q",
")",
":",
"while",
"not",
"self",
".",
"stopped",
"(",
")",
":",
"try",
":",
"return",
"q",
".",
"get",
"(",
"timeout",
"=",
"5",
")",
"except",
"queue",
".",
"Empty",
":",
"pass"
] | Take obj from queue, but will give up when the thread is stopped | [
"Take",
"obj",
"from",
"queue",
"but",
"will",
"give",
"up",
"when",
"the",
"thread",
"is",
"stopped"
] | python | train |
bulkan/robotframework-requests | src/RequestsLibrary/RequestsKeywords.py | https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L550-L607 | def post_request(
self,
alias,
uri,
data=None,
json=None,
params=None,
headers=None,
files=None,
allow_redirects=None,
timeout=None):
""" Send a POST request on the session object found using ... | [
"def",
"post_request",
"(",
"self",
",",
"alias",
",",
"uri",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"files",
"=",
"None",
",",
"allow_redirects",
"=",
"None",
",",
"timeout",... | Send a POST request on the session object found using the
given `alias`
``alias`` that will be used to identify the Session object in the cache
``uri`` to send the POST request to
``data`` a dictionary of key-value pairs that will be urlencoded
and sent as POST data
... | [
"Send",
"a",
"POST",
"request",
"on",
"the",
"session",
"object",
"found",
"using",
"the",
"given",
"alias"
] | python | train |
dbrattli/OSlash | oslash/observable.py | https://github.com/dbrattli/OSlash/blob/ffdc714c5d454f7519f740254de89f70850929eb/oslash/observable.py#L39-L45 | def map(self, mapper: Callable[[Any], Any]) -> 'Observable':
r"""Map a function over an observable.
Haskell: fmap f m = Cont $ \c -> runCont m (c . f)
"""
source = self
return Observable(lambda on_next: source.subscribe(compose(on_next, mapper))) | [
"def",
"map",
"(",
"self",
",",
"mapper",
":",
"Callable",
"[",
"[",
"Any",
"]",
",",
"Any",
"]",
")",
"->",
"'Observable'",
":",
"source",
"=",
"self",
"return",
"Observable",
"(",
"lambda",
"on_next",
":",
"source",
".",
"subscribe",
"(",
"compose",
... | r"""Map a function over an observable.
Haskell: fmap f m = Cont $ \c -> runCont m (c . f) | [
"r",
"Map",
"a",
"function",
"over",
"an",
"observable",
"."
] | python | train |
saltstack/salt | salt/cloud/clouds/gce.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L645-L701 | def delete_network(kwargs=None, call=None):
'''
Permanently delete a network.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_network gce name=mynet
'''
if call != 'function':
raise SaltCloudSystemExit(
'The delete_network function must be called with -f or ... | [
"def",
"delete_network",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The delete_network function must be called with -f or --function.'",
")",
"if",
"not",
"kwargs",
"o... | Permanently delete a network.
CLI Example:
.. code-block:: bash
salt-cloud -f delete_network gce name=mynet | [
"Permanently",
"delete",
"a",
"network",
"."
] | python | train |
aleju/imgaug | imgaug/augmentables/polys.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/polys.py#L836-L890 | def exterior_almost_equals(self, other, max_distance=1e-6, points_per_edge=8):
"""
Estimate if this and other polygon's exterior are almost identical.
The two exteriors can have different numbers of points, but any point
randomly sampled on the exterior of one polygon should be close to... | [
"def",
"exterior_almost_equals",
"(",
"self",
",",
"other",
",",
"max_distance",
"=",
"1e-6",
",",
"points_per_edge",
"=",
"8",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"list",
")",
":",
"other",
"=",
"Polygon",
"(",
"np",
".",
"float32",
"(",
... | Estimate if this and other polygon's exterior are almost identical.
The two exteriors can have different numbers of points, but any point
randomly sampled on the exterior of one polygon should be close to the
closest point on the exterior of the other polygon.
Note that this method wor... | [
"Estimate",
"if",
"this",
"and",
"other",
"polygon",
"s",
"exterior",
"are",
"almost",
"identical",
"."
] | python | valid |
materialsproject/pymatgen | pymatgen/phonon/plotter.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/phonon/plotter.py#L116-L191 | def get_plot(self, xlim=None, ylim=None, units="thz"):
"""
Get a matplotlib plot showing the DOS.
Args:
xlim: Specifies the x-axis limits. Set to None for automatic
determination.
ylim: Specifies the y-axis limits.
units: units for the frequen... | [
"def",
"get_plot",
"(",
"self",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"units",
"=",
"\"thz\"",
")",
":",
"u",
"=",
"freq_units",
"(",
"units",
")",
"ncolors",
"=",
"max",
"(",
"3",
",",
"len",
"(",
"self",
".",
"_doses",
")",
... | Get a matplotlib plot showing the DOS.
Args:
xlim: Specifies the x-axis limits. Set to None for automatic
determination.
ylim: Specifies the y-axis limits.
units: units for the frequencies. Accepted values thz, ev, mev, ha, cm-1, cm^-1. | [
"Get",
"a",
"matplotlib",
"plot",
"showing",
"the",
"DOS",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/utils/hparam.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L482-L504 | def parse(self, values):
"""Override existing hyperparameter values, parsing new values from a string.
See parse_values for more detail on the allowed format for values.
Args:
values: String. Comma separated list of `name=value` pairs where 'value'
must follow the syntax described above.
... | [
"def",
"parse",
"(",
"self",
",",
"values",
")",
":",
"type_map",
"=",
"{",
"}",
"for",
"name",
",",
"t",
"in",
"self",
".",
"_hparam_types",
".",
"items",
"(",
")",
":",
"param_type",
",",
"_",
"=",
"t",
"type_map",
"[",
"name",
"]",
"=",
"param... | Override existing hyperparameter values, parsing new values from a string.
See parse_values for more detail on the allowed format for values.
Args:
values: String. Comma separated list of `name=value` pairs where 'value'
must follow the syntax described above.
Returns:
The `HParams` ... | [
"Override",
"existing",
"hyperparameter",
"values",
"parsing",
"new",
"values",
"from",
"a",
"string",
"."
] | python | train |
chrippa/python-librtmp | librtmp/rtmp.py | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L242-L271 | def read_packet(self):
"""Reads a RTMP packet from the server.
Returns a :class:`RTMPPacket`.
Raises :exc:`RTMPError` on error.
Raises :exc:`RTMPTimeoutError` on timeout.
Usage::
>>> packet = conn.read_packet()
>>> packet.body
b'packet body ...'
... | [
"def",
"read_packet",
"(",
"self",
")",
":",
"packet",
"=",
"ffi",
".",
"new",
"(",
"\"RTMPPacket*\"",
")",
"packet_complete",
"=",
"False",
"while",
"not",
"packet_complete",
":",
"res",
"=",
"librtmp",
".",
"RTMP_ReadPacket",
"(",
"self",
".",
"rtmp",
",... | Reads a RTMP packet from the server.
Returns a :class:`RTMPPacket`.
Raises :exc:`RTMPError` on error.
Raises :exc:`RTMPTimeoutError` on timeout.
Usage::
>>> packet = conn.read_packet()
>>> packet.body
b'packet body ...' | [
"Reads",
"a",
"RTMP",
"packet",
"from",
"the",
"server",
"."
] | python | train |
yougov/mongo-connector | mongo_connector/connector.py | https://github.com/yougov/mongo-connector/blob/557cafd4b54c848cd54ef28a258391a154650cb4/mongo_connector/connector.py#L272-L314 | def read_oplog_progress(self):
"""Reads oplog progress from file provided by user.
This method is only called once before any threads are spanwed.
"""
if self.oplog_checkpoint is None:
return None
# Check for empty file
try:
if os.stat(self.oplog... | [
"def",
"read_oplog_progress",
"(",
"self",
")",
":",
"if",
"self",
".",
"oplog_checkpoint",
"is",
"None",
":",
"return",
"None",
"# Check for empty file",
"try",
":",
"if",
"os",
".",
"stat",
"(",
"self",
".",
"oplog_checkpoint",
")",
".",
"st_size",
"==",
... | Reads oplog progress from file provided by user.
This method is only called once before any threads are spanwed. | [
"Reads",
"oplog",
"progress",
"from",
"file",
"provided",
"by",
"user",
".",
"This",
"method",
"is",
"only",
"called",
"once",
"before",
"any",
"threads",
"are",
"spanwed",
"."
] | python | train |
petl-developers/petl | petl/io/whoosh.py | https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/io/whoosh.py#L257-L334 | def searchtextindex(index_or_dirname, query, limit=10, indexname=None,
docnum_field=None, score_field=None, fieldboosts=None,
search_kwargs=None):
"""
Search a Whoosh index using a query. E.g.::
>>> import petl as etl
>>> import os
>>> # set up an... | [
"def",
"searchtextindex",
"(",
"index_or_dirname",
",",
"query",
",",
"limit",
"=",
"10",
",",
"indexname",
"=",
"None",
",",
"docnum_field",
"=",
"None",
",",
"score_field",
"=",
"None",
",",
"fieldboosts",
"=",
"None",
",",
"search_kwargs",
"=",
"None",
... | Search a Whoosh index using a query. E.g.::
>>> import petl as etl
>>> import os
>>> # set up an index and load some documents via the Whoosh API
... from whoosh.index import create_in
>>> from whoosh.fields import *
>>> schema = Schema(title=TEXT(stored=True), path=ID(s... | [
"Search",
"a",
"Whoosh",
"index",
"using",
"a",
"query",
".",
"E",
".",
"g",
".",
"::"
] | python | train |
tensorflow/cleverhans | cleverhans/utils_pytorch.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils_pytorch.py#L41-L94 | def convert_pytorch_model_to_tf(model, out_dims=None):
"""
Convert a pytorch model into a tensorflow op that allows backprop
:param model: A pytorch nn.Module object
:param out_dims: The number of output dimensions (classes) for the model
:return: A model function that maps an input (tf.Tensor) to the
outpu... | [
"def",
"convert_pytorch_model_to_tf",
"(",
"model",
",",
"out_dims",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"\"convert_pytorch_model_to_tf is deprecated, switch to\"",
"+",
"\" dedicated PyTorch support provided by CleverHans v4.\"",
")",
"torch_state",
"=",
"{"... | Convert a pytorch model into a tensorflow op that allows backprop
:param model: A pytorch nn.Module object
:param out_dims: The number of output dimensions (classes) for the model
:return: A model function that maps an input (tf.Tensor) to the
output of the model (tf.Tensor) | [
"Convert",
"a",
"pytorch",
"model",
"into",
"a",
"tensorflow",
"op",
"that",
"allows",
"backprop",
":",
"param",
"model",
":",
"A",
"pytorch",
"nn",
".",
"Module",
"object",
":",
"param",
"out_dims",
":",
"The",
"number",
"of",
"output",
"dimensions",
"(",... | python | train |
pandas-dev/pandas | pandas/io/formats/style.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/style.py#L883-L931 | def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0,
subset=None, text_color_threshold=0.408):
"""
Color the background in a gradient according to
the data in each column (optionally row).
Requires matplotlib.
Parameters
--------... | [
"def",
"background_gradient",
"(",
"self",
",",
"cmap",
"=",
"'PuBu'",
",",
"low",
"=",
"0",
",",
"high",
"=",
"0",
",",
"axis",
"=",
"0",
",",
"subset",
"=",
"None",
",",
"text_color_threshold",
"=",
"0.408",
")",
":",
"subset",
"=",
"_maybe_numeric_s... | Color the background in a gradient according to
the data in each column (optionally row).
Requires matplotlib.
Parameters
----------
cmap : str or colormap
matplotlib colormap
low, high : float
compress the range by these values.
axis : {... | [
"Color",
"the",
"background",
"in",
"a",
"gradient",
"according",
"to",
"the",
"data",
"in",
"each",
"column",
"(",
"optionally",
"row",
")",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/analysis/elasticity/elastic.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/elasticity/elastic.py#L65-L79 | def calculate_stress(self, strain):
"""
Calculate's a given elastic tensor's contribution to the
stress using Einstein summation
Args:
strain (3x3 array-like): matrix corresponding to strain
"""
strain = np.array(strain)
if strain.shape == (6,):
... | [
"def",
"calculate_stress",
"(",
"self",
",",
"strain",
")",
":",
"strain",
"=",
"np",
".",
"array",
"(",
"strain",
")",
"if",
"strain",
".",
"shape",
"==",
"(",
"6",
",",
")",
":",
"strain",
"=",
"Strain",
".",
"from_voigt",
"(",
"strain",
")",
"as... | Calculate's a given elastic tensor's contribution to the
stress using Einstein summation
Args:
strain (3x3 array-like): matrix corresponding to strain | [
"Calculate",
"s",
"a",
"given",
"elastic",
"tensor",
"s",
"contribution",
"to",
"the",
"stress",
"using",
"Einstein",
"summation"
] | python | train |
pytroll/satpy | satpy/readers/aapp_l1b.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/aapp_l1b.py#L158-L191 | def get_angles(self, angle_id):
"""Get sun-satellite viewing angles"""
tic = datetime.now()
sunz40km = self._data["ang"][:, :, 0] * 1e-2
satz40km = self._data["ang"][:, :, 1] * 1e-2
azidiff40km = self._data["ang"][:, :, 2] * 1e-2
try:
from geotiepoints.inte... | [
"def",
"get_angles",
"(",
"self",
",",
"angle_id",
")",
":",
"tic",
"=",
"datetime",
".",
"now",
"(",
")",
"sunz40km",
"=",
"self",
".",
"_data",
"[",
"\"ang\"",
"]",
"[",
":",
",",
":",
",",
"0",
"]",
"*",
"1e-2",
"satz40km",
"=",
"self",
".",
... | Get sun-satellite viewing angles | [
"Get",
"sun",
"-",
"satellite",
"viewing",
"angles"
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/utils/_process_posix.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/_process_posix.py#L119-L187 | def system(self, cmd):
"""Execute a command in a subshell.
Parameters
----------
cmd : str
A command to be executed in the system shell.
Returns
-------
int : child's exitstatus
"""
# Get likely encoding for the output.
enc = DE... | [
"def",
"system",
"(",
"self",
",",
"cmd",
")",
":",
"# Get likely encoding for the output.",
"enc",
"=",
"DEFAULT_ENCODING",
"# Patterns to match on the output, for pexpect. We read input and",
"# allow either a short timeout or EOF",
"patterns",
"=",
"[",
"pexpect",
".",
"TIM... | Execute a command in a subshell.
Parameters
----------
cmd : str
A command to be executed in the system shell.
Returns
-------
int : child's exitstatus | [
"Execute",
"a",
"command",
"in",
"a",
"subshell",
"."
] | python | test |
fkarb/xltable | xltable/worksheet.py | https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/worksheet.py#L189-L278 | def _get_all_styles(self):
"""
return a dictionary of {(row, col) -> CellStyle}
for all cells that use a non-default style.
"""
_styles = {}
def _get_style(bold=False, bg_col=None, border=None):
if (bold, bg_col, border) not in _styles:
_styles... | [
"def",
"_get_all_styles",
"(",
"self",
")",
":",
"_styles",
"=",
"{",
"}",
"def",
"_get_style",
"(",
"bold",
"=",
"False",
",",
"bg_col",
"=",
"None",
",",
"border",
"=",
"None",
")",
":",
"if",
"(",
"bold",
",",
"bg_col",
",",
"border",
")",
"not"... | return a dictionary of {(row, col) -> CellStyle}
for all cells that use a non-default style. | [
"return",
"a",
"dictionary",
"of",
"{",
"(",
"row",
"col",
")",
"-",
">",
"CellStyle",
"}",
"for",
"all",
"cells",
"that",
"use",
"a",
"non",
"-",
"default",
"style",
"."
] | python | train |
idlesign/steampak | steampak/webapi/resources/apps.py | https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/webapi/resources/apps.py#L21-L37 | def get_filter_cardborder(*cardborder_type):
"""Returns game cards URL filter for a given cardborder
type (TAG_CARDBORDER_NORMAL / TAG_CARDBORDER_FOIL).
To be used in URL_GAMECARDS.
:param str|unicode cardborder_type:
:rtype: str|unicode
"""
filter_ = []
for type_ in cardborder_type:
... | [
"def",
"get_filter_cardborder",
"(",
"*",
"cardborder_type",
")",
":",
"filter_",
"=",
"[",
"]",
"for",
"type_",
"in",
"cardborder_type",
":",
"if",
"not",
"type_",
":",
"continue",
"filter_",
".",
"append",
"(",
"'category_'",
"+",
"APPID_CARDS",
"+",
"'_ca... | Returns game cards URL filter for a given cardborder
type (TAG_CARDBORDER_NORMAL / TAG_CARDBORDER_FOIL).
To be used in URL_GAMECARDS.
:param str|unicode cardborder_type:
:rtype: str|unicode | [
"Returns",
"game",
"cards",
"URL",
"filter",
"for",
"a",
"given",
"cardborder",
"type",
"(",
"TAG_CARDBORDER_NORMAL",
"/",
"TAG_CARDBORDER_FOIL",
")",
"."
] | python | train |
Cog-Creators/Red-Lavalink | lavalink/player_manager.py | https://github.com/Cog-Creators/Red-Lavalink/blob/5b3fc6eb31ee5db8bd2b633a523cf69749957111/lavalink/player_manager.py#L120-L132 | async def move_to(self, channel: discord.VoiceChannel):
"""
Moves this player to a voice channel.
Parameters
----------
channel : discord.VoiceChannel
"""
if channel.guild != self.channel.guild:
raise TypeError("Cannot move to a different guild.")
... | [
"async",
"def",
"move_to",
"(",
"self",
",",
"channel",
":",
"discord",
".",
"VoiceChannel",
")",
":",
"if",
"channel",
".",
"guild",
"!=",
"self",
".",
"channel",
".",
"guild",
":",
"raise",
"TypeError",
"(",
"\"Cannot move to a different guild.\"",
")",
"s... | Moves this player to a voice channel.
Parameters
----------
channel : discord.VoiceChannel | [
"Moves",
"this",
"player",
"to",
"a",
"voice",
"channel",
"."
] | python | train |
scanny/python-pptx | pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/shapes/connector.py#L88-L96 | def begin_y(self):
"""
Return the Y-position of the begin point of this connector, in
English Metric Units (as a |Length| object).
"""
cxnSp = self._element
y, cy, flipV = cxnSp.y, cxnSp.cy, cxnSp.flipV
begin_y = y+cy if flipV else y
return Emu(begin_y) | [
"def",
"begin_y",
"(",
"self",
")",
":",
"cxnSp",
"=",
"self",
".",
"_element",
"y",
",",
"cy",
",",
"flipV",
"=",
"cxnSp",
".",
"y",
",",
"cxnSp",
".",
"cy",
",",
"cxnSp",
".",
"flipV",
"begin_y",
"=",
"y",
"+",
"cy",
"if",
"flipV",
"else",
"y... | Return the Y-position of the begin point of this connector, in
English Metric Units (as a |Length| object). | [
"Return",
"the",
"Y",
"-",
"position",
"of",
"the",
"begin",
"point",
"of",
"this",
"connector",
"in",
"English",
"Metric",
"Units",
"(",
"as",
"a",
"|Length|",
"object",
")",
"."
] | python | train |
data-8/datascience | datascience/maps.py | https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/maps.py#L89-L97 | def copy(self):
"""
Copies the current Map into a new one and returns it.
"""
m = Map(features=self._features, width=self._width,
height=self._height, **self._attrs)
m._folium_map = self._folium_map
return m | [
"def",
"copy",
"(",
"self",
")",
":",
"m",
"=",
"Map",
"(",
"features",
"=",
"self",
".",
"_features",
",",
"width",
"=",
"self",
".",
"_width",
",",
"height",
"=",
"self",
".",
"_height",
",",
"*",
"*",
"self",
".",
"_attrs",
")",
"m",
".",
"_... | Copies the current Map into a new one and returns it. | [
"Copies",
"the",
"current",
"Map",
"into",
"a",
"new",
"one",
"and",
"returns",
"it",
"."
] | python | train |
pgmpy/pgmpy | pgmpy/readwrite/ProbModelXML.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/ProbModelXML.py#L160-L183 | def write_probmodelxml(model, path, encoding='utf-8', prettyprint=True):
"""
Write model in ProbModelXML format to path.
Parameters
----------
model : A NetworkX graph
Bayesian network or Markov network
path : file or string
File or filename to write.
Filenam... | [
"def",
"write_probmodelxml",
"(",
"model",
",",
"path",
",",
"encoding",
"=",
"'utf-8'",
",",
"prettyprint",
"=",
"True",
")",
":",
"writer",
"=",
"ProbModelXMLWriter",
"(",
"model",
",",
"path",
",",
"encoding",
"=",
"encoding",
",",
"prettyprint",
"=",
"... | Write model in ProbModelXML format to path.
Parameters
----------
model : A NetworkX graph
Bayesian network or Markov network
path : file or string
File or filename to write.
Filenames ending in .gz or .bz2 will be compressed.
encoding : string (optional)
... | [
"Write",
"model",
"in",
"ProbModelXML",
"format",
"to",
"path",
"."
] | python | train |
quantopian/zipline | zipline/data/resample.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/resample.py#L69-L100 | def minute_to_session(column, close_locs, data, out):
"""
Resample an array with minute data into an array with session data.
This function assumes that the minute data is the exact length of all
minutes in the sessions in the output.
Parameters
----------
column : str
The `open`, ... | [
"def",
"minute_to_session",
"(",
"column",
",",
"close_locs",
",",
"data",
",",
"out",
")",
":",
"if",
"column",
"==",
"'open'",
":",
"_minute_to_session_open",
"(",
"close_locs",
",",
"data",
",",
"out",
")",
"elif",
"column",
"==",
"'high'",
":",
"_minut... | Resample an array with minute data into an array with session data.
This function assumes that the minute data is the exact length of all
minutes in the sessions in the output.
Parameters
----------
column : str
The `open`, `high`, `low`, `close`, or `volume` column.
close_locs : array... | [
"Resample",
"an",
"array",
"with",
"minute",
"data",
"into",
"an",
"array",
"with",
"session",
"data",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/type/schema.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/type/schema.py#L264-L276 | def type_map_directive_reducer(
map_: TypeMap, directive: GraphQLDirective = None
) -> TypeMap:
"""Reducer function for creating the type map from given directives."""
# Directives are not validated until validate_schema() is called.
if not is_directive(directive):
return map_
directive = ca... | [
"def",
"type_map_directive_reducer",
"(",
"map_",
":",
"TypeMap",
",",
"directive",
":",
"GraphQLDirective",
"=",
"None",
")",
"->",
"TypeMap",
":",
"# Directives are not validated until validate_schema() is called.",
"if",
"not",
"is_directive",
"(",
"directive",
")",
... | Reducer function for creating the type map from given directives. | [
"Reducer",
"function",
"for",
"creating",
"the",
"type",
"map",
"from",
"given",
"directives",
"."
] | python | train |
brainiak/brainiak | brainiak/funcalign/srm.py | https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/funcalign/srm.py#L235-L266 | def transform(self, X, y=None):
"""Use the model to transform matrix to Shared Response space
Parameters
----------
X : list of 2D arrays, element i has shape=[voxels_i, samples_i]
Each element in the list contains the fMRI data of one subject
note that number of... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"# Check if the model exist",
"if",
"hasattr",
"(",
"self",
",",
"'w_'",
")",
"is",
"False",
":",
"raise",
"NotFittedError",
"(",
"\"The model fit has not been run yet.\"",
")",
"# Che... | Use the model to transform matrix to Shared Response space
Parameters
----------
X : list of 2D arrays, element i has shape=[voxels_i, samples_i]
Each element in the list contains the fMRI data of one subject
note that number of voxels and samples can vary across subject... | [
"Use",
"the",
"model",
"to",
"transform",
"matrix",
"to",
"Shared",
"Response",
"space"
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/geometry/calculations.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/calculations.py#L16-L50 | def _fast_cross_3d(x, y):
"""Compute cross product between list of 3D vectors
Much faster than np.cross() when the number of cross products
becomes large (>500). This is because np.cross() methods become
less memory efficient at this stage.
Parameters
----------
x : array
Input arr... | [
"def",
"_fast_cross_3d",
"(",
"x",
",",
"y",
")",
":",
"assert",
"x",
".",
"ndim",
"==",
"2",
"assert",
"y",
".",
"ndim",
"==",
"2",
"assert",
"x",
".",
"shape",
"[",
"1",
"]",
"==",
"3",
"assert",
"y",
".",
"shape",
"[",
"1",
"]",
"==",
"3",... | Compute cross product between list of 3D vectors
Much faster than np.cross() when the number of cross products
becomes large (>500). This is because np.cross() methods become
less memory efficient at this stage.
Parameters
----------
x : array
Input array 1.
y : array
Input... | [
"Compute",
"cross",
"product",
"between",
"list",
"of",
"3D",
"vectors"
] | python | train |
xtuml/pyxtuml | bridgepoint/ooaofooa.py | https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/ooaofooa.py#L567-L573 | def load_component(resource, name=None, load_globals=True):
'''
Load and return a model from a *resource*. The resource may be either a
filename, a path, or a list of filenames and/or paths.
'''
loader = _mk_loader(resource, load_globals)
return loader.build_component() | [
"def",
"load_component",
"(",
"resource",
",",
"name",
"=",
"None",
",",
"load_globals",
"=",
"True",
")",
":",
"loader",
"=",
"_mk_loader",
"(",
"resource",
",",
"load_globals",
")",
"return",
"loader",
".",
"build_component",
"(",
")"
] | Load and return a model from a *resource*. The resource may be either a
filename, a path, or a list of filenames and/or paths. | [
"Load",
"and",
"return",
"a",
"model",
"from",
"a",
"*",
"resource",
"*",
".",
"The",
"resource",
"may",
"be",
"either",
"a",
"filename",
"a",
"path",
"or",
"a",
"list",
"of",
"filenames",
"and",
"/",
"or",
"paths",
"."
] | python | test |
veltzer/pypitools | pypitools/scripts/upload.py | https://github.com/veltzer/pypitools/blob/5f097be21e9bc65578eed5b6b7855c1945540701/pypitools/scripts/upload.py#L32-L42 | def main():
"""
upload a package to pypi or gemfury
:return:
"""
setup_main()
config = ConfigData(clean=True)
try:
config.upload()
finally:
config.clean_after_if_needed() | [
"def",
"main",
"(",
")",
":",
"setup_main",
"(",
")",
"config",
"=",
"ConfigData",
"(",
"clean",
"=",
"True",
")",
"try",
":",
"config",
".",
"upload",
"(",
")",
"finally",
":",
"config",
".",
"clean_after_if_needed",
"(",
")"
] | upload a package to pypi or gemfury
:return: | [
"upload",
"a",
"package",
"to",
"pypi",
"or",
"gemfury",
":",
"return",
":"
] | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L488-L509 | def check_account_api_key(self, account_id, api_key, **kwargs): # noqa: E501
"""Check the API key. # noqa: E501
An endpoint for checking API key. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/api-keys/{apiKey} -H 'Authorization: Bearer API_KEY'` # noq... | [
"def",
"check_account_api_key",
"(",
"self",
",",
"account_id",
",",
"api_key",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'asynchronous'",
")",
":",
"retu... | Check the API key. # noqa: E501
An endpoint for checking API key. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/api-keys/{apiKey} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
... | [
"Check",
"the",
"API",
"key",
".",
"#",
"noqa",
":",
"E501"
] | python | train |
pecan/pecan | pecan/core.py | https://github.com/pecan/pecan/blob/833d0653fa0e6bbfb52545b091c30182105f4a82/pecan/core.py#L427-L552 | def find_controller(self, state):
'''
The main request handler for Pecan applications.
'''
# get a sorted list of hooks, by priority (no controller hooks yet)
req = state.request
pecan_state = req.pecan
# store the routing path for the current application to allo... | [
"def",
"find_controller",
"(",
"self",
",",
"state",
")",
":",
"# get a sorted list of hooks, by priority (no controller hooks yet)",
"req",
"=",
"state",
".",
"request",
"pecan_state",
"=",
"req",
".",
"pecan",
"# store the routing path for the current application to allow hoo... | The main request handler for Pecan applications. | [
"The",
"main",
"request",
"handler",
"for",
"Pecan",
"applications",
"."
] | python | train |
ajk8/hatchery | hatchery/executor.py | https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/executor.py#L66-L85 | def call(cmd_args, suppress_output=False):
""" Call an arbitary command and return the exit value, stdout, and stderr as a tuple
Command can be passed in as either a string or iterable
>>> result = call('hatchery', suppress_output=True)
>>> result.exitval
0
>>> result = call(['hatchery', 'notr... | [
"def",
"call",
"(",
"cmd_args",
",",
"suppress_output",
"=",
"False",
")",
":",
"if",
"not",
"funcy",
".",
"is_list",
"(",
"cmd_args",
")",
"and",
"not",
"funcy",
".",
"is_tuple",
"(",
"cmd_args",
")",
":",
"cmd_args",
"=",
"shlex",
".",
"split",
"(",
... | Call an arbitary command and return the exit value, stdout, and stderr as a tuple
Command can be passed in as either a string or iterable
>>> result = call('hatchery', suppress_output=True)
>>> result.exitval
0
>>> result = call(['hatchery', 'notreal'])
>>> result.exitval
1 | [
"Call",
"an",
"arbitary",
"command",
"and",
"return",
"the",
"exit",
"value",
"stdout",
"and",
"stderr",
"as",
"a",
"tuple"
] | python | train |
saltstack/salt | salt/modules/nftables.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nftables.py#L370-L426 | def get_rule_handle(table='filter', chain=None, rule=None, family='ipv4'):
'''
Get the handle for a particular rule
This function accepts a rule in a standard nftables command format,
starting with the chain. Trying to force users to adapt to a new
method of creating rules would be irritati... | [
"def",
"get_rule_handle",
"(",
"table",
"=",
"'filter'",
",",
"chain",
"=",
"None",
",",
"rule",
"=",
"None",
",",
"family",
"=",
"'ipv4'",
")",
":",
"ret",
"=",
"{",
"'comment'",
":",
"''",
",",
"'result'",
":",
"False",
"}",
"if",
"not",
"chain",
... | Get the handle for a particular rule
This function accepts a rule in a standard nftables command format,
starting with the chain. Trying to force users to adapt to a new
method of creating rules would be irritating at best, and we
already have a parser that can handle it.
CLI Example:
... | [
"Get",
"the",
"handle",
"for",
"a",
"particular",
"rule"
] | python | train |
evocell/rabifier | rabifier/rabmyfire.py | https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/rabmyfire.py#L73-L88 | def has_rabf_motif(self):
"""Checks if the sequence has enough RabF motifs within the G domain
If there exists more than one G domain in the sequence enough RabF motifs is required in at least one
of those domains to classify the sequence as a Rab.
"""
if self.rabf_motifs:
... | [
"def",
"has_rabf_motif",
"(",
"self",
")",
":",
"if",
"self",
".",
"rabf_motifs",
":",
"for",
"gdomain",
"in",
"self",
".",
"gdomain_regions",
":",
"beg",
",",
"end",
"=",
"map",
"(",
"int",
",",
"gdomain",
".",
"split",
"(",
"'-'",
")",
")",
"motifs... | Checks if the sequence has enough RabF motifs within the G domain
If there exists more than one G domain in the sequence enough RabF motifs is required in at least one
of those domains to classify the sequence as a Rab. | [
"Checks",
"if",
"the",
"sequence",
"has",
"enough",
"RabF",
"motifs",
"within",
"the",
"G",
"domain"
] | python | train |
pandas-dev/pandas | pandas/core/arrays/categorical.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L942-L983 | def reorder_categories(self, new_categories, ordered=None, inplace=False):
"""
Reorder categories as specified in new_categories.
`new_categories` need to include all old categories and no new category
items.
Parameters
----------
new_categories : Index-like
... | [
"def",
"reorder_categories",
"(",
"self",
",",
"new_categories",
",",
"ordered",
"=",
"None",
",",
"inplace",
"=",
"False",
")",
":",
"inplace",
"=",
"validate_bool_kwarg",
"(",
"inplace",
",",
"'inplace'",
")",
"if",
"set",
"(",
"self",
".",
"dtype",
".",... | Reorder categories as specified in new_categories.
`new_categories` need to include all old categories and no new category
items.
Parameters
----------
new_categories : Index-like
The categories in new order.
ordered : bool, optional
Whether or not... | [
"Reorder",
"categories",
"as",
"specified",
"in",
"new_categories",
"."
] | python | train |
crytic/slither | slither/detectors/reentrancy/reentrancy.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/reentrancy/reentrancy.py#L95-L179 | def _explore(self, node, visited, skip_father=None):
"""
Explore the CFG and look for re-entrancy
Heuristic: There is a re-entrancy if a state variable is written
after an external call
node.context will contains the external calls executed
... | [
"def",
"_explore",
"(",
"self",
",",
"node",
",",
"visited",
",",
"skip_father",
"=",
"None",
")",
":",
"if",
"node",
"in",
"visited",
":",
"return",
"visited",
"=",
"visited",
"+",
"[",
"node",
"]",
"# First we add the external calls executed in previous nodes"... | Explore the CFG and look for re-entrancy
Heuristic: There is a re-entrancy if a state variable is written
after an external call
node.context will contains the external calls executed
It contains the calls executed in father nodes
if node.context... | [
"Explore",
"the",
"CFG",
"and",
"look",
"for",
"re",
"-",
"entrancy",
"Heuristic",
":",
"There",
"is",
"a",
"re",
"-",
"entrancy",
"if",
"a",
"state",
"variable",
"is",
"written",
"after",
"an",
"external",
"call"
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L4680-L4688 | def getOverlayColor(self, ulOverlayHandle):
"""Gets the color tint of the overlay quad."""
fn = self.function_table.getOverlayColor
pfRed = c_float()
pfGreen = c_float()
pfBlue = c_float()
result = fn(ulOverlayHandle, byref(pfRed), byref(pfGreen), byref(pfBlue))
... | [
"def",
"getOverlayColor",
"(",
"self",
",",
"ulOverlayHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOverlayColor",
"pfRed",
"=",
"c_float",
"(",
")",
"pfGreen",
"=",
"c_float",
"(",
")",
"pfBlue",
"=",
"c_float",
"(",
")",
"result",... | Gets the color tint of the overlay quad. | [
"Gets",
"the",
"color",
"tint",
"of",
"the",
"overlay",
"quad",
"."
] | python | train |
cloud-custodian/cloud-custodian | c7n/log.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/log.py#L100-L121 | def emit(self, message):
"""Send logs"""
# We're sending messages asynchronously, bubble to caller when
# we've detected an error on the message. This isn't great,
# but options once we've gone async without a deferred/promise
# aren't great.
if self.transport and self.tr... | [
"def",
"emit",
"(",
"self",
",",
"message",
")",
":",
"# We're sending messages asynchronously, bubble to caller when",
"# we've detected an error on the message. This isn't great,",
"# but options once we've gone async without a deferred/promise",
"# aren't great.",
"if",
"self",
".",
... | Send logs | [
"Send",
"logs"
] | python | train |
mitsei/dlkit | dlkit/handcar/repository/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/objects.py#L580-L598 | def set_public_domain(self, public_domain=None):
"""Sets the public domain flag.
:param public_domain: the public domain status
:type public_domain: ``boolean``
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implement... | [
"def",
"set_public_domain",
"(",
"self",
",",
"public_domain",
"=",
"None",
")",
":",
"if",
"public_domain",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"metadata",
"=",
"Metadata",
"(",
"*",
"*",
"settings",
".",
"METADATA",
"[",
"'public_domain'"... | Sets the public domain flag.
:param public_domain: the public domain status
:type public_domain: ``boolean``
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"public",
"domain",
"flag",
"."
] | python | train |
dbcli/cli_helpers | cli_helpers/tabular_output/output_formatter.py | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L156-L159 | def _get_column_types(self, data):
"""Get a list of the data types for each column in *data*."""
columns = list(zip_longest(*data))
return [self._get_column_type(column) for column in columns] | [
"def",
"_get_column_types",
"(",
"self",
",",
"data",
")",
":",
"columns",
"=",
"list",
"(",
"zip_longest",
"(",
"*",
"data",
")",
")",
"return",
"[",
"self",
".",
"_get_column_type",
"(",
"column",
")",
"for",
"column",
"in",
"columns",
"]"
] | Get a list of the data types for each column in *data*. | [
"Get",
"a",
"list",
"of",
"the",
"data",
"types",
"for",
"each",
"column",
"in",
"*",
"data",
"*",
"."
] | python | test |
PmagPy/PmagPy | programs/fishrot.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/fishrot.py#L8-L63 | def main():
"""
NAME
fishrot.py
DESCRIPTION
generates set of Fisher distributed data from specified distribution
SYNTAX
fishrot.py [-h][-i][command line options]
OPTIONS
-h prints help message and quits
-i for interactive entry
-k kappa specify ka... | [
"def",
"main",
"(",
")",
":",
"N",
",",
"kappa",
",",
"D",
",",
"I",
"=",
"100",
",",
"20.",
",",
"0.",
",",
"90.",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"!=",
"0",
"and",
"'-h'",
"in",
"sys",
".",
"argv",
":",
"print",
"(",
"main",
... | NAME
fishrot.py
DESCRIPTION
generates set of Fisher distributed data from specified distribution
SYNTAX
fishrot.py [-h][-i][command line options]
OPTIONS
-h prints help message and quits
-i for interactive entry
-k kappa specify kappa, default is 20
... | [
"NAME",
"fishrot",
".",
"py"
] | python | train |
mickbad/mblibs | mblibs/fast.py | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L529-L531 | def debug(self, text):
""" Ajout d'un message de log de type DEBUG """
self.logger.debug("{}{}".format(self.message_prefix, text)) | [
"def",
"debug",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type DEBUG | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"DEBUG"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.