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 |
|---|---|---|---|---|---|---|---|---|---|
diging/tethne | tethne/classes/graphcollection.py | https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/classes/graphcollection.py#L213-L235 | def edges(self, data=False, native=True):
"""
Returns a list of all edges in the :class:`.GraphCollection`\.
Parameters
----------
data : bool
(default: False) If True, returns a list of 3-tuples containing
source and target node labels, and attributes.
... | [
"def",
"edges",
"(",
"self",
",",
"data",
"=",
"False",
",",
"native",
"=",
"True",
")",
":",
"edges",
"=",
"self",
".",
"master_graph",
".",
"edges",
"(",
"data",
"=",
"data",
")",
"if",
"native",
":",
"if",
"data",
":",
"edges",
"=",
"[",
"(",
... | Returns a list of all edges in the :class:`.GraphCollection`\.
Parameters
----------
data : bool
(default: False) If True, returns a list of 3-tuples containing
source and target node labels, and attributes.
Returns
-------
edges : list | [
"Returns",
"a",
"list",
"of",
"all",
"edges",
"in",
"the",
":",
"class",
":",
".",
"GraphCollection",
"\\",
"."
] | python | train | 31.565217 |
beerfactory/hbmqtt | hbmqtt/plugins/manager.py | https://github.com/beerfactory/hbmqtt/blob/4aa6fe982141abc3c54e9f4d7b981ab3eba0a13c/hbmqtt/plugins/manager.py#L115-L151 | def fire_event(self, event_name, wait=False, *args, **kwargs):
"""
Fire an event to plugins.
PluginManager schedule @asyncio.coroutinecalls for each plugin on method called "on_" + event_name
For example, on_connect will be called on event 'connect'
Method calls are schedule in t... | [
"def",
"fire_event",
"(",
"self",
",",
"event_name",
",",
"wait",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tasks",
"=",
"[",
"]",
"event_method_name",
"=",
"\"on_\"",
"+",
"event_name",
"for",
"plugin",
"in",
"self",
".",
"... | Fire an event to plugins.
PluginManager schedule @asyncio.coroutinecalls for each plugin on method called "on_" + event_name
For example, on_connect will be called on event 'connect'
Method calls are schedule in the asyn loop. wait parameter must be set to true to wait until all
mehtods ... | [
"Fire",
"an",
"event",
"to",
"plugins",
".",
"PluginManager",
"schedule"
] | python | train | 42.27027 |
moonso/vcf_parser | vcf_parser/utils/build_vep.py | https://github.com/moonso/vcf_parser/blob/8e2b6724e31995e0d43af501f25974310c6b843b/vcf_parser/utils/build_vep.py#L3-L31 | def build_vep_string(vep_info, vep_columns):
"""
Build a vep string formatted string.
Take a list with vep annotations and build a new vep string
Args:
vep_info (list): A list with vep annotation dictionaries
vep_columns (list): A list with the vep column names found in the
... | [
"def",
"build_vep_string",
"(",
"vep_info",
",",
"vep_columns",
")",
":",
"logger",
"=",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"Building vep string from {0}\"",
".",
"format",
"(",
"vep_info",
")",
")",
"logger",
".",
"debug",
"(",
... | Build a vep string formatted string.
Take a list with vep annotations and build a new vep string
Args:
vep_info (list): A list with vep annotation dictionaries
vep_columns (list): A list with the vep column names found in the
header of the vcf
Returns:
string: ... | [
"Build",
"a",
"vep",
"string",
"formatted",
"string",
".",
"Take",
"a",
"list",
"with",
"vep",
"annotations",
"and",
"build",
"a",
"new",
"vep",
"string",
"Args",
":",
"vep_info",
"(",
"list",
")",
":",
"A",
"list",
"with",
"vep",
"annotation",
"dictiona... | python | train | 32.448276 |
numenta/htmresearch | projects/sequence_prediction/continuous_sequence/run_knn.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/sequence_prediction/continuous_sequence/run_knn.py#L181-L198 | def normalizeSequence(sequence, considerDimensions=None):
"""
normalize sequence by subtracting the mean and
:param sequence: a list of data samples
:param considerDimensions: a list of dimensions to consider
:return: normalized sequence
"""
seq = np.array(sequence).astype('float64')
nSampleDim = seq.sh... | [
"def",
"normalizeSequence",
"(",
"sequence",
",",
"considerDimensions",
"=",
"None",
")",
":",
"seq",
"=",
"np",
".",
"array",
"(",
"sequence",
")",
".",
"astype",
"(",
"'float64'",
")",
"nSampleDim",
"=",
"seq",
".",
"shape",
"[",
"1",
"]",
"if",
"con... | normalize sequence by subtracting the mean and
:param sequence: a list of data samples
:param considerDimensions: a list of dimensions to consider
:return: normalized sequence | [
"normalize",
"sequence",
"by",
"subtracting",
"the",
"mean",
"and",
":",
"param",
"sequence",
":",
"a",
"list",
"of",
"data",
"samples",
":",
"param",
"considerDimensions",
":",
"a",
"list",
"of",
"dimensions",
"to",
"consider",
":",
"return",
":",
"normaliz... | python | train | 30.111111 |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L1641-L1662 | def get_account_api_key(self, account_id, api_key, **kwargs): # noqa: E501
"""Get API key details. # noqa: E501
An endpoint for retrieving API key details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/api-keys/{apiKey} -H 'Authorization: Bearer API_KEY'` # n... | [
"def",
"get_account_api_key",
"(",
"self",
",",
"account_id",
",",
"api_key",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'asynchronous'",
")",
":",
"return... | Get API key details. # noqa: E501
An endpoint for retrieving API key details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/api-keys/{apiKey} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
... | [
"Get",
"API",
"key",
"details",
".",
"#",
"noqa",
":",
"E501"
] | python | train | 55.227273 |
bitesofcode/projexui | projexui/widgets/xlineedit.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlineedit.py#L152-L182 | def adjustButtons( self ):
"""
Adjusts the placement of the buttons for this line edit.
"""
y = 1
for btn in self.buttons():
btn.setIconSize(self.iconSize())
btn.setFixedSize(QSize(self.height() - 2, self.height() - 2))
# adju... | [
"def",
"adjustButtons",
"(",
"self",
")",
":",
"y",
"=",
"1",
"for",
"btn",
"in",
"self",
".",
"buttons",
"(",
")",
":",
"btn",
".",
"setIconSize",
"(",
"self",
".",
"iconSize",
"(",
")",
")",
"btn",
".",
"setFixedSize",
"(",
"QSize",
"(",
"self",
... | Adjusts the placement of the buttons for this line edit. | [
"Adjusts",
"the",
"placement",
"of",
"the",
"buttons",
"for",
"this",
"line",
"edit",
"."
] | python | train | 33.258065 |
fr33jc/bang | bang/providers/hpcloud/__init__.py | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/__init__.py#L29-L104 | def create_db(self, instance_name, instance_type,
admin_username, admin_password, security_groups=None, db_name=None,
storage_size_gb=DEFAULT_STORAGE_SIZE_GB,
timeout_s=DEFAULT_TIMEOUT_S):
"""
Creates a database instance.
This method blocks until the db insta... | [
"def",
"create_db",
"(",
"self",
",",
"instance_name",
",",
"instance_type",
",",
"admin_username",
",",
"admin_password",
",",
"security_groups",
"=",
"None",
",",
"db_name",
"=",
"None",
",",
"storage_size_gb",
"=",
"DEFAULT_STORAGE_SIZE_GB",
",",
"timeout_s",
"... | Creates a database instance.
This method blocks until the db instance is active, or until
:attr:`timeout_s` has elapsed.
By default, hpcloud *assigns* an automatically-generated set of
credentials for an admin user. In addition to launching the db
instance, this method uses th... | [
"Creates",
"a",
"database",
"instance",
"."
] | python | train | 40.539474 |
theislab/scanpy | scanpy/tools/_dpt.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/tools/_dpt.py#L859-L873 | def _kendall_tau_subtract(self, len_old, diff_neg, tau_old):
"""Compute Kendall tau delta.
The new sequence has length len_old - 1.
Parameters
----------
len_old : int
The length of the old sequence, used to compute tau_old.
diff_neg : int
Differ... | [
"def",
"_kendall_tau_subtract",
"(",
"self",
",",
"len_old",
",",
"diff_neg",
",",
"tau_old",
")",
":",
"return",
"2.",
"/",
"(",
"len_old",
"-",
"2",
")",
"*",
"(",
"-",
"float",
"(",
"diff_neg",
")",
"/",
"(",
"len_old",
"-",
"1",
")",
"+",
"tau_... | Compute Kendall tau delta.
The new sequence has length len_old - 1.
Parameters
----------
len_old : int
The length of the old sequence, used to compute tau_old.
diff_neg : int
Difference between concordant and non-concordant pairs.
tau_old : floa... | [
"Compute",
"Kendall",
"tau",
"delta",
"."
] | python | train | 34.533333 |
Telefonica/toolium | toolium/config_driver.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/config_driver.py#L373-L381 | def _setup_opera(self, capabilities):
"""Setup Opera webdriver
:param capabilities: capabilities object
:returns: a new local Opera driver
"""
opera_driver = self.config.get('Driver', 'opera_driver_path')
self.logger.debug("Opera driver path given in properties: %s", ope... | [
"def",
"_setup_opera",
"(",
"self",
",",
"capabilities",
")",
":",
"opera_driver",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'Driver'",
",",
"'opera_driver_path'",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Opera driver path given in properties: %s\"",
... | Setup Opera webdriver
:param capabilities: capabilities object
:returns: a new local Opera driver | [
"Setup",
"Opera",
"webdriver"
] | python | train | 46.444444 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py#L626-L638 | def fcoe_get_login_output_fcoe_login_list_fcoe_login_session_mac(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcoe_get_login = ET.Element("fcoe_get_login")
config = fcoe_get_login
output = ET.SubElement(fcoe_get_login, "output")
fcoe_l... | [
"def",
"fcoe_get_login_output_fcoe_login_list_fcoe_login_session_mac",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcoe_get_login",
"=",
"ET",
".",
"Element",
"(",
"\"fcoe_get_login\"",
")",
"config... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 47.384615 |
tensorflow/cleverhans | cleverhans/attacks/spsa.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks/spsa.py#L246-L270 | def _compute_gradients(self, loss_fn, x, unused_optim_state):
"""Compute a new value of `x` to minimize `loss_fn`.
Args:
loss_fn: a callable that takes `x`, a batch of images, and returns
a batch of loss values. `x` will be optimized to minimize
`loss_fn(x)`.
x: A list o... | [
"def",
"_compute_gradients",
"(",
"self",
",",
"loss_fn",
",",
"x",
",",
"unused_optim_state",
")",
":",
"# Assumes `x` is a list,",
"# and contains a tensor representing a batch of images",
"assert",
"len",
"(",
"x",
")",
"==",
"1",
"and",
"isinstance",
"(",
"x",
"... | Compute a new value of `x` to minimize `loss_fn`.
Args:
loss_fn: a callable that takes `x`, a batch of images, and returns
a batch of loss values. `x` will be optimized to minimize
`loss_fn(x)`.
x: A list of Tensors, the values to be updated. This is analogous
to... | [
"Compute",
"a",
"new",
"value",
"of",
"x",
"to",
"minimize",
"loss_fn",
"."
] | python | train | 41.36 |
biolink/biolink-model | metamodel/generators/yumlgen.py | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L89-L109 | def class_box(self, cn: ClassDefinitionName) -> str:
""" Generate a box for the class. Populate its interior only if (a) it hasn't previously been generated and
(b) it appears in the gen_classes list
@param cn:
@param inherited:
@return:
"""
slot_defs: List[str]... | [
"def",
"class_box",
"(",
"self",
",",
"cn",
":",
"ClassDefinitionName",
")",
"->",
"str",
":",
"slot_defs",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"if",
"cn",
"not",
"in",
"self",
".",
"box_generated",
"and",
"(",
"not",
"self",
".",
"focus_cla... | Generate a box for the class. Populate its interior only if (a) it hasn't previously been generated and
(b) it appears in the gen_classes list
@param cn:
@param inherited:
@return: | [
"Generate",
"a",
"box",
"for",
"the",
"class",
".",
"Populate",
"its",
"interior",
"only",
"if",
"(",
"a",
")",
"it",
"hasn",
"t",
"previously",
"been",
"generated",
"and",
"(",
"b",
")",
"it",
"appears",
"in",
"the",
"gen_classes",
"list"
] | python | train | 52.571429 |
ellmetha/django-machina | machina/apps/forum_conversation/views.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/views.py#L73-L79 | def get_topic(self):
""" Returns the topic to consider. """
if not hasattr(self, 'topic'):
self.topic = get_object_or_404(
Topic.objects.select_related('forum').all(), pk=self.kwargs['pk'],
)
return self.topic | [
"def",
"get_topic",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'topic'",
")",
":",
"self",
".",
"topic",
"=",
"get_object_or_404",
"(",
"Topic",
".",
"objects",
".",
"select_related",
"(",
"'forum'",
")",
".",
"all",
"(",
")",
... | Returns the topic to consider. | [
"Returns",
"the",
"topic",
"to",
"consider",
"."
] | python | train | 38.142857 |
mozilla-iot/webthing-python | webthing/server.py | https://github.com/mozilla-iot/webthing-python/blob/65d467c89ed79d0bbc42b8b3c8f9e5a320edd237/webthing/server.py#L363-L397 | def put(self, thing_id='0', property_name=None):
"""
Handle a PUT request.
thing_id -- ID of the thing this request is for
property_name -- the name of the property from the URL path
"""
thing = self.get_thing(thing_id)
if thing is None:
self.set_stat... | [
"def",
"put",
"(",
"self",
",",
"thing_id",
"=",
"'0'",
",",
"property_name",
"=",
"None",
")",
":",
"thing",
"=",
"self",
".",
"get_thing",
"(",
"thing_id",
")",
"if",
"thing",
"is",
"None",
":",
"self",
".",
"set_status",
"(",
"404",
")",
"return",... | Handle a PUT request.
thing_id -- ID of the thing this request is for
property_name -- the name of the property from the URL path | [
"Handle",
"a",
"PUT",
"request",
"."
] | python | test | 28.942857 |
tkem/uritools | uritools/split.py | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L81-L99 | def geturi(self):
"""Return the re-combined version of the original URI reference as a
string.
"""
scheme, authority, path, query, fragment = self
# RFC 3986 5.3. Component Recomposition
result = []
if scheme is not None:
result.extend([scheme, self.... | [
"def",
"geturi",
"(",
"self",
")",
":",
"scheme",
",",
"authority",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"self",
"# RFC 3986 5.3. Component Recomposition",
"result",
"=",
"[",
"]",
"if",
"scheme",
"is",
"not",
"None",
":",
"result",
".",
"exten... | Return the re-combined version of the original URI reference as a
string. | [
"Return",
"the",
"re",
"-",
"combined",
"version",
"of",
"the",
"original",
"URI",
"reference",
"as",
"a",
"string",
"."
] | python | train | 33.263158 |
saltstack/salt | salt/modules/dpkg_lowpkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L404-L432 | def _get_pkg_ds_avail():
'''
Get the package information of the available packages, maintained by dselect.
Note, this will be not very useful, if dselect isn't installed.
:return:
'''
avail = "/var/lib/dpkg/available"
if not salt.utils.path.which('dselect') or not os.path.exists(avail):
... | [
"def",
"_get_pkg_ds_avail",
"(",
")",
":",
"avail",
"=",
"\"/var/lib/dpkg/available\"",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'dselect'",
")",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"avail",
")",
":",
"return",
... | Get the package information of the available packages, maintained by dselect.
Note, this will be not very useful, if dselect isn't installed.
:return: | [
"Get",
"the",
"package",
"information",
"of",
"the",
"available",
"packages",
"maintained",
"by",
"dselect",
".",
"Note",
"this",
"will",
"be",
"not",
"very",
"useful",
"if",
"dselect",
"isn",
"t",
"installed",
"."
] | python | train | 33.241379 |
sdss/sdss_access | python/sdss_access/path/path.py | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L453-L485 | def refine(self, filelist, regex, filterdir='out', **kwargs):
''' Returns a list of files filterd by a regular expression
Parameters
----------
filelist : list
A list of files to filter on.
regex : str
The regular expression string to filter your list
... | [
"def",
"refine",
"(",
"self",
",",
"filelist",
",",
"regex",
",",
"filterdir",
"=",
"'out'",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"filelist",
",",
"'Must provide a list of filenames to refine on'",
"assert",
"regex",
",",
"'Must provide a regular expression ... | Returns a list of files filterd by a regular expression
Parameters
----------
filelist : list
A list of files to filter on.
regex : str
The regular expression string to filter your list
filterdir: {'in', 'out'}
Indicates the filter to be inc... | [
"Returns",
"a",
"list",
"of",
"files",
"filterd",
"by",
"a",
"regular",
"expression"
] | python | train | 36.363636 |
pydanny/dj-webhooks | djwebhooks/senders/redisq.py | https://github.com/pydanny/dj-webhooks/blob/88e245bfe2020e96279af261d88bf8469ba469e5/djwebhooks/senders/redisq.py#L29-L82 | def worker(wrapped, dkwargs, hash_value=None, *args, **kwargs):
"""
This is an asynchronous sender callable that uses the Django ORM to store
webhooks. Redis is used to handle the message queue.
dkwargs argument requires the following key/values:
:event: A string representi... | [
"def",
"worker",
"(",
"wrapped",
",",
"dkwargs",
",",
"hash_value",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"event\"",
"not",
"in",
"dkwargs",
":",
"msg",
"=",
"\"djwebhooks.decorators.redis_hook requires an 'event' argument in ... | This is an asynchronous sender callable that uses the Django ORM to store
webhooks. Redis is used to handle the message queue.
dkwargs argument requires the following key/values:
:event: A string representing an event.
kwargs argument requires the following key/values
... | [
"This",
"is",
"an",
"asynchronous",
"sender",
"callable",
"that",
"uses",
"the",
"Django",
"ORM",
"to",
"store",
"webhooks",
".",
"Redis",
"is",
"used",
"to",
"handle",
"the",
"message",
"queue",
"."
] | python | valid | 33.648148 |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L357-L361 | def error(self, msg):
"""Callback run when a recoverable parsing error occurs"""
self._error = True
self._progress.printMsg('XML parse error: %s' % msg, error=True) | [
"def",
"error",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"_error",
"=",
"True",
"self",
".",
"_progress",
".",
"printMsg",
"(",
"'XML parse error: %s'",
"%",
"msg",
",",
"error",
"=",
"True",
")"
] | Callback run when a recoverable parsing error occurs | [
"Callback",
"run",
"when",
"a",
"recoverable",
"parsing",
"error",
"occurs"
] | python | train | 37 |
zhanglab/psamm | psamm/util.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/util.py#L196-L213 | def git_try_describe(repo_path):
"""Try to describe the current commit of a Git repository.
Return a string containing a string with the commit ID and/or a base tag,
if successful. Otherwise, return None.
"""
try:
p = subprocess.Popen(['git', 'describe', '--always', '--dirty'],
... | [
"def",
"git_try_describe",
"(",
"repo_path",
")",
":",
"try",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'git'",
",",
"'describe'",
",",
"'--always'",
",",
"'--dirty'",
"]",
",",
"cwd",
"=",
"repo_path",
",",
"stdout",
"=",
"subprocess",
".",
... | Try to describe the current commit of a Git repository.
Return a string containing a string with the commit ID and/or a base tag,
if successful. Otherwise, return None. | [
"Try",
"to",
"describe",
"the",
"current",
"commit",
"of",
"a",
"Git",
"repository",
"."
] | python | train | 31.666667 |
PythonCharmers/python-future | src/future/backports/email/_header_value_parser.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/_header_value_parser.py#L2318-L2370 | def get_address_list(value):
""" address_list = (address *("," address)) / obs-addr-list
obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])
We depart from the formal grammar here by continuing to parse until the end
of the input, assuming the input to be entirely composed of an
addre... | [
"def",
"get_address_list",
"(",
"value",
")",
":",
"address_list",
"=",
"AddressList",
"(",
")",
"while",
"value",
":",
"try",
":",
"token",
",",
"value",
"=",
"get_address",
"(",
"value",
")",
"address_list",
".",
"append",
"(",
"token",
")",
"except",
... | address_list = (address *("," address)) / obs-addr-list
obs-addr-list = *([CFWS] ",") address *("," [address / CFWS])
We depart from the formal grammar here by continuing to parse until the end
of the input, assuming the input to be entirely composed of an
address-list. This is always true in emai... | [
"address_list",
"=",
"(",
"address",
"*",
"(",
"address",
"))",
"/",
"obs",
"-",
"addr",
"-",
"list",
"obs",
"-",
"addr",
"-",
"list",
"=",
"*",
"(",
"[",
"CFWS",
"]",
")",
"address",
"*",
"(",
"[",
"address",
"/",
"CFWS",
"]",
")"
] | python | train | 46.528302 |
Kozea/cairocffi | cairocffi/context.py | https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L999-L1023 | def rectangle(self, x, y, width, height):
"""Adds a closed sub-path rectangle
of the given size to the current path
at position ``(x, y)`` in user-space coordinates.
This method is logically equivalent to::
context.move_to(x, y)
context.rel_line_to(width, 0)
... | [
"def",
"rectangle",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
":",
"cairo",
".",
"cairo_rectangle",
"(",
"self",
".",
"_pointer",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"self",
".",
"_check_status",
"(",
")"
... | Adds a closed sub-path rectangle
of the given size to the current path
at position ``(x, y)`` in user-space coordinates.
This method is logically equivalent to::
context.move_to(x, y)
context.rel_line_to(width, 0)
context.rel_line_to(0, height)
c... | [
"Adds",
"a",
"closed",
"sub",
"-",
"path",
"rectangle",
"of",
"the",
"given",
"size",
"to",
"the",
"current",
"path",
"at",
"position",
"(",
"x",
"y",
")",
"in",
"user",
"-",
"space",
"coordinates",
"."
] | python | train | 34.68 |
EricCrosson/stump | stump/stump.py | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L58-L80 | def pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | [
"def",
"pre",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'prefix_only'",
":",
"True",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the value of
... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
".",
"Default",
"logging",
"value",
":",
"info",
"."
] | python | train | 36.434783 |
tBuLi/symfit | symfit/core/fit.py | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/fit.py#L1031-L1040 | def dependent_data(self):
"""
Read-only Property
:return: Data belonging to each dependent variable as a dict with
variable names as key, data as value.
:rtype: collections.OrderedDict
"""
return OrderedDict((var, self.data[var])
... | [
"def",
"dependent_data",
"(",
"self",
")",
":",
"return",
"OrderedDict",
"(",
"(",
"var",
",",
"self",
".",
"data",
"[",
"var",
"]",
")",
"for",
"var",
"in",
"self",
".",
"model",
".",
"dependent_vars",
")"
] | Read-only Property
:return: Data belonging to each dependent variable as a dict with
variable names as key, data as value.
:rtype: collections.OrderedDict | [
"Read",
"-",
"only",
"Property"
] | python | train | 35.1 |
CivicSpleen/ambry | ambry/orm/partition.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/partition.py#L420-L434 | def detail_dict(self):
"""A more detailed dict that includes the descriptions, sub descriptions, table
and columns."""
d = self.dict
def aug_col(c):
d = c.dict
d['stats'] = [s.dict for s in c.stats]
return d
d['table'] = self.table.dict
... | [
"def",
"detail_dict",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"dict",
"def",
"aug_col",
"(",
"c",
")",
":",
"d",
"=",
"c",
".",
"dict",
"d",
"[",
"'stats'",
"]",
"=",
"[",
"s",
".",
"dict",
"for",
"s",
"in",
"c",
".",
"stats",
"]",
"r... | A more detailed dict that includes the descriptions, sub descriptions, table
and columns. | [
"A",
"more",
"detailed",
"dict",
"that",
"includes",
"the",
"descriptions",
"sub",
"descriptions",
"table",
"and",
"columns",
"."
] | python | train | 26.133333 |
modin-project/modin | modin/engines/base/frame/axis_partition.py | https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/engines/base/frame/axis_partition.py#L213-L236 | def deploy_func_between_two_axis_partitions(
cls, axis, func, num_splits, len_of_left, kwargs, *partitions
):
"""Deploy a function along a full axis between two data sets in Ray.
Args:
axis: The axis to perform the function along.
func: The function to perform.
... | [
"def",
"deploy_func_between_two_axis_partitions",
"(",
"cls",
",",
"axis",
",",
"func",
",",
"num_splits",
",",
"len_of_left",
",",
"kwargs",
",",
"*",
"partitions",
")",
":",
"lt_frame",
"=",
"pandas",
".",
"concat",
"(",
"list",
"(",
"partitions",
"[",
":"... | Deploy a function along a full axis between two data sets in Ray.
Args:
axis: The axis to perform the function along.
func: The function to perform.
num_splits: The number of splits to return
(see `split_result_of_axis_func_pandas`).
len_of_left: ... | [
"Deploy",
"a",
"function",
"along",
"a",
"full",
"axis",
"between",
"two",
"data",
"sets",
"in",
"Ray",
"."
] | python | train | 44.291667 |
JensRantil/rewind | rewind/server/eventstores.py | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L656-L670 | def key_exists(self, key):
"""Check if key has previously been added to this store.
This function makes a linear search through the log file and is very
slow.
Returns True if the event has previously been added, False otherwise.
"""
assert isinstance(key, str)
... | [
"def",
"key_exists",
"(",
"self",
",",
"key",
")",
":",
"assert",
"isinstance",
"(",
"key",
",",
"str",
")",
"self",
".",
"_close",
"(",
")",
"try",
":",
"return",
"self",
".",
"_unsafe_key_exists",
"(",
"key",
")",
"finally",
":",
"self",
".",
"_ope... | Check if key has previously been added to this store.
This function makes a linear search through the log file and is very
slow.
Returns True if the event has previously been added, False otherwise. | [
"Check",
"if",
"key",
"has",
"previously",
"been",
"added",
"to",
"this",
"store",
"."
] | python | train | 28.133333 |
StanfordVL/robosuite | robosuite/devices/spacemouse.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/devices/spacemouse.py#L138-L153 | def get_controller_state(self):
"""Returns the current state of the 3d mouse, a dictionary of pos, orn, grasp, and reset."""
dpos = self.control[:3] * 0.005
roll, pitch, yaw = self.control[3:] * 0.005
self.grasp = self.control_gripper
# convert RPY to an absolute orientation
... | [
"def",
"get_controller_state",
"(",
"self",
")",
":",
"dpos",
"=",
"self",
".",
"control",
"[",
":",
"3",
"]",
"*",
"0.005",
"roll",
",",
"pitch",
",",
"yaw",
"=",
"self",
".",
"control",
"[",
"3",
":",
"]",
"*",
"0.005",
"self",
".",
"grasp",
"=... | Returns the current state of the 3d mouse, a dictionary of pos, orn, grasp, and reset. | [
"Returns",
"the",
"current",
"state",
"of",
"the",
"3d",
"mouse",
"a",
"dictionary",
"of",
"pos",
"orn",
"grasp",
"and",
"reset",
"."
] | python | train | 47.0625 |
wummel/linkchecker | linkcheck/htmlutil/linkparse.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/htmlutil/linkparse.py#L164-L174 | def is_meta_url (attr, attrs):
"""Check if the meta attributes contain a URL."""
res = False
if attr == "content":
equiv = attrs.get_true('http-equiv', u'').lower()
scheme = attrs.get_true('scheme', u'').lower()
res = equiv in (u'refresh',) or scheme in (u'dcterms.uri',)
if attr ... | [
"def",
"is_meta_url",
"(",
"attr",
",",
"attrs",
")",
":",
"res",
"=",
"False",
"if",
"attr",
"==",
"\"content\"",
":",
"equiv",
"=",
"attrs",
".",
"get_true",
"(",
"'http-equiv'",
",",
"u''",
")",
".",
"lower",
"(",
")",
"scheme",
"=",
"attrs",
".",... | Check if the meta attributes contain a URL. | [
"Check",
"if",
"the",
"meta",
"attributes",
"contain",
"a",
"URL",
"."
] | python | train | 39.363636 |
ska-sa/katcp-python | katcp/sensortree.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/sensortree.py#L520-L534 | def recalculate(self, parent, updates):
"""Re-calculate the value of parent sensor.
Parent's value is calculated by calling the associate aggregation rule.
Parameters
----------
parent : :class:`katcp.Sensor` object
The sensor that needs to be updated.
updat... | [
"def",
"recalculate",
"(",
"self",
",",
"parent",
",",
"updates",
")",
":",
"rule_function",
",",
"children",
"=",
"self",
".",
"_aggregates",
"[",
"parent",
"]",
"rule_function",
"(",
"parent",
",",
"children",
")"
] | Re-calculate the value of parent sensor.
Parent's value is calculated by calling the associate aggregation rule.
Parameters
----------
parent : :class:`katcp.Sensor` object
The sensor that needs to be updated.
updates : sequence of :class:`katcp.Sensor` objects
... | [
"Re",
"-",
"calculate",
"the",
"value",
"of",
"parent",
"sensor",
"."
] | python | train | 34.8 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L188-L199 | def density(self, r, rho0, gamma):
"""
computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return:
"""
rho = rho0 / r**gamma
return rho | [
"def",
"density",
"(",
"self",
",",
"r",
",",
"rho0",
",",
"gamma",
")",
":",
"rho",
"=",
"rho0",
"/",
"r",
"**",
"gamma",
"return",
"rho"
] | computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return: | [
"computes",
"the",
"density",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"rho0",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"return",
":"
] | python | train | 19.583333 |
googleapis/google-cloud-python | trace/google/cloud/trace/_gapic.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace/_gapic.py#L51-L90 | def batch_write_spans(
self, name, spans, retry=method.DEFAULT, timeout=method.DEFAULT
):
"""
Sends new spans to Stackdriver Trace or updates existing traces. If the
name of a trace that you send matches that of an existing trace, new
spans are added to the existing trace. At... | [
"def",
"batch_write_spans",
"(",
"self",
",",
"name",
",",
"spans",
",",
"retry",
"=",
"method",
".",
"DEFAULT",
",",
"timeout",
"=",
"method",
".",
"DEFAULT",
")",
":",
"spans_pb_list",
"=",
"[",
"]",
"for",
"span_mapping",
"in",
"spans",
"[",
"\"spans\... | Sends new spans to Stackdriver Trace or updates existing traces. If the
name of a trace that you send matches that of an existing trace, new
spans are added to the existing trace. Attempt to update existing spans
results undefined behavior. If the name does not match, a new trace is
crea... | [
"Sends",
"new",
"spans",
"to",
"Stackdriver",
"Trace",
"or",
"updates",
"existing",
"traces",
".",
"If",
"the",
"name",
"of",
"a",
"trace",
"that",
"you",
"send",
"matches",
"that",
"of",
"an",
"existing",
"trace",
"new",
"spans",
"are",
"added",
"to",
"... | python | train | 47.625 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L364-L414 | def edit_vlan(
self,
environment_id,
name,
number,
description,
acl_file,
acl_file_v6,
id_vlan):
"""Edit a VLAN
:param id_vlan: ID for Vlan
:param environment_id: ID for Environment.
:param n... | [
"def",
"edit_vlan",
"(",
"self",
",",
"environment_id",
",",
"name",
",",
"number",
",",
"description",
",",
"acl_file",
",",
"acl_file_v6",
",",
"id_vlan",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_vlan",
")",
":",
"raise",
"InvalidParameterError"... | Edit a VLAN
:param id_vlan: ID for Vlan
:param environment_id: ID for Environment.
:param name: The name of VLAN.
:param description: Some description to VLAN.
:param number: Number of Vlan
:param acl_file: Acl IPv4 File name to VLAN.
:param acl_file_v6: Acl IPv6... | [
"Edit",
"a",
"VLAN"
] | python | train | 36.509804 |
nefarioustim/parker | parker/client.py | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L73-L90 | def get(self, uri, disable_proxy=False, stream=False):
"""Return Requests response to GET request."""
response = requests.get(
uri,
headers=self.headers,
allow_redirects=True,
cookies={},
stream=stream,
proxies=self.proxy if not dis... | [
"def",
"get",
"(",
"self",
",",
"uri",
",",
"disable_proxy",
"=",
"False",
",",
"stream",
"=",
"False",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"uri",
",",
"headers",
"=",
"self",
".",
"headers",
",",
"allow_redirects",
"=",
"True",
"... | Return Requests response to GET request. | [
"Return",
"Requests",
"response",
"to",
"GET",
"request",
"."
] | python | train | 37.444444 |
ktbyers/netmiko | netmiko/huawei/huawei.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L46-L85 | def set_base_prompt(
self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1
):
"""
Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comwar... | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\">\"",
",",
"alt_prompt_terminator",
"=",
"\"]\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"log",
".",
"debug",
"(",
"\"In set_base_prompt\"",
")",
"delay_factor",
"=",
"self",
".",
"... | Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comware
this will be the router prompt with < > or [ ] stripped off.
This will be set on logging in, but not when enteri... | [
"Sets",
"self",
".",
"base_prompt"
] | python | train | 36.525 |
aws/sagemaker-containers | src/sagemaker_containers/_encoders.py | https://github.com/aws/sagemaker-containers/blob/0030f07abbaf22a55d986d97274d7a8d1aa1f10c/src/sagemaker_containers/_encoders.py#L125-L140 | def decode(obj, content_type):
# type: (np.array or Iterable or int or float, str) -> np.array
"""Decode an object ton a one of the default content types to a numpy array.
Args:
obj (object): to be decoded.
content_type (str): content type to be used.
Returns:
np.array: decoded... | [
"def",
"decode",
"(",
"obj",
",",
"content_type",
")",
":",
"# type: (np.array or Iterable or int or float, str) -> np.array",
"try",
":",
"decoder",
"=",
"_decoders_map",
"[",
"content_type",
"]",
"return",
"decoder",
"(",
"obj",
")",
"except",
"KeyError",
":",
"ra... | Decode an object ton a one of the default content types to a numpy array.
Args:
obj (object): to be decoded.
content_type (str): content type to be used.
Returns:
np.array: decoded object. | [
"Decode",
"an",
"object",
"ton",
"a",
"one",
"of",
"the",
"default",
"content",
"types",
"to",
"a",
"numpy",
"array",
"."
] | python | train | 30.25 |
joshleeb/creditcard | creditcard/formatter.py | https://github.com/joshleeb/creditcard/blob/8cff49ba80029026c7e221764eb2387eb2e04a4c/creditcard/formatter.py#L23-L30 | def is_mastercard(n):
"""Checks if credit card number fits the mastercard format."""
n, length = str(n), len(str(n))
if length >= 16 and length <= 19:
if ''.join(n[:2]) in strings_between(51, 56):
return True
return False | [
"def",
"is_mastercard",
"(",
"n",
")",
":",
"n",
",",
"length",
"=",
"str",
"(",
"n",
")",
",",
"len",
"(",
"str",
"(",
"n",
")",
")",
"if",
"length",
">=",
"16",
"and",
"length",
"<=",
"19",
":",
"if",
"''",
".",
"join",
"(",
"n",
"[",
":"... | Checks if credit card number fits the mastercard format. | [
"Checks",
"if",
"credit",
"card",
"number",
"fits",
"the",
"mastercard",
"format",
"."
] | python | train | 31.375 |
Numigi/gitoo | src/core.py | https://github.com/Numigi/gitoo/blob/0921f5fb8a948021760bb0373a40f9fbe8a4a2e5/src/core.py#L82-L93 | def install(self, destination):
""" Install a third party odoo add-on
:param string destination: the folder where the add-on should end up at.
"""
logger.info(
"Installing %s@%s to %s",
self.repo, self.commit if self.commit else self.branch, destination
)... | [
"def",
"install",
"(",
"self",
",",
"destination",
")",
":",
"logger",
".",
"info",
"(",
"\"Installing %s@%s to %s\"",
",",
"self",
".",
"repo",
",",
"self",
".",
"commit",
"if",
"self",
".",
"commit",
"else",
"self",
".",
"branch",
",",
"destination",
"... | Install a third party odoo add-on
:param string destination: the folder where the add-on should end up at. | [
"Install",
"a",
"third",
"party",
"odoo",
"add",
"-",
"on"
] | python | train | 38.583333 |
JasonKessler/scattertext | scattertext/termscoring/ScaledFScore.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/termscoring/ScaledFScore.py#L166-L180 | def get_p_vals(self, X):
'''
Parameters
----------
X : np.array
Array of word counts, shape (N, 2) where N is the vocab size. X[:,0] is the
positive class, while X[:,1] is the negative class. None by default
Returns
-------
np.array of p-values
'''
z_scores = self.get_scores(X[:, 0], X[:, 1])... | [
"def",
"get_p_vals",
"(",
"self",
",",
"X",
")",
":",
"z_scores",
"=",
"self",
".",
"get_scores",
"(",
"X",
"[",
":",
",",
"0",
"]",
",",
"X",
"[",
":",
",",
"1",
"]",
")",
"return",
"norm",
".",
"cdf",
"(",
"z_scores",
")"
] | Parameters
----------
X : np.array
Array of word counts, shape (N, 2) where N is the vocab size. X[:,0] is the
positive class, while X[:,1] is the negative class. None by default
Returns
-------
np.array of p-values | [
"Parameters",
"----------",
"X",
":",
"np",
".",
"array",
"Array",
"of",
"word",
"counts",
"shape",
"(",
"N",
"2",
")",
"where",
"N",
"is",
"the",
"vocab",
"size",
".",
"X",
"[",
":",
"0",
"]",
"is",
"the",
"positive",
"class",
"while",
"X",
"[",
... | python | train | 22.266667 |
twisted/mantissa | xmantissa/interstore.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/interstore.py#L465-L474 | def routeAnswer(self, originalSender, originalTarget, value, messageID):
"""
Implement L{IMessageRouter.routeMessage} by synchronously locating an
account via L{axiom.userbase.LoginSystem.accountByAddress}, and
delivering a response to it by calling a method on it and returning a
... | [
"def",
"routeAnswer",
"(",
"self",
",",
"originalSender",
",",
"originalTarget",
",",
"value",
",",
"messageID",
")",
":",
"router",
"=",
"self",
".",
"_routerForAccount",
"(",
"originalSender",
")",
"return",
"router",
".",
"routeAnswer",
"(",
"originalSender",... | Implement L{IMessageRouter.routeMessage} by synchronously locating an
account via L{axiom.userbase.LoginSystem.accountByAddress}, and
delivering a response to it by calling a method on it and returning a
deferred containing its answer. | [
"Implement",
"L",
"{",
"IMessageRouter",
".",
"routeMessage",
"}",
"by",
"synchronously",
"locating",
"an",
"account",
"via",
"L",
"{",
"axiom",
".",
"userbase",
".",
"LoginSystem",
".",
"accountByAddress",
"}",
"and",
"delivering",
"a",
"response",
"to",
"it"... | python | train | 52.9 |
pyfca/pyfca | pyfca/implications.py | https://github.com/pyfca/pyfca/blob/cf8cea9e76076dbf4bb3f38996dcb5491b0eb0b0/pyfca/implications.py#L135-L151 | def B012(t,i):
"""
Constructs ternary implication coding (0=not there, 2=U, 1=V)
t is B column position
i = |M|-1 to 0
"""
if not i:
return "1"
nA = Awidth(i)
nB = Bwidth(i)
nBB = nB + nA
if t < nB:
return "0"+B012(t,i-1)
elif t < nBB:
return "1"+A012(... | [
"def",
"B012",
"(",
"t",
",",
"i",
")",
":",
"if",
"not",
"i",
":",
"return",
"\"1\"",
"nA",
"=",
"Awidth",
"(",
"i",
")",
"nB",
"=",
"Bwidth",
"(",
"i",
")",
"nBB",
"=",
"nB",
"+",
"nA",
"if",
"t",
"<",
"nB",
":",
"return",
"\"0\"",
"+",
... | Constructs ternary implication coding (0=not there, 2=U, 1=V)
t is B column position
i = |M|-1 to 0 | [
"Constructs",
"ternary",
"implication",
"coding",
"(",
"0",
"=",
"not",
"there",
"2",
"=",
"U",
"1",
"=",
"V",
")",
"t",
"is",
"B",
"column",
"position",
"i",
"=",
"|M|",
"-",
"1",
"to",
"0"
] | python | train | 21.058824 |
emory-libraries/eulxml | eulxml/xmlmap/core.py | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/core.py#L55-L58 | def parseUri(stream, uri=None):
"""Read an XML document from a URI, and return a :mod:`lxml.etree`
document."""
return etree.parse(stream, parser=_get_xmlparser(), base_url=uri) | [
"def",
"parseUri",
"(",
"stream",
",",
"uri",
"=",
"None",
")",
":",
"return",
"etree",
".",
"parse",
"(",
"stream",
",",
"parser",
"=",
"_get_xmlparser",
"(",
")",
",",
"base_url",
"=",
"uri",
")"
] | Read an XML document from a URI, and return a :mod:`lxml.etree`
document. | [
"Read",
"an",
"XML",
"document",
"from",
"a",
"URI",
"and",
"return",
"a",
":",
"mod",
":",
"lxml",
".",
"etree",
"document",
"."
] | python | train | 46.5 |
angr/angr | angr/concretization_strategies/__init__.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/concretization_strategies/__init__.py#L27-L31 | def _max(self, memory, addr, **kwargs):
"""
Gets the maximum solution of an address.
"""
return memory.state.solver.max(addr, exact=kwargs.pop('exact', self._exact), **kwargs) | [
"def",
"_max",
"(",
"self",
",",
"memory",
",",
"addr",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"memory",
".",
"state",
".",
"solver",
".",
"max",
"(",
"addr",
",",
"exact",
"=",
"kwargs",
".",
"pop",
"(",
"'exact'",
",",
"self",
".",
"_exac... | Gets the maximum solution of an address. | [
"Gets",
"the",
"maximum",
"solution",
"of",
"an",
"address",
"."
] | python | train | 40.6 |
kkroening/ffmpeg-python | ffmpeg/_utils.py | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L83-L91 | def convert_kwargs_to_cmd_line_args(kwargs):
"""Helper function to build command line arguments out of dict."""
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
args.append('-{}'.format(k))
if v is not None:
args.append('{}'.format(v))
return args | [
"def",
"convert_kwargs_to_cmd_line_args",
"(",
"kwargs",
")",
":",
"args",
"=",
"[",
"]",
"for",
"k",
"in",
"sorted",
"(",
"kwargs",
".",
"keys",
"(",
")",
")",
":",
"v",
"=",
"kwargs",
"[",
"k",
"]",
"args",
".",
"append",
"(",
"'-{}'",
".",
"form... | Helper function to build command line arguments out of dict. | [
"Helper",
"function",
"to",
"build",
"command",
"line",
"arguments",
"out",
"of",
"dict",
"."
] | python | train | 33.111111 |
delph-in/pydelphin | delphin/itsdb.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L1362-L1391 | def decode_row(line, fields=None):
"""
Decode a raw line from a profile into a list of column values.
Decoding involves splitting the line by the field delimiter
(`"@"` by default) and unescaping special characters. If *fields*
is given, cast the values into the datatype given by their
respecti... | [
"def",
"decode_row",
"(",
"line",
",",
"fields",
"=",
"None",
")",
":",
"cols",
"=",
"line",
".",
"rstrip",
"(",
"'\\n'",
")",
".",
"split",
"(",
"_field_delimiter",
")",
"cols",
"=",
"list",
"(",
"map",
"(",
"unescape",
",",
"cols",
")",
")",
"if"... | Decode a raw line from a profile into a list of column values.
Decoding involves splitting the line by the field delimiter
(`"@"` by default) and unescaping special characters. If *fields*
is given, cast the values into the datatype given by their
respective Field object.
Args:
line: a raw... | [
"Decode",
"a",
"raw",
"line",
"from",
"a",
"profile",
"into",
"a",
"list",
"of",
"column",
"values",
"."
] | python | train | 33.233333 |
Aluriak/bubble-tools | bubbletools/validator.py | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/validator.py#L120-L139 | def mergeability_validation(tree:BubbleTree) -> iter:
"""Yield message about mergables powernodes"""
def gen_warnings(one, two, inc_message:str) -> [str]:
"Yield the warning for given (power)nodes if necessary"
nodetype = ''
if tree.inclusions[one] and tree.inclusions[two]:
n... | [
"def",
"mergeability_validation",
"(",
"tree",
":",
"BubbleTree",
")",
"->",
"iter",
":",
"def",
"gen_warnings",
"(",
"one",
",",
"two",
",",
"inc_message",
":",
"str",
")",
"->",
"[",
"str",
"]",
":",
"\"Yield the warning for given (power)nodes if necessary\"",
... | Yield message about mergables powernodes | [
"Yield",
"message",
"about",
"mergables",
"powernodes"
] | python | train | 53.6 |
bwohlberg/sporco | sporco/admm/ccmod.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/ccmod.py#L408-L417 | def reconstruct(self, D=None):
"""Reconstruct representation."""
if D is None:
Df = self.Xf
else:
Df = sl.rfftn(D, None, self.cri.axisN)
Sf = np.sum(self.Zf * Df, axis=self.cri.axisM)
return sl.irfftn(Sf, self.cri.Nv, self.cri.axisN) | [
"def",
"reconstruct",
"(",
"self",
",",
"D",
"=",
"None",
")",
":",
"if",
"D",
"is",
"None",
":",
"Df",
"=",
"self",
".",
"Xf",
"else",
":",
"Df",
"=",
"sl",
".",
"rfftn",
"(",
"D",
",",
"None",
",",
"self",
".",
"cri",
".",
"axisN",
")",
"... | Reconstruct representation. | [
"Reconstruct",
"representation",
"."
] | python | train | 29 |
marshmallow-code/marshmallow | src/marshmallow/fields.py | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L435-L467 | def schema(self):
"""The nested Schema object.
.. versionchanged:: 1.0.0
Renamed from `serializer` to `schema`
"""
if not self.__schema:
# Inherit context from parent.
context = getattr(self.parent, 'context', {})
if isinstance(self.nested... | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__schema",
":",
"# Inherit context from parent.",
"context",
"=",
"getattr",
"(",
"self",
".",
"parent",
",",
"'context'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"self",
".",
"neste... | The nested Schema object.
.. versionchanged:: 1.0.0
Renamed from `serializer` to `schema` | [
"The",
"nested",
"Schema",
"object",
"."
] | python | train | 42.30303 |
jmgilman/Neolib | neolib/pyamf/amf3.py | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf3.py#L1232-L1238 | def writeString(self, s):
"""
Writes a string to the stream. It will be B{UTF-8} encoded.
"""
s = self.context.getBytesForString(s)
self.writeBytes(s) | [
"def",
"writeString",
"(",
"self",
",",
"s",
")",
":",
"s",
"=",
"self",
".",
"context",
".",
"getBytesForString",
"(",
"s",
")",
"self",
".",
"writeBytes",
"(",
"s",
")"
] | Writes a string to the stream. It will be B{UTF-8} encoded. | [
"Writes",
"a",
"string",
"to",
"the",
"stream",
".",
"It",
"will",
"be",
"B",
"{",
"UTF",
"-",
"8",
"}",
"encoded",
"."
] | python | train | 26.428571 |
a1ezzz/wasp-general | wasp_general/signals/signals.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L158-L167 | def watch(self, signal_name):
""" :meth:`.WSignalSourceProto.watch` implementation
:rtype: watcher: WSignalSource.Watcher
"""
watcher = WSignalSource.Watcher(
self.__queues[signal_name], lambda x: self.__watchers_callbacks[signal_name].remove(x)
)
self.__watchers_callbacks[signal_name].add(watcher)
re... | [
"def",
"watch",
"(",
"self",
",",
"signal_name",
")",
":",
"watcher",
"=",
"WSignalSource",
".",
"Watcher",
"(",
"self",
".",
"__queues",
"[",
"signal_name",
"]",
",",
"lambda",
"x",
":",
"self",
".",
"__watchers_callbacks",
"[",
"signal_name",
"]",
".",
... | :meth:`.WSignalSourceProto.watch` implementation
:rtype: watcher: WSignalSource.Watcher | [
":",
"meth",
":",
".",
"WSignalSourceProto",
".",
"watch",
"implementation"
] | python | train | 32.3 |
edx/edx-enterprise | enterprise/decorators.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/decorators.py#L53-L71 | def ignore_warning(warning):
"""
Ignore any emitted warnings from a function.
:param warning: The category of warning to ignore.
"""
def decorator(func):
"""
Return a decorated function whose emitted warnings are ignored.
"""
@wraps(func)
def wrapper(*args, *... | [
"def",
"ignore_warning",
"(",
"warning",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"\n Return a decorated function whose emitted warnings are ignored.\n \"\"\"",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*... | Ignore any emitted warnings from a function.
:param warning: The category of warning to ignore. | [
"Ignore",
"any",
"emitted",
"warnings",
"from",
"a",
"function",
"."
] | python | valid | 26.947368 |
treycucco/bidon | bidon/json_patch.py | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L77-L84 | def remove(parent, idx):
"""Remove a value from a dict."""
if isinstance(parent, dict):
del parent[idx]
elif isinstance(parent, list):
del parent[int(idx)]
else:
raise JSONPathError("Invalid path for operation") | [
"def",
"remove",
"(",
"parent",
",",
"idx",
")",
":",
"if",
"isinstance",
"(",
"parent",
",",
"dict",
")",
":",
"del",
"parent",
"[",
"idx",
"]",
"elif",
"isinstance",
"(",
"parent",
",",
"list",
")",
":",
"del",
"parent",
"[",
"int",
"(",
"idx",
... | Remove a value from a dict. | [
"Remove",
"a",
"value",
"from",
"a",
"dict",
"."
] | python | train | 28 |
draios/python-sdc-client | sdcclient/_scanning.py | https://github.com/draios/python-sdc-client/blob/47f83415842048778939b90944f64386a3bcb205/sdcclient/_scanning.py#L317-L333 | def delete_registry(self, registry):
'''**Description**
Delete an existing image registry
**Arguments**
- registry: Full hostname/port of registry. Eg. myrepo.example.com:5000
'''
# do some input string checking
if re.match(".*\\/.*", registry):
... | [
"def",
"delete_registry",
"(",
"self",
",",
"registry",
")",
":",
"# do some input string checking",
"if",
"re",
".",
"match",
"(",
"\".*\\\\/.*\"",
",",
"registry",
")",
":",
"return",
"[",
"False",
",",
"\"input registry name cannot contain '/' characters - valid regi... | **Description**
Delete an existing image registry
**Arguments**
- registry: Full hostname/port of registry. Eg. myrepo.example.com:5000 | [
"**",
"Description",
"**",
"Delete",
"an",
"existing",
"image",
"registry"
] | python | test | 42.588235 |
KrzyHonk/bpmn-python | bpmn_python/bpmn_diagram_export.py | https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_export.py#L244-L254 | def export_child_lane_set(parent_xml_element, child_lane_set, plane_element):
"""
Creates 'childLaneSet' element for exported BPMN XML file.
:param parent_xml_element: an XML element, parent of exported 'childLaneSet' element,
:param child_lane_set: dictionary with exported 'childLaneSe... | [
"def",
"export_child_lane_set",
"(",
"parent_xml_element",
",",
"child_lane_set",
",",
"plane_element",
")",
":",
"lane_set_xml",
"=",
"eTree",
".",
"SubElement",
"(",
"parent_xml_element",
",",
"consts",
".",
"Consts",
".",
"lane_set",
")",
"for",
"key",
",",
"... | Creates 'childLaneSet' element for exported BPMN XML file.
:param parent_xml_element: an XML element, parent of exported 'childLaneSet' element,
:param child_lane_set: dictionary with exported 'childLaneSet' element attributes and child elements,
:param plane_element: XML object, representing '... | [
"Creates",
"childLaneSet",
"element",
"for",
"exported",
"BPMN",
"XML",
"file",
"."
] | python | train | 63.909091 |
apache/incubator-heron | heron/executor/src/python/heron_executor.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/executor/src/python/heron_executor.py#L322-L383 | def parse_args(args):
"""Uses python argparse to collect positional args"""
Log.info("Input args: %r" % args)
parser = argparse.ArgumentParser()
parser.add_argument("--shard", type=int, required=True)
parser.add_argument("--topology-name", required=True)
parser.add_argument("--topology-id", re... | [
"def",
"parse_args",
"(",
"args",
")",
":",
"Log",
".",
"info",
"(",
"\"Input args: %r\"",
"%",
"args",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"--shard\"",
",",
"type",
"=",
"int",
",",
"req... | Uses python argparse to collect positional args | [
"Uses",
"python",
"argparse",
"to",
"collect",
"positional",
"args"
] | python | valid | 53.83871 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L185-L198 | def compile_ui(self, namespace, unknown):
"""Compile qt designer files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
... | [
"def",
"compile_ui",
"(",
"self",
",",
"namespace",
",",
"unknown",
")",
":",
"uifiles",
"=",
"namespace",
".",
"uifile",
"for",
"f",
"in",
"uifiles",
":",
"qtcompile",
".",
"compile_ui",
"(",
"f",
".",
"name",
")"
] | Compile qt designer files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
:raises: None | [
"Compile",
"qt",
"designer",
"files"
] | python | train | 31.357143 |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1473-L1530 | def setAllEntriesFromParList(self, aParList, updateModel=False):
""" Set all the parameter entry values in the GUI to the values
in the given par list. If 'updateModel' is True, the internal
param list will be updated to the new values as well as the GUI
entries (slower and n... | [
"def",
"setAllEntriesFromParList",
"(",
"self",
",",
"aParList",
",",
"updateModel",
"=",
"False",
")",
":",
"# Get model data, the list of pars",
"theParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
"(",
")",
"# we may modify members",
"if",
"len",
... | Set all the parameter entry values in the GUI to the values
in the given par list. If 'updateModel' is True, the internal
param list will be updated to the new values as well as the GUI
entries (slower and not always necessary). Note the
corresponding TparDisplay method. | [
"Set",
"all",
"the",
"parameter",
"entry",
"values",
"in",
"the",
"GUI",
"to",
"the",
"values",
"in",
"the",
"given",
"par",
"list",
".",
"If",
"updateModel",
"is",
"True",
"the",
"internal",
"param",
"list",
"will",
"be",
"updated",
"to",
"the",
"new",
... | python | train | 48.344828 |
mwouts/jupytext | jupytext/languages.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L87-L91 | def comment_lines(lines, prefix):
"""Return commented lines"""
if not prefix:
return lines
return [prefix + ' ' + line if line else prefix for line in lines] | [
"def",
"comment_lines",
"(",
"lines",
",",
"prefix",
")",
":",
"if",
"not",
"prefix",
":",
"return",
"lines",
"return",
"[",
"prefix",
"+",
"' '",
"+",
"line",
"if",
"line",
"else",
"prefix",
"for",
"line",
"in",
"lines",
"]"
] | Return commented lines | [
"Return",
"commented",
"lines"
] | python | train | 34.6 |
narfman0/helga-markovify | helga_markovify/plugin.py | https://github.com/narfman0/helga-markovify/blob/b5a82de070102e6da1fd3f5f81cad12d0a9185d8/helga_markovify/plugin.py#L70-L85 | def _handle_match(client, channel, nick, message, matches):
""" Match stores all channel info. If helga is asked something to
stimulate a markov response about channel data, then we shall graciously
provide it.
"""
generate_interrogative = _CHANNEL_GENERATE_REGEX.match(message)
if generate_inter... | [
"def",
"_handle_match",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"message",
",",
"matches",
")",
":",
"generate_interrogative",
"=",
"_CHANNEL_GENERATE_REGEX",
".",
"match",
"(",
"message",
")",
"if",
"generate_interrogative",
":",
"return",
"generate",
... | Match stores all channel info. If helga is asked something to
stimulate a markov response about channel data, then we shall graciously
provide it. | [
"Match",
"stores",
"all",
"channel",
"info",
".",
"If",
"helga",
"is",
"asked",
"something",
"to",
"stimulate",
"a",
"markov",
"response",
"about",
"channel",
"data",
"then",
"we",
"shall",
"graciously",
"provide",
"it",
"."
] | python | train | 44.3125 |
LionelAuroux/pyrser | pyrser/parsing/base.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/base.py#L314-L327 | def read_text(self, text: str) -> bool:
"""
Consume a strlen(text) text at current position in the stream
else return False.
Same as "" in BNF
ex : read_text("ls");.
"""
if self.read_eof():
return False
self._stream.save_context()
if se... | [
"def",
"read_text",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"bool",
":",
"if",
"self",
".",
"read_eof",
"(",
")",
":",
"return",
"False",
"self",
".",
"_stream",
".",
"save_context",
"(",
")",
"if",
"self",
".",
"peek_text",
"(",
"text",
"... | Consume a strlen(text) text at current position in the stream
else return False.
Same as "" in BNF
ex : read_text("ls");. | [
"Consume",
"a",
"strlen",
"(",
"text",
")",
"text",
"at",
"current",
"position",
"in",
"the",
"stream",
"else",
"return",
"False",
".",
"Same",
"as",
"in",
"BNF",
"ex",
":",
"read_text",
"(",
"ls",
")",
";",
"."
] | python | test | 33.285714 |
praekelt/django-preferences | preferences/models.py | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/models.py#L44-L59 | def site_cleanup(sender, action, instance, **kwargs):
"""
Make sure there is only a single preferences object per site.
So remove sites from pre-existing preferences objects.
"""
if action == 'post_add':
if isinstance(instance, Preferences) \
and hasattr(instance.__class__, 'obje... | [
"def",
"site_cleanup",
"(",
"sender",
",",
"action",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
"==",
"'post_add'",
":",
"if",
"isinstance",
"(",
"instance",
",",
"Preferences",
")",
"and",
"hasattr",
"(",
"instance",
".",
"__cla... | Make sure there is only a single preferences object per site.
So remove sites from pre-existing preferences objects. | [
"Make",
"sure",
"there",
"is",
"only",
"a",
"single",
"preferences",
"object",
"per",
"site",
".",
"So",
"remove",
"sites",
"from",
"pre",
"-",
"existing",
"preferences",
"objects",
"."
] | python | train | 41 |
RonenNess/Fileter | fileter/filters/pattern_filter.py | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/filters/pattern_filter.py#L24-L32 | def match(self, filepath):
"""
The function to check file.
Should return True if match, False otherwise.
"""
for pattern in self.__pattern:
if len(fnmatch.filter([filepath], pattern)) > 0:
return True
return False | [
"def",
"match",
"(",
"self",
",",
"filepath",
")",
":",
"for",
"pattern",
"in",
"self",
".",
"__pattern",
":",
"if",
"len",
"(",
"fnmatch",
".",
"filter",
"(",
"[",
"filepath",
"]",
",",
"pattern",
")",
")",
">",
"0",
":",
"return",
"True",
"return... | The function to check file.
Should return True if match, False otherwise. | [
"The",
"function",
"to",
"check",
"file",
".",
"Should",
"return",
"True",
"if",
"match",
"False",
"otherwise",
"."
] | python | train | 31.222222 |
rigetti/grove | grove/tomography/state_tomography.py | https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/tomography/state_tomography.py#L105-L168 | def estimate_from_ssr(histograms, readout_povm, channel_ops, settings):
"""
Estimate a density matrix from single shot histograms obtained by measuring bitstrings in
the Z-eigenbasis after application of given channel operators.
:param numpy.ndarray histograms: The single shot histogram... | [
"def",
"estimate_from_ssr",
"(",
"histograms",
",",
"readout_povm",
",",
"channel_ops",
",",
"settings",
")",
":",
"nqc",
"=",
"len",
"(",
"channel_ops",
"[",
"0",
"]",
".",
"dims",
"[",
"0",
"]",
")",
"pauli_basis",
"=",
"grove",
".",
"tomography",
".",... | Estimate a density matrix from single shot histograms obtained by measuring bitstrings in
the Z-eigenbasis after application of given channel operators.
:param numpy.ndarray histograms: The single shot histograms, `shape=(n_channels, dim)`.
:param DiagognalPOVM readout_povm: The POVM correspond... | [
"Estimate",
"a",
"density",
"matrix",
"from",
"single",
"shot",
"histograms",
"obtained",
"by",
"measuring",
"bitstrings",
"in",
"the",
"Z",
"-",
"eigenbasis",
"after",
"application",
"of",
"given",
"channel",
"operators",
"."
] | python | train | 48.0625 |
apache/incubator-superset | superset/dataframe.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/dataframe.py#L39-L60 | def dedup(l, suffix='__', case_sensitive=True):
"""De-duplicates a list of string by suffixing a counter
Always returns the same number of entries as provided, and always returns
unique values. Case sensitive comparison by default.
>>> print(','.join(dedup(['foo', 'bar', 'bar', 'bar', 'Bar'])))
fo... | [
"def",
"dedup",
"(",
"l",
",",
"suffix",
"=",
"'__'",
",",
"case_sensitive",
"=",
"True",
")",
":",
"new_l",
"=",
"[",
"]",
"seen",
"=",
"{",
"}",
"for",
"s",
"in",
"l",
":",
"s_fixed_case",
"=",
"s",
"if",
"case_sensitive",
"else",
"s",
".",
"lo... | De-duplicates a list of string by suffixing a counter
Always returns the same number of entries as provided, and always returns
unique values. Case sensitive comparison by default.
>>> print(','.join(dedup(['foo', 'bar', 'bar', 'bar', 'Bar'])))
foo,bar,bar__1,bar__2,Bar
>>> print(','.join(dedup(['... | [
"De",
"-",
"duplicates",
"a",
"list",
"of",
"string",
"by",
"suffixing",
"a",
"counter"
] | python | train | 34.772727 |
tjcsl/cslbot | cslbot/helpers/handler.py | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/handler.py#L345-L374 | def do_kick(self, send, target, nick, msg, slogan=True):
"""Kick users.
- If kick is disabled, don't do anything.
- If the bot is not a op, rage at a op.
- Kick the user.
"""
if not self.kick_enabled:
return
if target not in self.channels:
... | [
"def",
"do_kick",
"(",
"self",
",",
"send",
",",
"target",
",",
"nick",
",",
"msg",
",",
"slogan",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"kick_enabled",
":",
"return",
"if",
"target",
"not",
"in",
"self",
".",
"channels",
":",
"send",
"(... | Kick users.
- If kick is disabled, don't do anything.
- If the bot is not a op, rage at a op.
- Kick the user. | [
"Kick",
"users",
"."
] | python | train | 42.1 |
Stranger6667/postmarker | postmarker/models/stats.py | https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L87-L92 | def location(self, tag=None, fromdate=None, todate=None):
"""
Gets an overview of which part of the email links were clicked from (HTML or Text).
This is only recorded when Link Tracking is enabled for that email.
"""
return self.call("GET", "/stats/outbound/clicks/location", tag... | [
"def",
"location",
"(",
"self",
",",
"tag",
"=",
"None",
",",
"fromdate",
"=",
"None",
",",
"todate",
"=",
"None",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"GET\"",
",",
"\"/stats/outbound/clicks/location\"",
",",
"tag",
"=",
"tag",
",",
"fromdate... | Gets an overview of which part of the email links were clicked from (HTML or Text).
This is only recorded when Link Tracking is enabled for that email. | [
"Gets",
"an",
"overview",
"of",
"which",
"part",
"of",
"the",
"email",
"links",
"were",
"clicked",
"from",
"(",
"HTML",
"or",
"Text",
")",
".",
"This",
"is",
"only",
"recorded",
"when",
"Link",
"Tracking",
"is",
"enabled",
"for",
"that",
"email",
"."
] | python | train | 59 |
openergy/oplus | oplus/epm/epm.py | https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/epm/epm.py#L100-L143 | def _dev_populate_from_json_data(self, json_data):
"""
!! Must only be called once, when empty !!
"""
# workflow
# --------
# (methods belonging to create/update/delete framework:
# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.de... | [
"def",
"_dev_populate_from_json_data",
"(",
"self",
",",
"json_data",
")",
":",
"# workflow",
"# --------",
"# (methods belonging to create/update/delete framework:",
"# epm._dev_populate_from_json_data, table.batch_add, record.update, queryset.delete, record.delete)",
"# 1. add inert",
... | !! Must only be called once, when empty !! | [
"!!",
"Must",
"only",
"be",
"called",
"once",
"when",
"empty",
"!!"
] | python | test | 33.545455 |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L829-L871 | def print_statement_coverage(self):
"""Display how many of the direct statements have been converted.
Also prints how many are considered 'degenerate' and not converted."""
if not self.all_direct_stmts:
self.get_all_direct_statements()
if not self.degenerate_stmts:
... | [
"def",
"print_statement_coverage",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"all_direct_stmts",
":",
"self",
".",
"get_all_direct_statements",
"(",
")",
"if",
"not",
"self",
".",
"degenerate_stmts",
":",
"self",
".",
"get_degenerate_statements",
"(",
")"... | Display how many of the direct statements have been converted.
Also prints how many are considered 'degenerate' and not converted. | [
"Display",
"how",
"many",
"of",
"the",
"direct",
"statements",
"have",
"been",
"converted",
"."
] | python | train | 44.581395 |
Fire-Proof/cuepy | cuepy/cuepy.py | https://github.com/Fire-Proof/cuepy/blob/5add7d62a31589bcdc7d2103c9c482bf718556ec/cuepy/cuepy.py#L48-L58 | def device_count(self):
"""
Find amount of CUE devices
:returns: amount of CUE devices
:rtype: int
"""
device_count = get_device_count(self.corsair_sdk)
if device_count == -1:
self._raise_corsair_error()
return device_count | [
"def",
"device_count",
"(",
"self",
")",
":",
"device_count",
"=",
"get_device_count",
"(",
"self",
".",
"corsair_sdk",
")",
"if",
"device_count",
"==",
"-",
"1",
":",
"self",
".",
"_raise_corsair_error",
"(",
")",
"return",
"device_count"
] | Find amount of CUE devices
:returns: amount of CUE devices
:rtype: int | [
"Find",
"amount",
"of",
"CUE",
"devices"
] | python | train | 26.363636 |
cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L213-L233 | def CreateBlockDeviceMap(self, image_id, instance_type):
"""
If you launch without specifying a manual device block mapping, you may
not get all the ephemeral devices available to the given instance type.
This will build one that ensures all available ephemeral devices are
mapped.
... | [
"def",
"CreateBlockDeviceMap",
"(",
"self",
",",
"image_id",
",",
"instance_type",
")",
":",
"# get the block device mapping stored with the image",
"image",
"=",
"self",
".",
"ec2",
".",
"get_image",
"(",
"image_id",
")",
"block_device_map",
"=",
"image",
".",
"blo... | If you launch without specifying a manual device block mapping, you may
not get all the ephemeral devices available to the given instance type.
This will build one that ensures all available ephemeral devices are
mapped. | [
"If",
"you",
"launch",
"without",
"specifying",
"a",
"manual",
"device",
"block",
"mapping",
"you",
"may",
"not",
"get",
"all",
"the",
"ephemeral",
"devices",
"available",
"to",
"the",
"given",
"instance",
"type",
".",
"This",
"will",
"build",
"one",
"that",... | python | train | 50.571429 |
smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L82-L95 | def print_error_to_io_stream(err: Exception, io: TextIOBase, print_big_traceback : bool = True):
"""
Utility method to print an exception's content to a stream
:param err:
:param io:
:param print_big_traceback:
:return:
"""
if print_big_traceback:
traceback.print_tb(err.__traceb... | [
"def",
"print_error_to_io_stream",
"(",
"err",
":",
"Exception",
",",
"io",
":",
"TextIOBase",
",",
"print_big_traceback",
":",
"bool",
"=",
"True",
")",
":",
"if",
"print_big_traceback",
":",
"traceback",
".",
"print_tb",
"(",
"err",
".",
"__traceback__",
","... | Utility method to print an exception's content to a stream
:param err:
:param io:
:param print_big_traceback:
:return: | [
"Utility",
"method",
"to",
"print",
"an",
"exception",
"s",
"content",
"to",
"a",
"stream"
] | python | train | 36.928571 |
GeorgeArgyros/symautomata | symautomata/pythondfa.py | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L336-L356 | def load(self, txt_fst_file_name):
"""
Save the transducer in the text file format of OpenFST.
The format is specified as follows:
arc format: src dest ilabel olabel [weight]
final state format: state [weight]
lines may occur in any order except initial state must... | [
"def",
"load",
"(",
"self",
",",
"txt_fst_file_name",
")",
":",
"with",
"open",
"(",
"txt_fst_file_name",
",",
"'r'",
")",
"as",
"input_filename",
":",
"for",
"line",
"in",
"input_filename",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"split_line",
... | Save the transducer in the text file format of OpenFST.
The format is specified as follows:
arc format: src dest ilabel olabel [weight]
final state format: state [weight]
lines may occur in any order except initial state must be first line
Args:
txt_fst_file_n... | [
"Save",
"the",
"transducer",
"in",
"the",
"text",
"file",
"format",
"of",
"OpenFST",
".",
"The",
"format",
"is",
"specified",
"as",
"follows",
":",
"arc",
"format",
":",
"src",
"dest",
"ilabel",
"olabel",
"[",
"weight",
"]",
"final",
"state",
"format",
"... | python | train | 41 |
marcolagi/quantulum | quantulum/classifier.py | https://github.com/marcolagi/quantulum/blob/28b697dfa997116c1aa3ef63a3ceb8725bffd24f/quantulum/classifier.py#L139-L167 | def disambiguate_unit(unit, text):
"""
Resolve ambiguity.
Distinguish between units that have same names, symbols or abbreviations.
"""
new_unit = l.UNITS[unit]
if not new_unit:
new_unit = l.LOWER_UNITS[unit.lower()]
if not new_unit:
raise KeyError('Could not find un... | [
"def",
"disambiguate_unit",
"(",
"unit",
",",
"text",
")",
":",
"new_unit",
"=",
"l",
".",
"UNITS",
"[",
"unit",
"]",
"if",
"not",
"new_unit",
":",
"new_unit",
"=",
"l",
".",
"LOWER_UNITS",
"[",
"unit",
".",
"lower",
"(",
")",
"]",
"if",
"not",
"ne... | Resolve ambiguity.
Distinguish between units that have same names, symbols or abbreviations. | [
"Resolve",
"ambiguity",
"."
] | python | train | 33.965517 |
scanny/python-pptx | pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/shapes/shapetree.py#L171-L178 | def _iter_member_elms(self):
"""
Generate each child of the ``<p:spTree>`` element that corresponds to
a shape, in the sequence they appear in the XML.
"""
for shape_elm in self._spTree.iter_shape_elms():
if self._is_member_elm(shape_elm):
yield shape_... | [
"def",
"_iter_member_elms",
"(",
"self",
")",
":",
"for",
"shape_elm",
"in",
"self",
".",
"_spTree",
".",
"iter_shape_elms",
"(",
")",
":",
"if",
"self",
".",
"_is_member_elm",
"(",
"shape_elm",
")",
":",
"yield",
"shape_elm"
] | Generate each child of the ``<p:spTree>`` element that corresponds to
a shape, in the sequence they appear in the XML. | [
"Generate",
"each",
"child",
"of",
"the",
"<p",
":",
"spTree",
">",
"element",
"that",
"corresponds",
"to",
"a",
"shape",
"in",
"the",
"sequence",
"they",
"appear",
"in",
"the",
"XML",
"."
] | python | train | 39.5 |
erocarrera/pefile | pefile.py | https://github.com/erocarrera/pefile/blob/8a78a2e251a3f2336c232bf411133927b479edf2/pefile.py#L2217-L2237 | def full_load(self):
"""Process the data directories.
This method will load the data directories which might not have
been loaded if the "fast_load" option was used.
"""
self.parse_data_directories()
class RichHeader(object):
pass
rich_header = self... | [
"def",
"full_load",
"(",
"self",
")",
":",
"self",
".",
"parse_data_directories",
"(",
")",
"class",
"RichHeader",
"(",
"object",
")",
":",
"pass",
"rich_header",
"=",
"self",
".",
"parse_rich_header",
"(",
")",
"if",
"rich_header",
":",
"self",
".",
"RICH... | Process the data directories.
This method will load the data directories which might not have
been loaded if the "fast_load" option was used. | [
"Process",
"the",
"data",
"directories",
"."
] | python | train | 38 |
dmlc/gluon-nlp | scripts/parsing/common/data.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/parsing/common/data.py#L162-L171 | def log_info(self, logger):
"""Print statistical information via the provided logger
Parameters
----------
logger : logging.Logger
logger created using logging.getLogger()
"""
logger.info('#words in training set: %d' % self._words_in_train_data)
logge... | [
"def",
"log_info",
"(",
"self",
",",
"logger",
")",
":",
"logger",
".",
"info",
"(",
"'#words in training set: %d'",
"%",
"self",
".",
"_words_in_train_data",
")",
"logger",
".",
"info",
"(",
"\"Vocab info: #words %d, #tags %d #rels %d\"",
"%",
"(",
"self",
".",
... | Print statistical information via the provided logger
Parameters
----------
logger : logging.Logger
logger created using logging.getLogger() | [
"Print",
"statistical",
"information",
"via",
"the",
"provided",
"logger"
] | python | train | 41.1 |
pyviz/holoviews | holoviews/plotting/bokeh/element.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/bokeh/element.py#L2106-L2180 | def update_frame(self, key, ranges=None, element=None):
"""
Update the internal state of the Plot to represent the given
key tuple (where integers represent frames). Returns this
state.
"""
reused = isinstance(self.hmap, DynamicMap) and self.overlaid
if not reused... | [
"def",
"update_frame",
"(",
"self",
",",
"key",
",",
"ranges",
"=",
"None",
",",
"element",
"=",
"None",
")",
":",
"reused",
"=",
"isinstance",
"(",
"self",
".",
"hmap",
",",
"DynamicMap",
")",
"and",
"self",
".",
"overlaid",
"if",
"not",
"reused",
"... | Update the internal state of the Plot to represent the given
key tuple (where integers represent frames). Returns this
state. | [
"Update",
"the",
"internal",
"state",
"of",
"the",
"Plot",
"to",
"represent",
"the",
"given",
"key",
"tuple",
"(",
"where",
"integers",
"represent",
"frames",
")",
".",
"Returns",
"this",
"state",
"."
] | python | train | 42.333333 |
apache/incubator-heron | heron/tools/cli/src/python/deactivate.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/cli/src/python/deactivate.py#L34-L43 | def run(command, parser, cl_args, unknown_args):
'''
:param command:
:param parser:
:param cl_args:
:param unknown_args:
:return:
'''
Log.debug("Deactivate Args: %s", cl_args)
return cli_helper.run(command, cl_args, "deactivate topology") | [
"def",
"run",
"(",
"command",
",",
"parser",
",",
"cl_args",
",",
"unknown_args",
")",
":",
"Log",
".",
"debug",
"(",
"\"Deactivate Args: %s\"",
",",
"cl_args",
")",
"return",
"cli_helper",
".",
"run",
"(",
"command",
",",
"cl_args",
",",
"\"deactivate topol... | :param command:
:param parser:
:param cl_args:
:param unknown_args:
:return: | [
":",
"param",
"command",
":",
":",
"param",
"parser",
":",
":",
"param",
"cl_args",
":",
":",
"param",
"unknown_args",
":",
":",
"return",
":"
] | python | valid | 24.7 |
phaethon/kamene | kamene/layers/inet6.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L86-L122 | def getmacbyip6(ip6, chainCC=0):
"""
Returns the mac address to be used for provided 'ip6' peer.
neighborCache.get() method is used on instantiated neighbor cache.
Resolution mechanism is described in associated doc string.
(chainCC parameter value ends up being passed to sending function
use... | [
"def",
"getmacbyip6",
"(",
"ip6",
",",
"chainCC",
"=",
"0",
")",
":",
"if",
"in6_ismaddr",
"(",
"ip6",
")",
":",
"# Multicast ",
"mac",
"=",
"in6_getnsmac",
"(",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip6",
")",
")",
"return",
"mac",
"iff",... | Returns the mac address to be used for provided 'ip6' peer.
neighborCache.get() method is used on instantiated neighbor cache.
Resolution mechanism is described in associated doc string.
(chainCC parameter value ends up being passed to sending function
used to perform the resolution, if needed) | [
"Returns",
"the",
"mac",
"address",
"to",
"be",
"used",
"for",
"provided",
"ip6",
"peer",
".",
"neighborCache",
".",
"get",
"()",
"method",
"is",
"used",
"on",
"instantiated",
"neighbor",
"cache",
".",
"Resolution",
"mechanism",
"is",
"described",
"in",
"ass... | python | train | 26.783784 |
persandstrom/python-verisure | verisure/session.py | https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L529-L546 | def set_heat_pump_mode(self, device_label, mode):
""" Set heatpump mode
Args:
mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO'
"""
response = None
try:
response = requests.put(
urls.set_heatpump_state(self._giid, device_label),
h... | [
"def",
"set_heat_pump_mode",
"(",
"self",
",",
"device_label",
",",
"mode",
")",
":",
"response",
"=",
"None",
"try",
":",
"response",
"=",
"requests",
".",
"put",
"(",
"urls",
".",
"set_heatpump_state",
"(",
"self",
".",
"_giid",
",",
"device_label",
")",... | Set heatpump mode
Args:
mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO' | [
"Set",
"heatpump",
"mode",
"Args",
":",
"mode",
"(",
"str",
")",
":",
"HEAT",
"COOL",
"FAN",
"or",
"AUTO"
] | python | train | 38.722222 |
chrisjrn/registrasion | registrasion/controllers/conditions.py | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L75-L80 | def passes_filter(self, user):
''' Returns true if the condition passes the filter '''
cls = type(self.condition)
qs = cls.objects.filter(pk=self.condition.id)
return self.condition in self.pre_filter(qs, user) | [
"def",
"passes_filter",
"(",
"self",
",",
"user",
")",
":",
"cls",
"=",
"type",
"(",
"self",
".",
"condition",
")",
"qs",
"=",
"cls",
".",
"objects",
".",
"filter",
"(",
"pk",
"=",
"self",
".",
"condition",
".",
"id",
")",
"return",
"self",
".",
... | Returns true if the condition passes the filter | [
"Returns",
"true",
"if",
"the",
"condition",
"passes",
"the",
"filter"
] | python | test | 39.666667 |
quantmind/pulsar | pulsar/apps/wsgi/wrappers.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/wrappers.py#L367-L384 | def absolute_uri(self, location=None, scheme=None, **query):
"""Builds an absolute URI from ``location`` and variables
available in this request.
If no ``location`` is specified, the relative URI is built from
:meth:`full_path`.
"""
if not is_absolute_uri(location):
... | [
"def",
"absolute_uri",
"(",
"self",
",",
"location",
"=",
"None",
",",
"scheme",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"if",
"not",
"is_absolute_uri",
"(",
"location",
")",
":",
"if",
"location",
"or",
"location",
"is",
"None",
":",
"location"... | Builds an absolute URI from ``location`` and variables
available in this request.
If no ``location`` is specified, the relative URI is built from
:meth:`full_path`. | [
"Builds",
"an",
"absolute",
"URI",
"from",
"location",
"and",
"variables",
"available",
"in",
"this",
"request",
"."
] | python | train | 41.444444 |
niklasf/python-chess | chess/__init__.py | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2764-L2775 | def push_san(self, san: str) -> Move:
"""
Parses a move in standard algebraic notation, makes the move and puts
it on the the move stack.
Returns the move.
:raises: :exc:`ValueError` if neither legal nor a null move.
"""
move = self.parse_san(san)
self.p... | [
"def",
"push_san",
"(",
"self",
",",
"san",
":",
"str",
")",
"->",
"Move",
":",
"move",
"=",
"self",
".",
"parse_san",
"(",
"san",
")",
"self",
".",
"push",
"(",
"move",
")",
"return",
"move"
] | Parses a move in standard algebraic notation, makes the move and puts
it on the the move stack.
Returns the move.
:raises: :exc:`ValueError` if neither legal nor a null move. | [
"Parses",
"a",
"move",
"in",
"standard",
"algebraic",
"notation",
"makes",
"the",
"move",
"and",
"puts",
"it",
"on",
"the",
"the",
"move",
"stack",
"."
] | python | train | 28.166667 |
RedHatInsights/insights-core | insights/util/__init__.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/util/__init__.py#L238-L273 | def case_variants(*elements):
"""
For configs which take case-insensitive options, it is necessary to extend the list with
various common case variants (all combinations are not practical). In the future, this should
be removed, when parser filters are made case-insensitive.
Args:
*elements... | [
"def",
"case_variants",
"(",
"*",
"elements",
")",
":",
"expanded_list",
"=",
"[",
"]",
"for",
"element",
"in",
"elements",
":",
"low",
"=",
"element",
".",
"lower",
"(",
")",
"up",
"=",
"element",
".",
"upper",
"(",
")",
"title",
"=",
"element",
"."... | For configs which take case-insensitive options, it is necessary to extend the list with
various common case variants (all combinations are not practical). In the future, this should
be removed, when parser filters are made case-insensitive.
Args:
*elements (str): list of elements which need case-s... | [
"For",
"configs",
"which",
"take",
"case",
"-",
"insensitive",
"options",
"it",
"is",
"necessary",
"to",
"extend",
"the",
"list",
"with",
"various",
"common",
"case",
"variants",
"(",
"all",
"combinations",
"are",
"not",
"practical",
")",
".",
"In",
"the",
... | python | train | 35.805556 |
zsethna/OLGA | olga/load_model.py | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/load_model.py#L169-L187 | def generate_cutV_genomic_CDR3_segs(self):
"""Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline V segments so that delV can index directly for number of
nucleotides to delete from a segment.
... | [
"def",
"generate_cutV_genomic_CDR3_segs",
"(",
"self",
")",
":",
"max_palindrome",
"=",
"self",
".",
"max_delV_palindrome",
"self",
".",
"cutV_genomic_CDR3_segs",
"=",
"[",
"]",
"for",
"CDR3_V_seg",
"in",
"[",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"self",
".... | Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline V segments so that delV can index directly for number of
nucleotides to delete from a segment.
Sets the attribute cutV_genomic_CDR3_se... | [
"Add",
"palindromic",
"inserted",
"nucleotides",
"to",
"germline",
"V",
"sequences",
".",
"The",
"maximum",
"number",
"of",
"palindromic",
"insertions",
"are",
"appended",
"to",
"the",
"germline",
"V",
"segments",
"so",
"that",
"delV",
"can",
"index",
"directly"... | python | train | 40.842105 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py#L2065-L2094 | def run_cell_magic(self, magic_name, line, cell):
"""Execute the given cell magic.
Parameters
----------
magic_name : str
Name of the desired magic function, without '%' prefix.
line : str
The rest of the first input line as a single string.
... | [
"def",
"run_cell_magic",
"(",
"self",
",",
"magic_name",
",",
"line",
",",
"cell",
")",
":",
"fn",
"=",
"self",
".",
"find_cell_magic",
"(",
"magic_name",
")",
"if",
"fn",
"is",
"None",
":",
"lm",
"=",
"self",
".",
"find_line_magic",
"(",
"magic_name",
... | Execute the given cell magic.
Parameters
----------
magic_name : str
Name of the desired magic function, without '%' prefix.
line : str
The rest of the first input line as a single string.
cell : str
The body of the cell as a (possibly mul... | [
"Execute",
"the",
"given",
"cell",
"magic",
".",
"Parameters",
"----------",
"magic_name",
":",
"str",
"Name",
"of",
"the",
"desired",
"magic",
"function",
"without",
"%",
"prefix",
"."
] | python | test | 39.933333 |
Kronuz/pyScss | scss/extension/compass/images.py | https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/extension/compass/images.py#L199-L206 | def inline_image(image, mime_type=None, dst_color=None, src_color=None, spacing=None, collapse_x=None, collapse_y=None):
"""
Embeds the contents of a file directly inside your stylesheet, eliminating
the need for another HTTP request. For small files such images or fonts,
this can be a performance benef... | [
"def",
"inline_image",
"(",
"image",
",",
"mime_type",
"=",
"None",
",",
"dst_color",
"=",
"None",
",",
"src_color",
"=",
"None",
",",
"spacing",
"=",
"None",
",",
"collapse_x",
"=",
"None",
",",
"collapse_y",
"=",
"None",
")",
":",
"return",
"_image_url... | Embeds the contents of a file directly inside your stylesheet, eliminating
the need for another HTTP request. For small files such images or fonts,
this can be a performance benefit at the cost of a larger generated CSS
file. | [
"Embeds",
"the",
"contents",
"of",
"a",
"file",
"directly",
"inside",
"your",
"stylesheet",
"eliminating",
"the",
"need",
"for",
"another",
"HTTP",
"request",
".",
"For",
"small",
"files",
"such",
"images",
"or",
"fonts",
"this",
"can",
"be",
"a",
"performan... | python | train | 60.75 |
mixcloud/django-experiments | experiments/utils.py | https://github.com/mixcloud/django-experiments/blob/1f45e9f8a108b51e44918daa647269b2b8d43f1d/experiments/utils.py#L143-L158 | def incorporate(self, other_user):
"""Incorporate all enrollments and goals performed by the other user
If this user is not enrolled in a given experiment, the results for the
other user are incorporated. For experiments this user is already
enrolled in the results of the other user are... | [
"def",
"incorporate",
"(",
"self",
",",
"other_user",
")",
":",
"for",
"enrollment",
"in",
"other_user",
".",
"_get_all_enrollments",
"(",
")",
":",
"if",
"not",
"self",
".",
"_get_enrollment",
"(",
"enrollment",
".",
"experiment",
")",
":",
"self",
".",
"... | Incorporate all enrollments and goals performed by the other user
If this user is not enrolled in a given experiment, the results for the
other user are incorporated. For experiments this user is already
enrolled in the results of the other user are discarded.
This takes a relatively l... | [
"Incorporate",
"all",
"enrollments",
"and",
"goals",
"performed",
"by",
"the",
"other",
"user"
] | python | train | 70.4375 |
ska-sa/katcp-python | katcp/client.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/client.py#L1469-L1508 | def request_check(client, exception, *msg_parms, **kwargs):
"""Make blocking request to client and raise exception if reply is not ok.
Parameters
----------
client : DeviceClient instance
exception: Exception class to raise
*msg_parms : Message parameters sent to the Message.request() call
... | [
"def",
"request_check",
"(",
"client",
",",
"exception",
",",
"*",
"msg_parms",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"get",
"(",
"'timeout'",
",",
"None",
")",
"req_msg",
"=",
"Message",
".",
"request",
"(",
"*",
"msg_parms... | Make blocking request to client and raise exception if reply is not ok.
Parameters
----------
client : DeviceClient instance
exception: Exception class to raise
*msg_parms : Message parameters sent to the Message.request() call
**kwargs : Keyword arguments
Forwards kwargs['timeout'] to ... | [
"Make",
"blocking",
"request",
"to",
"client",
"and",
"raise",
"exception",
"if",
"reply",
"is",
"not",
"ok",
"."
] | python | train | 34.85 |
fastai/fastai | old/fastai/dataset.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/dataset.py#L594-L607 | def split_by_idx(idxs, *a):
"""
Split each array passed as *a, to a pair of arrays like this (elements selected by idxs, the remaining elements)
This can be used to split multiple arrays containing training data to validation and training set.
:param idxs [int]: list of indexes selected
:param a l... | [
"def",
"split_by_idx",
"(",
"idxs",
",",
"*",
"a",
")",
":",
"mask",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"a",
"[",
"0",
"]",
")",
",",
"dtype",
"=",
"bool",
")",
"mask",
"[",
"np",
".",
"array",
"(",
"idxs",
")",
"]",
"=",
"True",
"re... | Split each array passed as *a, to a pair of arrays like this (elements selected by idxs, the remaining elements)
This can be used to split multiple arrays containing training data to validation and training set.
:param idxs [int]: list of indexes selected
:param a list: list of np.array, each array should... | [
"Split",
"each",
"array",
"passed",
"as",
"*",
"a",
"to",
"a",
"pair",
"of",
"arrays",
"like",
"this",
"(",
"elements",
"selected",
"by",
"idxs",
"the",
"remaining",
"elements",
")",
"This",
"can",
"be",
"used",
"to",
"split",
"multiple",
"arrays",
"cont... | python | train | 54.571429 |
ranaroussi/ezibpy | ezibpy/ezibpy.py | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1832-L1844 | def cancelMarketDepth(self, contracts=None):
"""
Cancel streaming market data for contract
https://www.interactivebrokers.com/en/software/api/apiguide/java/cancelmktdepth.htm
"""
if contracts == None:
contracts = list(self.contracts.values())
elif not isinstan... | [
"def",
"cancelMarketDepth",
"(",
"self",
",",
"contracts",
"=",
"None",
")",
":",
"if",
"contracts",
"==",
"None",
":",
"contracts",
"=",
"list",
"(",
"self",
".",
"contracts",
".",
"values",
"(",
")",
")",
"elif",
"not",
"isinstance",
"(",
"contracts",
... | Cancel streaming market data for contract
https://www.interactivebrokers.com/en/software/api/apiguide/java/cancelmktdepth.htm | [
"Cancel",
"streaming",
"market",
"data",
"for",
"contract",
"https",
":",
"//",
"www",
".",
"interactivebrokers",
".",
"com",
"/",
"en",
"/",
"software",
"/",
"api",
"/",
"apiguide",
"/",
"java",
"/",
"cancelmktdepth",
".",
"htm"
] | python | train | 40.461538 |
suds-community/suds | suds/sax/document.py | https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/sax/document.py#L129-L146 | def getChildren(self, name=None, ns=None):
"""
Get a list of children by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: ... | [
"def",
"getChildren",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"matched",
"=",
"self",
".",
"__root",
"else",
":",
"matched",
"=",
"self",
".",
"getChild",
"(",
"name",
",",
"ns",
"... | Get a list of children by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{prefix}, I{name})
@return: The list of matching chil... | [
"Get",
"a",
"list",
"of",
"children",
"by",
"(",
"optional",
")",
"name",
"and",
"/",
"or",
"(",
"optional",
")",
"namespace",
"."
] | python | train | 34.944444 |
ioos/compliance-checker | compliance_checker/acdd.py | https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/acdd.py#L117-L141 | def get_applicable_variables(self, ds):
'''
Returns a list of variable names that are applicable to ACDD Metadata
Checks for variables. This includes geophysical and coordinate
variables only.
:param netCDF4.Dataset ds: An open netCDF dataset
'''
if self._applica... | [
"def",
"get_applicable_variables",
"(",
"self",
",",
"ds",
")",
":",
"if",
"self",
".",
"_applicable_variables",
"is",
"None",
":",
"self",
".",
"applicable_variables",
"=",
"cfutil",
".",
"get_geophysical_variables",
"(",
"ds",
")",
"varname",
"=",
"cfutil",
... | Returns a list of variable names that are applicable to ACDD Metadata
Checks for variables. This includes geophysical and coordinate
variables only.
:param netCDF4.Dataset ds: An open netCDF dataset | [
"Returns",
"a",
"list",
"of",
"variable",
"names",
"that",
"are",
"applicable",
"to",
"ACDD",
"Metadata",
"Checks",
"for",
"variables",
".",
"This",
"includes",
"geophysical",
"and",
"coordinate",
"variables",
"only",
"."
] | python | train | 48.56 |
saltstack/salt | salt/modules/virt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L2600-L2626 | def full_info(**kwargs):
'''
Return the node_info, vm_info and freemem
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to c... | [
"def",
"full_info",
"(",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"info",
"=",
"{",
"'freecpu'",
":",
"_freecpu",
"(",
"conn",
")",
",",
"'freemem'",
":",
"_freemem",
"(",
"conn",
")",
",",
"'node_info'",... | Return the node_info, vm_info and freemem
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overriding defaults
... | [
"Return",
"the",
"node_info",
"vm_info",
"and",
"freemem"
] | python | train | 24.703704 |
elifesciences/proofreader-python | proofreader/license_checker/__init__.py | https://github.com/elifesciences/proofreader-python/blob/387b3c65ee7777e26b3a7340179dc4ed68f24f58/proofreader/license_checker/__init__.py#L42-L64 | def run_license_checker(config_path):
# type: (str) -> None
"""Generate table of installed packages and check for license
warnings based off user defined restricted license values.
:param config_path: str
:return:
"""
whitelist_licenses = _get_whitelist_licenses(config_path)
table = Pri... | [
"def",
"run_license_checker",
"(",
"config_path",
")",
":",
"# type: (str) -> None",
"whitelist_licenses",
"=",
"_get_whitelist_licenses",
"(",
"config_path",
")",
"table",
"=",
"PrintTable",
"(",
"ROW_HEADERS",
")",
"warnings",
"=",
"[",
"]",
"for",
"pkg",
"in",
... | Generate table of installed packages and check for license
warnings based off user defined restricted license values.
:param config_path: str
:return: | [
"Generate",
"table",
"of",
"installed",
"packages",
"and",
"check",
"for",
"license",
"warnings",
"based",
"off",
"user",
"defined",
"restricted",
"license",
"values",
"."
] | python | train | 27.826087 |
pyhys/minimalmodbus | minimalmodbus.py | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1695-L1733 | def _hexdecode(hexstring):
"""Convert a hex encoded string to a byte string.
For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
Args:
hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
Allowed characters are '0' to '9', 'a' to ... | [
"def",
"_hexdecode",
"(",
"hexstring",
")",
":",
"# Note: For Python3 the appropriate would be: raise TypeError(new_error_message) from err",
"# but the Python2 interpreter will indicate SyntaxError.",
"# Thus we need to live with this warning in Python3:",
"# 'During handling of the above excepti... | Convert a hex encoded string to a byte string.
For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
Args:
hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
Allowed characters are '0' to '9', 'a' to 'f' and 'A' to 'F' (not space).
... | [
"Convert",
"a",
"hex",
"encoded",
"string",
"to",
"a",
"byte",
"string",
"."
] | python | train | 39.205128 |
apache/spark | python/pyspark/context.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L650-L665 | def binaryFiles(self, path, minPartitions=None):
"""
.. note:: Experimental
Read a directory of binary files from HDFS, a local file system
(available on all nodes), or any Hadoop-supported file system URI
as a byte array. Each file is read as a single record and returned
... | [
"def",
"binaryFiles",
"(",
"self",
",",
"path",
",",
"minPartitions",
"=",
"None",
")",
":",
"minPartitions",
"=",
"minPartitions",
"or",
"self",
".",
"defaultMinPartitions",
"return",
"RDD",
"(",
"self",
".",
"_jsc",
".",
"binaryFiles",
"(",
"path",
",",
... | .. note:: Experimental
Read a directory of binary files from HDFS, a local file system
(available on all nodes), or any Hadoop-supported file system URI
as a byte array. Each file is read as a single record and returned
in a key-value pair, where the key is the path of each file, the
... | [
"..",
"note",
"::",
"Experimental"
] | python | train | 47.25 |
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#L607-L630 | def cmp(self,junc,tolerance=0):
""" output comparison and allow for tolerance if desired
* -1 if junc comes before self
* 1 if junc comes after self
* 0 if overlaps
* 2 if else
:param junc:
:param tolerance: optional search space (default=0, no tolerance)
:type junc: Junction
:type... | [
"def",
"cmp",
"(",
"self",
",",
"junc",
",",
"tolerance",
"=",
"0",
")",
":",
"if",
"self",
".",
"overlaps",
"(",
"junc",
",",
"tolerance",
")",
":",
"return",
"0",
"#equal",
"if",
"self",
".",
"left",
".",
"chr",
"==",
"junc",
".",
"right",
".",... | output comparison and allow for tolerance if desired
* -1 if junc comes before self
* 1 if junc comes after self
* 0 if overlaps
* 2 if else
:param junc:
:param tolerance: optional search space (default=0, no tolerance)
:type junc: Junction
:type tolerance: int
:return: value of co... | [
"output",
"comparison",
"and",
"allow",
"for",
"tolerance",
"if",
"desired"
] | python | train | 28.125 |
PolyJIT/benchbuild | benchbuild/likwid.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/likwid.py#L54-L90 | def read_table(fstream):
"""
Read a likwid table info from the text stream.
Args:
fstream: Likwid's filestream.
Returns (dict(str: str)):
A dict containing likwid's table info as key/value pairs.
"""
pos = fstream.tell()
line = fstream.readline().strip()
fragments = lin... | [
"def",
"read_table",
"(",
"fstream",
")",
":",
"pos",
"=",
"fstream",
".",
"tell",
"(",
")",
"line",
"=",
"fstream",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"fragments",
"=",
"line",
".",
"split",
"(",
"\",\"",
")",
"fragments",
"=",
"["... | Read a likwid table info from the text stream.
Args:
fstream: Likwid's filestream.
Returns (dict(str: str)):
A dict containing likwid's table info as key/value pairs. | [
"Read",
"a",
"likwid",
"table",
"info",
"from",
"the",
"text",
"stream",
"."
] | python | train | 27.081081 |
autokey/autokey | lib/autokey/service.py | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/service.py#L414-L425 | def phrase_contains_special_keys(expansion: model.Expansion) -> bool:
"""
Determine if the expansion contains any special keys, including those resulting from any processed macros
(<script>, <file>, etc). If any are found, the phrase cannot be undone.
Python Zen: »In the face of ambigui... | [
"def",
"phrase_contains_special_keys",
"(",
"expansion",
":",
"model",
".",
"Expansion",
")",
"->",
"bool",
":",
"found_special_keys",
"=",
"KEY_FIND_RE",
".",
"findall",
"(",
"expansion",
".",
"string",
".",
"lower",
"(",
")",
")",
"return",
"bool",
"(",
"f... | Determine if the expansion contains any special keys, including those resulting from any processed macros
(<script>, <file>, etc). If any are found, the phrase cannot be undone.
Python Zen: »In the face of ambiguity, refuse the temptation to guess.«
The question 'What does the phrase expansion ... | [
"Determine",
"if",
"the",
"expansion",
"contains",
"any",
"special",
"keys",
"including",
"those",
"resulting",
"from",
"any",
"processed",
"macros",
"(",
"<script",
">",
"<file",
">",
"etc",
")",
".",
"If",
"any",
"are",
"found",
"the",
"phrase",
"cannot",
... | python | train | 67.75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.