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
kgiusti/pyngus
examples/rpc-client.py
https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-client.py#L245-L258
def _send_request(self): """Send a message containing the RPC method call """ msg = Message() msg.subject = "An RPC call!" msg.address = self._to msg.reply_to = self._reply_to msg.body = self._method msg.correlation_id = 5 # whatever... print("se...
[ "def", "_send_request", "(", "self", ")", ":", "msg", "=", "Message", "(", ")", "msg", ".", "subject", "=", "\"An RPC call!\"", "msg", ".", "address", "=", "self", ".", "_to", "msg", ".", "reply_to", "=", "self", ".", "_reply_to", "msg", ".", "body", ...
Send a message containing the RPC method call
[ "Send", "a", "message", "containing", "the", "RPC", "method", "call" ]
python
test
34.571429
deepmipt/DeepPavlov
deeppavlov/core/layers/tf_layers.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/layers/tf_layers.py#L74-L113
def dense_convolutional_network(units: tf.Tensor, n_hidden_list: List, filter_width=3, use_dilation=False, use_batch_norm=False, training_ph=None): """ Dens...
[ "def", "dense_convolutional_network", "(", "units", ":", "tf", ".", "Tensor", ",", "n_hidden_list", ":", "List", ",", "filter_width", "=", "3", ",", "use_dilation", "=", "False", ",", "use_batch_norm", "=", "False", ",", "training_ph", "=", "None", ")", ":",...
Densely connected convolutional layers. Based on the paper: [Gao 17] https://arxiv.org/abs/1608.06993 Args: units: a tensorflow tensor with dimensionality [None, n_tokens, n_features] n_hidden_list: list with number of hidden units at the ouput of each layer filter_w...
[ "Densely", "connected", "convolutional", "layers", ".", "Based", "on", "the", "paper", ":", "[", "Gao", "17", "]", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1608", ".", "06993" ]
python
test
49.65
arkottke/pysra
pysra/variation.py
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L594-L612
def calc_std_mod_reduc(mod_reduc): """Calculate the standard deviation as a function of G/G_max. Equation 7.29 from Darendeli (2001). Parameters ---------- mod_reduc : array_like Modulus reduction values. Returns ------- std : :class:`numpy....
[ "def", "calc_std_mod_reduc", "(", "mod_reduc", ")", ":", "mod_reduc", "=", "np", ".", "asarray", "(", "mod_reduc", ")", ".", "astype", "(", "float", ")", "std", "=", "(", "np", ".", "exp", "(", "-", "4.23", ")", "+", "np", ".", "sqrt", "(", "0.25",...
Calculate the standard deviation as a function of G/G_max. Equation 7.29 from Darendeli (2001). Parameters ---------- mod_reduc : array_like Modulus reduction values. Returns ------- std : :class:`numpy.ndarray` Standard deviation.
[ "Calculate", "the", "standard", "deviation", "as", "a", "function", "of", "G", "/", "G_max", "." ]
python
train
29.947368
inveniosoftware/invenio-search
invenio_search/ext.py
https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L256-L283
def create(self, ignore=None): """Yield tuple with created index name and responses from a client.""" ignore = ignore or [] def _create(tree_or_filename, alias=None): """Create indices and aliases by walking DFS.""" # Iterate over aliases: for name, value in ...
[ "def", "create", "(", "self", ",", "ignore", "=", "None", ")", ":", "ignore", "=", "ignore", "or", "[", "]", "def", "_create", "(", "tree_or_filename", ",", "alias", "=", "None", ")", ":", "\"\"\"Create indices and aliases by walking DFS.\"\"\"", "# Iterate over...
Yield tuple with created index name and responses from a client.
[ "Yield", "tuple", "with", "created", "index", "name", "and", "responses", "from", "a", "client", "." ]
python
train
38.107143
autokey/autokey
lib/autokey/interface.py
https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L630-L635
def _restore_clipboard_text(self, backup: str): """Restore the clipboard content.""" # Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before # the pasting happens, causing the backup to be pasted instead of the desired clipboard content. ...
[ "def", "_restore_clipboard_text", "(", "self", ",", "backup", ":", "str", ")", ":", "# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before", "# the pasting happens, causing the backup to be pasted instead of the desired clipboard content.",...
Restore the clipboard content.
[ "Restore", "the", "clipboard", "content", "." ]
python
train
66.5
mitsei/dlkit
dlkit/json_/grading/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/managers.py#L746-L761
def get_grade_entry_admin_session(self): """Gets the ``OsidSession`` associated with the grade entry administration service. return: (osid.grading.GradeEntryAdminSession) - a ``GradeEntryAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplem...
[ "def", "get_grade_entry_admin_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_grade_entry_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "GradeEntryAdminSession",...
Gets the ``OsidSession`` associated with the grade entry administration service. return: (osid.grading.GradeEntryAdminSession) - a ``GradeEntryAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_grade_entry_admin()`` is ...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "grade", "entry", "administration", "service", "." ]
python
train
44.1875
royi1000/py-libhdate
hdate/converters.py
https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/converters.py#L125-L149
def jdn_to_gdate(jdn): """ Convert from the Julian day to the Gregorian day. Algorithm from 'Julian and Gregorian Day Numbers' by Peter Meyer. Return: day, month, year """ # pylint: disable=invalid-name # The algorithm is a verbatim copy from Peter Meyer's article # No explanation in t...
[ "def", "jdn_to_gdate", "(", "jdn", ")", ":", "# pylint: disable=invalid-name", "# The algorithm is a verbatim copy from Peter Meyer's article", "# No explanation in the article is given for the variables", "# Hence the exceptions for pylint and for flake8 (E741)", "l", "=", "jdn", "+", "...
Convert from the Julian day to the Gregorian day. Algorithm from 'Julian and Gregorian Day Numbers' by Peter Meyer. Return: day, month, year
[ "Convert", "from", "the", "Julian", "day", "to", "the", "Gregorian", "day", "." ]
python
train
32.92
tanghaibao/jcvi
jcvi/compara/fractionation.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/compara/fractionation.py#L222-L285
def merge(args): """ %prog merge protein-quartets registry LOST Merge protein quartets table with dna quartets registry. This is specific to the napus project. """ from jcvi.formats.base import DictFile p = OptionParser(merge.__doc__) opts, args = p.parse_args(args) if len(args) !...
[ "def", "merge", "(", "args", ")", ":", "from", "jcvi", ".", "formats", ".", "base", "import", "DictFile", "p", "=", "OptionParser", "(", "merge", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", ...
%prog merge protein-quartets registry LOST Merge protein quartets table with dna quartets registry. This is specific to the napus project.
[ "%prog", "merge", "protein", "-", "quartets", "registry", "LOST" ]
python
train
28.765625
aluzzardi/wssh
wssh/server.py
https://github.com/aluzzardi/wssh/blob/4ccde12af67a0d7a121294ec6c4a5ec3c17de425/wssh/server.py#L169-L180
def shell(self, term='xterm'): """ Start an interactive shell session This method invokes a shell on the remote SSH server and proxies traffic to/from both peers. You must connect to a SSH server using ssh_connect() prior to starting the session. """ channel = s...
[ "def", "shell", "(", "self", ",", "term", "=", "'xterm'", ")", ":", "channel", "=", "self", ".", "_ssh", ".", "invoke_shell", "(", "term", ")", "self", ".", "_bridge", "(", "channel", ")", "channel", ".", "close", "(", ")" ]
Start an interactive shell session This method invokes a shell on the remote SSH server and proxies traffic to/from both peers. You must connect to a SSH server using ssh_connect() prior to starting the session.
[ "Start", "an", "interactive", "shell", "session" ]
python
train
32.5
pecan/pecan
pecan/routing.py
https://github.com/pecan/pecan/blob/833d0653fa0e6bbfb52545b091c30182105f4a82/pecan/routing.py#L119-L170
def lookup_controller(obj, remainder, request=None): ''' Traverses the requested url path and returns the appropriate controller object, including default routes. Handles common errors gracefully. ''' if request is None: warnings.warn( ( "The function signatu...
[ "def", "lookup_controller", "(", "obj", ",", "remainder", ",", "request", "=", "None", ")", ":", "if", "request", "is", "None", ":", "warnings", ".", "warn", "(", "(", "\"The function signature for %s.lookup_controller is changing \"", "\"in the next version of pecan.\\...
Traverses the requested url path and returns the appropriate controller object, including default routes. Handles common errors gracefully.
[ "Traverses", "the", "requested", "url", "path", "and", "returns", "the", "appropriate", "controller", "object", "including", "default", "routes", "." ]
python
train
39
mozilla-iot/webthing-python
webthing/thing.py
https://github.com/mozilla-iot/webthing-python/blob/65d467c89ed79d0bbc42b8b3c8f9e5a320edd237/webthing/thing.py#L298-L305
def add_event(self, event): """ Add a new event and notify subscribers. event -- the event that occurred """ self.events.append(event) self.event_notify(event)
[ "def", "add_event", "(", "self", ",", "event", ")", ":", "self", ".", "events", ".", "append", "(", "event", ")", "self", ".", "event_notify", "(", "event", ")" ]
Add a new event and notify subscribers. event -- the event that occurred
[ "Add", "a", "new", "event", "and", "notify", "subscribers", "." ]
python
test
25.125
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/docbook/__init__.py#L372-L386
def __xinclude_lxml(target, source, env): """ Resolving XIncludes, using the lxml module. """ from lxml import etree doc = etree.parse(str(source[0])) doc.xinclude() try: doc.write(str(target[0]), xml_declaration=True, encoding="UTF-8", pretty_print=True) ...
[ "def", "__xinclude_lxml", "(", "target", ",", "source", ",", "env", ")", ":", "from", "lxml", "import", "etree", "doc", "=", "etree", ".", "parse", "(", "str", "(", "source", "[", "0", "]", ")", ")", "doc", ".", "xinclude", "(", ")", "try", ":", ...
Resolving XIncludes, using the lxml module.
[ "Resolving", "XIncludes", "using", "the", "lxml", "module", "." ]
python
train
22.866667
CGATOxford/UMI-tools
umi_tools/network.py
https://github.com/CGATOxford/UMI-tools/blob/c4b5d84aac391d59916d294f8f4f8f5378abcfbe/umi_tools/network.py#L433-L463
def _get_adj_list_directional(self, umis, counts): ''' identify all umis within the hamming distance threshold and where the counts of the first umi is > (2 * second umi counts)-1''' adj_list = {umi: [] for umi in umis} if self.fuzzy_match: for umi1 in umis: ...
[ "def", "_get_adj_list_directional", "(", "self", ",", "umis", ",", "counts", ")", ":", "adj_list", "=", "{", "umi", ":", "[", "]", "for", "umi", "in", "umis", "}", "if", "self", ".", "fuzzy_match", ":", "for", "umi1", "in", "umis", ":", "# we need a se...
identify all umis within the hamming distance threshold and where the counts of the first umi is > (2 * second umi counts)-1
[ "identify", "all", "umis", "within", "the", "hamming", "distance", "threshold", "and", "where", "the", "counts", "of", "the", "first", "umi", "is", ">", "(", "2", "*", "second", "umi", "counts", ")", "-", "1" ]
python
train
46
Scoppio/RagnarokEngine3
Tutorials/Tutorial 3 - Creating new entities/tuto3.py
https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/Tutorials/Tutorial 3 - Creating new entities/tuto3.py#L120-L130
def __generate_location(self): """ Reset the location of the cloud once it has left the viewable area of the screen. """ screen_width = world.get_backbuffer_size().X self.movement_speed = random.randrange(10, 25) # This line of code places the cloud to the right of the v...
[ "def", "__generate_location", "(", "self", ")", ":", "screen_width", "=", "world", ".", "get_backbuffer_size", "(", ")", ".", "X", "self", ".", "movement_speed", "=", "random", ".", "randrange", "(", "10", ",", "25", ")", "# This line of code places the cloud to...
Reset the location of the cloud once it has left the viewable area of the screen.
[ "Reset", "the", "location", "of", "the", "cloud", "once", "it", "has", "left", "the", "viewable", "area", "of", "the", "screen", "." ]
python
train
51.272727
square/pylink
examples/rtt.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/examples/rtt.py#L68-L90
def write_rtt(jlink): """Writes kayboard input to JLink RTT buffer #0. This method is a loop that blocks waiting on stdin. When enter is pressed, LF and NUL bytes are added to the input and transmitted as a byte list. If the JLink is disconnected, it will exit gracefully. If any other exceptions ar...
[ "def", "write_rtt", "(", "jlink", ")", ":", "try", ":", "while", "jlink", ".", "connected", "(", ")", ":", "bytes", "=", "list", "(", "bytearray", "(", "input", "(", ")", ",", "\"utf-8\"", ")", "+", "b\"\\x0A\\x00\"", ")", "bytes_written", "=", "jlink"...
Writes kayboard input to JLink RTT buffer #0. This method is a loop that blocks waiting on stdin. When enter is pressed, LF and NUL bytes are added to the input and transmitted as a byte list. If the JLink is disconnected, it will exit gracefully. If any other exceptions are raised, they will be caught...
[ "Writes", "kayboard", "input", "to", "JLink", "RTT", "buffer", "#0", "." ]
python
train
33.782609
tonioo/sievelib
sievelib/commands.py
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L361-L387
def __is_valid_value_for_arg(self, arg, value, check_extension=True): """Check if value is allowed for arg Some commands only allow a limited set of values. The method always returns True for methods that do not provide such a set. :param arg: the argument's name :param...
[ "def", "__is_valid_value_for_arg", "(", "self", ",", "arg", ",", "value", ",", "check_extension", "=", "True", ")", ":", "if", "\"values\"", "not", "in", "arg", "and", "\"extension_values\"", "not", "in", "arg", ":", "return", "True", "if", "\"values\"", "in...
Check if value is allowed for arg Some commands only allow a limited set of values. The method always returns True for methods that do not provide such a set. :param arg: the argument's name :param value: the value to check :param check_extension: check if value require...
[ "Check", "if", "value", "is", "allowed", "for", "arg" ]
python
train
38.925926
gwastro/pycbc
pycbc/tmpltbank/partitioned_bank.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/partitioned_bank.py#L297-L361
def calc_point_distance_vary(self, chi_coords, point_fupper, mus): """ Calculate distance between point and the bank allowing the metric to vary based on varying upper frequency cutoff. Slower than calc_point_distance, but more reliable when upper frequency cutoff can change a lo...
[ "def", "calc_point_distance_vary", "(", "self", ",", "chi_coords", ",", "point_fupper", ",", "mus", ")", ":", "chi1_bin", ",", "chi2_bin", "=", "self", ".", "find_point_bin", "(", "chi_coords", ")", "min_dist", "=", "1000000000", "indexes", "=", "None", "for",...
Calculate distance between point and the bank allowing the metric to vary based on varying upper frequency cutoff. Slower than calc_point_distance, but more reliable when upper frequency cutoff can change a lot. Parameters ----------- chi_coords : numpy.array ...
[ "Calculate", "distance", "between", "point", "and", "the", "bank", "allowing", "the", "metric", "to", "vary", "based", "on", "varying", "upper", "frequency", "cutoff", ".", "Slower", "than", "calc_point_distance", "but", "more", "reliable", "when", "upper", "fre...
python
train
45.753846
noxdafox/clipspy
clips/classes.py
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L446-L448
def initializable(self): """True if the Slot is initializable.""" return bool(lib.EnvSlotInitableP(self._env, self._cls, self._name))
[ "def", "initializable", "(", "self", ")", ":", "return", "bool", "(", "lib", ".", "EnvSlotInitableP", "(", "self", ".", "_env", ",", "self", ".", "_cls", ",", "self", ".", "_name", ")", ")" ]
True if the Slot is initializable.
[ "True", "if", "the", "Slot", "is", "initializable", "." ]
python
train
49
treycucco/bidon
bidon/db/core/sql_writer.py
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L78-L89
def transform_op(self, op, value): """For comparisons, if the value is None (null), the '=' operator must be replaced with ' is ' and the '!=' operator must be replaced with ' is not '. This function handles that conversion. It's up to the caller to call this function only on comparisons and not on assignme...
[ "def", "transform_op", "(", "self", ",", "op", ",", "value", ")", ":", "if", "value", "is", "None", ":", "if", "_EQ_RE", ".", "match", "(", "op", ")", ":", "return", "\"is\"", "elif", "_NEQ_RE", ".", "match", "(", "op", ")", ":", "return", "\"is no...
For comparisons, if the value is None (null), the '=' operator must be replaced with ' is ' and the '!=' operator must be replaced with ' is not '. This function handles that conversion. It's up to the caller to call this function only on comparisons and not on assignments.
[ "For", "comparisons", "if", "the", "value", "is", "None", "(", "null", ")", "the", "=", "operator", "must", "be", "replaced", "with", "is", "and", "the", "!", "=", "operator", "must", "be", "replaced", "with", "is", "not", ".", "This", "function", "han...
python
train
38.25
lucaoflaif/pyCoinMarketCapAPI
coinmarketcapapi/cache.py
https://github.com/lucaoflaif/pyCoinMarketCapAPI/blob/a6ab1fa57c0610e8abf3a03e9144379bf9e49907/coinmarketcapapi/cache.py#L77-L85
def get_unset_cache(self): """return : returns a tuple (num_of_not_None_caches, [list of unset caches endpoint]) """ caches = [] if self._cached_api_global_response is None: caches.append('global') if self._cached_api_ticker_response is None: caches.append...
[ "def", "get_unset_cache", "(", "self", ")", ":", "caches", "=", "[", "]", "if", "self", ".", "_cached_api_global_response", "is", "None", ":", "caches", ".", "append", "(", "'global'", ")", "if", "self", ".", "_cached_api_ticker_response", "is", "None", ":",...
return : returns a tuple (num_of_not_None_caches, [list of unset caches endpoint])
[ "return", ":", "returns", "a", "tuple", "(", "num_of_not_None_caches", "[", "list", "of", "unset", "caches", "endpoint", "]", ")" ]
python
train
39.888889
aleju/imgaug
imgaug/augmentables/polys.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/polys.py#L1158-L1182
def remove_out_of_image(self, fully=True, partly=False): """ Remove all polygons that are fully or partially outside of the image. Parameters ---------- fully : bool, optional Whether to remove polygons that are fully outside of the image. partly : bool, opt...
[ "def", "remove_out_of_image", "(", "self", ",", "fully", "=", "True", ",", "partly", "=", "False", ")", ":", "polys_clean", "=", "[", "poly", "for", "poly", "in", "self", ".", "polygons", "if", "not", "poly", ".", "is_out_of_image", "(", "self", ".", "...
Remove all polygons that are fully or partially outside of the image. Parameters ---------- fully : bool, optional Whether to remove polygons that are fully outside of the image. partly : bool, optional Whether to remove polygons that are partially outside of th...
[ "Remove", "all", "polygons", "that", "are", "fully", "or", "partially", "outside", "of", "the", "image", "." ]
python
valid
33.12
h2non/paco
paco/reduce.py
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/reduce.py#L10-L83
def reduce(coro, iterable, initializer=None, limit=1, right=False, loop=None): """ Apply function of two arguments cumulatively to the items of sequence, from left to right, so as to reduce the sequence to a single value. Reduction will be executed sequentially without concurrency, so passed values...
[ "def", "reduce", "(", "coro", ",", "iterable", ",", "initializer", "=", "None", ",", "limit", "=", "1", ",", "right", "=", "False", ",", "loop", "=", "None", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "assert_iter", "(", "iterable"...
Apply function of two arguments cumulatively to the items of sequence, from left to right, so as to reduce the sequence to a single value. Reduction will be executed sequentially without concurrency, so passed values would be in order. This function is the asynchronous coroutine equivalent to Python s...
[ "Apply", "function", "of", "two", "arguments", "cumulatively", "to", "the", "items", "of", "sequence", "from", "left", "to", "right", "so", "as", "to", "reduce", "the", "sequence", "to", "a", "single", "value", "." ]
python
train
29.594595
bio2bel/bio2bel
src/bio2bel/manager/abstract_manager.py
https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/abstract_manager.py#L370-L384
def add_cli_summarize(main: click.Group) -> click.Group: # noqa: D202 """Add a ``summarize`` command to main :mod:`click` function.""" @main.command() @click.pass_obj def summarize(manager: AbstractManager): """Summarize the contents of the database.""" if not manager.is_populated(): ...
[ "def", "add_cli_summarize", "(", "main", ":", "click", ".", "Group", ")", "->", "click", ".", "Group", ":", "# noqa: D202", "@", "main", ".", "command", "(", ")", "@", "click", ".", "pass_obj", "def", "summarize", "(", "manager", ":", "AbstractManager", ...
Add a ``summarize`` command to main :mod:`click` function.
[ "Add", "a", "summarize", "command", "to", "main", ":", "mod", ":", "click", "function", "." ]
python
valid
36.6
appknox/pyaxmlparser
pyaxmlparser/core.py
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L614-L631
def get_elements(self, tag_name, attribute, with_namespace=True): """ Deprecated: use `get_all_attribute_value()` instead Return elements in xml files which match with the tag name and the specific attribute :param tag_name: a string which specify the tag name :param attribute: a...
[ "def", "get_elements", "(", "self", ",", "tag_name", ",", "attribute", ",", "with_namespace", "=", "True", ")", ":", "for", "i", "in", "self", ".", "xml", ":", "if", "self", ".", "xml", "[", "i", "]", "is", "None", ":", "continue", "for", "item", "...
Deprecated: use `get_all_attribute_value()` instead Return elements in xml files which match with the tag name and the specific attribute :param tag_name: a string which specify the tag name :param attribute: a string which specify the attribute
[ "Deprecated", ":", "use", "get_all_attribute_value", "()", "instead", "Return", "elements", "in", "xml", "files", "which", "match", "with", "the", "tag", "name", "and", "the", "specific", "attribute", ":", "param", "tag_name", ":", "a", "string", "which", "spe...
python
train
45
google/python-gflags
gflags/flagvalues.py
https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags/flagvalues.py#L914-L925
def ModuleHelp(self, module): """Describe the key flags of a module. Args: module: A module object or a module name (a string). Returns: string describing the key flags of a module. """ helplist = [] self.__RenderOurModuleKeyFlags(module, helplist) return '\n'.join(helplist)
[ "def", "ModuleHelp", "(", "self", ",", "module", ")", ":", "helplist", "=", "[", "]", "self", ".", "__RenderOurModuleKeyFlags", "(", "module", ",", "helplist", ")", "return", "'\\n'", ".", "join", "(", "helplist", ")" ]
Describe the key flags of a module. Args: module: A module object or a module name (a string). Returns: string describing the key flags of a module.
[ "Describe", "the", "key", "flags", "of", "a", "module", "." ]
python
train
25.5
mosdef-hub/mbuild
mbuild/coordinate_transform.py
https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/coordinate_transform.py#L555-L574
def spin(compound, theta, around): """Rotate a compound in place around an arbitrary vector. Parameters ---------- compound : mb.Compound The compound being rotated. theta : float The angle by which to rotate the compound, in radians. around : np.ndarray, shape=(3,), dtype=float...
[ "def", "spin", "(", "compound", ",", "theta", ",", "around", ")", ":", "around", "=", "np", ".", "asarray", "(", "around", ")", ".", "reshape", "(", "3", ")", "if", "np", ".", "array_equal", "(", "around", ",", "np", ".", "zeros", "(", "3", ")", ...
Rotate a compound in place around an arbitrary vector. Parameters ---------- compound : mb.Compound The compound being rotated. theta : float The angle by which to rotate the compound, in radians. around : np.ndarray, shape=(3,), dtype=float The axis about which to spin the ...
[ "Rotate", "a", "compound", "in", "place", "around", "an", "arbitrary", "vector", "." ]
python
train
32.55
secure-systems-lab/securesystemslib
securesystemslib/keys.py
https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L496-L582
def format_metadata_to_key(key_metadata): """ <Purpose> Construct a key dictionary (e.g., securesystemslib.formats.RSAKEY_SCHEMA) according to the keytype of 'key_metadata'. The dict returned by this function has the exact format as the dict returned by one of the key generations functions, like ge...
[ "def", "format_metadata_to_key", "(", "key_metadata", ")", ":", "# Does 'key_metadata' have the correct format?", "# This check will ensure 'key_metadata' has the appropriate number", "# of objects and object types, and that all dict keys are properly named.", "# Raise 'securesystemslib.exceptions...
<Purpose> Construct a key dictionary (e.g., securesystemslib.formats.RSAKEY_SCHEMA) according to the keytype of 'key_metadata'. The dict returned by this function has the exact format as the dict returned by one of the key generations functions, like generate_ed25519_key(). The dict returned has t...
[ "<Purpose", ">", "Construct", "a", "key", "dictionary", "(", "e", ".", "g", ".", "securesystemslib", ".", "formats", ".", "RSAKEY_SCHEMA", ")", "according", "to", "the", "keytype", "of", "key_metadata", ".", "The", "dict", "returned", "by", "this", "function...
python
train
36.505747
omtinez/pddb
pddb/pddb.py
https://github.com/omtinez/pddb/blob/a24cee0702c8286c5c466c51ca65cf8dbc2c183c/pddb/pddb.py#L947-L967
def _request(request, request_fallback=None): ''' Extract request fields wherever they may come from: GET, POST, forms, fallback ''' # Use lambdas to avoid evaluating bottle.request.* which may throw an Error all_dicts = [ lambda: request.json, lambda: request.forms, ...
[ "def", "_request", "(", "request", ",", "request_fallback", "=", "None", ")", ":", "# Use lambdas to avoid evaluating bottle.request.* which may throw an Error", "all_dicts", "=", "[", "lambda", ":", "request", ".", "json", ",", "lambda", ":", "request", ".", "forms",...
Extract request fields wherever they may come from: GET, POST, forms, fallback
[ "Extract", "request", "fields", "wherever", "they", "may", "come", "from", ":", "GET", "POST", "forms", "fallback" ]
python
train
39.47619
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgets/browser.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/browser.py#L557-L571
def resizeEvent(self, event): """Schedules an item layout if resize mode is \"adjust\". Somehow this is needed for correctly scaling down items. The reason this was reimplemented was the CommentDelegate. :param event: the resize event :type event: QtCore.QEvent :returns...
[ "def", "resizeEvent", "(", "self", ",", "event", ")", ":", "if", "self", ".", "resizeMode", "(", ")", "==", "self", ".", "Adjust", ":", "self", ".", "scheduleDelayedItemsLayout", "(", ")", "return", "super", "(", "ListLevel", ",", "self", ")", ".", "re...
Schedules an item layout if resize mode is \"adjust\". Somehow this is needed for correctly scaling down items. The reason this was reimplemented was the CommentDelegate. :param event: the resize event :type event: QtCore.QEvent :returns: None :rtype: None :rais...
[ "Schedules", "an", "item", "layout", "if", "resize", "mode", "is", "\\", "adjust", "\\", ".", "Somehow", "this", "is", "needed", "for", "correctly", "scaling", "down", "items", "." ]
python
train
34.333333
linuxsoftware/ls.joyous
ls/joyous/models/events.py
https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L807-L811
def _getFromTime(self, atDate=None): """ Time that the event starts (in the local time zone). """ return getLocalTime(self.date_from, self.time_from, self.tz)
[ "def", "_getFromTime", "(", "self", ",", "atDate", "=", "None", ")", ":", "return", "getLocalTime", "(", "self", ".", "date_from", ",", "self", ".", "time_from", ",", "self", ".", "tz", ")" ]
Time that the event starts (in the local time zone).
[ "Time", "that", "the", "event", "starts", "(", "in", "the", "local", "time", "zone", ")", "." ]
python
train
37.2
Alignak-monitoring/alignak
alignak/objects/item.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1315-L1337
def linkify_with_escalations(self, escalations): """ Link with escalations :param escalations: all escalations object :type escalations: alignak.objects.escalation.Escalations :return: None """ for i in self: if not hasattr(i, 'escalations'): ...
[ "def", "linkify_with_escalations", "(", "self", ",", "escalations", ")", ":", "for", "i", "in", "self", ":", "if", "not", "hasattr", "(", "i", ",", "'escalations'", ")", ":", "continue", "links_list", "=", "strip_and_uniq", "(", "i", ".", "escalations", ")...
Link with escalations :param escalations: all escalations object :type escalations: alignak.objects.escalation.Escalations :return: None
[ "Link", "with", "escalations" ]
python
train
35.652174
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L2451-L2460
def get_tagged_albums(self, tag, limit=None, cacheable=True): """Returns the albums tagged by a user.""" params = self._get_params() params["tag"] = tag params["taggingtype"] = "album" if limit: params["limit"] = limit doc = self._request(self.ws_prefix + ".g...
[ "def", "get_tagged_albums", "(", "self", ",", "tag", ",", "limit", "=", "None", ",", "cacheable", "=", "True", ")", ":", "params", "=", "self", ".", "_get_params", "(", ")", "params", "[", "\"tag\"", "]", "=", "tag", "params", "[", "\"taggingtype\"", "...
Returns the albums tagged by a user.
[ "Returns", "the", "albums", "tagged", "by", "a", "user", "." ]
python
train
39.6
tensorflow/probability
tensorflow_probability/python/optimizer/differential_evolution.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/optimizer/differential_evolution.py#L510-L516
def _find_best_in_population(population, values): """Finds the population member with the lowest value.""" best_value = tf.math.reduce_min(input_tensor=values) best_index = tf.where(tf.math.equal(values, best_value))[0, 0] return ([population_part[best_index] for population_part in population], best_...
[ "def", "_find_best_in_population", "(", "population", ",", "values", ")", ":", "best_value", "=", "tf", ".", "math", ".", "reduce_min", "(", "input_tensor", "=", "values", ")", "best_index", "=", "tf", ".", "where", "(", "tf", ".", "math", ".", "equal", ...
Finds the population member with the lowest value.
[ "Finds", "the", "population", "member", "with", "the", "lowest", "value", "." ]
python
test
45.714286
mapmyfitness/jtime
jtime/utils.py
https://github.com/mapmyfitness/jtime/blob/402fb6b40ac7a78c23fd02fac50c6dbe49e5ebfd/jtime/utils.py#L16-L56
def working_cycletime(start, end, workday_start=datetime.timedelta(hours=0), workday_end=datetime.timedelta(hours=24)): """ Get the working time between a beginning and an end point subtracting out non-office time """ def clamp(t, start, end): "Return 't' clamped to the range ['start', 'end']" ...
[ "def", "working_cycletime", "(", "start", ",", "end", ",", "workday_start", "=", "datetime", ".", "timedelta", "(", "hours", "=", "0", ")", ",", "workday_end", "=", "datetime", ".", "timedelta", "(", "hours", "=", "24", ")", ")", ":", "def", "clamp", "...
Get the working time between a beginning and an end point subtracting out non-office time
[ "Get", "the", "working", "time", "between", "a", "beginning", "and", "an", "end", "point", "subtracting", "out", "non", "-", "office", "time" ]
python
train
39.439024
pandas-dev/pandas
pandas/plotting/_misc.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_misc.py#L270-L356
def andrews_curves(frame, class_column, ax=None, samples=200, color=None, colormap=None, **kwds): """ Generate a matplotlib plot of Andrews curves, for visualising clusters of multivariate data. Andrews curves have the functional form: f(t) = x_1/sqrt(2) + x_2 sin(t) + x_3 cos(t...
[ "def", "andrews_curves", "(", "frame", ",", "class_column", ",", "ax", "=", "None", ",", "samples", "=", "200", ",", "color", "=", "None", ",", "colormap", "=", "None", ",", "*", "*", "kwds", ")", ":", "from", "math", "import", "sqrt", ",", "pi", "...
Generate a matplotlib plot of Andrews curves, for visualising clusters of multivariate data. Andrews curves have the functional form: f(t) = x_1/sqrt(2) + x_2 sin(t) + x_3 cos(t) + x_4 sin(2t) + x_5 cos(2t) + ... Where x coefficients correspond to the values of each dimension and t is ...
[ "Generate", "a", "matplotlib", "plot", "of", "Andrews", "curves", "for", "visualising", "clusters", "of", "multivariate", "data", "." ]
python
train
34.448276
kgori/treeCl
treeCl/distance_matrix.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/distance_matrix.py#L137-L144
def check_psd(matrix, tolerance=1e-6): """ A square matrix is PSD if all eigenvalues of its Hermitian part are non- negative. The Hermitian part is given by (self + M*)/2, where M* is the complex conjugate transpose of M """ hermitian = (matrix + matrix.T.conjugate()) / 2 eigenvalues = np.linalg.ei...
[ "def", "check_psd", "(", "matrix", ",", "tolerance", "=", "1e-6", ")", ":", "hermitian", "=", "(", "matrix", "+", "matrix", ".", "T", ".", "conjugate", "(", ")", ")", "/", "2", "eigenvalues", "=", "np", ".", "linalg", ".", "eigh", "(", "hermitian", ...
A square matrix is PSD if all eigenvalues of its Hermitian part are non- negative. The Hermitian part is given by (self + M*)/2, where M* is the complex conjugate transpose of M
[ "A", "square", "matrix", "is", "PSD", "if", "all", "eigenvalues", "of", "its", "Hermitian", "part", "are", "non", "-", "negative", ".", "The", "Hermitian", "part", "is", "given", "by", "(", "self", "+", "M", "*", ")", "/", "2", "where", "M", "*", "...
python
train
46.625
jaijuneja/PyTLDR
pytldr/summarize/lsa.py
https://github.com/jaijuneja/PyTLDR/blob/4ba2ab88dbbb1318a86bf4483264ab213e166b6b/pytldr/summarize/lsa.py#L49-L102
def summarize(self, text, topics=4, length=5, binary_matrix=True, topic_sigma_threshold=0.5): """ Implements the method of latent semantic analysis described by Steinberger and Jezek in the paper: J. Steinberger and K. Jezek (2004). Using latent semantic analysis in text summarization and summa...
[ "def", "summarize", "(", "self", ",", "text", ",", "topics", "=", "4", ",", "length", "=", "5", ",", "binary_matrix", "=", "True", ",", "topic_sigma_threshold", "=", "0.5", ")", ":", "text", "=", "self", ".", "_parse_input", "(", "text", ")", "sentence...
Implements the method of latent semantic analysis described by Steinberger and Jezek in the paper: J. Steinberger and K. Jezek (2004). Using latent semantic analysis in text summarization and summary evaluation. Proc. ISIM ’04, pp. 93–100. :param text: a string of text to be summarized, path t...
[ "Implements", "the", "method", "of", "latent", "semantic", "analysis", "described", "by", "Steinberger", "and", "Jezek", "in", "the", "paper", ":" ]
python
train
50.222222
dfiel/greenwavereality
greenwavereality/greenwavereality.py
https://github.com/dfiel/greenwavereality/blob/cb2c0328385eb7afda910cc483266086432fb708/greenwavereality/greenwavereality.py#L99-L106
def grab_bulbs(host, token=None): """Grab XML, then add all bulbs to a dict. Removes room functionality""" xml = grab_xml(host, token) bulbs = {} for room in xml: for device in room['device']: bulbs[int(device['did'])] = device return bulbs
[ "def", "grab_bulbs", "(", "host", ",", "token", "=", "None", ")", ":", "xml", "=", "grab_xml", "(", "host", ",", "token", ")", "bulbs", "=", "{", "}", "for", "room", "in", "xml", ":", "for", "device", "in", "room", "[", "'device'", "]", ":", "bul...
Grab XML, then add all bulbs to a dict. Removes room functionality
[ "Grab", "XML", "then", "add", "all", "bulbs", "to", "a", "dict", ".", "Removes", "room", "functionality" ]
python
train
34.125
tanghaibao/jcvi
jcvi/graphics/tree.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/graphics/tree.py#L254-L338
def main(args): """ %prog newicktree Plot Newick formatted tree. The gene structure can be plotted along if --gffdir is given. The gff file needs to be `genename.gff`. If --sizes is on, also show the number of amino acids. With --barcode a mapping file can be provided to convert seq names to ...
[ "def", "main", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "main", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--outgroup\"", ",", "help", "=", "\"Outgroup for rerooting the tree. \"", "+", "\"Use comma to separate multiple taxa.\"", ")", "p", ...
%prog newicktree Plot Newick formatted tree. The gene structure can be plotted along if --gffdir is given. The gff file needs to be `genename.gff`. If --sizes is on, also show the number of amino acids. With --barcode a mapping file can be provided to convert seq names to eg. species names, useful...
[ "%prog", "newicktree" ]
python
train
40.647059
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAIndicator/indicators.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAIndicator/indicators.py#L456-L464
def QA_indicator_BOLL(DataFrame, N=20, P=2): '布林线' C = DataFrame['close'] boll = MA(C, N) UB = boll + P * STD(C, N) LB = boll - P * STD(C, N) DICT = {'BOLL': boll, 'UB': UB, 'LB': LB} return pd.DataFrame(DICT)
[ "def", "QA_indicator_BOLL", "(", "DataFrame", ",", "N", "=", "20", ",", "P", "=", "2", ")", ":", "C", "=", "DataFrame", "[", "'close'", "]", "boll", "=", "MA", "(", "C", ",", "N", ")", "UB", "=", "boll", "+", "P", "*", "STD", "(", "C", ",", ...
布林线
[ "布林线" ]
python
train
25.555556
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/project_analysis/project_analysis_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/project_analysis/project_analysis_client.py#L66-L93
def get_git_repositories_activity_metrics(self, project, from_date, aggregation_type, skip, top): """GetGitRepositoriesActivityMetrics. [Preview API] Retrieves git activity metrics for repositories matching a specified criteria. :param str project: Project ID or project name :param datet...
[ "def", "get_git_repositories_activity_metrics", "(", "self", ",", "project", ",", "from_date", ",", "aggregation_type", ",", "skip", ",", "top", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'...
GetGitRepositoriesActivityMetrics. [Preview API] Retrieves git activity metrics for repositories matching a specified criteria. :param str project: Project ID or project name :param datetime from_date: Date from which, the trends are to be fetched. :param str aggregation_type: Bucket siz...
[ "GetGitRepositoriesActivityMetrics", ".", "[", "Preview", "API", "]", "Retrieves", "git", "activity", "metrics", "for", "repositories", "matching", "a", "specified", "criteria", ".", ":", "param", "str", "project", ":", "Project", "ID", "or", "project", "name", ...
python
train
62.607143
pyviz/holoviews
holoviews/element/path.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/element/path.py#L329-L344
def clone(self, *args, **overrides): """ Returns a clone of the object with matching parameter values containing the specified args and kwargs. """ link = overrides.pop('link', True) settings = dict(self.get_param_values(), **overrides) if 'id' not in settings: ...
[ "def", "clone", "(", "self", ",", "*", "args", ",", "*", "*", "overrides", ")", ":", "link", "=", "overrides", ".", "pop", "(", "'link'", ",", "True", ")", "settings", "=", "dict", "(", "self", ".", "get_param_values", "(", ")", ",", "*", "*", "o...
Returns a clone of the object with matching parameter values containing the specified args and kwargs.
[ "Returns", "a", "clone", "of", "the", "object", "with", "matching", "parameter", "values", "containing", "the", "specified", "args", "and", "kwargs", "." ]
python
train
42.75
apple/turicreate
src/unity/python/turicreate/toolkits/recommender/util.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/recommender/util.py#L1763-L1772
def _get_popularity_baseline(self): """ Returns a new popularity model matching the data set this model was trained with. Can be used for comparison purposes. """ response = self.__proxy__.get_popularity_baseline() from .popularity_recommender import PopularityRecommen...
[ "def", "_get_popularity_baseline", "(", "self", ")", ":", "response", "=", "self", ".", "__proxy__", ".", "get_popularity_baseline", "(", ")", "from", ".", "popularity_recommender", "import", "PopularityRecommender", "return", "PopularityRecommender", "(", "response", ...
Returns a new popularity model matching the data set this model was trained with. Can be used for comparison purposes.
[ "Returns", "a", "new", "popularity", "model", "matching", "the", "data", "set", "this", "model", "was", "trained", "with", ".", "Can", "be", "used", "for", "comparison", "purposes", "." ]
python
train
36.1
bitesofcode/projexui
projexui/widgets/xcombobox.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L373-L393
def setCheckedItems(self, items): """ Returns the checked items for this combobox. :return items | [<str>, ..] """ if not self.isCheckable(): return model = self.model() for i in range(self.count()): item_text = self.i...
[ "def", "setCheckedItems", "(", "self", ",", "items", ")", ":", "if", "not", "self", ".", "isCheckable", "(", ")", ":", "return", "model", "=", "self", ".", "model", "(", ")", "for", "i", "in", "range", "(", "self", ".", "count", "(", ")", ")", ":...
Returns the checked items for this combobox. :return items | [<str>, ..]
[ "Returns", "the", "checked", "items", "for", "this", "combobox", ".", ":", "return", "items", "|", "[", "<str", ">", "..", "]" ]
python
train
27.47619
paylogic/pip-accel
pip_accel/bdist.py
https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/bdist.py#L59-L122
def get_binary_dist(self, requirement): """ Get or create a cached binary distribution archive. :param requirement: A :class:`.Requirement` object. :returns: An iterable of tuples with two values each: A :class:`tarfile.TarInfo` object and a file-like object. ...
[ "def", "get_binary_dist", "(", "self", ",", "requirement", ")", ":", "cache_file", "=", "self", ".", "cache", ".", "get", "(", "requirement", ")", "if", "cache_file", ":", "if", "self", ".", "needs_invalidation", "(", "requirement", ",", "cache_file", ")", ...
Get or create a cached binary distribution archive. :param requirement: A :class:`.Requirement` object. :returns: An iterable of tuples with two values each: A :class:`tarfile.TarInfo` object and a file-like object. Gets the cached binary distribution that was previously buil...
[ "Get", "or", "create", "a", "cached", "binary", "distribution", "archive", "." ]
python
train
49.5
useblocks/sphinxcontrib-needs
sphinxcontrib/needs/utils.py
https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/utils.py#L18-L78
def row_col_maker(app, fromdocname, all_needs, need_info, need_key, make_ref=False, ref_lookup=False, prefix=''): """ Creates and returns a column. :param app: current sphinx app :param fromdocname: current document :param all_needs: Dictionary of all need objects :param need_info: need_info ob...
[ "def", "row_col_maker", "(", "app", ",", "fromdocname", ",", "all_needs", ",", "need_info", ",", "need_key", ",", "make_ref", "=", "False", ",", "ref_lookup", "=", "False", ",", "prefix", "=", "''", ")", ":", "row_col", "=", "nodes", ".", "entry", "(", ...
Creates and returns a column. :param app: current sphinx app :param fromdocname: current document :param all_needs: Dictionary of all need objects :param need_info: need_info object, which stores all related need data :param need_key: The key to access the needed data from need_info :param make...
[ "Creates", "and", "returns", "a", "column", "." ]
python
train
39.819672
gwastro/pycbc
pycbc/types/timeseries.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/types/timeseries.py#L201-L206
def at_time(self, time, nearest_sample=False): """ Return the value at the specified gps time """ if nearest_sample: time += self.delta_t / 2.0 return self[int((time-self.start_time)*self.sample_rate)]
[ "def", "at_time", "(", "self", ",", "time", ",", "nearest_sample", "=", "False", ")", ":", "if", "nearest_sample", ":", "time", "+=", "self", ".", "delta_t", "/", "2.0", "return", "self", "[", "int", "(", "(", "time", "-", "self", ".", "start_time", ...
Return the value at the specified gps time
[ "Return", "the", "value", "at", "the", "specified", "gps", "time" ]
python
train
40
anjishnu/ask-alexa-pykit
ask/alexa_io.py
https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/ask/alexa_io.py#L195-L213
def route_request(self, request_json, metadata=None): ''' Route the request object to the right handler function ''' request = Request(request_json) request.metadata = metadata # add reprompt handler or some such for default? handler_fn = self._handlers[self._default] # Set defa...
[ "def", "route_request", "(", "self", ",", "request_json", ",", "metadata", "=", "None", ")", ":", "request", "=", "Request", "(", "request_json", ")", "request", ".", "metadata", "=", "metadata", "# add reprompt handler or some such for default?", "handler_fn", "=",...
Route the request object to the right handler function
[ "Route", "the", "request", "object", "to", "the", "right", "handler", "function" ]
python
train
46.631579
Contraz/demosys-py
demosys/management/__init__.py
https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/management/__init__.py#L9-L19
def find_commands(command_dir: str) -> List[str]: """ Get all command names in the a folder :return: List of commands names """ if not command_dir: return [] return [name for _, name, is_pkg in pkgutil.iter_modules([command_dir]) if not is_pkg and not name.startswith('_')]
[ "def", "find_commands", "(", "command_dir", ":", "str", ")", "->", "List", "[", "str", "]", ":", "if", "not", "command_dir", ":", "return", "[", "]", "return", "[", "name", "for", "_", ",", "name", ",", "is_pkg", "in", "pkgutil", ".", "iter_modules", ...
Get all command names in the a folder :return: List of commands names
[ "Get", "all", "command", "names", "in", "the", "a", "folder" ]
python
valid
28.090909
yamins81/tabular
tabular/io.py
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1618-L1692
def loadbinary(fname): """ Load a numpy binary file or archive created by tabular.io.savebinary. Load a numpy binary file (``.npy``) or archive (``.npz``) created by :func:`tabular.io.savebinary`. The data and associated data type (e.g. `dtype`, including if given, column names) are load...
[ "def", "loadbinary", "(", "fname", ")", ":", "X", "=", "np", ".", "load", "(", "fname", ")", "if", "isinstance", "(", "X", ",", "np", ".", "lib", ".", "npyio", ".", "NpzFile", ")", ":", "if", "'coloring'", "in", "X", ".", "files", ":", "coloring"...
Load a numpy binary file or archive created by tabular.io.savebinary. Load a numpy binary file (``.npy``) or archive (``.npz``) created by :func:`tabular.io.savebinary`. The data and associated data type (e.g. `dtype`, including if given, column names) are loaded and reconstituted. If `fnam...
[ "Load", "a", "numpy", "binary", "file", "or", "archive", "created", "by", "tabular", ".", "io", ".", "savebinary", ".", "Load", "a", "numpy", "binary", "file", "(", ".", "npy", ")", "or", "archive", "(", ".", "npz", ")", "created", "by", ":", "func",...
python
train
32.76
dls-controls/pymalcolm
malcolm/core/part.py
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/part.py#L137-L145
def add_attribute_model(self, name, # type: str attr, # type: AttributeModel writeable_func=None, # type: Optional[Callable] ): # type: (...) -> AttributeModel """Register a pre-existing At...
[ "def", "add_attribute_model", "(", "self", ",", "name", ",", "# type: str", "attr", ",", "# type: AttributeModel", "writeable_func", "=", "None", ",", "# type: Optional[Callable]", ")", ":", "# type: (...) -> AttributeModel", "return", "self", ".", "_field_registry", "....
Register a pre-existing AttributeModel to be added to the Block
[ "Register", "a", "pre", "-", "existing", "AttributeModel", "to", "be", "added", "to", "the", "Block" ]
python
train
51.222222
saltstack/salt
salt/cloud/clouds/ec2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/ec2.py#L2934-L2948
def queue_instances(instances): ''' Queue a set of instances to be provisioned later. Expects a list. Currently this only queries node data, and then places it in the cloud cache (if configured). If the salt-cloud-reactor is being used, these instances will be automatically provisioned using that. ...
[ "def", "queue_instances", "(", "instances", ")", ":", "for", "instance_id", "in", "instances", ":", "node", "=", "_get_node", "(", "instance_id", "=", "instance_id", ")", "__utils__", "[", "'cloud.cache_node'", "]", "(", "node", ",", "__active_provider_name__", ...
Queue a set of instances to be provisioned later. Expects a list. Currently this only queries node data, and then places it in the cloud cache (if configured). If the salt-cloud-reactor is being used, these instances will be automatically provisioned using that. For more information about the salt-clo...
[ "Queue", "a", "set", "of", "instances", "to", "be", "provisioned", "later", ".", "Expects", "a", "list", "." ]
python
train
40
LonamiWebs/Telethon
telethon/events/common.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/events/common.py#L167-L176
def _load_entities(self): """ Must load all the entities it needs from cache, and return ``False`` if it could not find all of them. """ if not self._chat_peer: return True # Nothing to load (e.g. MessageDeleted) self._chat, self._input_chat = self._get_enti...
[ "def", "_load_entities", "(", "self", ")", ":", "if", "not", "self", ".", "_chat_peer", ":", "return", "True", "# Nothing to load (e.g. MessageDeleted)", "self", ".", "_chat", ",", "self", ".", "_input_chat", "=", "self", ".", "_get_entity_pair", "(", "self", ...
Must load all the entities it needs from cache, and return ``False`` if it could not find all of them.
[ "Must", "load", "all", "the", "entities", "it", "needs", "from", "cache", "and", "return", "False", "if", "it", "could", "not", "find", "all", "of", "them", "." ]
python
train
37.6
tensorflow/cleverhans
cleverhans/confidence_report.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/confidence_report.py#L238-L270
def print_stats(correctness, confidence, name): """ Prints out accuracy, coverage, etc. statistics :param correctness: ndarray One bool per example specifying whether it was correctly classified :param confidence: ndarray The probability associated with each prediction :param name: str The name of...
[ "def", "print_stats", "(", "correctness", ",", "confidence", ",", "name", ")", ":", "accuracy", "=", "correctness", ".", "mean", "(", ")", "wrongness", "=", "1", "-", "correctness", "denom1", "=", "np", ".", "maximum", "(", "1", ",", "wrongness", ".", ...
Prints out accuracy, coverage, etc. statistics :param correctness: ndarray One bool per example specifying whether it was correctly classified :param confidence: ndarray The probability associated with each prediction :param name: str The name of this type of data (e.g. "clean", "MaxConfidence")
[ "Prints", "out", "accuracy", "coverage", "etc", ".", "statistics", ":", "param", "correctness", ":", "ndarray", "One", "bool", "per", "example", "specifying", "whether", "it", "was", "correctly", "classified", ":", "param", "confidence", ":", "ndarray", "The", ...
python
train
43.333333
heuer/cablemap
cablemap.core/cablemap/core/predicates.py
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/predicates.py#L215-L232
def origin_central_asia(origin): """\ Returns if the origin is located in Central Asia. Holds true for the following countries: * Afghanistan * Kazakhstan * Kyrgyzstan * Tajikistan * Turkmenistan * Uzbekistan `origin` The origin to check. """...
[ "def", "origin_central_asia", "(", "origin", ")", ":", "return", "origin_afghanistan", "(", "origin", ")", "or", "origin_kazakhstan", "(", "origin", ")", "or", "origin_kyrgyzstan", "(", "origin", ")", "or", "origin_tajikistan", "(", "origin", ")", "or", "origin_...
\ Returns if the origin is located in Central Asia. Holds true for the following countries: * Afghanistan * Kazakhstan * Kyrgyzstan * Tajikistan * Turkmenistan * Uzbekistan `origin` The origin to check.
[ "\\", "Returns", "if", "the", "origin", "is", "located", "in", "Central", "Asia", "." ]
python
train
28.555556
sibirrer/lenstronomy
lenstronomy/LensModel/Profiles/nfw_ellipse.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw_ellipse.py#L44-L65
def derivatives(self, x, y, Rs, theta_Rs, e1, e2, center_x=0, center_y=0): """ returns df/dx and df/dy of the function (integral of NFW) """ phi_G, q = param_util.ellipticity2phi_q(e1, e2) x_shift = x - center_x y_shift = y - center_y cos_phi = np.cos(phi_G) ...
[ "def", "derivatives", "(", "self", ",", "x", ",", "y", ",", "Rs", ",", "theta_Rs", ",", "e1", ",", "e2", ",", "center_x", "=", "0", ",", "center_y", "=", "0", ")", ":", "phi_G", ",", "q", "=", "param_util", ".", "ellipticity2phi_q", "(", "e1", ",...
returns df/dx and df/dy of the function (integral of NFW)
[ "returns", "df", "/", "dx", "and", "df", "/", "dy", "of", "the", "function", "(", "integral", "of", "NFW", ")" ]
python
train
41.545455
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/futures.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/futures.py#L115-L140
def exception(self, timeout=None): """Return the exception raised by the call, if any. This blocks until the message has successfully been published, and returns the exception. If the call succeeded, return None. Args: timeout (Union[int, float]): The number of seconds befo...
[ "def", "exception", "(", "self", ",", "timeout", "=", "None", ")", ":", "# Wait until the future is done.", "if", "not", "self", ".", "_completed", ".", "wait", "(", "timeout", "=", "timeout", ")", ":", "raise", "exceptions", ".", "TimeoutError", "(", "\"Tim...
Return the exception raised by the call, if any. This blocks until the message has successfully been published, and returns the exception. If the call succeeded, return None. Args: timeout (Union[int, float]): The number of seconds before this call times out and rai...
[ "Return", "the", "exception", "raised", "by", "the", "call", "if", "any", "." ]
python
train
35.692308
SpriteLink/NIPAP
utilities/ipplan-import.py
https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/utilities/ipplan-import.py#L113-L139
def add_host(host): """ Put your host information in the prefix object. """ p = new_prefix() p.prefix = str(host['ipaddr']) p.type = "host" p.description = host['description'] p.node = host['fqdn'] p.avps = {} # Use remaining data from ipplan to populate comment field. if 'additiona...
[ "def", "add_host", "(", "host", ")", ":", "p", "=", "new_prefix", "(", ")", "p", ".", "prefix", "=", "str", "(", "host", "[", "'ipaddr'", "]", ")", "p", ".", "type", "=", "\"host\"", "p", ".", "description", "=", "host", "[", "'description'", "]", ...
Put your host information in the prefix object.
[ "Put", "your", "host", "information", "in", "the", "prefix", "object", "." ]
python
train
25.851852
pytorch/text
torchtext/data/field.py
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L277-L309
def build_vocab(self, *args, **kwargs): """Construct the Vocab object for this field from one or more datasets. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of...
[ "def", "build_vocab", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "counter", "=", "Counter", "(", ")", "sources", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "Dataset", ")", ":", "sou...
Construct the Vocab object for this field from one or more datasets. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of possible values for this field. If ...
[ "Construct", "the", "Vocab", "object", "for", "this", "field", "from", "one", "or", "more", "datasets", "." ]
python
train
44.515152
oceanprotocol/squid-py
squid_py/aquarius/aquarius.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L153-L166
def update_asset_ddo(self, did, ddo): """ Update the ddo of a did already registered. :param did: Asset DID string :param ddo: DDO instance :return: API response (depends on implementation) """ response = self.requests_session.put(f'{self.url}/{did}', data=ddo.as...
[ "def", "update_asset_ddo", "(", "self", ",", "did", ",", "ddo", ")", ":", "response", "=", "self", ".", "requests_session", ".", "put", "(", "f'{self.url}/{did}'", ",", "data", "=", "ddo", ".", "as_text", "(", ")", ",", "headers", "=", "self", ".", "_h...
Update the ddo of a did already registered. :param did: Asset DID string :param ddo: DDO instance :return: API response (depends on implementation)
[ "Update", "the", "ddo", "of", "a", "did", "already", "registered", "." ]
python
train
42.071429
jhuapl-boss/intern
intern/service/boss/project.py
https://github.com/jhuapl-boss/intern/blob/d8fc6df011d8f212c87e6a1fd4cc21cfb5d103ed/intern/service/boss/project.py#L74-L85
def create_group(self, name): """Create a new group. Args: name (string): Name of the group to create. Raises: requests.HTTPError on failure. """ self.service.create_group( name, self.url_prefix, self.auth, self.session, self.sess...
[ "def", "create_group", "(", "self", ",", "name", ")", ":", "self", ".", "service", ".", "create_group", "(", "name", ",", "self", ".", "url_prefix", ",", "self", ".", "auth", ",", "self", ".", "session", ",", "self", ".", "session_send_opts", ")" ]
Create a new group. Args: name (string): Name of the group to create. Raises: requests.HTTPError on failure.
[ "Create", "a", "new", "group", "." ]
python
train
26.916667
zeth/inputs
inputs.py
https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L1925-L1937
def handle_relative(self, event): """Relative mouse movement.""" delta_x, delta_y = self._get_relative(event) if delta_x: self.events.append( self.emulate_rel(0x00, delta_x, self.timeval)) if de...
[ "def", "handle_relative", "(", "self", ",", "event", ")", ":", "delta_x", ",", "delta_y", "=", "self", ".", "_get_relative", "(", "event", ")", "if", "delta_x", ":", "self", ".", "events", ".", "append", "(", "self", ".", "emulate_rel", "(", "0x00", ",...
Relative mouse movement.
[ "Relative", "mouse", "movement", "." ]
python
train
36.538462
git-afsantos/bonsai
bonsai/model.py
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L477-L486
def pretty_str(self, indent=0): """Return a human-readable string representation of this object. Kwargs: indent (int): The amount of spaces to use as indentation. """ spaces = ' ' * indent pretty = '{}namespace {}:\n'.format(spaces, self.name) pretty += '\n\n...
[ "def", "pretty_str", "(", "self", ",", "indent", "=", "0", ")", ":", "spaces", "=", "' '", "*", "indent", "pretty", "=", "'{}namespace {}:\\n'", ".", "format", "(", "spaces", ",", "self", ".", "name", ")", "pretty", "+=", "'\\n\\n'", ".", "join", "(", ...
Return a human-readable string representation of this object. Kwargs: indent (int): The amount of spaces to use as indentation.
[ "Return", "a", "human", "-", "readable", "string", "representation", "of", "this", "object", "." ]
python
train
38.8
sosy-lab/benchexec
benchexec/cgroups.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/cgroups.py#L133-L147
def _parse_proc_pid_cgroup(content): """ Parse a /proc/*/cgroup file into tuples of (subsystem,cgroup). @param content: An iterable over the lines of the file. @return: a generator of tuples """ for ownCgroup in content: #each line is "id:subsystem,subsystem:path" ownCgroup = own...
[ "def", "_parse_proc_pid_cgroup", "(", "content", ")", ":", "for", "ownCgroup", "in", "content", ":", "#each line is \"id:subsystem,subsystem:path\"", "ownCgroup", "=", "ownCgroup", ".", "strip", "(", ")", ".", "split", "(", "':'", ")", "try", ":", "path", "=", ...
Parse a /proc/*/cgroup file into tuples of (subsystem,cgroup). @param content: An iterable over the lines of the file. @return: a generator of tuples
[ "Parse", "a", "/", "proc", "/", "*", "/", "cgroup", "file", "into", "tuples", "of", "(", "subsystem", "cgroup", ")", "." ]
python
train
39
samluescher/django-media-tree
media_tree/utils/staticfiles.py
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/staticfiles.py#L108-L124
def find(file_node, dirs=ICON_DIRS, default_name=None, file_ext='.png'): """ Iterating all icon dirs, try to find a file called like the node's extension / mime subtype / mime type (in that order). For instance, for an MP3 file ("audio/mpeg"), this would look for: "mp3.png" / "au...
[ "def", "find", "(", "file_node", ",", "dirs", "=", "ICON_DIRS", ",", "default_name", "=", "None", ",", "file_ext", "=", "'.png'", ")", ":", "names", "=", "[", "]", "for", "attr_name", "in", "(", "'extension'", ",", "'mimetype'", ",", "'mime_supertype'", ...
Iterating all icon dirs, try to find a file called like the node's extension / mime subtype / mime type (in that order). For instance, for an MP3 file ("audio/mpeg"), this would look for: "mp3.png" / "audio/mpeg.png" / "audio.png"
[ "Iterating", "all", "icon", "dirs", "try", "to", "find", "a", "file", "called", "like", "the", "node", "s", "extension", "/", "mime", "subtype", "/", "mime", "type", "(", "in", "that", "order", ")", ".", "For", "instance", "for", "an", "MP3", "file", ...
python
train
43.823529
nyaruka/smartmin
smartmin/views.py
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L232-L246
def lookup_field_class(self, field, obj=None, default=None): """ Looks up any additional class we should include when rendering this field """ css = "" # is there a class specified for this field if field in self.field_config and 'class' in self.field_config[field]: ...
[ "def", "lookup_field_class", "(", "self", ",", "field", ",", "obj", "=", "None", ",", "default", "=", "None", ")", ":", "css", "=", "\"\"", "# is there a class specified for this field", "if", "field", "in", "self", ".", "field_config", "and", "'class'", "in",...
Looks up any additional class we should include when rendering this field
[ "Looks", "up", "any", "additional", "class", "we", "should", "include", "when", "rendering", "this", "field" ]
python
train
31.266667
basho/riak-python-client
riak/codecs/pbuf.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/pbuf.py#L847-L895
def decode_timeseries_row(self, tsrow, tscols=None, convert_timestamp=False): """ Decodes a TsRow into a list :param tsrow: the protobuf TsRow to decode. :type tsrow: riak.pb.riak_ts_pb2.TsRow :param tscols: the protobuf TsColumn data to help decode...
[ "def", "decode_timeseries_row", "(", "self", ",", "tsrow", ",", "tscols", "=", "None", ",", "convert_timestamp", "=", "False", ")", ":", "row", "=", "[", "]", "for", "i", ",", "cell", "in", "enumerate", "(", "tsrow", ".", "cells", ")", ":", "col", "=...
Decodes a TsRow into a list :param tsrow: the protobuf TsRow to decode. :type tsrow: riak.pb.riak_ts_pb2.TsRow :param tscols: the protobuf TsColumn data to help decode. :type tscols: list :rtype list
[ "Decodes", "a", "TsRow", "into", "a", "list" ]
python
train
42.816327
CitrineInformatics/dftparse
dftparse/vasp/outcar_parser.py
https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/vasp/outcar_parser.py#L4-L10
def _parse_total_magnetization(line, lines): """Parse the total magnetization, which is somewhat hidden""" toks = line.split() res = {"number of electrons": float(toks[3])} if len(toks) > 5: res["total magnetization"] = float(toks[5]) return res
[ "def", "_parse_total_magnetization", "(", "line", ",", "lines", ")", ":", "toks", "=", "line", ".", "split", "(", ")", "res", "=", "{", "\"number of electrons\"", ":", "float", "(", "toks", "[", "3", "]", ")", "}", "if", "len", "(", "toks", ")", ">",...
Parse the total magnetization, which is somewhat hidden
[ "Parse", "the", "total", "magnetization", "which", "is", "somewhat", "hidden" ]
python
train
38.142857
heitzmann/gdspy
gdspy/__init__.py
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2499-L2525
def get_labels(self, depth=None): """ Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------...
[ "def", "get_labels", "(", "self", ",", "depth", "=", "None", ")", ":", "labels", "=", "libCopy", ".", "deepcopy", "(", "self", ".", "labels", ")", "if", "depth", "is", "None", "or", "depth", ">", "0", ":", "for", "element", "in", "self", ".", "elem...
Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List con...
[ "Returns", "a", "list", "with", "a", "copy", "of", "the", "labels", "in", "this", "cell", "." ]
python
train
36.62963
weld-project/weld
python/grizzly/grizzly/grizzly_impl.py
https://github.com/weld-project/weld/blob/8ddd6db6b28878bef0892da44b1d2002b564389c/python/grizzly/grizzly/grizzly_impl.py#L469-L510
def compare(array, other, op, ty_str): """ Performs passed-in comparison op between every element in the passed-in array and other, and returns an array of booleans. Args: array (WeldObject / Numpy.ndarray): Input array other (WeldObject / Numpy.ndarray): Second input array op (...
[ "def", "compare", "(", "array", ",", "other", ",", "op", ",", "ty_str", ")", ":", "weld_obj", "=", "WeldObject", "(", "encoder_", ",", "decoder_", ")", "array_var", "=", "weld_obj", ".", "update", "(", "array", ")", "if", "isinstance", "(", "array", ",...
Performs passed-in comparison op between every element in the passed-in array and other, and returns an array of booleans. Args: array (WeldObject / Numpy.ndarray): Input array other (WeldObject / Numpy.ndarray): Second input array op (str): Op string used for element-wise comparison (=...
[ "Performs", "passed", "-", "in", "comparison", "op", "between", "every", "element", "in", "the", "passed", "-", "in", "array", "and", "other", "and", "returns", "an", "array", "of", "booleans", "." ]
python
train
33.738095
sanger-pathogens/Fastaq
pyfastaq/tasks.py
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L431-L443
def mean_length(infile, limit=None): '''Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N''' total = 0 count = 0 seq_reader = sequences.file_reader(infile) for seq in seq_reader: total += len(seq) ...
[ "def", "mean_length", "(", "infile", ",", "limit", "=", "None", ")", ":", "total", "=", "0", "count", "=", "0", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "for", "seq", "in", "seq_reader", ":", "total", "+=", "len", "(", ...
Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N
[ "Returns", "the", "mean", "length", "of", "the", "sequences", "in", "the", "input", "file", ".", "By", "default", "uses", "all", "sequences", ".", "To", "limit", "to", "the", "first", "N", "sequences", "use", "limit", "=", "N" ]
python
valid
33.307692
ssato/python-anyconfig
src/anyconfig/utils.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/utils.py#L38-L51
def get_file_extension(file_path): """ >>> get_file_extension("/a/b/c") '' >>> get_file_extension("/a/b.txt") 'txt' >>> get_file_extension("/a/b/c.tar.xz") 'xz' """ _ext = os.path.splitext(file_path)[-1] if _ext: return _ext[1:] if _ext.startswith('.') else _ext retu...
[ "def", "get_file_extension", "(", "file_path", ")", ":", "_ext", "=", "os", ".", "path", ".", "splitext", "(", "file_path", ")", "[", "-", "1", "]", "if", "_ext", ":", "return", "_ext", "[", "1", ":", "]", "if", "_ext", ".", "startswith", "(", "'.'...
>>> get_file_extension("/a/b/c") '' >>> get_file_extension("/a/b.txt") 'txt' >>> get_file_extension("/a/b/c.tar.xz") 'xz'
[ ">>>", "get_file_extension", "(", "/", "a", "/", "b", "/", "c", ")", ">>>", "get_file_extension", "(", "/", "a", "/", "b", ".", "txt", ")", "txt", ">>>", "get_file_extension", "(", "/", "a", "/", "b", "/", "c", ".", "tar", ".", "xz", ")", "xz" ]
python
train
22.285714
kennknowles/python-jsonpath-rw
jsonpath_rw/parser.py
https://github.com/kennknowles/python-jsonpath-rw/blob/f615451d7b405e23e0f80b15cad03b1427b0256d/jsonpath_rw/parser.py#L94-L101
def p_jsonpath_named_operator(self, p): "jsonpath : NAMED_OPERATOR" if p[1] == 'this': p[0] = This() elif p[1] == 'parent': p[0] = Parent() else: raise Exception('Unknown named operator `%s` at %s:%s' % (p[1], p.lineno(1), p.lexpos(1)))
[ "def", "p_jsonpath_named_operator", "(", "self", ",", "p", ")", ":", "if", "p", "[", "1", "]", "==", "'this'", ":", "p", "[", "0", "]", "=", "This", "(", ")", "elif", "p", "[", "1", "]", "==", "'parent'", ":", "p", "[", "0", "]", "=", "Parent...
jsonpath : NAMED_OPERATOR
[ "jsonpath", ":", "NAMED_OPERATOR" ]
python
train
37.125
chrislit/abydos
abydos/distance/_prefix.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/distance/_prefix.py#L41-L82
def sim(self, src, tar): """Return the prefix similarity of two strings. Prefix similarity is the ratio of the length of the shorter term that exactly matches the longer term to the length of the shorter term, beginning at the start of both terms. Parameters ---------- ...
[ "def", "sim", "(", "self", ",", "src", ",", "tar", ")", ":", "if", "src", "==", "tar", ":", "return", "1.0", "if", "not", "src", "or", "not", "tar", ":", "return", "0.0", "min_word", ",", "max_word", "=", "(", "src", ",", "tar", ")", "if", "len...
Return the prefix similarity of two strings. Prefix similarity is the ratio of the length of the shorter term that exactly matches the longer term to the length of the shorter term, beginning at the start of both terms. Parameters ---------- src : str Source...
[ "Return", "the", "prefix", "similarity", "of", "two", "strings", "." ]
python
valid
26.119048
UpCloudLtd/upcloud-python-api
upcloud_api/cloud_manager/firewall_mixin.py
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L57-L62
def delete_firewall_rule(self, server_uuid, firewall_rule_position): """ Delete a firewall rule based on a server uuid and rule position. """ url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position) return self.request('DELETE', url)
[ "def", "delete_firewall_rule", "(", "self", ",", "server_uuid", ",", "firewall_rule_position", ")", ":", "url", "=", "'/server/{0}/firewall_rule/{1}'", ".", "format", "(", "server_uuid", ",", "firewall_rule_position", ")", "return", "self", ".", "request", "(", "'DE...
Delete a firewall rule based on a server uuid and rule position.
[ "Delete", "a", "firewall", "rule", "based", "on", "a", "server", "uuid", "and", "rule", "position", "." ]
python
train
48.833333
ceph/ceph-deploy
ceph_deploy/util/system.py
https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/util/system.py#L5-L16
def executable_path(conn, executable): """ Remote validator that accepts a connection object to ensure that a certain executable is available returning its full path if so. Otherwise an exception with thorough details will be raised, informing the user that the executable was not found. """ ...
[ "def", "executable_path", "(", "conn", ",", "executable", ")", ":", "executable_path", "=", "conn", ".", "remote_module", ".", "which", "(", "executable", ")", "if", "not", "executable_path", ":", "raise", "ExecutableNotFound", "(", "executable", ",", "conn", ...
Remote validator that accepts a connection object to ensure that a certain executable is available returning its full path if so. Otherwise an exception with thorough details will be raised, informing the user that the executable was not found.
[ "Remote", "validator", "that", "accepts", "a", "connection", "object", "to", "ensure", "that", "a", "certain", "executable", "is", "available", "returning", "its", "full", "path", "if", "so", "." ]
python
train
39.916667
ensime/ensime-vim
ensime_shared/typecheck.py
https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/typecheck.py#L17-L24
def buffer_typechecks_and_display(self, call_id, payload): """Adds typecheck events to the buffer, and displays them right away. This is a workaround for this issue: https://github.com/ensime/ensime-server/issues/1616 """ self.buffer_typechecks(call_id, payload) self.edi...
[ "def", "buffer_typechecks_and_display", "(", "self", ",", "call_id", ",", "payload", ")", ":", "self", ".", "buffer_typechecks", "(", "call_id", ",", "payload", ")", "self", ".", "editor", ".", "display_notes", "(", "self", ".", "buffered_notes", ")" ]
Adds typecheck events to the buffer, and displays them right away. This is a workaround for this issue: https://github.com/ensime/ensime-server/issues/1616
[ "Adds", "typecheck", "events", "to", "the", "buffer", "and", "displays", "them", "right", "away", "." ]
python
train
43.875
bitesofcode/projexui
projexui/widgets/xdocktoolbar.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdocktoolbar.py#L522-L625
def setCurrentAction(self, action): """ Sets the current action for this widget that highlights the size for this toolbar. :param action | <QAction> """ if action == self._currentAction: return self._currentAction = act...
[ "def", "setCurrentAction", "(", "self", ",", "action", ")", ":", "if", "action", "==", "self", ".", "_currentAction", ":", "return", "self", ".", "_currentAction", "=", "action", "self", ".", "currentActionChanged", ".", "emit", "(", "action", ")", "labels",...
Sets the current action for this widget that highlights the size for this toolbar. :param action | <QAction>
[ "Sets", "the", "current", "action", "for", "this", "widget", "that", "highlights", "the", "size", "for", "this", "toolbar", ".", ":", "param", "action", "|", "<QAction", ">" ]
python
train
39.644231
nathancahill/mimicdb
mimicdb/s3/bucket.py
https://github.com/nathancahill/mimicdb/blob/9d0e8ebcba31d937f73752f9b88e5a4fec860765/mimicdb/s3/bucket.py#L129-L148
def _get_all(self, *args, **kwargs): """If 'force' is in the headers, retrieve the list of keys from S3. Otherwise, use the list() function to retrieve the keys from MimicDB. """ headers = kwargs.get('headers', args[2] if len(args) > 2 else None) or dict() if 'force' in headers:...
[ "def", "_get_all", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "kwargs", ".", "get", "(", "'headers'", ",", "args", "[", "2", "]", "if", "len", "(", "args", ")", ">", "2", "else", "None", ")", "or", "dict",...
If 'force' is in the headers, retrieve the list of keys from S3. Otherwise, use the list() function to retrieve the keys from MimicDB.
[ "If", "force", "is", "in", "the", "headers", "retrieve", "the", "list", "of", "keys", "from", "S3", ".", "Otherwise", "use", "the", "list", "()", "function", "to", "retrieve", "the", "keys", "from", "MimicDB", "." ]
python
valid
36.8
panosl/django-currencies
currencies/utils.py
https://github.com/panosl/django-currencies/blob/8d4c6c202ad7c4cc06263ab2c1b1f969bbe99acd/currencies/utils.py#L48-L55
def price_rounding(price, decimals=2): """Takes a decimal price and rounds to a number of decimal places""" try: exponent = D('.' + decimals * '0') except InvalidOperation: # Currencies with no decimal places, ex. JPY, HUF exponent = D() return price.quantize(exponent, rounding=R...
[ "def", "price_rounding", "(", "price", ",", "decimals", "=", "2", ")", ":", "try", ":", "exponent", "=", "D", "(", "'.'", "+", "decimals", "*", "'0'", ")", "except", "InvalidOperation", ":", "# Currencies with no decimal places, ex. JPY, HUF", "exponent", "=", ...
Takes a decimal price and rounds to a number of decimal places
[ "Takes", "a", "decimal", "price", "and", "rounds", "to", "a", "number", "of", "decimal", "places" ]
python
train
40.125
fozzle/python-brotherprint
brotherprint/brotherprint.py
https://github.com/fozzle/python-brotherprint/blob/5fb92df11b599c30a7da3d6ac7ed60acff230044/brotherprint/brotherprint.py#L568-L584
def double_width(self, action): '''Enable/cancel doublewidth printing Args: action: Enable or disable doublewidth printing. Options are 'on' and 'off' Returns: None Raises: RuntimeError: Invalid action. ''' if action == 'on': ...
[ "def", "double_width", "(", "self", ",", "action", ")", ":", "if", "action", "==", "'on'", ":", "action", "=", "'1'", "elif", "action", "==", "'off'", ":", "action", "=", "'0'", "else", ":", "raise", "RuntimeError", "(", "'Invalid action for function doubleW...
Enable/cancel doublewidth printing Args: action: Enable or disable doublewidth printing. Options are 'on' and 'off' Returns: None Raises: RuntimeError: Invalid action.
[ "Enable", "/", "cancel", "doublewidth", "printing", "Args", ":", "action", ":", "Enable", "or", "disable", "doublewidth", "printing", ".", "Options", "are", "on", "and", "off", "Returns", ":", "None", "Raises", ":", "RuntimeError", ":", "Invalid", "action", ...
python
train
31.294118
cgearhart/Resound
extract.py
https://github.com/cgearhart/Resound/blob/83a15be0ce2dc13003574c6039f8a1ad87734bc2/extract.py#L16-L42
def main(input_filename, songname, format, counter): """ Calculate the fingerprint hashses of the referenced audio file and save to disk as a pickle file """ # open the file & convert to wav song_data = AudioSegment.from_file(input_filename, format=format) song_data = song_data.set_channels...
[ "def", "main", "(", "input_filename", ",", "songname", ",", "format", ",", "counter", ")", ":", "# open the file & convert to wav", "song_data", "=", "AudioSegment", ".", "from_file", "(", "input_filename", ",", "format", "=", "format", ")", "song_data", "=", "s...
Calculate the fingerprint hashses of the referenced audio file and save to disk as a pickle file
[ "Calculate", "the", "fingerprint", "hashses", "of", "the", "referenced", "audio", "file", "and", "save", "to", "disk", "as", "a", "pickle", "file" ]
python
train
36.962963
ECESeniorDesign/greenhouse_envmgmt
greenhouse_envmgmt/control.py
https://github.com/ECESeniorDesign/greenhouse_envmgmt/blob/864e0ce98bfb220f9954026913a5470536de9818/greenhouse_envmgmt/control.py#L178-L219
def control(self, on=[], off=[]): """ This method serves as the primary interaction point to the controls interface. - The 'on' and 'off' arguments can either be a list or a single string. This allows for both individual device control and batch controls. Note: ...
[ "def", "control", "(", "self", ",", "on", "=", "[", "]", ",", "off", "=", "[", "]", ")", ":", "controls", "=", "{", "\"light\"", ",", "\"valve\"", ",", "\"fan\"", ",", "\"pump\"", "}", "def", "cast_arg", "(", "arg", ")", ":", "if", "type", "(", ...
This method serves as the primary interaction point to the controls interface. - The 'on' and 'off' arguments can either be a list or a single string. This allows for both individual device control and batch controls. Note: Both the onlist and offlist are optional. ...
[ "This", "method", "serves", "as", "the", "primary", "interaction", "point", "to", "the", "controls", "interface", ".", "-", "The", "on", "and", "off", "arguments", "can", "either", "be", "a", "list", "or", "a", "single", "string", ".", "This", "allows", ...
python
train
34.095238
nficano/python-lambda
aws_lambda/aws_lambda.py
https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L272-L366
def build( src, requirements=None, local_package=None, config_file='config.yaml', profile_name=None, ): """Builds the file bundle. :param str src: The path to your Lambda ready project (folder must contain a valid config.yaml and handler module (e.g.: service.py). :param str local_pa...
[ "def", "build", "(", "src", ",", "requirements", "=", "None", ",", "local_package", "=", "None", ",", "config_file", "=", "'config.yaml'", ",", "profile_name", "=", "None", ",", ")", ":", "# Load and parse the config file.", "path_to_config_file", "=", "os", "."...
Builds the file bundle. :param str src: The path to your Lambda ready project (folder must contain a valid config.yaml and handler module (e.g.: service.py). :param str local_package: The path to a local package with should be included in the deploy as well (and/or is not availab...
[ "Builds", "the", "file", "bundle", "." ]
python
valid
35.4
neo4j/neo4j-python-driver
neo4j/types/__init__.py
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L219-L235
def index(self, key): """ Return the index of the given item. :param key: :return: """ if isinstance(key, int): if 0 <= key < len(self.__keys): return key raise IndexError(key) elif isinstance(key, str): try: ...
[ "def", "index", "(", "self", ",", "key", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "if", "0", "<=", "key", "<", "len", "(", "self", ".", "__keys", ")", ":", "return", "key", "raise", "IndexError", "(", "key", ")", "elif", ...
Return the index of the given item. :param key: :return:
[ "Return", "the", "index", "of", "the", "given", "item", "." ]
python
train
26.647059
warner/magic-wormhole
src/wormhole/cli/cmd_receive.py
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cmd_receive.py#L40-L52
def receive(args, reactor=reactor, _debug_stash_wormhole=None): """I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: * WrongPasswordError: the two sides didn't use matching passwords * Timeout: something didn't happen fast eno...
[ "def", "receive", "(", "args", ",", "reactor", "=", "reactor", ",", "_debug_stash_wormhole", "=", "None", ")", ":", "r", "=", "Receiver", "(", "args", ",", "reactor", ")", "d", "=", "r", ".", "go", "(", ")", "if", "_debug_stash_wormhole", "is", "not", ...
I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: * WrongPasswordError: the two sides didn't use matching passwords * Timeout: something didn't happen fast enough for our tastes * TransferError: the sender rejected the transfe...
[ "I", "implement", "wormhole", "receive", ".", "I", "return", "a", "Deferred", "that", "fires", "with", "None", "(", "for", "success", ")", "or", "signals", "one", "of", "the", "following", "errors", ":", "*", "WrongPasswordError", ":", "the", "two", "sides...
python
train
46.538462
seleniumbase/SeleniumBase
seleniumbase/core/browser_launcher.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/core/browser_launcher.py#L63-L85
def _add_chrome_proxy_extension( chrome_options, proxy_string, proxy_user, proxy_pass): """ Implementation of https://stackoverflow.com/a/35293284 for https://stackoverflow.com/questions/12848327/ (Run Selenium on a proxy server that requires authentication.) """ if not "".join(sys.argv)...
[ "def", "_add_chrome_proxy_extension", "(", "chrome_options", ",", "proxy_string", ",", "proxy_user", ",", "proxy_pass", ")", ":", "if", "not", "\"\"", ".", "join", "(", "sys", ".", "argv", ")", "==", "\"-c\"", ":", "# Single-threaded", "proxy_helper", ".", "cr...
Implementation of https://stackoverflow.com/a/35293284 for https://stackoverflow.com/questions/12848327/ (Run Selenium on a proxy server that requires authentication.)
[ "Implementation", "of", "https", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "35293284", "for", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "12848327", "/", "(", "Run", "Selenium", "on", "a", "proxy", "server", "tha...
python
train
43.956522
c-soft/satel_integra
satel_integra/satel_integra.py
https://github.com/c-soft/satel_integra/blob/3b6d2020d1e10dc5aa40f30ee4ecc0f3a053eb3c/satel_integra/satel_integra.py#L409-L443
async def monitor_status(self, alarm_status_callback=None, zone_changed_callback=None, output_changed_callback=None): """Start monitoring of the alarm status. Send command to satel integra to start sending updates. Read in a loop and cal...
[ "async", "def", "monitor_status", "(", "self", ",", "alarm_status_callback", "=", "None", ",", "zone_changed_callback", "=", "None", ",", "output_changed_callback", "=", "None", ")", ":", "self", ".", "_alarm_status_callback", "=", "alarm_status_callback", "self", "...
Start monitoring of the alarm status. Send command to satel integra to start sending updates. Read in a loop and call respective callbacks when received messages.
[ "Start", "monitoring", "of", "the", "alarm", "status", "." ]
python
test
44.4
tensorflow/tensorboard
tensorboard/plugins/hparams/list_session_groups.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/hparams/list_session_groups.py#L524-L558
def _set_avg_session_metrics(session_group): """Sets the metrics for the group to be the average of its sessions. The resulting session group metrics consist of the union of metrics across the group's sessions. The value of each session group metric is the average of that metric values across the sessions in t...
[ "def", "_set_avg_session_metrics", "(", "session_group", ")", ":", "assert", "session_group", ".", "sessions", ",", "'SessionGroup cannot be empty.'", "# Algorithm: Iterate over all (session, metric) pairs and maintain a", "# dict from _MetricIdentifier to _MetricStats objects.", "# Then...
Sets the metrics for the group to be the average of its sessions. The resulting session group metrics consist of the union of metrics across the group's sessions. The value of each session group metric is the average of that metric values across the sessions in the group. The 'step' and 'wall_time_secs' fields...
[ "Sets", "the", "metrics", "for", "the", "group", "to", "be", "the", "average", "of", "its", "sessions", "." ]
python
train
48.171429
pandas-dev/pandas
pandas/core/sparse/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L997-L1039
def homogenize(series_dict): """ Conform a set of SparseSeries (with NaN fill_value) to a common SparseIndex corresponding to the locations where they all have data Parameters ---------- series_dict : dict or DataFrame Notes ----- Using the dumbest algorithm I could think of. Shoul...
[ "def", "homogenize", "(", "series_dict", ")", ":", "index", "=", "None", "need_reindex", "=", "False", "for", "_", ",", "series", "in", "series_dict", ".", "items", "(", ")", ":", "if", "not", "np", ".", "isnan", "(", "series", ".", "fill_value", ")", ...
Conform a set of SparseSeries (with NaN fill_value) to a common SparseIndex corresponding to the locations where they all have data Parameters ---------- series_dict : dict or DataFrame Notes ----- Using the dumbest algorithm I could think of. Should put some more thought into this ...
[ "Conform", "a", "set", "of", "SparseSeries", "(", "with", "NaN", "fill_value", ")", "to", "a", "common", "SparseIndex", "corresponding", "to", "the", "locations", "where", "they", "all", "have", "data" ]
python
train
25.093023
log2timeline/dfvfs
examples/recursive_hasher.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/examples/recursive_hasher.py#L39-L78
def _CalculateHashDataStream(self, file_entry, data_stream_name): """Calculates a message digest hash of the data of the file entry. Args: file_entry (dfvfs.FileEntry): file entry. data_stream_name (str): name of the data stream. Returns: bytes: digest hash or None. """ hash_cont...
[ "def", "_CalculateHashDataStream", "(", "self", ",", "file_entry", ",", "data_stream_name", ")", ":", "hash_context", "=", "hashlib", ".", "sha256", "(", ")", "try", ":", "file_object", "=", "file_entry", ".", "GetFileObject", "(", "data_stream_name", "=", "data...
Calculates a message digest hash of the data of the file entry. Args: file_entry (dfvfs.FileEntry): file entry. data_stream_name (str): name of the data stream. Returns: bytes: digest hash or None.
[ "Calculates", "a", "message", "digest", "hash", "of", "the", "data", "of", "the", "file", "entry", "." ]
python
train
28.6
CalebBell/fluids
fluids/compressible.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L1576-L1667
def Fritzsche(SG, Tavg, L=None, D=None, P1=None, P2=None, Q=None, Ts=288.7, Ps=101325., Zavg=1, E=1): r'''Calculation function for dealing with flow of a compressible gas in a pipeline with the Fritzsche formula. Can calculate any of the following, given all other inputs: * Flow rate ...
[ "def", "Fritzsche", "(", "SG", ",", "Tavg", ",", "L", "=", "None", ",", "D", "=", "None", ",", "P1", "=", "None", ",", "P2", "=", "None", ",", "Q", "=", "None", ",", "Ts", "=", "288.7", ",", "Ps", "=", "101325.", ",", "Zavg", "=", "1", ",",...
r'''Calculation function for dealing with flow of a compressible gas in a pipeline with the Fritzsche formula. Can calculate any of the following, given all other inputs: * Flow rate * Upstream pressure * Downstream pressure * Diameter of pipe * Length of pipe A variety of different co...
[ "r", "Calculation", "function", "for", "dealing", "with", "flow", "of", "a", "compressible", "gas", "in", "a", "pipeline", "with", "the", "Fritzsche", "formula", ".", "Can", "calculate", "any", "of", "the", "following", "given", "all", "other", "inputs", ":"...
python
train
40.880435
trustar/trustar-python
trustar/models/page.py
https://github.com/trustar/trustar-python/blob/707d51adc58d68aed7de12a4ca37949cb75cf122/trustar/models/page.py#L47-L61
def has_more_pages(self): """ :return: ``True`` if there are more pages available on the server. """ # if has_next property exists, it represents whether more pages exist if self.has_next is not None: return self.has_next # otherwise, try to compute whether ...
[ "def", "has_more_pages", "(", "self", ")", ":", "# if has_next property exists, it represents whether more pages exist", "if", "self", ".", "has_next", "is", "not", "None", ":", "return", "self", ".", "has_next", "# otherwise, try to compute whether or not more pages exist", ...
:return: ``True`` if there are more pages available on the server.
[ ":", "return", ":", "True", "if", "there", "are", "more", "pages", "available", "on", "the", "server", "." ]
python
train
35.066667
DLR-RM/RAFCON
source/rafcon/core/library_manager.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/library_manager.py#L405-L409
def remove_library_from_file_system(self, library_path, library_name): """Remove library from hard disk.""" library_file_system_path = self.get_os_path_to_library(library_path, library_name)[0] shutil.rmtree(library_file_system_path) self.refresh_libraries()
[ "def", "remove_library_from_file_system", "(", "self", ",", "library_path", ",", "library_name", ")", ":", "library_file_system_path", "=", "self", ".", "get_os_path_to_library", "(", "library_path", ",", "library_name", ")", "[", "0", "]", "shutil", ".", "rmtree", ...
Remove library from hard disk.
[ "Remove", "library", "from", "hard", "disk", "." ]
python
train
57.2
ioam/lancet
lancet/launch.py
https://github.com/ioam/lancet/blob/1fbbf88fa0e8974ff9ed462e3cb11722ddebdd6e/lancet/launch.py#L640-L653
def summary(self): """ A succinct summary of the Launcher configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user. """ print("Type: %s" % self.__class__.__name__) print("Batch Name: %r" % self.ba...
[ "def", "summary", "(", "self", ")", ":", "print", "(", "\"Type: %s\"", "%", "self", ".", "__class__", ".", "__name__", ")", "print", "(", "\"Batch Name: %r\"", "%", "self", ".", "batch_name", ")", "if", "self", ".", "tag", ":", "print", "(", "\"Tag: %s\"...
A succinct summary of the Launcher configuration. Unlike the repr, a summary does not have to be complete but must supply key information relevant to the user.
[ "A", "succinct", "summary", "of", "the", "Launcher", "configuration", ".", "Unlike", "the", "repr", "a", "summary", "does", "not", "have", "to", "be", "complete", "but", "must", "supply", "key", "information", "relevant", "to", "the", "user", "." ]
python
valid
42.142857
YosaiProject/yosai
yosai/core/realm/realm.py
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/realm/realm.py#L289-L340
def get_authzd_permissions(self, identifier, perm_domain): """ :type identifier: str :type domain: str :returns: a list of relevant json blobs, each a list of permission dicts """ related_perms = [] keys = ['*', perm_domain] def query_permissions(self)...
[ "def", "get_authzd_permissions", "(", "self", ",", "identifier", ",", "perm_domain", ")", ":", "related_perms", "=", "[", "]", "keys", "=", "[", "'*'", ",", "perm_domain", "]", "def", "query_permissions", "(", "self", ")", ":", "msg", "=", "(", "\"Could no...
:type identifier: str :type domain: str :returns: a list of relevant json blobs, each a list of permission dicts
[ ":", "type", "identifier", ":", "str", ":", "type", "domain", ":", "str" ]
python
train
38.923077
PythonCharmers/python-future
src/libfuturize/fixer_util.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/libfuturize/fixer_util.py#L230-L267
def future_import(feature, node): """ This seems to work """ root = find_root(node) if does_tree_import(u"__future__", feature, node): return # Look for a shebang or encoding line shebang_encoding_idx = None for idx, node in enumerate(root.children): # Is it a shebang ...
[ "def", "future_import", "(", "feature", ",", "node", ")", ":", "root", "=", "find_root", "(", "node", ")", "if", "does_tree_import", "(", "u\"__future__\"", ",", "feature", ",", "node", ")", ":", "return", "# Look for a shebang or encoding line", "shebang_encoding...
This seems to work
[ "This", "seems", "to", "work" ]
python
train
34.973684
Alignak-monitoring/alignak
alignak/objects/hostescalation.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostescalation.py#L109-L128
def explode(self, escalations): """Create instance of Escalation for each HostEscalation object :param escalations: list of escalation, used to add new ones :type escalations: alignak.objects.escalation.Escalations :return: None """ # Now we explode all escalations (host...
[ "def", "explode", "(", "self", ",", "escalations", ")", ":", "# Now we explode all escalations (host_name, hostgroup_name) to escalations", "for", "escalation", "in", "self", ":", "properties", "=", "escalation", ".", "__class__", ".", "properties", "name", "=", "getatt...
Create instance of Escalation for each HostEscalation object :param escalations: list of escalation, used to add new ones :type escalations: alignak.objects.escalation.Escalations :return: None
[ "Create", "instance", "of", "Escalation", "for", "each", "HostEscalation", "object" ]
python
train
44.25
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L259-L263
def _init_idxs_strpat(self, usr_hdrs): """List of indexes whose values will be strings.""" strpat = self.strpat_hdrs.keys() self.idxs_strpat = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in strpat]
[ "def", "_init_idxs_strpat", "(", "self", ",", "usr_hdrs", ")", ":", "strpat", "=", "self", ".", "strpat_hdrs", ".", "keys", "(", ")", "self", ".", "idxs_strpat", "=", "[", "Idx", "for", "Hdr", ",", "Idx", "in", "self", ".", "hdr2idx", ".", "items", "...
List of indexes whose values will be strings.
[ "List", "of", "indexes", "whose", "values", "will", "be", "strings", "." ]
python
train
51
tjvr/kurt
kurt/__init__.py
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L328-L402
def save(self, path=None, debug=False): """Save project to file. :param path: Path or file pointer. If you pass a file pointer, you're responsible for closing it. If path is not given, the :attr:`path` attribute is used, ...
[ "def", "save", "(", "self", ",", "path", "=", "None", ",", "debug", "=", "False", ")", ":", "p", "=", "self", ".", "copy", "(", ")", "plugin", "=", "p", ".", "_plugin", "# require path", "p", ".", "path", "=", "path", "or", "self", ".", "path", ...
Save project to file. :param path: Path or file pointer. If you pass a file pointer, you're responsible for closing it. If path is not given, the :attr:`path` attribute is used, usually the original path given to :attr:`load(...
[ "Save", "project", "to", "file", "." ]
python
train
32.933333