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
log2timeline/dfwinreg
dfwinreg/key_paths.py
https://github.com/log2timeline/dfwinreg/blob/9d488bb1db562197dbfb48de9613d6b29dea056e/dfwinreg/key_paths.py#L9-L36
def JoinKeyPath(path_segments): """Joins the path segments into key path. Args: path_segments (list[str]): Windows Registry key path segments. Returns: str: key path. """ # This is an optimized way to combine the path segments into a single path # and combine multiple successive path separators to...
[ "def", "JoinKeyPath", "(", "path_segments", ")", ":", "# This is an optimized way to combine the path segments into a single path", "# and combine multiple successive path separators to one.", "# Split all the path segments based on the path (segment) separator.", "path_segments", "=", "[", ...
Joins the path segments into key path. Args: path_segments (list[str]): Windows Registry key path segments. Returns: str: key path.
[ "Joins", "the", "path", "segments", "into", "key", "path", "." ]
python
train
31.571429
wummel/linkchecker
linkcheck/htmlutil/linkparse.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/htmlutil/linkparse.py#L234-L249
def get_link_name (self, tag, attrs, attr): """Parse attrs for link name. Return name of link.""" if tag == 'a' and attr == 'href': # Look for name only up to MAX_NAMELEN characters data = self.parser.peek(MAX_NAMELEN) data = data.decode(self.parser.encoding, "ignore"...
[ "def", "get_link_name", "(", "self", ",", "tag", ",", "attrs", ",", "attr", ")", ":", "if", "tag", "==", "'a'", "and", "attr", "==", "'href'", ":", "# Look for name only up to MAX_NAMELEN characters", "data", "=", "self", ".", "parser", ".", "peek", "(", "...
Parse attrs for link name. Return name of link.
[ "Parse", "attrs", "for", "link", "name", ".", "Return", "name", "of", "link", "." ]
python
train
39.625
cltk/cltk
cltk/corpus/arabic/utils/pyarabic/araby.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/arabic/utils/pyarabic/araby.py#L549-L561
def is_arabicstring(text): """ Checks for an Arabic standard Unicode block characters An arabic string can contain spaces, digits and pounctuation. but only arabic standard characters, not extended arabic @param text: input text @type text: unicode @return: True if all charaters are in Arabic...
[ "def", "is_arabicstring", "(", "text", ")", ":", "if", "re", ".", "search", "(", "u\"([^\\u0600-\\u0652%s%s%s\\s\\d])\"", "%", "(", "LAM_ALEF", ",", "LAM_ALEF_HAMZA_ABOVE", ",", "LAM_ALEF_MADDA_ABOVE", ")", ",", "text", ")", ":", "return", "False", "return", "Tr...
Checks for an Arabic standard Unicode block characters An arabic string can contain spaces, digits and pounctuation. but only arabic standard characters, not extended arabic @param text: input text @type text: unicode @return: True if all charaters are in Arabic block @rtype: Boolean
[ "Checks", "for", "an", "Arabic", "standard", "Unicode", "block", "characters", "An", "arabic", "string", "can", "contain", "spaces", "digits", "and", "pounctuation", ".", "but", "only", "arabic", "standard", "characters", "not", "extended", "arabic" ]
python
train
40
twaldear/flask-secure-headers
flask_secure_headers/headers.py
https://github.com/twaldear/flask-secure-headers/blob/3eca972b369608a7669b67cbe66679570a6505ce/flask_secure_headers/headers.py#L26-L34
def update_policy(self,defaultHeaders): """ if policy in default but not input still return """ if self.inputs is not None: for k,v in defaultHeaders.items(): if k not in self.inputs: self.inputs[k] = v return self.inputs else: return self.inputs
[ "def", "update_policy", "(", "self", ",", "defaultHeaders", ")", ":", "if", "self", ".", "inputs", "is", "not", "None", ":", "for", "k", ",", "v", "in", "defaultHeaders", ".", "items", "(", ")", ":", "if", "k", "not", "in", "self", ".", "inputs", "...
if policy in default but not input still return
[ "if", "policy", "in", "default", "but", "not", "input", "still", "return" ]
python
train
29.111111
ets-labs/python-dependency-injector
examples/miniapps/use_cases/example/use_cases.py
https://github.com/ets-labs/python-dependency-injector/blob/d04fe41eb17f667da38b97525e2d16c8f2d272fe/examples/miniapps/use_cases/example/use_cases.py#L19-L22
def execute(self, email): """Execute use case handling.""" print('Sign up user {0}'.format(email)) self.email_sender.send(email, 'Welcome, "{}"'.format(email))
[ "def", "execute", "(", "self", ",", "email", ")", ":", "print", "(", "'Sign up user {0}'", ".", "format", "(", "email", ")", ")", "self", ".", "email_sender", ".", "send", "(", "email", ",", "'Welcome, \"{}\"'", ".", "format", "(", "email", ")", ")" ]
Execute use case handling.
[ "Execute", "use", "case", "handling", "." ]
python
train
45
Unidata/MetPy
metpy/calc/thermo.py
https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/calc/thermo.py#L1912-L1941
def moist_static_energy(heights, temperature, specific_humidity): r"""Calculate the moist static energy of parcels. This function will calculate the moist static energy following equation 3.72 in [Hobbs2006]_. Notes ----- .. math::\text{moist static energy} = c_{pd} * T + gz + L_v q * :mat...
[ "def", "moist_static_energy", "(", "heights", ",", "temperature", ",", "specific_humidity", ")", ":", "return", "(", "dry_static_energy", "(", "heights", ",", "temperature", ")", "+", "mpconsts", ".", "Lv", "*", "specific_humidity", ".", "to", "(", "'dimensionle...
r"""Calculate the moist static energy of parcels. This function will calculate the moist static energy following equation 3.72 in [Hobbs2006]_. Notes ----- .. math::\text{moist static energy} = c_{pd} * T + gz + L_v q * :math:`T` is temperature * :math:`z` is height * :math:`q` is spec...
[ "r", "Calculate", "the", "moist", "static", "energy", "of", "parcels", "." ]
python
train
26.933333
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/interfaces/gatt.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/interfaces/gatt.py#L94-L101
def find_descriptor(self, uuid): """Return the first child descriptor found that has the specified UUID. Will return None if no descriptor that matches is found. """ for desc in self.list_descriptors(): if desc.uuid == uuid: return desc return None
[ "def", "find_descriptor", "(", "self", ",", "uuid", ")", ":", "for", "desc", "in", "self", ".", "list_descriptors", "(", ")", ":", "if", "desc", ".", "uuid", "==", "uuid", ":", "return", "desc", "return", "None" ]
Return the first child descriptor found that has the specified UUID. Will return None if no descriptor that matches is found.
[ "Return", "the", "first", "child", "descriptor", "found", "that", "has", "the", "specified", "UUID", ".", "Will", "return", "None", "if", "no", "descriptor", "that", "matches", "is", "found", "." ]
python
valid
38.75
glormph/msstitch
src/app/actions/prottable/info.py
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/info.py#L41-L45
def get_protein_data_pgrouped(proteindata, p_acc, headerfields): """Parses protein data for a certain protein into tsv output dictionary""" report = get_protein_data_base(proteindata, p_acc, headerfields) return get_cov_protnumbers(proteindata, p_acc, report)
[ "def", "get_protein_data_pgrouped", "(", "proteindata", ",", "p_acc", ",", "headerfields", ")", ":", "report", "=", "get_protein_data_base", "(", "proteindata", ",", "p_acc", ",", "headerfields", ")", "return", "get_cov_protnumbers", "(", "proteindata", ",", "p_acc"...
Parses protein data for a certain protein into tsv output dictionary
[ "Parses", "protein", "data", "for", "a", "certain", "protein", "into", "tsv", "output", "dictionary" ]
python
train
54.2
ArchiveTeam/wpull
wpull/network/pool.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/network/pool.py#L231-L237
def no_wait_release(self, connection: Connection): '''Synchronous version of :meth:`release`.''' _logger.debug('No wait check in.') release_task = asyncio.get_event_loop().create_task( self.release(connection) ) self._release_tasks.add(release_task)
[ "def", "no_wait_release", "(", "self", ",", "connection", ":", "Connection", ")", ":", "_logger", ".", "debug", "(", "'No wait check in.'", ")", "release_task", "=", "asyncio", ".", "get_event_loop", "(", ")", ".", "create_task", "(", "self", ".", "release", ...
Synchronous version of :meth:`release`.
[ "Synchronous", "version", "of", ":", "meth", ":", "release", "." ]
python
train
42.142857
devricks/soft_drf
soft_drf/api/serializers/base.py
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/serializers/base.py#L11-L19
def build_absolute_uri(self, uri): """ Return a fully qualified absolute url for the given uri. """ request = self.context.get('request', None) return ( request.build_absolute_uri(uri) if request is not None else uri )
[ "def", "build_absolute_uri", "(", "self", ",", "uri", ")", ":", "request", "=", "self", ".", "context", ".", "get", "(", "'request'", ",", "None", ")", "return", "(", "request", ".", "build_absolute_uri", "(", "uri", ")", "if", "request", "is", "not", ...
Return a fully qualified absolute url for the given uri.
[ "Return", "a", "fully", "qualified", "absolute", "url", "for", "the", "given", "uri", "." ]
python
train
30.111111
saltstack/salt
salt/modules/vsphere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L6528-L6555
def _format_coredump_stdout(cmd_ret): ''' Helper function to format the stdout from the get_coredump_network_config function. cmd_ret The return dictionary that comes from a cmd.run_all call. ''' ret_dict = {} for line in cmd_ret['stdout'].splitlines(): line = line.strip().lower...
[ "def", "_format_coredump_stdout", "(", "cmd_ret", ")", ":", "ret_dict", "=", "{", "}", "for", "line", "in", "cmd_ret", "[", "'stdout'", "]", ".", "splitlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", ...
Helper function to format the stdout from the get_coredump_network_config function. cmd_ret The return dictionary that comes from a cmd.run_all call.
[ "Helper", "function", "to", "format", "the", "stdout", "from", "the", "get_coredump_network_config", "function", "." ]
python
train
34.392857
facelessuser/backrefs
tools/unipropgen.py
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L159-L217
def gen_blocks(output, ascii_props=False, append=False, prefix=""): """Generate Unicode blocks.""" with codecs.open(output, 'a' if append else 'w', 'utf-8') as f: if not append: f.write(HEADER) f.write('%s_blocks = {' % prefix) no_block = [] last = -1 max_ra...
[ "def", "gen_blocks", "(", "output", ",", "ascii_props", "=", "False", ",", "append", "=", "False", ",", "prefix", "=", "\"\"", ")", ":", "with", "codecs", ".", "open", "(", "output", ",", "'a'", "if", "append", "else", "'w'", ",", "'utf-8'", ")", "as...
Generate Unicode blocks.
[ "Generate", "Unicode", "blocks", "." ]
python
train
47.508475
OpenTreeOfLife/peyotl
peyotl/phylo/tree.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L302-L345
def add_bits4subtree_ids(self, relevant_ids): """Adds a long integer bits4subtree_ids to each node (Fails cryptically if that field is already present!) relevant_ids can be a dict of _id to bit representation. If it is not supplied, a dict will be created by registering the leaf._id into a dict ...
[ "def", "add_bits4subtree_ids", "(", "self", ",", "relevant_ids", ")", ":", "if", "relevant_ids", ":", "checking", "=", "True", "else", ":", "checking", "=", "False", "relevant_ids", "=", "{", "}", "bit", "=", "1", "self", ".", "bits2internal_node", "=", "{...
Adds a long integer bits4subtree_ids to each node (Fails cryptically if that field is already present!) relevant_ids can be a dict of _id to bit representation. If it is not supplied, a dict will be created by registering the leaf._id into a dict (and returning the dict) the bits4subtree_ids wil...
[ "Adds", "a", "long", "integer", "bits4subtree_ids", "to", "each", "node", "(", "Fails", "cryptically", "if", "that", "field", "is", "already", "present!", ")", "relevant_ids", "can", "be", "a", "dict", "of", "_id", "to", "bit", "representation", ".", "If", ...
python
train
45.409091
gijzelaerr/python-snap7
snap7/client.py
https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/client.py#L165-L175
def delete(self, block_type, block_num): """ Deletes a block :param block_type: Type of block :param block_num: Bloc number """ logger.info("deleting block") blocktype = snap7.snap7types.block_types[block_type] result = self.library.Cli_Delete(sel...
[ "def", "delete", "(", "self", ",", "block_type", ",", "block_num", ")", ":", "logger", ".", "info", "(", "\"deleting block\"", ")", "blocktype", "=", "snap7", ".", "snap7types", ".", "block_types", "[", "block_type", "]", "result", "=", "self", ".", "libra...
Deletes a block :param block_type: Type of block :param block_num: Bloc number
[ "Deletes", "a", "block", ":", "param", "block_type", ":", "Type", "of", "block", ":", "param", "block_num", ":", "Bloc", "number" ]
python
train
33.090909
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_maps_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_maps_ext.py#L164-L176
def maps_get_rules_output_rules_policyname(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") maps_get_rules = ET.Element("maps_get_rules") config = maps_get_rules output = ET.SubElement(maps_get_rules, "output") rules = ET.SubElement(output...
[ "def", "maps_get_rules_output_rules_policyname", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "maps_get_rules", "=", "ET", ".", "Element", "(", "\"maps_get_rules\"", ")", "config", "=", "maps_get_...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
39.692308
clalancette/pycdlib
pycdlib/pycdlib.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L461-L491
def _assign_udf_desc_extents(descs, start_extent): # type: (PyCdlib._UDFDescriptors, int) -> None ''' An internal function to assign a consecutive sequence of extents for the given set of UDF Descriptors, starting at the given extent. Parameters: descs - The PyCdlib._UDFDescriptors object to a...
[ "def", "_assign_udf_desc_extents", "(", "descs", ",", "start_extent", ")", ":", "# type: (PyCdlib._UDFDescriptors, int) -> None", "current_extent", "=", "start_extent", "descs", ".", "pvd", ".", "set_extent_location", "(", "current_extent", ")", "current_extent", "+=", "1...
An internal function to assign a consecutive sequence of extents for the given set of UDF Descriptors, starting at the given extent. Parameters: descs - The PyCdlib._UDFDescriptors object to assign extents for. start_extent - The starting extent to assign from. Returns: Nothing.
[ "An", "internal", "function", "to", "assign", "a", "consecutive", "sequence", "of", "extents", "for", "the", "given", "set", "of", "UDF", "Descriptors", "starting", "at", "the", "given", "extent", "." ]
python
train
29.870968
hydraplatform/hydra-base
hydra_base/lib/attributes.py
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L240-L247
def get_attributes(**kwargs): """ Get all attributes """ attrs = db.DBSession.query(Attr).order_by(Attr.name).all() return attrs
[ "def", "get_attributes", "(", "*", "*", "kwargs", ")", ":", "attrs", "=", "db", ".", "DBSession", ".", "query", "(", "Attr", ")", ".", "order_by", "(", "Attr", ".", "name", ")", ".", "all", "(", ")", "return", "attrs" ]
Get all attributes
[ "Get", "all", "attributes" ]
python
train
18.375
mgedmin/check-manifest
check_manifest.py
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L774-L778
def file_matches(filename, patterns): """Does this filename match any of the patterns?""" return any(fnmatch.fnmatch(filename, pat) or fnmatch.fnmatch(os.path.basename(filename), pat) for pat in patterns)
[ "def", "file_matches", "(", "filename", ",", "patterns", ")", ":", "return", "any", "(", "fnmatch", ".", "fnmatch", "(", "filename", ",", "pat", ")", "or", "fnmatch", ".", "fnmatch", "(", "os", ".", "path", ".", "basename", "(", "filename", ")", ",", ...
Does this filename match any of the patterns?
[ "Does", "this", "filename", "match", "any", "of", "the", "patterns?" ]
python
train
47.6
CZ-NIC/yangson
yangson/statement.py
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/statement.py#L381-L393
def substatements(self) -> List[Statement]: """Parse substatements. Raises: EndOfInput: If past the end of input. """ res = [] self.opt_separator() while self.peek() != "}": res.append(self.statement()) self.opt_separator() sel...
[ "def", "substatements", "(", "self", ")", "->", "List", "[", "Statement", "]", ":", "res", "=", "[", "]", "self", ".", "opt_separator", "(", ")", "while", "self", ".", "peek", "(", ")", "!=", "\"}\"", ":", "res", ".", "append", "(", "self", ".", ...
Parse substatements. Raises: EndOfInput: If past the end of input.
[ "Parse", "substatements", "." ]
python
train
26.153846
PythonCharmers/python-future
src/future/types/newstr.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/types/newstr.py#L265-L273
def index(self, sub, *args): """ Like newstr.find() but raise ValueError when the substring is not found. """ pos = self.find(sub, *args) if pos == -1: raise ValueError('substring not found') return pos
[ "def", "index", "(", "self", ",", "sub", ",", "*", "args", ")", ":", "pos", "=", "self", ".", "find", "(", "sub", ",", "*", "args", ")", "if", "pos", "==", "-", "1", ":", "raise", "ValueError", "(", "'substring not found'", ")", "return", "pos" ]
Like newstr.find() but raise ValueError when the substring is not found.
[ "Like", "newstr", ".", "find", "()", "but", "raise", "ValueError", "when", "the", "substring", "is", "not", "found", "." ]
python
train
29.111111
ponty/confduino
confduino/boardremove.py
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardremove.py#L9-L20
def remove_board(board_id): """remove board. :param board_id: board id (e.g. 'diecimila') :rtype: None """ log.debug('remove %s', board_id) lines = boards_txt().lines() lines = filter(lambda x: not x.strip().startswith(board_id + '.'), lines) boards_txt().write_lines(lines)
[ "def", "remove_board", "(", "board_id", ")", ":", "log", ".", "debug", "(", "'remove %s'", ",", "board_id", ")", "lines", "=", "boards_txt", "(", ")", ".", "lines", "(", ")", "lines", "=", "filter", "(", "lambda", "x", ":", "not", "x", ".", "strip", ...
remove board. :param board_id: board id (e.g. 'diecimila') :rtype: None
[ "remove", "board", "." ]
python
train
24.833333
pgmpy/pgmpy
pgmpy/factors/discrete/DiscreteFactor.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/DiscreteFactor.py#L439-L525
def sum(self, phi1, inplace=True): """ DiscreteFactor sum with `phi1`. Parameters ---------- phi1: `DiscreteFactor` instance. DiscreteFactor to be added. inplace: boolean If inplace=True it will modify the factor itself, else would return ...
[ "def", "sum", "(", "self", ",", "phi1", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "if", "isinstance", "(", "phi1", ",", "(", "int", ",", "float", ")", ")", ":", "phi", "."...
DiscreteFactor sum with `phi1`. Parameters ---------- phi1: `DiscreteFactor` instance. DiscreteFactor to be added. inplace: boolean If inplace=True it will modify the factor itself, else would return a new factor. Returns ------- ...
[ "DiscreteFactor", "sum", "with", "phi1", "." ]
python
train
32.91954
RedFantom/ttkwidgets
ttkwidgets/color/colorpicker.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/color/colorpicker.py#L527-L534
def ok(self): """Validate color selection and destroy dialog.""" rgb, hsv, hexa = self.square.get() if self.alpha_channel: hexa = self.hexa.get() rgb += (self.alpha.get(),) self.color = rgb, hsv, hexa self.destroy()
[ "def", "ok", "(", "self", ")", ":", "rgb", ",", "hsv", ",", "hexa", "=", "self", ".", "square", ".", "get", "(", ")", "if", "self", ".", "alpha_channel", ":", "hexa", "=", "self", ".", "hexa", ".", "get", "(", ")", "rgb", "+=", "(", "self", "...
Validate color selection and destroy dialog.
[ "Validate", "color", "selection", "and", "destroy", "dialog", "." ]
python
train
34
ming060/robotframework-uiautomatorlibrary
uiautomatorlibrary/Mobile.py
https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L249-L253
def click_at_coordinates(self, x, y): """ Click at (x,y) coordinates. """ self.device.click(int(x), int(y))
[ "def", "click_at_coordinates", "(", "self", ",", "x", ",", "y", ")", ":", "self", ".", "device", ".", "click", "(", "int", "(", "x", ")", ",", "int", "(", "y", ")", ")" ]
Click at (x,y) coordinates.
[ "Click", "at", "(", "x", "y", ")", "coordinates", "." ]
python
train
27
allenai/allennlp
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L184-L198
def dataset_path_iterator(file_path: str) -> Iterator[str]: """ An iterator returning file_paths in a directory containing CONLL-formatted files. """ logger.info("Reading CONLL sentences from dataset files at: %s", file_path) for root, _, files in list(os.walk(file_path))...
[ "def", "dataset_path_iterator", "(", "file_path", ":", "str", ")", "->", "Iterator", "[", "str", "]", ":", "logger", ".", "info", "(", "\"Reading CONLL sentences from dataset files at: %s\"", ",", "file_path", ")", "for", "root", ",", "_", ",", "files", "in", ...
An iterator returning file_paths in a directory containing CONLL-formatted files.
[ "An", "iterator", "returning", "file_paths", "in", "a", "directory", "containing", "CONLL", "-", "formatted", "files", "." ]
python
train
48.066667
pybel/pybel
src/pybel/manager/cache_manager.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L1027-L1043
def get_or_create_author(self, name: str) -> Author: """Get an author by name, or creates one if it does not exist.""" author = self.object_cache_author.get(name) if author is not None: self.session.add(author) return author author = self.get_author_by_name(name...
[ "def", "get_or_create_author", "(", "self", ",", "name", ":", "str", ")", "->", "Author", ":", "author", "=", "self", ".", "object_cache_author", ".", "get", "(", "name", ")", "if", "author", "is", "not", "None", ":", "self", ".", "session", ".", "add"...
Get an author by name, or creates one if it does not exist.
[ "Get", "an", "author", "by", "name", "or", "creates", "one", "if", "it", "does", "not", "exist", "." ]
python
train
32.294118
xflows/rdm
rdm/db/converters.py
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L316-L326
def other_Orange_tables(self): ''' Returns the related tables as Orange example tables. :rtype: list ''' target_table = self.db.target_table if not self.db.orng_tables: return [self.convert_table(table, None) for table in self.db.tables if table != ta...
[ "def", "other_Orange_tables", "(", "self", ")", ":", "target_table", "=", "self", ".", "db", ".", "target_table", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "[", "self", ".", "convert_table", "(", "table", ",", "None", ")", "for",...
Returns the related tables as Orange example tables. :rtype: list
[ "Returns", "the", "related", "tables", "as", "Orange", "example", "tables", "." ]
python
train
39.909091
python-diamond/Diamond
src/collectors/dseopscenter/dseopscenter.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/dseopscenter/dseopscenter.py#L37-L111
def get_default_config(self): """ Returns the default collector settings """ config = super(DseOpsCenterCollector, self).get_default_config() metrics = [ 'cf-bf-false-positives', 'cf-bf-false-ratio', 'cf-bf-space-used', 'cf-keycache...
[ "def", "get_default_config", "(", "self", ")", ":", "config", "=", "super", "(", "DseOpsCenterCollector", ",", "self", ")", ".", "get_default_config", "(", ")", "metrics", "=", "[", "'cf-bf-false-positives'", ",", "'cf-bf-false-ratio'", ",", "'cf-bf-space-used'", ...
Returns the default collector settings
[ "Returns", "the", "default", "collector", "settings" ]
python
train
32.173333
google/flatbuffers
python/flatbuffers/builder.py
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L511-L518
def Slot(self, slotnum): """ Slot sets the vtable key `voffset` to the current location in the buffer. """ self.assertNested() self.current_vtable[slotnum] = self.Offset()
[ "def", "Slot", "(", "self", ",", "slotnum", ")", ":", "self", ".", "assertNested", "(", ")", "self", ".", "current_vtable", "[", "slotnum", "]", "=", "self", ".", "Offset", "(", ")" ]
Slot sets the vtable key `voffset` to the current location in the buffer.
[ "Slot", "sets", "the", "vtable", "key", "voffset", "to", "the", "current", "location", "in", "the", "buffer", "." ]
python
train
26.625
abourget/gevent-socketio
socketio/virtsocket.py
https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/virtsocket.py#L28-L53
def default_error_handler(socket, error_name, error_message, endpoint, msg_id, quiet): """This is the default error handler, you can override this when calling :func:`socketio.socketio_manage`. It basically sends an event through the socket with the 'error' name. See document...
[ "def", "default_error_handler", "(", "socket", ",", "error_name", ",", "error_message", ",", "endpoint", ",", "msg_id", ",", "quiet", ")", ":", "pkt", "=", "dict", "(", "type", "=", "'event'", ",", "name", "=", "'error'", ",", "args", "=", "[", "error_na...
This is the default error handler, you can override this when calling :func:`socketio.socketio_manage`. It basically sends an event through the socket with the 'error' name. See documentation for :meth:`Socket.error`. :param quiet: if quiet, this handler will not send a packet to the ...
[ "This", "is", "the", "default", "error", "handler", "you", "can", "override", "this", "when", "calling", ":", "func", ":", "socketio", ".", "socketio_manage", "." ]
python
valid
35.730769
dereneaton/ipyrad
ipyrad/analysis/bucky.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/bucky.py#L158-L264
def write_nexus_files(self, force=False, quiet=False): """ Write nexus files to {workdir}/{name}/[0-N].nex, If the directory already exists an exception will be raised unless you use the force flag which will remove all files in the directory. Parameters: ----------- ...
[ "def", "write_nexus_files", "(", "self", ",", "force", "=", "False", ",", "quiet", "=", "False", ")", ":", "## clear existing files ", "existing", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "workdir", ",", "self", ...
Write nexus files to {workdir}/{name}/[0-N].nex, If the directory already exists an exception will be raised unless you use the force flag which will remove all files in the directory. Parameters: ----------- force (bool): If True then all files in {workdir}/{name}...
[ "Write", "nexus", "files", "to", "{", "workdir", "}", "/", "{", "name", "}", "/", "[", "0", "-", "N", "]", ".", "nex", "If", "the", "directory", "already", "exists", "an", "exception", "will", "be", "raised", "unless", "you", "use", "the", "force", ...
python
valid
37.523364
ferhatelmas/sexmachine
sexmachine/detector.py
https://github.com/ferhatelmas/sexmachine/blob/85d33bb47ccc017676e69788750f116e391f52db/sexmachine/detector.py#L33-L40
def _parse(self, filename): """Opens data file and for each line, calls _eat_name_line""" self.names = {} with codecs.open(filename, encoding="iso8859-1") as f: for line in f: if any(map(lambda c: 128 < ord(c) < 160, line)): line = line.encode("iso...
[ "def", "_parse", "(", "self", ",", "filename", ")", ":", "self", ".", "names", "=", "{", "}", "with", "codecs", ".", "open", "(", "filename", ",", "encoding", "=", "\"iso8859-1\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "any", ...
Opens data file and for each line, calls _eat_name_line
[ "Opens", "data", "file", "and", "for", "each", "line", "calls", "_eat_name_line" ]
python
valid
49.25
MagicStack/asyncpg
asyncpg/connection.py
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1910-L1928
def _extract_stack(limit=10): """Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. """ frame = sys._getframe().f_back try: stack = traceback.StackSummary.extract( traceback.walk_stack(frame), lookup_lines=False) finally: ...
[ "def", "_extract_stack", "(", "limit", "=", "10", ")", ":", "frame", "=", "sys", ".", "_getframe", "(", ")", ".", "f_back", "try", ":", "stack", "=", "traceback", ".", "StackSummary", ".", "extract", "(", "traceback", ".", "walk_stack", "(", "frame", "...
Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode.
[ "Replacement", "for", "traceback", ".", "extract_stack", "()", "that", "only", "does", "the", "necessary", "work", "for", "asyncio", "debug", "mode", "." ]
python
train
28.368421
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L3114-L3206
def _all_recall_native_type(self, data, ptitem, prefix): """Checks if loaded data has the type it was stored in. If not converts it. :param data: Data item to be checked and converted :param ptitem: HDf5 Node or Leaf from where data was loaded :param prefix: Prefix for recalling the dat...
[ "def", "_all_recall_native_type", "(", "self", ",", "data", ",", "ptitem", ",", "prefix", ")", ":", "typestr", "=", "self", ".", "_all_get_from_attrs", "(", "ptitem", ",", "prefix", "+", "HDF5StorageService", ".", "SCALAR_TYPE", ")", "colltype", "=", "self", ...
Checks if loaded data has the type it was stored in. If not converts it. :param data: Data item to be checked and converted :param ptitem: HDf5 Node or Leaf from where data was loaded :param prefix: Prefix for recalling the data type from the hdf5 node attributes :return: ...
[ "Checks", "if", "loaded", "data", "has", "the", "type", "it", "was", "stored", "in", ".", "If", "not", "converts", "it", "." ]
python
test
43
UCL-INGI/INGInious
inginious/frontend/task_problems.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/task_problems.py#L220-L224
def show_input(self, template_helper, language, seed): """ Show MatchProblem """ header = ParsableText(self.gettext(language, self._header), "rst", translation=self._translations.get(language, gettext.NullTranslations())) return str(DisplayableMatchProblem.get_rende...
[ "def", "show_input", "(", "self", ",", "template_helper", ",", "language", ",", "seed", ")", ":", "header", "=", "ParsableText", "(", "self", ".", "gettext", "(", "language", ",", "self", ".", "_header", ")", ",", "\"rst\"", ",", "translation", "=", "sel...
Show MatchProblem
[ "Show", "MatchProblem" ]
python
train
74.4
CityOfZion/neo-python
neo/Wallets/Wallet.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/Wallet.py#L835-L862
def ToScriptHash(self, address): """ Retrieve the script_hash based from an address. Args: address (str): a base58 encoded address. Raises: ValuesError: if an invalid address is supplied or the coin version is incorrect Exception: if the address stri...
[ "def", "ToScriptHash", "(", "self", ",", "address", ")", ":", "if", "len", "(", "address", ")", "==", "34", ":", "if", "address", "[", "0", "]", "==", "'A'", ":", "data", "=", "b58decode", "(", "address", ")", "if", "data", "[", "0", "]", "!=", ...
Retrieve the script_hash based from an address. Args: address (str): a base58 encoded address. Raises: ValuesError: if an invalid address is supplied or the coin version is incorrect Exception: if the address string does not start with 'A' or the checksum fails ...
[ "Retrieve", "the", "script_hash", "based", "from", "an", "address", "." ]
python
train
35.75
ponty/eagexp
eagexp/partlist.py
https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/partlist.py#L104-L112
def print_partlist(input, timeout=20, showgui=False): '''print partlist text delivered by eagle :param input: .sch or .brd file name :param timeout: int :param showgui: Bool, True -> do not hide eagle GUI :rtype: None ''' print raw_partlist(input=input, timeout=timeout, showgui=showgui)
[ "def", "print_partlist", "(", "input", ",", "timeout", "=", "20", ",", "showgui", "=", "False", ")", ":", "print", "raw_partlist", "(", "input", "=", "input", ",", "timeout", "=", "timeout", ",", "showgui", "=", "showgui", ")" ]
print partlist text delivered by eagle :param input: .sch or .brd file name :param timeout: int :param showgui: Bool, True -> do not hide eagle GUI :rtype: None
[ "print", "partlist", "text", "delivered", "by", "eagle" ]
python
train
34.222222
nicolargo/glances
glances/plugins/glances_irq.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L142-L149
def __header(self, line): """Build the header (contain the number of CPU). CPU0 CPU1 CPU2 CPU3 0: 21 0 0 0 IO-APIC 2-edge timer """ self.cpu_number = len(line.split()) return self.cpu_number
[ "def", "__header", "(", "self", ",", "line", ")", ":", "self", ".", "cpu_number", "=", "len", "(", "line", ".", "split", "(", ")", ")", "return", "self", ".", "cpu_number" ]
Build the header (contain the number of CPU). CPU0 CPU1 CPU2 CPU3 0: 21 0 0 0 IO-APIC 2-edge timer
[ "Build", "the", "header", "(", "contain", "the", "number", "of", "CPU", ")", "." ]
python
train
36.75
twisted/axiom
axiom/_fincache.py
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L89-L114
def cache(self, key, value): """ Add an entry to the cache. A weakref to the value is stored, rather than a direct reference. The value must have a C{__finalizer__} method that returns a callable which will be invoked when the weakref is broken. @param key: The key iden...
[ "def", "cache", "(", "self", ",", "key", ",", "value", ")", ":", "fin", "=", "value", ".", "__finalizer__", "(", ")", "try", ":", "# It's okay if there's already a cache entry for this key as long", "# as the weakref has already been broken. See the comment in", "# get() fo...
Add an entry to the cache. A weakref to the value is stored, rather than a direct reference. The value must have a C{__finalizer__} method that returns a callable which will be invoked when the weakref is broken. @param key: The key identifying the cache entry. @param value: T...
[ "Add", "an", "entry", "to", "the", "cache", "." ]
python
train
39.730769
GibbsConsulting/django-plotly-dash
demo/demo/plotly_apps.py
https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L149-L188
def callback_liveIn_button_press(red_clicks, blue_clicks, green_clicks, rc_timestamp, bc_timestamp, gc_timestamp, **kwargs): # pylint: disable=unused-argument 'Input app button pressed, so do something interesting' if not rc_timestamp: rc_timestamp = 0 if not bc_tim...
[ "def", "callback_liveIn_button_press", "(", "red_clicks", ",", "blue_clicks", ",", "green_clicks", ",", "rc_timestamp", ",", "bc_timestamp", ",", "gc_timestamp", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-argument", "if", "not", "rc_timestamp", ":", ...
Input app button pressed, so do something interesting
[ "Input", "app", "button", "pressed", "so", "do", "something", "interesting" ]
python
train
41.75
apache/incubator-mxnet
python/mxnet/io/io.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L100-L112
def get_list(shapes, types): """Get DataDesc list from attribute lists. Parameters ---------- shapes : a tuple of (name_, shape_) types : a tuple of (name_, np.dtype) """ if types is not None: type_dict = dict(types) return [DataDesc(x[0]...
[ "def", "get_list", "(", "shapes", ",", "types", ")", ":", "if", "types", "is", "not", "None", ":", "type_dict", "=", "dict", "(", "types", ")", "return", "[", "DataDesc", "(", "x", "[", "0", "]", ",", "x", "[", "1", "]", ",", "type_dict", "[", ...
Get DataDesc list from attribute lists. Parameters ---------- shapes : a tuple of (name_, shape_) types : a tuple of (name_, np.dtype)
[ "Get", "DataDesc", "list", "from", "attribute", "lists", "." ]
python
train
32.384615
lorehov/mongolock
src/mongolock.py
https://github.com/lorehov/mongolock/blob/218c9dfacdc8de04616c0d141a5701c9217a9069/src/mongolock.py#L86-L95
def release(self, key, owner): """Release lock with given name. `key` - lock name `owner` - name of application/component/whatever which held a lock Raises `MongoLockException` if no such a lock. """ status = self.collection.find_and_modify( {'_id': key, '...
[ "def", "release", "(", "self", ",", "key", ",", "owner", ")", ":", "status", "=", "self", ".", "collection", ".", "find_and_modify", "(", "{", "'_id'", ":", "key", ",", "'owner'", ":", "owner", "}", ",", "{", "'locked'", ":", "False", ",", "'owner'",...
Release lock with given name. `key` - lock name `owner` - name of application/component/whatever which held a lock Raises `MongoLockException` if no such a lock.
[ "Release", "lock", "with", "given", "name", ".", "key", "-", "lock", "name", "owner", "-", "name", "of", "application", "/", "component", "/", "whatever", "which", "held", "a", "lock", "Raises", "MongoLockException", "if", "no", "such", "a", "lock", "." ]
python
train
41.4
YosaiProject/yosai
yosai/core/realm/realm.py
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/realm/realm.py#L377-L404
def is_permitted(self, identifiers, permission_s): """ If the authorization info cannot be obtained from the accountstore, permission check tuple yields False. :type identifiers: subject_abcs.IdentifierCollection :param permission_s: a collection of one or more permissions, re...
[ "def", "is_permitted", "(", "self", ",", "identifiers", ",", "permission_s", ")", ":", "identifier", "=", "identifiers", ".", "primary_identifier", "for", "required", "in", "permission_s", ":", "domain", "=", "Permission", ".", "get_domain", "(", "required", ")"...
If the authorization info cannot be obtained from the accountstore, permission check tuple yields False. :type identifiers: subject_abcs.IdentifierCollection :param permission_s: a collection of one or more permissions, represented as string-based permissions or P...
[ "If", "the", "authorization", "info", "cannot", "be", "obtained", "from", "the", "accountstore", "permission", "check", "tuple", "yields", "False", "." ]
python
train
37.285714
seomoz/shovel
shovel/tasks.py
https://github.com/seomoz/shovel/blob/fc29232b2b8be33972f8fb498a91a67e334f057f/shovel/tasks.py#L275-L278
def dry(self, *args, **kwargs): '''Perform a dry-run of the task''' return 'Would have executed:\n%s%s' % ( self.name, Args(self.spec).explain(*args, **kwargs))
[ "def", "dry", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "'Would have executed:\\n%s%s'", "%", "(", "self", ".", "name", ",", "Args", "(", "self", ".", "spec", ")", ".", "explain", "(", "*", "args", ",", "*", "*", ...
Perform a dry-run of the task
[ "Perform", "a", "dry", "-", "run", "of", "the", "task" ]
python
train
46.25
spacetelescope/stsci.tools
lib/stsci/tools/configobj.py
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L2337-L2345
def reset(self): """Clear ConfigObj instance and restore to 'freshly created' state.""" self.clear() self._initialise() # FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload) # requires an empty dictionary self.configspec = None # ...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "_initialise", "(", ")", "# FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)", "# requires an empty dictionary", "self", ".", "configspec", "=", "None"...
Clear ConfigObj instance and restore to 'freshly created' state.
[ "Clear", "ConfigObj", "instance", "and", "restore", "to", "freshly", "created", "state", "." ]
python
train
41.333333
log2timeline/dfvfs
dfvfs/vfs/os_file_system.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/os_file_system.py#L106-L125
def GetRootFileEntry(self): """Retrieves the root file entry. Returns: OSFileEntry: a file entry or None if not available. """ if platform.system() == 'Windows': # Return the root with the drive letter of the volume the current # working directory is on. location = os.getcwd() ...
[ "def", "GetRootFileEntry", "(", "self", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "# Return the root with the drive letter of the volume the current", "# working directory is on.", "location", "=", "os", ".", "getcwd", "(", ")", "loc...
Retrieves the root file entry. Returns: OSFileEntry: a file entry or None if not available.
[ "Retrieves", "the", "root", "file", "entry", "." ]
python
train
29.4
openstack/networking-arista
networking_arista/ml2/security_groups/switch_helper.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L316-L318
def get_delete_security_group_rule_commands(self, sg_id, sg_rule): """Commands for removing rule from ACLS""" return self._get_rule_cmds(sg_id, sg_rule, delete=True)
[ "def", "get_delete_security_group_rule_commands", "(", "self", ",", "sg_id", ",", "sg_rule", ")", ":", "return", "self", ".", "_get_rule_cmds", "(", "sg_id", ",", "sg_rule", ",", "delete", "=", "True", ")" ]
Commands for removing rule from ACLS
[ "Commands", "for", "removing", "rule", "from", "ACLS" ]
python
train
59.666667
mental32/spotify.py
spotify/http.py
https://github.com/mental32/spotify.py/blob/bb296cac7c3dd289908906b7069bd80f43950515/spotify/http.py#L297-L307
def artists(self, spotify_ids): """Get a spotify artists by their IDs. Parameters ---------- spotify_id : List[str] The spotify_ids to search with. """ route = Route('GET', '/artists') payload = {'ids': spotify_ids} return self.request(route, ...
[ "def", "artists", "(", "self", ",", "spotify_ids", ")", ":", "route", "=", "Route", "(", "'GET'", ",", "'/artists'", ")", "payload", "=", "{", "'ids'", ":", "spotify_ids", "}", "return", "self", ".", "request", "(", "route", ",", "params", "=", "payloa...
Get a spotify artists by their IDs. Parameters ---------- spotify_id : List[str] The spotify_ids to search with.
[ "Get", "a", "spotify", "artists", "by", "their", "IDs", "." ]
python
test
29.545455
helixyte/everest
everest/representers/dataelements.py
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/dataelements.py#L256-L268
def get_terminal_converted(self, attr): """ Returns the value of the specified attribute converted to a representation value. :param attr: Attribute to retrieve. :type attr: :class:`everest.representers.attributes.MappedAttribute` :returns: Representation string. ...
[ "def", "get_terminal_converted", "(", "self", ",", "attr", ")", ":", "value", "=", "self", ".", "data", ".", "get", "(", "attr", ".", "repr_name", ")", "return", "self", ".", "converter_registry", ".", "convert_to_representation", "(", "value", ",", "attr", ...
Returns the value of the specified attribute converted to a representation value. :param attr: Attribute to retrieve. :type attr: :class:`everest.representers.attributes.MappedAttribute` :returns: Representation string.
[ "Returns", "the", "value", "of", "the", "specified", "attribute", "converted", "to", "a", "representation", "value", "." ]
python
train
43.692308
getgauge/gauge-python
getgauge/parser_redbaron.py
https://github.com/getgauge/gauge-python/blob/90f3547dcfd2d16d51f116cdd4e53527eeab1a57/getgauge/parser_redbaron.py#L82-L87
def iter_steps(self): """Iterate over steps in the parsed file.""" for func, decorator in self._iter_step_func_decorators(): step = self._step_decorator_args(decorator) if step: yield step, func.name, self._span_for_node(func, True)
[ "def", "iter_steps", "(", "self", ")", ":", "for", "func", ",", "decorator", "in", "self", ".", "_iter_step_func_decorators", "(", ")", ":", "step", "=", "self", ".", "_step_decorator_args", "(", "decorator", ")", "if", "step", ":", "yield", "step", ",", ...
Iterate over steps in the parsed file.
[ "Iterate", "over", "steps", "in", "the", "parsed", "file", "." ]
python
test
47.166667
MKLab-ITI/reveal-user-annotation
reveal_user_annotation/twitter/manage_resources.py
https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/manage_resources.py#L107-L122
def get_topic_keyword_dictionary(): """ Opens the topic-keyword map resource file and returns the corresponding python dictionary. - Input: - file_path: The path pointing to the topic-keyword map resource file. - Output: - topic_set: A topic to keyword python dictionary. """ topic_keyword_dic...
[ "def", "get_topic_keyword_dictionary", "(", ")", ":", "topic_keyword_dictionary", "=", "dict", "(", ")", "file_row_gen", "=", "get_file_row_generator", "(", "get_package_path", "(", ")", "+", "\"/twitter/res/topics/topic_keyword_mapping\"", "+", "\".txt\"", ",", "\",\"", ...
Opens the topic-keyword map resource file and returns the corresponding python dictionary. - Input: - file_path: The path pointing to the topic-keyword map resource file. - Output: - topic_set: A topic to keyword python dictionary.
[ "Opens", "the", "topic", "-", "keyword", "map", "resource", "file", "and", "returns", "the", "corresponding", "python", "dictionary", "." ]
python
train
43.625
tensorflow/tensor2tensor
tensor2tensor/models/research/transformer_nat.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_nat.py#L51-L69
def vq_nearest_neighbor(x, hparams): """Find the nearest element in means to elements in x.""" bottleneck_size = 2**hparams.bottleneck_bits means = hparams.means x_norm_sq = tf.reduce_sum(tf.square(x), axis=-1, keepdims=True) means_norm_sq = tf.reduce_sum(tf.square(means), axis=-1, keepdims=True) scalar_pro...
[ "def", "vq_nearest_neighbor", "(", "x", ",", "hparams", ")", ":", "bottleneck_size", "=", "2", "**", "hparams", ".", "bottleneck_bits", "means", "=", "hparams", ".", "means", "x_norm_sq", "=", "tf", ".", "reduce_sum", "(", "tf", ".", "square", "(", "x", ...
Find the nearest element in means to elements in x.
[ "Find", "the", "nearest", "element", "in", "means", "to", "elements", "in", "x", "." ]
python
train
48.210526
ranaroussi/qtpylib
qtpylib/instrument.py
https://github.com/ranaroussi/qtpylib/blob/0dbbc465fafd9cb9b0f4d10e1e07fae4e15032dd/qtpylib/instrument.py#L278-L288
def buy_market(self, quantity, **kwargs): """ Shortcut for ``instrument.order("BUY", ...)`` and accepts all of its `optional parameters <#qtpylib.instrument.Instrument.order>`_ :Parameters: quantity : int Order quantity """ kwargs['limit_price'] = 0 ...
[ "def", "buy_market", "(", "self", ",", "quantity", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'limit_price'", "]", "=", "0", "kwargs", "[", "'order_type'", "]", "=", "\"MARKET\"", "self", ".", "parent", ".", "order", "(", "\"BUY\"", ",", "self"...
Shortcut for ``instrument.order("BUY", ...)`` and accepts all of its `optional parameters <#qtpylib.instrument.Instrument.order>`_ :Parameters: quantity : int Order quantity
[ "Shortcut", "for", "instrument", ".", "order", "(", "BUY", "...", ")", "and", "accepts", "all", "of", "its", "optional", "parameters", "<#qtpylib", ".", "instrument", ".", "Instrument", ".", "order", ">", "_" ]
python
train
37.818182
devassistant/devassistant
devassistant/dapi/dapicli.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L322-L334
def _get_assistants_snippets(path, name): '''Get Assistants and Snippets for a given DAP name on a given path''' result = [] subdirs = {'assistants': 2, 'snippets': 1} # Values used for stripping leading path tokens for loc in subdirs: for root, dirs, files in os.walk(os.path.join(path, loc)): ...
[ "def", "_get_assistants_snippets", "(", "path", ",", "name", ")", ":", "result", "=", "[", "]", "subdirs", "=", "{", "'assistants'", ":", "2", ",", "'snippets'", ":", "1", "}", "# Values used for stripping leading path tokens", "for", "loc", "in", "subdirs", "...
Get Assistants and Snippets for a given DAP name on a given path
[ "Get", "Assistants", "and", "Snippets", "for", "a", "given", "DAP", "name", "on", "a", "given", "path" ]
python
train
51.692308
pypa/pipenv
pipenv/vendor/yaspin/core.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/yaspin/core.py#L278-L292
def write(self, text): """Write text in the terminal without breaking the spinner.""" # similar to tqdm.write() # https://pypi.python.org/pypi/tqdm#writing-messages sys.stdout.write("\r") self._clear_line() _text = to_unicode(text) if PY2: _text = _te...
[ "def", "write", "(", "self", ",", "text", ")", ":", "# similar to tqdm.write()", "# https://pypi.python.org/pypi/tqdm#writing-messages", "sys", ".", "stdout", ".", "write", "(", "\"\\r\"", ")", "self", ".", "_clear_line", "(", ")", "_text", "=", "to_unicode", "(",...
Write text in the terminal without breaking the spinner.
[ "Write", "text", "in", "the", "terminal", "without", "breaking", "the", "spinner", "." ]
python
train
32.133333
ambitioninc/django-query-builder
querybuilder/query.py
https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1267-L1307
def format_sql(self): """ Builds the sql in a format that is easy for humans to read and debug :return: The formatted sql for this query :rtype: str """ # TODO: finish adding the other parts of the sql generation sql = '' # build SELECT select_se...
[ "def", "format_sql", "(", "self", ")", ":", "# TODO: finish adding the other parts of the sql generation", "sql", "=", "''", "# build SELECT", "select_segment", "=", "self", ".", "build_select_fields", "(", ")", "select_segment", "=", "select_segment", ".", "replace", "...
Builds the sql in a format that is easy for humans to read and debug :return: The formatted sql for this query :rtype: str
[ "Builds", "the", "sql", "in", "a", "format", "that", "is", "easy", "for", "humans", "to", "read", "and", "debug" ]
python
train
39.97561
joowani/quadriga
quadriga/book.py
https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/book.py#L120-L133
def buy_market_order(self, amount): """Place a buy order at market price. :param amount: Amount of major currency to buy at market price. :type amount: int | float | str | unicode | decimal.Decimal :return: Order details. :rtype: dict """ amount = str(amount) ...
[ "def", "buy_market_order", "(", "self", ",", "amount", ")", ":", "amount", "=", "str", "(", "amount", ")", "self", ".", "_log", "(", "\"buy {} {} at market price\"", ".", "format", "(", "amount", ",", "self", ".", "major", ")", ")", "return", "self", "."...
Place a buy order at market price. :param amount: Amount of major currency to buy at market price. :type amount: int | float | str | unicode | decimal.Decimal :return: Order details. :rtype: dict
[ "Place", "a", "buy", "order", "at", "market", "price", "." ]
python
train
36.642857
andreikop/qutepart
qutepart/__init__.py
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L350-L416
def _initActions(self): """Init shortcuts for text editing """ def createAction(text, shortcut, slot, iconFileName=None): """Create QAction with given parameters and add to the widget """ action = QAction(text, self) if iconFileName is not None: ...
[ "def", "_initActions", "(", "self", ")", ":", "def", "createAction", "(", "text", ",", "shortcut", ",", "slot", ",", "iconFileName", "=", "None", ")", ":", "\"\"\"Create QAction with given parameters and add to the widget\n \"\"\"", "action", "=", "QAction", ...
Init shortcuts for text editing
[ "Init", "shortcuts", "for", "text", "editing" ]
python
train
60.970149
bunq/sdk_python
bunq/sdk/model/generated/object_.py
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/object_.py#L301-L333
def is_all_field_none(self): """ :rtype: bool """ if self._billing_date is not None: return False if self._type_description is not None: return False if self._type_description_translated is not None: return False if self._un...
[ "def", "is_all_field_none", "(", "self", ")", ":", "if", "self", ".", "_billing_date", "is", "not", "None", ":", "return", "False", "if", "self", ".", "_type_description", "is", "not", "None", ":", "return", "False", "if", "self", ".", "_type_description_tra...
:rtype: bool
[ ":", "rtype", ":", "bool" ]
python
train
21.666667
CitrineInformatics/python-citrination-client
citrination_client/models/columns/base.py
https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/models/columns/base.py#L33-L49
def to_dict(self): """ Converts the column to a dictionary representation accepted by the Citrination server. :return: Dictionary with basic options, plus any column type specific options held under the "options" key :rtype: dict """ return { ...
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "\"type\"", ":", "self", ".", "type", ",", "\"name\"", ":", "self", ".", "name", ",", "\"group_by_key\"", ":", "self", ".", "group_by_key", ",", "\"role\"", ":", "self", ".", "role", ",", "\"units...
Converts the column to a dictionary representation accepted by the Citrination server. :return: Dictionary with basic options, plus any column type specific options held under the "options" key :rtype: dict
[ "Converts", "the", "column", "to", "a", "dictionary", "representation", "accepted", "by", "the", "Citrination", "server", "." ]
python
valid
30.705882
aparo/pyes
pyes/orm/queryset.py
https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/orm/queryset.py#L567-L585
def _cooked_fields(self, dj_fields): """ Returns a tuple of cooked fields :param dj_fields: a list of django name fields :return: """ from django.db import models valids = [] for field in dj_fields: try: dj_field, _, _, _ = sel...
[ "def", "_cooked_fields", "(", "self", ",", "dj_fields", ")", ":", "from", "django", ".", "db", "import", "models", "valids", "=", "[", "]", "for", "field", "in", "dj_fields", ":", "try", ":", "dj_field", ",", "_", ",", "_", ",", "_", "=", "self", "...
Returns a tuple of cooked fields :param dj_fields: a list of django name fields :return:
[ "Returns", "a", "tuple", "of", "cooked", "fields", ":", "param", "dj_fields", ":", "a", "list", "of", "django", "name", "fields", ":", "return", ":" ]
python
train
35.210526
openearth/mmi-python
mmi/runner.py
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/runner.py#L155-L160
def unregister(self): """unregister model at tracking server""" uuid = self.metadata["tracker"]["uuid"] # connect to server result = requests.delete(urljoin(self.tracker, 'models' + "/" + uuid)) logger.debug("unregistered at server %s with %s: %s", self.tracker, uuid, result)
[ "def", "unregister", "(", "self", ")", ":", "uuid", "=", "self", ".", "metadata", "[", "\"tracker\"", "]", "[", "\"uuid\"", "]", "# connect to server", "result", "=", "requests", ".", "delete", "(", "urljoin", "(", "self", ".", "tracker", ",", "'models'", ...
unregister model at tracking server
[ "unregister", "model", "at", "tracking", "server" ]
python
train
51.833333
pandas-dev/pandas
pandas/core/sparse/series.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L268-L284
def _ixs(self, i, axis=0): """ Return the i-th value or values in the SparseSeries by location Parameters ---------- i : int, slice, or sequence of integers Returns ------- value : scalar (int) or Series (slice, sequence) """ label = self...
[ "def", "_ixs", "(", "self", ",", "i", ",", "axis", "=", "0", ")", ":", "label", "=", "self", ".", "index", "[", "i", "]", "if", "isinstance", "(", "label", ",", "Index", ")", ":", "return", "self", ".", "take", "(", "i", ",", "axis", "=", "ax...
Return the i-th value or values in the SparseSeries by location Parameters ---------- i : int, slice, or sequence of integers Returns ------- value : scalar (int) or Series (slice, sequence)
[ "Return", "the", "i", "-", "th", "value", "or", "values", "in", "the", "SparseSeries", "by", "location" ]
python
train
26.235294
biolink/ontobio
ontobio/assoc_factory.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/assoc_factory.py#L104-L127
def create_from_assocs(self, assocs, **args): """ Creates from a list of association objects """ amap = defaultdict(list) subject_label_map = {} for a in assocs: subj = a['subject'] subj_id = subj['id'] subj_label = subj['label'] ...
[ "def", "create_from_assocs", "(", "self", ",", "assocs", ",", "*", "*", "args", ")", ":", "amap", "=", "defaultdict", "(", "list", ")", "subject_label_map", "=", "{", "}", "for", "a", "in", "assocs", ":", "subj", "=", "a", "[", "'subject'", "]", "sub...
Creates from a list of association objects
[ "Creates", "from", "a", "list", "of", "association", "objects" ]
python
train
37.125
cltrudeau/wrench
wrench/logtools/utils.py
https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/logtools/utils.py#L19-L29
def configure_file_logger(name, log_dir, log_level=logging.DEBUG): """Configures logging to use the :class:`SizeRotatingFileHandler`""" from .srothandler import SizeRotatingFileHandler root = logging.getLogger() root.setLevel(log_level) handler = SizeRotatingFileHandler(os.path.join(log_dir, '%s.lo...
[ "def", "configure_file_logger", "(", "name", ",", "log_dir", ",", "log_level", "=", "logging", ".", "DEBUG", ")", ":", "from", ".", "srothandler", "import", "SizeRotatingFileHandler", "root", "=", "logging", ".", "getLogger", "(", ")", "root", ".", "setLevel",...
Configures logging to use the :class:`SizeRotatingFileHandler`
[ "Configures", "logging", "to", "use", "the", ":", "class", ":", "SizeRotatingFileHandler" ]
python
train
40.727273
schapman1974/tinymongo
tinymongo/tinymongo.py
https://github.com/schapman1974/tinymongo/blob/993048059dc0aa789d879b69feb79a0f237a60b3/tinymongo/tinymongo.py#L177-L207
def insert_one(self, doc, *args, **kwargs): """ Inserts one document into the collection If contains '_id' key it is used, else it is generated. :param doc: the document :return: InsertOneResult """ if self.table is None: self.build_table() if...
[ "def", "insert_one", "(", "self", ",", "doc", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "table", "is", "None", ":", "self", ".", "build_table", "(", ")", "if", "not", "isinstance", "(", "doc", ",", "dict", ")", ":", ...
Inserts one document into the collection If contains '_id' key it is used, else it is generated. :param doc: the document :return: InsertOneResult
[ "Inserts", "one", "document", "into", "the", "collection", "If", "contains", "_id", "key", "it", "is", "used", "else", "it", "is", "generated", ".", ":", "param", "doc", ":", "the", "document", ":", "return", ":", "InsertOneResult" ]
python
train
34.806452
mitsei/dlkit
dlkit/json_/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/managers.py#L941-L956
def get_composition_admin_session(self): """Gets a composition administration session for creating, updating and deleting compositions. return: (osid.repository.CompositionAdminSession) - a ``CompositionAdminSession`` raise: OperationFailed - unable to complete request ...
[ "def", "get_composition_admin_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_composition_admin", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "CompositionAdminSession"...
Gets a composition administration session for creating, updating and deleting compositions. return: (osid.repository.CompositionAdminSession) - a ``CompositionAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_composition_admin...
[ "Gets", "a", "composition", "administration", "session", "for", "creating", "updating", "and", "deleting", "compositions", "." ]
python
train
45.25
goose3/goose3
goose3/text.py
https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/text.py#L35-L60
def get_encodings_from_content(content): """ Code from: https://github.com/sigmavirus24/requests-toolbelt/blob/master/requests_toolbelt/utils/deprecated.py Return encodings from given content string. :param content: string to extract encodings from. """ if isinstance(content, bytes): ...
[ "def", "get_encodings_from_content", "(", "content", ")", ":", "if", "isinstance", "(", "content", ",", "bytes", ")", ":", "find_charset", "=", "re", ".", "compile", "(", "br'<meta.*?charset=[\"\\']*([a-z0-9\\-_]+?) *?[\"\\'>]'", ",", "flags", "=", "re", ".", "I",...
Code from: https://github.com/sigmavirus24/requests-toolbelt/blob/master/requests_toolbelt/utils/deprecated.py Return encodings from given content string. :param content: string to extract encodings from.
[ "Code", "from", ":", "https", ":", "//", "github", ".", "com", "/", "sigmavirus24", "/", "requests", "-", "toolbelt", "/", "blob", "/", "master", "/", "requests_toolbelt", "/", "utils", "/", "deprecated", ".", "py", "Return", "encodings", "from", "given", ...
python
valid
36.769231
hollenstein/maspy
maspy/xml.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/xml.py#L129-L144
def recCopyElement(oldelement): """Generates a copy of an xml element and recursively of all child elements. :param oldelement: an instance of lxml.etree._Element :returns: a copy of the "oldelement" .. warning:: doesn't copy ``.text`` or ``.tail`` of xml elements """ newelement =...
[ "def", "recCopyElement", "(", "oldelement", ")", ":", "newelement", "=", "ETREE", ".", "Element", "(", "oldelement", ".", "tag", ",", "oldelement", ".", "attrib", ")", "if", "len", "(", "oldelement", ".", "getchildren", "(", ")", ")", ">", "0", ":", "f...
Generates a copy of an xml element and recursively of all child elements. :param oldelement: an instance of lxml.etree._Element :returns: a copy of the "oldelement" .. warning:: doesn't copy ``.text`` or ``.tail`` of xml elements
[ "Generates", "a", "copy", "of", "an", "xml", "element", "and", "recursively", "of", "all", "child", "elements", "." ]
python
train
33.25
majuss/lupupy
lupupy/devices/alarm.py
https://github.com/majuss/lupupy/blob/71af6c397837ffc393c7b8122be175602638d3c6/lupupy/devices/alarm.py#L24-L37
def set_mode(self, mode): """Set Lupusec alarm mode.""" _LOGGER.debug('State change called from alarm device') if not mode: _LOGGER.info('No mode supplied') elif mode not in CONST.ALL_MODES: _LOGGER.warning('Invalid mode') response_object = self._lupusec.s...
[ "def", "set_mode", "(", "self", ",", "mode", ")", ":", "_LOGGER", ".", "debug", "(", "'State change called from alarm device'", ")", "if", "not", "mode", ":", "_LOGGER", ".", "info", "(", "'No mode supplied'", ")", "elif", "mode", "not", "in", "CONST", ".", ...
Set Lupusec alarm mode.
[ "Set", "Lupusec", "alarm", "mode", "." ]
python
train
39.357143
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_mode.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_mode.py#L41-L48
def unknown_command(self, args): '''handle mode switch by mode name as command''' mode_mapping = self.master.mode_mapping() mode = args[0].upper() if mode in mode_mapping: self.master.set_mode(mode_mapping[mode]) return True return False
[ "def", "unknown_command", "(", "self", ",", "args", ")", ":", "mode_mapping", "=", "self", ".", "master", ".", "mode_mapping", "(", ")", "mode", "=", "args", "[", "0", "]", ".", "upper", "(", ")", "if", "mode", "in", "mode_mapping", ":", "self", ".",...
handle mode switch by mode name as command
[ "handle", "mode", "switch", "by", "mode", "name", "as", "command" ]
python
train
36.75
hydpy-dev/hydpy
hydpy/core/importtools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/importtools.py#L25-L92
def parameterstep(timestep=None): """Define a parameter time step size within a parameter control file. Argument: * timestep(|Period|): Time step size. Function parameterstep should usually be be applied in a line immediately behind the model import. Defining the step size of time dependent...
[ "def", "parameterstep", "(", "timestep", "=", "None", ")", ":", "if", "timestep", "is", "not", "None", ":", "parametertools", ".", "Parameter", ".", "parameterstep", "(", "timestep", ")", "namespace", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_...
Define a parameter time step size within a parameter control file. Argument: * timestep(|Period|): Time step size. Function parameterstep should usually be be applied in a line immediately behind the model import. Defining the step size of time dependent parameters is a prerequisite to access a...
[ "Define", "a", "parameter", "time", "step", "size", "within", "a", "parameter", "control", "file", "." ]
python
train
45.294118
horazont/aioxmpp
aioxmpp/rsm/xso.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/rsm/xso.py#L274-L286
def last_page(self_or_cls, max_=None): """ Return a query set which requests the last page. :param max_: Maximum number of items to return. :type max_: :class:`int` or :data:`None` :rtype: :class:`ResultSetMetadata` :return: A new request set up to request the last page....
[ "def", "last_page", "(", "self_or_cls", ",", "max_", "=", "None", ")", ":", "result", "=", "self_or_cls", "(", ")", "result", ".", "before", "=", "Before", "(", ")", "result", ".", "max_", "=", "max_", "return", "result" ]
Return a query set which requests the last page. :param max_: Maximum number of items to return. :type max_: :class:`int` or :data:`None` :rtype: :class:`ResultSetMetadata` :return: A new request set up to request the last page.
[ "Return", "a", "query", "set", "which", "requests", "the", "last", "page", "." ]
python
train
33.307692
delph-in/pydelphin
delphin/itsdb.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L2019-L2039
def read_raw_table(self, table): """ Yield rows in the [incr tsdb()] *table*. A row is a dictionary mapping column names to values. Data from a profile is decoded by decode_row(). No filters or applicators are used. """ fields = self.table_relations(table) if self.cast el...
[ "def", "read_raw_table", "(", "self", ",", "table", ")", ":", "fields", "=", "self", ".", "table_relations", "(", "table", ")", "if", "self", ".", "cast", "else", "None", "field_names", "=", "[", "f", ".", "name", "for", "f", "in", "self", ".", "tabl...
Yield rows in the [incr tsdb()] *table*. A row is a dictionary mapping column names to values. Data from a profile is decoded by decode_row(). No filters or applicators are used.
[ "Yield", "rows", "in", "the", "[", "incr", "tsdb", "()", "]", "*", "table", "*", ".", "A", "row", "is", "a", "dictionary", "mapping", "column", "names", "to", "values", ".", "Data", "from", "a", "profile", "is", "decoded", "by", "decode_row", "()", "...
python
train
50.666667
asweigart/pyautogui
pyautogui/_pyautogui_win.py
https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L451-L479
def _click(x, y, button): """Send the mouse click event to Windows by calling the mouse_event() win32 function. Args: button (str): The mouse button, either 'left', 'middle', or 'right' x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: ...
[ "def", "_click", "(", "x", ",", "y", ",", "button", ")", ":", "if", "button", "==", "'left'", ":", "try", ":", "_sendMouseEvent", "(", "MOUSEEVENTF_LEFTCLICK", ",", "x", ",", "y", ")", "except", "(", "PermissionError", ",", "OSError", ")", ":", "# TODO...
Send the mouse click event to Windows by calling the mouse_event() win32 function. Args: button (str): The mouse button, either 'left', 'middle', or 'right' x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None
[ "Send", "the", "mouse", "click", "event", "to", "Windows", "by", "calling", "the", "mouse_event", "()", "win32", "function", "." ]
python
train
41.551724
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_cmdlong.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_cmdlong.py#L151-L171
def cmd_velocity(self, args): '''velocity x-ms y-ms z-ms''' if (len(args) != 3): print("Usage: velocity x y z (m/s)") return if (len(args) == 3): x_mps = float(args[0]) y_mps = float(args[1]) z_mps = float(args[2]) #print("...
[ "def", "cmd_velocity", "(", "self", ",", "args", ")", ":", "if", "(", "len", "(", "args", ")", "!=", "3", ")", ":", "print", "(", "\"Usage: velocity x y z (m/s)\"", ")", "return", "if", "(", "len", "(", "args", ")", "==", "3", ")", ":", "x_mps", "=...
velocity x-ms y-ms z-ms
[ "velocity", "x", "-", "ms", "y", "-", "ms", "z", "-", "ms" ]
python
train
42
romanz/trezor-agent
libagent/util.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/util.py#L115-L129
def split_bits(value, *bits): """ Split integer value into list of ints, according to `bits` list. For example, split_bits(0x1234, 4, 8, 4) == [0x1, 0x23, 0x4] """ result = [] for b in reversed(bits): mask = (1 << b) - 1 result.append(value & mask) value = value >> b ...
[ "def", "split_bits", "(", "value", ",", "*", "bits", ")", ":", "result", "=", "[", "]", "for", "b", "in", "reversed", "(", "bits", ")", ":", "mask", "=", "(", "1", "<<", "b", ")", "-", "1", "result", ".", "append", "(", "value", "&", "mask", ...
Split integer value into list of ints, according to `bits` list. For example, split_bits(0x1234, 4, 8, 4) == [0x1, 0x23, 0x4]
[ "Split", "integer", "value", "into", "list", "of", "ints", "according", "to", "bits", "list", "." ]
python
train
24.266667
openstack/networking-cisco
networking_cisco/apps/saf/server/cisco_dfa_rest.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/cisco_dfa_rest.py#L740-L761
def update_project(self, org_name, part_name, dci_id=UNKNOWN_DCI_ID, service_node_ip=UNKNOWN_SRVN_NODE_IP, vrf_prof=None, desc=None): """Update project on the DCNM. :param org_name: name of organization. :param part_name: name of partition. ...
[ "def", "update_project", "(", "self", ",", "org_name", ",", "part_name", ",", "dci_id", "=", "UNKNOWN_DCI_ID", ",", "service_node_ip", "=", "UNKNOWN_SRVN_NODE_IP", ",", "vrf_prof", "=", "None", ",", "desc", "=", "None", ")", ":", "desc", "=", "desc", "or", ...
Update project on the DCNM. :param org_name: name of organization. :param part_name: name of partition. :param dci_id: Data Center interconnect id. :param desc: description of project.
[ "Update", "project", "on", "the", "DCNM", "." ]
python
train
50.545455
NiklasRosenstein-Python/nr-deprecated
nr/stream.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L54-L59
def map(cls, iterable, func, *a, **kw): """ Iterable-first replacement of Python's built-in `map()` function. """ return cls(func(x, *a, **kw) for x in iterable)
[ "def", "map", "(", "cls", ",", "iterable", ",", "func", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "return", "cls", "(", "func", "(", "x", ",", "*", "a", ",", "*", "*", "kw", ")", "for", "x", "in", "iterable", ")" ]
Iterable-first replacement of Python's built-in `map()` function.
[ "Iterable", "-", "first", "replacement", "of", "Python", "s", "built", "-", "in", "map", "()", "function", "." ]
python
train
28.833333
graphql-python/graphql-core-next
graphql/language/lexer.py
https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/language/lexer.py#L493-L509
def char2hex(a: str): """Convert a hex character to its integer value. '0' becomes 0, '9' becomes 9 'A' becomes 10, 'F' becomes 15 'a' becomes 10, 'f' becomes 15 Returns -1 on error. """ if "0" <= a <= "9": return ord(a) - 48 elif "A" <= a <= "F": return ord(a) - 55 ...
[ "def", "char2hex", "(", "a", ":", "str", ")", ":", "if", "\"0\"", "<=", "a", "<=", "\"9\"", ":", "return", "ord", "(", "a", ")", "-", "48", "elif", "\"A\"", "<=", "a", "<=", "\"F\"", ":", "return", "ord", "(", "a", ")", "-", "55", "elif", "\"...
Convert a hex character to its integer value. '0' becomes 0, '9' becomes 9 'A' becomes 10, 'F' becomes 15 'a' becomes 10, 'f' becomes 15 Returns -1 on error.
[ "Convert", "a", "hex", "character", "to", "its", "integer", "value", "." ]
python
train
22.058824
petl-developers/petl
petl/transform/validation.py
https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/transform/validation.py#L12-L71
def validate(table, constraints=None, header=None): """ Validate a `table` against a set of `constraints` and/or an expected `header`, e.g.:: >>> import petl as etl >>> # define some validation constraints ... header = ('foo', 'bar', 'baz') >>> constraints = [ ... ...
[ "def", "validate", "(", "table", ",", "constraints", "=", "None", ",", "header", "=", "None", ")", ":", "# noqa", "return", "ProblemsView", "(", "table", ",", "constraints", "=", "constraints", ",", "header", "=", "header", ")" ]
Validate a `table` against a set of `constraints` and/or an expected `header`, e.g.:: >>> import petl as etl >>> # define some validation constraints ... header = ('foo', 'bar', 'baz') >>> constraints = [ ... dict(name='foo_int', field='foo', test=int), ... d...
[ "Validate", "a", "table", "against", "a", "set", "of", "constraints", "and", "/", "or", "an", "expected", "header", "e", ".", "g", ".", "::" ]
python
train
55.1
nitely/kua
kua/routes.py
https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L90-L109
def make_params( key_parts: Sequence[str], variable_parts: VariablePartsType) -> Dict[str, Union[str, Tuple[str]]]: """ Map keys to variables. This map\ URL-pattern variables to\ a URL related parts :param key_parts: A list of URL parts :param variable_parts: A linked-list\ ...
[ "def", "make_params", "(", "key_parts", ":", "Sequence", "[", "str", "]", ",", "variable_parts", ":", "VariablePartsType", ")", "->", "Dict", "[", "str", ",", "Union", "[", "str", ",", "Tuple", "[", "str", "]", "]", "]", ":", "# The unwrapped variable part...
Map keys to variables. This map\ URL-pattern variables to\ a URL related parts :param key_parts: A list of URL parts :param variable_parts: A linked-list\ (ala nested tuples) of URL parts :return: The param dict with the values\ assigned to the keys :private:
[ "Map", "keys", "to", "variables", ".", "This", "map", "\\", "URL", "-", "pattern", "variables", "to", "\\", "a", "URL", "related", "parts" ]
python
train
33.55
saltstack/salt
salt/utils/data.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L320-L329
def decode_tuple(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, to_str=False): ''' Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2. ''' return tuple( de...
[ "def", "decode_tuple", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "normalize", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "to_str", "=", "False", ")", ":", "return", "tuple...
Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2.
[ "Decode", "all", "string", "values", "to", "Unicode", ".", "Optionally", "use", "to_str", "=", "True", "to", "ensure", "strings", "are", "str", "types", "and", "not", "unicode", "on", "Python", "2", "." ]
python
train
42.2
janpipek/physt
physt/binnings.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L704-L726
def fixed_width_binning(data=None, bin_width: Union[float, int] = 1, *, range=None, includes_right_edge=False, **kwargs) -> FixedWidthBinning: """Construct fixed-width binning schema. Parameters ---------- bin_width: float range: Optional[tuple] (min, max) align: Optional[float] ...
[ "def", "fixed_width_binning", "(", "data", "=", "None", ",", "bin_width", ":", "Union", "[", "float", ",", "int", "]", "=", "1", ",", "*", ",", "range", "=", "None", ",", "includes_right_edge", "=", "False", ",", "*", "*", "kwargs", ")", "->", "Fixed...
Construct fixed-width binning schema. Parameters ---------- bin_width: float range: Optional[tuple] (min, max) align: Optional[float] Must be multiple of bin_width
[ "Construct", "fixed", "-", "width", "binning", "schema", "." ]
python
train
40.73913
pyusb/pyusb
tools/vcp_terminal.py
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L540-L549
def fmt_text(text): """ convert characters that aren't printable to hex format """ PRINTABLE_CHAR = set( list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')]) newtext = ("\\x{:02X}".format( c) if c not in PRINTABLE_CHAR else chr(c) for c in text) textlines = "\r\n".join(l.str...
[ "def", "fmt_text", "(", "text", ")", ":", "PRINTABLE_CHAR", "=", "set", "(", "list", "(", "range", "(", "ord", "(", "' '", ")", ",", "ord", "(", "'~'", ")", "+", "1", ")", ")", "+", "[", "ord", "(", "'\\r'", ")", ",", "ord", "(", "'\\n'", ")"...
convert characters that aren't printable to hex format
[ "convert", "characters", "that", "aren", "t", "printable", "to", "hex", "format" ]
python
train
40.7
ask/carrot
carrot/backends/pystomp.py
https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/backends/pystomp.py#L54-L66
def ack(self): """Acknowledge this message as being processed., This will remove the message from the queue. :raises MessageStateError: If the message has already been acknowledged/requeued/rejected. """ if self.acknowledged: raise self.MessageStateError...
[ "def", "ack", "(", "self", ")", ":", "if", "self", ".", "acknowledged", ":", "raise", "self", ".", "MessageStateError", "(", "\"Message already acknowledged with state: %s\"", "%", "self", ".", "_state", ")", "self", ".", "backend", ".", "ack", "(", "self", ...
Acknowledge this message as being processed., This will remove the message from the queue. :raises MessageStateError: If the message has already been acknowledged/requeued/rejected.
[ "Acknowledge", "this", "message", "as", "being", "processed", ".", "This", "will", "remove", "the", "message", "from", "the", "queue", "." ]
python
train
34.769231
dellis23/ansible-toolkit
ansible_toolkit/vault.py
https://github.com/dellis23/ansible-toolkit/blob/7eb5198e1f68c9a3ca1d129d9e2a52fb3f0e65c5/ansible_toolkit/vault.py#L52-L85
def restore(path, password_file=None): """ Retrieves a file from the atk vault and restores it to its original location, re-encrypting it if it has changed. :param path: path to original file """ vault = VaultLib(get_vault_password(password_file)) atk_path = os.path.join(ATK_VAULT, path) ...
[ "def", "restore", "(", "path", ",", "password_file", "=", "None", ")", ":", "vault", "=", "VaultLib", "(", "get_vault_password", "(", "password_file", ")", ")", "atk_path", "=", "os", ".", "path", ".", "join", "(", "ATK_VAULT", ",", "path", ")", "# Load ...
Retrieves a file from the atk vault and restores it to its original location, re-encrypting it if it has changed. :param path: path to original file
[ "Retrieves", "a", "file", "from", "the", "atk", "vault", "and", "restores", "it", "to", "its", "original", "location", "re", "-", "encrypting", "it", "if", "it", "has", "changed", "." ]
python
train
28.411765
dmwm/DBS
Server/Python/src/dbs/web/DBSReaderModel.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSReaderModel.py#L1659-L1697
def listRunSummaries(self, dataset="", run_num=-1): """ API to list run summaries, like the maximal lumisection in a run. :param dataset: dataset name (Optional) :type dataset: str :param run_num: Run number (Required) :type run_num: str, long, int :rtype: list c...
[ "def", "listRunSummaries", "(", "self", ",", "dataset", "=", "\"\"", ",", "run_num", "=", "-", "1", ")", ":", "if", "run_num", "==", "-", "1", ":", "dbsExceptionHandler", "(", "\"dbsException-invalid-input\"", ",", "\"The run_num parameter is mandatory\"", ",", ...
API to list run summaries, like the maximal lumisection in a run. :param dataset: dataset name (Optional) :type dataset: str :param run_num: Run number (Required) :type run_num: str, long, int :rtype: list containing a dictionary with key max_lumi
[ "API", "to", "list", "run", "summaries", "like", "the", "maximal", "lumisection", "in", "a", "run", "." ]
python
train
50.128205
fastai/fastai
fastai/data_block.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L285-L287
def label_from_func(self, func:Callable, label_cls:Callable=None, **kwargs)->'LabelList': "Apply `func` to every input to get its label." return self._label_from_list([func(o) for o in self.items], label_cls=label_cls, **kwargs)
[ "def", "label_from_func", "(", "self", ",", "func", ":", "Callable", ",", "label_cls", ":", "Callable", "=", "None", ",", "*", "*", "kwargs", ")", "->", "'LabelList'", ":", "return", "self", ".", "_label_from_list", "(", "[", "func", "(", "o", ")", "fo...
Apply `func` to every input to get its label.
[ "Apply", "func", "to", "every", "input", "to", "get", "its", "label", "." ]
python
train
80.666667
eReuse/utils
ereuse_utils/naming.py
https://github.com/eReuse/utils/blob/989062e85095ea4e1204523fe0e298cf1046a01c/ereuse_utils/naming.py#L108-L110
def hid(manufacturer: str, serial_number: str, model: str) -> str: """Computes the HID for the given properties of a device. The HID is suitable to use to an URI.""" return Naming.url_word(manufacturer) + '-' + Naming.url_word(serial_number) + '-' + Naming.url_word(model)
[ "def", "hid", "(", "manufacturer", ":", "str", ",", "serial_number", ":", "str", ",", "model", ":", "str", ")", "->", "str", ":", "return", "Naming", ".", "url_word", "(", "manufacturer", ")", "+", "'-'", "+", "Naming", ".", "url_word", "(", "serial_nu...
Computes the HID for the given properties of a device. The HID is suitable to use to an URI.
[ "Computes", "the", "HID", "for", "the", "given", "properties", "of", "a", "device", ".", "The", "HID", "is", "suitable", "to", "use", "to", "an", "URI", "." ]
python
train
95.333333
PetrochukM/PyTorch-NLP
torchnlp/encoders/encoder.py
https://github.com/PetrochukM/PyTorch-NLP/blob/5f7320da5c8d781df072fab3f7e421c6347e5bfa/torchnlp/encoders/encoder.py#L43-L58
def decode(self, encoded): """ Decodes an object. Args: object_ (object): Encoded object. Returns: object: Object decoded. """ if self.enforce_reversible: self.enforce_reversible = False if self.encode(self.decode(encoded)) != enc...
[ "def", "decode", "(", "self", ",", "encoded", ")", ":", "if", "self", ".", "enforce_reversible", ":", "self", ".", "enforce_reversible", "=", "False", "if", "self", ".", "encode", "(", "self", ".", "decode", "(", "encoded", ")", ")", "!=", "encoded", "...
Decodes an object. Args: object_ (object): Encoded object. Returns: object: Object decoded.
[ "Decodes", "an", "object", "." ]
python
train
28.6875
Contraz/demosys-py
demosys/context/pyglet/window.py
https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/context/pyglet/window.py#L75-L80
def on_key_release(self, symbol, modifiers): """ Pyglet specific key release callback. Forwards and translates the events to :py:func:`keyboard_event` """ self.keyboard_event(symbol, self.keys.ACTION_RELEASE, modifiers)
[ "def", "on_key_release", "(", "self", ",", "symbol", ",", "modifiers", ")", ":", "self", ".", "keyboard_event", "(", "symbol", ",", "self", ".", "keys", ".", "ACTION_RELEASE", ",", "modifiers", ")" ]
Pyglet specific key release callback. Forwards and translates the events to :py:func:`keyboard_event`
[ "Pyglet", "specific", "key", "release", "callback", ".", "Forwards", "and", "translates", "the", "events", "to", ":", "py", ":", "func", ":", "keyboard_event" ]
python
valid
43.166667
sibirrer/lenstronomy
lenstronomy/ImSim/MultiBand/multi_frame.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/MultiBand/multi_frame.py#L126-L142
def error_response(self, kwargs_lens, kwargs_ps): """ returns the 1d array of the error estimate corresponding to the data response :return: 1d numpy array of response, 2d array of additonal errors (e.g. point source uncertainties) """ C_D_response, model_error = [], [] ...
[ "def", "error_response", "(", "self", ",", "kwargs_lens", ",", "kwargs_ps", ")", ":", "C_D_response", ",", "model_error", "=", "[", "]", ",", "[", "]", "for", "i", "in", "range", "(", "self", ".", "_num_bands", ")", ":", "if", "self", ".", "_compute_bo...
returns the 1d array of the error estimate corresponding to the data response :return: 1d numpy array of response, 2d array of additonal errors (e.g. point source uncertainties)
[ "returns", "the", "1d", "array", "of", "the", "error", "estimate", "corresponding", "to", "the", "data", "response" ]
python
train
50.294118
ArchiveTeam/wpull
wpull/protocol/ftp/stream.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/protocol/ftp/stream.py#L119-L142
def read_reply(self) -> Reply: '''Read a reply from the stream. Returns: .ftp.request.Reply: The reply Coroutine. ''' _logger.debug('Read reply') reply = Reply() while True: line = yield from self._connection.readline() if l...
[ "def", "read_reply", "(", "self", ")", "->", "Reply", ":", "_logger", ".", "debug", "(", "'Read reply'", ")", "reply", "=", "Reply", "(", ")", "while", "True", ":", "line", "=", "yield", "from", "self", ".", "_connection", ".", "readline", "(", ")", ...
Read a reply from the stream. Returns: .ftp.request.Reply: The reply Coroutine.
[ "Read", "a", "reply", "from", "the", "stream", "." ]
python
train
22.708333
BD2KGenomics/toil-scripts
src/toil_scripts/bwa_alignment/bwa_alignment.py
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/bwa_alignment.py#L21-L58
def download_reference_files(job, inputs, samples): """ Downloads shared files that are used by all samples for alignment, or generates them if they were not provided. :param JobFunctionWrappingJob job: passed automatically by Toil :param Namespace inputs: Input arguments (see main) :param list[lis...
[ "def", "download_reference_files", "(", "job", ",", "inputs", ",", "samples", ")", ":", "# Create dictionary to store FileStoreIDs of shared input files", "shared_ids", "=", "{", "}", "urls", "=", "[", "(", "'amb'", ",", "inputs", ".", "amb", ")", ",", "(", "'an...
Downloads shared files that are used by all samples for alignment, or generates them if they were not provided. :param JobFunctionWrappingJob job: passed automatically by Toil :param Namespace inputs: Input arguments (see main) :param list[list[str, list[str, str]]] samples: Samples in the format [UUID, [U...
[ "Downloads", "shared", "files", "that", "are", "used", "by", "all", "samples", "for", "alignment", "or", "generates", "them", "if", "they", "were", "not", "provided", "." ]
python
train
51
DiscordBotList/DBL-Python-Library
dbl/http.py
https://github.com/DiscordBotList/DBL-Python-Library/blob/c1461ae0acc644cdeedef8fd6b5e36f76d81c1aa/dbl/http.py#L78-L148
async def request(self, method, url, **kwargs): """Handles requests to the API""" rate_limiter = RateLimiter(max_calls=59, period=60, callback=limited) # handles ratelimits. max_calls is set to 59 because current implementation will retry in 60s after 60 calls is reached. DBL has a 1h block so o...
[ "async", "def", "request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "rate_limiter", "=", "RateLimiter", "(", "max_calls", "=", "59", ",", "period", "=", "60", ",", "callback", "=", "limited", ")", "# handles ratelimits. ...
Handles requests to the API
[ "Handles", "requests", "to", "the", "API" ]
python
test
42.380282
sbrisard/rebin
rebin.py
https://github.com/sbrisard/rebin/blob/a0abc9b6e6f82f3c80fe30129f139f1d54f78471/rebin.py#L88-L146
def rebin(a, factor, func=None): u"""Aggregate data from the input array ``a`` into rectangular tiles. The output array results from tiling ``a`` and applying `func` to each tile. ``factor`` specifies the size of the tiles. More precisely, the returned array ``out`` is such that:: out[i0, i1, ...
[ "def", "rebin", "(", "a", ",", "factor", ",", "func", "=", "None", ")", ":", "a", "=", "np", ".", "asarray", "(", "a", ")", "dim", "=", "a", ".", "ndim", "if", "np", ".", "isscalar", "(", "factor", ")", ":", "factor", "=", "dim", "*", "(", ...
u"""Aggregate data from the input array ``a`` into rectangular tiles. The output array results from tiling ``a`` and applying `func` to each tile. ``factor`` specifies the size of the tiles. More precisely, the returned array ``out`` is such that:: out[i0, i1, ...] = func(a[f0*i0:f0*(i0+1), f1*i1:...
[ "u", "Aggregate", "data", "from", "the", "input", "array", "a", "into", "rectangular", "tiles", "." ]
python
train
34.423729
SFDO-Tooling/CumulusCI
cumulusci/core/tasks.py
https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L166-L172
def _log_begin(self): """ Log the beginning of the task execution """ self.logger.info("Beginning task: %s", self.__class__.__name__) if self.salesforce_task and not self.flow: self.logger.info("%15s %s", "As user:", self.org_config.username) self.logger.info("%15s %s", "...
[ "def", "_log_begin", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Beginning task: %s\"", ",", "self", ".", "__class__", ".", "__name__", ")", "if", "self", ".", "salesforce_task", "and", "not", "self", ".", "flow", ":", "self", ".",...
Log the beginning of the task execution
[ "Log", "the", "beginning", "of", "the", "task", "execution" ]
python
train
53.714286
pytorch/vision
torchvision/transforms/functional.py
https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L212-L246
def resize(img, size, interpolation=Image.BILINEAR): r"""Resize the input PIL Image to the given size. Args: img (PIL Image): Image to be resized. size (sequence or int): Desired output size. If size is a sequence like (h, w), the output size will be matched to this. If size is an i...
[ "def", "resize", "(", "img", ",", "size", ",", "interpolation", "=", "Image", ".", "BILINEAR", ")", ":", "if", "not", "_is_pil_image", "(", "img", ")", ":", "raise", "TypeError", "(", "'img should be PIL Image. Got {}'", ".", "format", "(", "type", "(", "i...
r"""Resize the input PIL Image to the given size. Args: img (PIL Image): Image to be resized. size (sequence or int): Desired output size. If size is a sequence like (h, w), the output size will be matched to this. If size is an int, the smaller edge of the image will be mat...
[ "r", "Resize", "the", "input", "PIL", "Image", "to", "the", "given", "size", "." ]
python
test
41.285714
mitsei/dlkit
dlkit/json_/learning/searches.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/searches.py#L345-L356
def get_proficiencies(self): """Gets the proficiency list resulting from a search. return: (osid.learning.ProficiencyList) - the proficiency list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrie...
[ "def", "get_proficiencies", "(", "self", ")", ":", "if", "self", ".", "retrieved", ":", "raise", "errors", ".", "IllegalState", "(", "'List has already been retrieved.'", ")", "self", ".", "retrieved", "=", "True", "return", "objects", ".", "ProficiencyList", "(...
Gets the proficiency list resulting from a search. return: (osid.learning.ProficiencyList) - the proficiency list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "proficiency", "list", "resulting", "from", "a", "search", "." ]
python
train
41.166667