repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
CxAalto/gtfspy
gtfspy/osm_transfers.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/osm_transfers.py#L15-L74
def add_walk_distances_to_db_python(gtfs, osm_path, cutoff_distance_m=1000): """ Computes the walk paths between stops, and updates these to the gtfs database. Parameters ---------- gtfs: gtfspy.GTFS or str A GTFS object or a string representation. osm_path: str path to the Open...
[ "def", "add_walk_distances_to_db_python", "(", "gtfs", ",", "osm_path", ",", "cutoff_distance_m", "=", "1000", ")", ":", "if", "isinstance", "(", "gtfs", ",", "str", ")", ":", "gtfs", "=", "GTFS", "(", "gtfs", ")", "assert", "(", "isinstance", "(", "gtfs",...
Computes the walk paths between stops, and updates these to the gtfs database. Parameters ---------- gtfs: gtfspy.GTFS or str A GTFS object or a string representation. osm_path: str path to the OpenStreetMap file cutoff_distance_m: number maximum allowed distance in meters ...
[ "Computes", "the", "walk", "paths", "between", "stops", "and", "updates", "these", "to", "the", "gtfs", "database", "." ]
python
valid
43.966667
hatemile/hatemile-for-python
hatemile/implementation/css.py
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/css.py#L423-L443
def _get_regular_expression_of_symbols(self): """ Returns the regular expression to search all symbols. :return: The regular expression to search all symbols. :rtype: str """ regular_expression = None for symbol in self.symbols: formated_symbol = sel...
[ "def", "_get_regular_expression_of_symbols", "(", "self", ")", ":", "regular_expression", "=", "None", "for", "symbol", "in", "self", ".", "symbols", ":", "formated_symbol", "=", "self", ".", "_get_formated_symbol", "(", "symbol", "[", "'symbol'", "]", ")", "if"...
Returns the regular expression to search all symbols. :return: The regular expression to search all symbols. :rtype: str
[ "Returns", "the", "regular", "expression", "to", "search", "all", "symbols", "." ]
python
train
32.714286
mitsei/dlkit
dlkit/records/osid/base_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/osid/base_records.py#L2260-L2295
def clear_file(self): """stub""" if (self.get_file_metadata().is_read_only() or self.get_file_metadata().is_required()): raise NoAccess() if 'assetId' in self.my_osid_object_form._my_map['fileId']: rm = self.my_osid_object_form._get_provider_manager('REPOS...
[ "def", "clear_file", "(", "self", ")", ":", "if", "(", "self", ".", "get_file_metadata", "(", ")", ".", "is_read_only", "(", ")", "or", "self", ".", "get_file_metadata", "(", ")", ".", "is_required", "(", ")", ")", ":", "raise", "NoAccess", "(", ")", ...
stub
[ "stub" ]
python
train
45.666667
quantumlib/Cirq
cirq/linalg/predicates.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/predicates.py#L114-L134
def is_unitary( matrix: np.ndarray, *, rtol: float = 1e-5, atol: float = 1e-8) -> bool: """Determines if a matrix is approximately unitary. A matrix is unitary if it's square and its adjoint is its inverse. Args: matrix: The matrix to check. rtol: The per-ma...
[ "def", "is_unitary", "(", "matrix", ":", "np", ".", "ndarray", ",", "*", ",", "rtol", ":", "float", "=", "1e-5", ",", "atol", ":", "float", "=", "1e-8", ")", "->", "bool", ":", "return", "(", "matrix", ".", "shape", "[", "0", "]", "==", "matrix",...
Determines if a matrix is approximately unitary. A matrix is unitary if it's square and its adjoint is its inverse. Args: matrix: The matrix to check. rtol: The per-matrix-entry relative tolerance on equality. atol: The per-matrix-entry absolute tolerance on equality. Returns: ...
[ "Determines", "if", "a", "matrix", "is", "approximately", "unitary", "." ]
python
train
33.285714
fboender/ansible-cmdb
src/ansiblecmdb/parser.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/src/ansiblecmdb/parser.py#L194-L214
def _parse_vars(self, tokens): """ Given an iterable of tokens, returns variables and their values as a dictionary. For example: ['dtap=prod', 'comment=some comment'] Returns: {'dtap': 'prod', 'comment': 'some comment'} """ key_values = {}...
[ "def", "_parse_vars", "(", "self", ",", "tokens", ")", ":", "key_values", "=", "{", "}", "for", "token", "in", "tokens", ":", "if", "token", ".", "startswith", "(", "'#'", ")", ":", "# End parsing if we encounter a comment, which lasts", "# until the end of the li...
Given an iterable of tokens, returns variables and their values as a dictionary. For example: ['dtap=prod', 'comment=some comment'] Returns: {'dtap': 'prod', 'comment': 'some comment'}
[ "Given", "an", "iterable", "of", "tokens", "returns", "variables", "and", "their", "values", "as", "a", "dictionary", "." ]
python
train
31.714286
rackerlabs/simpl
simpl/db/mongodb.py
https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/db/mongodb.py#L567-L594
def _transform_incoming(self, son, collection, skip=0): """Recursively replace all keys that need transforming.""" skip = 0 if skip < 0 else skip if isinstance(son, dict): for (key, value) in son.items(): if key.startswith('$'): if isinstance(value...
[ "def", "_transform_incoming", "(", "self", ",", "son", ",", "collection", ",", "skip", "=", "0", ")", ":", "skip", "=", "0", "if", "skip", "<", "0", "else", "skip", "if", "isinstance", "(", "son", ",", "dict", ")", ":", "for", "(", "key", ",", "v...
Recursively replace all keys that need transforming.
[ "Recursively", "replace", "all", "keys", "that", "need", "transforming", "." ]
python
train
46
jantman/awslimitchecker
awslimitchecker/services/base.py
https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/base.py#L172-L205
def set_limit_override(self, limit_name, value, override_ta=True): """ Set a new limit ``value`` for the specified limit, overriding the default. If ``override_ta`` is True, also use this value instead of any found by Trusted Advisor. This method simply passes the data through to...
[ "def", "set_limit_override", "(", "self", ",", "limit_name", ",", "value", ",", "override_ta", "=", "True", ")", ":", "try", ":", "self", ".", "limits", "[", "limit_name", "]", ".", "set_limit_override", "(", "value", ",", "override_ta", "=", "override_ta", ...
Set a new limit ``value`` for the specified limit, overriding the default. If ``override_ta`` is True, also use this value instead of any found by Trusted Advisor. This method simply passes the data through to the :py:meth:`~awslimitchecker.limit.AwsLimit.set_limit_override` meth...
[ "Set", "a", "new", "limit", "value", "for", "the", "specified", "limit", "overriding", "the", "default", ".", "If", "override_ta", "is", "True", "also", "use", "this", "value", "instead", "of", "any", "found", "by", "Trusted", "Advisor", ".", "This", "meth...
python
train
40.705882
rocky/python3-trepan
celery/ctrepan.py
https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/celery/ctrepan.py#L113-L122
def debug(frame=None): """Set breakpoint at current location, or a specified frame""" # ??? if frame is None: frame = _frame().f_back dbg = RemoteCeleryTrepan() dbg.say(BANNER.format(self=dbg)) # dbg.say(SESSION_STARTED.format(self=dbg)) trepan.api.debug(dbg_opts=dbg.dbg_opts)
[ "def", "debug", "(", "frame", "=", "None", ")", ":", "# ???", "if", "frame", "is", "None", ":", "frame", "=", "_frame", "(", ")", ".", "f_back", "dbg", "=", "RemoteCeleryTrepan", "(", ")", "dbg", ".", "say", "(", "BANNER", ".", "format", "(", "self...
Set breakpoint at current location, or a specified frame
[ "Set", "breakpoint", "at", "current", "location", "or", "a", "specified", "frame" ]
python
test
30.5
gwastro/pycbc-glue
pycbc_glue/ligolw/table.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/table.py#L934-L942
def removeChild(self, child): """ Remove a child from this element. The child element is returned, and it's parentNode element is reset. """ super(Table, self).removeChild(child) if child.tagName == ligolw.Column.tagName: self._update_column_info() return child
[ "def", "removeChild", "(", "self", ",", "child", ")", ":", "super", "(", "Table", ",", "self", ")", ".", "removeChild", "(", "child", ")", "if", "child", ".", "tagName", "==", "ligolw", ".", "Column", ".", "tagName", ":", "self", ".", "_update_column_i...
Remove a child from this element. The child element is returned, and it's parentNode element is reset.
[ "Remove", "a", "child", "from", "this", "element", ".", "The", "child", "element", "is", "returned", "and", "it", "s", "parentNode", "element", "is", "reset", "." ]
python
train
30.111111
spyder-ide/spyder
spyder/plugins/editor/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2197-L2202
def set_or_edit_conditional_breakpoint(self): """Set/Edit conditional breakpoint""" editorstack = self.get_current_editorstack() if editorstack is not None: self.switch_to_plugin() editorstack.set_or_edit_conditional_breakpoint()
[ "def", "set_or_edit_conditional_breakpoint", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "editorstack", ".", "set_or_edit_con...
Set/Edit conditional breakpoint
[ "Set", "/", "Edit", "conditional", "breakpoint" ]
python
train
46.166667
manns/pyspread
pyspread/src/gui/grid_panels.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/grid_panels.py#L149-L160
def OnShiftVideo(self, event): """Shifts through the video""" length = self.player.get_length() time = self.player.get_time() if event.GetWheelRotation() < 0: target_time = max(0, time-length/100.0) elif event.GetWheelRotation() > 0: target_time = min(le...
[ "def", "OnShiftVideo", "(", "self", ",", "event", ")", ":", "length", "=", "self", ".", "player", ".", "get_length", "(", ")", "time", "=", "self", ".", "player", ".", "get_time", "(", ")", "if", "event", ".", "GetWheelRotation", "(", ")", "<", "0", ...
Shifts through the video
[ "Shifts", "through", "the", "video" ]
python
train
31.75
idlesign/uwsgiconf
uwsgiconf/options/caching.py
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/options/caching.py#L19-L37
def set_basic_params(self, no_expire=None, expire_scan_interval=None, report_freed=None): """ :param bool no_expire: Disable auto sweep of expired items. Since uWSGI 1.2, cache item expiration is managed by a thread in the master process, to reduce the risk of deadlock. This thre...
[ "def", "set_basic_params", "(", "self", ",", "no_expire", "=", "None", ",", "expire_scan_interval", "=", "None", ",", "report_freed", "=", "None", ")", ":", "self", ".", "_set", "(", "'cache-no-expire'", ",", "no_expire", ",", "cast", "=", "bool", ")", "se...
:param bool no_expire: Disable auto sweep of expired items. Since uWSGI 1.2, cache item expiration is managed by a thread in the master process, to reduce the risk of deadlock. This thread can be disabled (making item expiry a no-op) with the this option. :param int expire_s...
[ ":", "param", "bool", "no_expire", ":", "Disable", "auto", "sweep", "of", "expired", "items", ".", "Since", "uWSGI", "1", ".", "2", "cache", "item", "expiration", "is", "managed", "by", "a", "thread", "in", "the", "master", "process", "to", "reduce", "th...
python
train
45.368421
scheibler/khard
khard/address_book.py
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L202-L215
def get_short_uid(self, uid): """Get the shortend UID for the given UID. :param uid: the full UID to shorten :type uid: str :returns: the shortend uid or the empty string :rtype: str """ if uid: short_uids = self.get_short_uid_dict() for l...
[ "def", "get_short_uid", "(", "self", ",", "uid", ")", ":", "if", "uid", ":", "short_uids", "=", "self", ".", "get_short_uid_dict", "(", ")", "for", "length_of_uid", "in", "range", "(", "len", "(", "uid", ")", ",", "0", ",", "-", "1", ")", ":", "if"...
Get the shortend UID for the given UID. :param uid: the full UID to shorten :type uid: str :returns: the shortend uid or the empty string :rtype: str
[ "Get", "the", "shortend", "UID", "for", "the", "given", "UID", "." ]
python
test
34.214286
jtauber/sebastian
sebastian/core/elements.py
https://github.com/jtauber/sebastian/blob/4e460c3aeab332b45c74fe78e65e76ec87d5cfa8/sebastian/core/elements.py#L226-L231
def append(self, point): """ appends a copy of the given point to this sequence """ point = Point(point) self._elements.append(point)
[ "def", "append", "(", "self", ",", "point", ")", ":", "point", "=", "Point", "(", "point", ")", "self", ".", "_elements", ".", "append", "(", "point", ")" ]
appends a copy of the given point to this sequence
[ "appends", "a", "copy", "of", "the", "given", "point", "to", "this", "sequence" ]
python
train
28
pybel/pybel-tools
src/pybel_tools/selection/induce_subgraph.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/induce_subgraph.py#L35-L44
def get_subgraph_by_node_search(graph: BELGraph, query: Strings) -> BELGraph: """Get a sub-graph induced over all nodes matching the query string. :param graph: A BEL Graph :param query: A query string or iterable of query strings for node names Thinly wraps :func:`search_node_names` and :func:`get_su...
[ "def", "get_subgraph_by_node_search", "(", "graph", ":", "BELGraph", ",", "query", ":", "Strings", ")", "->", "BELGraph", ":", "nodes", "=", "search_node_names", "(", "graph", ",", "query", ")", "return", "get_subgraph_by_induction", "(", "graph", ",", "nodes", ...
Get a sub-graph induced over all nodes matching the query string. :param graph: A BEL Graph :param query: A query string or iterable of query strings for node names Thinly wraps :func:`search_node_names` and :func:`get_subgraph_by_induction`.
[ "Get", "a", "sub", "-", "graph", "induced", "over", "all", "nodes", "matching", "the", "query", "string", "." ]
python
valid
43.5
CalebBell/fluids
fluids/core.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L2202-L2238
def gravity(latitude, H): r'''Calculates local acceleration due to gravity `g` according to [1]_. Uses latitude and height to calculate `g`. .. math:: g = 9.780356(1 + 0.0052885\sin^2\phi - 0.0000059^22\phi) - 3.086\times 10^{-6} H Parameters ---------- latitude : float ...
[ "def", "gravity", "(", "latitude", ",", "H", ")", ":", "lat", "=", "latitude", "*", "pi", "/", "180", "g", "=", "9.780356", "*", "(", "1", "+", "0.0052885", "*", "sin", "(", "lat", ")", "**", "2", "-", "0.0000059", "*", "sin", "(", "2", "*", ...
r'''Calculates local acceleration due to gravity `g` according to [1]_. Uses latitude and height to calculate `g`. .. math:: g = 9.780356(1 + 0.0052885\sin^2\phi - 0.0000059^22\phi) - 3.086\times 10^{-6} H Parameters ---------- latitude : float Degrees, [degrees] H : fl...
[ "r", "Calculates", "local", "acceleration", "due", "to", "gravity", "g", "according", "to", "[", "1", "]", "_", ".", "Uses", "latitude", "and", "height", "to", "calculate", "g", "." ]
python
train
23.72973
adamrehn/ue4cli
ue4cli/ThirdPartyLibraryDetails.py
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L118-L122
def getPreprocessorDefinitions(self, engineRoot, delimiter=' '): """ Returns the list of preprocessor definitions for this library, joined using the specified delimiter """ return delimiter.join(self.resolveRoot(self.definitions, engineRoot))
[ "def", "getPreprocessorDefinitions", "(", "self", ",", "engineRoot", ",", "delimiter", "=", "' '", ")", ":", "return", "delimiter", ".", "join", "(", "self", ".", "resolveRoot", "(", "self", ".", "definitions", ",", "engineRoot", ")", ")" ]
Returns the list of preprocessor definitions for this library, joined using the specified delimiter
[ "Returns", "the", "list", "of", "preprocessor", "definitions", "for", "this", "library", "joined", "using", "the", "specified", "delimiter" ]
python
train
49.2
sorgerlab/indra
indra/sources/sparser/api.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L190-L212
def process_xml(xml_str): """Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXM...
[ "def", "process_xml", "(", "xml_str", ")", ":", "try", ":", "tree", "=", "ET", ".", "XML", "(", "xml_str", ",", "parser", "=", "UTB", "(", ")", ")", "except", "ET", ".", "ParseError", "as", "e", ":", "logger", ".", "error", "(", "'Could not parse XML...
Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXMLProcessor which has extracted St...
[ "Return", "processor", "with", "Statements", "extracted", "from", "a", "Sparser", "XML", "." ]
python
train
26.695652
genialis/resolwe
resolwe/flow/elastic_indexes/base.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L61-L66
def get_owner_names_value(self, obj): """Extract owners' names.""" return [ self._get_user(user) for user in get_users_with_permission(obj, get_full_perm('owner', obj)) ]
[ "def", "get_owner_names_value", "(", "self", ",", "obj", ")", ":", "return", "[", "self", ".", "_get_user", "(", "user", ")", "for", "user", "in", "get_users_with_permission", "(", "obj", ",", "get_full_perm", "(", "'owner'", ",", "obj", ")", ")", "]" ]
Extract owners' names.
[ "Extract", "owners", "names", "." ]
python
train
35.5
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1611-L1638
def get_work_item_template(self, project, type, fields=None, as_of=None, expand=None): """GetWorkItemTemplate. [Preview API] Returns a single work item from a template. :param str project: Project ID or project name :param str type: The work item type name :param str fields: Comm...
[ "def", "get_work_item_template", "(", "self", ",", "project", ",", "type", ",", "fields", "=", "None", ",", "as_of", "=", "None", ",", "expand", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_val...
GetWorkItemTemplate. [Preview API] Returns a single work item from a template. :param str project: Project ID or project name :param str type: The work item type name :param str fields: Comma-separated list of requested fields :param datetime as_of: AsOf UTC date time string ...
[ "GetWorkItemTemplate", ".", "[", "Preview", "API", "]", "Returns", "a", "single", "work", "item", "from", "a", "template", ".", ":", "param", "str", "project", ":", "Project", "ID", "or", "project", "name", ":", "param", "str", "type", ":", "The", "work"...
python
train
58.035714
gccxml/pygccxml
pygccxml/declarations/scopedef.py
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L457-L470
def _find_single(self, match_class, **keywds): """implementation details""" self._logger.debug('find single query execution - started') start_time = timeit.default_timer() norm_keywds = self.__normalize_args(**keywds) decl_matcher = self.__create_matcher(match_class, **norm_keywd...
[ "def", "_find_single", "(", "self", ",", "match_class", ",", "*", "*", "keywds", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'find single query execution - started'", ")", "start_time", "=", "timeit", ".", "default_timer", "(", ")", "norm_keywds", "=...
implementation details
[ "implementation", "details" ]
python
train
53.071429
estnltk/estnltk
estnltk/text.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L238-L249
def spans(self, layer): """Retrieve (start, end) tuples denoting the spans of given layer elements. Returns ------- list of (int, int) List of (start, end) tuples. """ spans = [] for data in self[layer]: spans.append((data[START], data[END...
[ "def", "spans", "(", "self", ",", "layer", ")", ":", "spans", "=", "[", "]", "for", "data", "in", "self", "[", "layer", "]", ":", "spans", ".", "append", "(", "(", "data", "[", "START", "]", ",", "data", "[", "END", "]", ")", ")", "return", "...
Retrieve (start, end) tuples denoting the spans of given layer elements. Returns ------- list of (int, int) List of (start, end) tuples.
[ "Retrieve", "(", "start", "end", ")", "tuples", "denoting", "the", "spans", "of", "given", "layer", "elements", "." ]
python
train
27.75
mongodb/mongo-python-driver
bson/__init__.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/bson/__init__.py#L399-L416
def _element_to_dict(data, position, obj_end, opts): """Decode a single key, value pair.""" element_type = data[position:position + 1] position += 1 element_name, position = _get_c_string(data, position, opts) try: value, position = _ELEMENT_GETTER[element_type](data, position, ...
[ "def", "_element_to_dict", "(", "data", ",", "position", ",", "obj_end", ",", "opts", ")", ":", "element_type", "=", "data", "[", "position", ":", "position", "+", "1", "]", "position", "+=", "1", "element_name", ",", "position", "=", "_get_c_string", "(",...
Decode a single key, value pair.
[ "Decode", "a", "single", "key", "value", "pair", "." ]
python
train
41.388889
tylertreat/BigQuery-Python
bigquery/client.py
https://github.com/tylertreat/BigQuery-Python/blob/88d99de42d954d49fc281460068f0e95003da098/bigquery/client.py#L1583-L1603
def _filter_tables_by_time(self, tables, start_time, end_time): """Filter a table dictionary and return table names based on the range of start and end times in unix seconds. Parameters ---------- tables : dict Dates referenced by table names start_time : int...
[ "def", "_filter_tables_by_time", "(", "self", ",", "tables", ",", "start_time", ",", "end_time", ")", ":", "return", "[", "table_name", "for", "(", "table_name", ",", "unix_seconds", ")", "in", "tables", ".", "items", "(", ")", "if", "self", ".", "_in_rang...
Filter a table dictionary and return table names based on the range of start and end times in unix seconds. Parameters ---------- tables : dict Dates referenced by table names start_time : int The unix time after which records will be fetched end_...
[ "Filter", "a", "table", "dictionary", "and", "return", "table", "names", "based", "on", "the", "range", "of", "start", "and", "end", "times", "in", "unix", "seconds", "." ]
python
train
33.714286
wbond/asn1crypto
asn1crypto/core.py
https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/core.py#L4329-L4344
def dump(self, force=False): """ Encodes the value using DER :param force: If the encoded contents already exist, clear them and regenerate to ensure they are in DER format instead of BER format :return: A byte string of the DER-encoded value ...
[ "def", "dump", "(", "self", ",", "force", "=", "False", ")", ":", "if", "force", ":", "self", ".", "_set_contents", "(", "force", "=", "force", ")", "return", "Asn1Value", ".", "dump", "(", "self", ")" ]
Encodes the value using DER :param force: If the encoded contents already exist, clear them and regenerate to ensure they are in DER format instead of BER format :return: A byte string of the DER-encoded value
[ "Encodes", "the", "value", "using", "DER" ]
python
train
25.5625
Tethik/flask-session-captcha
flask_session_captcha/__init__.py
https://github.com/Tethik/flask-session-captcha/blob/02bb68b9563ecc4967650b49b4c8447fecbc92d6/flask_session_captcha/__init__.py#L43-L58
def generate(self): """ Generates and returns a numeric captcha image in base64 format. Saves the correct answer in `session['captcha_answer']` Use later as: src = captcha.generate() <img src="{{src}}"> """ answer = self.rand.randrange(se...
[ "def", "generate", "(", "self", ")", ":", "answer", "=", "self", ".", "rand", ".", "randrange", "(", "self", ".", "max", ")", "answer", "=", "str", "(", "answer", ")", ".", "zfill", "(", "self", ".", "digits", ")", "image_data", "=", "self", ".", ...
Generates and returns a numeric captcha image in base64 format. Saves the correct answer in `session['captcha_answer']` Use later as: src = captcha.generate() <img src="{{src}}">
[ "Generates", "and", "returns", "a", "numeric", "captcha", "image", "in", "base64", "format", ".", "Saves", "the", "correct", "answer", "in", "session", "[", "captcha_answer", "]", "Use", "later", "as", ":" ]
python
train
40.4375
un33k/django-toolware
toolware/utils/convert.py
https://github.com/un33k/django-toolware/blob/973f3e003dc38b812897dab88455bee37dcaf931/toolware/utils/convert.py#L20-L26
def md_to_text(content): """ Converts markdown content to text """ text = None html = markdown.markdown(content) if html: text = html_to_text(content) return text
[ "def", "md_to_text", "(", "content", ")", ":", "text", "=", "None", "html", "=", "markdown", ".", "markdown", "(", "content", ")", "if", "html", ":", "text", "=", "html_to_text", "(", "content", ")", "return", "text" ]
Converts markdown content to text
[ "Converts", "markdown", "content", "to", "text" ]
python
test
26.285714
SCIP-Interfaces/PySCIPOpt
examples/finished/atsp.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/atsp.py#L172-L182
def sequence(arcs): """sequence: make a list of cities to visit, from set of arcs""" succ = {} for (i,j) in arcs: succ[i] = j curr = 1 # first node being visited sol = [curr] for i in range(len(arcs)-2): curr = succ[curr] sol.append(curr) return sol
[ "def", "sequence", "(", "arcs", ")", ":", "succ", "=", "{", "}", "for", "(", "i", ",", "j", ")", "in", "arcs", ":", "succ", "[", "i", "]", "=", "j", "curr", "=", "1", "# first node being visited", "sol", "=", "[", "curr", "]", "for", "i", "in",...
sequence: make a list of cities to visit, from set of arcs
[ "sequence", ":", "make", "a", "list", "of", "cities", "to", "visit", "from", "set", "of", "arcs" ]
python
train
26.727273
Tanganelli/CoAPthon3
coapthon/client/helperclient.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/client/helperclient.py#L264-L277
def mk_request_non(self, method, path): """ Create a request. :param method: the CoAP method :param path: the path of the request :return: the request """ request = Request() request.destination = self.server request.code = method.number ...
[ "def", "mk_request_non", "(", "self", ",", "method", ",", "path", ")", ":", "request", "=", "Request", "(", ")", "request", ".", "destination", "=", "self", ".", "server", "request", ".", "code", "=", "method", ".", "number", "request", ".", "uri_path", ...
Create a request. :param method: the CoAP method :param path: the path of the request :return: the request
[ "Create", "a", "request", "." ]
python
train
28.357143
Music-Moo/music2storage
music2storage/connection.py
https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/connection.py#L36-L58
def use_storage_service(self, service_name, custom_path): """ Sets the current storage service to service_name and runs the connect method on the service. :param str service_name: Name of the storage service :param str custom_path: Custom path where to download tracks for local storage ...
[ "def", "use_storage_service", "(", "self", ",", "service_name", ",", "custom_path", ")", ":", "try", ":", "self", ".", "current_storage", "=", "self", ".", "storage_services", "[", "service_name", "]", "except", "KeyError", ":", "if", "service_name", "==", "'g...
Sets the current storage service to service_name and runs the connect method on the service. :param str service_name: Name of the storage service :param str custom_path: Custom path where to download tracks for local storage (optional, and must already exist, use absolute paths only)
[ "Sets", "the", "current", "storage", "service", "to", "service_name", "and", "runs", "the", "connect", "method", "on", "the", "service", "." ]
python
test
50.26087
sosy-lab/benchexec
benchexec/check_cgroups.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/check_cgroups.py#L36-L80
def check_cgroup_availability(wait=1): """ Basic utility to check the availability and permissions of cgroups. This will log some warnings for the user if necessary. On some systems, daemons such as cgrulesengd might interfere with the cgroups of a process soon after it was started. Thus this functi...
[ "def", "check_cgroup_availability", "(", "wait", "=", "1", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "\"%(levelname)s: %(message)s\"", ")", "runexecutor", "=", "RunExecutor", "(", ")", "my_cgroups", "=", "runexecutor", ".", "cgroups", "if", "n...
Basic utility to check the availability and permissions of cgroups. This will log some warnings for the user if necessary. On some systems, daemons such as cgrulesengd might interfere with the cgroups of a process soon after it was started. Thus this function starts a process, waits a configurable amoun...
[ "Basic", "utility", "to", "check", "the", "availability", "and", "permissions", "of", "cgroups", ".", "This", "will", "log", "some", "warnings", "for", "the", "user", "if", "necessary", ".", "On", "some", "systems", "daemons", "such", "as", "cgrulesengd", "m...
python
train
51.666667
aestrivex/bctpy
bct/algorithms/centrality.py
https://github.com/aestrivex/bctpy/blob/4cb0e759eb4a038750b07e23bd29958c400684b8/bct/algorithms/centrality.py#L703-L742
def participation_coef(W, ci, degree='undirected'): ''' Participation coefficient is a measure of diversity of intermodular connections of individual nodes. Parameters ---------- W : NxN np.ndarray binary/weighted directed/undirected connection matrix ci : Nx1 np.ndarray com...
[ "def", "participation_coef", "(", "W", ",", "ci", ",", "degree", "=", "'undirected'", ")", ":", "if", "degree", "==", "'in'", ":", "W", "=", "W", ".", "T", "_", ",", "ci", "=", "np", ".", "unique", "(", "ci", ",", "return_inverse", "=", "True", "...
Participation coefficient is a measure of diversity of intermodular connections of individual nodes. Parameters ---------- W : NxN np.ndarray binary/weighted directed/undirected connection matrix ci : Nx1 np.ndarray community affiliation vector degree : str Flag to descr...
[ "Participation", "coefficient", "is", "a", "measure", "of", "diversity", "of", "intermodular", "connections", "of", "individual", "nodes", "." ]
python
train
29.525
saltstack/salt
salt/proxy/dummy.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/dummy.py#L189-L198
def uptodate(): ''' Call the REST endpoint to see if the packages on the "server" are up to date. ''' DETAILS = _load_state() for p in DETAILS['packages']: version_float = float(DETAILS['packages'][p]) version_float = version_float + 1.0 DETAILS['packages'][p] = six.text_type...
[ "def", "uptodate", "(", ")", ":", "DETAILS", "=", "_load_state", "(", ")", "for", "p", "in", "DETAILS", "[", "'packages'", "]", ":", "version_float", "=", "float", "(", "DETAILS", "[", "'packages'", "]", "[", "p", "]", ")", "version_float", "=", "versi...
Call the REST endpoint to see if the packages on the "server" are up to date.
[ "Call", "the", "REST", "endpoint", "to", "see", "if", "the", "packages", "on", "the", "server", "are", "up", "to", "date", "." ]
python
train
35.7
GoogleCloudPlatform/google-cloud-datastore
python/googledatastore/helper.py
https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/python/googledatastore/helper.py#L71-L111
def get_credentials_from_env(): """Get credentials from environment variables. Preference of credentials is: - No credentials if DATASTORE_EMULATOR_HOST is set. - Google APIs Signed JWT credentials based on DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE environments variables - Google Applicati...
[ "def", "get_credentials_from_env", "(", ")", ":", "if", "os", ".", "getenv", "(", "_DATASTORE_USE_STUB_CREDENTIAL_FOR_TEST_ENV", ")", ":", "logging", ".", "info", "(", "'connecting without credentials because %s is set.'", ",", "_DATASTORE_USE_STUB_CREDENTIAL_FOR_TEST_ENV", "...
Get credentials from environment variables. Preference of credentials is: - No credentials if DATASTORE_EMULATOR_HOST is set. - Google APIs Signed JWT credentials based on DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE environments variables - Google Application Default https://developers.googl...
[ "Get", "credentials", "from", "environment", "variables", "." ]
python
train
41.365854
saltstack/salt
salt/modules/zonecfg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zonecfg.py#L494-L570
def _resource(methode, zone, resource_type, resource_selector, **kwargs): ''' internal resource hanlder methode : string add or update zone : string name of zone resource_type : string type of resource resource_selector : string unique resource identifier **k...
[ "def", "_resource", "(", "methode", ",", "zone", ",", "resource_type", ",", "resource_selector", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'status'", ":", "True", "}", "# parse kwargs", "kwargs", "=", "salt", ".", "utils", ".", "args", ".", ...
internal resource hanlder methode : string add or update zone : string name of zone resource_type : string type of resource resource_selector : string unique resource identifier **kwargs : string|int|... resource properties
[ "internal", "resource", "hanlder" ]
python
train
37.714286
pypa/pipenv
pipenv/vendor/distlib/index.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/index.py#L75-L88
def read_configuration(self): """ Read the PyPI access configuration as supported by distutils, getting PyPI to do the actual work. This populates ``username``, ``password``, ``realm`` and ``url`` attributes from the configuration. """ # get distutils to do the work ...
[ "def", "read_configuration", "(", "self", ")", ":", "# get distutils to do the work", "c", "=", "self", ".", "_get_pypirc_command", "(", ")", "c", ".", "repository", "=", "self", ".", "url", "cfg", "=", "c", ".", "_read_pypirc", "(", ")", "self", ".", "use...
Read the PyPI access configuration as supported by distutils, getting PyPI to do the actual work. This populates ``username``, ``password``, ``realm`` and ``url`` attributes from the configuration.
[ "Read", "the", "PyPI", "access", "configuration", "as", "supported", "by", "distutils", "getting", "PyPI", "to", "do", "the", "actual", "work", ".", "This", "populates", "username", "password", "realm", "and", "url", "attributes", "from", "the", "configuration",...
python
train
42
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/prompts.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/prompts.py#L209-L217
def cwd_filt(depth): """Return the last depth elements of the current working directory. $HOME is always replaced with '~'. If depth==0, the full path is returned.""" cwd = os.getcwdu().replace(HOME,"~") out = os.sep.join(cwd.split(os.sep)[-depth:]) return out or os.sep
[ "def", "cwd_filt", "(", "depth", ")", ":", "cwd", "=", "os", ".", "getcwdu", "(", ")", ".", "replace", "(", "HOME", ",", "\"~\"", ")", "out", "=", "os", ".", "sep", ".", "join", "(", "cwd", ".", "split", "(", "os", ".", "sep", ")", "[", "-", ...
Return the last depth elements of the current working directory. $HOME is always replaced with '~'. If depth==0, the full path is returned.
[ "Return", "the", "last", "depth", "elements", "of", "the", "current", "working", "directory", "." ]
python
test
32
user-cont/conu
conu/backend/docker/utils.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L13-L62
def inspect_to_metadata(metadata_object, inspect_data): """ process data from `docker inspect` and update provided metadata object :param metadata_object: instance of Metadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :return: instance of Metadata ""...
[ "def", "inspect_to_metadata", "(", "metadata_object", ",", "inspect_data", ")", ":", "identifier", "=", "graceful_get", "(", "inspect_data", ",", "'Id'", ")", "if", "identifier", ":", "if", "\":\"", "in", "identifier", ":", "# format of image name from docker inspect:...
process data from `docker inspect` and update provided metadata object :param metadata_object: instance of Metadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :return: instance of Metadata
[ "process", "data", "from", "docker", "inspect", "and", "update", "provided", "metadata", "object" ]
python
train
40.9
wummel/linkchecker
linkcheck/colorama.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/colorama.py#L82-L90
def GetConsoleScreenBufferInfo(stream_id=STDOUT): """Get console screen buffer info object.""" handle = handles[stream_id] csbi = CONSOLE_SCREEN_BUFFER_INFO() success = windll.kernel32.GetConsoleScreenBufferInfo( handle, byref(csbi)) if not success: raise WinError() return csbi
[ "def", "GetConsoleScreenBufferInfo", "(", "stream_id", "=", "STDOUT", ")", ":", "handle", "=", "handles", "[", "stream_id", "]", "csbi", "=", "CONSOLE_SCREEN_BUFFER_INFO", "(", ")", "success", "=", "windll", ".", "kernel32", ".", "GetConsoleScreenBufferInfo", "(",...
Get console screen buffer info object.
[ "Get", "console", "screen", "buffer", "info", "object", "." ]
python
train
34.444444
eallik/spinoff
spinoff/util/lockfile.py
https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/util/lockfile.py#L11-L31
def lock_file(path, maxdelay=.1, lock_cls=LockFile, timeout=10.0): """Cooperative file lock. Uses `lockfile.LockFile` polling under the hood. `maxdelay` defines the interval between individual polls. """ lock = lock_cls(path) max_t = time.time() + timeout while True: if time.time() >= ...
[ "def", "lock_file", "(", "path", ",", "maxdelay", "=", ".1", ",", "lock_cls", "=", "LockFile", ",", "timeout", "=", "10.0", ")", ":", "lock", "=", "lock_cls", "(", "path", ")", "max_t", "=", "time", ".", "time", "(", ")", "+", "timeout", "while", "...
Cooperative file lock. Uses `lockfile.LockFile` polling under the hood. `maxdelay` defines the interval between individual polls.
[ "Cooperative", "file", "lock", ".", "Uses", "lockfile", ".", "LockFile", "polling", "under", "the", "hood", "." ]
python
train
31.857143
KE-works/pykechain
pykechain/models/activity.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/activity.py#L168-L187
def configure(self, inputs, outputs): """Configure activity input and output. You need to provide a list of input and output :class:`Property`. Does not work with lists of propery id's. :param inputs: iterable of input property models :type inputs: list(:class:`Property`) :para...
[ "def", "configure", "(", "self", ",", "inputs", ",", "outputs", ")", ":", "url", "=", "self", ".", "_client", ".", "_build_url", "(", "'activity'", ",", "activity_id", "=", "self", ".", "id", ")", "r", "=", "self", ".", "_client", ".", "_request", "(...
Configure activity input and output. You need to provide a list of input and output :class:`Property`. Does not work with lists of propery id's. :param inputs: iterable of input property models :type inputs: list(:class:`Property`) :param outputs: iterable of output property models ...
[ "Configure", "activity", "input", "and", "output", "." ]
python
train
43.7
CityOfZion/neo-python
neo/Core/State/StateDescriptor.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/StateDescriptor.py#L30-L38
def Size(self): """ Get the total size in bytes of the object. Returns: int: size. """ return s.uint8 + GetVarSize(self.Key) + GetVarSize(self.Field) + GetVarSize(self.Value)
[ "def", "Size", "(", "self", ")", ":", "return", "s", ".", "uint8", "+", "GetVarSize", "(", "self", ".", "Key", ")", "+", "GetVarSize", "(", "self", ".", "Field", ")", "+", "GetVarSize", "(", "self", ".", "Value", ")" ]
Get the total size in bytes of the object. Returns: int: size.
[ "Get", "the", "total", "size", "in", "bytes", "of", "the", "object", "." ]
python
train
24.444444
cjdrake/pyeda
pyeda/boolalg/bdd.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L549-L557
def _dfs_postorder(node, visited): """Iterate through nodes in DFS post-order.""" if node.lo is not None: yield from _dfs_postorder(node.lo, visited) if node.hi is not None: yield from _dfs_postorder(node.hi, visited) if node not in visited: visited.add(node) yield node
[ "def", "_dfs_postorder", "(", "node", ",", "visited", ")", ":", "if", "node", ".", "lo", "is", "not", "None", ":", "yield", "from", "_dfs_postorder", "(", "node", ".", "lo", ",", "visited", ")", "if", "node", ".", "hi", "is", "not", "None", ":", "y...
Iterate through nodes in DFS post-order.
[ "Iterate", "through", "nodes", "in", "DFS", "post", "-", "order", "." ]
python
train
34.444444
google/grumpy
third_party/stdlib/re.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/re.py#L160-L169
def subn(pattern, repl, string, count=0, flags=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that wer...
[ "def", "subn", "(", "pattern", ",", "repl", ",", "string", ",", "count", "=", "0", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "subn", "(", "repl", ",", "string", ",", "count", ")" ]
Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made. repl can be either a string or a callable; if ...
[ "Return", "a", "2", "-", "tuple", "containing", "(", "new_string", "number", ")", ".", "new_string", "is", "the", "string", "obtained", "by", "replacing", "the", "leftmost", "non", "-", "overlapping", "occurrences", "of", "the", "pattern", "in", "the", "sour...
python
valid
58.9
apache/airflow
airflow/www/security.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L500-L560
def _sync_dag_view_permissions(self, dag_id, access_control): """Set the access policy on the given DAG's ViewModel. :param dag_id: the ID of the DAG whose permissions should be updated :type dag_id: string :param access_control: a dict where each key is a rolename and each ...
[ "def", "_sync_dag_view_permissions", "(", "self", ",", "dag_id", ",", "access_control", ")", ":", "def", "_get_or_create_dag_permission", "(", "perm_name", ")", ":", "dag_perm", "=", "self", ".", "find_permission_view_menu", "(", "perm_name", ",", "dag_id", ")", "...
Set the access policy on the given DAG's ViewModel. :param dag_id: the ID of the DAG whose permissions should be updated :type dag_id: string :param access_control: a dict where each key is a rolename and each value is a set() of permission names (e.g., {'can_dag_read'} ...
[ "Set", "the", "access", "policy", "on", "the", "given", "DAG", "s", "ViewModel", "." ]
python
test
43.803279
noahbenson/neuropythy
neuropythy/geometry/mesh.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/geometry/mesh.py#L4160-L4220
def to_mesh(obj): ''' to_mesh(obj) yields a Mesh object that is equivalent to obj or identical to obj if obj is itself a mesh object. The following objects can be converted into meshes: * a mesh object * a tuple (coords, faces) where coords is a coordinate matrix and faces is a matrix of ...
[ "def", "to_mesh", "(", "obj", ")", ":", "if", "is_mesh", "(", "obj", ")", ":", "return", "obj", "elif", "pimms", ".", "is_vector", "(", "obj", ")", "and", "len", "(", "obj", ")", "==", "2", ":", "(", "a", ",", "b", ")", "=", "obj", "if", "pim...
to_mesh(obj) yields a Mesh object that is equivalent to obj or identical to obj if obj is itself a mesh object. The following objects can be converted into meshes: * a mesh object * a tuple (coords, faces) where coords is a coordinate matrix and faces is a matrix of coordinate indices tha...
[ "to_mesh", "(", "obj", ")", "yields", "a", "Mesh", "object", "that", "is", "equivalent", "to", "obj", "or", "identical", "to", "obj", "if", "obj", "is", "itself", "a", "mesh", "object", "." ]
python
train
61.770492
boriel/zxbasic
arch/zx48k/backend/__pload.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__pload.py#L148-L158
def _pload32(ins): """ Loads from stack pointer (SP) + X, being X 2st parameter. 1st operand must be a SIGNED integer. 2nd operand cannot be an immediate nor an address. """ output = _pload(ins.quad[2], 4) output.append('push de') output.append('push hl') return output
[ "def", "_pload32", "(", "ins", ")", ":", "output", "=", "_pload", "(", "ins", ".", "quad", "[", "2", "]", ",", "4", ")", "output", ".", "append", "(", "'push de'", ")", "output", ".", "append", "(", "'push hl'", ")", "return", "output" ]
Loads from stack pointer (SP) + X, being X 2st parameter. 1st operand must be a SIGNED integer. 2nd operand cannot be an immediate nor an address.
[ "Loads", "from", "stack", "pointer", "(", "SP", ")", "+", "X", "being", "X", "2st", "parameter", "." ]
python
train
26.909091
rene-aguirre/pywinusb
pywinusb/hid/core.py
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L395-L507
def open(self, output_only = False, shared = True): """Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing """ if self.is_opened(): raise HIDError("Device already opened") sharing_flags = 0 ...
[ "def", "open", "(", "self", ",", "output_only", "=", "False", ",", "shared", "=", "True", ")", ":", "if", "self", ".", "is_opened", "(", ")", ":", "raise", "HIDError", "(", "\"Device already opened\"", ")", "sharing_flags", "=", "0", "if", "shared", ":",...
Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing
[ "Open", "HID", "device", "and", "obtain", "Collection", "Information", ".", "It", "effectively", "prepares", "the", "HidDevice", "object", "for", "reading", "and", "writing" ]
python
train
43.026549
saltstack/salt
salt/modules/bluez_bluetooth.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bluez_bluetooth.py#L192-L208
def block(bdaddr): ''' Block a specific bluetooth device by BD Address CLI Example: .. code-block:: bash salt '*' bluetooth.block DE:AD:BE:EF:CA:FE ''' if not salt.utils.validate.net.mac(bdaddr): raise CommandExecutionError( 'Invalid BD address passed to bluetooth....
[ "def", "block", "(", "bdaddr", ")", ":", "if", "not", "salt", ".", "utils", ".", "validate", ".", "net", ".", "mac", "(", "bdaddr", ")", ":", "raise", "CommandExecutionError", "(", "'Invalid BD address passed to bluetooth.block'", ")", "cmd", "=", "'hciconfig ...
Block a specific bluetooth device by BD Address CLI Example: .. code-block:: bash salt '*' bluetooth.block DE:AD:BE:EF:CA:FE
[ "Block", "a", "specific", "bluetooth", "device", "by", "BD", "Address" ]
python
train
24.117647
The-Politico/politico-civic-election-night
electionnight/serializers/state.py
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/state.py#L69-L85
def get_content(self, obj): """All content for a state's page on an election day.""" election_day = ElectionDay.objects.get( date=self.context['election_date']) division = obj # In case of house special election, # use parent division. if obj.level.name == Div...
[ "def", "get_content", "(", "self", ",", "obj", ")", ":", "election_day", "=", "ElectionDay", ".", "objects", ".", "get", "(", "date", "=", "self", ".", "context", "[", "'election_date'", "]", ")", "division", "=", "obj", "# In case of house special election,",...
All content for a state's page on an election day.
[ "All", "content", "for", "a", "state", "s", "page", "on", "an", "election", "day", "." ]
python
train
32.705882
elifesciences/elife-tools
elifetools/parseJATS.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L368-L387
def pub_dates(soup): """ return a list of all the pub dates """ pub_dates = [] tags = raw_parser.pub_date(soup) for tag in tags: pub_date = OrderedDict() copy_attribute(tag.attrs, 'publication-format', pub_date) copy_attribute(tag.attrs, 'date-type', pub_date) cop...
[ "def", "pub_dates", "(", "soup", ")", ":", "pub_dates", "=", "[", "]", "tags", "=", "raw_parser", ".", "pub_date", "(", "soup", ")", "for", "tag", "in", "tags", ":", "pub_date", "=", "OrderedDict", "(", ")", "copy_attribute", "(", "tag", ".", "attrs", ...
return a list of all the pub dates
[ "return", "a", "list", "of", "all", "the", "pub", "dates" ]
python
train
36.2
Gandi/gandi.cli
gandi/cli/modules/status.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L39-L42
def status(cls): """Retrieve global status from status.gandi.net.""" return cls.json_get('%s/status' % cls.api_url, empty_key=True, send_key=False)
[ "def", "status", "(", "cls", ")", ":", "return", "cls", ".", "json_get", "(", "'%s/status'", "%", "cls", ".", "api_url", ",", "empty_key", "=", "True", ",", "send_key", "=", "False", ")" ]
Retrieve global status from status.gandi.net.
[ "Retrieve", "global", "status", "from", "status", ".", "gandi", ".", "net", "." ]
python
train
47
bharadwaj-raju/libdesktop
libdesktop/applications.py
https://github.com/bharadwaj-raju/libdesktop/blob/4d6b815755c76660b6ef4d2db6f54beff38c0db7/libdesktop/applications.py#L256-L322
def text_editor(file='', background=False, return_cmd=False): '''Starts the default graphical text editor. Start the user's preferred graphical text editor, optionally with a file. Args: file (str) : The file to be opened with the editor. Defaults to an empty string (i.e. no file). background (bool): Runs...
[ "def", "text_editor", "(", "file", "=", "''", ",", "background", "=", "False", ",", "return_cmd", "=", "False", ")", ":", "desktop_env", "=", "system", ".", "get_name", "(", ")", "if", "desktop_env", "==", "'windows'", ":", "editor_cmd_str", "=", "system",...
Starts the default graphical text editor. Start the user's preferred graphical text editor, optionally with a file. Args: file (str) : The file to be opened with the editor. Defaults to an empty string (i.e. no file). background (bool): Runs the editor in the background, instead of waiting for completion. ...
[ "Starts", "the", "default", "graphical", "text", "editor", "." ]
python
train
28.298507
reiinakano/xcessiv
xcessiv/stacker.py
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/stacker.py#L77-L103
def _process_using_meta_feature_generator(self, X, meta_feature_generator): """Process using secondary learner meta-feature generator Since secondary learner meta-feature generator can be anything e.g. predict, predict_proba, this internal method gives the ability to use any string. Just make s...
[ "def", "_process_using_meta_feature_generator", "(", "self", ",", "X", ",", "meta_feature_generator", ")", ":", "all_learner_meta_features", "=", "[", "]", "for", "idx", ",", "base_learner", "in", "enumerate", "(", "self", ".", "base_learners", ")", ":", "single_l...
Process using secondary learner meta-feature generator Since secondary learner meta-feature generator can be anything e.g. predict, predict_proba, this internal method gives the ability to use any string. Just make sure secondary learner has the method. Args: X (array-like)...
[ "Process", "using", "secondary", "learner", "meta", "-", "feature", "generator" ]
python
train
44
rigetti/grove
grove/tomography/utils.py
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/tomography/utils.py#L380-L429
def run_in_parallel(programs, nsamples, cxn, shuffle=True): """ Take sequences of Protoquil programs on disjoint qubits and execute a single sequence of programs that executes the input programs in parallel. Optionally randomize within each qubit-specific sequence. The programs are passed as a 2d a...
[ "def", "run_in_parallel", "(", "programs", ",", "nsamples", ",", "cxn", ",", "shuffle", "=", "True", ")", ":", "if", "shuffle", ":", "n_groups", "=", "len", "(", "programs", ")", "n_progs_per_group", "=", "len", "(", "programs", "[", "0", "]", ")", "pe...
Take sequences of Protoquil programs on disjoint qubits and execute a single sequence of programs that executes the input programs in parallel. Optionally randomize within each qubit-specific sequence. The programs are passed as a 2d array of Quil programs, where the (first) outer axis iterates over di...
[ "Take", "sequences", "of", "Protoquil", "programs", "on", "disjoint", "qubits", "and", "execute", "a", "single", "sequence", "of", "programs", "that", "executes", "the", "input", "programs", "in", "parallel", ".", "Optionally", "randomize", "within", "each", "qu...
python
train
51.52
tensorflow/tensor2tensor
tensor2tensor/models/research/transformer_nat.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_nat.py#L110-L118
def vq_discrete_unbottleneck(x, hparams): """Simple undiscretization from vector quantized representation.""" x_shape = common_layers.shape_list(x) bottleneck_size = 2**hparams.bottleneck_bits means = hparams.means x_flat = tf.reshape(x, [-1, bottleneck_size]) result = tf.matmul(x_flat, means) result = tf...
[ "def", "vq_discrete_unbottleneck", "(", "x", ",", "hparams", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "bottleneck_size", "=", "2", "**", "hparams", ".", "bottleneck_bits", "means", "=", "hparams", ".", "means", "x_flat", "...
Simple undiscretization from vector quantized representation.
[ "Simple", "undiscretization", "from", "vector", "quantized", "representation", "." ]
python
train
42.444444
sentinel-hub/sentinelhub-py
sentinelhub/aws.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L177-L192
def sort_download_list(self): """ Method for sorting the list of download requests. Band images have priority before metadata files. If bands images or metadata files are specified with a list they will be sorted in the same order as in the list. Otherwise they will be sorted alphabetica...
[ "def", "sort_download_list", "(", "self", ")", ":", "def", "aws_sort_function", "(", "download_request", ")", ":", "data_name", "=", "download_request", ".", "properties", "[", "'data_name'", "]", "if", "'product_name'", "in", "download_request", ".", "properties", ...
Method for sorting the list of download requests. Band images have priority before metadata files. If bands images or metadata files are specified with a list they will be sorted in the same order as in the list. Otherwise they will be sorted alphabetically (band B8A will be between B08 and B09).
[ "Method", "for", "sorting", "the", "list", "of", "download", "requests", ".", "Band", "images", "have", "priority", "before", "metadata", "files", ".", "If", "bands", "images", "or", "metadata", "files", "are", "specified", "with", "a", "list", "they", "will...
python
train
58.4375
greenbender/pynntp
nntp/nntp.py
https://github.com/greenbender/pynntp/blob/991a76331cdf5d8f9dbf5b18f6e29adc80749a2f/nntp/nntp.py#L191-L226
def status(self): """Reads a command response status. If there is no response message then the returned status message will be an empty string. Raises: NNTPError: If data is required to be read from the socket and fails. NNTPProtocolError: If the status line can...
[ "def", "status", "(", "self", ")", ":", "line", "=", "next", "(", "self", ".", "__line_gen", "(", ")", ")", ".", "rstrip", "(", ")", "parts", "=", "line", ".", "split", "(", "None", ",", "1", ")", "try", ":", "code", ",", "message", "=", "int",...
Reads a command response status. If there is no response message then the returned status message will be an empty string. Raises: NNTPError: If data is required to be read from the socket and fails. NNTPProtocolError: If the status line can't be parsed. NNT...
[ "Reads", "a", "command", "response", "status", "." ]
python
test
29.5
useblocks/sphinxcontrib-needs
sphinxcontrib/needs/directives/needflow.py
https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/needflow.py#L63-L68
def make_entity_name(name): """Creates a valid PlantUML entity name from the given value.""" invalid_chars = "-=!#$%^&*[](){}/~'`<>:;" for char in invalid_chars: name = name.replace(char, "_") return name
[ "def", "make_entity_name", "(", "name", ")", ":", "invalid_chars", "=", "\"-=!#$%^&*[](){}/~'`<>:;\"", "for", "char", "in", "invalid_chars", ":", "name", "=", "name", ".", "replace", "(", "char", ",", "\"_\"", ")", "return", "name" ]
Creates a valid PlantUML entity name from the given value.
[ "Creates", "a", "valid", "PlantUML", "entity", "name", "from", "the", "given", "value", "." ]
python
train
37.166667
Rapptz/discord.py
discord/role.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/role.py#L262-L283
async def delete(self, *, reason=None): """|coro| Deletes the role. You must have the :attr:`~Permissions.manage_roles` permission to use this. Parameters ----------- reason: Optional[:class:`str`] The reason for deleting this role. Shows up on the ...
[ "async", "def", "delete", "(", "self", ",", "*", ",", "reason", "=", "None", ")", ":", "await", "self", ".", "_state", ".", "http", ".", "delete_role", "(", "self", ".", "guild", ".", "id", ",", "self", ".", "id", ",", "reason", "=", "reason", ")...
|coro| Deletes the role. You must have the :attr:`~Permissions.manage_roles` permission to use this. Parameters ----------- reason: Optional[:class:`str`] The reason for deleting this role. Shows up on the audit log. Raises -------- ...
[ "|coro|" ]
python
train
26.136364
spyder-ide/spyder
spyder/utils/vcs.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/vcs.py#L100-L116
def get_hg_revision(repopath): """Return Mercurial revision for the repository located at repopath Result is a tuple (global, local, branch), with None values on error For example: >>> get_hg_revision(".") ('eba7273c69df+', '2015+', 'default') """ try: ass...
[ "def", "get_hg_revision", "(", "repopath", ")", ":", "try", ":", "assert", "osp", ".", "isdir", "(", "osp", ".", "join", "(", "repopath", ",", "'.hg'", ")", ")", "proc", "=", "programs", ".", "run_program", "(", "'hg'", ",", "[", "'id'", ",", "'-nib'...
Return Mercurial revision for the repository located at repopath Result is a tuple (global, local, branch), with None values on error For example: >>> get_hg_revision(".") ('eba7273c69df+', '2015+', 'default')
[ "Return", "Mercurial", "revision", "for", "the", "repository", "located", "at", "repopath", "Result", "is", "a", "tuple", "(", "global", "local", "branch", ")", "with", "None", "values", "on", "error", "For", "example", ":", ">>>", "get_hg_revision", "(", "....
python
train
45.882353
splunk/splunk-sdk-python
splunklib/binding.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1297-L1301
def close(self): """Closes this response.""" if self._connection: self._connection.close() self._response.close()
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_connection", ":", "self", ".", "_connection", ".", "close", "(", ")", "self", ".", "_response", ".", "close", "(", ")" ]
Closes this response.
[ "Closes", "this", "response", "." ]
python
train
29
fastai/fastai
fastai/basic_train.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/basic_train.py#L69-L76
def train_epoch(model:nn.Module, dl:DataLoader, opt:optim.Optimizer, loss_func:LossFunction)->None: "Simple training of `model` for 1 epoch of `dl` using optim `opt` and loss function `loss_func`." model.train() for xb,yb in dl: loss = loss_func(model(xb), yb) loss.backward() opt.ste...
[ "def", "train_epoch", "(", "model", ":", "nn", ".", "Module", ",", "dl", ":", "DataLoader", ",", "opt", ":", "optim", ".", "Optimizer", ",", "loss_func", ":", "LossFunction", ")", "->", "None", ":", "model", ".", "train", "(", ")", "for", "xb", ",", ...
Simple training of `model` for 1 epoch of `dl` using optim `opt` and loss function `loss_func`.
[ "Simple", "training", "of", "model", "for", "1", "epoch", "of", "dl", "using", "optim", "opt", "and", "loss", "function", "loss_func", "." ]
python
train
42.5
oisinmulvihill/stomper
lib/stomper/stompbuffer.py
https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stompbuffer.py#L69-L109
def getOneMessage ( self ): """ I pull one complete message off the buffer and return it decoded as a dict. If there is no complete message in the buffer, I return None. Note that the buffer can contain more than once message. You should therefore call me in a loop until...
[ "def", "getOneMessage", "(", "self", ")", ":", "(", "mbytes", ",", "hbytes", ")", "=", "self", ".", "_findMessageBytes", "(", "self", ".", "buffer", ")", "if", "not", "mbytes", ":", "return", "None", "msgdata", "=", "self", ".", "buffer", "[", ":", "...
I pull one complete message off the buffer and return it decoded as a dict. If there is no complete message in the buffer, I return None. Note that the buffer can contain more than once message. You should therefore call me in a loop until I return None.
[ "I", "pull", "one", "complete", "message", "off", "the", "buffer", "and", "return", "it", "decoded", "as", "a", "dict", ".", "If", "there", "is", "no", "complete", "message", "in", "the", "buffer", "I", "return", "None", "." ]
python
train
37.341463
nicferrier/md
src/mdlib/cli.py
https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L211-L219
def do_struct(self, subcmd, opts, message): """${cmd_name}: get the structure of the specified message ${cmd_usage} ${cmd_option_list} """ client = MdClient(self.maildir, filesystem=self.filesystem) as_json = getattr(opts, "json", False) client.getstruct(message,...
[ "def", "do_struct", "(", "self", ",", "subcmd", ",", "opts", ",", "message", ")", ":", "client", "=", "MdClient", "(", "self", ".", "maildir", ",", "filesystem", "=", "self", ".", "filesystem", ")", "as_json", "=", "getattr", "(", "opts", ",", "\"json\...
${cmd_name}: get the structure of the specified message ${cmd_usage} ${cmd_option_list}
[ "$", "{", "cmd_name", "}", ":", "get", "the", "structure", "of", "the", "specified", "message" ]
python
train
38.777778
pyblish/pyblish-qml
pyblish_qml/ipc/formatting.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/ipc/formatting.py#L53-L58
def format_records(records): """Serialise multiple records""" formatted = list() for record_ in records: formatted.append(format_record(record_)) return formatted
[ "def", "format_records", "(", "records", ")", ":", "formatted", "=", "list", "(", ")", "for", "record_", "in", "records", ":", "formatted", ".", "append", "(", "format_record", "(", "record_", ")", ")", "return", "formatted" ]
Serialise multiple records
[ "Serialise", "multiple", "records" ]
python
train
30.166667
PmagPy/PmagPy
pmagpy/validate_upload3.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L588-L599
def get_degree_cols(df): """ Take in a pandas DataFrame, and return a list of columns that are in that DataFrame AND should be between 0 - 360 degrees. """ vals = ['lon_w', 'lon_e', 'lat_lon_precision', 'pole_lon', 'paleolon', 'paleolon_sigma', 'lon', 'lon_sigma', 'vgp_lon', ...
[ "def", "get_degree_cols", "(", "df", ")", ":", "vals", "=", "[", "'lon_w'", ",", "'lon_e'", ",", "'lat_lon_precision'", ",", "'pole_lon'", ",", "'paleolon'", ",", "'paleolon_sigma'", ",", "'lon'", ",", "'lon_sigma'", ",", "'vgp_lon'", ",", "'paleo_lon'", ",", ...
Take in a pandas DataFrame, and return a list of columns that are in that DataFrame AND should be between 0 - 360 degrees.
[ "Take", "in", "a", "pandas", "DataFrame", "and", "return", "a", "list", "of", "columns", "that", "are", "in", "that", "DataFrame", "AND", "should", "be", "between", "0", "-", "360", "degrees", "." ]
python
train
45.25
mlperf/training
reinforcement/tensorflow/minigo/oneoffs/eval_sgf_to_cbt.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/oneoffs/eval_sgf_to_cbt.py#L179-L233
def write_eval_records(bt_table, game_data, last_game): """Write all eval_records to eval_table In addition to writing new rows table_state must be updated in row `table_state` columns `metadata:eval_game_counter` Args: bt_table: bigtable table to add rows to. game_data: metadata pairs (c...
[ "def", "write_eval_records", "(", "bt_table", ",", "game_data", ",", "last_game", ")", ":", "eval_num", "=", "last_game", "# Each column counts as a mutation so max rows is ~10000", "GAMES_PER_COMMIT", "=", "2000", "for", "games", "in", "grouper", "(", "tqdm", "(", "g...
Write all eval_records to eval_table In addition to writing new rows table_state must be updated in row `table_state` columns `metadata:eval_game_counter` Args: bt_table: bigtable table to add rows to. game_data: metadata pairs (column name, value) for each eval record. last_game: last...
[ "Write", "all", "eval_records", "to", "eval_table" ]
python
train
37.927273
AtomHash/evernode
evernode/classes/form_data.py
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L38-L46
def add_file(self, name, required=False, error=None, extensions=None): """ Add a file field to parse on request (uploads) """ if name is None: return self.file_arguments.append(dict( name=name, required=required, error=error, ex...
[ "def", "add_file", "(", "self", ",", "name", ",", "required", "=", "False", ",", "error", "=", "None", ",", "extensions", "=", "None", ")", ":", "if", "name", "is", "None", ":", "return", "self", ".", "file_arguments", ".", "append", "(", "dict", "("...
Add a file field to parse on request (uploads)
[ "Add", "a", "file", "field", "to", "parse", "on", "request", "(", "uploads", ")" ]
python
train
37
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1279-L1297
def uniform_binning_correction(x, n_bits=8): """Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)). """ n_bins = 2**n_bits batch_size, height, width, n_channels ...
[ "def", "uniform_binning_correction", "(", "x", ",", "n_bits", "=", "8", ")", ":", "n_bins", "=", "2", "**", "n_bits", "batch_size", ",", "height", ",", "width", ",", "n_channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "hwc", "=", "float...
Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)).
[ "Replaces", "x^i", "with", "q^i", "(", "x", ")", "=", "U", "(", "x", "x", "+", "1", ".", "0", "/", "256", ".", "0", ")", "." ]
python
train
30.210526
thilux/tvdb_client
tvdb_client/clients/ApiV2Client.py
https://github.com/thilux/tvdb_client/blob/2d5106f260367c0abe1284683697874df6343f78/tvdb_client/clients/ApiV2Client.py#L252-L271
def get_updated(self, from_time, to_time=None): """ Retrives a list of series that have changed on TheTVDB since a provided from time parameter and optionally to an specified to time. :param from_time: An epoch representation of the date from which to restrict the query to. :par...
[ "def", "get_updated", "(", "self", ",", "from_time", ",", "to_time", "=", "None", ")", ":", "arguments", "=", "locals", "(", ")", "optional_parameters", "=", "{", "'to_time'", ":", "'toTime'", "}", "query_string", "=", "'fromTime=%s&%s'", "%", "(", "from_tim...
Retrives a list of series that have changed on TheTVDB since a provided from time parameter and optionally to an specified to time. :param from_time: An epoch representation of the date from which to restrict the query to. :param to_time: An optional epcoh representation of the date to which to...
[ "Retrives", "a", "list", "of", "series", "that", "have", "changed", "on", "TheTVDB", "since", "a", "provided", "from", "time", "parameter", "and", "optionally", "to", "an", "specified", "to", "time", "." ]
python
train
50.7
softlayer/softlayer-python
SoftLayer/CLI/virt/list.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/virt/list.py#L70-L93
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, hourly, monthly, tag, columns, limit): """List virtual servers.""" vsi = SoftLayer.VSManager(env.client) guests = vsi.list_instances(hourly=hourly, monthly=monthly, ...
[ "def", "cli", "(", "env", ",", "sortby", ",", "cpu", ",", "domain", ",", "datacenter", ",", "hostname", ",", "memory", ",", "network", ",", "hourly", ",", "monthly", ",", "tag", ",", "columns", ",", "limit", ")", ":", "vsi", "=", "SoftLayer", ".", ...
List virtual servers.
[ "List", "virtual", "servers", "." ]
python
train
38.625
google/grr
grr/server/grr_response_server/gui/api_value_renderers.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_value_renderers.py#L91-L126
def GetRendererForValueOrClass(cls, value, limit_lists=-1): """Returns renderer corresponding to a given value and rendering args.""" if inspect.isclass(value): value_cls = value else: value_cls = value.__class__ cache_key = "%s_%d" % (value_cls.__name__, limit_lists) try: render...
[ "def", "GetRendererForValueOrClass", "(", "cls", ",", "value", ",", "limit_lists", "=", "-", "1", ")", ":", "if", "inspect", ".", "isclass", "(", "value", ")", ":", "value_cls", "=", "value", "else", ":", "value_cls", "=", "value", ".", "__class__", "cac...
Returns renderer corresponding to a given value and rendering args.
[ "Returns", "renderer", "corresponding", "to", "a", "given", "value", "and", "rendering", "args", "." ]
python
train
32.916667
payu-org/payu
payu/namcouple.py
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/namcouple.py#L35-L59
def substitute_timestep(self, regex, timestep): """ Substitute a new timestep value using regex. """ # Make one change at a time, each change affects subsequent matches. timestep_changed = False while True: matches = re.finditer(regex, self.str, re.MULTILINE ...
[ "def", "substitute_timestep", "(", "self", ",", "regex", ",", "timestep", ")", ":", "# Make one change at a time, each change affects subsequent matches.", "timestep_changed", "=", "False", "while", "True", ":", "matches", "=", "re", ".", "finditer", "(", "regex", ","...
Substitute a new timestep value using regex.
[ "Substitute", "a", "new", "timestep", "value", "using", "regex", "." ]
python
train
34.32
fracpete/python-weka-wrapper3
python/weka/classifiers.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/classifiers.py#L1133-L1155
def crossvalidate_model(self, classifier, data, num_folds, rnd, output=None): """ Crossvalidates the model using the specified data, number of folds and random number generator wrapper. :param classifier: the classifier to cross-validate :type classifier: Classifier :param data:...
[ "def", "crossvalidate_model", "(", "self", ",", "classifier", ",", "data", ",", "num_folds", ",", "rnd", ",", "output", "=", "None", ")", ":", "if", "output", "is", "None", ":", "generator", "=", "[", "]", "else", ":", "generator", "=", "[", "output", ...
Crossvalidates the model using the specified data, number of folds and random number generator wrapper. :param classifier: the classifier to cross-validate :type classifier: Classifier :param data: the data to evaluate on :type data: Instances :param num_folds: the number of fol...
[ "Crossvalidates", "the", "model", "using", "the", "specified", "data", "number", "of", "folds", "and", "random", "number", "generator", "wrapper", "." ]
python
train
42.608696
fastai/fastai
fastai/torch_core.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/torch_core.py#L198-L214
def split_no_wd_params(layer_groups:Collection[nn.Module])->List[List[nn.Parameter]]: "Separate the parameters in `layer_groups` between `no_wd_types` and bias (`bias_types`) from the rest." split_params = [] for l in layer_groups: l1,l2 = [],[] for c in l.children(): if isinsta...
[ "def", "split_no_wd_params", "(", "layer_groups", ":", "Collection", "[", "nn", ".", "Module", "]", ")", "->", "List", "[", "List", "[", "nn", ".", "Parameter", "]", "]", ":", "split_params", "=", "[", "]", "for", "l", "in", "layer_groups", ":", "l1", ...
Separate the parameters in `layer_groups` between `no_wd_types` and bias (`bias_types`) from the rest.
[ "Separate", "the", "parameters", "in", "layer_groups", "between", "no_wd_types", "and", "bias", "(", "bias_types", ")", "from", "the", "rest", "." ]
python
train
53.176471
scivision/gridaurora
gridaurora/calcemissions.py
https://github.com/scivision/gridaurora/blob/c3957b93c2201afff62bd104e0acead52c0d9e90/gridaurora/calcemissions.py#L62-L76
def getMetastable(rates, ver: np.ndarray, lamb, br, reactfn: Path): with h5py.File(reactfn, 'r') as f: A = f['/metastable/A'][:] lambnew = f['/metastable/lambda'].value.ravel(order='F') # some are not 1-D! """ concatenate along the reaction dimension, axis=-1 """ vnew = np.concaten...
[ "def", "getMetastable", "(", "rates", ",", "ver", ":", "np", ".", "ndarray", ",", "lamb", ",", "br", ",", "reactfn", ":", "Path", ")", ":", "with", "h5py", ".", "File", "(", "reactfn", ",", "'r'", ")", "as", "f", ":", "A", "=", "f", "[", "'/met...
concatenate along the reaction dimension, axis=-1
[ "concatenate", "along", "the", "reaction", "dimension", "axis", "=", "-", "1" ]
python
train
42.266667
cwoebker/pen
pen/edit.py
https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/edit.py#L73-L82
def split_focus(self): """Divide the focus edit widget at the cursor location.""" focus = self.lines[self.focus] pos = focus.edit_pos edit = urwid.Edit("", focus.edit_text[pos:], allow_tab=True) edit.original_text = "" focus.set_edit_text(focus.edit_text[:pos]) e...
[ "def", "split_focus", "(", "self", ")", ":", "focus", "=", "self", ".", "lines", "[", "self", ".", "focus", "]", "pos", "=", "focus", ".", "edit_pos", "edit", "=", "urwid", ".", "Edit", "(", "\"\"", ",", "focus", ".", "edit_text", "[", "pos", ":", ...
Divide the focus edit widget at the cursor location.
[ "Divide", "the", "focus", "edit", "widget", "at", "the", "cursor", "location", "." ]
python
train
37.8
secdev/scapy
scapy/main.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L336-L349
def update_session(fname=None): """Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from""" if fname is None: fname = conf.session try: s = six.moves.cPickle.load(gzip.open(fname, "rb")) except IOError: ...
[ "def", "update_session", "(", "fname", "=", "None", ")", ":", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "try", ":", "s", "=", "six", ".", "moves", ".", "cPickle", ".", "load", "(", "gzip", ".", "open", "(", "fname", ...
Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from
[ "Update", "current", "Scapy", "session", "from", "the", "file", "specified", "in", "the", "fname", "arg", "." ]
python
train
35
UCSBarchlab/PyRTL
pyrtl/helperfuncs.py
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/helperfuncs.py#L226-L274
def formatted_str_to_val(data, format, enum_set=None): """ Return an unsigned integer representation of the data given format specified. :param data: a string holding the value to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable...
[ "def", "formatted_str_to_val", "(", "data", ",", "format", ",", "enum_set", "=", "None", ")", ":", "type", "=", "format", "[", "0", "]", "bitwidth", "=", "int", "(", "format", "[", "1", ":", "]", ".", "split", "(", "'/'", ")", "[", "0", "]", ")",...
Return an unsigned integer representation of the data given format specified. :param data: a string holding the value to convert :param format: a string holding a format which will be used to convert the data string :param enum_set: an iterable of enums which are used as part of the converstion process ...
[ "Return", "an", "unsigned", "integer", "representation", "of", "the", "data", "given", "format", "specified", "." ]
python
train
42
odlgroup/odl
odl/contrib/solvers/spdhg/misc.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/contrib/solvers/spdhg/misc.py#L311-L398
def fgp_dual(p, data, alpha, niter, grad, proj_C, proj_P, tol=None, **kwargs): """Computes a solution to the ROF problem with the fast gradient projection algorithm. Parameters ---------- p : np.array dual initial variable data : np.array noisy data / proximal point alpha : ...
[ "def", "fgp_dual", "(", "p", ",", "data", ",", "alpha", ",", "niter", ",", "grad", ",", "proj_C", ",", "proj_P", ",", "tol", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Callback object", "callback", "=", "kwargs", ".", "pop", "(", "'callback'"...
Computes a solution to the ROF problem with the fast gradient projection algorithm. Parameters ---------- p : np.array dual initial variable data : np.array noisy data / proximal point alpha : float regularization parameter niter : int number of iterations ...
[ "Computes", "a", "solution", "to", "the", "ROF", "problem", "with", "the", "fast", "gradient", "projection", "algorithm", "." ]
python
train
25.306818
CitrineInformatics/pypif-sdk
pypif_sdk/func/replace_funcs.py
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/replace_funcs.py#L21-L34
def replace_by_key(pif, key, subs, new_key=None, remove=False): """Replace values that match a key Deeply traverses the pif object, looking for `key` and replacing values in accordance with `subs`. If `new_key` is set, the replaced values are assigned to that key. If `remove` is `True`, the old `...
[ "def", "replace_by_key", "(", "pif", ",", "key", ",", "subs", ",", "new_key", "=", "None", ",", "remove", "=", "False", ")", ":", "if", "not", "new_key", ":", "new_key", "=", "key", "remove", "=", "False", "orig", "=", "pif", ".", "as_dictionary", "(...
Replace values that match a key Deeply traverses the pif object, looking for `key` and replacing values in accordance with `subs`. If `new_key` is set, the replaced values are assigned to that key. If `remove` is `True`, the old `key` pairs are removed.
[ "Replace", "values", "that", "match", "a", "key" ]
python
train
40.714286
PyGithub/PyGithub
github/Repository.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Repository.py#L1833-L1843
def get_downloads(self): """ :calls: `GET /repos/:owner/:repo/downloads <http://developer.github.com/v3/repos/downloads>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Download.Download` """ return github.PaginatedList.PaginatedList( github.Do...
[ "def", "get_downloads", "(", "self", ")", ":", "return", "github", ".", "PaginatedList", ".", "PaginatedList", "(", "github", ".", "Download", ".", "Download", ",", "self", ".", "_requester", ",", "self", ".", "url", "+", "\"/downloads\"", ",", "None", ")"...
:calls: `GET /repos/:owner/:repo/downloads <http://developer.github.com/v3/repos/downloads>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Download.Download`
[ ":", "calls", ":", "GET", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "downloads", "<http", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "repos", "/", "downloads", ">", "_", ":", "rtype", ":", ":", "class", ":", ...
python
train
38.090909
CxAalto/gtfspy
gtfspy/gtfs.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1113-L1131
def increment_day_start_ut(self, day_start_ut, n_days=1): """Increment the GTFS-definition of "day start". Parameters ---------- day_start_ut : int unixtime of the previous start of day. If this time is between 12:00 or greater, there *will* be bugs. To solve t...
[ "def", "increment_day_start_ut", "(", "self", ",", "day_start_ut", ",", "n_days", "=", "1", ")", ":", "old_tz", "=", "self", ".", "set_current_process_time_zone", "(", ")", "day0", "=", "time", ".", "localtime", "(", "day_start_ut", "+", "43200", ")", "# tim...
Increment the GTFS-definition of "day start". Parameters ---------- day_start_ut : int unixtime of the previous start of day. If this time is between 12:00 or greater, there *will* be bugs. To solve this, run the input through day_start_ut first. n_...
[ "Increment", "the", "GTFS", "-", "definition", "of", "day", "start", "." ]
python
valid
42.368421
klen/adrest
adrest/utils/emitter.py
https://github.com/klen/adrest/blob/8b75c67123cffabe5ed98c222bb7ab43c904d89c/adrest/utils/emitter.py#L114-L126
def serialize(self, content): """ Serialize to JSON. :return string: serializaed JSON """ worker = JSONSerializer( scheme=self.resource, options=self.resource._meta.emit_options, format=self.resource._meta.emit_format, **self.resource._me...
[ "def", "serialize", "(", "self", ",", "content", ")", ":", "worker", "=", "JSONSerializer", "(", "scheme", "=", "self", ".", "resource", ",", "options", "=", "self", ".", "resource", ".", "_meta", ".", "emit_options", ",", "format", "=", "self", ".", "...
Serialize to JSON. :return string: serializaed JSON
[ "Serialize", "to", "JSON", "." ]
python
train
28.692308
mass-project/mass_api_client
mass_api_client/utils.py
https://github.com/mass-project/mass_api_client/blob/b200c32c93608bf3b2707fbf0e83a2228702e2c8/mass_api_client/utils.py#L75-L91
def process_analyses(analysis_system_instance, analysis_method, sleep_time): """Process all analyses which are scheduled for the analysis system instance. This function does not terminate on its own, give it a SIGINT or Ctrl+C to stop. :param analysis_system_instance: The analysis system instance for whic...
[ "def", "process_analyses", "(", "analysis_system_instance", ",", "analysis_method", ",", "sleep_time", ")", ":", "try", ":", "while", "True", ":", "for", "analysis_request", "in", "analysis_system_instance", ".", "get_scheduled_analyses", "(", ")", ":", "analysis_meth...
Process all analyses which are scheduled for the analysis system instance. This function does not terminate on its own, give it a SIGINT or Ctrl+C to stop. :param analysis_system_instance: The analysis system instance for which the analyses are scheduled. :param analysis_method: A function or method which...
[ "Process", "all", "analyses", "which", "are", "scheduled", "for", "the", "analysis", "system", "instance", "." ]
python
train
48.705882
CityOfZion/neo-python
neo/Wallets/Wallet.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/Wallet.py#L1217-L1232
def SignMessage(self, message, script_hash): """ Sign a message with a specified script_hash. Args: message (str): a hex encoded message to sign script_hash (UInt160): a bytearray (len 20). Returns: str: the signed message """ keypai...
[ "def", "SignMessage", "(", "self", ",", "message", ",", "script_hash", ")", ":", "keypair", "=", "self", ".", "GetKeyByScriptHash", "(", "script_hash", ")", "prikey", "=", "bytes", "(", "keypair", ".", "PrivateKey", ")", "res", "=", "Crypto", ".", "Default...
Sign a message with a specified script_hash. Args: message (str): a hex encoded message to sign script_hash (UInt160): a bytearray (len 20). Returns: str: the signed message
[ "Sign", "a", "message", "with", "a", "specified", "script_hash", "." ]
python
train
29.9375
jazzband/django-pipeline
pipeline/finders.py
https://github.com/jazzband/django-pipeline/blob/3cd2f93bb47bf8d34447e13ff691f7027e7b07a2/pipeline/finders.py#L26-L37
def find(self, path, all=False): """ Looks for files in PIPELINE.STYLESHEETS and PIPELINE.JAVASCRIPT """ matches = [] for elem in chain(settings.STYLESHEETS.values(), settings.JAVASCRIPT.values()): if normpath(elem['output_filename']) == normpath(path): ...
[ "def", "find", "(", "self", ",", "path", ",", "all", "=", "False", ")", ":", "matches", "=", "[", "]", "for", "elem", "in", "chain", "(", "settings", ".", "STYLESHEETS", ".", "values", "(", ")", ",", "settings", ".", "JAVASCRIPT", ".", "values", "(...
Looks for files in PIPELINE.STYLESHEETS and PIPELINE.JAVASCRIPT
[ "Looks", "for", "files", "in", "PIPELINE", ".", "STYLESHEETS", "and", "PIPELINE", ".", "JAVASCRIPT" ]
python
train
40
gem/oq-engine
openquake/baselib/datastore.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/datastore.py#L184-L195
def open(self, mode): """ Open the underlying .hdf5 file and the parent, if any """ if self.hdf5 == (): # not already open kw = dict(mode=mode, libver='latest') if mode == 'r': kw['swmr'] = True try: self.hdf5 = hdf5.Fi...
[ "def", "open", "(", "self", ",", "mode", ")", ":", "if", "self", ".", "hdf5", "==", "(", ")", ":", "# not already open", "kw", "=", "dict", "(", "mode", "=", "mode", ",", "libver", "=", "'latest'", ")", "if", "mode", "==", "'r'", ":", "kw", "[", ...
Open the underlying .hdf5 file and the parent, if any
[ "Open", "the", "underlying", ".", "hdf5", "file", "and", "the", "parent", "if", "any" ]
python
train
36
bcbio/bcbio-nextgen
bcbio/cwl/tool.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L313-L320
def _run_sbgenomics(args): """Run CWL on SevenBridges platform and Cancer Genomics Cloud. """ assert not args.no_container, "Seven Bridges runs require containers" main_file, json_file, project_name = _get_main_and_json(args.directory) flags = [] cmd = ["sbg-cwl-runner"] + flags + args.toolargs ...
[ "def", "_run_sbgenomics", "(", "args", ")", ":", "assert", "not", "args", ".", "no_container", ",", "\"Seven Bridges runs require containers\"", "main_file", ",", "json_file", ",", "project_name", "=", "_get_main_and_json", "(", "args", ".", "directory", ")", "flags...
Run CWL on SevenBridges platform and Cancer Genomics Cloud.
[ "Run", "CWL", "on", "SevenBridges", "platform", "and", "Cancer", "Genomics", "Cloud", "." ]
python
train
44.5
coin-or/GiMPy
src/gimpy/graph.py
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2046-L2067
def floyd_warshall_get_path(self, distance, nextn, i, j): ''' API: floyd_warshall_get_path(self, distance, nextn, i, j): Description: Finds shortest path between i and j using distance and nextn dictionaries. Pre: (1) distance and nextn are...
[ "def", "floyd_warshall_get_path", "(", "self", ",", "distance", ",", "nextn", ",", "i", ",", "j", ")", ":", "if", "distance", "[", "(", "i", ",", "j", ")", "]", "==", "'infinity'", ":", "return", "None", "k", "=", "nextn", "[", "(", "i", ",", "j"...
API: floyd_warshall_get_path(self, distance, nextn, i, j): Description: Finds shortest path between i and j using distance and nextn dictionaries. Pre: (1) distance and nextn are outputs of floyd_warshall method. (2) The graph does not have a n...
[ "API", ":", "floyd_warshall_get_path", "(", "self", "distance", "nextn", "i", "j", ")", ":", "Description", ":", "Finds", "shortest", "path", "between", "i", "and", "j", "using", "distance", "and", "nextn", "dictionaries", ".", "Pre", ":", "(", "1", ")", ...
python
train
37.318182
gabrielfalcao/dominic
dominic/xpath/expr.py
https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L580-L592
def axisfn(reverse=False, principal_node_type=xml.dom.Node.ELEMENT_NODE): """Axis function decorator. An axis function will take a node as an argument and return a sequence over the nodes along an XPath axis. Axis functions have two extra attributes indicating the axis direction and principal node typ...
[ "def", "axisfn", "(", "reverse", "=", "False", ",", "principal_node_type", "=", "xml", ".", "dom", ".", "Node", ".", "ELEMENT_NODE", ")", ":", "def", "decorate", "(", "f", ")", ":", "f", ".", "__name__", "=", "f", ".", "__name__", ".", "replace", "("...
Axis function decorator. An axis function will take a node as an argument and return a sequence over the nodes along an XPath axis. Axis functions have two extra attributes indicating the axis direction and principal node type.
[ "Axis", "function", "decorator", "." ]
python
train
38.923077
PX4/pyulog
pyulog/info.py
https://github.com/PX4/pyulog/blob/3bc4f9338d30e2e0a0dfbed58f54d200967e5056/pyulog/info.py#L15-L65
def show_info(ulog, verbose): """Show general information from an ULog""" m1, s1 = divmod(int(ulog.start_timestamp/1e6), 60) h1, m1 = divmod(m1, 60) m2, s2 = divmod(int((ulog.last_timestamp - ulog.start_timestamp)/1e6), 60) h2, m2 = divmod(m2, 60) print("Logging start time: {:d}:{:02d}:{:02d}, d...
[ "def", "show_info", "(", "ulog", ",", "verbose", ")", ":", "m1", ",", "s1", "=", "divmod", "(", "int", "(", "ulog", ".", "start_timestamp", "/", "1e6", ")", ",", "60", ")", "h1", ",", "m1", "=", "divmod", "(", "m1", ",", "60", ")", "m2", ",", ...
Show general information from an ULog
[ "Show", "general", "information", "from", "an", "ULog" ]
python
train
43.235294
apache/incubator-mxnet
python/mxnet/log.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/log.py#L90-L145
def get_logger(name=None, filename=None, filemode=None, level=WARNING): """Gets a customized logger. Parameters ---------- name: str, optional Name of the logger. filename: str, optional The filename to which the logger's output will be sent. filemode: str, optional The ...
[ "def", "get_logger", "(", "name", "=", "None", ",", "filename", "=", "None", ",", "filemode", "=", "None", ",", "level", "=", "WARNING", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "if", "name", "is", "not", "None", "and",...
Gets a customized logger. Parameters ---------- name: str, optional Name of the logger. filename: str, optional The filename to which the logger's output will be sent. filemode: str, optional The file mode to open the file (corresponding to `filename`), default is 'a...
[ "Gets", "a", "customized", "logger", "." ]
python
train
37.553571
consbio/ncdjango
ncdjango/geoprocessing/evaluation.py
https://github.com/consbio/ncdjango/blob/f807bfd1e4083ab29fbc3c4d4418be108383a710/ncdjango/geoprocessing/evaluation.py#L321-L332
def fn_abs(self, value): """ Return the absolute value of a number. :param value: The number. :return: The absolute value of the number. """ if is_ndarray(value): return numpy.absolute(value) else: return abs(value)
[ "def", "fn_abs", "(", "self", ",", "value", ")", ":", "if", "is_ndarray", "(", "value", ")", ":", "return", "numpy", ".", "absolute", "(", "value", ")", "else", ":", "return", "abs", "(", "value", ")" ]
Return the absolute value of a number. :param value: The number. :return: The absolute value of the number.
[ "Return", "the", "absolute", "value", "of", "a", "number", "." ]
python
train
23.833333
astropy/regions
regions/io/core.py
https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/regions/io/core.py#L549-L572
def _convert_sky_coords(self): """ Convert to sky coordinates """ parsed_angles = [(x, y) for x, y in zip(self.coord[:-1:2], self.coord[1::2]) if (isinstance(x, coordinates.Angle) and isinstance(y, coordinates.Angle)) ...
[ "def", "_convert_sky_coords", "(", "self", ")", ":", "parsed_angles", "=", "[", "(", "x", ",", "y", ")", "for", "x", ",", "y", "in", "zip", "(", "self", ".", "coord", "[", ":", "-", "1", ":", "2", "]", ",", "self", ".", "coord", "[", "1", ":"...
Convert to sky coordinates
[ "Convert", "to", "sky", "coordinates" ]
python
train
41.625
mitsei/dlkit
dlkit/json_/osid/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/objects.py#L1299-L1314
def set_start_date(self, date): """Sets the start date. arg: date (osid.calendaring.DateTime): the new date raise: InvalidArgument - ``date`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``date`` is ``null`` *compliance: ...
[ "def", "set_start_date", "(", "self", ",", "date", ")", ":", "if", "self", ".", "get_start_date_metadata", "(", ")", ".", "is_read_only", "(", ")", ":", "raise", "errors", ".", "NoAccess", "(", ")", "if", "not", "self", ".", "_is_valid_date_time", "(", "...
Sets the start date. arg: date (osid.calendaring.DateTime): the new date raise: InvalidArgument - ``date`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``date`` is ``null`` *compliance: mandatory -- This method must be implemente...
[ "Sets", "the", "start", "date", "." ]
python
train
42.75
psphere-project/psphere
psphere/client.py
https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L590-L677
def find_entity_view(self, view_type, begin_entity=None, filter={}, properties=None): """Find a ManagedEntity of the requested type. Traverses the MOB looking for an entity matching the filter. :param view_type: The type of ManagedEntity to find. :type view_typ...
[ "def", "find_entity_view", "(", "self", ",", "view_type", ",", "begin_entity", "=", "None", ",", "filter", "=", "{", "}", ",", "properties", "=", "None", ")", ":", "if", "properties", "is", "None", ":", "properties", "=", "[", "]", "kls", "=", "classma...
Find a ManagedEntity of the requested type. Traverses the MOB looking for an entity matching the filter. :param view_type: The type of ManagedEntity to find. :type view_type: str :param begin_entity: The MOR to start searching for the entity. \ The default is to start the searc...
[ "Find", "a", "ManagedEntity", "of", "the", "requested", "type", "." ]
python
train
40.602273
acutesoftware/AIKIF
aikif/cls_log.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L142-L146
def record_process(self, process, prg=''): """ log a process or program - log a physical program (.py, .bat, .exe) """ self._log(self.logFileProcess, force_to_string(process), prg)
[ "def", "record_process", "(", "self", ",", "process", ",", "prg", "=", "''", ")", ":", "self", ".", "_log", "(", "self", ".", "logFileProcess", ",", "force_to_string", "(", "process", ")", ",", "prg", ")" ]
log a process or program - log a physical program (.py, .bat, .exe)
[ "log", "a", "process", "or", "program", "-", "log", "a", "physical", "program", "(", ".", "py", ".", "bat", ".", "exe", ")" ]
python
train
41.6
gabstopper/smc-python
smc/core/engine.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L552-L567
def blacklist_bulk(self, blacklist): """ Add blacklist entries to the engine node in bulk. For blacklist to work, you must also create a rule with action "Apply Blacklist". First create your blacklist entries using :class:`smc.elements.other.Blacklist` then provide the blacklist ...
[ "def", "blacklist_bulk", "(", "self", ",", "blacklist", ")", ":", "self", ".", "make_request", "(", "EngineCommandFailed", ",", "method", "=", "'create'", ",", "resource", "=", "'blacklist'", ",", "json", "=", "blacklist", ".", "entries", ")" ]
Add blacklist entries to the engine node in bulk. For blacklist to work, you must also create a rule with action "Apply Blacklist". First create your blacklist entries using :class:`smc.elements.other.Blacklist` then provide the blacklist to this method. :param blacklist Blackli...
[ "Add", "blacklist", "entries", "to", "the", "engine", "node", "in", "bulk", ".", "For", "blacklist", "to", "work", "you", "must", "also", "create", "a", "rule", "with", "action", "Apply", "Blacklist", ".", "First", "create", "your", "blacklist", "entries", ...
python
train
39.75