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
OCHA-DAP/hdx-python-utilities
src/hdx/utilities/compare.py
https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/compare.py#L7-L21
def compare_files(path1, path2): # type: (str, str) -> List[str] """Returns the delta between two files using -, ?, + format excluding lines that are the same Args: path1 (str): Path to first file path2 (str): Path to second file Returns: List[str]: Delta between the two fi...
[ "def", "compare_files", "(", "path1", ",", "path2", ")", ":", "# type: (str, str) -> List[str]", "diff", "=", "difflib", ".", "ndiff", "(", "open", "(", "path1", ")", ".", "readlines", "(", ")", ",", "open", "(", "path2", ")", ".", "readlines", "(", ")",...
Returns the delta between two files using -, ?, + format excluding lines that are the same Args: path1 (str): Path to first file path2 (str): Path to second file Returns: List[str]: Delta between the two files
[ "Returns", "the", "delta", "between", "two", "files", "using", "-", "?", "+", "format", "excluding", "lines", "that", "are", "the", "same" ]
python
train
29.933333
dropbox/stone
stone/backends/python_types.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_types.py#L197-L223
def _docf(self, tag, val): """ Callback used as the handler argument to process_docs(). This converts Stone doc references to Sphinx-friendly annotations. """ if tag == 'type': return ':class:`{}`'.format(val) elif tag == 'route': if self.args.rout...
[ "def", "_docf", "(", "self", ",", "tag", ",", "val", ")", ":", "if", "tag", "==", "'type'", ":", "return", "':class:`{}`'", ".", "format", "(", "val", ")", "elif", "tag", "==", "'route'", ":", "if", "self", ".", "args", ".", "route_method", ":", "r...
Callback used as the handler argument to process_docs(). This converts Stone doc references to Sphinx-friendly annotations.
[ "Callback", "used", "as", "the", "handler", "argument", "to", "process_docs", "()", ".", "This", "converts", "Stone", "doc", "references", "to", "Sphinx", "-", "friendly", "annotations", "." ]
python
train
36.962963
quasipedia/swaggery
swaggery/utils.py
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/utils.py#L98-L101
def map_exception_codes(): '''Helper function to intialise CODES_TO_EXCEPTIONS.''' werkex = inspect.getmembers(exceptions, lambda x: getattr(x, 'code', None)) return {e.code: e for _, e in werkex}
[ "def", "map_exception_codes", "(", ")", ":", "werkex", "=", "inspect", ".", "getmembers", "(", "exceptions", ",", "lambda", "x", ":", "getattr", "(", "x", ",", "'code'", ",", "None", ")", ")", "return", "{", "e", ".", "code", ":", "e", "for", "_", ...
Helper function to intialise CODES_TO_EXCEPTIONS.
[ "Helper", "function", "to", "intialise", "CODES_TO_EXCEPTIONS", "." ]
python
train
51.25
miguelgrinberg/python-socketio
socketio/server.py
https://github.com/miguelgrinberg/python-socketio/blob/c0c1bf8d21e3597389b18938550a0724dd9676b7/socketio/server.py#L405-L443
def session(self, sid, namespace=None): """Return the user session for a client with context manager syntax. :param sid: The session id of the client. This is a context manager that returns the user session dictionary for the client. Any changes that are made to this dictionary inside ...
[ "def", "session", "(", "self", ",", "sid", ",", "namespace", "=", "None", ")", ":", "class", "_session_context_manager", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "server", ",", "sid", ",", "namespace", ")", ":", "self", ".", "serve...
Return the user session for a client with context manager syntax. :param sid: The session id of the client. This is a context manager that returns the user session dictionary for the client. Any changes that are made to this dictionary inside the context manager block are saved back to...
[ "Return", "the", "user", "session", "for", "a", "client", "with", "context", "manager", "syntax", "." ]
python
train
39.589744
rsheftel/raccoon
raccoon/series.py
https://github.com/rsheftel/raccoon/blob/e5c4b5fb933b51f33aff11e8168c39790e9a7c75/raccoon/series.py#L674-L681
def reset_index(self): """ Resets the index of the Series to simple integer list and the index name to 'index'. :return: nothing """ self.index = list(range(self.__len__())) self.index_name = 'index'
[ "def", "reset_index", "(", "self", ")", ":", "self", ".", "index", "=", "list", "(", "range", "(", "self", ".", "__len__", "(", ")", ")", ")", "self", ".", "index_name", "=", "'index'" ]
Resets the index of the Series to simple integer list and the index name to 'index'. :return: nothing
[ "Resets", "the", "index", "of", "the", "Series", "to", "simple", "integer", "list", "and", "the", "index", "name", "to", "index", "." ]
python
train
30.125
ml4ai/delphi
delphi/analysis/comparison/utils.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/analysis/comparison/utils.py#L18-L20
def get_output_nodes(G: nx.DiGraph) -> List[str]: """ Get all output nodes from a network. """ return [n for n, d in G.out_degree() if d == 0]
[ "def", "get_output_nodes", "(", "G", ":", "nx", ".", "DiGraph", ")", "->", "List", "[", "str", "]", ":", "return", "[", "n", "for", "n", ",", "d", "in", "G", ".", "out_degree", "(", ")", "if", "d", "==", "0", "]" ]
Get all output nodes from a network.
[ "Get", "all", "output", "nodes", "from", "a", "network", "." ]
python
train
49.333333
smarter-travel-media/stac
stac/http.py
https://github.com/smarter-travel-media/stac/blob/cdb29a17ede0924b122b3905a500442c62ae53b7/stac/http.py#L69-L102
def get_most_recent_versions(self, group, artifact, limit, remote=False, integration=False): """Get a list of the version numbers of the most recent artifacts (integration or non-integration), ordered by the version number, for a particular group and artifact combination. :param str gro...
[ "def", "get_most_recent_versions", "(", "self", ",", "group", ",", "artifact", ",", "limit", ",", "remote", "=", "False", ",", "integration", "=", "False", ")", ":", "if", "limit", "<", "1", ":", "raise", "ValueError", "(", "\"Releases limit must be positive\"...
Get a list of the version numbers of the most recent artifacts (integration or non-integration), ordered by the version number, for a particular group and artifact combination. :param str group: Group of the artifact to get versions of :param str artifact: Name of the artifact to get ve...
[ "Get", "a", "list", "of", "the", "version", "numbers", "of", "the", "most", "recent", "artifacts", "(", "integration", "or", "non", "-", "integration", ")", "ordered", "by", "the", "version", "number", "for", "a", "particular", "group", "and", "artifact", ...
python
train
51.352941
tanghaibao/jcvi
jcvi/assembly/kmer.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/kmer.py#L491-L516
def logodds(args): """ %prog logodds cnt1 cnt2 Compute log likelihood between two db. """ from math import log from jcvi.formats.base import DictFile p = OptionParser(logodds.__doc__) opts, args = p.parse_args(args) if len(args) != 2: sys.exit(not p.print_help()) cnt1...
[ "def", "logodds", "(", "args", ")", ":", "from", "math", "import", "log", "from", "jcvi", ".", "formats", ".", "base", "import", "DictFile", "p", "=", "OptionParser", "(", "logodds", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args"...
%prog logodds cnt1 cnt2 Compute log likelihood between two db.
[ "%prog", "logodds", "cnt1", "cnt2" ]
python
train
22.384615
aequitas/python-rflink
rflink/protocol.py
https://github.com/aequitas/python-rflink/blob/46759ce8daf95cfc7cdb608ae17bc5501be9f6d8/rflink/protocol.py#L304-L325
def create_rflink_connection(port=None, host=None, baud=57600, protocol=RflinkProtocol, packet_callback=None, event_callback=None, disconnect_callback=None, ignore=None, loop=None): """Create Rflink manager class, returns transport coroutine.""" # use de...
[ "def", "create_rflink_connection", "(", "port", "=", "None", ",", "host", "=", "None", ",", "baud", "=", "57600", ",", "protocol", "=", "RflinkProtocol", ",", "packet_callback", "=", "None", ",", "event_callback", "=", "None", ",", "disconnect_callback", "=", ...
Create Rflink manager class, returns transport coroutine.
[ "Create", "Rflink", "manager", "class", "returns", "transport", "coroutine", "." ]
python
train
38.636364
twilio/twilio-python
twilio/rest/autopilot/v1/assistant/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/autopilot/v1/assistant/__init__.py#L352-L361
def model_builds(self): """ Access the model_builds :returns: twilio.rest.autopilot.v1.assistant.model_build.ModelBuildList :rtype: twilio.rest.autopilot.v1.assistant.model_build.ModelBuildList """ if self._model_builds is None: self._model_builds = ModelBuil...
[ "def", "model_builds", "(", "self", ")", ":", "if", "self", ".", "_model_builds", "is", "None", ":", "self", ".", "_model_builds", "=", "ModelBuildList", "(", "self", ".", "_version", ",", "assistant_sid", "=", "self", ".", "_solution", "[", "'sid'", "]", ...
Access the model_builds :returns: twilio.rest.autopilot.v1.assistant.model_build.ModelBuildList :rtype: twilio.rest.autopilot.v1.assistant.model_build.ModelBuildList
[ "Access", "the", "model_builds" ]
python
train
40.4
sentinel-hub/eo-learn
core/eolearn/core/eoworkflow.py
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eoworkflow.py#L294-L315
def _get_dep_to_dot_name_mapping(dependencies): """ Creates mapping between Dependency classes and names used in DOT graph """ dot_name_to_deps = {} for dep in dependencies: dot_name = dep.name if dot_name not in dot_name_to_deps: dot_name...
[ "def", "_get_dep_to_dot_name_mapping", "(", "dependencies", ")", ":", "dot_name_to_deps", "=", "{", "}", "for", "dep", "in", "dependencies", ":", "dot_name", "=", "dep", ".", "name", "if", "dot_name", "not", "in", "dot_name_to_deps", ":", "dot_name_to_deps", "["...
Creates mapping between Dependency classes and names used in DOT graph
[ "Creates", "mapping", "between", "Dependency", "classes", "and", "names", "used", "in", "DOT", "graph" ]
python
train
33.727273
MacHu-GWU/single_file_module-project
sfm/iterable.py
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L65-L82
def nth(iterable, n, default=None): """Returns the nth item or a default value. Example:: >>> nth([0, 1, 2], 1) 1 >>> nth([0, 1, 2], 100) None **中文文档** 取出一个可循环对象中的第n个元素。等效于list(iterable)[n], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写...
[ "def", "nth", "(", "iterable", ",", "n", ",", "default", "=", "None", ")", ":", "return", "next", "(", "itertools", ".", "islice", "(", "iterable", ",", "n", ",", "None", ")", ",", "default", ")" ]
Returns the nth item or a default value. Example:: >>> nth([0, 1, 2], 1) 1 >>> nth([0, 1, 2], 100) None **中文文档** 取出一个可循环对象中的第n个元素。等效于list(iterable)[n], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写了的可循环对象。
[ "Returns", "the", "nth", "item", "or", "a", "default", "value", "." ]
python
train
21.166667
mlperf/training
reinforcement/tensorflow/minigo/ratings/ratings.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/ratings/ratings.py#L233-L268
def suggest_pairs(top_n=10, per_n=3, ignore_before=300): """ Find the maximally interesting pairs of players to match up First, sort the ratings by uncertainty. Then, take the ten highest players with the highest uncertainty For each of them, call them `p1` Sort all the models by their distance from...
[ "def", "suggest_pairs", "(", "top_n", "=", "10", ",", "per_n", "=", "3", ",", "ignore_before", "=", "300", ")", ":", "db", "=", "sqlite3", ".", "connect", "(", "\"ratings.db\"", ")", "data", "=", "db", ".", "execute", "(", "\"select model_winner, model_los...
Find the maximally interesting pairs of players to match up First, sort the ratings by uncertainty. Then, take the ten highest players with the highest uncertainty For each of them, call them `p1` Sort all the models by their distance from p1's rating and take the 20 nearest rated models. ('candidat...
[ "Find", "the", "maximally", "interesting", "pairs", "of", "players", "to", "match", "up", "First", "sort", "the", "ratings", "by", "uncertainty", ".", "Then", "take", "the", "ten", "highest", "players", "with", "the", "highest", "uncertainty", "For", "each", ...
python
train
47.777778
rstoneback/pysat
pysat/_instrument.py
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/_instrument.py#L709-L916
def load(self, yr=None, doy=None, date=None, fname=None, fid=None, verifyPad=False): """Load instrument data into Instrument object .data. Parameters ---------- yr : integer year for desired data doy : integer day of year date : date...
[ "def", "load", "(", "self", ",", "yr", "=", "None", ",", "doy", "=", "None", ",", "date", "=", "None", ",", "fname", "=", "None", ",", "fid", "=", "None", ",", "verifyPad", "=", "False", ")", ":", "# set options used by loading routine based upon user inpu...
Load instrument data into Instrument object .data. Parameters ---------- yr : integer year for desired data doy : integer day of year date : datetime object date to load fname : 'string' filename to be loaded verify...
[ "Load", "instrument", "data", "into", "Instrument", "object", ".", "data", "." ]
python
train
45.105769
Hackerfleet/hfos
hfos/ui/schemamanager.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L211-L223
def get(self, event): """Return a single schema""" self.log("Schemarequest for", event.data, "from", event.user, lvl=debug) if event.data in schemastore: response = { 'component': 'hfos.events.schemamanager', 'action': 'get', ...
[ "def", "get", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Schemarequest for\"", ",", "event", ".", "data", ",", "\"from\"", ",", "event", ".", "user", ",", "lvl", "=", "debug", ")", "if", "event", ".", "data", "in", "schemastore"...
Return a single schema
[ "Return", "a", "single", "schema" ]
python
train
40.615385
Robpol86/appveyor-artifacts
appveyor_artifacts.py
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L530-L559
def mangle_coverage(local_path, log): """Edit .coverage file substituting Windows file paths to Linux paths. :param str local_path: Destination path to save file to. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ # Read the file, or return if not a .cove...
[ "def", "mangle_coverage", "(", "local_path", ",", "log", ")", ":", "# Read the file, or return if not a .coverage file.", "with", "open", "(", "local_path", ",", "mode", "=", "'rb'", ")", "as", "handle", ":", "if", "handle", ".", "read", "(", "13", ")", "!=", ...
Edit .coverage file substituting Windows file paths to Linux paths. :param str local_path: Destination path to save file to. :param logging.Logger log: Logger for this function. Populated by with_log() decorator.
[ "Edit", ".", "coverage", "file", "substituting", "Windows", "file", "paths", "to", "Linux", "paths", "." ]
python
train
45.566667
kennethreitz/omnijson
omnijson/packages/simplejson/encoder.py
https://github.com/kennethreitz/omnijson/blob/a5890a51a59ad76f78a61f5bf91fa86b784cf694/omnijson/packages/simplejson/encoder.py#L34-L42
def encode_basestring(s): """Return a JSON representation of a Python string """ if isinstance(s, str) and HAS_UTF8.search(s) is not None: s = s.decode('utf-8') def replace(match): return ESCAPE_DCT[match.group(0)] return u'"' + ESCAPE.sub(replace, s) + u'"'
[ "def", "encode_basestring", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "str", ")", "and", "HAS_UTF8", ".", "search", "(", "s", ")", "is", "not", "None", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", "def", "replace", "(", "m...
Return a JSON representation of a Python string
[ "Return", "a", "JSON", "representation", "of", "a", "Python", "string" ]
python
train
31.888889
Locu/chronology
pykronos/pykronos/utils/cache.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/pykronos/pykronos/utils/cache.py#L120-L130
def _bucket_time(self, event_time): """ The seconds since epoch that represent a computed bucket. An event bucket is the time of the earliest possible event for that `bucket_width`. Example: if `bucket_width = timedelta(minutes=10)`, bucket times will be the number of seconds since epoch at 12...
[ "def", "_bucket_time", "(", "self", ",", "event_time", ")", ":", "event_time", "=", "kronos_time_to_epoch_time", "(", "event_time", ")", "return", "event_time", "-", "(", "event_time", "%", "self", ".", "_bucket_width", ")" ]
The seconds since epoch that represent a computed bucket. An event bucket is the time of the earliest possible event for that `bucket_width`. Example: if `bucket_width = timedelta(minutes=10)`, bucket times will be the number of seconds since epoch at 12:00, 12:10, ... on each day.
[ "The", "seconds", "since", "epoch", "that", "represent", "a", "computed", "bucket", "." ]
python
train
41.818182
siemens/django-mantis-stix-importer
mantis_stix_importer/importer.py
https://github.com/siemens/django-mantis-stix-importer/blob/20f5709e068101dad299f58134513d8873c91ba5/mantis_stix_importer/importer.py#L1235-L1323
def derive_iobject_type(self, embedding_ns, embedded_ns, elt_name): """ Derive type of information object stemming from an embedded element based on namespace information of embedding element, the embedded element itself, and the name of the element. """ # Extract name...
[ "def", "derive_iobject_type", "(", "self", ",", "embedding_ns", ",", "embedded_ns", ",", "elt_name", ")", ":", "# Extract namespace-information", "ns_info", "=", "search_by_re_list", "(", "self", ".", "RE_LIST_NS_TYPE_FROM_NS_URL", ",", "self", ".", "namespace_dict", ...
Derive type of information object stemming from an embedded element based on namespace information of embedding element, the embedded element itself, and the name of the element.
[ "Derive", "type", "of", "information", "object", "stemming", "from", "an", "embedded", "element", "based", "on", "namespace", "information", "of", "embedding", "element", "the", "embedded", "element", "itself", "and", "the", "name", "of", "the", "element", "." ]
python
train
45.797753
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L4059-L4073
def _prm_write_shared_array(self, key, data, hdf5_group, full_name, flag, **kwargs): """Creates and array that can be used with an HDF5 array object""" if flag == HDF5StorageService.ARRAY: self._prm_write_into_array(key, data, hdf5_group, full_name, **kwargs) elif flag in (HDF5Stora...
[ "def", "_prm_write_shared_array", "(", "self", ",", "key", ",", "data", ",", "hdf5_group", ",", "full_name", ",", "flag", ",", "*", "*", "kwargs", ")", ":", "if", "flag", "==", "HDF5StorageService", ".", "ARRAY", ":", "self", ".", "_prm_write_into_array", ...
Creates and array that can be used with an HDF5 array object
[ "Creates", "and", "array", "that", "can", "be", "used", "with", "an", "HDF5", "array", "object" ]
python
test
50.066667
EasyPost/pystalk
pystalk/client.py
https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L300-L324
def put_job_into(self, tube_name, data, pri=65536, delay=0, ttr=120): """Insert a new job into a specific queue. Wrapper around :func:`put_job`. :param tube_name: Tube name :type tube_name: str :param data: Job body :type data: Text (either str which will be encoded as utf-8, or...
[ "def", "put_job_into", "(", "self", ",", "tube_name", ",", "data", ",", "pri", "=", "65536", ",", "delay", "=", "0", ",", "ttr", "=", "120", ")", ":", "with", "self", ".", "using", "(", "tube_name", ")", "as", "inserter", ":", "return", "inserter", ...
Insert a new job into a specific queue. Wrapper around :func:`put_job`. :param tube_name: Tube name :type tube_name: str :param data: Job body :type data: Text (either str which will be encoded as utf-8, or bytes which are already utf-8 :param pri: Priority for the job :...
[ "Insert", "a", "new", "job", "into", "a", "specific", "queue", ".", "Wrapper", "around", ":", "func", ":", "put_job", "." ]
python
train
40.68
gwastro/pycbc
pycbc/sensitivity.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/sensitivity.py#L63-L82
def volume_to_distance_with_errors(vol, vol_err): """ Return the distance and standard deviation upper and lower bounds Parameters ---------- vol: float vol_err: float Returns ------- dist: float ehigh: float elow: float """ dist = (vol * 3.0/4.0/numpy.pi) ** (1.0/3.0)...
[ "def", "volume_to_distance_with_errors", "(", "vol", ",", "vol_err", ")", ":", "dist", "=", "(", "vol", "*", "3.0", "/", "4.0", "/", "numpy", ".", "pi", ")", "**", "(", "1.0", "/", "3.0", ")", "ehigh", "=", "(", "(", "vol", "+", "vol_err", ")", "...
Return the distance and standard deviation upper and lower bounds Parameters ---------- vol: float vol_err: float Returns ------- dist: float ehigh: float elow: float
[ "Return", "the", "distance", "and", "standard", "deviation", "upper", "and", "lower", "bounds" ]
python
train
25.75
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py#L694-L697
def _tr_paren(line_info): "Translate lines escaped with: /" return '%s%s(%s)' % (line_info.pre, line_info.ifun, ", ".join(line_info.the_rest.split()))
[ "def", "_tr_paren", "(", "line_info", ")", ":", "return", "'%s%s(%s)'", "%", "(", "line_info", ".", "pre", ",", "line_info", ".", "ifun", ",", "\", \"", ".", "join", "(", "line_info", ".", "the_rest", ".", "split", "(", ")", ")", ")" ]
Translate lines escaped with: /
[ "Translate", "lines", "escaped", "with", ":", "/" ]
python
test
48
google/transitfeed
kmlwriter.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L438-L475
def _CreateRoutePatternsFolder(self, parent, route, style_id=None, visible=True): """Create a KML Folder containing placemarks for each pattern in the route. A pattern is a sequence of stops used by one of the trips in the route. If there are not patterns for the route t...
[ "def", "_CreateRoutePatternsFolder", "(", "self", ",", "parent", ",", "route", ",", "style_id", "=", "None", ",", "visible", "=", "True", ")", ":", "pattern_id_to_trips", "=", "route", ".", "GetPatternIdTripDict", "(", ")", "if", "not", "pattern_id_to_trips", ...
Create a KML Folder containing placemarks for each pattern in the route. A pattern is a sequence of stops used by one of the trips in the route. If there are not patterns for the route then no folder is created and None is returned. Args: parent: The parent ElementTree.Element instance. r...
[ "Create", "a", "KML", "Folder", "containing", "placemarks", "for", "each", "pattern", "in", "the", "route", "." ]
python
train
40.947368
mjirik/io3d
io3d/dcmreaddata.py
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L491-L586
def get_metaData(self, dcmlist, series_number): """ Get metadata. Voxel size is obtained from PixelSpacing and difference of SliceLocation of two neighboorhoding slices (first have index ifile). Files in are used. """ # if dcmlist is None: # dcmlist = ...
[ "def", "get_metaData", "(", "self", ",", "dcmlist", ",", "series_number", ")", ":", "# if dcmlist is None:", "# dcmlist = self.files_in_serie", "# number of slice where to extract metadata inforamtion", "ifile", "=", "0", "if", "len", "(", "dcmlist", ")", "==", "0", ...
Get metadata. Voxel size is obtained from PixelSpacing and difference of SliceLocation of two neighboorhoding slices (first have index ifile). Files in are used.
[ "Get", "metadata", ".", "Voxel", "size", "is", "obtained", "from", "PixelSpacing", "and", "difference", "of", "SliceLocation", "of", "two", "neighboorhoding", "slices", "(", "first", "have", "index", "ifile", ")", ".", "Files", "in", "are", "used", "." ]
python
train
39.395833
openstack/horizon
horizon/templatetags/horizon.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/horizon.py#L95-L110
def horizon_main_nav(context): """Generates top-level dashboard navigation entries.""" if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) dashboards = [] for dash in Horizon.get_dashboards(): if dash.can_access(context): ...
[ "def", "horizon_main_nav", "(", "context", ")", ":", "if", "'request'", "not", "in", "context", ":", "return", "{", "}", "current_dashboard", "=", "context", "[", "'request'", "]", ".", "horizon", ".", "get", "(", "'dashboard'", ",", "None", ")", "dashboar...
Generates top-level dashboard navigation entries.
[ "Generates", "top", "-", "level", "dashboard", "navigation", "entries", "." ]
python
train
39.4375
pazz/alot
alot/helper.py
https://github.com/pazz/alot/blob/d0297605c0ec1c6b65f541d0fd5b69ac5a0f4ded/alot/helper.py#L570-L576
def mailto_to_envelope(mailto_str): """ Interpret mailto-string into a :class:`alot.db.envelope.Envelope` """ from alot.db.envelope import Envelope headers, body = parse_mailto(mailto_str) return Envelope(bodytext=body, headers=headers)
[ "def", "mailto_to_envelope", "(", "mailto_str", ")", ":", "from", "alot", ".", "db", ".", "envelope", "import", "Envelope", "headers", ",", "body", "=", "parse_mailto", "(", "mailto_str", ")", "return", "Envelope", "(", "bodytext", "=", "body", ",", "headers...
Interpret mailto-string into a :class:`alot.db.envelope.Envelope`
[ "Interpret", "mailto", "-", "string", "into", "a", ":", "class", ":", "alot", ".", "db", ".", "envelope", ".", "Envelope" ]
python
train
36.285714
limix/scipy-sugar
scipy_sugar/stats/_normalize.py
https://github.com/limix/scipy-sugar/blob/8109685b14f61cf4c7fc66e6a98f10f35cbd086c/scipy_sugar/stats/_normalize.py#L6-L32
def quantile_gaussianize(x): """Normalize a sequence of values via rank and Normal c.d.f. Args: x (array_like): sequence of values. Returns: Gaussian-normalized values. Example: .. doctest:: >>> from scipy_sugar.stats import quantile_gaussianize >>> print(quantil...
[ "def", "quantile_gaussianize", "(", "x", ")", ":", "from", "scipy", ".", "stats", "import", "norm", ",", "rankdata", "x", "=", "asarray", "(", "x", ",", "float", ")", ".", "copy", "(", ")", "ok", "=", "isfinite", "(", "x", ")", "x", "[", "ok", "]...
Normalize a sequence of values via rank and Normal c.d.f. Args: x (array_like): sequence of values. Returns: Gaussian-normalized values. Example: .. doctest:: >>> from scipy_sugar.stats import quantile_gaussianize >>> print(quantile_gaussianize([-1, 0, 2])) [...
[ "Normalize", "a", "sequence", "of", "values", "via", "rank", "and", "Normal", "c", ".", "d", ".", "f", "." ]
python
train
22.777778
ninuxorg/nodeshot
nodeshot/community/notifications/management/commands/purge_notifications.py
https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/management/commands/purge_notifications.py#L24-L35
def handle(self, *args, **options): """ Purge notifications """ # retrieve layers notifications = self.retrieve_old_notifications() count = len(notifications) if count > 0: self.output('found %d notifications to purge...' % count) notifications.delete() ...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "# retrieve layers", "notifications", "=", "self", ".", "retrieve_old_notifications", "(", ")", "count", "=", "len", "(", "notifications", ")", "if", "count", ">", "0", "...
Purge notifications
[ "Purge", "notifications" ]
python
train
38.5
rapidpro/expressions
python/temba_expressions/dates.py
https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/dates.py#L178-L239
def _get_token_possibilities(cls, token, mode): """ Returns all possible component types of a token without regard to its context. For example "26" could be year, date or minute, but can't be a month or an hour. :param token: the token to classify :param mode: the parse mode ...
[ "def", "_get_token_possibilities", "(", "cls", ",", "token", ",", "mode", ")", ":", "token", "=", "token", ".", "lower", "(", ")", ".", "strip", "(", ")", "possibilities", "=", "{", "}", "try", ":", "as_int", "=", "int", "(", "token", ")", "if", "m...
Returns all possible component types of a token without regard to its context. For example "26" could be year, date or minute, but can't be a month or an hour. :param token: the token to classify :param mode: the parse mode :return: the dict of possible types and values if token was of t...
[ "Returns", "all", "possible", "component", "types", "of", "a", "token", "without", "regard", "to", "its", "context", ".", "For", "example", "26", "could", "be", "year", "date", "or", "minute", "but", "can", "t", "be", "a", "month", "or", "an", "hour", ...
python
train
42.645161
bluedazzle/wechat_sender
wechat_sender/utils.py
https://github.com/bluedazzle/wechat_sender/blob/21d861735509153d6b34408157911c25a5d7018b/wechat_sender/utils.py#L22-L28
def _read_config_list(): """ 配置列表读取 """ with codecs.open('conf.ini', 'w+', encoding='utf-8') as f1: conf_list = [conf for conf in f1.read().split('\n') if conf != ''] return conf_list
[ "def", "_read_config_list", "(", ")", ":", "with", "codecs", ".", "open", "(", "'conf.ini'", ",", "'w+'", ",", "encoding", "=", "'utf-8'", ")", "as", "f1", ":", "conf_list", "=", "[", "conf", "for", "conf", "in", "f1", ".", "read", "(", ")", ".", "...
配置列表读取
[ "配置列表读取" ]
python
train
29.857143
chaoss/grimoirelab-perceval
perceval/backends/core/askbot.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/askbot.py#L393-L462
def parse_answers(html_question): """Parse the answers of a given HTML question. The method parses the answers related with a given HTML question, as well as all the comments related to the answer. :param html_question: raw HTML question element :returns: a list with the answe...
[ "def", "parse_answers", "(", "html_question", ")", ":", "def", "parse_answer_container", "(", "update_info", ")", ":", "\"\"\"Parse the answer info container of a given HTML question.\n\n The method parses the information available in the answer information\n container....
Parse the answers of a given HTML question. The method parses the answers related with a given HTML question, as well as all the comments related to the answer. :param html_question: raw HTML question element :returns: a list with the answers
[ "Parse", "the", "answers", "of", "a", "given", "HTML", "question", "." ]
python
test
46.542857
SeattleTestbed/seash
pyreadline/rlmain.py
https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/rlmain.py#L265-L274
def callback_read_char(self): u'''Reads a character and informs the readline callback interface when a line is received''' if self.keyboard_poll(): line = self.get_line_buffer() + u'\n' # however there is another newline added by # self.mode.readline_setup(prompt) whi...
[ "def", "callback_read_char", "(", "self", ")", ":", "if", "self", ".", "keyboard_poll", "(", ")", ":", "line", "=", "self", ".", "get_line_buffer", "(", ")", "+", "u'\\n'", "# however there is another newline added by", "# self.mode.readline_setup(prompt) which is calle...
u'''Reads a character and informs the readline callback interface when a line is received
[ "u", "Reads", "a", "character", "and", "informs", "the", "readline", "callback", "interface", "when", "a", "line", "is", "received" ]
python
train
49.7
saltstack/salt
salt/modules/nspawn.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nspawn.py#L1391-L1420
def pull_raw(url, name, verify=False): ''' Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image, and add it to /var/lib/machines as a new container. .. note:: **Requires systemd >= 219** url URL from which to download the container name Name for th...
[ "def", "pull_raw", "(", "url", ",", "name", ",", "verify", "=", "False", ")", ":", "return", "_pull_image", "(", "'raw'", ",", "url", ",", "name", ",", "verify", "=", "verify", ")" ]
Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image, and add it to /var/lib/machines as a new container. .. note:: **Requires systemd >= 219** url URL from which to download the container name Name for the new container verify : False Perform...
[ "Execute", "a", "machinectl", "pull", "-", "raw", "to", "download", "a", ".", "qcow2", "or", "raw", "disk", "image", "and", "add", "it", "to", "/", "var", "/", "lib", "/", "machines", "as", "a", "new", "container", "." ]
python
train
33.8
lsst-sqre/sqre-codekit
codekit/progressbar.py
https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/progressbar.py#L19-L40
def countdown_timer(seconds=10): """Show a simple countdown progress bar Parameters ---------- seconds Period of time the progress bar takes to reach zero. """ tick = 0.1 # seconds n_ticks = int(seconds / tick) widgets = ['Pause for panic: ', progressbar.ETA(), ' ', progressb...
[ "def", "countdown_timer", "(", "seconds", "=", "10", ")", ":", "tick", "=", "0.1", "# seconds", "n_ticks", "=", "int", "(", "seconds", "/", "tick", ")", "widgets", "=", "[", "'Pause for panic: '", ",", "progressbar", ".", "ETA", "(", ")", ",", "' '", "...
Show a simple countdown progress bar Parameters ---------- seconds Period of time the progress bar takes to reach zero.
[ "Show", "a", "simple", "countdown", "progress", "bar" ]
python
train
22.409091
chimera0/accel-brain-code
Reinforcement-Learning/pyqlearning/misc/beta_dist.py
https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/pyqlearning/misc/beta_dist.py#L95-L109
def variance(self): ''' Compute variance. Returns: variance. ''' alpha = self.__success + self.__default_alpha beta = self.__failure + self.__default_beta try: variance = alpha * beta / ((alpha + beta) ** 2) * (alpha + beta + 1) e...
[ "def", "variance", "(", "self", ")", ":", "alpha", "=", "self", ".", "__success", "+", "self", ".", "__default_alpha", "beta", "=", "self", ".", "__failure", "+", "self", ".", "__default_beta", "try", ":", "variance", "=", "alpha", "*", "beta", "/", "(...
Compute variance. Returns: variance.
[ "Compute", "variance", "." ]
python
train
25.4
thebigmunch/gmusicapi-wrapper
gmusicapi_wrapper/utils.py
https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/utils.py#L175-L181
def _check_field_value(field_value, pattern): """Check a song metadata field value for a pattern.""" if isinstance(field_value, list): return any(re.search(pattern, str(value), re.I) for value in field_value) else: return re.search(pattern, str(field_value), re.I)
[ "def", "_check_field_value", "(", "field_value", ",", "pattern", ")", ":", "if", "isinstance", "(", "field_value", ",", "list", ")", ":", "return", "any", "(", "re", ".", "search", "(", "pattern", ",", "str", "(", "value", ")", ",", "re", ".", "I", "...
Check a song metadata field value for a pattern.
[ "Check", "a", "song", "metadata", "field", "value", "for", "a", "pattern", "." ]
python
valid
38
klahnakoski/pyLibrary
jx_elasticsearch/es52/util.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/util.py#L21-L56
def es_query_template(path): """ RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :return: (es_query, es_filters) TUPLE """ if not is_text(path): Log.error("expecting path to be a string") if path != ".": f0 = {} ...
[ "def", "es_query_template", "(", "path", ")", ":", "if", "not", "is_text", "(", "path", ")", ":", "Log", ".", "error", "(", "\"expecting path to be a string\"", ")", "if", "path", "!=", "\".\"", ":", "f0", "=", "{", "}", "f1", "=", "{", "}", "output", ...
RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :return: (es_query, es_filters) TUPLE
[ "RETURN", "TEMPLATE", "AND", "PATH", "-", "TO", "-", "FILTER", "AS", "A", "2", "-", "TUPLE", ":", "param", "path", ":", "THE", "NESTED", "PATH", "(", "NOT", "INCLUDING", "TABLE", "NAME", ")", ":", "return", ":", "(", "es_query", "es_filters", ")", "T...
python
train
24.083333
OpenTreeOfLife/peyotl
peyotl/amendments/amendments_umbrella.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L352-L379
def TaxonomicAmendmentStore(repos_dict=None, repos_par=None, with_caching=True, assumed_doc_version=None, git_ssh=None, pkey=None, git_action_class=Taxo...
[ "def", "TaxonomicAmendmentStore", "(", "repos_dict", "=", "None", ",", "repos_par", "=", "None", ",", "with_caching", "=", "True", ",", "assumed_doc_version", "=", "None", ",", "git_ssh", "=", "None", ",", "pkey", "=", "None", ",", "git_action_class", "=", "...
Factory function for a _TaxonomicAmendmentStore object. A wrapper around the _TaxonomicAmendmentStore class instantiation for the most common use case: a singleton _TaxonomicAmendmentStore. If you need distinct _TaxonomicAmendmentStore objects, you'll need to call that class directly.
[ "Factory", "function", "for", "a", "_TaxonomicAmendmentStore", "object", "." ]
python
train
63.035714
chbrown/pi
pi/commands/install.py
https://github.com/chbrown/pi/blob/a3661eccf1c6f0105e34a0ee24328022bf4e6b92/pi/commands/install.py#L14-L23
def cli(parser): ''' Currently a cop-out -- just calls easy_install ''' parser.add_argument('-n', '--dry-run', action='store_true', help='Print uninstall actions without running') parser.add_argument('packages', nargs='+', help='Packages to install') opts = parser.parse_args() for package i...
[ "def", "cli", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'-n'", ",", "'--dry-run'", ",", "action", "=", "'store_true'", ",", "help", "=", "'Print uninstall actions without running'", ")", "parser", ".", "add_argument", "(", "'packages'", ",", ...
Currently a cop-out -- just calls easy_install
[ "Currently", "a", "cop", "-", "out", "--", "just", "calls", "easy_install" ]
python
train
37.8
pandas-dev/pandas
pandas/core/generic.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L3086-L3098
def _get_item_cache(self, item): """Return the cached item, item represents a label indexer.""" cache = self._item_cache res = cache.get(item) if res is None: values = self._data.get(item) res = self._box_item_values(item, values) cache[item] = res ...
[ "def", "_get_item_cache", "(", "self", ",", "item", ")", ":", "cache", "=", "self", ".", "_item_cache", "res", "=", "cache", ".", "get", "(", "item", ")", "if", "res", "is", "None", ":", "values", "=", "self", ".", "_data", ".", "get", "(", "item",...
Return the cached item, item represents a label indexer.
[ "Return", "the", "cached", "item", "item", "represents", "a", "label", "indexer", "." ]
python
train
33.384615
ManiacalLabs/PixelWeb
pixelweb/bottle.py
https://github.com/ManiacalLabs/PixelWeb/blob/9eacbfd40a1d35011c2dcea15c303da9636c6b9e/pixelweb/bottle.py#L2158-L2163
def meta_set(self, key, metafield, value): ''' Set the meta field for a key to a new value. This triggers the on-change handler for existing keys. ''' self._meta.setdefault(key, {})[metafield] = value if key in self: self[key] = self[key]
[ "def", "meta_set", "(", "self", ",", "key", ",", "metafield", ",", "value", ")", ":", "self", ".", "_meta", ".", "setdefault", "(", "key", ",", "{", "}", ")", "[", "metafield", "]", "=", "value", "if", "key", "in", "self", ":", "self", "[", "key"...
Set the meta field for a key to a new value. This triggers the on-change handler for existing keys.
[ "Set", "the", "meta", "field", "for", "a", "key", "to", "a", "new", "value", ".", "This", "triggers", "the", "on", "-", "change", "handler", "for", "existing", "keys", "." ]
python
train
46.833333
apache/incubator-mxnet
example/rcnn/symdata/bbox.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L79-L104
def bbox_transform(ex_rois, gt_rois, box_stds): """ compute bounding box regression targets from ex_rois to gt_rois :param ex_rois: [N, 4] :param gt_rois: [N, 4] :return: [N, 4] """ assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' ex_widths = ex_rois[:, 2] - ex_ro...
[ "def", "bbox_transform", "(", "ex_rois", ",", "gt_rois", ",", "box_stds", ")", ":", "assert", "ex_rois", ".", "shape", "[", "0", "]", "==", "gt_rois", ".", "shape", "[", "0", "]", ",", "'inconsistent rois number'", "ex_widths", "=", "ex_rois", "[", ":", ...
compute bounding box regression targets from ex_rois to gt_rois :param ex_rois: [N, 4] :param gt_rois: [N, 4] :return: [N, 4]
[ "compute", "bounding", "box", "regression", "targets", "from", "ex_rois", "to", "gt_rois", ":", "param", "ex_rois", ":", "[", "N", "4", "]", ":", "param", "gt_rois", ":", "[", "N", "4", "]", ":", "return", ":", "[", "N", "4", "]" ]
python
train
41.230769
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1995-L1998
def p_sysargs(self, p): 'sysargs : sysargs COMMA sysarg' p[0] = p[1] + (p[3],) p.set_lineno(0, p.lineno(1))
[ "def", "p_sysargs", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", "+", "(", "p", "[", "3", "]", ",", ")", "p", ".", "set_lineno", "(", "0", ",", "p", ".", "lineno", "(", "1", ")", ")" ]
sysargs : sysargs COMMA sysarg
[ "sysargs", ":", "sysargs", "COMMA", "sysarg" ]
python
train
32
annoviko/pyclustering
pyclustering/nnet/som.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/som.py#L712-L728
def get_winner_number(self): """! @brief Calculates number of winner at the last step of learning process. @return (uint) Number of winner. """ if self.__ccore_som_pointer is not None: self._award = wrapper.som_get_awards(self.__cco...
[ "def", "get_winner_number", "(", "self", ")", ":", "if", "self", ".", "__ccore_som_pointer", "is", "not", "None", ":", "self", ".", "_award", "=", "wrapper", ".", "som_get_awards", "(", "self", ".", "__ccore_som_pointer", ")", "winner_number", "=", "0", "for...
! @brief Calculates number of winner at the last step of learning process. @return (uint) Number of winner.
[ "!" ]
python
valid
30.176471
pymacaron/pymacaron-core
pymacaron_core/swagger/spec.py
https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L142-L213
def call_on_each_endpoint(self, callback): """Find all server endpoints defined in the swagger spec and calls 'callback' for each, with an instance of EndpointData as argument. """ if 'paths' not in self.swagger_dict: return for path, d in list(self.swagger_dict['pa...
[ "def", "call_on_each_endpoint", "(", "self", ",", "callback", ")", ":", "if", "'paths'", "not", "in", "self", ".", "swagger_dict", ":", "return", "for", "path", ",", "d", "in", "list", "(", "self", ".", "swagger_dict", "[", "'paths'", "]", ".", "items", ...
Find all server endpoints defined in the swagger spec and calls 'callback' for each, with an instance of EndpointData as argument.
[ "Find", "all", "server", "endpoints", "defined", "in", "the", "swagger", "spec", "and", "calls", "callback", "for", "each", "with", "an", "instance", "of", "EndpointData", "as", "argument", "." ]
python
train
47.222222
zhanglab/psamm
psamm/fluxcoupling.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxcoupling.py#L94-L121
def solve(self, reaction_1, reaction_2): """Return the flux coupling between two reactions The flux coupling is returned as a tuple indicating the minimum and maximum value of the v1/v2 reaction flux ratio. A value of None as either the minimum or maximum indicates that the interval is ...
[ "def", "solve", "(", "self", ",", "reaction_1", ",", "reaction_2", ")", ":", "# Update objective for reaction_1", "self", ".", "_prob", ".", "set_objective", "(", "self", ".", "_vbow", "(", "reaction_1", ")", ")", "# Update constraint for reaction_2", "if", "self"...
Return the flux coupling between two reactions The flux coupling is returned as a tuple indicating the minimum and maximum value of the v1/v2 reaction flux ratio. A value of None as either the minimum or maximum indicates that the interval is unbounded in that direction.
[ "Return", "the", "flux", "coupling", "between", "two", "reactions" ]
python
train
37.285714
saltstack/salt
salt/modules/trafficserver.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L450-L466
def clear_alarms(alarm): ''' Clear (acknowledge) an alarm event. The arguments are “all” for all current alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier (e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘). .. code-block:: bash salt '*' trafficserver.clear_alarms [all | #ev...
[ "def", "clear_alarms", "(", "alarm", ")", ":", "if", "_TRAFFICCTL", ":", "cmd", "=", "_traffic_ctl", "(", "'alarm'", ",", "'clear'", ",", "alarm", ")", "else", ":", "cmd", "=", "_traffic_line", "(", "'--clear_alarms'", ",", "alarm", ")", "return", "_subpro...
Clear (acknowledge) an alarm event. The arguments are “all” for all current alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier (e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘). .. code-block:: bash salt '*' trafficserver.clear_alarms [all | #event | name]
[ "Clear", "(", "acknowledge", ")", "an", "alarm", "event", ".", "The", "arguments", "are", "“all”", "for", "all", "current", "alarms", "a", "specific", "alarm", "number", "(", "e", ".", "g", ".", "‘‘1’‘", ")", "or", "an", "alarm", "string", "identifier", ...
python
train
28.705882
bwohlberg/sporco
sporco/admm/cbpdn.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/cbpdn.py#L1347-L1357
def uinit(self, ushape): """Return initialiser for working variable U.""" if self.opt['Y0'] is None: return np.zeros(ushape, dtype=self.dtype) else: # If initial Y is non-zero, initial U is chosen so that # the relevant dual optimality criterion (see (3.10) i...
[ "def", "uinit", "(", "self", ",", "ushape", ")", ":", "if", "self", ".", "opt", "[", "'Y0'", "]", "is", "None", ":", "return", "np", ".", "zeros", "(", "ushape", ",", "dtype", "=", "self", ".", "dtype", ")", "else", ":", "# If initial Y is non-zero, ...
Return initialiser for working variable U.
[ "Return", "initialiser", "for", "working", "variable", "U", "." ]
python
train
42.181818
brechtm/rinohtype
src/rinoh/dimension.py
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/dimension.py#L49-L61
def _make_operator(method_name): """Return an operator method that takes parameters of type :class:`Dimension`, evaluates them, and delegates to the :class:`float` operator with name `method_name`""" def operator(self, other): """Operator delegating to the :class:`float` meth...
[ "def", "_make_operator", "(", "method_name", ")", ":", "def", "operator", "(", "self", ",", "other", ")", ":", "\"\"\"Operator delegating to the :class:`float` method `method_name`\"\"\"", "float_operator", "=", "getattr", "(", "float", ",", "method_name", ")", "try", ...
Return an operator method that takes parameters of type :class:`Dimension`, evaluates them, and delegates to the :class:`float` operator with name `method_name`
[ "Return", "an", "operator", "method", "that", "takes", "parameters", "of", "type", ":", "class", ":", "Dimension", "evaluates", "them", "and", "delegates", "to", "the", ":", "class", ":", "float", "operator", "with", "name", "method_name" ]
python
train
46.230769
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L280-L286
def get_out_ip_addr(cls, tenant_id): """Retrieves the 'out' service subnet attributes. """ if tenant_id not in cls.serv_obj_dict: LOG.error("Fabric not prepared for tenant %s", tenant_id) return tenant_obj = cls.serv_obj_dict.get(tenant_id) return tenant_obj.get_o...
[ "def", "get_out_ip_addr", "(", "cls", ",", "tenant_id", ")", ":", "if", "tenant_id", "not", "in", "cls", ".", "serv_obj_dict", ":", "LOG", ".", "error", "(", "\"Fabric not prepared for tenant %s\"", ",", "tenant_id", ")", "return", "tenant_obj", "=", "cls", "....
Retrieves the 'out' service subnet attributes.
[ "Retrieves", "the", "out", "service", "subnet", "attributes", "." ]
python
train
46.571429
mbr/flask-kvsession
flask_kvsession/__init__.py
https://github.com/mbr/flask-kvsession/blob/83238b74d4e4d2ffbdfd65c1c0a00ceb4bdfd9fa/flask_kvsession/__init__.py#L89-L104
def destroy(self): """Destroys a session completely, by deleting all keys and removing it from the internal store immediately. This allows removing a session for security reasons, e.g. a login stored in a session will cease to exist if the session is destroyed. """ for k...
[ "def", "destroy", "(", "self", ")", ":", "for", "k", "in", "list", "(", "self", ".", "keys", "(", ")", ")", ":", "del", "self", "[", "k", "]", "if", "getattr", "(", "self", ",", "'sid_s'", ",", "None", ")", ":", "current_app", ".", "kvsession_sto...
Destroys a session completely, by deleting all keys and removing it from the internal store immediately. This allows removing a session for security reasons, e.g. a login stored in a session will cease to exist if the session is destroyed.
[ "Destroys", "a", "session", "completely", "by", "deleting", "all", "keys", "and", "removing", "it", "from", "the", "internal", "store", "immediately", "." ]
python
train
33.625
budacom/trading-bots
trading_bots/utils.py
https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/utils.py#L57-L61
def spread_value(value: Decimal, spread_p: Decimal) -> Tuple[Decimal, Decimal]: """Returns a lower and upper value separated by a spread percentage""" upper = value * (1 + spread_p) lower = value / (1 + spread_p) return lower, upper
[ "def", "spread_value", "(", "value", ":", "Decimal", ",", "spread_p", ":", "Decimal", ")", "->", "Tuple", "[", "Decimal", ",", "Decimal", "]", ":", "upper", "=", "value", "*", "(", "1", "+", "spread_p", ")", "lower", "=", "value", "/", "(", "1", "+...
Returns a lower and upper value separated by a spread percentage
[ "Returns", "a", "lower", "and", "upper", "value", "separated", "by", "a", "spread", "percentage" ]
python
train
48.8
ramses-tech/ramses
ramses/models.py
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L59-L82
def prepare_relationship(config, model_name, raml_resource): """ Create referenced model if it doesn't exist. When preparing a relationship, we check to see if the model that will be referenced already exists. If not, it is created so that it will be possible to use it in a relationship. Thus the first...
[ "def", "prepare_relationship", "(", "config", ",", "model_name", ",", "raml_resource", ")", ":", "if", "get_existing_model", "(", "model_name", ")", "is", "None", ":", "plural_route", "=", "'/'", "+", "pluralize", "(", "model_name", ".", "lower", "(", ")", "...
Create referenced model if it doesn't exist. When preparing a relationship, we check to see if the model that will be referenced already exists. If not, it is created so that it will be possible to use it in a relationship. Thus the first usage of this model in RAML file must provide its schema in POST...
[ "Create", "referenced", "model", "if", "it", "doesn", "t", "exist", "." ]
python
train
47.666667
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/rsa.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L503-L523
def new_rsa_key(key_size=2048, kid='', use='', public_exponent=65537): """ Creates a new RSA key pair and wraps it in a :py:class:`cryptojwt.jwk.rsa.RSAKey` instance :param key_size: The size of the key :param kid: The key ID :param use: What the is supposed to be used for. 2 choices 'sig'/'enc...
[ "def", "new_rsa_key", "(", "key_size", "=", "2048", ",", "kid", "=", "''", ",", "use", "=", "''", ",", "public_exponent", "=", "65537", ")", ":", "_key", "=", "rsa", ".", "generate_private_key", "(", "public_exponent", "=", "public_exponent", ",", "key_siz...
Creates a new RSA key pair and wraps it in a :py:class:`cryptojwt.jwk.rsa.RSAKey` instance :param key_size: The size of the key :param kid: The key ID :param use: What the is supposed to be used for. 2 choices 'sig'/'enc' :param public_exponent: The value of the public exponent. :return: A :py:...
[ "Creates", "a", "new", "RSA", "key", "pair", "and", "wraps", "it", "in", "a", ":", "py", ":", "class", ":", "cryptojwt", ".", "jwk", ".", "rsa", ".", "RSAKey", "instance" ]
python
train
34.52381
LogicalDash/LiSE
allegedb/allegedb/cache.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L931-L938
def iter_predecessors(self, graph, dest, branch, turn, tick, *, forward=None): """Iterate over predecessors to a given destination node at a given time.""" if self.db._no_kc: yield from self._adds_dels_sucpred(self.predecessors[graph, dest], branch, turn, tick)[0] return ...
[ "def", "iter_predecessors", "(", "self", ",", "graph", ",", "dest", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", "=", "None", ")", ":", "if", "self", ".", "db", ".", "_no_kc", ":", "yield", "from", "self", ".", "_adds_dels_sucpr...
Iterate over predecessors to a given destination node at a given time.
[ "Iterate", "over", "predecessors", "to", "a", "given", "destination", "node", "at", "a", "given", "time", "." ]
python
train
57.5
MeirKriheli/django-bidi-utils
bidiutils/context_processors.py
https://github.com/MeirKriheli/django-bidi-utils/blob/48a8c481fe728fbccf486582999e79454195036e/bidiutils/context_processors.py#L3-L33
def bidi(request): """Adds to the context BiDi related variables LANGUAGE_DIRECTION -- Direction of current language ('ltr' or 'rtl') LANGUAGE_START -- Start of language layout ('right' for rtl, 'left' for 'ltr') LANGUAGE_END -- End of language layout ('left' for rtl, 'right' ...
[ "def", "bidi", "(", "request", ")", ":", "from", "django", ".", "utils", "import", "translation", "from", "django", ".", "utils", ".", "safestring", "import", "mark_safe", "if", "translation", ".", "get_language_bidi", "(", ")", ":", "extra_context", "=", "{...
Adds to the context BiDi related variables LANGUAGE_DIRECTION -- Direction of current language ('ltr' or 'rtl') LANGUAGE_START -- Start of language layout ('right' for rtl, 'left' for 'ltr') LANGUAGE_END -- End of language layout ('left' for rtl, 'right' for 'ltr...
[ "Adds", "to", "the", "context", "BiDi", "related", "variables" ]
python
test
32.193548
tensorforce/tensorforce
tensorforce/contrib/openai_universe.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/openai_universe.py#L86-L96
def _int_to_pos(self, flat_position): """Returns x, y from flat_position integer. Args: flat_position: flattened position integer Returns: x, y """ return flat_position % self.env.action_space.screen_shape[0],\ flat_position % self.env.action_space.scre...
[ "def", "_int_to_pos", "(", "self", ",", "flat_position", ")", ":", "return", "flat_position", "%", "self", ".", "env", ".", "action_space", ".", "screen_shape", "[", "0", "]", ",", "flat_position", "%", "self", ".", "env", ".", "action_space", ".", "screen...
Returns x, y from flat_position integer. Args: flat_position: flattened position integer Returns: x, y
[ "Returns", "x", "y", "from", "flat_position", "integer", "." ]
python
valid
29.181818
bluec0re/android-backup-tools
android_backup/android_backup.py
https://github.com/bluec0re/android-backup-tools/blob/e2e0d95e56624c1a99a176df9e307398e837d908/android_backup/android_backup.py#L145-L236
def _decrypt(self, fp, password=None): """ Internal decryption function Uses either the password argument for the decryption, or, if not supplied, the password field of the object :param fp: a file object or similar which supports the readline and read methods :rtype: P...
[ "def", "_decrypt", "(", "self", ",", "fp", ",", "password", "=", "None", ")", ":", "if", "AES", "is", "None", ":", "raise", "ImportError", "(", "\"PyCrypto required\"", ")", "if", "password", "is", "None", ":", "password", "=", "self", ".", "password", ...
Internal decryption function Uses either the password argument for the decryption, or, if not supplied, the password field of the object :param fp: a file object or similar which supports the readline and read methods :rtype: Proxy
[ "Internal", "decryption", "function" ]
python
train
34.804348
gatkin/declxml
declxml.py
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L374-L430
def array( item_processor, # type: Processor alias=None, # type: Optional[Text] nested=None, # type: Optional[Text] omit_empty=False, # type: bool hooks=None # type: Optional[Hooks] ): # type: (...) -> RootProcessor """ Create an array processor that can be used ...
[ "def", "array", "(", "item_processor", ",", "# type: Processor", "alias", "=", "None", ",", "# type: Optional[Text]", "nested", "=", "None", ",", "# type: Optional[Text]", "omit_empty", "=", "False", ",", "# type: bool", "hooks", "=", "None", "# type: Optional[Hooks]"...
Create an array processor that can be used to parse and serialize array data. XML arrays may be nested within an array element, or they may be embedded within their parent. A nested array would look like: .. sourcecode:: xml <root-element> <some-element>ABC</some-element> ...
[ "Create", "an", "array", "processor", "that", "can", "be", "used", "to", "parse", "and", "serialize", "array", "data", "." ]
python
train
38.877193
MacHu-GWU/single_file_module-project
sfm/rnd.py
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L92-L102
def rand_ssn(): """Random SSN. (9 digits) Example:: >>> rand_ssn() 295-50-0178 """ return "%s-%s-%s" % (rand_str(3, string.digits), rand_str(2, string.digits), rand_str(4, string.digits))
[ "def", "rand_ssn", "(", ")", ":", "return", "\"%s-%s-%s\"", "%", "(", "rand_str", "(", "3", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "2", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "4", ",", "string", ".", "digits", ")...
Random SSN. (9 digits) Example:: >>> rand_ssn() 295-50-0178
[ "Random", "SSN", ".", "(", "9", "digits", ")" ]
python
train
23.727273
jtwhite79/pyemu
pyemu/prototypes/da.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/prototypes/da.py#L299-L309
def update(self): """update performs the analysis, then runs the forecast using the updated self.parensemble. This can be called repeatedly to iterate...""" parensemble = self.analysis_evensen() obsensemble = self.forecast(parensemble=parensemble) # todo: check for phi improveme...
[ "def", "update", "(", "self", ")", ":", "parensemble", "=", "self", ".", "analysis_evensen", "(", ")", "obsensemble", "=", "self", ".", "forecast", "(", "parensemble", "=", "parensemble", ")", "# todo: check for phi improvement", "if", "True", ":", "self", "."...
update performs the analysis, then runs the forecast using the updated self.parensemble. This can be called repeatedly to iterate...
[ "update", "performs", "the", "analysis", "then", "runs", "the", "forecast", "using", "the", "updated", "self", ".", "parensemble", ".", "This", "can", "be", "called", "repeatedly", "to", "iterate", "..." ]
python
train
40.272727
ergoithz/browsepy
browsepy/manager.py
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/manager.py#L302-L339
def create_widget(self, place, type, file=None, **kwargs): ''' Create a widget object based on given arguments. If file object is provided, callable arguments will be resolved: its return value will be used after calling them with file as first parameter. All extra `kwa...
[ "def", "create_widget", "(", "self", ",", "place", ",", "type", ",", "file", "=", "None", ",", "*", "*", "kwargs", ")", ":", "widget_class", "=", "self", ".", "widget_types", ".", "get", "(", "type", ",", "self", ".", "widget_types", "[", "'base'", "...
Create a widget object based on given arguments. If file object is provided, callable arguments will be resolved: its return value will be used after calling them with file as first parameter. All extra `kwargs` parameters will be passed to widget constructor. :param place: pl...
[ "Create", "a", "widget", "object", "based", "on", "given", "arguments", "." ]
python
train
38.973684
KrzyHonk/bpmn-python
bpmn_python/bpmn_process_csv_export.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_process_csv_export.py#L110-L205
def export_element(bpmn_graph, export_elements, node, nodes_classification, order=0, prefix="", condition="", who="", add_join=False): """ Export a node with "Element" classification (task, subprocess or gateway) :param bpmn_graph: an instance of BpmnDiagramGraph class, ...
[ "def", "export_element", "(", "bpmn_graph", ",", "export_elements", ",", "node", ",", "nodes_classification", ",", "order", "=", "0", ",", "prefix", "=", "\"\"", ",", "condition", "=", "\"\"", ",", "who", "=", "\"\"", ",", "add_join", "=", "False", ")", ...
Export a node with "Element" classification (task, subprocess or gateway) :param bpmn_graph: an instance of BpmnDiagramGraph class, :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that will be used in exported CSV document, :...
[ "Export", "a", "node", "with", "Element", "classification", "(", "task", "subprocess", "or", "gateway", ")" ]
python
train
62.833333
blue-yonder/tsfresh
tsfresh/feature_extraction/feature_calculators.py
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L370-L418
def partial_autocorrelation(x, param): """ Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial autocorrelation of a time series :math:`\\lbrace x_t, t = 1 \\ldots T \\rbrace` equals the partial correlation of :math:`x_t` and :math:`x_{t-k}`, adjusted for th...
[ "def", "partial_autocorrelation", "(", "x", ",", "param", ")", ":", "# Check the difference between demanded lags by param and possible lags to calculate (depends on len(x))", "max_demanded_lag", "=", "max", "(", "[", "lag", "[", "\"lag\"", "]", "for", "lag", "in", "param",...
Calculates the value of the partial autocorrelation function at the given lag. The lag `k` partial autocorrelation of a time series :math:`\\lbrace x_t, t = 1 \\ldots T \\rbrace` equals the partial correlation of :math:`x_t` and :math:`x_{t-k}`, adjusted for the intermediate variables :math:`\\lbrace x_{t-1...
[ "Calculates", "the", "value", "of", "the", "partial", "autocorrelation", "function", "at", "the", "given", "lag", ".", "The", "lag", "k", "partial", "autocorrelation", "of", "a", "time", "series", ":", "math", ":", "\\\\", "lbrace", "x_t", "t", "=", "1", ...
python
train
47.897959
zetaops/pyoko
pyoko/db/queryset.py
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L356-L382
def get(self, key=None, **kwargs): """ Ensures that only one result is returned from DB and raises an exception otherwise. Can work in 3 different way. - If no argument is given, only does "ensuring about one and only object" job. - If key given as only argument, retriev...
[ "def", "get", "(", "self", ",", "key", "=", "None", ",", "*", "*", "kwargs", ")", ":", "clone", "=", "copy", ".", "deepcopy", "(", "self", ")", "# If we are in a slice, adjust the start and rows", "if", "self", ".", "_start", ":", "clone", ".", "adapter", ...
Ensures that only one result is returned from DB and raises an exception otherwise. Can work in 3 different way. - If no argument is given, only does "ensuring about one and only object" job. - If key given as only argument, retrieves the object from DB. - if query filters g...
[ "Ensures", "that", "only", "one", "result", "is", "returned", "from", "DB", "and", "raises", "an", "exception", "otherwise", ".", "Can", "work", "in", "3", "different", "way", "." ]
python
train
40.111111
globocom/GloboNetworkAPI-client-python
networkapiclient/Roteiro.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Roteiro.py#L171-L201
def listar_por_equipamento(self, id_equipment): """List all Script related Equipment. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {script': [{‘id’: < id >, ‘nome’: ...
[ "def", "listar_por_equipamento", "(", "self", ",", "id_equipment", ")", ":", "if", "not", "is_valid_int_param", "(", "id_equipment", ")", ":", "raise", "InvalidParameterError", "(", "u'The identifier of Equipment is invalid or was not informed.'", ")", "url", "=", "'scrip...
List all Script related Equipment. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {script': [{‘id’: < id >, ‘nome’: < nome >, ‘descricao’: < descricao >, ...
[ "List", "all", "Script", "related", "Equipment", "." ]
python
train
39.322581
coleifer/irc
irc.py
https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L246-L270
def enter_event_loop(self): """\ Main loop of the IRCConnection - reads from the socket and dispatches based on regex matching """ patterns = self.dispatch_patterns() self.logger.debug('entering receive loop') while 1: try: data = self...
[ "def", "enter_event_loop", "(", "self", ")", ":", "patterns", "=", "self", ".", "dispatch_patterns", "(", ")", "self", ".", "logger", ".", "debug", "(", "'entering receive loop'", ")", "while", "1", ":", "try", ":", "data", "=", "self", ".", "_sock_file", ...
\ Main loop of the IRCConnection - reads from the socket and dispatches based on regex matching
[ "\\", "Main", "loop", "of", "the", "IRCConnection", "-", "reads", "from", "the", "socket", "and", "dispatches", "based", "on", "regex", "matching" ]
python
test
29
wiredrive/wtframework
wtframework/wtf/web/page.py
https://github.com/wiredrive/wtframework/blob/ef7f86c4d4cf7fb17745fd627b3cc4a41f4c0216/wtframework/wtf/web/page.py#L114-L130
def create_page(cls, webdriver=None, **kwargs): """Class method short cut to call PageFactory on itself. Use it to instantiate this PageObject using a webdriver. Args: webdriver (Webdriver): Instance of Selenium Webdriver. Returns: PageObject Raises: ...
[ "def", "create_page", "(", "cls", ",", "webdriver", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "webdriver", ":", "webdriver", "=", "WTF_WEBDRIVER_MANAGER", ".", "get_driver", "(", ")", "return", "PageFactory", ".", "create_page", "(", "cl...
Class method short cut to call PageFactory on itself. Use it to instantiate this PageObject using a webdriver. Args: webdriver (Webdriver): Instance of Selenium Webdriver. Returns: PageObject Raises: InvalidPageError
[ "Class", "method", "short", "cut", "to", "call", "PageFactory", "on", "itself", ".", "Use", "it", "to", "instantiate", "this", "PageObject", "using", "a", "webdriver", "." ]
python
train
29.705882
zhmcclient/python-zhmcclient
zhmcclient/_storage_volume.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_storage_volume.py#L496-L554
def indicate_fulfillment_ficon(self, control_unit, unit_address): """ TODO: Add ControlUnit objects etc for FICON support. Indicate completion of :term:`fulfillment` for this ECKD (=FICON) storage volume and provide identifying information (control unit and unit address) about t...
[ "def", "indicate_fulfillment_ficon", "(", "self", ",", "control_unit", ",", "unit_address", ")", ":", "# The operation requires exactly 2 characters in lower case", "unit_address_2", "=", "format", "(", "int", "(", "unit_address", ",", "16", ")", ",", "'02x'", ")", "b...
TODO: Add ControlUnit objects etc for FICON support. Indicate completion of :term:`fulfillment` for this ECKD (=FICON) storage volume and provide identifying information (control unit and unit address) about the actual storage volume on the storage subsystem. Manually indicatin...
[ "TODO", ":", "Add", "ControlUnit", "objects", "etc", "for", "FICON", "support", "." ]
python
train
37.220339
pyroscope/pyrobase
src/pyrobase/bencode.py
https://github.com/pyroscope/pyrobase/blob/7a2591baa492c3d8997ab4801b97c7b1f2ebc6b1/src/pyrobase/bencode.py#L170-L180
def bread(stream): """ Decode a file or stream to an object. """ if hasattr(stream, "read"): return bdecode(stream.read()) else: handle = open(stream, "rb") try: return bdecode(handle.read()) finally: handle.close()
[ "def", "bread", "(", "stream", ")", ":", "if", "hasattr", "(", "stream", ",", "\"read\"", ")", ":", "return", "bdecode", "(", "stream", ".", "read", "(", ")", ")", "else", ":", "handle", "=", "open", "(", "stream", ",", "\"rb\"", ")", "try", ":", ...
Decode a file or stream to an object.
[ "Decode", "a", "file", "or", "stream", "to", "an", "object", "." ]
python
train
25.181818
loli/medpy
medpy/metric/histogram.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L34-L93
def minowski(h1, h2, p = 2): # 46..45..14,11..43..44 / 45 us for p=int(-inf..-24..-1,1..24..inf) / float @array, +20 us @list \w 100 bins r""" Minowski distance. With :math:`p=2` equal to the Euclidean distance, with :math:`p=1` equal to the Manhattan distance, and the Chebyshev distance implementa...
[ "def", "minowski", "(", "h1", ",", "h2", ",", "p", "=", "2", ")", ":", "# 46..45..14,11..43..44 / 45 us for p=int(-inf..-24..-1,1..24..inf) / float @array, +20 us @list \\w 100 bins", "h1", ",", "h2", "=", "__prepare_histogram", "(", "h1", ",", "h2", ")", "if", "0", ...
r""" Minowski distance. With :math:`p=2` equal to the Euclidean distance, with :math:`p=1` equal to the Manhattan distance, and the Chebyshev distance implementation represents the case of :math:`p=\pm inf`. The Minowksi distance between two histograms :math:`H` and :math:`H'` of size :math:`m...
[ "r", "Minowski", "distance", ".", "With", ":", "math", ":", "p", "=", "2", "equal", "to", "the", "Euclidean", "distance", "with", ":", "math", ":", "p", "=", "1", "equal", "to", "the", "Manhattan", "distance", "and", "the", "Chebyshev", "distance", "im...
python
train
28.116667
abw333/dominoes
dominoes/game.py
https://github.com/abw333/dominoes/blob/ea9f532c9b834117a5c07d214711515872f7537e/dominoes/game.py#L375-L400
def missing_values(self): ''' Computes the values that must be missing from each player's hand, based on when they have passed. :return: a list of sets, each one containing the values that must be missing from the corresponding player's hand '''...
[ "def", "missing_values", "(", "self", ")", ":", "missing", "=", "[", "set", "(", ")", "for", "_", "in", "self", ".", "hands", "]", "# replay the game from the beginning", "board", "=", "dominoes", ".", "SkinnyBoard", "(", ")", "player", "=", "self", ".", ...
Computes the values that must be missing from each player's hand, based on when they have passed. :return: a list of sets, each one containing the values that must be missing from the corresponding player's hand
[ "Computes", "the", "values", "that", "must", "be", "missing", "from", "each", "player", "s", "hand", "based", "on", "when", "they", "have", "passed", "." ]
python
train
33.076923
Erotemic/utool
utool/util_inspect.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1052-L1101
def is_defined_by_module(item, module, parent=None): """ Check if item is directly defined by a module. This check may be prone to errors. """ flag = False if isinstance(item, types.ModuleType): if not hasattr(item, '__file__'): try: # hack for cv2 and xfeatur...
[ "def", "is_defined_by_module", "(", "item", ",", "module", ",", "parent", "=", "None", ")", ":", "flag", "=", "False", "if", "isinstance", "(", "item", ",", "types", ".", "ModuleType", ")", ":", "if", "not", "hasattr", "(", "item", ",", "'__file__'", "...
Check if item is directly defined by a module. This check may be prone to errors.
[ "Check", "if", "item", "is", "directly", "defined", "by", "a", "module", ".", "This", "check", "may", "be", "prone", "to", "errors", "." ]
python
train
40.24
joeferraro/mm
mm/sforce/base.py
https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L562-L568
def describeSObject(self, sObjectsType): ''' Describes metadata (field list and object properties) for the specified object. ''' self._setHeaders('describeSObject') return self._sforce.service.describeSObject(sObjectsType)
[ "def", "describeSObject", "(", "self", ",", "sObjectsType", ")", ":", "self", ".", "_setHeaders", "(", "'describeSObject'", ")", "return", "self", ".", "_sforce", ".", "service", ".", "describeSObject", "(", "sObjectsType", ")" ]
Describes metadata (field list and object properties) for the specified object.
[ "Describes", "metadata", "(", "field", "list", "and", "object", "properties", ")", "for", "the", "specified", "object", "." ]
python
train
34.285714
BeyondTheClouds/enoslib
enoslib/infra/enos_g5k/g5k_api_utils.py
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L455-L490
def can_start_on_cluster(nodes_status, nodes, start, walltime): """Check if #nodes can be started on a given cluster. This is intended to give a good enough approximation. This can be use to prefiltered possible reservation dates be...
[ "def", "can_start_on_cluster", "(", "nodes_status", ",", "nodes", ",", "start", ",", "walltime", ")", ":", "candidates", "=", "[", "]", "for", "node", ",", "status", "in", "nodes_status", ".", "items", "(", ")", ":", "reservations", "=", "status", ".", "...
Check if #nodes can be started on a given cluster. This is intended to give a good enough approximation. This can be use to prefiltered possible reservation dates before submitting them on oar.
[ "Check", "if", "#nodes", "can", "be", "started", "on", "a", "given", "cluster", "." ]
python
train
40.083333
sunlightlabs/name-cleaver
name_cleaver/names.py
https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/names.py#L176-L242
def new_from_tokens(self, *args, **kwargs): """ Takes in a name that has been split by spaces. Names which are in [last, first] format need to be preprocessed. The nickname must be in double quotes to be recognized as such. This can take name parts in in these or...
[ "def", "new_from_tokens", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'allow_quoted_nicknames'", ")", ":", "args", "=", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "args", "if", "not",...
Takes in a name that has been split by spaces. Names which are in [last, first] format need to be preprocessed. The nickname must be in double quotes to be recognized as such. This can take name parts in in these orders: first, middle, last, nick, suffix, honorific ...
[ "Takes", "in", "a", "name", "that", "has", "been", "split", "by", "spaces", ".", "Names", "which", "are", "in", "[", "last", "first", "]", "format", "need", "to", "be", "preprocessed", ".", "The", "nickname", "must", "be", "in", "double", "quotes", "to...
python
train
34.537313
rocky/python-uncompyle6
uncompyle6/semantics/linemap.py
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/linemap.py#L25-L35
def write(self, *data): """Augment write routine to keep track of current line""" for l in data: ## print("XXX write: '%s'" % l) for i in str(l): if i == '\n': self.current_line_number += 1 pass pass ...
[ "def", "write", "(", "self", ",", "*", "data", ")", ":", "for", "l", "in", "data", ":", "## print(\"XXX write: '%s'\" % l)", "for", "i", "in", "str", "(", "l", ")", ":", "if", "i", "==", "'\\n'", ":", "self", ".", "current_line_number", "+=", "1", "p...
Augment write routine to keep track of current line
[ "Augment", "write", "routine", "to", "keep", "track", "of", "current", "line" ]
python
train
33.909091
phoebe-project/phoebe2
phoebe/parameters/parameters.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/parameters.py#L3935-L3940
def remove_not_valid_selections(self): """ update the value to remove any that are (no longer) valid """ value = [v for v in self.get_value() if self.valid_selection(v)] self.set_value(value)
[ "def", "remove_not_valid_selections", "(", "self", ")", ":", "value", "=", "[", "v", "for", "v", "in", "self", ".", "get_value", "(", ")", "if", "self", ".", "valid_selection", "(", "v", ")", "]", "self", ".", "set_value", "(", "value", ")" ]
update the value to remove any that are (no longer) valid
[ "update", "the", "value", "to", "remove", "any", "that", "are", "(", "no", "longer", ")", "valid" ]
python
train
37.666667
mjirik/io3d
io3d/datawriter.py
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datawriter.py#L208-L237
def DataCopyWithOverlay(self, dcmfilelist, out_dir, overlays): """ Function make 3D data from dicom file slices :dcmfilelist list of sorted .dcm files :overlays dictionary of binary overlays. {1:np.array([...]), 3:...} :out_dir output directory """ dcmlist = dcm...
[ "def", "DataCopyWithOverlay", "(", "self", ",", "dcmfilelist", ",", "out_dir", ",", "overlays", ")", ":", "dcmlist", "=", "dcmfilelist", "# data3d = []", "for", "i", "in", "range", "(", "len", "(", "dcmlist", ")", ")", ":", "onefile", "=", "dcmlist", "[", ...
Function make 3D data from dicom file slices :dcmfilelist list of sorted .dcm files :overlays dictionary of binary overlays. {1:np.array([...]), 3:...} :out_dir output directory
[ "Function", "make", "3D", "data", "from", "dicom", "file", "slices" ]
python
train
32
gwastro/pycbc
pycbc/io/hdf.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/io/hdf.py#L241-L258
def cluster(self, window): """ Cluster the dict array, assuming it has the relevant Coinc colums, time1, time2, stat, and timeslide_id """ # If no events, do nothing pivot_ifo = self.attrs['pivot'] fixed_ifo = self.attrs['fixed'] if len(self.data['%s/time' % pivot...
[ "def", "cluster", "(", "self", ",", "window", ")", ":", "# If no events, do nothing", "pivot_ifo", "=", "self", ".", "attrs", "[", "'pivot'", "]", "fixed_ifo", "=", "self", ".", "attrs", "[", "'fixed'", "]", "if", "len", "(", "self", ".", "data", "[", ...
Cluster the dict array, assuming it has the relevant Coinc colums, time1, time2, stat, and timeslide_id
[ "Cluster", "the", "dict", "array", "assuming", "it", "has", "the", "relevant", "Coinc", "colums", "time1", "time2", "stat", "and", "timeslide_id" ]
python
train
44.833333
thriftrw/thriftrw-python
thriftrw/idl/parser.py
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L76-L78
def p_namespace(self, p): '''namespace : NAMESPACE namespace_scope IDENTIFIER''' p[0] = ast.Namespace(scope=p[2], name=p[3], lineno=p.lineno(1))
[ "def", "p_namespace", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "ast", ".", "Namespace", "(", "scope", "=", "p", "[", "2", "]", ",", "name", "=", "p", "[", "3", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", "...
namespace : NAMESPACE namespace_scope IDENTIFIER
[ "namespace", ":", "NAMESPACE", "namespace_scope", "IDENTIFIER" ]
python
train
52.666667
singularityhub/sregistry-cli
sregistry/main/s3/query.py
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/s3/query.py#L41-L77
def search_all(self, quiet=False): '''a "show all" search that doesn't require a query Parameters ========== quiet: if quiet is True, we only are using the function to return rows of results. ''' results = [] for obj in self.bucket.objects.all(): subsr...
[ "def", "search_all", "(", "self", ",", "quiet", "=", "False", ")", ":", "results", "=", "[", "]", "for", "obj", "in", "self", ".", "bucket", ".", "objects", ".", "all", "(", ")", ":", "subsrc", "=", "obj", ".", "Object", "(", ")", "# Metadata bug w...
a "show all" search that doesn't require a query Parameters ========== quiet: if quiet is True, we only are using the function to return rows of results.
[ "a", "show", "all", "search", "that", "doesn", "t", "require", "a", "query", "Parameters", "==========", "quiet", ":", "if", "quiet", "is", "True", "we", "only", "are", "using", "the", "function", "to", "return", "rows", "of", "results", "." ]
python
test
27.864865
gwastro/pycbc
docs/_include/inference_io_inheritance_diagrams.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/docs/_include/inference_io_inheritance_diagrams.py#L8-L12
def get_topclasses(cls): """Gets the base classes that are in pycbc.""" bases = [c for c in inspect.getmro(cls) if c.__module__.startswith('pycbc') and c != cls] return ', '.join(['{}.{}'.format(c.__module__, c.__name__) for c in bases])
[ "def", "get_topclasses", "(", "cls", ")", ":", "bases", "=", "[", "c", "for", "c", "in", "inspect", ".", "getmro", "(", "cls", ")", "if", "c", ".", "__module__", ".", "startswith", "(", "'pycbc'", ")", "and", "c", "!=", "cls", "]", "return", "', '"...
Gets the base classes that are in pycbc.
[ "Gets", "the", "base", "classes", "that", "are", "in", "pycbc", "." ]
python
train
51.6
tensorflow/tensor2tensor
tensor2tensor/layers/common_layers.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_layers.py#L2389-L2440
def linear_set_layer(layer_size, inputs, context=None, activation_fn=tf.nn.relu, dropout=0.0, name=None): """Basic layer type for doing funky things with sets. Applies a linear transformation to each element in...
[ "def", "linear_set_layer", "(", "layer_size", ",", "inputs", ",", "context", "=", "None", ",", "activation_fn", "=", "tf", ".", "nn", ".", "relu", ",", "dropout", "=", "0.0", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(",...
Basic layer type for doing funky things with sets. Applies a linear transformation to each element in the input set. If a context is supplied, it is concatenated with the inputs. e.g. One can use global_pool_1d to get a representation of the set which can then be used as the context for the next layer. ...
[ "Basic", "layer", "type", "for", "doing", "funky", "things", "with", "sets", "." ]
python
train
37.211538
JarryShaw/PyPCAPKit
src/protocols/internet/hip.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L505-L553
def _read_para_puzzle(self, code, cbit, clen, *, desc, length, version): """Read HIP PUZZLE parameter. Structure of HIP PUZZLE parameter [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 ...
[ "def", "_read_para_puzzle", "(", "self", ",", "code", ",", "cbit", ",", "clen", ",", "*", ",", "desc", ",", "length", ",", "version", ")", ":", "if", "version", "==", "1", "and", "clen", "!=", "12", ":", "raise", "ProtocolError", "(", "f'HIPv{version}:...
Read HIP PUZZLE parameter. Structure of HIP PUZZLE parameter [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...
[ "Read", "HIP", "PUZZLE", "parameter", "." ]
python
train
42.755102
equinor/segyio
python/segyio/segy.py
https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/segy.py#L573-L603
def xline(self): """ Interact with segy in crossline mode Returns ------- xline : Line or None Raises ------ ValueError If the file is unstructured Notes ----- .. versionadded:: 1.1 """ if self.unstruc...
[ "def", "xline", "(", "self", ")", ":", "if", "self", ".", "unstructured", ":", "raise", "ValueError", "(", "self", ".", "_unstructured_errmsg", ")", "if", "self", ".", "_xline", "is", "not", "None", ":", "return", "self", ".", "_xline", "self", ".", "_...
Interact with segy in crossline mode Returns ------- xline : Line or None Raises ------ ValueError If the file is unstructured Notes ----- .. versionadded:: 1.1
[ "Interact", "with", "segy", "in", "crossline", "mode" ]
python
train
23.354839
proycon/pynlpl
pynlpl/formats/folia.py
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L569-L591
def makeelement(E, tagname, **kwargs): """Internal function""" if sys.version < '3': try: kwargs2 = {} for k,v in kwargs.items(): kwargs2[k.encode('utf-8')] = v.encode('utf-8') #return E._makeelement(tagname.encode('utf-8'), **{ k.encode('utf-8'): ...
[ "def", "makeelement", "(", "E", ",", "tagname", ",", "*", "*", "kwargs", ")", ":", "if", "sys", ".", "version", "<", "'3'", ":", "try", ":", "kwargs2", "=", "{", "}", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "kwargs2",...
Internal function
[ "Internal", "function" ]
python
train
47.043478
awslabs/sockeye
sockeye/image_captioning/utils.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/image_captioning/utils.py#L170-L198
def zero_pad_features(features: List[np.ndarray], target_shape: tuple) -> List[np.ndarray]: """ Zero pad to numpy array. :param features: List of numpy arrays. :param target_shape: Target shape of each numpy array in the list feat. Note: target_shape should be g...
[ "def", "zero_pad_features", "(", "features", ":", "List", "[", "np", ".", "ndarray", "]", ",", "target_shape", ":", "tuple", ")", "->", "List", "[", "np", ".", "ndarray", "]", ":", "pad_features", "=", "[", "]", "for", "feature", "in", "features", ":",...
Zero pad to numpy array. :param features: List of numpy arrays. :param target_shape: Target shape of each numpy array in the list feat. Note: target_shape should be greater that the largest shapes in feat. :return: A list of padded numpy arrays.
[ "Zero", "pad", "to", "numpy", "array", "." ]
python
train
56.068966
not-na/peng3d
peng3d/gui/widgets.py
https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/gui/widgets.py#L246-L257
def clickable(self): """ Property used for determining if the widget should be clickable by the user. This is only true if the submenu of this widget is active and this widget is enabled. The widget may be either disabled by setting this property or the :py:attr:`enable...
[ "def", "clickable", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "submenu", ",", "Container", ")", ":", "return", "self", ".", "submenu", ".", "name", "==", "self", ".", "submenu", ".", "menu", ".", "activeSubMenu", "and", "self"...
Property used for determining if the widget should be clickable by the user. This is only true if the submenu of this widget is active and this widget is enabled. The widget may be either disabled by setting this property or the :py:attr:`enabled` attribute.
[ "Property", "used", "for", "determining", "if", "the", "widget", "should", "be", "clickable", "by", "the", "user", ".", "This", "is", "only", "true", "if", "the", "submenu", "of", "this", "widget", "is", "active", "and", "this", "widget", "is", "enabled", ...
python
test
50
chinapnr/fishbase
fishbase/fish_random.py
https://github.com/chinapnr/fishbase/blob/23c5147a6bc0d8ed36409e55352ffb2c5b0edc82/fishbase/fish_random.py#L528-L619
def gen_random_company_name(): """ 随机生成一个公司名称 :returns: * company_name: (string) 银行名称 举例如下:: print('--- gen_random_company_name demo ---') print(gen_random_company_name()) print('---') 输出结果:: --- gen_random_company_name demo --- 上海大升旅游质询有限责任公司 ...
[ "def", "gen_random_company_name", "(", ")", ":", "region_info", "=", "(", "\"北京,上海,广州,深圳,天津,成都,杭州,苏州,重庆,武汉,南京,大连,沈阳,长沙,郑州,西安,青岛,\"", "\"无锡,济南,宁波,佛山,南通,哈尔滨,东莞,福州,长春,石家庄,烟台,合肥,唐山,常州,太原,昆明,\"", "\"潍坊,南昌,泉州,温州,绍兴,嘉兴,厦门,贵阳,淄博,徐州,南宁,扬州,呼和浩特,鄂尔多斯,乌鲁木齐,\"", "\"金华,台州,镇江,威海,珠海,东营,大庆,中山,盐城,包头,保定,济宁,泰州,廊坊...
随机生成一个公司名称 :returns: * company_name: (string) 银行名称 举例如下:: print('--- gen_random_company_name demo ---') print(gen_random_company_name()) print('---') 输出结果:: --- gen_random_company_name demo --- 上海大升旅游质询有限责任公司 ---
[ "随机生成一个公司名称" ]
python
train
53.23913
log2timeline/dfwinreg
dfwinreg/regf.py
https://github.com/log2timeline/dfwinreg/blob/9d488bb1db562197dbfb48de9613d6b29dea056e/dfwinreg/regf.py#L248-L259
def data(self): """bytes: value data as a byte string. Raises: WinRegistryValueError: if the value data cannot be read. """ try: return self._pyregf_value.data except IOError as exception: raise errors.WinRegistryValueError( 'Unable to read data from value: {0:s} with er...
[ "def", "data", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_pyregf_value", ".", "data", "except", "IOError", "as", "exception", ":", "raise", "errors", ".", "WinRegistryValueError", "(", "'Unable to read data from value: {0:s} with error: {1!s}'", "."...
bytes: value data as a byte string. Raises: WinRegistryValueError: if the value data cannot be read.
[ "bytes", ":", "value", "data", "as", "a", "byte", "string", "." ]
python
train
31.583333
openvax/mhcflurry
mhcflurry/class1_neural_network.py
https://github.com/openvax/mhcflurry/blob/deb7c1629111254b484a2711619eb2347db36524/mhcflurry/class1_neural_network.py#L274-L288
def get_config(self): """ serialize to a dict all attributes except model weights Returns ------- dict """ self.update_network_description() result = dict(self.__dict__) result['_network'] = None result['network_weights'] = None ...
[ "def", "get_config", "(", "self", ")", ":", "self", ".", "update_network_description", "(", ")", "result", "=", "dict", "(", "self", ".", "__dict__", ")", "result", "[", "'_network'", "]", "=", "None", "result", "[", "'network_weights'", "]", "=", "None", ...
serialize to a dict all attributes except model weights Returns ------- dict
[ "serialize", "to", "a", "dict", "all", "attributes", "except", "model", "weights", "Returns", "-------", "dict" ]
python
train
27.666667
mitsei/dlkit
dlkit/aws_adapter/osid/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/aws_adapter/osid/managers.py#L24-L63
def _initialize(self, runtime): """Common initializer for OsidManager and OsidProxyManager""" if runtime is None: raise NullArgument() if self._my_runtime is not None: raise IllegalState('this manager has already been initialized.') self._my_runtime = runtime ...
[ "def", "_initialize", "(", "self", ",", "runtime", ")", ":", "if", "runtime", "is", "None", ":", "raise", "NullArgument", "(", ")", "if", "self", ".", "_my_runtime", "is", "not", "None", ":", "raise", "IllegalState", "(", "'this manager has already been initia...
Common initializer for OsidManager and OsidProxyManager
[ "Common", "initializer", "for", "OsidManager", "and", "OsidProxyManager" ]
python
train
62.425
basho/riak-python-client
riak/table.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/table.py#L51-L64
def new(self, rows, columns=None): """ A shortcut for manually instantiating a new :class:`~riak.ts_object.TsObject` :param rows: An list of lists with timeseries data :type rows: list :param columns: An list of Column names and types. Optional. :type columns: li...
[ "def", "new", "(", "self", ",", "rows", ",", "columns", "=", "None", ")", ":", "from", "riak", ".", "ts_object", "import", "TsObject", "return", "TsObject", "(", "self", ".", "_client", ",", "self", ",", "rows", ",", "columns", ")" ]
A shortcut for manually instantiating a new :class:`~riak.ts_object.TsObject` :param rows: An list of lists with timeseries data :type rows: list :param columns: An list of Column names and types. Optional. :type columns: list :rtype: :class:`~riak.ts_object.TsObject`
[ "A", "shortcut", "for", "manually", "instantiating", "a", "new", ":", "class", ":", "~riak", ".", "ts_object", ".", "TsObject" ]
python
train
33.928571
rlabbe/filterpy
filterpy/kalman/square_root.py
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L227-L249
def predict(self, u=0): """ Predict next state (prior) using the Kalman filter state propagation equations. Parameters ---------- u : np.array, optional Optional control vector. If non-zero, it is multiplied by B to create the control input into ...
[ "def", "predict", "(", "self", ",", "u", "=", "0", ")", ":", "# x = Fx + Bu", "self", ".", "x", "=", "dot", "(", "self", ".", "F", ",", "self", ".", "x", ")", "+", "dot", "(", "self", ".", "B", ",", "u", ")", "# P = FPF' + Q", "_", ",", "P2",...
Predict next state (prior) using the Kalman filter state propagation equations. Parameters ---------- u : np.array, optional Optional control vector. If non-zero, it is multiplied by B to create the control input into the system.
[ "Predict", "next", "state", "(", "prior", ")", "using", "the", "Kalman", "filter", "state", "propagation", "equations", "." ]
python
train
28.391304
saltstack/salt
salt/modules/smf_service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smf_service.py#L155-L176
def start(name): ''' Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> ''' cmd = '/usr/sbin/svcadm enable -s -t {0}'.format(name) retcode = __salt__['cmd.retcode'](cmd, python_shell=False) if not retcode: return True ...
[ "def", "start", "(", "name", ")", ":", "cmd", "=", "'/usr/sbin/svcadm enable -s -t {0}'", ".", "format", "(", "name", ")", "retcode", "=", "__salt__", "[", "'cmd.retcode'", "]", "(", "cmd", ",", "python_shell", "=", "False", ")", "if", "not", "retcode", ":...
Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name>
[ "Start", "the", "specified", "service" ]
python
train
31.909091
shoebot/shoebot
shoebot/core/canvas.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L106-L111
def settings(self, **kwargs): ''' Pass a load of settings into the canvas ''' for k, v in kwargs.items(): setattr(self, k, v)
[ "def", "settings", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "k", ",", "v", ")" ]
Pass a load of settings into the canvas
[ "Pass", "a", "load", "of", "settings", "into", "the", "canvas" ]
python
valid
27.333333
tenforce/docker-py-aiohttp
aiodockerpy/utils/json_stream.py
https://github.com/tenforce/docker-py-aiohttp/blob/ab997f18bdbeb6d83abc6e5281934493552015f3/aiodockerpy/utils/json_stream.py#L11-L21
async def stream_as_text(stream): """ Given a stream of bytes or text, if any of the items in the stream are bytes convert them to text. This function can be removed once we return text streams instead of byte streams. """ async for data in stream: if not isinstance(data, six.text_ty...
[ "async", "def", "stream_as_text", "(", "stream", ")", ":", "async", "for", "data", "in", "stream", ":", "if", "not", "isinstance", "(", "data", ",", "six", ".", "text_type", ")", ":", "data", "=", "data", ".", "decode", "(", "'utf-8'", ",", "'replace'"...
Given a stream of bytes or text, if any of the items in the stream are bytes convert them to text. This function can be removed once we return text streams instead of byte streams.
[ "Given", "a", "stream", "of", "bytes", "or", "text", "if", "any", "of", "the", "items", "in", "the", "stream", "are", "bytes", "convert", "them", "to", "text", ".", "This", "function", "can", "be", "removed", "once", "we", "return", "text", "streams", ...
python
train
34.909091
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L9423-L9440
def pcpool(name, cvals): """ This entry point provides toolkit programmers a method for programmatically inserting character data into the kernel pool. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pcpool_c.html :param name: The kernel pool name to associate with cvals. :type nam...
[ "def", "pcpool", "(", "name", ",", "cvals", ")", ":", "name", "=", "stypes", ".", "stringToCharP", "(", "name", ")", "lenvals", "=", "ctypes", ".", "c_int", "(", "len", "(", "max", "(", "cvals", ",", "key", "=", "len", ")", ")", "+", "1", ")", ...
This entry point provides toolkit programmers a method for programmatically inserting character data into the kernel pool. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pcpool_c.html :param name: The kernel pool name to associate with cvals. :type name: str :param cvals: An array of ...
[ "This", "entry", "point", "provides", "toolkit", "programmers", "a", "method", "for", "programmatically", "inserting", "character", "data", "into", "the", "kernel", "pool", "." ]
python
train
35.888889