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 |
|---|---|---|---|---|---|---|---|---|---|
pyamg/pyamg | pyamg/blackbox.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/blackbox.py#L55-L155 | def solver_configuration(A, B=None, verb=True):
"""Generate a dictionary of SA parameters for an arbitray matrix A.
Parameters
----------
A : array, matrix, csr_matrix, bsr_matrix
(n x n) matrix to invert, CSR or BSR format preferred for efficiency
B : None, array
Near null-space mo... | [
"def",
"solver_configuration",
"(",
"A",
",",
"B",
"=",
"None",
",",
"verb",
"=",
"True",
")",
":",
"# Ensure acceptable format of A",
"A",
"=",
"make_csr",
"(",
"A",
")",
"config",
"=",
"{",
"}",
"# Detect symmetry",
"if",
"ishermitian",
"(",
"A",
",",
... | Generate a dictionary of SA parameters for an arbitray matrix A.
Parameters
----------
A : array, matrix, csr_matrix, bsr_matrix
(n x n) matrix to invert, CSR or BSR format preferred for efficiency
B : None, array
Near null-space modes used to construct the smoothed aggregation solver
... | [
"Generate",
"a",
"dictionary",
"of",
"SA",
"parameters",
"for",
"an",
"arbitray",
"matrix",
"A",
"."
] | python | train | 37.207921 |
underworldcode/stripy | stripy-src/stripy/cartesian.py | https://github.com/underworldcode/stripy/blob/d4c3480c3e58c88489ded695eadbe7cd5bf94b48/stripy-src/stripy/cartesian.py#L889-L905 | def edge_lengths(self):
"""
Compute the edge-lengths of each triangle in the triangulation.
"""
simplex = self.simplices.T
# simplex is vectors a, b, c defining the corners
a = self.points[simplex[0]]
b = self.points[simplex[1]]
c = self.points[simplex[2]... | [
"def",
"edge_lengths",
"(",
"self",
")",
":",
"simplex",
"=",
"self",
".",
"simplices",
".",
"T",
"# simplex is vectors a, b, c defining the corners",
"a",
"=",
"self",
".",
"points",
"[",
"simplex",
"[",
"0",
"]",
"]",
"b",
"=",
"self",
".",
"points",
"["... | Compute the edge-lengths of each triangle in the triangulation. | [
"Compute",
"the",
"edge",
"-",
"lengths",
"of",
"each",
"triangle",
"in",
"the",
"triangulation",
"."
] | python | train | 29.235294 |
StackStorm/pybind | pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/__init__.py#L197-L218 | def _set_ospf_level1(self, v, load=False):
"""
Setter method for ospf_level1, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/ospf_level1 (empty)
If this variable is read-only (config:... | [
"def",
"_set_ospf_level1",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for ospf_level1, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/ospf_level1 (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_ospf_lev... | [
"Setter",
"method",
"for",
"ospf_level1",
"mapped",
"from",
"YANG",
"variable",
"/",
"routing_system",
"/",
"router",
"/",
"isis",
"/",
"router_isis_cmds_holder",
"/",
"address_family",
"/",
"ipv6",
"/",
"af_ipv6_unicast",
"/",
"af_ipv6_attributes",
"/",
"af_common_... | python | train | 84.727273 |
oscarlazoarjona/fast | fast/atomic_structure.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1894-L2127 | def calculate_r_matrices(fine_states, reduced_matrix_elements, q=None,
numeric=True, convention=1):
ur"""Calculate the matrix elements of the electric dipole (in the helicity
basis).
We calculate all matrix elements for the D2 line in Rb 87.
>>> from sympy import symbols, ppri... | [
"def",
"calculate_r_matrices",
"(",
"fine_states",
",",
"reduced_matrix_elements",
",",
"q",
"=",
"None",
",",
"numeric",
"=",
"True",
",",
"convention",
"=",
"1",
")",
":",
"magnetic_states",
"=",
"make_list_of_states",
"(",
"fine_states",
",",
"'magnetic'",
",... | ur"""Calculate the matrix elements of the electric dipole (in the helicity
basis).
We calculate all matrix elements for the D2 line in Rb 87.
>>> from sympy import symbols, pprint
>>> red = symbols("r", positive=True)
>>> reduced_matrix_elements = [[0, -red], [red, 0]]
>>> g = State("Rb", 87, ... | [
"ur",
"Calculate",
"the",
"matrix",
"elements",
"of",
"the",
"electric",
"dipole",
"(",
"in",
"the",
"helicity",
"basis",
")",
"."
] | python | train | 53.423077 |
thisfred/val | val/_val.py | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L358-L363 | def _validated(self, data):
"""Convert data or die trying."""
try:
return self.convert(data)
except (TypeError, ValueError) as ex:
raise NotValid(*ex.args) | [
"def",
"_validated",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"return",
"self",
".",
"convert",
"(",
"data",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
"as",
"ex",
":",
"raise",
"NotValid",
"(",
"*",
"ex",
".",
"args",
")"
] | Convert data or die trying. | [
"Convert",
"data",
"or",
"die",
"trying",
"."
] | python | train | 33 |
ga4gh/ga4gh-server | ga4gh/server/exceptions.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/exceptions.py#L17-L26 | def getExceptionClass(errorCode):
"""
Converts the specified error code into the corresponding class object.
Raises a KeyError if the errorCode is not found.
"""
classMap = {}
for name, class_ in inspect.getmembers(sys.modules[__name__]):
if inspect.isclass(class_) and issubclass(class_,... | [
"def",
"getExceptionClass",
"(",
"errorCode",
")",
":",
"classMap",
"=",
"{",
"}",
"for",
"name",
",",
"class_",
"in",
"inspect",
".",
"getmembers",
"(",
"sys",
".",
"modules",
"[",
"__name__",
"]",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"clas... | Converts the specified error code into the corresponding class object.
Raises a KeyError if the errorCode is not found. | [
"Converts",
"the",
"specified",
"error",
"code",
"into",
"the",
"corresponding",
"class",
"object",
".",
"Raises",
"a",
"KeyError",
"if",
"the",
"errorCode",
"is",
"not",
"found",
"."
] | python | train | 41.7 |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/utils/cache/value_cache.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/utils/cache/value_cache.py#L42-L57 | def store_value(self, name, value, parameters=None):
"""Stores the value of a certain variable
The value of a variable with name 'name' is stored together with the parameters that were used for the
calculation.
:param str name: The name of the variable
:param value: The value t... | [
"def",
"store_value",
"(",
"self",
",",
"name",
",",
"value",
",",
"parameters",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"parameters",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"\"parameters must be a dict\"",
")",
"hash",
"=",
"self... | Stores the value of a certain variable
The value of a variable with name 'name' is stored together with the parameters that were used for the
calculation.
:param str name: The name of the variable
:param value: The value to be cached
:param dict parameters: The parameters on wh... | [
"Stores",
"the",
"value",
"of",
"a",
"certain",
"variable"
] | python | train | 42.1875 |
tensorflow/tensor2tensor | tensor2tensor/layers/common_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_attention.py#L2307-L2323 | def _extract_blocks(x, block_h, block_w):
"""Helper function for local 2d attention.
Args:
x: a [batch, height, width, depth] tensor
block_h: An integer. block height
block_w: An inteter. block width
returns:
a [batch, num_heads, height/block_h, width/block_w, depth] tensor
"""
(_, height, w... | [
"def",
"_extract_blocks",
"(",
"x",
",",
"block_h",
",",
"block_w",
")",
":",
"(",
"_",
",",
"height",
",",
"width",
",",
"depth",
")",
"=",
"common_layers",
".",
"shape_list",
"(",
"x",
")",
"assert",
"height",
"%",
"block_h",
"==",
"0",
"assert",
"... | Helper function for local 2d attention.
Args:
x: a [batch, height, width, depth] tensor
block_h: An integer. block height
block_w: An inteter. block width
returns:
a [batch, num_heads, height/block_h, width/block_w, depth] tensor | [
"Helper",
"function",
"for",
"local",
"2d",
"attention",
"."
] | python | train | 32.764706 |
praekelt/django-analytics | analytics/geckoboard_views.py | https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/geckoboard_views.py#L43-L54 | def get_next_colour():
"""
Gets the next colour in the Geckoboard colour list.
"""
colour = settings.GECKOBOARD_COLOURS[get_next_colour.cur_colour]
get_next_colour.cur_colour += 1
if get_next_colour.cur_colour >= len(settings.GECKOBOARD_COLOURS):
get_next_colour.cur_colour = 0
ret... | [
"def",
"get_next_colour",
"(",
")",
":",
"colour",
"=",
"settings",
".",
"GECKOBOARD_COLOURS",
"[",
"get_next_colour",
".",
"cur_colour",
"]",
"get_next_colour",
".",
"cur_colour",
"+=",
"1",
"if",
"get_next_colour",
".",
"cur_colour",
">=",
"len",
"(",
"setting... | Gets the next colour in the Geckoboard colour list. | [
"Gets",
"the",
"next",
"colour",
"in",
"the",
"Geckoboard",
"colour",
"list",
"."
] | python | test | 26.583333 |
insightindustry/validator-collection | validator_collection/validators.py | https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/validators.py#L2517-L2552 | def ipv6(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid IP address version 6.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValue... | [
"def",
"ipv6",
"(",
"value",
",",
"allow_empty",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"value",
"and",
"allow_empty",
"is",
"False",
":",
"raise",
"errors",
".",
"EmptyValueError",
"(",
"'value (%s) was empty'",
"%",
"value",
")",
... | Validate that ``value`` is a valid IP address version 6.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` i... | [
"Validate",
"that",
"value",
"is",
"a",
"valid",
"IP",
"address",
"version",
"6",
"."
] | python | train | 33.416667 |
mabuchilab/QNET | src/qnet/algebra/core/algebraic_properties.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/algebraic_properties.py#L93-L104 | def idem(cls, ops, kwargs):
"""Remove duplicate arguments and order them via the cls's order_key key
object/function.
E.g.::
>>> class Set(Operation):
... order_key = lambda val: val
... simplifications = [idem, ]
>>> Set.create(1,2,3,1,3)
Set(1, 2, 3)
""... | [
"def",
"idem",
"(",
"cls",
",",
"ops",
",",
"kwargs",
")",
":",
"return",
"sorted",
"(",
"set",
"(",
"ops",
")",
",",
"key",
"=",
"cls",
".",
"order_key",
")",
",",
"kwargs"
] | Remove duplicate arguments and order them via the cls's order_key key
object/function.
E.g.::
>>> class Set(Operation):
... order_key = lambda val: val
... simplifications = [idem, ]
>>> Set.create(1,2,3,1,3)
Set(1, 2, 3) | [
"Remove",
"duplicate",
"arguments",
"and",
"order",
"them",
"via",
"the",
"cls",
"s",
"order_key",
"key",
"object",
"/",
"function",
".",
"E",
".",
"g",
".",
"::"
] | python | train | 30.416667 |
UDST/pandana | pandana/loaders/osm.py | https://github.com/UDST/pandana/blob/961a7ef8d3b0144b190cb60bbd61845fca6fb314/pandana/loaders/osm.py#L160-L189 | def node_query(lat_min, lng_min, lat_max, lng_max, tags=None):
"""
Search for OSM nodes within a bounding box that match given tags.
Parameters
----------
lat_min, lng_min, lat_max, lng_max : float
tags : str or list of str, optional
Node tags that will be used to filter the search.
... | [
"def",
"node_query",
"(",
"lat_min",
",",
"lng_min",
",",
"lat_max",
",",
"lng_max",
",",
"tags",
"=",
"None",
")",
":",
"node_data",
"=",
"make_osm_query",
"(",
"build_node_query",
"(",
"lat_min",
",",
"lng_min",
",",
"lat_max",
",",
"lng_max",
",",
"tags... | Search for OSM nodes within a bounding box that match given tags.
Parameters
----------
lat_min, lng_min, lat_max, lng_max : float
tags : str or list of str, optional
Node tags that will be used to filter the search.
See http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide
... | [
"Search",
"for",
"OSM",
"nodes",
"within",
"a",
"bounding",
"box",
"that",
"match",
"given",
"tags",
"."
] | python | test | 35.966667 |
ValvePython/steam | steam/client/builtins/web.py | https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/client/builtins/web.py#L22-L54 | def get_web_session_cookies(self):
"""Get web authentication cookies via WebAPI's ``AuthenticateUser``
.. note::
The cookies are valid only while :class:`.SteamClient` instance is logged on.
:return: dict with authentication cookies
:rtype: :class:`dict`, :class:`None`
... | [
"def",
"get_web_session_cookies",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"logged_on",
":",
"return",
"None",
"resp",
"=",
"self",
".",
"send_job_and_wait",
"(",
"MsgProto",
"(",
"EMsg",
".",
"ClientRequestWebAPIAuthenticateUserNonce",
")",
",",
"timeou... | Get web authentication cookies via WebAPI's ``AuthenticateUser``
.. note::
The cookies are valid only while :class:`.SteamClient` instance is logged on.
:return: dict with authentication cookies
:rtype: :class:`dict`, :class:`None` | [
"Get",
"web",
"authentication",
"cookies",
"via",
"WebAPI",
"s",
"AuthenticateUser"
] | python | train | 34.30303 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/gridfs/__init__.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/__init__.py#L239-L264 | def find_one(self, filter=None, *args, **kwargs):
"""Get a single file from gridfs.
All arguments to :meth:`find` are also valid arguments for
:meth:`find_one`, although any `limit` argument will be
ignored. Returns a single :class:`~gridfs.grid_file.GridOut`,
or ``None`` if no ... | [
"def",
"find_one",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"filter",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"filter",
",",
"Mapping",
")",
":",
"filter",
"=",
"{",
"\"_id\""... | Get a single file from gridfs.
All arguments to :meth:`find` are also valid arguments for
:meth:`find_one`, although any `limit` argument will be
ignored. Returns a single :class:`~gridfs.grid_file.GridOut`,
or ``None`` if no matching file is found. For example::
file = fs.... | [
"Get",
"a",
"single",
"file",
"from",
"gridfs",
"."
] | python | train | 41.461538 |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L570-L577 | def tile_is_valid(self):
""" Checks if tile has tile info and valid timestamp
:return: `True` if tile is valid and `False` otherwise
:rtype: bool
"""
return self.tile_info is not None \
and (self.datetime == self.date or self.datetime == self.parse_datetime(self.tile... | [
"def",
"tile_is_valid",
"(",
"self",
")",
":",
"return",
"self",
".",
"tile_info",
"is",
"not",
"None",
"and",
"(",
"self",
".",
"datetime",
"==",
"self",
".",
"date",
"or",
"self",
".",
"datetime",
"==",
"self",
".",
"parse_datetime",
"(",
"self",
"."... | Checks if tile has tile info and valid timestamp
:return: `True` if tile is valid and `False` otherwise
:rtype: bool | [
"Checks",
"if",
"tile",
"has",
"tile",
"info",
"and",
"valid",
"timestamp"
] | python | train | 41.625 |
nerdvegas/rez | src/rez/suite.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/suite.py#L219-L223 | def bump_context(self, name):
"""Causes the context's tools to take priority over all others."""
data = self._context(name)
data["priority"] = self._next_priority
self._flush_tools() | [
"def",
"bump_context",
"(",
"self",
",",
"name",
")",
":",
"data",
"=",
"self",
".",
"_context",
"(",
"name",
")",
"data",
"[",
"\"priority\"",
"]",
"=",
"self",
".",
"_next_priority",
"self",
".",
"_flush_tools",
"(",
")"
] | Causes the context's tools to take priority over all others. | [
"Causes",
"the",
"context",
"s",
"tools",
"to",
"take",
"priority",
"over",
"all",
"others",
"."
] | python | train | 42 |
Bogdanp/anom-py | anom/conditions.py | https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L21-L23 | def is_none(entity, prop, name):
"bool: True if the value of a property is None."
return is_not_empty(entity, prop, name) and getattr(entity, name) is None | [
"def",
"is_none",
"(",
"entity",
",",
"prop",
",",
"name",
")",
":",
"return",
"is_not_empty",
"(",
"entity",
",",
"prop",
",",
"name",
")",
"and",
"getattr",
"(",
"entity",
",",
"name",
")",
"is",
"None"
] | bool: True if the value of a property is None. | [
"bool",
":",
"True",
"if",
"the",
"value",
"of",
"a",
"property",
"is",
"None",
"."
] | python | train | 53.666667 |
aparo/pyes | pyes/facets.py | https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/facets.py#L20-L22 | def add_geo_facet(self, *args, **kwargs):
"""Add a geo factory facet"""
self.facets.append(GeoDistanceFacet(*args, **kwargs)) | [
"def",
"add_geo_facet",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"facets",
".",
"append",
"(",
"GeoDistanceFacet",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | Add a geo factory facet | [
"Add",
"a",
"geo",
"factory",
"facet"
] | python | train | 46.333333 |
olitheolix/qtmacs | qtmacs/qtmacsmain_macros.py | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain_macros.py#L483-L491 | def abort(self, msgObj):
"""
Disconnect all signals and turn macro processing in the event
handler back on.
"""
self.qteMain.qtesigKeyparsed.disconnect(self.qteKeyPress)
self.qteMain.qtesigAbort.disconnect(self.abort)
self.qteActive = False
self.qteMain.qt... | [
"def",
"abort",
"(",
"self",
",",
"msgObj",
")",
":",
"self",
".",
"qteMain",
".",
"qtesigKeyparsed",
".",
"disconnect",
"(",
"self",
".",
"qteKeyPress",
")",
"self",
".",
"qteMain",
".",
"qtesigAbort",
".",
"disconnect",
"(",
"self",
".",
"abort",
")",
... | Disconnect all signals and turn macro processing in the event
handler back on. | [
"Disconnect",
"all",
"signals",
"and",
"turn",
"macro",
"processing",
"in",
"the",
"event",
"handler",
"back",
"on",
"."
] | python | train | 37.333333 |
moonlitesolutions/SolrClient | SolrClient/indexq.py | https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L240-L279 | def complete(self, filepath):
'''
Marks the item as complete by moving it to the done directory and optionally gzipping it.
'''
if not os.path.exists(filepath):
raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath))
if self._devel: self.logger... | [
"def",
"complete",
"(",
"self",
",",
"filepath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"raise",
"FileNotFoundError",
"(",
"\"Can't Complete {}, it doesn't exist\"",
".",
"format",
"(",
"filepath",
")",
")",
"if",... | Marks the item as complete by moving it to the done directory and optionally gzipping it. | [
"Marks",
"the",
"item",
"as",
"complete",
"by",
"moving",
"it",
"to",
"the",
"done",
"directory",
"and",
"optionally",
"gzipping",
"it",
"."
] | python | train | 45.4 |
cjdrake/pyeda | pyeda/boolalg/bdd.py | https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L198-L208 | def _bddnode(root, lo, hi):
"""Return a unique BDD node."""
if lo is hi:
node = lo
else:
key = (root, lo, hi)
try:
node = _NODES[key]
except KeyError:
node = _NODES[key] = BDDNode(*key)
return node | [
"def",
"_bddnode",
"(",
"root",
",",
"lo",
",",
"hi",
")",
":",
"if",
"lo",
"is",
"hi",
":",
"node",
"=",
"lo",
"else",
":",
"key",
"=",
"(",
"root",
",",
"lo",
",",
"hi",
")",
"try",
":",
"node",
"=",
"_NODES",
"[",
"key",
"]",
"except",
"... | Return a unique BDD node. | [
"Return",
"a",
"unique",
"BDD",
"node",
"."
] | python | train | 23.545455 |
securestate/termineter | lib/termineter/interface.py | https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/interface.py#L428-L440 | def do_reload(self, args):
"""Reload a module in to the framework"""
if args.module is not None:
if args.module not in self.frmwk.modules:
self.print_error('Invalid Module Selected.')
return
module = self.frmwk.modules[args.module]
elif self.frmwk.current_module:
module = self.frmwk.current_modul... | [
"def",
"do_reload",
"(",
"self",
",",
"args",
")",
":",
"if",
"args",
".",
"module",
"is",
"not",
"None",
":",
"if",
"args",
".",
"module",
"not",
"in",
"self",
".",
"frmwk",
".",
"modules",
":",
"self",
".",
"print_error",
"(",
"'Invalid Module Select... | Reload a module in to the framework | [
"Reload",
"a",
"module",
"in",
"to",
"the",
"framework"
] | python | train | 31.153846 |
waqasbhatti/astrobase | astrobase/lcproc/checkplotproc.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/checkplotproc.py#L754-L948 | def parallel_update_objectinfo_cplist(
cplist,
liststartindex=None,
maxobjects=None,
nworkers=NCPUS,
fast_mode=False,
findercmap='gray_r',
finderconvolve=None,
deredden_object=True,
custom_bandpasses=None,
gaia_submit_timeout=10.0,
... | [
"def",
"parallel_update_objectinfo_cplist",
"(",
"cplist",
",",
"liststartindex",
"=",
"None",
",",
"maxobjects",
"=",
"None",
",",
"nworkers",
"=",
"NCPUS",
",",
"fast_mode",
"=",
"False",
",",
"findercmap",
"=",
"'gray_r'",
",",
"finderconvolve",
"=",
"None",
... | This updates objectinfo for a list of checkplots.
Useful in cases where a previous round of GAIA/finderchart/external catalog
acquisition failed. This will preserve the following keys in the checkplots
if they exist:
comments
varinfo
objectinfo.objecttags
Parameters
----------
cp... | [
"This",
"updates",
"objectinfo",
"for",
"a",
"list",
"of",
"checkplots",
"."
] | python | valid | 38.774359 |
solvebio/solvebio-python | solvebio/utils/tabulate.py | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L470-L489 | def _build_row(cells, padding, begin, sep, end):
"Return a string which represents a row of data cells."
pad = " " * padding
padded_cells = [pad + cell + pad for cell in cells]
# SolveBio: we're only displaying Key-Value tuples (dimension of 2).
# enforce that we don't wrap lines by setting a max... | [
"def",
"_build_row",
"(",
"cells",
",",
"padding",
",",
"begin",
",",
"sep",
",",
"end",
")",
":",
"pad",
"=",
"\" \"",
"*",
"padding",
"padded_cells",
"=",
"[",
"pad",
"+",
"cell",
"+",
"pad",
"for",
"cell",
"in",
"cells",
"]",
"# SolveBio: we're only... | Return a string which represents a row of data cells. | [
"Return",
"a",
"string",
"which",
"represents",
"a",
"row",
"of",
"data",
"cells",
"."
] | python | test | 40.3 |
awslabs/serverless-application-model | samtranslator/model/sam_resources.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/sam_resources.py#L644-L688 | def _construct_lambda_layer(self, intrinsics_resolver):
"""Constructs and returns the Lambda function.
:returns: a list containing the Lambda function and execution role resources
:rtype: list
"""
# Resolve intrinsics if applicable:
self.LayerName = self._resolve_string_... | [
"def",
"_construct_lambda_layer",
"(",
"self",
",",
"intrinsics_resolver",
")",
":",
"# Resolve intrinsics if applicable:",
"self",
".",
"LayerName",
"=",
"self",
".",
"_resolve_string_parameter",
"(",
"intrinsics_resolver",
",",
"self",
".",
"LayerName",
",",
"'LayerNa... | Constructs and returns the Lambda function.
:returns: a list containing the Lambda function and execution role resources
:rtype: list | [
"Constructs",
"and",
"returns",
"the",
"Lambda",
"function",
"."
] | python | train | 55.2 |
watson-developer-cloud/python-sdk | ibm_watson/assistant_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/assistant_v1.py#L3047-L3056 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self, 'created') and self.created is not None:
_dict['created'] = datetime_to_string(sel... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'text'",
")",
"and",
"self",
".",
"text",
"is",
"not",
"None",
":",
"_dict",
"[",
"'text'",
"]",
"=",
"self",
".",
"text",
"if",
"hasattr",
"(",... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train | 47.2 |
honeynet/beeswarm | beeswarm/drones/client/baits/ftp.py | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L128-L140 | def decide(self):
"""
Decides the next command to be launched based on the current state.
:return: Tuple containing the next command name, and it's parameters.
"""
next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
param = ''
if n... | [
"def",
"decide",
"(",
"self",
")",
":",
"next_command_name",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"COMMAND_MAP",
"[",
"self",
".",
"state",
"[",
"'last_command'",
"]",
"]",
")",
"param",
"=",
"''",
"if",
"next_command_name",
"==",
"'retrieve'",
... | Decides the next command to be launched based on the current state.
:return: Tuple containing the next command name, and it's parameters. | [
"Decides",
"the",
"next",
"command",
"to",
"be",
"launched",
"based",
"on",
"the",
"current",
"state",
"."
] | python | train | 41.307692 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py#L69-L73 | def setFormat(self, start, count, format):
""" Reimplemented to highlight selectively.
"""
start += self._current_offset
super(FrontendHighlighter, self).setFormat(start, count, format) | [
"def",
"setFormat",
"(",
"self",
",",
"start",
",",
"count",
",",
"format",
")",
":",
"start",
"+=",
"self",
".",
"_current_offset",
"super",
"(",
"FrontendHighlighter",
",",
"self",
")",
".",
"setFormat",
"(",
"start",
",",
"count",
",",
"format",
")"
] | Reimplemented to highlight selectively. | [
"Reimplemented",
"to",
"highlight",
"selectively",
"."
] | python | test | 42.6 |
dsoprea/PySecure | pysecure/adapters/ssha.py | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/adapters/ssha.py#L249-L260 | def _ssh_forward_accept(ssh_session, timeout_ms):
"""Waiting for an incoming connection from a reverse forwarded port. Note
that this results in a kernel block until a connection is received.
"""
ssh_channel = c_ssh_forward_accept(c_void_p(ssh_session),
c_int(tim... | [
"def",
"_ssh_forward_accept",
"(",
"ssh_session",
",",
"timeout_ms",
")",
":",
"ssh_channel",
"=",
"c_ssh_forward_accept",
"(",
"c_void_p",
"(",
"ssh_session",
")",
",",
"c_int",
"(",
"timeout_ms",
")",
")",
"if",
"ssh_channel",
"is",
"None",
":",
"raise",
"Ss... | Waiting for an incoming connection from a reverse forwarded port. Note
that this results in a kernel block until a connection is received. | [
"Waiting",
"for",
"an",
"incoming",
"connection",
"from",
"a",
"reverse",
"forwarded",
"port",
".",
"Note",
"that",
"this",
"results",
"in",
"a",
"kernel",
"block",
"until",
"a",
"connection",
"is",
"received",
"."
] | python | train | 33.916667 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3901-L3909 | def xpathNextSelf(self, ctxt):
"""Traversal function for the "self" direction The self axis
contains just the context node itself """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.xmlXPathNextSelf(ctxt__o, self._o)
if ret is None:raise xpathE... | [
"def",
"xpathNextSelf",
"(",
"self",
",",
"ctxt",
")",
":",
"if",
"ctxt",
"is",
"None",
":",
"ctxt__o",
"=",
"None",
"else",
":",
"ctxt__o",
"=",
"ctxt",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlXPathNextSelf",
"(",
"ctxt__o",
",",
"self",
".",
... | Traversal function for the "self" direction The self axis
contains just the context node itself | [
"Traversal",
"function",
"for",
"the",
"self",
"direction",
"The",
"self",
"axis",
"contains",
"just",
"the",
"context",
"node",
"itself"
] | python | train | 44.444444 |
edx/edx-enterprise | enterprise/admin/forms.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/forms.py#L227-L231 | def clean_notify(self):
"""
Clean the notify_on_enrollment field.
"""
return self.cleaned_data.get(self.Fields.NOTIFY, self.NotificationTypes.DEFAULT) | [
"def",
"clean_notify",
"(",
"self",
")",
":",
"return",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"self",
".",
"Fields",
".",
"NOTIFY",
",",
"self",
".",
"NotificationTypes",
".",
"DEFAULT",
")"
] | Clean the notify_on_enrollment field. | [
"Clean",
"the",
"notify_on_enrollment",
"field",
"."
] | python | valid | 35.6 |
crocs-muni/roca | roca/detect.py | https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1027-L1066 | def process_inputs(self):
"""
Processes input data
:return:
"""
ret = []
files = self.args.files
if files is None:
return ret
for fname in files:
if fname == '-':
if self.args.base64stdin:
for li... | [
"def",
"process_inputs",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"files",
"=",
"self",
".",
"args",
".",
"files",
"if",
"files",
"is",
"None",
":",
"return",
"ret",
"for",
"fname",
"in",
"files",
":",
"if",
"fname",
"==",
"'-'",
":",
"if",
"... | Processes input data
:return: | [
"Processes",
"input",
"data",
":",
"return",
":"
] | python | train | 26.125 |
mongodb/mongo-python-driver | pymongo/message.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/message.py#L796-L803 | def _delete(collection_name, spec, opts, flags):
"""Get an OP_DELETE message."""
encoded = _dict_to_bson(spec, False, opts) # Uses extensions.
return b"".join([
_ZERO_32,
_make_c_string(collection_name),
_pack_int(flags),
encoded]), len(encoded) | [
"def",
"_delete",
"(",
"collection_name",
",",
"spec",
",",
"opts",
",",
"flags",
")",
":",
"encoded",
"=",
"_dict_to_bson",
"(",
"spec",
",",
"False",
",",
"opts",
")",
"# Uses extensions.",
"return",
"b\"\"",
".",
"join",
"(",
"[",
"_ZERO_32",
",",
"_m... | Get an OP_DELETE message. | [
"Get",
"an",
"OP_DELETE",
"message",
"."
] | python | train | 35.375 |
Esri/ArcREST | src/arcrest/enrichment/_geoenrichment.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L382-L443 | def dataCollections(self,
countryName=None,
addDerivativeVariables=None,
outFields=None,
suppressNullValues=False):
"""
The GeoEnrichment service uses the concept of a data collection to
define the da... | [
"def",
"dataCollections",
"(",
"self",
",",
"countryName",
"=",
"None",
",",
"addDerivativeVariables",
"=",
"None",
",",
"outFields",
"=",
"None",
",",
"suppressNullValues",
"=",
"False",
")",
":",
"if",
"addDerivativeVariables",
"is",
"None",
":",
"addDerivativ... | The GeoEnrichment service uses the concept of a data collection to
define the data attributes returned by the enrichment service. Each
data collection has a unique name that acts as an ID that is passed
in the dataCollections parameter of the GeoEnrichment service.
Some data collections ... | [
"The",
"GeoEnrichment",
"service",
"uses",
"the",
"concept",
"of",
"a",
"data",
"collection",
"to",
"define",
"the",
"data",
"attributes",
"returned",
"by",
"the",
"enrichment",
"service",
".",
"Each",
"data",
"collection",
"has",
"a",
"unique",
"name",
"that"... | python | train | 48.983871 |
saltstack/salt | salt/cloud/clouds/ec2.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/ec2.py#L3583-L3621 | def _extract_instance_info(instances):
'''
Given an instance query, return a dict of all instance data
'''
ret = {}
for instance in instances:
# items could be type dict or list (for stopped EC2 instances)
if isinstance(instance['instancesSet']['item'], list):
for item in... | [
"def",
"_extract_instance_info",
"(",
"instances",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"instance",
"in",
"instances",
":",
"# items could be type dict or list (for stopped EC2 instances)",
"if",
"isinstance",
"(",
"instance",
"[",
"'instancesSet'",
"]",
"[",
"'item... | Given an instance query, return a dict of all instance data | [
"Given",
"an",
"instance",
"query",
"return",
"a",
"dict",
"of",
"all",
"instance",
"data"
] | python | train | 37.487179 |
contentful-labs/contentful.py | contentful/cda/serialization.py | https://github.com/contentful-labs/contentful.py/blob/d9eb4a68abcad33e4766e2be8c7b35e605210b5a/contentful/cda/serialization.py#L118-L134 | def create_content_type(json):
"""Create :class:`.resource.ContentType` from JSON.
:param json: JSON dict.
:return: ContentType instance.
"""
result = ContentType(json['sys'])
for field in json['fields']:
field_id = field['id']
del field['id']
... | [
"def",
"create_content_type",
"(",
"json",
")",
":",
"result",
"=",
"ContentType",
"(",
"json",
"[",
"'sys'",
"]",
")",
"for",
"field",
"in",
"json",
"[",
"'fields'",
"]",
":",
"field_id",
"=",
"field",
"[",
"'id'",
"]",
"del",
"field",
"[",
"'id'",
... | Create :class:`.resource.ContentType` from JSON.
:param json: JSON dict.
:return: ContentType instance. | [
"Create",
":",
"class",
":",
".",
"resource",
".",
"ContentType",
"from",
"JSON",
"."
] | python | train | 27.058824 |
saltstack/salt | salt/modules/aliases.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L64-L106 | def __write_aliases_file(lines):
'''
Write a new copy of the aliases file. Lines is a list of lines
as returned by __parse_aliases.
'''
afn = __get_aliases_filename()
adir = os.path.dirname(afn)
out = tempfile.NamedTemporaryFile(dir=adir, delete=False)
if not __opts__.get('integration... | [
"def",
"__write_aliases_file",
"(",
"lines",
")",
":",
"afn",
"=",
"__get_aliases_filename",
"(",
")",
"adir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"afn",
")",
"out",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"dir",
"=",
"adir",
",",
"dele... | Write a new copy of the aliases file. Lines is a list of lines
as returned by __parse_aliases. | [
"Write",
"a",
"new",
"copy",
"of",
"the",
"aliases",
"file",
".",
"Lines",
"is",
"a",
"list",
"of",
"lines",
"as",
"returned",
"by",
"__parse_aliases",
"."
] | python | train | 31.511628 |
VIVelev/PyDojoML | dojo/cluster/kmeans.py | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/cluster/kmeans.py#L77-L102 | def fit(self, X):
"""The K-Means itself
"""
self._X = super().cluster(X)
candidates = []
for _ in range(self.n_runs):
self._init_random_centroids()
while True:
prev_clusters = self.clusters
self._assign_clusters()
... | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"_X",
"=",
"super",
"(",
")",
".",
"cluster",
"(",
"X",
")",
"candidates",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"n_runs",
")",
":",
"self",
".",
"_init_random_ce... | The K-Means itself | [
"The",
"K",
"-",
"Means",
"itself"
] | python | train | 28 |
ionelmc/python-cogen | cogen/core/proactors/epoll_impl.py | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/epoll_impl.py#L49-L83 | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of miliseconds (seconds/1000).
"""
ptimeout = int(timeout.microseconds/1000+timeout.... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"ptimeout",
"=",
"int",
"(",
"timeout",
".",
"microseconds",
"/",
"1000",
"+",
"timeout",
".",
"seconds",
"*",
"1000",
"if",
"timeout",
"else",
"(",
"self",
".",
"m_resolution",
"if",
"ti... | Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of miliseconds (seconds/1000). | [
"Run",
"a",
"proactor",
"loop",
"and",
"return",
"new",
"socket",
"events",
".",
"Timeout",
"is",
"a",
"timedelta",
"object",
"0",
"if",
"active",
"coros",
"or",
"None",
".",
"epoll",
"timeout",
"param",
"is",
"a",
"integer",
"number",
"of",
"miliseconds",... | python | train | 45.314286 |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2534-L2537 | def organization_membership_create(self, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/organization_memberships#create-membership"
api_path = "/api/v2/organization_memberships.json"
return self.call(api_path, method="POST", data=data, **kwargs) | [
"def",
"organization_membership_create",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/organization_memberships.json\"",
"return",
"self",
".",
"call",
"(",
"api_path",
",",
"method",
"=",
"\"POST\"",
",",
"data",
"=",
... | https://developer.zendesk.com/rest_api/docs/core/organization_memberships#create-membership | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"organization_memberships#create",
"-",
"membership"
] | python | train | 71.5 |
graphistry/pygraphistry | graphistry/plotter.py | https://github.com/graphistry/pygraphistry/blob/3dfc50e60232c6f5fedd6e5fa9d3048b606944b8/graphistry/plotter.py#L350-L381 | def pandas2igraph(self, edges, directed=True):
"""Convert a pandas edge dataframe to an IGraph graph.
Uses current bindings. Defaults to treating edges as directed.
**Example**
::
import graphistry
g = graphistry.bind()
es = pandas.... | [
"def",
"pandas2igraph",
"(",
"self",
",",
"edges",
",",
"directed",
"=",
"True",
")",
":",
"import",
"igraph",
"self",
".",
"_check_mandatory_bindings",
"(",
"False",
")",
"self",
".",
"_check_bound_attribs",
"(",
"edges",
",",
"[",
"'source'",
",",
"'destin... | Convert a pandas edge dataframe to an IGraph graph.
Uses current bindings. Defaults to treating edges as directed.
**Example**
::
import graphistry
g = graphistry.bind()
es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]})
... | [
"Convert",
"a",
"pandas",
"edge",
"dataframe",
"to",
"an",
"IGraph",
"graph",
"."
] | python | train | 37.125 |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L896-L907 | def img2img_transformer_tiny():
"""Tiny params."""
hparams = img2img_transformer2d_base()
hparams.num_hidden_layers = 2
hparams.hidden_size = 128
hparams.batch_size = 4
hparams.max_length = 128
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.filter_size = 128
hparams.num_... | [
"def",
"img2img_transformer_tiny",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_base",
"(",
")",
"hparams",
".",
"num_hidden_layers",
"=",
"2",
"hparams",
".",
"hidden_size",
"=",
"128",
"hparams",
".",
"batch_size",
"=",
"4",
"hparams",
".",
"max_lengt... | Tiny params. | [
"Tiny",
"params",
"."
] | python | train | 30 |
jedie/DragonPy | boot_dragonpy.py | https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L913-L956 | def create_environment(home_dir, site_packages=False, clear=False,
unzip_setuptools=False,
prompt=None, search_dirs=None, download=False,
no_setuptools=False, no_pip=False, no_wheel=False,
symlink=True):
"""
Creates a ne... | [
"def",
"create_environment",
"(",
"home_dir",
",",
"site_packages",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"unzip_setuptools",
"=",
"False",
",",
"prompt",
"=",
"None",
",",
"search_dirs",
"=",
"None",
",",
"download",
"=",
"False",
",",
"no_setuptoo... | Creates a new environment in ``home_dir``.
If ``site_packages`` is true, then the global ``site-packages/``
directory will be on the path.
If ``clear`` is true (default False) then the environment will
first be cleared. | [
"Creates",
"a",
"new",
"environment",
"in",
"home_dir",
"."
] | python | train | 28.113636 |
Azure/blobxfer | blobxfer/operations/resume.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/resume.py#L151-L189 | def add_or_update_record(
self, final_path, ase, chunk_size, next_integrity_chunk,
completed, md5):
# type: (DownloadResumeManager, pathlib.Path,
# blobxfer.models.azure.StorageEntity, int, int, bool,
# str) -> None
"""Add or update a resume record
... | [
"def",
"add_or_update_record",
"(",
"self",
",",
"final_path",
",",
"ase",
",",
"chunk_size",
",",
"next_integrity_chunk",
",",
"completed",
",",
"md5",
")",
":",
"# type: (DownloadResumeManager, pathlib.Path,",
"# blobxfer.models.azure.StorageEntity, int, int, bool,",
... | Add or update a resume record
:param DownloadResumeManager self: this
:param pathlib.Path final_path: final path
:param blobxfer.models.azure.StorageEntity ase: Storage Entity
:param int chunk_size: chunk size in bytes
:param int next_integrity_chunk: next integrity chunk
... | [
"Add",
"or",
"update",
"a",
"resume",
"record",
":",
"param",
"DownloadResumeManager",
"self",
":",
"this",
":",
"param",
"pathlib",
".",
"Path",
"final_path",
":",
"final",
"path",
":",
"param",
"blobxfer",
".",
"models",
".",
"azure",
".",
"StorageEntity",... | python | train | 41.794872 |
odlgroup/odl | odl/space/base_tensors.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/space/base_tensors.py#L907-L1006 | def show(self, title=None, method='', indices=None, force_show=False,
fig=None, **kwargs):
"""Display the function graphically.
Parameters
----------
title : string, optional
Set the title of the figure
method : string, optional
1d methods:
... | [
"def",
"show",
"(",
"self",
",",
"title",
"=",
"None",
",",
"method",
"=",
"''",
",",
"indices",
"=",
"None",
",",
"force_show",
"=",
"False",
",",
"fig",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"odl",
".",
"discr",
"import",
"uni... | Display the function graphically.
Parameters
----------
title : string, optional
Set the title of the figure
method : string, optional
1d methods:
``'plot'`` : graph plot
``'scatter'`` : scattered 2d points (2nd axis <-> value)
... | [
"Display",
"the",
"function",
"graphically",
"."
] | python | train | 39.27 |
edx/bok-choy | bok_choy/browser.py | https://github.com/edx/bok-choy/blob/cdd0d423419fc0c49d56a9226533aa1490b60afc/bok_choy/browser.py#L79-L104 | def save_source(driver, name):
"""
Save the rendered HTML of the browser.
The location of the source can be configured
by the environment variable `SAVED_SOURCE_DIR`. If not set,
this defaults to the current working directory.
Args:
driver (selenium.webdriver): The Selenium-controlled... | [
"def",
"save_source",
"(",
"driver",
",",
"name",
")",
":",
"source",
"=",
"driver",
".",
"page_source",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'SAVED_SOURCE_DIR'",
")",
",",
"'{name}.html'",
".",
... | Save the rendered HTML of the browser.
The location of the source can be configured
by the environment variable `SAVED_SOURCE_DIR`. If not set,
this defaults to the current working directory.
Args:
driver (selenium.webdriver): The Selenium-controlled browser.
name (str): A name to use... | [
"Save",
"the",
"rendered",
"HTML",
"of",
"the",
"browser",
"."
] | python | train | 34.269231 |
jkenlooper/chill | src/chill/operate.py | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L391-L481 | def operate_menu():
"Select between these operations on the database"
selection = True
while selection:
print globals()['operate_menu'].__doc__
selection = select([
'chill.database functions',
'execute sql file',
'render_node',
'New collectio... | [
"def",
"operate_menu",
"(",
")",
":",
"selection",
"=",
"True",
"while",
"selection",
":",
"print",
"globals",
"(",
")",
"[",
"'operate_menu'",
"]",
".",
"__doc__",
"selection",
"=",
"select",
"(",
"[",
"'chill.database functions'",
",",
"'execute sql file'",
... | Select between these operations on the database | [
"Select",
"between",
"these",
"operations",
"on",
"the",
"database"
] | python | train | 40.725275 |
rackerlabs/simpl | simpl/utils/cli.py | https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/utils/cli.py#L36-L49 | def error(self, message, print_help=False):
"""Provide a more helpful message if there are too few arguments."""
if 'too few arguments' in message.lower():
target = sys.argv.pop(0)
sys.argv.insert(
0, os.path.basename(target) or os.path.relpath(target))
... | [
"def",
"error",
"(",
"self",
",",
"message",
",",
"print_help",
"=",
"False",
")",
":",
"if",
"'too few arguments'",
"in",
"message",
".",
"lower",
"(",
")",
":",
"target",
"=",
"sys",
".",
"argv",
".",
"pop",
"(",
"0",
")",
"sys",
".",
"argv",
"."... | Provide a more helpful message if there are too few arguments. | [
"Provide",
"a",
"more",
"helpful",
"message",
"if",
"there",
"are",
"too",
"few",
"arguments",
"."
] | python | train | 41.785714 |
Ouranosinc/xclim | xclim/generic.py | https://github.com/Ouranosinc/xclim/blob/2080d139188bd8de2aeca097a025c2d89d6e0e09/xclim/generic.py#L247-L256 | def default_freq(**indexer):
"""Return the default frequency."""
freq = 'AS-JAN'
if indexer:
if 'DJF' in indexer.values():
freq = 'AS-DEC'
if 'month' in indexer and sorted(indexer.values()) != indexer.values():
raise (NotImplementedError)
return freq | [
"def",
"default_freq",
"(",
"*",
"*",
"indexer",
")",
":",
"freq",
"=",
"'AS-JAN'",
"if",
"indexer",
":",
"if",
"'DJF'",
"in",
"indexer",
".",
"values",
"(",
")",
":",
"freq",
"=",
"'AS-DEC'",
"if",
"'month'",
"in",
"indexer",
"and",
"sorted",
"(",
"... | Return the default frequency. | [
"Return",
"the",
"default",
"frequency",
"."
] | python | train | 29.8 |
NuGrid/NuGridPy | nugridpy/ppn.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/ppn.py#L813-L850 | def _getattr(self, attri, fname=None, numtype='cycNum'):
''' Private method for getting an attribute, called from get.'''
if str(fname.__class__)=="<type 'list'>":
isList=True
else:
isList=False
data=[]
if fname==None:
fname=self.files
... | [
"def",
"_getattr",
"(",
"self",
",",
"attri",
",",
"fname",
"=",
"None",
",",
"numtype",
"=",
"'cycNum'",
")",
":",
"if",
"str",
"(",
"fname",
".",
"__class__",
")",
"==",
"\"<type 'list'>\"",
":",
"isList",
"=",
"True",
"else",
":",
"isList",
"=",
"... | Private method for getting an attribute, called from get. | [
"Private",
"method",
"for",
"getting",
"an",
"attribute",
"called",
"from",
"get",
"."
] | python | train | 37.210526 |
gwastro/pycbc | pycbc/workflow/core.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/core.py#L54-L67 | def check_output_error_and_retcode(*popenargs, **kwargs):
"""
This function is used to obtain the stdout of a command. It is only used
internally, recommend using the make_external_call command if you want
to call external executables.
"""
if 'stdout' in kwargs:
raise ValueError('stdout ... | [
"def",
"check_output_error_and_retcode",
"(",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'stdout'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"'stdout argument not allowed, it will be overridden.'",
")",
"process",
"=",
"subprocess",
".",
"Po... | This function is used to obtain the stdout of a command. It is only used
internally, recommend using the make_external_call command if you want
to call external executables. | [
"This",
"function",
"is",
"used",
"to",
"obtain",
"the",
"stdout",
"of",
"a",
"command",
".",
"It",
"is",
"only",
"used",
"internally",
"recommend",
"using",
"the",
"make_external_call",
"command",
"if",
"you",
"want",
"to",
"call",
"external",
"executables",
... | python | train | 44.357143 |
mikeboers/Flask-ACL | flask_acl/extension.py | https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/extension.py#L116-L144 | def route_acl(self, *acl, **options):
"""Decorator to attach an ACL to a route.
E.g::
@app.route('/url/to/view')
@authz.route_acl('''
ALLOW WHEEL ALL
DENY ANY ALL
''')
def my_admin_function():
pa... | [
"def",
"route_acl",
"(",
"self",
",",
"*",
"acl",
",",
"*",
"*",
"options",
")",
":",
"def",
"_route_acl",
"(",
"func",
")",
":",
"func",
".",
"__acl__",
"=",
"acl",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"a... | Decorator to attach an ACL to a route.
E.g::
@app.route('/url/to/view')
@authz.route_acl('''
ALLOW WHEEL ALL
DENY ANY ALL
''')
def my_admin_function():
pass | [
"Decorator",
"to",
"attach",
"an",
"ACL",
"to",
"a",
"route",
"."
] | python | train | 28.034483 |
moluwole/Bast | bast/migration.py | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/migration.py#L102-L125 | def check_packages(db_name):
"""
Check if the driver for the user defined host is available. If it is not available, download it using PIP
:param db_name:
:return:
"""
print('Checking for required Database Driver')
reqs = subprocess.check_output([sys.executable, ... | [
"def",
"check_packages",
"(",
"db_name",
")",
":",
"print",
"(",
"'Checking for required Database Driver'",
")",
"reqs",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"sys",
".",
"executable",
",",
"'-m'",
",",
"'pip'",
",",
"'freeze'",
"]",
")",
"installe... | Check if the driver for the user defined host is available. If it is not available, download it using PIP
:param db_name:
:return: | [
"Check",
"if",
"the",
"driver",
"for",
"the",
"user",
"defined",
"host",
"is",
"available",
".",
"If",
"it",
"is",
"not",
"available",
"download",
"it",
"using",
"PIP",
":",
"param",
"db_name",
":",
":",
"return",
":"
] | python | train | 36.75 |
miguelgrinberg/python-socketio | socketio/server.py | https://github.com/miguelgrinberg/python-socketio/blob/c0c1bf8d21e3597389b18938550a0724dd9676b7/socketio/server.py#L377-L391 | def get_session(self, sid, namespace=None):
"""Return the user session for a client.
:param sid: The session id of the client.
:param namespace: The Socket.IO namespace. If this argument is omitted
the default namespace is used.
The return value is a dictionar... | [
"def",
"get_session",
"(",
"self",
",",
"sid",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"namespace",
"or",
"'/'",
"eio_session",
"=",
"self",
".",
"eio",
".",
"get_session",
"(",
"sid",
")",
"return",
"eio_session",
".",
"setdefault",
"... | Return the user session for a client.
:param sid: The session id of the client.
:param namespace: The Socket.IO namespace. If this argument is omitted
the default namespace is used.
The return value is a dictionary. Modifications made to this
dictionary are no... | [
"Return",
"the",
"user",
"session",
"for",
"a",
"client",
"."
] | python | train | 42.733333 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L118-L125 | def local_manager_rule(self):
"""Return rule for local manager.
"""
adm_gid = self.local_manager_gid
if not adm_gid:
return None
config = self.root['settings']['ugm_localmanager'].attrs
return config[adm_gid] | [
"def",
"local_manager_rule",
"(",
"self",
")",
":",
"adm_gid",
"=",
"self",
".",
"local_manager_gid",
"if",
"not",
"adm_gid",
":",
"return",
"None",
"config",
"=",
"self",
".",
"root",
"[",
"'settings'",
"]",
"[",
"'ugm_localmanager'",
"]",
".",
"attrs",
"... | Return rule for local manager. | [
"Return",
"rule",
"for",
"local",
"manager",
"."
] | python | train | 32.625 |
broadinstitute/fiss | firecloud/fiss.py | https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L1163-L1167 | def health(args):
""" Health FireCloud Server """
r = fapi.health()
fapi._check_response_code(r, 200)
return r.content | [
"def",
"health",
"(",
"args",
")",
":",
"r",
"=",
"fapi",
".",
"health",
"(",
")",
"fapi",
".",
"_check_response_code",
"(",
"r",
",",
"200",
")",
"return",
"r",
".",
"content"
] | Health FireCloud Server | [
"Health",
"FireCloud",
"Server"
] | python | train | 26 |
earlzo/hfut | examples/curriculum_calendar.py | https://github.com/earlzo/hfut/blob/09270a9647fba79f26fd1a8a3c53c0678b5257a1/examples/curriculum_calendar.py#L14-L47 | def schedule2calendar(schedule, name='课表', using_todo=True):
"""
将上课时间表转换为 icalendar
:param schedule: 上课时间表
:param name: 日历名称
:param using_todo: 使用 ``icalendar.Todo`` 而不是 ``icalendar.Event`` 作为活动类
:return: icalendar.Calendar()
"""
# https://zh.wikipedia.org/wiki/ICalendar
# http://i... | [
"def",
"schedule2calendar",
"(",
"schedule",
",",
"name",
"=",
"'课表', us",
"i",
"g_todo=Tru",
"e",
"):",
"",
"",
"# https://zh.wikipedia.org/wiki/ICalendar",
"# http://icalendar.readthedocs.io/en/latest",
"# https://tools.ietf.org/html/rfc5545",
"cal",
"=",
"icalendar",
".",
... | 将上课时间表转换为 icalendar
:param schedule: 上课时间表
:param name: 日历名称
:param using_todo: 使用 ``icalendar.Todo`` 而不是 ``icalendar.Event`` 作为活动类
:return: icalendar.Calendar() | [
"将上课时间表转换为",
"icalendar"
] | python | train | 36.735294 |
polysquare/polysquare-generic-file-linter | polysquarelinter/spelling.py | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L61-L68 | def clear_caches(): # suppress(unused-function)
"""Clear all caches."""
for _, reader in _spellchecker_cache.values():
reader.close()
_spellchecker_cache.clear()
_valid_words_cache.clear()
_user_dictionary_cache.clear() | [
"def",
"clear_caches",
"(",
")",
":",
"# suppress(unused-function)",
"for",
"_",
",",
"reader",
"in",
"_spellchecker_cache",
".",
"values",
"(",
")",
":",
"reader",
".",
"close",
"(",
")",
"_spellchecker_cache",
".",
"clear",
"(",
")",
"_valid_words_cache",
".... | Clear all caches. | [
"Clear",
"all",
"caches",
"."
] | python | train | 30.25 |
rm-hull/luma.core | luma/core/legacy/__init__.py | https://github.com/rm-hull/luma.core/blob/034b628fb304a01e77732a299c0b42e94d6443db/luma/core/legacy/__init__.py#L33-L58 | def text(draw, xy, txt, fill=None, font=None):
"""
Draw a legacy font starting at :py:attr:`x`, :py:attr:`y` using the
prescribed fill and font.
:param draw: A valid canvas to draw the text onto.
:type draw: PIL.ImageDraw
:param txt: The text string to display (must be ASCII only).
:type tx... | [
"def",
"text",
"(",
"draw",
",",
"xy",
",",
"txt",
",",
"fill",
"=",
"None",
",",
"font",
"=",
"None",
")",
":",
"font",
"=",
"font",
"or",
"DEFAULT_FONT",
"x",
",",
"y",
"=",
"xy",
"for",
"ch",
"in",
"txt",
":",
"for",
"byte",
"in",
"font",
... | Draw a legacy font starting at :py:attr:`x`, :py:attr:`y` using the
prescribed fill and font.
:param draw: A valid canvas to draw the text onto.
:type draw: PIL.ImageDraw
:param txt: The text string to display (must be ASCII only).
:type txt: str
:param xy: An ``(x, y)`` tuple denoting the top-... | [
"Draw",
"a",
"legacy",
"font",
"starting",
"at",
":",
"py",
":",
"attr",
":",
"x",
":",
"py",
":",
"attr",
":",
"y",
"using",
"the",
"prescribed",
"fill",
"and",
"font",
"."
] | python | train | 32.692308 |
CI-WATER/gsshapy | gsshapy/orm/evt.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/evt.py#L115-L120 | def as_yml(self):
"""
Return yml compatible version of self
"""
return YmlFileEvent(name=str(self.name),
subfolder=str(self.subfolder)) | [
"def",
"as_yml",
"(",
"self",
")",
":",
"return",
"YmlFileEvent",
"(",
"name",
"=",
"str",
"(",
"self",
".",
"name",
")",
",",
"subfolder",
"=",
"str",
"(",
"self",
".",
"subfolder",
")",
")"
] | Return yml compatible version of self | [
"Return",
"yml",
"compatible",
"version",
"of",
"self"
] | python | train | 31.666667 |
eaton-lab/toytree | toytree/etemini.py | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L241-L274 | def add_child(self, child=None, name=None, dist=None, support=None):
"""
Adds a new child to this node. If child node is not suplied
as an argument, a new node instance will be created.
Parameters
----------
child:
the node instance to be added as a... | [
"def",
"add_child",
"(",
"self",
",",
"child",
"=",
"None",
",",
"name",
"=",
"None",
",",
"dist",
"=",
"None",
",",
"support",
"=",
"None",
")",
":",
"if",
"child",
"is",
"None",
":",
"child",
"=",
"self",
".",
"__class__",
"(",
")",
"if",
"name... | Adds a new child to this node. If child node is not suplied
as an argument, a new node instance will be created.
Parameters
----------
child:
the node instance to be added as a child.
name:
the name that will be given to the child.
dist... | [
"Adds",
"a",
"new",
"child",
"to",
"this",
"node",
".",
"If",
"child",
"node",
"is",
"not",
"suplied",
"as",
"an",
"argument",
"a",
"new",
"node",
"instance",
"will",
"be",
"created",
".",
"Parameters",
"----------"
] | python | train | 26.911765 |
zsimic/runez | src/runez/click.py | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L70-L76 | def version(*args, **attrs):
"""Show the version and exit."""
if hasattr(sys, "_getframe"):
package = attrs.pop("package", sys._getframe(1).f_globals.get("__package__"))
if package:
attrs.setdefault("version", get_version(package))
return click.version_option(*args, **attrs) | [
"def",
"version",
"(",
"*",
"args",
",",
"*",
"*",
"attrs",
")",
":",
"if",
"hasattr",
"(",
"sys",
",",
"\"_getframe\"",
")",
":",
"package",
"=",
"attrs",
".",
"pop",
"(",
"\"package\"",
",",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_globals... | Show the version and exit. | [
"Show",
"the",
"version",
"and",
"exit",
"."
] | python | train | 44.142857 |
gwastro/pycbc | pycbc/inference/models/base.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/base.py#L577-L607 | def prior_rvs(self, size=1, prior=None):
"""Returns random variates drawn from the prior.
If the ``sampling_params`` are different from the ``variable_params``,
the variates are transformed to the `sampling_params` parameter space
before being returned.
Parameters
-----... | [
"def",
"prior_rvs",
"(",
"self",
",",
"size",
"=",
"1",
",",
"prior",
"=",
"None",
")",
":",
"# draw values from the prior",
"if",
"prior",
"is",
"None",
":",
"prior",
"=",
"self",
".",
"prior_distribution",
"p0",
"=",
"prior",
".",
"rvs",
"(",
"size",
... | Returns random variates drawn from the prior.
If the ``sampling_params`` are different from the ``variable_params``,
the variates are transformed to the `sampling_params` parameter space
before being returned.
Parameters
----------
size : int, optional
Numbe... | [
"Returns",
"random",
"variates",
"drawn",
"from",
"the",
"prior",
"."
] | python | train | 37.741935 |
opendatateam/udata | udata/models/__init__.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/models/__init__.py#L60-L79 | def resolve_model(self, model):
'''
Resolve a model given a name or dict with `class` entry.
:raises ValueError: model specification is wrong or does not exists
'''
if not model:
raise ValueError('Unsupported model specifications')
if isinstance(model, basest... | [
"def",
"resolve_model",
"(",
"self",
",",
"model",
")",
":",
"if",
"not",
"model",
":",
"raise",
"ValueError",
"(",
"'Unsupported model specifications'",
")",
"if",
"isinstance",
"(",
"model",
",",
"basestring",
")",
":",
"classname",
"=",
"model",
"elif",
"... | Resolve a model given a name or dict with `class` entry.
:raises ValueError: model specification is wrong or does not exists | [
"Resolve",
"a",
"model",
"given",
"a",
"name",
"or",
"dict",
"with",
"class",
"entry",
"."
] | python | train | 35.65 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/runsnakerun/listviews.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/listviews.py#L227-L236 | def reorder(self, single_column=False):
"""Force a reorder of the displayed items"""
if single_column:
columns = self.sortOrder[:1]
else:
columns = self.sortOrder
for ascending,column in columns[::-1]:
# Python 2.2+ guarantees stable sort, so sort by e... | [
"def",
"reorder",
"(",
"self",
",",
"single_column",
"=",
"False",
")",
":",
"if",
"single_column",
":",
"columns",
"=",
"self",
".",
"sortOrder",
"[",
":",
"1",
"]",
"else",
":",
"columns",
"=",
"self",
".",
"sortOrder",
"for",
"ascending",
",",
"colu... | Force a reorder of the displayed items | [
"Force",
"a",
"reorder",
"of",
"the",
"displayed",
"items"
] | python | train | 46 |
brocade/pynos | pynos/versions/base/yang/brocade_ras.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_ras.py#L293-L304 | def bna_config_cmd_output_status_string(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
bna_config_cmd = ET.Element("bna_config_cmd")
config = bna_config_cmd
output = ET.SubElement(bna_config_cmd, "output")
status_string = ET.SubElement(o... | [
"def",
"bna_config_cmd_output_status_string",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"bna_config_cmd",
"=",
"ET",
".",
"Element",
"(",
"\"bna_config_cmd\"",
")",
"config",
"=",
"bna_config_c... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 40 |
BerkeleyAutomation/autolab_core | autolab_core/learning_analysis.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L515-L541 | def accuracy_curve(self, delta_tau=0.01):
""" Computes the relationship between probability threshold
and classification accuracy. """
# compute thresholds based on the sorted probabilities
orig_thresh = self.threshold
sorted_labels, sorted_probs = self.sorted_values
sco... | [
"def",
"accuracy_curve",
"(",
"self",
",",
"delta_tau",
"=",
"0.01",
")",
":",
"# compute thresholds based on the sorted probabilities",
"orig_thresh",
"=",
"self",
".",
"threshold",
"sorted_labels",
",",
"sorted_probs",
"=",
"self",
".",
"sorted_values",
"scores",
"=... | Computes the relationship between probability threshold
and classification accuracy. | [
"Computes",
"the",
"relationship",
"between",
"probability",
"threshold",
"and",
"classification",
"accuracy",
"."
] | python | train | 29.222222 |
saltstack/salt | salt/runners/net.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/net.py#L183-L213 | def _find_interfaces_ip(mac):
'''
Helper to search the interfaces IPs using the MAC address.
'''
try:
mac = napalm_helpers.convert(napalm_helpers.mac, mac)
except AddrFormatError:
return ('', '', [])
all_interfaces = _get_mine('net.interfaces')
all_ipaddrs = _get_mine('net.i... | [
"def",
"_find_interfaces_ip",
"(",
"mac",
")",
":",
"try",
":",
"mac",
"=",
"napalm_helpers",
".",
"convert",
"(",
"napalm_helpers",
".",
"mac",
",",
"mac",
")",
"except",
"AddrFormatError",
":",
"return",
"(",
"''",
",",
"''",
",",
"[",
"]",
")",
"all... | Helper to search the interfaces IPs using the MAC address. | [
"Helper",
"to",
"search",
"the",
"interfaces",
"IPs",
"using",
"the",
"MAC",
"address",
"."
] | python | train | 42.483871 |
saltstack/salt | salt/states/onyx.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/onyx.py#L153-L197 | def user_absent(name):
'''
Ensure a user is not present
name
username to remove if it exists
Examples:
.. code-block:: yaml
delete:
onyx.user_absent:
- name: daniel
'''
ret = {'name': name,
'result': False,
'changes': {},
... | [
"def",
"user_absent",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"old_user",
"=",
"__salt__",
"[",
"'onyx.cmd'",
"]",
"(",
"'get_use... | Ensure a user is not present
name
username to remove if it exists
Examples:
.. code-block:: yaml
delete:
onyx.user_absent:
- name: daniel | [
"Ensure",
"a",
"user",
"is",
"not",
"present"
] | python | train | 22.844444 |
stuaxo/vext | setup.py | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L151-L197 | def package_info(self):
"""
:return: list of package info on installed packages
"""
import subprocess
# create a commandline like pip show Pillow show
package_names = self.installed_packages()
if not package_names:
# No installed packages yet, so noth... | [
"def",
"package_info",
"(",
"self",
")",
":",
"import",
"subprocess",
"# create a commandline like pip show Pillow show",
"package_names",
"=",
"self",
".",
"installed_packages",
"(",
")",
"if",
"not",
"package_names",
":",
"# No installed packages yet, so nothign to do here... | :return: list of package info on installed packages | [
":",
"return",
":",
"list",
"of",
"package",
"info",
"on",
"installed",
"packages"
] | python | train | 34.978723 |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/namespacebrowser.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L153-L171 | def setup_toolbar(self):
"""Setup toolbar"""
load_button = create_toolbutton(self, text=_('Import data'),
icon=ima.icon('fileimport'),
triggered=lambda: self.import_data())
self.save_button = create_toolbutton(s... | [
"def",
"setup_toolbar",
"(",
"self",
")",
":",
"load_button",
"=",
"create_toolbutton",
"(",
"self",
",",
"text",
"=",
"_",
"(",
"'Import data'",
")",
",",
"icon",
"=",
"ima",
".",
"icon",
"(",
"'fileimport'",
")",
",",
"triggered",
"=",
"lambda",
":",
... | Setup toolbar | [
"Setup",
"toolbar"
] | python | train | 55.894737 |
olitheolix/qtmacs | qtmacs/qtmacsmain_macros.py | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain_macros.py#L254-L277 | def qteStartRecordingHook(self, msgObj):
"""
Commence macro recording.
Macros are recorded by connecting to the 'keypressed' signal
it emits.
If the recording has already commenced, or if this method was
called during a macro replay, then return immediately.
"""... | [
"def",
"qteStartRecordingHook",
"(",
"self",
",",
"msgObj",
")",
":",
"if",
"self",
".",
"qteRecording",
":",
"self",
".",
"qteMain",
".",
"qteStatus",
"(",
"'Macro recording already enabled'",
")",
"return",
"# Update status flag.",
"self",
".",
"qteRecording",
"... | Commence macro recording.
Macros are recorded by connecting to the 'keypressed' signal
it emits.
If the recording has already commenced, or if this method was
called during a macro replay, then return immediately. | [
"Commence",
"macro",
"recording",
"."
] | python | train | 33.916667 |
collectiveacuity/labPack | labpack/storage/google/drive.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L376-L392 | def _walk(self, root_path='', root_id=''):
''' a generator method which walks the file structure of the dropbox collection '''
title = '%s._walk' % self.__class__.__name__
if root_id:
pass
elif root_path:
root_id, root_parent = self._get... | [
"def",
"_walk",
"(",
"self",
",",
"root_path",
"=",
"''",
",",
"root_id",
"=",
"''",
")",
":",
"title",
"=",
"'%s._walk'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"if",
"root_id",
":",
"pass",
"elif",
"root_path",
":",
"root_id",
",",
"root_par... | a generator method which walks the file structure of the dropbox collection | [
"a",
"generator",
"method",
"which",
"walks",
"the",
"file",
"structure",
"of",
"the",
"dropbox",
"collection"
] | python | train | 40.176471 |
pandas-dev/pandas | pandas/io/html.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/html.py#L375-L420 | def _parse_thead_tbody_tfoot(self, table_html):
"""
Given a table, return parsed header, body, and foot.
Parameters
----------
table_html : node-like
Returns
-------
tuple of (header, body, footer), each a list of list-of-text rows.
Notes
... | [
"def",
"_parse_thead_tbody_tfoot",
"(",
"self",
",",
"table_html",
")",
":",
"header_rows",
"=",
"self",
".",
"_parse_thead_tr",
"(",
"table_html",
")",
"body_rows",
"=",
"self",
".",
"_parse_tbody_tr",
"(",
"table_html",
")",
"footer_rows",
"=",
"self",
".",
... | Given a table, return parsed header, body, and foot.
Parameters
----------
table_html : node-like
Returns
-------
tuple of (header, body, footer), each a list of list-of-text rows.
Notes
-----
Header and body are lists-of-lists. Top level list i... | [
"Given",
"a",
"table",
"return",
"parsed",
"header",
"body",
"and",
"foot",
"."
] | python | train | 36.065217 |
frascoweb/frasco | frasco/actions/loaders.py | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/loaders.py#L70-L84 | def create_action_from_dict(name, spec, base_class=ActionsAction, metaclass=type, pop_keys=False):
"""Creates an action class based on a dict loaded using load_grouped_actions()
"""
actions = load_grouped_actions(spec, pop_keys=pop_keys)
attrs = {"actions": actions, "name": name}
if "as" in spec:
... | [
"def",
"create_action_from_dict",
"(",
"name",
",",
"spec",
",",
"base_class",
"=",
"ActionsAction",
",",
"metaclass",
"=",
"type",
",",
"pop_keys",
"=",
"False",
")",
":",
"actions",
"=",
"load_grouped_actions",
"(",
"spec",
",",
"pop_keys",
"=",
"pop_keys",
... | Creates an action class based on a dict loaded using load_grouped_actions() | [
"Creates",
"an",
"action",
"class",
"based",
"on",
"a",
"dict",
"loaded",
"using",
"load_grouped_actions",
"()"
] | python | train | 40.533333 |
hosford42/xcs | xcs/algorithms/xcs.py | https://github.com/hosford42/xcs/blob/183bdd0dd339e19ded3be202f86e1b38bdb9f1e5/xcs/algorithms/xcs.py#L779-L813 | def _action_set_subsumption(self, action_set):
"""Perform action set subsumption."""
# Select a condition with maximum bit count among those having
# sufficient experience and sufficiently low error.
selected_rule = None
selected_bit_count = None
for rule in action_set:
... | [
"def",
"_action_set_subsumption",
"(",
"self",
",",
"action_set",
")",
":",
"# Select a condition with maximum bit count among those having",
"# sufficient experience and sufficiently low error.",
"selected_rule",
"=",
"None",
"selected_bit_count",
"=",
"None",
"for",
"rule",
"in... | Perform action set subsumption. | [
"Perform",
"action",
"set",
"subsumption",
"."
] | python | train | 43.114286 |
Microsoft/knack | knack/deprecation.py | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/deprecation.py#L127-L131 | def _version_less_than_or_equal_to(self, v1, v2):
""" Returns true if v1 <= v2. """
# pylint: disable=no-name-in-module, import-error
from distutils.version import LooseVersion
return LooseVersion(v1) <= LooseVersion(v2) | [
"def",
"_version_less_than_or_equal_to",
"(",
"self",
",",
"v1",
",",
"v2",
")",
":",
"# pylint: disable=no-name-in-module, import-error",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"return",
"LooseVersion",
"(",
"v1",
")",
"<=",
"LooseVersion",
"(... | Returns true if v1 <= v2. | [
"Returns",
"true",
"if",
"v1",
"<",
"=",
"v2",
"."
] | python | train | 49.6 |
noahbenson/pimms | pimms/util.py | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L282-L289 | def is_str(arg):
'''
is_str(x) yields True if x is a string object or a 0-dim numpy array of a string and yields
False otherwise.
'''
return (isinstance(arg, six.string_types) or
is_npscalar(arg, 'string') or
is_npvalue(arg, 'string')) | [
"def",
"is_str",
"(",
"arg",
")",
":",
"return",
"(",
"isinstance",
"(",
"arg",
",",
"six",
".",
"string_types",
")",
"or",
"is_npscalar",
"(",
"arg",
",",
"'string'",
")",
"or",
"is_npvalue",
"(",
"arg",
",",
"'string'",
")",
")"
] | is_str(x) yields True if x is a string object or a 0-dim numpy array of a string and yields
False otherwise. | [
"is_str",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"string",
"object",
"or",
"a",
"0",
"-",
"dim",
"numpy",
"array",
"of",
"a",
"string",
"and",
"yields",
"False",
"otherwise",
"."
] | python | train | 34.375 |
hotdoc/hotdoc | hotdoc/core/tree.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/tree.py#L577-L595 | def resolve_symbols(self, database, link_resolver, page=None):
"""Will call resolve_symbols on all the stale subpages of the tree.
Args:
page: hotdoc.core.tree.Page, the page to resolve symbols in,
will recurse on potential subpages.
"""
page = page or self.root
... | [
"def",
"resolve_symbols",
"(",
"self",
",",
"database",
",",
"link_resolver",
",",
"page",
"=",
"None",
")",
":",
"page",
"=",
"page",
"or",
"self",
".",
"root",
"if",
"page",
".",
"ast",
"is",
"None",
"and",
"not",
"page",
".",
"generated",
":",
"wi... | Will call resolve_symbols on all the stale subpages of the tree.
Args:
page: hotdoc.core.tree.Page, the page to resolve symbols in,
will recurse on potential subpages. | [
"Will",
"call",
"resolve_symbols",
"on",
"all",
"the",
"stale",
"subpages",
"of",
"the",
"tree",
".",
"Args",
":",
"page",
":",
"hotdoc",
".",
"core",
".",
"tree",
".",
"Page",
"the",
"page",
"to",
"resolve",
"symbols",
"in",
"will",
"recurse",
"on",
"... | python | train | 39.631579 |
romana/vpc-router | vpcrouter/currentstate/__init__.py | https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/currentstate/__init__.py#L87-L124 | def get_state_repr(self, path):
"""
Returns the current state, or sub-state, depending on the path.
"""
if path == "ips":
return {
"failed_ips" : self.failed_ips,
"questionable_ips" : self.questionable_ips,
"working_set" ... | [
"def",
"get_state_repr",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"==",
"\"ips\"",
":",
"return",
"{",
"\"failed_ips\"",
":",
"self",
".",
"failed_ips",
",",
"\"questionable_ips\"",
":",
"self",
".",
"questionable_ips",
",",
"\"working_set\"",
":",
... | Returns the current state, or sub-state, depending on the path. | [
"Returns",
"the",
"current",
"state",
"or",
"sub",
"-",
"state",
"depending",
"on",
"the",
"path",
"."
] | python | train | 33.026316 |
gabrielfalcao/dominic | dominic/xpath/expr.py | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L681-L704 | def merge_into_nodeset(target, source):
"""Place all the nodes from the source node-set into the target
node-set, preserving document order. Both node-sets must be in
document order to begin with.
"""
if len(target) == 0:
target.extend(source)
return
source = [n for n in sourc... | [
"def",
"merge_into_nodeset",
"(",
"target",
",",
"source",
")",
":",
"if",
"len",
"(",
"target",
")",
"==",
"0",
":",
"target",
".",
"extend",
"(",
"source",
")",
"return",
"source",
"=",
"[",
"n",
"for",
"n",
"in",
"source",
"if",
"n",
"not",
"in"... | Place all the nodes from the source node-set into the target
node-set, preserving document order. Both node-sets must be in
document order to begin with. | [
"Place",
"all",
"the",
"nodes",
"from",
"the",
"source",
"node",
"-",
"set",
"into",
"the",
"target",
"node",
"-",
"set",
"preserving",
"document",
"order",
".",
"Both",
"node",
"-",
"sets",
"must",
"be",
"in",
"document",
"order",
"to",
"begin",
"with",... | python | train | 36.583333 |
apple/turicreate | src/unity/python/turicreate/toolkits/clustering/dbscan.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/clustering/dbscan.py#L24-L322 | def create(dataset, features=None, distance=None, radius=1.,
min_core_neighbors=10, verbose=True):
"""
Create a DBSCAN clustering model. The DBSCAN method partitions the input
dataset into three types of points, based on the estimated probability
density at each point.
- **Core** points ... | [
"def",
"create",
"(",
"dataset",
",",
"features",
"=",
"None",
",",
"distance",
"=",
"None",
",",
"radius",
"=",
"1.",
",",
"min_core_neighbors",
"=",
"10",
",",
"verbose",
"=",
"True",
")",
":",
"## Start the training time clock and instantiate an empty model",
... | Create a DBSCAN clustering model. The DBSCAN method partitions the input
dataset into three types of points, based on the estimated probability
density at each point.
- **Core** points have a large number of points within a given neighborhood.
Specifically, `min_core_neighbors` must be within distanc... | [
"Create",
"a",
"DBSCAN",
"clustering",
"model",
".",
"The",
"DBSCAN",
"method",
"partitions",
"the",
"input",
"dataset",
"into",
"three",
"types",
"of",
"points",
"based",
"on",
"the",
"estimated",
"probability",
"density",
"at",
"each",
"point",
"."
] | python | train | 41.839465 |
zhanglab/psamm | psamm/fastcore.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L147-L153 | def flip(self, reactions):
"""Flip the specified reactions."""
for reaction in reactions:
if reaction in self._flipped:
self._flipped.remove(reaction)
else:
self._flipped.add(reaction) | [
"def",
"flip",
"(",
"self",
",",
"reactions",
")",
":",
"for",
"reaction",
"in",
"reactions",
":",
"if",
"reaction",
"in",
"self",
".",
"_flipped",
":",
"self",
".",
"_flipped",
".",
"remove",
"(",
"reaction",
")",
"else",
":",
"self",
".",
"_flipped",... | Flip the specified reactions. | [
"Flip",
"the",
"specified",
"reactions",
"."
] | python | train | 35.714286 |
saltstack/salt | salt/modules/openbsdrcctl_service.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/openbsdrcctl_service.py#L54-L67 | def available(name):
'''
Return True if the named service is available.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd
'''
cmd = '{0} get {1}'.format(_cmd(), name)
if __salt__['cmd.retcode'](cmd) == 2:
return False
return True | [
"def",
"available",
"(",
"name",
")",
":",
"cmd",
"=",
"'{0} get {1}'",
".",
"format",
"(",
"_cmd",
"(",
")",
",",
"name",
")",
"if",
"__salt__",
"[",
"'cmd.retcode'",
"]",
"(",
"cmd",
")",
"==",
"2",
":",
"return",
"False",
"return",
"True"
] | Return True if the named service is available.
CLI Example:
.. code-block:: bash
salt '*' service.available sshd | [
"Return",
"True",
"if",
"the",
"named",
"service",
"is",
"available",
"."
] | python | train | 20.214286 |
jepegit/cellpy | cellpy/readers/cellreader.py | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/cellreader.py#L342-L365 | def set_raw_datadir(self, directory=None):
"""Set the directory containing .res-files.
Used for setting directory for looking for res-files.@
A valid directory name is required.
Args:
directory (str): path to res-directory
Example:
>>> d = CellpyData()
... | [
"def",
"set_raw_datadir",
"(",
"self",
",",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"is",
"None",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"no directory name given\"",
")",
"return",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"("... | Set the directory containing .res-files.
Used for setting directory for looking for res-files.@
A valid directory name is required.
Args:
directory (str): path to res-directory
Example:
>>> d = CellpyData()
>>> directory = "MyData/Arbindata"
... | [
"Set",
"the",
"directory",
"containing",
".",
"res",
"-",
"files",
"."
] | python | train | 29.208333 |
alephdata/memorious | memorious/operations/fetch.py | https://github.com/alephdata/memorious/blob/b4033c5064447ed5f696f9c2bbbc6c12062d2fa4/memorious/operations/fetch.py#L44-L71 | def dav_index(context, data):
"""List files in a WebDAV directory."""
# This is made to work with ownCloud/nextCloud, but some rumor has
# it they are "standards compliant" and it should thus work for
# other DAV servers.
url = data.get('url')
result = context.http.request('PROPFIND', url)
f... | [
"def",
"dav_index",
"(",
"context",
",",
"data",
")",
":",
"# This is made to work with ownCloud/nextCloud, but some rumor has",
"# it they are \"standards compliant\" and it should thus work for",
"# other DAV servers.",
"url",
"=",
"data",
".",
"get",
"(",
"'url'",
")",
"resu... | List files in a WebDAV directory. | [
"List",
"files",
"in",
"a",
"WebDAV",
"directory",
"."
] | python | train | 34.142857 |
bxlab/bx-python | lib/bx/wiggle.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/wiggle.py#L14-L63 | def IntervalReader( f ):
"""
Iterator yielding chrom, start, end, strand, value.
Values are zero-based, half-open.
Regions which lack a score are ignored.
"""
current_chrom = None
current_pos = None
current_step = None
# always for wiggle data
strand = '+'
mode = "bed"
... | [
"def",
"IntervalReader",
"(",
"f",
")",
":",
"current_chrom",
"=",
"None",
"current_pos",
"=",
"None",
"current_step",
"=",
"None",
"# always for wiggle data",
"strand",
"=",
"'+'",
"mode",
"=",
"\"bed\"",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
... | Iterator yielding chrom, start, end, strand, value.
Values are zero-based, half-open.
Regions which lack a score are ignored. | [
"Iterator",
"yielding",
"chrom",
"start",
"end",
"strand",
"value",
".",
"Values",
"are",
"zero",
"-",
"based",
"half",
"-",
"open",
".",
"Regions",
"which",
"lack",
"a",
"score",
"are",
"ignored",
"."
] | python | train | 38.98 |
Unity-Technologies/ml-agents | ml-agents/mlagents/trainers/trainer_metrics.py | https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/trainer_metrics.py#L51-L58 | def add_delta_step(self, delta: float):
"""
Inform Metrics class about time to step in environment.
"""
if self.delta_last_experience_collection:
self.delta_last_experience_collection += delta
else:
self.delta_last_experience_collection = delta | [
"def",
"add_delta_step",
"(",
"self",
",",
"delta",
":",
"float",
")",
":",
"if",
"self",
".",
"delta_last_experience_collection",
":",
"self",
".",
"delta_last_experience_collection",
"+=",
"delta",
"else",
":",
"self",
".",
"delta_last_experience_collection",
"=",... | Inform Metrics class about time to step in environment. | [
"Inform",
"Metrics",
"class",
"about",
"time",
"to",
"step",
"in",
"environment",
"."
] | python | train | 37.625 |
angr/angr | angr/state_plugins/abstract_memory.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/abstract_memory.py#L68-L87 | def get_abstract_locations(self, addr, size):
"""
Get a list of abstract locations that is within the range of [addr, addr + size]
This implementation is pretty slow. But since this method won't be called frequently, we can live with the bad
implementation for now.
:param addr:... | [
"def",
"get_abstract_locations",
"(",
"self",
",",
"addr",
",",
"size",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"aloc",
"in",
"self",
".",
"_alocs",
".",
"values",
"(",
")",
":",
"for",
"seg",
"in",
"aloc",
".",
"segments",
":",
"if",
"seg",
".",
... | Get a list of abstract locations that is within the range of [addr, addr + size]
This implementation is pretty slow. But since this method won't be called frequently, we can live with the bad
implementation for now.
:param addr: Starting address of the memory region.
:param size: ... | [
"Get",
"a",
"list",
"of",
"abstract",
"locations",
"that",
"is",
"within",
"the",
"range",
"of",
"[",
"addr",
"addr",
"+",
"size",
"]"
] | python | train | 38.45 |
eumis/pyviews | pyviews/binding/implementations.py | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/binding/implementations.py#L37-L42 | def destroy(self):
'''Unsubscribes callback from observable'''
self._observable.release(self._key, self._callback)
self._observable = None
self._key = None
self._callback = None | [
"def",
"destroy",
"(",
"self",
")",
":",
"self",
".",
"_observable",
".",
"release",
"(",
"self",
".",
"_key",
",",
"self",
".",
"_callback",
")",
"self",
".",
"_observable",
"=",
"None",
"self",
".",
"_key",
"=",
"None",
"self",
".",
"_callback",
"=... | Unsubscribes callback from observable | [
"Unsubscribes",
"callback",
"from",
"observable"
] | python | train | 35.333333 |
novopl/peltak | src/peltak/core/versioning.py | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L235-L248 | def write(self, version):
# type: (str) -> None
""" Write the project version to .py file.
This will regex search in the file for a
``__version__ = VERSION_STRING`` and substitute the version string
for the new version.
"""
with open(self.version_file) as fp:
... | [
"def",
"write",
"(",
"self",
",",
"version",
")",
":",
"# type: (str) -> None",
"with",
"open",
"(",
"self",
".",
"version_file",
")",
"as",
"fp",
":",
"content",
"=",
"fp",
".",
"read",
"(",
")",
"ver_statement",
"=",
"\"__version__ = '{}'\"",
".",
"forma... | Write the project version to .py file.
This will regex search in the file for a
``__version__ = VERSION_STRING`` and substitute the version string
for the new version. | [
"Write",
"the",
"project",
"version",
"to",
".",
"py",
"file",
"."
] | python | train | 36.785714 |
Chilipp/psyplot | psyplot/plotter.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/plotter.py#L1588-L1592 | def draw(self):
"""Draw the figures and those that are shared and have been changed"""
for fig in self.figs2draw:
fig.canvas.draw()
self._figs2draw.clear() | [
"def",
"draw",
"(",
"self",
")",
":",
"for",
"fig",
"in",
"self",
".",
"figs2draw",
":",
"fig",
".",
"canvas",
".",
"draw",
"(",
")",
"self",
".",
"_figs2draw",
".",
"clear",
"(",
")"
] | Draw the figures and those that are shared and have been changed | [
"Draw",
"the",
"figures",
"and",
"those",
"that",
"are",
"shared",
"and",
"have",
"been",
"changed"
] | python | train | 37.4 |
vstconsulting/vstutils | vstutils/api/doc_generator.py | https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/api/doc_generator.py#L167-L193 | def get_status_code_and_schema_rst(self, responses):
'''
Function for prepare information about responses with example, prepare only
responses with status code from `101` to `299`
:param responses: -- dictionary that contains responses, with status code as key
:type responses: di... | [
"def",
"get_status_code_and_schema_rst",
"(",
"self",
",",
"responses",
")",
":",
"for",
"status_code",
",",
"response_schema",
"in",
"responses",
".",
"items",
"(",
")",
":",
"status_code",
"=",
"int",
"(",
"status_code",
")",
"schema",
"=",
"response_schema",
... | Function for prepare information about responses with example, prepare only
responses with status code from `101` to `299`
:param responses: -- dictionary that contains responses, with status code as key
:type responses: dict
:return: | [
"Function",
"for",
"prepare",
"information",
"about",
"responses",
"with",
"example",
"prepare",
"only",
"responses",
"with",
"status",
"code",
"from",
"101",
"to",
"299",
":",
"param",
"responses",
":",
"--",
"dictionary",
"that",
"contains",
"responses",
"with... | python | train | 43.222222 |
taskcluster/taskcluster-client.py | taskcluster/utils.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/utils.py#L322-L348 | def optionsFromEnvironment(defaults=None):
"""Fetch root URL and credentials from the standard TASKCLUSTER_…
environment variables and return them in a format suitable for passing to a
client constructor."""
options = defaults or {}
credentials = options.get('credentials', {})
rootUrl = os.envi... | [
"def",
"optionsFromEnvironment",
"(",
"defaults",
"=",
"None",
")",
":",
"options",
"=",
"defaults",
"or",
"{",
"}",
"credentials",
"=",
"options",
".",
"get",
"(",
"'credentials'",
",",
"{",
"}",
")",
"rootUrl",
"=",
"os",
".",
"environ",
".",
"get",
... | Fetch root URL and credentials from the standard TASKCLUSTER_…
environment variables and return them in a format suitable for passing to a
client constructor. | [
"Fetch",
"root",
"URL",
"and",
"credentials",
"from",
"the",
"standard",
"TASKCLUSTER_…",
"environment",
"variables",
"and",
"return",
"them",
"in",
"a",
"format",
"suitable",
"for",
"passing",
"to",
"a",
"client",
"constructor",
"."
] | python | train | 31.148148 |
CodeReclaimers/neat-python | neat/genome.py | https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L547-L557 | def connect_partial_nodirect(self, config):
"""
Create a partially-connected genome,
with (unless no hidden nodes) no direct input-output connections."""
assert 0 <= config.connection_fraction <= 1
all_connections = self.compute_full_connections(config, False)
shuffle(all... | [
"def",
"connect_partial_nodirect",
"(",
"self",
",",
"config",
")",
":",
"assert",
"0",
"<=",
"config",
".",
"connection_fraction",
"<=",
"1",
"all_connections",
"=",
"self",
".",
"compute_full_connections",
"(",
"config",
",",
"False",
")",
"shuffle",
"(",
"a... | Create a partially-connected genome,
with (unless no hidden nodes) no direct input-output connections. | [
"Create",
"a",
"partially",
"-",
"connected",
"genome",
"with",
"(",
"unless",
"no",
"hidden",
"nodes",
")",
"no",
"direct",
"input",
"-",
"output",
"connections",
"."
] | python | train | 55.090909 |
molmod/molmod | molmod/graphs.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/graphs.py#L1423-L1427 | def iter_initial_relations(self, subject_graph):
"""Iterate over all valid initial relations for a match"""
vertex0 = 0
for vertex1 in range(subject_graph.num_vertices):
yield vertex0, vertex1 | [
"def",
"iter_initial_relations",
"(",
"self",
",",
"subject_graph",
")",
":",
"vertex0",
"=",
"0",
"for",
"vertex1",
"in",
"range",
"(",
"subject_graph",
".",
"num_vertices",
")",
":",
"yield",
"vertex0",
",",
"vertex1"
] | Iterate over all valid initial relations for a match | [
"Iterate",
"over",
"all",
"valid",
"initial",
"relations",
"for",
"a",
"match"
] | python | train | 44.8 |
vtkiorg/vtki | vtki/utilities.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L53-L106 | def get_scalar(mesh, name, preference='cell', info=False, err=False):
""" Searches both point and cell data for an array
Parameters
----------
name : str
The name of the array to get the range.
preference : str, optional
When scalars is specified, this is the perfered scalar type t... | [
"def",
"get_scalar",
"(",
"mesh",
",",
"name",
",",
"preference",
"=",
"'cell'",
",",
"info",
"=",
"False",
",",
"err",
"=",
"False",
")",
":",
"parr",
"=",
"point_scalar",
"(",
"mesh",
",",
"name",
")",
"carr",
"=",
"cell_scalar",
"(",
"mesh",
",",
... | Searches both point and cell data for an array
Parameters
----------
name : str
The name of the array to get the range.
preference : str, optional
When scalars is specified, this is the perfered scalar type to
search for in the dataset. Must be either ``'point'`` or ``'cell'``... | [
"Searches",
"both",
"point",
"and",
"cell",
"data",
"for",
"an",
"array"
] | python | train | 31.351852 |
codeforamerica/epa_python | epa/gics/gics.py | https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/epa/gics/gics.py#L60-L66 | def eligible_cost(self, column=None, value=None, **kwargs):
"""
The assistance dollar amounts by eligible cost category.
>>> GICS().eligible_cost('amount', 100000)
"""
return self._resolve_call('GIC_ELIGIBLE_COST', column, value, **kwargs) | [
"def",
"eligible_cost",
"(",
"self",
",",
"column",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_resolve_call",
"(",
"'GIC_ELIGIBLE_COST'",
",",
"column",
",",
"value",
",",
"*",
"*",
"kwargs",
")"... | The assistance dollar amounts by eligible cost category.
>>> GICS().eligible_cost('amount', 100000) | [
"The",
"assistance",
"dollar",
"amounts",
"by",
"eligible",
"cost",
"category",
"."
] | python | train | 39.142857 |
mathandy/svgpathtools | svgpathtools/path.py | https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/path.py#L147-L160 | def bez2poly(bez, numpy_ordering=True, return_poly1d=False):
"""Converts a Bezier object or tuple of Bezier control points to a tuple
of coefficients of the expanded polynomial.
return_poly1d : returns a numpy.poly1d object. This makes computations
of derivatives/anti-derivatives and many other operati... | [
"def",
"bez2poly",
"(",
"bez",
",",
"numpy_ordering",
"=",
"True",
",",
"return_poly1d",
"=",
"False",
")",
":",
"if",
"is_bezier_segment",
"(",
"bez",
")",
":",
"bez",
"=",
"bez",
".",
"bpoints",
"(",
")",
"return",
"bezier2polynomial",
"(",
"bez",
",",... | Converts a Bezier object or tuple of Bezier control points to a tuple
of coefficients of the expanded polynomial.
return_poly1d : returns a numpy.poly1d object. This makes computations
of derivatives/anti-derivatives and many other operations quite quick.
numpy_ordering : By default (to accommodate num... | [
"Converts",
"a",
"Bezier",
"object",
"or",
"tuple",
"of",
"Bezier",
"control",
"points",
"to",
"a",
"tuple",
"of",
"coefficients",
"of",
"the",
"expanded",
"polynomial",
".",
"return_poly1d",
":",
"returns",
"a",
"numpy",
".",
"poly1d",
"object",
".",
"This"... | python | train | 54.857143 |
kivy/python-for-android | pythonforandroid/recipe.py | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipe.py#L580-L612 | def get_recipe(cls, name, ctx):
'''Returns the Recipe with the given name, if it exists.'''
name = name.lower()
if not hasattr(cls, "recipes"):
cls.recipes = {}
if name in cls.recipes:
return cls.recipes[name]
recipe_file = None
for recipes_dir in... | [
"def",
"get_recipe",
"(",
"cls",
",",
"name",
",",
"ctx",
")",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"\"recipes\"",
")",
":",
"cls",
".",
"recipes",
"=",
"{",
"}",
"if",
"name",
"in",
"cls",
... | Returns the Recipe with the given name, if it exists. | [
"Returns",
"the",
"Recipe",
"with",
"the",
"given",
"name",
"if",
"it",
"exists",
"."
] | python | train | 37.727273 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.