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 |
|---|---|---|---|---|---|---|---|---|---|
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavcrc.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavcrc.py#L14-L21 | def accumulate(self, buf):
'''add in some more bytes'''
accum = self.crc
for b in buf:
tmp = b ^ (accum & 0xff)
tmp = (tmp ^ (tmp<<4)) & 0xFF
accum = (accum>>8) ^ (tmp<<8) ^ (tmp<<3) ^ (tmp>>4)
self.crc = accum | [
"def",
"accumulate",
"(",
"self",
",",
"buf",
")",
":",
"accum",
"=",
"self",
".",
"crc",
"for",
"b",
"in",
"buf",
":",
"tmp",
"=",
"b",
"^",
"(",
"accum",
"&",
"0xff",
")",
"tmp",
"=",
"(",
"tmp",
"^",
"(",
"tmp",
"<<",
"4",
")",
")",
"&",... | add in some more bytes | [
"add",
"in",
"some",
"more",
"bytes"
] | python | train | 33.875 |
twilio/twilio-python | twilio/rest/preview/sync/service/sync_map/sync_map_item.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/sync/service/sync_map/sync_map_item.py#L229-L243 | def get_instance(self, payload):
"""
Build an instance of SyncMapItemInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance
:rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"SyncMapItemInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
"map_sid",
"=",
"self",
".",
"_s... | Build an instance of SyncMapItemInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance
:rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance | [
"Build",
"an",
"instance",
"of",
"SyncMapItemInstance"
] | python | train | 35.6 |
gwpy/gwpy | gwpy/cli/qtransform.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/cli/qtransform.py#L106-L151 | def _finalize_arguments(self, args):
"""Derive standard args from our weird ones
:type args: Namespace with command line arguments
"""
gps = args.gps
search = args.search
# ensure we have enough data for filter settling
max_plot = max(args.plot)
search = m... | [
"def",
"_finalize_arguments",
"(",
"self",
",",
"args",
")",
":",
"gps",
"=",
"args",
".",
"gps",
"search",
"=",
"args",
".",
"search",
"# ensure we have enough data for filter settling",
"max_plot",
"=",
"max",
"(",
"args",
".",
"plot",
")",
"search",
"=",
... | Derive standard args from our weird ones
:type args: Namespace with command line arguments | [
"Derive",
"standard",
"args",
"from",
"our",
"weird",
"ones",
":",
"type",
"args",
":",
"Namespace",
"with",
"command",
"line",
"arguments"
] | python | train | 31.391304 |
lrq3000/pyFileFixity | pyFileFixity/lib/brownanrs/ff.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L69-L121 | def find_prime_polynomials(generator=2, c_exp=8, fast_primes=False, single=False):
'''Compute the list of prime polynomials for the given generator and galois field characteristic exponent.'''
# fast_primes will output less results but will be significantly faster.
# single will output the first prime polyn... | [
"def",
"find_prime_polynomials",
"(",
"generator",
"=",
"2",
",",
"c_exp",
"=",
"8",
",",
"fast_primes",
"=",
"False",
",",
"single",
"=",
"False",
")",
":",
"# fast_primes will output less results but will be significantly faster.",
"# single will output the first prime po... | Compute the list of prime polynomials for the given generator and galois field characteristic exponent. | [
"Compute",
"the",
"list",
"of",
"prime",
"polynomials",
"for",
"the",
"given",
"generator",
"and",
"galois",
"field",
"characteristic",
"exponent",
"."
] | python | train | 98 |
maxcutler/python-wordpress-xmlrpc | wordpress_xmlrpc/fieldmaps.py | https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/fieldmaps.py#L44-L54 | def get_outputs(self, input_value):
"""
Generate a set of output values for a given input.
"""
output_value = self.convert_to_xmlrpc(input_value)
output = {}
for name in self.output_names:
output[name] = output_value
return output | [
"def",
"get_outputs",
"(",
"self",
",",
"input_value",
")",
":",
"output_value",
"=",
"self",
".",
"convert_to_xmlrpc",
"(",
"input_value",
")",
"output",
"=",
"{",
"}",
"for",
"name",
"in",
"self",
".",
"output_names",
":",
"output",
"[",
"name",
"]",
"... | Generate a set of output values for a given input. | [
"Generate",
"a",
"set",
"of",
"output",
"values",
"for",
"a",
"given",
"input",
"."
] | python | train | 27.272727 |
todddeluca/python-vagrant | vagrant/__init__.py | https://github.com/todddeluca/python-vagrant/blob/83b26f9337b1f2cb6314210923bbd189e7c9199e/vagrant/__init__.py#L965-L976 | def _run_vagrant_command(self, args):
'''
Run a vagrant command and return its stdout.
args: A sequence of arguments to a vagrant command line.
e.g. ['up', 'my_vm_name', '--no-provision'] or
['up', None, '--no-provision'] for a non-Multi-VM environment.
'''
# Make... | [
"def",
"_run_vagrant_command",
"(",
"self",
",",
"args",
")",
":",
"# Make subprocess command",
"command",
"=",
"self",
".",
"_make_vagrant_command",
"(",
"args",
")",
"with",
"self",
".",
"err_cm",
"(",
")",
"as",
"err_fh",
":",
"return",
"compat",
".",
"de... | Run a vagrant command and return its stdout.
args: A sequence of arguments to a vagrant command line.
e.g. ['up', 'my_vm_name', '--no-provision'] or
['up', None, '--no-provision'] for a non-Multi-VM environment. | [
"Run",
"a",
"vagrant",
"command",
"and",
"return",
"its",
"stdout",
".",
"args",
":",
"A",
"sequence",
"of",
"arguments",
"to",
"a",
"vagrant",
"command",
"line",
".",
"e",
".",
"g",
".",
"[",
"up",
"my_vm_name",
"--",
"no",
"-",
"provision",
"]",
"o... | python | train | 47.916667 |
ChrisBeaumont/smother | smother/cli.py | https://github.com/ChrisBeaumont/smother/blob/65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb/smother/cli.py#L124-L130 | def to_coverage(ctx):
"""
Produce a .coverage file from a smother file
"""
sm = Smother.load(ctx.obj['report'])
sm.coverage = coverage.coverage()
sm.write_coverage() | [
"def",
"to_coverage",
"(",
"ctx",
")",
":",
"sm",
"=",
"Smother",
".",
"load",
"(",
"ctx",
".",
"obj",
"[",
"'report'",
"]",
")",
"sm",
".",
"coverage",
"=",
"coverage",
".",
"coverage",
"(",
")",
"sm",
".",
"write_coverage",
"(",
")"
] | Produce a .coverage file from a smother file | [
"Produce",
"a",
".",
"coverage",
"file",
"from",
"a",
"smother",
"file"
] | python | train | 26.142857 |
klahnakoski/pyLibrary | mo_dots/lists.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L248-L257 | def not_right(self, num):
"""
WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE LEFT [:-num:]
"""
if num == None:
return FlatList([_get_list(self)[:-1:]])
if num <= 0:
return FlatList.EMPTY
return FlatList(_get_list(self)[:-num:]) | [
"def",
"not_right",
"(",
"self",
",",
"num",
")",
":",
"if",
"num",
"==",
"None",
":",
"return",
"FlatList",
"(",
"[",
"_get_list",
"(",
"self",
")",
"[",
":",
"-",
"1",
":",
"]",
"]",
")",
"if",
"num",
"<=",
"0",
":",
"return",
"FlatList",
"."... | WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE LEFT [:-num:] | [
"WITH",
"SLICES",
"BEING",
"FLAT",
"WE",
"NEED",
"A",
"SIMPLE",
"WAY",
"TO",
"SLICE",
"FROM",
"THE",
"LEFT",
"[",
":",
"-",
"num",
":",
"]"
] | python | train | 30.7 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/ServiceProxy.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/ServiceProxy.py#L192-L302 | def _call(self, name, soapheaders):
"""return the Call to the named remote web service method.
closure used to prevent multiple values for name and soapheaders
parameters
"""
def call_closure(*args, **kwargs):
"""Call the named remote web service method."""... | [
"def",
"_call",
"(",
"self",
",",
"name",
",",
"soapheaders",
")",
":",
"def",
"call_closure",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Call the named remote web service method.\"\"\"",
"if",
"len",
"(",
"args",
")",
"and",
"len",
"(",
"... | return the Call to the named remote web service method.
closure used to prevent multiple values for name and soapheaders
parameters | [
"return",
"the",
"Call",
"to",
"the",
"named",
"remote",
"web",
"service",
"method",
".",
"closure",
"used",
"to",
"prevent",
"multiple",
"values",
"for",
"name",
"and",
"soapheaders",
"parameters"
] | python | train | 44.675676 |
marcomusy/vtkplotter | vtkplotter/shapes.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/shapes.py#L498-L545 | def Arrow(startPoint, endPoint, s=None, c="r", alpha=1, res=12):
"""
Build a 3D arrow from `startPoint` to `endPoint` of section size `s`,
expressed as the fraction of the window size.
.. note:: If ``s=None`` the arrow is scaled proportionally to its length,
otherwise it represents th... | [
"def",
"Arrow",
"(",
"startPoint",
",",
"endPoint",
",",
"s",
"=",
"None",
",",
"c",
"=",
"\"r\"",
",",
"alpha",
"=",
"1",
",",
"res",
"=",
"12",
")",
":",
"axis",
"=",
"np",
".",
"array",
"(",
"endPoint",
")",
"-",
"np",
".",
"array",
"(",
"... | Build a 3D arrow from `startPoint` to `endPoint` of section size `s`,
expressed as the fraction of the window size.
.. note:: If ``s=None`` the arrow is scaled proportionally to its length,
otherwise it represents the fraction of the window size.
|OrientedArrow| | [
"Build",
"a",
"3D",
"arrow",
"from",
"startPoint",
"to",
"endPoint",
"of",
"section",
"size",
"s",
"expressed",
"as",
"the",
"fraction",
"of",
"the",
"window",
"size",
".",
"..",
"note",
"::",
"If",
"s",
"=",
"None",
"the",
"arrow",
"is",
"scaled",
"pr... | python | train | 30.208333 |
tcalmant/ipopo | pelix/http/__init__.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/http/__init__.py#L335-L380 | def send_content(
self,
http_code,
content,
mime_type="text/html",
http_message=None,
content_length=-1,
):
# type: (int, str, str, str, int) -> None
"""
Utility method to send the given content as an answer.
You can still use get_wfile... | [
"def",
"send_content",
"(",
"self",
",",
"http_code",
",",
"content",
",",
"mime_type",
"=",
"\"text/html\"",
",",
"http_message",
"=",
"None",
",",
"content_length",
"=",
"-",
"1",
",",
")",
":",
"# type: (int, str, str, str, int) -> None",
"self",
".",
"set_re... | Utility method to send the given content as an answer.
You can still use get_wfile or write afterwards, if you forced the
content length.
If content_length is negative (default), it will be computed as the
length of the content;
if it is positive, the given value will be used;
... | [
"Utility",
"method",
"to",
"send",
"the",
"given",
"content",
"as",
"an",
"answer",
".",
"You",
"can",
"still",
"use",
"get_wfile",
"or",
"write",
"afterwards",
"if",
"you",
"forced",
"the",
"content",
"length",
"."
] | python | train | 32.543478 |
QUANTAXIS/QUANTAXIS | QUANTAXIS/QAUtil/QADate_trade.py | https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAUtil/QADate_trade.py#L7341-L7367 | def QA_util_get_real_date(date, trade_list=trade_date_sse, towards=-1):
"""
获取真实的交易日期,其中,第三个参数towards是表示向前/向后推
towards=1 日期向后迭代
towards=-1 日期向前迭代
@ yutiansut
"""
date = str(date)[0:10]
if towards == 1:
while date not in trade_list:
date = str(
datetim... | [
"def",
"QA_util_get_real_date",
"(",
"date",
",",
"trade_list",
"=",
"trade_date_sse",
",",
"towards",
"=",
"-",
"1",
")",
":",
"date",
"=",
"str",
"(",
"date",
")",
"[",
"0",
":",
"10",
"]",
"if",
"towards",
"==",
"1",
":",
"while",
"date",
"not",
... | 获取真实的交易日期,其中,第三个参数towards是表示向前/向后推
towards=1 日期向后迭代
towards=-1 日期向前迭代
@ yutiansut | [
"获取真实的交易日期",
"其中",
"第三个参数towards是表示向前",
"/",
"向后推",
"towards",
"=",
"1",
"日期向后迭代",
"towards",
"=",
"-",
"1",
"日期向前迭代",
"@",
"yutiansut"
] | python | train | 30.148148 |
bskinn/opan | opan/utils/symm.py | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L350-L370 | def geom_check_axis(g, atwts, ax,
nmax=_DEF.SYMM_MATCH_NMAX,
tol=_DEF.SYMM_MATCH_TOL):
""" [Get max proper order and reflection for an axis]
.. todo:: Complete geom_parse_axis docstring
"""
# Imports
import numpy as np
# Store the max found rotation order of the geometry.
... | [
"def",
"geom_check_axis",
"(",
"g",
",",
"atwts",
",",
"ax",
",",
"nmax",
"=",
"_DEF",
".",
"SYMM_MATCH_NMAX",
",",
"tol",
"=",
"_DEF",
".",
"SYMM_MATCH_TOL",
")",
":",
"# Imports",
"import",
"numpy",
"as",
"np",
"# Store the max found rotation order of the geom... | [Get max proper order and reflection for an axis]
.. todo:: Complete geom_parse_axis docstring | [
"[",
"Get",
"max",
"proper",
"order",
"and",
"reflection",
"for",
"an",
"axis",
"]"
] | python | train | 28.238095 |
softlayer/softlayer-python | SoftLayer/managers/firewall.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/firewall.py#L168-L212 | def _get_fwl_port_speed(self, server_id, is_virt=True):
"""Determines the appropriate speed for a firewall.
:param int server_id: The ID of server the firewall is for
:param bool is_virt: True if the server_id is for a virtual server
:returns: a integer representing the Mbps speed of a ... | [
"def",
"_get_fwl_port_speed",
"(",
"self",
",",
"server_id",
",",
"is_virt",
"=",
"True",
")",
":",
"fwl_port_speed",
"=",
"0",
"if",
"is_virt",
":",
"mask",
"=",
"(",
"'primaryNetworkComponent[maxSpeed]'",
")",
"svc",
"=",
"self",
".",
"client",
"[",
"'Virt... | Determines the appropriate speed for a firewall.
:param int server_id: The ID of server the firewall is for
:param bool is_virt: True if the server_id is for a virtual server
:returns: a integer representing the Mbps speed of a firewall | [
"Determines",
"the",
"appropriate",
"speed",
"for",
"a",
"firewall",
"."
] | python | train | 42.911111 |
nccgroup/Scout2 | AWSScout2/services/route53.py | https://github.com/nccgroup/Scout2/blob/5d86d46d7ed91a92000496189e9cfa6b98243937/AWSScout2/services/route53.py#L30-L40 | def parse_domains(self, domain, params):
"""
Parse a single Route53Domains domain
"""
domain_id = self.get_non_aws_id(domain['DomainName'])
domain['name'] = domain.pop('DomainName')
#TODO: Get Dnssec info when available
#api_client = params['api_client']
#... | [
"def",
"parse_domains",
"(",
"self",
",",
"domain",
",",
"params",
")",
":",
"domain_id",
"=",
"self",
".",
"get_non_aws_id",
"(",
"domain",
"[",
"'DomainName'",
"]",
")",
"domain",
"[",
"'name'",
"]",
"=",
"domain",
".",
"pop",
"(",
"'DomainName'",
")",... | Parse a single Route53Domains domain | [
"Parse",
"a",
"single",
"Route53Domains",
"domain"
] | python | train | 42.272727 |
alfred82santa/dirty-models | dirty_models/models.py | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L726-L760 | def _get_field_type(self, key, value):
"""
Helper to create field object based on value type
"""
if isinstance(value, bool):
return BooleanField(name=key)
elif isinstance(value, int):
return IntegerField(name=key)
elif isinstance(value, float):
... | [
"def",
"_get_field_type",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"BooleanField",
"(",
"name",
"=",
"key",
")",
"elif",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"ret... | Helper to create field object based on value type | [
"Helper",
"to",
"create",
"field",
"object",
"based",
"on",
"value",
"type"
] | python | train | 42.542857 |
its-rigs/Trolly | trolly/organisation.py | https://github.com/its-rigs/Trolly/blob/483dc94c352df40dc05ead31820b059b2545cf82/trolly/organisation.py#L38-L53 | def get_members(self, **query_params):
'''
Get all members attached to this organisation. Returns a list of
Member objects
Returns:
list(Member): The members attached to this organisation
'''
members = self.get_members_json(self.base_uri,
... | [
"def",
"get_members",
"(",
"self",
",",
"*",
"*",
"query_params",
")",
":",
"members",
"=",
"self",
".",
"get_members_json",
"(",
"self",
".",
"base_uri",
",",
"query_params",
"=",
"query_params",
")",
"members_list",
"=",
"[",
"]",
"for",
"member_json",
"... | Get all members attached to this organisation. Returns a list of
Member objects
Returns:
list(Member): The members attached to this organisation | [
"Get",
"all",
"members",
"attached",
"to",
"this",
"organisation",
".",
"Returns",
"a",
"list",
"of",
"Member",
"objects"
] | python | test | 31.75 |
bear/parsedatetime | parsedatetime/__init__.py | https://github.com/bear/parsedatetime/blob/830775dc5e36395622b41f12317f5e10c303d3a2/parsedatetime/__init__.py#L1940-L2244 | def nlp(self, inputString, sourceTime=None, version=None):
"""Utilizes parse() after making judgements about what datetime
information belongs together.
It makes logical groupings based on proximity and returns a parsed
datetime for each matched grouping of datetime text, along with
... | [
"def",
"nlp",
"(",
"self",
",",
"inputString",
",",
"sourceTime",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"orig_inputstring",
"=",
"inputString",
"# replace periods at the end of sentences w/ spaces",
"# opposed to removing them altogether in order to",
"# retai... | Utilizes parse() after making judgements about what datetime
information belongs together.
It makes logical groupings based on proximity and returns a parsed
datetime for each matched grouping of datetime text, along with
location info within the given inputString.
@type input... | [
"Utilizes",
"parse",
"()",
"after",
"making",
"judgements",
"about",
"what",
"datetime",
"information",
"belongs",
"together",
"."
] | python | train | 46.790164 |
confluentinc/confluent-kafka-python | examples/adminapi.py | https://github.com/confluentinc/confluent-kafka-python/blob/5a8aeb741609e61eaccafff2a67fa494dd549e8b/examples/adminapi.py#L143-L232 | def example_delta_alter_configs(a, args):
"""
The AlterConfigs Kafka API requires all configuration to be passed,
any left out configuration properties will revert to their default settings.
This example shows how to just modify the supplied configuration entries
by first reading the configuration ... | [
"def",
"example_delta_alter_configs",
"(",
"a",
",",
"args",
")",
":",
"# Convert supplied config to resources.",
"# We can reuse the same resources both for describe_configs and",
"# alter_configs.",
"resources",
"=",
"[",
"]",
"for",
"restype",
",",
"resname",
",",
"configs... | The AlterConfigs Kafka API requires all configuration to be passed,
any left out configuration properties will revert to their default settings.
This example shows how to just modify the supplied configuration entries
by first reading the configuration from the broker, updating the supplied
configurati... | [
"The",
"AlterConfigs",
"Kafka",
"API",
"requires",
"all",
"configuration",
"to",
"be",
"passed",
"any",
"left",
"out",
"configuration",
"properties",
"will",
"revert",
"to",
"their",
"default",
"settings",
"."
] | python | train | 39.3 |
StackStorm/pybind | pybind/nos/v6_0_2f/interface/port_channel/spanning_tree/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface/port_channel/spanning_tree/__init__.py#L209-L230 | def _set_edgeport(self, v, load=False):
"""
Setter method for edgeport, mapped from YANG variable /interface/port_channel/spanning_tree/edgeport (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_edgeport is considered as a private
method. Backends looking t... | [
"def",
"_set_edgeport",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base"... | Setter method for edgeport, mapped from YANG variable /interface/port_channel/spanning_tree/edgeport (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_edgeport is considered as a private
method. Backends looking to populate this variable should
do so via callin... | [
"Setter",
"method",
"for",
"edgeport",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"port_channel",
"/",
"spanning_tree",
"/",
"edgeport",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false"... | python | train | 81.681818 |
Contraz/demosys-py | demosys/timers/music.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/timers/music.py#L59-L66 | def get_time(self) -> float:
"""
Get the current position in the music in seconds
"""
if self.paused:
return self.pause_time
return mixer.music.get_pos() / 1000.0 | [
"def",
"get_time",
"(",
"self",
")",
"->",
"float",
":",
"if",
"self",
".",
"paused",
":",
"return",
"self",
".",
"pause_time",
"return",
"mixer",
".",
"music",
".",
"get_pos",
"(",
")",
"/",
"1000.0"
] | Get the current position in the music in seconds | [
"Get",
"the",
"current",
"position",
"in",
"the",
"music",
"in",
"seconds"
] | python | valid | 26 |
O365/python-o365 | O365/excel.py | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/excel.py#L1364-L1395 | def update(self, *, name=None, show_headers=None, show_totals=None, style=None):
"""
Updates this table
:param str name: the name of the table
:param bool show_headers: whether or not to show the headers
:param bool show_totals: whether or not to show the totals
:param st... | [
"def",
"update",
"(",
"self",
",",
"*",
",",
"name",
"=",
"None",
",",
"show_headers",
"=",
"None",
",",
"show_totals",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
"and",
"show_headers",
"is",
"None",
"and",
"show_to... | Updates this table
:param str name: the name of the table
:param bool show_headers: whether or not to show the headers
:param bool show_totals: whether or not to show the totals
:param str style: the style of the table
:return: Success or Failure | [
"Updates",
"this",
"table",
":",
"param",
"str",
"name",
":",
"the",
"name",
"of",
"the",
"table",
":",
"param",
"bool",
"show_headers",
":",
"whether",
"or",
"not",
"to",
"show",
"the",
"headers",
":",
"param",
"bool",
"show_totals",
":",
"whether",
"or... | python | train | 37.625 |
osrg/ryu | ryu/services/protocols/bgp/bgpspeaker.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/bgpspeaker.py#L410-L557 | def neighbor_add(self, address, remote_as,
remote_port=DEFAULT_BGP_PORT,
enable_ipv4=DEFAULT_CAP_MBGP_IPV4,
enable_ipv6=DEFAULT_CAP_MBGP_IPV6,
enable_vpnv4=DEFAULT_CAP_MBGP_VPNV4,
enable_vpnv6=DEFAULT_CAP_MBGP_VPNV6... | [
"def",
"neighbor_add",
"(",
"self",
",",
"address",
",",
"remote_as",
",",
"remote_port",
"=",
"DEFAULT_BGP_PORT",
",",
"enable_ipv4",
"=",
"DEFAULT_CAP_MBGP_IPV4",
",",
"enable_ipv6",
"=",
"DEFAULT_CAP_MBGP_IPV6",
",",
"enable_vpnv4",
"=",
"DEFAULT_CAP_MBGP_VPNV4",
"... | This method registers a new neighbor. The BGP speaker tries to
establish a bgp session with the peer (accepts a connection
from the peer and also tries to connect to it).
``address`` specifies the IP address of the peer. It must be
the string representation of an IP address. Only IPv4 i... | [
"This",
"method",
"registers",
"a",
"new",
"neighbor",
".",
"The",
"BGP",
"speaker",
"tries",
"to",
"establish",
"a",
"bgp",
"session",
"with",
"the",
"peer",
"(",
"accepts",
"a",
"connection",
"from",
"the",
"peer",
"and",
"also",
"tries",
"to",
"connect"... | python | train | 39.013514 |
christophertbrown/bioscripts | ctbBio/rax.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L55-L76 | def get_ids(a):
"""
make copy of sequences with short identifier
"""
a_id = '%s.id.fa' % (a.rsplit('.', 1)[0])
a_id_lookup = '%s.id.lookup' % (a.rsplit('.', 1)[0])
if check(a_id) is True:
return a_id, a_id_lookup
a_id_f = open(a_id, 'w')
a_id_lookup_f = open(a_id_lookup, 'w')
... | [
"def",
"get_ids",
"(",
"a",
")",
":",
"a_id",
"=",
"'%s.id.fa'",
"%",
"(",
"a",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
")",
"a_id_lookup",
"=",
"'%s.id.lookup'",
"%",
"(",
"a",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
... | make copy of sequences with short identifier | [
"make",
"copy",
"of",
"sequences",
"with",
"short",
"identifier"
] | python | train | 32.227273 |
log2timeline/dfvfs | dfvfs/file_io/data_range_io.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/data_range_io.py#L91-L121 | def SetRange(self, range_offset, range_size):
"""Sets the data range (offset and size).
The data range is used to map a range of data within one file
(e.g. a single partition within a full disk image) as a file-like object.
Args:
range_offset (int): start offset of the data range.
range_si... | [
"def",
"SetRange",
"(",
"self",
",",
"range_offset",
",",
"range_size",
")",
":",
"if",
"self",
".",
"_is_open",
":",
"raise",
"IOError",
"(",
"'Already open.'",
")",
"if",
"range_offset",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid range offset: {0:d... | Sets the data range (offset and size).
The data range is used to map a range of data within one file
(e.g. a single partition within a full disk image) as a file-like object.
Args:
range_offset (int): start offset of the data range.
range_size (int): size of the data range.
Raises:
... | [
"Sets",
"the",
"data",
"range",
"(",
"offset",
"and",
"size",
")",
"."
] | python | train | 31.322581 |
Shapeways/coyote_framework | coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py | https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py#L655-L660 | def checkbox_check(self, force_check=False):
"""
Wrapper to check a checkbox
"""
if not self.get_attribute('checked'):
self.click(force_click=force_check) | [
"def",
"checkbox_check",
"(",
"self",
",",
"force_check",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"get_attribute",
"(",
"'checked'",
")",
":",
"self",
".",
"click",
"(",
"force_click",
"=",
"force_check",
")"
] | Wrapper to check a checkbox | [
"Wrapper",
"to",
"check",
"a",
"checkbox"
] | python | train | 32.333333 |
10gen/mongo-orchestration | mongo_orchestration/process.py | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L94-L98 | def release_port(self, port):
"""release port"""
if port in self.__closed:
self.__closed.remove(port)
self.__ports.add(port) | [
"def",
"release_port",
"(",
"self",
",",
"port",
")",
":",
"if",
"port",
"in",
"self",
".",
"__closed",
":",
"self",
".",
"__closed",
".",
"remove",
"(",
"port",
")",
"self",
".",
"__ports",
".",
"add",
"(",
"port",
")"
] | release port | [
"release",
"port"
] | python | train | 31.2 |
PyCQA/pylint | pylint/message/message_handler_mix_in.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L187-L196 | def get_message_state_scope(self, msgid, line=None, confidence=UNDEFINED):
"""Returns the scope at which a message was enabled/disabled."""
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE
try:
if line in self.file_s... | [
"def",
"get_message_state_scope",
"(",
"self",
",",
"msgid",
",",
"line",
"=",
"None",
",",
"confidence",
"=",
"UNDEFINED",
")",
":",
"if",
"self",
".",
"config",
".",
"confidence",
"and",
"confidence",
".",
"name",
"not",
"in",
"self",
".",
"config",
".... | Returns the scope at which a message was enabled/disabled. | [
"Returns",
"the",
"scope",
"at",
"which",
"a",
"message",
"was",
"enabled",
"/",
"disabled",
"."
] | python | test | 48.8 |
bsolomon1124/pyfinance | pyfinance/datasets.py | https://github.com/bsolomon1124/pyfinance/blob/c95925209a809b4e648e79cbeaf7711d8e5ff1a6/pyfinance/datasets.py#L597-L659 | def load_retaildata():
"""Monthly retail trade data from census.gov."""
# full = 'https://www.census.gov/retail/mrts/www/mrtssales92-present.xls'
# indiv = 'https://www.census.gov/retail/marts/www/timeseries.html'
db = {
"Auto, other Motor Vehicle": "https://www.census.gov/retail/marts/ww... | [
"def",
"load_retaildata",
"(",
")",
":",
"# full = 'https://www.census.gov/retail/mrts/www/mrtssales92-present.xls'\r",
"# indiv = 'https://www.census.gov/retail/marts/www/timeseries.html'\r",
"db",
"=",
"{",
"\"Auto, other Motor Vehicle\"",
":",
"\"https://www.census.gov/retail/marts/www/ad... | Monthly retail trade data from census.gov. | [
"Monthly",
"retail",
"trade",
"data",
"from",
"census",
".",
"gov",
"."
] | python | train | 52.492063 |
DataDog/integrations-core | kubelet/datadog_checks/kubelet/kubelet.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/kubelet.py#L393-L433 | def _report_container_spec_metrics(self, pod_list, instance_tags):
"""Reports pod requests & limits by looking at pod specs."""
for pod in pod_list['items']:
pod_name = pod.get('metadata', {}).get('name')
pod_phase = pod.get('status', {}).get('phase')
if self._should_... | [
"def",
"_report_container_spec_metrics",
"(",
"self",
",",
"pod_list",
",",
"instance_tags",
")",
":",
"for",
"pod",
"in",
"pod_list",
"[",
"'items'",
"]",
":",
"pod_name",
"=",
"pod",
".",
"get",
"(",
"'metadata'",
",",
"{",
"}",
")",
".",
"get",
"(",
... | Reports pod requests & limits by looking at pod specs. | [
"Reports",
"pod",
"requests",
"&",
"limits",
"by",
"looking",
"at",
"pod",
"specs",
"."
] | python | train | 48.658537 |
flyingfrog81/fixreal | fixreal.py | https://github.com/flyingfrog81/fixreal/blob/dc0c1c66b0b94357e4c181607fa385bfb5ccc5f8/fixreal.py#L162-L177 | def fix2real(uval, conv):
"""
Convert a 32 bit unsigned int register into the value it represents in its Fixed arithmetic form.
@param uval: the numeric unsigned value in simulink representation
@param conv: conv structure with conversion specs as generated by I{get_conv}
@return: the real number re... | [
"def",
"fix2real",
"(",
"uval",
",",
"conv",
")",
":",
"res",
"=",
"0",
"int_val",
"=",
"(",
"(",
"uval",
"&",
"conv",
"[",
"\"int_mask\"",
"]",
")",
">>",
"conv",
"[",
"\"bin_point\"",
"]",
")",
"dec_val",
"=",
"conv",
"[",
"\"dec_step\"",
"]",
"*... | Convert a 32 bit unsigned int register into the value it represents in its Fixed arithmetic form.
@param uval: the numeric unsigned value in simulink representation
@param conv: conv structure with conversion specs as generated by I{get_conv}
@return: the real number represented by the Fixed arithmetic defi... | [
"Convert",
"a",
"32",
"bit",
"unsigned",
"int",
"register",
"into",
"the",
"value",
"it",
"represents",
"in",
"its",
"Fixed",
"arithmetic",
"form",
"."
] | python | train | 48.25 |
bitesofcode/projexui | projexui/widgets/xmultitagedit.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmultitagedit.py#L99-L114 | def drawDisplay( self, painter, option, rect, text ):
"""
Handles the display drawing for this delegate.
:param painter | <QPainter>
option | <QStyleOption>
rect | <QRect>
text | <str>
"""
painter.se... | [
"def",
"drawDisplay",
"(",
"self",
",",
"painter",
",",
"option",
",",
"rect",
",",
"text",
")",
":",
"painter",
".",
"setBrush",
"(",
"Qt",
".",
"NoBrush",
")",
"painter",
".",
"drawText",
"(",
"rect",
".",
"left",
"(",
")",
"+",
"3",
",",
"rect",... | Handles the display drawing for this delegate.
:param painter | <QPainter>
option | <QStyleOption>
rect | <QRect>
text | <str> | [
"Handles",
"the",
"display",
"drawing",
"for",
"this",
"delegate",
".",
":",
"param",
"painter",
"|",
"<QPainter",
">",
"option",
"|",
"<QStyleOption",
">",
"rect",
"|",
"<QRect",
">",
"text",
"|",
"<str",
">"
] | python | train | 35.5 |
materialsproject/pymatgen | pymatgen/analysis/structure_prediction/substitution_probability.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_prediction/substitution_probability.py#L223-L258 | def composition_prediction(self, composition, to_this_composition=True):
"""
Returns charged balanced substitutions from a starting or ending
composition.
Args:
composition:
starting or ending composition
to_this_composition:
If tr... | [
"def",
"composition_prediction",
"(",
"self",
",",
"composition",
",",
"to_this_composition",
"=",
"True",
")",
":",
"preds",
"=",
"self",
".",
"list_prediction",
"(",
"list",
"(",
"composition",
".",
"keys",
"(",
")",
")",
",",
"to_this_composition",
")",
"... | Returns charged balanced substitutions from a starting or ending
composition.
Args:
composition:
starting or ending composition
to_this_composition:
If true, substitutions with this as a final composition
will be found. If false, s... | [
"Returns",
"charged",
"balanced",
"substitutions",
"from",
"a",
"starting",
"or",
"ending",
"composition",
"."
] | python | train | 39.055556 |
aamalev/aiohttp_apiset | aiohttp_apiset/compat.py | https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/compat.py#L370-L374 | def add_patch(self, *args, **kwargs):
"""
Shortcut for add_route with method PATCH
"""
return self.add_route(hdrs.METH_PATCH, *args, **kwargs) | [
"def",
"add_patch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"add_route",
"(",
"hdrs",
".",
"METH_PATCH",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Shortcut for add_route with method PATCH | [
"Shortcut",
"for",
"add_route",
"with",
"method",
"PATCH"
] | python | train | 34 |
gamechanger/dusty | dusty/log.py | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/log.py#L67-L88 | def streaming_to_client():
"""Puts the client logger into streaming mode, which sends
unbuffered input through to the socket one character at a time.
We also disable propagation so the root logger does not
receive many one-byte emissions. This context handler
was originally created for streaming Com... | [
"def",
"streaming_to_client",
"(",
")",
":",
"for",
"handler",
"in",
"client_logger",
".",
"handlers",
":",
"if",
"hasattr",
"(",
"handler",
",",
"'append_newlines'",
")",
":",
"break",
"else",
":",
"handler",
"=",
"None",
"old_propagate",
"=",
"client_logger"... | Puts the client logger into streaming mode, which sends
unbuffered input through to the socket one character at a time.
We also disable propagation so the root logger does not
receive many one-byte emissions. This context handler
was originally created for streaming Compose up's
terminal output thro... | [
"Puts",
"the",
"client",
"logger",
"into",
"streaming",
"mode",
"which",
"sends",
"unbuffered",
"input",
"through",
"to",
"the",
"socket",
"one",
"character",
"at",
"a",
"time",
".",
"We",
"also",
"disable",
"propagation",
"so",
"the",
"root",
"logger",
"doe... | python | valid | 40 |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/tree_ensemble.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/tree_ensemble.py#L36-L55 | def set_default_prediction_value(self, values):
"""
Set the default prediction value(s).
The values given here form the base prediction value that the values
at activated leaves are added to. If values is a scalar, then
the output of the tree must also be 1 dimensional; otherwi... | [
"def",
"set_default_prediction_value",
"(",
"self",
",",
"values",
")",
":",
"if",
"type",
"(",
"values",
")",
"is",
"not",
"list",
":",
"values",
"=",
"[",
"float",
"(",
"values",
")",
"]",
"self",
".",
"tree_parameters",
".",
"numPredictionDimensions",
"... | Set the default prediction value(s).
The values given here form the base prediction value that the values
at activated leaves are added to. If values is a scalar, then
the output of the tree must also be 1 dimensional; otherwise, values
must be a list with length matching the dimension... | [
"Set",
"the",
"default",
"prediction",
"value",
"(",
"s",
")",
"."
] | python | train | 38.55 |
Groundworkstech/pybfd | pybfd/bfd.py | https://github.com/Groundworkstech/pybfd/blob/9e722435929b4ad52212043a6f1e9e9ce60b5d72/pybfd/bfd.py#L406-L411 | def format(self):
"""Return the format attribute of the BFD file being processed."""
if not self._ptr:
raise BfdException("BFD not initialized")
return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.FORMAT) | [
"def",
"format",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_ptr",
":",
"raise",
"BfdException",
"(",
"\"BFD not initialized\"",
")",
"return",
"_bfd",
".",
"get_bfd_attribute",
"(",
"self",
".",
"_ptr",
",",
"BfdAttributes",
".",
"FORMAT",
")"
] | Return the format attribute of the BFD file being processed. | [
"Return",
"the",
"format",
"attribute",
"of",
"the",
"BFD",
"file",
"being",
"processed",
"."
] | python | train | 39.833333 |
nitmir/django-cas-server | cas_server/views.py | https://github.com/nitmir/django-cas-server/blob/d106181b94c444f1946269da5c20f6c904840ad3/cas_server/views.py#L619-L636 | def process_get(self):
"""
Analyse the GET request
:return:
* :attr:`USER_NOT_AUTHENTICATED` if the user is not authenticated or is requesting
for authentication renewal
* :attr:`USER_AUTHENTICATED` if the user is authenticated and is no... | [
"def",
"process_get",
"(",
"self",
")",
":",
"# generate a new LT",
"self",
".",
"gen_lt",
"(",
")",
"if",
"not",
"self",
".",
"request",
".",
"session",
".",
"get",
"(",
"\"authenticated\"",
")",
"or",
"self",
".",
"renew",
":",
"# authentication will be ne... | Analyse the GET request
:return:
* :attr:`USER_NOT_AUTHENTICATED` if the user is not authenticated or is requesting
for authentication renewal
* :attr:`USER_AUTHENTICATED` if the user is authenticated and is not requesting
for authenticati... | [
"Analyse",
"the",
"GET",
"request"
] | python | train | 39.166667 |
senaite/senaite.core | bika/lims/browser/contact.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/contact.py#L201-L204 | def add_status_message(self, message, severity="info"):
"""Set a portal message
"""
self.context.plone_utils.addPortalMessage(message, severity) | [
"def",
"add_status_message",
"(",
"self",
",",
"message",
",",
"severity",
"=",
"\"info\"",
")",
":",
"self",
".",
"context",
".",
"plone_utils",
".",
"addPortalMessage",
"(",
"message",
",",
"severity",
")"
] | Set a portal message | [
"Set",
"a",
"portal",
"message"
] | python | train | 41.25 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L3957-L3969 | def get_stp_mst_detail_output_cist_cist_reg_root_id(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_stp_mst_detail = ET.Element("get_stp_mst_detail")
config = get_stp_mst_detail
output = ET.SubElement(get_stp_mst_detail, "output")
cis... | [
"def",
"get_stp_mst_detail_output_cist_cist_reg_root_id",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_stp_mst_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_stp_mst_detail\"",
")",
"config",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 43.230769 |
brocade/pynos | pynos/versions/ver_7/ver_7_0_0/interface.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/interface.py#L45-L118 | def ip_unnumbered(self, **kwargs):
"""Configure an unnumbered interface.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet etc).
name (str): Name of interface id.
(For interface: 1/0/5, 1/0/10 etc).
delete... | [
"def",
"ip_unnumbered",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'ip_donor_interface_name'",
"]",
"=",
"kwargs",
".",
"pop",
"(",
"'donor_name'",
")",
"kwargs",
"[",
"'ip_donor_interface_type'",
"]",
"=",
"kwargs",
".",
"pop",
"(",
"... | Configure an unnumbered interface.
Args:
int_type (str): Type of interface. (gigabitethernet,
tengigabitethernet etc).
name (str): Name of interface id.
(For interface: 1/0/5, 1/0/10 etc).
delete (bool): True is the IP address is added and F... | [
"Configure",
"an",
"unnumbered",
"interface",
"."
] | python | train | 51.405405 |
PmagPy/PmagPy | pmagpy/pmagplotlib.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmagplotlib.py#L295-L316 | def plot_site(fignum, SiteRec, data, key):
"""
deprecated (used in ipmag)
"""
print('Site mean data: ')
print(' dec inc n_lines n_planes kappa R alpha_95 comp coord')
print(SiteRec['site_dec'], SiteRec['site_inc'], SiteRec['site_n_lines'], SiteRec['site_n_planes'], SiteRec['site_k'],
... | [
"def",
"plot_site",
"(",
"fignum",
",",
"SiteRec",
",",
"data",
",",
"key",
")",
":",
"print",
"(",
"'Site mean data: '",
")",
"print",
"(",
"' dec inc n_lines n_planes kappa R alpha_95 comp coord'",
")",
"print",
"(",
"SiteRec",
"[",
"'site_dec'",
"]",
",",
... | deprecated (used in ipmag) | [
"deprecated",
"(",
"used",
"in",
"ipmag",
")"
] | python | train | 49.045455 |
anti1869/aiohttp_autoreload | src/aiohttp_autoreload.py | https://github.com/anti1869/aiohttp_autoreload/blob/1d9b9b67ffba1073fa35495d87538b4570807367/src/aiohttp_autoreload.py#L58-L76 | def start(io_loop=None, check_time=2):
"""Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated.
"""
io_loop = io_loop or asyncio.get_event_loop()
if io_loop in _io_loops:
return
_io_loops[io_loop] = True
if len(_io_loops) >... | [
"def",
"start",
"(",
"io_loop",
"=",
"None",
",",
"check_time",
"=",
"2",
")",
":",
"io_loop",
"=",
"io_loop",
"or",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"io_loop",
"in",
"_io_loops",
":",
"return",
"_io_loops",
"[",
"io_loop",
"]",
"=",
"... | Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated. | [
"Begins",
"watching",
"source",
"files",
"for",
"changes",
"."
] | python | train | 36.421053 |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/_audio_feature_extractor.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/_audio_feature_extractor.py#L192-L201 | def get_spec(self):
"""
Return the Core ML spec
"""
if _mac_ver() >= (10, 14):
return self.vggish_model.get_spec()
else:
vggish_model_file = VGGish()
coreml_model_path = vggish_model_file.get_model_path(format='coreml')
return MLMod... | [
"def",
"get_spec",
"(",
"self",
")",
":",
"if",
"_mac_ver",
"(",
")",
">=",
"(",
"10",
",",
"14",
")",
":",
"return",
"self",
".",
"vggish_model",
".",
"get_spec",
"(",
")",
"else",
":",
"vggish_model_file",
"=",
"VGGish",
"(",
")",
"coreml_model_path"... | Return the Core ML spec | [
"Return",
"the",
"Core",
"ML",
"spec"
] | python | train | 34.3 |
mlperf/training | translation/tensorflow/transformer/utils/tokenizer.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L224-L240 | def _split_string_to_tokens(text):
"""Splits text to a list of string tokens."""
if not text:
return []
ret = []
token_start = 0
# Classify each character in the input string
is_alnum = [c in _ALPHANUMERIC_CHAR_SET for c in text]
for pos in xrange(1, len(text)):
if is_alnum[pos] != is_alnum[pos - ... | [
"def",
"_split_string_to_tokens",
"(",
"text",
")",
":",
"if",
"not",
"text",
":",
"return",
"[",
"]",
"ret",
"=",
"[",
"]",
"token_start",
"=",
"0",
"# Classify each character in the input string",
"is_alnum",
"=",
"[",
"c",
"in",
"_ALPHANUMERIC_CHAR_SET",
"for... | Splits text to a list of string tokens. | [
"Splits",
"text",
"to",
"a",
"list",
"of",
"string",
"tokens",
"."
] | python | train | 30.058824 |
HumanCellAtlas/cloud-blobstore | cloud_blobstore/gs.py | https://github.com/HumanCellAtlas/cloud-blobstore/blob/b8a60e8e8c0da0e39dda084cb467a34cd2d1ef0a/cloud_blobstore/gs.py#L246-L258 | def get_creation_date(
self,
bucket: str,
key: str,
) -> datetime.datetime:
"""
Retrieves the creation date for a given key in a given bucket.
:param bucket: the bucket the object resides in.
:param key: the key of the object for which the creation... | [
"def",
"get_creation_date",
"(",
"self",
",",
"bucket",
":",
"str",
",",
"key",
":",
"str",
",",
")",
"->",
"datetime",
".",
"datetime",
":",
"blob_obj",
"=",
"self",
".",
"_get_blob_obj",
"(",
"bucket",
",",
"key",
")",
"return",
"blob_obj",
".",
"tim... | Retrieves the creation date for a given key in a given bucket.
:param bucket: the bucket the object resides in.
:param key: the key of the object for which the creation date is being retrieved.
:return: the creation date | [
"Retrieves",
"the",
"creation",
"date",
"for",
"a",
"given",
"key",
"in",
"a",
"given",
"bucket",
".",
":",
"param",
"bucket",
":",
"the",
"bucket",
"the",
"object",
"resides",
"in",
".",
":",
"param",
"key",
":",
"the",
"key",
"of",
"the",
"object",
... | python | train | 36 |
krukas/Trionyx | trionyx/layout.py | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L326-L336 | def get_rendered_objects(self):
"""Render objects"""
objects = self.objects
if isinstance(objects, str):
objects = getattr(self.object, objects).all()
return [
self.get_rendered_object(obj)
for obj in objects
] | [
"def",
"get_rendered_objects",
"(",
"self",
")",
":",
"objects",
"=",
"self",
".",
"objects",
"if",
"isinstance",
"(",
"objects",
",",
"str",
")",
":",
"objects",
"=",
"getattr",
"(",
"self",
".",
"object",
",",
"objects",
")",
".",
"all",
"(",
")",
... | Render objects | [
"Render",
"objects"
] | python | train | 25.272727 |
ThreatConnect-Inc/tcex | tcex/tcex_ti_batch.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti_batch.py#L974-L989 | def mutex(self, mutex, **kwargs):
"""Add Mutex data to Batch object.
Args:
mutex (str): The value for this Indicator.
confidence (str, kwargs): The threat confidence for this Indicator.
date_added (str, kwargs): The date timestamp the Indicator was created.
... | [
"def",
"mutex",
"(",
"self",
",",
"mutex",
",",
"*",
"*",
"kwargs",
")",
":",
"indicator_obj",
"=",
"Mutex",
"(",
"mutex",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"_indicator",
"(",
"indicator_obj",
")"
] | Add Mutex data to Batch object.
Args:
mutex (str): The value for this Indicator.
confidence (str, kwargs): The threat confidence for this Indicator.
date_added (str, kwargs): The date timestamp the Indicator was created.
last_modified (str, kwargs): The date time... | [
"Add",
"Mutex",
"data",
"to",
"Batch",
"object",
"."
] | python | train | 43.0625 |
SheffieldML/GPy | GPy/likelihoods/student_t.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/likelihoods/student_t.py#L185-L202 | def dlogpdf_dlink_dvar(self, inv_link_f, y, Y_metadata=None):
"""
Derivative of the dlogpdf_dlink w.r.t variance parameter (t_noise)
.. math::
\\frac{d}{d\\sigma^{2}}(\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{df}) = \\frac{-2\\sigma v(v + 1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i})... | [
"def",
"dlogpdf_dlink_dvar",
"(",
"self",
",",
"inv_link_f",
",",
"y",
",",
"Y_metadata",
"=",
"None",
")",
":",
"e",
"=",
"y",
"-",
"inv_link_f",
"dlogpdf_dlink_dvar",
"=",
"(",
"self",
".",
"v",
"*",
"(",
"self",
".",
"v",
"+",
"1",
")",
"*",
"("... | Derivative of the dlogpdf_dlink w.r.t variance parameter (t_noise)
.. math::
\\frac{d}{d\\sigma^{2}}(\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{df}) = \\frac{-2\\sigma v(v + 1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i}))^2 + \\sigma^2 v)^2}
:param inv_link_f: latent variables inv_link_f
... | [
"Derivative",
"of",
"the",
"dlogpdf_dlink",
"w",
".",
"r",
".",
"t",
"variance",
"parameter",
"(",
"t_noise",
")"
] | python | train | 45.777778 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile_ext.py#L130-L141 | def get_port_profile_for_intf_output_has_more(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_port_profile_for_intf = ET.Element("get_port_profile_for_intf")
config = get_port_profile_for_intf
output = ET.SubElement(get_port_profile_for_intf,... | [
"def",
"get_port_profile_for_intf_output_has_more",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_port_profile_for_intf",
"=",
"ET",
".",
"Element",
"(",
"\"get_port_profile_for_intf\"",
")",
"con... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 42.5 |
fdiskyou/kcshell | kcshell/disassembler.py | https://github.com/fdiskyou/kcshell/blob/f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f/kcshell/disassembler.py#L15-L27 | def get_cs_archs(self):
''' capstone disassembler '''
cs_archs = {
'x16': (CS_ARCH_X86, CS_MODE_16),
'x86': (CS_ARCH_X86, CS_MODE_32),
'x64': (CS_ARCH_X86, CS_MODE_64),
'arm': (CS_ARCH_ARM, CS_MODE_ARM),
'arm_t':... | [
"def",
"get_cs_archs",
"(",
"self",
")",
":",
"cs_archs",
"=",
"{",
"'x16'",
":",
"(",
"CS_ARCH_X86",
",",
"CS_MODE_16",
")",
",",
"'x86'",
":",
"(",
"CS_ARCH_X86",
",",
"CS_MODE_32",
")",
",",
"'x64'",
":",
"(",
"CS_ARCH_X86",
",",
"CS_MODE_64",
")",
... | capstone disassembler | [
"capstone",
"disassembler"
] | python | train | 43.307692 |
quantopian/zipline | zipline/assets/asset_writer.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_writer.py#L856-L874 | def _all_tables_present(self, txn):
"""
Checks if any tables are present in the current assets database.
Parameters
----------
txn : Transaction
The open transaction to check in.
Returns
-------
has_tables : bool
True if any table... | [
"def",
"_all_tables_present",
"(",
"self",
",",
"txn",
")",
":",
"conn",
"=",
"txn",
".",
"connect",
"(",
")",
"for",
"table_name",
"in",
"asset_db_table_names",
":",
"if",
"txn",
".",
"dialect",
".",
"has_table",
"(",
"conn",
",",
"table_name",
")",
":"... | Checks if any tables are present in the current assets database.
Parameters
----------
txn : Transaction
The open transaction to check in.
Returns
-------
has_tables : bool
True if any tables are present, otherwise False. | [
"Checks",
"if",
"any",
"tables",
"are",
"present",
"in",
"the",
"current",
"assets",
"database",
"."
] | python | train | 27.736842 |
jason-weirather/py-seq-tools | seqtools/structure/transcript/__init__.py | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/structure/transcript/__init__.py#L567-L573 | def get_string(self):
"""A string representation of the junction
:return: string represnetation
:rtype: string
"""
return self.left.chr+':'+str(self.left.end)+'-'+self.right.chr+':'+str(self.right.start) | [
"def",
"get_string",
"(",
"self",
")",
":",
"return",
"self",
".",
"left",
".",
"chr",
"+",
"':'",
"+",
"str",
"(",
"self",
".",
"left",
".",
"end",
")",
"+",
"'-'",
"+",
"self",
".",
"right",
".",
"chr",
"+",
"':'",
"+",
"str",
"(",
"self",
... | A string representation of the junction
:return: string represnetation
:rtype: string | [
"A",
"string",
"representation",
"of",
"the",
"junction"
] | python | train | 31.142857 |
KnorrFG/pyparadigm | pyparadigm/misc.py | https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L70-L87 | def display(surface):
"""Displays a pygame.Surface in the window.
in pygame the window is represented through a surface, on which you can draw
as on any other pygame.Surface. A refernce to to the screen can be optained
via the :py:func:`pygame.display.get_surface` function. To display the
conte... | [
"def",
"display",
"(",
"surface",
")",
":",
"screen",
"=",
"pygame",
".",
"display",
".",
"get_surface",
"(",
")",
"screen",
".",
"blit",
"(",
"surface",
",",
"(",
"0",
",",
"0",
")",
")",
"pygame",
".",
"display",
".",
"flip",
"(",
")"
] | Displays a pygame.Surface in the window.
in pygame the window is represented through a surface, on which you can draw
as on any other pygame.Surface. A refernce to to the screen can be optained
via the :py:func:`pygame.display.get_surface` function. To display the
contents of the screen surface in ... | [
"Displays",
"a",
"pygame",
".",
"Surface",
"in",
"the",
"window",
".",
"in",
"pygame",
"the",
"window",
"is",
"represented",
"through",
"a",
"surface",
"on",
"which",
"you",
"can",
"draw",
"as",
"on",
"any",
"other",
"pygame",
".",
"Surface",
".",
"A",
... | python | train | 40.222222 |
bids-standard/pybids | bids/reports/utils.py | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/utils.py#L107-L135 | def get_seqstr(config, metadata):
"""
Extract and reformat imaging sequence(s) and variant(s) into pretty
strings.
Parameters
----------
config : :obj:`dict`
A dictionary with relevant information regarding sequences, sequence
variants, phase encoding directions, and task names.... | [
"def",
"get_seqstr",
"(",
"config",
",",
"metadata",
")",
":",
"seq_abbrs",
"=",
"metadata",
".",
"get",
"(",
"'ScanningSequence'",
",",
"''",
")",
".",
"split",
"(",
"'_'",
")",
"seqs",
"=",
"[",
"config",
"[",
"'seq'",
"]",
".",
"get",
"(",
"seq",
... | Extract and reformat imaging sequence(s) and variant(s) into pretty
strings.
Parameters
----------
config : :obj:`dict`
A dictionary with relevant information regarding sequences, sequence
variants, phase encoding directions, and task names.
metadata : :obj:`dict`
The metada... | [
"Extract",
"and",
"reformat",
"imaging",
"sequence",
"(",
"s",
")",
"and",
"variant",
"(",
"s",
")",
"into",
"pretty",
"strings",
"."
] | python | train | 31.551724 |
JarryShaw/PyPCAPKit | src/foundation/extraction.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L614-L685 | def _default_read_frame(self, *, frame=None, mpkit=None):
"""Read frames with default engine.
- Extract frames and each layer of packets.
- Make Info object out of frame properties.
- Append Info.
- Write plist & append Info.
"""
from pcapkit.toolkit.default imp... | [
"def",
"_default_read_frame",
"(",
"self",
",",
"*",
",",
"frame",
"=",
"None",
",",
"mpkit",
"=",
"None",
")",
":",
"from",
"pcapkit",
".",
"toolkit",
".",
"default",
"import",
"(",
"ipv4_reassembly",
",",
"ipv6_reassembly",
",",
"tcp_reassembly",
",",
"t... | Read frames with default engine.
- Extract frames and each layer of packets.
- Make Info object out of frame properties.
- Append Info.
- Write plist & append Info. | [
"Read",
"frames",
"with",
"default",
"engine",
"."
] | python | train | 33.625 |
cgrok/cr-async | examples/crcog.py | https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/examples/crcog.py#L22-L42 | async def profile(self, ctx, tag):
'''Example command for use inside a discord bot cog.'''
if not self.check_valid_tag(tag):
return await ctx.send('Invalid tag!')
profile = await self.cr.get_profile(tag)
em = discord.Embed(color=0x00FFFFF)
em.set_author(name=str(pro... | [
"async",
"def",
"profile",
"(",
"self",
",",
"ctx",
",",
"tag",
")",
":",
"if",
"not",
"self",
".",
"check_valid_tag",
"(",
"tag",
")",
":",
"return",
"await",
"ctx",
".",
"send",
"(",
"'Invalid tag!'",
")",
"profile",
"=",
"await",
"self",
".",
"cr"... | Example command for use inside a discord bot cog. | [
"Example",
"command",
"for",
"use",
"inside",
"a",
"discord",
"bot",
"cog",
"."
] | python | train | 34.761905 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L192-L199 | def get_group_details(group):
""" Get group details. """
result = []
for datastore in _get_datastores():
value = datastore.get_group_details(group)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | [
"def",
"get_group_details",
"(",
"group",
")",
":",
"result",
"=",
"[",
"]",
"for",
"datastore",
"in",
"_get_datastores",
"(",
")",
":",
"value",
"=",
"datastore",
".",
"get_group_details",
"(",
"group",
")",
"value",
"[",
"'datastore'",
"]",
"=",
"datasto... | Get group details. | [
"Get",
"group",
"details",
"."
] | python | train | 33.5 |
Autodesk/aomi | aomi/model/context.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L217-L220 | def remove(self, resource):
"""Removes a resource from the context"""
if isinstance(resource, Resource):
self._resources.remove(resource) | [
"def",
"remove",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"Resource",
")",
":",
"self",
".",
"_resources",
".",
"remove",
"(",
"resource",
")"
] | Removes a resource from the context | [
"Removes",
"a",
"resource",
"from",
"the",
"context"
] | python | train | 40.5 |
biocore-ntnu/epic | epic/statistics/compute_poisson.py | https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/statistics/compute_poisson.py#L6-L18 | def _factln(num):
# type: (int) -> float
"""
Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.
"""
if num < 20:
log_factorial = log(factorial(num))
else:
log_factorial = num * log(num) - num + log(num * (1 + 4 * num * (
1... | [
"def",
"_factln",
"(",
"num",
")",
":",
"# type: (int) -> float",
"if",
"num",
"<",
"20",
":",
"log_factorial",
"=",
"log",
"(",
"factorial",
"(",
"num",
")",
")",
"else",
":",
"log_factorial",
"=",
"num",
"*",
"log",
"(",
"num",
")",
"-",
"num",
"+"... | Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise. | [
"Computes",
"logfactorial",
"regularly",
"for",
"tractable",
"numbers",
"uses",
"Ramanujans",
"approximation",
"otherwise",
"."
] | python | train | 28.230769 |
chrisrink10/basilisp | src/basilisp/lang/keyword.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/keyword.py#L80-L87 | def keyword(
name: str,
ns: Optional[str] = None,
kw_cache: atom.Atom["PMap[int, Keyword]"] = __INTERN,
) -> Keyword:
"""Create a new keyword."""
h = hash((name, ns))
return kw_cache.swap(__get_or_create, h, name, ns)[h] | [
"def",
"keyword",
"(",
"name",
":",
"str",
",",
"ns",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"kw_cache",
":",
"atom",
".",
"Atom",
"[",
"\"PMap[int, Keyword]\"",
"]",
"=",
"__INTERN",
",",
")",
"->",
"Keyword",
":",
"h",
"=",
"hash",
"... | Create a new keyword. | [
"Create",
"a",
"new",
"keyword",
"."
] | python | test | 29.625 |
lebinh/aq | aq/sqlite_util.py | https://github.com/lebinh/aq/blob/eb366dd063db25598daa70a216170776e83383f4/aq/sqlite_util.py#L74-L85 | def insert_all(db, schema_name, table_name, columns, items):
"""
Insert all item in given items list into the specified table, schema_name.table_name.
"""
table = '{0}.{1}'.format(schema_name, table_name) if schema_name else table_name
columns_list = ', '.join(columns)
values_list = ', '.join(['... | [
"def",
"insert_all",
"(",
"db",
",",
"schema_name",
",",
"table_name",
",",
"columns",
",",
"items",
")",
":",
"table",
"=",
"'{0}.{1}'",
".",
"format",
"(",
"schema_name",
",",
"table_name",
")",
"if",
"schema_name",
"else",
"table_name",
"columns_list",
"=... | Insert all item in given items list into the specified table, schema_name.table_name. | [
"Insert",
"all",
"item",
"in",
"given",
"items",
"list",
"into",
"the",
"specified",
"table",
"schema_name",
".",
"table_name",
"."
] | python | train | 48.083333 |
has2k1/mizani | mizani/scale.py | https://github.com/has2k1/mizani/blob/312d0550ee0136fd1b0384829b33f3b2065f47c8/mizani/scale.py#L76-L105 | def train(cls, new_data, old=None):
"""
Train a continuous scale
Parameters
----------
new_data : array_like
New values
old : array_like
Old range. Most likely a tuple of length 2.
Returns
-------
out : tuple
L... | [
"def",
"train",
"(",
"cls",
",",
"new_data",
",",
"old",
"=",
"None",
")",
":",
"if",
"not",
"len",
"(",
"new_data",
")",
":",
"return",
"old",
"if",
"not",
"hasattr",
"(",
"new_data",
",",
"'dtype'",
")",
":",
"new_data",
"=",
"np",
".",
"asarray"... | Train a continuous scale
Parameters
----------
new_data : array_like
New values
old : array_like
Old range. Most likely a tuple of length 2.
Returns
-------
out : tuple
Limits(range) of the scale | [
"Train",
"a",
"continuous",
"scale"
] | python | valid | 25.2 |
pytorch/tnt | torchnet/dataset/shuffledataset.py | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/dataset/shuffledataset.py#L44-L61 | def resample(self, seed=None):
"""Resample the dataset.
Args:
seed (int, optional): Seed for resampling. By default no seed is
used.
"""
if seed is not None:
gen = torch.manual_seed(seed)
else:
gen = torch.default_generator
... | [
"def",
"resample",
"(",
"self",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"not",
"None",
":",
"gen",
"=",
"torch",
".",
"manual_seed",
"(",
"seed",
")",
"else",
":",
"gen",
"=",
"torch",
".",
"default_generator",
"if",
"self",
".",
"r... | Resample the dataset.
Args:
seed (int, optional): Seed for resampling. By default no seed is
used. | [
"Resample",
"the",
"dataset",
"."
] | python | train | 31.333333 |
mitsei/dlkit | dlkit/handcar/learning/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L2795-L2812 | def get_activities_by_query(self, activity_query=None):
"""Gets a list of Activities matching the given activity query.
arg: activityQuery (osid.learning.ActivityQuery): the
activity query
return: (osid.learning.ActivityList) - the returned ActivityList
raise: NullAr... | [
"def",
"get_activities_by_query",
"(",
"self",
",",
"activity_query",
"=",
"None",
")",
":",
"url_path",
"=",
"construct_url",
"(",
"'activities'",
",",
"bank_id",
"=",
"self",
".",
"_catalog_idstr",
")",
"query_terms",
"=",
"[",
"v",
"for",
"k",
",",
"v",
... | Gets a list of Activities matching the given activity query.
arg: activityQuery (osid.learning.ActivityQuery): the
activity query
return: (osid.learning.ActivityList) - the returned ActivityList
raise: NullArgument - activityQuery is null
raise: OperationFailed - un... | [
"Gets",
"a",
"list",
"of",
"Activities",
"matching",
"the",
"given",
"activity",
"query",
"."
] | python | train | 49.166667 |
dslackw/sun | sun/utils.py | https://github.com/dslackw/sun/blob/ff3501757ce1cc2f0db195f7a6b1d23f601dce32/sun/utils.py#L83-L90 | def read_config(config):
"""Read config file and return uncomment line
"""
for line in config.splitlines():
line = line.lstrip()
if line and not line.startswith("#"):
return line
return "" | [
"def",
"read_config",
"(",
"config",
")",
":",
"for",
"line",
"in",
"config",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"line",
"and",
"not",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"return",
"... | Read config file and return uncomment line | [
"Read",
"config",
"file",
"and",
"return",
"uncomment",
"line"
] | python | train | 28.125 |
mitsei/dlkit | dlkit/json_/assessment/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/managers.py#L777-L791 | def get_item_lookup_session(self):
"""Gets the ``OsidSession`` associated with the item lookup service.
return: (osid.assessment.ItemLookupSession) - an
``ItemLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_item_loo... | [
"def",
"get_item_lookup_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_item_lookup",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"ItemLookupSession",
"(",
"runtim... | Gets the ``OsidSession`` associated with the item lookup service.
return: (osid.assessment.ItemLookupSession) - an
``ItemLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_item_lookup()`` is ``false``
*compliance: opti... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"item",
"lookup",
"service",
"."
] | python | train | 42.8 |
jjgomera/iapws | iapws/iapws97.py | https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L1056-L1097 | def Region2_cp0(Tr, Pr):
"""Ideal properties for Region 2
Parameters
----------
Tr : float
Reduced temperature, [-]
Pr : float
Reduced pressure, [-]
Returns
-------
prop : array
Array with ideal Gibbs energy partial derivatives:
* g: Ideal Specific ... | [
"def",
"Region2_cp0",
"(",
"Tr",
",",
"Pr",
")",
":",
"Jo",
"=",
"[",
"0",
",",
"1",
",",
"-",
"5",
",",
"-",
"4",
",",
"-",
"3",
",",
"-",
"2",
",",
"-",
"1",
",",
"2",
",",
"3",
"]",
"no",
"=",
"[",
"-",
"0.96927686500217E+01",
",",
"... | Ideal properties for Region 2
Parameters
----------
Tr : float
Reduced temperature, [-]
Pr : float
Reduced pressure, [-]
Returns
-------
prop : array
Array with ideal Gibbs energy partial derivatives:
* g: Ideal Specific Gibbs energy [kJ/kg]
... | [
"Ideal",
"properties",
"for",
"Region",
"2"
] | python | train | 28.357143 |
DataBiosphere/toil | src/toil/serviceManager.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/serviceManager.py#L73-L88 | def scheduleServices(self, jobGraph):
"""
Schedule the services of a job asynchronously.
When the job's services are running the jobGraph for the job will
be returned by toil.leader.ServiceManager.getJobGraphsWhoseServicesAreRunning.
:param toil.jobGraph.JobGraph jobGraph: wrapp... | [
"def",
"scheduleServices",
"(",
"self",
",",
"jobGraph",
")",
":",
"# Add jobGraph to set being processed by the service manager",
"self",
".",
"jobGraphsWithServicesBeingStarted",
".",
"add",
"(",
"jobGraph",
")",
"# Add number of jobs managed by ServiceManager",
"self",
".",
... | Schedule the services of a job asynchronously.
When the job's services are running the jobGraph for the job will
be returned by toil.leader.ServiceManager.getJobGraphsWhoseServicesAreRunning.
:param toil.jobGraph.JobGraph jobGraph: wrapper of job with services to schedule. | [
"Schedule",
"the",
"services",
"of",
"a",
"job",
"asynchronously",
".",
"When",
"the",
"job",
"s",
"services",
"are",
"running",
"the",
"jobGraph",
"for",
"the",
"job",
"will",
"be",
"returned",
"by",
"toil",
".",
"leader",
".",
"ServiceManager",
".",
"get... | python | train | 47.8125 |
spyder-ide/spyder | spyder/utils/stringmatching.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/stringmatching.py#L50-L176 | def get_search_score(query, choice, ignore_case=True, apply_regex=True,
template='{}'):
"""Returns a tuple with the enriched text (if a template is provided) and
a score for the match.
Parameters
----------
query : str
String with letters to search in choice (in order o... | [
"def",
"get_search_score",
"(",
"query",
",",
"choice",
",",
"ignore_case",
"=",
"True",
",",
"apply_regex",
"=",
"True",
",",
"template",
"=",
"'{}'",
")",
":",
"original_choice",
"=",
"choice",
"result",
"=",
"(",
"original_choice",
",",
"NOT_FOUND_SCORE",
... | Returns a tuple with the enriched text (if a template is provided) and
a score for the match.
Parameters
----------
query : str
String with letters to search in choice (in order of appearance).
choice : str
Sentence/words in which to search for the 'query' letters.
ignore_case :... | [
"Returns",
"a",
"tuple",
"with",
"the",
"enriched",
"text",
"(",
"if",
"a",
"template",
"is",
"provided",
")",
"and",
"a",
"score",
"for",
"the",
"match",
"."
] | python | train | 35.377953 |
niemasd/TreeSwift | treeswift/Tree.py | https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L986-L992 | def scale_edges(self, multiplier):
'''Multiply all edges in this ``Tree`` by ``multiplier``'''
if not isinstance(multiplier,int) and not isinstance(multiplier,float):
raise TypeError("multiplier must be an int or float")
for node in self.traverse_preorder():
if node.edge_... | [
"def",
"scale_edges",
"(",
"self",
",",
"multiplier",
")",
":",
"if",
"not",
"isinstance",
"(",
"multiplier",
",",
"int",
")",
"and",
"not",
"isinstance",
"(",
"multiplier",
",",
"float",
")",
":",
"raise",
"TypeError",
"(",
"\"multiplier must be an int or flo... | Multiply all edges in this ``Tree`` by ``multiplier`` | [
"Multiply",
"all",
"edges",
"in",
"this",
"Tree",
"by",
"multiplier"
] | python | train | 54.285714 |
rigetti/quantumflow | quantumflow/measures.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/measures.py#L59-L73 | def purity(rho: Density) -> bk.BKTensor:
"""
Calculate the purity of a mixed quantum state.
Purity, defined as tr(rho^2), has an upper bound of 1 for a pure state,
and a lower bound of 1/D (where D is the Hilbert space dimension) for a
competently mixed state.
Two closely related measures are ... | [
"def",
"purity",
"(",
"rho",
":",
"Density",
")",
"->",
"bk",
".",
"BKTensor",
":",
"tensor",
"=",
"rho",
".",
"tensor",
"N",
"=",
"rho",
".",
"qubit_nb",
"matrix",
"=",
"bk",
".",
"reshape",
"(",
"tensor",
",",
"[",
"2",
"**",
"N",
",",
"2",
"... | Calculate the purity of a mixed quantum state.
Purity, defined as tr(rho^2), has an upper bound of 1 for a pure state,
and a lower bound of 1/D (where D is the Hilbert space dimension) for a
competently mixed state.
Two closely related measures are the linear entropy, 1- purity, and the
participat... | [
"Calculate",
"the",
"purity",
"of",
"a",
"mixed",
"quantum",
"state",
"."
] | python | train | 35 |
xenadevel/PyXenaManager | xenamanager/api/xena_rest.py | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_rest.py#L113-L123 | def set_attributes(self, obj, **attributes):
""" Set attributes.
:param obj: requested object.
:param attributes: dictionary of {attribute: value} to set
"""
attributes_url = '{}/{}/attributes'.format(self.session_url, obj.ref)
attributes_list = [{u'name': str(name), u'... | [
"def",
"set_attributes",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"attributes",
")",
":",
"attributes_url",
"=",
"'{}/{}/attributes'",
".",
"format",
"(",
"self",
".",
"session_url",
",",
"obj",
".",
"ref",
")",
"attributes_list",
"=",
"[",
"{",
"u'name'",
... | Set attributes.
:param obj: requested object.
:param attributes: dictionary of {attribute: value} to set | [
"Set",
"attributes",
"."
] | python | train | 47.818182 |
IdentityPython/SATOSA | src/satosa/internal.py | https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/internal.py#L44-L55 | def from_dict(cls, data):
"""
:type data: dict[str, str]
:rtype: satosa.internal.AuthenticationInformation
:param data: A dict representation of an AuthenticationInformation object
:return: An AuthenticationInformation object
"""
return cls(
auth_class... | [
"def",
"from_dict",
"(",
"cls",
",",
"data",
")",
":",
"return",
"cls",
"(",
"auth_class_ref",
"=",
"data",
".",
"get",
"(",
"\"auth_class_ref\"",
")",
",",
"timestamp",
"=",
"data",
".",
"get",
"(",
"\"timestamp\"",
")",
",",
"issuer",
"=",
"data",
".... | :type data: dict[str, str]
:rtype: satosa.internal.AuthenticationInformation
:param data: A dict representation of an AuthenticationInformation object
:return: An AuthenticationInformation object | [
":",
"type",
"data",
":",
"dict",
"[",
"str",
"str",
"]",
":",
"rtype",
":",
"satosa",
".",
"internal",
".",
"AuthenticationInformation",
":",
"param",
"data",
":",
"A",
"dict",
"representation",
"of",
"an",
"AuthenticationInformation",
"object",
":",
"retur... | python | train | 36.25 |
bjoernricks/python-quilt | quilt/db.py | https://github.com/bjoernricks/python-quilt/blob/fae88237f601848cc34d073584d9dcb409f01777/quilt/db.py#L125-L130 | def save(self):
""" Saves current patches list in the series file """
with open(self.series_file, "wb") as f:
for patchline in self.patchlines:
f.write(_encode_str(str(patchline)))
f.write(b"\n") | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"series_file",
",",
"\"wb\"",
")",
"as",
"f",
":",
"for",
"patchline",
"in",
"self",
".",
"patchlines",
":",
"f",
".",
"write",
"(",
"_encode_str",
"(",
"str",
"(",
"patchline",
... | Saves current patches list in the series file | [
"Saves",
"current",
"patches",
"list",
"in",
"the",
"series",
"file"
] | python | test | 41.666667 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/entitlements.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/entitlements.py#L57-L66 | def delete_entitlement(owner, repo, identifier):
"""Delete an entitlement from a repository."""
client = get_entitlements_api()
with catch_raise_api_exception():
_, _, headers = client.entitlements_delete_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratel... | [
"def",
"delete_entitlement",
"(",
"owner",
",",
"repo",
",",
"identifier",
")",
":",
"client",
"=",
"get_entitlements_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"_",
",",
"_",
",",
"headers",
"=",
"client",
".",
"entitlements_delete_wi... | Delete an entitlement from a repository. | [
"Delete",
"an",
"entitlement",
"from",
"a",
"repository",
"."
] | python | train | 35 |
tensorflow/tensor2tensor | tensor2tensor/trax/layers/core.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/layers/core.py#L247-L275 | def _conv_general_permutations(self, dimension_numbers):
"""Utility for convolution dimension permutations relative to Conv HLO."""
lhs_spec, rhs_spec, out_spec = dimension_numbers
lhs_char, rhs_char, out_char = ('N', 'C'), ('O', 'I'), ('N', 'C')
charpairs = (lhs_char, rhs_char, out_char)
for i, (a,... | [
"def",
"_conv_general_permutations",
"(",
"self",
",",
"dimension_numbers",
")",
":",
"lhs_spec",
",",
"rhs_spec",
",",
"out_spec",
"=",
"dimension_numbers",
"lhs_char",
",",
"rhs_char",
",",
"out_char",
"=",
"(",
"'N'",
",",
"'C'",
")",
",",
"(",
"'O'",
","... | Utility for convolution dimension permutations relative to Conv HLO. | [
"Utility",
"for",
"convolution",
"dimension",
"permutations",
"relative",
"to",
"Conv",
"HLO",
"."
] | python | train | 54.448276 |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/custom_objects_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/custom_objects_api.py#L1195-L1219 | def get_namespaced_custom_object_status(self, group, version, namespace, plural, name, **kwargs): # noqa: E501
"""get_namespaced_custom_object_status # noqa: E501
read status of the specified namespace scoped custom object # noqa: E501
This method makes a synchronous HTTP request by default.... | [
"def",
"get_namespaced_custom_object_status",
"(",
"self",
",",
"group",
",",
"version",
",",
"namespace",
",",
"plural",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs... | get_namespaced_custom_object_status # noqa: E501
read status of the specified namespace scoped custom object # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_namespaced_custom_ob... | [
"get_namespaced_custom_object_status",
"#",
"noqa",
":",
"E501"
] | python | train | 59.24 |
JoeVirtual/KonFoo | konfoo/core.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L428-L538 | def load(self, file, **options):
""" Loads the field *value* for each :class:`Field` *nested* in the
`Container` from an ``.ini`` *file*.
:param str file: name and location of the ``.ini`` *file*.
:keyword str section: section in the ``.ini`` *file* to lookup the
value for e... | [
"def",
"load",
"(",
"self",
",",
"file",
",",
"*",
"*",
"options",
")",
":",
"section",
"=",
"options",
".",
"pop",
"(",
"'section'",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"parser",
"=",
"ConfigParser",
"(",
")",
"parser",
".",
"read",... | Loads the field *value* for each :class:`Field` *nested* in the
`Container` from an ``.ini`` *file*.
:param str file: name and location of the ``.ini`` *file*.
:keyword str section: section in the ``.ini`` *file* to lookup the
value for each :class:`Field` in the `Container`.
... | [
"Loads",
"the",
"field",
"*",
"value",
"*",
"for",
"each",
":",
"class",
":",
"Field",
"*",
"nested",
"*",
"in",
"the",
"Container",
"from",
"an",
".",
"ini",
"*",
"file",
"*",
"."
] | python | train | 38.387387 |
warrenspe/hconf | hconf/subparsers/ini.py | https://github.com/warrenspe/hconf/blob/12074d15dc3641d3903488c95d89a507386a32d5/hconf/subparsers/ini.py#L46-L67 | def parse(self, configManager, config):
"""
Parse configuration options out of an .ini configuration file.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object containing configuration options popul... | [
"def",
"parse",
"(",
"self",
",",
"configManager",
",",
"config",
")",
":",
"parser",
"=",
"ConfigParser",
".",
"RawConfigParser",
"(",
")",
"configOptions",
"=",
"dict",
"(",
")",
"configFile",
"=",
"self",
".",
"_getConfigFile",
"(",
"config",
")",
"if",... | Parse configuration options out of an .ini configuration file.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object containing configuration options populated thus far.
Outputs: A dictionary of new configu... | [
"Parse",
"configuration",
"options",
"out",
"of",
"an",
".",
"ini",
"configuration",
"file",
"."
] | python | train | 37.090909 |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L179-L189 | def _get_loftee(data):
"""Retrieve loss of function plugin parameters for LOFTEE.
https://github.com/konradjk/loftee
"""
ancestral_file = tz.get_in(("genome_resources", "variation", "ancestral"), data)
if not ancestral_file or not os.path.exists(ancestral_file):
ancestral_file = "false"
... | [
"def",
"_get_loftee",
"(",
"data",
")",
":",
"ancestral_file",
"=",
"tz",
".",
"get_in",
"(",
"(",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"ancestral\"",
")",
",",
"data",
")",
"if",
"not",
"ancestral_file",
"or",
"not",
"os",
".",
"path",
"."... | Retrieve loss of function plugin parameters for LOFTEE.
https://github.com/konradjk/loftee | [
"Retrieve",
"loss",
"of",
"function",
"plugin",
"parameters",
"for",
"LOFTEE",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"konradjk",
"/",
"loftee"
] | python | train | 47 |
apple/turicreate | src/unity/python/turicreate/_gl_pickle.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/_gl_pickle.py#L52-L71 | def _is_not_pickle_safe_gl_class(obj_class):
"""
Check if class is a Turi create model.
The function does it by checking the method resolution order (MRO) of the
class and verifies that _Model is the base class.
Parameters
----------
obj_class : Class to be checked.
Returns
---... | [
"def",
"_is_not_pickle_safe_gl_class",
"(",
"obj_class",
")",
":",
"gl_ds",
"=",
"[",
"_SFrame",
",",
"_SArray",
",",
"_SGraph",
"]",
"# Object is GLC-DS or GLC-Model",
"return",
"(",
"obj_class",
"in",
"gl_ds",
")",
"or",
"_is_not_pickle_safe_gl_model_class",
"(",
... | Check if class is a Turi create model.
The function does it by checking the method resolution order (MRO) of the
class and verifies that _Model is the base class.
Parameters
----------
obj_class : Class to be checked.
Returns
----------
True if the class is a GLC Model. | [
"Check",
"if",
"class",
"is",
"a",
"Turi",
"create",
"model",
"."
] | python | train | 25.65 |
EmbodiedCognition/pagoda | pagoda/skeleton.py | https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/skeleton.py#L284-L295 | def joint_distances(self):
'''Get the current joint separations for the skeleton.
Returns
-------
distances : list of float
A list expressing the distance between the two joint anchor points,
for each joint in the skeleton. These quantities describe how
... | [
"def",
"joint_distances",
"(",
"self",
")",
":",
"return",
"[",
"(",
"(",
"np",
".",
"array",
"(",
"j",
".",
"anchor",
")",
"-",
"j",
".",
"anchor2",
")",
"**",
"2",
")",
".",
"sum",
"(",
")",
"for",
"j",
"in",
"self",
".",
"joints",
"]"
] | Get the current joint separations for the skeleton.
Returns
-------
distances : list of float
A list expressing the distance between the two joint anchor points,
for each joint in the skeleton. These quantities describe how
"exploded" the bodies in the skelet... | [
"Get",
"the",
"current",
"joint",
"separations",
"for",
"the",
"skeleton",
"."
] | python | valid | 45.5 |
chaoss/grimoirelab-elk | utils/index_mapping.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/utils/index_mapping.py#L62-L89 | def find_uuid(es_url, index):
""" Find the unique identifier field for a given index """
uid_field = None
# Get the first item to detect the data source and raw/enriched type
res = requests.get('%s/%s/_search?size=1' % (es_url, index))
first_item = res.json()['hits']['hits'][0]['_source']
fiel... | [
"def",
"find_uuid",
"(",
"es_url",
",",
"index",
")",
":",
"uid_field",
"=",
"None",
"# Get the first item to detect the data source and raw/enriched type",
"res",
"=",
"requests",
".",
"get",
"(",
"'%s/%s/_search?size=1'",
"%",
"(",
"es_url",
",",
"index",
")",
")"... | Find the unique identifier field for a given index | [
"Find",
"the",
"unique",
"identifier",
"field",
"for",
"a",
"given",
"index"
] | python | train | 35.25 |
tk0miya/tk.phpautodoc | src/phply/phpparse.py | https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L556-L562 | def p_class_constant_declaration(p):
'''class_constant_declaration : class_constant_declaration COMMA STRING EQUALS static_scalar
| CONST STRING EQUALS static_scalar'''
if len(p) == 6:
p[0] = p[1] + [ast.ClassConstant(p[3], p[5], lineno=p.lineno(2))]
else:
p... | [
"def",
"p_class_constant_declaration",
"(",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"6",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",
"[",
"ast",
".",
"ClassConstant",
"(",
"p",
"[",
"3",
"]",
",",
"p",
"[",
"5",
"]",
","... | class_constant_declaration : class_constant_declaration COMMA STRING EQUALS static_scalar
| CONST STRING EQUALS static_scalar | [
"class_constant_declaration",
":",
"class_constant_declaration",
"COMMA",
"STRING",
"EQUALS",
"static_scalar",
"|",
"CONST",
"STRING",
"EQUALS",
"static_scalar"
] | python | train | 53 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L525-L586 | def _add_cat_dict(self,
cat_dict_class,
key_in_self,
check_for_dupes=True,
compare_to_existing=True,
**kwargs):
"""Add a `CatDict` to this `Entry`.
CatDict only added if initialization succeeds... | [
"def",
"_add_cat_dict",
"(",
"self",
",",
"cat_dict_class",
",",
"key_in_self",
",",
"check_for_dupes",
"=",
"True",
",",
"compare_to_existing",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Make sure that a source is given, and is valid (nor erroneous)",
"if",
"... | Add a `CatDict` to this `Entry`.
CatDict only added if initialization succeeds and it
doesn't already exist within the Entry. | [
"Add",
"a",
"CatDict",
"to",
"this",
"Entry",
"."
] | python | train | 43.016129 |
tensorflow/probability | tensorflow_probability/python/distributions/gaussian_process_regression_model.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/gaussian_process_regression_model.py#L39-L70 | def _is_empty_observation_data(
feature_ndims, observation_index_points, observations):
"""Returns `True` if given observation data is empty.
Emptiness means either
1. Both `observation_index_points` and `observations` are `None`, or
2. the "number of observations" shape is 0. The shape of
`observa... | [
"def",
"_is_empty_observation_data",
"(",
"feature_ndims",
",",
"observation_index_points",
",",
"observations",
")",
":",
"# If both input locations and observations are `None`, we consider this",
"# \"empty\" observation data.",
"if",
"observation_index_points",
"is",
"None",
"and"... | Returns `True` if given observation data is empty.
Emptiness means either
1. Both `observation_index_points` and `observations` are `None`, or
2. the "number of observations" shape is 0. The shape of
`observation_index_points` is `[..., N, f1, ..., fF]`, where `N` is the
number of observations and th... | [
"Returns",
"True",
"if",
"given",
"observation",
"data",
"is",
"empty",
"."
] | python | test | 41.46875 |
ewels/MultiQC | multiqc/modules/minionqc/minionqc.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/minionqc/minionqc.py#L72-L110 | def parse_minionqc_report(self, s_name, f):
'''
Parses minionqc's 'summary.yaml' report file for results.
Uses only the "All reads" stats. Ignores "Q>=x" part.
'''
try:
# Parsing as OrderedDict is slightly messier with YAML
# http://stackoverflow.com/a/210... | [
"def",
"parse_minionqc_report",
"(",
"self",
",",
"s_name",
",",
"f",
")",
":",
"try",
":",
"# Parsing as OrderedDict is slightly messier with YAML",
"# http://stackoverflow.com/a/21048064/713980",
"def",
"dict_constructor",
"(",
"loader",
",",
"node",
")",
":",
"return",... | Parses minionqc's 'summary.yaml' report file for results.
Uses only the "All reads" stats. Ignores "Q>=x" part. | [
"Parses",
"minionqc",
"s",
"summary",
".",
"yaml",
"report",
"file",
"for",
"results",
".",
"Uses",
"only",
"the",
"All",
"reads",
"stats",
".",
"Ignores",
"Q",
">",
"=",
"x",
"part",
"."
] | python | train | 44.333333 |
openid/python-openid | openid/server/trustroot.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/server/trustroot.py#L136-L188 | def isSane(self):
"""
This method checks the to see if a trust root represents a
reasonable (sane) set of URLs. 'http://*.com/', for example
is not a reasonable pattern, as it cannot meaningfully specify
the site claiming it. This function attempts to find many
related ... | [
"def",
"isSane",
"(",
"self",
")",
":",
"if",
"self",
".",
"host",
"==",
"'localhost'",
":",
"return",
"True",
"host_parts",
"=",
"self",
".",
"host",
".",
"split",
"(",
"'.'",
")",
"if",
"self",
".",
"wildcard",
":",
"assert",
"host_parts",
"[",
"0"... | This method checks the to see if a trust root represents a
reasonable (sane) set of URLs. 'http://*.com/', for example
is not a reasonable pattern, as it cannot meaningfully specify
the site claiming it. This function attempts to find many
related examples, but it can only work via heu... | [
"This",
"method",
"checks",
"the",
"to",
"see",
"if",
"a",
"trust",
"root",
"represents",
"a",
"reasonable",
"(",
"sane",
")",
"set",
"of",
"URLs",
".",
"http",
":",
"//",
"*",
".",
"com",
"/",
"for",
"example",
"is",
"not",
"a",
"reasonable",
"patte... | python | train | 30.566038 |
chrisjrn/registrasion | registrasion/views.py | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L733-L775 | def invoice(request, invoice_id, access_code=None):
''' Displays an invoice.
This view is not authenticated, but it will only allow access to either:
the user the invoice belongs to; staff; or a request made with the correct
access code.
Arguments:
invoice_id (castable to int): The invoic... | [
"def",
"invoice",
"(",
"request",
",",
"invoice_id",
",",
"access_code",
"=",
"None",
")",
":",
"current_invoice",
"=",
"InvoiceController",
".",
"for_id_or_404",
"(",
"invoice_id",
")",
"if",
"not",
"current_invoice",
".",
"can_view",
"(",
"user",
"=",
"reque... | Displays an invoice.
This view is not authenticated, but it will only allow access to either:
the user the invoice belongs to; staff; or a request made with the correct
access code.
Arguments:
invoice_id (castable to int): The invoice_id for the invoice you want
to view.
... | [
"Displays",
"an",
"invoice",
"."
] | python | test | 26.139535 |
doconix/django-mako-plus | django_mako_plus/provider/base.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/base.py#L149-L153 | def get_cache_item(self):
'''Gets the cached item. Raises AttributeError if it hasn't been set.'''
if settings.DEBUG:
raise AttributeError('Caching disabled in DEBUG mode')
return getattr(self.template, self.options['template_cache_key']) | [
"def",
"get_cache_item",
"(",
"self",
")",
":",
"if",
"settings",
".",
"DEBUG",
":",
"raise",
"AttributeError",
"(",
"'Caching disabled in DEBUG mode'",
")",
"return",
"getattr",
"(",
"self",
".",
"template",
",",
"self",
".",
"options",
"[",
"'template_cache_ke... | Gets the cached item. Raises AttributeError if it hasn't been set. | [
"Gets",
"the",
"cached",
"item",
".",
"Raises",
"AttributeError",
"if",
"it",
"hasn",
"t",
"been",
"set",
"."
] | python | train | 54 |
scour-project/scour | scour/scour.py | https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L656-L690 | def removeUnreferencedElements(doc, keepDefs):
"""
Removes all unreferenced elements except for <svg>, <font>, <metadata>, <title>, and <desc>.
Also vacuums the defs of any non-referenced renderable elements.
Returns the number of unreferenced elements removed from the document.
"""
global _num... | [
"def",
"removeUnreferencedElements",
"(",
"doc",
",",
"keepDefs",
")",
":",
"global",
"_num_elements_removed",
"num",
"=",
"0",
"# Remove certain unreferenced elements outside of defs",
"removeTags",
"=",
"[",
"'linearGradient'",
",",
"'radialGradient'",
",",
"'pattern'",
... | Removes all unreferenced elements except for <svg>, <font>, <metadata>, <title>, and <desc>.
Also vacuums the defs of any non-referenced renderable elements.
Returns the number of unreferenced elements removed from the document. | [
"Removes",
"all",
"unreferenced",
"elements",
"except",
"for",
"<svg",
">",
"<font",
">",
"<metadata",
">",
"<title",
">",
"and",
"<desc",
">",
".",
"Also",
"vacuums",
"the",
"defs",
"of",
"any",
"non",
"-",
"referenced",
"renderable",
"elements",
"."
] | python | train | 39.314286 |
Qiskit/qiskit-terra | qiskit/quantum_info/operators/channel/kraus.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L250-L265 | def power(self, n):
"""The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
Kraus: the matrix power of the SuperOp converted to a Kraus channel.
Raises:
QiskitError: if the input and output d... | [
"def",
"power",
"(",
"self",
",",
"n",
")",
":",
"if",
"n",
">",
"0",
":",
"return",
"super",
"(",
")",
".",
"power",
"(",
"n",
")",
"return",
"Kraus",
"(",
"SuperOp",
"(",
"self",
")",
".",
"power",
"(",
"n",
")",
")"
] | The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
Kraus: the matrix power of the SuperOp converted to a Kraus channel.
Raises:
QiskitError: if the input and output dimensions of the
Qu... | [
"The",
"matrix",
"power",
"of",
"the",
"channel",
"."
] | python | test | 31.625 |
jameslyons/python_speech_features | python_speech_features/base.py | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L149-L177 | def get_filterbanks(nfilt=20,nfft=512,samplerate=16000,lowfreq=0,highfreq=None):
"""Compute a Mel-filterbank. The filters are stored in the rows, the columns correspond
to fft bins. The filters are returned as an array of size nfilt * (nfft/2 + 1)
:param nfilt: the number of filters in the filterbank, defa... | [
"def",
"get_filterbanks",
"(",
"nfilt",
"=",
"20",
",",
"nfft",
"=",
"512",
",",
"samplerate",
"=",
"16000",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
"None",
")",
":",
"highfreq",
"=",
"highfreq",
"or",
"samplerate",
"/",
"2",
"assert",
"highfre... | Compute a Mel-filterbank. The filters are stored in the rows, the columns correspond
to fft bins. The filters are returned as an array of size nfilt * (nfft/2 + 1)
:param nfilt: the number of filters in the filterbank, default 20.
:param nfft: the FFT size. Default is 512.
:param samplerate: the sample... | [
"Compute",
"a",
"Mel",
"-",
"filterbank",
".",
"The",
"filters",
"are",
"stored",
"in",
"the",
"rows",
"the",
"columns",
"correspond",
"to",
"fft",
"bins",
".",
"The",
"filters",
"are",
"returned",
"as",
"an",
"array",
"of",
"size",
"nfilt",
"*",
"(",
... | python | train | 50.241379 |
aws/sagemaker-containers | src/sagemaker_containers/_mpi.py | https://github.com/aws/sagemaker-containers/blob/0030f07abbaf22a55d986d97274d7a8d1aa1f10c/src/sagemaker_containers/_mpi.py#L207-L227 | def _can_connect(host, port=22): # type: (str, int) -> bool
"""Checks if the connection to provided ``host`` and ``port`` is possible or not.
Args:
host (str): Hostname for the host to check connection.
port (int): Port name of the host to check connection on.
"""
try:
... | [
"def",
"_can_connect",
"(",
"host",
",",
"port",
"=",
"22",
")",
":",
"# type: (str, int) -> bool",
"try",
":",
"logger",
".",
"debug",
"(",
"'Testing connection to host %s'",
",",
"host",
")",
"client",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"client",
... | Checks if the connection to provided ``host`` and ``port`` is possible or not.
Args:
host (str): Hostname for the host to check connection.
port (int): Port name of the host to check connection on. | [
"Checks",
"if",
"the",
"connection",
"to",
"provided",
"host",
"and",
"port",
"is",
"possible",
"or",
"not",
".",
"Args",
":",
"host",
"(",
"str",
")",
":",
"Hostname",
"for",
"the",
"host",
"to",
"check",
"connection",
".",
"port",
"(",
"int",
")",
... | python | train | 39.52381 |
cldf/pycldf | src/pycldf/dataset.py | https://github.com/cldf/pycldf/blob/636f1eb3ea769394e14ad9e42a83b6096efa9728/src/pycldf/dataset.py#L161-L189 | def auto_constraints(self, component=None):
"""
Use CLDF reference properties to implicitely create foreign key constraints.
:param component: A Table object or `None`.
"""
if not component:
for table in self.tables:
self.auto_constraints(table)
... | [
"def",
"auto_constraints",
"(",
"self",
",",
"component",
"=",
"None",
")",
":",
"if",
"not",
"component",
":",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"self",
".",
"auto_constraints",
"(",
"table",
")",
"return",
"if",
"not",
"component",
".",... | Use CLDF reference properties to implicitely create foreign key constraints.
:param component: A Table object or `None`. | [
"Use",
"CLDF",
"reference",
"properties",
"to",
"implicitely",
"create",
"foreign",
"key",
"constraints",
"."
] | python | valid | 35.965517 |
klahnakoski/pyLibrary | jx_base/language.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/language.py#L147-L216 | def value_compare(left, right, ordering=1):
"""
SORT VALUES, NULL IS THE LEAST VALUE
:param left: LHS
:param right: RHS
:param ordering: (-1, 0, 1) TO AFFECT SORT ORDER
:return: The return value is negative if x < y, zero if x == y and strictly positive if x > y.
"""
try:
ltype ... | [
"def",
"value_compare",
"(",
"left",
",",
"right",
",",
"ordering",
"=",
"1",
")",
":",
"try",
":",
"ltype",
"=",
"left",
".",
"__class__",
"rtype",
"=",
"right",
".",
"__class__",
"if",
"ltype",
"in",
"list_types",
"or",
"rtype",
"in",
"list_types",
"... | SORT VALUES, NULL IS THE LEAST VALUE
:param left: LHS
:param right: RHS
:param ordering: (-1, 0, 1) TO AFFECT SORT ORDER
:return: The return value is negative if x < y, zero if x == y and strictly positive if x > y. | [
"SORT",
"VALUES",
"NULL",
"IS",
"THE",
"LEAST",
"VALUE",
":",
"param",
"left",
":",
"LHS",
":",
"param",
"right",
":",
"RHS",
":",
"param",
"ordering",
":",
"(",
"-",
"1",
"0",
"1",
")",
"TO",
"AFFECT",
"SORT",
"ORDER",
":",
"return",
":",
"The",
... | python | train | 30.685714 |
aalireza/SimpleAudioIndexer | SimpleAudioIndexer/__init__.py | https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L439-L454 | def _get_audio_channels(self, audio_abs_path):
"""
Parameters
----------
audio_abs_path : str
Returns
-------
channel_num : int
"""
channel_num = int(
subprocess.check_output(
("""sox --i {} | grep "{}" | awk -F " : " '... | [
"def",
"_get_audio_channels",
"(",
"self",
",",
"audio_abs_path",
")",
":",
"channel_num",
"=",
"int",
"(",
"subprocess",
".",
"check_output",
"(",
"(",
"\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}'\"\"\"",
")",
".",
"format",
"(",
"audio_abs_path",
",... | Parameters
----------
audio_abs_path : str
Returns
-------
channel_num : int | [
"Parameters",
"----------",
"audio_abs_path",
":",
"str"
] | python | train | 29.125 |
Contraz/demosys-py | demosys/context/__init__.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/context/__init__.py#L23-L29 | def ctx() -> moderngl.Context:
"""ModernGL context"""
win = window()
if not win.ctx:
raise RuntimeError("Attempting to get context before creation")
return win.ctx | [
"def",
"ctx",
"(",
")",
"->",
"moderngl",
".",
"Context",
":",
"win",
"=",
"window",
"(",
")",
"if",
"not",
"win",
".",
"ctx",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to get context before creation\"",
")",
"return",
"win",
".",
"ctx"
] | ModernGL context | [
"ModernGL",
"context"
] | python | valid | 26 |
RI-imaging/qpformat | qpformat/file_formats/series_hdf5_qpimage.py | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_qpimage.py#L32-L47 | def get_qpimage(self, idx):
"""Return background-corrected QPImage of data at index `idx`"""
if self._bgdata:
# The user has explicitly chosen different background data
# using `get_qpimage_raw`.
qpi = super(SeriesHdf5Qpimage, self).get_qpimage(idx)
else:
... | [
"def",
"get_qpimage",
"(",
"self",
",",
"idx",
")",
":",
"if",
"self",
".",
"_bgdata",
":",
"# The user has explicitly chosen different background data",
"# using `get_qpimage_raw`.",
"qpi",
"=",
"super",
"(",
"SeriesHdf5Qpimage",
",",
"self",
")",
".",
"get_qpimage",... | Return background-corrected QPImage of data at index `idx` | [
"Return",
"background",
"-",
"corrected",
"QPImage",
"of",
"data",
"at",
"index",
"idx"
] | python | train | 43.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.