repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
econ-ark/HARK | HARK/cAndCwithStickyE/StickyEtools.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/cAndCwithStickyE/StickyEtools.py#L46-L196 | def makeStickyEdataFile(Economy,ignore_periods,description='',filename=None,save_data=False,calc_micro_stats=True,meas_err_base=None):
'''
Makes descriptive statistics and macroeconomic data file. Behaves slightly
differently for heterogeneous agents vs representative agent models.
Parameters
-----... | [
"def",
"makeStickyEdataFile",
"(",
"Economy",
",",
"ignore_periods",
",",
"description",
"=",
"''",
",",
"filename",
"=",
"None",
",",
"save_data",
"=",
"False",
",",
"calc_micro_stats",
"=",
"True",
",",
"meas_err_base",
"=",
"None",
")",
":",
"# Extract time... | Makes descriptive statistics and macroeconomic data file. Behaves slightly
differently for heterogeneous agents vs representative agent models.
Parameters
----------
Economy : Market or AgentType
A representation of the model economy. For heterogeneous agents specifications,
this will ... | [
"Makes",
"descriptive",
"statistics",
"and",
"macroeconomic",
"data",
"file",
".",
"Behaves",
"slightly",
"differently",
"for",
"heterogeneous",
"agents",
"vs",
"representative",
"agent",
"models",
"."
] | python | train | 61.695364 |
portfors-lab/sparkle | sparkle/gui/stim/dynamic_stacker.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/dynamic_stacker.py#L7-L16 | def widgetForName(self, name):
"""Gets a widget with *name*
:param name: the widgets in this container should all have
a name() method. This is the string to match to that result
:type name: str
"""
for iwidget in range(len(self)):
if self.widget(iwidget).na... | [
"def",
"widgetForName",
"(",
"self",
",",
"name",
")",
":",
"for",
"iwidget",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"if",
"self",
".",
"widget",
"(",
"iwidget",
")",
".",
"name",
"(",
")",
"==",
"name",
":",
"return",
"self",
"."... | Gets a widget with *name*
:param name: the widgets in this container should all have
a name() method. This is the string to match to that result
:type name: str | [
"Gets",
"a",
"widget",
"with",
"*",
"name",
"*"
] | python | train | 36.8 |
newville/wxmplot | examples/floatcontrol.py | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/floatcontrol.py#L135-L149 | def SetValue(self, value=None, act=True):
" main method to set value "
if value is None:
value = wx.TextCtrl.GetValue(self).strip()
self.__CheckValid(value)
self.__GetMark()
if value is not None:
wx.TextCtrl.SetValue(self, self.format % set_float(value))
... | [
"def",
"SetValue",
"(",
"self",
",",
"value",
"=",
"None",
",",
"act",
"=",
"True",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"wx",
".",
"TextCtrl",
".",
"GetValue",
"(",
"self",
")",
".",
"strip",
"(",
")",
"self",
".",
"__CheckV... | main method to set value | [
"main",
"method",
"to",
"set",
"value"
] | python | train | 35.133333 |
juju/charm-helpers | charmhelpers/contrib/hahelpers/cluster.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hahelpers/cluster.py#L189-L195 | def peer_ips(peer_relation='cluster', addr_key='private-address'):
'''Return a dict of peers and their private-address'''
peers = {}
for r_id in relation_ids(peer_relation):
for unit in relation_list(r_id):
peers[unit] = relation_get(addr_key, rid=r_id, unit=unit)
return peers | [
"def",
"peer_ips",
"(",
"peer_relation",
"=",
"'cluster'",
",",
"addr_key",
"=",
"'private-address'",
")",
":",
"peers",
"=",
"{",
"}",
"for",
"r_id",
"in",
"relation_ids",
"(",
"peer_relation",
")",
":",
"for",
"unit",
"in",
"relation_list",
"(",
"r_id",
... | Return a dict of peers and their private-address | [
"Return",
"a",
"dict",
"of",
"peers",
"and",
"their",
"private",
"-",
"address"
] | python | train | 43.857143 |
ScienceLogic/amiuploader | amiimporter/amiupload.py | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/amiupload.py#L69-L77 | def vmdk_to_ami(args):
"""
Calls methods to perform vmdk import
:param args:
:return:
"""
aws_importer = AWSUtilities.AWSUtils(args.directory, args.aws_profile, args.s3_bucket,
args.aws_regions, args.ami_name, args.vmdk_upload_file)
aws_importer.impor... | [
"def",
"vmdk_to_ami",
"(",
"args",
")",
":",
"aws_importer",
"=",
"AWSUtilities",
".",
"AWSUtils",
"(",
"args",
".",
"directory",
",",
"args",
".",
"aws_profile",
",",
"args",
".",
"s3_bucket",
",",
"args",
".",
"aws_regions",
",",
"args",
".",
"ami_name",... | Calls methods to perform vmdk import
:param args:
:return: | [
"Calls",
"methods",
"to",
"perform",
"vmdk",
"import",
":",
"param",
"args",
":",
":",
"return",
":"
] | python | train | 35.555556 |
NORDUnet/python-norduniclient | norduniclient/core.py | https://github.com/NORDUnet/python-norduniclient/blob/ee5084a6f45caac614b4fda4a023749ca52f786c/norduniclient/core.py#L655-L671 | def create_relationship(manager, handle_id, other_handle_id, rel_type):
"""
Makes a relationship from node to other_node depending on which
meta_type the nodes are. Returns the relationship or raises
NoRelationshipPossible exception.
"""
meta_type = get_node_meta_type(manager, handle_id)
if ... | [
"def",
"create_relationship",
"(",
"manager",
",",
"handle_id",
",",
"other_handle_id",
",",
"rel_type",
")",
":",
"meta_type",
"=",
"get_node_meta_type",
"(",
"manager",
",",
"handle_id",
")",
"if",
"meta_type",
"==",
"'Location'",
":",
"return",
"create_location... | Makes a relationship from node to other_node depending on which
meta_type the nodes are. Returns the relationship or raises
NoRelationshipPossible exception. | [
"Makes",
"a",
"relationship",
"from",
"node",
"to",
"other_node",
"depending",
"on",
"which",
"meta_type",
"the",
"nodes",
"are",
".",
"Returns",
"the",
"relationship",
"or",
"raises",
"NoRelationshipPossible",
"exception",
"."
] | python | train | 57 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L724-L779 | def isLoggedOn(rh, userid):
"""
Determine whether a virtual machine is logged on.
Input:
Request Handle:
userid being queried
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - 0: if we got... | [
"def",
"isLoggedOn",
"(",
"rh",
",",
"userid",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.isLoggedOn, userid: \"",
"+",
"userid",
")",
"results",
"=",
"{",
"'overallRC'",
":",
"0",
",",
"'rc'",
":",
"0",
",",
"'rs'",
":",
"0",
",",
"}",
... | Determine whether a virtual machine is logged on.
Input:
Request Handle:
userid being queried
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - 0: if we got status. Otherwise, it is the
... | [
"Determine",
"whether",
"a",
"virtual",
"machine",
"is",
"logged",
"on",
"."
] | python | train | 32.678571 |
cltl/KafNafParserPy | KafNafParserPy/KafNafParserMod.py | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/KafNafParserMod.py#L621-L629 | def get_properties(self):
"""
Returns all the properties of the features layer (iterator)
@rtype: L{Cproperty}
@return: list of properties
"""
if self.features_layer is not None:
for property in self.features_layer.get_properties():
yield prope... | [
"def",
"get_properties",
"(",
"self",
")",
":",
"if",
"self",
".",
"features_layer",
"is",
"not",
"None",
":",
"for",
"property",
"in",
"self",
".",
"features_layer",
".",
"get_properties",
"(",
")",
":",
"yield",
"propertyfound_entities",
".",
"get",
"(",
... | Returns all the properties of the features layer (iterator)
@rtype: L{Cproperty}
@return: list of properties | [
"Returns",
"all",
"the",
"properties",
"of",
"the",
"features",
"layer",
"(",
"iterator",
")"
] | python | train | 38.777778 |
tobiasfeistmantl/python-actioncable-zwei | actioncable/connection.py | https://github.com/tobiasfeistmantl/python-actioncable-zwei/blob/04876b4425a295485af8976acceb0b46d2ef1c8d/actioncable/connection.py#L149-L157 | def _on_close(self, socket):
"""
Called when the connection was closed.
"""
self.logger.debug('Connection closed.')
for subscription in self.subscriptions.values():
if subscription.state == 'subscribed':
subscription.state = 'connection_pending' | [
"def",
"_on_close",
"(",
"self",
",",
"socket",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Connection closed.'",
")",
"for",
"subscription",
"in",
"self",
".",
"subscriptions",
".",
"values",
"(",
")",
":",
"if",
"subscription",
".",
"state",
... | Called when the connection was closed. | [
"Called",
"when",
"the",
"connection",
"was",
"closed",
"."
] | python | train | 34 |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L82-L107 | def xmlparser(xml, objectify=True):
""" Parse xml
:param xml: XML element
:type xml: Union[text_type, lxml.etree._Element]
:rtype: lxml.etree._Element
:returns: An element object
:raises: TypeError if element is not in accepted type
"""
doclose = None
if isinstance(xml, (etree._Ele... | [
"def",
"xmlparser",
"(",
"xml",
",",
"objectify",
"=",
"True",
")",
":",
"doclose",
"=",
"None",
"if",
"isinstance",
"(",
"xml",
",",
"(",
"etree",
".",
"_Element",
",",
"ObjectifiedElement",
",",
"etree",
".",
"_ElementTree",
")",
")",
":",
"return",
... | Parse xml
:param xml: XML element
:type xml: Union[text_type, lxml.etree._Element]
:rtype: lxml.etree._Element
:returns: An element object
:raises: TypeError if element is not in accepted type | [
"Parse",
"xml"
] | python | train | 28.384615 |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L3545-L3589 | def software_breakpoint_set(self, addr, thumb=False, arm=False, flash=False, ram=False):
"""Sets a software breakpoint at the specified address.
If ``thumb`` is ``True``, the breakpoint is set in THUMB-mode, while if
``arm`` is ``True``, the breakpoint is set in ARM-mode, otherwise a
no... | [
"def",
"software_breakpoint_set",
"(",
"self",
",",
"addr",
",",
"thumb",
"=",
"False",
",",
"arm",
"=",
"False",
",",
"flash",
"=",
"False",
",",
"ram",
"=",
"False",
")",
":",
"if",
"flash",
"and",
"not",
"ram",
":",
"flags",
"=",
"enums",
".",
"... | Sets a software breakpoint at the specified address.
If ``thumb`` is ``True``, the breakpoint is set in THUMB-mode, while if
``arm`` is ``True``, the breakpoint is set in ARM-mode, otherwise a
normal breakpoint is set.
If ``flash`` is ``True``, the breakpoint is set in flash, otherwise... | [
"Sets",
"a",
"software",
"breakpoint",
"at",
"the",
"specified",
"address",
"."
] | python | train | 41.288889 |
jopohl/urh | src/urh/models/TableModel.py | https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/TableModel.py#L337-L373 | def find_differences(self, refindex: int):
"""
Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]]
"""
differences = defaultdict(set)
if refindex >= len(self.proto... | [
"def",
"find_differences",
"(",
"self",
",",
"refindex",
":",
"int",
")",
":",
"differences",
"=",
"defaultdict",
"(",
"set",
")",
"if",
"refindex",
">=",
"len",
"(",
"self",
".",
"protocol",
".",
"messages",
")",
":",
"return",
"differences",
"if",
"sel... | Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]] | [
"Search",
"all",
"differences",
"between",
"protocol",
"messages",
"regarding",
"a",
"reference",
"message"
] | python | train | 32.891892 |
crate/crate-python | src/crate/client/cursor.py | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/cursor.py#L43-L56 | def execute(self, sql, parameters=None, bulk_parameters=None):
"""
Prepare and execute a database operation (query or command).
"""
if self.connection._closed:
raise ProgrammingError("Connection closed")
if self._closed:
raise ProgrammingError("Cursor clo... | [
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"parameters",
"=",
"None",
",",
"bulk_parameters",
"=",
"None",
")",
":",
"if",
"self",
".",
"connection",
".",
"_closed",
":",
"raise",
"ProgrammingError",
"(",
"\"Connection closed\"",
")",
"if",
"self",
".... | Prepare and execute a database operation (query or command). | [
"Prepare",
"and",
"execute",
"a",
"database",
"operation",
"(",
"query",
"or",
"command",
")",
"."
] | python | train | 38.071429 |
inveniosoftware/invenio-records-files | invenio_records_files/api.py | https://github.com/inveniosoftware/invenio-records-files/blob/c410eba986ea43be7e97082d5dcbbdc19ccec39c/invenio_records_files/api.py#L180-L192 | def sort_by(self, *ids):
"""Update files order.
:param ids: List of ids specifying the final status of the list.
"""
# Support sorting by file_ids or keys.
files = {str(f_.file_id): f_.key for f_ in self}
# self.record['_files'] = [{'key': files.get(id_, id_)} for id_ in... | [
"def",
"sort_by",
"(",
"self",
",",
"*",
"ids",
")",
":",
"# Support sorting by file_ids or keys.",
"files",
"=",
"{",
"str",
"(",
"f_",
".",
"file_id",
")",
":",
"f_",
".",
"key",
"for",
"f_",
"in",
"self",
"}",
"# self.record['_files'] = [{'key': files.get(i... | Update files order.
:param ids: List of ids specifying the final status of the list. | [
"Update",
"files",
"order",
"."
] | python | train | 36.846154 |
sixty-north/cosmic-ray | plugins/execution-engines/celery4/cosmic_ray_celery4_engine/worker.py | https://github.com/sixty-north/cosmic-ray/blob/c654e074afbb7b7fcbc23359083c1287c0d3e991/plugins/execution-engines/celery4/cosmic_ray_celery4_engine/worker.py#L25-L48 | def worker_task(work_item, config):
"""The celery task which performs a single mutation and runs a test suite.
This runs `cosmic-ray worker` in a subprocess and returns the results,
passing `config` to it via stdin.
Args:
work_item: A dict describing a WorkItem.
config: The configurati... | [
"def",
"worker_task",
"(",
"work_item",
",",
"config",
")",
":",
"global",
"_workspace",
"_ensure_workspace",
"(",
"config",
")",
"result",
"=",
"worker",
"(",
"work_item",
".",
"module_path",
",",
"config",
".",
"python_version",
",",
"work_item",
".",
"opera... | The celery task which performs a single mutation and runs a test suite.
This runs `cosmic-ray worker` in a subprocess and returns the results,
passing `config` to it via stdin.
Args:
work_item: A dict describing a WorkItem.
config: The configuration to use for the test execution.
Retu... | [
"The",
"celery",
"task",
"which",
"performs",
"a",
"single",
"mutation",
"and",
"runs",
"a",
"test",
"suite",
"."
] | python | train | 27.541667 |
inspirehep/harvesting-kit | harvestingkit/inspire_cds_package/from_cds.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L111-L157 | def determine_collections(self):
"""Try to determine which collections this record should belong to."""
for value in record_get_field_values(self.record, '980', code='a'):
if 'NOTE' in value.upper():
self.collections.add('NOTE')
if 'THESIS' in value.upper():
... | [
"def",
"determine_collections",
"(",
"self",
")",
":",
"for",
"value",
"in",
"record_get_field_values",
"(",
"self",
".",
"record",
",",
"'980'",
",",
"code",
"=",
"'a'",
")",
":",
"if",
"'NOTE'",
"in",
"value",
".",
"upper",
"(",
")",
":",
"self",
"."... | Try to determine which collections this record should belong to. | [
"Try",
"to",
"determine",
"which",
"collections",
"this",
"record",
"should",
"belong",
"to",
"."
] | python | valid | 41 |
bloomberg/bqplot | bqplot/pyplot.py | https://github.com/bloomberg/bqplot/blob/8eb8b163abe9ee6306f6918067e2f36c1caef2ef/bqplot/pyplot.py#L743-L778 | def imshow(image, format, **kwargs):
"""Draw an image in the current context figure.
Parameters
----------
image: image data
Image data, depending on the passed format, can be one of:
- an instance of an ipywidgets Image
- a file name
- a raw byte string
f... | [
"def",
"imshow",
"(",
"image",
",",
"format",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"format",
"==",
"'widget'",
":",
"ipyimage",
"=",
"image",
"elif",
"format",
"==",
"'filename'",
":",
"with",
"open",
"(",
"image",
",",
"'rb'",
")",
"as",
"f",
... | Draw an image in the current context figure.
Parameters
----------
image: image data
Image data, depending on the passed format, can be one of:
- an instance of an ipywidgets Image
- a file name
- a raw byte string
format: {'widget', 'filename', ...}
T... | [
"Draw",
"an",
"image",
"in",
"the",
"current",
"context",
"figure",
".",
"Parameters",
"----------",
"image",
":",
"image",
"data",
"Image",
"data",
"depending",
"on",
"the",
"passed",
"format",
"can",
"be",
"one",
"of",
":",
"-",
"an",
"instance",
"of",
... | python | train | 37.916667 |
langloisjp/pysvcmetrics | statsdclient.py | https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L40-L48 | def gauge(self, stats, value):
"""
Log gauges
>>> client = StatsdClient()
>>> client.gauge('example.gauge', 47)
>>> client.gauge(('example.gauge41', 'example.gauge43'), 47)
"""
self.update_stats(stats, value, self.SC_GAUGE) | [
"def",
"gauge",
"(",
"self",
",",
"stats",
",",
"value",
")",
":",
"self",
".",
"update_stats",
"(",
"stats",
",",
"value",
",",
"self",
".",
"SC_GAUGE",
")"
] | Log gauges
>>> client = StatsdClient()
>>> client.gauge('example.gauge', 47)
>>> client.gauge(('example.gauge41', 'example.gauge43'), 47) | [
"Log",
"gauges"
] | python | train | 30.222222 |
MonashBI/arcana | arcana/repository/xnat.py | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L582-L592 | def convert_subject_ids(self, subject_ids):
"""
Convert subject ids to strings if they are integers
"""
# TODO: need to make this generalisable via a
# splitting+mapping function passed to the repository
if subject_ids is not None:
subject_ids = set(
... | [
"def",
"convert_subject_ids",
"(",
"self",
",",
"subject_ids",
")",
":",
"# TODO: need to make this generalisable via a",
"# splitting+mapping function passed to the repository",
"if",
"subject_ids",
"is",
"not",
"None",
":",
"subject_ids",
"=",
"set",
"(",
"(",
"'{:0... | Convert subject ids to strings if they are integers | [
"Convert",
"subject",
"ids",
"to",
"strings",
"if",
"they",
"are",
"integers"
] | python | train | 39.818182 |
Cito/DBUtils | DBUtils/SteadyPg.py | https://github.com/Cito/DBUtils/blob/90e8825e038f08c82044b8e50831480175fa026a/DBUtils/SteadyPg.py#L188-L207 | def reopen(self):
"""Reopen the tough connection.
It will not complain if the connection cannot be reopened.
"""
try:
self._con.reopen()
except Exception:
if self._transcation:
self._transaction = False
try:
... | [
"def",
"reopen",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_con",
".",
"reopen",
"(",
")",
"except",
"Exception",
":",
"if",
"self",
".",
"_transcation",
":",
"self",
".",
"_transaction",
"=",
"False",
"try",
":",
"self",
".",
"_con",
".",
"... | Reopen the tough connection.
It will not complain if the connection cannot be reopened. | [
"Reopen",
"the",
"tough",
"connection",
"."
] | python | train | 26.85 |
ssalentin/plip | plip/modules/mp.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/mp.py#L30-L32 | def pool_args(function, sequence, kwargs):
"""Return a single iterator of n elements of lists of length 3, given a sequence of len n."""
return zip(itertools.repeat(function), sequence, itertools.repeat(kwargs)) | [
"def",
"pool_args",
"(",
"function",
",",
"sequence",
",",
"kwargs",
")",
":",
"return",
"zip",
"(",
"itertools",
".",
"repeat",
"(",
"function",
")",
",",
"sequence",
",",
"itertools",
".",
"repeat",
"(",
"kwargs",
")",
")"
] | Return a single iterator of n elements of lists of length 3, given a sequence of len n. | [
"Return",
"a",
"single",
"iterator",
"of",
"n",
"elements",
"of",
"lists",
"of",
"length",
"3",
"given",
"a",
"sequence",
"of",
"len",
"n",
"."
] | python | train | 72.333333 |
tensorflow/mesh | mesh_tensorflow/transformer/utils.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L524-L712 | def run(tpu_job_name,
tpu,
gcp_project,
tpu_zone,
model_dir,
model_type="bitransformer",
vocabulary=gin.REQUIRED,
train_dataset_fn=None,
eval_dataset_fn=None,
dataset_split="train",
autostack=True,
checkpoint_path="",
mode="... | [
"def",
"run",
"(",
"tpu_job_name",
",",
"tpu",
",",
"gcp_project",
",",
"tpu_zone",
",",
"model_dir",
",",
"model_type",
"=",
"\"bitransformer\"",
",",
"vocabulary",
"=",
"gin",
".",
"REQUIRED",
",",
"train_dataset_fn",
"=",
"None",
",",
"eval_dataset_fn",
"="... | Run training/eval/inference.
Args:
tpu_job_name: string, name of TPU worker binary
tpu: string, the Cloud TPU to use for training
gcp_project: string, project name for the Cloud TPU-enabled project
tpu_zone: string, GCE zone where the Cloud TPU is located in
model_dir: string, estimator model_dir... | [
"Run",
"training",
"/",
"eval",
"/",
"inference",
"."
] | python | train | 37.15873 |
fabiobatalha/crossrefapi | crossref/restful.py | https://github.com/fabiobatalha/crossrefapi/blob/53f84ee0d8a8fc6ad9b2493f51c5151e66d2faf7/crossref/restful.py#L1811-L1839 | def request_doi_status_by_batch_id(self, doi_batch_id, data_type='result'):
"""
This method retrieve the DOI requests status.
file_name: Used as unique ID to identify a deposit.
data_type: [contents, result]
contents - retrieve the XML submited by the publisher
... | [
"def",
"request_doi_status_by_batch_id",
"(",
"self",
",",
"doi_batch_id",
",",
"data_type",
"=",
"'result'",
")",
":",
"endpoint",
"=",
"self",
".",
"get_endpoint",
"(",
"'submissionDownload'",
")",
"params",
"=",
"{",
"'usr'",
":",
"self",
".",
"api_user",
"... | This method retrieve the DOI requests status.
file_name: Used as unique ID to identify a deposit.
data_type: [contents, result]
contents - retrieve the XML submited by the publisher
result - retrieve a XML with the status of the submission | [
"This",
"method",
"retrieve",
"the",
"DOI",
"requests",
"status",
"."
] | python | train | 27.551724 |
JNRowe/upoints | upoints/gpx.py | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/gpx.py#L207-L217 | def range(self, location, distance):
"""Test whether locations are within a given range of ``location``.
Args:
location (Point): Location to test range against
distance (float): Distance to test location is within
Returns:
list of list of Point: Groups of po... | [
"def",
"range",
"(",
"self",
",",
"location",
",",
"distance",
")",
":",
"return",
"(",
"segment",
".",
"range",
"(",
"location",
",",
"distance",
")",
"for",
"segment",
"in",
"self",
")"
] | Test whether locations are within a given range of ``location``.
Args:
location (Point): Location to test range against
distance (float): Distance to test location is within
Returns:
list of list of Point: Groups of points in range per segment | [
"Test",
"whether",
"locations",
"are",
"within",
"a",
"given",
"range",
"of",
"location",
"."
] | python | train | 38 |
crm416/semantic | semantic/units.py | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/units.py#L125-L146 | def convert(self, inp):
"""Converts a string representation of some quantity of units into a
quantities object.
Args:
inp (str): A textual representation of some quantity of units,
e.g., "fifty kilograms".
Returns:
A quantities object representin... | [
"def",
"convert",
"(",
"self",
",",
"inp",
")",
":",
"inp",
"=",
"self",
".",
"_preprocess",
"(",
"inp",
")",
"n",
"=",
"NumberService",
"(",
")",
".",
"longestNumber",
"(",
"inp",
")",
"units",
"=",
"self",
".",
"extractUnits",
"(",
"inp",
")",
"#... | Converts a string representation of some quantity of units into a
quantities object.
Args:
inp (str): A textual representation of some quantity of units,
e.g., "fifty kilograms".
Returns:
A quantities object representing the described quantity and its
... | [
"Converts",
"a",
"string",
"representation",
"of",
"some",
"quantity",
"of",
"units",
"into",
"a",
"quantities",
"object",
"."
] | python | train | 29.681818 |
Asana/python-asana | asana/resources/gen/sections.py | https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/resources/gen/sections.py#L25-L34 | def find_by_project(self, project, params={}, **options):
"""Returns the compact records for all sections in the specified project.
Parameters
----------
project : {Id} The project to get sections from.
[params] : {Object} Parameters for the request
"""
path = "... | [
"def",
"find_by_project",
"(",
"self",
",",
"project",
",",
"params",
"=",
"{",
"}",
",",
"*",
"*",
"options",
")",
":",
"path",
"=",
"\"/projects/%s/sections\"",
"%",
"(",
"project",
")",
"return",
"self",
".",
"client",
".",
"get",
"(",
"path",
",",
... | Returns the compact records for all sections in the specified project.
Parameters
----------
project : {Id} The project to get sections from.
[params] : {Object} Parameters for the request | [
"Returns",
"the",
"compact",
"records",
"for",
"all",
"sections",
"in",
"the",
"specified",
"project",
"."
] | python | train | 40.1 |
Alignak-monitoring/alignak | alignak/daemons/schedulerdaemon.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemons/schedulerdaemon.py#L503-L514 | def clean_previous_run(self):
"""Clean variables from previous configuration
:return: None
"""
# Execute the base class treatment...
super(Alignak, self).clean_previous_run()
# Clean all lists
self.pollers.clear()
self.reactionners.clear()
self.b... | [
"def",
"clean_previous_run",
"(",
"self",
")",
":",
"# Execute the base class treatment...",
"super",
"(",
"Alignak",
",",
"self",
")",
".",
"clean_previous_run",
"(",
")",
"# Clean all lists",
"self",
".",
"pollers",
".",
"clear",
"(",
")",
"self",
".",
"reacti... | Clean variables from previous configuration
:return: None | [
"Clean",
"variables",
"from",
"previous",
"configuration"
] | python | train | 26.916667 |
mila/pyoo | pyoo.py | https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1918-L1923 | def open_spreadsheet(self, path, as_template=False):
"""
Opens an exiting spreadsheet document on the local file system.
"""
desktop = self.cls(self.hostname, self.port)
return desktop.open_spreadsheet(path, as_template=as_template) | [
"def",
"open_spreadsheet",
"(",
"self",
",",
"path",
",",
"as_template",
"=",
"False",
")",
":",
"desktop",
"=",
"self",
".",
"cls",
"(",
"self",
".",
"hostname",
",",
"self",
".",
"port",
")",
"return",
"desktop",
".",
"open_spreadsheet",
"(",
"path",
... | Opens an exiting spreadsheet document on the local file system. | [
"Opens",
"an",
"exiting",
"spreadsheet",
"document",
"on",
"the",
"local",
"file",
"system",
"."
] | python | train | 44.5 |
AmesCornish/buttersink | buttersink/progress.py | https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/progress.py#L82-L88 | def close(self):
""" Stop overwriting display, or update parent. """
if self.parent:
self.parent.update(self.parent.offset + self.offset)
return
self.output.write("\n")
self.output.flush() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
":",
"self",
".",
"parent",
".",
"update",
"(",
"self",
".",
"parent",
".",
"offset",
"+",
"self",
".",
"offset",
")",
"return",
"self",
".",
"output",
".",
"write",
"(",
"\"\\n\""... | Stop overwriting display, or update parent. | [
"Stop",
"overwriting",
"display",
"or",
"update",
"parent",
"."
] | python | train | 34 |
geophysics-ubonn/crtomo_tools | src/td_plot.py | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L719-L836 | def create_singleplots(plotman, cov, mag, pha, pha_fpi, alpha, options):
'''Plot the data of the tomodir in individual plots.
'''
magunit = 'log_rho'
if not pha == []:
[real, imag] = calc_complex(mag, pha)
if not pha_fpi == []:
[real_fpi, imag_fpi] = calc_complex(mag, pha_fpi... | [
"def",
"create_singleplots",
"(",
"plotman",
",",
"cov",
",",
"mag",
",",
"pha",
",",
"pha_fpi",
",",
"alpha",
",",
"options",
")",
":",
"magunit",
"=",
"'log_rho'",
"if",
"not",
"pha",
"==",
"[",
"]",
":",
"[",
"real",
",",
"imag",
"]",
"=",
"calc... | Plot the data of the tomodir in individual plots. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"individual",
"plots",
"."
] | python | train | 40.042373 |
RJT1990/pyflux | pyflux/garch/segarch.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/segarch.py#L219-L272 | def _mean_prediction(self, lmda, Y, scores, h, t_params):
""" Creates a h-step ahead mean prediction
Parameters
----------
lmda : np.array
The past predicted values
Y : np.array
The past data
scores : np.array
The past scores
... | [
"def",
"_mean_prediction",
"(",
"self",
",",
"lmda",
",",
"Y",
",",
"scores",
",",
"h",
",",
"t_params",
")",
":",
"# Create arrays to iteratre over",
"lmda_exp",
"=",
"lmda",
".",
"copy",
"(",
")",
"scores_exp",
"=",
"scores",
".",
"copy",
"(",
")",
"Y_... | Creates a h-step ahead mean prediction
Parameters
----------
lmda : np.array
The past predicted values
Y : np.array
The past data
scores : np.array
The past scores
h : int
How many steps ahead for the prediction
... | [
"Creates",
"a",
"h",
"-",
"step",
"ahead",
"mean",
"prediction"
] | python | train | 34.203704 |
tantale/deprecated | docs/source/tutorial/v3/liberty.py | https://github.com/tantale/deprecated/blob/3dc742c571de7cebbbdaaf4c554f2f36fc61b3db/docs/source/tutorial/v3/liberty.py#L18-L25 | def better_print(self, printer=None):
"""
Print the value using a *printer*.
:param printer: Callable used to print the value, by default: :func:`pprint.pprint`
"""
printer = printer or pprint.pprint
printer(self.value) | [
"def",
"better_print",
"(",
"self",
",",
"printer",
"=",
"None",
")",
":",
"printer",
"=",
"printer",
"or",
"pprint",
".",
"pprint",
"printer",
"(",
"self",
".",
"value",
")"
] | Print the value using a *printer*.
:param printer: Callable used to print the value, by default: :func:`pprint.pprint` | [
"Print",
"the",
"value",
"using",
"a",
"*",
"printer",
"*",
"."
] | python | train | 32.625 |
baguette-io/baguette-messaging | farine/connectors/sql/__init__.py | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/connectors/sql/__init__.py#L19-L26 | def to_json(self, extras=None):
"""
Convert a model into a json using the playhouse shortcut.
"""
extras = extras or {}
to_dict = model_to_dict(self)
to_dict.update(extras)
return json.dumps(to_dict, cls=sel.serializers.JsonEncoder) | [
"def",
"to_json",
"(",
"self",
",",
"extras",
"=",
"None",
")",
":",
"extras",
"=",
"extras",
"or",
"{",
"}",
"to_dict",
"=",
"model_to_dict",
"(",
"self",
")",
"to_dict",
".",
"update",
"(",
"extras",
")",
"return",
"json",
".",
"dumps",
"(",
"to_di... | Convert a model into a json using the playhouse shortcut. | [
"Convert",
"a",
"model",
"into",
"a",
"json",
"using",
"the",
"playhouse",
"shortcut",
"."
] | python | train | 35.125 |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/models.py | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/models.py#L106-L122 | def create(cls, parent, child, relation_type, index=None):
"""Create a PID relation for given parent and child."""
try:
with db.session.begin_nested():
obj = cls(parent_id=parent.id,
child_id=child.id,
relation_type=relation... | [
"def",
"create",
"(",
"cls",
",",
"parent",
",",
"child",
",",
"relation_type",
",",
"index",
"=",
"None",
")",
":",
"try",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"obj",
"=",
"cls",
"(",
"parent_id",
"=",
"parent",
"... | Create a PID relation for given parent and child. | [
"Create",
"a",
"PID",
"relation",
"for",
"given",
"parent",
"and",
"child",
"."
] | python | train | 42.705882 |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/admissionregistration_v1beta1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/admissionregistration_v1beta1_api.py#L1307-L1330 | def read_mutating_webhook_configuration(self, name, **kwargs): # noqa: E501
"""read_mutating_webhook_configuration # noqa: E501
read the specified MutatingWebhookConfiguration # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, ... | [
"def",
"read_mutating_webhook_configuration",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
... | read_mutating_webhook_configuration # noqa: E501
read the specified MutatingWebhookConfiguration # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_mutating_webhook_configuration(... | [
"read_mutating_webhook_configuration",
"#",
"noqa",
":",
"E501"
] | python | train | 56.375 |
collectiveacuity/labPack | labpack/location/find.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/location/find.py#L104-L130 | def get_locations(self):
'''
a method to retrieve all the locations tracked by the model
:return: dictionary with location id keys
NOTE: results are added to self.locations property
{
'location.id': {
'
... | [
"def",
"get_locations",
"(",
"self",
")",
":",
"import",
"requests",
"url",
"=",
"self",
".",
"endpoint",
"+",
"'/locations'",
"params",
"=",
"{",
"'group'",
":",
"self",
".",
"group_name",
"}",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
... | a method to retrieve all the locations tracked by the model
:return: dictionary with location id keys
NOTE: results are added to self.locations property
{
'location.id': {
'
}
} | [
"a",
"method",
"to",
"retrieve",
"all",
"the",
"locations",
"tracked",
"by",
"the",
"model",
":",
"return",
":",
"dictionary",
"with",
"location",
"id",
"keys",
"NOTE",
":",
"results",
"are",
"added",
"to",
"self",
".",
"locations",
"property",
"{",
"locat... | python | train | 26.222222 |
kyper-data/python-highcharts | highcharts/highstock/highstock.py | https://github.com/kyper-data/python-highcharts/blob/a4c488ae5c2e125616efad5a722f3dfd8a9bc450/highcharts/highstock/highstock.py#L388-L396 | def save_file(self, filename = 'StockChart'):
""" save htmlcontent as .html file """
filename = filename + '.html'
with open(filename, 'w') as f:
#self.buildhtml()
f.write(self.htmlcontent)
f.closed | [
"def",
"save_file",
"(",
"self",
",",
"filename",
"=",
"'StockChart'",
")",
":",
"filename",
"=",
"filename",
"+",
"'.html'",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"#self.buildhtml()",
"f",
".",
"write",
"(",
"self",
".",
"h... | save htmlcontent as .html file | [
"save",
"htmlcontent",
"as",
".",
"html",
"file"
] | python | train | 29.333333 |
bast/flanders | cmake/autocmake/configure.py | https://github.com/bast/flanders/blob/792f9eed8511cb553e67a25b6c5ce60fd6ae97bc/cmake/autocmake/configure.py#L36-L52 | def setup_build_path(build_path):
"""
Create build directory. If this already exists, print informative
error message and quit.
"""
if os.path.isdir(build_path):
fname = os.path.join(build_path, 'CMakeCache.txt')
if os.path.exists(fname):
sys.stderr.write('aborting setup\... | [
"def",
"setup_build_path",
"(",
"build_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"build_path",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"build_path",
",",
"'CMakeCache.txt'",
")",
"if",
"os",
".",
"path",
".",
"... | Create build directory. If this already exists, print informative
error message and quit. | [
"Create",
"build",
"directory",
".",
"If",
"this",
"already",
"exists",
"print",
"informative",
"error",
"message",
"and",
"quit",
"."
] | python | train | 37.117647 |
zooniverse/panoptes-python-client | panoptes_client/panoptes.py | https://github.com/zooniverse/panoptes-python-client/blob/138d93cb03378501a8d349428e381ad73f928680/panoptes_client/panoptes.py#L657-L672 | def where(cls, **kwargs):
"""
Returns a generator which yields instances matching the given query
arguments.
For example, this would yield all :py:class:`.Project`::
Project.where()
And this would yield all launch approved :py:class:`.Project`::
Projec... | [
"def",
"where",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"_id",
"=",
"kwargs",
".",
"pop",
"(",
"'id'",
",",
"''",
")",
"return",
"cls",
".",
"paginated_results",
"(",
"*",
"cls",
".",
"http_get",
"(",
"_id",
",",
"params",
"=",
"kwargs",
"... | Returns a generator which yields instances matching the given query
arguments.
For example, this would yield all :py:class:`.Project`::
Project.where()
And this would yield all launch approved :py:class:`.Project`::
Project.where(launch_approved=True) | [
"Returns",
"a",
"generator",
"which",
"yields",
"instances",
"matching",
"the",
"given",
"query",
"arguments",
"."
] | python | train | 28.375 |
vpelletier/python-libusb1 | usb1/libusb1.py | https://github.com/vpelletier/python-libusb1/blob/740c9778e28523e4ec3543415d95f5400ae0fa24/usb1/libusb1.py#L1083-L1095 | def get_iso_packet_buffer_list(transfer_p):
"""
Python-specific helper extracting a list of iso packet buffers.
"""
transfer = transfer_p.contents
offset = 0
result = []
append = result.append
for iso_transfer in _get_iso_packet_list(transfer):
length = iso_transfer.length
... | [
"def",
"get_iso_packet_buffer_list",
"(",
"transfer_p",
")",
":",
"transfer",
"=",
"transfer_p",
".",
"contents",
"offset",
"=",
"0",
"result",
"=",
"[",
"]",
"append",
"=",
"result",
".",
"append",
"for",
"iso_transfer",
"in",
"_get_iso_packet_list",
"(",
"tr... | Python-specific helper extracting a list of iso packet buffers. | [
"Python",
"-",
"specific",
"helper",
"extracting",
"a",
"list",
"of",
"iso",
"packet",
"buffers",
"."
] | python | train | 31.461538 |
cedricbonhomme/Stegano | stegano/lsbset/generators.py | https://github.com/cedricbonhomme/Stegano/blob/502e6303791d348e479290c22108551ba3be254f/stegano/lsbset/generators.py#L110-L118 | def ackermann_naive(m: int, n: int) -> int:
"""Ackermann number.
"""
if m == 0:
return n + 1
elif n == 0:
return ackermann(m - 1, 1)
else:
return ackermann(m - 1, ackermann(m, n - 1)) | [
"def",
"ackermann_naive",
"(",
"m",
":",
"int",
",",
"n",
":",
"int",
")",
"->",
"int",
":",
"if",
"m",
"==",
"0",
":",
"return",
"n",
"+",
"1",
"elif",
"n",
"==",
"0",
":",
"return",
"ackermann",
"(",
"m",
"-",
"1",
",",
"1",
")",
"else",
... | Ackermann number. | [
"Ackermann",
"number",
"."
] | python | train | 24.333333 |
pydata/xarray | xarray/core/utils.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L258-L265 | def to_0d_array(value: Any) -> np.ndarray:
"""Given a value, wrap it in a 0-D numpy.ndarray.
"""
if np.isscalar(value) or (isinstance(value, np.ndarray) and
value.ndim == 0):
return np.array(value)
else:
return to_0d_object_array(value) | [
"def",
"to_0d_array",
"(",
"value",
":",
"Any",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"np",
".",
"isscalar",
"(",
"value",
")",
"or",
"(",
"isinstance",
"(",
"value",
",",
"np",
".",
"ndarray",
")",
"and",
"value",
".",
"ndim",
"==",
"0",
"... | Given a value, wrap it in a 0-D numpy.ndarray. | [
"Given",
"a",
"value",
"wrap",
"it",
"in",
"a",
"0",
"-",
"D",
"numpy",
".",
"ndarray",
"."
] | python | train | 36.375 |
joelfrederico/SciSalt | scisalt/matplotlib/pcolor_axes.py | https://github.com/joelfrederico/SciSalt/blob/7bf57c49c7dde0a8b0aa337fbd2fbd527ce7a67f/scisalt/matplotlib/pcolor_axes.py#L11-L30 | def pcolor_axes(array, px_to_units=px_to_units):
"""
Return axes :code:`x, y` for *array* to be used with :func:`matplotlib.pyplot.color`.
*px_to_units* is a function to convert pixels to units. By default, returns pixels.
"""
# ======================================
# Coords need to be +1 larg... | [
"def",
"pcolor_axes",
"(",
"array",
",",
"px_to_units",
"=",
"px_to_units",
")",
":",
"# ======================================",
"# Coords need to be +1 larger than array",
"# ======================================",
"x_size",
"=",
"array",
".",
"shape",
"[",
"0",
"]",
"+"... | Return axes :code:`x, y` for *array* to be used with :func:`matplotlib.pyplot.color`.
*px_to_units* is a function to convert pixels to units. By default, returns pixels. | [
"Return",
"axes",
":",
"code",
":",
"x",
"y",
"for",
"*",
"array",
"*",
"to",
"be",
"used",
"with",
":",
"func",
":",
"matplotlib",
".",
"pyplot",
".",
"color",
"."
] | python | valid | 31.35 |
jamieleshaw/lurklib | lurklib/connection.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/connection.py#L280-L304 | def umode(self, nick, modes=''):
"""
Sets/gets user modes.
Required arguments:
* nick - Nick to set/get user modes for.
Optional arguments:
* modes='' - Sets these user modes on a nick.
"""
with self.lock:
if not modes:
self.sen... | [
"def",
"umode",
"(",
"self",
",",
"nick",
",",
"modes",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"not",
"modes",
":",
"self",
".",
"send",
"(",
"'MODE %s'",
"%",
"nick",
")",
"if",
"self",
".",
"readable",
"(",
")",
":",
"ms... | Sets/gets user modes.
Required arguments:
* nick - Nick to set/get user modes for.
Optional arguments:
* modes='' - Sets these user modes on a nick. | [
"Sets",
"/",
"gets",
"user",
"modes",
".",
"Required",
"arguments",
":",
"*",
"nick",
"-",
"Nick",
"to",
"set",
"/",
"get",
"user",
"modes",
"for",
".",
"Optional",
"arguments",
":",
"*",
"modes",
"=",
"-",
"Sets",
"these",
"user",
"modes",
"on",
"a"... | python | train | 35.6 |
alefnula/tea | tea/console/color.py | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/console/color.py#L286-L308 | def _colorize_single_line(line, regexp, color_def):
"""Print single line to console with ability to colorize parts of it."""
match = regexp.match(line)
groupdict = match.groupdict()
groups = match.groups()
if not groupdict:
# no named groups, just colorize whole line
color = c... | [
"def",
"_colorize_single_line",
"(",
"line",
",",
"regexp",
",",
"color_def",
")",
":",
"match",
"=",
"regexp",
".",
"match",
"(",
"line",
")",
"groupdict",
"=",
"match",
".",
"groupdict",
"(",
")",
"groups",
"=",
"match",
".",
"groups",
"(",
")",
"if"... | Print single line to console with ability to colorize parts of it. | [
"Print",
"single",
"line",
"to",
"console",
"with",
"ability",
"to",
"colorize",
"parts",
"of",
"it",
"."
] | python | train | 36.956522 |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2632-L2673 | def namedb_get_name_preorder( db, preorder_hash, current_block ):
"""
Get a (singular) name preorder record outstanding at the given block, given the preorder hash.
NOTE: returns expired preorders.
Return the preorder record on success.
Return None if not found.
"""
select_query = "SEL... | [
"def",
"namedb_get_name_preorder",
"(",
"db",
",",
"preorder_hash",
",",
"current_block",
")",
":",
"select_query",
"=",
"\"SELECT * FROM preorders WHERE preorder_hash = ? AND op = ? AND block_number < ?;\"",
"args",
"=",
"(",
"preorder_hash",
",",
"NAME_PREORDER",
",",
"curr... | Get a (singular) name preorder record outstanding at the given block, given the preorder hash.
NOTE: returns expired preorders.
Return the preorder record on success.
Return None if not found. | [
"Get",
"a",
"(",
"singular",
")",
"name",
"preorder",
"record",
"outstanding",
"at",
"the",
"given",
"block",
"given",
"the",
"preorder",
"hash",
".",
"NOTE",
":",
"returns",
"expired",
"preorders",
".",
"Return",
"the",
"preorder",
"record",
"on",
"success"... | python | train | 34.047619 |
artefactual-labs/mets-reader-writer | metsrw/mets.py | https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/mets.py#L342-L385 | def _parse_tree_structmap(self, tree, parent_elem, normative_parent_elem=None):
"""Recursively parse all the children of parent_elem, including amdSecs
and dmdSecs.
:param lxml._ElementTree tree: encodes the entire METS file.
:param lxml._Element parent_elem: the element whose children w... | [
"def",
"_parse_tree_structmap",
"(",
"self",
",",
"tree",
",",
"parent_elem",
",",
"normative_parent_elem",
"=",
"None",
")",
":",
"siblings",
"=",
"[",
"]",
"el_to_normative",
"=",
"self",
".",
"_get_el_to_normative",
"(",
"parent_elem",
",",
"normative_parent_el... | Recursively parse all the children of parent_elem, including amdSecs
and dmdSecs.
:param lxml._ElementTree tree: encodes the entire METS file.
:param lxml._Element parent_elem: the element whose children we are
parsing.
:param lxml._Element normative_parent_elem: the normativ... | [
"Recursively",
"parse",
"all",
"the",
"children",
"of",
"parent_elem",
"including",
"amdSecs",
"and",
"dmdSecs",
".",
":",
"param",
"lxml",
".",
"_ElementTree",
"tree",
":",
"encodes",
"the",
"entire",
"METS",
"file",
".",
":",
"param",
"lxml",
".",
"_Elemen... | python | train | 52.090909 |
bcbio/bcbio-nextgen | bcbio/illumina/flowcell.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/flowcell.py#L39-L54 | def get_fastq_dir(fc_dir):
"""Retrieve the fastq directory within Solexa flowcell output.
"""
full_goat_bc = glob.glob(os.path.join(fc_dir, "Data", "*Firecrest*", "Bustard*"))
bustard_bc = glob.glob(os.path.join(fc_dir, "Data", "Intensities", "*Bustard*"))
machine_bc = os.path.join(fc_dir, "Data", "... | [
"def",
"get_fastq_dir",
"(",
"fc_dir",
")",
":",
"full_goat_bc",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"fc_dir",
",",
"\"Data\"",
",",
"\"*Firecrest*\"",
",",
"\"Bustard*\"",
")",
")",
"bustard_bc",
"=",
"glob",
".",
"glob",... | Retrieve the fastq directory within Solexa flowcell output. | [
"Retrieve",
"the",
"fastq",
"directory",
"within",
"Solexa",
"flowcell",
"output",
"."
] | python | train | 45 |
PmagPy/PmagPy | pmagpy/pmag.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L5150-L5165 | def Dir_anis_corr(InDir, AniSpec):
"""
takes the 6 element 's' vector and the Dec,Inc 'InDir' data,
performs simple anisotropy correction. returns corrected Dec, Inc
"""
Dir = np.zeros((3), 'f')
Dir[0] = InDir[0]
Dir[1] = InDir[1]
Dir[2] = 1.
chi, chi_inv = check_F(AniSpec)
if ch... | [
"def",
"Dir_anis_corr",
"(",
"InDir",
",",
"AniSpec",
")",
":",
"Dir",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
")",
",",
"'f'",
")",
"Dir",
"[",
"0",
"]",
"=",
"InDir",
"[",
"0",
"]",
"Dir",
"[",
"1",
"]",
"=",
"InDir",
"[",
"1",
"]",
"Dir"... | takes the 6 element 's' vector and the Dec,Inc 'InDir' data,
performs simple anisotropy correction. returns corrected Dec, Inc | [
"takes",
"the",
"6",
"element",
"s",
"vector",
"and",
"the",
"Dec",
"Inc",
"InDir",
"data",
"performs",
"simple",
"anisotropy",
"correction",
".",
"returns",
"corrected",
"Dec",
"Inc"
] | python | train | 27.6875 |
OpenTreeOfLife/peyotl | peyotl/git_storage/git_shard.py | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/git_shard.py#L275-L287 | def _read_master_branch_resource(self, fn, is_json=False):
"""This will force the current branch to master! """
with self._master_branch_repo_lock:
ga = self._create_git_action_for_global_resource()
with ga.lock():
ga.checkout_master()
if os.path.e... | [
"def",
"_read_master_branch_resource",
"(",
"self",
",",
"fn",
",",
"is_json",
"=",
"False",
")",
":",
"with",
"self",
".",
"_master_branch_repo_lock",
":",
"ga",
"=",
"self",
".",
"_create_git_action_for_global_resource",
"(",
")",
"with",
"ga",
".",
"lock",
... | This will force the current branch to master! | [
"This",
"will",
"force",
"the",
"current",
"branch",
"to",
"master!"
] | python | train | 43.615385 |
druids/django-chamber | chamber/models/__init__.py | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L258-L264 | def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset.
"""
bulk_change_and_save(self, update_only_changed_fields=update_only... | [
"def",
"change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"False",
",",
"*",
"*",
"changed_fields",
")",
":",
"bulk_change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"update_only_changed_fields",
",",
"*",
"*",
"changed_fields... | Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset. | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"each",
"object",
"in",
"the",
"queryset",
"saves",
"objects",
"and",
"returns",
"the",
"changed",
"objects",
"in",
"the",
"queryset",
"."
] | python | train | 53.857143 |
tethysplatform/condorpy | condorpy/job.py | https://github.com/tethysplatform/condorpy/blob/a5aaaef0d73198f7d9756dda7abe98b4e209f1f4/condorpy/job.py#L183-L191 | def log_file(self):
"""The path to the log file for this job.
"""
log_file = self.get('log')
if not log_file:
log_file = '%s.log' % (self.name)
self.set('log', log_file)
return os.path.join(self.initial_dir, self.get('log')) | [
"def",
"log_file",
"(",
"self",
")",
":",
"log_file",
"=",
"self",
".",
"get",
"(",
"'log'",
")",
"if",
"not",
"log_file",
":",
"log_file",
"=",
"'%s.log'",
"%",
"(",
"self",
".",
"name",
")",
"self",
".",
"set",
"(",
"'log'",
",",
"log_file",
")",... | The path to the log file for this job. | [
"The",
"path",
"to",
"the",
"log",
"file",
"for",
"this",
"job",
"."
] | python | train | 31.222222 |
ewels/MultiQC | multiqc/modules/fastqc/fastqc.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/fastqc/fastqc.py#L939-L951 | def avg_bp_from_range(self, bp):
""" Helper function - FastQC often gives base pair ranges (eg. 10-15)
which are not helpful when plotting. This returns the average from such
ranges as an int, which is helpful. If not a range, just returns the int """
try:
if '-' in bp:
... | [
"def",
"avg_bp_from_range",
"(",
"self",
",",
"bp",
")",
":",
"try",
":",
"if",
"'-'",
"in",
"bp",
":",
"maxlen",
"=",
"float",
"(",
"bp",
".",
"split",
"(",
"\"-\"",
",",
"1",
")",
"[",
"1",
"]",
")",
"minlen",
"=",
"float",
"(",
"bp",
".",
... | Helper function - FastQC often gives base pair ranges (eg. 10-15)
which are not helpful when plotting. This returns the average from such
ranges as an int, which is helpful. If not a range, just returns the int | [
"Helper",
"function",
"-",
"FastQC",
"often",
"gives",
"base",
"pair",
"ranges",
"(",
"eg",
".",
"10",
"-",
"15",
")",
"which",
"are",
"not",
"helpful",
"when",
"plotting",
".",
"This",
"returns",
"the",
"average",
"from",
"such",
"ranges",
"as",
"an",
... | python | train | 40.307692 |
aio-libs/aioftp | ftpbench.py | https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/ftpbench.py#L159-L174 | def human2bytes(s):
"""
>>> human2bytes('1M')
1048576
>>> human2bytes('1G')
1073741824
"""
symbols = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
letter = s[-1:].strip().upper()
num = s[:-1]
assert num.isdigit() and letter in symbols, s
num = float(num)
prefix = {symbols... | [
"def",
"human2bytes",
"(",
"s",
")",
":",
"symbols",
"=",
"(",
"'B'",
",",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'T'",
",",
"'P'",
",",
"'E'",
",",
"'Z'",
",",
"'Y'",
")",
"letter",
"=",
"s",
"[",
"-",
"1",
":",
"]",
".",
"strip",
"(",
")",
... | >>> human2bytes('1M')
1048576
>>> human2bytes('1G')
1073741824 | [
">>>",
"human2bytes",
"(",
"1M",
")",
"1048576",
">>>",
"human2bytes",
"(",
"1G",
")",
"1073741824"
] | python | valid | 26.6875 |
vilmibm/done | parsedatetime/parsedatetime.py | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime.py#L389-L440 | def parseDateText(self, dateString):
"""
Parse long-form date strings::
'May 31st, 2006'
'Jan 1st'
'July 2006'
@type dateString: string
@param dateString: text to convert to a datetime
@rtype: struct_time
@return: calcu... | [
"def",
"parseDateText",
"(",
"self",
",",
"dateString",
")",
":",
"yr",
",",
"mth",
",",
"dy",
",",
"hr",
",",
"mn",
",",
"sec",
",",
"wd",
",",
"yd",
",",
"isdst",
"=",
"time",
".",
"localtime",
"(",
")",
"currentMth",
"=",
"mth",
"currentDy",
"... | Parse long-form date strings::
'May 31st, 2006'
'Jan 1st'
'July 2006'
@type dateString: string
@param dateString: text to convert to a datetime
@rtype: struct_time
@return: calculated C{struct_time} value of dateString | [
"Parse",
"long",
"-",
"form",
"date",
"strings",
"::",
"May",
"31st",
"2006",
"Jan",
"1st",
"July",
"2006"
] | python | train | 29.211538 |
peergradeio/flask-mongo-profiler | flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py | https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py#L27-L65 | def generic_ref_formatter(view, context, model, name, lazy=False):
"""
For GenericReferenceField and LazyGenericReferenceField
See Also
--------
diff_formatter
"""
try:
if lazy:
rel_model = getattr(model, name).fetch()
else:
rel_model = getattr(model,... | [
"def",
"generic_ref_formatter",
"(",
"view",
",",
"context",
",",
"model",
",",
"name",
",",
"lazy",
"=",
"False",
")",
":",
"try",
":",
"if",
"lazy",
":",
"rel_model",
"=",
"getattr",
"(",
"model",
",",
"name",
")",
".",
"fetch",
"(",
")",
"else",
... | For GenericReferenceField and LazyGenericReferenceField
See Also
--------
diff_formatter | [
"For",
"GenericReferenceField",
"and",
"LazyGenericReferenceField"
] | python | train | 31.205128 |
psd-tools/psd-tools | src/psd_tools/api/layers.py | https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/layers.py#L342-L351 | def compose(self, *args, **kwargs):
"""
Compose layer and masks (mask, vector mask, and clipping layers).
:return: :py:class:`PIL.Image`, or `None` if the layer has no pixel.
"""
from psd_tools.api.composer import compose_layer
if self.bbox == (0, 0, 0, 0):
r... | [
"def",
"compose",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"psd_tools",
".",
"api",
".",
"composer",
"import",
"compose_layer",
"if",
"self",
".",
"bbox",
"==",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
":",
... | Compose layer and masks (mask, vector mask, and clipping layers).
:return: :py:class:`PIL.Image`, or `None` if the layer has no pixel. | [
"Compose",
"layer",
"and",
"masks",
"(",
"mask",
"vector",
"mask",
"and",
"clipping",
"layers",
")",
"."
] | python | train | 37.3 |
jmcarp/flask-apispec | flask_apispec/annotations.py | https://github.com/jmcarp/flask-apispec/blob/d8cb658fa427f051568e58d6af201b8e9924c325/flask_apispec/annotations.py#L74-L91 | def doc(inherit=None, **kwargs):
"""Annotate the decorated view function or class with the specified Swagger
attributes.
Usage:
.. code-block:: python
@doc(tags=['pet'], description='a pet store')
def get_pet(pet_id):
return Pet.query.filter(Pet.id == pet_id).one()
:p... | [
"def",
"doc",
"(",
"inherit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"annotate",
"(",
"func",
",",
"'docs'",
",",
"[",
"kwargs",
"]",
",",
"inherit",
"=",
"inherit",
")",
"return",
"activate",
"(",
... | Annotate the decorated view function or class with the specified Swagger
attributes.
Usage:
.. code-block:: python
@doc(tags=['pet'], description='a pet store')
def get_pet(pet_id):
return Pet.query.filter(Pet.id == pet_id).one()
:param inherit: Inherit Swagger documentat... | [
"Annotate",
"the",
"decorated",
"view",
"function",
"or",
"class",
"with",
"the",
"specified",
"Swagger",
"attributes",
"."
] | python | train | 28 |
O365/python-o365 | release.py | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/release.py#L50-L69 | def upload(ctx, release, rebuild):
""" Uploads distribuition files to pypi or pypitest. """
dist_path = Path(DIST_PATH)
if rebuild is False:
if not dist_path.exists() or not list(dist_path.glob('*')):
print("No distribution files found. Please run 'build' command first")
retu... | [
"def",
"upload",
"(",
"ctx",
",",
"release",
",",
"rebuild",
")",
":",
"dist_path",
"=",
"Path",
"(",
"DIST_PATH",
")",
"if",
"rebuild",
"is",
"False",
":",
"if",
"not",
"dist_path",
".",
"exists",
"(",
")",
"or",
"not",
"list",
"(",
"dist_path",
"."... | Uploads distribuition files to pypi or pypitest. | [
"Uploads",
"distribuition",
"files",
"to",
"pypi",
"or",
"pypitest",
"."
] | python | train | 31.8 |
Chilipp/psy-simple | psy_simple/base.py | https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/base.py#L133-L167 | def get_fig_data_attrs(self, delimiter=None):
"""Join the data attributes with other plotters in the project
This method joins the attributes of the
:class:`~psyplot.InteractiveBase` instances in the project that
draw on the same figure as this instance does.
Parameters
... | [
"def",
"get_fig_data_attrs",
"(",
"self",
",",
"delimiter",
"=",
"None",
")",
":",
"if",
"self",
".",
"project",
"is",
"not",
"None",
":",
"delimiter",
"=",
"next",
"(",
"filter",
"(",
"lambda",
"d",
":",
"d",
"is",
"not",
"None",
",",
"[",
"delimite... | Join the data attributes with other plotters in the project
This method joins the attributes of the
:class:`~psyplot.InteractiveBase` instances in the project that
draw on the same figure as this instance does.
Parameters
----------
delimiter: str
Specifies ... | [
"Join",
"the",
"data",
"attributes",
"with",
"other",
"plotters",
"in",
"the",
"project"
] | python | train | 42.371429 |
Robpol86/docoptcfg | docoptcfg.py | https://github.com/Robpol86/docoptcfg/blob/3746dc263549f7f3ef5a86e739d588546b084bde/docoptcfg.py#L234-L279 | def docoptcfg(doc, argv=None, env_prefix=None, config_option=None, ignore=None, *args, **kwargs):
"""Pass most args/kwargs to docopt. Handle `env_prefix` and `config_option`.
:raise DocoptcfgError: If `config_option` isn't found in docstring.
:raise DocoptcfgFileError: On any error while trying to read and... | [
"def",
"docoptcfg",
"(",
"doc",
",",
"argv",
"=",
"None",
",",
"env_prefix",
"=",
"None",
",",
"config_option",
"=",
"None",
",",
"ignore",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"docopt_dict",
"=",
"docopt",
".",
"docopt",... | Pass most args/kwargs to docopt. Handle `env_prefix` and `config_option`.
:raise DocoptcfgError: If `config_option` isn't found in docstring.
:raise DocoptcfgFileError: On any error while trying to read and parse config file (if enabled).
:param str doc: Docstring passed to docopt.
:param iter argv: s... | [
"Pass",
"most",
"args",
"/",
"kwargs",
"to",
"docopt",
".",
"Handle",
"env_prefix",
"and",
"config_option",
"."
] | python | train | 43.086957 |
sdispater/orator | orator/orm/builder.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/builder.py#L63-L85 | def without_global_scope(self, scope):
"""
Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder
"""
if isinstance(scope, basestring):
del self._scopes[scope]
return self
k... | [
"def",
"without_global_scope",
"(",
"self",
",",
"scope",
")",
":",
"if",
"isinstance",
"(",
"scope",
",",
"basestring",
")",
":",
"del",
"self",
".",
"_scopes",
"[",
"scope",
"]",
"return",
"self",
"keys",
"=",
"[",
"]",
"for",
"key",
",",
"value",
... | Remove a registered global scope.
:param scope: The scope to remove
:type scope: Scope or str
:rtype: Builder | [
"Remove",
"a",
"registered",
"global",
"scope",
"."
] | python | train | 23.782609 |
rbarrois/aionotify | aionotify/base.py | https://github.com/rbarrois/aionotify/blob/6cfa35b26a2660f77f29a92d3efb7d1dde685b43/aionotify/base.py#L84-L93 | def setup(self, loop):
"""Start the watcher, registering new watches if any."""
self._loop = loop
self._fd = LibC.inotify_init()
for alias, (path, flags) in self.requests.items():
self._setup_watch(alias, path, flags)
# We pass ownership of the fd to the transport; ... | [
"def",
"setup",
"(",
"self",
",",
"loop",
")",
":",
"self",
".",
"_loop",
"=",
"loop",
"self",
".",
"_fd",
"=",
"LibC",
".",
"inotify_init",
"(",
")",
"for",
"alias",
",",
"(",
"path",
",",
"flags",
")",
"in",
"self",
".",
"requests",
".",
"items... | Start the watcher, registering new watches if any. | [
"Start",
"the",
"watcher",
"registering",
"new",
"watches",
"if",
"any",
"."
] | python | test | 41.9 |
automl/HpBandSter | hpbandster/optimizers/kde/mvkde.py | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/kde/mvkde.py#L210-L237 | def _get_types(self):
""" extracts the needed types from the configspace for faster retrival later
type = 0 - numerical (continuous or integer) parameter
type >=1 - categorical parameter
TODO: figure out a way to properly handle ordinal parameters
"""
types = []
num_values = []
for hp in se... | [
"def",
"_get_types",
"(",
"self",
")",
":",
"types",
"=",
"[",
"]",
"num_values",
"=",
"[",
"]",
"for",
"hp",
"in",
"self",
".",
"configspace",
".",
"get_hyperparameters",
"(",
")",
":",
"#print(hp)",
"if",
"isinstance",
"(",
"hp",
",",
"CS",
".",
"C... | extracts the needed types from the configspace for faster retrival later
type = 0 - numerical (continuous or integer) parameter
type >=1 - categorical parameter
TODO: figure out a way to properly handle ordinal parameters | [
"extracts",
"the",
"needed",
"types",
"from",
"the",
"configspace",
"for",
"faster",
"retrival",
"later",
"type",
"=",
"0",
"-",
"numerical",
"(",
"continuous",
"or",
"integer",
")",
"parameter",
"type",
">",
"=",
"1",
"-",
"categorical",
"parameter",
"TODO"... | python | train | 32.25 |
PetrochukM/PyTorch-NLP | torchnlp/utils.py | https://github.com/PetrochukM/PyTorch-NLP/blob/5f7320da5c8d781df072fab3f7e421c6347e5bfa/torchnlp/utils.py#L241-L281 | def tensors_to(tensors, *args, **kwargs):
""" Apply ``torch.Tensor.to`` to tensors in a generic data structure.
Inspired by:
https://github.com/pytorch/pytorch/blob/master/torch/utils/data/_utils/collate.py#L31
Args:
tensors (tensor, dict, list, namedtuple or tuple): Data structure with tensor... | [
"def",
"tensors_to",
"(",
"tensors",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"torch",
".",
"is_tensor",
"(",
"tensors",
")",
":",
"return",
"tensors",
".",
"to",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"elif",
"isinstance... | Apply ``torch.Tensor.to`` to tensors in a generic data structure.
Inspired by:
https://github.com/pytorch/pytorch/blob/master/torch/utils/data/_utils/collate.py#L31
Args:
tensors (tensor, dict, list, namedtuple or tuple): Data structure with tensor values to
move.
*args: Argume... | [
"Apply",
"torch",
".",
"Tensor",
".",
"to",
"to",
"tensors",
"in",
"a",
"generic",
"data",
"structure",
"."
] | python | train | 40.317073 |
joelfrederico/SciSalt | scisalt/facettools/logbookForm.py | https://github.com/joelfrederico/SciSalt/blob/7bf57c49c7dde0a8b0aa337fbd2fbd527ce7a67f/scisalt/facettools/logbookForm.py#L359-L390 | def submitEntry(self):
"""Process user inputs and subit logbook entry when user clicks Submit button"""
# logType = self.logui.logType.currentText()
mcclogs, physlogs = self.selectedLogs()
success = True
if mcclogs != []:
if not self.acceptedUser("MC... | [
"def",
"submitEntry",
"(",
"self",
")",
":",
"# logType = self.logui.logType.currentText()",
"mcclogs",
",",
"physlogs",
"=",
"self",
".",
"selectedLogs",
"(",
")",
"success",
"=",
"True",
"if",
"mcclogs",
"!=",
"[",
"]",
":",
"if",
"not",
"self",
".",
"acce... | Process user inputs and subit logbook entry when user clicks Submit button | [
"Process",
"user",
"inputs",
"and",
"subit",
"logbook",
"entry",
"when",
"user",
"clicks",
"Submit",
"button"
] | python | valid | 37.75 |
woolfson-group/isambard | isambard/ampal/protein.py | https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/protein.py#L1069-L1141 | def n_cap(self, n_cap='acetyl', cap_dihedral=None):
"""Adds an N-terminal acetamide cap.
Notes
-----
Default behaviour is to duplicate the dihedral angle of the
succeeding residues such that the orientation of the carbonyl
of the acetyl will resemble that of the first re... | [
"def",
"n_cap",
"(",
"self",
",",
"n_cap",
"=",
"'acetyl'",
",",
"cap_dihedral",
"=",
"None",
")",
":",
"if",
"n_cap",
"==",
"'acetyl'",
":",
"methylacetamide",
"=",
"Ligand",
"(",
"atoms",
"=",
"None",
",",
"mol_code",
"=",
"'UNK'",
",",
"is_hetero",
... | Adds an N-terminal acetamide cap.
Notes
-----
Default behaviour is to duplicate the dihedral angle of the
succeeding residues such that the orientation of the carbonyl
of the acetyl will resemble that of the first residue. This
can be adjusted by supplying a cap_dihedral... | [
"Adds",
"an",
"N",
"-",
"terminal",
"acetamide",
"cap",
"."
] | python | train | 49.164384 |
happyleavesaoc/python-limitlessled | limitlessled/group/commands/legacy.py | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/commands/legacy.py#L29-L42 | def get_bytes(self, bridge):
"""
Gets the full command as bytes.
:param bridge: The bridge, to which the command should be sent.
"""
if self.cmd_2 is not None:
cmd = [self.cmd_1, self.cmd_2]
else:
cmd = [self.cmd_1, self.SUFFIX_BYTE]
if br... | [
"def",
"get_bytes",
"(",
"self",
",",
"bridge",
")",
":",
"if",
"self",
".",
"cmd_2",
"is",
"not",
"None",
":",
"cmd",
"=",
"[",
"self",
".",
"cmd_1",
",",
"self",
".",
"cmd_2",
"]",
"else",
":",
"cmd",
"=",
"[",
"self",
".",
"cmd_1",
",",
"sel... | Gets the full command as bytes.
:param bridge: The bridge, to which the command should be sent. | [
"Gets",
"the",
"full",
"command",
"as",
"bytes",
".",
":",
"param",
"bridge",
":",
"The",
"bridge",
"to",
"which",
"the",
"command",
"should",
"be",
"sent",
"."
] | python | train | 30.642857 |
jlesquembre/autopilot | src/autopilot/main.py | https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/main.py#L28-L46 | def new(project_name):
"""Creates a new project"""
try:
locale.setlocale(locale.LC_ALL, '')
except:
print("Warning: Unable to set locale. Expect encoding problems.")
config = utils.get_config()
config['new_project']['project_name'] = project_name
values = new_project_ui(confi... | [
"def",
"new",
"(",
"project_name",
")",
":",
"try",
":",
"locale",
".",
"setlocale",
"(",
"locale",
".",
"LC_ALL",
",",
"''",
")",
"except",
":",
"print",
"(",
"\"Warning: Unable to set locale. Expect encoding problems.\"",
")",
"config",
"=",
"utils",
".",
"... | Creates a new project | [
"Creates",
"a",
"new",
"project"
] | python | train | 28.157895 |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L267-L276 | def word_under_mouse_cursor(self):
"""
Selects the word under the **mouse** cursor.
:return: A QTextCursor with the word under mouse cursor selected.
"""
editor = self._editor
text_cursor = editor.cursorForPosition(editor._last_mouse_pos)
text_cursor = self.word_... | [
"def",
"word_under_mouse_cursor",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"text_cursor",
"=",
"editor",
".",
"cursorForPosition",
"(",
"editor",
".",
"_last_mouse_pos",
")",
"text_cursor",
"=",
"self",
".",
"word_under_cursor",
"(",
"True",... | Selects the word under the **mouse** cursor.
:return: A QTextCursor with the word under mouse cursor selected. | [
"Selects",
"the",
"word",
"under",
"the",
"**",
"mouse",
"**",
"cursor",
"."
] | python | train | 36.9 |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1055-L1063 | def comments(self, ticket, include_inline_images=False):
"""
Retrieve the comments for a ticket.
:param ticket: Ticket object or id
:param include_inline_images: Boolean. If `True`, inline image attachments will be
returned in each comments' `attachments` field alongside non... | [
"def",
"comments",
"(",
"self",
",",
"ticket",
",",
"include_inline_images",
"=",
"False",
")",
":",
"return",
"self",
".",
"_query_zendesk",
"(",
"self",
".",
"endpoint",
".",
"comments",
",",
"'comment'",
",",
"id",
"=",
"ticket",
",",
"include_inline_imag... | Retrieve the comments for a ticket.
:param ticket: Ticket object or id
:param include_inline_images: Boolean. If `True`, inline image attachments will be
returned in each comments' `attachments` field alongside non-inline attachments | [
"Retrieve",
"the",
"comments",
"for",
"a",
"ticket",
"."
] | python | train | 53.666667 |
boundlessgeo/gsconfig | src/geoserver/catalog.py | https://github.com/boundlessgeo/gsconfig/blob/532f561f32b91ea8debea0573c503dd20988bf40/src/geoserver/catalog.py#L618-L669 | def add_granule(self, data, store, workspace=None):
'''Harvest/add a granule into an existing imagemosaic'''
ext = os.path.splitext(data)[-1]
if ext == ".zip":
type = "file.imagemosaic"
upload_data = open(data, 'rb')
headers = {
"Content-type":... | [
"def",
"add_granule",
"(",
"self",
",",
"data",
",",
"store",
",",
"workspace",
"=",
"None",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"data",
")",
"[",
"-",
"1",
"]",
"if",
"ext",
"==",
"\".zip\"",
":",
"type",
"=",
"\"file.... | Harvest/add a granule into an existing imagemosaic | [
"Harvest",
"/",
"add",
"a",
"granule",
"into",
"an",
"existing",
"imagemosaic"
] | python | valid | 32.288462 |
limodou/uliweb | uliweb/contrib/auth/__init__.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/auth/__init__.py#L90-L125 | def set_user_session(user):
"""
Set user session
:param user: user object chould be model instance or dict
:return:
"""
from uliweb import settings, request
user_fieldname = settings.get_var('AUTH/GET_AUTH_USER_FIELDNAME', 'id')
share_session = settings.get_var('AUTH/AUTH_SHARE... | [
"def",
"set_user_session",
"(",
"user",
")",
":",
"from",
"uliweb",
"import",
"settings",
",",
"request",
"user_fieldname",
"=",
"settings",
".",
"get_var",
"(",
"'AUTH/GET_AUTH_USER_FIELDNAME'",
",",
"'id'",
")",
"share_session",
"=",
"settings",
".",
"get_var",
... | Set user session
:param user: user object chould be model instance or dict
:return: | [
"Set",
"user",
"session",
":",
"param",
"user",
":",
"user",
"object",
"chould",
"be",
"model",
"instance",
"or",
"dict",
":",
"return",
":"
] | python | train | 43.305556 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/util.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/util.py#L315-L359 | def read_examples(input_files, batch_size, shuffle, num_epochs=None):
"""Creates readers and queues for reading example protos."""
files = []
for e in input_files:
for path in e.split(','):
files.extend(file_io.get_matching_files(path))
thread_count = multiprocessing.cpu_count()
# The minimum numbe... | [
"def",
"read_examples",
"(",
"input_files",
",",
"batch_size",
",",
"shuffle",
",",
"num_epochs",
"=",
"None",
")",
":",
"files",
"=",
"[",
"]",
"for",
"e",
"in",
"input_files",
":",
"for",
"path",
"in",
"e",
".",
"split",
"(",
"','",
")",
":",
"file... | Creates readers and queues for reading example protos. | [
"Creates",
"readers",
"and",
"queues",
"for",
"reading",
"example",
"protos",
"."
] | python | train | 35.311111 |
saltstack/salt | salt/utils/minions.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/minions.py#L355-L363 | def _check_pillar_exact_minions(self, expr, delimiter, greedy):
'''
Return the minions found by looking via pillar
'''
return self._check_cache_minions(expr,
delimiter,
greedy,
... | [
"def",
"_check_pillar_exact_minions",
"(",
"self",
",",
"expr",
",",
"delimiter",
",",
"greedy",
")",
":",
"return",
"self",
".",
"_check_cache_minions",
"(",
"expr",
",",
"delimiter",
",",
"greedy",
",",
"'pillar'",
",",
"exact_match",
"=",
"True",
")"
] | Return the minions found by looking via pillar | [
"Return",
"the",
"minions",
"found",
"by",
"looking",
"via",
"pillar"
] | python | train | 43.555556 |
lowandrew/OLCTools | spadespipeline/quality.py | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/quality.py#L695-L712 | def run_qaml(self):
"""
Create and run the GenomeQAML system call
"""
logging.info('Running GenomeQAML quality assessment')
qaml_call = 'classify.py -t {tf} -r {rf}'\
.format(tf=self.qaml_path,
rf=self.qaml_report)
make_path(self.reportpath... | [
"def",
"run_qaml",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Running GenomeQAML quality assessment'",
")",
"qaml_call",
"=",
"'classify.py -t {tf} -r {rf}'",
".",
"format",
"(",
"tf",
"=",
"self",
".",
"qaml_path",
",",
"rf",
"=",
"self",
".",
"qam... | Create and run the GenomeQAML system call | [
"Create",
"and",
"run",
"the",
"GenomeQAML",
"system",
"call"
] | python | train | 42.944444 |
xtrementl/focus | focus/parser/parser.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L312-L322 | def _rule_option(self):
""" Parses the production rule::
option : NAME value ';'
Returns list (name, value_list).
"""
name = self._get_token(self.RE_NAME)
value = self._rule_value()
self._expect_token(';')
return [name, value] | [
"def",
"_rule_option",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"_get_token",
"(",
"self",
".",
"RE_NAME",
")",
"value",
"=",
"self",
".",
"_rule_value",
"(",
")",
"self",
".",
"_expect_token",
"(",
"';'",
")",
"return",
"[",
"name",
",",
"va... | Parses the production rule::
option : NAME value ';'
Returns list (name, value_list). | [
"Parses",
"the",
"production",
"rule",
"::",
"option",
":",
"NAME",
"value",
";"
] | python | train | 27.090909 |
beregond/jsonmodels | jsonmodels/utilities.py | https://github.com/beregond/jsonmodels/blob/97a1a6b90a49490fc5a6078f49027055d2e13541/jsonmodels/utilities.py#L60-L90 | def compare_schemas(one, two):
"""Compare two structures that represents JSON schemas.
For comparison you can't use normal comparison, because in JSON schema
lists DO NOT keep order (and Python lists do), so this must be taken into
account during comparison.
Note this wont check all configurations... | [
"def",
"compare_schemas",
"(",
"one",
",",
"two",
")",
":",
"one",
"=",
"_normalize_string_type",
"(",
"one",
")",
"two",
"=",
"_normalize_string_type",
"(",
"two",
")",
"_assert_same_types",
"(",
"one",
",",
"two",
")",
"if",
"isinstance",
"(",
"one",
","... | Compare two structures that represents JSON schemas.
For comparison you can't use normal comparison, because in JSON schema
lists DO NOT keep order (and Python lists do), so this must be taken into
account during comparison.
Note this wont check all configurations, only first one that seems to
mat... | [
"Compare",
"two",
"structures",
"that",
"represents",
"JSON",
"schemas",
"."
] | python | train | 30.774194 |
costastf/locationsharinglib | _CI/library/patch.py | https://github.com/costastf/locationsharinglib/blob/dcd74b0cdb59b951345df84987238763e50ef282/_CI/library/patch.py#L198-L203 | def pathstrip(path, n):
""" Strip n leading components from the given path """
pathlist = [path]
while os.path.dirname(pathlist[0]) != b'':
pathlist[0:1] = os.path.split(pathlist[0])
return b'/'.join(pathlist[n:]) | [
"def",
"pathstrip",
"(",
"path",
",",
"n",
")",
":",
"pathlist",
"=",
"[",
"path",
"]",
"while",
"os",
".",
"path",
".",
"dirname",
"(",
"pathlist",
"[",
"0",
"]",
")",
"!=",
"b''",
":",
"pathlist",
"[",
"0",
":",
"1",
"]",
"=",
"os",
".",
"p... | Strip n leading components from the given path | [
"Strip",
"n",
"leading",
"components",
"from",
"the",
"given",
"path"
] | python | train | 36.666667 |
chimera0/accel-brain-code | Automatic-Summarization/demo/demo_with_n_gram_japanese_web_page.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Automatic-Summarization/demo/demo_with_n_gram_japanese_web_page.py#L10-L41 | def Main(url):
'''
Entry Point.
Args:
url: target url.
'''
# The object of Web-Scraping.
web_scrape = WebScraping()
# Execute Web-Scraping.
document = web_scrape.scrape(url)
# The object of automatic summarization with N-gram.
auto_abstractor = NgramAutoAbstractor... | [
"def",
"Main",
"(",
"url",
")",
":",
"# The object of Web-Scraping.",
"web_scrape",
"=",
"WebScraping",
"(",
")",
"# Execute Web-Scraping.",
"document",
"=",
"web_scrape",
".",
"scrape",
"(",
"url",
")",
"# The object of automatic summarization with N-gram.",
"auto_abstra... | Entry Point.
Args:
url: target url. | [
"Entry",
"Point",
".",
"Args",
":",
"url",
":",
"target",
"url",
"."
] | python | train | 28.09375 |
Phyks/libbmc | libbmc/bibtex.py | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L43-L51 | def write(filename, data):
"""
Create a new BibTeX file.
:param filename: The name of the BibTeX file to write.
:param data: A ``bibtexparser.BibDatabase`` object.
"""
with open(filename, 'w') as fh:
fh.write(bibdatabase2bibtex(data)) | [
"def",
"write",
"(",
"filename",
",",
"data",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"bibdatabase2bibtex",
"(",
"data",
")",
")"
] | Create a new BibTeX file.
:param filename: The name of the BibTeX file to write.
:param data: A ``bibtexparser.BibDatabase`` object. | [
"Create",
"a",
"new",
"BibTeX",
"file",
"."
] | python | train | 28.777778 |
fabioz/PyDev.Debugger | _pydev_imps/_pydev_inspect.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_inspect.py#L312-L320 | def getmoduleinfo(path):
"""Get the module name, suffix, mode, and module type for a given file."""
filename = os.path.basename(path)
suffixes = map(lambda (suffix, mode, mtype):
(-len(suffix), suffix, mode, mtype), imp.get_suffixes())
suffixes.sort() # try longest suffixes first, in ... | [
"def",
"getmoduleinfo",
"(",
"path",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"suffixes",
"=",
"map",
"(",
"lambda",
"(",
"suffix",
",",
"mode",
",",
"mtype",
")",
":",
"(",
"-",
"len",
"(",
"suffix",
")",
... | Get the module name, suffix, mode, and module type for a given file. | [
"Get",
"the",
"module",
"name",
"suffix",
"mode",
"and",
"module",
"type",
"for",
"a",
"given",
"file",
"."
] | python | train | 52.888889 |
markfinger/python-js-host | js_host/bin.py | https://github.com/markfinger/python-js-host/blob/7727138c1eae779335d55fb4d7734698225a6322/js_host/bin.py#L78-L109 | def spawn_managed_host(config_file, manager, connect_on_start=True):
"""
Spawns a managed host, if it is not already running
"""
data = manager.request_host_status(config_file)
is_running = data['started']
# Managed hosts run as persistent processes, so it may already be running
if is_run... | [
"def",
"spawn_managed_host",
"(",
"config_file",
",",
"manager",
",",
"connect_on_start",
"=",
"True",
")",
":",
"data",
"=",
"manager",
".",
"request_host_status",
"(",
"config_file",
")",
"is_running",
"=",
"data",
"[",
"'started'",
"]",
"# Managed hosts run as ... | Spawns a managed host, if it is not already running | [
"Spawns",
"a",
"managed",
"host",
"if",
"it",
"is",
"not",
"already",
"running"
] | python | train | 26.90625 |
zikzakmedia/python-mediawiki | mediawiki/wikimarkup/__init__.py | https://github.com/zikzakmedia/python-mediawiki/blob/7c26732efa520e16c35350815ce98cd7610a0bcb/mediawiki/wikimarkup/__init__.py#L690-L707 | def decodeTagAttributes(self, text):
"""docstring for decodeTagAttributes"""
attribs = {}
if text.strip() == u'':
return attribs
scanner = _attributePat.scanner(text)
match = scanner.search()
while match:
key, val1, val2, val3, val4 = match.groups()
value = val1 or val2 or val3 or val4
if value:... | [
"def",
"decodeTagAttributes",
"(",
"self",
",",
"text",
")",
":",
"attribs",
"=",
"{",
"}",
"if",
"text",
".",
"strip",
"(",
")",
"==",
"u''",
":",
"return",
"attribs",
"scanner",
"=",
"_attributePat",
".",
"scanner",
"(",
"text",
")",
"match",
"=",
... | docstring for decodeTagAttributes | [
"docstring",
"for",
"decodeTagAttributes"
] | python | train | 26 |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L280-L308 | def find_button(browser, value):
"""
Find a button with the given value.
Searches for the following different kinds of buttons:
<input type="submit">
<input type="reset">
<input type="button">
<input type="image">
<button>
<{a,p,div,span,...} role="button">
... | [
"def",
"find_button",
"(",
"browser",
",",
"value",
")",
":",
"field_types",
"=",
"(",
"'submit'",
",",
"'reset'",
",",
"'button-element'",
",",
"'button'",
",",
"'image'",
",",
"'button-role'",
",",
")",
"return",
"reduce",
"(",
"operator",
".",
"add",
",... | Find a button with the given value.
Searches for the following different kinds of buttons:
<input type="submit">
<input type="reset">
<input type="button">
<input type="image">
<button>
<{a,p,div,span,...} role="button">
Returns: an :class:`ElementSelector` | [
"Find",
"a",
"button",
"with",
"the",
"given",
"value",
"."
] | python | train | 21.827586 |
iqbal-lab-org/cluster_vcf_records | cluster_vcf_records/vcf_record.py | https://github.com/iqbal-lab-org/cluster_vcf_records/blob/0db26af36b6da97a7361364457d2152dc756055c/cluster_vcf_records/vcf_record.py#L402-L410 | def to_record_per_alt(self):
'''Returns list of vcf_records. One per variant
in the ALT column. Does not change INFO/FORMAT etc columns, which
means that they are now broken'''
record_list = []
for alt in self.ALT:
record_list.append(copy.copy(self))
recor... | [
"def",
"to_record_per_alt",
"(",
"self",
")",
":",
"record_list",
"=",
"[",
"]",
"for",
"alt",
"in",
"self",
".",
"ALT",
":",
"record_list",
".",
"append",
"(",
"copy",
".",
"copy",
"(",
"self",
")",
")",
"record_list",
"[",
"-",
"1",
"]",
".",
"AL... | Returns list of vcf_records. One per variant
in the ALT column. Does not change INFO/FORMAT etc columns, which
means that they are now broken | [
"Returns",
"list",
"of",
"vcf_records",
".",
"One",
"per",
"variant",
"in",
"the",
"ALT",
"column",
".",
"Does",
"not",
"change",
"INFO",
"/",
"FORMAT",
"etc",
"columns",
"which",
"means",
"that",
"they",
"are",
"now",
"broken"
] | python | train | 40.111111 |
JensRantil/rewind | rewind/server/eventstores.py | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L915-L951 | def from_config(config, **options):
"""Instantiate an `SyncedRotationEventStores` from config.
Parameters:
config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this even... | [
"def",
"from_config",
"(",
"config",
",",
"*",
"*",
"options",
")",
":",
"required_args",
"=",
"(",
"'storage-backends'",
",",
")",
"optional_args",
"=",
"{",
"'events_per_batch'",
":",
"25000",
"}",
"rconfig",
".",
"check_config_options",
"(",
"\"SyncedRotation... | Instantiate an `SyncedRotationEventStores` from config.
Parameters:
config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this event store. Warning will be logged
... | [
"Instantiate",
"an",
"SyncedRotationEventStores",
"from",
"config",
"."
] | python | train | 40.972973 |
JamesRamm/longclaw | longclaw/orders/api.py | https://github.com/JamesRamm/longclaw/blob/8bbf2e6d703271b815ec111813c7c5d1d4e4e810/longclaw/orders/api.py#L14-L19 | def refund_order(self, request, pk):
"""Refund the order specified by the pk
"""
order = Order.objects.get(id=pk)
order.refund()
return Response(status=status.HTTP_204_NO_CONTENT) | [
"def",
"refund_order",
"(",
"self",
",",
"request",
",",
"pk",
")",
":",
"order",
"=",
"Order",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"pk",
")",
"order",
".",
"refund",
"(",
")",
"return",
"Response",
"(",
"status",
"=",
"status",
".",
"HTTP_... | Refund the order specified by the pk | [
"Refund",
"the",
"order",
"specified",
"by",
"the",
"pk"
] | python | train | 35.666667 |
PySimpleGUI/PySimpleGUI | PySimpleGUIWx/PySimpleGUIWx.py | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWx/PySimpleGUIWx.py#L6768-L6821 | def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_fol... | [
"def",
"PopupGetFolder",
"(",
"message",
",",
"title",
"=",
"None",
",",
"default_path",
"=",
"''",
",",
"no_window",
"=",
"False",
",",
"size",
"=",
"(",
"None",
",",
"None",
")",
",",
"button_color",
"=",
"None",
",",
"background_color",
"=",
"None",
... | Display popup with text entry field and browse button. Browse for folder
:param message:
:param default_path:
:param no_window:
:param size:
:param button_color:
:param background_color:
:param text_color:
:param icon:
:param font:
:param no_titlebar:
:param grab_anywhere:
... | [
"Display",
"popup",
"with",
"text",
"entry",
"field",
"and",
"browse",
"button",
".",
"Browse",
"for",
"folder",
":",
"param",
"message",
":",
":",
"param",
"default_path",
":",
":",
"param",
"no_window",
":",
":",
"param",
"size",
":",
":",
"param",
"bu... | python | train | 36 |
hanguokai/youku | youku/youku_users.py | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_users.py#L115-L129 | def create_friendship(self, access_token,
user_id=None, user_name=None):
"""doc: http://open.youku.com/docs/doc?id=28
"""
url = 'https://openapi.youku.com/v2/users/friendship/create.json'
data = {
'client_id': self.client_id,
'access_toke... | [
"def",
"create_friendship",
"(",
"self",
",",
"access_token",
",",
"user_id",
"=",
"None",
",",
"user_name",
"=",
"None",
")",
":",
"url",
"=",
"'https://openapi.youku.com/v2/users/friendship/create.json'",
"data",
"=",
"{",
"'client_id'",
":",
"self",
".",
"clien... | doc: http://open.youku.com/docs/doc?id=28 | [
"doc",
":",
"http",
":",
"//",
"open",
".",
"youku",
".",
"com",
"/",
"docs",
"/",
"doc?id",
"=",
"28"
] | python | train | 35.2 |
SandstoneHPC/sandstone-ide | sandstone/lib/filesystem/handlers.py | https://github.com/SandstoneHPC/sandstone-ide/blob/7a47947fb07281c3e3018042863dc67e7e56dc04/sandstone/lib/filesystem/handlers.py#L56-L66 | def _rename(self):
"""
Called during a PUT request where the action specifies
a rename operation. Returns resource URI of the renamed file.
"""
newname = self.action['newname']
try:
newpath = self.fs.rename(self.fp,newname)
except OSError:
... | [
"def",
"_rename",
"(",
"self",
")",
":",
"newname",
"=",
"self",
".",
"action",
"[",
"'newname'",
"]",
"try",
":",
"newpath",
"=",
"self",
".",
"fs",
".",
"rename",
"(",
"self",
".",
"fp",
",",
"newname",
")",
"except",
"OSError",
":",
"raise",
"to... | Called during a PUT request where the action specifies
a rename operation. Returns resource URI of the renamed file. | [
"Called",
"during",
"a",
"PUT",
"request",
"where",
"the",
"action",
"specifies",
"a",
"rename",
"operation",
".",
"Returns",
"resource",
"URI",
"of",
"the",
"renamed",
"file",
"."
] | python | train | 33.181818 |
thespacedoctor/qubits | qubits/cl_utils.py | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/cl_utils.py#L49-L433 | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"WARNING\"",
",",
"options_first",
"=",
"False",
... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | python | train | 40.937662 |
tanghaibao/goatools | goatools/grouper/wr_sections.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L182-L202 | def wr_txt_section_hdrgos(self, fout_txt, sortby=None, prt_section=True):
"""Write high GO IDs that are actually used to group current set of GO IDs."""
sec2d_go = self.grprobj.get_sections_2d() # lists of GO IDs
sec2d_nt = self.get_sections_2dnt(sec2d_go) # lists of GO Grouper namedtuples
... | [
"def",
"wr_txt_section_hdrgos",
"(",
"self",
",",
"fout_txt",
",",
"sortby",
"=",
"None",
",",
"prt_section",
"=",
"True",
")",
":",
"sec2d_go",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"# lists of GO IDs",
"sec2d_nt",
"=",
"self",
".",... | Write high GO IDs that are actually used to group current set of GO IDs. | [
"Write",
"high",
"GO",
"IDs",
"that",
"are",
"actually",
"used",
"to",
"group",
"current",
"set",
"of",
"GO",
"IDs",
"."
] | python | train | 54.047619 |
cackharot/suds-py3 | suds/sax/element.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/sax/element.py#L369-L386 | def replaceChild(self, child, content):
"""
Replace I{child} with the specified I{content}.
@param child: A child element.
@type child: L{Element}
@param content: An element or collection of elements.
@type content: L{Element} or [L{Element},]
"""
if child... | [
"def",
"replaceChild",
"(",
"self",
",",
"child",
",",
"content",
")",
":",
"if",
"child",
"not",
"in",
"self",
".",
"children",
":",
"raise",
"Exception",
"(",
"'child not-found'",
")",
"index",
"=",
"self",
".",
"children",
".",
"index",
"(",
"child",
... | Replace I{child} with the specified I{content}.
@param child: A child element.
@type child: L{Element}
@param content: An element or collection of elements.
@type content: L{Element} or [L{Element},] | [
"Replace",
"I",
"{",
"child",
"}",
"with",
"the",
"specified",
"I",
"{",
"content",
"}",
"."
] | python | train | 36.888889 |
rpcope1/PythonConfluenceAPI | PythonConfluenceAPI/api.py | https://github.com/rpcope1/PythonConfluenceAPI/blob/b7f0ca2a390f964715fdf3a60b5b0c5ef7116d40/PythonConfluenceAPI/api.py#L691-L705 | def get_space_information(self, space_key, expand=None, callback=None):
"""
Returns information about a space.
:param space_key (string): A string containing the key of the space.
:param expand (string): OPTIONAL: A comma separated list of properties to expand on the space. Default: Empt... | [
"def",
"get_space_information",
"(",
"self",
",",
"space_key",
",",
"expand",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"expand",
":",
"params",
"[",
"\"expand\"",
"]",
"=",
"expand",
"return",
"self",
".",
"_s... | Returns information about a space.
:param space_key (string): A string containing the key of the space.
:param expand (string): OPTIONAL: A comma separated list of properties to expand on the space. Default: Empty.
:param callback: OPTIONAL: The callback to execute on the resulting data, before ... | [
"Returns",
"information",
"about",
"a",
"space",
".",
":",
"param",
"space_key",
"(",
"string",
")",
":",
"A",
"string",
"containing",
"the",
"key",
"of",
"the",
"space",
".",
":",
"param",
"expand",
"(",
"string",
")",
":",
"OPTIONAL",
":",
"A",
"comm... | python | train | 61.533333 |
galaxyproject/pulsar | pulsar/managers/queued_external_drmaa.py | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/queued_external_drmaa.py#L91-L108 | def _handle_default(value, script_name):
""" There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer s... | [
"def",
"_handle_default",
"(",
"value",
",",
"script_name",
")",
":",
"if",
"value",
":",
"return",
"value",
"installed_script",
"=",
"which",
"(",
"\"pulsar-%s\"",
"%",
"script_name",
".",
"replace",
"(",
"\"_\"",
",",
"\"-\"",
")",
")",
"if",
"installed_sc... | There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer style variant of these
scripts and returns the... | [
"There",
"are",
"two",
"potential",
"variants",
"of",
"these",
"scripts",
"the",
"Bash",
"scripts",
"that",
"are",
"meant",
"to",
"be",
"run",
"within",
"PULSAR_ROOT",
"for",
"older",
"-",
"style",
"installs",
"and",
"the",
"binaries",
"created",
"by",
"setu... | python | train | 37.611111 |
saltstack/salt | salt/returners/postgres_local_cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L224-L253 | def returner(load):
'''
Return data to a postgres server
'''
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
sql = '''INSERT INTO salt_returns
(fun, jid, return, id, success)
VALUES (%s, %s, %s, %s, %s)'''
try:
ret = six.text_ty... | [
"def",
"returner",
"(",
"load",
")",
":",
"conn",
"=",
"_get_conn",
"(",
")",
"if",
"conn",
"is",
"None",
":",
"return",
"None",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"sql",
"=",
"'''INSERT INTO salt_returns\n (fun, jid, return, id, success)\n ... | Return data to a postgres server | [
"Return",
"data",
"to",
"a",
"postgres",
"server"
] | python | train | 25.566667 |
astrocatalogs/astrocats | astrocats/catalog/catalog.py | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L754-L851 | def load_stubs(self, log_mem=False):
"""Load all events in their `stub` (name, alias, etc only) form.
Used in `update` mode.
"""
# Initialize parameter related to diagnostic output of memory usage
if log_mem:
import psutil
process = psutil.Process(os.getp... | [
"def",
"load_stubs",
"(",
"self",
",",
"log_mem",
"=",
"False",
")",
":",
"# Initialize parameter related to diagnostic output of memory usage",
"if",
"log_mem",
":",
"import",
"psutil",
"process",
"=",
"psutil",
".",
"Process",
"(",
"os",
".",
"getpid",
"(",
")",... | Load all events in their `stub` (name, alias, etc only) form.
Used in `update` mode. | [
"Load",
"all",
"events",
"in",
"their",
"stub",
"(",
"name",
"alias",
"etc",
"only",
")",
"form",
"."
] | python | train | 43.285714 |
JetBrains/teamcity-messages | teamcity/pylint_reporter.py | https://github.com/JetBrains/teamcity-messages/blob/44f6d1fde33a48547a8f9fe31814522347a87b39/teamcity/pylint_reporter.py#L64-L71 | def display_reports(self, layout):
"""Issues the final PyLint score as a TeamCity build statistic value"""
try:
score = self.linter.stats['global_note']
except (AttributeError, KeyError):
pass
else:
self.tc.message('buildStatisticValue', key='PyLintSco... | [
"def",
"display_reports",
"(",
"self",
",",
"layout",
")",
":",
"try",
":",
"score",
"=",
"self",
".",
"linter",
".",
"stats",
"[",
"'global_note'",
"]",
"except",
"(",
"AttributeError",
",",
"KeyError",
")",
":",
"pass",
"else",
":",
"self",
".",
"tc"... | Issues the final PyLint score as a TeamCity build statistic value | [
"Issues",
"the",
"final",
"PyLint",
"score",
"as",
"a",
"TeamCity",
"build",
"statistic",
"value"
] | python | train | 41.875 |
saltstack/salt | salt/modules/pkgng.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkgng.py#L129-L141 | def _contextkey(jail=None, chroot=None, root=None, prefix='pkg.list_pkgs'):
'''
As this module is designed to manipulate packages in jails and chroots, use
the passed jail/chroot to ensure that a key in the __context__ dict that is
unique to that jail/chroot is used.
'''
if jail:
return ... | [
"def",
"_contextkey",
"(",
"jail",
"=",
"None",
",",
"chroot",
"=",
"None",
",",
"root",
"=",
"None",
",",
"prefix",
"=",
"'pkg.list_pkgs'",
")",
":",
"if",
"jail",
":",
"return",
"six",
".",
"text_type",
"(",
"prefix",
")",
"+",
"'.jail_{0}'",
".",
... | As this module is designed to manipulate packages in jails and chroots, use
the passed jail/chroot to ensure that a key in the __context__ dict that is
unique to that jail/chroot is used. | [
"As",
"this",
"module",
"is",
"designed",
"to",
"manipulate",
"packages",
"in",
"jails",
"and",
"chroots",
"use",
"the",
"passed",
"jail",
"/",
"chroot",
"to",
"ensure",
"that",
"a",
"key",
"in",
"the",
"__context__",
"dict",
"that",
"is",
"unique",
"to",
... | python | train | 41.384615 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.