repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
chatfirst/chatfirst
chatfirst/models.py
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/models.py#L209-L221
def to_json(self): """ Serialize object to json dict :return: dict """ data = dict() data['InterlocutorId'] = self.id_ data['Text'] = self.text data['Username'] = self.username data['FirstName'] = self.first_name data['LastName'] = self.la...
[ "def", "to_json", "(", "self", ")", ":", "data", "=", "dict", "(", ")", "data", "[", "'InterlocutorId'", "]", "=", "self", ".", "id_", "data", "[", "'Text'", "]", "=", "self", ".", "text", "data", "[", "'Username'", "]", "=", "self", ".", "username...
Serialize object to json dict :return: dict
[ "Serialize", "object", "to", "json", "dict" ]
python
train
softlayer/softlayer-python
SoftLayer/managers/vs_capacity.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_capacity.py#L100-L123
def create(self, name, backend_router_id, flavor, instances, test=False): """Orders a Virtual_ReservedCapacityGroup :param string name: Name for the new reserved capacity :param int backend_router_id: This selects the pod. See create_options for a list :param string flavor: Capacity Key...
[ "def", "create", "(", "self", ",", "name", ",", "backend_router_id", ",", "flavor", ",", "instances", ",", "test", "=", "False", ")", ":", "# Since orderManger needs a DC id, just send in 0, the API will ignore it", "args", "=", "(", "self", ".", "capacity_package", ...
Orders a Virtual_ReservedCapacityGroup :param string name: Name for the new reserved capacity :param int backend_router_id: This selects the pod. See create_options for a list :param string flavor: Capacity KeyName, see create_options for a list :param int instances: Number of guest thi...
[ "Orders", "a", "Virtual_ReservedCapacityGroup" ]
python
train
openfisca/openfisca-core
openfisca_core/parameters.py
https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/parameters.py#L423-L430
def merge(self, other): """ Merges another ParameterNode into the current node. In case of child name conflict, the other node child will replace the current node child. """ for child_name, child in other.children.items(): self.add_child(child_name, child)
[ "def", "merge", "(", "self", ",", "other", ")", ":", "for", "child_name", ",", "child", "in", "other", ".", "children", ".", "items", "(", ")", ":", "self", ".", "add_child", "(", "child_name", ",", "child", ")" ]
Merges another ParameterNode into the current node. In case of child name conflict, the other node child will replace the current node child.
[ "Merges", "another", "ParameterNode", "into", "the", "current", "node", "." ]
python
train
mpg-age-bioinformatics/AGEpy
AGEpy/gtf.py
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L111-L130
def GTFtoBED(inGTF,name): """ Transform a GTF dataframe into a bed dataframe :param inGTF: GTF dataframe for transformation :param name: field of the GTF data frame to be use for the bed 'name' positon returns: a bed dataframe with the corresponding bed fiels: 'chrom','chromStart','chromEnd','name...
[ "def", "GTFtoBED", "(", "inGTF", ",", "name", ")", ":", "bed", "=", "inGTF", ".", "copy", "(", ")", "bed", ".", "reset_index", "(", "inplace", "=", "True", ",", "drop", "=", "True", ")", "if", "name", "not", "in", "bed", ".", "columns", ".", "tol...
Transform a GTF dataframe into a bed dataframe :param inGTF: GTF dataframe for transformation :param name: field of the GTF data frame to be use for the bed 'name' positon returns: a bed dataframe with the corresponding bed fiels: 'chrom','chromStart','chromEnd','name','score','strand'
[ "Transform", "a", "GTF", "dataframe", "into", "a", "bed", "dataframe" ]
python
train
Mindwerks/worldengine
worldengine/draw.py
https://github.com/Mindwerks/worldengine/blob/64dff8eb7824ce46b5b6cb8006bcef21822ef144/worldengine/draw.py#L147-L194
def _elevation_color(elevation, sea_level=1.0): """ Calculate color based on elevation :param elevation: :return: """ color_step = 1.5 if sea_level is None: sea_level = -1 if elevation < sea_level/2: elevation /= sea_level return 0.0, 0.0, 0.75 + 0.5 * elevation ...
[ "def", "_elevation_color", "(", "elevation", ",", "sea_level", "=", "1.0", ")", ":", "color_step", "=", "1.5", "if", "sea_level", "is", "None", ":", "sea_level", "=", "-", "1", "if", "elevation", "<", "sea_level", "/", "2", ":", "elevation", "/=", "sea_l...
Calculate color based on elevation :param elevation: :return:
[ "Calculate", "color", "based", "on", "elevation", ":", "param", "elevation", ":", ":", "return", ":" ]
python
train
wummel/linkchecker
linkcheck/parser/__init__.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/parser/__init__.py#L53-L57
def parse_opera (url_data): """Parse an opera bookmark file.""" from ..bookmarks.opera import parse_bookmark_data for url, name, lineno in parse_bookmark_data(url_data.get_content()): url_data.add_url(url, line=lineno, name=name)
[ "def", "parse_opera", "(", "url_data", ")", ":", "from", ".", ".", "bookmarks", ".", "opera", "import", "parse_bookmark_data", "for", "url", ",", "name", ",", "lineno", "in", "parse_bookmark_data", "(", "url_data", ".", "get_content", "(", ")", ")", ":", "...
Parse an opera bookmark file.
[ "Parse", "an", "opera", "bookmark", "file", "." ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L1104-L1113
def vcenter_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id = ET.SubElement(vcenter, "id") id.text = kwargs.pop('id') callback = kwargs.pop('c...
[ "def", "vcenter_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "vcenter", "=", "ET", ".", "SubElement", "(", "config", ",", "\"vcenter\"", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
BernardFW/bernard
src/bernard/platforms/facebook/platform.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L973-L982
async def ensure_usable_media(self, media: BaseMedia) -> UrlMedia: """ So far, let's just accept URL media. We'll see in the future how it goes. """ if not isinstance(media, UrlMedia): raise ValueError('Facebook platform only accepts URL media') return media
[ "async", "def", "ensure_usable_media", "(", "self", ",", "media", ":", "BaseMedia", ")", "->", "UrlMedia", ":", "if", "not", "isinstance", "(", "media", ",", "UrlMedia", ")", ":", "raise", "ValueError", "(", "'Facebook platform only accepts URL media'", ")", "re...
So far, let's just accept URL media. We'll see in the future how it goes.
[ "So", "far", "let", "s", "just", "accept", "URL", "media", ".", "We", "ll", "see", "in", "the", "future", "how", "it", "goes", "." ]
python
train
pyopenapi/pyswagger
pyswagger/utils.py
https://github.com/pyopenapi/pyswagger/blob/333c4ca08e758cd2194943d9904a3eda3fe43977/pyswagger/utils.py#L439-L480
def walk(start, ofn, cyc=None): """ Non recursive DFS to detect cycles :param start: start vertex in graph :param ofn: function to get the list of outgoing edges of a vertex :param cyc: list of existing cycles, cycles are represented in a list started with minimum vertex. :return: cycles :rtype...
[ "def", "walk", "(", "start", ",", "ofn", ",", "cyc", "=", "None", ")", ":", "ctx", ",", "stk", "=", "{", "}", ",", "[", "start", "]", "cyc", "=", "[", "]", "if", "cyc", "==", "None", "else", "cyc", "while", "len", "(", "stk", ")", ":", "top...
Non recursive DFS to detect cycles :param start: start vertex in graph :param ofn: function to get the list of outgoing edges of a vertex :param cyc: list of existing cycles, cycles are represented in a list started with minimum vertex. :return: cycles :rtype: list of lists
[ "Non", "recursive", "DFS", "to", "detect", "cycles" ]
python
train
mixmastamyk/console
console/windows.py
https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/windows.py#L199-L203
def set_position(x, y, stream=STD_OUTPUT_HANDLE): ''' Sets current position of the cursor. ''' stream = kernel32.GetStdHandle(stream) value = x + (y << 16) kernel32.SetConsoleCursorPosition(stream, c_long(value))
[ "def", "set_position", "(", "x", ",", "y", ",", "stream", "=", "STD_OUTPUT_HANDLE", ")", ":", "stream", "=", "kernel32", ".", "GetStdHandle", "(", "stream", ")", "value", "=", "x", "+", "(", "y", "<<", "16", ")", "kernel32", ".", "SetConsoleCursorPositio...
Sets current position of the cursor.
[ "Sets", "current", "position", "of", "the", "cursor", "." ]
python
train
wuher/devil
devil/datamapper.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/datamapper.py#L272-L286
def _get_name_from_url(self, request): """ Determine short name for the mapper based on the URL. Short name can be either in query string (e.g. ?format=json) or as an extension to the URL (e.g. myresource.json). :returns: short name of the mapper or ``None`` if not found. """ ...
[ "def", "_get_name_from_url", "(", "self", ",", "request", ")", ":", "format", "=", "request", ".", "GET", ".", "get", "(", "'format'", ",", "None", ")", "if", "not", "format", ":", "match", "=", "self", ".", "_format_query_pattern", ".", "match", "(", ...
Determine short name for the mapper based on the URL. Short name can be either in query string (e.g. ?format=json) or as an extension to the URL (e.g. myresource.json). :returns: short name of the mapper or ``None`` if not found.
[ "Determine", "short", "name", "for", "the", "mapper", "based", "on", "the", "URL", "." ]
python
train
Xion/taipan
taipan/functional/combinators.py
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/functional/combinators.py#L76-L145
def merge(arg, *rest, **kwargs): """Merge a collection, with functions as items, into a single function that takes a collection and maps its items through corresponding functions. :param arg: A collection of functions, such as list, tuple, or dictionary :param default: Optional default function to use ...
[ "def", "merge", "(", "arg", ",", "*", "rest", ",", "*", "*", "kwargs", ")", ":", "ensure_keyword_args", "(", "kwargs", ",", "optional", "=", "(", "'default'", ",", ")", ")", "has_default", "=", "'default'", "in", "kwargs", "if", "has_default", ":", "de...
Merge a collection, with functions as items, into a single function that takes a collection and maps its items through corresponding functions. :param arg: A collection of functions, such as list, tuple, or dictionary :param default: Optional default function to use for items within mer...
[ "Merge", "a", "collection", "with", "functions", "as", "items", "into", "a", "single", "function", "that", "takes", "a", "collection", "and", "maps", "its", "items", "through", "corresponding", "functions", "." ]
python
train
asphalt-framework/asphalt
asphalt/core/context.py
https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L410-L442
def get_resources(self, type: Type[T_Resource]) -> Set[T_Resource]: """ Retrieve all the resources of the given type in this context and its parents. Any matching resource factories are also triggered if necessary. :param type: type of the resources to get :return: a set of all...
[ "def", "get_resources", "(", "self", ",", "type", ":", "Type", "[", "T_Resource", "]", ")", "->", "Set", "[", "T_Resource", "]", ":", "assert", "check_argument_types", "(", ")", "# Collect all the matching resources from this context", "resources", "=", "{", "cont...
Retrieve all the resources of the given type in this context and its parents. Any matching resource factories are also triggered if necessary. :param type: type of the resources to get :return: a set of all found resources of the given type
[ "Retrieve", "all", "the", "resources", "of", "the", "given", "type", "in", "this", "context", "and", "its", "parents", "." ]
python
train
tehmaze/natural
natural/number.py
https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/number.py#L117-L134
def percentage(value, digits=2): ''' Converts a fraction to a formatted percentage. :param value: number :param digits: default ``2`` >>> print(percentage(1)) 100.00 % >>> print(percentage(0.23, digits=0)) 23 % >>> print(percentage(23.421)) 2,342.10 % ''' value = floa...
[ "def", "percentage", "(", "value", ",", "digits", "=", "2", ")", ":", "value", "=", "float", "(", "value", ")", "*", "100.0", "return", "u''", "+", "'%s %%'", "%", "(", "_format", "(", "value", ",", "digits", ")", ",", ")" ]
Converts a fraction to a formatted percentage. :param value: number :param digits: default ``2`` >>> print(percentage(1)) 100.00 % >>> print(percentage(0.23, digits=0)) 23 % >>> print(percentage(23.421)) 2,342.10 %
[ "Converts", "a", "fraction", "to", "a", "formatted", "percentage", "." ]
python
train
dls-controls/pymalcolm
malcolm/modules/pandablocks/pandablocksclient.py
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L145-L171
def _recv_loop(self): """Service socket recv, returning responses to the correct queue""" self._completed_response_lines = [] self._is_multiline = None lines_iterator = self._get_lines() while True: try: line = next(lines_iterator) if s...
[ "def", "_recv_loop", "(", "self", ")", ":", "self", ".", "_completed_response_lines", "=", "[", "]", "self", ".", "_is_multiline", "=", "None", "lines_iterator", "=", "self", ".", "_get_lines", "(", ")", "while", "True", ":", "try", ":", "line", "=", "ne...
Service socket recv, returning responses to the correct queue
[ "Service", "socket", "recv", "returning", "responses", "to", "the", "correct", "queue" ]
python
train
inasafe/inasafe
safe/gui/widgets/message_viewer.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L305-L312
def to_message(self): """Collate all message elements to a single message.""" my_message = m.Message() if self.static_message is not None: my_message.add(self.static_message) for myDynamic in self.dynamic_messages: my_message.add(myDynamic) return my_messa...
[ "def", "to_message", "(", "self", ")", ":", "my_message", "=", "m", ".", "Message", "(", ")", "if", "self", ".", "static_message", "is", "not", "None", ":", "my_message", ".", "add", "(", "self", ".", "static_message", ")", "for", "myDynamic", "in", "s...
Collate all message elements to a single message.
[ "Collate", "all", "message", "elements", "to", "a", "single", "message", "." ]
python
train
google/google-visualization-python
gviz_api.py
https://github.com/google/google-visualization-python/blob/cbfb4d69ad2f4ca30dc55791629280aa3214c8e3/gviz_api.py#L683-L768
def ToJSCode(self, name, columns_order=None, order_by=()): """Writes the data table as a JS code string. This method writes a string of JS code that can be run to generate a DataTable with the specified data. Typically used for debugging only. Args: name: The name of the table. The name woul...
[ "def", "ToJSCode", "(", "self", ",", "name", ",", "columns_order", "=", "None", ",", "order_by", "=", "(", ")", ")", ":", "encoder", "=", "DataTableJSONEncoder", "(", ")", "if", "columns_order", "is", "None", ":", "columns_order", "=", "[", "col", "[", ...
Writes the data table as a JS code string. This method writes a string of JS code that can be run to generate a DataTable with the specified data. Typically used for debugging only. Args: name: The name of the table. The name would be used as the DataTable's variable name in the crea...
[ "Writes", "the", "data", "table", "as", "a", "JS", "code", "string", "." ]
python
train
agabrown/PyGaia
pygaia/plot/sky.py
https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/plot/sky.py#L10-L31
def _orderGridlinePoints(x, y): """ This code takes care of ordering the points (x,y), calculated for a sky map parallel or merdian, such that the drawing code can start at one end of the curve and end at the other (so no artifacts due to connecting the disjoint ends occur). Parameters ---------- x - Se...
[ "def", "_orderGridlinePoints", "(", "x", ",", "y", ")", ":", "xroll", "=", "roll", "(", "x", ",", "1", ")", "yroll", "=", "roll", "(", "y", ",", "1", ")", "distance", "=", "(", "xroll", "-", "x", ")", "**", "2", "+", "(", "yroll", "-", "y", ...
This code takes care of ordering the points (x,y), calculated for a sky map parallel or merdian, such that the drawing code can start at one end of the curve and end at the other (so no artifacts due to connecting the disjoint ends occur). Parameters ---------- x - Set of x coordinates y - Set of y coordi...
[ "This", "code", "takes", "care", "of", "ordering", "the", "points", "(", "x", "y", ")", "calculated", "for", "a", "sky", "map", "parallel", "or", "merdian", "such", "that", "the", "drawing", "code", "can", "start", "at", "one", "end", "of", "the", "cur...
python
test
martinpitt/python-dbusmock
dbusmock/mockobject.py
https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/mockobject.py#L149-L161
def GetAll(self, interface_name, *args, **kwargs): '''Standard D-Bus API for getting all property values''' self.log('GetAll ' + interface_name) if not interface_name: interface_name = self.interface try: return self.props[interface_name] except KeyError...
[ "def", "GetAll", "(", "self", ",", "interface_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", "(", "'GetAll '", "+", "interface_name", ")", "if", "not", "interface_name", ":", "interface_name", "=", "self", ".", "interface...
Standard D-Bus API for getting all property values
[ "Standard", "D", "-", "Bus", "API", "for", "getting", "all", "property", "values" ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L414-L440
def write_rst(self, prefix: str = "", suffix: str = "", heading_underline_char: str = "=", method: AutodocMethod = None, overwrite: bool = False, mock: bool = False) -> None: """ Writes the RST fi...
[ "def", "write_rst", "(", "self", ",", "prefix", ":", "str", "=", "\"\"", ",", "suffix", ":", "str", "=", "\"\"", ",", "heading_underline_char", ":", "str", "=", "\"=\"", ",", "method", ":", "AutodocMethod", "=", "None", ",", "overwrite", ":", "bool", "...
Writes the RST file to our destination RST filename, making any necessary directories. Args: prefix: as for :func:`rst_content` suffix: as for :func:`rst_content` heading_underline_char: as for :func:`rst_content` method: as for :func:`rst_content` ...
[ "Writes", "the", "RST", "file", "to", "our", "destination", "RST", "filename", "making", "any", "necessary", "directories", "." ]
python
train
iotaledger/iota.lib.py
iota/bin/__init__.py
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/bin/__init__.py#L41-L55
def execute(self, api, **arguments): # type: (Iota, **Any) -> Optional[int] """ Executes the command and (optionally) returns an exit code (used by the shell to determine if the application exited cleanly). :param api: The API object used to communicate with the node...
[ "def", "execute", "(", "self", ",", "api", ",", "*", "*", "arguments", ")", ":", "# type: (Iota, **Any) -> Optional[int]", "raise", "NotImplementedError", "(", "'Not implemented in {cls}.'", ".", "format", "(", "cls", "=", "type", "(", "self", ")", ".", "__name_...
Executes the command and (optionally) returns an exit code (used by the shell to determine if the application exited cleanly). :param api: The API object used to communicate with the node. :param arguments: Command-line arguments parsed by the argument parser.
[ "Executes", "the", "command", "and", "(", "optionally", ")", "returns", "an", "exit", "code", "(", "used", "by", "the", "shell", "to", "determine", "if", "the", "application", "exited", "cleanly", ")", "." ]
python
test
hubo1016/vlcp
vlcp/event/pqueue.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L855-L862
def unblock(self, event): ''' Remove a block ''' if event not in self.blockEvents: return self.blockEvents[event].unblock(event) del self.blockEvents[event]
[ "def", "unblock", "(", "self", ",", "event", ")", ":", "if", "event", "not", "in", "self", ".", "blockEvents", ":", "return", "self", ".", "blockEvents", "[", "event", "]", ".", "unblock", "(", "event", ")", "del", "self", ".", "blockEvents", "[", "e...
Remove a block
[ "Remove", "a", "block" ]
python
train
openstack/quark
quark/drivers/ironic_driver.py
https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L369-L393
def update_port(self, context, port_id, **kwargs): """Update a port. :param context: neutron api request context. :param port_id: neutron port id. :param kwargs: optional kwargs. :raises IronicException: If the client is unable to update the downstream port for any r...
[ "def", "update_port", "(", "self", ",", "context", ",", "port_id", ",", "*", "*", "kwargs", ")", ":", "LOG", ".", "info", "(", "\"update_port %s %s\"", "%", "(", "context", ".", "tenant_id", ",", "port_id", ")", ")", "# TODO(morgabra): Change this when we enab...
Update a port. :param context: neutron api request context. :param port_id: neutron port id. :param kwargs: optional kwargs. :raises IronicException: If the client is unable to update the downstream port for any reason, the exception will be logged and IronicExce...
[ "Update", "a", "port", "." ]
python
valid
wakatime/wakatime
wakatime/packages/simplejson/__init__.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/simplejson/__init__.py#L462-L533
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, use_decimal=False, **kw): """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) to a Python object. *encoding* determines the ...
[ "def", "loads", "(", "s", ",", "encoding", "=", "None", ",", "cls", "=", "None", ",", "object_hook", "=", "None", ",", "parse_float", "=", "None", ",", "parse_int", "=", "None", ",", "parse_constant", "=", "None", ",", "object_pairs_hook", "=", "None", ...
Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) to a Python object. *encoding* determines the encoding used to interpret any :class:`str` objects decoded by this instance (``'utf-8'`` by default). It has no effect when decoding :class:`unicode` objects. Note that ...
[ "Deserialize", "s", "(", "a", "str", "or", "unicode", "instance", "containing", "a", "JSON", "document", ")", "to", "a", "Python", "object", "." ]
python
train
radujica/baloo
baloo/weld/weld_ops.py
https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L97-L133
def weld_filter(array, weld_type, bool_array): """Returns a new array only with the elements with a corresponding True in bool_array. Parameters ---------- array : numpy.ndarray or WeldObject Input data. weld_type : WeldType Type of the elements in the input array. bool_array : ...
[ "def", "weld_filter", "(", "array", ",", "weld_type", ",", "bool_array", ")", ":", "obj_id", ",", "weld_obj", "=", "create_weld_object", "(", "array", ")", "bool_obj_id", "=", "get_weld_obj_id", "(", "weld_obj", ",", "bool_array", ")", "weld_template", "=", "\...
Returns a new array only with the elements with a corresponding True in bool_array. Parameters ---------- array : numpy.ndarray or WeldObject Input data. weld_type : WeldType Type of the elements in the input array. bool_array : numpy.ndarray or WeldObject Array of bool with...
[ "Returns", "a", "new", "array", "only", "with", "the", "elements", "with", "a", "corresponding", "True", "in", "bool_array", "." ]
python
train
danishabdullah/algen
algen/compilers.py
https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L171-L206
def compiled_foreign_keys(self): """Returns compiled foreign key definitions""" def get_column_args(column): tmp = [] for arg_name, arg_val in column.items(): if arg_name not in ('name', 'type', 'reference'): if arg_name in ('server_default', ...
[ "def", "compiled_foreign_keys", "(", "self", ")", ":", "def", "get_column_args", "(", "column", ")", ":", "tmp", "=", "[", "]", "for", "arg_name", ",", "arg_val", "in", "column", ".", "items", "(", ")", ":", "if", "arg_name", "not", "in", "(", "'name'"...
Returns compiled foreign key definitions
[ "Returns", "compiled", "foreign", "key", "definitions" ]
python
train
eerimoq/bincopy
bincopy.py
https://github.com/eerimoq/bincopy/blob/5e02cd001c3e9b54729425db6bffad5f03e1beac/bincopy.py#L146-L156
def pack_ihex(type_, address, size, data): """Create a Intel HEX record of given data. """ line = '{:02X}{:04X}{:02X}'.format(size, address, type_) if data: line += binascii.hexlify(data).decode('ascii').upper() return ':{}{:02X}'.format(line, crc_ihex(line))
[ "def", "pack_ihex", "(", "type_", ",", "address", ",", "size", ",", "data", ")", ":", "line", "=", "'{:02X}{:04X}{:02X}'", ".", "format", "(", "size", ",", "address", ",", "type_", ")", "if", "data", ":", "line", "+=", "binascii", ".", "hexlify", "(", ...
Create a Intel HEX record of given data.
[ "Create", "a", "Intel", "HEX", "record", "of", "given", "data", "." ]
python
train
manns/pyspread
pyspread/src/lib/vlc.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L5785-L5794
def libvlc_video_get_chapter_description(p_mi, i_title): '''Get the description of available chapters for specific title. @param p_mi: the media player. @param i_title: selected title. @return: list containing description of available chapter for title i_title. ''' f = _Cfunctions.get('libvlc_vi...
[ "def", "libvlc_video_get_chapter_description", "(", "p_mi", ",", "i_title", ")", ":", "f", "=", "_Cfunctions", ".", "get", "(", "'libvlc_video_get_chapter_description'", ",", "None", ")", "or", "_Cfunction", "(", "'libvlc_video_get_chapter_description'", ",", "(", "("...
Get the description of available chapters for specific title. @param p_mi: the media player. @param i_title: selected title. @return: list containing description of available chapter for title i_title.
[ "Get", "the", "description", "of", "available", "chapters", "for", "specific", "title", "." ]
python
train
scheibler/khard
khard/khard.py
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/khard.py#L1046-L1115
def email_subcommand(search_terms, vcard_list, parsable, remove_first_line): """Print a mail client friendly contacts table that is compatible with the default format used by mutt. Output format: single line of text email_address\tname\ttype email_address\tname\ttype [...] ...
[ "def", "email_subcommand", "(", "search_terms", ",", "vcard_list", ",", "parsable", ",", "remove_first_line", ")", ":", "matching_email_address_list", "=", "[", "]", "all_email_address_list", "=", "[", "]", "for", "vcard", "in", "vcard_list", ":", "for", "type", ...
Print a mail client friendly contacts table that is compatible with the default format used by mutt. Output format: single line of text email_address\tname\ttype email_address\tname\ttype [...] :param search_terms: used as search term to filter the contacts before pr...
[ "Print", "a", "mail", "client", "friendly", "contacts", "table", "that", "is", "compatible", "with", "the", "default", "format", "used", "by", "mutt", ".", "Output", "format", ":", "single", "line", "of", "text", "email_address", "\\", "tname", "\\", "ttype"...
python
test
jedie/DragonPy
dragonpy/utils/srecord_utils.py
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L95-L114
def get_readable_string(integer): r""" Convert an integer to a readable 2-character representation. This is useful for reversing examples: 41 == ".A", 13 == "\n", 20 (space) == "__" Returns a readable 2-char representation of an int. """ if integer == 9: #\t readable_strin...
[ "def", "get_readable_string", "(", "integer", ")", ":", "if", "integer", "==", "9", ":", "#\\t", "readable_string", "=", "\"\\\\t\"", "elif", "integer", "==", "10", ":", "#\\r", "readable_string", "=", "\"\\\\r\"", "elif", "integer", "==", "13", ":", "#\\n",...
r""" Convert an integer to a readable 2-character representation. This is useful for reversing examples: 41 == ".A", 13 == "\n", 20 (space) == "__" Returns a readable 2-char representation of an int.
[ "r", "Convert", "an", "integer", "to", "a", "readable", "2", "-", "character", "representation", ".", "This", "is", "useful", "for", "reversing", "examples", ":", "41", "==", ".", "A", "13", "==", "\\", "n", "20", "(", "space", ")", "==", "__", "Retu...
python
train
yandex/yandex-tank
yandextank/core/tankcore.py
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/core/tankcore.py#L417-L437
def __collect_file(self, filename, keep_original=False): """ Move or copy single file to artifacts dir """ dest = self.artifacts_dir + '/' + os.path.basename(filename) logger.debug("Collecting file: %s to %s", filename, dest) if not filename or not os.path.exists(filename...
[ "def", "__collect_file", "(", "self", ",", "filename", ",", "keep_original", "=", "False", ")", ":", "dest", "=", "self", ".", "artifacts_dir", "+", "'/'", "+", "os", ".", "path", ".", "basename", "(", "filename", ")", "logger", ".", "debug", "(", "\"C...
Move or copy single file to artifacts dir
[ "Move", "or", "copy", "single", "file", "to", "artifacts", "dir" ]
python
test
cloudera/impyla
impala/hiveserver2.py
https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/hiveserver2.py#L80-L140
def cursor(self, user=None, configuration=None, convert_types=True, dictify=False, fetch_error=True): """Get a cursor from the HiveServer2 (HS2) connection. Parameters ---------- user : str, optional configuration : dict of str keys and values, optional ...
[ "def", "cursor", "(", "self", ",", "user", "=", "None", ",", "configuration", "=", "None", ",", "convert_types", "=", "True", ",", "dictify", "=", "False", ",", "fetch_error", "=", "True", ")", ":", "# PEP 249", "log", ".", "debug", "(", "'Getting a curs...
Get a cursor from the HiveServer2 (HS2) connection. Parameters ---------- user : str, optional configuration : dict of str keys and values, optional Configuration overlay for the HS2 session. convert_types : bool, optional When `False`, timestamps and dec...
[ "Get", "a", "cursor", "from", "the", "HiveServer2", "(", "HS2", ")", "connection", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L269-L286
def _get_hypocentral_depth_term(self, C, rup): """ Returns the hypocentral depth scaling term defined in equations 21 - 23 """ if rup.hypo_depth <= 7.0: fhyp_h = 0.0 elif rup.hypo_depth > 20.0: fhyp_h = 13.0 else: fhyp_h = rup.hypo_dept...
[ "def", "_get_hypocentral_depth_term", "(", "self", ",", "C", ",", "rup", ")", ":", "if", "rup", ".", "hypo_depth", "<=", "7.0", ":", "fhyp_h", "=", "0.0", "elif", "rup", ".", "hypo_depth", ">", "20.0", ":", "fhyp_h", "=", "13.0", "else", ":", "fhyp_h",...
Returns the hypocentral depth scaling term defined in equations 21 - 23
[ "Returns", "the", "hypocentral", "depth", "scaling", "term", "defined", "in", "equations", "21", "-", "23" ]
python
train
ambitioninc/django-query-builder
querybuilder/tables.py
https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L136-L150
def get_alias(self): """ Gets the alias for the table or the auto_alias if one is set. If there isn't any kind of alias, None is returned. :returns: The table alias, auto_alias, or None :rtype: str or None """ alias = None if self.alias: alias...
[ "def", "get_alias", "(", "self", ")", ":", "alias", "=", "None", "if", "self", ".", "alias", ":", "alias", "=", "self", ".", "alias", "elif", "self", ".", "auto_alias", ":", "alias", "=", "self", ".", "auto_alias", "return", "alias" ]
Gets the alias for the table or the auto_alias if one is set. If there isn't any kind of alias, None is returned. :returns: The table alias, auto_alias, or None :rtype: str or None
[ "Gets", "the", "alias", "for", "the", "table", "or", "the", "auto_alias", "if", "one", "is", "set", ".", "If", "there", "isn", "t", "any", "kind", "of", "alias", "None", "is", "returned", "." ]
python
train
openeemeter/eeweather
eeweather/visualization.py
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/visualization.py#L29-L132
def plot_station_mapping( target_latitude, target_longitude, isd_station, distance_meters, target_label="target", ): # pragma: no cover """ Plots this mapping on a map.""" try: import matplotlib.pyplot as plt except ImportError: raise ImportError("Plotting requires matpl...
[ "def", "plot_station_mapping", "(", "target_latitude", ",", "target_longitude", ",", "isd_station", ",", "distance_meters", ",", "target_label", "=", "\"target\"", ",", ")", ":", "# pragma: no cover", "try", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", ...
Plots this mapping on a map.
[ "Plots", "this", "mapping", "on", "a", "map", "." ]
python
train
scanny/python-pptx
pptx/opc/pkgwriter.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/opc/pkgwriter.py#L81-L92
def xml_for(cls, parts): """ Return content types XML mapping each part in *parts* to the appropriate content type and suitable for storage as ``[Content_Types].xml`` in an OPC package. """ cti = cls() cti._defaults['rels'] = CT.OPC_RELATIONSHIPS cti._defa...
[ "def", "xml_for", "(", "cls", ",", "parts", ")", ":", "cti", "=", "cls", "(", ")", "cti", ".", "_defaults", "[", "'rels'", "]", "=", "CT", ".", "OPC_RELATIONSHIPS", "cti", ".", "_defaults", "[", "'xml'", "]", "=", "CT", ".", "XML", "for", "part", ...
Return content types XML mapping each part in *parts* to the appropriate content type and suitable for storage as ``[Content_Types].xml`` in an OPC package.
[ "Return", "content", "types", "XML", "mapping", "each", "part", "in", "*", "parts", "*", "to", "the", "appropriate", "content", "type", "and", "suitable", "for", "storage", "as", "[", "Content_Types", "]", ".", "xml", "in", "an", "OPC", "package", "." ]
python
train
3DLIRIOUS/MeshLabXML
meshlabxml/files.py
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L282-L322
def measure_dimension(fbasename=None, log=None, axis1=None, offset1=0.0, axis2=None, offset2=0.0, ml_version=ml_version): """Measure a dimension of a mesh""" axis1 = axis1.lower() axis2 = axis2.lower() ml_script1_file = 'TEMP3D_measure_dimension.mlx' file_out = 'TEMP3D_measure_...
[ "def", "measure_dimension", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "axis1", "=", "None", ",", "offset1", "=", "0.0", ",", "axis2", "=", "None", ",", "offset2", "=", "0.0", ",", "ml_version", "=", "ml_version", ")", ":", "axis1", ...
Measure a dimension of a mesh
[ "Measure", "a", "dimension", "of", "a", "mesh" ]
python
test
jaraco/svg.charts
svg/charts/graph.py
https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L324-L347
def make_datapoint_text(self, x, y, value, style=None): """ Add text for a datapoint """ if not self.show_data_values: # do nothing return # first lay down the text in a wide white stroke to # differentiate it from the background e = etree.SubElement(self.foreground, 'text', { 'x': str(x), 'y...
[ "def", "make_datapoint_text", "(", "self", ",", "x", ",", "y", ",", "value", ",", "style", "=", "None", ")", ":", "if", "not", "self", ".", "show_data_values", ":", "# do nothing", "return", "# first lay down the text in a wide white stroke to", "# differentiate it...
Add text for a datapoint
[ "Add", "text", "for", "a", "datapoint" ]
python
test
browniebroke/deezer-python
deezer/client.py
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L246-L264
def advanced_search(self, terms, relation=None, index=0, limit=25, **kwargs): """ Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` ...
[ "def", "advanced_search", "(", "self", ",", "terms", ",", "relation", "=", "None", ",", "index", "=", "0", ",", "limit", "=", "25", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "terms", ",", "dict", ")", ",", "\"terms must be a dict\...
Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` objects. >>> client.advanced_search({"artist": "Daft Punk", "album": "Homework"}) ...
[ "Advanced", "search", "of", "track", "album", "or", "artist", "." ]
python
train
galaxy-genome-annotation/python-apollo
apollo/status/__init__.py
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/status/__init__.py#L35-L50
def show_status(self, status): """ Get a specific status :type status: str :param status: Status to show :rtype: dict :return: A dictionnary containing status description """ statuses = self.get_statuses() statuses = [x for x in statuses if x['va...
[ "def", "show_status", "(", "self", ",", "status", ")", ":", "statuses", "=", "self", ".", "get_statuses", "(", ")", "statuses", "=", "[", "x", "for", "x", "in", "statuses", "if", "x", "[", "'value'", "]", "==", "status", "]", "if", "len", "(", "sta...
Get a specific status :type status: str :param status: Status to show :rtype: dict :return: A dictionnary containing status description
[ "Get", "a", "specific", "status" ]
python
train
seperman/deepdiff
deepdiff/diff.py
https://github.com/seperman/deepdiff/blob/a66879190fadc671632f154c1fcb82f5c3cef800/deepdiff/diff.py#L455-L489
def __create_hashtable(self, t, level): """Create hashtable of {item_hash: (indexes, item)}""" hashes = {} for (i, item) in enumerate(t): try: hashes_all = DeepHash(item, hashes=self.hashes, ...
[ "def", "__create_hashtable", "(", "self", ",", "t", ",", "level", ")", ":", "hashes", "=", "{", "}", "for", "(", "i", ",", "item", ")", "in", "enumerate", "(", "t", ")", ":", "try", ":", "hashes_all", "=", "DeepHash", "(", "item", ",", "hashes", ...
Create hashtable of {item_hash: (indexes, item)}
[ "Create", "hashtable", "of", "{", "item_hash", ":", "(", "indexes", "item", ")", "}" ]
python
train
andrenarchy/krypy
krypy/deflation.py
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L160-L180
def B_(self): r''':math:`\underline{B}=\langle V_{n+1},M_lAM_rU\rangle`. This property is obtained from :math:`C` if the operator is self-adjoint. Otherwise, the inner products have to be formed explicitly.''' (n_, n) = self.H.shape ls = self.linear_system if sel...
[ "def", "B_", "(", "self", ")", ":", "(", "n_", ",", "n", ")", "=", "self", ".", "H", ".", "shape", "ls", "=", "self", ".", "linear_system", "if", "self", ".", "_B_", "is", "None", "or", "self", ".", "_B_", ".", "shape", "[", "1", "]", "<", ...
r''':math:`\underline{B}=\langle V_{n+1},M_lAM_rU\rangle`. This property is obtained from :math:`C` if the operator is self-adjoint. Otherwise, the inner products have to be formed explicitly.
[ "r", ":", "math", ":", "\\", "underline", "{", "B", "}", "=", "\\", "langle", "V_", "{", "n", "+", "1", "}", "M_lAM_rU", "\\", "rangle", "." ]
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py#L280-L297
def _print_refs(self, refs, total, prefix=' ', level=1, minsize=0, minpct=0.1): """ Print individual referents recursively. """ lrefs = list(refs) lrefs.sort(key=lambda x: x.size) lrefs.reverse() for ref in lrefs: if ref.size > m...
[ "def", "_print_refs", "(", "self", ",", "refs", ",", "total", ",", "prefix", "=", "' '", ",", "level", "=", "1", ",", "minsize", "=", "0", ",", "minpct", "=", "0.1", ")", ":", "lrefs", "=", "list", "(", "refs", ")", "lrefs", ".", "sort", "(", ...
Print individual referents recursively.
[ "Print", "individual", "referents", "recursively", "." ]
python
train
MycroftAI/mycroft-precise
precise/scripts/convert.py
https://github.com/MycroftAI/mycroft-precise/blob/e17cebdd171906dbd8a16e282d8a7966fba2eeba/precise/scripts/convert.py#L32-L76
def convert(model_path: str, out_file: str): """ Converts an HD5F file from Keras to a .pb for use with TensorFlow Args: model_path: location of Keras model out_file: location to write protobuf """ print('Converting', model_path, 'to', out_file, '...') import tensorflow as tf ...
[ "def", "convert", "(", "model_path", ":", "str", ",", "out_file", ":", "str", ")", ":", "print", "(", "'Converting'", ",", "model_path", ",", "'to'", ",", "out_file", ",", "'...'", ")", "import", "tensorflow", "as", "tf", "from", "precise", ".", "model",...
Converts an HD5F file from Keras to a .pb for use with TensorFlow Args: model_path: location of Keras model out_file: location to write protobuf
[ "Converts", "an", "HD5F", "file", "from", "Keras", "to", "a", ".", "pb", "for", "use", "with", "TensorFlow" ]
python
train
slinderman/pypolyagamma
pypolyagamma/binary_trees.py
https://github.com/slinderman/pypolyagamma/blob/abdc0c53e5114092998f51bf66f1900bc567f0bd/pypolyagamma/binary_trees.py#L60-L74
def random_tree(n_leaves): """ Randomly partition the nodes """ def _random_subtree(leaves): if len(leaves) == 1: return leaves[0] elif len(leaves) == 2: return (leaves[0], leaves[1]) else: split = npr.randint(1, len(leaves)-1) retu...
[ "def", "random_tree", "(", "n_leaves", ")", ":", "def", "_random_subtree", "(", "leaves", ")", ":", "if", "len", "(", "leaves", ")", "==", "1", ":", "return", "leaves", "[", "0", "]", "elif", "len", "(", "leaves", ")", "==", "2", ":", "return", "("...
Randomly partition the nodes
[ "Randomly", "partition", "the", "nodes" ]
python
train
saltstack/salt
salt/modules/boto_iam.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iam.py#L1748-L1776
def create_policy(policy_name, policy_document, path=None, description=None, region=None, key=None, keyid=None, profile=None): ''' Create a policy. CLI Example: .. code-block:: bash salt myminios boto_iam.create_policy mypolicy '{"Version": "2012-10-17", "Statement": [{ "Effe...
[ "def", "create_policy", "(", "policy_name", ",", "policy_document", ",", "path", "=", "None", ",", "description", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn"...
Create a policy. CLI Example: .. code-block:: bash salt myminios boto_iam.create_policy mypolicy '{"Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": ["s3:Get*", "s3:List*"], "Resource": ["arn:aws:s3:::my-bucket/shared/*"]},]}'
[ "Create", "a", "policy", "." ]
python
train
saltstack/salt
salt/pillar/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/__init__.py#L948-L1026
def ext_pillar(self, pillar, errors=None): ''' Render the external pillar data ''' if errors is None: errors = [] try: # Make sure that on-demand git_pillar is fetched before we try to # compile the pillar data. git_pillar will fetch a remote w...
[ "def", "ext_pillar", "(", "self", ",", "pillar", ",", "errors", "=", "None", ")", ":", "if", "errors", "is", "None", ":", "errors", "=", "[", "]", "try", ":", "# Make sure that on-demand git_pillar is fetched before we try to", "# compile the pillar data. git_pillar w...
Render the external pillar data
[ "Render", "the", "external", "pillar", "data" ]
python
train
metagriffin/fso
fso/filesystemoverlay.py
https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L486-L491
def fso_symlink(self, source, link_name): 'overlays os.symlink()' path = self.deref(link_name, to_parent=True) if self._exists(path): raise OSError(17, 'File exists') self._addentry(OverlayEntry(self, path, stat.S_IFLNK, source))
[ "def", "fso_symlink", "(", "self", ",", "source", ",", "link_name", ")", ":", "path", "=", "self", ".", "deref", "(", "link_name", ",", "to_parent", "=", "True", ")", "if", "self", ".", "_exists", "(", "path", ")", ":", "raise", "OSError", "(", "17",...
overlays os.symlink()
[ "overlays", "os", ".", "symlink", "()" ]
python
valid
SatelliteQE/nailgun
nailgun/entity_mixins.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entity_mixins.py#L437-L490
def path(self, which=None): """Return the path to the current entity. Return the path to base entities of this entity's type if: * ``which`` is ``'base'``, or * ``which`` is ``None`` and instance attribute ``id`` is unset. Return the path to this exact entity if instance attri...
[ "def", "path", "(", "self", ",", "which", "=", "None", ")", ":", "# It is OK that member ``self._meta`` is not found. Subclasses are", "# required to set that attribute if they wish to use this method.", "#", "# Beware of leading and trailing slashes:", "#", "# urljoin('example.com...
Return the path to the current entity. Return the path to base entities of this entity's type if: * ``which`` is ``'base'``, or * ``which`` is ``None`` and instance attribute ``id`` is unset. Return the path to this exact entity if instance attribute ``id`` is set and: ...
[ "Return", "the", "path", "to", "the", "current", "entity", "." ]
python
train
petebachant/PXL
pxl/timeseries.py
https://github.com/petebachant/PXL/blob/d7d06cb74422e1ac0154741351fbecea080cfcc0/pxl/timeseries.py#L99-L119
def build_plane_arrays(x, y, qlist): """Build a 2-D array out of data taken in the same plane, for contour plotting. """ if type(qlist) is not list: return_list = False qlist = [qlist] else: return_list = True xv = x[np.where(y==y[0])[0]] yv = y[np.where(x==...
[ "def", "build_plane_arrays", "(", "x", ",", "y", ",", "qlist", ")", ":", "if", "type", "(", "qlist", ")", "is", "not", "list", ":", "return_list", "=", "False", "qlist", "=", "[", "qlist", "]", "else", ":", "return_list", "=", "True", "xv", "=", "x...
Build a 2-D array out of data taken in the same plane, for contour plotting.
[ "Build", "a", "2", "-", "D", "array", "out", "of", "data", "taken", "in", "the", "same", "plane", "for", "contour", "plotting", "." ]
python
train
scottjbarr/bitfinex
bitfinex/client.py
https://github.com/scottjbarr/bitfinex/blob/03f7c71615fe38c2e28be0ebb761d3106ef0a51a/bitfinex/client.py#L383-L398
def ticker(self, symbol): """ GET /ticker/:symbol curl https://api.bitfinex.com/v1/ticker/btcusd { 'ask': '562.9999', 'timestamp': '1395552290.70933607', 'bid': '562.25', 'last_price': u'562.25', 'mid': u'562.62495'} ""...
[ "def", "ticker", "(", "self", ",", "symbol", ")", ":", "data", "=", "self", ".", "_get", "(", "self", ".", "url_for", "(", "PATH_TICKER", ",", "(", "symbol", ")", ")", ")", "# convert all values to floats", "return", "self", ".", "_convert_to_floats", "(",...
GET /ticker/:symbol curl https://api.bitfinex.com/v1/ticker/btcusd { 'ask': '562.9999', 'timestamp': '1395552290.70933607', 'bid': '562.25', 'last_price': u'562.25', 'mid': u'562.62495'}
[ "GET", "/", "ticker", "/", ":", "symbol" ]
python
train
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L803-L817
def to_dict(self): """Convert state to dictionary to save in task payload.""" result = {"mapreduce_spec": self.mapreduce_spec.to_json_str(), "shard_id": self.shard_id, "slice_id": str(self.slice_id), "input_reader_state": self.input_reader.to_json_str(), "...
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "{", "\"mapreduce_spec\"", ":", "self", ".", "mapreduce_spec", ".", "to_json_str", "(", ")", ",", "\"shard_id\"", ":", "self", ".", "shard_id", ",", "\"slice_id\"", ":", "str", "(", "self", ".", "sl...
Convert state to dictionary to save in task payload.
[ "Convert", "state", "to", "dictionary", "to", "save", "in", "task", "payload", "." ]
python
train
federico123579/Trading212-API
tradingAPI/low_level.py
https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/low_level.py#L526-L531
def new_pos(self, html_div): """factory method pattern""" pos = self.Position(self, html_div) pos.bind_mov() self.positions.append(pos) return pos
[ "def", "new_pos", "(", "self", ",", "html_div", ")", ":", "pos", "=", "self", ".", "Position", "(", "self", ",", "html_div", ")", "pos", ".", "bind_mov", "(", ")", "self", ".", "positions", ".", "append", "(", "pos", ")", "return", "pos" ]
factory method pattern
[ "factory", "method", "pattern" ]
python
train
konstantint/PassportEye
passporteye/mrz/text.py
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/mrz/text.py#L183-L227
def to_dict(self): """Converts this object to an (ordered) dictionary of field-value pairs. >>> m = MRZ(['IDAUT10000999<6<<<<<<<<<<<<<<<', '7109094F1112315AUT<<<<<<<<<<<6', 'MUSTERFRAU<<ISOLDE<<<<<<<<<<<<']).to_dict() >>> assert m['type'] == 'ID' and m['country'] == 'AUT' and m['number'] == '10...
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "OrderedDict", "(", ")", "result", "[", "'mrz_type'", "]", "=", "self", ".", "mrz_type", "result", "[", "'valid_score'", "]", "=", "self", ".", "valid_score", "if", "self", ".", "mrz_type", "is", ...
Converts this object to an (ordered) dictionary of field-value pairs. >>> m = MRZ(['IDAUT10000999<6<<<<<<<<<<<<<<<', '7109094F1112315AUT<<<<<<<<<<<6', 'MUSTERFRAU<<ISOLDE<<<<<<<<<<<<']).to_dict() >>> assert m['type'] == 'ID' and m['country'] == 'AUT' and m['number'] == '10000999<' >>> assert m[...
[ "Converts", "this", "object", "to", "an", "(", "ordered", ")", "dictionary", "of", "field", "-", "value", "pairs", "." ]
python
train
wasp/waspy
waspy/transports/rabbit_patches.py
https://github.com/wasp/waspy/blob/31cc352f300a089f9607d7f13d93591d4c69d5ec/waspy/transports/rabbit_patches.py#L99-L122
async def _write_frame_awaiting_response(self, waiter_id, frame, request, no_wait, check_open=True, drain=True): '''Write a frame and set a waiter for the response (unless no_wait is set)''' if no_wait: await self._write_frame(frame, request, check_open=check...
[ "async", "def", "_write_frame_awaiting_response", "(", "self", ",", "waiter_id", ",", "frame", ",", "request", ",", "no_wait", ",", "check_open", "=", "True", ",", "drain", "=", "True", ")", ":", "if", "no_wait", ":", "await", "self", ".", "_write_frame", ...
Write a frame and set a waiter for the response (unless no_wait is set)
[ "Write", "a", "frame", "and", "set", "a", "waiter", "for", "the", "response", "(", "unless", "no_wait", "is", "set", ")" ]
python
train
frostming/marko
marko/parser.py
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/parser.py#L65-L90
def parse(self, source_or_text): """Do the actual parsing and returns an AST or parsed element. :param source_or_text: the text or source object. Based on the type, it will do following: - text: returns the parsed Document element. - source: parse the source and retu...
[ "def", "parse", "(", "self", ",", "source_or_text", ")", ":", "if", "isinstance", "(", "source_or_text", ",", "string_types", ")", ":", "block", ".", "parser", "=", "self", "inline", ".", "parser", "=", "self", "return", "self", ".", "block_elements", "[",...
Do the actual parsing and returns an AST or parsed element. :param source_or_text: the text or source object. Based on the type, it will do following: - text: returns the parsed Document element. - source: parse the source and returns the parsed children as a list.
[ "Do", "the", "actual", "parsing", "and", "returns", "an", "AST", "or", "parsed", "element", "." ]
python
train
AdvancedClimateSystems/uModbus
umodbus/server/serial/rtu.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/server/serial/rtu.py#L69-L77
def create_response_adu(self, meta_data, response_pdu): """ Build response ADU from meta data and response PDU and return it. :param meta_data: A dict with meta data. :param request_pdu: A bytearray containing request PDU. :return: A bytearray containing request ADU. """ ...
[ "def", "create_response_adu", "(", "self", ",", "meta_data", ",", "response_pdu", ")", ":", "first_part_adu", "=", "struct", ".", "pack", "(", "'>B'", ",", "meta_data", "[", "'unit_id'", "]", ")", "+", "response_pdu", "return", "first_part_adu", "+", "get_crc"...
Build response ADU from meta data and response PDU and return it. :param meta_data: A dict with meta data. :param request_pdu: A bytearray containing request PDU. :return: A bytearray containing request ADU.
[ "Build", "response", "ADU", "from", "meta", "data", "and", "response", "PDU", "and", "return", "it", "." ]
python
train
johnnoone/aioconsul
aioconsul/client/acl_endpoint.py
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/acl_endpoint.py#L15-L59
async def create(self, token): """Creates a new token with a given policy Parameters: token (Object): Token specification Returns: Object: token ID The create endpoint is used to make a new token. A token has a name, a type, and a set of ACL rules. ...
[ "async", "def", "create", "(", "self", ",", "token", ")", ":", "token", "=", "encode_token", "(", "token", ")", "response", "=", "await", "self", ".", "_api", ".", "put", "(", "\"/v1/acl/create\"", ",", "data", "=", "token", ")", "return", "response", ...
Creates a new token with a given policy Parameters: token (Object): Token specification Returns: Object: token ID The create endpoint is used to make a new token. A token has a name, a type, and a set of ACL rules. The request body may take the form:: ...
[ "Creates", "a", "new", "token", "with", "a", "given", "policy" ]
python
train
ekmmetering/ekmmeters
ekmmeters.py
https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1875-L1912
def splitEkmDate(dateint): """Break out a date from Omnimeter read. Note a corrupt date will raise an exception when you convert it to int to hand to this method. Args: dateint (int): Omnimeter datetime as int. Returns: tuple: Named tuple which breaks ...
[ "def", "splitEkmDate", "(", "dateint", ")", ":", "date_str", "=", "str", "(", "dateint", ")", "dt", "=", "namedtuple", "(", "'EkmDate'", ",", "[", "'yy'", ",", "'mm'", ",", "'dd'", ",", "'weekday'", ",", "'hh'", ",", "'minutes'", ",", "'ss'", "]", ")...
Break out a date from Omnimeter read. Note a corrupt date will raise an exception when you convert it to int to hand to this method. Args: dateint (int): Omnimeter datetime as int. Returns: tuple: Named tuple which breaks out as followws: ========...
[ "Break", "out", "a", "date", "from", "Omnimeter", "read", "." ]
python
test
alan-turing-institute/topic-modelling-tools
topicmodels/LDA/gibbs.py
https://github.com/alan-turing-institute/topic-modelling-tools/blob/f0cf90cdd06f1072e824b446f201c7469b9de5df/topicmodels/LDA/gibbs.py#L153-L167
def tt_comp(self, sampled_topics): """ Compute term-topic matrix from sampled_topics. """ samples = sampled_topics.shape[0] tt = np.zeros((self.V, self.K, samples)) for s in range(samples): tt[:, :, s] = \ samplers_lda.tt_comp(se...
[ "def", "tt_comp", "(", "self", ",", "sampled_topics", ")", ":", "samples", "=", "sampled_topics", ".", "shape", "[", "0", "]", "tt", "=", "np", ".", "zeros", "(", "(", "self", ".", "V", ",", "self", ".", "K", ",", "samples", ")", ")", "for", "s",...
Compute term-topic matrix from sampled_topics.
[ "Compute", "term", "-", "topic", "matrix", "from", "sampled_topics", "." ]
python
train
titusjan/argos
argos/inspector/pgplugins/imageplot2d.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/imageplot2d.py#L244-L249
def setVerCrossPlotAutoRangeOn(self, axisNumber): """ Sets the vertical cross-hair plot's auto-range on for the axis with number axisNumber. :param axisNumber: 0 (X-axis), 1 (Y-axis), 2, (Both X and Y axes). """ setXYAxesAutoRangeOn(self, self.verCrossPlotRangeCti, self.yAxisRangeCt...
[ "def", "setVerCrossPlotAutoRangeOn", "(", "self", ",", "axisNumber", ")", ":", "setXYAxesAutoRangeOn", "(", "self", ",", "self", ".", "verCrossPlotRangeCti", ",", "self", ".", "yAxisRangeCti", ",", "axisNumber", ")" ]
Sets the vertical cross-hair plot's auto-range on for the axis with number axisNumber. :param axisNumber: 0 (X-axis), 1 (Y-axis), 2, (Both X and Y axes).
[ "Sets", "the", "vertical", "cross", "-", "hair", "plot", "s", "auto", "-", "range", "on", "for", "the", "axis", "with", "number", "axisNumber", "." ]
python
train
Erotemic/utool
utool/util_dict.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L571-L614
def all_dict_combinations(varied_dict): """ all_dict_combinations Args: varied_dict (dict): a dict with lists of possible parameter settings Returns: list: dict_list a list of dicts correpsonding to all combinations of params settings CommandLine: python -m utool.util_dic...
[ "def", "all_dict_combinations", "(", "varied_dict", ")", ":", "#tups_list = [[(key, val) for val in val_list]", "# if isinstance(val_list, (list, tuple))", "# else [(key, val_list)]", "# for (key, val_list) in six.iteritems(varied_dict)]", "tups_list", "=", ...
all_dict_combinations Args: varied_dict (dict): a dict with lists of possible parameter settings Returns: list: dict_list a list of dicts correpsonding to all combinations of params settings CommandLine: python -m utool.util_dict --test-all_dict_combinations Example: ...
[ "all_dict_combinations" ]
python
train
fudge-py/fudge
fudge/__init__.py
https://github.com/fudge-py/fudge/blob/b283fbc1a41900f3f5845b10b8c2ef9136a67ebc/fudge/__init__.py#L777-L805
def expects_call(self): """The fake must be called. .. doctest:: :hide: >>> import fudge >>> fudge.clear_expectations() >>> fudge.clear_calls() This is useful for when you stub out a function as opposed to a class. For example:: ...
[ "def", "expects_call", "(", "self", ")", ":", "self", ".", "_callable", "=", "ExpectedCall", "(", "self", ",", "call_name", "=", "self", ".", "_name", ",", "callable", "=", "True", ")", "return", "self" ]
The fake must be called. .. doctest:: :hide: >>> import fudge >>> fudge.clear_expectations() >>> fudge.clear_calls() This is useful for when you stub out a function as opposed to a class. For example:: >>> import fudge ...
[ "The", "fake", "must", "be", "called", "." ]
python
train
bocong/urbandictionary-py
urbandictionary.py
https://github.com/bocong/urbandictionary-py/blob/aa919cd2c28563ca7f09ff80a3125de2dc7576ba/urbandictionary.py#L63-L70
def defineID(defid): """Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str) """ json = _get_urban_json(UD_DEFID_URL + urlquote(str(defid))) return _parse_urban_json(json)
[ "def", "defineID", "(", "defid", ")", ":", "json", "=", "_get_urban_json", "(", "UD_DEFID_URL", "+", "urlquote", "(", "str", "(", "defid", ")", ")", ")", "return", "_parse_urban_json", "(", "json", ")" ]
Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str)
[ "Search", "for", "UD", "s", "definition", "ID", "and", "return", "list", "of", "UrbanDefinition", "objects", "." ]
python
train
jlesquembre/termite
termite/utils.py
https://github.com/jlesquembre/termite/blob/fb77dcaa31872dc14dd3eeac694cd4c44aeee27b/termite/utils.py#L31-L58
def copy_rec(source, dest): """Copy files between diferent directories. Copy one or more files to an existing directory. This function is recursive, if the source is a directory, all its subdirectories are created in the destination. Existing files in destination are overwrited without any warning....
[ "def", "copy_rec", "(", "source", ",", "dest", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "source", ")", ":", "for", "child", "in", "os", ".", "listdir", "(", "source", ")", ":", "new_dest", "=", "os", ".", "path", ".", "join", "(", ...
Copy files between diferent directories. Copy one or more files to an existing directory. This function is recursive, if the source is a directory, all its subdirectories are created in the destination. Existing files in destination are overwrited without any warning. Args: source (str): F...
[ "Copy", "files", "between", "diferent", "directories", "." ]
python
train
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L311-L366
def references2marc(self, key, value): """Populate the ``999C5`` MARC field.""" reference = value.get('reference', {}) pids = force_list(reference.get('persistent_identifiers')) a_values = ['doi:' + el for el in force_list(reference.get('dois'))] a_values.extend(['hdl:' + el['value'] for el in pids...
[ "def", "references2marc", "(", "self", ",", "key", ",", "value", ")", ":", "reference", "=", "value", ".", "get", "(", "'reference'", ",", "{", "}", ")", "pids", "=", "force_list", "(", "reference", ".", "get", "(", "'persistent_identifiers'", ")", ")", ...
Populate the ``999C5`` MARC field.
[ "Populate", "the", "999C5", "MARC", "field", "." ]
python
train
juju/python-libjuju
juju/model.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2281-L2312
def make_archive(self, path): """Create archive of directory and write to ``path``. :param path: Path to archive Ignored:: * build/* - This is used for packing the charm itself and any similar tasks. * */.* - Hidden files are all ignored fo...
[ "def", "make_archive", "(", "self", ",", "path", ")", ":", "zf", "=", "zipfile", ".", "ZipFile", "(", "path", ",", "'w'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "for", "dirpath", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "se...
Create archive of directory and write to ``path``. :param path: Path to archive Ignored:: * build/* - This is used for packing the charm itself and any similar tasks. * */.* - Hidden files are all ignored for now. This will most ...
[ "Create", "archive", "of", "directory", "and", "write", "to", "path", "." ]
python
train
maljovec/topopy
topopy/MergeTree.py
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MergeTree.py#L135-L160
def build_for_contour_tree(self, contour_tree, negate=False): """ A helper function that will reduce duplication of data by reusing the parent contour tree's parameters and data """ if self.debug: tree_type = "Join" if negate: tree_type = "Spli...
[ "def", "build_for_contour_tree", "(", "self", ",", "contour_tree", ",", "negate", "=", "False", ")", ":", "if", "self", ".", "debug", ":", "tree_type", "=", "\"Join\"", "if", "negate", ":", "tree_type", "=", "\"Split\"", "sys", ".", "stdout", ".", "write",...
A helper function that will reduce duplication of data by reusing the parent contour tree's parameters and data
[ "A", "helper", "function", "that", "will", "reduce", "duplication", "of", "data", "by", "reusing", "the", "parent", "contour", "tree", "s", "parameters", "and", "data" ]
python
train
fermiPy/fermipy
fermipy/plotting.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L1159-L1251
def make_roi_plots(self, gta, mcube_tot, **kwargs): """Make various diagnostic plots for the 1D and 2D counts/model distributions. Parameters ---------- prefix : str Prefix that will be appended to all filenames. """ fmt = kwargs.get('format', self...
[ "def", "make_roi_plots", "(", "self", ",", "gta", ",", "mcube_tot", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "kwargs", ".", "get", "(", "'format'", ",", "self", ".", "config", "[", "'format'", "]", ")", "figsize", "=", "kwargs", ".", "get", "...
Make various diagnostic plots for the 1D and 2D counts/model distributions. Parameters ---------- prefix : str Prefix that will be appended to all filenames.
[ "Make", "various", "diagnostic", "plots", "for", "the", "1D", "and", "2D", "counts", "/", "model", "distributions", "." ]
python
train
jason-weirather/py-seq-tools
seqtools/format/sam/bam/bamindex.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L58-L79
def check_ordered(self): """ True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false :return: is it ordered? :rtype: bool """ sys.stderr.write("error unimplemented check_ordered\n") sys.exit() seen_chrs = set() curr_chr ...
[ "def", "check_ordered", "(", "self", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"error unimplemented check_ordered\\n\"", ")", "sys", ".", "exit", "(", ")", "seen_chrs", "=", "set", "(", ")", "curr_chr", "=", "None", "prevstart", "=", "0", "for",...
True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false :return: is it ordered? :rtype: bool
[ "True", "if", "each", "chromosome", "is", "listed", "together", "as", "a", "chunk", "and", "if", "the", "range", "starts", "go", "from", "smallest", "to", "largest", "otherwise", "false" ]
python
train
ifduyue/urlfetch
urlfetch.py
https://github.com/ifduyue/urlfetch/blob/e0ea4673367c157eb832ba4ba2635306c81a61be/urlfetch.py#L314-L322
def json(self): """Load response body as json. :raises: :class:`ContentDecodingError` """ try: return json.loads(self.text) except Exception as e: raise ContentDecodingError(e)
[ "def", "json", "(", "self", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "self", ".", "text", ")", "except", "Exception", "as", "e", ":", "raise", "ContentDecodingError", "(", "e", ")" ]
Load response body as json. :raises: :class:`ContentDecodingError`
[ "Load", "response", "body", "as", "json", "." ]
python
train
scanny/python-pptx
pptx/chart/data.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/data.py#L769-L777
def add_data_point(self, x, y, size, number_format=None): """ Append a new BubbleDataPoint object having the values *x*, *y*, and *size*. The optional *number_format* is used to format the Y value. If not provided, the number format is inherited from the series data. """ ...
[ "def", "add_data_point", "(", "self", ",", "x", ",", "y", ",", "size", ",", "number_format", "=", "None", ")", ":", "data_point", "=", "BubbleDataPoint", "(", "self", ",", "x", ",", "y", ",", "size", ",", "number_format", ")", "self", ".", "append", ...
Append a new BubbleDataPoint object having the values *x*, *y*, and *size*. The optional *number_format* is used to format the Y value. If not provided, the number format is inherited from the series data.
[ "Append", "a", "new", "BubbleDataPoint", "object", "having", "the", "values", "*", "x", "*", "*", "y", "*", "and", "*", "size", "*", ".", "The", "optional", "*", "number_format", "*", "is", "used", "to", "format", "the", "Y", "value", ".", "If", "not...
python
train
raiden-network/raiden
raiden/messages.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/messages.py#L1597-L1608
def to_dict(self) -> Dict[str, Any]: """Message format according to monitoring service spec""" return { 'type': self.__class__.__name__, 'channel_identifier': self.channel_identifier, 'token_network_address': to_normalized_address(self.token_network_address), ...
[ "def", "to_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "'type'", ":", "self", ".", "__class__", ".", "__name__", ",", "'channel_identifier'", ":", "self", ".", "channel_identifier", ",", "'token_network_address'", ...
Message format according to monitoring service spec
[ "Message", "format", "according", "to", "monitoring", "service", "spec" ]
python
train
ionelmc/python-cogen
examples/cogen-irc/CogenIrcApp/cogenircapp/websetup.py
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-irc/CogenIrcApp/cogenircapp/websetup.py#L11-L14
def setup_config(command, filename, section, vars): """Place any commands to setup cogenircapp here""" conf = appconfig('config:' + filename) load_environment(conf.global_conf, conf.local_conf)
[ "def", "setup_config", "(", "command", ",", "filename", ",", "section", ",", "vars", ")", ":", "conf", "=", "appconfig", "(", "'config:'", "+", "filename", ")", "load_environment", "(", "conf", ".", "global_conf", ",", "conf", ".", "local_conf", ")" ]
Place any commands to setup cogenircapp here
[ "Place", "any", "commands", "to", "setup", "cogenircapp", "here" ]
python
train
rhgrant10/Groupy
groupy/api/memberships.py
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L248-L259
def get_failed_requests(self, results): """Return the requests that failed. :param results: the results of a membership request check :type results: :class:`list` :return: the failed requests :rtype: generator """ data = {member['guid']: member for member in resu...
[ "def", "get_failed_requests", "(", "self", ",", "results", ")", ":", "data", "=", "{", "member", "[", "'guid'", "]", ":", "member", "for", "member", "in", "results", "}", "for", "request", "in", "self", ".", "requests", ":", "if", "request", "[", "'gui...
Return the requests that failed. :param results: the results of a membership request check :type results: :class:`list` :return: the failed requests :rtype: generator
[ "Return", "the", "requests", "that", "failed", "." ]
python
train
saltstack/salt
salt/states/azurearm_network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1544-L1727
def public_ip_address_present(name, resource_group, tags=None, sku=None, public_ip_allocation_method=None, public_ip_address_version=None, dns_settings=None, idle_timeout_in_minutes=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 ...
[ "def", "public_ip_address_present", "(", "name", ",", "resource_group", ",", "tags", "=", "None", ",", "sku", "=", "None", ",", "public_ip_allocation_method", "=", "None", ",", "public_ip_address_version", "=", "None", ",", "dns_settings", "=", "None", ",", "idl...
.. versionadded:: 2019.2.0 Ensure a public IP address exists. :param name: Name of the public IP address. :param resource_group: The resource group assigned to the public IP address. :param dns_settings: An optional dictionary representing a valid PublicIPAddressDnsSettings o...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
python
train
rochacbruno/dynaconf
dynaconf/base.py
https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/base.py#L729-L732
def reload(self, env=None, silent=None): # pragma: no cover """Clean end Execute all loaders""" self.clean() self.execute_loaders(env, silent)
[ "def", "reload", "(", "self", ",", "env", "=", "None", ",", "silent", "=", "None", ")", ":", "# pragma: no cover", "self", ".", "clean", "(", ")", "self", ".", "execute_loaders", "(", "env", ",", "silent", ")" ]
Clean end Execute all loaders
[ "Clean", "end", "Execute", "all", "loaders" ]
python
train
skggm/skggm
inverse_covariance/profiling/lattice_graph.py
https://github.com/skggm/skggm/blob/a0ed406586c4364ea3297a658f415e13b5cbdaf8/inverse_covariance/profiling/lattice_graph.py#L40-L73
def prototype_adjacency(self, n_block_features, alpha): """Build a new graph. Doc for ".create(n_features, alpha)" Parameters ----------- n_features : int alpha : float (0,1) The complexity / sparsity factor. Each graph will have a minimum of ...
[ "def", "prototype_adjacency", "(", "self", ",", "n_block_features", ",", "alpha", ")", ":", "return", "lattice", "(", "self", ".", "prng", ",", "n_block_features", ",", "alpha", ",", "random_sign", "=", "self", ".", "random_sign", ",", "low", "=", "self", ...
Build a new graph. Doc for ".create(n_features, alpha)" Parameters ----------- n_features : int alpha : float (0,1) The complexity / sparsity factor. Each graph will have a minimum of n_blocks * ceil(alpha * n_block_features) ...
[ "Build", "a", "new", "graph", "." ]
python
train
bcbnz/python-rofi
rofi.py
https://github.com/bcbnz/python-rofi/blob/d20b3a2ba4ba1b294b002f25a8fb526c5115d0d4/rofi.py#L465-L533
def generic_entry(self, prompt, validator=None, message=None, rofi_args=None, **kwargs): """A generic entry box. Parameters ---------- prompt: string Text prompt for the entry. validator: function, optional A function to validate and convert the value ent...
[ "def", "generic_entry", "(", "self", ",", "prompt", ",", "validator", "=", "None", ",", "message", "=", "None", ",", "rofi_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "error", "=", "\"\"", "rofi_args", "=", "rofi_args", "or", "[", "]", "# ...
A generic entry box. Parameters ---------- prompt: string Text prompt for the entry. validator: function, optional A function to validate and convert the value entered by the user. It should take one parameter, the string that the user entered, and ...
[ "A", "generic", "entry", "box", "." ]
python
train
pycontribs/pyrax
pyrax/cloudblockstorage.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L98-L105
def update(self, display_name=None, display_description=None): """ Update the specified values on this snapshot. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ return self.manager...
[ "def", "update", "(", "self", ",", "display_name", "=", "None", ",", "display_description", "=", "None", ")", ":", "return", "self", ".", "manager", ".", "update", "(", "self", ",", "display_name", "=", "display_name", ",", "display_description", "=", "displ...
Update the specified values on this snapshot. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised.
[ "Update", "the", "specified", "values", "on", "this", "snapshot", ".", "You", "may", "specify", "one", "or", "more", "values", "to", "update", ".", "If", "no", "values", "are", "specified", "as", "non", "-", "None", "the", "call", "is", "a", "no", "-",...
python
train
delph-in/pydelphin
delphin/tokens.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L85-L107
def to_dict(self): """ Encode the token as a dictionary suitable for JSON serialization. """ d = { 'id': self.id, 'start': self.start, 'end': self.end, 'form': self.form } if self.lnk is not None: cfrom, cto = se...
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "{", "'id'", ":", "self", ".", "id", ",", "'start'", ":", "self", ".", "start", ",", "'end'", ":", "self", ".", "end", ",", "'form'", ":", "self", ".", "form", "}", "if", "self", ".", "lnk", ...
Encode the token as a dictionary suitable for JSON serialization.
[ "Encode", "the", "token", "as", "a", "dictionary", "suitable", "for", "JSON", "serialization", "." ]
python
train
hasgeek/coaster
coaster/views/misc.py
https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/views/misc.py#L115-L172
def endpoint_for(url, method=None, return_rule=False, follow_redirects=True): """ Given an absolute URL, retrieve the matching endpoint name (or rule) and view arguments. Requires a current request context to determine runtime environment. :param str method: HTTP method to use (defaults to GET) ...
[ "def", "endpoint_for", "(", "url", ",", "method", "=", "None", ",", "return_rule", "=", "False", ",", "follow_redirects", "=", "True", ")", ":", "parsed_url", "=", "urlsplit", "(", "url", ")", "if", "not", "parsed_url", ".", "netloc", ":", "# We require an...
Given an absolute URL, retrieve the matching endpoint name (or rule) and view arguments. Requires a current request context to determine runtime environment. :param str method: HTTP method to use (defaults to GET) :param bool return_rule: Return the URL rule instead of the endpoint name :param bool...
[ "Given", "an", "absolute", "URL", "retrieve", "the", "matching", "endpoint", "name", "(", "or", "rule", ")", "and", "view", "arguments", ".", "Requires", "a", "current", "request", "context", "to", "determine", "runtime", "environment", "." ]
python
train
zhmcclient/python-zhmcclient
zhmcclient/_cpc.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_cpc.py#L1204-L1266
def list_associated_storage_groups( self, full_properties=False, filter_args=None): """ Return the :term:`storage groups <storage group>` that are associated to this CPC. If the CPC does not support the "dpm-storage-management" feature, or does not have it enabled, a...
[ "def", "list_associated_storage_groups", "(", "self", ",", "full_properties", "=", "False", ",", "filter_args", "=", "None", ")", ":", "if", "filter_args", "is", "None", ":", "filter_args", "=", "{", "}", "else", ":", "filter_args", "=", "filter_args", ".", ...
Return the :term:`storage groups <storage group>` that are associated to this CPC. If the CPC does not support the "dpm-storage-management" feature, or does not have it enabled, an empty list is returned. Storage groups for which the authenticated user does not have object-acce...
[ "Return", "the", ":", "term", ":", "storage", "groups", "<storage", "group", ">", "that", "are", "associated", "to", "this", "CPC", "." ]
python
train
attilaolah/diffbot.py
diffbot.py
https://github.com/attilaolah/diffbot.py/blob/b66d68a36a22c944297c0575413db23687029af4/diffbot.py#L33-L46
def _get(url, params=None): """HTTP GET request.""" try: response = requests.get(url, params=params) response.raise_for_status() # If JSON fails, return raw data # (e.g. when downloading CSV job logs). try: return response.json(...
[ "def", "_get", "(", "url", ",", "params", "=", "None", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "params", "=", "params", ")", "response", ".", "raise_for_status", "(", ")", "# If JSON fails, return raw data", "# (e.g....
HTTP GET request.
[ "HTTP", "GET", "request", "." ]
python
train
agile-geoscience/welly
welly/utils.py
https://github.com/agile-geoscience/welly/blob/ed4c991011d6290938fef365553041026ba29f42/welly/utils.py#L326-L370
def moving_average(a, length, mode='valid'): """ From ``bruges`` Computes the mean in a moving window. Naive implementation. Example: >>> test = np.array([1,9,9,9,9,9,9,2,3,9,2,2,3,1,1,1,1,3,4,9,9,9,8,3]) >>> moving_average(test, 7, mode='same') [ 4.42857143, 5.57142857, 6.71...
[ "def", "moving_average", "(", "a", ",", "length", ",", "mode", "=", "'valid'", ")", ":", "pad", "=", "np", ".", "floor", "(", "length", "/", "2", ")", "if", "mode", "==", "'full'", ":", "pad", "*=", "2", "pad", "=", "int", "(", "pad", ")", "# M...
From ``bruges`` Computes the mean in a moving window. Naive implementation. Example: >>> test = np.array([1,9,9,9,9,9,9,2,3,9,2,2,3,1,1,1,1,3,4,9,9,9,8,3]) >>> moving_average(test, 7, mode='same') [ 4.42857143, 5.57142857, 6.71428571, 7.85714286, 8. , 7.14285714, 7....
[ "From", "bruges" ]
python
train
empirical-org/Quill-NLP-Tools-and-Datasets
utils/qfragment/examples/porcupine/app.py
https://github.com/empirical-org/Quill-NLP-Tools-and-Datasets/blob/f2ff579ddf3a556d9cdc47c5f702422fa06863d9/utils/qfragment/examples/porcupine/app.py#L49-L56
def list_submissions(): """List the past submissions with information about them""" submissions = [] try: submissions = session.query(Submission).all() except SQLAlchemyError as e: session.rollback() return render_template('list_submissions.html', submissions=submissions)
[ "def", "list_submissions", "(", ")", ":", "submissions", "=", "[", "]", "try", ":", "submissions", "=", "session", ".", "query", "(", "Submission", ")", ".", "all", "(", ")", "except", "SQLAlchemyError", "as", "e", ":", "session", ".", "rollback", "(", ...
List the past submissions with information about them
[ "List", "the", "past", "submissions", "with", "information", "about", "them" ]
python
train
CalebBell/ht
ht/conv_internal.py
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_internal.py#L634-L677
def turbulent_Petukhov_Kirillov_Popov(Re=None, Pr=None, fd=None): r'''Calculates internal convection Nusselt number for turbulent flows in pipe according to [2]_ and [3]_ as in [1]_. .. math:: Nu = \frac{(f/8)RePr}{C+12.7(f/8)^{1/2}(Pr^{2/3}-1)}\\ C = 1.07 + 900/Re - [0.63/(1+10Pr)] Pa...
[ "def", "turbulent_Petukhov_Kirillov_Popov", "(", "Re", "=", "None", ",", "Pr", "=", "None", ",", "fd", "=", "None", ")", ":", "C", "=", "1.07", "+", "900.", "/", "Re", "-", "(", "0.63", "/", "(", "1.", "+", "10.", "*", "Pr", ")", ")", "return", ...
r'''Calculates internal convection Nusselt number for turbulent flows in pipe according to [2]_ and [3]_ as in [1]_. .. math:: Nu = \frac{(f/8)RePr}{C+12.7(f/8)^{1/2}(Pr^{2/3}-1)}\\ C = 1.07 + 900/Re - [0.63/(1+10Pr)] Parameters ---------- Re : float Reynolds number, [-] ...
[ "r", "Calculates", "internal", "convection", "Nusselt", "number", "for", "turbulent", "flows", "in", "pipe", "according", "to", "[", "2", "]", "_", "and", "[", "3", "]", "_", "as", "in", "[", "1", "]", "_", "." ]
python
train
yyuu/botornado
boto/mturk/connection.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/mturk/connection.py#L515-L523
def notify_workers(self, worker_ids, subject, message_text): """ Send a text message to workers. """ params = {'Subject' : subject, 'MessageText': message_text} self.build_list_params(params, worker_ids, 'WorkerId') return self._process_request('NotifyW...
[ "def", "notify_workers", "(", "self", ",", "worker_ids", ",", "subject", ",", "message_text", ")", ":", "params", "=", "{", "'Subject'", ":", "subject", ",", "'MessageText'", ":", "message_text", "}", "self", ".", "build_list_params", "(", "params", ",", "wo...
Send a text message to workers.
[ "Send", "a", "text", "message", "to", "workers", "." ]
python
train
PythonSanSebastian/docstamp
docstamp/qrcode.py
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/qrcode.py#L44-L58
def _qrcode_to_file(qrcode, out_filepath): """ Save a `qrcode` object into `out_filepath`. Parameters ---------- qrcode: qrcode object out_filepath: str Path to the output file. """ try: qrcode.save(out_filepath) except Exception as exc: raise IOError('Error tryi...
[ "def", "_qrcode_to_file", "(", "qrcode", ",", "out_filepath", ")", ":", "try", ":", "qrcode", ".", "save", "(", "out_filepath", ")", "except", "Exception", "as", "exc", ":", "raise", "IOError", "(", "'Error trying to save QR code file {}.'", ".", "format", "(", ...
Save a `qrcode` object into `out_filepath`. Parameters ---------- qrcode: qrcode object out_filepath: str Path to the output file.
[ "Save", "a", "qrcode", "object", "into", "out_filepath", ".", "Parameters", "----------", "qrcode", ":", "qrcode", "object" ]
python
test
maxzheng/localconfig
localconfig/manager.py
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L398-L414
def _set_comment(self, section, comment, key=None): """ Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to """ if '\n' in comment: comment = '\n# '.j...
[ "def", "_set_comment", "(", "self", ",", "section", ",", "comment", ",", "key", "=", "None", ")", ":", "if", "'\\n'", "in", "comment", ":", "comment", "=", "'\\n# '", ".", "join", "(", "comment", ".", "split", "(", "'\\n'", ")", ")", "comment", "=", ...
Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to
[ "Set", "a", "comment", "for", "section", "or", "key" ]
python
train
astroML/gatspy
gatspy/periodic/template_modeler.py
https://github.com/astroML/gatspy/blob/a8f94082a3f27dfe9cb58165707b883bf28d9223/gatspy/periodic/template_modeler.py#L92-L111
def _chi2(self, theta, period, tmpid, return_gradient=False): """ Compute the chi2 for the given parameters, period, & template Optionally return the gradient for faster optimization """ template = self.templates[tmpid] phase = (self.t / period - theta[2]) % 1 mo...
[ "def", "_chi2", "(", "self", ",", "theta", ",", "period", ",", "tmpid", ",", "return_gradient", "=", "False", ")", ":", "template", "=", "self", ".", "templates", "[", "tmpid", "]", "phase", "=", "(", "self", ".", "t", "/", "period", "-", "theta", ...
Compute the chi2 for the given parameters, period, & template Optionally return the gradient for faster optimization
[ "Compute", "the", "chi2", "for", "the", "given", "parameters", "period", "&", "template" ]
python
train
ultrabug/py3status
py3status/core.py
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/core.py#L455-L468
def get_user_configured_modules(self): """ Get a dict of all available and configured py3status modules in the user's i3status.conf. """ user_modules = {} if not self.py3_modules: return user_modules for module_name, module_info in self.get_user_module...
[ "def", "get_user_configured_modules", "(", "self", ")", ":", "user_modules", "=", "{", "}", "if", "not", "self", ".", "py3_modules", ":", "return", "user_modules", "for", "module_name", ",", "module_info", "in", "self", ".", "get_user_modules", "(", ")", ".", ...
Get a dict of all available and configured py3status modules in the user's i3status.conf.
[ "Get", "a", "dict", "of", "all", "available", "and", "configured", "py3status", "modules", "in", "the", "user", "s", "i3status", ".", "conf", "." ]
python
train
xflows/rdm
rdm/db/converters.py
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L304-L314
def target_Orange_table(self): ''' Returns the target table as an Orange example table. :rtype: orange.ExampleTable ''' table, cls_att = self.db.target_table, self.db.target_att if not self.db.orng_tables: return self.convert_table(table, cls_att=cls_att)...
[ "def", "target_Orange_table", "(", "self", ")", ":", "table", ",", "cls_att", "=", "self", ".", "db", ".", "target_table", ",", "self", ".", "db", ".", "target_att", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "self", ".", "conve...
Returns the target table as an Orange example table. :rtype: orange.ExampleTable
[ "Returns", "the", "target", "table", "as", "an", "Orange", "example", "table", "." ]
python
train
quantopian/empyrical
empyrical/stats.py
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L937-L960
def _to_pandas(ob): """Convert an array-like to a pandas object. Parameters ---------- ob : array-like The object to convert. Returns ------- pandas_structure : pd.Series or pd.DataFrame The correct structure based on the dimensionality of the data. """ if isinstanc...
[ "def", "_to_pandas", "(", "ob", ")", ":", "if", "isinstance", "(", "ob", ",", "(", "pd", ".", "Series", ",", "pd", ".", "DataFrame", ")", ")", ":", "return", "ob", "if", "ob", ".", "ndim", "==", "1", ":", "return", "pd", ".", "Series", "(", "ob...
Convert an array-like to a pandas object. Parameters ---------- ob : array-like The object to convert. Returns ------- pandas_structure : pd.Series or pd.DataFrame The correct structure based on the dimensionality of the data.
[ "Convert", "an", "array", "-", "like", "to", "a", "pandas", "object", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/lxml/html/__init__.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/lxml/html/__init__.py#L918-L953
def submit_form(form, extra_values=None, open_http=None): """ Helper function to submit a form. Returns a file-like object, as from ``urllib.urlopen()``. This object also has a ``.geturl()`` function, which shows the URL if there were any redirects. You can use this like:: form = doc.for...
[ "def", "submit_form", "(", "form", ",", "extra_values", "=", "None", ",", "open_http", "=", "None", ")", ":", "values", "=", "form", ".", "form_values", "(", ")", "if", "extra_values", ":", "if", "hasattr", "(", "extra_values", ",", "'items'", ")", ":", ...
Helper function to submit a form. Returns a file-like object, as from ``urllib.urlopen()``. This object also has a ``.geturl()`` function, which shows the URL if there were any redirects. You can use this like:: form = doc.forms[0] form.inputs['foo'].value = 'bar' # etc response ...
[ "Helper", "function", "to", "submit", "a", "form", ".", "Returns", "a", "file", "-", "like", "object", "as", "from", "urllib", ".", "urlopen", "()", ".", "This", "object", "also", "has", "a", ".", "geturl", "()", "function", "which", "shows", "the", "U...
python
test
twilio/twilio-python
twilio/rest/messaging/v1/service/alpha_sender.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/messaging/v1/service/alpha_sender.py#L303-L317
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AlphaSenderContext for this AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_se...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "AlphaSenderContext", "(", "self", ".", "_version", ",", "service_sid", "=", "self", ".", "_solution", "[", "'service_sid'", "]", ",",...
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AlphaSenderContext for this AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L674-L684
def _AddFieldPaths(node, prefix, field_mask): """Adds the field paths descended from node to field_mask.""" if not node: field_mask.paths.append(prefix) return for name in sorted(node): if prefix: child_path = prefix + '.' + name else: child_path = name _AddFieldPaths(node[name], c...
[ "def", "_AddFieldPaths", "(", "node", ",", "prefix", ",", "field_mask", ")", ":", "if", "not", "node", ":", "field_mask", ".", "paths", ".", "append", "(", "prefix", ")", "return", "for", "name", "in", "sorted", "(", "node", ")", ":", "if", "prefix", ...
Adds the field paths descended from node to field_mask.
[ "Adds", "the", "field", "paths", "descended", "from", "node", "to", "field_mask", "." ]
python
train
AguaClara/aguaclara
aguaclara/design/cdc.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/cdc.py#L33-L43
def viscosity_kinematic_alum(conc_alum, temp): """Return the dynamic viscosity of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. This function assumes that the temperature dependence can be explained ...
[ "def", "viscosity_kinematic_alum", "(", "conc_alum", ",", "temp", ")", ":", "nu", "=", "(", "1", "+", "(", "4.255", "*", "10", "**", "-", "6", ")", "*", "conc_alum", "**", "2.289", ")", "*", "pc", ".", "viscosity_kinematic", "(", "temp", ")", ".", ...
Return the dynamic viscosity of water at a given temperature. If given units, the function will automatically convert to Kelvin. If not given units, the function will assume Kelvin. This function assumes that the temperature dependence can be explained based on the effect on water and that there is no ...
[ "Return", "the", "dynamic", "viscosity", "of", "water", "at", "a", "given", "temperature", "." ]
python
train
ajvb/webpype
webpype/client.py
https://github.com/ajvb/webpype/blob/cc9ed84c81b98a83925630b417ddb67b7567b677/webpype/client.py#L82-L100
def execute_from_file(self, url, file_var): ''' Identical to WebPypeClient.execute(), except this function accepts a file path or file type instead of a dictionary. ''' if isinstance(file_var, file): f = file_var elif isinstance(file_var, str): tr...
[ "def", "execute_from_file", "(", "self", ",", "url", ",", "file_var", ")", ":", "if", "isinstance", "(", "file_var", ",", "file", ")", ":", "f", "=", "file_var", "elif", "isinstance", "(", "file_var", ",", "str", ")", ":", "try", ":", "f", "=", "open...
Identical to WebPypeClient.execute(), except this function accepts a file path or file type instead of a dictionary.
[ "Identical", "to", "WebPypeClient", ".", "execute", "()", "except", "this", "function", "accepts", "a", "file", "path", "or", "file", "type", "instead", "of", "a", "dictionary", "." ]
python
train
dturanski/springcloudstream
springcloudstream/tcp/tcp.py
https://github.com/dturanski/springcloudstream/blob/208b542f9eba82e97882d52703af8e965a62a980/springcloudstream/tcp/tcp.py#L97-L112
def create_handler(cls, message_handler, buffer_size, logger): """ Class variables used here since the framework creates an instance for each connection :param message_handler: the MessageHandler used to process each message. :param buffer_size: the TCP buffer size. :param logge...
[ "def", "create_handler", "(", "cls", ",", "message_handler", ",", "buffer_size", ",", "logger", ")", ":", "cls", ".", "BUFFER_SIZE", "=", "buffer_size", "cls", ".", "message_handler", "=", "message_handler", "cls", ".", "logger", "=", "logger", "cls", ".", "...
Class variables used here since the framework creates an instance for each connection :param message_handler: the MessageHandler used to process each message. :param buffer_size: the TCP buffer size. :param logger: the global logger. :return: this class.
[ "Class", "variables", "used", "here", "since", "the", "framework", "creates", "an", "instance", "for", "each", "connection" ]
python
train